kavea/src/static/babylon-4.2.0.js

16 lines
3.2 MiB
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

!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()}("undefined"!=typeof self?self:"undefined"!=typeof global?global:this,(function(){return function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}return i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},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 n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},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=169)}([function(e,t,i){"use strict";i.d(t,"d",(function(){return c})),i.d(t,"e",(function(){return l})),i.d(t,"f",(function(){return u})),i.d(t,"b",(function(){return h})),i.d(t,"a",(function(){return d})),i.d(t,"c",(function(){return p}));var n=i(14),r=i(28),o=i(44),a=i(11),s=i(74),c=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=0|this.x;return e=397*e^(0|this.y)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},e.prototype.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),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.negateInPlace=function(){return this.x*=-1,this.y*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*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=r.a),e&&n.a.WithinEpsilon(this.x,e.x,t)&&n.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();return 0===e||(this.x/=e,this.y/=e),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,n,r,o){var a=o*o,s=o*a;return new e(.5*(2*i.x+(-t.x+n.x)*o+(2*t.x-5*i.x+4*n.x-r.x)*a+(-t.x+3*i.x-3*n.x+r.x)*s),.5*(2*i.y+(-t.y+n.y)*o+(2*t.y-5*i.y+4*n.y-r.y)*a+(-t.y+3*i.y-3*n.y+r.y)*s))},e.Clamp=function(t,i,n){var r=t.x;r=(r=r>n.x?n.x:r)<i.x?i.x:r;var o=t.y;return new e(r,o=(o=o>n.y?n.y:o)<i.y?i.y:o)},e.Hermite=function(t,i,n,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,l=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t.x*c+n.x*l+i.x*u+r.x*h,t.y*c+n.y*l+i.y*u+r.y*h)},e.Lerp=function(t,i,n){return new e(t.x+(i.x-t.x)*n,t.y+(i.y-t.y)*n)},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 n=e.Zero();return e.TransformToRef(t,i,n),n},e.TransformToRef=function(e,t,i){var n=t.m,r=e.x*n[0]+e.y*n[4]+n[12],o=e.x*n[1]+e.y*n[5]+n[13];i.x=r,i.y=o},e.PointInTriangle=function(e,t,i,n){var r=.5*(-i.y*n.x+t.y*(-i.x+n.x)+t.x*(i.y-n.y)+i.x*n.y),o=r<0?-1:1,a=(t.y*n.x-t.x*n.y+(n.y-t.y)*e.x+(t.x-n.x)*e.y)*o,s=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return a>0&&s>0&&a+s<2*r*o},e.Distance=function(t,i){return Math.sqrt(e.DistanceSquared(t,i))},e.DistanceSquared=function(e,t){var i=e.x-t.x,n=e.y-t.y;return i*i+n*n},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.DistanceOfPointFromSegment=function(t,i,n){var r=e.DistanceSquared(i,n);if(0===r)return e.Distance(t,i);var o=n.subtract(i),a=Math.max(0,Math.min(1,e.Dot(t.subtract(i),o)/r)),s=i.add(o.multiplyByFloats(a,a));return e.Distance(t,s)},e}(),l=function(){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this._isDirty=!0,this._x=e,this._y=t,this._z=i}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),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=0|this._x;return e=397*(e=397*e^(0|this._y))^(0|this._z)},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.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toQuaternion=function(){return h.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,n){return new e(this._x-t,this._y-i,this._z-n)},e.prototype.subtractFromFloatsToRef=function(e,t,i,n){return n.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.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this._x,-1*this._y,-1*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.projectOnPlane=function(t,i){var n=e.Zero();return this.projectOnPlaneToRef(t,i,n),n},e.prototype.projectOnPlaneToRef=function(t,i,n){var r=t.normal,o=t.d,a=f.Vector3[0];this.subtractToRef(i,a),a.normalize();var s=e.Dot(a,r),c=-(e.Dot(i,r)+o)/s,l=a.scaleInPlace(c);i.addToRef(l,n)},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=r.a),e&&n.a.WithinEpsilon(this._x,e._x,t)&&n.a.WithinEpsilon(this._y,e._y,t)&&n.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,n){return new e(this._x*t,this._y*i,this._z*n)},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(!n.a.WithinEpsilon(t,i,e))return!0;var r=Math.abs(this._z);return!n.a.WithinEpsilon(t,r,e)||!n.a.WithinEpsilon(i,r,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this._x);return e!==Math.abs(this._y)||e!==Math.abs(this._z)},enumerable:!1,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())||(f.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(i,n){t[i]=f.Vector3[0][e[n]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,i){return t.toRotationMatrix(f.Matrix[0]),e.TransformCoordinatesToRef(this,f.Matrix[0],i),i},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,i){return this.subtractToRef(t,f.Vector3[0]),f.Vector3[0].rotateByQuaternionToRef(e,f.Vector3[0]),t.addToRef(f.Vector3[0],i),i},e.prototype.cross=function(t){return e.Cross(this,t)},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,n,r){var o=e.Dot(t,n)-r;return o/(o-(e.Dot(i,n)-r))},e.GetAngleBetweenVectors=function(t,i,n){var r=t.normalizeToRef(f.Vector3[1]),o=i.normalizeToRef(f.Vector3[2]),a=e.Dot(r,o),s=f.Vector3[3];return e.CrossToRef(r,o,s),e.Dot(s,n)>0?Math.acos(a):-Math.acos(a)},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,n){return e.FromArrayToRef(t,i,n)},e.FromFloatsToRef=function(e,t,i,n){n.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:!1,configurable:!0}),Object.defineProperty(e,"ZeroReadOnly",{get:function(){return e._ZeroReadOnly},enumerable:!1,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(t){return void 0===t&&(t=!1),new e(0,0,t?-1:1)},e.Backward=function(t){return void 0===t&&(t=!1),new e(0,0,t?1:-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 n=e.Zero();return e.TransformCoordinatesToRef(t,i,n),n},e.TransformCoordinatesToRef=function(t,i,n){e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,i,n)},e.TransformCoordinatesFromFloatsToRef=function(e,t,i,n,r){var o=n.m,a=e*o[0]+t*o[4]+i*o[8]+o[12],s=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]);r.x=a*l,r.y=s*l,r.z=c*l},e.TransformNormal=function(t,i){var n=e.Zero();return e.TransformNormalToRef(t,i,n),n},e.TransformNormalToRef=function(e,t,i){this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,i)},e.TransformNormalFromFloatsToRef=function(e,t,i,n,r){var o=n.m;r.x=e*o[0]+t*o[4]+i*o[8],r.y=e*o[1]+t*o[5]+i*o[9],r.z=e*o[2]+t*o[6]+i*o[10]},e.CatmullRom=function(t,i,n,r,o){var a=o*o,s=o*a;return new e(.5*(2*i._x+(-t._x+n._x)*o+(2*t._x-5*i._x+4*n._x-r._x)*a+(-t._x+3*i._x-3*n._x+r._x)*s),.5*(2*i._y+(-t._y+n._y)*o+(2*t._y-5*i._y+4*n._y-r._y)*a+(-t._y+3*i._y-3*n._y+r._y)*s),.5*(2*i._z+(-t._z+n._z)*o+(2*t._z-5*i._z+4*n._z-r._z)*a+(-t._z+3*i._z-3*n._z+r._z)*s))},e.Clamp=function(t,i,n){var r=new e;return e.ClampToRef(t,i,n,r),r},e.ClampToRef=function(e,t,i,n){var r=e._x;r=(r=r>i._x?i._x:r)<t._x?t._x:r;var o=e._y;o=(o=o>i._y?i._y:o)<t._y?t._y:o;var a=e._z;a=(a=a>i._z?i._z:a)<t._z?t._z:a,n.copyFromFloats(r,o,a)},e.CheckExtends=function(e,t,i){t.minimizeInPlace(e),i.maximizeInPlace(e)},e.Hermite=function(t,i,n,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,l=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t._x*c+n._x*l+i._x*u+r._x*h,t._y*c+n._y*l+i._y*u+r._y*h,t._z*c+n._z*l+i._z*u+r._z*h)},e.Lerp=function(t,i,n){var r=new e(0,0,0);return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){n.x=e._x+(t._x-e._x)*i,n.y=e._y+(t._y-e._y)*i,n.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 n=e.Zero();return e.CrossToRef(t,i,n),n},e.CrossToRef=function(e,t,i){var n=e._y*t._z-e._z*t._y,r=e._z*t._x-e._x*t._z,o=e._x*t._y-e._y*t._x;i.copyFromFloats(n,r,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,n,r){var o=new e;return e.ProjectToRef(t,i,n,r,o),o},e.ProjectToRef=function(t,i,n,r,o){var a=r.width,s=r.height,c=r.x,l=r.y,u=f.Matrix[1];d.FromValuesToRef(a/2,0,0,0,0,-s/2,0,0,0,0,.5,0,c+a/2,s/2+l,.5,1,u);var h=f.Matrix[0];return i.multiplyToRef(n,h),h.multiplyToRef(u,h),e.TransformCoordinatesToRef(t,h,o),o},e._UnprojectFromInvertedMatrixToRef=function(t,i,r){e.TransformCoordinatesToRef(t,i,r);var o=i.m,a=t._x*o[3]+t._y*o[7]+t._z*o[11]+o[15];n.a.WithinEpsilon(a,1)&&r.scaleInPlace(1/a)},e.UnprojectFromTransform=function(t,i,n,r,o){var a=f.Matrix[0];r.multiplyToRef(o,a),a.invert(),t.x=t._x/i*2-1,t.y=-(t._y/n*2-1);var s=new e;return e._UnprojectFromInvertedMatrixToRef(t,a,s),s},e.Unproject=function(t,i,n,r,o,a){var s=e.Zero();return e.UnprojectToRef(t,i,n,r,o,a,s),s},e.UnprojectToRef=function(t,i,n,r,o,a,s){e.UnprojectFloatsToRef(t._x,t._y,t._z,i,n,r,o,a,s)},e.UnprojectFloatsToRef=function(t,i,n,r,o,a,s,c,l){var u=f.Matrix[0];a.multiplyToRef(s,u),u.multiplyToRef(c,u),u.invert();var h=f.Vector3[0];h.x=t/r*2-1,h.y=-(i/o*2-1),h.z=2*n-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,n=e._y-t._y,r=e._z-t._z;return i*i+n*n+r*r},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.RotationFromAxis=function(t,i,n){var r=e.Zero();return e.RotationFromAxisToRef(t,i,n,r),r},e.RotationFromAxisToRef=function(e,t,i,n){var r=f.Quaternion[0];h.RotationQuaternionFromAxisToRef(e,t,i,r),r.toEulerAnglesToRef(n)},e._UpReadOnly=e.Up(),e._ZeroReadOnly=e.Zero(),e}(),u=function(){function e(e,t,i,n){this.x=e,this.y=t,this.z=i,this.w=n}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=0|this.x;return e=397*(e=397*(e=397*e^(0|this.y))^(0|this.z))^(0|this.w)},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.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),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,n,r){return new e(this.x-t,this.y-i,this.z-n,this.w-r)},e.prototype.subtractFromFloatsToRef=function(e,t,i,n,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,r.w=this.w-n,this},e.prototype.negate=function(){return new e(-this.x,-this.y,-this.z,-this.w)},e.prototype.negateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this.w*=-1,this},e.prototype.negateToRef=function(e){return e.copyFromFloats(-1*this.x,-1*this.y,-1*this.z,-1*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=r.a),e&&n.a.WithinEpsilon(this.x,e.x,t)&&n.a.WithinEpsilon(this.y,e.y,t)&&n.a.WithinEpsilon(this.z,e.z,t)&&n.a.WithinEpsilon(this.w,e.w,t)},e.prototype.equalsToFloats=function(e,t,i,n){return this.x===e&&this.y===t&&this.z===i&&this.w===n},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,n,r){return new e(this.x*t,this.y*i,this.z*n,this.w*r)},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 l(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,n){return this.x=e,this.y=t,this.z=i,this.w=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},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,n){e.FromArrayToRef(t,i,n)},e.FromFloatsToRef=function(e,t,i,n,r){r.x=e,r.y=t,r.z=i,r.w=n},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,n=e.y-t.y,r=e.z-t.z,o=e.w-t.w;return i*i+n*n+r*r+o*o},e.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},e.TransformNormal=function(t,i){var n=e.Zero();return e.TransformNormalToRef(t,i,n),n},e.TransformNormalToRef=function(e,t,i){var n=t.m,r=e.x*n[0]+e.y*n[4]+e.z*n[8],o=e.x*n[1]+e.y*n[5]+e.z*n[9],a=e.x*n[2]+e.y*n[6]+e.z*n[10];i.x=r,i.y=o,i.z=a,i.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,i,n,r,o){var a=r.m;o.x=e*a[0]+t*a[4]+i*a[8],o.y=e*a[1]+t*a[5]+i*a[9],o.z=e*a[2]+t*a[6]+i*a[10],o.w=n},e.FromVector3=function(t,i){return void 0===i&&(i=0),new e(t._x,t._y,t._z,i)},e}(),h=function(){function e(e,t,i,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),this._isDirty=!0,this._x=e,this._y=t,this._z=i,this._w=n}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this._z},set:function(e){this._z=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"w",{get:function(){return this._w},set:function(e){this._w=e,this._isDirty=!0},enumerable:!1,configurable:!0}),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=0|this._x;return e=397*(e=397*(e=397*e^(0|this._y))^(0|this._z))^(0|this._w)},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.equalsWithEpsilon=function(e,t){return void 0===t&&(t=r.a),e&&n.a.WithinEpsilon(this._x,e._x,t)&&n.a.WithinEpsilon(this._y,e._y,t)&&n.a.WithinEpsilon(this._z,e._z,t)&&n.a.WithinEpsilon(this._w,e._w,t)},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,n){return this.x=e,this.y=t,this.z=i,this.w=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},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,n=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,r=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,n,r,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=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=l.Zero();return this.toEulerAnglesToRef(t),t},e.prototype.toEulerAnglesToRef=function(e){var t=this._z,i=this._x,n=this._y,r=this._w,o=r*r,a=t*t,s=i*i,c=n*n,l=n*t-i*r;return l<-.4999999?(e.y=2*Math.atan2(n,r),e.x=Math.PI/2,e.z=0):l>.4999999?(e.y=2*Math.atan2(n,r),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(i*n+t*r),-a-s+c+o),e.x=Math.asin(-2*(t*n-i*r)),e.y=Math.atan2(2*(t*i+n*r),a-s-c+o)),this},e.prototype.toRotationMatrix=function(e){return d.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,n=e.m,r=n[0],o=n[4],a=n[8],s=n[1],c=n[5],l=n[9],u=n[2],h=n[6],d=n[10],f=r+c+d;f>0?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(h-l)*i,t.y=(a-u)*i,t.z=(s-o)*i):r>c&&r>d?(i=2*Math.sqrt(1+r-c-d),t.w=(h-l)/i,t.x=.25*i,t.y=(o+s)/i,t.z=(a+u)/i):c>d?(i=2*Math.sqrt(1+c-r-d),t.w=(a-u)/i,t.x=(o+s)/i,t.y=.25*i,t.z=(l+h)/i):(i=2*Math.sqrt(1+d-r-c),t.w=(s-o)/i,t.x=(a+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 n=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e._x*n,i.y=e._y*n,i.z=e._z*n,i},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.FromEulerAngles=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(i,t,n,r),r},e.FromEulerAnglesToRef=function(t,i,n,r){return e.RotationYawPitchRollToRef(i,t,n,r),r},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,n){var r=new e;return e.RotationYawPitchRollToRef(t,i,n,r),r},e.RotationYawPitchRollToRef=function(e,t,i,n){var r=.5*i,o=.5*t,a=.5*e,s=Math.sin(r),c=Math.cos(r),l=Math.sin(o),u=Math.cos(o),h=Math.sin(a),d=Math.cos(a);n.x=d*l*c+h*u*s,n.y=h*u*c-d*l*s,n.z=d*u*s-h*l*c,n.w=d*u*c+h*l*s},e.RotationAlphaBetaGamma=function(t,i,n){var r=new e;return e.RotationAlphaBetaGammaToRef(t,i,n,r),r},e.RotationAlphaBetaGammaToRef=function(e,t,i,n){var r=.5*(i+e),o=.5*(i-e),a=.5*t;n.x=Math.cos(o)*Math.sin(a),n.y=Math.sin(o)*Math.sin(a),n.z=Math.sin(r)*Math.cos(a),n.w=Math.cos(r)*Math.cos(a)},e.RotationQuaternionFromAxis=function(t,i,n){var r=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,i,n,r),r},e.RotationQuaternionFromAxisToRef=function(t,i,n,r){var o=f.Matrix[0];d.FromXYZAxesToRef(t.normalize(),i.normalize(),n.normalize(),o),e.FromRotationMatrixToRef(o,r)},e.Slerp=function(t,i,n){var r=e.Identity();return e.SlerpToRef(t,i,n,r),r},e.SlerpToRef=function(e,t,i,n){var r,o,a=e._x*t._x+e._y*t._y+e._z*t._z+e._w*t._w,s=!1;if(a<0&&(s=!0,a=-a),a>.999999)o=1-i,r=s?-i:i;else{var c=Math.acos(a),l=1/Math.sin(c);o=Math.sin((1-i)*c)*l,r=s?-Math.sin(i*c)*l:Math.sin(i*c)*l}n.x=o*e._x+r*t._x,n.y=o*e._y+r*t._y,n.z=o*e._z+r*t._z,n.w=o*e._w+r*t._w},e.Hermite=function(t,i,n,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,l=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t._x*c+n._x*l+i._x*u+r._x*h,t._y*c+n._y*l+i._y*u+r._y*h,t._z*c+n._z*l+i._z*u+r._z*h,t._w*c+n._w*l+i._w*u+r._w*h)},e}(),d=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,s.a.MatrixTrackPrecisionChange&&s.a.MatrixTrackedMatrices.push(this),this._m=new s.a.MatrixCurrentType(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e,"Use64Bits",{get:function(){return s.a.MatrixUse64Bits},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!1,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,n,r){void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===r&&(r=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||n,this._isIdentityDirty=!this._isIdentity&&i,this._isIdentity3x2Dirty=!this._isIdentity3x2&&r},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]||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],n=e[2],r=e[3],o=e[4],a=e[5],s=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],m=e[15],g=h*m-_*d,v=u*m-p*d,b=u*_-p*h,y=l*m-f*d,T=l*_-h*f,E=l*p-f*u;return t*+(a*g-s*v+c*b)+i*-(o*g-s*y+c*T)+n*+(o*v-a*y+c*E)+r*-(o*b-a*T+s*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,n=t._m,r=e.m,o=0;o<16;o++)n[o]=i[o]+r[o];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,i=e.m,n=0;n<16;n++)t[n]+=i[n];return this._markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var i=this._m,n=i[0],r=i[1],o=i[2],a=i[3],s=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],m=i[13],g=i[14],v=i[15],b=f*v-g*p,y=d*v-m*p,T=d*g-m*f,E=h*v-_*p,S=h*g-f*_,A=h*m-_*d,P=+(c*b-l*y+u*T),C=-(s*b-l*E+u*S),R=+(s*y-c*E+u*A),x=-(s*T-c*S+l*A),O=n*P+r*C+o*R+a*x;if(0===O)return t.copyFrom(this),this;var M=1/O,I=l*v-g*u,D=c*v-m*u,N=c*g-m*l,L=s*v-_*u,w=s*g-_*l,F=s*m-_*c,B=l*p-f*u,U=c*p-d*u,V=c*f-d*l,k=s*p-h*u,z=s*f-h*l,G=s*d-h*c,j=-(r*b-o*y+a*T),W=+(n*b-o*E+a*S),H=-(n*y-r*E+a*A),X=+(n*T-r*S+o*A),Y=+(r*I-o*D+a*N),K=-(n*I-o*L+a*w),Q=+(n*D-r*L+a*F),q=-(n*N-r*w+o*F),Z=-(r*B-o*U+a*V),J=+(n*B-o*k+a*z),$=-(n*U-r*k+a*G),ee=+(n*V-r*z+o*G);return e.FromValuesToRef(P*M,j*M,Y*M,Z*M,C*M,W*M,K*M,J*M,R*M,H*M,Q*M,$*M,x*M,X*M,q*M,ee*M,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.addTranslationFromFloats=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 l(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);var i=this._m;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],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 n=this._m,r=e.m,o=n[0],a=n[1],s=n[2],c=n[3],l=n[4],u=n[5],h=n[6],d=n[7],f=n[8],p=n[9],_=n[10],m=n[11],g=n[12],v=n[13],b=n[14],y=n[15],T=r[0],E=r[1],S=r[2],A=r[3],P=r[4],C=r[5],R=r[6],x=r[7],O=r[8],M=r[9],I=r[10],D=r[11],N=r[12],L=r[13],w=r[14],F=r[15];return t[i]=o*T+a*P+s*O+c*N,t[i+1]=o*E+a*C+s*M+c*L,t[i+2]=o*S+a*R+s*I+c*w,t[i+3]=o*A+a*x+s*D+c*F,t[i+4]=l*T+u*P+h*O+d*N,t[i+5]=l*E+u*C+h*M+d*L,t[i+6]=l*S+u*R+h*I+d*w,t[i+7]=l*A+u*x+h*D+d*F,t[i+8]=f*T+p*P+_*O+m*N,t[i+9]=f*E+p*C+_*M+m*L,t[i+10]=f*S+p*R+_*I+m*w,t[i+11]=f*A+p*x+_*D+m*F,t[i+12]=g*T+v*P+b*O+y*N,t[i+13]=g*E+v*C+b*M+y*L,t[i+14]=g*S+v*R+b*I+y*w,t[i+15]=g*A+v*x+b*D+y*F,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,n=t.m;return i[0]===n[0]&&i[1]===n[1]&&i[2]===n[2]&&i[3]===n[3]&&i[4]===n[4]&&i[5]===n[5]&&i[6]===n[6]&&i[7]===n[7]&&i[8]===n[8]&&i[9]===n[9]&&i[10]===n[10]&&i[11]===n[11]&&i[12]===n[12]&&i[13]===n[13]&&i[14]===n[14]&&i[15]===n[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=0|this._m[0],t=1;t<16;t++)e=397*e^(0|this._m[t]);return e},e.prototype.decompose=function(t,i,n){if(this._isIdentity)return n&&n.setAll(0),t&&t.setAll(1),i&&i.copyFromFloats(0,0,0,1),!0;var r=this._m;if(n&&n.copyFromFloats(r[12],r[13],r[14]),(t=t||f.Vector3[0]).x=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),t.y=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),t.z=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[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,a=1/t._y,s=1/t._z;e.FromValuesToRef(r[0]*o,r[1]*o,r[2]*o,0,r[4]*a,r[5]*a,r[6]*a,0,r[8]*s,r[9]*s,r[10]*s,0,0,0,0,1,f.Matrix[0]),h.FromRotationMatrixToRef(f.Matrix[0],i)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new u(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,n,r){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]=n,this._m[o+3]=r,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=f.Matrix[0];this.invertToRef(i),i.transposeToRef(t);var n=t._m;e.FromValuesToRef(n[0],n[1],n[2],0,n[4],n[5],n[6],0,n[8],n[9],n[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=f.Vector3[0];if(!this.decompose(i))return e.IdentityToRef(t),this;var n=this._m,r=1/i._x,o=1/i._y,a=1/i._z;return e.FromValuesToRef(n[0]*r,n[1]*r,n[2]*r,0,n[4]*o,n[5]*o,n[6]*o,0,n[8]*a,n[9]*a,n[10]*a,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 n=new e;return e.FromArrayToRef(t,i,n),n},e.FromArrayToRef=function(e,t,i){for(var n=0;n<16;n++)i._m[n]=e[n+t];i._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,i,n){for(var r=0;r<16;r++)n._m[r]=e[r+t]*i;n._markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!1,configurable:!0}),e.FromValuesToRef=function(e,t,i,n,r,o,a,s,c,l,u,h,d,f,p,_,m){var g=m._m;g[0]=e,g[1]=t,g[2]=i,g[3]=n,g[4]=r,g[5]=o,g[6]=a,g[7]=s,g[8]=c,g[9]=l,g[10]=u,g[11]=h,g[12]=d,g[13]=f,g[14]=p,g[15]=_,m._markAsUpdated()},e.FromValues=function(t,i,n,r,o,a,s,c,l,u,h,d,f,p,_,m){var g=new e,v=g._m;return v[0]=t,v[1]=i,v[2]=n,v[3]=r,v[4]=o,v[5]=a,v[6]=s,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]=m,g._markAsUpdated(),g},e.Compose=function(t,i,n){var r=new e;return e.ComposeToRef(t,i,n,r),r},e.ComposeToRef=function(e,t,i,n){var r=n._m,o=t._x,a=t._y,s=t._z,c=t._w,l=o+o,u=a+a,h=s+s,d=o*l,f=o*u,p=o*h,_=a*u,m=a*h,g=s*h,v=c*l,b=c*u,y=c*h,T=e._x,E=e._y,S=e._z;r[0]=(1-(_+g))*T,r[1]=(f+y)*T,r[2]=(p-b)*T,r[3]=0,r[4]=(f-y)*E,r[5]=(1-(d+g))*E,r[6]=(m+v)*E,r[7]=0,r[8]=(p+b)*S,r[9]=(m-v)*S,r[10]=(1-(d+_))*S,r[11]=0,r[12]=i._x,r[13]=i._y,r[14]=i._z,r[15]=1,n._markAsUpdated()},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 n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,r,n,0,0,-n,r,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.RotationYToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,0,-n,0,0,1,0,0,n,0,r,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.RotationZToRef=function(t,i){var n=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,n,0,0,-n,r,0,0,0,0,1,0,0,0,0,1,i),i._updateIdentityStatus(1===r&&0===n)},e.RotationAxis=function(t,i){var n=new e;return e.RotationAxisToRef(t,i,n),n},e.RotationAxisToRef=function(e,t,i){var n=Math.sin(-t),r=Math.cos(-t),o=1-r;e.normalize();var a=i._m;a[0]=e._x*e._x*o+r,a[1]=e._x*e._y*o-e._z*n,a[2]=e._x*e._z*o+e._y*n,a[3]=0,a[4]=e._y*e._x*o+e._z*n,a[5]=e._y*e._y*o+r,a[6]=e._y*e._z*o-e._x*n,a[7]=0,a[8]=e._z*e._x*o-e._y*n,a[9]=e._z*e._y*o+e._x*n,a[10]=e._z*e._z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i._markAsUpdated()},e.RotationAlignToRef=function(e,t,i){var n=l.Cross(t,e),r=l.Dot(t,e),o=1/(1+r),a=i._m;a[0]=n._x*n._x*o+r,a[1]=n._y*n._x*o-n._z,a[2]=n._z*n._x*o+n._y,a[3]=0,a[4]=n._x*n._y*o+n._z,a[5]=n._y*n._y*o+r,a[6]=n._z*n._y*o-n._x,a[7]=0,a[8]=n._x*n._z*o-n._y,a[9]=n._y*n._z*o+n._x,a[10]=n._z*n._z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,i._markAsUpdated()},e.RotationYawPitchRoll=function(t,i,n){var r=new e;return e.RotationYawPitchRollToRef(t,i,n,r),r},e.RotationYawPitchRollToRef=function(e,t,i,n){h.RotationYawPitchRollToRef(e,t,i,f.Quaternion[0]),f.Quaternion[0].toRotationMatrix(n)},e.Scaling=function(t,i,n){var r=new e;return e.ScalingToRef(t,i,n,r),r},e.ScalingToRef=function(t,i,n,r){e.FromValuesToRef(t,0,0,0,0,i,0,0,0,0,n,0,0,0,0,1,r),r._updateIdentityStatus(1===t&&1===i&&1===n)},e.Translation=function(t,i,n){var r=new e;return e.TranslationToRef(t,i,n,r),r},e.TranslationToRef=function(t,i,n,r){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,n,1,r),r._updateIdentityStatus(0===t&&0===i&&0===n)},e.Lerp=function(t,i,n){var r=new e;return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){for(var r=n._m,o=e.m,a=t.m,s=0;s<16;s++)r[s]=o[s]*(1-i)+a[s]*i;n._markAsUpdated()},e.DecomposeLerp=function(t,i,n){var r=new e;return e.DecomposeLerpToRef(t,i,n,r),r},e.DecomposeLerpToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Quaternion[0],s=f.Vector3[1];t.decompose(o,a,s);var c=f.Vector3[2],u=f.Quaternion[1],d=f.Vector3[3];i.decompose(c,u,d);var p=f.Vector3[4];l.LerpToRef(o,c,n,p);var _=f.Quaternion[2];h.SlerpToRef(a,u,n,_);var m=f.Vector3[5];l.LerpToRef(s,d,n,m),e.ComposeToRef(p,_,m,r)},e.LookAtLH=function(t,i,n){var r=new e;return e.LookAtLHToRef(t,i,n,r),r},e.LookAtLHToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Vector3[1],s=f.Vector3[2];i.subtractToRef(t,s),s.normalize(),l.CrossToRef(n,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),l.CrossToRef(s,o,a),a.normalize();var u=-l.Dot(o,t),h=-l.Dot(a,t),d=-l.Dot(s,t);e.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,u,h,d,1,r)},e.LookAtRH=function(t,i,n){var r=new e;return e.LookAtRHToRef(t,i,n,r),r},e.LookAtRHToRef=function(t,i,n,r){var o=f.Vector3[0],a=f.Vector3[1],s=f.Vector3[2];t.subtractToRef(i,s),s.normalize(),l.CrossToRef(n,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),l.CrossToRef(s,o,a),a.normalize();var u=-l.Dot(o,t),h=-l.Dot(a,t),d=-l.Dot(s,t);e.FromValuesToRef(o._x,a._x,s._x,0,o._y,a._y,s._y,0,o._z,a._z,s._z,0,u,h,d,1,r)},e.OrthoLH=function(t,i,n,r){var o=new e;return e.OrthoLHToRef(t,i,n,r,o),o},e.OrthoLHToRef=function(t,i,n,r,o){var a=2/t,s=2/i,c=2/(r-n),l=-(r+n)/(r-n);e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,0,0,0,l,1,o),o._updateIdentityStatus(1===a&&1===s&&1===c&&0===l)},e.OrthoOffCenterLH=function(t,i,n,r,o,a){var s=new e;return e.OrthoOffCenterLHToRef(t,i,n,r,o,a,s),s},e.OrthoOffCenterLHToRef=function(t,i,n,r,o,a,s){var c=2/(i-t),l=2/(r-n),u=2/(a-o),h=-(a+o)/(a-o),d=(t+i)/(t-i),f=(r+n)/(n-r);e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,0,d,f,h,1,s),s._markAsUpdated()},e.OrthoOffCenterRH=function(t,i,n,r,o,a){var s=new e;return e.OrthoOffCenterRHToRef(t,i,n,r,o,a,s),s},e.OrthoOffCenterRHToRef=function(t,i,n,r,o,a,s){e.OrthoOffCenterLHToRef(t,i,n,r,o,a,s),s._m[10]*=-1},e.PerspectiveLH=function(t,i,n,r){var o=new e,a=2*n/t,s=2*n/i,c=(r+n)/(r-n),l=-2*r*n/(r-n);return e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,1,0,0,l,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,i,n,r){var o=new e;return e.PerspectiveFovLHToRef(t,i,n,r,o),o},e.PerspectiveFovLHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=n,c=r,l=1/Math.tan(.5*t),u=a?l/i:l,h=a?l:l*i,d=(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseLHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),c=a?s/i:s,l=a?s:s*i;e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,-n,1,0,0,1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,i,n,r){var o=new e;return e.PerspectiveFovRHToRef(t,i,n,r,o),o},e.PerspectiveFovRHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=n,c=r,l=1/Math.tan(.5*t),u=a?l/i:l,h=a?l:l*i,d=-(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,-1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseRHToRef=function(t,i,n,r,o,a){void 0===a&&(a=!0);var s=1/Math.tan(.5*t),c=a?s/i:s,l=a?s:s*i;e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,-n,-1,0,0,-1,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,i,n,r){void 0===r&&(r=!1);var o=r?-1:1,a=Math.tan(e.upDegrees*Math.PI/180),s=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/(a+s),d=n._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]=-(a-s)*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),n._markAsUpdated()},e.GetFinalMatrix=function(t,i,n,r,o,a){var s=t.width,c=t.height,l=t.x,u=t.y,h=e.FromValues(s/2,0,0,0,0,-c/2,0,0,0,0,a-o,0,l+s/2,c/2+u,o,1),d=f.Matrix[0];return i.multiplyToRef(n,d),d.multiplyToRef(r,d),d.multiply(h)},e.GetAsMatrix2x2=function(e){var t=e.m,i=[t[0],t[1],t[4],t[5]];return s.a.MatrixUse64Bits?i:new Float32Array(i)},e.GetAsMatrix3x3=function(e){var t=e.m,i=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return s.a.MatrixUse64Bits?i:new Float32Array(i)},e.Transpose=function(t){var i=new e;return e.TransposeToRef(t,i),i},e.TransposeToRef=function(e,t){var i=t._m,n=e.m;i[0]=n[0],i[1]=n[4],i[2]=n[8],i[3]=n[12],i[4]=n[1],i[5]=n[5],i[6]=n[9],i[7]=n[13],i[8]=n[2],i[9]=n[6],i[10]=n[10],i[11]=n[14],i[12]=n[3],i[13]=n[7],i[14]=n[11],i[15]=n[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 n=t.normal.x,r=t.normal.y,o=t.normal.z,a=-2*n,s=-2*r,c=-2*o;e.FromValuesToRef(a*n+1,s*n,c*n,0,a*r,s*r+1,c*r,0,a*o,s*o,c*o+1,0,a*t.d,s*t.d,c*t.d,1,i)},e.FromXYZAxesToRef=function(t,i,n,r){e.FromValuesToRef(t._x,t._y,t._z,0,i._x,i._y,i._z,0,n._x,n._y,n._z,0,0,0,0,1,r)},e.FromQuaternionToRef=function(e,t){var i=e._x*e._x,n=e._y*e._y,r=e._z*e._z,o=e._x*e._y,a=e._z*e._w,s=e._z*e._x,c=e._y*e._w,l=e._y*e._z,u=e._x*e._w;t._m[0]=1-2*(n+r),t._m[1]=2*(o+a),t._m[2]=2*(s-c),t._m[3]=0,t._m[4]=2*(o-a),t._m[5]=1-2*(r+i),t._m[6]=2*(l+u),t._m[7]=0,t._m[8]=2*(s+c),t._m[9]=2*(l-u),t._m[10]=1-2*(n+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}(),f=function(){function e(){}return e.Vector3=o.a.BuildArray(6,l.Zero),e.Matrix=o.a.BuildArray(2,d.Identity),e.Quaternion=o.a.BuildArray(3,h.Zero),e}(),p=function(){function e(){}return e.Vector2=o.a.BuildArray(3,c.Zero),e.Vector3=o.a.BuildArray(13,l.Zero),e.Vector4=o.a.BuildArray(3,u.Zero),e.Quaternion=o.a.BuildArray(2,h.Zero),e.Matrix=o.a.BuildArray(8,d.Identity),e}();a.a.RegisteredTypes["BABYLON.Vector2"]=c,a.a.RegisteredTypes["BABYLON.Vector3"]=l,a.a.RegisteredTypes["BABYLON.Vector4"]=u,a.a.RegisteredTypes["BABYLON.Matrix"]=d},function(e,t,i){"use strict";i.d(t,"d",(function(){return r})),i.d(t,"a",(function(){return o})),i.d(t,"c",(function(){return a})),i.d(t,"b",(function(){return s})),i.d(t,"e",(function(){return c})),i.d(t,"f",(function(){return l}));
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])})(e,t)};function r(e,t){function i(){this.constructor=e}n(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,n=arguments.length;i<n;i++)for(var r in t=arguments[i])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)};function a(e,t,i,n){var r,o=arguments.length,a=o<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,i,n);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,i,a):r(t,i))||a);return o>3&&a&&Object.defineProperty(t,i,a),a}function s(e,t,i,n){return new(i||(i=Promise))((function(r,o){function a(e){try{c(n.next(e))}catch(e){o(e)}}function s(e){try{c(n.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,s)}c((n=n.apply(e,t||[])).next())}))}function c(e,t){var i,n,r,o,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(i)throw new TypeError("Generator is already executing.");for(;a;)try{if(i=1,n&&(r=2&o[0]?n.return:o[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,o[1])).done)return r;switch(n=0,r&&(o=[2&o[0],r.value]),o[0]){case 0:case 1:r=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!r||o[1]>r[0]&&o[1]<r[3])){a.label=o[1];break}if(6===o[0]&&a.label<r[1]){a.label=r[1],r=o;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(o);break}r[2]&&a.ops.pop(),a.trys.pop();continue}o=t.call(e,a)}catch(e){o=[6,e],n=0}finally{i=r=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}}Object.create;function l(){for(var e=0,t=0,i=arguments.length;t<i;t++)e+=arguments[t].length;var n=Array(e),r=0;for(t=0;t<i;t++)for(var o=arguments[t],a=0,s=o.length;a<s;a++,r++)n[r]=o[a];return n}Object.create},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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.ALPHA_ONEONE_ONEONE=11,e.ALPHA_ALPHATOCOLOR=12,e.ALPHA_REVERSEONEMINUS=13,e.ALPHA_SRC_DSTONEMINUSSRCALPHA=14,e.ALPHA_ONEONE_ONEZERO=15,e.ALPHA_EXCLUSION=16,e.ALPHA_EQUATION_ADD=0,e.ALPHA_EQUATION_SUBSTRACT=1,e.ALPHA_EQUATION_REVERSE_SUBTRACT=2,e.ALPHA_EQUATION_MAX=3,e.ALPHA_EQUATION_MIN=4,e.ALPHA_EQUATION_DARKEN=5,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_NEAREST_NEAREST=1,e.TEXTURE_BILINEAR_SAMPLINGMODE=2,e.TEXTURE_LINEAR_LINEAR=2,e.TEXTURE_TRILINEAR_SAMPLINGMODE=3,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_MIPLINEAR=8,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=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.TEXTURE_FILTERING_QUALITY_OFFLINE=4096,e.TEXTURE_FILTERING_QUALITY_HIGH=64,e.TEXTURE_FILTERING_QUALITY_MEDIUM=16,e.TEXTURE_FILTERING_QUALITY_LOW=8,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_PrePassDirtyFlag=32,e.MATERIAL_AllDirtyFlag=63,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.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.PREPASS_IRRADIANCE_TEXTURE_TYPE=0,e.PREPASS_POSITION_TEXTURE_TYPE=1,e.PREPASS_VELOCITY_TEXTURE_TYPE=2,e.PREPASS_REFLECTIVITY_TEXTURE_TYPE=3,e.PREPASS_COLOR_TEXTURE_TYPE=4,e.PREPASS_DEPTHNORMAL_TEXTURE_TYPE=5,e.PREPASS_ALBEDO_TEXTURE_TYPE=6,e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return d})),i.d(t,"c",(function(){return f})),i.d(t,"m",(function(){return p})),i.d(t,"e",(function(){return _})),i.d(t,"h",(function(){return m})),i.d(t,"n",(function(){return g})),i.d(t,"o",(function(){return v})),i.d(t,"k",(function(){return b})),i.d(t,"g",(function(){return y})),i.d(t,"f",(function(){return T})),i.d(t,"i",(function(){return E})),i.d(t,"l",(function(){return S})),i.d(t,"j",(function(){return A})),i.d(t,"d",(function(){return P})),i.d(t,"a",(function(){return C}));var n=i(37),r=i(0),o=i(21),a=i(9),s={},c={},l=function(e,t,i){var r=e();n.a&&n.a.AddTagsTo(r,t.tags);var o=u(r);for(var a in o){var s=o[a],c=t[a],l=s.type;if(null!=c&&"uniqueId"!==a)switch(l){case 0:case 6:case 11:r[a]=c;break;case 1:r[a]=i||c.isRenderTarget?c:c.clone();break;case 2:case 3:case 4:case 5:case 7:case 10:case 12:r[a]=i?c:c.clone()}}return r};function u(e){var t=e.getClassName();if(c[t])return c[t];c[t]={};for(var i=c[t],n=e,r=t;r;){var o=s[r];for(var a in o)i[a]=o[a];var l=void 0,u=!1;do{if(!(l=Object.getPrototypeOf(n)).getClassName){u=!0;break}if(l.getClassName()!==r)break;n=l}while(l);if(u)break;r=l.getClassName(),n=l}return i}function h(e,t){return function(i,n){var r=function(e){var t=e.getClassName();return s[t]||(s[t]={}),s[t]}(i);r[n]||(r[n]={type:e,sourceName:t})}}function d(e,t){return void 0===t&&(t=null),function(e,t){return void 0===t&&(t=null),function(i,n){var r=t||"_"+n;Object.defineProperty(i,n,{get:function(){return this[r]},set:function(t){this[r]!==t&&(this[r]=t,i[e].apply(this))},enumerable:!0,configurable:!0})}}(e,t)}function f(e){return h(0,e)}function p(e){return h(1,e)}function _(e){return h(2,e)}function m(e){return h(3,e)}function g(e){return h(4,e)}function v(e){return h(5,e)}function b(e){return h(6,e)}function y(e){return h(7,e)}function T(e){return h(8,e)}function E(e){return h(9,e)}function S(e){return h(10,e)}function A(e){return h(12,e)}function P(e){return h(11,e)}var C=function(){function e(){}return e.AppendSerializedAnimations=function(e,t){if(e.animations){t.animations=[];for(var i=0;i<e.animations.length;i++){var n=e.animations[i];t.animations.push(n.serialize())}}},e.Serialize=function(e,t){t||(t={}),n.a&&(t.tags=n.a.GetTags(e));var i=u(e);for(var r in i){var o=i[r],a=o.sourceName||r,s=o.type,c=e[r];if(null!=c&&"uniqueId"!==r)switch(s){case 0:t[a]=c;break;case 1:t[a]=c.serialize();break;case 2:t[a]=c.asArray();break;case 3:t[a]=c.serialize();break;case 4:case 5:t[a]=c.asArray();break;case 6:t[a]=c.id;break;case 7:t[a]=c.serialize();break;case 8:t[a]=c.asArray();break;case 9:t[a]=c.serialize();break;case 10:t[a]=c.asArray();break;case 11:t[a]=c.id;case 12:t[a]=c.asArray()}}return t},e.Parse=function(t,i,o,s){void 0===s&&(s=null);var c=t();s||(s=""),n.a&&n.a.AddTagsTo(c,i.tags);var l=u(c);for(var h in l){var d=l[h],f=i[d.sourceName||h],p=d.type;if(null!=f&&"uniqueId"!==h){var _=c;switch(p){case 0:_[h]=f;break;case 1:o&&(_[h]=e._TextureParser(f,o,s));break;case 2:_[h]=a.a.FromArray(f);break;case 3:_[h]=e._FresnelParametersParser(f);break;case 4:_[h]=r.d.FromArray(f);break;case 5:_[h]=r.e.FromArray(f);break;case 6:o&&(_[h]=o.getLastMeshByID(f));break;case 7:_[h]=e._ColorCurvesParser(f);break;case 8:_[h]=a.b.FromArray(f);break;case 9:_[h]=e._ImageProcessingConfigurationParser(f);break;case 10:_[h]=r.b.FromArray(f);break;case 11:o&&(_[h]=o.getCameraByID(f));case 12:_[h]=r.a.FromArray(f)}}}return c},e.Clone=function(e,t){return l(e,t,!1)},e.Instanciate=function(e,t){return l(e,t,!0)},e._ImageProcessingConfigurationParser=function(e){throw o.a.WarnImport("ImageProcessingConfiguration")},e._FresnelParametersParser=function(e){throw o.a.WarnImport("FresnelParameters")},e._ColorCurvesParser=function(e){throw o.a.WarnImport("ColorCurves")},e._TextureParser=function(e,t,i){throw o.a.WarnImport("Texture")},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n})),i.d(t,"b",(function(){return r}));var n=function(){function e(e,t,i,n,r,o,a,s){void 0===n&&(n=0),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),this._isAlreadyOwned=!1,e.getScene?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=o,this._divisor=s||1,this._data=t,this.byteStride=a?n:n*Float32Array.BYTES_PER_ELEMENT,r||this.create()}return e.prototype.createVertexBuffer=function(e,t,i,n,o,a,s){void 0===a&&(a=!1);var c=a?t:t*Float32Array.BYTES_PER_ELEMENT,l=n?a?n:n*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new r(this._engine,this,e,this._updatable,!0,l,void 0===o?this._instanced:o,c,i,void 0,void 0,!0,this._divisor||s)},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,n){void 0===n&&(n=!1),this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,n?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),this._data=null)},e.prototype._increaseReferences=function(){this._buffer&&(this._isAlreadyOwned?this._buffer.references++:this._isAlreadyOwned=!0)},e.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},e}(),r=function(){function e(t,i,r,o,a,s,c,l,u,h,d,f,p,_){if(void 0===d&&(d=!1),void 0===f&&(f=!1),void 0===p&&(p=1),void 0===_&&(_=!1),i instanceof n?(this._buffer=i,this._ownsBuffer=_,_&&this._buffer._increaseReferences()):(this._buffer=new n(t,i,o,s,a,c,f),this._ownsBuffer=!0),this._kind=r,null==h){var m=this.getData();this.type=e.FLOAT,m instanceof Int8Array?this.type=e.BYTE:m instanceof Uint8Array?this.type=e.UNSIGNED_BYTE:m instanceof Int16Array?this.type=e.SHORT:m instanceof Uint16Array?this.type=e.UNSIGNED_SHORT:m instanceof Int32Array?this.type=e.INT:m instanceof Uint32Array&&(this.type=e.UNSIGNED_INT)}else this.type=h;var g=e.GetTypeByteLength(this.type);f?(this._size=u||(s?s/g:e.DeduceStride(r)),this.byteStride=s||this._buffer.byteStride||this._size*g,this.byteOffset=l||0):(this._size=u||s||e.DeduceStride(r),this.byteStride=s?s*g:this._buffer.byteStride||this._size*g,this.byteOffset=(l||0)*g),this.normalized=d,this._instanced=void 0!==c&&c,this._instanceDivisor=c?p:0}return Object.defineProperty(e.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(e){this._instanceDivisor=e,this._instanced=0!=e},enumerable:!1,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.UNSIGNED_INT:case e.FLOAT:return 4;default:throw new Error("Invalid type '"+t+"'")}},e.ForEach=function(t,i,n,r,o,a,s,c){if(t instanceof Array)for(var l=i/4,u=n/4,h=0;h<a;h+=r){for(var d=0;d<r;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<a;h+=r){var _=i;for(d=0;d<r;d++){c(e._GetFloatValue(f,o,_,s),h+d),_+=p}i+=n}}},e._GetFloatValue=function(t,i,n,r){switch(i){case e.BYTE:var o=t.getInt8(n);return r&&(o=Math.max(o/127,-1)),o;case e.UNSIGNED_BYTE:o=t.getUint8(n);return r&&(o/=255),o;case e.SHORT:o=t.getInt16(n,!0);return r&&(o=Math.max(o/32767,-1)),o;case e.UNSIGNED_SHORT:o=t.getUint16(n,!0);return r&&(o/=65535),o;case e.INT:return t.getInt32(n,!0);case e.UNSIGNED_INT:return t.getUint32(n,!0);case e.FLOAT:return t.getFloat32(n,!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,"a",(function(){return c}));var n=i(6),r=i(2),o=i(38),a=i(8),s=i(128),c=function(){function e(t,i,r,a,c,l,u,h,d,f){var p,_=this;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),this.name=null,this.defines="",this.onCompiled=null,this.onError=null,this.onBind=null,this.uniqueId=0,this.onCompileObservable=new n.c,this.onErrorObservable=new n.c,this._onBindObservable=null,this._wasPreviouslyReady=!1,this._bonesComputationForcedToCPU=!1,this._multiTarget=!1,this._uniformBuffersNames={},this._samplers={},this._isReady=!1,this._compilationError="",this._allFallbacksProcessed=!1,this._uniforms={},this._key="",this._fallbacks=null,this._vertexSourceCode="",this._fragmentSourceCode="",this._vertexSourceCodeOverride="",this._fragmentSourceCodeOverride="",this._transformFeedbackVaryings=null,this._rawVertexSourceCode="",this._rawFragmentSourceCode="",this._pipelineContext=null,this._valueCache={},this.name=t;var m,g,v=null;if(i.attributes){var b=i;if(this._engine=r,this._attributesNames=b.attributes,this._uniformsNames=b.uniformsNames.concat(b.samplers),this._samplerList=b.samplers.slice(),this.defines=b.defines,this.onError=b.onError,this.onCompiled=b.onCompiled,this._fallbacks=b.fallbacks,this._indexParameters=b.indexParameters,this._transformFeedbackVaryings=b.transformFeedbackVaryings||null,this._multiTarget=!!b.multiTarget,b.uniformBuffersNames){this._uniformBuffersNamesList=b.uniformBuffersNames.slice();for(var y=0;y<b.uniformBuffersNames.length;y++)this._uniformBuffersNames[b.uniformBuffersNames[y]]=y}v=null!==(p=b.processFinalCode)&&void 0!==p?p:null}else this._engine=c,this.defines=null==l?"":l,this._uniformsNames=r.concat(a),this._samplerList=a?a.slice():[],this._attributesNames=i,this._uniformBuffersNamesList=[],this.onError=d,this.onCompiled=h,this._indexParameters=f,this._fallbacks=u;this._attributeLocationByName={},this.uniqueId=e._uniqueIdSeed++;var T=o.a.IsWindowObjectExist()?this._engine.getHostDocument():null;t.vertexSource?m="source:"+t.vertexSource:t.vertexElement?(m=T?T.getElementById(t.vertexElement):null)||(m=t.vertexElement):m=t.vertex||t,t.fragmentSource?g="source:"+t.fragmentSource:t.fragmentElement?(g=T?T.getElementById(t.fragmentElement):null)||(g=t.fragmentElement):g=t.fragment||t;var E={defines:this.defines.split("\n"),indexParameters:this._indexParameters,isFragment:!1,shouldUseHighPrecisionShader:this._engine._shouldUseHighPrecisionShader,processor:this._engine._shaderProcessor,supportsUniformBuffers:this._engine.supportsUniformBuffers,shadersRepository:e.ShadersRepository,includesShadersStore:e.IncludesShadersStore,version:(100*this._engine.webGLVersion).toString(),platformName:this._engine.webGLVersion>=2?"WEBGL2":"WEBGL1"};this._loadShader(m,"Vertex","",(function(e){_._rawVertexSourceCode=e,_._loadShader(g,"Fragment","Pixel",(function(i){_._rawFragmentSourceCode=i,s.a.Process(e,E,(function(e){v&&(e=v("vertex",e)),E.isFragment=!0,s.a.Process(i,E,(function(i){v&&(i=v("fragment",i)),_._useFinalCode(e,i,t)}),_._engine)}),_._engine)}))}))}return Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new n.c),this._onBindObservable},enumerable:!1,configurable:!0}),e.prototype._useFinalCode=function(e,t,i){if(i){var n=i.vertexElement||i.vertex||i.spectorName||i,r=i.fragmentElement||i.fragment||i.spectorName||i;this._vertexSourceCode="#define SHADER_NAME vertex:"+n+"\n"+e,this._fragmentSourceCode="#define SHADER_NAME fragment:"+r+"\n"+t}else this._vertexSourceCode=e,this._fragmentSourceCode=t;this._prepareEffect()},Object.defineProperty(e.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),e.prototype.isReady=function(){try{return this._isReadyInternal()}catch(e){return!1}},e.prototype._isReadyInternal=function(){return!!this._isReady||!!this._pipelineContext&&this._pipelineContext.isReady},e.prototype.getEngine=function(){return this._engine},e.prototype.getPipelineContext=function(){return this._pipelineContext},e.prototype.getAttributesNames=function(){return this._attributesNames},e.prototype.getAttributeLocation=function(e){return this._attributes[e]},e.prototype.getAttributeLocationByName=function(e){return this._attributeLocationByName[e]},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[e]},e.prototype.getSamplers=function(){return this._samplerList},e.prototype.getUniformNames=function(){return this._uniformsNames},e.prototype.getUniformBuffersNames=function(){return this._uniformBuffersNamesList},e.prototype.getIndexParameters=function(){return this._indexParameters},e.prototype.getCompilationError=function(){return this._compilationError},e.prototype.allFallbacksProcessed=function(){return this._allFallbacksProcessed},e.prototype.executeWhenCompiled=function(e){var t=this;this.isReady()?e(this):(this.onCompileObservable.add((function(t){e(t)})),this._pipelineContext&&!this._pipelineContext.isAsync||setTimeout((function(){t._checkIsReady(null)}),16))},e.prototype._checkIsReady=function(e){var t=this;try{if(this._isReadyInternal())return}catch(t){return void this._processCompilationErrors(t,e)}setTimeout((function(){t._checkIsReady(e)}),16)},e.prototype._loadShader=function(t,i,n,r){var a;if("undefined"!=typeof HTMLElement&&t instanceof HTMLElement)return void r(o.a.GetDOMTextContent(t));"source:"!==t.substr(0,7)?"base64:"!==t.substr(0,7)?e.ShadersStore[t+i+"Shader"]?r(e.ShadersStore[t+i+"Shader"]):n&&e.ShadersStore[t+n+"Shader"]?r(e.ShadersStore[t+n+"Shader"]):(a="."===t[0]||"/"===t[0]||t.indexOf("http")>-1?t:e.ShadersRepository+t,this._engine._loadFile(a+"."+i.toLowerCase()+".fx",r)):r(window.atob(t.substr(7))):r(t.substr(7))},Object.defineProperty(e.prototype,"vertexSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fragmentSourceCode",{get:function(){return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:this._fragmentSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawVertexSourceCode",{get:function(){return this._rawVertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawFragmentSourceCode",{get:function(){return this._rawFragmentSourceCode},enumerable:!1,configurable:!0}),e.prototype._rebuildProgram=function(e,t,i,n){var o=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){n&&n(t)},this.onCompiled=function(){var e=o.getEngine().scenes;if(e)for(var t=0;t<e.length;t++)e[t].markAllMaterialsAsDirty(r.a.MATERIAL_AllDirtyFlag);o._pipelineContext._handlesSpectorRebuildCallback(i)},this._fallbacks=null,this._prepareEffect()},e.prototype._prepareEffect=function(){var e=this,t=this._attributesNames,i=this.defines;this._valueCache={};var n=this._pipelineContext;try{var r=this._engine;this._pipelineContext=r.createPipelineContext();var o=this._rebuildProgram.bind(this);this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?r._preparePipelineContext(this._pipelineContext,this._vertexSourceCodeOverride,this._fragmentSourceCodeOverride,!0,o,null,this._transformFeedbackVaryings):r._preparePipelineContext(this._pipelineContext,this._vertexSourceCode,this._fragmentSourceCode,!1,o,i,this._transformFeedbackVaryings),r._executeWhenRenderingStateIsCompiled(this._pipelineContext,(function(){if(r.supportsUniformBuffers)for(var i in e._uniformBuffersNames)e.bindUniformBlock(i,e._uniformBuffersNames[i]);var o;if(r.getUniforms(e._pipelineContext,e._uniformsNames).forEach((function(t,i){e._uniforms[e._uniformsNames[i]]=t})),e._attributes=r.getAttributes(e._pipelineContext,t),t)for(var a=0;a<t.length;a++){var s=t[a];e._attributeLocationByName[s]=e._attributes[a]}for(o=0;o<e._samplerList.length;o++){null==e.getUniform(e._samplerList[o])&&(e._samplerList.splice(o,1),o--)}e._samplerList.forEach((function(t,i){e._samplers[t]=i})),r.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()._deletePipelineContext(n)})),this._pipelineContext.isAsync&&this._checkIsReady(n)}catch(e){this._processCompilationErrors(e,n)}},e.prototype._getShaderCodeAndErrorLine=function(e,t,i){var n=i?/FRAGMENT SHADER ERROR: 0:(\d+?):/:/VERTEX SHADER ERROR: 0:(\d+?):/,r=null;if(t&&e){var o=t.match(n);if(o&&2===o.length){var a=parseInt(o[1]),s=e.split("\n",-1);s.length>=a&&(r="Offending line ["+a+"] in "+(i?"fragment":"vertex")+" code: "+s[a-1])}}return[e,r]},e.prototype._processCompilationErrors=function(t,i){var n,r,o,s,c;void 0===i&&(i=null),this._compilationError=t.message;var l=this._attributesNames,u=this._fallbacks;if(a.a.Error("Unable to compile effect:"),a.a.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),a.a.Error("Attributes: "+l.map((function(e){return" "+e}))),a.a.Error("Defines:\r\n"+this.defines),e.LogShaderCodeOnCompilationError){var h=null,d=null,f=null;(null===(o=this._pipelineContext)||void 0===o?void 0:o._getVertexShaderCode())&&(f=(n=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],h=n[1],f&&(a.a.Error("Vertex code:"),a.a.Error(f))),(null===(s=this._pipelineContext)||void 0===s?void 0:s._getFragmentShaderCode())&&(f=(r=this._getShaderCodeAndErrorLine(null===(c=this._pipelineContext)||void 0===c?void 0:c._getFragmentShaderCode(),this._compilationError,!0))[0],d=r[1],f&&(a.a.Error("Fragment code:"),a.a.Error(f))),h&&a.a.Error(h),d&&a.a.Error(d)}a.a.Error("Error: "+this._compilationError),i&&(this._pipelineContext=i,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),u?(this._pipelineContext=null,u.hasMoreFallbacks?(this._allFallbacksProcessed=!1,a.a.Error("Trying next fallback."),this.defines=u.reduce(this.defines,this),this._prepareEffect()):(this._allFallbacksProcessed=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())):this._allFallbacksProcessed=!0},Object.defineProperty(e.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!1,configurable:!0}),e.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers[e],t)},e.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers[e],this._uniforms[e],t)},e.prototype.setTextureArray=function(e,t){var i=e+"Ex";if(-1===this._samplerList.indexOf(i+"0")){for(var n=this._samplerList.indexOf(e),r=1;r<t.length;r++){var o=i+(r-1).toString();this._samplerList.splice(n+r,0,o)}for(var a=0,s=0,c=this._samplerList;s<c.length;s++){var l=c[s];this._samplers[l]=a,a+=1}}this._engine.setTextureArray(this._samplers[e],this._uniforms[e],t)},e.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers[e],t)},e.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers[e],t)},e.prototype._cacheMatrix=function(e,t){var i=this._valueCache[e],n=t.updateFlag;return(void 0===i||i!==n)&&(this._valueCache[e]=n,!0)},e.prototype._cacheFloat2=function(e,t,i){var n=this._valueCache[e];if(!n||2!==n.length)return n=[t,i],this._valueCache[e]=n,!0;var r=!1;return n[0]!==t&&(n[0]=t,r=!0),n[1]!==i&&(n[1]=i,r=!0),r},e.prototype._cacheFloat3=function(e,t,i,n){var r=this._valueCache[e];if(!r||3!==r.length)return r=[t,i,n],this._valueCache[e]=r,!0;var o=!1;return r[0]!==t&&(r[0]=t,o=!0),r[1]!==i&&(r[1]=i,o=!0),r[2]!==n&&(r[2]=n,o=!0),o},e.prototype._cacheFloat4=function(e,t,i,n,r){var o=this._valueCache[e];if(!o||4!==o.length)return o=[t,i,n,r],this._valueCache[e]=o,!0;var a=!1;return o[0]!==t&&(o[0]=t,a=!0),o[1]!==i&&(o[1]=i,a=!0),o[2]!==n&&(o[2]=n,a=!0),o[3]!==r&&(o[3]=r,a=!0),a},e.prototype.bindUniformBuffer=function(t,i){var n=this._uniformBuffersNames[i];void 0!==n&&e._baseCache[n]!==t&&(e._baseCache[n]=t,this._engine.bindUniformBufferBase(t,n))},e.prototype.bindUniformBlock=function(e,t){this._engine.bindUniformBlock(this._pipelineContext,e,t)},e.prototype.setInt=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||this._engine.setInt(this._uniforms[e],t)&&(this._valueCache[e]=t),this},e.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this._uniforms[e],t),this},e.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this._uniforms[e],t),this},e.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this._uniforms[e],t),this},e.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this._uniforms[e],t),this},e.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this._uniforms[e],t),this},e.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this._uniforms[e],t),this},e.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this._uniforms[e],t),this},e.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this._uniforms[e],t),this},e.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this._uniforms[e],t),this},e.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this._uniforms[e],t),this},e.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this._uniforms[e],t),this},e.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this._uniforms[e],t),this},e.prototype.setMatrices=function(e,t){return t?(this._valueCache[e]=null,this._engine.setMatrices(this._uniforms[e],t),this):this},e.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&(this._engine.setMatrices(this._uniforms[e],t.toArray())||(this._valueCache[e]=null)),this},e.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this._uniforms[e],t),this},e.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this._uniforms[e],t),this},e.prototype.setFloat=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||this._engine.setFloat(this._uniforms[e],t)&&(this._valueCache[e]=t),this},e.prototype.setBool=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||this._engine.setInt(this._uniforms[e],t?1:0)&&(this._valueCache[e]=t),this},e.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&(this._engine.setFloat2(this._uniforms[e],t.x,t.y)||(this._valueCache[e]=null)),this},e.prototype.setFloat2=function(e,t,i){return this._cacheFloat2(e,t,i)&&(this._engine.setFloat2(this._uniforms[e],t,i)||(this._valueCache[e]=null)),this},e.prototype.setVector3=function(e,t){return this._cacheFloat3(e,t.x,t.y,t.z)&&(this._engine.setFloat3(this._uniforms[e],t.x,t.y,t.z)||(this._valueCache[e]=null)),this},e.prototype.setFloat3=function(e,t,i,n){return this._cacheFloat3(e,t,i,n)&&(this._engine.setFloat3(this._uniforms[e],t,i,n)||(this._valueCache[e]=null)),this},e.prototype.setVector4=function(e,t){return this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&(this._engine.setFloat4(this._uniforms[e],t.x,t.y,t.z,t.w)||(this._valueCache[e]=null)),this},e.prototype.setFloat4=function(e,t,i,n,r){return this._cacheFloat4(e,t,i,n,r)&&(this._engine.setFloat4(this._uniforms[e],t,i,n,r)||(this._valueCache[e]=null)),this},e.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&(this._engine.setFloat3(this._uniforms[e],t.r,t.g,t.b)||(this._valueCache[e]=null)),this},e.prototype.setColor4=function(e,t,i){return this._cacheFloat4(e,t.r,t.g,t.b,i)&&(this._engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,i)||(this._valueCache[e]=null)),this},e.prototype.setDirectColor4=function(e,t){return this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&(this._engine.setFloat4(this._uniforms[e],t.r,t.g,t.b,t.a)||(this._valueCache[e]=null)),this},e.prototype.dispose=function(){this._engine._releaseEffect(this)},e.RegisterShader=function(t,i,n){i&&(e.ShadersStore[t+"PixelShader"]=i),n&&(e.ShadersStore[t+"VertexShader"]=n)},e.ResetCache=function(){e._baseCache={}},e.ShadersRepository="src/Shaders/",e.LogShaderCodeOnCompilationError=!0,e._uniqueIdSeed=0,e._baseCache={},e.ShadersStore={},e.IncludesShadersStore={},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n})),i.d(t,"d",(function(){return r})),i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return a}));var n=function(){function e(e,t,i,n){void 0===t&&(t=!1),this.initalize(e,t,i,n)}return e.prototype.initalize=function(e,t,i,n){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=n,this},e}(),r=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,n,r){void 0===n&&(n=-1),void 0===r&&(r=null);var o=new e;o._observers=new Array,o._observables=t;for(var a=0,s=t;a<s.length;a++){var c=s[a].add(i,n,!1,r);c&&o._observers.push(c)}return o},e}(),a=function(){function e(e){this._observers=new Array,this._eventState=new n(0),e&&(this._onObserverAdded=e)}return Object.defineProperty(e.prototype,"observers",{get:function(){return this._observers},enumerable:!1,configurable:!0}),e.prototype.add=function(e,t,i,n,o){if(void 0===t&&(t=-1),void 0===i&&(i=!1),void 0===n&&(n=null),void 0===o&&(o=!1),!e)return null;var a=new r(e,t,n);return a.unregisterOnNextCall=o,i?this._observers.unshift(a):this._observers.push(a),this._onObserverAdded&&this._onObserverAdded(a),a},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++){var n=this._observers[i];if(!n._willBeUnregistered&&(n.callback===e&&(!t||t===n.scope)))return this._deferUnregister(n),!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.makeObserverTopPriority=function(e){this._remove(e),this._observers.unshift(e)},e.prototype.makeObserverBottomPriority=function(e){this._remove(e),this._observers.push(e)},e.prototype.notifyObservers=function(e,t,i,n,r){if(void 0===t&&(t=-1),!this._observers.length)return!0;var o=this._eventState;o.mask=t,o.target=i,o.currentTarget=n,o.skipNextObservers=!1,o.lastReturnValue=e,o.userInfo=r;for(var a=0,s=this._observers;a<s.length;a++){var c=s[a];if(!c._willBeUnregistered&&(c.mask&t&&(c.scope?o.lastReturnValue=c.callback.apply(c.scope,[e,o]):o.lastReturnValue=c.callback(e,o),c.unregisterOnNextCall&&this._deferUnregister(c)),o.skipNextObservers))return!1}return!0},e.prototype.notifyObserversWithPromise=function(e,t,i,n,r){var o=this;void 0===t&&(t=-1);var a=Promise.resolve(e);if(!this._observers.length)return a;var s=this._eventState;return s.mask=t,s.target=i,s.currentTarget=n,s.skipNextObservers=!1,s.userInfo=r,this._observers.forEach((function(i){s.skipNextObservers||i._willBeUnregistered||i.mask&t&&(a=i.scope?a.then((function(t){return s.lastReturnValue=t,i.callback.apply(i.scope,[e,s])})):a.then((function(t){return s.lastReturnValue=t,i.callback(e,s)})),i.unregisterOnNextCall&&o._deferUnregister(i))})),a.then((function(){return e}))},e.prototype.notifyObserver=function(e,t,i){void 0===i&&(i=-1);var n=this._eventState;n.mask=i,n.skipNextObservers=!1,e.callback(t,n)},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 n=i[t];if(n.mask&e||n.mask===e)return!0}return!1},e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return x})),i.d(t,"c",(function(){return M})),i.d(t,"a",(function(){return N}));var n=i(1),r=i(6),o=i(12),a=i(41),s=i(37),c=i(0),l=i(9),u=i(29),h=i(4),d=i(16),f=i(71),p=i(31),_=i(61),m=i(43),g=i(25),v=i(68),b=i(69),y=i(2),T=i(3),E=i(8),S=i(11),A=i(21),P=i(17),C=i(149),R=i(70),x=function(){},O=function(){this.visibleInstances={},this.batchCache=new M,this.instancesBufferSize=2048},M=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array,this.hardwareInstancedRendering=new Array},I=function(){this.instancesCount=0,this.matrixBuffer=null,this.matrixBufferSize=512,this.boundingVectors=[],this.worldMatrices=null},D=function(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._morphTargetManager=null},N=function(e){function t(i,n,r,o,c,l){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===l&&(l=!0);var u=e.call(this,i,n)||this;if(u._internalMeshDataInfo=new D,u.delayLoadState=y.a.DELAYLOADSTATE_NONE,u.instances=new Array,u._creationDataStorage=null,u._geometry=null,u._instanceDataStorage=new O,u._thinInstanceDataStorage=new I,u._effectiveMaterial=null,u._shouldGenerateFlatShading=!1,u._originalBuilderSideOrientation=t.DEFAULTSIDE,u.overrideMaterialSideOrientation=null,n=u.getScene(),o){if(o._geometry&&o._geometry.applyToMesh(u),a.a.DeepCopy(o,u,["name","material","skeleton","instances","parent","uniqueId","source","metadata","morphTargetManager","hasInstances","source","worldMatrixInstancedBuffer","hasLODLevels","geometry","isBlocked","areNormalsFrozen","facetNb","isFacetDataEnabled","lightSources","useBones","isAnInstance","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances","cloneMeshMap"],["_poseMatrix"]),u._internalMeshDataInfo._source=o,n.useClonedMeshMap&&(o._internalMeshDataInfo.meshMap||(o._internalMeshDataInfo.meshMap={}),o._internalMeshDataInfo.meshMap[u.uniqueId]=u),u._originalBuilderSideOrientation=o._originalBuilderSideOrientation,u._creationDataStorage=o._creationDataStorage,o._ranges){var h=o._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,s.a&&s.a.HasTags(o)&&s.a.AddTagsTo(u,s.a.GetTags(o,!0)),u.setEnabled(o.isEnabled()),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)}if(o.morphTargetManager&&(u.morphTargetManager=o.morphTargetManager),n.getPhysicsEngine){var m=n.getPhysicsEngine();if(l&&m){var g=m.getImpostorForPhysicsObject(o);g&&(u.physicsImpostor=g.clone(u))}}for(d=0;d<n.particleSystems.length;d++){var v=n.particleSystems[d];v.emitter===o&&v.clone(v.name,u)}u.refreshBoundingInfo(),u.computeWorldMatrix(!0)}return null!==r&&(u.parent=r),u._instanceDataStorage.hardwareInstancedRendering=u.getEngine().getCaps().instancedArrays,u}return Object(n.d)(t,e),t._GetDefaultSideOrientation=function(e){return e||t.FRONTSIDE},Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(e&&this._internalMeshDataInfo._sourcePositions&&(this.setVerticesData(h.b.PositionKind,this._internalMeshDataInfo._sourcePositions.slice(),!0),this._internalMeshDataInfo._sourceNormals&&this.setVerticesData(h.b.NormalKind,this._internalMeshDataInfo._sourceNormals.slice(),!0)),this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRenderObservable",{get:function(){return this._internalMeshDataInfo._onBeforeRenderObservable||(this._internalMeshDataInfo._onBeforeRenderObservable=new r.c),this._internalMeshDataInfo._onBeforeRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeBindObservable",{get:function(){return this._internalMeshDataInfo._onBeforeBindObservable||(this._internalMeshDataInfo._onBeforeBindObservable=new r.c),this._internalMeshDataInfo._onBeforeBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRenderObservable",{get:function(){return this._internalMeshDataInfo._onAfterRenderObservable||(this._internalMeshDataInfo._onAfterRenderObservable=new r.c),this._internalMeshDataInfo._onAfterRenderObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeDrawObservable",{get:function(){return this._internalMeshDataInfo._onBeforeDrawObservable||(this._internalMeshDataInfo._onBeforeDrawObservable=new r.c),this._internalMeshDataInfo._onBeforeDrawObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasInstances",{get:function(){return this.instances.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasThinInstances",{get:function(){var e;return(null!==(e=this._thinInstanceDataStorage.instancesCount)&&void 0!==e?e:0)>0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"morphTargetManager",{get:function(){return this._internalMeshDataInfo._morphTargetManager},set:function(e){this._internalMeshDataInfo._morphTargetManager!==e&&(this._internalMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"source",{get:function(){return this._internalMeshDataInfo._source},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cloneMeshMap",{get:function(){return this._internalMeshDataInfo.meshMap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesData},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manualUpdateOfWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.manualUpdate},set:function(e){this._instanceDataStorage.manualUpdate=e},enumerable:!1,configurable:!0}),t.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var n=!(this.getTotalVertices()>0)||t&&t.doNotInstantiate?this.clone("Clone of "+(this.name||this.id),e||this.parent,!0):this.createInstance("instance of "+(this.name||this.id));n&&(n.parent=e||this.parent,n.position=this.position.clone(),n.scaling=this.scaling.clone(),this.rotationQuaternion?n.rotationQuaternion=this.rotationQuaternion.clone():n.rotation=this.rotation.clone(),i&&i(this,n));for(var r=0,o=this.getChildTransformNodes(!0);r<o.length;r++){o[r].instantiateHierarchy(n,t,i)}return n},t.prototype.getClassName=function(){return"Mesh"},Object.defineProperty(t.prototype,"_isMesh",{get:function(){return!0},enumerable:!1,configurable:!0}),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 n=0;n<this.animations.length;n++)i+=", animation[0]: "+this.animations[n].toString(t);if(t)if(this._geometry){var r=this.getIndices(),o=this.getVerticesData(h.b.PositionKind);o&&r&&(i+=", flat shading: "+(o.length/3===r.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._internalMeshDataInfo._LODLevels.length>0},enumerable:!1,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){this._internalMeshDataInfo._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 E.a.Warn("You cannot use a mesh as LOD level twice"),this;var i=new C.a(e,t);return this._internalMeshDataInfo._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,i=0;i<t._LODLevels.length;i++){var n=t._LODLevels[i];if(n.distance===e)return n.mesh}return null},t.prototype.removeLODLevel=function(e){for(var t=this._internalMeshDataInfo,i=0;i<t._LODLevels.length;i++)t._LODLevels[i].mesh===e&&(t._LODLevels.splice(i,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},t.prototype.getLOD=function(e,t){var i,n=this._internalMeshDataInfo;if(!n._LODLevels||0===n._LODLevels.length)return this;t?i=t:i=this.getBoundingInfo().boundingSphere;var r=i.centerWorld.subtract(e.globalPosition).length();if(n._LODLevels[n._LODLevels.length-1].distance>r)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this;for(var o=0;o<n._LODLevels.length;o++){var a=n._LODLevels[o];if(a.distance<r){if(a.mesh){if(a.mesh.delayLoadState===y.a.DELAYLOADSTATE_NOTLOADED)return a.mesh._checkDelayState(),this;if(a.mesh.delayLoadState===y.a.DELAYLOADSTATE_LOADING)return this;a.mesh._preActivate(),a.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)}return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,a.mesh),a.mesh}}return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this},Object.defineProperty(t.prototype,"geometry",{get:function(){return this._geometry},enumerable:!1,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:!1,configurable:!0}),t.prototype.isReady=function(t,i){var n,r,o,a,s,c;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 l=this.getEngine(),u=this.getScene(),h=i||l.getCaps().instancedArrays&&(this.instances.length>0||this.hasThinInstances);this.computeWorldMatrix();var d=this.material||u.defaultMaterial;if(d)if(d._storeEffectOnSubMeshes)for(var f=0,p=this.subMeshes;f<p.length;f++){var _=(E=p[f]).getMaterial();if(_)if(_._storeEffectOnSubMeshes){if(!_.isReadyForSubMesh(this,E,h))return!1}else if(!_.isReady(this,h))return!1}else if(!d.isReady(this,h))return!1;for(var m=0,g=this.lightSources;m<g.length;m++){var v=g[m].getShadowGenerator();if(v&&(!(null===(n=v.getShadowMap())||void 0===n?void 0:n.renderList)||(null===(r=v.getShadowMap())||void 0===r?void 0:r.renderList)&&-1!==(null===(a=null===(o=v.getShadowMap())||void 0===o?void 0:o.renderList)||void 0===a?void 0:a.indexOf(this))))for(var b=0,T=this.subMeshes;b<T.length;b++){var E=T[b];if(!v.isReady(E,h,null!==(c=null===(s=E.getMaterial())||void 0===s?void 0:s.needAlphaBlendingForMesh(this))&&void 0!==c&&c))return!1}}for(var S=0,A=this._internalMeshDataInfo._LODLevels;S<A.length;S++){var P=A[S];if(P.mesh&&!P.mesh.isReady(h))return!1}return!0},Object.defineProperty(t.prototype,"areNormalsFrozen",{get:function(){return this._internalMeshDataInfo._areNormalsFrozen},enumerable:!1,configurable:!0}),t.prototype.freezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!0,this},t.prototype.unfreezeNormals=function(){return this._internalMeshDataInfo._areNormalsFrozen=!1,this},Object.defineProperty(t.prototype,"overridenInstanceCount",{set:function(e){this._instanceDataStorage.overridenInstanceCount=e},enumerable:!1,configurable:!0}),t.prototype._preActivate=function(){var e=this._internalMeshDataInfo,t=this.getScene().getRenderId();return e._preActivateId===t||(e._preActivateId=t,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]||(void 0!==this._instanceDataStorage.previousRenderId&&this._instanceDataStorage.isFrozen&&(this._instanceDataStorage.visibleInstances[this._instanceDataStorage.previousRenderId]=null),this._instanceDataStorage.previousRenderId=t,this._instanceDataStorage.visibleInstances[t]=new Array),this._instanceDataStorage.visibleInstances[t].push(e),this},t.prototype._afterComputeWorldMatrix=function(){e.prototype._afterComputeWorldMatrix.call(this),this.hasThinInstances&&(this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1))},t.prototype._postActivate=function(){this.edgesShareWithInstances&&this.edgesRenderer&&this.edgesRenderer.isEnabled&&this._renderingGroup&&(this._renderingGroup._edgesRenderers.pushNoDuplicate(this.edgesRenderer),this.edgesRenderer.customInstances.push(this.getWorldMatrix()))},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 n=i.length,r=!1;if(e)r=!0;else for(var o=0,a=this.subMeshes;o<a.length;o++){var s=a[o];if(s.indexStart+s.indexCount>n){r=!0;break}if(s.verticesStart+s.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new _.a(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),i=t/e|0,n=0;i%3!=0;)i++;this.releaseSubMeshes();for(var r=0;r<e&&!(n>=t);r++)_.a.CreateFromIndices(0,n,r===e-1?t-n:i,this),n+=i;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,i,n){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,n);else{var r=new d.a;r.set(t,e);var o=this.getScene();new f.a(f.a.RandomId(),o,r,i,this)}return this},t.prototype.removeVerticesData=function(e){this._geometry&&this._geometry.removeVerticesData(e)},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=f.a.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},t.prototype.updateVerticesData=function(e,t,i,n){return this._geometry?(n?(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(h.b.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(h.b.PositionKind,i,!1,!1),t){var n=this.getIndices(),r=this.getVerticesData(h.b.NormalKind);if(!r)return this;d.a.ComputeNormals(i,n,r),this.updateVerticesData(h.b.NormalKind,r,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;if(1===this._geometry.meshes.length)return this;var e=this._geometry,t=this._geometry.copy(f.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 n=new d.a;n.indices=e;var r=this.getScene();new f.a(f.a.RandomId(),r,n,i,this)}return this},t.prototype.updateIndices=function(e,t,i){return void 0===i&&(i=!1),this._geometry?(this._geometry.updateIndices(e,t,i),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 n,r=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(i){case g.a.PointFillMode:n=null;break;case g.a.WireFrameFillMode:n=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case g.a.TriangleFillMode:n=this._geometry.getIndexBuffer()}return this._geometry._bind(t,n),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var n=this.getScene().getEngine();return this._unIndexed||t==g.a.PointFillMode?n.drawArraysType(t,e.verticesStart,e.verticesCount,i):t==g.a.WireFrameFillMode?n.drawElementsType(t,0,e._linesIndexCount,i):n.drawElementsType(t,e.indexStart,e.indexCount,i),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,t){if(void 0===t&&(t=!1),this._instanceDataStorage.isFrozen&&this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch;var i=this.getScene(),n=i._isInIntermediateRendering(),r=n?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,o=this._instanceDataStorage.batchCache;if(o.mustReturn=!1,o.renderSelf[e]=t||!r&&this.isEnabled()&&this.isVisible,o.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances&&!t){var a=this._instanceDataStorage.visibleInstances,s=i.getRenderId(),c=n?a.intermediateDefaultRenderId:a.defaultRenderId;o.visibleInstances[e]=a[s],!o.visibleInstances[e]&&c&&(o.visibleInstances[e]=a[c])}return o.hardwareInstancedRendering[e]=!t&&this._instanceDataStorage.hardwareInstancedRendering&&null!==o.visibleInstances[e]&&void 0!==o.visibleInstances[e],this._instanceDataStorage.previousBatch=o,o},t.prototype._renderWithInstances=function(e,t,i,n,r){var o=i.visibleInstances[e._id];if(!o)return this;for(var a=this._instanceDataStorage,s=a.instancesBufferSize,c=a.instancesBuffer,l=16*(o.length+1)*4;a.instancesBufferSize<l;)a.instancesBufferSize*=2;a.instancesData&&s==a.instancesBufferSize||(a.instancesData=new Float32Array(a.instancesBufferSize/4));var u=0,d=0,f=i.renderSelf[e._id],p=!c||s!==a.instancesBufferSize;if(this._instanceDataStorage.manualUpdate||a.isFrozen&&!p)d=(f?1:0)+o.length;else{var _=this._effectiveMesh.getWorldMatrix();if(f&&(_.copyToArray(a.instancesData,u),u+=16,d++),o)for(var m=0;m<o.length;m++){o[m].getWorldMatrix().copyToArray(a.instancesData,u),u+=16,d++}}return p?(c&&c.dispose(),c=new h.a(r,a.instancesData,!0,16,!1,!0),a.instancesBuffer=c,this.setVerticesBuffer(c.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(c.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(c.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(c.createVertexBuffer("world3",12,4))):this._instanceDataStorage.isFrozen||c.updateDirectly(a.instancesData,0,d),this._processInstancedBuffers(o,f),this.getScene()._activeIndices.addCount(e.indexCount*d,!1),this._bind(e,n,t),this._draw(e,t,d),r.unbindInstanceAttributes(),this},t.prototype._renderWithThinInstances=function(e,t,i,n){var r,o,a=null!==(o=null===(r=this._thinInstanceDataStorage)||void 0===r?void 0:r.instancesCount)&&void 0!==o?o:0;this.getScene()._activeIndices.addCount(e.indexCount*a,!1),this._bind(e,i,t),this._draw(e,t,a),n.unbindInstanceAttributes()},t.prototype._processInstancedBuffers=function(e,t){},t.prototype._processRendering=function(e,t,i,n,r,o,a,s){var c=this.getScene(),l=c.getEngine();if(o&&t.getRenderingMesh().hasThinInstances)return this._renderWithThinInstances(t,n,i,l),this;if(o)this._renderWithInstances(t,n,r,i,l);else{var u=0;r.renderSelf[t._id]&&(a&&a(!1,e._effectiveMesh.getWorldMatrix(),s),u++,this._draw(t,n,this._instanceDataStorage.overridenInstanceCount));var h=r.visibleInstances[t._id];if(h){var d=h.length;u+=d;for(var f=0;f<d;f++){var p=h[f].getWorldMatrix();a&&a(!0,p,s),this._draw(t,n)}}c._activeIndices.addCount(t.indexCount*u,!1)}return this},t.prototype._rebuild=function(){this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null),e.prototype._rebuild.call(this)},t.prototype._freeze=function(){if(this.subMeshes){for(var e=0;e<this.subMeshes.length;e++)this._getInstancesRenderList(e);this._effectiveMaterial=null,this._instanceDataStorage.isFrozen=!0}},t.prototype._unFreeze=function(){this._instanceDataStorage.isFrozen=!1,this._instanceDataStorage.previousBatch=null},t.prototype.render=function(e,t,i){var n=this.getScene();if(this._internalAbstractMeshDataInfo._isActiveIntermediate?this._internalAbstractMeshDataInfo._isActiveIntermediate=!1:this._internalAbstractMeshDataInfo._isActive=!1,this._checkOcclusionQuery())return this;var r=this._getInstancesRenderList(e._id,!!i);if(r.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeRenderObservable&&this._internalMeshDataInfo._onBeforeRenderObservable.notifyObservers(this);var o,a=n.getEngine(),s=r.hardwareInstancedRendering[e._id]||e.getRenderingMesh().hasThinInstances,c=this._instanceDataStorage,l=e.getMaterial();if(!l)return this;if(!c.isFrozen||!this._effectiveMaterial||this._effectiveMaterial!==l){if(l._storeEffectOnSubMeshes){if(!l.isReadyForSubMesh(this,e,s))return this}else if(!l.isReady(this,s))return this;this._effectiveMaterial=l}t&&a.setAlphaMode(this._effectiveMaterial.alphaMode),o=this._effectiveMaterial._storeEffectOnSubMeshes?e.effect:this._effectiveMaterial.getEffect();for(var u=0,h=n._beforeRenderingMeshStage;u<h.length;u++){h[u].action(this,e,r,o)}if(!o)return this;var d,f=i||this._effectiveMesh;if(c.isFrozen||!this._effectiveMaterial.backFaceCulling&&null===this.overrideMaterialSideOrientation)d=c.sideOrientation;else{var p=f._getWorldMatrixDeterminant();null==(d=this.overrideMaterialSideOrientation)&&(d=this._effectiveMaterial.sideOrientation),p<0&&(d=d===g.a.ClockWiseSideOrientation?g.a.CounterClockWiseSideOrientation:g.a.ClockWiseSideOrientation),c.sideOrientation=d}var _=this._effectiveMaterial._preBind(o,d);this._effectiveMaterial.forceDepthWrite&&a.setDepthWrite(!0);var m=n.forcePointsCloud?g.a.PointFillMode:n.forceWireframe?g.a.WireFrameFillMode:this._effectiveMaterial.fillMode;this._internalMeshDataInfo._onBeforeBindObservable&&this._internalMeshDataInfo._onBeforeBindObservable.notifyObservers(this),s||this._bind(e,o,m);var v=f.getWorldMatrix();this._effectiveMaterial._storeEffectOnSubMeshes?this._effectiveMaterial.bindForSubMesh(v,this,e):this._effectiveMaterial.bind(v,this),!this._effectiveMaterial.backFaceCulling&&this._effectiveMaterial.separateCullingPass&&(a.setState(!0,this._effectiveMaterial.zOffset,!1,!_),this._processRendering(this,e,o,m,r,s,this._onBeforeDraw,this._effectiveMaterial),a.setState(!0,this._effectiveMaterial.zOffset,!1,_)),this._processRendering(this,e,o,m,r,s,this._onBeforeDraw,this._effectiveMaterial),this._effectiveMaterial.unbind();for(var b=0,y=n._afterRenderingMeshStage;b<y.length;b++){y[b].action(this,e,r,o)}return this._internalMeshDataInfo._onAfterRenderObservable&&this._internalMeshDataInfo._onAfterRenderObservable.notifyObservers(this),this},t.prototype._onBeforeDraw=function(e,t,i){e&&i&&i.bindOnlyWorldMatrix(t)},t.prototype.cleanMatrixWeights=function(){this.isVerticesDataPresent(h.b.MatricesWeightsKind)&&(this.isVerticesDataPresent(h.b.MatricesWeightsExtraKind)?this.normalizeSkinWeightsAndExtra():this.normalizeSkinFourWeights())},t.prototype.normalizeSkinFourWeights=function(){for(var e=this.getVerticesData(h.b.MatricesWeightsKind),t=e.length,i=0;i<t;i+=4){var n=e[i]+e[i+1]+e[i+2]+e[i+3];if(0===n)e[i]=1;else{var r=1/n;e[i]*=r,e[i+1]*=r,e[i+2]*=r,e[i+3]*=r}}this.setVerticesData(h.b.MatricesWeightsKind,e)},t.prototype.normalizeSkinWeightsAndExtra=function(){for(var e=this.getVerticesData(h.b.MatricesWeightsExtraKind),t=this.getVerticesData(h.b.MatricesWeightsKind),i=t.length,n=0;n<i;n+=4){var r=t[n]+t[n+1]+t[n+2]+t[n+3];if(0===(r+=e[n]+e[n+1]+e[n+2]+e[n+3]))t[n]=1;else{var o=1/r;t[n]*=o,t[n+1]*=o,t[n+2]*=o,t[n+3]*=o,e[n]*=o,e[n+1]*=o,e[n+2]*=o,e[n+3]*=o}}this.setVerticesData(h.b.MatricesWeightsKind,t),this.setVerticesData(h.b.MatricesWeightsKind,e)},t.prototype.validateSkinning=function(){var e=this.getVerticesData(h.b.MatricesWeightsExtraKind),t=this.getVerticesData(h.b.MatricesWeightsKind);if(null===t||null==this.skeleton)return{skinned:!1,valid:!0,report:"not skinned"};for(var i=t.length,n=0,r=0,o=0,a=0,s=null===e?4:8,c=new Array,l=0;l<=s;l++)c[l]=0;for(l=0;l<i;l+=4){for(var u=t[l],d=u,f=0===d?0:1,p=1;p<s;p++){var _=p<4?t[l+p]:e[l+p-4];_>u&&n++,0!==_&&f++,d+=_,u=_}if(c[f]++,f>o&&(o=f),0===d)r++;else{var m=1/d,g=0;for(p=0;p<s;p++)g+=p<4?Math.abs(t[l+p]-t[l+p]*m):Math.abs(e[l+p-4]-e[l+p-4]*m);g>.001&&a++}}var v=this.skeleton.bones.length,b=this.getVerticesData(h.b.MatricesIndicesKind),y=this.getVerticesData(h.b.MatricesIndicesExtraKind),T=0;for(l=0;l<i;l+=4)for(p=0;p<s;p++){var E=p<4?b[l+p]:y[l+p-4];(E>=v||E<0)&&T++}return{skinned:!0,valid:0===r&&0===a&&0===T,report:"Number of Weights = "+i/4+"\nMaximum influences = "+o+"\nMissing Weights = "+r+"\nNot Sorted = "+n+"\nNot Normalized = "+a+"\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.b.LoadFile(this.delayLoadingFile,(function(i){i instanceof ArrayBuffer?t._delayLoadingFunction(i,t):t._delayLoadingFunction(JSON.parse(i),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),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 n=this.getScene().multiMaterials;for(t=n.length-1;t>-1;t--)if(n[t].id===e)return this.material=n[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(h.b.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,n=this.getVerticesData(h.b.PositionKind),r=new Array;for(i=0;i<n.length;i+=3)c.e.TransformCoordinates(c.e.FromArray(n,i),e).toArray(r,i);if(this.setVerticesData(h.b.PositionKind,r,this.getVertexBuffer(h.b.PositionKind).isUpdatable()),this.isVerticesDataPresent(h.b.NormalKind)){for(n=this.getVerticesData(h.b.NormalKind),r=[],i=0;i<n.length;i+=3)c.e.TransformNormal(c.e.FromArray(n,i),e).normalize().toArray(r,i);this.setVerticesData(h.b.NormalKind,r,this.getVertexBuffer(h.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(e){return void 0===e&&(e=!0),this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.resetLocalMatrix(e),this},Object.defineProperty(t.prototype,"_positions",{get:function(){return this._geometry?this._geometry._positions:null},enumerable:!1,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,n,r){return void 0===e&&(e=""),void 0===i&&(i=null),void 0===r&&(r=!0),new t(e,this.getScene(),i,this,n,r)},t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);var n=this._internalMeshDataInfo;if(n._onBeforeDrawObservable&&n._onBeforeDrawObservable.clear(),n._onBeforeBindObservable&&n._onBeforeBindObservable.clear(),n._onBeforeRenderObservable&&n._onBeforeRenderObservable.clear(),n._onAfterRenderObservable&&n._onAfterRenderObservable.clear(),this._scene.useClonedMeshMap){if(n.meshMap)for(var r in n.meshMap){(s=n.meshMap[r])&&(s._internalMeshDataInfo._source=null,n.meshMap[r]=void 0)}n._source&&n._source._internalMeshDataInfo.meshMap&&(n._source._internalMeshDataInfo.meshMap[this.uniqueId]=void 0)}else for(var o=0,a=this.getScene().meshes;o<a.length;o++){var s;(s=a[o])._internalMeshDataInfo&&s._internalMeshDataInfo._source&&s._internalMeshDataInfo._source===this&&(s._internalMeshDataInfo._source=null)}n._source=null,this._disposeInstanceSpecificData(),this._disposeThinInstanceSpecificData(),e.prototype.dispose.call(this,t,i)},t.prototype._disposeInstanceSpecificData=function(){},t.prototype._disposeThinInstanceSpecificData=function(){},t.prototype.applyDisplacementMap=function(e,t,i,n,r,a,s){var c=this;void 0===s&&(s=!1);var l=this.getScene();return o.b.LoadImage(e,(function(e){var o=e.width,l=e.height,u=R.a.CreateCanvas(o,l).getContext("2d");u.drawImage(e,0,0);var h=u.getImageData(0,0,o,l).data;c.applyDisplacementMapFromBuffer(h,o,l,t,i,r,a,s),n&&n(c)}),(function(){}),l.offlineProvider),this},t.prototype.applyDisplacementMapFromBuffer=function(e,t,i,n,r,o,a,s){if(void 0===s&&(s=!1),!this.isVerticesDataPresent(h.b.PositionKind)||!this.isVerticesDataPresent(h.b.NormalKind)||!this.isVerticesDataPresent(h.b.UVKind))return E.a.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var l=this.getVerticesData(h.b.PositionKind,!0,!0),u=this.getVerticesData(h.b.NormalKind),f=this.getVerticesData(h.b.UVKind),p=c.e.Zero(),_=c.e.Zero(),m=c.d.Zero();o=o||c.d.Zero(),a=a||new c.d(1,1);for(var g=0;g<l.length;g+=3){c.e.FromArrayToRef(l,g,p),c.e.FromArrayToRef(u,g,_),c.d.FromArrayToRef(f,g/3*2,m);var v=4*((Math.abs(m.x*a.x+o.x%1)*(t-1)%t|0)+(Math.abs(m.y*a.y+o.y%1)*(i-1)%i|0)*t),b=.3*(e[v]/255)+.59*(e[v+1]/255)+.11*(e[v+2]/255);_.normalize(),_.scaleInPlace(n+(r-n)*b),(p=p.add(_)).toArray(l,g)}return d.a.ComputeNormals(l,this.getIndices(),u),s?(this.setVerticesData(h.b.PositionKind,l),this.setVerticesData(h.b.NormalKind,u)):(this.updateVerticesData(h.b.PositionKind,l),this.updateVerticesData(h.b.NormalKind,u)),this},t.prototype.convertToFlatShadedMesh=function(){var e,t,i=this.getVerticesDataKinds(),n={},r={},o={},a=!1;for(e=0;e<i.length;e++){t=i[e];var s=this.getVertexBuffer(t);t!==h.b.NormalKind?(n[t]=s,r[t]=n[t].getData(),o[t]=[]):(a=s.isUpdatable(),i.splice(e,1),e--)}var l,u=this.subMeshes.slice(0),d=this.getIndices(),f=this.getTotalIndices();for(l=0;l<f;l++){var p=d[l];for(e=0;e<i.length;e++)for(var m=n[t=i[e]].getStrideSize(),g=0;g<m;g++)o[t].push(r[t][p*m+g])}var v=[],b=o[h.b.PositionKind];for(l=0;l<f;l+=3){d[l]=l,d[l+1]=l+1,d[l+2]=l+2;for(var y=c.e.FromArray(b,3*l),T=c.e.FromArray(b,3*(l+1)),E=c.e.FromArray(b,3*(l+2)),S=y.subtract(T),A=E.subtract(T),P=c.e.Normalize(c.e.Cross(S,A)),C=0;C<3;C++)v.push(P.x),v.push(P.y),v.push(P.z)}for(this.setIndices(d),this.setVerticesData(h.b.NormalKind,v,a),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],n[t].isUpdatable());this.releaseSubMeshes();for(var R=0;R<u.length;R++){var x=u[R];_.a.AddToMesh(x.materialIndex,x.indexStart,x.indexCount,x.indexStart,x.indexCount,this)}return this.synchronizeInstances(),this},t.prototype.convertToUnIndexedMesh=function(){var e,t,i=this.getVerticesDataKinds(),n={},r={},o={};for(e=0;e<i.length;e++){t=i[e];var a=this.getVertexBuffer(t);n[t]=a,r[t]=n[t].getData(),o[t]=[]}var s,c=this.subMeshes.slice(0),l=this.getIndices(),u=this.getTotalIndices();for(s=0;s<u;s++){var h=l[s];for(e=0;e<i.length;e++)for(var d=n[t=i[e]].getStrideSize(),f=0;f<d;f++)o[t].push(r[t][h*d+f])}for(s=0;s<u;s+=3)l[s]=s,l[s+1]=s+1,l[s+2]=s+2;for(this.setIndices(l),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],n[t].isUpdatable());this.releaseSubMeshes();for(var p=0;p<c.length;p++){var m=c[p];_.a.AddToMesh(m.materialIndex,m.indexStart,m.indexCount,m.indexStart,m.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},t.prototype.flipFaces=function(e){void 0===e&&(e=!1);var t,i,n=d.a.ExtractFromMesh(this);if(e&&this.isVerticesDataPresent(h.b.NormalKind)&&n.normals)for(t=0;t<n.normals.length;t++)n.normals[t]*=-1;if(n.indices)for(t=0;t<n.indices.length;t+=3)i=n.indices[t+1],n.indices[t+1]=n.indices[t+2],n.indices[t+2]=i;return n.applyToMesh(this,this.isVertexBufferUpdatable(h.b.PositionKind)),this},t.prototype.increaseVertices=function(e){var t=d.a.ExtractFromMesh(this),i=t.uvs,n=t.indices,r=t.positions,o=t.normals;if(n&&r&&o&&i){for(var a,s,l=e+1,u=new Array,f=0;f<l+1;f++)u[f]=new Array;var p,_=new c.e(0,0,0),m=new c.e(0,0,0),g=new c.d(0,0),v=new Array,b=new Array,y=new Array,T=r.length,S=i.length;for(f=0;f<n.length;f+=3){b[0]=n[f],b[1]=n[f+1],b[2]=n[f+2];for(var A=0;A<3;A++)if(a=b[A],s=b[(A+1)%3],void 0===y[a]&&void 0===y[s]?(y[a]=new Array,y[s]=new Array):(void 0===y[a]&&(y[a]=new Array),void 0===y[s]&&(y[s]=new Array)),void 0===y[a][s]&&void 0===y[s][a]){y[a][s]=[],_.x=(r[3*s]-r[3*a])/l,_.y=(r[3*s+1]-r[3*a+1])/l,_.z=(r[3*s+2]-r[3*a+2])/l,m.x=(o[3*s]-o[3*a])/l,m.y=(o[3*s+1]-o[3*a+1])/l,m.z=(o[3*s+2]-o[3*a+2])/l,g.x=(i[2*s]-i[2*a])/l,g.y=(i[2*s+1]-i[2*a+1])/l,y[a][s].push(a);for(var P=1;P<l;P++)y[a][s].push(r.length/3),r[T]=r[3*a]+P*_.x,o[T++]=o[3*a]+P*m.x,r[T]=r[3*a+1]+P*_.y,o[T++]=o[3*a+1]+P*m.y,r[T]=r[3*a+2]+P*_.z,o[T++]=o[3*a+2]+P*m.z,i[S++]=i[2*a]+P*g.x,i[S++]=i[2*a+1]+P*g.y;y[a][s].push(s),y[s][a]=new Array,p=y[a][s].length;for(var C=0;C<p;C++)y[s][a][C]=y[a][s][p-1-C]}u[0][0]=n[f],u[1][0]=y[n[f]][n[f+1]][1],u[1][1]=y[n[f]][n[f+2]][1];for(P=2;P<l;P++){u[P][0]=y[n[f]][n[f+1]][P],u[P][P]=y[n[f]][n[f+2]][P],_.x=(r[3*u[P][P]]-r[3*u[P][0]])/P,_.y=(r[3*u[P][P]+1]-r[3*u[P][0]+1])/P,_.z=(r[3*u[P][P]+2]-r[3*u[P][0]+2])/P,m.x=(o[3*u[P][P]]-o[3*u[P][0]])/P,m.y=(o[3*u[P][P]+1]-o[3*u[P][0]+1])/P,m.z=(o[3*u[P][P]+2]-o[3*u[P][0]+2])/P,g.x=(i[2*u[P][P]]-i[2*u[P][0]])/P,g.y=(i[2*u[P][P]+1]-i[2*u[P][0]+1])/P;for(A=1;A<P;A++)u[P][A]=r.length/3,r[T]=r[3*u[P][0]]+A*_.x,o[T++]=o[3*u[P][0]]+A*m.x,r[T]=r[3*u[P][0]+1]+A*_.y,o[T++]=o[3*u[P][0]+1]+A*m.y,r[T]=r[3*u[P][0]+2]+A*_.z,o[T++]=o[3*u[P][0]+2]+A*m.z,i[S++]=i[2*u[P][0]]+A*g.x,i[S++]=i[2*u[P][0]+1]+A*g.y}u[l]=y[n[f+1]][n[f+2]],v.push(u[0][0],u[1][0],u[1][1]);for(P=1;P<l;P++){for(A=0;A<P;A++)v.push(u[P][A],u[P+1][A],u[P+1][A+1]),v.push(u[P][A],u[P+1][A+1],u[P][A+1]);v.push(u[P][A],u[P+1][A],u[P+1][A+1])}}t.indices=v,t.applyToMesh(this,this.isVertexBufferUpdatable(h.b.PositionKind))}else E.a.Warn("VertexData contains null entries")},t.prototype.forceSharedVertices=function(){var e=d.a.ExtractFromMesh(this),t=e.uvs,i=e.indices,n=e.positions,r=e.colors;if(void 0===i||void 0===n||null===i||null===n)E.a.Warn("VertexData contains empty entries");else{for(var o,a,s=new Array,c=new Array,l=new Array,u=new Array,f=new Array,p=0,_={},m=0;m<i.length;m+=3){a=[i[m],i[m+1],i[m+2]],f=new Array;for(var g=0;g<3;g++){f[g]="";for(var v=0;v<3;v++)Math.abs(n[3*a[g]+v])<1e-8&&(n[3*a[g]+v]=0),f[g]+=n[3*a[g]+v]+"|"}if(f[0]!=f[1]&&f[0]!=f[2]&&f[1]!=f[2])for(g=0;g<3;g++){if(void 0===(o=_[f[g]])){_[f[g]]=p,o=p++;for(v=0;v<3;v++)s.push(n[3*a[g]+v]);if(null!=r)for(v=0;v<4;v++)u.push(r[4*a[g]+v]);if(null!=t)for(v=0;v<2;v++)l.push(t[2*a[g]+v])}c.push(o)}}var b=new Array;d.a.ComputeNormals(s,c,b),e.positions=s,e.indices=c,e.normals=b,null!=t&&(e.uvs=l),null!=r&&(e.colors=u),e.applyToMesh(this,this.isVertexBufferUpdatable(h.b.PositionKind))}},t._instancedMeshFactory=function(e,t){throw A.a.WarnImport("InstancedMesh")},t._PhysicsImpostorParser=function(e,t,i){throw A.a.WarnImport("PhysicsImpostor")},t.prototype.createInstance=function(e){var i=this.geometry;if(i&&i.meshes.length>1)for(var n=0,r=i.meshes.slice(0);n<r.length;n++){var o=r[n];o!==this&&o.makeGeometryUnique()}return t._instancedMeshFactory(e,this)},t.prototype.synchronizeInstances=function(){this._geometry&&1!==this._geometry.meshes.length&&this.instances.length&&this.makeGeometryUnique();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(),n=this.getVerticesData(h.b.PositionKind);if(!n||!i)return this;for(var r=new Array,a=0;a<n.length;a+=3)r.push(c.e.FromArray(n,a));var s=new Array;return o.a.SyncAsyncForLoop(r.length,40,(function(e){for(var t=r.length-1-e,i=r[t],n=0;n<t;++n){var o=r[n];if(i.equals(o)){s[t]=n;break}}}),(function(){for(var n=0;n<i.length;++n)i[n]=s[i[n]]||i[n];var r=t.subMeshes.slice(0);t.setIndices(i),t.subMeshes=r,e&&e(t)})),this},t.prototype.serialize=function(e){e.name=this.name,e.id=this.id,e.uniqueId=this.uniqueId,e.type=this.getClassName(),s.a&&s.a.HasTags(this)&&(e.tags=s.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,e.overrideMaterialSideOrientation=this.overrideMaterialSideOrientation,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 n=0;n<this.subMeshes.length;n++){var r=this.subMeshes[n];e.subMeshes.push({materialIndex:r.materialIndex,verticesStart:r.verticesStart,verticesCount:r.verticesCount,indexStart:r.indexStart,indexCount:r.indexCount})}}(this.material?this.material.doNotSerialize||(e.materialId=this.material.id):this.material=null,this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id,e.numBoneInfluencers=this.numBoneInfluencers),this.getScene()._getComponent(P.a.NAME_PHYSICSENGINE))&&((l=this.getPhysicsImpostor())&&(e.physicsMass=l.getParam("mass"),e.physicsFriction=l.getParam("friction"),e.physicsRestitution=l.getParam("mass"),e.physicsImpostor=l.type));this.metadata&&(e.metadata=this.metadata),e.instances=[];for(var a=0;a<this.instances.length;a++){var c=this.instances[a];if(!c.doNotSerialize){var l,u={name:c.name,id:c.id,isEnabled:c.isEnabled(!1),isVisible:c.isVisible,isPickable:c.isPickable,checkCollisions:c.checkCollisions,position:c.position.asArray(),scaling:c.scaling.asArray()};if(c.parent&&(u.parentId=c.parent.id),c.rotationQuaternion?u.rotationQuaternion=c.rotationQuaternion.asArray():c.rotation&&(u.rotation=c.rotation.asArray()),this.getScene()._getComponent(P.a.NAME_PHYSICSENGINE))(l=c.getPhysicsImpostor())&&(u.physicsMass=l.getParam("mass"),u.physicsFriction=l.getParam("friction"),u.physicsRestitution=l.getParam("mass"),u.physicsImpostor=l.type);c.metadata&&(u.metadata=c.metadata),e.instances.push(u),T.a.AppendSerializedAnimations(c,u),u.ranges=c.serializeAnimationRanges()}}if(this._thinInstanceDataStorage.instancesCount&&this._thinInstanceDataStorage.matrixData&&(e.thinInstances={instancesCount:this._thinInstanceDataStorage.instancesCount,matrixData:o.b.SliceToArray(this._thinInstanceDataStorage.matrixData),matrixBufferSize:this._thinInstanceDataStorage.matrixBufferSize},this._userThinInstanceBuffersStorage)){var h={data:{},sizes:{},strides:{}};for(var d in this._userThinInstanceBuffersStorage.data)h.data[d]=o.b.SliceToArray(this._userThinInstanceBuffersStorage.data[d]),h.sizes[d]=this._userThinInstanceBuffersStorage.sizes[d],h.strides[d]=this._userThinInstanceBuffersStorage.strides[d];e.thinInstances.userThinInstance=h}T.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._internalMeshDataInfo._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices())return E.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),n=i.getPositions();if(!n)return void E.a.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(h.b.PositionKind+t,n,!1,3);var r=i.getNormals();r&&this.geometry.setVerticesData(h.b.NormalKind+t,r,!1,3);var o=i.getTangents();o&&this.geometry.setVerticesData(h.b.TangentKind+t,o,!1,3);var a=i.getUVs();a&&this.geometry.setVerticesData(h.b.UVKind+"_"+t,a,!1,2)}}else for(t=0;this.geometry.isVerticesDataPresent(h.b.PositionKind+t);)this.geometry.removeVerticesData(h.b.PositionKind+t),this.geometry.isVerticesDataPresent(h.b.NormalKind+t)&&this.geometry.removeVerticesData(h.b.NormalKind+t),this.geometry.isVerticesDataPresent(h.b.TangentKind+t)&&this.geometry.removeVerticesData(h.b.TangentKind+t),this.geometry.isVerticesDataPresent(h.b.UVKind+t)&&this.geometry.removeVerticesData(h.b.UVKind+"_"+t),t++}},t.Parse=function(e,i,n){var r;if((r=e.type&&"GroundMesh"===e.type?t._GroundMeshParser(e,i):new t(e.name,i)).id=e.id,s.a&&s.a.AddTagsTo(r,e.tags),r.position=c.e.FromArray(e.position),void 0!==e.metadata&&(r.metadata=e.metadata),e.rotationQuaternion?r.rotationQuaternion=c.b.FromArray(e.rotationQuaternion):e.rotation&&(r.rotation=c.e.FromArray(e.rotation)),r.scaling=c.e.FromArray(e.scaling),e.localMatrix?r.setPreTransformMatrix(c.a.FromArray(e.localMatrix)):e.pivotMatrix&&r.setPivotMatrix(c.a.FromArray(e.pivotMatrix)),r.setEnabled(e.isEnabled),r.isVisible=e.isVisible,r.infiniteDistance=e.infiniteDistance,r.showBoundingBox=e.showBoundingBox,r.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,void 0!==e.applyFog&&(r.applyFog=e.applyFog),void 0!==e.pickable&&(r.isPickable=e.pickable),void 0!==e.alphaIndex&&(r.alphaIndex=e.alphaIndex),r.receiveShadows=e.receiveShadows,r.billboardMode=e.billboardMode,void 0!==e.visibility&&(r.visibility=e.visibility),r.checkCollisions=e.checkCollisions,r.overrideMaterialSideOrientation=e.overrideMaterialSideOrientation,void 0!==e.isBlocker&&(r.isBlocker=e.isBlocker),r._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(r._waitingData.freezeWorldMatrix=e.freezeWorldMatrix),e.parentId&&(r._waitingParentId=e.parentId),void 0!==e.actions&&(r._waitingData.actions=e.actions),void 0!==e.overlayAlpha&&(r.overlayAlpha=e.overlayAlpha),void 0!==e.overlayColor&&(r.overlayColor=l.a.FromArray(e.overlayColor)),void 0!==e.renderOverlay&&(r.renderOverlay=e.renderOverlay),r.isUnIndexed=!!e.isUnIndexed,r.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(r.delayLoadState=y.a.DELAYLOADSTATE_NOTLOADED,r.delayLoadingFile=n+e.delayLoadingFile,r._boundingInfo=new m.a(c.e.FromArray(e.boundingBoxMinimum),c.e.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(r._binaryInfo=e._binaryInfo),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(h.b.UVKind),e.hasUVs2&&r._delayInfo.push(h.b.UV2Kind),e.hasUVs3&&r._delayInfo.push(h.b.UV3Kind),e.hasUVs4&&r._delayInfo.push(h.b.UV4Kind),e.hasUVs5&&r._delayInfo.push(h.b.UV5Kind),e.hasUVs6&&r._delayInfo.push(h.b.UV6Kind),e.hasColors&&r._delayInfo.push(h.b.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(h.b.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(h.b.MatricesWeightsKind),r._delayLoadingFunction=f.a._ImportGeometry,b.a.ForceFullSceneLoadingForIncremental&&r._checkDelayState()):f.a._ImportGeometry(e,r),e.materialId?r.setMaterialByID(e.materialId):r.material=null,e.morphTargetManagerId>-1&&(r.morphTargetManager=i.getMorphTargetManagerById(e.morphTargetManagerId)),void 0!==e.skeletonId&&null!==e.skeletonId&&(r.skeleton=i.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o<e.animations.length;o++){var a=e.animations[o];(g=S.a.GetClass("BABYLON.Animation"))&&r.animations.push(g.Parse(a))}u.a.ParseAnimationRanges(r,e,i)}if(e.autoAnimate&&i.beginAnimation(r,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?r.layerMask=Math.abs(parseInt(e.layerMask)):r.layerMask=268435455,e.physicsImpostor&&t._PhysicsImpostorParser(i,r,e),e.lodMeshIds&&(r._waitingData.lods={ids:e.lodMeshIds,distances:e.lodDistances?e.lodDistances:null,coverages:e.lodCoverages?e.lodCoverages:null}),e.instances)for(var d=0;d<e.instances.length;d++){var p=e.instances[d],_=r.createInstance(p.name);if(p.id&&(_.id=p.id),s.a&&(p.tags?s.a.AddTagsTo(_,p.tags):s.a.AddTagsTo(_,e.tags)),_.position=c.e.FromArray(p.position),void 0!==p.metadata&&(_.metadata=p.metadata),p.parentId&&(_._waitingParentId=p.parentId),void 0!==p.isEnabled&&null!==p.isEnabled&&_.setEnabled(p.isEnabled),void 0!==p.isVisible&&null!==p.isVisible&&(_.isVisible=p.isVisible),void 0!==p.isPickable&&null!==p.isPickable&&(_.isPickable=p.isPickable),p.rotationQuaternion?_.rotationQuaternion=c.b.FromArray(p.rotationQuaternion):p.rotation&&(_.rotation=c.e.FromArray(p.rotation)),_.scaling=c.e.FromArray(p.scaling),null!=p.checkCollisions&&null!=p.checkCollisions&&(_.checkCollisions=p.checkCollisions),null!=p.pickable&&null!=p.pickable&&(_.isPickable=p.pickable),null!=p.showBoundingBox&&null!=p.showBoundingBox&&(_.showBoundingBox=p.showBoundingBox),null!=p.showSubMeshesBoundingBox&&null!=p.showSubMeshesBoundingBox&&(_.showSubMeshesBoundingBox=p.showSubMeshesBoundingBox),null!=p.alphaIndex&&null!=p.showSubMeshesBoundingBox&&(_.alphaIndex=p.alphaIndex),p.physicsImpostor&&t._PhysicsImpostorParser(i,_,p),p.animations){for(o=0;o<p.animations.length;o++){var g;a=p.animations[o],(g=S.a.GetClass("BABYLON.Animation"))&&_.animations.push(g.Parse(a))}u.a.ParseAnimationRanges(_,p,i),p.autoAnimate&&i.beginAnimation(_,p.autoAnimateFrom,p.autoAnimateTo,p.autoAnimateLoop,p.autoAnimateSpeed||1)}}if(e.thinInstances){var v=e.thinInstances;if(v.matrixData?(r.thinInstanceSetBuffer("matrix",new Float32Array(v.matrixData),16,!1),r._thinInstanceDataStorage.matrixBufferSize=v.matrixBufferSize,r._thinInstanceDataStorage.instancesCount=v.instancesCount):r._thinInstanceDataStorage.matrixBufferSize=v.matrixBufferSize,e.thinInstances.userThinInstance){var T=e.thinInstances.userThinInstance;for(var E in T.data)r.thinInstanceSetBuffer(E,new Float32Array(T.data[E]),T.strides[E],!1),r._userThinInstanceBuffersStorage.sizes[E]=T.sizes[E]}}return r},t.CreateRibbon=function(e,t,i,n,r,o,a,s,c){throw A.a.WarnImport("MeshBuilder")},t.CreateDisc=function(e,t,i,n,r,o){throw void 0===n&&(n=null),A.a.WarnImport("MeshBuilder")},t.CreateBox=function(e,t,i,n,r){throw void 0===i&&(i=null),A.a.WarnImport("MeshBuilder")},t.CreateSphere=function(e,t,i,n,r,o){throw A.a.WarnImport("MeshBuilder")},t.CreateHemisphere=function(e,t,i,n){throw A.a.WarnImport("MeshBuilder")},t.CreateCylinder=function(e,t,i,n,r,o,a,s,c){throw A.a.WarnImport("MeshBuilder")},t.CreateTorus=function(e,t,i,n,r,o,a){throw A.a.WarnImport("MeshBuilder")},t.CreateTorusKnot=function(e,t,i,n,r,o,a,s,c,l){throw A.a.WarnImport("MeshBuilder")},t.CreateLines=function(e,t,i,n,r){throw void 0===i&&(i=null),void 0===n&&(n=!1),void 0===r&&(r=null),A.a.WarnImport("MeshBuilder")},t.CreateDashedLines=function(e,t,i,n,r,o,a,s){throw void 0===o&&(o=null),A.a.WarnImport("MeshBuilder")},t.CreatePolygon=function(e,t,i,n,r,o,a){throw void 0===a&&(a=earcut),A.a.WarnImport("MeshBuilder")},t.ExtrudePolygon=function(e,t,i,n,r,o,a,s){throw void 0===s&&(s=earcut),A.a.WarnImport("MeshBuilder")},t.ExtrudeShape=function(e,t,i,n,r,o,a,s,c,l){throw void 0===a&&(a=null),A.a.WarnImport("MeshBuilder")},t.ExtrudeShapeCustom=function(e,t,i,n,r,o,a,s,c,l,u,h){throw A.a.WarnImport("MeshBuilder")},t.CreateLathe=function(e,t,i,n,r,o,a){throw A.a.WarnImport("MeshBuilder")},t.CreatePlane=function(e,t,i,n,r){throw A.a.WarnImport("MeshBuilder")},t.CreateGround=function(e,t,i,n,r,o){throw A.a.WarnImport("MeshBuilder")},t.CreateTiledGround=function(e,t,i,n,r,o,a,s,c){throw A.a.WarnImport("MeshBuilder")},t.CreateGroundFromHeightMap=function(e,t,i,n,r,o,a,s,c,l,u){throw A.a.WarnImport("MeshBuilder")},t.CreateTube=function(e,t,i,n,r,o,a,s,c,l){throw A.a.WarnImport("MeshBuilder")},t.CreatePolyhedron=function(e,t,i){throw A.a.WarnImport("MeshBuilder")},t.CreateIcoSphere=function(e,t,i){throw A.a.WarnImport("MeshBuilder")},t.CreateDecal=function(e,t,i,n,r,o){throw A.a.WarnImport("MeshBuilder")},t.CreateCapsule=function(e,t,i){throw A.a.WarnImport("MeshBuilder")},t.prototype.setPositionsForCPUSkinning=function(){var e=this._internalMeshDataInfo;if(!e._sourcePositions){var t=this.getVerticesData(h.b.PositionKind);if(!t)return e._sourcePositions;e._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(h.b.PositionKind)||this.setVerticesData(h.b.PositionKind,t,!0)}return e._sourcePositions},t.prototype.setNormalsForCPUSkinning=function(){var e=this._internalMeshDataInfo;if(!e._sourceNormals){var t=this.getVerticesData(h.b.NormalKind);if(!t)return e._sourceNormals;e._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(h.b.NormalKind)||this.setVerticesData(h.b.NormalKind,t,!0)}return e._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(h.b.PositionKind))return this;if(!this.isVerticesDataPresent(h.b.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(h.b.MatricesWeightsKind))return this;var t=this.isVerticesDataPresent(h.b.NormalKind),i=this._internalMeshDataInfo;if(!i._sourcePositions){var n=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=n}t&&!i._sourceNormals&&this.setNormalsForCPUSkinning();var r=this.getVerticesData(h.b.PositionKind);if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r));var o=this.getVerticesData(h.b.NormalKind);if(t){if(!o)return this;o instanceof Float32Array||(o=new Float32Array(o))}var a=this.getVerticesData(h.b.MatricesIndicesKind),s=this.getVerticesData(h.b.MatricesWeightsKind);if(!s||!a)return this;for(var l,u=this.numBoneInfluencers>4,d=u?this.getVerticesData(h.b.MatricesIndicesExtraKind):null,f=u?this.getVerticesData(h.b.MatricesWeightsExtraKind):null,p=e.getTransformMatrices(this),_=c.e.Zero(),m=new c.a,g=new c.a,v=0,b=0;b<r.length;b+=3,v+=4){var y;for(l=0;l<4;l++)(y=s[v+l])>0&&(c.a.FromFloat32ArrayToRefScaled(p,Math.floor(16*a[v+l]),y,g),m.addToSelf(g));if(u)for(l=0;l<4;l++)(y=f[v+l])>0&&(c.a.FromFloat32ArrayToRefScaled(p,Math.floor(16*d[v+l]),y,g),m.addToSelf(g));c.e.TransformCoordinatesFromFloatsToRef(i._sourcePositions[b],i._sourcePositions[b+1],i._sourcePositions[b+2],m,_),_.toArray(r,b),t&&(c.e.TransformNormalFromFloatsToRef(i._sourceNormals[b],i._sourceNormals[b+1],i._sourceNormals[b+2],m,_),_.toArray(o,b)),m.reset()}return this.updateVerticesData(h.b.PositionKind,r),t&&this.updateVerticesData(h.b.NormalKind,o),this},t.MinMax=function(e){var t=null,i=null;return e.forEach((function(e){var n=e.getBoundingInfo().boundingBox;t&&i?(t.minimizeInPlace(n.minimumWorld),i.maximizeInPlace(n.maximumWorld)):(t=n.minimumWorld,i=n.maximumWorld)})),t&&i?{min:t,max:i}:{min:c.e.Zero(),max:c.e.Zero()}},t.Center=function(e){var i=e instanceof Array?t.MinMax(e):e;return c.e.Center(i.min,i.max)},t.MergeMeshes=function(e,i,n,r,o,a){var s;if(void 0===i&&(i=!0),!n){var c=0;for(s=0;s<e.length;s++)if(e[s]&&(c+=e[s].getTotalVertices())>=65536)return E.a.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}if(a){var l,u,h=null;o=!1}var f,p=new Array,m=new Array,g=null,b=new Array,y=null;for(s=0;s<e.length;s++)if(e[s]){var T=e[s];if(T.isAnInstance)return E.a.Warn("Cannot merge instance meshes."),null;var S=T.computeWorldMatrix(!0);if((f=d.a.ExtractFromMesh(T,!0,!0)).transform(S),g?g.merge(f,n):(g=f,y=T),o&&b.push(T.getTotalIndices()),a)if(T.material){var A=T.material;if(A instanceof v.a){for(u=0;u<A.subMaterials.length;u++)p.indexOf(A.subMaterials[u])<0&&p.push(A.subMaterials[u]);for(l=0;l<T.subMeshes.length;l++)m.push(p.indexOf(A.subMaterials[T.subMeshes[l].materialIndex])),b.push(T.subMeshes[l].indexCount)}else for(p.indexOf(A)<0&&p.push(A),l=0;l<T.subMeshes.length;l++)m.push(p.indexOf(A)),b.push(T.subMeshes[l].indexCount)}else for(l=0;l<T.subMeshes.length;l++)m.push(0),b.push(T.subMeshes[l].indexCount)}if(y=y,r||(r=new t(y.name+"_merged",y.getScene())),g.applyToMesh(r),r.checkCollisions=y.checkCollisions,r.overrideMaterialSideOrientation=y.overrideMaterialSideOrientation,i)for(s=0;s<e.length;s++)e[s]&&e[s].dispose();if(o||a){r.releaseSubMeshes(),s=0;for(var P=0;s<b.length;)_.a.CreateFromIndices(0,P,b[s],r),P+=b[s],s++}if(a){for((h=new v.a(y.name+"_merged",y.getScene())).subMaterials=p,l=0;l<r.subMeshes.length;l++)r.subMeshes[l].materialIndex=m[l];r.material=h}else r.material=y.material;return r},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=d.a.FRONTSIDE,t.BACKSIDE=d.a.BACKSIDE,t.DOUBLESIDE=d.a.DOUBLESIDE,t.DEFAULTSIDE=d.a.DEFAULTSIDE,t.NO_CAP=0,t.CAP_START=1,t.CAP_END=2,t.CAP_ALL=3,t.NO_FLIP=0,t.FLIP_TILE=1,t.ROTATE_TILE=2,t.FLIP_ROW=3,t.ROTATE_ROW=4,t.FLIP_N_ROTATE_TILE=5,t.FLIP_N_ROTATE_ROW=6,t.CENTER=0,t.LEFT=1,t.RIGHT=2,t.TOP=3,t.BOTTOM=4,t._GroundMeshParser=function(e,t){throw A.a.WarnImport("GroundMesh")},t}(p.a);S.a.RegisteredTypes["BABYLON.Mesh"]=N},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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 n="<div style='color:white'>"+i+"</div><br>";e._AddLogEntry(n)},e._WarnDisabled=function(e){},e._WarnEnabled=function(t){var i=e._FormatMessage(t);console.warn("BJS - "+i);var n="<div style='color:orange'>"+i+"</div><br>";e._AddLogEntry(n)},e._ErrorDisabled=function(e){},e._ErrorEnabled=function(t){e.errorsCount++;var i=e._FormatMessage(t);console.error("BJS - "+i);var n="<div style='color:red'>"+i+"</div><br>";e._AddLogEntry(n)},Object.defineProperty(e,"LogCache",{get:function(){return e._LogCache},enumerable:!1,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:!1,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,"a",(function(){return s})),i.d(t,"b",(function(){return c})),i.d(t,"c",(function(){return l}));var n=i(14),r=i(28),o=i(44),a=i(11),s=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=255*this.r|0;return e=397*(e=397*e^(255*this.g|0))^(255*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.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new c(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=n.a.Clamp(this.r,e,t),i.g=n.a.Clamp(this.g,e,t),i.b=n.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"#"+n.a.ToHex(e)+n.a.ToHex(t)+n.a.ToHex(i)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toHSV=function(){var t=new e;return this.toHSVToRef(t),t},e.prototype.toHSVToRef=function(e){var t=this.r,i=this.g,n=this.b,r=Math.max(t,i,n),o=Math.min(t,i,n),a=0,s=0,c=r,l=r-o;0!==r&&(s=l/r),r!=o&&(r==t?(a=(i-n)/l,i<n&&(a+=6)):r==i?a=(n-t)/l+2:r==n&&(a=(t-i)/l+4),a*=60),e.r=a,e.g=s,e.b=c},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,r.c),e.g=Math.pow(this.g,r.c),e.b=Math.pow(this.b,r.c),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,r.b),e.g=Math.pow(this.g,r.b),e.b=Math.pow(this.b,r.b),this},e.HSVtoRGBToRef=function(e,t,i,n){var r=i*t,o=e/60,a=r*(1-Math.abs(o%2-1)),s=0,c=0,l=0;o>=0&&o<=1?(s=r,c=a):o>=1&&o<=2?(s=a,c=r):o>=2&&o<=3?(c=r,l=a):o>=3&&o<=4?(c=a,l=r):o>=4&&o<=5?(s=a,l=r):o>=5&&o<=6&&(s=r,l=a);var u=i-r;n.set(s+u,c+u,l+u)},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),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16);return e.FromInts(i,n,r)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2])},e.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2]},e.FromInts=function(t,i,n){return new e(t/255,i/255,n/255)},e.Lerp=function(t,i,n){var r=new e(0,0,0);return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){n.r=e.r+(t.r-e.r)*i,n.g=e.g+(t.g-e.g)*i,n.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:!1,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}(),c=function(){function e(e,t,i,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),this.r=e,this.g=t,this.b=i,this.a=n}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.fromArray=function(t,i){return void 0===i&&(i=0),e.FromArrayToRef(t,i,this),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=n.a.Clamp(this.r,e,t),i.g=n.a.Clamp(this.g,e,t),i.b=n.a.Clamp(this.b,e,t),i.a=n.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=255*this.r|0;return e=397*(e=397*(e=397*e^(255*this.g|0))^(255*this.b|0))^(255*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,n){return this.r=e,this.g=t,this.b=i,this.a=n,this},e.prototype.set=function(e,t,i,n){return this.copyFromFloats(e,t,i,n)},e.prototype.toHexString=function(e){void 0===e&&(e=!1);var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;if(e)return"#"+n.a.ToHex(t)+n.a.ToHex(i)+n.a.ToHex(r);var o=255*this.a|0;return"#"+n.a.ToHex(t)+n.a.ToHex(i)+n.a.ToHex(r)+n.a.ToHex(o)},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,r.c),e.g=Math.pow(this.g,r.c),e.b=Math.pow(this.b,r.c),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,r.b),e.g=Math.pow(this.g,r.b),e.b=Math.pow(this.b,r.b),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),n=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);return e.FromInts(i,n,r,o)},e.Lerp=function(t,i,n){var r=new e(0,0,0,0);return e.LerpToRef(t,i,n,r),r},e.LerpToRef=function(e,t,i,n){n.r=e.r+(t.r-e.r)*i,n.g=e.g+(t.g-e.g)*i,n.b=e.b+(t.b-e.b)*i,n.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.FromArrayToRef=function(e,t,i){void 0===t&&(t=0),i.r=e[t],i.g=e[t+1],i.b=e[t+2],i.a=e[t+3]},e.FromInts=function(t,i,n,r){return new e(t/255,i/255,n/255,r/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],n=0;n<e.length;n+=3){var r=n/3*4;i[r]=e[n],i[r+1]=e[n+1],i[r+2]=e[n+2],i[r+3]=1}return i}return e},e}(),l=function(){function e(){}return e.Color3=o.a.BuildArray(3,s.Black),e.Color4=o.a.BuildArray(3,(function(){return new c(0,0,0,0)})),e}();a.a.RegisteredTypes["BABYLON.Color3"]=s,a.a.RegisteredTypes["BABYLON.Color4"]=c},function(e,t,i){"use strict";i.d(t,"a",(function(){return m}));var n=i(1),r=i(3),o=i(6),a=i(0),s=i(52),c=i(2),l=i(11),u=i(21),h=i(104),d=i(122),f=i(64),p=i(34),_=i(150),m=function(e){function t(i,n,r,a,s,l,u,d,f,p,_,m){void 0===r&&(r=!1),void 0===a&&(a=!0),void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===u&&(u=null),void 0===d&&(d=null),void 0===f&&(f=!1);var g=e.call(this,n)||this;g.url=null,g.uOffset=0,g.vOffset=0,g.uScale=1,g.vScale=1,g.uAng=0,g.vAng=0,g.wAng=0,g.uRotationCenter=.5,g.vRotationCenter=.5,g.wRotationCenter=.5,g.homogeneousRotationInUVTransform=!1,g.inspectableCustomProperties=null,g._noMipmap=!1,g._invertY=!1,g._rowGenerationMatrix=null,g._cachedTextureMatrix=null,g._projectionModeMatrix=null,g._t0=null,g._t1=null,g._t2=null,g._cachedUOffset=-1,g._cachedVOffset=-1,g._cachedUScale=0,g._cachedVScale=0,g._cachedUAng=-1,g._cachedVAng=-1,g._cachedWAng=-1,g._cachedProjectionMatrixId=-1,g._cachedURotationCenter=-1,g._cachedVRotationCenter=-1,g._cachedWRotationCenter=-1,g._cachedHomogeneousRotationInUVTransform=!1,g._cachedCoordinatesMode=-1,g._initialSamplingMode=t.BILINEAR_SAMPLINGMODE,g._buffer=null,g._deleteBuffer=!1,g._format=null,g._delayedOnLoad=null,g._delayedOnError=null,g.onLoadObservable=new o.c,g._isBlocking=!0,g.name=i||"",g.url=i,g._noMipmap=r,g._invertY=a,g._initialSamplingMode=s,g._buffer=d,g._deleteBuffer=f,g._mimeType=_,g._loaderOptions=m,p&&(g._format=p);var v=g.getScene(),b=g._getEngine();if(!b)return g;b.onBeforeTextureInitObservable.notifyObservers(g);var y=function(){g._texture&&(g._texture._invertVScale&&(g.vScale*=-1,g.vOffset+=1),null!==g._texture._cachedWrapU&&(g.wrapU=g._texture._cachedWrapU,g._texture._cachedWrapU=null),null!==g._texture._cachedWrapV&&(g.wrapV=g._texture._cachedWrapV,g._texture._cachedWrapV=null),null!==g._texture._cachedWrapR&&(g.wrapR=g._texture._cachedWrapR,g._texture._cachedWrapR=null)),g.onLoadObservable.hasObservers()&&g.onLoadObservable.notifyObservers(g),l&&l(),!g.isBlocking&&v&&v.resetCachedMaterial()};return g.url?(g._texture=g._getFromCache(g.url,r,s,a),g._texture?g._texture.isReady?h.a.SetImmediate((function(){return y()})):g._texture.onLoadedObservable.add(y):v&&v.useDelayedTextureLoading?(g.delayLoadState=c.a.DELAYLOADSTATE_NOTLOADED,g._delayedOnLoad=y,g._delayedOnError=u):(g._texture=b.createTexture(g.url,r,a,v,s,y,u,g._buffer,void 0,g._format,null,_,m),f&&(g._buffer=null)),g):(g._delayedOnLoad=y,g._delayedOnError=u,g)}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mimeType",{get:function(){return this._mimeType},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplingMode",{get:function(){return this._texture?this._texture.samplingMode:this._initialSamplingMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"invertY",{get:function(){return this._invertY},enumerable:!1,configurable:!0}),t.prototype.updateURL=function(e,t,i){void 0===t&&(t=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(c.a.MATERIAL_TextureDirtyFlag)),this.name&&!p.a.StartsWith(this.name,"data:")||(this.name=e),this.url=e,this._buffer=t,this.delayLoadState=c.a.DELAYLOADSTATE_NOTLOADED,i&&(this._delayedOnLoad=i),this.delayLoad()},t.prototype.delayLoad=function(){if(this.delayLoadState===c.a.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=c.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY),this._texture?this._delayedOnLoad&&(this._texture.isReady?h.a.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,null,this._mimeType,this._loaderOptions),this._deleteBuffer&&(this._buffer=null)),this._delayedOnLoad=null,this._delayedOnError=null)}},t.prototype._prepareRowForTextureGeneration=function(e,t,i,n){e*=this._cachedUScale,t*=this._cachedVScale,e-=this.uRotationCenter*this._cachedUScale,t-=this.vRotationCenter*this._cachedVScale,i-=this.wRotationCenter,a.e.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,n),n.x+=this.uRotationCenter*this._cachedUScale+this._cachedUOffset,n.y+=this.vRotationCenter*this._cachedVScale+this._cachedVOffset,n.z+=this.wRotationCenter},t.prototype.checkTransformsAreIdentical=function(e){return null!==e&&this.uOffset===e.uOffset&&this.vOffset===e.vOffset&&this.uScale===e.uScale&&this.vScale===e.vScale&&this.uAng===e.uAng&&this.vAng===e.vAng&&this.wAng===e.wAng},t.prototype.getTextureMatrix=function(e){var t=this;if(void 0===e&&(e=1),this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale*e===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng&&this.uRotationCenter===this._cachedURotationCenter&&this.vRotationCenter===this._cachedVRotationCenter&&this.wRotationCenter===this._cachedWRotationCenter&&this.homogeneousRotationInUVTransform===this._cachedHomogeneousRotationInUVTransform)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale*e,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedURotationCenter=this.uRotationCenter,this._cachedVRotationCenter=this.vRotationCenter,this._cachedWRotationCenter=this.wRotationCenter,this._cachedHomogeneousRotationInUVTransform=this.homogeneousRotationInUVTransform,this._cachedTextureMatrix&&this._rowGenerationMatrix||(this._cachedTextureMatrix=a.a.Zero(),this._rowGenerationMatrix=new a.a,this._t0=a.e.Zero(),this._t1=a.e.Zero(),this._t2=a.e.Zero()),a.a.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this.homogeneousRotationInUVTransform?(a.a.TranslationToRef(-this._cachedURotationCenter,-this._cachedVRotationCenter,-this._cachedWRotationCenter,a.c.Matrix[0]),a.a.TranslationToRef(this._cachedURotationCenter,this._cachedVRotationCenter,this._cachedWRotationCenter,a.c.Matrix[1]),a.a.ScalingToRef(this._cachedUScale,this._cachedVScale,0,a.c.Matrix[2]),a.a.TranslationToRef(this._cachedUOffset,this._cachedVOffset,0,a.c.Matrix[3]),a.c.Matrix[0].multiplyToRef(this._rowGenerationMatrix,this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.c.Matrix[1],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.c.Matrix[2],this._cachedTextureMatrix),this._cachedTextureMatrix.multiplyToRef(a.c.Matrix[3],this._cachedTextureMatrix),this._cachedTextureMatrix.setRowFromFloats(2,this._cachedTextureMatrix.m[12],this._cachedTextureMatrix.m[13],this._cachedTextureMatrix.m[14],1)):(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.a.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 i=this.getScene();return i?(i.markAllMaterialsAsDirty(c.a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(t)})),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.a.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=a.a.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.a.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.a.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var n=i.getProjectionMatrix();this._cachedProjectionMatrixId=n.updateFlag,n.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:a.a.IdentityToRef(this._cachedTextureMatrix)}return i.markAllMaterialsAsDirty(c.a.MATERIAL_TextureDirtyFlag,(function(t){return-1!==t.getActiveTextures().indexOf(e)})),this._cachedTextureMatrix},t.prototype.clone=function(){var e=this;return r.a.Clone((function(){return new t(e._texture?e._texture.url:null,e.getScene(),e._noMipmap,e._invertY,e.samplingMode,void 0,void 0,e._texture?e._texture._buffer:void 0)}),this)},t.prototype.serialize=function(){var i=this.name;t.SerializeBuffers||p.a.StartsWith(this.name,"data:")&&(this.name=""),p.a.StartsWith(this.name,"data:")&&this.url===this.name&&(this.url="");var n=e.prototype.serialize.call(this);return n?((t.SerializeBuffers||t.ForceSerializeBuffers)&&("string"==typeof this._buffer&&"data:"===this._buffer.substr(0,5)?(n.base64String=this._buffer,n.name=n.name.replace("data:","")):this.url&&p.a.StartsWith(this.url,"data:")&&this._buffer instanceof Uint8Array?n.base64String="data:image/png;base64,"+p.a.EncodeArrayBufferToBase64(this._buffer):t.ForceSerializeBuffers&&(n.base64String=_.a.GenerateBase64StringFromTexture(this))),n.invertY=this._invertY,n.samplingMode=this.samplingMode,this.name=i,n):null},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,n){if(e.customType){var o=d.a.Instantiate(e.customType).Parse(e,i,n);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,n);if(!e.name&&!e.isRenderTarget)return null;var a=function(){if(s&&s._texture&&(s._texture._cachedWrapU=null,s._texture._cachedWrapV=null,s._texture._cachedWrapR=null),e.samplingMode){var t=e.samplingMode;s&&s.samplingMode!==t&&s.updateSamplingMode(t)}if(s&&e.animations)for(var i=0;i<e.animations.length;i++){var n=e.animations[i],r=l.a.GetClass("BABYLON.Animation");r&&s.animations.push(r.Parse(n))}},s=r.a.Parse((function(){var r,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=f.a.FromArray(e.mirrorPlane),a(),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 a(),c}if(e.base64String)r=t.CreateFromBase64String(e.base64String,e.name,i,!o,e.invertY,void 0,a);else{var h=void 0;h=e.name&&e.name.indexOf("://")>0?e.name:n+e.name,(p.a.StartsWith(e.url,"data:")||t.UseSerializedUrlIfAny&&e.url)&&(h=e.url),r=new t(h,i,!o,e.invertY,void 0,a)}return r}),e,i);return s},t.CreateFromBase64String=function(e,i,n,r,o,a,s,l,u){return void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===l&&(l=null),void 0===u&&(u=c.a.TEXTUREFORMAT_RGBA),new t("data:"+i,n,r,o,a,s,l,e,!1,u)},t.LoadFromDataString=function(e,i,n,r,o,a,s,l,u,h){return void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!0),void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=c.a.TEXTUREFORMAT_RGBA),"data:"!==e.substr(0,5)&&(e="data:"+e),new t(e,n,o,a,s,l,u,i,r,h)},t.SerializeBuffers=!0,t.ForceSerializeBuffers=!1,t._CubeTextureParser=function(e,t,i){throw u.a.WarnImport("CubeTexture")},t._CreateMirror=function(e,t,i,n){throw u.a.WarnImport("MirrorTexture")},t._CreateRenderTargetTexture=function(e,t,i,n){throw u.a.WarnImport("RenderTargetTexture")},t.NEAREST_SAMPLINGMODE=c.a.TEXTURE_NEAREST_SAMPLINGMODE,t.NEAREST_NEAREST_MIPLINEAR=c.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.BILINEAR_SAMPLINGMODE=c.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPNEAREST=c.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TRILINEAR_SAMPLINGMODE=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.LINEAR_LINEAR_MIPLINEAR=c.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.NEAREST_NEAREST_MIPNEAREST=c.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.NEAREST_LINEAR_MIPNEAREST=c.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.NEAREST_LINEAR_MIPLINEAR=c.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.NEAREST_LINEAR=c.a.TEXTURE_NEAREST_LINEAR,t.NEAREST_NEAREST=c.a.TEXTURE_NEAREST_NEAREST,t.LINEAR_NEAREST_MIPNEAREST=c.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.LINEAR_NEAREST_MIPLINEAR=c.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.LINEAR_LINEAR=c.a.TEXTURE_LINEAR_LINEAR,t.LINEAR_NEAREST=c.a.TEXTURE_LINEAR_NEAREST,t.EXPLICIT_MODE=c.a.TEXTURE_EXPLICIT_MODE,t.SPHERICAL_MODE=c.a.TEXTURE_SPHERICAL_MODE,t.PLANAR_MODE=c.a.TEXTURE_PLANAR_MODE,t.CUBIC_MODE=c.a.TEXTURE_CUBIC_MODE,t.PROJECTION_MODE=c.a.TEXTURE_PROJECTION_MODE,t.SKYBOX_MODE=c.a.TEXTURE_SKYBOX_MODE,t.INVCUBIC_MODE=c.a.TEXTURE_INVCUBIC_MODE,t.EQUIRECTANGULAR_MODE=c.a.TEXTURE_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MODE=c.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=c.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.CLAMP_ADDRESSMODE=c.a.TEXTURE_CLAMP_ADDRESSMODE,t.WRAP_ADDRESSMODE=c.a.TEXTURE_WRAP_ADDRESSMODE,t.MIRROR_ADDRESSMODE=c.a.TEXTURE_MIRROR_ADDRESSMODE,t.UseSerializedUrlIfAny=!1,Object(n.c)([Object(r.c)()],t.prototype,"url",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uOffset",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vOffset",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uScale",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vScale",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uAng",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vAng",void 0),Object(n.c)([Object(r.c)()],t.prototype,"wAng",void 0),Object(n.c)([Object(r.c)()],t.prototype,"uRotationCenter",void 0),Object(n.c)([Object(r.c)()],t.prototype,"vRotationCenter",void 0),Object(n.c)([Object(r.c)()],t.prototype,"wRotationCenter",void 0),Object(n.c)([Object(r.c)()],t.prototype,"homogeneousRotationInUVTransform",void 0),Object(n.c)([Object(r.c)()],t.prototype,"isBlocking",null),t}(s.a);l.a.RegisteredTypes["BABYLON.Texture"]=m,r.a._TextureParser=m.Parse},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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,"b",(function(){return m})),i.d(t,"c",(function(){return g})),i.d(t,"a",(function(){return v}));var n=i(6),r=i(38),o=i(8),a=i(41),s=i(57),c=i(21),l=i(49),u=i(22),h=i(56),d=i(145),f=i(104),p=i(122),_=i(120),m=function(){function e(){}return Object.defineProperty(e,"BaseUrl",{get:function(){return h.a.BaseUrl},set:function(e){h.a.BaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DefaultRetryStrategy",{get:function(){return h.a.DefaultRetryStrategy},set:function(e){h.a.DefaultRetryStrategy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CorsBehavior",{get:function(){return h.a.CorsBehavior},set:function(e){h.a.CorsBehavior=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"UseFallbackTexture",{get:function(){return u.a.UseFallbackTexture},set:function(e){u.a.UseFallbackTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RegisteredExternalClasses",{get:function(){return p.a.RegisteredExternalClasses},set:function(e){p.a.RegisteredExternalClasses=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fallbackTexture",{get:function(){return u.a.FallbackTexture},set:function(e){u.a.FallbackTexture=e},enumerable:!1,configurable:!0}),e.FetchToRef=function(e,t,i,n,r,o){var a=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*n%n|0)*i);o.r=r[a]/255,o.g=r[a+1]/255,o.b=r[a+2]/255,o.a=r[a+3]/255},e.Mix=function(e,t,i){return e*(1-i)+t*i},e.Instantiate=function(e){return p.a.Instantiate(e)},e.Slice=function(e,t,i){return e.slice?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SliceToArray=function(e,t,i){return Array.isArray(e)?e.slice(t,i):Array.prototype.slice.call(e,t,i)},e.SetImmediate=function(e){f.a.SetImmediate(e)},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.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.MakeArray=function(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:null},e.GetPointerPrefix=function(e){var t="pointer";return r.a.IsWindowObjectExist()&&!window.PointerEvent&&r.a.IsNavigatorAvailable()&&!navigator.pointerEnabled&&(t="mouse"),!e._badDesktopOS||e._badOS||document&&"ontouchend"in document||(t="mouse"),t},e.SetCorsBehavior=function(e,t){h.a.SetCorsBehavior(e,t)},e.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},Object.defineProperty(e,"PreprocessUrl",{get:function(){return h.a.PreprocessUrl},set:function(e){h.a.PreprocessUrl=e},enumerable:!1,configurable:!0}),e.LoadImage=function(e,t,i,n,r){return h.a.LoadImage(e,t,i,n,r)},e.LoadFile=function(e,t,i,n,r,o){return h.a.LoadFile(e,t,i,n,r,o)},e.LoadFileAsync=function(e,t){return void 0===t&&(t=!0),new Promise((function(i,n){h.a.LoadFile(e,(function(e){i(e)}),void 0,void 0,t,(function(e,t){n(t)}))}))},e.LoadScript=function(e,t,i,n){if(r.a.IsWindowObjectExist()){var o=document.getElementsByTagName("head")[0],a=document.createElement("script");a.setAttribute("type","text/javascript"),a.setAttribute("src",e),n&&(a.id=n),a.onload=function(){t&&t()},a.onerror=function(t){i&&i("Unable to load script '"+e+"'",t)},o.appendChild(a)}},e.LoadScriptAsync=function(e,t){var i=this;return new Promise((function(t,n){i.LoadScript(e,(function(){t()}),(function(e,t){n(t)}))}))},e.ReadFileAsDataURL=function(e,t,i){var r=new FileReader,o={onCompleteObservable:new n.c,abort:function(){return r.abort()}};return r.onloadend=function(e){o.onCompleteObservable.notifyObservers(o)},r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e),o},e.ReadFile=function(e,t,i,n,r){return h.a.ReadFile(e,t,i,n,r)},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.DeepCopy=function(e,t,i,n){a.a.DeepCopy(e,t,i,n)},e.IsEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},e.RegisterTopRootEvents=function(e,t){for(var i=0;i<t.length;i++){var n=t[i];e.addEventListener(n.name,n.handler,!1);try{window.parent&&window.parent.addEventListener(n.name,n.handler,!1)}catch(e){}}},e.UnregisterTopRootEvents=function(e,t){for(var i=0;i<t.length;i++){var n=t[i];e.removeEventListener(n.name,n.handler);try{e.parent&&e.parent.removeEventListener(n.name,n.handler)}catch(e){}}},e.DumpFramebuffer=function(t,i,n,r,o,a){void 0===o&&(o="image/png");for(var s=4*t,c=i/2,l=n.readPixels(0,0,t,i),u=0;u<c;u++)for(var h=0;h<s;h++){var d=h+u*s,f=h+(i-u-1)*s,p=l[d];l[d]=l[f],l[f]=p}e._ScreenshotCanvas||(e._ScreenshotCanvas=document.createElement("canvas")),e._ScreenshotCanvas.width=t,e._ScreenshotCanvas.height=i;var _=e._ScreenshotCanvas.getContext("2d");if(_){var m=_.createImageData(t,i);m.data.set(l),_.putImageData(m,0,0),e.EncodeScreenshotCanvasData(r,o,a)}},e.ToBlob=function(e,t,i){void 0===i&&(i="image/png"),e.toBlob||(e.toBlob=function(e,t,i){var n=this;setTimeout((function(){for(var r=atob(n.toDataURL(t,i).split(",")[1]),o=r.length,a=new Uint8Array(o),s=0;s<o;s++)a[s]=r.charCodeAt(s);e(new Blob([a]))}))}),e.toBlob((function(e){t(e)}),i)},e.EncodeScreenshotCanvasData=function(t,i,n){(void 0===i&&(i="image/png"),t)?t(e._ScreenshotCanvas.toDataURL(i)):this.ToBlob(e._ScreenshotCanvas,(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),a=window.open("");if(!a)return;var s=a.document.createElement("img");s.onload=function(){URL.revokeObjectURL(o)},s.src=o,a.document.body.appendChild(s)}}),i)},e.Download=function(e,t){if(navigator&&navigator.msSaveBlob)navigator.msSaveBlob(e,t);else{var i=window.URL.createObjectURL(e),n=document.createElement("a");document.body.appendChild(n),n.style.display="none",n.href=i,n.download=t,n.addEventListener("click",(function(){n.parentElement&&n.parentElement.removeChild(n)})),n.click(),window.URL.revokeObjectURL(i)}},e.BackCompatCameraNoPreventDefault=function(e){return"boolean"==typeof e[0]?e[0]:"boolean"==typeof e[1]&&e[1]},e.CreateScreenshot=function(e,t,i,n,r){throw void 0===r&&(r="image/png"),c.a.WarnImport("ScreenshotTools")},e.CreateScreenshotAsync=function(e,t,i,n){throw void 0===n&&(n="image/png"),c.a.WarnImport("ScreenshotTools")},e.CreateScreenshotUsingRenderTarget=function(e,t,i,n,r,o,a,s){throw void 0===r&&(r="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),c.a.WarnImport("ScreenshotTools")},e.CreateScreenshotUsingRenderTargetAsync=function(e,t,i,n,r,o,a){throw void 0===n&&(n="image/png"),void 0===r&&(r=1),void 0===o&&(o=!1),c.a.WarnImport("ScreenshotTools")},e.RandomId=function(){return _.a.RandomId()},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,n=new Uint8Array(new ArrayBuffer(i)),r=0;r<i;r++)n[r]=t.charCodeAt(r);return n.buffer},e.GetAbsoluteUrl=function(e){var t=document.createElement("a");return t.href=e,t.href},Object.defineProperty(e,"errorsCount",{get:function(){return o.a.errorsCount},enumerable:!1,configurable:!0}),e.Log=function(e){o.a.Log(e)},e.Warn=function(e){o.a.Warn(e)},e.Error=function(e){o.a.Error(e)},Object.defineProperty(e,"LogCache",{get:function(){return o.a.LogCache},enumerable:!1,configurable:!0}),e.ClearLogCache=function(){o.a.ClearLogCache()},Object.defineProperty(e,"LogLevels",{set:function(e){o.a.LogLevels=e},enumerable:!1,configurable:!0}),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:!1,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(!r.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.timeEnd(t))},Object.defineProperty(e,"Now",{get:function(){return s.a.Now},enumerable:!1,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,n=e;i<n.length;i++){var r=n[i];if(t(r))return r}return null},e.getFullClassName=function(e,t){void 0===t&&(t=!1);var i=null,n=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){var r=t?e:Object.getPrototypeOf(e);i=r.constructor.__bjsclassName__,n=r.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(null!=n?n+".":"")+i:null},e.DelayAsync=function(e){return new Promise((function(t){setTimeout((function(){t()}),e)}))},e.IsSafari=function(){return/^((?!chrome|android).)*safari/i.test(navigator.userAgent)},e.UseCustomRequestHeaders=!1,e.CustomRequestHeaders=l.a.CustomRequestHeaders,e._tmpFloatArray=new Float32Array(1),e.GetDOMTextContent=r.a.GetDOMTextContent,e.NoneLogLevel=o.a.NoneLogLevel,e.MessageLogLevel=o.a.MessageLogLevel,e.WarningLogLevel=o.a.WarningLogLevel,e.ErrorLogLevel=o.a.ErrorLogLevel,e.AllLogLevel=o.a.AllLogLevel,e.IsWindowObjectExist=r.a.IsWindowObjectExist,e.PerformanceNoneLogLevel=0,e.PerformanceUserMarkLogLevel=1,e.PerformanceConsoleLogLevel=2,e.StartPerformanceCounter=e._StartPerformanceCounterDisabled,e.EndPerformanceCounter=e._EndPerformanceCounterDisabled,e}();function g(e,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}var v=function(){function e(e,t,i,n){void 0===n&&(n=0),this.iterations=e,this.index=n-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,n,r){void 0===r&&(r=0);var o=new e(t,i,n,r);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,i,n,r,o,a){return void 0===a&&(a=0),e.Run(Math.ceil(t/i),(function(e){o&&o()?e.breakLoop():setTimeout((function(){for(var r=0;r<i;++r){var a=e.index*i+r;if(a>=t)break;if(n(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),r)},e}();u.a.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",d.a.Apply()},function(e,t,i){"use strict";i.d(t,"a",(function(){return p}));var n=i(1),r=i(6),o=i(38),a=i(22),s=i(21),c=i(26),l=i(2),u=i(146),h=i(55),d=i(88),f=i(8),p=(i(123),i(129),i(124),function(e){function t(i,n,a,s){void 0===s&&(s=!1);var c=e.call(this,i,n,a,s)||this;if(c.enableOfflineSupport=!1,c.disableManifestCheck=!1,c.scenes=new Array,c.onNewSceneAddedObservable=new r.c,c.postProcesses=new Array,c.isPointerLock=!1,c.onResizeObservable=new r.c,c.onCanvasBlurObservable=new r.c,c.onCanvasFocusObservable=new r.c,c.onCanvasPointerOutObservable=new r.c,c.onBeginFrameObservable=new r.c,c.customAnimationFrameRequester=null,c.onEndFrameObservable=new r.c,c.onBeforeShaderCompilationObservable=new r.c,c.onAfterShaderCompilationObservable=new r.c,c._deterministicLockstep=!1,c._lockstepMaxSteps=4,c._timeStep=1/60,c._fps=60,c._deltaTime=0,c._drawCalls=new h.a,c.canvasTabIndex=1,c.disablePerformanceMonitorInBackground=!1,c._performanceMonitor=new u.a,t.Instances.push(c),!i)return c;if(a=c._creationOptions,i.getContext){var l=i;if(c._onCanvasFocus=function(){c.onCanvasFocusObservable.notifyObservers(c)},c._onCanvasBlur=function(){c.onCanvasBlurObservable.notifyObservers(c)},l.addEventListener("focus",c._onCanvasFocus),l.addEventListener("blur",c._onCanvasBlur),c._onBlur=function(){c.disablePerformanceMonitorInBackground&&c._performanceMonitor.disable(),c._windowIsBackground=!0},c._onFocus=function(){c.disablePerformanceMonitorInBackground&&c._performanceMonitor.enable(),c._windowIsBackground=!1},c._onCanvasPointerOut=function(e){c.onCanvasPointerOutObservable.notifyObservers(e)},l.addEventListener("pointerout",c._onCanvasPointerOut),o.a.IsWindowObjectExist()){var d=c.getHostWindow();d.addEventListener("blur",c._onBlur),d.addEventListener("focus",c._onFocus);var f=document;c._onFullscreenChange=function(){void 0!==f.fullscreen?c.isFullscreen=f.fullscreen:void 0!==f.mozFullScreen?c.isFullscreen=f.mozFullScreen:void 0!==f.webkitIsFullScreen?c.isFullscreen=f.webkitIsFullScreen:void 0!==f.msIsFullScreen&&(c.isFullscreen=f.msIsFullScreen),c.isFullscreen&&c._pointerLockRequested&&l&&t._RequestPointerlock(l)},document.addEventListener("fullscreenchange",c._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",c._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",c._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",c._onFullscreenChange,!1),c._onPointerLockChange=function(){c.isPointerLock=f.mozPointerLockElement===l||f.webkitPointerLockElement===l||f.msPointerLockElement===l||f.pointerLockElement===l},document.addEventListener("pointerlockchange",c._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",c._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",c._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",c._onPointerLockChange,!1),!t.audioEngine&&a.audioEngine&&t.AudioEngineFactory&&(t.audioEngine=t.AudioEngineFactory(c.getRenderingCanvas()))}c._connectVREvents(),c.enableOfflineSupport=void 0!==t.OfflineProviderFactory,a.doNotHandleTouchAction||c._disableTouchAction(),c._deterministicLockstep=!!a.deterministicLockstep,c._lockstepMaxSteps=a.lockstepMaxSteps||0,c._timeStep=a.timeStep||1/60}return c._prepareVRComponent(),a.autoEnableWebVR&&c.initWebVR(),c}return Object(n.d)(t,e),Object.defineProperty(t,"NpmPackage",{get:function(){return c.a.NpmPackage},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Version",{get:function(){return c.a.Version},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Instances",{get:function(){return a.a.Instances},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedEngine",{get:function(){return a.a.LastCreatedEngine},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LastCreatedScene",{get:function(){return a.a.LastCreatedScene},enumerable:!1,configurable:!0}),t.MarkAllMaterialsAsDirty=function(e,i){for(var n=0;n<t.Instances.length;n++)for(var r=t.Instances[n],o=0;o<r.scenes.length;o++)r.scenes[o].markAllMaterialsAsDirty(e,i)},t.DefaultLoadingScreenFactory=function(e){throw s.a.WarnImport("LoadingScreen")},Object.defineProperty(t.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!!t._RescalePostProcessFactory},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!1,configurable:!0}),t.prototype.getInputElement=function(){return this._renderingCanvas},t.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)},t.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},t.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},t.prototype.getInputElementClientRect=function(){return this._renderingCanvas?this.getInputElement().getBoundingClientRect():null},t.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},t.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},t.prototype.getTimeStep=function(){return 1e3*this._timeStep},t.prototype.generateMipMapsForCubemap=function(e,t){if(void 0===t&&(t=!0),e.generateMipMaps){var i=this._gl;this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,e,!0),i.generateMipmap(i.TEXTURE_CUBE_MAP),t&&this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)}},t.prototype.setState=function(e,t,i,n){void 0===t&&(t=0),void 0===n&&(n=!1),(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);var r=this.cullBackFaces?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==r||i)&&(this._depthCullingState.cullFace=r),this.setZOffset(t);var o=n?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==o||i)&&(this._depthCullingState.frontFace=o)},t.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},t.prototype.getZOffset=function(){return this._depthCullingState.zOffset},t.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},t.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},t.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},t.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},t.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},t.prototype.getStencilMask=function(){return this._stencilState.stencilMask},t.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},t.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},t.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},t.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},t.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},t.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},t.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},t.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},t.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},t.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},t.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},t.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},t.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},t.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},t.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},t.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},t.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},t.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},t.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},t.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},t.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},t.prototype.cacheStencilState=function(){this._cachedStencilBuffer=this.getStencilBuffer(),this._cachedStencilFunction=this.getStencilFunction(),this._cachedStencilMask=this.getStencilMask(),this._cachedStencilOperationPass=this.getStencilOperationPass(),this._cachedStencilOperationFail=this.getStencilOperationFail(),this._cachedStencilOperationDepthFail=this.getStencilOperationDepthFail(),this._cachedStencilReference=this.getStencilFunctionReference()},t.prototype.restoreStencilState=function(){this.setStencilFunction(this._cachedStencilFunction),this.setStencilMask(this._cachedStencilMask),this.setStencilBuffer(this._cachedStencilBuffer),this.setStencilOperationPass(this._cachedStencilOperationPass),this.setStencilOperationFail(this._cachedStencilOperationFail),this.setStencilOperationDepthFail(this._cachedStencilOperationDepthFail),this.setStencilFunctionReference(this._cachedStencilReference)},t.prototype.setDirectViewport=function(e,t,i,n){var r=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,n),r},t.prototype.scissorClear=function(e,t,i,n,r){this.enableScissor(e,t,i,n),this.clear(r,!0,!0,!0),this.disableScissor()},t.prototype.enableScissor=function(e,t,i,n){var r=this._gl;r.enable(r.SCISSOR_TEST),r.scissor(e,t,i,n)},t.prototype.disableScissor=function(){var e=this._gl;e.disable(e.SCISSOR_TEST)},t.prototype._reportDrawCall=function(){this._drawCalls.addCount(1,!1)},t.prototype.initWebVR=function(){throw s.a.WarnImport("WebVRCamera")},t.prototype._prepareVRComponent=function(){},t.prototype._connectVREvents=function(e,t){},t.prototype._submitVRFrame=function(){},t.prototype.disableVR=function(){},t.prototype.isVRPresenting=function(){return!1},t.prototype._requestVRFrame=function(){},t.prototype._loadFileAsync=function(e,t,i){var n=this;return new Promise((function(r,o){n._loadFile(e,(function(e){r(e)}),void 0,t,i,(function(e,t){o(t)}))}))},t.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null},t.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null},t.prototype.setDepthStencilTexture=function(e,t,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),i&&i.depthStencilTexture?this._setTexture(e,i,!1,!0):this._setTexture(e,null))},t.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t?t._textures.data[t._currentRenderTextureInd]:null)},t.prototype.setTextureFromPostProcessOutput=function(e,t){this._bindTexture(e,t?t._outputTexture:null)},t.prototype._rebuildBuffers=function(){for(var t=0,i=this.scenes;t<i.length;t++){var n=i[t];n.resetCachedMaterial(),n._rebuildGeometries(),n._rebuildTextures()}e.prototype._rebuildBuffers.call(this)},t.prototype._renderFrame=function(){for(var e=0;e<this._activeRenderLoops.length;e++){(0,this._activeRenderLoops[e])()}},t.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;!this.renderEvenInBackground&&this._windowIsBackground&&(e=!1),e&&(this.beginFrame(),this._renderViews()||this._renderFrame(),this.endFrame())}this._activeRenderLoops.length>0?this.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=this._queueNewFrame(this.customAnimationFrameRequester.renderFunction||this._boundRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this.isVRPresenting()?this._requestVRFrame():this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},t.prototype._renderViews=function(){return!1},t.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},t.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&t._RequestFullscreen(this._renderingCanvas))},t.prototype.exitFullscreen=function(){this.isFullscreen&&t._ExitFullscreen()},t.prototype.enterPointerlock=function(){this._renderingCanvas&&t._RequestPointerlock(this._renderingCanvas)},t.prototype.exitPointerlock=function(){t._ExitPointerlock()},t.prototype.beginFrame=function(){this._measureFps(),this.onBeginFrameObservable.notifyObservers(this),e.prototype.beginFrame.call(this)},t.prototype.endFrame=function(){e.prototype.endFrame.call(this),this._submitVRFrame(),this.onEndFrameObservable.notifyObservers(this)},t.prototype.resize=function(){this.isVRPresenting()||e.prototype.resize.call(this)},t.prototype.setSize=function(t,i){if(!this._renderingCanvas)return!1;if(!e.prototype.setSize.call(this,t,i))return!1;if(this.scenes){for(var n=0;n<this.scenes.length;n++)for(var r=this.scenes[n],o=0;o<r.cameras.length;o++){r.cameras[o]._currentRenderId=0}this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this)}return!0},t.prototype._deletePipelineContext=function(t){var i=t;i&&i.program&&i.transformFeedback&&(this.deleteTransformFeedback(i.transformFeedback),i.transformFeedback=null),e.prototype._deletePipelineContext.call(this,t)},t.prototype.createShaderProgram=function(t,i,n,r,o,a){void 0===a&&(a=null),o=o||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var s=e.prototype.createShaderProgram.call(this,t,i,n,r,o,a);return this.onAfterShaderCompilationObservable.notifyObservers(this),s},t.prototype._createShaderProgram=function(e,t,i,n,r){void 0===r&&(r=null);var o=n.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");if(n.attachShader(o,t),n.attachShader(o,i),this.webGLVersion>1&&r){var a=this.createTransformFeedback();this.bindTransformFeedback(a),this.setTranformFeedbackVaryings(o,r),e.transformFeedback=a}return n.linkProgram(o),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=n,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},t.prototype._releaseTexture=function(t){e.prototype._releaseTexture.call(this,t),this.scenes.forEach((function(e){e.postProcesses.forEach((function(e){e._outputTexture==t&&(e._outputTexture=null)})),e.cameras.forEach((function(e){e._postProcesses.forEach((function(e){e&&e._outputTexture==t&&(e._outputTexture=null)}))}))}))},t.prototype._rescaleTexture=function(e,i,n,r,o){var a=this;this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,this._gl.LINEAR),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._gl.CLAMP_TO_EDGE),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._gl.CLAMP_TO_EDGE);var s=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:l.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:l.a.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&t._RescalePostProcessFactory&&(this._rescalePostProcess=t._RescalePostProcessFactory(this)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(t){t._bindTexture("textureSampler",e)};var t=n;t||(t=a.scenes[a.scenes.length-1]),t.postProcessManager.directRender([a._rescalePostProcess],s,!0),a._bindTextureDirectly(a._gl.TEXTURE_2D,i,!0),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,r,0,0,i.width,i.height,0),a.unBindFramebuffer(s),a._releaseTexture(s),o&&o()}))},t.prototype.getFps=function(){return this._fps},t.prototype.getDeltaTime=function(){return this._deltaTime},t.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},t.prototype._uploadImageToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var r=this._gl,o=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),s=this._getRGBABufferInternalSizedFormat(e.type,a),c=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);var l=r.TEXTURE_2D;e.isCube&&(l=r.TEXTURE_CUBE_MAP_POSITIVE_X+i),r.texImage2D(l,n,s,a,o,t),this._bindTextureDirectly(c,null,!0)},t.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,this.getCaps().maxMSAASamples),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&&i.renderbufferStorageMultisample){var n=i.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=n,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var r=i.createRenderbuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,r),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,r),e._MSAARenderBuffer=r}else this._bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),this._bindUnboundFramebuffer(null),t},t.prototype.updateTextureComparisonFunction=function(e,t){if(1!==this.webGLVersion){var i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,l.a.LEQUAL),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,l.a.LEQUAL),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}else f.a.Error("WebGL 1 does not support texture comparison.")},t.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");var i=new d.a(t);return i.capacity=e,this.bindArrayBuffer(i),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),i},t.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},t.prototype._clientWaitAsync=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=10);var n=this._gl;return new Promise((function(r,o){var a=function(){var s=n.clientWaitSync(e,t,0);s!=n.WAIT_FAILED?s!=n.TIMEOUT_EXPIRED?r():setTimeout(a,i):o()};a()}))},t.prototype._readPixelsAsync=function(e,t,i,n,r,o,a){if(this._webGLVersion<2)throw new Error("_readPixelsAsync only work on WebGL2+");var s=this._gl,c=s.createBuffer();s.bindBuffer(s.PIXEL_PACK_BUFFER,c),s.bufferData(s.PIXEL_PACK_BUFFER,a.byteLength,s.STREAM_READ),s.readPixels(e,t,i,n,r,o,0),s.bindBuffer(s.PIXEL_PACK_BUFFER,null);var l=s.fenceSync(s.SYNC_GPU_COMMANDS_COMPLETE,0);return l?(s.flush(),this._clientWaitAsync(l,0,10).then((function(){return s.deleteSync(l),s.bindBuffer(s.PIXEL_PACK_BUFFER,c),s.getBufferSubData(s.PIXEL_PACK_BUFFER,0,a),s.bindBuffer(s.PIXEL_PACK_BUFFER,null),s.deleteBuffer(c),a}))):null},t.prototype.dispose=function(){for(this.hideLoadingUI(),this.onNewSceneAddedObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();1===t.Instances.length&&t.audioEngine&&t.audioEngine.dispose(),this.disableVR(),o.a.IsWindowObjectExist()&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._renderingCanvas&&(this._renderingCanvas.removeEventListener("focus",this._onCanvasFocus),this._renderingCanvas.removeEventListener("blur",this._onCanvasBlur),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasPointerOut)),o.a.IsDocumentAvailable()&&(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))),e.prototype.dispose.call(this);var i=t.Instances.indexOf(this);i>=0&&t.Instances.splice(i,1),this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear()},t.prototype._disableTouchAction=function(){this._renderingCanvas&&this._renderingCanvas.setAttribute&&(this._renderingCanvas.setAttribute("touch-action","none"),this._renderingCanvas.style.touchAction="none",this._renderingCanvas.style.msTouchAction="none")},t.prototype.displayLoadingUI=function(){if(o.a.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},t.prototype.hideLoadingUI=function(){if(o.a.IsWindowObjectExist()){var e=this._loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(t.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&this._renderingCanvas&&(this._loadingScreen=t.DefaultLoadingScreenFactory(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!1,configurable:!0}),t._RequestPointerlock=function(e){e.requestPointerLock=e.requestPointerLock||e.msRequestPointerLock||e.mozRequestPointerLock||e.webkitRequestPointerLock,e.requestPointerLock&&e.requestPointerLock()},t._ExitPointerlock=function(){var e=document;document.exitPointerLock=document.exitPointerLock||e.msExitPointerLock||e.mozExitPointerLock||e.webkitExitPointerLock,document.exitPointerLock&&document.exitPointerLock()},t._RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t._ExitFullscreen=function(){var e=document;document.exitFullscreen?document.exitFullscreen():e.mozCancelFullScreen?e.mozCancelFullScreen():e.webkitCancelFullScreen?e.webkitCancelFullScreen():e.msCancelFullScreen&&e.msCancelFullScreen()},t.ALPHA_DISABLE=l.a.ALPHA_DISABLE,t.ALPHA_ADD=l.a.ALPHA_ADD,t.ALPHA_COMBINE=l.a.ALPHA_COMBINE,t.ALPHA_SUBTRACT=l.a.ALPHA_SUBTRACT,t.ALPHA_MULTIPLY=l.a.ALPHA_MULTIPLY,t.ALPHA_MAXIMIZED=l.a.ALPHA_MAXIMIZED,t.ALPHA_ONEONE=l.a.ALPHA_ONEONE,t.ALPHA_PREMULTIPLIED=l.a.ALPHA_PREMULTIPLIED,t.ALPHA_PREMULTIPLIED_PORTERDUFF=l.a.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHA_INTERPOLATE=l.a.ALPHA_INTERPOLATE,t.ALPHA_SCREENMODE=l.a.ALPHA_SCREENMODE,t.DELAYLOADSTATE_NONE=l.a.DELAYLOADSTATE_NONE,t.DELAYLOADSTATE_LOADED=l.a.DELAYLOADSTATE_LOADED,t.DELAYLOADSTATE_LOADING=l.a.DELAYLOADSTATE_LOADING,t.DELAYLOADSTATE_NOTLOADED=l.a.DELAYLOADSTATE_NOTLOADED,t.NEVER=l.a.NEVER,t.ALWAYS=l.a.ALWAYS,t.LESS=l.a.LESS,t.EQUAL=l.a.EQUAL,t.LEQUAL=l.a.LEQUAL,t.GREATER=l.a.GREATER,t.GEQUAL=l.a.GEQUAL,t.NOTEQUAL=l.a.NOTEQUAL,t.KEEP=l.a.KEEP,t.REPLACE=l.a.REPLACE,t.INCR=l.a.INCR,t.DECR=l.a.DECR,t.INVERT=l.a.INVERT,t.INCR_WRAP=l.a.INCR_WRAP,t.DECR_WRAP=l.a.DECR_WRAP,t.TEXTURE_CLAMP_ADDRESSMODE=l.a.TEXTURE_CLAMP_ADDRESSMODE,t.TEXTURE_WRAP_ADDRESSMODE=l.a.TEXTURE_WRAP_ADDRESSMODE,t.TEXTURE_MIRROR_ADDRESSMODE=l.a.TEXTURE_MIRROR_ADDRESSMODE,t.TEXTUREFORMAT_ALPHA=l.a.TEXTUREFORMAT_ALPHA,t.TEXTUREFORMAT_LUMINANCE=l.a.TEXTUREFORMAT_LUMINANCE,t.TEXTUREFORMAT_LUMINANCE_ALPHA=l.a.TEXTUREFORMAT_LUMINANCE_ALPHA,t.TEXTUREFORMAT_RGB=l.a.TEXTUREFORMAT_RGB,t.TEXTUREFORMAT_RGBA=l.a.TEXTUREFORMAT_RGBA,t.TEXTUREFORMAT_RED=l.a.TEXTUREFORMAT_RED,t.TEXTUREFORMAT_R=l.a.TEXTUREFORMAT_R,t.TEXTUREFORMAT_RG=l.a.TEXTUREFORMAT_RG,t.TEXTUREFORMAT_RED_INTEGER=l.a.TEXTUREFORMAT_RED_INTEGER,t.TEXTUREFORMAT_R_INTEGER=l.a.TEXTUREFORMAT_R_INTEGER,t.TEXTUREFORMAT_RG_INTEGER=l.a.TEXTUREFORMAT_RG_INTEGER,t.TEXTUREFORMAT_RGB_INTEGER=l.a.TEXTUREFORMAT_RGB_INTEGER,t.TEXTUREFORMAT_RGBA_INTEGER=l.a.TEXTUREFORMAT_RGBA_INTEGER,t.TEXTURETYPE_UNSIGNED_BYTE=l.a.TEXTURETYPE_UNSIGNED_BYTE,t.TEXTURETYPE_UNSIGNED_INT=l.a.TEXTURETYPE_UNSIGNED_INT,t.TEXTURETYPE_FLOAT=l.a.TEXTURETYPE_FLOAT,t.TEXTURETYPE_HALF_FLOAT=l.a.TEXTURETYPE_HALF_FLOAT,t.TEXTURETYPE_BYTE=l.a.TEXTURETYPE_BYTE,t.TEXTURETYPE_SHORT=l.a.TEXTURETYPE_SHORT,t.TEXTURETYPE_UNSIGNED_SHORT=l.a.TEXTURETYPE_UNSIGNED_SHORT,t.TEXTURETYPE_INT=l.a.TEXTURETYPE_INT,t.TEXTURETYPE_UNSIGNED_INTEGER=l.a.TEXTURETYPE_UNSIGNED_INTEGER,t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=l.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=l.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=l.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=l.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,t.TEXTURETYPE_UNSIGNED_INT_24_8=l.a.TEXTURETYPE_UNSIGNED_INT_24_8,t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=l.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=l.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=l.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,t.TEXTURE_NEAREST_SAMPLINGMODE=l.a.TEXTURE_NEAREST_SAMPLINGMODE,t.TEXTURE_BILINEAR_SAMPLINGMODE=l.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.TEXTURE_TRILINEAR_SAMPLINGMODE=l.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.TEXTURE_NEAREST_NEAREST_MIPLINEAR=l.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR_MIPNEAREST=l.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TEXTURE_LINEAR_LINEAR_MIPLINEAR=l.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_NEAREST_MIPNEAREST=l.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPNEAREST=l.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPLINEAR=l.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_LINEAR=l.a.TEXTURE_NEAREST_LINEAR,t.TEXTURE_NEAREST_NEAREST=l.a.TEXTURE_NEAREST_NEAREST,t.TEXTURE_LINEAR_NEAREST_MIPNEAREST=l.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.TEXTURE_LINEAR_NEAREST_MIPLINEAR=l.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR=l.a.TEXTURE_LINEAR_LINEAR,t.TEXTURE_LINEAR_NEAREST=l.a.TEXTURE_LINEAR_NEAREST,t.TEXTURE_EXPLICIT_MODE=l.a.TEXTURE_EXPLICIT_MODE,t.TEXTURE_SPHERICAL_MODE=l.a.TEXTURE_SPHERICAL_MODE,t.TEXTURE_PLANAR_MODE=l.a.TEXTURE_PLANAR_MODE,t.TEXTURE_CUBIC_MODE=l.a.TEXTURE_CUBIC_MODE,t.TEXTURE_PROJECTION_MODE=l.a.TEXTURE_PROJECTION_MODE,t.TEXTURE_SKYBOX_MODE=l.a.TEXTURE_SKYBOX_MODE,t.TEXTURE_INVCUBIC_MODE=l.a.TEXTURE_INVCUBIC_MODE,t.TEXTURE_EQUIRECTANGULAR_MODE=l.a.TEXTURE_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=l.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.SCALEMODE_FLOOR=l.a.SCALEMODE_FLOOR,t.SCALEMODE_NEAREST=l.a.SCALEMODE_NEAREST,t.SCALEMODE_CEILING=l.a.SCALEMODE_CEILING,t._RescalePostProcessFactory=null,t}(c.a))},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1401298e-51);var n=e-t;return-i<=n&&n<=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 n=e.Repeat(i-t,360);return n>180&&(n-=360),n},e.PingPong=function(t,i){var n=e.Repeat(t,2*i);return i-Math.abs(n-i)},e.SmoothStep=function(t,i,n){var r=e.Clamp(n);return i*(r=-2*r*r*r+3*r*r)+t*(1-r)},e.MoveTowards=function(t,i,n){return Math.abs(i-t)<=n?i:t+e.Sign(i-t)*n},e.MoveTowardsAngle=function(t,i,n){var r=e.DeltaAngle(t,i),o=0;return-n<r&&r<n?o=i:(i=t+r,o=e.MoveTowards(t,i,n)),o},e.Lerp=function(e,t,i){return e+(t-e)*i},e.LerpAngle=function(t,i,n){var r=e.Repeat(i-t,360);return r>180&&(r-=360),t+r*e.Clamp(n)},e.InverseLerp=function(t,i,n){return t!=i?e.Clamp((n-t)/(i-t)):0},e.Hermite=function(e,t,i,n,r){var o=r*r,a=r*o;return e*(2*a-3*o+1)+i*(-2*a+3*o)+t*(a-2*o+r)+n*(a-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 h}));var n=i(8),r=i(20),o=i(22),a=i(4),s=i(48),c=i(2),l=i(9),u=i(119),h=function(){function e(){}return e.BindEyePosition=function(e,t,i){if(void 0===i&&(i="vEyePosition"),t._forcedViewPosition)e.setVector3(i,t._forcedViewPosition);else{var n=t.activeCamera.globalPosition;n||(n=t.activeCamera.devicePosition),e.setVector3(i,t._mirroredCameraPosition?t._mirroredCameraPosition:n)}},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 n=e.getTextureMatrix();t.updateMatrix(i+"Matrix",n)},e.GetFogState=function(e,t){return t.fogEnabled&&e.applyFog&&t.fogMode!==r.a.FOGMODE_NONE},e.PrepareDefinesForMisc=function(e,t,i,n,r,o,a){a._areMiscDirty&&(a.LOGARITHMICDEPTH=i,a.POINTSIZE=n,a.FOG=r&&this.GetFogState(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=o)},e.PrepareDefinesForFrameBoundValues=function(e,t,i,n,r,o){void 0===r&&(r=null),void 0===o&&(o=!1);var a,s,c,l,u,h,d=!1;a=null==r?void 0!==e.clipPlane&&null!==e.clipPlane:r,s=null==r?void 0!==e.clipPlane2&&null!==e.clipPlane2:r,c=null==r?void 0!==e.clipPlane3&&null!==e.clipPlane3:r,l=null==r?void 0!==e.clipPlane4&&null!==e.clipPlane4:r,u=null==r?void 0!==e.clipPlane5&&null!==e.clipPlane5:r,h=null==r?void 0!==e.clipPlane6&&null!==e.clipPlane6:r,i.CLIPPLANE!==a&&(i.CLIPPLANE=a,d=!0),i.CLIPPLANE2!==s&&(i.CLIPPLANE2=s,d=!0),i.CLIPPLANE3!==c&&(i.CLIPPLANE3=c,d=!0),i.CLIPPLANE4!==l&&(i.CLIPPLANE4=l,d=!0),i.CLIPPLANE5!==u&&(i.CLIPPLANE5=u,d=!0),i.CLIPPLANE6!==h&&(i.CLIPPLANE6=h,d=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,d=!0),i.INSTANCES!==n&&(i.INSTANCES=n,d=!0),i.THIN_INSTANCES!==o&&(i.THIN_INSTANCES=o,d=!0),d&&i.markAsUnprocessed()},e.PrepareDefinesForBones=function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;var i=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&i)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!i&&void 0;var n=e.getScene().prePassRenderer;if(n&&n.enabled){var r=-1===n.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=r}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0},e.PrepareDefinesForMorphTargets=function(e,t){var i=e.morphTargetManager;i?(t.MORPHTARGETS_UV=i.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=i.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=i.supportsNormals&&t.NORMAL,t.MORPHTARGETS=i.numInfluencers>0,t.NUM_MORPH_INFLUENCERS=i.numInfluencers):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)},e.PrepareDefinesForAttributes=function(e,t,i,n,r,o){if(void 0===r&&(r=!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}return n&&this.PrepareDefinesForBones(e,t),r&&this.PrepareDefinesForMorphTargets(e,t),!0},e.PrepareDefinesForMultiview=function(e,t){if(e.activeCamera){var i=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=i&&t.markAsUnprocessed()}},e.PrepareDefinesForPrePass=function(e,t,i){var n=t.PREPASS;if(t._arePrePassDirty){var r=[{type:c.a.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:c.a.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:c.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:c.a.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:c.a.PREPASS_ALBEDO_TEXTURE_TYPE,define:"PREPASS_ALBEDO",index:"PREPASS_ALBEDO_INDEX"},{type:c.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,define:"PREPASS_DEPTHNORMAL",index:"PREPASS_DEPTHNORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&i){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount;for(var o=0;o<r.length;o++){var a=e.prePassRenderer.getIndex(r[o].type);-1!==a?(t[r[o].define]=!0,t[r[o].index]=a):t[r[o].define]=!1}}else{t.PREPASS=!1;for(o=0;o<r.length;o++)t[r[o].define]=!1}t.PREPASS!=n&&(t.markAsUnprocessed(),t.markAsImageProcessingDirty())}},e.PrepareDefinesForLight=function(e,t,i,n,r,o,a){switch(a.needNormals=!0,void 0===r["LIGHT"+n]&&(a.needRebuild=!0),r["LIGHT"+n]=!0,r["SPOTLIGHT"+n]=!1,r["HEMILIGHT"+n]=!1,r["POINTLIGHT"+n]=!1,r["DIRLIGHT"+n]=!1,i.prepareLightSpecificDefines(r,n),r["LIGHT_FALLOFF_PHYSICAL"+n]=!1,r["LIGHT_FALLOFF_GLTF"+n]=!1,r["LIGHT_FALLOFF_STANDARD"+n]=!1,i.falloffType){case s.a.FALLOFF_GLTF:r["LIGHT_FALLOFF_GLTF"+n]=!0;break;case s.a.FALLOFF_PHYSICAL:r["LIGHT_FALLOFF_PHYSICAL"+n]=!0;break;case s.a.FALLOFF_STANDARD:r["LIGHT_FALLOFF_STANDARD"+n]=!0}if(o&&!i.specular.equalsFloats(0,0,0)&&(a.specularEnabled=!0),r["SHADOW"+n]=!1,r["SHADOWCSM"+n]=!1,r["SHADOWCSMDEBUG"+n]=!1,r["SHADOWCSMNUM_CASCADES"+n]=!1,r["SHADOWCSMUSESHADOWMAXZ"+n]=!1,r["SHADOWCSMNOBLEND"+n]=!1,r["SHADOWCSM_RIGHTHANDED"+n]=!1,r["SHADOWPCF"+n]=!1,r["SHADOWPCSS"+n]=!1,r["SHADOWPOISSON"+n]=!1,r["SHADOWESM"+n]=!1,r["SHADOWCLOSEESM"+n]=!1,r["SHADOWCUBE"+n]=!1,r["SHADOWLOWQUALITY"+n]=!1,r["SHADOWMEDIUMQUALITY"+n]=!1,t&&t.receiveShadows&&e.shadowsEnabled&&i.shadowEnabled){var c=i.getShadowGenerator();if(c){var l=c.getShadowMap();l&&l.renderList&&l.renderList.length>0&&(a.shadowEnabled=!0,c.prepareDefines(r,n))}}i.lightmapMode!=s.a.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+n]=!0,r["LIGHTMAPNOSPECULAR"+n]=i.lightmapMode==s.a.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+n]=!1,r["LIGHTMAPNOSPECULAR"+n]=!1)},e.PrepareDefinesForLights=function(e,t,i,n,r,o){if(void 0===r&&(r=4),void 0===o&&(o=!1),!i._areLightsDirty)return i._needNormals;var a=0,s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var c=0,l=t.lightSources;c<l.length;c++){var u=l[c];if(this.PrepareDefinesForLight(e,t,u,a,i,n,s),++a===r)break}i.SPECULARTERM=s.specularEnabled,i.SHADOWS=s.shadowEnabled;for(var h=a;h<r;h++)void 0!==i["LIGHT"+h]&&(i["LIGHT"+h]=!1,i["HEMILIGHT"+h]=!1,i["POINTLIGHT"+h]=!1,i["DIRLIGHT"+h]=!1,i["SPOTLIGHT"+h]=!1,i["SHADOW"+h]=!1,i["SHADOWCSM"+h]=!1,i["SHADOWCSMDEBUG"+h]=!1,i["SHADOWCSMNUM_CASCADES"+h]=!1,i["SHADOWCSMUSESHADOWMAXZ"+h]=!1,i["SHADOWCSMNOBLEND"+h]=!1,i["SHADOWCSM_RIGHTHANDED"+h]=!1,i["SHADOWPCF"+h]=!1,i["SHADOWPCSS"+h]=!1,i["SHADOWPOISSON"+h]=!1,i["SHADOWESM"+h]=!1,i["SHADOWCLOSEESM"+h]=!1,i["SHADOWCUBE"+h]=!1,i["SHADOWLOWQUALITY"+h]=!1,i["SHADOWMEDIUMQUALITY"+h]=!1);var d=e.getEngine().getCaps();return void 0===i.SHADOWFLOAT&&(s.needRebuild=!0),i.SHADOWFLOAT=s.shadowEnabled&&(d.textureFloatRender&&d.textureFloatLinearFiltering||d.textureHalfFloatRender&&d.textureHalfFloatLinearFiltering),i.LIGHTMAPEXCLUDED=s.lightmapMode,s.needRebuild&&i.rebuild(),s.needNormals},e.PrepareUniformsAndSamplersForLight=function(e,t,i,n,r,o){void 0===r&&(r=null),void 0===o&&(o=!1),r&&r.push("Light"+e),o||(t.push("vLightData"+e,"vLightDiffuse"+e,"vLightSpecular"+e,"vLightDirection"+e,"vLightFalloff"+e,"vLightGround"+e,"lightMatrix"+e,"shadowsInfo"+e,"depthValues"+e),i.push("shadowSampler"+e),i.push("depthSampler"+e),t.push("viewFrustumZ"+e,"cascadeBlendFactor"+e,"lightSizeUVCorrection"+e,"depthCorrection"+e,"penumbraDarkness"+e,"frustumLengths"+e),n&&(i.push("projectionLightSampler"+e),t.push("textureProjectionMatrix"+e)))},e.PrepareUniformsAndSamplersList=function(e,t,i,n){var r;void 0===n&&(n=4);var o=null;if(e.uniformsNames){var a=e;r=a.uniformsNames,o=a.uniformBuffersNames,t=a.samplers,i=a.defines,n=a.maxSimultaneousLights||0}else r=e,t||(t=[]);for(var s=0;s<n&&i["LIGHT"+s];s++)this.PrepareUniformsAndSamplersForLight(s,r,t,i["PROJECTEDLIGHTTEXTURE"+s],o);i.NUM_MORPH_INFLUENCERS&&r.push("morphTargetInfluences")},e.HandleFallbacksForShadows=function(e,t,i,n){void 0===i&&(i=4),void 0===n&&(n=0);for(var r=0,o=0;o<i&&e["LIGHT"+o];o++)o>0&&(r=n+o,t.addFallback(r,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(n,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(n,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(n,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(n,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(n,"SHADOWESM"+o),e["SHADOWCLOSEESM"+o]&&t.addFallback(n,"SHADOWCLOSEESM"+o));return r++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,i){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=i,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,i){var r=i.NUM_MORPH_INFLUENCERS;if(r>0&&o.a.LastCreatedEngine)for(var s=o.a.LastCreatedEngine.getCaps().maxVertexAttribs,c=t.morphTargetManager,l=c&&c.supportsNormals&&i.NORMAL,u=c&&c.supportsTangents&&i.TANGENT,h=c&&c.supportsUVs&&i.UV1,d=0;d<r;d++)e.push(a.b.PositionKind+d),l&&e.push(a.b.NormalKind+d),u&&e.push(a.b.TangentKind+d),h&&e.push(a.b.UVKind+"_"+d),e.length>s&&n.a.Error("Cannot add more vertex attributes for mesh "+t.name)},e.PrepareAttributesForBones=function(e,t,i,n){i.NUM_BONE_INFLUENCERS>0&&(n.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||t.THIN_INSTANCES)&&this.PushAttributesForInstances(e)},e.PushAttributesForInstances=function(e){e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3")},e.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},e.BindLight=function(e,t,i,n,r,o){void 0===o&&(o=!1),e._bindLight(t,i,n,r,o)},e.BindLights=function(e,t,i,n,r,o){void 0===r&&(r=4),void 0===o&&(o=!1);for(var a=Math.min(t.lightSources.length,r),s=0;s<a;s++){var c=t.lightSources[s];this.BindLight(c,s,e,i,"boolean"==typeof n?n:n.SPECULARTERM,o)}},e.BindFogParameters=function(e,t,i,n){void 0===n&&(n=!1),e.fogEnabled&&t.applyFog&&e.fogMode!==r.a.FOGMODE_NONE&&(i.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),n?(e.fogColor.toLinearSpaceToRef(this._tempFogColor),i.setColor3("vFogColor",this._tempFogColor)):i.setColor3("vFogColor",e.fogColor))},e.BindBonesParameters=function(t,i,n){if(i&&t&&(t.computeBonesUsingShaders&&i._bonesComputationForcedToCPU&&(t.computeBonesUsingShaders=!1),t.useBones&&t.computeBonesUsingShaders&&t.skeleton)){var r=t.skeleton;if(r.isUsingTextureForMatrices&&i.getUniformIndex("boneTextureWidth")>-1){var o=r.getTransformMatrixTexture(t);i.setTexture("boneSampler",o),i.setFloat("boneTextureWidth",4*(r.bones.length+1))}else{var a=r.getTransformMatrices(t);a&&(i.setMatrices("mBones",a),n&&t.getScene().prePassRenderer&&t.getScene().prePassRenderer.getIndex(c.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(n.previousBones[t.uniqueId]&&i.setMatrices("mPreviousBones",n.previousBones[t.uniqueId]),e._CopyBonesTransformationMatrices(a,n.previousBones[t.uniqueId])))}}},e._CopyBonesTransformationMatrices=function(e,t){return t.set(e),t},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){u.a.BindClipPlane(e,t)},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._tempFogColor=l.a.Black(),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(0),r=i(4),o=i(21),a=i(9),s=i(8),c=function(){function e(){}return e.prototype.set=function(e,t){switch(e.length||s.a.Warn("Setting vertex data kind '"+t+"' with an empty array"),t){case r.b.PositionKind:this.positions=e;break;case r.b.NormalKind:this.normals=e;break;case r.b.TangentKind:this.tangents=e;break;case r.b.UVKind:this.uvs=e;break;case r.b.UV2Kind:this.uvs2=e;break;case r.b.UV3Kind:this.uvs3=e;break;case r.b.UV4Kind:this.uvs4=e;break;case r.b.UV5Kind:this.uvs5=e;break;case r.b.UV6Kind:this.uvs6=e;break;case r.b.ColorKind:this.colors=e;break;case r.b.MatricesIndicesKind:this.matricesIndices=e;break;case r.b.MatricesWeightsKind:this.matricesWeights=e;break;case r.b.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case r.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(r.b.PositionKind,this.positions,t),this.normals&&e.setVerticesData(r.b.NormalKind,this.normals,t),this.tangents&&e.setVerticesData(r.b.TangentKind,this.tangents,t),this.uvs&&e.setVerticesData(r.b.UVKind,this.uvs,t),this.uvs2&&e.setVerticesData(r.b.UV2Kind,this.uvs2,t),this.uvs3&&e.setVerticesData(r.b.UV3Kind,this.uvs3,t),this.uvs4&&e.setVerticesData(r.b.UV4Kind,this.uvs4,t),this.uvs5&&e.setVerticesData(r.b.UV5Kind,this.uvs5,t),this.uvs6&&e.setVerticesData(r.b.UV6Kind,this.uvs6,t),this.colors&&e.setVerticesData(r.b.ColorKind,this.colors,t),this.matricesIndices&&e.setVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t),this.matricesWeights&&e.setVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t),this.matricesIndicesExtra&&e.setVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),this.matricesWeightsExtra&&e.setVerticesData(r.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(r.b.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(r.b.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(r.b.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(r.b.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(r.b.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(r.b.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(r.b.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(r.b.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(r.b.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(r.b.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(r.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this},e.prototype.transform=function(e){var t,i=e.determinant()<0,r=n.e.Zero();if(this.positions){var o=n.e.Zero();for(t=0;t<this.positions.length;t+=3)n.e.FromArrayToRef(this.positions,t,o),n.e.TransformCoordinatesToRef(o,e,r),this.positions[t]=r.x,this.positions[t+1]=r.y,this.positions[t+2]=r.z}if(this.normals){var a=n.e.Zero();for(t=0;t<this.normals.length;t+=3)n.e.FromArrayToRef(this.normals,t,a),n.e.TransformNormalToRef(a,e,r),this.normals[t]=r.x,this.normals[t+1]=r.y,this.normals[t+2]=r.z}if(this.tangents){var s=n.f.Zero(),c=n.f.Zero();for(t=0;t<this.tangents.length;t+=4)n.f.FromArrayToRef(this.tangents,t,s),n.f.TransformNormalToRef(s,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 n=this.indices.length+e.indices.length,r=t||this.indices instanceof Uint32Array?new Uint32Array(n):new Uint16Array(n);r.set(this.indices);for(var o=this.indices.length,a=0;a<e.indices.length;a++)r[o+a]=e.indices[a]+i;this.indices=r}else for(a=0;a<e.indices.length;a++)this.indices.push(e.indices[a]+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,n=e instanceof Float32Array,r=t instanceof Float32Array;if(n){var o=new Float32Array(i);return o.set(e),o.set(t,e.length),o}if(r){var a=e.slice(0),s=0;for(i=t.length;s<i;s++)a.push(t[s]);return a}return e.concat(t)},e.prototype._validate=function(){if(!this.positions)throw new Error("Positions are required");var e=function(e,t){var i=r.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(r.b.PositionKind,this.positions),i=function(i,n){var r=e(i,n);if(r!==t)throw new Error("The "+i+"s element count ("+r+") does not match the positions count ("+t+")")};this.normals&&i(r.b.NormalKind,this.normals),this.tangents&&i(r.b.TangentKind,this.tangents),this.uvs&&i(r.b.UVKind,this.uvs),this.uvs2&&i(r.b.UV2Kind,this.uvs2),this.uvs3&&i(r.b.UV3Kind,this.uvs3),this.uvs4&&i(r.b.UV4Kind,this.uvs4),this.uvs5&&i(r.b.UV5Kind,this.uvs5),this.uvs6&&i(r.b.UV6Kind,this.uvs6),this.colors&&i(r.b.ColorKind,this.colors),this.matricesIndices&&i(r.b.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&i(r.b.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&i(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&i(r.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,n){return e._ExtractFrom(t,i,n)},e.ExtractFromGeometry=function(t,i,n){return e._ExtractFrom(t,i,n)},e._ExtractFrom=function(t,i,n){var o=new e;return t.isVerticesDataPresent(r.b.PositionKind)&&(o.positions=t.getVerticesData(r.b.PositionKind,i,n)),t.isVerticesDataPresent(r.b.NormalKind)&&(o.normals=t.getVerticesData(r.b.NormalKind,i,n)),t.isVerticesDataPresent(r.b.TangentKind)&&(o.tangents=t.getVerticesData(r.b.TangentKind,i,n)),t.isVerticesDataPresent(r.b.UVKind)&&(o.uvs=t.getVerticesData(r.b.UVKind,i,n)),t.isVerticesDataPresent(r.b.UV2Kind)&&(o.uvs2=t.getVerticesData(r.b.UV2Kind,i,n)),t.isVerticesDataPresent(r.b.UV3Kind)&&(o.uvs3=t.getVerticesData(r.b.UV3Kind,i,n)),t.isVerticesDataPresent(r.b.UV4Kind)&&(o.uvs4=t.getVerticesData(r.b.UV4Kind,i,n)),t.isVerticesDataPresent(r.b.UV5Kind)&&(o.uvs5=t.getVerticesData(r.b.UV5Kind,i,n)),t.isVerticesDataPresent(r.b.UV6Kind)&&(o.uvs6=t.getVerticesData(r.b.UV6Kind,i,n)),t.isVerticesDataPresent(r.b.ColorKind)&&(o.colors=t.getVerticesData(r.b.ColorKind,i,n)),t.isVerticesDataPresent(r.b.MatricesIndicesKind)&&(o.matricesIndices=t.getVerticesData(r.b.MatricesIndicesKind,i,n)),t.isVerticesDataPresent(r.b.MatricesWeightsKind)&&(o.matricesWeights=t.getVerticesData(r.b.MatricesWeightsKind,i,n)),t.isVerticesDataPresent(r.b.MatricesIndicesExtraKind)&&(o.matricesIndicesExtra=t.getVerticesData(r.b.MatricesIndicesExtraKind,i,n)),t.isVerticesDataPresent(r.b.MatricesWeightsExtraKind)&&(o.matricesWeightsExtra=t.getVerticesData(r.b.MatricesWeightsExtraKind,i,n)),o.indices=t.getIndices(i,n),o},e.CreateRibbon=function(e){throw o.a.WarnImport("ribbonBuilder")},e.CreateBox=function(e){throw o.a.WarnImport("boxBuilder")},e.CreateTiledBox=function(e){throw o.a.WarnImport("tiledBoxBuilder")},e.CreateTiledPlane=function(e){throw o.a.WarnImport("tiledPlaneBuilder")},e.CreateSphere=function(e){throw o.a.WarnImport("sphereBuilder")},e.CreateCylinder=function(e){throw o.a.WarnImport("cylinderBuilder")},e.CreateTorus=function(e){throw o.a.WarnImport("torusBuilder")},e.CreateLineSystem=function(e){throw o.a.WarnImport("linesBuilder")},e.CreateDashedLines=function(e){throw o.a.WarnImport("linesBuilder")},e.CreateGround=function(e){throw o.a.WarnImport("groundBuilder")},e.CreateTiledGround=function(e){throw o.a.WarnImport("groundBuilder")},e.CreateGroundFromHeightMap=function(e){throw o.a.WarnImport("groundBuilder")},e.CreatePlane=function(e){throw o.a.WarnImport("planeBuilder")},e.CreateDisc=function(e){throw o.a.WarnImport("discBuilder")},e.CreatePolygon=function(e,t,i,n,r,a,s){throw o.a.WarnImport("polygonBuilder")},e.CreateIcoSphere=function(e){throw o.a.WarnImport("icoSphereBuilder")},e.CreatePolyhedron=function(e){throw o.a.WarnImport("polyhedronBuilder")},e.CreateCapsule=function(e){throw void 0===e&&(e={orientation:n.e.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}),o.a.WarnImport("capsuleBuilder")},e.CreateTorusKnot=function(e){throw o.a.WarnImport("torusKnotBuilder")},e.ComputeNormals=function(e,t,i,r){var o=0,a=0,s=0,c=0,l=0,u=0,h=0,d=0,f=0,p=0,_=0,m=0,g=0,v=0,b=0,y=0,T=0,E=0,S=0,A=0,P=!1,C=!1,R=!1,x=!1,O=1,M=0,I=null;if(r&&(P=!!r.facetNormals,C=!!r.facetPositions,R=!!r.facetPartitioning,O=!0===r.useRightHandedSystem?-1:1,M=r.ratio||0,x=!!r.depthSort,I=r.distanceTo,x)){void 0===I&&(I=n.e.Zero());var D=r.depthSortedFacets}var N=0,L=0,w=0,F=0;if(R&&r&&r.bbSize){var B=0,U=0,V=0,k=0,z=0,G=0,j=0,W=0,H=0,X=0,Y=0,K=0,Q=0,q=0,Z=0,J=0,$=r.bbSize.x>r.bbSize.y?r.bbSize.x:r.bbSize.y;$=$>r.bbSize.z?$:r.bbSize.z,N=r.subDiv.X*M/r.bbSize.x,L=r.subDiv.Y*M/r.bbSize.y,w=r.subDiv.Z*M/r.bbSize.z,F=r.subDiv.max*r.subDiv.max,r.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(g=(m=3*t[3*o])+1,v=m+2,y=(b=3*t[3*o+1])+1,T=b+2,S=(E=3*t[3*o+2])+1,A=E+2,a=e[m]-e[b],s=e[g]-e[y],c=e[v]-e[T],l=e[E]-e[b],u=e[S]-e[y],d=O*(s*(h=e[A]-e[T])-c*u),f=O*(c*l-a*h),p=O*(a*u-s*l),d/=_=0===(_=Math.sqrt(d*d+f*f+p*p))?1:_,f/=_,p/=_,P&&r&&(r.facetNormals[o].x=d,r.facetNormals[o].y=f,r.facetNormals[o].z=p),C&&r&&(r.facetPositions[o].x=(e[m]+e[b]+e[E])/3,r.facetPositions[o].y=(e[g]+e[y]+e[S])/3,r.facetPositions[o].z=(e[v]+e[T]+e[A])/3),R&&r&&(B=Math.floor((r.facetPositions[o].x-r.bInfo.minimum.x*M)*N),U=Math.floor((r.facetPositions[o].y-r.bInfo.minimum.y*M)*L),V=Math.floor((r.facetPositions[o].z-r.bInfo.minimum.z*M)*w),k=Math.floor((e[m]-r.bInfo.minimum.x*M)*N),z=Math.floor((e[g]-r.bInfo.minimum.y*M)*L),G=Math.floor((e[v]-r.bInfo.minimum.z*M)*w),j=Math.floor((e[b]-r.bInfo.minimum.x*M)*N),W=Math.floor((e[y]-r.bInfo.minimum.y*M)*L),H=Math.floor((e[T]-r.bInfo.minimum.z*M)*w),X=Math.floor((e[E]-r.bInfo.minimum.x*M)*N),Y=Math.floor((e[S]-r.bInfo.minimum.y*M)*L),K=Math.floor((e[A]-r.bInfo.minimum.z*M)*w),q=k+r.subDiv.max*z+F*G,Z=j+r.subDiv.max*W+F*H,J=X+r.subDiv.max*Y+F*K,Q=B+r.subDiv.max*U+F*V,r.facetPartitioning[Q]=r.facetPartitioning[Q]?r.facetPartitioning[Q]:new Array,r.facetPartitioning[q]=r.facetPartitioning[q]?r.facetPartitioning[q]:new Array,r.facetPartitioning[Z]=r.facetPartitioning[Z]?r.facetPartitioning[Z]:new Array,r.facetPartitioning[J]=r.facetPartitioning[J]?r.facetPartitioning[J]:new Array,r.facetPartitioning[q].push(o),Z!=q&&r.facetPartitioning[Z].push(o),J!=Z&&J!=q&&r.facetPartitioning[J].push(o),Q!=q&&Q!=Z&&Q!=J&&r.facetPartitioning[Q].push(o)),x&&r&&r.facetPositions){var te=D[o];te.ind=3*o,te.sqDistance=n.e.DistanceSquared(r.facetPositions[o],I)}i[m]+=d,i[g]+=f,i[v]+=p,i[b]+=d,i[y]+=f,i[T]+=p,i[E]+=d,i[S]+=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,r,o,a,s,c){var l,u,h=r.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=r[l],r[l]=r[l+2],r[l+2]=f;for(u=0;u<d;u++)o[u]=-o[u];break;case e.DOUBLESIDE:for(var p=i.length,_=p/3,m=0;m<p;m++)i[p+m]=i[m];for(l=0;l<h;l+=3)r[l+h]=r[l+2]+_,r[l+1+h]=r[l+1]+_,r[l+2+h]=r[l]+_;for(u=0;u<d;u++)o[d+u]=-o[u];var g=a.length,v=0;for(v=0;v<g;v++)a[v+g]=a[v];for(s=s||new n.f(0,0,1,1),c=c||new n.f(0,0,1,1),v=0,l=0;l<g/2;l++)a[v]=s.x+(s.z-s.x)*a[v],a[v+1]=s.y+(s.w-s.y)*a[v+1],a[v+g]=c.x+(c.z-c.x)*a[v+g],a[v+g+1]=c.y+(c.w-c.y)*a[v+g+1],v+=2}},e.ImportVertexData=function(t,i){var n=new e,o=t.positions;o&&n.set(o,r.b.PositionKind);var s=t.normals;s&&n.set(s,r.b.NormalKind);var c=t.tangents;c&&n.set(c,r.b.TangentKind);var l=t.uvs;l&&n.set(l,r.b.UVKind);var u=t.uv2s;u&&n.set(u,r.b.UV2Kind);var h=t.uv3s;h&&n.set(h,r.b.UV3Kind);var d=t.uv4s;d&&n.set(d,r.b.UV4Kind);var f=t.uv5s;f&&n.set(f,r.b.UV5Kind);var p=t.uv6s;p&&n.set(p,r.b.UV6Kind);var _=t.colors;_&&n.set(a.b.CheckColors4(_,o.length/3),r.b.ColorKind);var m=t.matricesIndices;m&&n.set(m,r.b.MatricesIndicesKind);var g=t.matricesWeights;g&&n.set(g,r.b.MatricesWeightsKind);var v=t.indices;v&&(n.indices=v),i.setAllVerticesData(n,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 r})),i.d(t,"b",(function(){return o}));var n=i(1),r=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_PREPASSRENDERER="PrePassRenderer",e.NAME_DEPTHRENDERER="DepthRenderer",e.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",e.NAME_SPRITE="Sprite",e.NAME_SUBSURFACE="SubSurface",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_PREACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,e.STEP_BEFORECAMERADRAW_EFFECTLAYER=0,e.STEP_BEFORECAMERADRAW_LAYER=1,e.STEP_BEFORECAMERADRAW_PREPASS=2,e.STEP_BEFORERENDERTARGETDRAW_LAYER=0,e.STEP_BEFORERENDERINGMESH_PREPASS=0,e.STEP_BEFORERENDERINGMESH_OUTLINE=1,e.STEP_AFTERRENDERINGMESH_PREPASS=0,e.STEP_AFTERRENDERINGMESH_OUTLINE=1,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_AFTERCAMERADRAW_PREPASS=4,e.STEP_AFTERRENDER_AUDIO=0,e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=0,e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=2,e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,e.STEP_BEFORECLEARSTAGE_PREPASS=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 Object(n.d)(t,e),t.Create=function(){return Object.create(t.prototype)},t.prototype.registerStep=function(e,t,i){var n=0;for(Number.MAX_VALUE;n<this.length;n++){if(e<this[n].index)break}this.splice(n,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 a})),i.d(t,"d",(function(){return s})),i.d(t,"b",(function(){return c}));var n=i(1),r=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}(),a=function(e,t){this.type=e,this.event=t},s=function(e){function t(t,i,n,o){var a=e.call(this,t,i)||this;return a.ray=null,a.skipOnPointerObservable=!1,a.localPosition=new r.d(n,o),a}return Object(n.d)(t,e),t}(a),c=function(e){function t(t,i,n){var r=e.call(this,t,i)||this;return r.pickInfo=n,r}return Object(n.d)(t,e),t}(a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(13),r=i(2),o=function(){function e(){}return Object.defineProperty(e,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DetailTextureEnabled",{get:function(){return this._DetailTextureEnabled},set:function(e){this._DetailTextureEnabled!==e&&(this._DetailTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_FresnelDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ClearCoatTextureEnabled",{get:function(){return this._ClearCoatTextureEnabled},set:function(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ClearCoatBumpTextureEnabled",{get:function(){return this._ClearCoatBumpTextureEnabled},set:function(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ClearCoatTintTextureEnabled",{get:function(){return this._ClearCoatTintTextureEnabled},set:function(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"SheenTextureEnabled",{get:function(){return this._SheenTextureEnabled},set:function(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"AnisotropicTextureEnabled",{get:function(){return this._AnisotropicTextureEnabled},set:function(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ThicknessTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,n.a.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),e._DiffuseTextureEnabled=!0,e._DetailTextureEnabled=!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._ClearCoatTextureEnabled=!0,e._ClearCoatBumpTextureEnabled=!0,e._ClearCoatTintTextureEnabled=!0,e._SheenTextureEnabled=!0,e._AnisotropicTextureEnabled=!0,e._ThicknessTextureEnabled=!0,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return U}));var n=i(1),r=i(12),o=i(57),a=i(6),s=i(33),c=i(112),l=i(37),u=i(0),h=i(46),d=i(31),f=i(24),p=i(35),_=i(42),m=i(85),g=i(48),v=i(54),b=i(47),y=i(95),T=i(96),E=i(17),S=i(2),A=i(38),P=i(8),C=i(22),R=i(21),x=i(18),O=i(91),M=i(66),I=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"doubleClick",{get:function(){return this._doubleClick},set:function(e){this._doubleClick=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasSwiped",{get:function(){return this._hasSwiped},set:function(e){this._hasSwiped=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignore",{get:function(){return this._ignore},set:function(e){this._ignore=e},enumerable:!1,configurable:!0}),e}(),D=function(){function e(e){this._alreadyAttached=!1,this._wheelEventName="",this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._totalPointersPressed=0,this._doubleClickOccured=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new u.d(0,0),this._previousStartingPointerPosition=new u.d(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._meshUnderPointerId=[],this._keyboardIsAttached=!1,this._scene=e}return Object.defineProperty(e.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!1,configurable:!0}),e.prototype.getMeshUnderPointerByPointerId=function(e){return this._meshUnderPointerId[e]},Object.defineProperty(e.prototype,"unTranslatedPointer",{get:function(){return new u.d(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pointerX",{get:function(){return this._pointerX},set:function(e){this._pointerX=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pointerY",{get:function(){return this._pointerY},set:function(e){this._pointerY=e},enumerable:!1,configurable:!0}),e.prototype._updatePointerPosition=function(e){var t=this._scene.getEngine().getInputElementClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)},e.prototype._processPointerMove=function(e,t){var i=this._scene,n=i.getEngine(),r=n.getInputElement();if(r){r.tabIndex=n.canvasTabIndex,i.doNotHandleCursors||(r.style.cursor=i.defaultCursor);var o=!!(e&&e.hit&&e.pickedMesh);o?(i.setPointerOverMesh(e.pickedMesh,t.pointerId),this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.hasPointerTriggers&&(i.doNotHandleCursors||(this._pointerOverMesh.actionManager.hoverCursor?r.style.cursor=this._pointerOverMesh.actionManager.hoverCursor:r.style.cursor=i.hoverCursor))):i.setPointerOverMesh(null,t.pointerId);for(var a=0,s=i._pointerMoveStage;a<s.length;a++){e=s[a].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,o,r)}if(e){var c=t.type===this._wheelEventName?x.a.POINTERWHEEL:x.a.POINTERMOVE;if(i.onPointerMove&&i.onPointerMove(t,e,c),i.onPointerObservable.hasObservers()){var l=new x.b(c,t,e);this._setRayOnPointerInfo(l),i.onPointerObservable.notifyObservers(l,c)}}}},e.prototype._setRayOnPointerInfo=function(e){var t=this._scene;e.pickInfo&&!e.pickInfo._pickingUnavailable&&(e.pickInfo.ray||(e.pickInfo.ray=t.createPickingRay(e.event.offsetX,e.event.offsetY,u.a.Identity(),t.activeCamera)))},e.prototype._checkPrePointerObservable=function(e,t,i){var n=this._scene,r=new x.d(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.ray=e.ray),n.onPrePointerObservable.notifyObservers(r,i),!!r.skipOnPointerObservable},e.prototype.simulatePointerMove=function(e,t){var i=new PointerEvent("pointermove",t);this._checkPrePointerObservable(e,i,x.a.POINTERMOVE)||this._processPointerMove(e,i)},e.prototype.simulatePointerDown=function(e,t){var i=new PointerEvent("pointerdown",t);this._checkPrePointerObservable(e,i,x.a.POINTERDOWN)||this._processPointerDown(e,i)},e.prototype._processPointerDown=function(t,i){var n=this,r=this._scene;if(t&&t.hit&&t.pickedMesh){this._pickedDownMesh=t.pickedMesh;var o=t.pickedMesh._getActionManagerForTrigger();if(o){if(o.hasPickTriggers)switch(o.processTrigger(S.a.ACTION_OnPickDownTrigger,b.a.CreateNew(t.pickedMesh,i)),i.button){case 0:o.processTrigger(S.a.ACTION_OnLeftPickTrigger,b.a.CreateNew(t.pickedMesh,i));break;case 1:o.processTrigger(S.a.ACTION_OnCenterPickTrigger,b.a.CreateNew(t.pickedMesh,i));break;case 2:o.processTrigger(S.a.ACTION_OnRightPickTrigger,b.a.CreateNew(t.pickedMesh,i))}o.hasSpecificTrigger(S.a.ACTION_OnLongPressTrigger)&&window.setTimeout((function(){var t=r.pick(n._unTranslatedPointerX,n._unTranslatedPointerY,(function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(S.a.ACTION_OnLongPressTrigger)&&e==n._pickedDownMesh}),!1,r.cameraToUseForPointers);t&&t.hit&&t.pickedMesh&&o&&0!==n._totalPointersPressed&&Date.now()-n._startingPointerTime>e.LongPressDelay&&!n._isPointerSwiping()&&(n._startingPointerTime=0,o.processTrigger(S.a.ACTION_OnLongPressTrigger,b.a.CreateNew(t.pickedMesh,i)))}),e.LongPressDelay)}}else for(var a=0,s=r._pointerDownStage;a<s.length;a++){t=s[a].action(this._unTranslatedPointerX,this._unTranslatedPointerY,t,i)}if(t){var c=x.a.POINTERDOWN;if(r.onPointerDown&&r.onPointerDown(i,t,c),r.onPointerObservable.hasObservers()){var l=new x.b(c,i,t);this._setRayOnPointerInfo(l),r.onPointerObservable.notifyObservers(l,c)}}},e.prototype._isPointerSwiping=function(){return Math.abs(this._startingPointerPosition.x-this._pointerX)>e.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>e.DragMovementThreshold},e.prototype.simulatePointerUp=function(e,t,i){var n=new PointerEvent("pointerup",t),r=new I;i?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,n,x.a.POINTERUP)||this._processPointerUp(e,n,r)},e.prototype._processPointerUp=function(e,t,i){var n=this._scene;if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(n.onPointerPick&&n.onPointerPick(t,e),i.singleClick&&!i.ignore&&n.onPointerObservable.hasObservers())){var r=x.a.POINTERPICK,o=new x.b(r,t,e);this._setRayOnPointerInfo(o),n.onPointerObservable.notifyObservers(o,r)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!i.ignore){a.processTrigger(S.a.ACTION_OnPickUpTrigger,b.a.CreateNew(e.pickedMesh,t)),!i.hasSwiped&&i.singleClick&&a.processTrigger(S.a.ACTION_OnPickTrigger,b.a.CreateNew(e.pickedMesh,t));var s=e.pickedMesh._getActionManagerForTrigger(S.a.ACTION_OnDoublePickTrigger);i.doubleClick&&s&&s.processTrigger(S.a.ACTION_OnDoublePickTrigger,b.a.CreateNew(e.pickedMesh,t))}}else if(!i.ignore)for(var c=0,l=n._pointerUpStage;c<l.length;c++){e=l[c].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t)}if(this._pickedDownMesh&&this._pickedDownMesh!==this._pickedUpMesh){var u=this._pickedDownMesh._getActionManagerForTrigger(S.a.ACTION_OnPickOutTrigger);u&&u.processTrigger(S.a.ACTION_OnPickOutTrigger,b.a.CreateNew(this._pickedDownMesh,t))}var h=0;if(n.onPointerObservable.hasObservers()){if(!i.ignore&&!i.hasSwiped&&(i.singleClick&&n.onPointerObservable.hasSpecificMask(x.a.POINTERTAP)?h=x.a.POINTERTAP:i.doubleClick&&n.onPointerObservable.hasSpecificMask(x.a.POINTERDOUBLETAP)&&(h=x.a.POINTERDOUBLETAP),h)){o=new x.b(h,t,e);this._setRayOnPointerInfo(o),n.onPointerObservable.notifyObservers(o,h)}if(!i.ignore){h=x.a.POINTERUP;o=new x.b(h,t,e);this._setRayOnPointerInfo(o),n.onPointerObservable.notifyObservers(o,h)}}n.onPointerUp&&!i.ignore&&n.onPointerUp(t,e,h)},e.prototype.isPointerCaptured=function(e){return void 0===e&&(e=0),this._pointerCaptures[e]},e.prototype.attachControl=function(t,i,n,o){var a=this;void 0===t&&(t=!0),void 0===i&&(i=!0),void 0===n&&(n=!0),void 0===o&&(o=null);var s=this._scene;if(o||(o=s.getEngine().getInputElement()),o){this._alreadyAttached&&this.detachControl(),this._alreadyAttachedTo=o;var c=s.getEngine();this._initActionManager=function(e,t){if(!a._meshPickProceed){var i=s.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,s.pointerDownPredicate,!1,s.cameraToUseForPointers);a._currentPickResult=i,i&&(e=i.hit&&i.pickedMesh?i.pickedMesh._getActionManagerForTrigger():null),a._meshPickProceed=!0}return e},this._delayedSimpleClick=function(t,i,n){(Date.now()-a._previousStartingPointerTime>e.DoubleClickDelay&&!a._doubleClickOccured||t!==a._previousButtonPressed)&&(a._doubleClickOccured=!1,i.singleClick=!0,i.ignore=!1,n(i,a._currentPickResult))},this._initClickEvent=function(t,i,n,r){var o=new I;a._currentPickResult=null;var s=null,c=t.hasSpecificMask(x.a.POINTERPICK)||i.hasSpecificMask(x.a.POINTERPICK)||t.hasSpecificMask(x.a.POINTERTAP)||i.hasSpecificMask(x.a.POINTERTAP)||t.hasSpecificMask(x.a.POINTERDOUBLETAP)||i.hasSpecificMask(x.a.POINTERDOUBLETAP);!c&&O.a&&(s=a._initActionManager(s,o))&&(c=s.hasPickTriggers);var l=!1;if(c){var u=n.button;if(o.hasSwiped=a._isPointerSwiping(),!o.hasSwiped){var h=!e.ExclusiveDoubleClickMode;h||(h=!t.hasSpecificMask(x.a.POINTERDOUBLETAP)&&!i.hasSpecificMask(x.a.POINTERDOUBLETAP))&&!O.a.HasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)&&(s=a._initActionManager(s,o))&&(h=!s.hasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)),h?(Date.now()-a._previousStartingPointerTime>e.DoubleClickDelay||u!==a._previousButtonPressed)&&(o.singleClick=!0,r(o,a._currentPickResult),l=!0):(a._previousDelayedSimpleClickTimeout=a._delayedSimpleClickTimeout,a._delayedSimpleClickTimeout=window.setTimeout(a._delayedSimpleClick.bind(a,u,o,r),e.DoubleClickDelay));var d=t.hasSpecificMask(x.a.POINTERDOUBLETAP)||i.hasSpecificMask(x.a.POINTERDOUBLETAP);!d&&O.a.HasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)&&(s=a._initActionManager(s,o))&&(d=s.hasSpecificTrigger(S.a.ACTION_OnDoublePickTrigger)),d&&(u===a._previousButtonPressed&&Date.now()-a._previousStartingPointerTime<e.DoubleClickDelay&&!a._doubleClickOccured?(o.hasSwiped||a._isPointerSwiping()?(a._doubleClickOccured=!1,a._previousStartingPointerTime=a._startingPointerTime,a._previousStartingPointerPosition.x=a._startingPointerPosition.x,a._previousStartingPointerPosition.y=a._startingPointerPosition.y,a._previousButtonPressed=u,e.ExclusiveDoubleClickMode?(a._previousDelayedSimpleClickTimeout&&clearTimeout(a._previousDelayedSimpleClickTimeout),a._previousDelayedSimpleClickTimeout=a._delayedSimpleClickTimeout,r(o,a._previousPickResult)):r(o,a._currentPickResult)):(a._previousStartingPointerTime=0,a._doubleClickOccured=!0,o.doubleClick=!0,o.ignore=!1,e.ExclusiveDoubleClickMode&&a._previousDelayedSimpleClickTimeout&&clearTimeout(a._previousDelayedSimpleClickTimeout),a._previousDelayedSimpleClickTimeout=a._delayedSimpleClickTimeout,r(o,a._currentPickResult)),l=!0):(a._doubleClickOccured=!1,a._previousStartingPointerTime=a._startingPointerTime,a._previousStartingPointerPosition.x=a._startingPointerPosition.x,a._previousStartingPointerPosition.y=a._startingPointerPosition.y,a._previousButtonPressed=u))}}l||r(o,a._currentPickResult)},this._onPointerMove=function(e){if(void 0===e.pointerId&&(e.pointerId=0),a._updatePointerPosition(e),!a._checkPrePointerObservable(null,e,e.type===a._wheelEventName?x.a.POINTERWHEEL:x.a.POINTERMOVE)&&(s.cameraToUseForPointers||s.activeCamera)){s.pointerMovePredicate||(s.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||s.constantlyUpdateMeshUnderPointer||null!=e._getActionManagerForTrigger())&&(!s.cameraToUseForPointers||0!=(s.cameraToUseForPointers.layerMask&e.layerMask))});var t=s.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,s.pointerMovePredicate,!1,s.cameraToUseForPointers);a._processPointerMove(t,e)}},this._onPointerDown=function(e){if(a._totalPointersPressed++,a._pickedDownMesh=null,a._meshPickProceed=!1,void 0===e.pointerId&&(e.pointerId=0),a._updatePointerPosition(e),s.preventDefaultOnPointerDown&&o&&(e.preventDefault(),o.focus()),a._startingPointerPosition.x=a._pointerX,a._startingPointerPosition.y=a._pointerY,a._startingPointerTime=Date.now(),!a._checkPrePointerObservable(null,e,x.a.POINTERDOWN)&&(s.cameraToUseForPointers||s.activeCamera)){a._pointerCaptures[e.pointerId]=!0,s.pointerDownPredicate||(s.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!s.cameraToUseForPointers||0!=(s.cameraToUseForPointers.layerMask&e.layerMask))}),a._pickedDownMesh=null;var t=s.pick(a._unTranslatedPointerX,a._unTranslatedPointerY,s.pointerDownPredicate,!1,s.cameraToUseForPointers);a._processPointerDown(t,e)}},this._onPointerUp=function(e){0!==a._totalPointersPressed&&(a._totalPointersPressed--,a._pickedUpMesh=null,a._meshPickProceed=!1,void 0===e.pointerId&&(e.pointerId=0),a._updatePointerPosition(e),s.preventDefaultOnPointerUp&&o&&(e.preventDefault(),o.focus()),a._initClickEvent(s.onPrePointerObservable,s.onPointerObservable,e,(function(t,i){if(s.onPrePointerObservable.hasObservers()&&!t.ignore){if(!t.hasSwiped){if(t.singleClick&&s.onPrePointerObservable.hasSpecificMask(x.a.POINTERTAP)&&a._checkPrePointerObservable(null,e,x.a.POINTERTAP))return;if(t.doubleClick&&s.onPrePointerObservable.hasSpecificMask(x.a.POINTERDOUBLETAP)&&a._checkPrePointerObservable(null,e,x.a.POINTERDOUBLETAP))return}if(a._checkPrePointerObservable(null,e,x.a.POINTERUP))return}a._pointerCaptures[e.pointerId]&&(a._pointerCaptures[e.pointerId]=!1,(s.cameraToUseForPointers||s.activeCamera)&&(s.pointerUpPredicate||(s.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!s.cameraToUseForPointers||0!=(s.cameraToUseForPointers.layerMask&e.layerMask))}),!a._meshPickProceed&&(O.a&&O.a.HasTriggers||s.onPointerObservable.hasObservers())&&a._initActionManager(null,t),i||(i=a._currentPickResult),a._processPointerUp(i,e,t),a._previousPickResult=a._currentPickResult))})))},this._onKeyDown=function(e){var t=M.a.KEYDOWN;if(s.onPreKeyboardObservable.hasObservers()){var i=new M.c(t,e);if(s.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(s.onKeyboardObservable.hasObservers()){i=new M.b(t,e);s.onKeyboardObservable.notifyObservers(i,t)}s.actionManager&&s.actionManager.processTrigger(S.a.ACTION_OnKeyDownTrigger,b.a.CreateNewFromScene(s,e))},this._onKeyUp=function(e){var t=M.a.KEYUP;if(s.onPreKeyboardObservable.hasObservers()){var i=new M.c(t,e);if(s.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(s.onKeyboardObservable.hasObservers()){i=new M.b(t,e);s.onKeyboardObservable.notifyObservers(i,t)}s.actionManager&&s.actionManager.processTrigger(S.a.ACTION_OnKeyUpTrigger,b.a.CreateNewFromScene(s,e))};var l=function(){o&&!a._keyboardIsAttached&&(o.addEventListener("keydown",a._onKeyDown,!1),o.addEventListener("keyup",a._onKeyUp,!1),a._keyboardIsAttached=!0)};this._onCanvasFocusObserver=c.onCanvasFocusObservable.add((document.activeElement===o&&l(),l)),this._onCanvasBlurObserver=c.onCanvasBlurObservable.add((function(){o&&(o.removeEventListener("keydown",a._onKeyDown),o.removeEventListener("keyup",a._onKeyUp),a._keyboardIsAttached=!1)})),l();var u=r.b.GetPointerPrefix(c);if(n&&(o.addEventListener(u+"move",this._onPointerMove,!1),this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll",o.addEventListener(this._wheelEventName,this._onPointerMove,!1)),i&&o.addEventListener(u+"down",this._onPointerDown,!1),t){var h=s.getEngine().getHostWindow();h&&h.addEventListener(u+"up",this._onPointerUp,!1)}this._alreadyAttached=!0}},e.prototype.detachControl=function(){var e=this._scene.getEngine(),t=r.b.GetPointerPrefix(e);this._alreadyAttachedTo&&this._alreadyAttached&&(this._alreadyAttachedTo.removeEventListener(t+"move",this._onPointerMove),this._alreadyAttachedTo.removeEventListener(this._wheelEventName,this._onPointerMove),this._alreadyAttachedTo.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),this._alreadyAttachedTo.removeEventListener("keydown",this._onKeyDown),this._alreadyAttachedTo.removeEventListener("keyup",this._onKeyUp),this._scene.doNotHandleCursors||(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1)},e.prototype.setPointerOverMesh=function(e,t){if(void 0===t&&(t=0),t<0&&(t=0),this._meshUnderPointerId[t]!==e){var i,n=this._meshUnderPointerId[t];n&&(i=n._getActionManagerForTrigger(S.a.ACTION_OnPointerOutTrigger))&&i.processTrigger(S.a.ACTION_OnPointerOutTrigger,b.a.CreateNew(n,void 0,{pointerId:t})),this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,(n=this._meshUnderPointerId[t])&&(i=n._getActionManagerForTrigger(S.a.ACTION_OnPointerOverTrigger))&&i.processTrigger(S.a.ACTION_OnPointerOverTrigger,b.a.CreateNew(n,void 0,{pointerId:t}))}},e.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},e.DragMovementThreshold=10,e.LongPressDelay=500,e.DoubleClickDelay=300,e.ExclusiveDoubleClickMode=!1,e}(),N=i(55),L=i(9),w=i(90),F=i(152),B=i(56),U=function(e){function t(i,r){var o=e.call(this)||this;o._inputManager=new D(o),o.cameraToUseForPointers=null,o._isScene=!0,o._blockEntityCollection=!1,o.autoClear=!0,o.autoClearDepthAndStencil=!0,o.clearColor=new L.b(.2,.2,.3,1),o.ambientColor=new L.a(0,0,0),o._environmentIntensity=1,o._forceWireframe=!1,o._skipFrustumClipping=!1,o._forcePointsCloud=!1,o.animationsEnabled=!0,o._animationPropertiesOverride=null,o.useConstantAnimationDeltaTime=!1,o.constantlyUpdateMeshUnderPointer=!1,o.hoverCursor="pointer",o.defaultCursor="",o.doNotHandleCursors=!1,o.preventDefaultOnPointerDown=!0,o.preventDefaultOnPointerUp=!0,o.metadata=null,o.reservedDataStore=null,o.disableOfflineSupportExceptionRules=new Array,o.onDisposeObservable=new a.c,o._onDisposeObserver=null,o.onBeforeRenderObservable=new a.c,o._onBeforeRenderObserver=null,o.onAfterRenderObservable=new a.c,o.onAfterRenderCameraObservable=new a.c,o._onAfterRenderObserver=null,o.onBeforeAnimationsObservable=new a.c,o.onAfterAnimationsObservable=new a.c,o.onBeforeDrawPhaseObservable=new a.c,o.onAfterDrawPhaseObservable=new a.c,o.onReadyObservable=new a.c,o.onBeforeCameraRenderObservable=new a.c,o._onBeforeCameraRenderObserver=null,o.onAfterCameraRenderObservable=new a.c,o._onAfterCameraRenderObserver=null,o.onBeforeActiveMeshesEvaluationObservable=new a.c,o.onAfterActiveMeshesEvaluationObservable=new a.c,o.onBeforeParticlesRenderingObservable=new a.c,o.onAfterParticlesRenderingObservable=new a.c,o.onDataLoadedObservable=new a.c,o.onNewCameraAddedObservable=new a.c,o.onCameraRemovedObservable=new a.c,o.onNewLightAddedObservable=new a.c,o.onLightRemovedObservable=new a.c,o.onNewGeometryAddedObservable=new a.c,o.onGeometryRemovedObservable=new a.c,o.onNewTransformNodeAddedObservable=new a.c,o.onTransformNodeRemovedObservable=new a.c,o.onNewMeshAddedObservable=new a.c,o.onMeshRemovedObservable=new a.c,o.onNewSkeletonAddedObservable=new a.c,o.onSkeletonRemovedObservable=new a.c,o.onNewMaterialAddedObservable=new a.c,o.onNewMultiMaterialAddedObservable=new a.c,o.onMaterialRemovedObservable=new a.c,o.onMultiMaterialRemovedObservable=new a.c,o.onNewTextureAddedObservable=new a.c,o.onTextureRemovedObservable=new a.c,o.onBeforeRenderTargetsRenderObservable=new a.c,o.onAfterRenderTargetsRenderObservable=new a.c,o.onBeforeStepObservable=new a.c,o.onAfterStepObservable=new a.c,o.onActiveCameraChanged=new a.c,o.onBeforeRenderingGroupObservable=new a.c,o.onAfterRenderingGroupObservable=new a.c,o.onMeshImportedObservable=new a.c,o.onAnimationFileImportedObservable=new a.c,o._registeredForLateAnimationBindings=new s.b(256),o.onPrePointerObservable=new a.c,o.onPointerObservable=new a.c,o.onPreKeyboardObservable=new a.c,o.onKeyboardObservable=new a.c,o._useRightHandedSystem=!1,o._timeAccumulator=0,o._currentStepId=0,o._currentInternalStep=0,o._fogEnabled=!0,o._fogMode=t.FOGMODE_NONE,o.fogColor=new L.a(.2,.2,.3),o.fogDensity=.1,o.fogStart=0,o.fogEnd=1e3,o.prePass=!1,o._shadowsEnabled=!0,o._lightsEnabled=!0,o.activeCameras=new Array,o._texturesEnabled=!0,o.physicsEnabled=!0,o.particlesEnabled=!0,o.spritesEnabled=!0,o._skeletonsEnabled=!0,o.lensFlaresEnabled=!0,o.collisionsEnabled=!0,o.gravity=new u.e(0,-9.807,0),o.postProcessesEnabled=!0,o.renderTargetsEnabled=!0,o.dumpNextRenderTargets=!1,o.customRenderTargets=new Array,o.importedMeshesFiles=new Array,o.probesEnabled=!0,o._meshesForIntersections=new s.b(256),o.proceduralTexturesEnabled=!0,o._totalVertices=new N.a,o._activeIndices=new N.a,o._activeParticles=new N.a,o._activeBones=new N.a,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._toBeDisposed=new Array(256),o._activeRequests=new Array,o._pendingData=new Array,o._isDisposed=!1,o.dispatchAllSubMeshesOfActiveMeshes=!1,o._activeMeshes=new s.a(256),o._processedMaterials=new s.a(256),o._renderTargets=new s.b(256),o._activeParticleSystems=new s.a(256),o._activeSkeletons=new s.b(32),o._softwareSkinnedMeshes=new s.b(32),o._activeAnimatables=new Array,o._transformMatrix=u.a.Zero(),o.requireLightSorting=!1,o._components=[],o._serializableComponents=[],o._transientComponents=[],o._beforeCameraUpdateStage=E.b.Create(),o._beforeClearStage=E.b.Create(),o._gatherRenderTargetsStage=E.b.Create(),o._gatherActiveCameraRenderTargetsStage=E.b.Create(),o._isReadyForMeshStage=E.b.Create(),o._beforeEvaluateActiveMeshStage=E.b.Create(),o._evaluateSubMeshStage=E.b.Create(),o._preActiveMeshStage=E.b.Create(),o._cameraDrawRenderTargetStage=E.b.Create(),o._beforeCameraDrawStage=E.b.Create(),o._beforeRenderTargetDrawStage=E.b.Create(),o._beforeRenderingGroupDrawStage=E.b.Create(),o._beforeRenderingMeshStage=E.b.Create(),o._afterRenderingMeshStage=E.b.Create(),o._afterRenderingGroupDrawStage=E.b.Create(),o._afterCameraDrawStage=E.b.Create(),o._afterRenderTargetDrawStage=E.b.Create(),o._afterRenderStage=E.b.Create(),o._pointerMoveStage=E.b.Create(),o._pointerDownStage=E.b.Create(),o._pointerUpStage=E.b.Create(),o.geometriesByUniqueId=null,o._defaultMeshCandidates={data:[],length:0},o._defaultSubMeshCandidates={data:[],length:0},o._preventFreeActiveMeshesAndRenderingGroups=!1,o._activeMeshesFrozen=!1,o._skipEvaluateActiveMeshesCompletely=!1,o._allowPostProcessClearColor=!0,o.getDeterministicFrameTime=function(){return o._engine.getTimeStep()},o._blockMaterialDirtyMechanism=!1;var c=Object(n.a)({useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1},r);return o._engine=i||C.a.LastCreatedEngine,c.virtual||(C.a._LastCreatedScene=o,o._engine.scenes.push(o)),o._uid=null,o._renderingManager=new T.b(o),y.a&&(o.postProcessManager=new y.a(o)),A.a.IsWindowObjectExist()&&o.attachControl(),o._createUbo(),_.a&&(o._imageProcessingConfiguration=new _.a),o.setDefaultCandidateProviders(),c.useGeometryUniqueIdsMap&&(o.geometriesByUniqueId={}),o.useMaterialMeshMap=c.useMaterialMeshMap,o.useClonedMeshMap=c.useClonedMeshMap,r&&r.virtual||o._engine.onNewSceneAddedObservable.notifyObservers(o),o}return Object(n.d)(t,e),t.DefaultMaterialFactory=function(e){throw R.a.WarnImport("StandardMaterial")},t.CollisionCoordinatorFactory=function(){throw R.a.WarnImport("DefaultCollisionCoordinator")},Object.defineProperty(t.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"environmentIntensity",{get:function(){return this._environmentIntensity},set:function(e){this._environmentIntensity!==e&&(this._environmentIntensity=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skipFrustumClipping",{get:function(){return this._skipFrustumClipping},set:function(e){this._skipFrustumClipping!==e&&(this._skipFrustumClipping=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"unTranslatedPointer",{get:function(){return this._inputManager.unTranslatedPointer},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DragMovementThreshold",{get:function(){return D.DragMovementThreshold},set:function(e){D.DragMovementThreshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LongPressDelay",{get:function(){return D.LongPressDelay},set:function(e){D.LongPressDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DoubleClickDelay",{get:function(){return D.DoubleClickDelay},set:function(e){D.DoubleClickDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ExclusiveDoubleClickMode",{get:function(){return D.ExclusiveDoubleClickMode},set:function(e){D.ExclusiveDoubleClickMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,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(S.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fogMode",{get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_LightDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_LightDirtyFlag))},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(S.a.MATERIAL_AttributesDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionCoordinator",{get:function(){return this._collisionCoordinator||(this._collisionCoordinator=t.CollisionCoordinatorFactory(),this._collisionCoordinator.init(this)),this._collisionCoordinator},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!1,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&&t.serialize&&this._serializableComponents.push(t)},t.prototype._getComponent=function(e){for(var t=0,i=this._components;t<i.length;t++){var n=i[t];if(n.name===e)return n}return null},t.prototype.getClassName=function(){return"Scene"},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._inputManager.meshUnderPointer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerX",{get:function(){return this._inputManager.pointerX},set:function(e){this._inputManager.pointerX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pointerY",{get:function(){return this._inputManager.pointerY},set:function(e){this._inputManager.pointerY=e},enumerable:!1,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:!1,configurable:!0}),t.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(t.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!1,configurable:!0}),t.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(t.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!1,configurable:!0}),t.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(t.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!1,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._createUbo=function(){this._sceneUbo=new m.a(this._engine,void 0,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},t.prototype.simulatePointerMove=function(e,t){return this._inputManager.simulatePointerMove(e,t),this},t.prototype.simulatePointerDown=function(e,t){return this._inputManager.simulatePointerDown(e,t),this},t.prototype.simulatePointerUp=function(e,t,i){return this._inputManager.simulatePointerUp(e,t,i),this},t.prototype.isPointerCaptured=function(e){return void 0===e&&(e=0),this._inputManager.isPointerCaptured(e)},t.prototype.attachControl=function(e,t,i){void 0===e&&(e=!0),void 0===t&&(t=!0),void 0===i&&(i=!0),this._inputManager.attachControl(e,t,i)},t.prototype.detachControl=function(){this._inputManager.detachControl()},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 n=i.hasThinInstances||"InstancedMesh"===i.getClassName()||"InstancedLinesMesh"===i.getClassName()||t.getCaps().instancedArrays&&i.instances.length>0,r=0,o=this._isReadyForMeshStage;r<o.length;r++){if(!o[r].action(i,n))return!1}}}for(e=0;e<this.geometries.length;e++){if(this.geometries[e].delayLoadState===S.a.DELAYLOADSTATE_LOADING)return!1}if(this.activeCameras&&this.activeCameras.length>0)for(var a=0,s=this.activeCameras;a<s.length;a++){if(!s[a].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:!1,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;return this._registerTransientComponents(),this.isReady()?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1)):void(this._executeWhenReadyTimeoutId=setTimeout((function(){e._checkIsReady()}),150))},Object.defineProperty(t.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!1,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=o.a.Now},t.prototype.getViewMatrix=function(){return this._viewMatrix},t.prototype.getProjectionMatrix=function(){return this._projectionMatrix},t.prototype.getTransformMatrix=function(){return this._transformMatrix},t.prototype.setTransformMatrix=function(e,t,i,n){this._viewUpdateFlag===e.updateFlag&&this._projectionUpdateFlag===t.updateFlag||(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?w.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=w.a.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(i,n):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update()))},t.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},t.prototype.getUniqueId=function(){return F.a.UniqueId},t.prototype.addMesh=function(e,t){var i=this;void 0===t&&(t=!1),this._blockEntityCollection||(this.meshes.push(e),e._resyncLightSources(),e.parent||e._addToSceneRootNodes(),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 n=this.meshes.indexOf(e);return-1!==n&&(this.meshes[n]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.removeMesh(e)})),n},t.prototype.addTransformNode=function(e){this._blockEntityCollection||(e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),e.parent||e._addToSceneRootNodes(),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(),e.parent||e._removeFromSceneRootNodes()}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),this.onSkeletonRemovedObservable.notifyObservers(e)),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,n=this.meshes;i<n.length;i++){n[i]._removeLightSource(e,!1)}this.lights.splice(t,1),this.sortLightsByPriority(),e.parent||e._removeFromSceneRootNodes()}return this.onLightRemovedObservable.notifyObservers(e),t},t.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);if(-1!==t&&(this.cameras.splice(t,1),e.parent||e._removeFromSceneRootNodes()),this.activeCameras){var i=this.activeCameras.indexOf(e);-1!==i&&this.activeCameras.splice(i,1)}return 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.stopAnimation=function(e,t,i){},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),this.onMultiMaterialRemovedObservable.notifyObservers(e),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){if(!this._blockEntityCollection){this.lights.push(e),this.sortLightsByPriority(),e.parent||e._addToSceneRootNodes();for(var t=0,i=this.meshes;t<i.length;t++){var n=i[t];-1===n.lightSources.indexOf(e)&&(n.lightSources.push(e),n._resyncLightSources())}this.onNewLightAddedObservable.notifyObservers(e)}},t.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(g.a.CompareLightsPriority)},t.prototype.addCamera=function(e){this._blockEntityCollection||(this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e),e.parent||e._addToSceneRootNodes())},t.prototype.addSkeleton=function(e){this._blockEntityCollection||(this.skeletons.push(e),this.onNewSkeletonAddedObservable.notifyObservers(e))},t.prototype.addParticleSystem=function(e){this._blockEntityCollection||this.particleSystems.push(e)},t.prototype.addAnimation=function(e){this._blockEntityCollection||this.animations.push(e)},t.prototype.addAnimationGroup=function(e){this._blockEntityCollection||this.animationGroups.push(e)},t.prototype.addMultiMaterial=function(e){this._blockEntityCollection||(this.multiMaterials.push(e),this.onNewMultiMaterialAddedObservable.notifyObservers(e))},t.prototype.addMaterial=function(e){this._blockEntityCollection||(e._indexInSceneMaterialArray=this.materials.length,this.materials.push(e),this.onNewMaterialAddedObservable.notifyObservers(e))},t.prototype.addMorphTargetManager=function(e){this._blockEntityCollection||this.morphTargetManagers.push(e)},t.prototype.addGeometry=function(e){this._blockEntityCollection||(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._blockEntityCollection||(this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e))},t.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0),this._engine.getInputElement()&&(this.activeCamera&&this.activeCamera.detachControl(),this.activeCamera=e,t&&e.attachControl())},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.getMaterialByUniqueID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].uniqueId===e)return this.materials[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.getLastMaterialByID=function(e){for(var t=this.materials.length-1;t>=0;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.getTextureByUniqueID=function(e){for(var t=0;t<this.textures.length;t++)if(this.textures[t].uniqueId===e)return this.textures[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],n=0;n<i.bones.length;n++)if(i.bones[n].id===e)return i.bones[n];return null},t.prototype.getBoneByName=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],n=0;n<i.bones.length;n++)if(i.bones[n].name===e)return i.bones[n];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];i&&(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.getTransformNodeByUniqueID=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].uniqueId===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 n=this.getLightByID(e);if(n)return n;var r=this.getCameraByID(e);if(r)return r;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 n=this.getLightByName(e);if(n)return n;var r=this.getCameraByName(e);if(r)return r;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.getSkeletonByUniqueId=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].uniqueId===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],n=0;n<i.numTargets;++n){var r=i.getTarget(n);if(r.id===e)return r}return null},t.prototype.getMorphTargetByName=function(e){for(var t=0;t<this.morphTargetManagers.length;++t)for(var i=this.morphTargetManagers[t],n=0;n<i.numTargets;++n){var r=i.getTarget(n);if(r.name===e)return r}return null},t.prototype.getPostProcessByName=function(e){for(var t=0;t<this.postProcesses.length;++t){var i=this.postProcesses[t];if(i.name===e)return i}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=r.b.RandomId()),this._uid},enumerable:!1,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,i){if(i.hasInstances||i.isAnInstance||this.dispatchAllSubMeshesOfActiveMeshes||this._skipFrustumClipping||t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){for(var n=0,r=this._evaluateSubMeshStage;n<r.length;n++){r[n].action(t,e)}var o=e.getMaterial();null!=o&&(o.hasRenderTargetTextures&&null!=o.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(o)&&(this._processedMaterials.push(o),this._renderTargets.concatWithNoDuplicate(o.getRenderTargetTextures())),this._renderingManager.dispatch(e,t,o))}},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:!1,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(e,t,i){var n=this;return void 0===e&&(e=!1),this.executeWhenReady((function(){if(n.activeCamera){n._frustumPlanes||n.setTransformMatrix(n.activeCamera.getViewMatrix(),n.activeCamera.getProjectionMatrix()),n._evaluateActiveMeshes(),n._activeMeshesFrozen=!0,n._skipEvaluateActiveMeshesCompletely=e;for(var r=0;r<n._activeMeshes.length;r++)n._activeMeshes.data[r]._freeze();t&&t()}else i&&i("No active camera found")})),this},t.prototype.unfreezeActiveMeshes=function(){for(var e=0;e<this.meshes.length;e++){var t=this.meshes[e];t._internalAbstractMeshDataInfo&&(t._internalAbstractMeshDataInfo._isActive=!1)}for(e=0;e<this._activeMeshes.length;e++)this._activeMeshes.data[e]._unFreeze();return this._activeMeshesFrozen=!1,this},t.prototype._evaluateActiveMeshes=function(){if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely)for(var e=this._activeMeshes.length,t=0;t<e;t++){(s=this._activeMeshes.data[t]).computeWorldMatrix()}if(this._activeParticleSystems){var i=this._activeParticleSystems.length;for(t=0;t<i;t++)this._activeParticleSystems.data[t].animate()}}else if(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 n=0,r=this._beforeEvaluateActiveMeshStage;n<r.length;n++){r[n].action()}var o=this.getActiveMeshCandidates(),a=o.length;for(t=0;t<a;t++){var s;if((s=o.data[t])._internalAbstractMeshDataInfo._currentLODIsUpToDate=!1,!s.isBlocked&&(this._totalVertices.addCount(s.getTotalVertices(),!1),s.isReady()&&s.isEnabled()&&0!==s.scaling.lengthSquared())){s.computeWorldMatrix(),s.actionManager&&s.actionManager.hasSpecificTriggers2(S.a.ACTION_OnIntersectionEnterTrigger,S.a.ACTION_OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNoDuplicate(s);var c=this.customLODSelector?this.customLODSelector(s,this.activeCamera):s.getLOD(this.activeCamera);if(s._internalAbstractMeshDataInfo._currentLOD=c,s._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0,null!=c&&(c!==s&&c.billboardMode!==h.a.BILLBOARDMODE_NONE&&c.computeWorldMatrix(),s._preActivate(),s.isVisible&&s.visibility>0&&0!=(s.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||s.alwaysSelectAsActiveMesh||s.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(s),this.activeCamera._activeMeshes.push(s),c!==s&&c._activate(this._renderId,!1);for(var l=0,u=this._preActiveMeshStage;l<u.length;l++){u[l].action(s)}s._activate(this._renderId,!1)&&(s.isAnInstance?s._internalAbstractMeshDataInfo._actAsRegularMesh&&(c=s):c._internalAbstractMeshDataInfo._onlyForInstances=!1,c._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(s,c)),s._postActivate()}}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var d=0;d<this.particleSystems.length;d++){var f=this.particleSystems[d];if(f.isStarted()&&f.emitter){var p=f.emitter;p.position&&!p.isEnabled()||(this._activeParticleSystems.push(f),f.animate(),this._renderingManager.dispatchParticles(f))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},t.prototype._activeMesh=function(e,t){if(this._skeletonsEnabled&&null!==t.skeleton&&void 0!==t.skeleton&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),null!=t&&void 0!==t.subMeshes&&null!==t.subMeshes&&t.subMeshes.length>0)for(var i=this.getActiveSubMeshCandidates(t),n=i.length,r=0;r<n;r++){var o=i.data[r];this._evaluateSubMesh(o,t,e)}},t.prototype.updateTransformMatrix=function(e){this.activeCamera&&this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},t.prototype._bindFrameBuffer=function(){if(this.activeCamera&&this.activeCamera._multiviewTexture)this.activeCamera._multiviewTexture._bindFrameBuffer();else if(this.activeCamera&&this.activeCamera.outputRenderTarget){if(this.getEngine().getCaps().multiview&&this.activeCamera.outputRenderTarget&&this.activeCamera.outputRenderTarget.getViewCount()>1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var e=this.activeCamera.outputRenderTarget.getInternalTexture();e?this.getEngine().bindFramebuffer(e):P.a.Error("Camera contains invalid customDefaultRenderTarget")}}else this.getEngine().restoreDefaultFramebuffer()},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.getEngine().getCaps().multiview&&e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1?this.setTransformMatrix(e._rigCameras[0].getViewMatrix(),e._rigCameras[0].getProjectionMatrix(),e._rigCameras[1].getViewMatrix(),e._rigCameras[1].getProjectionMatrix()):this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var n=0;n<this._softwareSkinnedMeshes.length;n++){var o=this._softwareSkinnedMeshes.data[n];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 a=0,s=this._gatherActiveCameraRenderTargetsStage;a<s.length;a++){s[a].action(this._renderTargets)}var c=!1;if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,this._renderTargets.length>0){r.b.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var l=0;l<this._renderTargets.length;l++){var u=this._renderTargets.data[l];if(u._shouldRender()){this._renderId++;var h=u.activeCamera&&u.activeCamera!==this.activeCamera;u.render(h,this.dumpNextRenderTargets),c=!0}}r.b.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._renderId++}for(var d=0,f=this._cameraDrawRenderTargetStage;d<f.length;d++){c=f[d].action(this.activeCamera)||c}this._intermediateRendering=!1,this.activeCamera&&this.activeCamera.outputRenderTarget&&(c=!0)}c&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),!this.postProcessManager||e._multiviewTexture||this.prePass||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 m=0,g=this._afterCameraDrawStage;m<g.length;m++){g[m].action(this.activeCamera)}if(this.postProcessManager&&!e._multiviewTexture){var v=e.outputRenderTarget?e.outputRenderTarget.getInternalTexture():void 0;this.postProcessManager._finalizeFrame(e.isIntermediate,v)}this._renderTargets.reset(),this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}},t.prototype._processSubCameras=function(e){if(e.cameraRigMode===f.a.RIG_MODE_NONE||e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1&&this.getEngine().getCaps().multiview)return this._renderForCamera(e),void this.onAfterRenderCameraObservable.notifyObservers(e);if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else 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()),this.onAfterRenderCameraObservable.notifyObservers(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;t.actionManager&&i<t.actionManager.actions.length;i++){var n=t.actionManager.actions[i];if(n.trigger===S.a.ACTION_OnIntersectionEnterTrigger||n.trigger===S.a.ACTION_OnIntersectionExitTrigger){var r=n.getTriggerParameter(),o=r instanceof d.a?r:r.mesh,a=o.intersectsMesh(t,r.usePreciseIntersection),s=t._intersectionsInProgress.indexOf(o);a&&-1===s?n.trigger===S.a.ACTION_OnIntersectionEnterTrigger?(n._executeCurrent(b.a.CreateNew(t,void 0,o)),t._intersectionsInProgress.push(o)):n.trigger===S.a.ACTION_OnIntersectionExitTrigger&&t._intersectionsInProgress.push(o):!a&&s>-1&&(n.trigger===S.a.ACTION_OnIntersectionExitTrigger&&n._executeCurrent(b.a.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(S.a.ACTION_OnIntersectionExitTrigger,(function(e){var t=e instanceof d.a?e:e.mesh;return o===t}))&&n.trigger!==S.a.ACTION_OnIntersectionExitTrigger||t._intersectionsInProgress.splice(s,1))}}}},t.prototype._advancePhysicsEngineStep=function(e){},t.prototype._animate=function(){},t.prototype.animate=function(){if(this._engine.isDeterministicLockStep()){var e=Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime))+this._timeAccumulator,i=this._engine.getTimeStep(),n=1e3/i/1e3,r=0,o=this._engine.getLockstepMaxSteps(),a=Math.floor(e/i);for(a=Math.min(a,o);e>0&&r<a;)this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=i*n,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(i),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,r++,e-=i;this._timeAccumulator=e<0?0:e}else{e=this.useConstantAnimationDeltaTime?16:Math.max(t.MinDeltaTime,Math.min(this._engine.getDeltaTime(),t.MaxDeltaTime));this._animationRatio=.06*e,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this.physicsEnabled&&this._advancePhysicsEngineStep(e)}},t.prototype.render=function(e,t){if(void 0===e&&(e=!0),void 0===t&&(t=!1),!this.isDisposed){this.onReadyObservable.hasObservers()&&-1===this._executeWhenReadyTimeoutId&&this._checkIsReady(),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(S.a.ACTION_OnEveryFrameTrigger),t||this.animate();for(var i=0,n=this._beforeCameraUpdateStage;i<n.length;i++){n[i].action()}if(e)if(this.activeCameras&&this.activeCameras.length>0)for(var o=0;o<this.activeCameras.length;o++){var a=this.activeCameras[o];if(a.update(),a.cameraRigMode!==f.a.RIG_MODE_NONE)for(var s=0;s<a._rigCameras.length;s++)a._rigCameras[s].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==f.a.RIG_MODE_NONE))for(s=0;s<this.activeCamera._rigCameras.length;s++)this.activeCamera._rigCameras[s].update();this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var c=this.getEngine(),l=this.activeCamera;if(this.renderTargetsEnabled){r.b.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!0;for(var u=0;u<this.customRenderTargets.length;u++){var h=this.customRenderTargets[u];if(h._shouldRender()){if(this._renderId++,this.activeCamera=h.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");c.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),h.render(l!==this.activeCamera,this.dumpNextRenderTargets)}}r.b.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=l,this._activeCamera&&this._activeCamera.cameraRigMode!==f.a.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var d=0,p=this._beforeClearStage;d<p.length;d++){p[d].action()}!this.autoClearDepthAndStencil&&!this.autoClear||this.prePass||this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil);for(var _=0,m=this._gatherRenderTargetsStage;_<m.length;_++){m[_].action(this._renderTargets)}if(this.activeCameras&&this.activeCameras.length>0)for(o=0;o<this.activeCameras.length;o++)o>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[o]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var g=0,v=this._afterRenderStage;g<v.length;g++){v[g].action()}if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(s=0;s<this._toBeDisposed.length;s++){var b=this._toBeDisposed[s];b&&b.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,C.a._LastCreatedScene===this&&(C.a._LastCreatedScene=null),this.skeletons=[],this.morphTargetManagers=[],this._transientComponents=[],this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._preActiveMeshStage.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.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,n=this._activeRequests;i<n.length;i++){n[i].abort()}var r;if(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.onNewSkeletonAddedObservable.clear(),this.onSkeletonRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onNewMultiMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onMultiMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.onActiveCameraChanged.clear(),this.detachControl(),this._engine.getInputElement())for(r=0;r<this.cameras.length;r++)this.cameras[r].detachControl();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.transformNodes[0].dispose(!0);for(;this.cameras.length;)this.cameras[0].dispose();for(this._defaultMaterial&&this._defaultMaterial.dispose();this.multiMaterials.length;)this.multiMaterials[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this._multiviewSceneUbo&&this._multiviewSceneUbo.dispose(),this.postProcessManager.dispose(),(r=this._engine.scenes.indexOf(this))>-1&&this._engine.scenes.splice(r,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,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.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),i=new u.e(-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 n=e.getBoundingInfo(),r=n.boundingBox.minimumWorld,o=n.boundingBox.maximumWorld;u.e.CheckExtends(r,t,i),u.e.CheckExtends(o,t,i)}})),{min:t,max:i}},t.prototype.createPickingRay=function(e,t,i,n,r){throw void 0===r&&(r=!1),R.a.WarnImport("Ray")},t.prototype.createPickingRayToRef=function(e,t,i,n,r,o){throw void 0===o&&(o=!1),R.a.WarnImport("Ray")},t.prototype.createPickingRayInCameraSpace=function(e,t,i){throw R.a.WarnImport("Ray")},t.prototype.createPickingRayInCameraSpaceToRef=function(e,t,i,n){throw R.a.WarnImport("Ray")},t.prototype.pick=function(e,t,i,n,r,o){var a=new v.a;return a._pickingUnavailable=!0,a},t.prototype.pickWithBoundingInfo=function(e,t,i,n,r){var o=new v.a;return o._pickingUnavailable=!0,o},t.prototype.pickWithRay=function(e,t,i,n){throw R.a.WarnImport("Ray")},t.prototype.multiPick=function(e,t,i,n,r){throw R.a.WarnImport("Ray")},t.prototype.multiPickWithRay=function(e,t,i){throw R.a.WarnImport("Ray")},t.prototype.setPointerOverMesh=function(e,t){this._inputManager.setPointerOverMesh(e,t)},t.prototype.getPointerOverMesh=function(){return this._inputManager.getPointerOverMesh()},t.prototype._rebuildGeometries=function(){for(var e=0,t=this.geometries;e<t.length;e++){t[e]._rebuild()}for(var i=0,n=this.meshes;i<n.length;i++){n[i]._rebuild()}this.postProcessManager&&this.postProcessManager._rebuild();for(var r=0,o=this._components;r<o.length;r++){o[r].rebuild()}for(var a=0,s=this.particleSystems;a<s.length;a++){s[a].rebuild()}},t.prototype._rebuildTextures=function(){for(var e=0,t=this.textures;e<t.length;e++){t[e]._rebuild()}this.markAllMaterialsAsDirty(S.a.MATERIAL_TextureDirtyFlag)},t.prototype._getByTags=function(e,t,i){if(void 0===t)return e;var n=[];for(var r in i=i||function(e){},e){var o=e[r];l.a&&l.a.MatchesQuery(o,t)&&(n.push(o),i(o))}return n},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.getTransformNodesByTags=function(e,t){return this._getByTags(this.transformNodes,e,t)},t.prototype.setRenderingOrder=function(e,t,i,n){void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),this._renderingManager.setRenderingOrder(e,t,i,n)},t.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,n){void 0===i&&(i=!0),void 0===n&&(n=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,n)},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(S.a.MATERIAL_AllDirtyFlag))},enumerable:!1,configurable:!0}),t.prototype.markAllMaterialsAsDirty=function(e,t){if(!this._blockMaterialDirtyMechanism)for(var i=0,n=this.materials;i<n.length;i++){var r=n[i];t&&!t(r)||r.markAsDirty(e)}},t.prototype._loadFile=function(e,t,i,n,r,o){var a=this,s=B.a.LoadFile(e,t,i,n?this.offlineProvider:void 0,r,o);return this._activeRequests.push(s),s.onCompleteObservable.add((function(e){a._activeRequests.splice(a._activeRequests.indexOf(e),1)})),s},t.prototype._loadFileAsync=function(e,t,i,n){var r=this;return new Promise((function(o,a){r._loadFile(e,(function(e){o(e)}),t,i,n,(function(e,t){a(t)}))}))},t.prototype._requestFile=function(e,t,i,n,r,o,a){var s=this,c=B.a.RequestFile(e,t,i,n?this.offlineProvider:void 0,r,o,a);return this._activeRequests.push(c),c.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),c},t.prototype._requestFileAsync=function(e,t,i,n,r){var o=this;return new Promise((function(a,s){o._requestFile(e,(function(e){a(e)}),t,i,n,(function(e){s(e)}),r)}))},t.prototype._readFile=function(e,t,i,n,r){var o=this,a=B.a.ReadFile(e,t,i,n,r);return this._activeRequests.push(a),a.onCompleteObservable.add((function(e){o._activeRequests.splice(o._activeRequests.indexOf(e),1)})),a},t.prototype._readFileAsync=function(e,t,i){var n=this;return new Promise((function(r,o){n._readFile(e,(function(e){r(e)}),t,i,(function(e){o(e)}))}))},t.FOGMODE_NONE=0,t.FOGMODE_EXP=1,t.FOGMODE_EXP2=2,t.FOGMODE_LINEAR=3,t.MinDeltaTime=1,t.MaxDeltaTime=1e3,t}(p.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.WarnImport=function(e){return e+" needs to be imported before as it contains a side-effect required by your code."},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return Object.defineProperty(e,"LastCreatedEngine",{get:function(){return 0===this.Instances.length?null:this.Instances[this.Instances.length-1]},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LastCreatedScene",{get:function(){return this._LastCreatedScene},enumerable:!1,configurable:!0}),e.Instances=new Array,e._LastCreatedScene=null,e.UseFallbackTexture=!0,e.FallbackTexture="",e}()},function(e,t,i){"use strict";i.d(t,"c",(function(){return n})),i.d(t,"a",(function(){return a})),i.d(t,"b",(function(){return o}));var n,r=i(0);!function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(n||(n={}));var o,a=function(){function e(){}return e.X=new r.e(1,0,0),e.Y=new r.e(0,1,0),e.Z=new r.e(0,0,1),e}();!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(o||(o={}))},function(e,t,i){"use strict";i.d(t,"a",(function(){return _}));var n=i(1),r=i(3),o=i(33),a=i(12),s=i(6),c=i(0),l=i(29),u=i(8),h=i(11),d=i(21),f=i(58),p=i(90),_=function(e){function t(i,n,r,a){void 0===a&&(a=!0);var l=e.call(this,i,r)||this;return l._position=c.e.Zero(),l._upVector=c.e.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 f.a(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 s.c,l.onProjectionMatrixChangedObservable=new s.c,l.onAfterCheckInputsObservable=new s.c,l.onRestoreStateObservable=new s.c,l.isRigCamera=!1,l._rigCameras=new Array,l._webvrViewMatrix=c.a.Identity(),l._skipRendering=!1,l._projectionMatrix=new c.a,l._postProcesses=new Array,l._activeMeshes=new o.a(256),l._globalPosition=c.e.Zero(),l._computedViewMatrix=c.a.Identity(),l._doNotComputeProjectionMatrix=!1,l._transformMatrix=c.a.Zero(),l._refreshFrustumPlanes=!0,l._isCamera=!0,l._isLeftCamera=!1,l._isRightCamera=!1,l.getScene().addCamera(l),a&&!l.getScene().activeCamera&&(l.getScene().activeCamera=l),l.position=n,l}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upVector=e},enumerable:!1,configurable:!0}),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:!1,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,n=this._postProcesses;i<n.length;i++){var r=n[i];if(r&&!r.isReady())return!1}return e.prototype.isReady.call(this,t)},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=new c.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new c.e(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:!1,configurable:!0}),Object.defineProperty(t.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!1,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 n=this._rigCameras[t],r=n._rigPostProcess;if(r)"pass"===r.getEffectName()&&(n.isIntermediate=0===this._postProcesses.length),n._postProcesses=this._postProcesses.slice(0).concat(r),r.markTextureDirty();else n._postProcesses=this._postProcesses.slice(0)}},t.prototype.attachPostProcess=function(e,t){return void 0===t&&(t=null),!e.isReusable()&&this._postProcesses.indexOf(e)>-1?(u.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._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._scene.prePassRenderer&&this._scene.prePassRenderer.markAsDirty(),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},t.prototype._getViewMatrix=function(){return c.a.Identity()},t.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()||(this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childUpdateId++,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.parent&&this.parent.onViewMatrixChangedObservable&&this.parent.onViewMatrixChangedObservable.notifyObservers(this.parent),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){var i,n,r,o,a,s,l,u;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 h=this.getEngine(),d=this.getScene();if(this.mode===t.PERSPECTIVE_CAMERA){this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=h.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1);var f=h.useReverseDepthBuffer;(d.useRightHandedSystem?f?c.a.PerspectiveFovReverseRHToRef:c.a.PerspectiveFovRHToRef:f?c.a.PerspectiveFovReverseLHToRef:c.a.PerspectiveFovLHToRef)(this.fov,h.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED)}else{var p=h.getRenderWidth()/2,_=h.getRenderHeight()/2;d.useRightHandedSystem?c.a.OrthoOffCenterRHToRef(null!==(i=this.orthoLeft)&&void 0!==i?i:-p,null!==(n=this.orthoRight)&&void 0!==n?n:p,null!==(r=this.orthoBottom)&&void 0!==r?r:-_,null!==(o=this.orthoTop)&&void 0!==o?o:_,this.minZ,this.maxZ,this._projectionMatrix):c.a.OrthoOffCenterLHToRef(null!==(a=this.orthoLeft)&&void 0!==a?a:-p,null!==(s=this.orthoRight)&&void 0!==s?s:p,null!==(l=this.orthoBottom)&&void 0!==l?l:-_,null!==(u=this.orthoTop)&&void 0!==u?u:_,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=h.getRenderWidth(),this._cache.renderHeight=h.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?p.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=p.a.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e,t){if(void 0===t&&(t=!1),this._updateFrustumPlanes(),t&&this.rigCameras.length>0){var i=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),i=i||e.isInFrustum(t._frustumPlanes)})),i}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,i){throw void 0===e&&(e=100),d.a.WarnImport("Ray")},t.prototype.getForwardRayToRef=function(e,t,i,n){throw void 0===t&&(t=100),d.a.WarnImport("Ray")},t.prototype.dispose=function(i,n){for(void 0===n&&(n=!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 r=this._rigCameras.pop();r&&r.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 a=this._postProcesses[o];a&&a.dispose(this)}for(o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),e.prototype.dispose.call(this,i,n)},Object.defineProperty(t.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!1,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 n=this._rigCameras.pop();n&&n.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=i.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=a.b.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var r=this.createRigCamera(this.name+"_L",0);r&&(r._isLeftCamera=!0);var o=this.createRigCamera(this.name+"_R",1);o&&(o._isRightCamera=!0),r&&o&&(this._rigCameras.push(r),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:case t.RIG_MODE_STEREOSCOPIC_INTERLACED: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.a.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.a.Identity()},t.prototype._getWebVRViewMatrix=function(){return c.a.Identity()},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=a.b.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=r.a.Serialize(this);return e.type=this.getClassName(),this.parent&&(e.parentId=this.parent.id),this.inputs&&this.inputs.serialize(e),r.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.prototype.clone=function(e){return r.a.Clone(t.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},t.prototype.getDirection=function(e){var t=c.e.Zero();return this.getDirectionToRef(e,t),t},Object.defineProperty(t.prototype,"absoluteRotation",{get:function(){var e=c.b.Zero();return this.getWorldMatrix().decompose(void 0,e),e},enumerable:!1,configurable:!0}),t.prototype.getDirectionToRef=function(e,t){c.e.TransformNormalToRef(e,this.getWorldMatrix(),t)},t.GetConstructorFromName=function(e,i,n,r,o){void 0===r&&(r=0),void 0===o&&(o=!0);var a=l.a.Construct(e,i,n,{interaxial_distance:r,isStereoscopicSideBySide:o});return a||function(){return t._createDefaultParsedCamera(i,n)}},t.prototype.computeWorldMatrix=function(){return this.getWorldMatrix()},t.Parse=function(e,i){var n=e.type,o=t.GetConstructorFromName(n,e.name,i,e.interaxial_distance,e.isStereoscopicSideBySide),a=r.a.Parse(o,e,i);if(e.parentId&&(a._waitingParentId=e.parentId),a.inputs&&(a.inputs.parse(e),a._setupInputs()),e.upVector&&(a.upVector=c.e.FromArray(e.upVector)),a.setPosition&&(a.position.copyFromFloats(0,0,0),a.setPosition(c.e.FromArray(e.position))),e.target&&a.setTarget&&a.setTarget(c.e.FromArray(e.target)),e.cameraRigMode){var s=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};a.setCameraRigMode(e.cameraRigMode,s)}if(e.animations){for(var u=0;u<e.animations.length;u++){var d=e.animations[u],f=h.a.GetClass("BABYLON.Animation");f&&a.animations.push(f.Parse(d))}l.a.ParseAnimationRanges(a,e,i)}return e.autoAnimate&&i.beginAnimation(a,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),a},t._createDefaultParsedCamera=function(e,t){throw d.a.WarnImport("UniversalCamera")},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_STEREOSCOPIC_INTERLACED=14,t.RIG_MODE_VR=20,t.RIG_MODE_WEBVR=21,t.RIG_MODE_CUSTOM=22,t.ForceAttachControlToAlwaysPreventDefault=!1,Object(n.c)([Object(r.o)("position")],t.prototype,"_position",void 0),Object(n.c)([Object(r.o)("upVector")],t.prototype,"_upVector",void 0),Object(n.c)([Object(r.c)()],t.prototype,"orthoLeft",void 0),Object(n.c)([Object(r.c)()],t.prototype,"orthoRight",void 0),Object(n.c)([Object(r.c)()],t.prototype,"orthoBottom",void 0),Object(n.c)([Object(r.c)()],t.prototype,"orthoTop",void 0),Object(n.c)([Object(r.c)()],t.prototype,"fov",void 0),Object(n.c)([Object(r.c)()],t.prototype,"minZ",void 0),Object(n.c)([Object(r.c)()],t.prototype,"maxZ",void 0),Object(n.c)([Object(r.c)()],t.prototype,"inertia",void 0),Object(n.c)([Object(r.c)()],t.prototype,"mode",void 0),Object(n.c)([Object(r.c)()],t.prototype,"layerMask",void 0),Object(n.c)([Object(r.c)()],t.prototype,"fovMode",void 0),Object(n.c)([Object(r.c)()],t.prototype,"cameraRigMode",void 0),Object(n.c)([Object(r.c)()],t.prototype,"interaxialDistance",void 0),Object(n.c)([Object(r.c)()],t.prototype,"isStereoscopicSideBySide",void 0),t}(l.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return f}));var n=i(1),r=i(3),o=i(12),a=i(6),s=i(22),c=i(61),l=i(85),u=i(2),h=i(8),d=i(64),f=function(){function e(t,i,n){this.shadowDepthWrapper=null,this.allowShaderHotSwapping=!0,this.metadata=null,this.reservedDataStore=null,this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this.onCompiled=null,this.onError=null,this.getRenderTargetTextures=null,this.doNotSerialize=!1,this._storeEffectOnSubMeshes=!1,this.animations=null,this.onDisposeObservable=new a.c,this._onDisposeObserver=null,this._onUnBindObservable=null,this._onBindObserver=null,this._alphaMode=u.a.ALPHA_COMBINE,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.disableColorWrite=!1,this.forceDepthWrite=!1,this.depthFunction=0,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._effect=null,this._useUBO=!1,this._fillMode=e.TriangleFillMode,this._cachedDepthWriteState=!1,this._cachedColorWriteState=!1,this._cachedDepthFunctionState=0,this._indexInSceneMaterialArray=-1,this.meshMap=null,this._forceAlphaTest=!1,this._transparencyMode=null,this.name=t;var r=1;for(this._scene=i||s.a.LastCreatedScene,this.id=t||o.b.RandomId();this._scene.getMaterialByID(this.id);)this.id=t+" "+r++;this.uniqueId=this._scene.getUniqueId(),this._scene.useRightHandedSystem?this.sideOrientation=e.ClockWiseSideOrientation:this.sideOrientation=e.CounterClockWiseSideOrientation,this._uniformBuffer=new l.a(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,n||this._scene.addMaterial(this),this._scene.useMaterialMeshMap&&(this.meshMap={})}return Object.defineProperty(e.prototype,"canRenderToMRT",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alpha",{get:function(){return this._alpha},set:function(t){this._alpha!==t&&(this._alpha=t,this.markAsDirty(e.MiscDirtyFlag))},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new a.c),this._onBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new a.c),this._onUnBindObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onEffectCreatedObservable",{get:function(){return this._onEffectCreatedObservable||(this._onEffectCreatedObservable=new a.c),this._onEffectCreatedObservable},enumerable:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,configurable:!0}),e.prototype.freeze=function(){this.markDirty(),this.checkReadyOnlyOnce=!0},e.prototype.unfreeze=function(){this.markDirty(),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},Object.defineProperty(e.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,this._forceAlphaTest=t===e.MATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_disableAlphaBlending",{get:function(){return this._transparencyMode===e.MATERIAL_OPAQUE||this._transparencyMode===e.MATERIAL_ALPHATEST},enumerable:!1,configurable:!0}),e.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&this.alpha<1},e.prototype.needAlphaBlendingForMesh=function(e){return!(this._disableAlphaBlending&&e.visibility>=1)&&(this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha)},e.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest},e.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},e.prototype.getAlphaTestTexture=function(){return null},e.prototype.markDirty=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){var i=t[e];if(i.subMeshes)for(var n=0,r=i.subMeshes;n<r.length;n++){var o=r[n];o.getMaterial()===this&&(o.effect&&(o.effect._wasPreviouslyReady=!1))}}},e.prototype._preBind=function(t,i){void 0===i&&(i=null);var n=this._scene.getEngine(),r=(null==i?this.sideOrientation:i)===e.ClockWiseSideOrientation;return n.enableEffect(t||this._effect),n.setState(this.backFaceCulling,this.zOffset,!1,r),r},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._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)}if(this.disableColorWrite){t=this._scene.getEngine();this._cachedColorWriteState=t.getColorWrite(),t.setColorWrite(!1)}if(0!==this.depthFunction){t=this._scene.getEngine();this._cachedDepthFunctionState=t.getDepthFunction()||0,t.setDepthFunction(this.depthFunction)}},e.prototype.unbind=function(){(this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),0!==this.depthFunction)&&this._scene.getEngine().setDepthFunction(this._cachedDepthFunctionState);this.disableDepthWrite&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState);this.disableColorWrite&&this._scene.getEngine().setColorWrite(this._cachedColorWriteState)},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 n=this.meshMap[i];n&&t.push(n)}return t}return this._scene.meshes.filter((function(t){return t.material===e}))},e.prototype.forceCompilation=function(e,t,i,r){var o=this,a=Object(n.a)({clipPlane:!1,useInstances:!1},i),s=this.getScene(),l=this.allowShaderHotSwapping;this.allowShaderHotSwapping=!1;var u=function(){if(o._scene&&o._scene.getEngine()){var i=s.clipPlane;if(a.clipPlane&&(s.clipPlane=new d.a(0,0,0,1)),o._storeEffectOnSubMeshes){var n=!0,h=null;if(e.subMeshes){var f=new c.a(0,0,0,0,0,e,void 0,!1,!1);f._materialDefines&&(f._materialDefines._renderId=-1),o.isReadyForSubMesh(e,f,a.useInstances)||(f.effect&&f.effect.getCompilationError()&&f.effect.allFallbacksProcessed()?h=f.effect.getCompilationError():(n=!1,setTimeout(u,16)))}n&&(o.allowShaderHotSwapping=l,h&&r&&r(h),t&&t(o))}else o.isReady()?(o.allowShaderHotSwapping=l,t&&t(o)):setTimeout(u,16);a.clipPlane&&(s.clipPlane=i)}};u()},e.prototype.forceCompilationAsync=function(e,t){var i=this;return new Promise((function(n,r){i.forceCompilation(e,(function(){n()}),t,(function(e){r(e)}))}))},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),t&e.PrePassDirtyFlag&&e._DirtyCallbackArray.push(e._PrePassDirtyCallBack),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 n=i[t];if(n.subMeshes)for(var r=0,o=n.subMeshes;r<o.length;r++){var a=o[r];a.getMaterial()===this&&(a._materialDefines&&e(a._materialDefines))}}},e.prototype._markScenePrePassDirty=function(){if(!this.getScene().blockMaterialDirtyMechanism){var e=this.getScene().enablePrePassRenderer();e&&e.markAsDirty()}},e.prototype._markAllSubMeshesAsAllDirty=function(){this._markAllSubMeshesAsDirty(e._AllDirtyCallBack)},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._markAllSubMeshesAsPrePassDirty=function(){this._markAllSubMeshesAsDirty(e._MiscDirtyCallBack)},e.prototype._markAllSubMeshesAsTexturesAndMiscDirty=function(){this._markAllSubMeshesAsDirty(e._TextureAndMiscDirtyCallBack)},e.prototype.setPrePassRenderer=function(e){return!1},e.prototype.dispose=function(e,t,i){var n=this.getScene();if(n.stopAnimation(this),n.freeProcessedMaterials(),n.removeMaterial(this),!0!==i)if(this.meshMap)for(var r in this.meshMap){(s=this.meshMap[r])&&(s.material=null,this.releaseVertexArrayObject(s,e))}else for(var o=0,a=n.meshes;o<a.length;o++){var s;(s=a[o]).material!==this||s.sourceMesh||(s.material=null,this.releaseVertexArrayObject(s,e))}this._uniformBuffer.dispose(),e&&this._effect&&(this._storeEffectOnSubMeshes||this._effect.dispose(),this._effect=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear(),this._onEffectCreatedObservable&&this._onEffectCreatedObservable.clear()},e.prototype.releaseVertexArrayObject=function(e,t){if(e.geometry){var i=e.geometry;if(this._storeEffectOnSubMeshes)for(var n=0,r=e.subMeshes;n<r.length;n++){var o=r[n];i._releaseVertexArrayObject(o._materialEffect),t&&o._materialEffect&&o._materialEffect.dispose()}else i._releaseVertexArrayObject(this._effect)}},e.prototype.serialize=function(){return r.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 h.a.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."),null}else e.customType="BABYLON.StandardMaterial";return o.b.Instantiate(e.customType).Parse(e,t,i)},e.TriangleFillMode=u.a.MATERIAL_TriangleFillMode,e.WireFrameFillMode=u.a.MATERIAL_WireFrameFillMode,e.PointFillMode=u.a.MATERIAL_PointFillMode,e.PointListDrawMode=u.a.MATERIAL_PointListDrawMode,e.LineListDrawMode=u.a.MATERIAL_LineListDrawMode,e.LineLoopDrawMode=u.a.MATERIAL_LineLoopDrawMode,e.LineStripDrawMode=u.a.MATERIAL_LineStripDrawMode,e.TriangleStripDrawMode=u.a.MATERIAL_TriangleStripDrawMode,e.TriangleFanDrawMode=u.a.MATERIAL_TriangleFanDrawMode,e.ClockWiseSideOrientation=u.a.MATERIAL_ClockWiseSideOrientation,e.CounterClockWiseSideOrientation=u.a.MATERIAL_CounterClockWiseSideOrientation,e.TextureDirtyFlag=u.a.MATERIAL_TextureDirtyFlag,e.LightDirtyFlag=u.a.MATERIAL_LightDirtyFlag,e.FresnelDirtyFlag=u.a.MATERIAL_FresnelDirtyFlag,e.AttributesDirtyFlag=u.a.MATERIAL_AttributesDirtyFlag,e.MiscDirtyFlag=u.a.MATERIAL_MiscDirtyFlag,e.PrePassDirtyFlag=u.a.MATERIAL_PrePassDirtyFlag,e.AllDirtyFlag=u.a.MATERIAL_AllDirtyFlag,e.MATERIAL_OPAQUE=0,e.MATERIAL_ALPHATEST=1,e.MATERIAL_ALPHABLEND=2,e.MATERIAL_ALPHATESTANDBLEND=3,e.MATERIAL_NORMALBLENDMETHOD_WHITEOUT=0,e.MATERIAL_NORMALBLENDMETHOD_RNM=1,e._AllDirtyCallBack=function(e){return e.markAllAsDirty()},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._PrePassDirtyCallBack=function(e){return e.markAsPrePassDirty()},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,n=e._DirtyCallbackArray;i<n.length;i++){(0,n[i])(t)}},Object(n.c)([Object(r.c)()],e.prototype,"id",void 0),Object(n.c)([Object(r.c)()],e.prototype,"uniqueId",void 0),Object(n.c)([Object(r.c)()],e.prototype,"name",void 0),Object(n.c)([Object(r.c)()],e.prototype,"checkReadyOnEveryCall",void 0),Object(n.c)([Object(r.c)()],e.prototype,"checkReadyOnlyOnce",void 0),Object(n.c)([Object(r.c)()],e.prototype,"state",void 0),Object(n.c)([Object(r.c)("alpha")],e.prototype,"_alpha",void 0),Object(n.c)([Object(r.c)("backFaceCulling")],e.prototype,"_backFaceCulling",void 0),Object(n.c)([Object(r.c)()],e.prototype,"sideOrientation",void 0),Object(n.c)([Object(r.c)("alphaMode")],e.prototype,"_alphaMode",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_needDepthPrePass",void 0),Object(n.c)([Object(r.c)()],e.prototype,"disableDepthWrite",void 0),Object(n.c)([Object(r.c)()],e.prototype,"disableColorWrite",void 0),Object(n.c)([Object(r.c)()],e.prototype,"forceDepthWrite",void 0),Object(n.c)([Object(r.c)()],e.prototype,"depthFunction",void 0),Object(n.c)([Object(r.c)()],e.prototype,"separateCullingPass",void 0),Object(n.c)([Object(r.c)("fogEnabled")],e.prototype,"_fogEnabled",void 0),Object(n.c)([Object(r.c)()],e.prototype,"pointSize",void 0),Object(n.c)([Object(r.c)()],e.prototype,"zOffset",void 0),Object(n.c)([Object(r.c)()],e.prototype,"pointsCloud",null),Object(n.c)([Object(r.c)()],e.prototype,"fillMode",null),Object(n.c)([Object(r.c)()],e.prototype,"transparencyMode",null),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return T}));var n=i(22),r=i(5),o=i(21),a=i(6),s=i(141),c=i(142),l=i(143),u=i(2),h=i(27),d=i(8),f=i(38),p=function(){function e(){}return e.prototype.postProcessor=function(e,t,i,n){if(!n.getCaps().drawBuffersExtension){e=e.replace(/#extension.+GL_EXT_draw_buffers.+(enable|require)/g,"")}return e},e}(),_=i(118),m=i(88),g=i(144),v=i(70),b=i(74),y=function(){},T=function(){function e(t,i,n,r){var o=this;void 0===r&&(r=!1),this.forcePOTTextures=!1,this.isFullscreen=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.validateShaderPrograms=!1,this.useReverseDepthBuffer=!1,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this._webGLVersion=1,this._windowIsBackground=!1,this._highPrecisionShadersAllowed=!0,this._badOS=!1,this._badDesktopOS=!1,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this.onContextLostObservable=new a.c,this.onContextRestoredObservable=new a.c,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this.disableVertexArrayObjects=!1,this._colorWrite=!0,this._colorWriteChanged=!0,this._depthCullingState=new s.a,this._stencilState=new c.a,this._alphaState=new l.a,this._alphaMode=u.a.ALPHA_ADD,this._alphaEquation=u.a.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._dummyFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._activeRequests=new Array,this._transformTextureUrl=null,this.hostInformation={isMobile:!1},this.premultipliedAlpha=!0,this.onBeforeTextureInitObservable=new a.c,this._viewportCached={x:0,y:0,z:0,w:0},this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._getDepthStencilBuffer=function(e,t,i,n,r,a){var s=o._gl,c=s.createRenderbuffer();return s.bindRenderbuffer(s.RENDERBUFFER,c),i>1&&s.renderbufferStorageMultisample?s.renderbufferStorageMultisample(s.RENDERBUFFER,i,r,e,t):s.renderbufferStorage(s.RENDERBUFFER,n,e,t),s.framebufferRenderbuffer(s.FRAMEBUFFER,a,s.RENDERBUFFER,c),s.bindRenderbuffer(s.RENDERBUFFER,null),c},this._boundUniforms={};var h=null;if(t){if(n=n||{},b.a.SetMatrixPrecision(!!n.useHighPrecisionMatrix),t.getContext){if(h=t,this._renderingCanvas=h,null!=i&&(n.antialias=i),void 0===n.deterministicLockstep&&(n.deterministicLockstep=!1),void 0===n.lockstepMaxSteps&&(n.lockstepMaxSteps=4),void 0===n.timeStep&&(n.timeStep=1/60),void 0===n.preserveDrawingBuffer&&(n.preserveDrawingBuffer=!1),void 0===n.audioEngine&&(n.audioEngine=!0),void 0===n.stencil&&(n.stencil=!0),!1===n.premultipliedAlpha&&(this.premultipliedAlpha=!1),void 0===n.xrCompatible&&(n.xrCompatible=!0),this._doNotHandleContextLost=!!n.doNotHandleContextLost,navigator&&navigator.userAgent){var m=navigator.userAgent;this.hostInformation.isMobile=-1!==m.indexOf("Mobile");for(var g=0,v=e.ExceptionList;g<v.length;g++){var T=v[g],E=T.key,S=T.targets;if(new RegExp(E).test(m)){if(T.capture&&T.captureConstraint){var A=T.capture,P=T.captureConstraint,C=new RegExp(A).exec(m);if(C&&C.length>0)if(parseInt(C[C.length-1])>=P)continue}for(var R=0,x=S;R<x.length;R++){switch(x[R]){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"vao":this.disableVertexArrayObjects=!0}}}}}if(this._doNotHandleContextLost||(this._onContextLost=function(e){e.preventDefault(),o._contextWasLost=!0,d.a.Warn("WebGL context lost."),o.onContextLostObservable.notifyObservers(o)},this._onContextRestored=function(){setTimeout((function(){o._initGLContext(),o._rebuildEffects(),o._rebuildInternalTextures(),o._rebuildBuffers(),o.wipeCaches(!0),d.a.Warn("WebGL context successfully restored."),o.onContextRestoredObservable.notifyObservers(o),o._contextWasLost=!1}),0)},h.addEventListener("webglcontextlost",this._onContextLost,!1),h.addEventListener("webglcontextrestored",this._onContextRestored,!1),n.powerPreference="high-performance"),!n.disableWebGL2Support)try{this._gl=h.getContext("webgl2",n)||h.getContext("experimental-webgl2",n),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",n)||h.getContext("experimental-webgl",n)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported")}else{this._gl=t,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2);var O=this._gl.getContextAttributes();O&&(n.stencil=O.stencil)}this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),void 0!==n.useHighPrecisionFloats&&(this._highPrecisionShadersAllowed=n.useHighPrecisionFloats);var M=f.a.IsWindowObjectExist()&&window.devicePixelRatio||1,I=n.limitDeviceRatio||M;this._hardwareScalingLevel=r?1/Math.min(I,M):1,this.resize(),this._isStencilEnable=!!n.stencil,this._initGLContext();for(var D=0;D<this._caps.maxVertexAttribs;D++)this._currentBufferPointers[D]=new y;this.webGLVersion>1?this._shaderProcessor=new _.a:this._shaderProcessor=new p,this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),this._creationOptions=n,console.log("Babylon.js v"+e.Version+" - "+this.description)}}return Object.defineProperty(e,"NpmPackage",{get:function(){return"babylonjs@4.2.0"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"Version",{get:function(){return"4.2.0"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"description",{get:function(){var e="WebGL"+this.webGLVersion;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShadersRepository",{get:function(){return r.a.ShadersRepository},set:function(e){r.a.ShadersRepository=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_shouldUseHighPrecisionShader",{get:function(){return!(!this._caps.highPrecisionShaderSupported||!this._highPrecisionShadersAllowed)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"_supportsHardwareTextureRescaling",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framebufferDimensionsObject",{set:function(e){this._framebufferDimensionsObject=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture2DArray",{get:function(){return this._emptyTexture2DArray||(this._emptyTexture2DArray=this.createRawTexture2DArray(new Uint8Array(4),1,1,1,u.a.TEXTUREFORMAT_RGBA,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture2DArray},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,u.a.TEXTUREFORMAT_RGBA,u.a.TEXTURETYPE_UNSIGNED_INT,!1,!1,u.a.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),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()}r.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._uniformBuffers;e<t.length;e++){t[e]._rebuild()}},e.prototype._initGLContext=function(){this._caps={maxTexturesImageUnits:this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),maxCombinedTexturesImageUnits:this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),maxVertexTextureImageUnits:this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),maxTextureSize:this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),maxSamples:this._webGLVersion>1?this._gl.getParameter(this._gl.MAX_SAMPLES):1,maxCubemapTextureSize:this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),maxRenderTextureSize:this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),maxVertexAttribs:this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),maxVaryingVectors:this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),maxFragmentUniformVectors:this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),maxVertexUniformVectors:this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),parallelShaderCompile:this._gl.getExtension("KHR_parallel_shader_compile"),standardDerivatives:this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),maxAnisotropy:1,astc:this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),bptc:this._gl.getExtension("EXT_texture_compression_bptc")||this._gl.getExtension("WEBKIT_EXT_texture_compression_bptc"),s3tc:this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),pvrtc:this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),etc1:this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),etc2:this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),textureAnisotropicFilterExtension:this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),uintIndices:this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),fragmentDepthSupported:this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),highPrecisionShaderSupported:!1,timerQuery:this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),canUseTimestampForTimerQuery:!1,drawBuffersExtension:!1,maxMSAASamples:1,colorBufferFloat:this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),textureFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),textureHalfFloat:!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),textureHalfFloatRender:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloatLinearFiltering:!1,vertexArrayObject:!1,instancedArrays:!1,textureLOD:!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),blendMinMax:!1,multiview:this._gl.getExtension("OVR_multiview2"),oculusMultiview:this._gl.getExtension("OCULUS_multiview"),depthTextureExtension:!1},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"),36193!==this._gl.HALF_FLOAT_OES&&(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.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.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._webGLVersion>1&&5131!==this._gl.HALF_FLOAT_OES&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._webGLVersion>1)this._caps.drawBuffersExtension=!0,this._caps.maxMSAASamples=this._gl.getParameter(this._gl.MAX_SAMPLES);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"]}}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.disableVertexArrayObjects)this._caps.vertexArrayObject=!1;else if(this._webGLVersion>1)this._caps.vertexArrayObject=!0;else{var r=this._gl.getExtension("OES_vertex_array_object");null!=r&&(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=r.createVertexArrayOES.bind(r),this._gl.bindVertexArray=r.bindVertexArrayOES.bind(r),this._gl.deleteVertexArray=r.deleteVertexArrayOES.bind(r))}if(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var o=this._gl.getExtension("ANGLE_instanced_arrays");null!=o?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=o.drawArraysInstancedANGLE.bind(o),this._gl.drawElementsInstanced=o.drawElementsInstancedANGLE.bind(o),this._gl.vertexAttribDivisor=o.vertexAttribDivisorANGLE.bind(o)):this._caps.instancedArrays=!1}if(this._gl.getShaderPrecisionFormat){var a=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);a&&s&&(this._caps.highPrecisionShaderSupported=0!==a.precision&&0!==s.precision)}if(this._webGLVersion>1)this._caps.blendMinMax=!0;else{var c=this._gl.getExtension("EXT_blend_minmax");null!=c&&(this._caps.blendMinMax=!0,this._gl.MAX=c.MAX_EXT,this._gl.MIN=c.MIN_EXT)}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!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:!1,configurable:!0}),e.prototype.getClassName=function(){return"ThinEngine"},Object.defineProperty(e.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!1,configurable:!0}),e.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=v.a.CreateCanvas(1,1);var e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}},e.prototype.resetTextureCache=function(){for(var e in this._boundTexturesCache)this._boundTexturesCache.hasOwnProperty(e)&&(this._boundTexturesCache[e]=null);this._currentTextureChannel=-1},e.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},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.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._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},e.prototype.getRenderingCanvas=function(){return this._renderingCanvas},e.prototype.getHostWindow=function(){return f.a.IsWindowObjectExist()?this._renderingCanvas&&this._renderingCanvas.ownerDocument&&this._renderingCanvas.ownerDocument.defaultView?this._renderingCanvas.ownerDocument.defaultView:window:null},e.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferWidth:this._gl.drawingBufferWidth},e.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._framebufferDimensionsObject?this._framebufferDimensionsObject.framebufferHeight:this._gl.drawingBufferHeight},e.prototype._queueNewFrame=function(t,i){return e.QueueNewFrame(t,i)},e.prototype.runRenderLoop=function(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._boundRenderFunction=this._renderLoop.bind(this),this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow())))},e.prototype.clear=function(e,t,i,n){void 0===n&&(n=!1),this.applyStates();var r=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),r|=this._gl.COLOR_BUFFER_BIT),i&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GREATER,this._gl.clearDepth(0)):this._gl.clearDepth(1),r|=this._gl.DEPTH_BUFFER_BIT),n&&(this._gl.clearStencil(0),r|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(r)},e.prototype._viewport=function(e,t,i,n){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&n===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=n,this._gl.viewport(e,t,i,n))},e.prototype.setViewport=function(e,t,i){var n=t||this.getRenderWidth(),r=i||this.getRenderHeight(),o=e.x||0,a=e.y||0;this._cachedViewport=e,this._viewport(o*n,a*r,n*e.width,r*e.height)},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer()},e.prototype.resize=function(){var e,t;f.a.IsWindowObjectExist()?(e=this._renderingCanvas?this._renderingCanvas.clientWidth||this._renderingCanvas.width:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight||this._renderingCanvas.height:window.innerHeight):(e=this._renderingCanvas?this._renderingCanvas.width:100,t=this._renderingCanvas?this._renderingCanvas.height:100),this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)},e.prototype.setSize=function(e,t){return!!this._renderingCanvas&&(e|=0,t|=0,(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)&&(this._renderingCanvas.width=e,this._renderingCanvas.height=t,!0))},e.prototype.bindFramebuffer=function(e,t,i,n,r,o,a){void 0===t&&(t=0),void 0===o&&(o=0),void 0===a&&(a=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var s=this._gl;e.is2DArray?s.framebufferTextureLayer(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,e._webGLTexture,o,a):e.isCube&&s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,o);var c=e._depthStencilTexture;if(c){var l=c._generateStencilBuffer?s.DEPTH_STENCIL_ATTACHMENT:s.DEPTH_ATTACHMENT;e.is2DArray?s.framebufferTextureLayer(s.FRAMEBUFFER,l,c._webGLTexture,o,a):e.isCube?s.framebufferTexture2D(s.FRAMEBUFFER,l,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,c._webGLTexture,o):s.framebufferTexture2D(s.FRAMEBUFFER,l,s.TEXTURE_2D,c._webGLTexture,o)}this._cachedViewport&&!r?this.setViewport(this._cachedViewport,i,n):(i||(i=e.width,o&&(i/=Math.pow(2,o))),n||(n=e.height,o&&(n/=Math.pow(2,o))),this._viewport(0,0,i,n)),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 n=this._gl;if(e._MSAAFramebuffer){if(e._textureArray)return void this.unBindMultiColorAttachmentFramebuffer(e._textureArray,t,i);n.bindFramebuffer(n.READ_FRAMEBUFFER,e._MSAAFramebuffer),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,e._framebuffer),n.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,n.COLOR_BUFFER_BIT,n.NEAREST)}!e.generateMipMaps||t||e.isCube||(this._bindTextureDirectly(n.TEXTURE_2D,e,!0),n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null)),i&&(e._MSAAFramebuffer&&this._bindUnboundFramebuffer(e._framebuffer),i()),this._bindUnboundFramebuffer(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._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},e.prototype.createVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.STATIC_DRAW)},e.prototype._createVertexBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error("Unable to create vertex buffer");var n=new m.a(i);return this.bindArrayBuffer(n),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(),n.references=1,n},e.prototype.createDynamicVertexBuffer=function(e){return this._createVertexBuffer(e,this._gl.DYNAMIC_DRAW)},e.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},e.prototype.createIndexBuffer=function(e,t){var i=this._gl.createBuffer(),n=new m.a(i);if(!i)throw new Error("Unable to create index buffer");this.bindIndexBuffer(n);var r=this._normalizeIndexData(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),n.references=1,n.is32Bits=4===r.BYTES_PER_ELEMENT,n},e.prototype._normalizeIndexData=function(e){if(e instanceof Uint16Array)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(var t=0;t<e.length;t++)if(e[t]>=65535)return new Uint32Array(e);return new Uint16Array(e)}return new Uint16Array(e)},e.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},e.prototype.bindUniformBlock=function(e,t,i){var n=e.program,r=this._gl.getUniformBlockIndex(n,t);this._gl.uniformBlockBinding(n,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?e.underlyingResource:null),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,n,r,o,a){var s=this._currentBufferPointers[t];if(s){var c=!1;s.active?(s.buffer!==e&&(s.buffer=e,c=!0),s.size!==i&&(s.size=i,c=!0),s.type!==n&&(s.type=n,c=!0),s.normalized!==r&&(s.normalized=r,c=!0),s.stride!==o&&(s.stride=o,c=!0),s.offset!==a&&(s.offset=a,c=!0)):(c=!0,s.active=!0,s.index=t,s.size=i,s.type=n,s.normalized=r,s.stride=o,s.offset=a,s.buffer=e),(c||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,n,r,o,a))}},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 n=0;n<i.length;n++){var r=t.getAttributeLocation(n);if(r>=0){var o=e[i[n]];if(!o)continue;this._gl.enableVertexAttribArray(r),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[r]=!0);var a=o.getBuffer();a&&(this._vertexAttribPointer(a,r,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(r,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(a))))}}},e.prototype.recordVertexArrayObject=function(e,t,i){var n=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(n),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),n},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,n,r){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==r){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=r;var o=r.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var a=0,s=0;s<o;s++)if(s<i.length){var c=r.getAttributeLocation(s);c>=0&&(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0,this._vertexAttribPointer(e,c,i[s],this._gl.FLOAT,!1,n,a)),a+=4*i[s]}}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 n=this._currentInstanceBuffers[t];e!=n&&n.references&&(e=n,this.bindArrayBuffer(n));var r=this._currentInstanceLocations[t];this._gl.vertexAttribDivisor(r,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._deleteBuffer(e),!0)},e.prototype._deleteBuffer=function(e){this._gl.deleteBuffer(e.underlyingResource)},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)this.bindInstancesBuffer(e,i,!0);else for(var n=0;n<4;n++){var r=i[n];this._vertexAttribArraysEnabled[r]||(this._gl.enableVertexAttribArray(r),this._vertexAttribArraysEnabled[r]=!0),this._vertexAttribPointer(e,r,4,this._gl.FLOAT,!1,64,16*n),this._gl.vertexAttribDivisor(r,1),this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(e)}},e.prototype.bindInstancesBuffer=function(e,t,i){void 0===i&&(i=!0),this.bindArrayBuffer(e);var n=0;if(i)for(var r=0;r<t.length;r++){n+=4*(o=t[r]).attributeSize}for(r=0;r<t.length;r++){var o;void 0===(o=t[r]).index&&(o.index=this._currentEffect.getAttributeLocationByName(o.attributeName)),o.index<0||(this._vertexAttribArraysEnabled[o.index]||(this._gl.enableVertexAttribArray(o.index),this._vertexAttribArraysEnabled[o.index]=!0),this._vertexAttribPointer(e,o.index,o.attributeSize,o.attributeType||this._gl.FLOAT,o.normalized||!1,n,o.offset),this._gl.vertexAttribDivisor(o.index,void 0===o.divisor?1:o.divisor),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e))}},e.prototype.disableInstanceAttributeByName=function(e){if(this._currentEffect){var t=this._currentEffect.getAttributeLocationByName(e);this.disableInstanceAttribute(t)}},e.prototype.disableInstanceAttribute=function(e){for(var t,i=!1;-1!==(t=this._currentInstanceLocations.indexOf(e));)this._currentInstanceLocations.splice(t,1),this._currentInstanceBuffers.splice(t,1),i=!0,t=this._currentInstanceLocations.indexOf(e);i&&(this._gl.vertexAttribDivisor(e,0),this.disableAttributeByIndex(e))},e.prototype.disableAttributeByIndex=function(e){this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1},e.prototype.draw=function(e,t,i,n){this.drawElementsType(e?u.a.MATERIAL_TriangleFillMode:u.a.MATERIAL_WireFrameFillMode,t,i,n)},e.prototype.drawPointClouds=function(e,t,i){this.drawArraysType(u.a.MATERIAL_PointFillMode,e,t,i)},e.prototype.drawUnIndexed=function(e,t,i,n){this.drawArraysType(e?u.a.MATERIAL_TriangleFillMode:u.a.MATERIAL_WireFrameFillMode,t,i,n)},e.prototype.drawElementsType=function(e,t,i,n){this.applyStates(),this._reportDrawCall();var r=this._drawMode(e),o=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,a=this._uintIndicesCurrentlySet?4:2;n?this._gl.drawElementsInstanced(r,i,o,t*a,n):this._gl.drawElements(r,i,o,t*a)},e.prototype.drawArraysType=function(e,t,i,n){this.applyStates(),this._reportDrawCall();var r=this._drawMode(e);n?this._gl.drawArraysInstanced(r,t,i,n):this._gl.drawArrays(r,t,i)},e.prototype._drawMode=function(e){switch(e){case u.a.MATERIAL_TriangleFillMode:return this._gl.TRIANGLES;case u.a.MATERIAL_PointFillMode:return this._gl.POINTS;case u.a.MATERIAL_WireFrameFillMode:return this._gl.LINES;case u.a.MATERIAL_PointListDrawMode:return this._gl.POINTS;case u.a.MATERIAL_LineListDrawMode:return this._gl.LINES;case u.a.MATERIAL_LineLoopDrawMode:return this._gl.LINE_LOOP;case u.a.MATERIAL_LineStripDrawMode:return this._gl.LINE_STRIP;case u.a.MATERIAL_TriangleStripDrawMode:return this._gl.TRIANGLE_STRIP;case u.a.MATERIAL_TriangleFanDrawMode:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}},e.prototype._reportDrawCall=function(){},e.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deletePipelineContext(e.getPipelineContext()))},e.prototype._deletePipelineContext=function(e){var t=e;t&&t.program&&(t.program.__SPECTOR_rebuildProgram=null,this._gl.deleteProgram(t.program))},e.prototype.createEffect=function(e,t,i,n,o,a,s,c,l){var u=(e.vertexElement||e.vertex||e.vertexToken||e.vertexSource||e)+"+"+(e.fragmentElement||e.fragment||e.fragmentToken||e.fragmentSource||e)+"@"+(o||t.defines);if(this._compiledEffects[u]){var h=this._compiledEffects[u];return s&&h.isReady()&&s(h),h}var d=new r.a(e,t,i,n,this,o,a,s,c,l);return d._key=u,this._compiledEffects[u]=d,d},e._ConcatenateShader=function(e,t,i){return void 0===i&&(i=""),i+(t?t+"\n":"")+e},e.prototype._compileShader=function(t,i,n,r){return this._compileRawShader(e._ConcatenateShader(t,n,r),i)},e.prototype._compileRawShader=function(e,t){var i=this._gl,n=i.createShader("vertex"===t?i.VERTEX_SHADER:i.FRAGMENT_SHADER);if(!n)throw new Error("Something went wrong while compile the shader.");return i.shaderSource(n,e),i.compileShader(n),n},e.prototype._getShaderSource=function(e){return this._gl.getShaderSource(e)},e.prototype.createRawShaderProgram=function(e,t,i,n,r){void 0===r&&(r=null),n=n||this._gl;var o=this._compileRawShader(t,"vertex"),a=this._compileRawShader(i,"fragment");return this._createShaderProgram(e,o,a,n,r)},e.prototype.createShaderProgram=function(e,t,i,n,r,o){void 0===o&&(o=null),r=r||this._gl;var a=this._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"",s=this._compileShader(t,"vertex",n,a),c=this._compileShader(i,"fragment",n,a);return this._createShaderProgram(e,s,c,r,o)},e.prototype.createPipelineContext=function(){var e=new g.a;return e.engine=this,this._caps.parallelShaderCompile&&(e.isParallelCompiled=!0),e},e.prototype._createShaderProgram=function(e,t,i,n,r){void 0===r&&(r=null);var o=n.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");return n.attachShader(o,t),n.attachShader(o,i),n.linkProgram(o),e.context=n,e.vertexShader=t,e.fragmentShader=i,e.isParallelCompiled||this._finalizePipelineContext(e),o},e.prototype._finalizePipelineContext=function(e){var t=e.context,i=e.vertexShader,n=e.fragmentShader,r=e.program;if(!t.getProgramParameter(r,t.LINK_STATUS)){var o,a;if(!this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(i))throw e.vertexCompilationError=o,new Error("VERTEX SHADER "+o);if(!this._gl.getShaderParameter(n,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(n))throw e.fragmentCompilationError=o,new Error("FRAGMENT SHADER "+o);if(a=t.getProgramInfoLog(r))throw e.programLinkError=a,new Error(a)}if(this.validateShaderPrograms&&(t.validateProgram(r),!t.getProgramParameter(r,t.VALIDATE_STATUS)&&(a=t.getProgramInfoLog(r))))throw e.programValidationError=a,new Error(a);t.deleteShader(i),t.deleteShader(n),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)},e.prototype._preparePipelineContext=function(e,t,i,n,r,o,a){var s=e;s.program=n?this.createRawShaderProgram(s,t,i,void 0,a):this.createShaderProgram(s,t,i,o,void 0,a),s.program.__SPECTOR_rebuildProgram=r},e.prototype._isRenderingStateCompiled=function(e){var t=e;return!!this._gl.getProgramParameter(t.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(this._finalizePipelineContext(t),!0)},e.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var i=e;if(i.isParallelCompiled){var n=i.onCompiled;i.onCompiled=n?function(){n(),t()}:t}else t()},e.prototype.getUniforms=function(e,t){for(var i=new Array,n=e,r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(n.program,t[r]));return i},e.prototype.getAttributes=function(e,t){for(var i=[],n=e,r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(n.program,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.setInt=function(e,t){return!!e&&(this._gl.uniform1i(e,t),!0)},e.prototype.setIntArray=function(e,t){return!!e&&(this._gl.uniform1iv(e,t),!0)},e.prototype.setIntArray2=function(e,t){return!(!e||t.length%2!=0)&&(this._gl.uniform2iv(e,t),!0)},e.prototype.setIntArray3=function(e,t){return!(!e||t.length%3!=0)&&(this._gl.uniform3iv(e,t),!0)},e.prototype.setIntArray4=function(e,t){return!(!e||t.length%4!=0)&&(this._gl.uniform4iv(e,t),!0)},e.prototype.setArray=function(e,t){return!!e&&(this._gl.uniform1fv(e,t),!0)},e.prototype.setArray2=function(e,t){return!(!e||t.length%2!=0)&&(this._gl.uniform2fv(e,t),!0)},e.prototype.setArray3=function(e,t){return!(!e||t.length%3!=0)&&(this._gl.uniform3fv(e,t),!0)},e.prototype.setArray4=function(e,t){return!(!e||t.length%4!=0)&&(this._gl.uniform4fv(e,t),!0)},e.prototype.setMatrices=function(e,t){return!!e&&(this._gl.uniformMatrix4fv(e,!1,t),!0)},e.prototype.setMatrix3x3=function(e,t){return!!e&&(this._gl.uniformMatrix3fv(e,!1,t),!0)},e.prototype.setMatrix2x2=function(e,t){return!!e&&(this._gl.uniformMatrix2fv(e,!1,t),!0)},e.prototype.setFloat=function(e,t){return!!e&&(this._gl.uniform1f(e,t),!0)},e.prototype.setFloat2=function(e,t,i){return!!e&&(this._gl.uniform2f(e,t,i),!0)},e.prototype.setFloat3=function(e,t,i,n){return!!e&&(this._gl.uniform3f(e,t,i,n),!0)},e.prototype.setFloat4=function(e,t,i,n,r){return!!e&&(this._gl.uniform4f(e,t,i,n,r),!0)},e.prototype.applyStates=function(){if(this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl),this._colorWriteChanged){this._colorWriteChanged=!1;var e=this._colorWrite;this._gl.colorMask(e,e,e,e)}},e.prototype.setColorWrite=function(e){e!==this._colorWrite&&(this._colorWriteChanged=!0,this._colorWrite=e)},e.prototype.getColorWrite=function(){return this._colorWrite},Object.defineProperty(e.prototype,"depthCullingState",{get:function(){return this._depthCullingState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaState",{get:function(){return this._alphaState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilState",{get:function(){return this._stencilState},enumerable:!1,configurable:!0}),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,this._unbindVertexArrayObject(),e&&(this._currentProgram=null,this.resetTextureCache(),this._stencilState.reset(),this._depthCullingState.reset(),this._depthCullingState.depthFunc=this._gl.LEQUAL,this._alphaState.reset(),this._alphaMode=u.a.ALPHA_ADD,this._alphaEquation=u.a.ALPHA_DISABLE,this._colorWrite=!0,this._colorWriteChanged=!0,this._unpackFlipYCached=null,this._gl.pixelStorei(this._gl.UNPACK_COLORSPACE_CONVERSION_WEBGL,this._gl.NONE),this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),this._mustWipeVertexAttributes=!0,this.unbindAllAttributes()),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this.bindIndexBuffer(null))},e.prototype._getSamplingParameters=function(e,t){var i=this._gl,n=i.NEAREST,r=i.NEAREST;switch(e){case u.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:n=i.LINEAR,r=t?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case u.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:n=i.LINEAR,r=t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case u.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:n=i.NEAREST,r=t?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case u.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:n=i.NEAREST,r=t?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case u.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:n=i.NEAREST,r=t?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case u.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:n=i.NEAREST,r=t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case u.a.TEXTURE_NEAREST_LINEAR:n=i.NEAREST,r=i.LINEAR;break;case u.a.TEXTURE_NEAREST_NEAREST:n=i.NEAREST,r=i.NEAREST;break;case u.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:n=i.LINEAR,r=t?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case u.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:n=i.LINEAR,r=t?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case u.a.TEXTURE_LINEAR_LINEAR:n=i.LINEAR,r=i.LINEAR;break;case u.a.TEXTURE_LINEAR_NEAREST:n=i.LINEAR,r=i.NEAREST}return{min:r,mag:n}},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,o,a,s,c,l,f,p,_,m,g){var v=this;void 0===a&&(a=u.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===f&&(f=null),void 0===p&&(p=null),void 0===_&&(_=null);var b="data:"===(t=t||"").substr(0,5),y="blob:"===t.substr(0,5),T=b&&-1!==t.indexOf(";base64,"),E=f||new h.a(this,h.b.Url),S=t;!this._transformTextureUrl||T||f||l||(t=this._transformTextureUrl(t)),S!==t&&(E._originalUrl=S);var A=t.lastIndexOf("."),P=_||(A>-1?t.substring(A).toLowerCase():""),C=null;P.indexOf("?")>-1&&(P=P.split("?")[0]);for(var R=0,x=e._TextureLoaders;R<x.length;R++){var O=x[R];if(O.canLoad(P,m)){C=O;break}}o&&o._addPendingData(E),E.url=t,E.generateMipMaps=!i,E.samplingMode=a,E.invertY=r,this._doNotHandleContextLost||(E._buffer=l);var M=null;s&&!f&&(M=E.onLoadedObservable.add(s)),f||this._internalTexturesCache.push(E);var I=function(e,r){o&&o._removePendingData(E),t===S?(M&&E.onLoadedObservable.remove(M),n.a.UseFallbackTexture&&v.createTexture(n.a.FallbackTexture,i,E.invertY,o,a,null,c,l,E),c&&c((e||"Unknown error")+(n.a.UseFallbackTexture?" - Fallback texture was used":""),r)):(d.a.Warn("Failed to load "+t+", falling back to "+S),v.createTexture(S,i,E.invertY,o,a,s,c,l,E,p,_,m,g))};if(C){var D=function(e){C.loadData(e,E,(function(e,t,i,n,r,s){s?I("TextureLoader failed to load data"):v._prepareWebGLTexture(E,o,e,t,E.invertY,!i,n,(function(){return r(),!1}),a)}),g)};l?l instanceof ArrayBuffer?D(new Uint8Array(l)):ArrayBuffer.isView(l)?D(l):c&&c("Unable to load: only ArrayBuffer or ArrayBufferView is supported",null):this._loadFile(t,(function(e){return D(new Uint8Array(e))}),void 0,o?o.offlineProvider:void 0,!0,(function(e,t){I("Unable to load "+(e&&e.responseURL,t))}))}else{var N=function(e){y&&!v._doNotHandleContextLost&&(E._buffer=e),v._prepareWebGLTexture(E,o,e.width,e.height,E.invertY,i,!1,(function(t,i,n){var r=v._gl,a=e.width===t&&e.height===i,s=p?v._getInternalFormat(p):".jpg"===P?r.RGB:r.RGBA;if(a)return r.texImage2D(r.TEXTURE_2D,0,s,s,r.UNSIGNED_BYTE,e),!1;var c=v._caps.maxTextureSize;if(e.width>c||e.height>c||!v._supportsHardwareTextureRescaling)return v._prepareWorkingCanvas(),!(!v._workingCanvas||!v._workingContext)&&(v._workingCanvas.width=t,v._workingCanvas.height=i,v._workingContext.drawImage(e,0,0,e.width,e.height,0,0,t,i),r.texImage2D(r.TEXTURE_2D,0,s,s,r.UNSIGNED_BYTE,v._workingCanvas),E.width=t,E.height=i,!1);var l=new h.a(v,h.b.Temp);return v._bindTextureDirectly(r.TEXTURE_2D,l,!0),r.texImage2D(r.TEXTURE_2D,0,s,s,r.UNSIGNED_BYTE,e),v._rescaleTexture(l,E,o,s,(function(){v._releaseTexture(l),v._bindTextureDirectly(r.TEXTURE_2D,E,!0),n()})),!0}),a)};!b||T?l&&(l.decoding||l.close)?N(l):e._FileToolsLoadImage(t,N,I,o?o.offlineProvider:null,m):"string"==typeof l||l instanceof ArrayBuffer||ArrayBuffer.isView(l)||l instanceof Blob?e._FileToolsLoadImage(l,N,I,o?o.offlineProvider:null,m):l&&N(l)}return E},e._FileToolsLoadImage=function(e,t,i,n,r){throw o.a.WarnImport("FileTools")},e.prototype._rescaleTexture=function(e,t,i,n,r){},e.prototype.createRawTexture=function(e,t,i,n,r,a,s,c,l){throw void 0===c&&(c=null),void 0===l&&(l=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport("Engine.RawTexture")},e.prototype.createRawCubeTexture=function(e,t,i,n,r,a,s,c){throw void 0===c&&(c=null),o.a.WarnImport("Engine.RawTexture")},e.prototype.createRawTexture3D=function(e,t,i,n,r,a,s,c,l,h){throw void 0===l&&(l=null),void 0===h&&(h=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport("Engine.RawTexture")},e.prototype.createRawTexture2DArray=function(e,t,i,n,r,a,s,c,l,h){throw void 0===l&&(l=null),void 0===h&&(h=u.a.TEXTURETYPE_UNSIGNED_INT),o.a.WarnImport("Engine.RawTexture")},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._getTextureTarget=function(e){return e.isCube?this._gl.TEXTURE_CUBE_MAP:e.is3D?this._gl.TEXTURE_3D:e.is2DArray||e.isMultiview?this._gl.TEXTURE_2D_ARRAY:this._gl.TEXTURE_2D},e.prototype.updateTextureSamplingMode=function(e,t,i){void 0===i&&(i=!1);var n=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.generateMipMaps||i);this._setTextureParameterInteger(n,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(n,this._gl.TEXTURE_MIN_FILTER,r.min),i&&(t.generateMipMaps=!0,this._gl.generateMipmap(n)),this._bindTextureDirectly(n,null),t.samplingMode=e},e.prototype.updateTextureWrappingMode=function(e,t,i,n){void 0===i&&(i=null),void 0===n&&(n=null);var r=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==i&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i),e),e._cachedWrapV=i),(e.is2DArray||e.is3D)&&null!==n&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(n),e),e._cachedWrapR=n),this._bindTextureDirectly(r,null)},e.prototype._setupDepthStencilTexture=function(e,t,i,n,r){var o=t.width||t,a=t.height||t,s=t.layers||0;e.baseWidth=o,e.baseHeight=a,e.width=o,e.height=a,e.is2DArray=s>0,e.depth=s,e.isReady=!0,e.samples=1,e.generateMipMaps=!1,e._generateDepthBuffer=!0,e._generateStencilBuffer=i,e.samplingMode=n?u.a.TEXTURE_BILINEAR_SAMPLINGMODE:u.a.TEXTURE_NEAREST_SAMPLINGMODE,e.type=u.a.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=r;var c=this._gl,l=this._getTextureTarget(e),h=this._getSamplingParameters(e.samplingMode,!1);c.texParameteri(l,c.TEXTURE_MAG_FILTER,h.mag),c.texParameteri(l,c.TEXTURE_MIN_FILTER,h.min),c.texParameteri(l,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(l,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),0===r?(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,u.a.LEQUAL),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,r),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE))},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0);var s=this._gl,c=s.TEXTURE_2D;e.isCube&&(c=s.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(c,a,t,i,n,0,r)},e.prototype._uploadDataToTextureDirectly=function(e,t,i,n,r,o){void 0===i&&(i=0),void 0===n&&(n=0),void 0===o&&(o=!1);var a=this._gl,s=this._getWebGLTextureType(e.type),c=this._getInternalFormat(e.format),l=void 0===r?this._getRGBABufferInternalSizedFormat(e.type,e.format):this._getInternalFormat(r);this._unpackFlipY(e.invertY);var u=a.TEXTURE_2D;e.isCube&&(u=a.TEXTURE_CUBE_MAP_POSITIVE_X+i);var h=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),f=o?e.width:Math.pow(2,Math.max(h-n,0)),p=o?e.height:Math.pow(2,Math.max(d-n,0));a.texImage2D(u,n,l,f,p,0,c,s,t)},e.prototype.updateTextureData=function(e,t,i,n,r,o,a,s){void 0===a&&(a=0),void 0===s&&(s=0);var c=this._gl,l=this._getWebGLTextureType(e.type),u=this._getInternalFormat(e.format);this._unpackFlipY(e.invertY);var h=c.TEXTURE_2D;e.isCube&&(h=c.TEXTURE_CUBE_MAP_POSITIVE_X+a),c.texSubImage2D(h,s,i,n,r,o,u,l,t)},e.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0);var r=this._gl,o=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,n),this._bindTextureDirectly(o,null,!0)},e.prototype._prepareWebGLTextureContinuation=function(e,t,i,n,r){var o=this._gl;if(o){var a=this._getSamplingParameters(r,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,a.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,a.min),i||n||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,n,r,o,a,s,c,l){var h=this;void 0===l&&(l=u.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,f=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(n,d):n),p=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(r,d):r),_=this._gl;_&&(t._webGLTexture?(this._bindTextureDirectly(_.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=n,t.baseHeight=r,t.width=f,t.height=p,t.isReady=!0,c(f,p,(function(){h._prepareWebGLTextureContinuation(t,i,a,s,l)}))||this._prepareWebGLTextureContinuation(t,i,a,s,l)):i&&i._removePendingData(t))},e.prototype._setupFramebufferDepthAttachments=function(e,t,i,n,r){void 0===r&&(r=1);var o=this._gl;if(e&&t)return this._getDepthStencilBuffer(i,n,r,o.DEPTH_STENCIL,o.DEPTH24_STENCIL8,o.DEPTH_STENCIL_ATTACHMENT);if(t){var a=o.DEPTH_COMPONENT16;return this._webGLVersion>1&&(a=o.DEPTH_COMPONENT32F),this._getDepthStencilBuffer(i,n,r,a,a,o.DEPTH_ATTACHMENT)}return e?this._getDepthStencilBuffer(i,n,r,o.STENCIL_INDEX8,o.STENCIL_INDEX8,o.STENCIL_ATTACHMENT):null},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){this._releaseFramebufferObjects(e),this._deleteTexture(e._webGLTexture),this.unbindAllTextures();var t=this._internalTexturesCache.indexOf(e);-1!==t&&this._internalTexturesCache.splice(t,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()},e.prototype._deleteTexture=function(e){this._gl.deleteTexture(e)},e.prototype._setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},e.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.program);for(var i=e.getSamplers(),n=0;n<i.length;n++){var r=e.getUniform(i[n]);r&&(this._boundUniforms[n]=r)}this._currentEffect=null},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,n){void 0===i&&(i=!1),void 0===n&&(n=!1);var r=!1,o=t&&t._associatedChannel>-1;return i&&o&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||n?(this._activateCurrentTexture(),t&&t.isMultiview?this._gl.bindTexture(e,t?t._colorTextureArray:null):this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)):i&&(r=!0,this._activateCurrentTexture()),o&&!i&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),r},e.prototype._bindTexture=function(e,t){if(void 0!==e){t&&(t._associatedChannel=e),this._activeChannel=e;var i=t?this._getTextureTarget(t):this._gl.TEXTURE_2D;this._bindTextureDirectly(i,t)}},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),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},e.prototype.setTexture=function(e,t,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},e.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i&&i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},e.prototype._getTextureWrapMode=function(e){switch(e){case u.a.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case u.a.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case u.a.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.prototype._setTexture=function(e,t,i,n){if(void 0===i&&(i=!1),void 0===n&&(n=!1),!t)return null!=this._boundTexturesCache[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),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===u.a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var r;r=n?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!i&&r&&(r._associatedChannel=e);var o=!0;this._boundTexturesCache[e]===r&&(i||this._bindSamplerUniformToChannel(r._associatedChannel,e),o=!1),this._activeChannel=e;var a=this._getTextureTarget(r);if(o&&this._bindTextureDirectly(a,r,i),r&&!r.isMultiview){if(r.isCube&&r._cachedCoordinatesMode!==t.coordinatesMode){r._cachedCoordinatesMode=t.coordinatesMode;var s=t.coordinatesMode!==u.a.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==u.a.TEXTURE_SKYBOX_MODE?u.a.TEXTURE_WRAP_ADDRESSMODE:u.a.TEXTURE_CLAMP_ADDRESSMODE;t.wrapU=s,t.wrapV=s}r._cachedWrapU!==t.wrapU&&(r._cachedWrapU=t.wrapU,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),r)),r._cachedWrapV!==t.wrapV&&(r._cachedWrapV=t.wrapV,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),r)),r.is3D&&r._cachedWrapR!==t.wrapR&&(r._cachedWrapR=t.wrapR,this._setTextureParameterInteger(a,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),r)),this._setAnisotropicLevel(a,r,t.anisotropicFilteringLevel)}return!0},e.prototype.setTextureArray=function(e,t,i){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var n=0;n<i.length;n++){var r=i[n].getInternalTexture();r?(this._textureUnits[n]=e+n,r._associatedChannel=e+n):this._textureUnits[n]=-1}this._gl.uniform1iv(t,this._textureUnits);for(var o=0;o<i.length;o++)this._setTexture(this._textureUnits[o],i[o],!0)}},e.prototype._setAnisotropicLevel=function(e,t,i){var n=this._caps.textureAnisotropicFilterExtension;t.samplingMode!==u.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST&&t.samplingMode!==u.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR&&t.samplingMode!==u.a.TEXTURE_LINEAR_LINEAR&&(i=1),n&&t._cachedAnisotropicFilteringLevel!==i&&(this._setTextureParameterFloat(e,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(i,this._caps.maxAnisotropy),t),t._cachedAnisotropicFilteringLevel=i)},e.prototype._setTextureParameterFloat=function(e,t,i,n){this._bindTextureDirectly(e,n,!0,!0),this._gl.texParameterf(e,t,i)},e.prototype._setTextureParameterInteger=function(e,t,i,n){n&&this._bindTextureDirectly(e,n,!0,!0),this._gl.texParameteri(e,t,i)},e.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var e=0;e<this._caps.maxVertexAttribs;e++)this.disableAttributeByIndex(e)}else{e=0;for(var t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||this.disableAttributeByIndex(e)}},e.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}},e.prototype.dispose=function(){this.stopRenderLoop(),this.onBeforeTextureInitObservable&&this.onBeforeTextureInitObservable.clear(),this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],f.a.IsWindowObjectExist()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._boundRenderFunction=null,r.a.ResetCache();for(var e=0,t=this._activeRequests;e<t.length;e++){t[e].abort()}},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.getError=function(){return this._gl.getError()},e.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.a.TEXTURETYPE_FLOAT)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(u.a.TEXTURETYPE_HALF_FLOAT)},e.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,n=t.createTexture();t.bindTexture(t.TEXTURE_2D,n),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 r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,n,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 a=t.RGBA,s=t.UNSIGNED_BYTE,c=new Uint8Array(4);t.readPixels(0,0,1,1,a,s,c),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(n),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},e.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case u.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case u.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case u.a.TEXTURETYPE_BYTE:return this._gl.BYTE;case u.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case u.a.TEXTURETYPE_SHORT:return this._gl.SHORT;case u.a.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case u.a.TEXTURETYPE_INT:return this._gl.INT;case u.a.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case u.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case u.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case u.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case u.a.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case u.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case u.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case u.a.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(e){var t=this._gl.RGBA;switch(e){case u.a.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case u.a.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case u.a.TEXTUREFORMAT_RED:t=this._gl.RED;break;case u.a.TEXTUREFORMAT_RG:t=this._gl.RG;break;case u.a.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case u.a.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}if(this._webGLVersion>1)switch(e){case u.a.TEXTUREFORMAT_RED_INTEGER:t=this._gl.RED_INTEGER;break;case u.a.TEXTUREFORMAT_RG_INTEGER:t=this._gl.RG_INTEGER;break;case u.a.TEXTUREFORMAT_RGB_INTEGER:t=this._gl.RGB_INTEGER;break;case u.a.TEXTUREFORMAT_RGBA_INTEGER:t=this._gl.RGBA_INTEGER}return t},e.prototype._getRGBABufferInternalSizedFormat=function(e,t){if(1===this._webGLVersion){if(void 0!==t)switch(t){case u.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB}return this._gl.RGBA}switch(e){case u.a.TEXTURETYPE_BYTE:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case u.a.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case u.a.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R8;case u.a.TEXTUREFORMAT_RG:return this._gl.RG8;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB8;case u.a.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case u.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case u.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case u.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case u.a.TEXTURETYPE_SHORT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case u.a.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case u.a.TEXTURETYPE_INT:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case u.a.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case u.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case u.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case u.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case u.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case u.a.TEXTURETYPE_FLOAT:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R32F;case u.a.TEXTUREFORMAT_RG:return this._gl.RG32F;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case u.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case u.a.TEXTURETYPE_HALF_FLOAT:switch(t){case u.a.TEXTUREFORMAT_RED:return this._gl.R16F;case u.a.TEXTUREFORMAT_RG:return this._gl.RG16F;case u.a.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case u.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case u.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case u.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case u.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case u.a.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case u.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(e){return e===u.a.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===u.a.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},e.prototype._loadFile=function(t,i,n,r,o,a){var s=this,c=e._FileToolsLoadFile(t,i,n,r,o,a);return this._activeRequests.push(c),c.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),c},e._FileToolsLoadFile=function(e,t,i,n,r,a){throw o.a.WarnImport("FileTools")},e.prototype.readPixels=function(e,t,i,n,r){void 0===r&&(r=!0);var o=r?4:3,a=r?this._gl.RGBA:this._gl.RGB,s=new Uint8Array(n*i*o);return this._gl.readPixels(e,t,i,n,a,this._gl.UNSIGNED_BYTE,s),s},Object.defineProperty(e,"IsSupported",{get:function(){return this.isSupported()},enumerable:!1,configurable:!0}),e.isSupported=function(){if(null!==this._HasMajorPerformanceCaveat)return!this._HasMajorPerformanceCaveat;if(null===this._IsSupported)try{var e=v.a.CreateCanvas(1,1),t=e.getContext("webgl")||e.getContext("experimental-webgl");this._IsSupported=null!=t&&!!window.WebGLRenderingContext}catch(e){this._IsSupported=!1}return this._IsSupported},Object.defineProperty(e,"HasMajorPerformanceCaveat",{get:function(){if(null===this._HasMajorPerformanceCaveat)try{var e=v.a.CreateCanvas(1,1),t=e.getContext("webgl",{failIfMajorPerformanceCaveat:!0})||e.getContext("experimental-webgl",{failIfMajorPerformanceCaveat:!0});this._HasMajorPerformanceCaveat=!t}catch(e){this._HasMajorPerformanceCaveat=!1}return this._HasMajorPerformanceCaveat},enumerable:!1,configurable:!0}),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),n=e.FloorPOT(t);return i-t>t-n?n:i},e.GetExponentOfTwo=function(t,i,n){var r;switch(void 0===n&&(n=u.a.SCALEMODE_NEAREST),n){case u.a.SCALEMODE_FLOOR:r=e.FloorPOT(t);break;case u.a.SCALEMODE_NEAREST:r=e.NearestPOT(t);break;case u.a.SCALEMODE_CEILING:default:r=e.CeilingPOT(t)}return Math.min(r,i)},e.QueueNewFrame=function(e,t){return f.a.IsWindowObjectExist()?(t||(t=window),t.requestPostAnimationFrame?t.requestPostAnimationFrame(e):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)):"undefined"!=typeof requestAnimationFrame?requestAnimationFrame(e):setTimeout(e,16)},e.prototype.getHostDocument=function(){return this._renderingCanvas&&this._renderingCanvas.ownerDocument?this._renderingCanvas.ownerDocument:document},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:"Chrome/72.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/73.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Chrome/74.+?Mobile",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/71",capture:null,captureConstraint:null,targets:["vao"]},{key:"Mac OS.+Chrome/72",capture:null,captureConstraint:null,targets:["vao"]}],e._TextureLoaders=[],e.CollisionsEpsilon=.001,e._IsSupported=null,e._HasMajorPerformanceCaveat=null,e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"a",(function(){return c}));var n,r=i(6),o=i(102),a=i(2),s=i(21);!function(e){e[e.Unknown=0]="Unknown",e[e.Url=1]="Url",e[e.Temp=2]="Temp",e[e.Raw=3]="Raw",e[e.Dynamic=4]="Dynamic",e[e.RenderTarget=5]="RenderTarget",e[e.MultiRenderTarget=6]="MultiRenderTarget",e[e.Cube=7]="Cube",e[e.CubeRaw=8]="CubeRaw",e[e.CubePrefiltered=9]="CubePrefiltered",e[e.Raw3D=10]="Raw3D",e[e.Raw2DArray=11]="Raw2DArray",e[e.Depth=12]="Depth",e[e.CubeRawRGBD=13]="CubeRawRGBD"}(n||(n={}));var c=function(){function e(e,t,i){void 0===i&&(i=!1),this.isReady=!1,this.isCube=!1,this.is3D=!1,this.is2DArray=!1,this.isMultiview=!1,this.url="",this.samplingMode=-1,this.generateMipMaps=!1,this.samples=0,this.type=-1,this.format=-1,this.onLoadedObservable=new r.c,this.width=0,this.height=0,this.depth=0,this.baseWidth=0,this.baseHeight=0,this.baseDepth=0,this.invertY=!1,this._invertVScale=!1,this._associatedChannel=-1,this._source=n.Unknown,this._buffer=null,this._bufferView=null,this._bufferViewArray=null,this._bufferViewArrayArray=null,this._size=0,this._extension="",this._files=null,this._workingCanvas=null,this._workingContext=null,this._framebuffer=null,this._depthStencilBuffer=null,this._MSAAFramebuffer=null,this._MSAARenderBuffer=null,this._attachments=null,this._textureArray=null,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._isDisabled=!1,this._compression=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._comparisonFunction=0,this._sphericalPolynomial=null,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._colorTextureArray=null,this._depthStencilTextureArray=null,this._lodTextureHigh=null,this._lodTextureMid=null,this._lodTextureLow=null,this._isRGBD=!1,this._linearSpecularLOD=!1,this._irradianceTexture=null,this._webGLTexture=null,this._references=1,this._gammaSpace=null,this._engine=e,this._source=t,i||(this._webGLTexture=e._createTexture())}return e.prototype.getEngine=function(){return this._engine},Object.defineProperty(e.prototype,"source",{get:function(){return this._source},enumerable:!1,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,r=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this.source){case n.Temp:return;case n.Url:return void(i=this._engine.createTexture(null!==(t=this._originalUrl)&&void 0!==t?t:this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(function(){i._swapAndDie(r),r.isReady=!0}),null,this._buffer,void 0,this.format));case n.Raw:return(i=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 n.Raw3D:return(i=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 n.Raw2DArray:return(i=this._engine.createRawTexture2DArray(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 n.Dynamic:return(i=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 n.RenderTarget:var s=new o.a;if(s.generateDepthBuffer=this._generateDepthBuffer,s.generateMipMaps=this.generateMipMaps,s.generateStencilBuffer=this._generateStencilBuffer,s.samplingMode=this.samplingMode,s.type=this.type,this.isCube)i=this._engine.createRenderTargetCubeTexture(this.width,s);else{var c={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};i=this._engine.createRenderTargetTexture(c,s)}return i._swapAndDie(this),void(this.isReady=!0);case n.Depth:var l={bilinearFiltering:this.samplingMode!==a.a.TEXTURE_BILINEAR_SAMPLINGMODE,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube},u={width:this.width,height:this.height,layers:this.is2DArray?this.depth:void 0};return(i=this._engine.createDepthStencilTexture(u,l))._swapAndDie(this),void(this.isReady=!0);case n.Cube:return void(i=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(function(){i._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension));case n.CubeRaw:return(i=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 n.CubeRawRGBD:return i=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),void e._UpdateRGBDAsync(i,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then((function(){i._swapAndDie(r),r.isReady=!0}));case n.CubePrefiltered:return void((i=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(function(e){e&&e._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},e.prototype._swapAndDie=function(e){e._webGLTexture=this._webGLTexture,e._isRGBD=this._isRGBD,this._framebuffer&&(e._framebuffer=this._framebuffer),this._depthStencilBuffer&&(e._depthStencilBuffer=this._depthStencilBuffer),e._depthStencilTexture=this._depthStencilTexture,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),this._irradianceTexture&&(e._irradianceTexture&&e._irradianceTexture.dispose(),e._irradianceTexture=this._irradianceTexture);var t,i=this._engine.getLoadedTexturesCache();-1!==(t=i.indexOf(this))&&i.splice(t,1),-1===(t=i.indexOf(e))&&i.push(e)},e.prototype.dispose=function(){this._webGLTexture&&(this._references--,0===this._references&&(this._engine._releaseTexture(this),this._webGLTexture=null))},e._UpdateRGBDAsync=function(e,t,i,n,r){throw s.a.WarnImport("environmentTextureTools")},e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return n})),i.d(t,"c",(function(){return r})),i.d(t,"a",(function(){return o}));var n=1/2.2,r=2.2,o=.001},function(e,t,i){"use strict";i.d(t,"a",(function(){return l}));var n=i(1),r=i(0),o=i(3),a=i(6),s=i(22),c=i(21),l=function(){function e(e,t){void 0===t&&(t=null),this.state="",this.metadata=null,this.reservedDataStore=null,this._doNotSerialize=!1,this._isDisposed=!1,this.animations=new Array,this._ranges={},this.onReady=null,this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentUpdateId=-1,this._childUpdateId=-1,this._waitingParentId=null,this._cache={},this._parentNode=null,this._children=null,this._worldMatrix=r.a.Identity(),this._worldMatrixDeterminant=0,this._worldMatrixDeterminantIsDirty=!0,this._sceneRootNodesIndex=-1,this._animationPropertiesOverride=null,this._isNode=!0,this.onDisposeObservable=new a.c,this._onDisposeObserver=null,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||s.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return e.AddNodeConstructor=function(e,t){this._NodeConstructors[e]=t},e.Construct=function(e,t,i,n){var r=this._NodeConstructors[e];return r?r(t,i,n):null},Object.defineProperty(e.prototype,"doNotSerialize",{get:function(){return!!this._doNotSerialize||!!this._parentNode&&this._parentNode.doNotSerialize},set:function(e){this._doNotSerialize=e},enumerable:!1,configurable:!0}),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:!1,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:!1,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:!1,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)||(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._behaviors[t].detach(),this._behaviors.splice(t,1)),this},Object.defineProperty(e.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!1,configurable:!0}),e.prototype.getBehaviorByName=function(e){for(var t=0,i=this._behaviors;t<i.length;t++){var n=i[t];if(n.name===e)return n}return null},e.prototype.getWorldMatrix=function(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},e.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminantIsDirty&&(this._worldMatrixDeterminantIsDirty=!1,this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrixDeterminant},Object.defineProperty(e.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!1,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._getActionManagerForTrigger=function(e,t){return void 0===t&&(t=!0),this.parent?this.parent._getActionManagerForTrigger(e,!1):null},e.prototype._updateCache=function(e){},e.prototype._isSynchronized=function(){return!0},e.prototype._markSyncedWithParent=function(){this._parentNode&&(this._parentUpdateId=this._parentNode._childUpdateId)},e.prototype.isSynchronizedWithParent=function(){return!this._parentNode||this._parentUpdateId===this._parentNode._childUpdateId&&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 n=0;n<this._children.length;n++){var r=this._children[n];i&&!i(r)||e.push(r),t||r._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,n){if(!this._ranges[t]){this._ranges[t]=e._AnimationRangeFactory(t,i,n);for(var r=0,o=this.animations.length;r<o;r++)this.animations[r]&&this.animations[r].createRange(t,i,n)}},e.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,n=this.animations.length;i<n;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=null},e.prototype.getAnimationRange=function(e){return this._ranges[e]||null},e.prototype.getAnimationRanges=function(){var e,t=[];for(e in this._ranges)t.push(this._ranges[e]);return t},e.prototype.beginAnimation=function(e,t,i,n){var r=this.getAnimationRange(e);return r?this._scene.beginAnimation(this,r.from,r.to,t,i,n):null},e.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var i=this._ranges[t];if(i){var n={};n.name=t,n.from=i.from,n.to=i.to,e.push(n)}}return e},e.prototype.computeWorldMatrix=function(e){return this._worldMatrix||(this._worldMatrix=r.a.Identity()),this._worldMatrix},e.prototype.dispose=function(e,t){if(void 0===t&&(t=!1),this._isDisposed=!0,!e)for(var i=0,n=this.getDescendants(!0);i<n.length;i++){n[i].dispose(e,t)}this.parent?this.parent=null:this._removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var r=0,o=this._behaviors;r<o.length;r++){o[r].detach()}this._behaviors=[]},e.ParseAnimationRanges=function(e,t,i){if(t.ranges)for(var n=0;n<t.ranges.length;n++){var r=t.ranges[n];e.createAnimationRange(r.name,r.from,r.to)}},e.prototype.getHierarchyBoundingVectors=function(e,t){var i,n;void 0===e&&(e=!0),void 0===t&&(t=null),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);if(this.getBoundingInfo&&this.subMeshes){var o=this.getBoundingInfo();i=o.boundingBox.minimumWorld.clone(),n=o.boundingBox.maximumWorld.clone()}else i=new r.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new r.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);if(e)for(var a=0,s=this.getDescendants(!1);a<s.length;a++){var c=s[a];if(c.computeWorldMatrix(!0),(!t||t(c))&&c.getBoundingInfo&&0!==c.getTotalVertices()){var l=c.getBoundingInfo().boundingBox,u=l.minimumWorld,h=l.maximumWorld;r.e.CheckExtends(u,i,n),r.e.CheckExtends(h,i,n)}}return{min:i,max:n}},e._AnimationRangeFactory=function(e,t,i){throw c.a.WarnImport("AnimationRange")},e._NodeConstructors={},Object(n.c)([Object(o.c)()],e.prototype,"name",void 0),Object(n.c)([Object(o.c)()],e.prototype,"id",void 0),Object(n.c)([Object(o.c)()],e.prototype,"uniqueId",void 0),Object(n.c)([Object(o.c)()],e.prototype,"state",void 0),Object(n.c)([Object(o.c)()],e.prototype,"metadata",void 0),e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return O})),i.d(t,"a",(function(){return M}));var n=i(1),r=i(3),o=i(33),a=i(20),s=i(0),c=i(9),l=i(4),u=i(105),h=i(42),d=i(25),f=i(76),p=i(87),_=i(15),m=i(10),g=i(11),v=i(19),b=i(5),y="uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform float visibility;\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#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION) || defined(REFLECTIONMAP_EQUIRECTANGULAR) || defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_SKYBOX)\nuniform mat4 reflectionMatrix;\n#endif\n#ifndef REFLECTIONMAP_SKYBOX\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";b.a.IncludesShadersStore.defaultFragmentDeclaration=y;var T="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;\nvec2 vTangentSpaceParams;\nfloat pointSize;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nfloat visibility;\nvec4 vDiffuseColor;\nvec4 vDetailInfos;\nmat4 detailMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};\n";b.a.IncludesShadersStore.defaultUboDeclaration=T;i(160),i(59),i(106),i(107),i(154),i(130),i(161),i(131),i(108),i(109),i(132),i(133),i(115),i(116),i(125),i(110),i(134),i(162),i(135),i(155),i(136);var E="#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\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<bumpFragmentMainFunctions>\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#if defined(ALPHATEST) && !defined(ALPHATEST_AFTERALLALPHACOMPUTATIONS)\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#ifdef DETAIL\nbaseColor.rgb=baseColor.rgb*2.0*mix(0.5,detailColor.r,vDetailInfos.y);\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\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec4 refractionColor=vec4(0.,0.,0.,1.);\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);\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);\n#endif\n#ifdef RGBDREFRACTION\nrefractionColor.rgb=fromRGBD(refractionColor);\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor.rgb=toGammaSpace(refractionColor.rgb);\n#endif\nrefractionColor.rgb*=vRefractionInfos.x;\n#endif\n\nvec4 reflectionColor=vec4(0.,0.,0.,1.);\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);\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW);\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);\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor.rgb=toGammaSpace(reflectionColor.rgb);\n#endif\nreflectionColor.rgb*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor.rgb*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor.rgb*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor.rgb*=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.rgb*=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#ifdef ALPHATEST\n#ifdef ALPHATEST_AFTERALLALPHACOMPUTATIONS\nif (alpha<alphaCutOff)\ndiscard;\n#endif\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\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.rgb,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+emissiveColor+refractionColor.rgb,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor.rgb+refractionColor.rgb,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor.rgb;\n#else\ncolor.rgb+=lightmapColor.rgb;\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\ncolor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\ngl_FragData[0]=color;\n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef PREPASS_IRRADIANCE\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_DEPTHNORMAL\ngl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);\n#endif\n#ifdef PREPASS_ALBEDO\ngl_FragData[PREPASS_ALBEDO_INDEX]=vec4(0.0,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(SPECULAR)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=specularMapColor;\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=color;\n#endif\n}\n";b.a.ShadersStore.defaultPixelShader=E;var S="\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";b.a.IncludesShadersStore.defaultVertexDeclaration=S;i(78),i(79),i(163),i(164),i(117),i(137),i(93),i(94),i(100),i(80),i(81),i(165),i(156),i(111),i(157),i(138);b.a.IncludesShadersStore.pointCloudVertex="#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";i(158);var A="#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#include<prePassVertexDeclaration>\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(DETAIL) && DETAILDIRECTUV == 0\nvarying vec2 vDetailUV;\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#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\nvNormalW=normalize(normalWorld*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\nvPositionW=vec3(worldPos);\n#include<prePassVertex>\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 uvUpdated=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(DETAIL) && DETAILDIRECTUV == 0\nif (vDetailInfos.x == 0.)\n{\nvDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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";b.a.ShadersStore.defaultVertexShader=A;var P=i(2),C=i(67),R=i(92),x={effect:null,subMesh:null},O=function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.DETAIL=!1,t.DETAILDIRECTUV=0,t.DETAIL_NORMALBLENDMETHOD=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.CLIPPLANE5=!1,t.CLIPPLANE6=!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.BONES_VELOCITY_ENABLED=!1,t.INSTANCES=!1,t.THIN_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_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.MORPHTARGETS_UV=!1,t.NUM_MORPH_INFLUENCERS=0,t.NONUNIFORMSCALING=!1,t.PREMULTIPLYALPHA=!1,t.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,t.ALPHABLEND=!0,t.PREPASS=!1,t.PREPASS_IRRADIANCE=!1,t.PREPASS_IRRADIANCE_INDEX=-1,t.PREPASS_ALBEDO=!1,t.PREPASS_ALBEDO_INDEX=-1,t.PREPASS_DEPTHNORMAL=!1,t.PREPASS_DEPTHNORMAL_INDEX=-1,t.PREPASS_POSITION=!1,t.PREPASS_POSITION_INDEX=-1,t.PREPASS_VELOCITY=!1,t.PREPASS_VELOCITY_INDEX=-1,t.PREPASS_REFLECTIVITY=!1,t.PREPASS_REFLECTIVITY_INDEX=-1,t.SCENE_MRT_COUNT=0,t.RGBDLIGHTMAP=!1,t.RGBDREFLECTION=!1,t.RGBDREFRACTION=!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.MULTIVIEW=!1,t.IS_REFLECTION_LINEAR=!1,t.IS_REFRACTION_LINEAR=!1,t.EXPOSURE=!1,t.rebuild(),t}return Object(n.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 n=i[t];this[n]=n===e}},t}(f.a),M=function(e){function t(i,n){var r=e.call(this,i,n)||this;return r._diffuseTexture=null,r._ambientTexture=null,r._opacityTexture=null,r._reflectionTexture=null,r._emissiveTexture=null,r._specularTexture=null,r._bumpTexture=null,r._lightmapTexture=null,r._refractionTexture=null,r.ambientColor=new c.a(0,0,0),r.diffuseColor=new c.a(1,1,1),r.specularColor=new c.a(1,1,1),r.emissiveColor=new c.a(0,0,0),r.specularPower=64,r._useAlphaFromDiffuseTexture=!1,r._useEmissiveAsIllumination=!1,r._linkEmissiveWithDiffuse=!1,r._useSpecularOverAlpha=!1,r._useReflectionOverAlpha=!1,r._disableLighting=!1,r._useObjectSpaceNormalMap=!1,r._useParallax=!1,r._useParallaxOcclusion=!1,r.parallaxScaleBias=.05,r._roughness=0,r.indexOfRefraction=.98,r.invertRefractionY=!0,r.alphaCutOff=.4,r._useLightmapAsShadowmap=!1,r._useReflectionFresnelFromSpecular=!1,r._useGlossinessFromSpecularMapAlpha=!1,r._maxSimultaneousLights=4,r._invertNormalMapX=!1,r._invertNormalMapY=!1,r._twoSidedLighting=!1,r.detailMap=new R.a(r._markAllSubMeshesAsTexturesDirty.bind(r)),r._renderTargets=new o.a(16),r._worldViewProjectionMatrix=s.a.Zero(),r._globalAmbientColor=new c.a(0,0,0),r._rebuildInParallel=!1,r._attachImageProcessingConfiguration(null),r.prePassConfiguration=new u.a,r.getRenderTargetTextures=function(){return r._renderTargets.reset(),t.ReflectionTextureEnabled&&r._reflectionTexture&&r._reflectionTexture.isRenderTarget&&r._renderTargets.push(r._reflectionTexture),t.RefractionTextureEnabled&&r._refractionTexture&&r._refractionTexture.isRenderTarget&&r._renderTargets.push(r._refractionTexture),r._renderTargets},r}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canRenderToMRT",{get:function(){return!0},enumerable:!1,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:!1,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:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled)},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||this._hasAlphaChannel()&&(null==this._transparencyMode||this._transparencyMode===d.a.MATERIAL_ALPHATEST)},t.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture&&this._transparencyMode!==d.a.MATERIAL_OPAQUE},t.prototype._hasAlphaChannel=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha||null!=this._opacityTexture},t.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},t.prototype.isReadyForSubMesh=function(e,i,n){if(void 0===n&&(n=!1),i.effect&&this.isFrozen&&i.effect._wasPreviouslyReady)return!0;i._materialDefines||(i._materialDefines=new O);var r=this.getScene(),o=i._materialDefines;if(this._isReadyForSubMesh(i))return!0;var a=r.getEngine();if(o._needNormals=_.a.PrepareDefinesForLights(r,e,o,!0,this._maxSimultaneousLights,this._disableLighting),_.a.PrepareDefinesForMultiview(r,o),_.a.PrepareDefinesForPrePass(r,o,this.canRenderToMRT),o._areTexturesDirty){if(o._needUVs=!1,o.MAINUV1=!1,o.MAINUV2=!1,r.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._diffuseTexture,o,"DIFFUSE")}else o.DIFFUSE=!1;if(this._ambientTexture&&t.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._ambientTexture,o,"AMBIENT")}else o.AMBIENT=!1;if(this._opacityTexture&&t.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;_.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===m.a.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,o.RGBDREFLECTION=this._reflectionTexture.isRGBD,this._reflectionTexture.coordinatesMode){case m.a.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case m.a.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case m.a.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case m.a.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case m.a.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case m.a.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case m.a.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case m.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case m.a.CUBIC_MODE:case m.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;_.a.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,o.RGBDLIGHTMAP=this._lightmapTexture.isRGBD}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;_.a.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(r.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;_.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,o.RGBDREFRACTION=this._refractionTexture.isRGBD}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===P.a.ALPHA_PREMULTIPLIED||this.alphaMode===P.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,o.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(!this.detailMap.isReadyForSubMesh(o,r))return!1;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),_.a.PrepareDefinesForMisc(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,o),_.a.PrepareDefinesForAttributes(e,o,!0,!0,!0),_.a.PrepareDefinesForFrameBoundValues(r,a,o,n,null,i.getRenderingMesh().hasThinInstances),this.detailMap.prepareDefines(o,r),o.isDirty){var s=o._areLightsDisposed;o.markAsProcessed();var c=new C.a;o.REFLECTION&&c.addFallback(0,"REFLECTION"),o.SPECULAR&&c.addFallback(0,"SPECULAR"),o.BUMP&&c.addFallback(0,"BUMP"),o.PARALLAX&&c.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&c.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&c.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&c.addFallback(1,"FOG"),o.POINTSIZE&&c.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&c.addFallback(0,"LOGARITHMICDEPTH"),_.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights),o.SPECULARTERM&&c.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&c.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&c.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&c.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&c.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&c.addFallback(4,"FRESNEL"),o.MULTIVIEW&&c.addFallback(0,"MULTIVIEW");var d=[l.b.PositionKind];o.NORMAL&&d.push(l.b.NormalKind),o.UV1&&d.push(l.b.UVKind),o.UV2&&d.push(l.b.UV2Kind),o.VERTEXCOLOR&&d.push(l.b.ColorKind),_.a.PrepareAttributesForBones(d,e,o,c),_.a.PrepareAttributesForInstances(d,o),_.a.PrepareAttributesForMorphTargets(d,e,o);var f="default",p=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","visibility","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","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"],v=["Material","Scene"];R.a.AddUniforms(p),R.a.AddSamplers(g),u.a.AddUniforms(p),u.a.AddSamplers(p),h.a&&(h.a.PrepareUniforms(p,o),h.a.PrepareSamplers(g,o)),_.a.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:v,samplers:g,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var b={};this.customShaderNameResolve&&(f=this.customShaderNameResolve(f,p,v,g,o,d,b));var y=o.toString(),T=i.effect,E=r.getEngine().createEffect(f,{attributes:d,uniformsNames:p,uniformBuffersNames:v,samplers:g,defines:y,fallbacks:c,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS},processFinalCode:b.processFinalCode,multiTarget:o.PREPASS},a);if(E)if(this._onEffectCreatedObservable&&(x.effect=E,x.subMesh=i,this._onEffectCreatedObservable.notifyObservers(x)),this.allowShaderHotSwapping&&T&&!E.isReady()){if(E=T,this._rebuildInParallel=!0,o.markAsUnprocessed(),s)return o._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,r.resetCachedMaterial(),i.setEffect(E,o),this.buildUniformLayout()}return!(!i.effect||!i.effect.isReady())&&(o._renderId=r.getRenderId(),i.effect._wasPreviouslyReady=!0,!0)},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),e.addUniform("vDiffuseColor",4),R.a.PrepareUniformBuffer(e),e.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,n){var r=this.getScene(),o=n._materialDefines;if(o){var s=n.effect;if(s){this._activeEffect=s,o.INSTANCES&&!o.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,r,i,e,this.isFrozen),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(r,s,i.visibility);_.a.BindBonesParameters(i,s);var u=this._uniformBuffer;if(l){if(u.bindToEffect(s,"Material"),this.bindViewProjection(s),!u.useUbo||!this.isFrozen||!u.isSync){if(t.FresnelEnabled&&o.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(u.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),u.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&u.updateColor4("opacityParts",new c.a(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(u.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),u.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(u.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),u.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(u.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),u.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),r.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(u.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),_.a.BindTextureMatrix(this._diffuseTexture,u,"diffuse")),this._ambientTexture&&t.AmbientTextureEnabled&&(u.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),_.a.BindTextureMatrix(this._ambientTexture,u,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(u.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),_.a.BindTextureMatrix(this._opacityTexture,u,"opacity")),this._hasAlphaChannel()&&s.setFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&t.ReflectionTextureEnabled&&(u.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),u.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var h=this._reflectionTexture;u.updateVector3("vReflectionPosition",h.boundingBoxPosition),u.updateVector3("vReflectionSize",h.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(u.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),_.a.BindTextureMatrix(this._emissiveTexture,u,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(u.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),_.a.BindTextureMatrix(this._lightmapTexture,u,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(u.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),_.a.BindTextureMatrix(this._specularTexture,u,"specular")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(u.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),_.a.BindTextureMatrix(this._bumpTexture,u,"bump"),r._mirroredCameraPosition?u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var d=1;this._refractionTexture.isCube||(u.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(d=this._refractionTexture.depth)),u.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,d,this.invertRefractionY?-1:1)}}this.pointsCloud&&u.updateFloat("pointSize",this.pointSize),o.SPECULARTERM&&u.updateColor4("vSpecularColor",this.specularColor,this.specularPower),u.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:c.a.BlackReadOnly),u.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha)}if(u.updateFloat("visibility",i.visibility),r.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&s.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&s.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&s.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?s.setTexture("reflectionCubeSampler",this._reflectionTexture):s.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&s.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&s.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&s.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&s.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){d=1;this._refractionTexture.isCube?s.setTexture("refractionCubeSampler",this._refractionTexture):s.setTexture("refraction2DSampler",this._refractionTexture)}this.detailMap.bindForSubMesh(u,r,this.isFrozen),_.a.BindClipPlane(s,r),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),_.a.BindEyePosition(s,r),s.setColor3("vAmbientColor",this._globalAmbientColor)}!l&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&_.a.BindLights(r,i,s,o,this._maxSimultaneousLights,this._rebuildInParallel),(r.fogEnabled&&i.applyFog&&r.fogMode!==a.a.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(s),_.a.BindFogParameters(r,i,s),o.NUM_MORPH_INFLUENCERS&&_.a.BindMorphTargetParameters(i,s),this.useLogarithmicDepth&&_.a.BindLogDepth(o,s,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),u.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),this.detailMap.getAnimatables(e),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),this.detailMap.getActiveTextures(t),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||this.detailMap.hasTexture(t))))))))))},t.prototype.dispose=function(t,i){var n,r,o,a,s,c,l,u,h;i&&(null===(n=this._diffuseTexture)||void 0===n||n.dispose(),null===(r=this._ambientTexture)||void 0===r||r.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(c=this._specularTexture)||void 0===c||c.dispose(),null===(l=this._bumpTexture)||void 0===l||l.dispose(),null===(u=this._lightmapTexture)||void 0===u||u.dispose(),null===(h=this._refractionTexture)||void 0===h||h.dispose()),this.detailMap.dispose(i),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,n=r.a.Clone((function(){return new t(e,i.getScene())}),this);return n.name=e,n.id=e,n},t.prototype.serialize=function(){return r.a.Serialize(this)},t.Parse=function(e,i,n){return r.a.Parse((function(){return new t(e.name,i)}),e,i,n)},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return v.a.DiffuseTextureEnabled},set:function(e){v.a.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DetailTextureEnabled",{get:function(){return v.a.DetailTextureEnabled},set:function(e){v.a.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return v.a.AmbientTextureEnabled},set:function(e){v.a.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return v.a.OpacityTextureEnabled},set:function(e){v.a.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return v.a.ReflectionTextureEnabled},set:function(e){v.a.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return v.a.EmissiveTextureEnabled},set:function(e){v.a.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return v.a.SpecularTextureEnabled},set:function(e){v.a.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return v.a.BumpTextureEnabled},set:function(e){v.a.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return v.a.LightmapTextureEnabled},set:function(e){v.a.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return v.a.RefractionTextureEnabled},set:function(e){v.a.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return v.a.ColorGradingTextureEnabled},set:function(e){v.a.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return v.a.FresnelEnabled},set:function(e){v.a.FresnelEnabled=e},enumerable:!1,configurable:!0}),Object(n.c)([Object(r.m)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),Object(n.c)([Object(r.m)("ambientTexture")],t.prototype,"_ambientTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(n.c)([Object(r.m)("opacityTexture")],t.prototype,"_opacityTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(n.c)([Object(r.m)("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(n.c)([Object(r.m)("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(n.c)([Object(r.m)("specularTexture")],t.prototype,"_specularTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),Object(n.c)([Object(r.m)("bumpTexture")],t.prototype,"_bumpTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(n.c)([Object(r.m)("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),Object(n.c)([Object(r.m)("refractionTexture")],t.prototype,"_refractionTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),Object(n.c)([Object(r.e)("ambient")],t.prototype,"ambientColor",void 0),Object(n.c)([Object(r.e)("diffuse")],t.prototype,"diffuseColor",void 0),Object(n.c)([Object(r.e)("specular")],t.prototype,"specularColor",void 0),Object(n.c)([Object(r.e)("emissive")],t.prototype,"emissiveColor",void 0),Object(n.c)([Object(r.c)()],t.prototype,"specularPower",void 0),Object(n.c)([Object(r.c)("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),Object(n.c)([Object(r.c)("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),Object(n.c)([Object(r.c)("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),Object(n.c)([Object(r.c)("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(n.c)([Object(r.c)("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),Object(n.c)([Object(r.c)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(n.c)([Object(r.c)("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(n.c)([Object(r.c)("useParallax")],t.prototype,"_useParallax",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(n.c)([Object(r.c)("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(n.c)([Object(r.c)()],t.prototype,"parallaxScaleBias",void 0),Object(n.c)([Object(r.c)("roughness")],t.prototype,"_roughness",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(n.c)([Object(r.c)()],t.prototype,"indexOfRefraction",void 0),Object(n.c)([Object(r.c)()],t.prototype,"invertRefractionY",void 0),Object(n.c)([Object(r.c)()],t.prototype,"alphaCutOff",void 0),Object(n.c)([Object(r.c)("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(n.c)([Object(r.h)("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),Object(n.c)([Object(r.h)("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),Object(n.c)([Object(r.h)("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),Object(n.c)([Object(r.h)("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),Object(n.c)([Object(r.h)("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),Object(n.c)([Object(r.c)("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),Object(n.c)([Object(r.c)("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),Object(n.c)([Object(r.c)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(n.c)([Object(r.c)("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(n.c)([Object(r.c)("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(n.c)([Object(r.c)("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),Object(n.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(n.c)([Object(r.c)()],t.prototype,"useLogarithmicDepth",null),t}(p.a);g.a.RegisteredTypes["BABYLON.StandardMaterial"]=M,a.a.DefaultMaterialFactory=function(e){return new M("default material",e)}},function(e,t,i){"use strict";i.d(t,"a",(function(){return S}));var n=i(1),r=i(12),o=i(6),a=i(0),s=i(13),c=i(4),l=i(16),u=i(46),h=i(54),d=i(43),f=i(2),p=i(147),_=i(21),m=i(101),g=i(9),v=i(28),b=i(23),y=i(11),T=function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=a.e.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1},E=function(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new T,this._visibility=1,this._skeleton=null,this._layerMask=268435455,this._computeBonesUsingShaders=!0,this._isActive=!1,this._onlyForInstances=!1,this._isActiveIntermediate=!1,this._onlyForInstancesIntermediate=!1,this._actAsRegularMesh=!1,this._currentLOD=null,this._currentLODIsUpToDate=!1},S=function(e){function t(i,n){void 0===n&&(n=null);var r=e.call(this,i,n,!1)||this;return r._internalAbstractMeshDataInfo=new E,r.cullingStrategy=t.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,r.onCollideObservable=new o.c,r.onCollisionPositionChangeObservable=new o.c,r.onMaterialChangedObservable=new o.c,r.definedFacingForward=!0,r._occlusionQuery=null,r._renderingGroup=null,r.alphaIndex=Number.MAX_VALUE,r.isVisible=!0,r.isPickable=!0,r.showSubMeshesBoundingBox=!1,r.isBlocker=!1,r.enablePointerMoveEvents=!1,r._renderingGroupId=0,r._material=null,r.outlineColor=g.a.Red(),r.outlineWidth=.02,r.overlayColor=g.a.Red(),r.overlayAlpha=.5,r.useOctreeForRenderingSelection=!0,r.useOctreeForPicking=!0,r.useOctreeForCollisions=!0,r.alwaysSelectAsActiveMesh=!1,r.doNotSyncBoundingInfo=!1,r.actionManager=null,r._meshCollisionData=new p.a,r.ellipsoid=new a.e(.5,1,.5),r.ellipsoidOffset=new a.e(0,0,0),r.edgesWidth=1,r.edgesColor=new g.b(1,0,0,1),r._edgesRenderer=null,r._masterMesh=null,r._boundingInfo=null,r._renderId=0,r._intersectionsInProgress=new Array,r._unIndexed=!1,r._lightSources=new Array,r._waitingData={lods:null,actions:null,freezeWorldMatrix:null},r._bonesTransformMatrices=null,r._transformMatrixTexture=null,r.onRebuildObservable=new o.c,r._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),t.subtractToRef(r._meshCollisionData._oldPositionForCollisions,r._meshCollisionData._diffPositionForCollisions),r._meshCollisionData._diffPositionForCollisions.length()>s.a.CollisionsEpsilon&&r.position.addInPlace(r._meshCollisionData._diffPositionForCollisions),i&&r.onCollideObservable.notifyObservers(i),r.onCollisionPositionChangeObservable.notifyObservers(r.position)},r.getScene().addMesh(r),r._resyncLightSources(),r}return Object(n.d)(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return u.a.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return u.a.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return u.a.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return u.a.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return u.a.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return u.a.BILLBOARDMODE_USE_POSITION},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,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._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver),this._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver),this._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){this._internalAbstractMeshDataInfo._visibility!==e&&(this._internalAbstractMeshDataInfo._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._renderingGroupId},set:function(e){this._renderingGroupId=e},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasVertexAlpha",{get:function(){return this._internalAbstractMeshDataInfo._hasVertexAlpha},set:function(e){this._internalAbstractMeshDataInfo._hasVertexAlpha!==e&&(this._internalAbstractMeshDataInfo._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useVertexColors",{get:function(){return this._internalAbstractMeshDataInfo._useVertexColors},set:function(e){this._internalAbstractMeshDataInfo._useVertexColors!==e&&(this._internalAbstractMeshDataInfo._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"computeBonesUsingShaders",{get:function(){return this._internalAbstractMeshDataInfo._computeBonesUsingShaders},set:function(e){this._internalAbstractMeshDataInfo._computeBonesUsingShaders!==e&&(this._internalAbstractMeshDataInfo._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"numBoneInfluencers",{get:function(){return this._internalAbstractMeshDataInfo._numBoneInfluencers},set:function(e){this._internalAbstractMeshDataInfo._numBoneInfluencers!==e&&(this._internalAbstractMeshDataInfo._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"applyFog",{get:function(){return this._internalAbstractMeshDataInfo._applyFog},set:function(e){this._internalAbstractMeshDataInfo._applyFog!==e&&(this._internalAbstractMeshDataInfo._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"layerMask",{get:function(){return this._internalAbstractMeshDataInfo._layerMask},set:function(e){e!==this._internalAbstractMeshDataInfo._layerMask&&(this._internalAbstractMeshDataInfo._layerMask=e,this._resyncLightSources())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(e){this._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionResponse",{get:function(){return this._meshCollisionData._collisionResponse},set:function(e){this._meshCollisionData._collisionResponse=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(e){this._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surroundingMeshes",{get:function(){return this._meshCollisionData._surroundingMeshes},set:function(e){this._meshCollisionData._surroundingMeshes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_positions",{get:function(){return null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._internalAbstractMeshDataInfo._skeleton},set:function(e){var t=this._internalAbstractMeshDataInfo._skeleton;t&&t.needInitialSkinMatrix&&t._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._internalAbstractMeshDataInfo._skeleton=e,this._internalAbstractMeshDataInfo._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"AbstractMesh"},t.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0);var i=this._internalAbstractMeshDataInfo._skeleton;return i&&(t+=", skeleton: "+i.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingData.freezeWorldMatrix?"YES":"NO")),t},t.prototype._getEffectiveParent=function(){return this._masterMesh&&this.billboardMode!==u.a.BILLBOARDMODE_NONE?this._masterMesh:e.prototype._getEffectiveParent.call(this)},t.prototype._getActionManagerForTrigger=function(e,t){if(void 0===t&&(t=!0),this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},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._resyncLightSource=function(e){var t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e),n=!1;if(-1===i){if(!t)return;this._lightSources.push(e)}else{if(t)return;n=!0,this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty(n)},t.prototype._unBindEffect=function(){for(var e=0,t=this.subMeshes;e<t.length;e++){t[e].setEffect(null)}},t.prototype._removeLightSource=function(e,t){var i=this._lightSources.indexOf(e);-1!==i&&(this._lightSources.splice(i,1),this._markSubMeshesAsLightDirty(t))},t.prototype._markSubMeshesAsDirty=function(e){if(this.subMeshes)for(var t=0,i=this.subMeshes;t<i.length;t++){var n=i[t];n._materialDefines&&e(n._materialDefines)}},t.prototype._markSubMeshesAsLightDirty=function(e){void 0===e&&(e=!1),this._markSubMeshesAsDirty((function(t){return t.markAsLightDirty(e)}))},t.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},t.prototype._markSubMeshesAsMiscDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsMiscDirty()}))},Object.defineProperty(t.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBlocked",{get:function(){return!1},enumerable:!1,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,n){return this},t.prototype.updateVerticesData=function(e,t,i,n){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(t,i,n){return void 0===t&&(t=!0),void 0===i&&(i=!1),e.prototype.normalizeToUnitCube.call(this,t,i,n)},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:!1,configurable:!0}),t.prototype._preActivate=function(){},t.prototype._preActivateForIntermediateRendering=function(e){},t.prototype._activate=function(e,t){return this._renderId=e,!0},t.prototype._postActivate=function(){},t.prototype._freeze=function(){},t.prototype._unFreeze=function(){},t.prototype.getWorldMatrix=function(){return this._masterMesh&&this.billboardMode===u.a.BILLBOARDMODE_NONE?this._masterMesh.getWorldMatrix():e.prototype.getWorldMatrix.call(this)},t.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():e.prototype._getWorldMatrixDeterminant.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasThinInstances",{get:function(){return!1},enumerable:!1,configurable:!0}),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 n=new a.a;(this.rotationQuaternion?this.rotationQuaternion:a.b.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(n);var r=a.e.Zero(),o=this.definedFacingForward?-1:1;return a.e.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,n,r),r},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 n=this.definedFacingForward?1:-1;return new a.e(e*n,t,i*n)},t.prototype.refreshBoundingInfo=function(e){return void 0===e&&(e=!1),this._boundingInfo&&this._boundingInfo.isLocked||this._refreshBoundingInfo(this._getPositionData(e),null),this},t.prototype._refreshBoundingInfo=function(e,t){if(e){var i=Object(m.a)(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 n=0;n<this.subMeshes.length;n++)this.subMeshes[n].refreshBoundingInfo(e);this._updateBoundingInfo()},t.prototype._getPositionData=function(e){var t=this.getVerticesData(c.b.PositionKind);if(t&&e&&this.skeleton){t=r.b.Slice(t),this._generatePointsArray();var i=this.getVerticesData(c.b.MatricesIndicesKind),n=this.getVerticesData(c.b.MatricesWeightsKind);if(n&&i){var o=this.numBoneInfluencers>4,s=o?this.getVerticesData(c.b.MatricesIndicesExtraKind):null,l=o?this.getVerticesData(c.b.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var u=this.skeleton.getTransformMatrices(this),h=a.c.Vector3[0],d=a.c.Matrix[0],f=a.c.Matrix[1],p=0,_=0;_<t.length;_+=3,p+=4){var m,g;for(d.reset(),m=0;m<4;m++)(g=n[p+m])>0&&(a.a.FromFloat32ArrayToRefScaled(u,Math.floor(16*i[p+m]),g,f),d.addToSelf(f));if(o)for(m=0;m<4;m++)(g=l[p+m])>0&&(a.a.FromFloat32ArrayToRefScaled(u,Math.floor(16*s[p+m]),g,f),d.addToSelf(f));a.e.TransformCoordinatesFromFloatsToRef(t[_],t[_+1],t[_+2],d,h),h.toArray(t,_),this._positions&&this._positions[_/3].copyFrom(h)}}}return t},t.prototype._updateBoundingInfo=function(){var e=this._effectiveMesh;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 n=this.subMeshes[i];(t>1||!n.IsGlobal)&&n.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(t.prototype,"_effectiveMesh",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this},enumerable:!1,configurable:!0}),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 n=0,r=this.getChildMeshes();n<r.length;n++){if(r[n].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._meshCollisionData._checkCollisions},set:function(e){this._meshCollisionData._checkCollisions=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collider",{get:function(){return this._meshCollisionData._collider},enumerable:!1,configurable:!0}),t.prototype.moveWithCollisions=function(e){this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._meshCollisionData._oldPositionForCollisions);var t=this.getScene().collisionCoordinator;return this._meshCollisionData._collider||(this._meshCollisionData._collider=t.createCollider()),this._meshCollisionData._collider._radius=this.ellipsoid,t.getNewPosition(this._meshCollisionData._oldPositionForCollisions,e,this._meshCollisionData._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 n=e.verticesStart,r=e.verticesStart+e.verticesCount,o=n;o<r;o++)e._lastColliderWorldVertices.push(a.e.TransformCoordinates(this._positions[o],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial(),this),this},t.prototype._processCollisionsForSubMeshes=function(e,t){for(var i=this._scene.getCollidingSubMeshCandidates(this,e),n=i.length,r=0;r<n;r++){var o=i.data[r];n>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=a.c.Matrix[0],i=a.c.Matrix[1];return a.a.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,i,n,r,o){var s;void 0===n&&(n=!1),void 0===o&&(o=!1);var c=new h.a,l="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,u=this._boundingInfo;if(!this.subMeshes||!u)return c;if(!(o||e.intersectsSphere(u.boundingSphere,l)&&e.intersectsBox(u.boundingBox,l)))return c;if(n)return c.hit=!o,c.pickedMesh=o?null:this,c.distance=o?0:a.e.Distance(e.origin,u.boundingSphere.center),c.subMeshId=0,c;if(!this._generatePointsArray())return c;for(var d=null,p=this._scene.getIntersectingSubMeshCandidates(this,e),_=p.length,m=!1,g=0;g<_;g++){var v=(b=p.data[g]).getMaterial();if(v&&((null===(s=this.getIndices())||void 0===s?void 0:s.length)&&(v.fillMode==f.a.MATERIAL_TriangleStripDrawMode||v.fillMode==f.a.MATERIAL_TriangleFillMode||v.fillMode==f.a.MATERIAL_WireFrameFillMode||v.fillMode==f.a.MATERIAL_PointFillMode))){m=!0;break}}if(!m)return c.hit=!0,c.pickedMesh=this,c.distance=a.e.Distance(e.origin,u.boundingSphere.center),c.subMeshId=-1,c;for(g=0;g<_;g++){var b=p.data[g];if(!(_>1)||b.canIntersects(e)){var y=b.intersects(e,this._positions,this.getIndices(),t,i);if(y&&(t||!d||y.distance<d.distance)&&((d=y).subMeshId=g,t))break}}if(d){var T=null!=r?r:this.skeleton&&this.skeleton.overrideMesh?this.skeleton.overrideMesh.getWorldMatrix():this.getWorldMatrix(),E=a.c.Vector3[0],S=a.c.Vector3[1];a.e.TransformCoordinatesToRef(e.origin,T,E),e.direction.scaleToRef(d.distance,S);var A=a.e.TransformNormal(S,T).addInPlace(E);return c.hit=!0,c.distance=a.e.Distance(E,A),c.pickedPoint=A,c.pickedMesh=this,c.bu=d.bu||0,c.bv=d.bv||0,c.subMeshFaceId=d.faceId,c.faceId=d.faceId+p.data[d.subMeshId].indexStart/(-1!==this.getClassName().indexOf("LinesMesh")?2:3),c.subMeshId=d.subMeshId,c}return c},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 n,r=this;for(void 0===i&&(i=!1),this._scene.useMaterialMeshMap&&this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this.getScene().freeActiveMeshes(),this.getScene().freeRenderingGroups(),void 0!==this.actionManager&&null!==this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this._internalAbstractMeshDataInfo._skeleton=null,this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null),n=0;n<this._intersectionsInProgress.length;n++){var o=this._intersectionsInProgress[n],a=o._intersectionsInProgress.indexOf(this);o._intersectionsInProgress.splice(a,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach((function(e){var t=e.includedOnlyMeshes.indexOf(r);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(r))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();if(i){var n=i.getShadowMap();n&&n.renderList&&-1!==(t=n.renderList.indexOf(r))&&n.renderList.splice(t,1)}})),"InstancedMesh"===this.getClassName()&&"InstancedLinesMesh"===this.getClassName()||this.releaseSubMeshes();var s=this.getScene().getEngine();if(this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,s.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),s.wipeCaches(),this.getScene().removeMesh(this),i&&this.material&&("MultiMaterial"===this.material.getClassName()?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!t)for(n=0;n<this.getScene().particleSystems.length;n++)this.getScene().particleSystems[n].emitter===this&&(this.getScene().particleSystems[n].dispose(),n--);this._internalAbstractMeshDataInfo._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._internalAbstractMeshDataInfo._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]=a.e.Zero(),e.facetPositions[t]=a.e.Zero();return e.facetDataEnabled=!0,this},t.prototype.updateFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;e.facetDataEnabled||this._initFacetData();var t=this.getVerticesData(c.b.PositionKind),i=this.getIndices(),n=this.getVerticesData(c.b.NormalKind),r=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,s=0;s<i.length;s++)if(i[s]>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:a.e.Zero()}e.depthSortedFacets=[];for(var h=0;h<e.facetNb;h++){var d={ind:3*h,sqDistance:0};e.depthSortedFacets.push(d)}e.invertedMatrix=a.a.Identity(),e.facetDepthSortOrigin=a.e.Zero()}e.bbSize.x=r.maximum.x-r.minimum.x>v.a?r.maximum.x-r.minimum.x:v.a,e.bbSize.y=r.maximum.y-r.minimum.y>v.a?r.maximum.y-r.minimum.y:v.a,e.bbSize.z=r.maximum.z-r.minimum.z>v.a?r.maximum.z-r.minimum.z:v.a;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=r,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),a.e.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,l.a.ComputeNormals(t,i,n,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,void 0,!0)}return this},t.prototype.getFacetLocalNormals=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetNormals||this.updateFacetData(),e.facetNormals},t.prototype.getFacetLocalPositions=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetPositions||this.updateFacetData(),e.facetPositions},t.prototype.getFacetLocalPartitioning=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetPartitioning||this.updateFacetData(),e.facetPartitioning},t.prototype.getFacetPosition=function(e){var t=a.e.Zero();return this.getFacetPositionToRef(e,t),t},t.prototype.getFacetPositionToRef=function(e,t){var i=this.getFacetLocalPositions()[e],n=this.getWorldMatrix();return a.e.TransformCoordinatesToRef(i,n,t),this},t.prototype.getFacetNormal=function(e){var t=a.e.Zero();return this.getFacetNormalToRef(e,t),t},t.prototype.getFacetNormalToRef=function(e,t){var i=this.getFacetLocalNormals()[e];return a.e.TransformNormalToRef(i,this.getWorldMatrix(),t),this},t.prototype.getFacetsAtLocalCoordinates=function(e,t,i){var n=this.getBoundingInfo(),r=this._internalAbstractMeshDataInfo._facetData,o=Math.floor((e-n.minimum.x*r.partitioningBBoxRatio)*r.subDiv.X*r.partitioningBBoxRatio/r.bbSize.x),a=Math.floor((t-n.minimum.y*r.partitioningBBoxRatio)*r.subDiv.Y*r.partitioningBBoxRatio/r.bbSize.y),s=Math.floor((i-n.minimum.z*r.partitioningBBoxRatio)*r.subDiv.Z*r.partitioningBBoxRatio/r.bbSize.z);return o<0||o>r.subDiv.max||a<0||a>r.subDiv.max||s<0||s>r.subDiv.max?null:r.facetPartitioning[o+r.subDiv.max*a+r.subDiv.max*r.subDiv.max*s]},t.prototype.getClosestFacetAtCoordinates=function(e,t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var s=this.getWorldMatrix(),c=a.c.Matrix[5];s.invertToRef(c);var l=a.c.Vector3[8];a.e.TransformCoordinatesFromFloatsToRef(e,t,i,c,l);var u=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,n,r,o);return n&&a.e.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,s,n),u},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var a=null,s=0,c=0,l=0,u=0,h=0,d=0,f=0,p=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var v,b,y,T=Number.MAX_VALUE,E=T,S=0;S<g.length;S++)b=m[v=g[S]],u=(e-(y=_[v]).x)*b.x+(t-y.y)*b.y+(i-y.z)*b.z,(!r||r&&o&&u>=0||r&&!o&&u<=0)&&(u=b.x*y.x+b.y*y.y+b.z*y.z,h=-(b.x*e+b.y*t+b.z*i-u)/(b.x*b.x+b.y*b.y+b.z*b.z),(E=(s=(d=e+b.x*h)-e)*s+(c=(f=t+b.y*h)-t)*c+(l=(p=i+b.z*h)-i)*l)<T&&(T=E,a=v,n&&(n.x=d,n.y=f,n.z=p)));return a},t.prototype.getFacetDataParameters=function(){return this._internalAbstractMeshDataInfo._facetData.facetParameters},t.prototype.disableFacetData=function(){var e=this._internalAbstractMeshDataInfo._facetData;return e.facetDataEnabled&&(e.facetDataEnabled=!1,e.facetPositions=new Array,e.facetNormals=new Array,e.facetPartitioning=new Array,e.facetParameters=null,e.depthSortedIndices=new Uint32Array(0)),this},t.prototype.updateIndices=function(e,t,i){return void 0===i&&(i=!1),this},t.prototype.createNormals=function(e){var t,i=this.getVerticesData(c.b.PositionKind),n=this.getIndices();return t=this.isVerticesDataPresent(c.b.NormalKind)?this.getVerticesData(c.b.NormalKind):[],l.a.ComputeNormals(i,n,t,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(c.b.NormalKind,t,e),this},t.prototype.alignWithNormal=function(e,t){t||(t=b.a.Y);var i=a.c.Vector3[0],n=a.c.Vector3[1];return a.e.CrossToRef(t,e,n),a.e.CrossToRef(e,n,i),this.rotationQuaternion?a.b.RotationQuaternionFromAxisToRef(i,e,n,this.rotationQuaternion):a.e.RotationFromAxisToRef(i,e,n,this.rotation),this},t.prototype._checkOcclusionQuery=function(){return!1},t.prototype.disableEdgesRendering=function(){throw _.a.WarnImport("EdgesRenderer")},t.prototype.enableEdgesRendering=function(e,t,i){throw _.a.WarnImport("EdgesRenderer")},t.prototype.getConnectedParticleSystems=function(){var e=this;return this._scene.particleSystems.filter((function(t){return t.emitter===e}))},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);y.a.RegisteredTypes["BABYLON.AbstractMesh"]=S},function(e,t,i){"use strict";i.d(t,"a",(function(){return u}));var n=i(8),r=i(44),o=i(0),a=i(31),s=i(7),c=i(50),l=i(23);s.a._PhysicsImpostorParser=function(e,t,i){return new u(t,i.physicsImpostor,{mass:i.physicsMass,friction:i.physicsFriction,restitution:i.physicsRestitution},e)};var u=function(){function e(e,t,i,r){var a=this;void 0===i&&(i={mass:0}),this.object=e,this.type=t,this._options=i,this._scene=r,this._pluginData={},this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=o.e.Zero(),this._isDisposed=!1,this.soft=!1,this.segments=0,this._tmpQuat=new o.b,this._tmpQuat2=new o.b,this.beforeStep=function(){a._physicsEngine&&(a.object.translate(a._deltaPosition,-1),a._deltaRotationConjugated&&a.object.rotationQuaternion&&a.object.rotationQuaternion.multiplyToRef(a._deltaRotationConjugated,a.object.rotationQuaternion),a.object.computeWorldMatrix(!1),a.object.parent&&a.object.rotationQuaternion?(a.getParentsRotation(),a._tmpQuat.multiplyToRef(a.object.rotationQuaternion,a._tmpQuat)):a._tmpQuat.copyFrom(a.object.rotationQuaternion||new o.b),a._options.disableBidirectionalTransformation||a.object.rotationQuaternion&&a._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(a,a.object.getAbsolutePosition(),a._tmpQuat),a._onBeforePhysicsStepCallbacks.forEach((function(e){e(a)})))},this.afterStep=function(){a._physicsEngine&&(a._onAfterPhysicsStepCallbacks.forEach((function(e){e(a)})),a._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(a),a.object.parent&&a.object.rotationQuaternion&&(a.getParentsRotation(),a._tmpQuat.conjugateInPlace(),a._tmpQuat.multiplyToRef(a.object.rotationQuaternion,a.object.rotationQuaternion)),a.object.setAbsolutePosition(a.object.position),a._deltaRotation&&a.object.rotationQuaternion&&a.object.rotationQuaternion.multiplyToRef(a._deltaRotation,a.object.rotationQuaternion),a.object.translate(a._deltaPosition,1))},this.onCollideEvent=null,this.onCollide=function(e){if((a._onPhysicsCollideCallbacks.length||a.onCollideEvent)&&a._physicsEngine){var t=a._physicsEngine.getImpostorWithPhysicsBody(e.body);t&&(a.onCollideEvent&&a.onCollideEvent(a,t),a._onPhysicsCollideCallbacks.filter((function(e){return-1!==e.otherImpostors.indexOf(t)})).forEach((function(i){i.callback(a,t,e.point)})))}},this.object?(this.object.parent&&0!==i.mass&&n.a.Warn("A physics impostor has been created for an object which has a parent. Babylon physics currently works in local space so unexpected issues may occur."),!this._scene&&e.getScene&&(this._scene=e.getScene()),this._scene&&(this.type>100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=o.b.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new o.b),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.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===i.pressure?200:i.pressure,this._options.stiffness=void 0===i.stiffness?1:i.stiffness,this._options.velocityIterations=void 0===i.velocityIterations?20:i.velocityIterations,this._options.positionIterations=void 0===i.positionIterations?20:i.positionIterations,this._options.fixedPoints=void 0===i.fixedPoints?0:i.fixedPoints,this._options.margin=void 0===i.margin?0:i.margin,this._options.damping=void 0===i.damping?0:i.damping,this._options.path=void 0===i.path?null:i.path,this._options.shape=void 0===i.shape?null:i.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&n.a.Warn("You must affect impostors to children before affecting impostor to parent.")):n.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):n.a.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!1,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:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"pressure",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.setBodyPressure?e.getBodyPressure(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPressure&&t.setBodyPressure(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stiffness",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyStiffness?e.getBodyStiffness(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyStiffness&&t.setBodyStiffness(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"velocityIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyVelocityIterations?e.getBodyVelocityIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyVelocityIterations&&t.setBodyVelocityIterations(this,e)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionIterations",{get:function(){if(!this._physicsEngine)return 0;var e=this._physicsEngine.getPhysicsPlugin();return e.getBodyPositionIterations?e.getBodyPositionIterations(this):0},set:function(e){if(this._physicsEngine){var t=this._physicsEngine.getPhysicsPlugin();t.setBodyPositionIterations&&t.setBodyPositionIterations(this,e)}},enumerable:!1,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 a.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:!1,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:!1,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion,i=this.object.scaling.clone();this.object.rotationQuaternion=e.IDENTITY_QUATERNION;var n=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);n&&n.decompose(i,void 0,void 0);var r=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(i);return this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),r}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.e.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.e.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):n.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):n.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],r=-1;this._onPhysicsCollideCallbacks.some((function(e,n){if(e.callback===t&&e.otherImpostors.length===i.length){var o=e.otherImpostors.every((function(e){return i.indexOf(e)>-1}));return o&&(r=n),o}return!1}))?this._onPhysicsCollideCallbacks.splice(r,1):n.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.b.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 n=new c.e(t,i);return this.addJoint(e,n),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.addAnchor=function(e,t,i,n,r){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,i,n,r),this):this},e.prototype.addHook=function(e,t,i,n){if(!this._physicsEngine)return this;var r=this._physicsEngine.getPhysicsPlugin();return r.appendAnchor?(this._physicsEngine&&r.appendHook(this,e,t,i,n),this):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.b),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,n,r,o){var a=e._tmpVecs[0],s=this.object;if(s.rotationQuaternion)if(o){var c=e._tmpQuat;s.rotationQuaternion.multiplyToRef(o,c),t.setRotationQuaternion(c,l.c.WORLD,i)}else t.setRotationQuaternion(s.rotationQuaternion,l.c.WORLD,i);a.x=0,a.y=0,a.z=0,n&&(a.x=n.x,a.y=n.y,a.z=n.z,t.getDirectionToRef(a,i,a),null==r&&(r=n.length()),a.x*=r,a.y*=r,a.z*=r),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,i)):(i.setAbsolutePosition(s.getAbsolutePosition()),i.position.x-=a.x,i.position.y-=a.y,i.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,i,n,r,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var c=e._tmpQuat;t.getRotationQuaternionToRef(l.c.WORLD,i,c),c.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(l.c.WORLD,i,s.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==r&&n&&(r=n.length()),null!=r&&(u.x+=h.x*r,u.y+=h.y*r,u.z+=h.z*r),s.setAbsolutePosition(u)},e.DEFAULT_OBJECT_SIZE=new o.e(1,1,1),e.IDENTITY_QUATERNION=o.b.Identity(),e._tmpVecs=r.a.BuildArray(3,o.e.Zero),e._tmpQuat=o.b.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CapsuleImpostor=6,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e.ConvexHullImpostor=10,e.CustomImpostor=100,e.RopeImpostor=101,e.ClothImpostor=102,e.SoftbodyImpostor=103,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r})),i.d(t,"b",(function(){return o}));var n=i(1),r=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 Object(n.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}(r)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.EndsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},e.StartsWith=function(e,t){return!!e&&0===e.indexOf(t)},e.Decode=function(e){if("undefined"!=typeof TextDecoder)return(new TextDecoder).decode(e);for(var t="",i=0;i<e.byteLength;i++)t+=String.fromCharCode(e[i]);return t},e.EncodeArrayBufferToBase64=function(e){for(var t,i,n,r,o,a,s,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0,h=ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):new Uint8Array(e);u<h.length;)r=(t=h[u++])>>2,o=(3&t)<<4|(i=u<h.length?h[u++]:Number.NaN)>>4,a=(15&i)<<2|(n=u<h.length?h[u++]:Number.NaN)>>6,s=63&n,isNaN(i)?a=s=64:isNaN(n)&&(s=64),l+=c.charAt(r)+c.charAt(o)+c.charAt(a)+c.charAt(s);return l},e.PadNumber=function(e,t){for(var i=String(e);i.length<t;)i="0"+i;return i},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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,this._environmentTexture=null,this.postProcesses=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,n){for(var r in this._BabylonFileParsers)this._BabylonFileParsers.hasOwnProperty(r)&&this._BabylonFileParsers[r](e,t,i,n)},Object.defineProperty(e.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture=e},enumerable:!1,configurable:!0}),e.prototype.getNodes=function(){var e=new Array;return e=(e=(e=(e=e.concat(this.meshes)).concat(this.lights)).concat(this.cameras)).concat(this.transformNodes),this.skeletons.forEach((function(t){return e=e.concat(t.bones)})),e},e._BabylonFileParsers={},e._IndividualBabylonFileParsers={},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return u}));var n=i(20),r=i(6),o=i(18),a=i(22),s=i(86),c=i(0),l=i(9),u=function(){function e(e,t){var i=this;void 0===t&&(t=!0),this.originalScene=e,this._pointerCaptures={},this._lastPointerEvents={},this._sharedGizmoLight=null,this._renderCamera=null,this.pickUtilitySceneFirst=!0,this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.onPointerOutObservable=new r.c,this.utilityLayerScene=new n.a(e.getEngine(),{virtual:!0}),this.utilityLayerScene.useRightHandedSystem=e.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,this.utilityLayerScene.detachControl(),t&&(this._originalPointerObserver=e.onPrePointerObservable.add((function(t,n){if(i.utilityLayerScene.activeCamera&&(i.processAllEvents||t.type===o.a.POINTERMOVE||t.type===o.a.POINTERUP||t.type===o.a.POINTERDOWN||t.type===o.a.POINTERDOUBLETAP)){i.utilityLayerScene.pointerX=e.pointerX,i.utilityLayerScene.pointerY=e.pointerY;var r=t.event;if(e.isPointerCaptured(r.pointerId))i._pointerCaptures[r.pointerId]=!1;else{var a=t.ray?i.utilityLayerScene.pickWithRay(t.ray):i.utilityLayerScene.pick(e.pointerX,e.pointerY);if(!t.ray&&a&&(t.ray=a.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,a),t.type),void(t.type===o.a.POINTERUP&&i._pointerCaptures[r.pointerId]&&(i._pointerCaptures[r.pointerId]=!1));if(i.utilityLayerScene.autoClearDepthAndStencil||i.pickUtilitySceneFirst)a&&a.hit&&(t.skipOnPointerObservable||i.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(t.type,t.event,a),t.type),t.skipOnPointerObservable=!0);else{var s=t.ray?e.pickWithRay(t.ray):e.pick(e.pointerX,e.pointerY),c=t.event;s&&a&&(0===a.distance&&s.pickedMesh?i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(s.pickedMesh)?(i._notifyObservers(t,s,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]&&(a.distance<s.distance||0===s.distance)?(i._notifyObservers(t,a,c),t.skipOnPointerObservable||(t.skipOnPointerObservable=a.distance>0)):!i._pointerCaptures[c.pointerId]&&a.distance>s.distance&&(i.mainSceneTrackerPredicate&&i.mainSceneTrackerPredicate(s.pickedMesh)?(i._notifyObservers(t,s,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._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterCameraRenderObservable.add((function(e){i.shouldRender&&e==i.getRenderCamera()&&i.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){i.dispose()})),this._updateCamera()}return e.prototype.getRenderCamera=function(e){if(this._renderCamera)return this._renderCamera;var t=void 0;return t=this.originalScene.activeCameras&&this.originalScene.activeCameras.length>1?this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.originalScene.activeCamera,e&&t&&t.isRigCamera?t.rigParent:t},e.prototype.setRenderCamera=function(e){this._renderCamera=e},e.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new s.a("shared gizmo light",new c.e(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=l.a.Gray()),this._sharedGizmoLight},Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null}))),e._DefaultUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),e.prototype._notifyObservers=function(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(e.type,e.event,t),e.type),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.onAfterCameraRenderObservable.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.utilityLayerScene.cameraToUseForPointers=this.getRenderCamera(),this.utilityLayerScene.activeCamera=this.getRenderCamera()},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(139),r=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){if(!e._tags)return!1;var t=e._tags;for(var i in t)if(t.hasOwnProperty(i))return!0;return!1},e.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var n in e._tags)e._tags.hasOwnProperty(n)&&!0===e._tags[n]&&i.push(n);return i.join(" ")}return e._tags},e.AddTagsTo=function(t,i){i&&("string"==typeof i&&i.split(" ").forEach((function(i,n,r){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 n=i.split(" ");for(var r in n)e._RemoveTagFrom(t,n[r])}},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 n}));var n=function(){function e(){}return e.IsWindowObjectExist=function(){return"undefined"!=typeof window},e.IsNavigatorAvailable=function(){return"undefined"!=typeof navigator},e.IsDocumentAvailable=function(){return"undefined"!=typeof document},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 n=i(44),r=i(0),o=i(54),a=i(114),s=i(20),c=i(24),l=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,n){void 0===n&&(n=0);var r,o,a,s,c=e._TmpVector3[0].copyFromFloats(t.x-n,t.y-n,t.z-n),l=e._TmpVector3[1].copyFromFloats(i.x+n,i.y+n,i.z+n),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(r=1/this.direction.x,o=(c.x-this.origin.x)*r,(a=(l.x-this.origin.x)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,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(r=1/this.direction.y,o=(c.y-this.origin.y)*r,(a=(l.y-this.origin.y)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,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(r=1/this.direction.z,o=(c.z-this.origin.z)*r,(a=(l.z-this.origin.z)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,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,n=e.center.y-this.origin.y,r=e.center.z-this.origin.z,o=i*i+n*n+r*r,a=e.radius+t,s=a*a;if(o<=s)return!0;var c=i*this.direction.x+n*this.direction.y+r*this.direction.z;return!(c<0)&&o-c*c<=s},e.prototype.intersectsTriangle=function(t,i,n){var o=e._TmpVector3[0],s=e._TmpVector3[1],c=e._TmpVector3[2],l=e._TmpVector3[3],u=e._TmpVector3[4];i.subtractToRef(t,o),n.subtractToRef(t,s),r.e.CrossToRef(this.direction,s,c);var h=r.e.Dot(o,c);if(0===h)return null;var d=1/h;this.origin.subtractToRef(t,l);var f=r.e.Dot(l,c)*d;if(f<0||f>1)return null;r.e.CrossToRef(l,o,u);var p=r.e.Dot(this.direction,u)*d;if(p<0||f+p>1)return null;var _=r.e.Dot(s,u)*d;return _>this.length?null:new a.a(1-f-p,f,_)},e.prototype.intersectsPlane=function(e){var t,i=r.e.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var n=r.e.Dot(e.normal,this.origin);return(t=(-e.d-n)/i)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case"y":return(i=(this.origin.y-t)/this.direction.y)>0?null:new r.e(this.origin.x+this.direction.x*-i,t,this.origin.z+this.direction.z*-i);case"x":return(i=(this.origin.x-t)/this.direction.x)>0?null:new r.e(t,this.origin.y+this.direction.y*-i,this.origin.z+this.direction.z*-i);case"z":var i;return(i=(this.origin.z-t)/this.direction.z)>0?null:new r.e(this.origin.x+this.direction.x*-i,this.origin.y+this.direction.y*-i,t);default:return null}},e.prototype.intersectsMesh=function(t,i){var n=r.c.Matrix[0];return t.getWorldMatrix().invertToRef(n),this._tmpRay?e.TransformToRef(this,n,this._tmpRay):this._tmpRay=e.Transform(this,n),t.intersects(this._tmpRay,i)},e.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var n=0;n<e.length;n++){var r=this.intersectsMesh(e[n],t);r.hit&&i.push(r)}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,n){var o=this.origin,a=r.c.Vector3[0],s=r.c.Vector3[1],c=r.c.Vector3[2],l=r.c.Vector3[3];i.subtractToRef(t,a),this.direction.scaleToRef(e.rayl,c),o.addToRef(c,s),t.subtractToRef(o,l);var u,h,d,f,p=r.e.Dot(a,a),_=r.e.Dot(a,c),m=r.e.Dot(c,c),g=r.e.Dot(a,l),v=r.e.Dot(c,l),b=p*m-_*_,y=b,T=b;b<e.smallnum?(h=0,y=1,f=v,T=m):(f=p*v-_*g,(h=_*v-m*g)<0?(h=0,f=v,T=m):h>y&&(h=y,f=v+_,T=m)),f<0?(f=0,-g<0?h=0:-g>p?h=y:(h=-g,y=p)):f>T&&(f=T,-g+_<0?h=0:-g+_>p?h=y:(h=-g+_,y=p)),u=Math.abs(h)<e.smallnum?0:h/y,d=Math.abs(f)<e.smallnum?0:f/T;var E=r.c.Vector3[4];c.scaleToRef(d,E);var S=r.c.Vector3[5];a.scaleToRef(u,S),S.addInPlace(l);var A=r.c.Vector3[6];return S.subtractToRef(E,A),d>0&&d<=this.length&&A.lengthSquared()<n*n?S.length():-1},e.prototype.update=function(e,t,i,n,r,o,a){return this.unprojectRayToRef(e,t,i,n,r,o,a),this},e.Zero=function(){return new e(r.e.Zero(),r.e.Zero())},e.CreateNew=function(t,i,n,r,o,a,s){return e.Zero().update(t,i,n,r,o,a,s)},e.CreateNewFromTo=function(t,i,n){void 0===n&&(n=r.a.IdentityReadOnly);var o=i.subtract(t),a=Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z);return o.normalize(),e.Transform(new e(t,o,a),n)},e.Transform=function(t,i){var n=new e(new r.e(0,0,0),new r.e(0,0,0));return e.TransformToRef(t,i,n),n},e.TransformToRef=function(e,t,i){r.e.TransformCoordinatesToRef(e.origin,t,i.origin),r.e.TransformNormalToRef(e.direction,t,i.direction),i.length=e.length;var n=i.direction,o=n.length();if(0!==o&&1!==o){var a=1/o;n.x*=a,n.y*=a,n.z*=a,i.length*=o}},e.prototype.unprojectRayToRef=function(e,t,i,n,o,a,s){var c=r.c.Matrix[0];o.multiplyToRef(a,c),c.multiplyToRef(s,c),c.invert();var l=r.c.Vector3[0];l.x=e/i*2-1,l.y=-(t/n*2-1),l.z=-1;var u=r.c.Vector3[1].copyFromFloats(l.x,l.y,1),h=r.c.Vector3[2],d=r.c.Vector3[3];r.e._UnprojectFromInvertedMatrixToRef(l,c,h),r.e._UnprojectFromInvertedMatrixToRef(u,c,d),this.origin.copyFrom(h),d.subtractToRef(h,this.direction),this.direction.normalize()},e._TmpVector3=n.a.BuildArray(6,r.e.Zero),e.smallnum=1e-8,e.rayl=1e9,e}();s.a.prototype.createPickingRay=function(e,t,i,n,r){void 0===r&&(r=!1);var o=l.Zero();return this.createPickingRayToRef(e,t,i,o,n,r),o},s.a.prototype.createPickingRayToRef=function(e,t,i,n,o,a){void 0===a&&(a=!1);var s=this.getEngine();if(!o){if(!this.activeCamera)return this;o=this.activeCamera}var c=o.viewport.toGlobal(s.getRenderWidth(),s.getRenderHeight());return e=e/s.getHardwareScalingLevel()-c.x,t=t/s.getHardwareScalingLevel()-(s.getRenderHeight()-c.y-c.height),n.update(e,t,c.width,c.height,i||r.a.IdentityReadOnly,a?r.a.IdentityReadOnly:o.getViewMatrix(),o.getProjectionMatrix()),this},s.a.prototype.createPickingRayInCameraSpace=function(e,t,i){var n=l.Zero();return this.createPickingRayInCameraSpaceToRef(e,t,n,i),n},s.a.prototype.createPickingRayInCameraSpaceToRef=function(e,t,i,n){if(!o.a)return this;var a=this.getEngine();if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var s=n.viewport.toGlobal(a.getRenderWidth(),a.getRenderHeight()),c=r.a.Identity();return e=e/a.getHardwareScalingLevel()-s.x,t=t/a.getHardwareScalingLevel()-(a.getRenderHeight()-s.y-s.height),i.update(e,t,s.width,s.height,c,c,n.getProjectionMatrix()),this},s.a.prototype._internalPickForMesh=function(e,t,i,n,r,o,a,s){var c=t(n),l=i.intersects(c,r,a,o,n,s);return l&&l.hit?!r&&null!=e&&l.distance>=e.distance?null:l:null},s.a.prototype._internalPick=function(e,t,i,n,a){if(!o.a)return null;for(var s=null,c=0;c<this.meshes.length;c++){var l=this.meshes[c];if(t){if(!t(l))continue}else if(!l.isEnabled()||!l.isVisible||!l.isPickable)continue;var u,h=l.skeleton&&l.skeleton.overrideMesh?l.skeleton.overrideMesh.getWorldMatrix():l.getWorldMatrix();if(l.hasThinInstances&&l.thinInstanceEnablePicking){if(u=this._internalPickForMesh(s,e,l,h,!0,!0,a)){if(n)return s;for(var d=r.c.Matrix[1],f=l.thinInstanceGetWorldMatrices(),p=0;p<f.length;p++){f[p].multiplyToRef(h,d);var _=this._internalPickForMesh(s,e,l,d,i,n,a,!0);if(_&&((s=_).thinInstanceIndex=p,i))return s}}}else if((u=this._internalPickForMesh(s,e,l,h,i,n,a))&&(s=u,i))return s}return s||new o.a},s.a.prototype._internalMultiPick=function(e,t,i){if(!o.a)return null;for(var n=new Array,a=0;a<this.meshes.length;a++){var s=this.meshes[a];if(t){if(!t(s))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var c,l=s.skeleton&&s.skeleton.overrideMesh?s.skeleton.overrideMesh.getWorldMatrix():s.getWorldMatrix();if(s.hasThinInstances&&s.thinInstanceEnablePicking){if(c=this._internalPickForMesh(null,e,s,l,!0,!0,i))for(var u=r.c.Matrix[1],h=s.thinInstanceGetWorldMatrices(),d=0;d<h.length;d++){h[d].multiplyToRef(l,u);var f=this._internalPickForMesh(null,e,s,u,!1,!1,i,!0);f&&(f.thinInstanceIndex=d,n.push(f))}}else(c=this._internalPickForMesh(null,e,s,l,!1,!1,i))&&n.push(c)}return n},s.a.prototype.pickWithBoundingInfo=function(e,t,i,n,a){var s=this;if(!o.a)return null;var c=this._internalPick((function(i){return s._tempPickingRay||(s._tempPickingRay=l.Zero()),s.createPickingRayToRef(e,t,i,s._tempPickingRay,a||null),s._tempPickingRay}),i,n,!0);return c&&(c.ray=this.createPickingRay(e,t,r.a.Identity(),a||null)),c},s.a.prototype.pick=function(e,t,i,n,a,s){var c=this;if(!o.a)return null;var u=this._internalPick((function(i){return c._tempPickingRay||(c._tempPickingRay=l.Zero()),c.createPickingRayToRef(e,t,i,c._tempPickingRay,a||null),c._tempPickingRay}),i,n,!1,s);return u&&(u.ray=this.createPickingRay(e,t,r.a.Identity(),a||null)),u},s.a.prototype.pickWithRay=function(e,t,i,n){var o=this,a=this._internalPick((function(t){return o._pickWithRayInverseMatrix||(o._pickWithRayInverseMatrix=r.a.Identity()),t.invertToRef(o._pickWithRayInverseMatrix),o._cachedRayForTransform||(o._cachedRayForTransform=l.Zero()),l.TransformToRef(e,o._pickWithRayInverseMatrix,o._cachedRayForTransform),o._cachedRayForTransform}),t,i,!1,n);return a&&(a.ray=e),a},s.a.prototype.multiPick=function(e,t,i,n,r){var o=this;return this._internalMultiPick((function(i){return o.createPickingRay(e,t,i,n||null)}),i,r)},s.a.prototype.multiPickWithRay=function(e,t,i){var n=this;return this._internalMultiPick((function(t){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=r.a.Identity()),t.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=l.Zero()),l.TransformToRef(e,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform}),t,i)},c.a.prototype.getForwardRay=function(e,t,i){return void 0===e&&(e=100),this.getForwardRayToRef(new l(r.e.Zero(),r.e.Zero(),e),e,t,i)},c.a.prototype.getForwardRayToRef=function(e,t,i,n){return void 0===t&&(t=100),i||(i=this.getWorldMatrix()),e.length=t,n?e.origin.copyFrom(n):e.origin.copyFrom(this.position),r.c.Vector3[2].set(0,0,this._scene.useRightHandedSystem?-1:1),r.e.TransformNormalToRef(r.c.Vector3[2],i,r.c.Vector3[3]),r.e.NormalizeToRef(r.c.Vector3[3],e.direction),e}},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(0),r=i(7),o=i(16),a=i(98),s=i(4);o.a.CreateLineSystem=function(e){for(var t=[],i=[],n=e.lines,r=e.colors,a=[],s=0,c=0;c<n.length;c++)for(var l=n[c],u=0;u<l.length;u++){if(i.push(l[u].x,l[u].y,l[u].z),r){var h=r[c];a.push(h[u].r,h[u].g,h[u].b,h[u].a)}u>0&&(t.push(s-1),t.push(s)),s++}var d=new o.a;return d.indices=t,d.positions=i,r&&(d.colors=a),d},o.a.CreateDashedLines=function(e){var t,i,r=e.dashSize||3,a=e.gapSize||1,s=e.dashNb||200,c=e.points,l=new Array,u=new Array,h=n.e.Zero(),d=0,f=0,p=0,_=0,m=0;for(m=0;m<c.length-1;m++)c[m+1].subtractToRef(c[m],h),d+=h.length();for(i=r*(t=d/s)/(r+a),m=0;m<c.length-1;m++){c[m+1].subtractToRef(c[m],h),f=Math.floor(h.length()/t),h.normalize();for(var g=0;g<f;g++)p=t*g,l.push(c[m].x+p*h.x,c[m].y+p*h.y,c[m].z+p*h.z),l.push(c[m].x+(p+i)*h.x,c[m].y+(p+i)*h.y,c[m].z+(p+i)*h.z),u.push(_,_+1),_+=2}var v=new o.a;return v.positions=l,v.indices=u,v},r.a.CreateLines=function(e,t,i,n,r){void 0===i&&(i=null),void 0===n&&(n=!1),void 0===r&&(r=null);var o={points:t,updatable:n,instance:r};return c.CreateLines(e,o,i)},r.a.CreateDashedLines=function(e,t,i,n,r,o,a,s){void 0===o&&(o=null);var l={points:t,dashSize:i,gapSize:n,dashNb:r,updatable:a,instance:s};return c.CreateDashedLines(e,l,o)};var c=function(){function e(){}return e.CreateLineSystem=function(e,t,i){var n=t.instance,r=t.lines,c=t.colors;if(n){var l,u,h=n.getVerticesData(s.b.PositionKind);c&&(l=n.getVerticesData(s.b.ColorKind));for(var d=0,f=0,p=0;p<r.length;p++)for(var _=r[p],m=0;m<_.length;m++)h[d]=_[m].x,h[d+1]=_[m].y,h[d+2]=_[m].z,c&&l&&(u=c[p],l[f]=u[m].r,l[f+1]=u[m].g,l[f+2]=u[m].b,l[f+3]=u[m].a,f+=4),d+=3;return n.updateVerticesData(s.b.PositionKind,h,!1,!1),c&&l&&n.updateVerticesData(s.b.ColorKind,l,!1,!1),n}var g=!!c,v=new a.b(e,i,null,void 0,void 0,g,t.useVertexAlpha);return o.a.CreateLineSystem(t).applyToMesh(v,t.updatable),v},e.CreateLines=function(t,i,n){void 0===n&&(n=null);var r=i.colors?[i.colors]:null;return e.CreateLineSystem(t,{lines:[i.points],updatable:i.updatable,instance:i.instance,colors:r,useVertexAlpha:i.useVertexAlpha},n)},e.CreateDashedLines=function(e,t,i){void 0===i&&(i=null);var s=t.points,c=t.instance,l=t.gapSize||1,u=t.dashSize||3;if(c){return c.updateMeshPositions((function(e){var t,i,r=n.e.Zero(),o=e.length/6,a=0,l=0,u=0,h=0,d=0,f=0;for(d=0;d<s.length-1;d++)s[d+1].subtractToRef(s[d],r),a+=r.length();t=a/o;var p=c._creationDataStorage.dashSize;for(i=p*t/(p+c._creationDataStorage.gapSize),d=0;d<s.length-1;d++)for(s[d+1].subtractToRef(s[d],r),l=Math.floor(r.length()/t),r.normalize(),f=0;f<l&&h<e.length;)u=t*f,e[h]=s[d].x+u*r.x,e[h+1]=s[d].y+u*r.y,e[h+2]=s[d].z+u*r.z,e[h+3]=s[d].x+(u+i)*r.x,e[h+4]=s[d].y+(u+i)*r.y,e[h+5]=s[d].z+(u+i)*r.z,h+=6,f++;for(;h<e.length;)e[h]=s[d].x,e[h+1]=s[d].y,e[h+2]=s[d].z,h+=3}),!1),c}var h=new a.b(e,i,null,void 0,void 0,void 0,t.useVertexAlpha);return o.a.CreateDashedLines(t).applyToMesh(h,t.updatable),h._creationDataStorage=new r.b,h._creationDataStorage.dashSize=u,h._creationDataStorage.gapSize=l,h},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(34),r=i(8),o=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};var a=function(){function e(){}return e.DeepCopy=function(e,t,i,a){for(var s=0,c=function(e){var t=[];do{Object.getOwnPropertyNames(e).forEach((function(e){-1===t.indexOf(e)&&t.push(e)}))}while(e=Object.getPrototypeOf(e));return t}(e);s<c.length;s++){var l=c[s];if(("_"!==l[0]||a&&-1!==a.indexOf(l))&&!(n.a.EndsWith(l,"Observable")||i&&-1!==i.indexOf(l))){var u=e[l],h=typeof u;if("function"!==h)try{if("object"===h)if(u instanceof Array){if(t[l]=[],u.length>0)if("object"==typeof u[0])for(var d=0;d<u.length;d++){var f=o(u[d],t);-1===t[l].indexOf(f)&&t[l].push(f)}else t[l]=u.slice(0)}else t[l]=o(u,t);else t[l]=u}catch(e){r.a.Warn(e.message)}}}},e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return u})),i.d(t,"a",(function(){return h}));var n=i(1),r=i(3),o=i(6),a=i(12),s=i(9),c=i(76),l=i(121),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 Object(n.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 s.b(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:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"toneMappingType",{get:function(){return this._toneMappingType},set:function(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"contrast",{get:function(){return this._contrast},set:function(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())},enumerable:!1,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(this._colorCurvesEnabled&&this.colorCurves&&l.a.Bind(this.colorCurves,e),this._vignetteEnabled){var i=1/e.getEngine().getRenderWidth(),n=1/e.getEngine().getRenderHeight();e.setFloat2("vInverseScreenSize",i,n);var r=null!=t?t:n/i,o=Math.tan(.5*this.vignetteCameraFov),s=o*r,c=Math.sqrt(s*o);s=a.b.Mix(s,c,this.vignetteStretch),o=a.b.Mix(o,c,this.vignetteStretch),e.setFloat4("vignetteSettings1",s,o,-s*this.vignetteCentreX,-o*this.vignetteCentreY);var u=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,u)}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);var h=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(h-1)/h,.5/h,h,this.colorGradingTexture.level)}},e.prototype.clone=function(){return r.a.Clone((function(){return new e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.Parse=function(t){return r.a.Parse((function(){return new e}),t,null,null)},Object.defineProperty(e,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!1,configurable:!0}),Object.defineProperty(e,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!1,configurable:!0}),e.TONEMAPPING_STANDARD=0,e.TONEMAPPING_ACES=1,e._VIGNETTEMODE_MULTIPLY=0,e._VIGNETTEMODE_OPAQUE=1,Object(n.c)([Object(r.g)()],e.prototype,"colorCurves",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_colorCurvesEnabled",void 0),Object(n.c)([Object(r.m)("colorGradingTexture")],e.prototype,"_colorGradingTexture",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_colorGradingEnabled",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_colorGradingWithGreenDepth",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_colorGradingBGR",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_exposure",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_toneMappingEnabled",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_toneMappingType",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_contrast",void 0),Object(n.c)([Object(r.c)()],e.prototype,"vignetteStretch",void 0),Object(n.c)([Object(r.c)()],e.prototype,"vignetteCentreX",void 0),Object(n.c)([Object(r.c)()],e.prototype,"vignetteCentreY",void 0),Object(n.c)([Object(r.c)()],e.prototype,"vignetteWeight",void 0),Object(n.c)([Object(r.f)()],e.prototype,"vignetteColor",void 0),Object(n.c)([Object(r.c)()],e.prototype,"vignetteCameraFov",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_vignetteBlendMode",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_vignetteEnabled",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_applyByPostProcess",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_isEnabled",void 0),e}();r.a._ImageProcessingConfigurationParser=h.Parse},function(e,t,i){"use strict";i.d(t,"a",(function(){return d}));var n=i(44),r=i(0),o=i(2),a=i(103),s=i(113),c={min:0,max:0},l={min:0,max:0},u=function(e,t,i){var n=r.e.Dot(t.centerWorld,e),o=Math.abs(r.e.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(r.e.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(r.e.Dot(t.directions[2],e))*t.extendSize.z;i.min=n-o,i.max=n+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 a.a(e,t,i),this.boundingSphere=new s.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!1,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,i){var n=e.TmpVector3[0].copyFrom(t).subtractInPlace(i),r=e.TmpVector3[1].copyFrom(t).addInPlace(i);return this.boundingBox.reConstruct(n,r,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(n,r,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:!1,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(!s.a.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!a.a.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,n=e.boundingBox;return!!h(i.directions[0],i,n)&&(!!h(i.directions[1],i,n)&&(!!h(i.directions[2],i,n)&&(!!h(n.directions[0],i,n)&&(!!h(n.directions[1],i,n)&&(!!h(n.directions[2],i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[1]),i,n)&&(!!h(r.e.Cross(i.directions[0],n.directions[2]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[1]),i,n)&&(!!h(r.e.Cross(i.directions[1],n.directions[2]),i,n)&&(!!h(r.e.Cross(i.directions[2],n.directions[0]),i,n)&&(!!h(r.e.Cross(i.directions[2],n.directions[1]),i,n)&&!!h(r.e.Cross(i.directions[2],n.directions[2]),i,n))))))))))))))},e.TmpVector3=n.a.BuildArray(2,r.e.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.BuildArray=function(e,t){for(var i=[],n=0;n<e;++n)i.push(t());return i},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(0),r=i(7),o=i(16);o.a.CreateSphere=function(e){for(var t=e.segments||32,i=e.diameterX||e.diameter||1,r=e.diameterY||e.diameter||1,a=e.diameterZ||e.diameter||1,s=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=!!e.dedupTopBottomIndices,h=new n.e(i/2,r/2,a/2),d=2+t,f=2*d,p=[],_=[],m=[],g=[],v=0;v<=d;v++){for(var b=v/d,y=b*Math.PI*c,T=0;T<=f;T++){var E=T/f,S=E*Math.PI*2*s,A=n.a.RotationZ(-y),P=n.a.RotationY(S),C=n.e.TransformCoordinates(n.e.Up(),A),R=n.e.TransformCoordinates(C,P),x=R.multiply(h),O=R.divide(h).normalize();_.push(x.x,x.y,x.z),m.push(O.x,O.y,O.z),g.push(E,b)}if(v>0)for(var M=_.length/3,I=M-2*(f+1);I+f+2<M;I++)u?(v>1&&(p.push(I),p.push(I+1),p.push(I+f+1)),(v<d||c<1)&&(p.push(I+f+1),p.push(I+1),p.push(I+f+2))):(p.push(I),p.push(I+1),p.push(I+f+1),p.push(I+f+1),p.push(I+1),p.push(I+f+2))}o.a._ComputeSides(l,_,p,m,g,e.frontUVs,e.backUVs);var D=new o.a;return D.indices=p,D.positions=_,D.normals=m,D.uvs=g,D},r.a.CreateSphere=function(e,t,i,n,r,o){var s={segments:t,diameterX:i,diameterY:i,diameterZ:i,sideOrientation:o,updatable:r};return a.CreateSphere(e,s,n)};var a=function(){function e(){}return e.CreateSphere=function(e,t,i){void 0===i&&(i=null);var n=new r.a(e,i);return t.sideOrientation=r.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,o.a.CreateSphere(t).applyToMesh(n,t.updatable),n},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return l}));var n=i(1),r=i(3),o=i(6),a=i(0),s=i(29),c=i(23),l=function(e){function t(i,n,r){void 0===n&&(n=null),void 0===r&&(r=!0);var s=e.call(this,i,n)||this;return s._forward=new a.e(0,0,1),s._forwardInverted=new a.e(0,0,-1),s._up=new a.e(0,1,0),s._right=new a.e(1,0,0),s._rightInverted=new a.e(-1,0,0),s._position=a.e.Zero(),s._rotation=a.e.Zero(),s._rotationQuaternion=null,s._scaling=a.e.One(),s._isDirty=!1,s._transformToBoneReferal=null,s._isAbsoluteSynced=!1,s._billboardMode=t.BILLBOARDMODE_NONE,s._preserveParentRotationForBillboard=!1,s.scalingDeterminant=1,s._infiniteDistance=!1,s.ignoreNonUniformScaling=!1,s.reIntegrateRotationIntoRotationQuaternion=!1,s._poseMatrix=null,s._localMatrix=a.a.Zero(),s._usePivotMatrix=!1,s._absolutePosition=a.e.Zero(),s._absoluteScaling=a.e.Zero(),s._absoluteRotationQuaternion=a.b.Identity(),s._pivotMatrix=a.a.Identity(),s._postMultiplyPivotMatrix=!1,s._isWorldMatrixFrozen=!1,s._indexInSceneTransformNodesArray=-1,s.onAfterWorldMatrixUpdateObservable=new o.c,s._nonUniformScaling=!1,r&&s.getScene().addTransformNode(s),s}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"billboardMode",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"preserveParentRotationForBillboard",{get:function(){return this._preserveParentRotationForBillboard},set:function(e){e!==this._preserveParentRotationForBillboard&&(this._preserveParentRotationForBillboard=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"infiniteDistance",{get:function(){return this._infiniteDistance},set:function(e){this._infiniteDistance!==e&&(this._infiniteDistance=e)},enumerable:!1,configurable:!0}),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:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._rotationQuaternion=null,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this._rotation.setAll(0),this._isDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"forward",{get:function(){return a.e.Normalize(a.e.TransformNormal(this.getScene().useRightHandedSystem?this._forwardInverted:this._forward,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"up",{get:function(){return a.e.Normalize(a.e.TransformNormal(this._up,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return a.e.Normalize(a.e.TransformNormal(this.getScene().useRightHandedSystem?this._rightInverted:this._right,this.getWorldMatrix()))},enumerable:!1,configurable:!0}),t.prototype.updatePoseMatrix=function(e){return this._poseMatrix?(this._poseMatrix.copyFrom(e),this):(this._poseMatrix=e.clone(),this)},t.prototype.getPoseMatrix=function(){return this._poseMatrix||(this._poseMatrix=a.a.Identity()),this._poseMatrix},t.prototype._isSynchronized=function(){var e=this._cache;return this.billboardMode===e.billboardMode&&this.billboardMode===t.BILLBOARDMODE_NONE&&(!e.pivotMatrixUpdated&&(!this.infiniteDistance&&(!this.position._isDirty&&(!this.scaling._isDirty&&!(this._rotationQuaternion&&this._rotationQuaternion._isDirty||this.rotation._isDirty)))))},t.prototype._initCache=function(){e.prototype._initCache.call(this);var t=this._cache;t.localMatrixUpdated=!1,t.billboardMode=-1,t.infiniteDistance=!1},t.prototype.markAsDirty=function(e){return this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},Object.defineProperty(t.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"absoluteScaling",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteScaling},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"absoluteRotationQuaternion",{get:function(){return this._syncAbsoluteScalingAndRotation(),this._absoluteRotationQuaternion},enumerable:!1,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._usePivotMatrix=!this._pivotMatrix.isIdentity(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=a.a.Invert(this._pivotMatrix)),this},t.prototype.getPivotMatrix=function(){return this._pivotMatrix},t.prototype.instantiateHierarchy=function(e,t,i){void 0===e&&(e=null);var n=this.clone("Clone of "+(this.name||this.id),e||this.parent,!0);n&&i&&i(this,n);for(var r=0,o=this.getChildTransformNodes(!0);r<o.length;r++){o[r].instantiateHierarchy(n,t,i)}return n},t.prototype.freezeWorldMatrix=function(e){return void 0===e&&(e=null),e?this._worldMatrix=e:(this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0)),this._isDirty=!1,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:!1,configurable:!0}),t.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},t.prototype.setAbsolutePosition=function(e){if(!e)return this;var t,i,n;if(void 0===e.x){if(arguments.length<3)return this;t=arguments[0],i=arguments[1],n=arguments[2]}else t=e.x,i=e.y,n=e.z;if(this.parent){var r=a.c.Matrix[0];this.parent.getWorldMatrix().invertToRef(r),a.e.TransformCoordinatesFromFloatsToRef(t,i,n,r,this.position)}else this.position.x=t,this.position.y=i,this.position.z=n;return this._absolutePosition.copyFrom(e),this},t.prototype.setPositionWithLocalVector=function(e){return this.computeWorldMatrix(),this.position=a.e.TransformNormal(e,this._localMatrix),this},t.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var e=a.c.Matrix[0];return this._localMatrix.invertToRef(e),a.e.TransformNormal(this.position,e)},t.prototype.locallyTranslate=function(e){return this.computeWorldMatrix(!0),this.position=a.e.TransformCoordinates(e,this._localMatrix),this},t.prototype.lookAt=function(e,i,n,r,o){void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),void 0===o&&(o=c.c.LOCAL);var s=t._lookAtVectorCache,l=o===c.c.LOCAL?this.position:this.getAbsolutePosition();if(e.subtractToRef(l,s),this.setDirection(s,i,n,r),o===c.c.WORLD&&this.parent)if(this.rotationQuaternion){var u=a.c.Matrix[0];this.rotationQuaternion.toRotationMatrix(u);var h=a.c.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(h),h.invert(),u.multiplyToRef(h,u),this.rotationQuaternion.fromRotationMatrix(u)}else{var d=a.c.Quaternion[0];a.b.FromEulerVectorToRef(this.rotation,d);u=a.c.Matrix[0];d.toRotationMatrix(u);h=a.c.Matrix[1];this.parent.getWorldMatrix().getRotationMatrixToRef(h),h.invert(),u.multiplyToRef(h,u),d.fromRotationMatrix(u),d.toEulerAnglesToRef(this.rotation)}return this},t.prototype.getDirection=function(e){var t=a.e.Zero();return this.getDirectionToRef(e,t),t},t.prototype.getDirectionToRef=function(e,t){return a.e.TransformNormalToRef(e,this.getWorldMatrix(),t),this},t.prototype.setDirection=function(e,t,i,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=0);var r=-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.b.RotationYawPitchRollToRef(r+t,s+i,n,this.rotationQuaternion):(this.rotation.x=s+i,this.rotation.y=r+t,this.rotation.z=n),this},t.prototype.setPivotPoint=function(e,t){void 0===t&&(t=c.c.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var i=this.getWorldMatrix();if(t==c.c.WORLD){var n=a.c.Matrix[0];i.invertToRef(n),e=a.e.TransformCoordinates(e,n)}return this.setPivotMatrix(a.a.Translation(-e.x,-e.y,-e.z),!0)},t.prototype.getPivotPoint=function(){var e=a.e.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.e.Zero();return this.getAbsolutePivotPointToRef(e),e},t.prototype.getAbsolutePivotPointToRef=function(e){return this.getPivotPointToRef(e),a.e.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this},t.prototype.setParent=function(e){if(!e&&!this.parent)return this;var t=a.c.Quaternion[0],i=a.c.Vector3[0],n=a.c.Vector3[1];if(e){var r=a.c.Matrix[0],o=a.c.Matrix[1];this.computeWorldMatrix(!0),e.computeWorldMatrix(!0),e.getWorldMatrix().invertToRef(o),this.getWorldMatrix().multiplyToRef(o,r),r.decompose(n,t,i)}else this.computeWorldMatrix(!0),this.getWorldMatrix().decompose(n,t,i);return this.rotationQuaternion?this.rotationQuaternion.copyFrom(t):t.toEulerAnglesToRef(this.rotation),this.scaling.copyFrom(n),this.position.copyFrom(i),this.parent=e,this},Object.defineProperty(t.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!1,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.getSkeleton().prepare(),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,n){var r;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=this.rotation.toQuaternion(),this.rotation.setAll(0)),n&&n!==c.c.LOCAL){if(this.parent){var o=a.c.Matrix[0];this.parent.getWorldMatrix().invertToRef(o),e=a.e.TransformNormal(e,o)}(r=a.b.RotationAxisToRef(e,i,t._rotationAxisCache)).multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else r=a.b.RotationAxisToRef(e,i,t._rotationAxisCache),this.rotationQuaternion.multiplyToRef(r,this.rotationQuaternion);return this},t.prototype.rotateAround=function(e,t,i){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=a.b.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.setAll(0));var n=a.c.Vector3[0],r=a.c.Vector3[1],o=a.c.Vector3[2],s=a.c.Quaternion[0],c=a.c.Matrix[0],l=a.c.Matrix[1],u=a.c.Matrix[2],h=a.c.Matrix[3];return e.subtractToRef(this.position,n),a.a.TranslationToRef(n.x,n.y,n.z,c),a.a.TranslationToRef(-n.x,-n.y,-n.z,l),a.a.RotationAxisToRef(t,i,u),l.multiplyToRef(u,h),h.multiplyToRef(c,h),h.decompose(r,s,o),this.position.addInPlace(o),s.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},t.prototype.translate=function(e,t,i){var n=e.scale(t);if(i&&i!==c.c.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var r=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(r)}return this},t.prototype.addRotation=function(e,t,i){var n;this.rotationQuaternion?n=this.rotationQuaternion:(n=a.c.Quaternion[1],a.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,n));var r=a.c.Quaternion[0];return a.b.RotationYawPitchRollToRef(t,e,i,r),n.multiplyInPlace(r),this.rotationQuaternion||n.toEulerAnglesToRef(this.rotation),this},t.prototype._getEffectiveParent=function(){return this.parent},t.prototype.computeWorldMatrix=function(e){if(this._isWorldMatrixFrozen&&!this._isDirty)return this._worldMatrix;var i=this.getScene().getRenderId();if(!this._isDirty&&!e&&this.isSynchronized())return this._currentRenderId=i,this._worldMatrix;var n=this.getScene().activeCamera,r=0!=(this._billboardMode&t.BILLBOARDMODE_USE_POSITION),o=this._billboardMode!==t.BILLBOARDMODE_NONE&&!this.preserveParentRotationForBillboard;o&&n&&r&&(this.lookAt(n.position),(this.billboardMode&t.BILLBOARDMODE_X)!==t.BILLBOARDMODE_X&&(this.rotation.x=0),(this.billboardMode&t.BILLBOARDMODE_Y)!==t.BILLBOARDMODE_Y&&(this.rotation.y=0),(this.billboardMode&t.BILLBOARDMODE_Z)!==t.BILLBOARDMODE_Z&&(this.rotation.z=0)),this._updateCache();var s=this._cache;s.pivotMatrixUpdated=!1,s.billboardMode=this.billboardMode,s.infiniteDistance=this.infiniteDistance,this._currentRenderId=i,this._childUpdateId++,this._isDirty=!1,this._position._isDirty=!1,this._rotation._isDirty=!1,this._scaling._isDirty=!1;var c,l=this._getEffectiveParent(),u=t._TmpScaling,h=this._position;if(this._infiniteDistance&&!this.parent&&n){var d=n.getWorldMatrix(),f=new a.e(d.m[12],d.m[13],d.m[14]);(h=t._TmpTranslation).copyFromFloats(this._position.x+f.x,this._position.y+f.y,this._position.z+f.z)}(u.copyFromFloats(this._scaling.x*this.scalingDeterminant,this._scaling.y*this.scalingDeterminant,this._scaling.z*this.scalingDeterminant),this._rotationQuaternion)?(this._rotationQuaternion._isDirty=!1,c=this._rotationQuaternion,this.reIntegrateRotationIntoRotationQuaternion&&this.rotation.lengthSquared()&&(this._rotationQuaternion.multiplyInPlace(a.b.RotationYawPitchRoll(this._rotation.y,this._rotation.x,this._rotation.z)),this._rotation.copyFromFloats(0,0,0))):(c=t._TmpRotation,a.b.RotationYawPitchRollToRef(this._rotation.y,this._rotation.x,this._rotation.z,c));if(this._usePivotMatrix){var p=a.c.Matrix[1];a.a.ScalingToRef(u.x,u.y,u.z,p);var _=a.c.Matrix[0];c.toRotationMatrix(_),this._pivotMatrix.multiplyToRef(p,a.c.Matrix[4]),a.c.Matrix[4].multiplyToRef(_,this._localMatrix),this._postMultiplyPivotMatrix&&this._localMatrix.multiplyToRef(this._pivotMatrixInverse,this._localMatrix),this._localMatrix.addTranslationFromFloats(h.x,h.y,h.z)}else a.a.ComposeToRef(u,c,h,this._localMatrix);if(l&&l.getWorldMatrix){if(e&&l.computeWorldMatrix(),o){this._transformToBoneReferal?l.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),a.c.Matrix[7]):a.c.Matrix[7].copyFrom(l.getWorldMatrix());var m=a.c.Vector3[5],g=a.c.Vector3[6];a.c.Matrix[7].decompose(g,void 0,m),a.a.ScalingToRef(g.x,g.y,g.z,a.c.Matrix[7]),a.c.Matrix[7].setTranslation(m),this._localMatrix.multiplyToRef(a.c.Matrix[7],this._worldMatrix)}else this._transformToBoneReferal?(this._localMatrix.multiplyToRef(l.getWorldMatrix(),a.c.Matrix[6]),a.c.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localMatrix.multiplyToRef(l.getWorldMatrix(),this._worldMatrix);this._markSyncedWithParent()}else this._worldMatrix.copyFrom(this._localMatrix);if(o&&n&&this.billboardMode&&!r){var v=a.c.Vector3[0];if(this._worldMatrix.getTranslationToRef(v),a.c.Matrix[1].copyFrom(n.getViewMatrix()),a.c.Matrix[1].setTranslationFromFloats(0,0,0),a.c.Matrix[1].invertToRef(a.c.Matrix[0]),(this.billboardMode&t.BILLBOARDMODE_ALL)!==t.BILLBOARDMODE_ALL){a.c.Matrix[0].decompose(void 0,a.c.Quaternion[0],void 0);var b=a.c.Vector3[1];a.c.Quaternion[0].toEulerAnglesToRef(b),(this.billboardMode&t.BILLBOARDMODE_X)!==t.BILLBOARDMODE_X&&(b.x=0),(this.billboardMode&t.BILLBOARDMODE_Y)!==t.BILLBOARDMODE_Y&&(b.y=0),(this.billboardMode&t.BILLBOARDMODE_Z)!==t.BILLBOARDMODE_Z&&(b.z=0),a.a.RotationYawPitchRollToRef(b.y,b.x,b.z,a.c.Matrix[0])}this._worldMatrix.setTranslationFromFloats(0,0,0),this._worldMatrix.multiplyToRef(a.c.Matrix[0],this._worldMatrix),this._worldMatrix.setTranslation(a.c.Vector3[0])}return this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this._scaling.isNonUniformWithinEpsilon(1e-6)?this._updateNonUniformScalingState(!0):l&&l._nonUniformScaling?this._updateNonUniformScalingState(l._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this._isAbsoluteSynced=!1,this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=a.a.Invert(this._worldMatrix)),this._worldMatrixDeterminantIsDirty=!0,this._worldMatrix},t.prototype.resetLocalMatrix=function(e){if(void 0===e&&(e=!0),this.computeWorldMatrix(),e)for(var t=this.getChildren(),i=0;i<t.length;++i){var n=t[i];if(n){n.computeWorldMatrix();var r=a.c.Matrix[0];n._localMatrix.multiplyToRef(this._localMatrix,r);var o=a.c.Quaternion[0];r.decompose(n.scaling,o,n.position),n.rotationQuaternion?n.rotationQuaternion=o:o.toEulerAnglesToRef(n.rotation)}}this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=a.b.Identity()),this._worldMatrix=a.a.Identity()},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.e.TransformCoordinates(this.getAbsolutePosition(),e.getViewMatrix())},t.prototype.getDistanceToCamera=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),this.getAbsolutePosition().subtract(e.globalPosition).length()},t.prototype.clone=function(e,i,n){var o=this,a=r.a.Clone((function(){return new t(e,o.getScene())}),this);if(a.name=e,a.id=e,i&&(a.parent=i),!n)for(var s=this.getDescendants(!0),c=0;c<s.length;c++){var l=s[c];l.clone&&l.clone(e+"."+l.name,a)}return a},t.prototype.serialize=function(e){var t=r.a.Serialize(this,e);return t.type=this.getClassName(),this.parent&&(t.parentId=this.parent.id),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),this.parent&&(t.parentId=this.parent.id),t},t.Parse=function(e,i,n){var o=r.a.Parse((function(){return new t(e.name,i)}),e,i,n);return e.localMatrix?o.setPreTransformMatrix(a.a.FromArray(e.localMatrix)):e.pivotMatrix&&o.setPivotMatrix(a.a.FromArray(e.pivotMatrix)),o.setEnabled(e.isEnabled),e.parentId&&(o._waitingParentId=e.parentId),o},t.prototype.getChildTransformNodes=function(e,i){var n=[];return this._getDescendants(n,e,(function(e){return(!i||i(e))&&e instanceof t})),n},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 n=0,r=this.getChildTransformNodes(!0);n<r.length;n++){var o=r[n];o.parent=null,o.computeWorldMatrix(!0)}e.prototype.dispose.call(this,t,i)},t.prototype.normalizeToUnitCube=function(e,t,i){void 0===e&&(e=!0),void 0===t&&(t=!1);var n=null,r=null;t&&(this.rotationQuaternion?(r=this.rotationQuaternion.clone(),this.rotationQuaternion.copyFromFloats(0,0,0,1)):this.rotation&&(n=this.rotation.clone(),this.rotation.copyFromFloats(0,0,0)));var o=this.getHierarchyBoundingVectors(e,i),a=o.max.subtract(o.min),s=Math.max(a.x,a.y,a.z);if(0===s)return this;var c=1/s;return this.scaling.scaleInPlace(c),t&&(this.rotationQuaternion&&r?this.rotationQuaternion.copyFrom(r):this.rotation&&n&&this.rotation.copyFrom(n)),this},t.prototype._syncAbsoluteScalingAndRotation=function(){this._isAbsoluteSynced||(this._worldMatrix.decompose(this._absoluteScaling,this._absoluteRotationQuaternion),this._isAbsoluteSynced=!0)},t.BILLBOARDMODE_NONE=0,t.BILLBOARDMODE_X=1,t.BILLBOARDMODE_Y=2,t.BILLBOARDMODE_Z=4,t.BILLBOARDMODE_ALL=7,t.BILLBOARDMODE_USE_POSITION=128,t._TmpRotation=a.b.Zero(),t._TmpScaling=a.e.Zero(),t._TmpTranslation=a.e.Zero(),t._lookAtVectorCache=new a.e(0,0,0),t._rotationAxisCache=new a.b,Object(n.c)([Object(r.o)("position")],t.prototype,"_position",void 0),Object(n.c)([Object(r.o)("rotation")],t.prototype,"_rotation",void 0),Object(n.c)([Object(r.l)("rotationQuaternion")],t.prototype,"_rotationQuaternion",void 0),Object(n.c)([Object(r.o)("scaling")],t.prototype,"_scaling",void 0),Object(n.c)([Object(r.c)("billboardMode")],t.prototype,"_billboardMode",void 0),Object(n.c)([Object(r.c)()],t.prototype,"scalingDeterminant",void 0),Object(n.c)([Object(r.c)("infiniteDistance")],t.prototype,"_infiniteDistance",void 0),Object(n.c)([Object(r.c)()],t.prototype,"ignoreNonUniformScaling",void 0),Object(n.c)([Object(r.c)()],t.prototype,"reIntegrateRotationIntoRotationQuaternion",void 0),t}(s.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(e,t,i,n,r,o){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=n,this.sourceEvent=r,this.additionalData=o}return e.CreateNew=function(t,i,n){var r=t.getScene();return new e(t,r.pointerX,r.pointerY,r.meshUnderPointer||t,i,n)},e.CreateNewFromSprite=function(t,i,n,r){return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,n,r)},e.CreateNewFromScene=function(t,i){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)},e.CreateNewFromPrimitive=function(t,i,n,r){return new e(t,i.x,i.y,null,n,r)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return u}));var n=i(1),r=i(3),o=i(0),a=i(9),s=i(29),c=i(85),l=i(11),u=function(e){function t(i,n){var r=e.call(this,i,n)||this;return r.diffuse=new a.a(1,1,1),r.specular=new a.a(1,1,1),r.falloffType=t.FALLOFF_DEFAULT,r.intensity=1,r._range=Number.MAX_VALUE,r._inverseSquaredRange=0,r._photometricScale=1,r._intensityMode=t.INTENSITYMODE_AUTOMATIC,r._radius=1e-5,r.renderPriority=0,r._shadowEnabled=!0,r._excludeWithLayerMask=0,r._includeOnlyWithLayerMask=0,r._lightmapMode=0,r._excludedMeshesIds=new Array,r._includedOnlyMeshesIds=new Array,r._isLight=!0,r.getScene().addLight(r),r._uniformBuffer=new c.a(r.getScene().getEngine()),r._buildUniformLayout(),r.includedOnlyMeshes=new Array,r.excludedMeshes=new Array,r._resyncMeshes(),r}return Object(n.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowEnabled",{get:function(){return this._shadowEnabled},set:function(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),t.prototype.transferTexturesToEffect=function(e,t){return this},t.prototype._bindLight=function(e,t,i,n,r){void 0===r&&(r=!1);var o=e.toString(),s=!1;if(!r||!this._uniformBuffer._alreadyBound){if(this._uniformBuffer.bindToEffect(i,"Light"+o),this._renderId!==t.getRenderId()||!this._uniformBuffer.useUbo){this._renderId=t.getRenderId();var c=this.getScaledIntensity();this.transferToEffect(i,o),this.diffuse.scaleToRef(c,a.c.Color3[0]),this._uniformBuffer.updateColor4("vLightDiffuse",a.c.Color3[0],this.range,o),n&&(this.specular.scaleToRef(c,a.c.Color3[1]),this._uniformBuffer.updateColor4("vLightSpecular",a.c.Color3[1],this.radius,o)),s=!0}if(this.transferTexturesToEffect(i,o),t.shadowsEnabled&&this.shadowEnabled){var l=this.getShadowGenerator();l&&(l.bindShadowLight(o,i),s=!0)}s&&this._uniformBuffer.update()}},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.isDisposed()||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.e.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 n=0,r=this.getScene().meshes;n<r.length;n++){r[n]._removeLightSource(this,!0)}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,i){void 0===i&&(i=null);var n=t.GetConstructorFromName(this.getTypeID(),e,this.getScene());if(!n)return null;var o=r.a.Clone(n,this);return i&&(o.parent=i),o.setEnabled(this.isEnabled()),o},t.prototype.serialize=function(){var e=r.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)}))),r.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.GetConstructorFromName=function(e,t,i){var n=s.a.Construct("Light_Type_"+e,t,i);return n||null},t.Parse=function(e,i){var n=t.GetConstructorFromName(e.type,e.name,i);if(!n)return null;var o=r.a.Parse(n,e,i);if(e.excludedMeshesIds&&(o._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(o._waitingParentId=e.parentId),void 0!==e.falloffType&&(o.falloffType=e.falloffType),void 0!==e.lightmapMode&&(o.lightmapMode=e.lightmapMode),e.animations){for(var a=0;a<e.animations.length;a++){var c=e.animations[a],u=l.a.GetClass("BABYLON.Animation");u&&o.animations.push(u.Parse(c))}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 n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];for(var o=i.apply(e,n),a=0,s=n;a<s.length;a++){var c=s[a];c._resyncLightSource(t)}return o};var n=e.splice;e.splice=function(i,r){for(var o=n.apply(e,[i,r]),a=0,s=o;a<s.length;a++){s[a]._resyncLightSource(t)}return o};for(var r=0,o=e;r<o.length;r++){o[r]._resyncLightSource(this)}},t.prototype._hookArrayForIncludedOnly=function(e){var t=this,i=e.push;e.push=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=i.apply(e,n);return t._resyncMeshes(),o};var n=e.splice;e.splice=function(i,r){var o=n.apply(e,[i,r]);return t._resyncMeshes(),o},this._resyncMeshes()},t.prototype._resyncMeshes=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){t[e]._resyncLightSource(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(),n=this.intensityMode;switch(n===t.INTENSITYMODE_AUTOMATIC&&(n=i===t.LIGHTTYPEID_DIRECTIONALLIGHT?t.INTENSITYMODE_ILLUMINANCE:t.INTENSITYMODE_LUMINOUSINTENSITY),i){case t.LIGHTTYPEID_POINTLIGHT:case t.LIGHTTYPEID_SPOTLIGHT:switch(n){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(n){case t.INTENSITYMODE_ILLUMINANCE:e=1;break;case t.INTENSITYMODE_LUMINANCE:var r=this.radius;r=Math.max(r,.001),e=2*Math.PI*(1-Math.cos(r))}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,Object(n.c)([Object(r.e)()],t.prototype,"diffuse",void 0),Object(n.c)([Object(r.e)()],t.prototype,"specular",void 0),Object(n.c)([Object(r.c)()],t.prototype,"falloffType",void 0),Object(n.c)([Object(r.c)()],t.prototype,"intensity",void 0),Object(n.c)([Object(r.c)()],t.prototype,"range",null),Object(n.c)([Object(r.c)()],t.prototype,"intensityMode",null),Object(n.c)([Object(r.c)()],t.prototype,"radius",null),Object(n.c)([Object(r.c)()],t.prototype,"_renderPriority",void 0),Object(n.c)([Object(r.b)("_reorderLightsInScene")],t.prototype,"renderPriority",void 0),Object(n.c)([Object(r.c)("shadowEnabled")],t.prototype,"_shadowEnabled",void 0),Object(n.c)([Object(r.c)("excludeWithLayerMask")],t.prototype,"_excludeWithLayerMask",void 0),Object(n.c)([Object(r.c)("includeOnlyWithLayerMask")],t.prototype,"_includeOnlyWithLayerMask",void 0),Object(n.c)([Object(r.c)("lightmapMode")],t.prototype,"_lightmapMode",void 0),t}(s.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this._xhr="undefined"!=typeof _native&&_native.XMLHttpRequest?new _native.XMLHttpRequest:new XMLHttpRequest}return e.prototype._injectCustomRequestHeaders=function(){for(var t in e.CustomRequestHeaders){var i=e.CustomRequestHeaders[t];i&&this._xhr.setRequestHeader(t,i)}},Object.defineProperty(e.prototype,"onprogress",{get:function(){return this._xhr.onprogress},set:function(e){this._xhr.onprogress=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this._xhr.readyState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"status",{get:function(){return this._xhr.status},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"statusText",{get:function(){return this._xhr.statusText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"response",{get:function(){return this._xhr.response},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseURL",{get:function(){return this._xhr.responseURL},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseText",{get:function(){return this._xhr.responseText},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"responseType",{get:function(){return this._xhr.responseType},set:function(e){this._xhr.responseType=e},enumerable:!1,configurable:!0}),e.prototype.addEventListener=function(e,t,i){this._xhr.addEventListener(e,t,i)},e.prototype.removeEventListener=function(e,t,i){this._xhr.removeEventListener(e,t,i)},e.prototype.abort=function(){this._xhr.abort()},e.prototype.send=function(t){e.CustomRequestHeaders&&this._injectCustomRequestHeaders(),this._xhr.send(t)},e.prototype.open=function(t,i){for(var n=0,r=e.CustomRequestModifiers;n<r.length;n++){(0,r[n])(this._xhr,i)}return i=(i=i.replace("file:http:","http:")).replace("file:https:","https:"),this._xhr.open(t,i,!0)},e.prototype.setRequestHeader=function(e,t){this._xhr.setRequestHeader(e,t)},e.prototype.getResponseHeader=function(e){return this._xhr.getResponseHeader(e)},e.CustomRequestHeaders={},e.CustomRequestModifiers=new Array,e}()},function(e,t,i){"use strict";i.d(t,"e",(function(){return r})),i.d(t,"a",(function(){return o})),i.d(t,"d",(function(){return a})),i.d(t,"c",(function(){return s})),i.d(t,"b",(function(){return c}));var n=i(1),r=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"physicsPlugin",{set:function(e){this._physicsPlugin=e},enumerable:!1,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,r.DistanceJoint,t)||this}return Object(n.d)(t,e),t.prototype.updateDistance=function(e,t){this._physicsPlugin.updateDistanceJoint(this,e,t)},t}(r),a=function(e){function t(t,i){return e.call(this,t,i)||this}return Object(n.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}(r),s=function(e){function t(t){return e.call(this,r.HingeJoint,t)||this}return Object(n.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}(a),c=function(e){function t(t){return e.call(this,r.Hinge2Joint,t)||this}return Object(n.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}(a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return s}));var n=i(0),r=i(7),o=i(36),a=i(18),s=function(){function e(e){var t=this;void 0===e&&(e=o.a.DefaultUtilityLayer),this.gizmoLayer=e,this._attachedMesh=null,this._attachedNode=null,this._scaleRatio=1,this._isHovered=!1,this._customMeshSet=!1,this._updateGizmoRotationToMatchAttachedMesh=!0,this.updateGizmoPositionToMatchAttachedMesh=!0,this.updateScale=!0,this._interactionsEnabled=!0,this._tempQuaternion=new n.b(0,0,0,1),this._tempVector=new n.e,this._tempVector2=new n.e,this._tempMatrix1=new n.a,this._tempMatrix2=new n.a,this._rightHandtoLeftHandMatrix=n.a.RotationY(Math.PI),this._rootMesh=new r.a("gizmoRootNode",e.utilityLayerScene),this._rootMesh.rotationQuaternion=n.b.Identity(),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add((function(){t._update()}))}return Object.defineProperty(e.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHovered",{get:function(){return this._isHovered},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e,e&&(this._attachedNode=e),this._rootMesh.setEnabled(!!e),this._attachedNodeChanged(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"attachedNode",{get:function(){return this._attachedNode},set:function(e){this._attachedNode=e,this._attachedMesh=null,this._rootMesh.setEnabled(!!e),this._attachedNodeChanged(e)},enumerable:!1,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},Object.defineProperty(e.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e},enumerable:!1,configurable:!0}),e.prototype._attachedNodeChanged=function(e){},e.prototype._update=function(){if(this.attachedNode){var e=this.attachedNode;if(this.attachedMesh&&(e=this.attachedMesh._effectiveMesh||this.attachedNode),this.updateGizmoPositionToMatchAttachedMesh){var t=e.getWorldMatrix().getRow(3),i=t?t.toVector3():new n.e(0,0,0);this._rootMesh.position.copyFrom(i)}if(this.updateGizmoRotationToMatchAttachedMesh?e.getWorldMatrix().decompose(void 0,this._rootMesh.rotationQuaternion):this._rootMesh.rotationQuaternion.set(0,0,0,1),this.updateScale){var r=this.gizmoLayer.utilityLayerScene.activeCamera,o=r.globalPosition;r.devicePosition&&(o=r.devicePosition),this._rootMesh.position.subtractToRef(o,this._tempVector);var a=this._tempVector.length()*this.scaleRatio;this._rootMesh.scaling.set(a,a,a),e._getWorldMatrixDeterminant()<0&&(this._rootMesh.scaling.y*=-1)}else this._rootMesh.scaling.setAll(this.scaleRatio)}},e.prototype._matrixChanged=function(){if(this._attachedNode)if(this._attachedNode._isCamera){var e,t,i=this._attachedNode;if(i.parent){var n=this._tempMatrix2;i.parent._worldMatrix.invertToRef(n),this._attachedNode._worldMatrix.multiplyToRef(n,this._tempMatrix1),e=this._tempMatrix1}else e=this._attachedNode._worldMatrix;if(i.getScene().useRightHandedSystem?(this._rightHandtoLeftHandMatrix.multiplyToRef(e,this._tempMatrix2),t=this._tempMatrix2):t=e,t.decompose(this._tempVector2,this._tempQuaternion,this._tempVector),"FreeCamera"===this._attachedNode.getClassName()||"FlyCamera"===this._attachedNode.getClassName()||"ArcFollowCamera"===this._attachedNode.getClassName()||"TargetCamera"===this._attachedNode.getClassName()||"TouchCamera"===this._attachedNode.getClassName()||"UniversalCamera"===this._attachedNode.getClassName()){var r=this._attachedNode;r.rotation=this._tempQuaternion.toEulerAngles(),r.rotationQuaternion&&r.rotationQuaternion.copyFrom(this._tempQuaternion)}i.position.copyFrom(this._tempVector)}else if(this._attachedNode._isMesh||"AbstractMesh"===this._attachedNode.getClassName()||"TransformNode"===this._attachedNode.getClassName()||"InstancedMesh"===this._attachedNode.getClassName()){var o=this._attachedNode;if(o.parent){n=this._tempMatrix1;var a=this._tempMatrix2;o.parent.getWorldMatrix().invertToRef(n),this._attachedNode.getWorldMatrix().multiplyToRef(n,a),a.decompose(o.scaling,this._tempQuaternion,o.position)}else this._attachedNode._worldMatrix.decompose(o.scaling,this._tempQuaternion,o.position);o.billboardMode||(o.rotationQuaternion?o.rotationQuaternion.copyFrom(this._tempQuaternion):o.rotation=this._tempQuaternion.toEulerAngles())}else if("Bone"===this._attachedNode.getClassName()){var s=this._attachedNode,c=s.getParent();if(c){var l=this._tempMatrix1,u=this._tempMatrix2;c.getWorldMatrix().invertToRef(l),s.getWorldMatrix().multiplyToRef(l,u),s.getLocalMatrix().copyFrom(u)}else{s.getLocalMatrix().copyFrom(s.getWorldMatrix())}s.markAsDirty()}},e.GizmoAxisPointerObserver=function(e,t){var i=!1;return e.utilityLayerScene.onPointerObservable.add((function(e){var n,r;if(e.pickInfo){if(e.type===a.a.POINTERMOVE){if(i)return;t.forEach((function(t){var i,n;if(t.colliderMeshes&&t.gizmoMeshes){var r=-1!=(null===(i=t.colliderMeshes)||void 0===i?void 0:i.indexOf(null===(n=null==e?void 0:e.pickInfo)||void 0===n?void 0:n.pickedMesh))||t.active?t.hoverMaterial:t.material;t.gizmoMeshes.forEach((function(e){e.material=r,e.color&&(e.color=r.diffuseColor)}))}}))}if(e.type===a.a.POINTERDOWN)if(t.has(null===(n=e.pickInfo.pickedMesh)||void 0===n?void 0:n.parent))i=!0,t.get(null===(r=e.pickInfo.pickedMesh)||void 0===r?void 0:r.parent).active=!0,t.forEach((function(t){var i,n,r=-1!=(null===(i=t.colliderMeshes)||void 0===i?void 0:i.indexOf(null===(n=null==e?void 0:e.pickInfo)||void 0===n?void 0:n.pickedMesh))||t.active?t.hoverMaterial:t.disableMaterial;t.gizmoMeshes.forEach((function(e){e.material=r,e.color&&(e.color=r.diffuseColor)}))}));e.type===a.a.POINTERUP&&t.forEach((function(e){e.active=!1,i=!1,e.gizmoMeshes.forEach((function(t){t.material=e.material,t.color&&(t.color=e.material.diffuseColor)}))}))}}))},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 h}));var n=i(1),r=i(3),o=i(6),a=i(0),s=i(22),c=i(2),l=i(120),u=(i(56),i(77)),h=function(e){function t(i){var n=e.call(this,null)||this;return n.metadata=null,n.reservedDataStore=null,n._hasAlpha=!1,n.getAlphaFromRGB=!1,n.level=1,n.coordinatesIndex=0,n._coordinatesMode=c.a.TEXTURE_EXPLICIT_MODE,n.wrapR=c.a.TEXTURE_WRAP_ADDRESSMODE,n.anisotropicFilteringLevel=t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,n._isCube=!1,n._gammaSpace=!0,n.invertZ=!1,n.lodLevelInAlpha=!1,n.isRenderTarget=!1,n._prefiltered=!1,n.animations=new Array,n.onDisposeObservable=new o.c,n._onDisposeObserver=null,n._scene=null,n._texture=null,n._uid=null,i?t._isScene(i)?n._scene=i:n._engine=i:n._scene=s.a.LastCreatedScene,n._scene&&(n.uniqueId=n._scene.getUniqueId(),n._scene.addTexture(n),n._engine=n._scene.getEngine()),n._uid=null,n}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(c.a.MATERIAL_TextureDirtyFlag|c.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(c.a.MATERIAL_TextureDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{get:function(){return this._wrapU},set:function(e){this._wrapU=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wrapV",{get:function(){return this._wrapV},set:function(e){this._wrapV=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isCube",{get:function(){return this._texture?this._texture.isCube:this._isCube},set:function(e){this._texture?this._texture.isCube=e:this._isCube=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(e){this._texture&&(this._texture.is3D=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"is2DArray",{get:function(){return!!this._texture&&this._texture.is2DArray},set:function(e){this._texture&&(this._texture.is2DArray=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gammaSpace",{get:function(){return this._texture?(null===this._texture._gammaSpace&&(this._texture._gammaSpace=this._gammaSpace),this._texture._gammaSpace):this._gammaSpace},set:function(e){if(this._texture){if(this._texture._gammaSpace===e)return;this._texture._gammaSpace=e}else{if(this._gammaSpace===e)return;this._gammaSpace=e}this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isRGBD",{get:function(){return null!=this._texture&&this._texture._isRGBD},set:function(e){this._texture&&(this._texture._isRGBD=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(e){this._texture&&(this._texture._lodGenerationOffset=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0},set:function(e){this._texture&&(this._texture._lodGenerationScale=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linearSpecularLOD",{get:function(){return!!this._texture&&this._texture._linearSpecularLOD},set:function(e){this._texture&&(this._texture._linearSpecularLOD=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"irradianceTexture",{get:function(){return this._texture?this._texture._irradianceTexture:null},set:function(e){this._texture&&(this._texture._irradianceTexture=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=l.a.RandomId()),this._uid},enumerable:!1,configurable:!0}),t.prototype.toString=function(){return this.name},t.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype._getEngine=function(){return this._engine},t.prototype.checkTransformsAreIdentical=function(e){return null!==e},t.prototype.getTextureMatrix=function(){return a.a.IdentityReadOnly},t.prototype.getReflectionTextureMatrix=function(){return a.a.IdentityReadOnly},t.prototype.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()},t.prototype.scale=function(e){},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype._getFromCache=function(e,t,i,n){var r=this._getEngine();if(!r)return null;for(var o=r.getLoadedTexturesCache(),a=0;a<o.length;a++){var s=o[a];if(!(void 0!==n&&n!==s.invertY||s.url!==e||s.generateMipMaps!==!t||i&&i!==s.samplingMode))return s.incrementReferences(),s}return null},t.prototype._rebuild=function(){},t.prototype.clone=function(){return null},Object.defineProperty(t.prototype,"textureType",{get:function(){return this._texture&&void 0!==this._texture.type?this._texture.type:c.a.TEXTURETYPE_UNSIGNED_INT},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureFormat",{get:function(){return this._texture&&void 0!==this._texture.format?this._texture.format:c.a.TEXTUREFORMAT_RGBA},enumerable:!1,configurable:!0}),t.prototype._markAllSubMeshesAsTexturesDirty=function(){var e=this.getScene();e&&e.markAllMaterialsAsDirty(c.a.MATERIAL_TextureDirtyFlag)},t.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 n=this.getSize(),r=n.width,o=n.height,a=this._getEngine();if(!a)return null;0!=t&&(r/=Math.pow(2,t),o/=Math.pow(2,t),r=Math.round(r),o=Math.round(o));try{return this._texture.isCube?a._readTexturePixels(this._texture,r,o,e,t,i):a._readTexturePixels(this._texture,r,o,-1,t,i)}catch(e){return null}},Object.defineProperty(t.prototype,"_lodTextureHigh",{get:function(){return this._texture?this._texture._lodTextureHigh:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureMid",{get:function(){return this._texture?this._texture._lodTextureMid:null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureLow",{get:function(){return this._texture?this._texture._lodTextureLow:null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){if(this._scene){this._scene.stopAnimation&&this._scene.stopAnimation(this),this._scene._removePendingData(this);var t=this._scene.textures.indexOf(this);t>=0&&this._scene.textures.splice(t,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),e.prototype.dispose.call(this)},t.prototype.serialize=function(){if(!this.name)return null;var e=r.a.Serialize(this);return r.a.AppendSerializedAnimations(this,e),e},t.WhenAllReady=function(e,t){var i=e.length;if(0!==i)for(var n=0;n<e.length;n++){var r=e[n];if(r.isReady())0==--i&&t();else{var o=r.onLoadObservable;o&&o.addOnce((function(){0==--i&&t()}))}}else t()},t._isScene=function(e){return"Scene"===e.getClassName()},t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,Object(n.c)([Object(r.c)()],t.prototype,"uniqueId",void 0),Object(n.c)([Object(r.c)()],t.prototype,"name",void 0),Object(n.c)([Object(r.c)()],t.prototype,"metadata",void 0),Object(n.c)([Object(r.c)("hasAlpha")],t.prototype,"_hasAlpha",void 0),Object(n.c)([Object(r.c)()],t.prototype,"getAlphaFromRGB",void 0),Object(n.c)([Object(r.c)()],t.prototype,"level",void 0),Object(n.c)([Object(r.c)()],t.prototype,"coordinatesIndex",void 0),Object(n.c)([Object(r.c)("coordinatesMode")],t.prototype,"_coordinatesMode",void 0),Object(n.c)([Object(r.c)()],t.prototype,"wrapU",null),Object(n.c)([Object(r.c)()],t.prototype,"wrapV",null),Object(n.c)([Object(r.c)()],t.prototype,"wrapR",void 0),Object(n.c)([Object(r.c)()],t.prototype,"anisotropicFilteringLevel",void 0),Object(n.c)([Object(r.c)()],t.prototype,"isCube",null),Object(n.c)([Object(r.c)()],t.prototype,"is3D",null),Object(n.c)([Object(r.c)()],t.prototype,"is2DArray",null),Object(n.c)([Object(r.c)()],t.prototype,"gammaSpace",null),Object(n.c)([Object(r.c)()],t.prototype,"invertZ",void 0),Object(n.c)([Object(r.c)()],t.prototype,"lodLevelInAlpha",void 0),Object(n.c)([Object(r.c)()],t.prototype,"lodGenerationOffset",null),Object(n.c)([Object(r.c)()],t.prototype,"lodGenerationScale",null),Object(n.c)([Object(r.c)()],t.prototype,"linearSpecularLOD",null),Object(n.c)([Object(r.m)()],t.prototype,"irradianceTexture",null),Object(n.c)([Object(r.c)()],t.prototype,"isRenderTarget",void 0),t}(function(){function e(e){this._wrapU=c.a.TEXTURE_WRAP_ADDRESSMODE,this._wrapV=c.a.TEXTURE_WRAP_ADDRESSMODE,this.wrapR=c.a.TEXTURE_WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=4,this.delayLoadState=c.a.DELAYLOADSTATE_NONE,this._texture=null,this._engine=null,this._cachedSize=u.a.Zero(),this._cachedBaseSize=u.a.Zero(),this._texture=e,this._texture&&(this._engine=this._texture.getEngine())}return Object.defineProperty(e.prototype,"wrapU",{get:function(){return this._wrapU},set:function(e){this._wrapU=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wrapV",{get:function(){return this._wrapV},set:function(e){this._wrapV=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"coordinatesMode",{get:function(){return 0},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"is2DArray",{get:function(){return!!this._texture&&this._texture.is2DArray},set:function(e){this._texture&&(this._texture.is2DArray=e)},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"ThinTexture"},e.prototype.isReady=function(){return this.delayLoadState===c.a.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},e.prototype.delayLoad=function(){},e.prototype.getInternalTexture=function(){return this._texture},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?(this._cachedBaseSize.width=this._texture._size,this._cachedBaseSize.height=this._texture._size,this._cachedBaseSize):(this._cachedBaseSize.width=this._texture.baseWidth,this._cachedBaseSize.height=this._texture.baseHeight,this._cachedBaseSize):(this._cachedBaseSize.width=0,this._cachedBaseSize.height=0,this._cachedBaseSize)},e.prototype.updateSamplingMode=function(e){this._texture&&this._engine&&this._engine.updateTextureSamplingMode(e,this._texture)},e.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},e.prototype.dispose=function(){this._texture&&(this.releaseInternalTexture(),this._engine=null)},e}())},function(e,t,i){"use strict";i.d(t,"a",(function(){return l}));var n=i(0),r=i(9),o=i(7),a=i(16),s=i(20),c=i(23);a.a.CreateCylinder=function(e){var t=e.height||2,i=0===e.diameterTop?0:e.diameterTop||e.diameter||1,s=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1;i=i||1e-5,s=s||1e-5;var l,u=e.tessellation||24,h=e.subdivisions||1,d=!!e.hasRings,f=!!e.enclose,p=0===e.cap?0:e.cap||o.a.CAP_ALL,_=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,m=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,g=e.faceUV||new Array(3),v=e.faceColors,b=2+(1+(1!==_&&f?2:0))*(d?h:1);for(l=0;l<b;l++)v&&void 0===v[l]&&(v[l]=new r.b(1,1,1,1));for(l=0;l<b;l++)g&&void 0===g[l]&&(g[l]=new n.f(0,0,1,1));var y,T,E,S,A,P,C=new Array,R=new Array,x=new Array,O=new Array,M=new Array,I=2*Math.PI*_/u,D=(s-i)/2/t,N=n.e.Zero(),L=n.e.Zero(),w=n.e.Zero(),F=n.e.Zero(),B=n.e.Zero(),U=c.a.Y,V=1,k=1,z=0,G=0;for(S=0;S<=h;S++)for(E=((T=S/h)*(i-s)+s)/2,V=d&&0!==S&&S!==h?2:1,P=0;P<V;P++){for(d&&(k+=P),f&&(k+=2*P),A=0;A<=u;A++)y=A*I,N.x=Math.cos(-y)*E,N.y=-t/2+T*t,N.z=Math.sin(-y)*E,0===i&&S===h?(L.x=x[x.length-3*(u+1)],L.y=x[x.length-3*(u+1)+1],L.z=x[x.length-3*(u+1)+2]):(L.x=N.x,L.z=N.z,L.y=Math.sqrt(L.x*L.x+L.z*L.z)*D,L.normalize()),0===A&&(w.copyFrom(N),F.copyFrom(L)),R.push(N.x,N.y,N.z),x.push(L.x,L.y,L.z),G=d?z!==k?g[k].y:g[k].w:g[k].y+(g[k].w-g[k].y)*T,O.push(g[k].x+(g[k].z-g[k].x)*A/u,G),v&&M.push(v[k].r,v[k].g,v[k].b,v[k].a);1!==_&&f&&(R.push(N.x,N.y,N.z),R.push(0,N.y,0),R.push(0,N.y,0),R.push(w.x,w.y,w.z),n.e.CrossToRef(U,L,B),B.normalize(),x.push(B.x,B.y,B.z,B.x,B.y,B.z),n.e.CrossToRef(F,U,B),B.normalize(),x.push(B.x,B.y,B.z,B.x,B.y,B.z),G=d?z!==k?g[k+1].y:g[k+1].w:g[k+1].y+(g[k+1].w-g[k+1].y)*T,O.push(g[k+1].x,G),O.push(g[k+1].z,G),G=d?z!==k?g[k+2].y:g[k+2].w:g[k+2].y+(g[k+2].w-g[k+2].y)*T,O.push(g[k+2].x,G),O.push(g[k+2].z,G),v&&(M.push(v[k+1].r,v[k+1].g,v[k+1].b,v[k+1].a),M.push(v[k+1].r,v[k+1].g,v[k+1].b,v[k+1].a),M.push(v[k+2].r,v[k+2].g,v[k+2].b,v[k+2].a),M.push(v[k+2].r,v[k+2].g,v[k+2].b,v[k+2].a))),z!==k&&(z=k)}var j=1!==_&&f?u+4:u;for(S=0,k=0;k<h;k++){var W=0,H=0,X=0,Y=0;for(A=0;A<u;A++)W=S*(j+1)+A,H=(S+1)*(j+1)+A,X=S*(j+1)+(A+1),Y=(S+1)*(j+1)+(A+1),C.push(W,H,X),C.push(Y,X,H);1!==_&&f&&(C.push(W+2,H+2,X+2),C.push(Y+2,X+2,H+2),C.push(W+4,H+4,X+4),C.push(Y+4,X+4,H+4)),S=d?S+2:S+1}var K=function(e){var r=e?i/2:s/2;if(0!==r){var o,a,c,l=e?g[b-1]:g[0],h=null;v&&(h=e?v[b-1]:v[0]);var d=R.length/3,f=e?t/2:-t/2,p=new n.e(0,f,0);R.push(p.x,p.y,p.z),x.push(0,e?1:-1,0),O.push(l.x+.5*(l.z-l.x),l.y+.5*(l.w-l.y)),h&&M.push(h.r,h.g,h.b,h.a);var m=new n.d(.5,.5);for(c=0;c<=u;c++){o=2*Math.PI*c*_/u;var y=Math.cos(-o),T=Math.sin(-o);a=new n.e(y*r,f,T*r);var E=new n.d(y*m.x+.5,T*m.y+.5);R.push(a.x,a.y,a.z),x.push(0,e?1:-1,0),O.push(l.x+(l.z-l.x)*E.x,l.y+(l.w-l.y)*E.y),h&&M.push(h.r,h.g,h.b,h.a)}for(c=0;c<u;c++)e?(C.push(d),C.push(d+(c+2)),C.push(d+(c+1))):(C.push(d),C.push(d+(c+1)),C.push(d+(c+2)))}};p!==o.a.CAP_START&&p!==o.a.CAP_ALL||K(!1),p!==o.a.CAP_END&&p!==o.a.CAP_ALL||K(!0),a.a._ComputeSides(m,R,C,x,O,e.frontUVs,e.backUVs);var Q=new a.a;return Q.indices=C,Q.positions=R,Q.normals=x,Q.uvs=O,v&&(Q.colors=M),Q},o.a.CreateCylinder=function(e,t,i,n,r,a,c,u,h){void 0!==c&&c instanceof s.a||(void 0!==c&&(h=u||o.a.DEFAULTSIDE,u=c),c=a,a=1);var d={height:t,diameterTop:i,diameterBottom:n,tessellation:r,subdivisions:a,sideOrientation:h,updatable:u};return l.CreateCylinder(e,d,c)};var l=function(){function e(){}return e.CreateCylinder=function(e,t,i){var n=new o.a(e,i);return t.sideOrientation=o.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,a.a.CreateCylinder(t).applyToMesh(n,t.updatable),n},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(0),r=i(4),o=function(){function e(){this._pickingUnavailable=!1,this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshFaceId=-1,this.subMeshId=0,this.pickedSprite=null,this.thinInstanceIndex=-1,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(r.b.NormalKind))return null;var i,o=this.pickedMesh.getIndices();if(!o)return null;if(t){var a=this.pickedMesh.getVerticesData(r.b.NormalKind),s=n.e.FromArray(a,3*o[3*this.faceId]),c=n.e.FromArray(a,3*o[3*this.faceId+1]),l=n.e.FromArray(a,3*o[3*this.faceId+2]);s=s.scale(this.bu),c=c.scale(this.bv),l=l.scale(1-this.bu-this.bv),i=new n.e(s.x+c.x+l.x,s.y+c.y+l.y,s.z+c.z+l.z)}else{var u=this.pickedMesh.getVerticesData(r.b.PositionKind),h=n.e.FromArray(u,3*o[3*this.faceId]),d=n.e.FromArray(u,3*o[3*this.faceId+1]),f=n.e.FromArray(u,3*o[3*this.faceId+2]),p=h.subtract(d),_=f.subtract(d);i=n.e.Cross(p,_)}if(e){var m=this.pickedMesh.getWorldMatrix();this.pickedMesh.nonUniformScaling&&(n.c.Matrix[0].copyFrom(m),(m=n.c.Matrix[0]).setTranslationFromFloats(0,0,0),m.invert(),m.transposeToRef(n.c.Matrix[1]),m=n.c.Matrix[1]),i=n.e.TransformNormal(i,m)}return i.normalize(),i},e.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(r.b.UVKind))return null;var e=this.pickedMesh.getIndices();if(!e)return null;var t=this.pickedMesh.getVerticesData(r.b.UVKind);if(!t)return null;var i=n.d.FromArray(t,2*e[3*this.faceId]),o=n.d.FromArray(t,2*e[3*this.faceId+1]),a=n.d.FromArray(t,2*e[3*this.faceId+2]);return i=i.scale(this.bu),o=o.scale(this.bv),a=a.scale(1-this.bu-this.bv),new n.d(i.x+o.x+a.x,i.y+o.y+a.y)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(57),r=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!1,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(t,i){e.Enabled&&(this._current+=t,i&&this._fetchResult())},e.prototype.beginMonitoring=function(){e.Enabled&&(this._startMonitoringTime=n.a.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=n.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=n.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,t,i){"use strict";i.d(t,"b",(function(){return f})),i.d(t,"d",(function(){return p})),i.d(t,"c",(function(){return _})),i.d(t,"a",(function(){return m}));var n=i(1),r=i(49),o=i(38),a=i(6),s=i(83),c=i(140),l=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(n.d)(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),u=i(34),h=i(26),d=i(128),f=function(e){function t(i,n){var o=e.call(this,i)||this;return o.name="LoadFileError",l._setPrototypeOf(o,t.prototype),n instanceof r.a?o.request=n:o.file=n,o}return Object(n.d)(t,e),t}(l),p=function(e){function t(i,n){var r=e.call(this,i)||this;return r.request=n,r.name="RequestFileError",l._setPrototypeOf(r,t.prototype),r}return Object(n.d)(t,e),t}(l),_=function(e){function t(i,n){var r=e.call(this,i)||this;return r.file=n,r.name="ReadFileError",l._setPrototypeOf(r,t.prototype),r}return Object(n.d)(t,e),t}(l),m=function(){function e(){}return e._CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},e.SetCorsBehavior=function(t,i){if((!t||0!==t.indexOf("data:"))&&e.CorsBehavior)if("string"==typeof e.CorsBehavior||this.CorsBehavior instanceof String)i.crossOrigin=e.CorsBehavior;else{var n=e.CorsBehavior(t);n&&(i.crossOrigin=n)}},e.LoadImage=function(t,i,n,r,o){var a;void 0===o&&(o="");var c=!1;if(t instanceof ArrayBuffer||ArrayBuffer.isView(t)?"undefined"!=typeof Blob?(a=URL.createObjectURL(new Blob([t],{type:o})),c=!0):a="data:"+o+";base64,"+u.a.EncodeArrayBufferToBase64(t):t instanceof Blob?(a=URL.createObjectURL(t),c=!0):(a=e._CleanUrl(t),a=e.PreprocessUrl(t)),"undefined"==typeof Image)return e.LoadFile(a,(function(e){createImageBitmap(new Blob([e],{type:o})).then((function(e){i(e),c&&URL.revokeObjectURL(a)})).catch((function(e){n&&n("Error while trying to load image: "+t,e)}))}),void 0,r||void 0,!0,(function(e,i){n&&n("Error while trying to load image: "+t,i)})),null;var l=new Image;e.SetCorsBehavior(a,l);var h=function(){l.removeEventListener("load",h),l.removeEventListener("error",d),i(l),c&&l.src&&URL.revokeObjectURL(l.src)},d=function(e){if(l.removeEventListener("load",h),l.removeEventListener("error",d),n){var i=t.toString();n("Error while trying to load image: "+(i.length<32?i:i.slice(0,32)+"..."),e)}c&&l.src&&URL.revokeObjectURL(l.src)};l.addEventListener("load",h),l.addEventListener("error",d);var f=function(){l.src=a};if("data:"!==a.substr(0,5)&&r&&r.enableTexturesOffline)r.open((function(){r&&r.loadImage(a,l)}),f);else{if(-1!==a.indexOf("file:")){var p=decodeURIComponent(a.substring(5).toLowerCase());if(s.a.FilesToLoad[p]){try{var _;try{_=URL.createObjectURL(s.a.FilesToLoad[p])}catch(e){_=URL.createObjectURL(s.a.FilesToLoad[p])}l.src=_,c=!0}catch(e){l.src=""}return l}}f()}return l},e.ReadFile=function(e,t,i,n,r){var o=new FileReader,s={onCompleteObservable:new a.c,abort:function(){return o.abort()}};return o.onloadend=function(e){return s.onCompleteObservable.notifyObservers(s)},r&&(o.onerror=function(t){r(new _("Unable to read "+e.name,e))}),o.onload=function(e){t(e.target.result)},i&&(o.onprogress=i),n?o.readAsArrayBuffer(e):o.readAsText(e),s},e.LoadFile=function(t,i,n,r,o,a){if(-1!==t.indexOf("file:")){var c=decodeURIComponent(t.substring(5).toLowerCase());0===c.indexOf("./")&&(c=c.substring(2));var l=s.a.FilesToLoad[c];if(l)return e.ReadFile(l,i,n,o,a?function(e){return a(void 0,new f(e.message,e.file))}:void 0)}return e.RequestFile(t,(function(e,t){i(e,t?t.responseURL:void 0)}),n,r,o,a?function(e){a(e.request,new f(e.message,e.request))}:void 0)},e.RequestFile=function(t,i,n,s,c,l,u){t=e._CleanUrl(t),t=e.PreprocessUrl(t);var h=e.BaseUrl+t,d=!1,f={onCompleteObservable:new a.c,abort:function(){return d=!0}},_=function(){var t=new r.a,a=null;f.abort=function(){d=!0,t.readyState!==(XMLHttpRequest.DONE||4)&&t.abort(),null!==a&&(clearTimeout(a),a=null)};var s=function(_){t.open("GET",h),u&&u(t),c&&(t.responseType="arraybuffer"),n&&t.addEventListener("progress",n);var m=function(){t.removeEventListener("loadend",m),f.onCompleteObservable.notifyObservers(f),f.onCompleteObservable.clear()};t.addEventListener("loadend",m);var g=function(){if(!d&&t.readyState===(XMLHttpRequest.DONE||4)){if(t.removeEventListener("readystatechange",g),t.status>=200&&t.status<300||0===t.status&&(!o.a.IsWindowObjectExist()||e.IsFileURL()))return void i(c?t.response:t.responseText,t);var n=e.DefaultRetryStrategy;if(n){var u=n(h,t,_);if(-1!==u)return t.removeEventListener("loadend",m),t=new r.a,void(a=setTimeout((function(){return s(_+1)}),u))}var f=new p("Error status: "+t.status+" "+t.statusText+" - Unable to load "+h,t);l&&l(f)}};t.addEventListener("readystatechange",g),t.send()};s(0)};if(s&&s.enableSceneOffline){var m=function(e){e&&e.status>400?l&&l(e):_()};s.open((function(){s&&s.loadFile(e.BaseUrl+t,(function(e){d||i(e),f.onCompleteObservable.notifyObservers(f)}),n?function(e){d||n(e)}:void 0,m,c)}),m)}else _();return f},e.IsFileURL=function(){return"undefined"!=typeof location&&"file:"===location.protocol},e.DefaultRetryStrategy=c.a.ExponentialBackoff(),e.BaseUrl="",e.CorsBehavior="anonymous",e.PreprocessUrl=function(e){return e},e}();h.a._FileToolsLoadImage=m.LoadImage.bind(m),h.a._FileToolsLoadFile=m.LoadFile.bind(m),d.a._FileToolsLoadFile=m.LoadFile.bind(m)},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(38),r=function(){function e(){}return Object.defineProperty(e,"Now",{get:function(){return n.a.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!1,configurable:!0}),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(e,t,i,n){this.x=e,this.y=t,this.width=i,this.height=n}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}()},function(e,t,i){"use strict";var n="helperFunctions",r="const float PI=3.1415926535897932384626433832795;\nconst float HALF_MIN=5.96046448e-08;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\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 toLinearSpace(float color)\n{\nreturn pow(color,LinearEncodePowerApprox);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec4 toLinearSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(LinearEncodePowerApprox)),color.a);\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nvec4 toGammaSpace(vec4 color)\n{\nreturn vec4(pow(color.rgb,vec3(GammaEncodePowerApprox)),color.a);\n}\nfloat toGammaSpace(float color)\n{\nreturn pow(color,GammaEncodePowerApprox);\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*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=maxEps(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}\n";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(0),r=function(){function e(){}return e._RemoveAndStorePivotPoint=function(t){t&&0===e._PivotCached&&(t.getPivotPointToRef(e._OldPivotPoint),e._PivotPostMultiplyPivotMatrix=t._postMultiplyPivotMatrix,e._OldPivotPoint.equalsToFloats(0,0,0)||(t.setPivotMatrix(n.a.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),t._postMultiplyPivotMatrix=e._PivotPostMultiplyPivotMatrix,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 n.e,e._PivotTranslation=new n.e,e._PivotTmpVector=new n.e,e._PivotPostMultiplyPivotMatrix=!1,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(4),r=i(114),o=i(43),a=i(2),s=i(101),c=function(){function e(e,t,i,n,r,o,a,s,c){void 0===s&&(s=!0),void 0===c&&(c=!0),this.materialIndex=e,this.verticesStart=t,this.verticesCount=i,this.indexStart=n,this.indexCount=r,this._materialDefines=null,this._materialEffect=null,this._effectOverride=null,this._linesIndexCount=0,this._linesIndexBuffer=null,this._lastColliderWorldVertices=null,this._lastColliderTransformMatrix=null,this._renderId=0,this._alphaIndex=0,this._distanceToCamera=0,this._currentMaterial=null,this._mesh=o,this._renderingMesh=a||o,c&&o.subMeshes.push(this),this._trianglePlanes=[],this._id=o.subMeshes.length-1,s&&(this.refreshBoundingInfo(),o.computeWorldMatrix(!0))}return Object.defineProperty(e.prototype,"materialDefines",{get:function(){return this._materialDefines},set:function(e){this._materialDefines=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"effect",{get:function(){var e;return null!==(e=this._effectOverride)&&void 0!==e?e:this._materialEffect},enumerable:!1,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.AddToMesh=function(t,i,n,r,o,a,s,c){return void 0===c&&(c=!0),new e(t,i,n,r,o,a,s,c)},Object.defineProperty(e.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!1,configurable:!0}),e.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},e.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},e.prototype.getMesh=function(){return this._mesh},e.prototype.getRenderingMesh=function(){return this._renderingMesh},e.prototype.getReplacementMesh=function(){return this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null},e.prototype.getEffectiveMesh=function(){var e=this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:null;return e||this._renderingMesh},e.prototype.getMaterial=function(){var e=this._renderingMesh.material;if(null==e)return this._mesh.getScene().defaultMaterial;if(this._IsMultiMaterial(e)){var t=e.getSubMaterial(this.materialIndex);return this._currentMaterial!==t&&(this._currentMaterial=t,this._materialDefines=null),t}return e},e.prototype._IsMultiMaterial=function(e){return void 0!==e.getSubMaterial},e.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=null),this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(n.b.PositionKind)),!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=Object(s.b)(e,i,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(t.minimum,t.maximum):this._boundingInfo=new o.a(t.minimum,t.maximum),this},e.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},e.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t&&t.update(e),this},e.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)},e.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)},e.prototype.render=function(e){return this._renderingMesh.render(this,e,this._mesh._internalAbstractMeshDataInfo._actAsRegularMesh?this._mesh:void 0),this},e.prototype._getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],n=this.indexStart;n<this.indexStart+this.indexCount;n+=3)i.push(e[n],e[n+1],e[n+1],e[n+2],e[n+2],e[n]);this._linesIndexBuffer=t.createIndexBuffer(i),this._linesIndexCount=i.length}return this._linesIndexBuffer},e.prototype.canIntersects=function(e){var t=this.getBoundingInfo();return!!t&&e.intersectsBox(t.boundingBox)},e.prototype.intersects=function(e,t,i,n,r){var o=this.getMaterial();if(!o)return null;var s=3,c=!1;switch(o.fillMode){case a.a.MATERIAL_PointListDrawMode:case a.a.MATERIAL_LineListDrawMode:case a.a.MATERIAL_LineLoopDrawMode:case a.a.MATERIAL_LineStripDrawMode:case a.a.MATERIAL_TriangleFanDrawMode:return null;case a.a.MATERIAL_TriangleStripDrawMode:s=1,c=!0}return"InstancedLinesMesh"===this._mesh.getClassName()||"LinesMesh"===this._mesh.getClassName()?i.length?this._intersectLines(e,t,i,this._mesh.intersectionThreshold,n):this._intersectUnIndexedLines(e,t,i,this._mesh.intersectionThreshold,n):!i.length&&this._mesh._unIndexed?this._intersectUnIndexedTriangles(e,t,i,n,r):this._intersectTriangles(e,t,i,s,c,n,r)},e.prototype._intersectLines=function(e,t,i,n,o){for(var a=null,s=this.indexStart;s<this.indexStart+this.indexCount;s+=2){var c=t[i[s]],l=t[i[s+1]],u=e.intersectionSegment(c,l,n);if(!(u<0)&&((o||!a||u<a.distance)&&((a=new r.a(null,null,u)).faceId=s/2,o)))break}return a},e.prototype._intersectUnIndexedLines=function(e,t,i,n,o){for(var a=null,s=this.verticesStart;s<this.verticesStart+this.verticesCount;s+=2){var c=t[s],l=t[s+1],u=e.intersectionSegment(c,l,n);if(!(u<0)&&((o||!a||u<a.distance)&&((a=new r.a(null,null,u)).faceId=s/2,o)))break}return a},e.prototype._intersectTriangles=function(e,t,i,n,r,o,a){for(var s=null,c=-1,l=this.indexStart;l<this.indexStart+this.indexCount;l+=n){c++;var u=i[l],h=i[l+1],d=i[l+2];if(r&&4294967295===d)l+=2;else{var f=t[u],p=t[h],_=t[d];if(!a||a(f,p,_,e)){var m=e.intersectsTriangle(f,p,_);if(m){if(m.distance<0)continue;if((o||!s||m.distance<s.distance)&&((s=m).faceId=c,o))break}}}}return s},e.prototype._intersectUnIndexedTriangles=function(e,t,i,n,r){for(var o=null,a=this.verticesStart;a<this.verticesStart+this.verticesCount;a+=3){var s=t[a],c=t[a+1],l=t[a+2];if(!r||r(s,c,l,e)){var u=e.intersectsTriangle(s,c,l);if(u){if(u.distance<0)continue;if((n||!o||u.distance<o.distance)&&((o=u).faceId=a/3,n))break}}}return o},e.prototype._rebuild=function(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)},e.prototype.clone=function(t,i){var n=new e(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,i,!1);if(!this.IsGlobal){var r=this.getBoundingInfo();if(!r)return n;n._boundingInfo=new o.a(r.minimum,r.maximum)}return n},e.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)},e.prototype.getClassName=function(){return"SubMesh"},e.CreateFromIndices=function(t,i,n,r,o){for(var a=Number.MAX_VALUE,s=-Number.MAX_VALUE,c=(o||r).getIndices(),l=i;l<i+n;l++){var u=c[l];u<a&&(a=u),u>s&&(s=u)}return new e(t,a,s-a+1,i,n,r,o)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(1),r=i(8),o=i(10),a=i(2),s=(i(126),i(70)),c=function(e){function t(t,i,n,r,c,l,u){void 0===n&&(n=null),void 0===c&&(c=a.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=a.a.TEXTUREFORMAT_RGBA);var h=e.call(this,null,n,!r,u,c,void 0,void 0,void 0,void 0,l)||this;h.name=t,h.wrapU=o.a.CLAMP_ADDRESSMODE,h.wrapV=o.a.CLAMP_ADDRESSMODE,h._generateMipMaps=r;var d=h._getEngine();if(!d)return h;i.getContext?(h._canvas=i,h._texture=d.createDynamicTexture(i.width,i.height,r,c)):(h._canvas=s.a.CreateCanvas(1,1),i.width||0===i.width?h._texture=d.createDynamicTexture(i.width,i.height,r,c):h._texture=d.createDynamicTexture(i,i,r,c));var f=h.getSize();return h._canvas.width=f.width,h._canvas.height=f.height,h._context=h._canvas.getContext("2d"),h}return Object(n.d)(t,e),t.prototype.getClassName=function(){return"DynamicTexture"},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._getEngine().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._getEngine().updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},t.prototype.drawText=function(e,t,i,n,r,o,a,s){void 0===s&&(s=!0);var c=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,c.width,c.height)),this._context.font=n,null==t){var l=this._context.measureText(e);t=(c.width-l.width)/2}if(null==i){var u=parseInt(n.replace(/\D/g,""));i=c.height/2+u/3.65}this._context.fillStyle=r||"",this._context.fillText(e,t,i),s&&this.update(a)},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),n=new t(this.name,i,e,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.wrapU=this.wrapU,n.wrapV=this.wrapV,n},t.prototype.serialize=function(){var t=this.getScene();t&&!t.isReady()&&r.a.Warn("The scene must be ready before serializing the dynamic texture");var i=e.prototype.serialize.call(this);return this._IsCanvasElement(this._canvas)&&(i.base64String=this._canvas.toDataURL()),i.invertY=this._invertY,i.samplingMode=this.samplingMode,i},t.prototype._IsCanvasElement=function(e){return void 0!==e.toDataURL},t.prototype._rebuild=function(){this.update()},t}(o.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return s}));var n=i(0),r=i(9),o=i(7),a=i(16);a.a.CreateBox=function(e){var t,i=[0,1,2,0,2,3,4,5,6,4,6,7,8,9,10,8,10,11,12,13,14,12,14,15,16,17,18,16,18,19,20,21,22,20,22,23],o=[0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0,0,0,1,0,0,1,0,0,1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,-1,0],s=[],c=e.width||e.size||1,l=e.height||e.size||1,u=e.depth||e.size||1,h=e.wrap||!1,d=void 0===e.topBaseAt?1:e.topBaseAt,f=void 0===e.bottomBaseAt?0:e.bottomBaseAt,p=[2,0,3,1][d=(d+4)%4],_=[2,0,1,3][f=(f+4)%4],m=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(h){i=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],m=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];for(var g=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],v=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],b=[17,18,19,16],y=[22,23,20,21];p>0;)g.unshift(g.pop()),b.unshift(b.pop()),p--;for(;_>0;)v.unshift(v.pop()),y.unshift(y.pop()),_--;g=g.flat(),v=v.flat(),m=m.concat(g).concat(v),i.push(b[0],b[2],b[3],b[0],b[1],b[2]),i.push(y[0],y[2],y[3],y[0],y[1],y[2])}var T=[c/2,l/2,u/2];t=m.reduce((function(e,t,i){return e.concat(t*T[i%3])}),[]);for(var E=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,S=e.faceUV||new Array(6),A=e.faceColors,P=[],C=0;C<6;C++)void 0===S[C]&&(S[C]=new n.f(0,0,1,1)),A&&void 0===A[C]&&(A[C]=new r.b(1,1,1,1));for(var R=0;R<6;R++)if(s.push(S[R].z,S[R].w),s.push(S[R].x,S[R].w),s.push(S[R].x,S[R].y),s.push(S[R].z,S[R].y),A)for(var x=0;x<4;x++)P.push(A[R].r,A[R].g,A[R].b,A[R].a);a.a._ComputeSides(E,t,i,o,s,e.frontUVs,e.backUVs);var O=new a.a;if(O.indices=i,O.positions=t,O.normals=o,O.uvs=s,A){var M=E===a.a.DOUBLESIDE?P.concat(P):P;O.colors=M}return O},o.a.CreateBox=function(e,t,i,n,r){void 0===i&&(i=null);var o={size:t,sideOrientation:r,updatable:n};return s.CreateBox(e,o,i)};var s=function(){function e(){}return e.CreateBox=function(e,t,i){void 0===i&&(i=null);var n=new o.a(e,i);return t.sideOrientation=o.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,a.a.CreateBox(t).applyToMesh(n,t.updatable),n},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(0),r=function(){function e(e,t,i,r){this.normal=new n.e(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^(0|this.d)},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=e._TmpMatrix;t.invertToRef(i);var n=i.m,r=this.normal.x,o=this.normal.y,a=this.normal.z,s=this.d;return new e(r*n[0]+o*n[1]+a*n[2]+s*n[3],r*n[4]+o*n[5]+a*n[6]+s*n[7],r*n[8]+o*n[9]+a*n[10]+s*n[11],r*n[12]+o*n[13]+a*n[14]+s*n[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 n,r=t.x-e.x,o=t.y-e.y,a=t.z-e.z,s=i.x-e.x,c=i.y-e.y,l=i.z-e.z,u=o*l-a*c,h=a*s-r*l,d=r*c-o*s,f=Math.sqrt(u*u+h*h+d*d);return n=0!==f?1/f:0,this.normal.x=u*n,this.normal.y=h*n,this.normal.z=d*n,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return n.e.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return n.e.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,n){var r=new e(0,0,0,0);return r.copyFromPoints(t,i,n),r},e.FromPositionAndNormal=function(t,i){var n=new e(0,0,0,0);return i.normalize(),n.normal=i,n.d=-(i.x*t.x+i.y*t.y+i.z*t.z),n},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return n.e.Dot(i,t)+r},e._TmpMatrix=n.a.Identity(),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return u}));var n=i(7),r=i(20),o=i(6),a=i(0),s=i(18),c=i(39),l=i(60),u=(i(84),function(){function e(e){this._useAlternatePickedPointAboveMaxDragAngleDragSpeed=-1.1,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.startAndReleaseDragOnPointerEvents=!0,this.detachCameraControls=!0,this.useObjectOrientationForDragging=!0,this.validateDrag=function(e){return!0},this._tmpVector=new a.e(0,0,0),this._alternatePickedPoint=new a.e(0,0,0),this._worldDragAxis=new a.e(0,0,0),this._targetPosition=new a.e(0,0,0),this._attachedToElement=!1,this._startDragRay=new c.a(new a.e,new a.e),this._lastPointerRay={},this._dragDelta=new a.e,this._pointA=new a.e(0,0,0),this._pointC=new a.e(0,0,0),this._localAxis=new a.e(0,0,0),this._lookAt=new a.e(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,"options",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t,i){var o=this;this._scene=t.getScene(),this.attachedNode=t,e._planeScene||(this._debugMode?e._planeScene=this._scene:(e._planeScene=new r.a(this._scene.getEngine(),{virtual:!0}),e._planeScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._planeScene.dispose(),e._planeScene=null})))),this._dragPlane=n.a.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,e._planeScene,!1,n.a.DOUBLESIDE),this.lastDragPosition=new a.e(0,0,0);var u=i||function(e){return o.attachedNode==e||e.isDescendantOf(o.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t,i){if(o.enabled)if(t.type==s.a.POINTERDOWN)o.startAndReleaseDragOnPointerEvents&&!o.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&u(t.pickInfo.pickedMesh)&&o._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint);else if(t.type==s.a.POINTERUP)o.startAndReleaseDragOnPointerEvents&&o.currentDraggingPointerID==t.event.pointerId&&o.releaseDrag();else if(t.type==s.a.POINTERMOVE){var n=t.event.pointerId;if(o.currentDraggingPointerID===e._AnyMouseID&&n!==e._AnyMouseID){var r=t.event;("mouse"===r.pointerType||!o._scene.getEngine().hostInformation.isMobile&&r instanceof MouseEvent)&&(o._lastPointerRay[o.currentDraggingPointerID]&&(o._lastPointerRay[n]=o._lastPointerRay[o.currentDraggingPointerID],delete o._lastPointerRay[o.currentDraggingPointerID]),o.currentDraggingPointerID=n)}o._lastPointerRay[n]||(o._lastPointerRay[n]=new c.a(new a.e,new a.e)),t.pickInfo&&t.pickInfo.ray&&(o._lastPointerRay[n].origin.copyFrom(t.pickInfo.ray.origin),o._lastPointerRay[n].direction.copyFrom(t.pickInfo.ray.direction),o.currentDraggingPointerID==n&&o.dragging&&o._moveDrag(t.pickInfo.ray))}})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){o._moving&&o.moveAttached&&(l.a._RemoveAndStorePivotPoint(o.attachedNode),o._targetPosition.subtractToRef(o.attachedNode.absolutePosition,o._tmpVector),o._tmpVector.scaleInPlace(o.dragDeltaRatio),o.attachedNode.getAbsolutePosition().addToRef(o._tmpVector,o._tmpVector),o.validateDrag(o._tmpVector)&&o.attachedNode.setAbsolutePosition(o._tmpVector),l.a._RestorePivotPoint(o.attachedNode))}))},e.prototype.releaseDrag=function(){if(this.dragging&&(this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID})),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedToElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera){if("ArcRotateCamera"===this._scene.activeCamera.getClassName()){var e=this._scene.activeCamera;e.attachControl(!e.inputs||e.inputs.noPreventDefault,e._useCtrlForPanning,e._panningMouseButton)}else this._scene.activeCamera.attachControl(!this._scene.activeCamera.inputs||this._scene.activeCamera.inputs.noPreventDefault);this._attachedToElement=!1}},e.prototype.startDrag=function(t,i,n){void 0===t&&(t=e._AnyMouseID),this._startDrag(t,i,n);var r=this._lastPointerRay[t];t===e._AnyMouseID&&(r=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),r&&this._moveDrag(r)},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 n=this._pickWithRayOnDragPlane(this._startDragRay);n&&(this.dragging=!0,this.currentDraggingPointerID=e,this.lastDragPosition.copyFrom(n),this.onDragStartObservable.notifyObservers({dragPlanePoint:n,pointerId:this.currentDraggingPointerID}),this._targetPosition.copyFrom(this.attachedNode.absolutePosition),this.detachCameraControls&&this._scene.activeCamera&&this._scene.activeCamera.inputs&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedToElement?(this._scene.activeCamera.detachControl(),this._attachedToElement=!0):this._attachedToElement=!1)),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?(this.useObjectOrientationForDragging?a.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis):this._worldDragAxis.copyFrom(this._options.dragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=a.e.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 n=Math.acos(a.e.Dot(this._dragPlane.forward,t.direction));if(n>Math.PI/2&&(n=Math.PI-n),this.maxDragAngle>0&&n>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(t.direction),this.attachedNode.absolutePosition.subtractToRef(t.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed*a.e.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var r=a.e.Dot(this._dragPlane.forward,this._tmpVector);return this._dragPlane.forward.scaleToRef(-r,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.useObjectOrientationForDragging?a.e.TransformCoordinatesToRef(this._options.dragAxis,this.attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),e.origin.subtractToRef(this._pointA,this._pointC),this._pointC.normalize(),Math.abs(a.e.Dot(this._localAxis,this._pointC))>.999?Math.abs(a.e.Dot(a.e.UpReadOnly,this._pointC))>.999?this._lookAt.copyFrom(a.e.Right()):this._lookAt.copyFrom(a.e.UpReadOnly):(a.e.CrossToRef(this._localAxis,this._pointC,this._lookAt),a.e.CrossToRef(this._localAxis,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.useObjectOrientationForDragging?a.e.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.position.copyFrom(this.attachedNode.absolutePosition),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this.releaseDrag()},e._AnyMouseID=-2,e}())},function(e,t,i){"use strict";i.d(t,"a",(function(){return r})),i.d(t,"b",(function(){return o})),i.d(t,"c",(function(){return a}));var n=i(1),r=function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e}(),o=function(e,t){this.type=e,this.event=t},a=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.type=t,n.event=i,n.skipOnPointerObservable=!1,n}return Object(n.d)(t,e),t}(o)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1,this._mesh=null}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,"hasMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!1,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),n=0;n<i.meshes.length;n++){var r=i.meshes[n];if(r.material){if(r.computeBonesUsingShaders&&0!==r.numBoneInfluencers)if(r.material.getEffect()===t)r.computeBonesUsingShaders=!1;else if(r.subMeshes)for(var o=0,a=r.subMeshes;o<a.length;o++){if(a[o].effect===t){r.computeBonesUsingShaders=!1;break}}}else!this._mesh.material&&r.computeBonesUsingShaders&&r.numBoneInfluencers>0&&(r.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(n=0;n<s.length;n++)e=e.replace("#define "+s[n],"");this._currentRank++}return e},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return s}));var n=i(1),r=i(25),o=i(37),a=i(11),s=function(e){function t(t,i){var n=e.call(this,t,i,!0)||this;return i.multiMaterials.push(n),n.subMaterials=new Array,n._storeEffectOnSubMeshes=!0,n}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!1,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 n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=i.apply(e,n);return t._markAllSubMeshesAsTexturesDirty(),o};var n=e.splice;e.splice=function(i,r){var o=n.apply(e,[i,r]);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.hasTexture=function(t){var i;if(e.prototype.hasTexture.call(this,t))return!0;for(var n=0;n<this.subMaterials.length;n++)if(null===(i=this.subMaterials[n])||void 0===i?void 0:i.hasTexture(t))return!0;return!1},t.prototype.getClassName=function(){return"MultiMaterial"},t.prototype.isReadyForSubMesh=function(e,t,i){for(var n=0;n<this.subMaterials.length;n++){var r=this.subMaterials[n];if(r){if(r._storeEffectOnSubMeshes){if(!r.isReadyForSubMesh(e,t,i))return!1;continue}if(!r.isReady(e))return!1}}return!0},t.prototype.clone=function(e,i){for(var n=new t(e,this.getScene()),r=0;r<this.subMaterials.length;r++){var o=null,a=this.subMaterials[r];o=i&&a?a.clone(e+"-"+a.name):this.subMaterials[r],n.subMaterials.push(o)}return n},t.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,o.a&&(e.tags=o.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,n){var r=this.getScene();if(r){if(n)for(var o=0;o<this.subMaterials.length;o++){var a=this.subMaterials[o];a&&a.dispose(t,i)}(o=r.multiMaterials.indexOf(this))>=0&&r.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,i)}},t.ParseMultiMaterial=function(e,i){var n=new t(e.name,i);n.id=e.id,o.a&&o.a.AddTagsTo(n,e.tags);for(var r=0;r<e.materials.length;r++){var a=e.materials[r];a?n.subMaterials.push(i.getLastMaterialByID(a)):n.subMaterials.push(null)}return n},t}(r.a);a.a.RegisteredTypes["BABYLON.MultiMaterial"]=s},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(2),r=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return e._ForceFullSceneLoadingForIncremental},set:function(t){e._ForceFullSceneLoadingForIncremental=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return e._ShowLoadingScreen},set:function(t){e._ShowLoadingScreen=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return e._loggingLevel},set:function(t){e._loggingLevel=t},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return e._CleanBoneMatrixWeights},set:function(t){e._CleanBoneMatrixWeights=t},enumerable:!1,configurable:!0}),e._ForceFullSceneLoadingForIncremental=!1,e._ShowLoadingScreen=!0,e._CleanBoneMatrixWeights=!1,e._loggingLevel=n.a.SCENELOADER_NO_LOGGING,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.CreateCanvas=function(e,t){if("undefined"==typeof document)return new OffscreenCanvas(e,t);var i=document.createElement("canvas");return i.width=e,i.height=t,i},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return p}));var n=i(0),r=i(9),o=i(16),a=i(4),s=i(61),c=i(69),l=i(43),u=i(2),h=i(12),d=i(37),f=i(101),p=function(){function e(e,t,i,n,r){void 0===n&&(n=!1),void 0===r&&(r=null),this.delayLoadState=u.a.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this._positionsCache=[],this.useBoundingInfoFromGeometry=!1,this.id=e,this.uniqueId=t.getUniqueId(),this._engine=t.getEngine(),this._meshes=[],this._scene=t,this._vertexBuffers={},this._indices=[],this._updatable=n,i?this.setAllVerticesData(i,n):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),r&&(this.applyToMesh(r),r.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:!1,configurable:!0}),e.CreateGeometryForMesh=function(t){var i=new e(e.RandomId(),t.getScene());return i.applyToMesh(t),i},Object.defineProperty(e.prototype,"meshes",{get:function(){return this._meshes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"extend",{get:function(){return this._extend},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._engine},e.prototype.isReady=function(){return this.delayLoadState===u.a.DELAYLOADSTATE_LOADED||this.delayLoadState===u.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:!1,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,n){void 0===i&&(i=!1),i&&Array.isArray(t)&&(t=new Float32Array(t));var r=new a.b(this._engine,t,e,i,0===this._meshes.length,n);this.setVerticesBuffer(r)},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===a.b.PositionKind){var n=e.getData();null!=t?this._totalVertices=t:null!=n&&(this._totalVertices=n.length/(e.byteStride/4)),this._updateExtend(n),this._resetPointsArrayCache();for(var r=this._meshes,o=r.length,s=0;s<o;s++){var c=r[s];c._boundingInfo=new l.a(this._extend.minimum,this._extend.maximum),c._createGlobalSubMesh(!1),c.computeWorldMatrix(!0)}}this.notifyUpdate(i),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},e.prototype.updateVerticesDataDirectly=function(e,t,i,n){void 0===n&&(n=!1);var r=this.getVertexBuffer(e);r&&(r.updateDirectly(t,i,n),this.notifyUpdate(e))},e.prototype.updateVerticesData=function(e,t,i){void 0===i&&(i=!1);var n=this.getVertexBuffer(e);n&&(n.update(t),e===a.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,n=this._meshes;i<n.length;i++){var r=n[i];r._boundingInfo?r._boundingInfo.reConstruct(this._extend.minimum,this._extend.maximum):r._boundingInfo=new l.a(this._extend.minimum,this._extend.maximum);for(var o=0,a=r.subMeshes;o<a.length;o++){a[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 n=this.getVertexBuffer(e);if(!n)return null;var r=n.getData();if(!r)return null;var o=n.getSize()*a.b.GetTypeByteLength(n.type),s=this._totalVertices*n.getSize();if(n.type!==a.b.FLOAT||n.byteStride!==o){var c=[];return n.forEach(s,(function(e){return c.push(e)})),c}if(!(r instanceof Array||r instanceof Float32Array)||0!==n.byteOffset||r.length!==s){if(r instanceof Array){var l=n.byteOffset/4;return h.b.Slice(r,l,l+s)}if(r instanceof ArrayBuffer)return new Float32Array(r,n.byteOffset,s);l=r.byteOffset+n.byteOffset;if(i||t&&1!==this._meshes.length){var u=new Float32Array(s),d=new Float32Array(r.buffer,l,s);return u.set(d),u}var f=l%4;return f&&(l=Math.max(0,l-f)),new Float32Array(r.buffer,l,s)}return i||t&&1!==this._meshes.length?h.b.Slice(r):r},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,i){if(void 0===i&&(i=!1),this._indexBuffer)if(this._indexBufferIsUpdatable){var n=e.length!==this._indices.length;if(i||(this._indices=e.slice()),this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t),n)for(var r=0,o=this._meshes;r<o.length;r++){o[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 n=0,r=this._meshes;n<r.length;n++){r[n]._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 n=i.length,r=[],o=0;o<n;o++)r.push(i[o]);return r}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,n=i.indexOf(e);-1!==n&&(i.splice(n,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),this.useBoundingInfoFromGeometry&&this._boundingInfo?this._extend={minimum:this._boundingInfo.minimum.clone(),maximum:this._boundingInfo.maximum.clone()}:(e||(e=this.getVerticesData(a.b.PositionKind)),this._extend=Object(f.a)(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 n=this._vertexBuffers[i].getBuffer();n&&(n.references=t),i===a.b.PositionKind&&(this._extend||this._updateExtend(),e._boundingInfo=new l.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!==u.a.DELAYLOADSTATE_LOADING&&(this.isReady()?t&&t():(this.delayLoadState=u.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(n){if(i._delayLoadingFunction){i._delayLoadingFunction(JSON.parse(n),i),i.delayLoadState=u.a.DELAYLOADSTATE_LOADED,i._delayInfo=[],e._removePendingData(i);for(var r=i._meshes,o=r.length,a=0;a<o;a++)i._applyToMesh(r[a]);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 n=this.getVerticesData(a.b.PositionKind,!1);if(null!=n&&n.length>0){for(t=0;t<n.length;t+=3)n[t+2]=-n[t+2];this.setVerticesData(a.b.PositionKind,n,!1)}var r=this.getVerticesData(a.b.NormalKind,!1);if(null!=r&&r.length>0){for(t=0;t<r.length;t+=3)r[t+2]=-r[t+2];this.setVerticesData(a.b.NormalKind,r,!1)}},e.prototype._resetPointsArrayCache=function(){this._positions=null},e.prototype._generatePointsArray=function(){if(this._positions)return!0;var e=this.getVerticesData(a.b.PositionKind);if(!e||0===e.length)return!1;for(var t=3*this._positionsCache.length,i=this._positionsCache.length;t<e.length;t+=3,++i)this._positionsCache[i]=n.e.FromArray(e,t);for(t=0,i=0;t<e.length;t+=3,++i)this._positionsCache[i].set(e[0+t],e[1+t],e[2+t]);return this._positionsCache.length=e.length/3,this._positions=this._positionsCache,!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 n in this._meshes=[],this._disposeVertexArrayObjects(),this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=u.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 o.a;i.indices=[];var n=this.getIndices();if(n)for(var r=0;r<n.length;r++)i.indices.push(n[r]);var a,s=!1,c=!1;for(a in this._vertexBuffers){var u=this.getVerticesData(a);if(u&&(u instanceof Float32Array?i.set(new Float32Array(u),a):i.set(u.slice(0),a),!c)){var h=this.getVertexBuffer(a);h&&(c=!(s=h.isUpdatable()))}}var d=new e(t,this._scene,i,s);for(a in d.delayLoadState=this.delayLoadState,d.delayLoadingFile=this.delayLoadingFile,d._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)d._delayInfo=d._delayInfo||[],d._delayInfo.push(a);return d._boundingInfo=new l.a(this._extend.minimum,this._extend.maximum),d},e.prototype.serialize=function(){var e={};return e.id=this.id,e.updatable=this._updatable,d.a&&d.a.HasTags(this)&&(e.tags=d.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(a.b.PositionKind)&&(e.positions=this.toNumberArray(this.getVerticesData(a.b.PositionKind)),this.isVertexBufferUpdatable(a.b.PositionKind)&&(e.positions._updatable=!0)),this.isVerticesDataPresent(a.b.NormalKind)&&(e.normals=this.toNumberArray(this.getVerticesData(a.b.NormalKind)),this.isVertexBufferUpdatable(a.b.NormalKind)&&(e.normals._updatable=!0)),this.isVerticesDataPresent(a.b.TangentKind)&&(e.tangets=this.toNumberArray(this.getVerticesData(a.b.TangentKind)),this.isVertexBufferUpdatable(a.b.TangentKind)&&(e.tangets._updatable=!0)),this.isVerticesDataPresent(a.b.UVKind)&&(e.uvs=this.toNumberArray(this.getVerticesData(a.b.UVKind)),this.isVertexBufferUpdatable(a.b.UVKind)&&(e.uvs._updatable=!0)),this.isVerticesDataPresent(a.b.UV2Kind)&&(e.uv2s=this.toNumberArray(this.getVerticesData(a.b.UV2Kind)),this.isVertexBufferUpdatable(a.b.UV2Kind)&&(e.uv2s._updatable=!0)),this.isVerticesDataPresent(a.b.UV3Kind)&&(e.uv3s=this.toNumberArray(this.getVerticesData(a.b.UV3Kind)),this.isVertexBufferUpdatable(a.b.UV3Kind)&&(e.uv3s._updatable=!0)),this.isVerticesDataPresent(a.b.UV4Kind)&&(e.uv4s=this.toNumberArray(this.getVerticesData(a.b.UV4Kind)),this.isVertexBufferUpdatable(a.b.UV4Kind)&&(e.uv4s._updatable=!0)),this.isVerticesDataPresent(a.b.UV5Kind)&&(e.uv5s=this.toNumberArray(this.getVerticesData(a.b.UV5Kind)),this.isVertexBufferUpdatable(a.b.UV5Kind)&&(e.uv5s._updatable=!0)),this.isVerticesDataPresent(a.b.UV6Kind)&&(e.uv6s=this.toNumberArray(this.getVerticesData(a.b.UV6Kind)),this.isVertexBufferUpdatable(a.b.UV6Kind)&&(e.uv6s._updatable=!0)),this.isVerticesDataPresent(a.b.ColorKind)&&(e.colors=this.toNumberArray(this.getVerticesData(a.b.ColorKind)),this.isVertexBufferUpdatable(a.b.ColorKind)&&(e.colors._updatable=!0)),this.isVerticesDataPresent(a.b.MatricesIndicesKind)&&(e.matricesIndices=this.toNumberArray(this.getVerticesData(a.b.MatricesIndicesKind)),e.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(a.b.MatricesIndicesKind)&&(e.matricesIndices._updatable=!0)),this.isVerticesDataPresent(a.b.MatricesWeightsKind)&&(e.matricesWeights=this.toNumberArray(this.getVerticesData(a.b.MatricesWeightsKind)),this.isVertexBufferUpdatable(a.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 h.b.RandomId()},e._ImportGeometry=function(t,i){var n=i.getScene(),o=t.geometryId;if(o){var c=n.getGeometryByID(o);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(a.b.PositionKind,u,!1)}if(l.normalsAttrDesc&&l.normalsAttrDesc.count>0){var h=new Float32Array(t,l.normalsAttrDesc.offset,l.normalsAttrDesc.count);i.setVerticesData(a.b.NormalKind,h,!1)}if(l.tangetsAttrDesc&&l.tangetsAttrDesc.count>0){var d=new Float32Array(t,l.tangetsAttrDesc.offset,l.tangetsAttrDesc.count);i.setVerticesData(a.b.TangentKind,d,!1)}if(l.uvsAttrDesc&&l.uvsAttrDesc.count>0){var f=new Float32Array(t,l.uvsAttrDesc.offset,l.uvsAttrDesc.count);i.setVerticesData(a.b.UVKind,f,!1)}if(l.uvs2AttrDesc&&l.uvs2AttrDesc.count>0){var p=new Float32Array(t,l.uvs2AttrDesc.offset,l.uvs2AttrDesc.count);i.setVerticesData(a.b.UV2Kind,p,!1)}if(l.uvs3AttrDesc&&l.uvs3AttrDesc.count>0){var _=new Float32Array(t,l.uvs3AttrDesc.offset,l.uvs3AttrDesc.count);i.setVerticesData(a.b.UV3Kind,_,!1)}if(l.uvs4AttrDesc&&l.uvs4AttrDesc.count>0){var m=new Float32Array(t,l.uvs4AttrDesc.offset,l.uvs4AttrDesc.count);i.setVerticesData(a.b.UV4Kind,m,!1)}if(l.uvs5AttrDesc&&l.uvs5AttrDesc.count>0){var g=new Float32Array(t,l.uvs5AttrDesc.offset,l.uvs5AttrDesc.count);i.setVerticesData(a.b.UV5Kind,g,!1)}if(l.uvs6AttrDesc&&l.uvs6AttrDesc.count>0){var v=new Float32Array(t,l.uvs6AttrDesc.offset,l.uvs6AttrDesc.count);i.setVerticesData(a.b.UV6Kind,v,!1)}if(l.colorsAttrDesc&&l.colorsAttrDesc.count>0){var b=new Float32Array(t,l.colorsAttrDesc.offset,l.colorsAttrDesc.count);i.setVerticesData(a.b.ColorKind,b,!1,l.colorsAttrDesc.stride)}if(l.matricesIndicesAttrDesc&&l.matricesIndicesAttrDesc.count>0){for(var y=new Int32Array(t,l.matricesIndicesAttrDesc.offset,l.matricesIndicesAttrDesc.count),T=[],E=0;E<y.length;E++){var S=y[E];T.push(255&S),T.push((65280&S)>>8),T.push((16711680&S)>>16),T.push(S>>24&255)}i.setVerticesData(a.b.MatricesIndicesKind,T,!1)}if(l.matricesIndicesExtraAttrDesc&&l.matricesIndicesExtraAttrDesc.count>0){for(y=new Int32Array(t,l.matricesIndicesExtraAttrDesc.offset,l.matricesIndicesExtraAttrDesc.count),T=[],E=0;E<y.length;E++){S=y[E];T.push(255&S),T.push((65280&S)>>8),T.push((16711680&S)>>16),T.push(S>>24&255)}i.setVerticesData(a.b.MatricesIndicesExtraKind,T,!1)}if(l.matricesWeightsAttrDesc&&l.matricesWeightsAttrDesc.count>0){var A=new Float32Array(t,l.matricesWeightsAttrDesc.offset,l.matricesWeightsAttrDesc.count);i.setVerticesData(a.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 C=new Int32Array(t,l.subMeshesAttrDesc.offset,5*l.subMeshesAttrDesc.count);i.subMeshes=[];for(E=0;E<l.subMeshesAttrDesc.count;E++){var R=C[5*E+0],x=C[5*E+1],O=C[5*E+2],M=C[5*E+3],I=C[5*E+4];s.a.AddToMesh(R,x,O,M,I,i)}}}else if(t.positions&&t.normals&&t.indices){if(i.setVerticesData(a.b.PositionKind,t.positions,t.positions._updatable),i.setVerticesData(a.b.NormalKind,t.normals,t.normals._updatable),t.tangents&&i.setVerticesData(a.b.TangentKind,t.tangents,t.tangents._updatable),t.uvs&&i.setVerticesData(a.b.UVKind,t.uvs,t.uvs._updatable),t.uvs2&&i.setVerticesData(a.b.UV2Kind,t.uvs2,t.uvs2._updatable),t.uvs3&&i.setVerticesData(a.b.UV3Kind,t.uvs3,t.uvs3._updatable),t.uvs4&&i.setVerticesData(a.b.UV4Kind,t.uvs4,t.uvs4._updatable),t.uvs5&&i.setVerticesData(a.b.UV5Kind,t.uvs5,t.uvs5._updatable),t.uvs6&&i.setVerticesData(a.b.UV6Kind,t.uvs6,t.uvs6._updatable),t.colors&&i.setVerticesData(a.b.ColorKind,r.b.CheckColors4(t.colors,t.positions.length/3),t.colors._updatable),t.matricesIndices)if(t.matricesIndices._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(a.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&255)}i.setVerticesData(a.b.MatricesIndicesKind,T,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,i.setVerticesData(a.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&255)}i.setVerticesData(a.b.MatricesIndicesExtraKind,T,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,i),i.setVerticesData(a.b.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&i.setVerticesData(a.b.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),i.setIndices(t.indices,null)}if(t.subMeshes){i.subMeshes=[];for(var N=0;N<t.subMeshes.length;N++){var L=t.subMeshes[N];s.a.AddToMesh(L.materialIndex,L.verticesStart,L.verticesCount,L.indexStart,L.indexCount,i)}}i._shouldGenerateFlatShading&&(i.convertToFlatShadedMesh(),i._shouldGenerateFlatShading=!1),i.computeWorldMatrix(!0),n.onMeshImportedObservable.notifyObservers(i)},e._CleanMatricesWeights=function(e,t){if(c.a.CleanBoneMatrixWeights){var i=0;if(e.skeletonId>-1){var n=t.getScene().getLastSkeletonByID(e.skeletonId);if(n){i=n.bones.length;for(var r=t.getVerticesData(a.b.MatricesIndicesKind),o=t.getVerticesData(a.b.MatricesIndicesExtraKind),s=e.matricesWeights,l=e.matricesWeightsExtra,u=e.numBoneInfluencer,h=s.length,d=0;d<h;d+=4){for(var f=0,p=-1,_=0;_<4;_++){f+=m=s[d+_],m<.001&&p<0&&(p=_)}if(l)for(_=0;_<4;_++){var m;f+=m=l[d+_],m<.001&&p<0&&(p=_+4)}if((p<0||p>u-1)&&(p=u-1),f>.001){var g=1/f;for(_=0;_<4;_++)s[d+_]*=g;if(l)for(_=0;_<4;_++)l[d+_]*=g}else p>=4?(l[d+p-4]=1-f,o[d+p-4]=i):(s[d+p]=1-f,r[d+p]=i)}t.setVerticesData(a.b.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(a.b.MatricesIndicesExtraKind,o)}}}},e.Parse=function(t,i,r){if(i.getGeometryByID(t.id))return null;var s=new e(t.id,i,void 0,t.updatable);return d.a&&d.a.AddTagsTo(s,t.tags),t.delayLoadingFile?(s.delayLoadState=u.a.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=r+t.delayLoadingFile,s._boundingInfo=new l.a(n.e.FromArray(t.boundingBoxMinimum),n.e.FromArray(t.boundingBoxMaximum)),s._delayInfo=[],t.hasUVs&&s._delayInfo.push(a.b.UVKind),t.hasUVs2&&s._delayInfo.push(a.b.UV2Kind),t.hasUVs3&&s._delayInfo.push(a.b.UV3Kind),t.hasUVs4&&s._delayInfo.push(a.b.UV4Kind),t.hasUVs5&&s._delayInfo.push(a.b.UV5Kind),t.hasUVs6&&s._delayInfo.push(a.b.UV6Kind),t.hasColors&&s._delayInfo.push(a.b.ColorKind),t.hasMatricesIndices&&s._delayInfo.push(a.b.MatricesIndicesKind),t.hasMatricesWeights&&s._delayInfo.push(a.b.MatricesWeightsKind),s._delayLoadingFunction=o.a.ImportVertexData):o.a.ImportVertexData(t,s),i.pushGeometry(s,!0),s},e}()},function(e,t,i){"use strict";i.d(t,"e",(function(){return n})),i.d(t,"c",(function(){return s})),i.d(t,"a",(function(){return c})),i.d(t,"b",(function(){return l})),i.d(t,"f",(function(){return u})),i.d(t,"g",(function(){return h})),i.d(t,"d",(function(){return d}));var n,r=i(14),o=i(0),a=i(28);!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(n||(n={}));var s=function(){function e(){}return e.Interpolate=function(e,t,i,n,r){for(var o=1-3*n+3*t,a=3*n-6*t,s=3*t,c=e,l=0;l<5;l++){var u=c*c;c-=(o*(u*c)+a*u+s*c-e)*(1/(3*o*u+2*a*c+s)),c=Math.min(1,Math.max(0,c))}return 3*Math.pow(1-c,2)*c*i+3*(1-c)*Math.pow(c,2)*r+Math.pow(c,3)},e}(),c=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 n=i.subtract(t);return new e(Math.atan2(n.y,n.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}(),l=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),a=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,s=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,l=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new o.d((a*(t.y-i.y)-s*(e.y-t.y))/l,((e.x-t.x)*s-(t.x-i.x)*a)/l),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=c.BetweenTwoPoints(this.centerPoint,this.startPoint);var u=this.startAngle.degrees(),h=c.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),d=c.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-u>180&&(h-=360),h-u<-180&&(h+=360),d-h>180&&(d-=360),d-h<-180&&(d+=360),this.orientation=h-u<0?n.CW:n.CCW,this.angle=c.FromDegrees(this.orientation===n.CW?u-d:d-u)},u=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new o.d(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new o.d(e,t),n=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(n).length(),this},e.prototype.addArcTo=function(e,t,i,r,a){if(void 0===a&&(a=36),this.closed)return this;var s=this._points[this._points.length-1],c=new o.d(e,t),u=new o.d(i,r),h=new l(s,c,u),d=h.angle.radians()/a;h.orientation===n.CW&&(d*=-1);for(var f=h.startAngle.radians()+d,p=0;p<a;p++){var _=Math.cos(f)*h.radius+h.centerPoint.x,m=Math.sin(f)*h.radius+h.centerPoint.y;this.addLineTo(_,m),f+=d}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},e.prototype.getPoints=function(){return this._points},e.prototype.getPointAtLengthPosition=function(e){if(e<0||e>1)return o.d.Zero();for(var t=e*this.length(),i=0,n=0;n<this._points.length;n++){var r=(n+1)%this._points.length,a=this._points[n],s=this._points[r].subtract(a),c=s.length()+i;if(t>=i&&t<=c){var l=s.normalize(),u=t-i;return new o.d(a.x+l.x*u,a.y+l.y*u)}i=c}return o.d.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e}(),h=function(){function e(e,t,i,n){void 0===t&&(t=null),void 0===n&&(n=!1),this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array,this._pointAtData={id:0,point:o.e.Zero(),previousPointArrayIndex:0,position:0,subPosition:0,interpolateReady:!1,interpolationMatrix:o.a.Identity()};for(var r=0;r<e.length;r++)this._curve[r]=e[r].clone();this._raw=i||!1,this._alignTangentsWithPath=n,this._compute(t,n)}return e.prototype.getCurve=function(){return this._curve},e.prototype.getPoints=function(){return this._curve},e.prototype.length=function(){return this._distances[this._distances.length-1]},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.getPointAt=function(e){return this._updatePointAtData(e).point},e.prototype.getTangentAt=function(e,t){return void 0===t&&(t=!1),this._updatePointAtData(e,t),t?o.e.TransformCoordinates(o.e.Forward(),this._pointAtData.interpolationMatrix):this._tangents[this._pointAtData.previousPointArrayIndex]},e.prototype.getNormalAt=function(e,t){return void 0===t&&(t=!1),this._updatePointAtData(e,t),t?o.e.TransformCoordinates(o.e.Right(),this._pointAtData.interpolationMatrix):this._normals[this._pointAtData.previousPointArrayIndex]},e.prototype.getBinormalAt=function(e,t){return void 0===t&&(t=!1),this._updatePointAtData(e,t),t?o.e.TransformCoordinates(o.e.UpReadOnly,this._pointAtData.interpolationMatrix):this._binormals[this._pointAtData.previousPointArrayIndex]},e.prototype.getDistanceAt=function(e){return this.length()*e},e.prototype.getPreviousPointIndexAt=function(e){return this._updatePointAtData(e),this._pointAtData.previousPointArrayIndex},e.prototype.getSubPositionAt=function(e){return this._updatePointAtData(e),this._pointAtData.subPosition},e.prototype.getClosestPositionTo=function(e){for(var t=Number.MAX_VALUE,i=0,n=0;n<this._curve.length-1;n++){var r=this._curve[n+0],a=this._curve[n+1].subtract(r).normalize(),s=this._distances[n+1]-this._distances[n+0],c=Math.min(Math.max(o.e.Dot(a,e.subtract(r).normalize()),0)*o.e.Distance(r,e)/s,1),l=o.e.Distance(r.add(a.scale(c*s)),e);l<t&&(t=l,i=(this._distances[n+0]+s*c)/this.length())}return i},e.prototype.slice=function(t,i){if(void 0===t&&(t=0),void 0===i&&(i=1),t<0&&(t=1- -1*t%1),i<0&&(i=1- -1*i%1),t>i){var n=t;t=i,i=n}var r=this.getCurve(),o=this.getPointAt(t),a=this.getPreviousPointIndexAt(t),s=this.getPointAt(i),c=this.getPreviousPointIndexAt(i)+1,l=[];return 0!==t&&(a++,l.push(o)),l.push.apply(l,r.slice(a,c)),1===i&&1!==t||l.push(s),new e(l,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1);for(var n=0;n<e.length;n++)this._curve[n].x=e[n].x,this._curve[n].y=e[n].y,this._curve[n].z=e[n].z;return this._compute(t,i),this},e.prototype._compute=function(e,t){void 0===t&&(t=!1);var i=this._curve.length;if(!(i<2)){this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[i-1]=this._curve[i-1].subtract(this._curve[i-2]),this._raw||this._tangents[i-1].normalize();var n,r,a,s,c,l=this._tangents[0],u=this._normalVector(l,e);this._normals[0]=u,this._raw||this._normals[0].normalize(),this._binormals[0]=o.e.Cross(l,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var h=1;h<i;h++)n=this._getLastNonNullVector(h),h<i-1&&(r=this._getFirstNonNullVector(h),this._tangents[h]=t?r:n.add(r),this._tangents[h].normalize()),this._distances[h]=this._distances[h-1]+this._curve[h].subtract(this._curve[h-1]).length(),a=this._tangents[h],c=this._binormals[h-1],this._normals[h]=o.e.Cross(c,a),this._raw||(0===this._normals[h].length()?(s=this._normals[h-1],this._normals[h]=s.clone()):this._normals[h].normalize()),this._binormals[h]=o.e.Cross(a,this._normals[h]),this._raw||this._binormals[h].normalize();this._pointAtData.id=NaN}},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,n,s=e.length();(0===s&&(s=1),null==t)?(n=r.a.WithinEpsilon(Math.abs(e.y)/s,1,a.a)?r.a.WithinEpsilon(Math.abs(e.x)/s,1,a.a)?r.a.WithinEpsilon(Math.abs(e.z)/s,1,a.a)?o.e.Zero():new o.e(0,0,1):new o.e(1,0,0):new o.e(0,-1,0),i=o.e.Cross(e,n)):(i=o.e.Cross(e,t),o.e.CrossToRef(i,e,i));return i.normalize(),i},e.prototype._updatePointAtData=function(e,t){if(void 0===t&&(t=!1),this._pointAtData.id===e)return this._pointAtData.interpolateReady||this._updateInterpolationMatrix(),this._pointAtData;this._pointAtData.id=e;var i=this.getPoints();if(e<=0)return this._setPointAtData(0,0,i[0],0,t);if(e>=1)return this._setPointAtData(1,1,i[i.length-1],i.length-1,t);for(var n,r=i[0],a=0,s=e*this.length(),c=1;c<i.length;c++){n=i[c];var l=o.e.Distance(r,n);if((a+=l)===s)return this._setPointAtData(e,1,n,c,t);if(a>s){var u=(a-s)/l,h=r.subtract(n),d=n.add(h.scaleInPlace(u));return this._setPointAtData(e,1-u,d,c-1,t)}r=n}return this._pointAtData},e.prototype._setPointAtData=function(e,t,i,n,r){return this._pointAtData.point=i,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=n,this._pointAtData.interpolateReady=r,r&&this._updateInterpolationMatrix(),this._pointAtData},e.prototype._updateInterpolationMatrix=function(){this._pointAtData.interpolationMatrix=o.a.Identity();var e=this._pointAtData.previousPointArrayIndex;if(e!==this._tangents.length-1){var t=e+1,i=this._tangents[e].clone(),n=this._normals[e].clone(),r=this._binormals[e].clone(),a=this._tangents[t].clone(),s=this._normals[t].clone(),c=this._binormals[t].clone(),l=o.b.RotationQuaternionFromAxis(n,r,i),u=o.b.RotationQuaternionFromAxis(s,c,a);o.b.Slerp(l,u,this._pointAtData.subPosition).toRotationMatrix(this._pointAtData.interpolationMatrix)}},e}(),d=function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,n,r){r=r>2?r:3;for(var a=new Array,s=function(e,t,i,n){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*n},c=0;c<=r;c++)a.push(new o.e(s(c/r,t.x,i.x,n.x),s(c/r,t.y,i.y,n.y),s(c/r,t.z,i.z,n.z)));return new e(a)},e.CreateCubicBezier=function(t,i,n,r,a){a=a>3?a:4;for(var s=new Array,c=function(e,t,i,n,r){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*n+e*e*e*r},l=0;l<=a;l++)s.push(new o.e(c(l/a,t.x,i.x,n.x,r.x),c(l/a,t.y,i.y,n.y,r.y),c(l/a,t.z,i.z,n.z,r.z)));return new e(s)},e.CreateHermiteSpline=function(t,i,n,r,a){for(var s=new Array,c=1/a,l=0;l<=a;l++)s.push(o.e.Hermite(t,i,n,r,l*c));return new e(s)},e.CreateCatmullRomSpline=function(t,i,n){var r=new Array,a=1/i,s=0;if(n){for(var c=t.length,l=0;l<c;l++){s=0;for(var u=0;u<i;u++)r.push(o.e.CatmullRom(t[l%c],t[(l+1)%c],t[(l+2)%c],t[(l+3)%c],s)),s+=a}r.push(r[0])}else{var h=new Array;h.push(t[0].clone()),Array.prototype.push.apply(h,t),h.push(t[t.length-1].clone());for(l=0;l<h.length-3;l++){s=0;for(u=0;u<i;u++)r.push(o.e.CatmullRom(h[l],h[l+1],h[l+2],h[l+3],s)),s+=a}l--,r.push(o.e.CatmullRom(h[l],h[l+1],h[l+2],h[l+3],s))}return new e(r)},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],n=this._points.slice(),r=t.getPoints(),o=1;o<r.length;o++)n.push(r[o].subtract(r[0]).add(i));return new e(n)},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}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return m}));var n=i(1),r=i(3),o=i(0),a=i(4),s=i(10),c=i(15),l=i(25),u=i(11),h=i(9),d=i(67),f=i(49),p=i(13),_={effect:null,subMesh:null},m=function(e){function t(t,i,r,a){void 0===a&&(a={});var s=e.call(this,t,i)||this;return s._textures={},s._textureArrays={},s._floats={},s._ints={},s._floatsArrays={},s._colors3={},s._colors3Arrays={},s._colors4={},s._colors4Arrays={},s._vectors2={},s._vectors3={},s._vectors4={},s._matrices={},s._matrixArrays={},s._matrices3x3={},s._matrices2x2={},s._vectors2Arrays={},s._vectors3Arrays={},s._vectors4Arrays={},s._cachedWorldViewMatrix=new o.a,s._cachedWorldViewProjectionMatrix=new o.a,s._multiview=!1,s._shaderPath=r,s._options=Object(n.a)({needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],defines:[]},a),s}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"shaderPath",{get:function(){return this._shaderPath},set:function(e){this._shaderPath=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),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.setColor4Array=function(e,t){return this._checkUniform(e),this._colors4Arrays[e]=t.reduce((function(e,t){return t.toArray(e,e.length),e}),[]),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.setMatrices=function(e,t){this._checkUniform(e);for(var i=new Float32Array(16*t.length),n=0;n<t.length;n++){t[n].copyToArray(i,16*n)}return this._matrixArrays[e]=i,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.setArray4=function(e,t){return this._checkUniform(e),this._vectors4Arrays[e]=t,this},t.prototype._checkCache=function(e,t){return!e||(!this._effect||-1!==this._effect.defines.indexOf("#define INSTANCES")===t)},t.prototype.isReadyForSubMesh=function(e,t,i){return this.isReady(e,i)},t.prototype.isReady=function(e,t){var i,n;if(this._effect&&this.isFrozen&&this._effect._wasPreviouslyReady)return!0;var r=this.getScene(),o=r.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===r.getRenderId()&&this._checkCache(e,t))return!0;var s=[],l=[],u=new d.a;o.getCaps().multiview&&r.activeCamera&&r.activeCamera.outputRenderTarget&&r.activeCamera.outputRenderTarget.getViewCount()>1&&(this._multiview=!0,s.push("#define MULTIVIEW"),-1!==this._options.uniforms.indexOf("viewProjection")&&-1===this._options.uniforms.push("viewProjectionR")&&this._options.uniforms.push("viewProjectionR"));for(var h=0;h<this._options.defines.length;h++)s.push(this._options.defines[h]);for(h=0;h<this._options.attributes.length;h++)l.push(this._options.attributes[h]);e&&e.isVerticesDataPresent(a.b.ColorKind)&&(l.push(a.b.ColorKind),s.push("#define VERTEXCOLOR")),t&&(s.push("#define INSTANCES"),c.a.PushAttributesForInstances(l),(null==e?void 0:e.hasThinInstances)&&s.push("#define THIN_INSTANCES"));var f=0;if(e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton){l.push(a.b.MatricesIndicesKind),l.push(a.b.MatricesWeightsKind),e.numBoneInfluencers>4&&(l.push(a.b.MatricesIndicesExtraKind),l.push(a.b.MatricesWeightsExtraKind));var p=e.skeleton;f=e.numBoneInfluencers,s.push("#define NUM_BONE_INFLUENCERS "+f),u.addCPUSkinningFallback(0,e),p.isUsingTextureForMatrices?(s.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")):(s.push("#define BonesPerMesh "+(p.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else s.push("#define NUM_BONE_INFLUENCERS 0");for(var m in this._textures)if(!this._textures[m].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&s.push("#define ALPHATEST");var g=this._shaderPath,v=this._options.uniforms,b=this._options.uniformBuffers,y=this._options.samplers;this.customShaderNameResolve&&(v=v.slice(),b=b.slice(),y=y.slice(),g=this.customShaderNameResolve(g,v,b,y,s,l));var T=this._effect,E=s.join("\n");return this._cachedDefines!==E&&(this._cachedDefines=E,this._effect=o.createEffect(g,{attributes:l,uniformsNames:v,uniformBuffersNames:b,samplers:y,defines:E,fallbacks:u,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:f}},o),this._onEffectCreatedObservable&&(_.effect=this._effect,this._onEffectCreatedObservable.notifyObservers(_))),null!==(n=!(null===(i=this._effect)||void 0===i?void 0:i.isReady()))&&void 0!==n&&!n&&(T!==this._effect&&r.resetCachedMaterial(),this._renderId=r.getRenderId(),this._effect._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e,t){var i=this.getScene(),n=null!=t?t:this._effect;n&&(-1!==this._options.uniforms.indexOf("world")&&n.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(i.getViewMatrix(),this._cachedWorldViewMatrix),n.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(i.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),n.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},t.prototype.bindForSubMesh=function(e,t,i){this.bind(e,t,i._effectOverride)},t.prototype.bind=function(e,t,i){this.bindOnlyWorldMatrix(e,i);var n=null!=i?i:this._effect;if(n&&this.getScene().getCachedMaterial()!==this){var r;for(r in-1!==this._options.uniforms.indexOf("view")&&n.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&n.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&(n.setMatrix("viewProjection",this.getScene().getTransformMatrix()),this._multiview&&n.setMatrix("viewProjectionR",this.getScene()._transformMatrixR)),this.getScene().activeCamera&&-1!==this._options.uniforms.indexOf("cameraPosition")&&n.setVector3("cameraPosition",this.getScene().activeCamera.globalPosition),c.a.BindBonesParameters(t,n),this._textures)n.setTexture(r,this._textures[r]);for(r in this._textureArrays)n.setTextureArray(r,this._textureArrays[r]);for(r in this._ints)n.setInt(r,this._ints[r]);for(r in this._floats)n.setFloat(r,this._floats[r]);for(r in this._floatsArrays)n.setArray(r,this._floatsArrays[r]);for(r in this._colors3)n.setColor3(r,this._colors3[r]);for(r in this._colors3Arrays)n.setArray3(r,this._colors3Arrays[r]);for(r in this._colors4){var o=this._colors4[r];n.setFloat4(r,o.r,o.g,o.b,o.a)}for(r in this._colors4Arrays)n.setArray4(r,this._colors4Arrays[r]);for(r in this._vectors2)n.setVector2(r,this._vectors2[r]);for(r in this._vectors3)n.setVector3(r,this._vectors3[r]);for(r in this._vectors4)n.setVector4(r,this._vectors4[r]);for(r in this._matrices)n.setMatrix(r,this._matrices[r]);for(r in this._matrixArrays)n.setMatrices(r,this._matrixArrays[r]);for(r in this._matrices3x3)n.setMatrix3x3(r,this._matrices3x3[r]);for(r in this._matrices2x2)n.setMatrix2x2(r,this._matrices2x2[r]);for(r in this._vectors2Arrays)n.setArray2(r,this._vectors2Arrays[r]);for(r in this._vectors3Arrays)n.setArray3(r,this._vectors3Arrays[r]);for(r in this._vectors4Arrays)n.setArray4(r,this._vectors4Arrays[r])}var a=this._effect;this._effect=n,this._afterBind(t),this._effect=a},t.prototype._afterBind=function(t){e.prototype._afterBind.call(this,t),this.getScene()._cachedEffect=this._effect},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 n=this._textureArrays[i],r=0;r<n.length;r++)t.push(n[r]);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 n=this._textureArrays[i],r=0;r<n.length;r++)if(n[r]===t)return!0;return!1},t.prototype.clone=function(e){var i=this,o=r.a.Clone((function(){return new t(e,i.getScene(),i._shaderPath,i._options)}),this);for(var a in o.name=e,o.id=e,"object"==typeof o._shaderPath&&(o._shaderPath=Object(n.a)({},o._shaderPath)),this._options=Object(n.a)({},this._options),Object.keys(this._options).forEach((function(e){var t=i._options[e];Array.isArray(t)&&(i._options[e]=t.slice(0))})),this._textures)o.setTexture(a,this._textures[a]);for(var a in this._floats)o.setFloat(a,this._floats[a]);for(var a in this._floatsArrays)o.setFloats(a,this._floatsArrays[a]);for(var a in this._colors3)o.setColor3(a,this._colors3[a]);for(var a in this._colors4)o.setColor4(a,this._colors4[a]);for(var a in this._vectors2)o.setVector2(a,this._vectors2[a]);for(var a in this._vectors3)o.setVector3(a,this._vectors3[a]);for(var a in this._vectors4)o.setVector4(a,this._vectors4[a]);for(var a in this._matrices)o.setMatrix(a,this._matrices[a]);for(var a in this._matrices3x3)o.setMatrix3x3(a,this._matrices3x3[a]);for(var a in this._matrices2x2)o.setMatrix2x2(a,this._matrices2x2[a]);return o},t.prototype.dispose=function(t,i,n){if(i){var r;for(r in this._textures)this._textures[r].dispose();for(r in this._textureArrays)for(var o=this._textureArrays[r],a=0;a<o.length;a++)o[a].dispose()}this._textures={},e.prototype.dispose.call(this,t,i,n)},t.prototype.serialize=function(){var e,t=r.a.Serialize(this);for(e in t.customType="BABYLON.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],n=0;n<i.length;n++)t.textureArrays[e].push(i[n].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.colors4Arrays={},this._colors4Arrays)t.colors4Arrays[e]=this._colors4Arrays[e];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.matrixArray={},this._matrixArrays)t.matrixArray[e]=this._matrixArrays[e];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];for(e in t.vectors4Arrays={},this._vectors4Arrays)t.vectors4Arrays[e]=this._vectors4Arrays[e];return t},t.Parse=function(e,i,n){var a,c=r.a.Parse((function(){return new t(e.name,i,e.shaderPath,e.options)}),e,i,n);for(a in e.textures)c.setTexture(a,s.a.Parse(e.textures[a],i,n));for(a in e.textureArrays){for(var l=e.textureArrays[a],u=new Array,d=0;d<l.length;d++)u.push(s.a.Parse(l[d],i,n));c.setTextureArray(a,u)}for(a in e.floats)c.setFloat(a,e.floats[a]);for(a in e.floatsArrays)c.setFloats(a,e.floatsArrays[a]);for(a in e.colors3)c.setColor3(a,h.a.FromArray(e.colors3[a]));for(a in e.colors3Arrays){var f=e.colors3Arrays[a].reduce((function(e,t,i){return i%3==0?e.push([t]):e[e.length-1].push(t),e}),[]).map((function(e){return h.a.FromArray(e)}));c.setColor3Array(a,f)}for(a in e.colors4)c.setColor4(a,h.b.FromArray(e.colors4[a]));for(a in e.colors4Arrays){f=e.colors4Arrays[a].reduce((function(e,t,i){return i%4==0?e.push([t]):e[e.length-1].push(t),e}),[]).map((function(e){return h.b.FromArray(e)}));c.setColor4Array(a,f)}for(a in e.vectors2)c.setVector2(a,o.d.FromArray(e.vectors2[a]));for(a in e.vectors3)c.setVector3(a,o.e.FromArray(e.vectors3[a]));for(a in e.vectors4)c.setVector4(a,o.f.FromArray(e.vectors4[a]));for(a in e.matrices)c.setMatrix(a,o.a.FromArray(e.matrices[a]));for(a in e.matrixArray)c._matrixArrays[a]=new Float32Array(e.matrixArray[a]);for(a in e.matrices3x3)c.setMatrix3x3(a,e.matrices3x3[a]);for(a in e.matrices2x2)c.setMatrix2x2(a,e.matrices2x2[a]);for(a in e.vectors2Arrays)c.setArray2(a,e.vectors2Arrays[a]);for(a in e.vectors3Arrays)c.setArray3(a,e.vectors3Arrays[a]);for(a in e.vectors4Arrays)c.setArray4(a,e.vectors4Arrays[a]);return c},t.ParseFromFileAsync=function(e,t,i,n){var r=this;return void 0===n&&(n=""),new Promise((function(o,a){var s=new f.a;s.addEventListener("readystatechange",(function(){if(4==s.readyState)if(200==s.status){var t=JSON.parse(s.responseText),c=r.Parse(t,i||p.a.LastCreatedScene,n);e&&(c.name=e),o(c)}else a("Unable to load the ShaderMaterial")})),s.open("GET",t),s.send()}))},t.CreateFromSnippetAsync=function(e,t,i){var n=this;return void 0===i&&(i=""),new Promise((function(r,o){var a=new f.a;a.addEventListener("readystatechange",(function(){if(4==a.readyState)if(200==a.status){var s=JSON.parse(JSON.parse(a.responseText).jsonPayload),c=JSON.parse(s.shaderMaterial),l=n.Parse(c,t||p.a.LastCreatedScene,i);l.snippetId=e,r(l)}else o("Unable to load the snippet "+e)})),a.open("GET",n.SnippetUrl+"/"+e.replace(/#/g,"/")),a.send()}))},t.SnippetUrl="https://snippet.babylonjs.com",t}(l.a);u.a.RegisteredTypes["BABYLON.ShaderMaterial"]=m},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.SetMatrixPrecision=function(t){if(e.MatrixTrackPrecisionChange=!1,t&&!e.MatrixUse64Bits&&e.MatrixTrackedMatrices)for(var i=0;i<e.MatrixTrackedMatrices.length;++i){var n=e.MatrixTrackedMatrices[i],r=n._m;n._m=new Array(16);for(var o=0;o<16;++o)n._m[o]=r[o]}e.MatrixUse64Bits=t,e.MatrixCurrentType=e.MatrixUse64Bits?Array:Float32Array,e.MatrixTrackedMatrices=null},e.MatrixUse64Bits=!1,e.MatrixTrackPrecisionChange=!0,e.MatrixCurrentType=Float32Array,e.MatrixTrackedMatrices=[],e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return p}));var n=i(1),r=i(6),o=i(0),a=i(46),s=i(7),c=i(53),l=i(65),u=i(51),h=i(36),d=i(30),f=i(9),p=function(e){function t(i,n,a,c,u){var p;void 0===n&&(n=f.a.Gray()),void 0===a&&(a=h.a.DefaultUtilityLayer),void 0===c&&(c=null),void 0===u&&(u=1);var _=e.call(this,a)||this;_._pointerObserver=null,_.snapDistance=0,_.onSnapObservable=new r.c,_._isEnabled=!0,_._parent=null,_._dragging=!1,_._parent=c,_._coloredMaterial=new d.a("",a.utilityLayerScene),_._coloredMaterial.diffuseColor=n,_._coloredMaterial.specularColor=n.subtract(new f.a(.1,.1,.1)),_._hoverMaterial=new d.a("",a.utilityLayerScene),_._hoverMaterial.diffuseColor=f.a.Yellow(),_._disableMaterial=new d.a("",a.utilityLayerScene),_._disableMaterial.diffuseColor=f.a.Gray(),_._disableMaterial.alpha=.4;var m=t._CreateArrow(a.utilityLayerScene,_._coloredMaterial,u),g=t._CreateArrow(a.utilityLayerScene,_._coloredMaterial,u+4,!0);_._gizmoMesh=new s.a("",a.utilityLayerScene),_._gizmoMesh.addChild(m),_._gizmoMesh.addChild(g),_._gizmoMesh.lookAt(_._rootMesh.position.add(i)),_._gizmoMesh.scaling.scaleInPlace(1/3),_._gizmoMesh.parent=_._rootMesh;var v=0,b=new o.e,y={snapDistance:0};_.dragBehavior=new l.a({dragAxis:i}),_.dragBehavior.moveAttached=!1,_._rootMesh.addBehavior(_.dragBehavior),_.dragBehavior.onDragObservable.add((function(e){if(_.attachedNode){if(0==_.snapDistance)_.attachedNode.position&&_.attachedNode.position.addInPlaceFromFloats(e.delta.x,e.delta.y,e.delta.z),_.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z),_.attachedNode.updateCache();else if(v+=e.dragDistance,Math.abs(v)>_.snapDistance){var t=Math.floor(Math.abs(v)/_.snapDistance);v%=_.snapDistance,e.delta.normalizeToRef(b),b.scaleInPlace(_.snapDistance*t),_.attachedNode.getWorldMatrix().addTranslationFromFloats(b.x,b.y,b.z),_.attachedNode.updateCache(),y.snapDistance=_.snapDistance*t,_.onSnapObservable.notifyObservers(y)}_._matrixChanged()}})),_.dragBehavior.onDragStartObservable.add((function(){_._dragging=!0})),_.dragBehavior.onDragEndObservable.add((function(){_._dragging=!1}));var T=a._getSharedGizmoLight();T.includedOnlyMeshes=T.includedOnlyMeshes.concat(_._rootMesh.getChildMeshes(!1));var E={gizmoMeshes:m.getChildMeshes(),colliderMeshes:g.getChildMeshes(),material:_._coloredMaterial,hoverMaterial:_._hoverMaterial,disableMaterial:_._disableMaterial,active:!1};return null===(p=_._parent)||void 0===p||p.addToAxisCache(g,E),_._pointerObserver=a.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!_._customMeshSet&&(_._isHovered=!(-1==E.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!_._parent)){var i=_._isHovered||_._dragging?_._hoverMaterial:_._coloredMaterial;E.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}})),_}return Object(n.d)(t,e),t._CreateArrow=function(e,t,i,n){void 0===i&&(i=1),void 0===n&&(n=!1);var r=new a.a("arrow",e),o=c.a.CreateCylinder("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(i-1)/4),tessellation:96},e),s=c.a.CreateCylinder("cylinder",{diameterTop:.005*i,height:.275,diameterBottom:.005*i,tessellation:96},e);return o.parent=r,o.material=t,o.rotation.x=Math.PI/2,o.position.z+=.3,s.parent=r,s.material=t,s.position.z+=.1375,s.rotation.x=Math.PI/2,n&&(s.visibility=0,o.visibility=0),r},t._CreateArrowInstance=function(e,t){for(var i=new a.a("arrow",e),n=0,r=t.getChildMeshes();n<r.length;n++){var o=r[n];o.createInstance(o.name).parent=i}return i},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t}(u.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this._isDirty=!0,this._areLightsDirty=!0,this._areLightsDisposed=!1,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._arePrePassDirty=!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:!1,configurable:!0}),e.prototype.markAsProcessed=function(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areLightsDisposed=!1,this._areMiscDirty=!1,this._arePrePassDirty=!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(e){void 0===e&&(e=!1),this._areLightsDirty=!0,this._areLightsDisposed=this._areLightsDisposed||e,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.markAsPrePassDirty=function(){this._arePrePassDirty=!0,this._isDirty=!0},e.prototype.rebuild=function(){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],n=this[i];switch(typeof n){case"number":case"string":e+="#define "+i+" "+n+"\n";break;default:n&&(e+="#define "+i+"\n")}}return e},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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=0|this.width;return e=397*e^(0|this.height)},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:!1,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,n){return new e(t.width+(i.width-t.width)*n,t.height+(i.height-t.height)*n)},e}()},function(e,t,i){"use strict";var n="bonesDeclaration",r="#if NUM_BONE_INFLUENCERS>0\n#ifdef BONETEXTURE\nuniform sampler2D boneSampler;\nuniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#ifdef BONES_VELOCITY_ENABLED\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\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\n#define inline\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[n]=r},function(e,t,i){"use strict";var n="instancesDeclaration",r="#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#ifdef THIN_INSTANCES\nuniform mat4 world;\n#endif\n#else\nuniform mat4 world;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="instancesVertex",r="#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#ifdef THIN_INSTANCES\nfinalWorld=world*finalWorld;\n#endif\n#else\nmat4 finalWorld=world;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="#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=n},function(e,t,i){"use strict";i.d(t,"a",(function(){return c}));var n=i(0),r=i(7),o=i(4),a=i(16),s=i(43);a.a.CreateRibbon=function(e){var t=e.pathArray,i=e.closeArray||!1,n=e.closePath||!1,r=e.invertUV||!1,s=Math.floor(t[0].length/2),c=e.offset||s;c=c>s?s:Math.floor(c);var l,u,h,d,f=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,p=e.uvs,_=e.colors,m=[],g=[],v=[],b=[],y=[],T=[],E=[],S=[],A=[],P=[];if(t.length<2){var C=[],R=[];for(h=0;h<t[0].length-c;h++)C.push(t[0][h]),R.push(t[0][h+c]);t=[C,R]}var x,O,M,I,D,N=0,L=n?1:0;for(l=t[0].length,u=0;u<t.length;u++){for(E[u]=0,y[u]=[0],l=l<(O=(x=t[u]).length)?l:O,d=0;d<O;)m.push(x[d].x,x[d].y,x[d].z),d>0&&(M=x[d].subtract(x[d-1]).length()+E[u],y[u].push(M),E[u]=M),d++;n&&(d--,m.push(x[0].x,x[0].y,x[0].z),M=x[d].subtract(x[0]).length()+E[u],y[u].push(M),E[u]=M),A[u]=O+L,P[u]=N,N+=O+L}var w,F,B=null,U=null;for(h=0;h<l+L;h++){for(S[h]=0,T[h]=[0],u=0;u<t.length-1;u++)I=t[u],D=t[u+1],h===l?(B=I[0],U=D[0]):(B=I[h],U=D[h]),M=U.subtract(B).length()+S[h],T[h].push(M),S[h]=M;i&&U&&B&&(I=t[u],D=t[0],h===l&&(U=D[0]),M=U.subtract(B).length()+S[h],S[h]=M)}if(p)for(u=0;u<p.length;u++)b.push(p[u].x,p[u].y);else for(u=0;u<t.length;u++)for(h=0;h<l+L;h++)w=0!=E[u]?y[u][h]/E[u]:0,F=0!=S[h]?T[h][u]/S[h]:0,r?b.push(F,w):b.push(w,F);for(var V=0,k=A[u=0]-1,z=A[u+1]-1,G=k<z?k:z,j=P[1]-P[0],W=i?A.length:A.length-1;V<=G&&u<W;)g.push(V,V+j,V+1),g.push(V+j+1,V+1,V+j),(V+=1)===G&&(++u===A.length-1?(j=P[0]-P[u],k=A[u]-1,z=A[0]-1):(j=P[u+1]-P[u],k=A[u]-1,z=A[u+1]-1),V=P[u],G=k<z?k+V:z+V);if(a.a.ComputeNormals(m,g,v),n){var H=0,X=0;for(u=0;u<t.length;u++)H=3*P[u],X=u+1<t.length?3*(P[u+1]-1):v.length-3,v[H]=.5*(v[H]+v[X]),v[H+1]=.5*(v[H+1]+v[X+1]),v[H+2]=.5*(v[H+2]+v[X+2]),v[X]=v[H],v[X+1]=v[H+1],v[X+2]=v[H+2]}a.a._ComputeSides(f,m,g,v,b,e.frontUVs,e.backUVs);var Y=null;if(_){Y=new Float32Array(4*_.length);for(var K=0;K<_.length;K++)Y[4*K]=_[K].r,Y[4*K+1]=_[K].g,Y[4*K+2]=_[K].b,Y[4*K+3]=_[K].a}var Q=new a.a,q=new Float32Array(m),Z=new Float32Array(v),J=new Float32Array(b);return Q.indices=g,Q.positions=q,Q.normals=Z,Q.uvs=J,Y&&Q.set(Y,o.b.ColorKind),n&&(Q._idx=P),Q},r.a.CreateRibbon=function(e,t,i,n,r,o,a,s,l){return void 0===i&&(i=!1),void 0===a&&(a=!1),c.CreateRibbon(e,{pathArray:t,closeArray:i,closePath:n,offset:r,updatable:a,sideOrientation:s,instance:l},o)};var c=function(){function e(){}return e.CreateRibbon=function(e,t,i){void 0===i&&(i=null);var c=t.pathArray,l=t.closeArray,u=t.closePath,h=r.a._GetDefaultSideOrientation(t.sideOrientation),d=t.instance,f=t.updatable;if(d){var p=n.c.Vector3[0].setAll(Number.MAX_VALUE),_=n.c.Vector3[1].setAll(-Number.MAX_VALUE),m=d.getVerticesData(o.b.PositionKind);if(function(e){for(var t=c[0].length,i=d,n=0,o=i._originalBuilderSideOrientation===r.a.DOUBLESIDE?2:1,a=1;a<=o;++a)for(var s=0;s<c.length;++s){var l=c[s],u=l.length;t=t<u?t:u;for(var h=0;h<t;++h){var f=l[h];e[n]=f.x,e[n+1]=f.y,e[n+2]=f.z,p.minimizeInPlaceFromFloats(f.x,f.y,f.z),_.maximizeInPlaceFromFloats(f.x,f.y,f.z),n+=3}if(i._creationDataStorage&&i._creationDataStorage.closePath){f=l[0];e[n]=f.x,e[n+1]=f.y,e[n+2]=f.z,n+=3}}}(m),d._boundingInfo?d._boundingInfo.reConstruct(p,_,d._worldMatrix):d._boundingInfo=new s.a(p,_,d._worldMatrix),d.updateVerticesData(o.b.PositionKind,m,!1,!1),t.colors){for(var g=d.getVerticesData(o.b.ColorKind),v=0,b=0;v<t.colors.length;v++,b+=4){var y=t.colors[v];g[b]=y.r,g[b+1]=y.g,g[b+2]=y.b,g[b+3]=y.a}d.updateVerticesData(o.b.ColorKind,g,!1,!1)}if(t.uvs){for(var T=d.getVerticesData(o.b.UVKind),E=0;E<t.uvs.length;E++)T[2*E]=t.uvs[E].x,T[2*E+1]=t.uvs[E].y;d.updateVerticesData(o.b.UVKind,T,!1,!1)}if(!d.areNormalsFrozen||d.isFacetDataEnabled){var S=d.getIndices(),A=d.getVerticesData(o.b.NormalKind),P=d.isFacetDataEnabled?d.getFacetDataParameters():null;if(a.a.ComputeNormals(m,S,A,P),d._creationDataStorage&&d._creationDataStorage.closePath)for(var C=0,R=0,x=0;x<c.length;x++)C=3*d._creationDataStorage.idx[x],R=x+1<c.length?3*(d._creationDataStorage.idx[x+1]-1):A.length-3,A[C]=.5*(A[C]+A[R]),A[C+1]=.5*(A[C+1]+A[R+1]),A[C+2]=.5*(A[C+2]+A[R+2]),A[R]=A[C],A[R+1]=A[C+1],A[R+2]=A[C+2];d.areNormalsFrozen||d.updateVerticesData(o.b.NormalKind,A,!1,!1)}return d}var O=new r.a(e,i);O._originalBuilderSideOrientation=h,O._creationDataStorage=new r.b;var M=a.a.CreateRibbon(t);return u&&(O._creationDataStorage.idx=M._idx),O._creationDataStorage.closePath=u,O._creationDataStorage.closeArray=l,M.applyToMesh(O,f),O},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.FilesToLoad={},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(7),r=i(16);r.a.CreatePlane=function(e){var t=[],i=[],n=[],o=[],a=e.width||e.size||1,s=e.height||e.size||1,c=0===e.sideOrientation?0:e.sideOrientation||r.a.DEFAULTSIDE,l=a/2,u=s/2;i.push(-l,-u,0),n.push(0,0,-1),o.push(0,0),i.push(l,-u,0),n.push(0,0,-1),o.push(1,0),i.push(l,u,0),n.push(0,0,-1),o.push(1,1),i.push(-l,u,0),n.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),r.a._ComputeSides(c,i,t,n,o,e.frontUVs,e.backUVs);var h=new r.a;return h.indices=t,h.positions=i,h.normals=n,h.uvs=o,h},n.a.CreatePlane=function(e,t,i,n,r){var a={size:t,width:t,height:t,sideOrientation:r,updatable:n};return o.CreatePlane(e,a,i)};var o=function(){function e(){}return e.CreatePlane=function(e,t,i){void 0===i&&(i=null);var o=new n.a(e,i);return t.sideOrientation=n.a._GetDefaultSideOrientation(t.sideOrientation),o._originalBuilderSideOrientation=t.sideOrientation,r.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 r}));var n=i(8),r=(i(153),function(){function e(e,t,i){this._alreadyBound=!1,this._valueCache={},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:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!1,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 n=this._uniformLocationPointer-i,r=0;r<n;r++)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 n=0;n<t;n++)i.push(0)}this._fillAlignment(t),this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(n=0;n<t;n++)this._data.push(i[n]);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 n=[t,i];this.addUniform(e,n)},e.prototype.addFloat3=function(e,t,i,n){var r=[t,i,n];this.addUniform(e,r)},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 n=new Array;t.toArray(n),n.push(i),this.addUniform(e,n)},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._bufferData&&(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 r=this._uniformLocations[e];if(void 0===r){if(this._buffer)return void n.a.Error("Cannot add an uniform after UBO has been created.");this.addUniform(e,i),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(a=0;a<i;a++)this._bufferData[r+a]=t[a];else{for(var o=!1,a=0;a<i;a++)16!==i&&this._bufferData[r+a]===t[a]||(o=!0,this._bufferData[r+a]=t[a]);this._needSync=this._needSync||o}},e.prototype._cacheMatrix=function(e,t){var i=this._valueCache[e],n=t.updateFlag;return(void 0===i||i!==n)&&(this._valueCache[e]=n,!0)},e.prototype._updateMatrix3x3ForUniform=function(t,i){for(var n=0;n<3;n++)e._tempBuffer[4*n]=i[3*n],e._tempBuffer[4*n+1]=i[3*n+1],e._tempBuffer[4*n+2]=i[3*n+2],e._tempBuffer[4*n+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 n=0;n<2;n++)e._tempBuffer[4*n]=i[2*n],e._tempBuffer[4*n+1]=i[2*n+1],e._tempBuffer[4*n+2]=0,e._tempBuffer[4*n+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,n){void 0===n&&(n=""),this._currentEffect.setFloat2(e+n,t,i)},e.prototype._updateFloat2ForUniform=function(t,i,n){e._tempBuffer[0]=i,e._tempBuffer[1]=n,this.updateUniform(t,e._tempBuffer,2)},e.prototype._updateFloat3ForEffect=function(e,t,i,n,r){void 0===r&&(r=""),this._currentEffect.setFloat3(e+r,t,i,n)},e.prototype._updateFloat3ForUniform=function(t,i,n,r){e._tempBuffer[0]=i,e._tempBuffer[1]=n,e._tempBuffer[2]=r,this.updateUniform(t,e._tempBuffer,3)},e.prototype._updateFloat4ForEffect=function(e,t,i,n,r,o){void 0===o&&(o=""),this._currentEffect.setFloat4(e+o,t,i,n,r)},e.prototype._updateFloat4ForUniform=function(t,i,n,r,o){e._tempBuffer[0]=i,e._tempBuffer[1]=n,e._tempBuffer[2]=r,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._cacheMatrix(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,n){void 0===n&&(n=""),this._currentEffect.setColor4(e+n,t,i)},e.prototype._updateColor4ForUniform=function(t,i,n){i.toArray(e._tempBuffer),e._tempBuffer[3]=n,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&&(this._alreadyBound=!0,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 l}));var n=i(1),r=i(3),o=i(0),a=i(9),s=i(29),c=i(48);s.a.AddNodeConstructor("Light_Type_3",(function(e,t){return function(){return new l(e,o.e.Zero(),t)}}));var l=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r.groundColor=new a.a(0,0,0),r.direction=i||o.e.Up(),r}return Object(n.d)(t,e),t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),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.e.Normalize(e.subtract(o.e.Zero())),this.direction},t.prototype.getShadowGenerator=function(){return null},t.prototype.transferToEffect=function(e,t){var i=o.e.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.transferToNodeMaterialEffect=function(e,t){var i=o.e.Normalize(this.direction);return e.setFloat3(t,i.x,i.y,i.z),this},t.prototype.computeWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=o.a.Identity()),this._worldMatrix},t.prototype.getTypeID=function(){return c.a.LIGHTTYPEID_HEMISPHERICLIGHT},t.prototype.prepareLightSpecificDefines=function(e,t){e["HEMILIGHT"+t]=!0},Object(n.c)([Object(r.e)()],t.prototype,"groundColor",void 0),Object(n.c)([Object(r.o)()],t.prototype,"direction",void 0),t}(c.a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(1),r=i(0),o=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n._normalMatrix=new r.a,n._storeEffectOnSubMeshes=!0,n}return Object(n.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._isReadyForSubMesh=function(e){var t=e._materialDefines;return!(this.checkReadyOnEveryCall||!e.effect||!t||t._renderId!==this.getScene().getRenderId())},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(25).a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(1),r=function(e){function t(t){var i=e.call(this)||this;return i._buffer=t,i}return Object(n.d)(t,e),Object.defineProperty(t.prototype,"underlyingResource",{get:function(){return this._buffer},enumerable:!1,configurable:!0}),t}(i(89).a)},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this.references=0,this.capacity=0,this.is32Bits=!1}return Object.defineProperty(e.prototype,"underlyingResource",{get:function(){return null},enumerable:!1,configurable:!0}),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(64),r=function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new n.a(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,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(2),r=function(){function e(){this.hoverCursor="",this.actions=new Array,this.isRecursive=!1}return Object.defineProperty(e,"HasTriggers",{get:function(){for(var t in e.Triggers)if(e.Triggers.hasOwnProperty(t))return!0;return!1},enumerable:!1,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>=n.a.ACTION_OnPickTrigger&&i<=n.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,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 c}));var n=i(1),r=i(25),o=i(3),a=i(19),s=i(15),c=function(){function e(e){this._texture=null,this.diffuseBlendLevel=1,this.roughnessBlendLevel=1,this.bumpLevel=1,this._normalBlendMethod=r.a.MATERIAL_NORMALBLENDMETHOD_WHITEOUT,this._isEnabled=!1,this.isEnabled=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){var i=t.getEngine();return!(e._areTexturesDirty&&t.texturesEnabled&&i.getCaps().standardDerivatives&&this._texture&&a.a.DetailTextureEnabled&&!this._texture.isReady())},e.prototype.prepareDefines=function(e,t){if(this._isEnabled){e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod;var i=t.getEngine();e._areTexturesDirty&&(i.getCaps().standardDerivatives&&this._texture&&a.a.DetailTextureEnabled&&this._isEnabled?(s.a.PrepareDefinesForMergedUV(this._texture,e,"DETAIL"),e.DETAIL_NORMALBLENDMETHOD=this._normalBlendMethod):e.DETAIL=!1)}else e.DETAIL=!1},e.prototype.bindForSubMesh=function(e,t,i){this._isEnabled&&(e.useUbo&&i&&e.isSync||this._texture&&a.a.DetailTextureEnabled&&(e.updateFloat4("vDetailInfos",this._texture.coordinatesIndex,this.diffuseBlendLevel,this.bumpLevel,this.roughnessBlendLevel),s.a.BindTextureMatrix(this._texture,e,"detail")),t.texturesEnabled&&this._texture&&a.a.DetailTextureEnabled&&e.setTexture("detailSampler",this._texture))},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){var t;e&&(null===(t=this._texture)||void 0===t||t.dispose())},e.prototype.getClassName=function(){return"DetailMap"},e.AddUniforms=function(e){e.push("vDetailInfos")},e.AddSamplers=function(e){e.push("detailSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vDetailInfos",4),e.addUniform("detailMatrix",16)},e.prototype.copyTo=function(e){o.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return o.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;o.a.Parse((function(){return n}),e,t,i)},Object(n.c)([Object(o.m)("detailTexture"),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(n.c)([Object(o.c)()],e.prototype,"diffuseBlendLevel",void 0),Object(n.c)([Object(o.c)()],e.prototype,"roughnessBlendLevel",void 0),Object(n.c)([Object(o.c)()],e.prototype,"bumpLevel",void 0),Object(n.c)([Object(o.c)(),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"normalBlendMethod",void 0),Object(n.c)([Object(o.c)(),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),e}()},function(e,t,i){"use strict";var n="morphTargetsVertexGlobalDeclaration",r="#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="morphTargetsVertexDeclaration",r="#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#ifdef MORPHTARGETS_UV\nattribute vec2 uv_{X};\n#endif\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(25),r=i(4),o=i(2),a=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[r.b.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[r.b.PositionKind]=new r.b(this._scene.getEngine(),e,r.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[r.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,r,o,a){void 0===t&&(t=null),void 0===i&&(i=!1),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=!1);for(var s=this._scene.getEngine(),c=0;c<e.length;c++){c<e.length-1?e[c+1].activate(this._scene.activeCamera,t):t?s.bindFramebuffer(t,r,void 0,void 0,i,o):a||s.restoreDefaultFramebuffer();var l=e[c],u=l.apply();u&&(l.onBeforeRenderObservable.notifyObservers(u),this._prepareBuffers(),s.bindBuffers(this._vertexBuffers,this._indexBuffer,u),s.drawElementsType(n.a.TriangleFillMode,0,6),l.onAfterRenderObservable.notifyObservers(u))}s.setDepthBuffer(!0),s.setDepthWrite(!0)},e.prototype._finalizeFrame=function(e,t,i,r,a){void 0===a&&(a=!1);var s=this._scene.activeCamera;if(s&&0!==(r=r||s._postProcesses.filter((function(e){return null!=e}))).length&&this._scene.postProcessesEnabled){for(var c=this._scene.getEngine(),l=0,u=r.length;l<u;l++){var h=r[l];if(l<u-1?h._outputTexture=r[l+1].activate(s,t):t?(c.bindFramebuffer(t,i,void 0,void 0,a),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(n.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[r.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[r.b.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r})),i.d(t,"b",(function(){return o}));var n=i(148),r=function(){},o=function(){function e(t){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new r,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,n,r){var o=this._renderingGroupInfo;if(o.scene=this._scene,o.camera=this._scene.activeCamera,this._scene.spriteManagers&&r)for(var a=0;a<this._scene.spriteManagers.length;a++){var s=this._scene.spriteManagers[a];this.dispatchSprites(s)}for(a=e.MIN_RENDERINGGROUPS;a<e.MAX_RENDERINGGROUPS;a++){this._depthStencilBufferAlreadyCleaned=a===e.MIN_RENDERINGGROUPS;var c=this._renderingGroups[a];if(c){var l=Math.pow(2,a);if(o.renderingGroupId=a,this._scene.onBeforeRenderingGroupObservable.notifyObservers(o,l),e.AUTOCLEAR){var u=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(a):this._autoClearDepthStencil[a];u&&u.autoClear&&this._clearDepthStencilBuffer(u.depth,u.stencil)}for(var h=0,d=this._scene._beforeRenderingGroupDrawStage;h<d.length;h++){d[h].action(a)}c.render(t,r,n,i);for(var f=0,p=this._scene._afterRenderingGroupDrawStage;f<p.length;f++){p[f].action(a)}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 n.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 n=t.renderingGroupId||0;this._prepareRenderingGroup(n),this._renderingGroups[n].dispatch(e,t,i)},e.prototype.setRenderingOrder=function(e,t,i,n){if(void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=n,this._renderingGroups[e]){var r=this._renderingGroups[e];r.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],r.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],r.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}},e.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,n){void 0===i&&(i=!0),void 0===n&&(n=!0),this._autoClearDepthStencil[e]={autoClear:t,depth:i,stencil:n}},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 s}));var n=i(0),r=i(7),o=i(82),a=i(72);r.a.ExtrudeShape=function(e,t,i,n,o,a,c,l,u,h){void 0===c&&(c=null);var d={shape:t,path:i,scale:n,rotation:o,cap:0===a?0:a||r.a.NO_CAP,sideOrientation:u,instance:h,updatable:l};return s.ExtrudeShape(e,d,c)},r.a.ExtrudeShapeCustom=function(e,t,i,n,o,a,c,l,u,h,d,f){var p={shape:t,path:i,scaleFunction:n,rotationFunction:o,ribbonCloseArray:a,ribbonClosePath:c,cap:0===l?0:l||r.a.NO_CAP,sideOrientation:d,instance:f,updatable:h};return s.ExtrudeShapeCustom(e,p,u)};var s=function(){function e(){}return e.ExtrudeShape=function(t,i,n){void 0===n&&(n=null);var o=i.path,a=i.shape,s=i.scale||1,c=i.rotation||0,l=0===i.cap?0:i.cap||r.a.NO_CAP,u=i.updatable,h=r.a._GetDefaultSideOrientation(i.sideOrientation),d=i.instance||null,f=i.invertUV||!1;return e._ExtrudeShapeGeneric(t,a,o,s,c,null,null,!1,!1,l,!1,n,!!u,h,d,f,i.frontUVs||null,i.backUVs||null)},e.ExtrudeShapeCustom=function(t,i,n){void 0===n&&(n=null);var o=i.path,a=i.shape,s=i.scaleFunction||function(){return 1},c=i.rotationFunction||function(){return 0},l=i.ribbonCloseArray||!1,u=i.ribbonClosePath||!1,h=0===i.cap?0:i.cap||r.a.NO_CAP,d=i.updatable,f=r.a._GetDefaultSideOrientation(i.sideOrientation),p=i.instance,_=i.invertUV||!1;return e._ExtrudeShapeGeneric(t,a,o,null,null,s,c,l,u,h,!0,n,!!d,f,p||null,_,i.frontUVs||null,i.backUVs||null)},e._ExtrudeShapeGeneric=function(e,t,i,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T){var E,S,A=function(e,t,i,o,a,s,c,l,u,h){for(var d=i.getTangents(),f=i.getNormals(),p=i.getBinormals(),_=i.getDistances(),m=0,g=h&&l?l:function(){return null!==s?s:0},v=h&&c?c:function(){return null!==a?a:1},b=u===r.a.NO_CAP||u===r.a.CAP_END?0:2,y=n.c.Matrix[0],T=0;T<t.length;T++){for(var E=new Array,S=g(T,_[T]),A=v(T,_[T]),P=0;P<e.length;P++){n.a.RotationAxisToRef(d[T],m,y);var C=d[T].scale(e[P].z).add(f[T].scale(e[P].x)).add(p[T].scale(e[P].y)),R=E[P]?E[P]:n.e.Zero();n.e.TransformCoordinatesToRef(C,y,R),R.scaleInPlace(A).addInPlace(t[T]),E[P]=R}o[b]=E,m+=S,b++}var x=function(e){var t,i=Array(),r=n.e.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(u){case r.a.NO_CAP:break;case r.a.CAP_START:o[0]=x(o[2]),o[1]=o[2];break;case r.a.CAP_END:o[b]=o[b-1],o[b+1]=x(o[b-1]);break;case r.a.CAP_ALL:o[0]=x(o[2]),o[1]=o[2],o[b]=o[b-1],o[b+1]=x(o[b-1])}return o};if(v){var P=v._creationDataStorage;return E=P.path3D.update(i),S=A(t,i,P.path3D,P.pathArray,s,c,l,u,P.cap,p),v=r.a.CreateRibbon("",S,!1,!1,0,_||void 0,!1,0,v)}S=A(t,i,E=new a.g(i),new Array,s,c,l,u,f=f<0||f>3?0:f,p);var C=o.a.CreateRibbon(e,{pathArray:S,closeArray:h,closePath:d,updatable:m,sideOrientation:g,invertUV:b,frontUVs:y||void 0,backUVs:T||void 0},_);return C._creationDataStorage.pathArray=S,C._creationDataStorage.path3D=E,C._creationDataStorage.cap=f,C},e}()},function(e,t,i){"use strict";i.d(t,"b",(function(){return h})),i.d(t,"a",(function(){return d}));var n=i(1),r=i(9),o=i(4),a=i(7),s=i(151),c=i(25),l=i(73),u=i(15),h=(i(166),i(167),function(e){function t(t,i,n,a,s,c,u){void 0===i&&(i=null),void 0===n&&(n=null),void 0===a&&(a=null);var h=e.call(this,t,i,n,a,s)||this;h.useVertexColor=c,h.useVertexAlpha=u,h.color=new r.a(1,1,1),h.alpha=1,a&&(h.color=a.color.clone(),h.alpha=a.alpha,h.useVertexColor=a.useVertexColor,h.useVertexAlpha=a.useVertexAlpha),h.intersectionThreshold=.1;var d={attributes:[o.b.PositionKind,"world0","world1","world2","world3"],uniforms:["vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","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.color4=new r.b),h._colorShader=new l.a("colorShader",h.getScene(),"color",d),h}return Object(n.d)(t,e),t.prototype._addClipPlaneDefine=function(e){var t="#define "+e;-1===this._colorShader.options.defines.indexOf(t)&&this._colorShader.options.defines.push(t)},t.prototype._removeClipPlaneDefine=function(e){var t="#define "+e,i=this._colorShader.options.defines.indexOf(t);-1!==i&&this._colorShader.options.defines.splice(i,1)},t.prototype.isReady=function(){var t=this.getScene();return t.clipPlane?this._addClipPlaneDefine("CLIPPLANE"):this._removeClipPlaneDefine("CLIPPLANE"),t.clipPlane2?this._addClipPlaneDefine("CLIPPLANE2"):this._removeClipPlaneDefine("CLIPPLANE2"),t.clipPlane3?this._addClipPlaneDefine("CLIPPLANE3"):this._removeClipPlaneDefine("CLIPPLANE3"),t.clipPlane4?this._addClipPlaneDefine("CLIPPLANE4"):this._removeClipPlaneDefine("CLIPPLANE4"),t.clipPlane5?this._addClipPlaneDefine("CLIPPLANE5"):this._removeClipPlaneDefine("CLIPPLANE5"),t.clipPlane6?this._addClipPlaneDefine("CLIPPLANE6"):this._removeClipPlaneDefine("CLIPPLANE6"),!!this._colorShader.isReady(this)&&e.prototype.isReady.call(this)},t.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(t.prototype,"material",{get:function(){return this._colorShader},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return!1},enumerable:!1,configurable:!0}),t.prototype._bind=function(e,t,i){if(!this._geometry)return this;var n=this._colorShader.getEffect(),r=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(this._geometry._bind(n,r),!this.useVertexColor){var o=this.color,a=o.r,s=o.g,c=o.b;this.color4.set(a,s,c,this.alpha),this._colorShader.setColor4("color",this.color4)}return u.a.BindClipPlane(n,this.getScene()),this},t.prototype._draw=function(e,t,i){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var n=this.getScene().getEngine();return this._unIndexed?n.drawArraysType(c.a.LineListDrawMode,e.verticesStart,e.verticesCount,i):n.drawElementsType(c.a.LineListDrawMode,e.indexStart,e.indexCount,i),this},t.prototype.dispose=function(t){this._colorShader.dispose(!1,!1,!0),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e,i,n){return void 0===i&&(i=null),new t(e,this.getScene(),i,this,n)},t.prototype.createInstance=function(e){return new d(e,this)},t}(a.a)),d=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.intersectionThreshold=i.intersectionThreshold,n}return Object(n.d)(t,e),t.prototype.getClassName=function(){return"InstancedLinesMesh"},t}(s.a)},function(e,t,i){"use strict";i.r(t),i.d(t,"AxesViewer",(function(){return c})),i.d(t,"BoneAxesViewer",(function(){return h})),i.d(t,"DebugLayerTab",(function(){return n})),i.d(t,"DebugLayer",(function(){return m})),i.d(t,"PhysicsViewer",(function(){return A})),i.d(t,"RayHelper",(function(){return C})),i.d(t,"SkeletonViewer",(function(){return N}));var n,r=i(0),o=i(30),a=i(75),s=i(9),c=function(){function e(t,i,n,c,l,u){if(void 0===i&&(i=1),void 0===n&&(n=2),this._scaleLinesFactor=4,this._instanced=!1,this.scene=null,this.scaleLines=1,this.scaleLines=i,!c){var h=new o.a("",t);h.disableLighting=!0,h.emissiveColor=s.a.Red().scale(.5),c=a.a._CreateArrow(t,h)}if(!l){var d=new o.a("",t);d.disableLighting=!0,d.emissiveColor=s.a.Green().scale(.5),l=a.a._CreateArrow(t,d)}if(!u){var f=new o.a("",t);f.disableLighting=!0,f.emissiveColor=s.a.Blue().scale(.5),u=a.a._CreateArrow(t,f)}this._xAxis=c,this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis=l,this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis=u,this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),null!=n&&(e._SetRenderingGroupId(this._xAxis,n),e._SetRenderingGroupId(this._yAxis,n),e._SetRenderingGroupId(this._zAxis,n)),this.scene=t,this.update(new r.e,r.e.Right(),r.e.Up(),r.e.Forward())}return Object.defineProperty(e.prototype,"xAxis",{get:function(){return this._xAxis},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"yAxis",{get:function(){return this._yAxis},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zAxis",{get:function(){return this._zAxis},enumerable:!1,configurable:!0}),e.prototype.update=function(e,t,i,n){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(n),this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor)},e.prototype.createInstance=function(){var t=a.a._CreateArrowInstance(this.scene,this._xAxis),i=a.a._CreateArrowInstance(this.scene,this._yAxis),n=a.a._CreateArrowInstance(this.scene,this._zAxis),r=new e(this.scene,this.scaleLines,null,t,i,n);return r._instanced=!0,r},e.prototype.dispose=function(){this._xAxis&&this._xAxis.dispose(!1,!this._instanced),this._yAxis&&this._yAxis.dispose(!1,!this._instanced),this._zAxis&&this._zAxis.dispose(!1,!this._instanced),this.scene=null},e._SetRenderingGroupId=function(e,t){e.getChildMeshes().forEach((function(e){e.renderingGroupId=t}))},e}(),l=i(1),u=i(23),h=function(e){function t(t,i,n,o){void 0===o&&(o=1);var a=e.call(this,t,o)||this;return a.pos=r.e.Zero(),a.xaxis=r.e.Zero(),a.yaxis=r.e.Zero(),a.zaxis=r.e.Zero(),a.mesh=n,a.bone=i,a}return Object(l.d)(t,e),t.prototype.update=function(){if(this.mesh&&this.bone){var t=this.bone;t._markAsDirtyAndCompose(),t.getAbsolutePositionToRef(this.mesh,this.pos),t.getDirectionToRef(u.a.X,this.mesh,this.xaxis),t.getDirectionToRef(u.a.Y,this.mesh,this.yaxis),t.getDirectionToRef(u.a.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}(c),d=i(12),f=i(6),p=i(20),_=i(13);Object.defineProperty(p.a.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new m(this)),this._debugLayer},enumerable:!0,configurable:!0}),function(e){e[e.Properties=0]="Properties",e[e.Debug=1]="Debug",e[e.Statistics=2]="Statistics",e[e.Tools=3]="Tools",e[e.Settings=4]="Settings"}(n||(n={}));var m=function(){function e(e){var t=this;this.BJSINSPECTOR=this._getGlobalInspector(),this._scene=e,this._scene.onDisposeObservable.add((function(){t._scene._debugLayer&&t._scene._debugLayer.hide()}))}return Object.defineProperty(e.prototype,"onPropertyChangedObservable",{get:function(){return this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector?this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable:(this._onPropertyChangedObservable||(this._onPropertyChangedObservable=new f.c),this._onPropertyChangedObservable)},enumerable:!1,configurable:!0}),e.prototype._createInspector=function(e){if(!this.isVisible()){if(this._onPropertyChangedObservable){for(var t=0,i=this._onPropertyChangedObservable.observers;t<i.length;t++){var n=i[t];this.BJSINSPECTOR.Inspector.OnPropertyChangedObservable.add(n)}this._onPropertyChangedObservable.clear(),this._onPropertyChangedObservable=void 0}var r=Object(l.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,r)}},e.prototype.select=function(e,t){this.BJSINSPECTOR&&(t&&("[object String]"==Object.prototype.toString.call(t)?this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(t):this.BJSINSPECTOR.Inspector.MarkMultipleLineContainerTitlesForHighlighting(t)),this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(e))},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.setAsActiveScene=function(){this.BJSINSPECTOR&&this.BJSINSPECTOR.Inspector._SetNewScene(this._scene)},e.prototype.show=function(t){var i=this;return new Promise((function(n,r){if(void 0===i.BJSINSPECTOR){var o=t&&t.inspectorURL?t.inspectorURL:e.InspectorURL;d.b.LoadScript(o,(function(){i._createInspector(t),n(i)}))}else i._createInspector(t),n(i)}))},e.InspectorURL="https://unpkg.com/babylonjs-inspector@"+_.a.Version+"/babylon.inspector.bundle.js",e}(),g=i(7),v=i(63),b=i(45),y=i(22),T=i(32),E=i(36),S=i(53),A=function(){function e(e){this._impostors=[],this._meshes=[],this._numMeshes=0,this._debugMeshMeshes=new Array,this._scene=e||y.a.LastCreatedScene;var t=this._scene.getPhysicsEngine();t&&(this._physicsEnginePlugin=t.getPhysicsPlugin()),this._utilityLayer=new E.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{if(i.type===T.a.MeshImpostor)continue;var n=this._meshes[t];n&&e&&e.syncMeshWithImpostor(n,i)}}},e.prototype.showImpostor=function(e,t){if(!this._scene)return null;for(var i=0;i<this._numMeshes;i++)if(this._impostors[i]==e)return null;var n=this._getDebugMesh(e,t);return n&&(this._impostors[this._numMeshes]=e,this._meshes[this._numMeshes]=n,0===this._numMeshes&&(this._renderFunction=this._updateDebugMeshes.bind(this),this._scene.registerBeforeRender(this._renderFunction)),this._numMeshes++),n},e.prototype.hideImpostor=function(e){if(e&&this._scene&&this._utilityLayer){for(var t=!1,i=this._utilityLayer.utilityLayerScene,n=0;n<this._numMeshes;n++)if(this._impostors[n]==e){var r=this._meshes[n];if(!r)continue;i.removeMesh(r),r.dispose();var o=this._debugMeshMeshes.indexOf(r);o>-1&&this._debugMeshMeshes.splice(o,1),this._numMeshes--,this._numMeshes>0?(this._meshes[n]=this._meshes[this._numMeshes],this._impostors[n]=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 o.a("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=s.a.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=v.a.CreateBox("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=r.b.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(e),this._debugBoxMesh.setEnabled(!1)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugSphereMesh=function(e){return this._debugSphereMesh||(this._debugSphereMesh=b.a.CreateSphere("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=r.b.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugCylinderMesh=function(e){return this._debugCylinderMesh||(this._debugCylinderMesh=S.a.CreateCylinder("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=r.b.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var i=new g.a(e.name,t,null,e);return i.position=r.e.Zero(),i.setParent(e),i.material=this._getDebugMaterial(t),this._debugMeshMeshes.push(i),i},e.prototype._getDebugMesh=function(e,t){var i=this;if(!this._utilityLayer)return null;if(t&&t.parent&&t.parent.physicsImpostor)return null;var n=null,r=this._utilityLayer.utilityLayerScene;switch(e.type){case T.a.BoxImpostor:n=this._getDebugBoxMesh(r),e.getBoxSizeToRef(n.scaling);break;case T.a.SphereImpostor:n=this._getDebugSphereMesh(r);var o=e.getRadius();n.scaling.x=2*o,n.scaling.y=2*o,n.scaling.z=2*o;break;case T.a.MeshImpostor:t&&(n=this._getDebugMeshMesh(t,r));break;case T.a.NoImpostor:if(t)t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){i._getDebugBoxMesh(r).parent=e}));break;case T.a.CylinderImpostor:n=this._getDebugCylinderMesh(r);var a=e.object.getBoundingInfo();n.scaling.x=a.boundingBox.maximum.x-a.boundingBox.minimum.x,n.scaling.y=a.boundingBox.maximum.y-a.boundingBox.minimum.y,n.scaling.z=a.boundingBox.maximum.z-a.boundingBox.minimum.z}return n},e.prototype.dispose=function(){for(var e=this._numMeshes,t=0;t<e;t++)this.hideImpostor(this._impostors[0]);this._debugBoxMesh&&this._debugBoxMesh.dispose(),this._debugSphereMesh&&this._debugSphereMesh.dispose(),this._debugCylinderMesh&&this._debugCylinderMesh.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}(),P=i(40),C=function(){function e(e){this.ray=e}return e.CreateAndShow=function(t,i,n){var r=new e(t);return r.show(i,n),r},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=g.a.CreateLines("ray",this._renderPoints,e,!0),this._renderLine.isPickable=!1,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),this._renderPoints[0].copyFrom(e.origin),g.a.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)}},e.prototype.attachToMesh=function(e,t,i,n){var o=this;this._attachedToMesh=e;var a=this.ray;a&&(a.direction||(a.direction=r.e.Zero()),a.origin||(a.origin=r.e.Zero()),n&&(a.length=n),i||(i=r.e.Zero()),t||(t=new r.e(0,0,-1)),this._scene||(this._scene=e.getScene()),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(t),this._meshSpaceOrigin.copyFrom(i)):(this._meshSpaceDirection=t.clone(),this._meshSpaceOrigin=i.clone()),this._onAfterRenderObserver||(this._onAfterRenderObserver=this._scene.onBeforeRenderObservable.add((function(){return o._updateToMesh()})),this._onAfterStepObserver=this._scene.onAfterStepObservable.add((function(){return o._updateToMesh()}))),this._attachedToMesh.computeWorldMatrix(!0),this._updateToMesh())},e.prototype.detachFromMesh=function(){this._attachedToMesh&&this._scene&&(this._onAfterRenderObserver&&(this._scene.onBeforeRenderObservable.remove(this._onAfterRenderObserver),this._scene.onAfterStepObservable.remove(this._onAfterStepObserver)),this._attachedToMesh=null,this._onAfterRenderObserver=null,this._onAfterStepObserver=null,this._scene=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.e.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),e.origin)))},e.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},e}(),R=i(25),x=i(73),O=i(62),M=i(4),I=i(5),D=i(97),N=function(){function e(t,i,n,r,o,a){var c,l,u,h,d,f,p,_,m,g,v,b,y,T;void 0===r&&(r=!0),void 0===o&&(o=3),void 0===a&&(a={}),this.skeleton=t,this.mesh=i,this.autoUpdateBonesMatrices=r,this.renderingGroupId=o,this.options=a,this.color=s.a.White(),this._debugLines=new Array,this._localAxes=null,this._isEnabled=!1,this._obs=null,this._scene=n,this._ready=!1,a.pauseAnimations=null===(c=a.pauseAnimations)||void 0===c||c,a.returnToRest=null!==(l=a.returnToRest)&&void 0!==l&&l,a.displayMode=null!==(u=a.displayMode)&&void 0!==u?u:e.DISPLAY_LINES,a.displayOptions=null!==(h=a.displayOptions)&&void 0!==h?h:{},a.displayOptions.midStep=null!==(d=a.displayOptions.midStep)&&void 0!==d?d:.235,a.displayOptions.midStepFactor=null!==(f=a.displayOptions.midStepFactor)&&void 0!==f?f:.155,a.displayOptions.sphereBaseSize=null!==(p=a.displayOptions.sphereBaseSize)&&void 0!==p?p:.15,a.displayOptions.sphereScaleUnit=null!==(_=a.displayOptions.sphereScaleUnit)&&void 0!==_?_:2,a.displayOptions.sphereFactor=null!==(m=a.displayOptions.sphereFactor)&&void 0!==m?m:.865,a.displayOptions.spurFollowsChild=null!==(g=a.displayOptions.spurFollowsChild)&&void 0!==g&&g,a.displayOptions.showLocalAxes=null!==(v=a.displayOptions.showLocalAxes)&&void 0!==v&&v,a.displayOptions.localAxesSize=null!==(b=a.displayOptions.localAxesSize)&&void 0!==b?b:.075,a.computeBonesUsingShaders=null===(y=a.computeBonesUsingShaders)||void 0===y||y,a.useAllBones=null===(T=a.useAllBones)||void 0===T||T;var S=i.getVerticesData(M.b.MatricesIndicesKind),A=i.getVerticesData(M.b.MatricesWeightsKind);if(this._boneIndices=new Set,!a.useAllBones&&S&&A)for(var P=0;P<S.length;++P){var C=S[P];0!==A[P]&&this._boneIndices.add(C)}this._utilityLayer=new E.a(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0;var R=this.options.displayMode||0;R>e.DISPLAY_SPHERE_AND_SPURS&&(R=e.DISPLAY_LINES),this.displayMode=R,this.update(),this._bindObs()}return e.CreateBoneWeightShader=function(e,t){var i,n,r,o,a,c,l=e.skeleton,u=null!==(i=e.colorBase)&&void 0!==i?i:s.a.Black(),h=null!==(n=e.colorZero)&&void 0!==n?n:s.a.Blue(),d=null!==(r=e.colorQuarter)&&void 0!==r?r:s.a.Green(),f=null!==(o=e.colorHalf)&&void 0!==o?o:s.a.Yellow(),p=null!==(a=e.colorFull)&&void 0!==a?a:s.a.Red(),_=null!==(c=e.targetBoneIndex)&&void 0!==c?c:0;I.a.ShadersStore["boneWeights:"+l.name+"VertexShader"]="precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n\n #include<bonesDeclaration>\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n\n #include<instancesDeclaration>\n\n varying vec3 vColor;\n\n uniform vec3 colorBase;\n uniform vec3 colorZero;\n uniform vec3 colorQuarter;\n uniform vec3 colorHalf;\n uniform vec3 colorFull;\n\n uniform float targetBoneIndex;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include<instancesVertex>\n #include<bonesVertex>\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n vec3 color = colorBase;\n float totalWeight = 0.;\n if(matricesIndices[0] == targetBoneIndex && matricesWeights[0] > 0.){\n totalWeight += matricesWeights[0];\n }\n if(matricesIndices[1] == targetBoneIndex && matricesWeights[1] > 0.){\n totalWeight += matricesWeights[1];\n }\n if(matricesIndices[2] == targetBoneIndex && matricesWeights[2] > 0.){\n totalWeight += matricesWeights[2];\n }\n if(matricesIndices[3] == targetBoneIndex && matricesWeights[3] > 0.){\n totalWeight += matricesWeights[3];\n }\n\n color = mix(color, colorZero, smoothstep(0., 0.25, totalWeight));\n color = mix(color, colorQuarter, smoothstep(0.25, 0.5, totalWeight));\n color = mix(color, colorHalf, smoothstep(0.5, 0.75, totalWeight));\n color = mix(color, colorFull, smoothstep(0.75, 1.0, totalWeight));\n vColor = color;\n\n gl_Position = projection * view * worldPos;\n }",I.a.ShadersStore["boneWeights:"+l.name+"FragmentShader"]="\n precision highp float;\n varying vec3 vPosition;\n\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4(vColor, 1.0);\n gl_FragColor = color;\n }\n ";var m=new x.a("boneWeight:"+l.name,t,{vertex:"boneWeights:"+l.name,fragment:"boneWeights:"+l.name},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorBase","colorZero","colorQuarter","colorHalf","colorFull","targetBoneIndex"]});return m.setColor3("colorBase",u),m.setColor3("colorZero",h),m.setColor3("colorQuarter",d),m.setColor3("colorHalf",f),m.setColor3("colorFull",p),m.setFloat("targetBoneIndex",_),m.getClassName=function(){return"BoneWeightShader"},m.transparencyMode=R.a.MATERIAL_OPAQUE,m},e.CreateSkeletonMapShader=function(t,i){var n,r=t.skeleton,o=null!==(n=t.colorMap)&&void 0!==n?n:[{color:new s.a(1,.38,.18),location:0},{color:new s.a(.59,.18,1),location:.2},{color:new s.a(.59,1,.18),location:.4},{color:new s.a(1,.87,.17),location:.6},{color:new s.a(1,.17,.42),location:.8},{color:new s.a(.17,.68,1),location:1}],a=r.bones.length+1,c=e._CreateBoneMapColorBuffer(a,o,i),l=new x.a("boneWeights:"+r.name,i,{vertexSource:"precision highp float;\n\n attribute vec3 position;\n attribute vec2 uv;\n\n uniform mat4 view;\n uniform mat4 projection;\n uniform mat4 worldViewProjection;\n uniform float colorMap["+4*r.bones.length+"];\n\n #include<bonesDeclaration>\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include<instancesDeclaration>\n\n varying vec3 vColor;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include<instancesVertex>\n #include<bonesVertex>\n\n vec3 color = vec3(0.);\n bool first = true;\n\n for (int i = 0; i < 4; i++) {\n int boneIdx = int(matricesIndices[i]);\n float boneWgt = matricesWeights[i];\n\n vec3 c = vec3(colorMap[boneIdx * 4 + 0], colorMap[boneIdx * 4 + 1], colorMap[boneIdx * 4 + 2]);\n\n if (boneWgt > 0.) {\n if (first) {\n first = false;\n color = c;\n } else {\n color = mix(color, c, boneWgt);\n }\n }\n }\n\n vColor = color;\n\n vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);\n\n gl_Position = projection * view * worldPos;\n }",fragmentSource:"\n precision highp float;\n varying vec3 vColor;\n\n void main() {\n vec4 color = vec4( vColor, 1.0 );\n gl_FragColor = color;\n }\n "},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorMap"]});return l.setFloats("colorMap",c),l.getClassName=function(){return"SkeletonMapShader"},l.transparencyMode=R.a.MATERIAL_OPAQUE,l},e._CreateBoneMapColorBuffer=function(e,t,i){var n=new O.a("temp",{width:e,height:1},i,!1),r=n.getContext(),o=r.createLinearGradient(0,0,e,0);t.forEach((function(e){o.addColorStop(e.location,e.color.toHexString())})),r.fillStyle=o,r.fillRect(0,0,e,1),n.update();for(var a=[],s=r.getImageData(0,0,e,1).data,c=0;c<s.length;c++)a.push(s[c]*(1/255));return n.dispose(),a},Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"utilityLayer",{get:function(){return this._utilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return this._ready},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ready",{set:function(e){this._ready=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"debugMesh",{get:function(){return this._debugMesh},set:function(e){this._debugMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"displayMode",{get:function(){return this.options.displayMode||e.DISPLAY_LINES},set:function(t){t>e.DISPLAY_SPHERE_AND_SPURS&&(t=e.DISPLAY_LINES),this.options.displayMode=t},enumerable:!1,configurable:!0}),e.prototype._bindObs=function(){var t=this;switch(this.displayMode){case e.DISPLAY_LINES:this._obs=this.scene.onBeforeRenderObservable.add((function(){t._displayLinesUpdate()}))}},e.prototype.update=function(){switch(this.displayMode){case e.DISPLAY_LINES:this._displayLinesUpdate();break;case e.DISPLAY_SPHERES:this._buildSpheresAndSpurs(!0);break;case e.DISPLAY_SPHERE_AND_SPURS:this._buildSpheresAndSpurs(!1)}this._buildLocalAxes()},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this.isEnabled!==e&&(this._isEnabled=e,this.debugMesh&&this.debugMesh.setEnabled(e),e&&!this._obs?this._bindObs():!e&&this._obs&&(this.scene.onBeforeRenderObservable.remove(this._obs),this._obs=null))},enumerable:!1,configurable:!0}),e.prototype._getBonePosition=function(e,t,i,n,o,a){void 0===n&&(n=0),void 0===o&&(o=0),void 0===a&&(a=0);var s=r.c.Matrix[0],c=t.getParent();if(s.copyFrom(t.getLocalMatrix()),0!==n||0!==o||0!==a){var l=r.c.Matrix[1];r.a.IdentityToRef(l),l.setTranslationFromFloats(n,o,a),l.multiplyToRef(s,s)}c&&s.multiplyToRef(c.getAbsoluteTransform(),s),s.multiplyToRef(i,s),e.x=s.m[12],e.y=s.m[13],e.z=s.m[14]},e.prototype._getLinesForBonesWithLength=function(e,t){for(var i=e.length,n=this.mesh._effectiveMesh.position,o=0,a=0;a<i;a++){var s=e[a],c=this._debugLines[o];-1!==s._index&&(this._boneIndices.has(s.getIndex())||this.options.useAllBones)&&(c||(c=[r.e.Zero(),r.e.Zero()],this._debugLines[o]=c),this._getBonePosition(c[0],s,t),this._getBonePosition(c[1],s,t,0,s.length,0),c[0].subtractInPlace(n),c[1].subtractInPlace(n),o++)}},e.prototype._getLinesForBonesNoLength=function(e){for(var t=e.length,i=0,n=this.mesh._effectiveMesh,o=n.position,a=t-1;a>=0;a--){var s=e[a],c=s.getParent();if(c&&(this._boneIndices.has(s.getIndex())||this.options.useAllBones)){var l=this._debugLines[i];l||(l=[r.e.Zero(),r.e.Zero()],this._debugLines[i]=l),s.getAbsolutePositionToRef(n,l[0]),c.getAbsolutePositionToRef(n,l[1]),l[0].subtractInPlace(o),l[1].subtractInPlace(o),i++}}},e.prototype._revert=function(e){this.options.pauseAnimations&&(this.scene.animationsEnabled=e,this.utilityLayer.utilityLayerScene.animationsEnabled=e)},e.prototype._getAbsoluteBindPoseToRef=function(e,t){null!==e&&-1!==e._index?(this._getAbsoluteBindPoseToRef(e.getParent(),t),e.getBindPose().multiplyToRef(t,t)):t.copyFrom(r.a.Identity())},e.prototype._buildSpheresAndSpurs=function(e){var t,i;void 0===e&&(e=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var n=null===(t=this.utilityLayer)||void 0===t?void 0:t.utilityLayerScene,o=this.skeleton.bones,a=[],s=[],c=this.scene.animationsEnabled;try{this.options.pauseAnimations&&(this.scene.animationsEnabled=!1,n.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();for(var l=Number.NEGATIVE_INFINITY,u=this.options.displayOptions||{},h=function(t){var i=o[t];if(-1===i._index||!d._boneIndices.has(i.getIndex())&&!d.options.useAllBones)return"continue";var c=new r.a;d._getAbsoluteBindPoseToRef(i,c);var h=new r.e;c.decompose(void 0,void 0,h),i.children.forEach((function(t,o){var a=new r.a;t.getBindPose().multiplyToRef(c,a);var d=new r.e;a.decompose(void 0,void 0,d);var f=r.e.Distance(h,d);if(f>l&&(l=f),!e){for(var p=d.clone().subtract(h.clone()),_=p.length(),m=p.normalize().scale(_),v=u.midStep||.165,b=u.midStepFactor||.215,y=m.scale(v),T=D.a.ExtrudeShapeCustom("skeletonViewer",{shape:[new r.e(1,-1,0),new r.e(1,1,0),new r.e(-1,1,0),new r.e(-1,-1,0),new r.e(1,-1,0)],path:[r.e.Zero(),y,m],scaleFunction:function(e){switch(e){case 0:case 2:return 0;case 1:return _*b}return 0},sideOrientation:g.a.DEFAULTSIDE,updatable:!1},n),E=T.getTotalVertices(),S=[],A=[],P=0;P<E;P++)S.push(1,0,0,0),u.spurFollowsChild&&P>9?A.push(t.getIndex(),0,0,0):A.push(i.getIndex(),0,0,0);T.position=h.clone(),T.setVerticesData(M.b.MatricesWeightsKind,S,!1),T.setVerticesData(M.b.MatricesIndicesKind,A,!1),T.convertToFlatShadedMesh(),s.push(T)}}));for(var f=u.sphereBaseSize||.2,p=b.a.CreateSphere("skeletonViewer",{segments:6,diameter:f,updatable:!0},n),_=p.getTotalVertices(),m=[],v=[],y=0;y<_;y++)m.push(1,0,0,0),v.push(i.getIndex(),0,0,0);p.setVerticesData(M.b.MatricesWeightsKind,m,!1),p.setVerticesData(M.b.MatricesIndicesKind,v,!1),p.position=h.clone(),a.push([p,i])},d=this,f=0;f<o.length;f++)h(f);var p=u.sphereScaleUnit||2,_=u.sphereFactor||.85,m=[];for(f=0;f<a.length;f++){for(var v=a[f],y=v[0],T=v[1],E=1/(p/l),S=0,A=T;A.getParent()&&-1!==A.getParent().getIndex();)S++,A=A.getParent();y.scaling.scaleInPlace(E*Math.pow(_,S)),m.push(y)}this.debugMesh=g.a.MergeMeshes(m.concat(s),!0,!0),this.debugMesh&&(this.debugMesh.renderingGroupId=this.renderingGroupId,this.debugMesh.skeleton=this.skeleton,this.debugMesh.parent=this.mesh,this.debugMesh.computeBonesUsingShaders=null===(i=this.options.computeBonesUsingShaders)||void 0===i||i,this.debugMesh.alwaysSelectAsActiveMesh=!0),this.utilityLayer._getSharedGizmoLight().intensity=.7,this._revert(c),this.ready=!0}catch(e){console.error(e),this._revert(c),this.dispose()}},e.prototype._buildLocalAxes=function(){var e;this._localAxes&&this._localAxes.dispose(),this._localAxes=null;var t=this.options.displayOptions||{};if(t.showLocalAxes){var i=this._utilityLayer.utilityLayerScene,n=t.localAxesSize||.075,o=[],a=[],c=new s.b(1,0,0,1),l=new s.b(0,1,0,1),u=new s.b(0,0,1,1),h=[],d=[];for(var f in this.skeleton.bones){var p=this.skeleton.bones[f];if(-1!==p._index&&(this._boneIndices.has(p.getIndex())||this.options.useAllBones)){var _=new r.a,m=new r.e;this._getAbsoluteBindPoseToRef(p,_),_.decompose(void 0,void 0,m);var g=p.getBindPose().getRotationMatrix(),v=r.e.TransformCoordinates(new r.e(0+n,0,0),g),b=r.e.TransformCoordinates(new r.e(0,0+n,0),g),y=r.e.TransformCoordinates(new r.e(0,0,0+n),g),T=[[m,m.add(v)],[m,m.add(b)],[m,m.add(y)]],E=[[c,c],[l,l],[u,u]];o.push.apply(o,T),a.push.apply(a,E);for(var S=0;S<6;S++)h.push(1,0,0,0),d.push(p.getIndex(),0,0,0)}}this._localAxes=P.a.CreateLineSystem("localAxes",{lines:o,colors:a,updatable:!0},i),this._localAxes.setVerticesData(M.b.MatricesWeightsKind,h,!1),this._localAxes.setVerticesData(M.b.MatricesIndicesKind,d,!1),this._localAxes.skeleton=this.skeleton,this._localAxes.renderingGroupId=this.renderingGroupId,this._localAxes.parent=this.mesh,this._localAxes.computeBonesUsingShaders=null===(e=this.options.computeBonesUsingShaders)||void 0===e||e}},e.prototype._displayLinesUpdate=function(){if(this._utilityLayer){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();var e=this.mesh._effectiveMesh;void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones):this._getLinesForBonesWithLength(this.skeleton.bones,e.getWorldMatrix());var t=this._utilityLayer.utilityLayerScene;t&&(this._debugMesh?P.a.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},t):(this._debugMesh=P.a.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},t),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color)}},e.prototype.changeDisplayMode=function(e){var t=!!this.isEnabled;this.displayMode!==e&&(this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this.displayMode=e,this.update(),this._bindObs(),this.isEnabled=t)},e.prototype.changeDisplayOptions=function(e,t){var i=!!this.isEnabled;this.options.displayOptions[e]=t,this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this.update(),this._bindObs(),this.isEnabled=i},e.prototype.dispose=function(){this.isEnabled=!1,this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null),this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null),this.ready=!1},e.DISPLAY_LINES=0,e.DISPLAY_SPHERES=1,e.DISPLAY_SPHERE_AND_SPURS=2,e}()},function(e,t,i){"use strict";var n="morphTargetsVertex",r="#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#ifdef MORPHTARGETS_UV\nuvUpdated+=(uv_{X}-uv)*morphTargetInfluences[{X}];\n#endif\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"b",(function(){return r})),i.d(t,"a",(function(){return o}));var n=i(0);function r(e,t,i,r,o){void 0===o&&(o=null);for(var a=new n.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new n.e(-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];a.minimizeInPlaceFromFloats(u,h,d),s.maximizeInPlaceFromFloats(u,h,d)}return o&&(a.x-=a.x*o.x+o.y,a.y-=a.y*o.x+o.y,a.z-=a.z*o.x+o.y,s.x+=s.x*o.x+o.y,s.y+=s.y*o.x+o.y,s.z+=s.z*o.x+o.y),{minimum:a,maximum:s}}function o(e,t,i,r,o){void 0===r&&(r=null);var a=new n.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new n.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);o||(o=3);for(var c=t,l=t*o;c<t+i;c++,l+=o){var u=e[l],h=e[l+1],d=e[l+2];a.minimizeInPlaceFromFloats(u,h,d),s.maximizeInPlaceFromFloats(u,h,d)}return r&&(a.x-=a.x*r.x+r.y,a.y-=a.y*r.x+r.y,a.z-=a.z*r.x+r.y,s.x+=s.x*r.x+r.y,s.y+=s.y*r.x+r.y,s.z+=s.z*r.x+r.y),{minimum:a,maximum:s}}},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){}},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(44),r=i(0),o=i(28),a=function(){function e(e,t,i){this.vectors=n.a.BuildArray(8,r.e.Zero),this.center=r.e.Zero(),this.centerWorld=r.e.Zero(),this.extendSize=r.e.Zero(),this.extendSizeWorld=r.e.Zero(),this.directions=n.a.BuildArray(3,r.e.Zero),this.vectorsWorld=n.a.BuildArray(8,r.e.Zero),this.minimumWorld=r.e.Zero(),this.maximumWorld=r.e.Zero(),this.minimum=r.e.Zero(),this.maximum=r.e.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){var n=e.x,o=e.y,a=e.z,s=t.x,c=t.y,l=t.z,u=this.vectors;this.minimum.copyFromFloats(n,o,a),this.maximum.copyFromFloats(s,c,l),u[0].copyFromFloats(n,o,a),u[1].copyFromFloats(s,c,l),u[2].copyFromFloats(s,o,a),u[3].copyFromFloats(n,c,a),u[4].copyFromFloats(n,o,l),u[5].copyFromFloats(s,c,a),u[6].copyFromFloats(n,c,l),u[7].copyFromFloats(s,o,l),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=i||r.a.IdentityReadOnly,this._update(this._worldMatrix)},e.prototype.scale=function(t){var i=e.TmpVector3,n=this.maximum.subtractToRef(this.minimum,i[0]),r=n.length();n.normalizeFromLength(r);var o=r*t,a=n.scaleInPlace(.5*o),s=this.center.subtractToRef(a,i[1]),c=this.center.addToRef(a,i[2]);return this.reConstruct(s,c,this._worldMatrix),this},e.prototype.getWorldMatrix=function(){return this._worldMatrix},e.prototype._update=function(e){var t=this.minimumWorld,i=this.maximumWorld,n=this.directions,o=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),i.copyFrom(this.maximum);for(s=0;s<8;++s)o[s].copyFrom(a[s]);this.extendSizeWorld.copyFrom(this.extendSize),this.centerWorld.copyFrom(this.center)}else{t.setAll(Number.MAX_VALUE),i.setAll(-Number.MAX_VALUE);for(var s=0;s<8;++s){var c=o[s];r.e.TransformCoordinatesToRef(a[s],e,c),t.minimizeInPlace(c),i.maximizeInPlace(c)}i.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),i.addToRef(t,this.centerWorld).scaleInPlace(.5)}r.e.FromArrayToRef(e.m,0,n[0]),r.e.FromArrayToRef(e.m,4,n[1]),r.e.FromArrayToRef(e.m,8,n[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,n=t.x,r=t.y,a=t.z,s=i.x,c=i.y,l=i.z,u=e.x,h=e.y,d=e.z,f=-o.a;return!(s-u<f||f>u-n)&&(!(c-h<f||f>h-r)&&!(l-d<f||f>d-a))},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,n=this.maximumWorld,r=i.x,o=i.y,a=i.z,s=n.x,c=n.y,l=n.z,u=e.x,h=e.y,d=e.z,f=t.x,p=t.y,_=t.z;return!(s<u||r>f)&&(!(c<h||o>p)&&!(l<d||a>_))},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,i,n,o){var a=e.TmpVector3[0];return r.e.ClampToRef(n,t,i,a),r.e.DistanceSquared(n,a)<=o*o},e.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;++i)for(var n=t[i],r=0;r<8;++r)if(n.dotCoordinate(e[r])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var i=0;i<6;++i){for(var n=!0,r=t[i],o=0;o<8;++o)if(r.dotCoordinate(e[o])>=0){n=!1;break}if(n)return!1}return!0},e.TmpVector3=n.a.BuildArray(3,r.e.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(38),r=function(){function e(){}return e.SetImmediate=function(e){n.a.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(0),r=i(2),o=function(){function e(){this.previousWorldMatrices={},this.previousBones={}}return e.AddUniforms=function(e){e.push("previousWorld","previousViewProjection")},e.AddSamplers=function(e){},e.prototype.bindForSubMesh=function(e,t,i,o,a){t.prePassRenderer&&t.prePassRenderer.enabled&&-1!==t.prePassRenderer.getIndex(r.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(this.previousWorldMatrices[i.uniqueId]||(this.previousWorldMatrices[i.uniqueId]=n.a.Identity()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix()),e.setMatrix("previousWorld",this.previousWorldMatrices[i.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[i.uniqueId]=o.clone(),this.previousViewProjection=t.getTransformMatrix().clone())},e}()},function(e,t,i){"use strict";var n="lightFragmentDeclaration",r="#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec4 vLightSpecular{X};\n#else\nvec4 vLightSpecular{X}=vec4(0.);\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif 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[n]=r},function(e,t,i){"use strict";var n="lightUboDeclaration",r="#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec4 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#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float viewFrustumZ{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float frustumLengths{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float cascadeBlendFactor{X};\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\nuniform highp sampler2DArray depthSampler{X};\nuniform vec2 lightSizeUVCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float depthCorrection{X}[SHADOWCSMNUM_CASCADES{X}];\nuniform float penumbraDarkness{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DArrayShadow shadowSampler{X};\n#else\nuniform highp sampler2DArray shadowSampler{X};\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nconst vec3 vCascadeColorsMultiplier{X}[8]=vec3[8]\n(\nvec3 ( 1.5,0.0,0.0 ),\nvec3 ( 0.0,1.5,0.0 ),\nvec3 ( 0.0,0.0,5.5 ),\nvec3 ( 1.5,0.0,5.5 ),\nvec3 ( 1.5,1.5,0.0 ),\nvec3 ( 1.0,1.0,1.0 ),\nvec3 ( 0.0,1.0,5.5 ),\nvec3 ( 0.5,3.5,0.75 )\n);\nvec3 shadowDebug{X};\n#endif\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nint index{X}=-1;\n#else\nint index{X}=SHADOWCSMNUM_CASCADES{X}-1;\n#endif\nfloat diff{X}=0.;\n#elif 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[n]=r},function(e,t,i){"use strict";var n="imageProcessingDeclaration",r="#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[n]=r},function(e,t,i){"use strict";var n="imageProcessingFunctions",r="#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\n#define inline\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=saturate(sliceUV);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=saturate(sliceUV);\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=saturate(color);\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=saturate(result.rgb);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=result.rgb*result.rgb*(3.0-2.0*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[n]=r},function(e,t,i){"use strict";var n="clipPlaneFragment",r="#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\n#ifdef CLIPPLANE5\nif (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nif (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="clipPlaneVertex",r="#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\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,vClipPlane6);\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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=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:!1,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,"a",(function(){return o}));var n=i(44),r=i(0),o=function(){function e(e,t,i){this.center=r.e.Zero(),this.centerWorld=r.e.Zero(),this.minimum=r.e.Zero(),this.maximum=r.e.Zero(),this.reConstruct(e,t,i)}return e.prototype.reConstruct=function(e,t,i){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var n=r.e.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*n,this._update(i||r.a.IdentityReadOnly)},e.prototype.scale=function(t){var i=this.radius*t,n=e.TmpVector3,r=n[0].setAll(i),o=this.center.subtractToRef(r,n[1]),a=this.center.addToRef(r,n[2]);return this.reConstruct(o,a,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{r.e.TransformCoordinatesToRef(this.center,t,this.centerWorld);var i=e.TmpVector3[0];r.e.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,n=0;n<6;n++)if(e[n].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=r.e.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld<t)},e.Intersects=function(e,t){var i=r.e.DistanceSquared(e.centerWorld,t.centerWorld),n=e.radiusWorld+t.radiusWorld;return!(n*n<i)},e.TmpVector3=n.a.BuildArray(3,r.e.Zero),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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";var n="clipPlaneFragmentDeclaration",r="#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\n#ifdef CLIPPLANE5\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nvarying float fClipDistance6;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="logDepthDeclaration",r="#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="clipPlaneVertexDeclaration",r="#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\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;\nvarying float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;\nvarying float fClipDistance6;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.prototype.attributeProcessor=function(e){return e.replace("attribute","in")},e.prototype.varyingProcessor=function(e,t){return e.replace("varying",t?"in":"out")},e.prototype.postProcessor=function(e,t,i){var n=-1!==e.search(/#extension.+GL_EXT_draw_buffers.+require/);if(e=(e=e.replace(/#extension.+(GL_OVR_multiview2|GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"")).replace(/texture2D\s*\(/g,"texture("),i)e=(e=(e=(e=(e=(e=(e=e.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(");else if(-1!==t.indexOf("#define MULTIVIEW"))return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e;return e},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return 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)}if(t.clipPlane5){i=t.clipPlane5;e.setFloat4("vClipPlane5",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane6){i=t.clipPlane6;e.setFloat4("vClipPlane6",i.normal.x,i.normal.y,i.normal.z,i.d)}},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return 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}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(1),r=i(3),o=i(9),a=function(){function e(){this._dirty=!0,this._tempColor=new o.b(0,0,0,0),this._globalCurve=new o.b(0,0,0,0),this._highlightsCurve=new o.b(0,0,0,0),this._midtonesCurve=new o.b(0,0,0,0),this._shadowsCurve=new o.b(0,0,0,0),this._positiveCurve=new o.b(0,0,0,0),this._negativeCurve=new o.b(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:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"globalExposure",{get:function(){return this._globalExposure},set:function(e){this._globalExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"ColorCurves"},e.Bind=function(e,t,i,n,r){void 0===i&&(i="vCameraColorCurvePositive"),void 0===n&&(n="vCameraColorCurveNeutral"),void 0===r&&(r="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(n,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(r,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,n,r,o){null!=t&&(t=e.clamp(t,0,360),i=e.clamp(i,-100,100),n=e.clamp(n,-100,100),r=e.clamp(r,-100,100),i=e.applyColorGradingSliderNonlinear(i),i*=.5,r=e.applyColorGradingSliderNonlinear(r),i<0&&(i*=-1,t=(t+180)%360),e.fromHSBToRef(t,i,50+.25*r,o),o.scaleToRef(2,o),o.a=1+.01*n)},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,n,r){var o=e.clamp(t,0,360),a=e.clamp(i/100,0,1),s=e.clamp(n/100,0,1);if(0===a)r.r=s,r.g=s,r.b=s;else{o/=60;var c=Math.floor(o),l=o-c,u=s*(1-a),h=s*(1-a*l),d=s*(1-a*(1-l));switch(c){case 0:r.r=s,r.g=d,r.b=u;break;case 1:r.r=h,r.g=s,r.b=u;break;case 2:r.r=u,r.g=s,r.b=d;break;case 3:r.r=u,r.g=h,r.b=s;break;case 4:r.r=d,r.g=u,r.b=s;break;default:r.r=s,r.g=u,r.b=h}}r.a=1},e.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},e.prototype.clone=function(){return r.a.Clone((function(){return new e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.Parse=function(t){return r.a.Parse((function(){return new e}),t,null,null)},Object(n.c)([Object(r.c)()],e.prototype,"_globalHue",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_globalDensity",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_globalSaturation",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_globalExposure",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_highlightsHue",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_highlightsDensity",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_highlightsSaturation",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_highlightsExposure",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_midtonesHue",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_midtonesDensity",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_midtonesSaturation",void 0),Object(n.c)([Object(r.c)()],e.prototype,"_midtonesExposure",void 0),e}();r.a._ColorCurvesParser=a.Parse},function(e,t,i){"use strict";i.d(t,"a",(function(){return o}));var n=i(8),r=i(11),o=function(){function e(){}return e.Instantiate=function(e){if(this.RegisteredExternalClasses&&this.RegisteredExternalClasses[e])return this.RegisteredExternalClasses[e];var t=r.a.GetClass(e);if(t)return t;n.a.Warn(e+" not found, you may have missed an import.");for(var i=e.split("."),o=window||this,a=0,s=i.length;a<s;a++)o=o[i[a]];return"function"!=typeof o?null:o},e.RegisteredExternalClasses={},e}()},function(e,t,i){"use strict";var n=i(26),r=i(2);n.a.prototype.setAlphaConstants=function(e,t,i,n){this._alphaState.setAlphaBlendConstants(e,t,i,n)},n.a.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case r.a.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case r.a.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 r.a.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 r.a.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 r.a.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case r.a.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case r.a.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 r.a.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case r.a.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 r.a.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 r.a.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;break;case r.a.ALPHA_ONEONE_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case r.a.ALPHA_ALPHATOCOLOR:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case r.a.ALPHA_REVERSEONEMINUS:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE_MINUS_DST_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case r.a.ALPHA_SRC_DSTONEMINUSSRCALPHA: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 r.a.ALPHA_ONEONE_ONEZERO:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ONE,this._gl.ZERO),this._alphaState.alphaBlend=!0;break;case r.a.ALPHA_EXCLUSION:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE_MINUS_DST_COLOR,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0}t||(this.depthCullingState.depthMask=e===r.a.ALPHA_DISABLE),this._alphaMode=e}},n.a.prototype.getAlphaMode=function(){return this._alphaMode},n.a.prototype.setAlphaEquation=function(e){if(this._alphaEquation!==e){switch(e){case r.a.ALPHA_EQUATION_ADD:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_ADD,this._gl.FUNC_ADD);break;case r.a.ALPHA_EQUATION_SUBSTRACT:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_SUBTRACT,this._gl.FUNC_SUBTRACT);break;case r.a.ALPHA_EQUATION_REVERSE_SUBTRACT:this._alphaState.setAlphaEquationParameters(this._gl.FUNC_REVERSE_SUBTRACT,this._gl.FUNC_REVERSE_SUBTRACT);break;case r.a.ALPHA_EQUATION_MAX:this._alphaState.setAlphaEquationParameters(this._gl.MAX,this._gl.MAX);break;case r.a.ALPHA_EQUATION_MIN:this._alphaState.setAlphaEquationParameters(this._gl.MIN,this._gl.MIN);break;case r.a.ALPHA_EQUATION_DARKEN:this._alphaState.setAlphaEquationParameters(this._gl.MIN,this._gl.FUNC_ADD)}this._alphaEquation=e}},n.a.prototype.getAlphaEquation=function(){return this._alphaEquation}},function(e,t,i){"use strict";var n=i(26);n.a.prototype.updateDynamicIndexBuffer=function(e,t,i){var n;void 0===i&&(i=0),this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),n=t instanceof Uint16Array||t instanceof Uint32Array?t:e.is32Bits?new Uint32Array(t):new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,n,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},n.a.prototype.updateDynamicVertexBuffer=function(e,t,i,n){this.bindArrayBuffer(e),void 0===i&&(i=0);var r=t.length||t.byteLength;void 0===n||n>=r&&0===i?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+n)):(t=t instanceof ArrayBuffer?new Uint8Array(t,i,n):new Uint8Array(t.buffer,t.byteOffset+i,n),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()}},function(e,t,i){"use strict";var n="fogFragmentDeclaration",r="#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[n]=r},function(e,t,i){"use strict";var n=i(26),r=i(27);n.a.prototype.createDynamicTexture=function(e,t,i,o){var a=new r.a(this,r.b.Dynamic);return a.baseWidth=e,a.baseHeight=t,i&&(e=this.needPOTTextures?n.a.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?n.a.GetExponentOfTwo(t,this._caps.maxTextureSize):t),a.width=e,a.height=t,a.isReady=!1,a.generateMipMaps=i,a.samplingMode=o,this.updateTextureSamplingMode(o,a),this._internalTexturesCache.push(a),a},n.a.prototype.updateDynamicTexture=function(e,t,i,n,r,o){if(void 0===n&&(n=!1),void 0===o&&(o=!1),e){var a=this._gl,s=a.TEXTURE_2D,c=this._bindTextureDirectly(s,e,!0,o);this._unpackFlipY(void 0===i?e.invertY:i),n&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var l=this._getWebGLTextureType(e.type),u=this._getInternalFormat(r||e.format),h=this._getRGBABufferInternalSizedFormat(e.type,u);a.texImage2D(s,0,h,u,l,t),e.generateMipMaps&&a.generateMipmap(s),c||this._bindTextureDirectly(s,null),n&&a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}}},function(e,t,i){"use strict";i.r(t),i.d(t,"AbstractScene",(function(){return n.a})),i.d(t,"AbstractActionManager",(function(){return r.a})),i.d(t,"Action",(function(){return l})),i.d(t,"ActionEvent",(function(){return u.a})),i.d(t,"ActionManager",(function(){return M})),i.d(t,"Condition",(function(){return d})),i.d(t,"ValueCondition",(function(){return f})),i.d(t,"PredicateCondition",(function(){return p})),i.d(t,"StateCondition",(function(){return _})),i.d(t,"SwitchBooleanAction",(function(){return v})),i.d(t,"SetStateAction",(function(){return b})),i.d(t,"SetValueAction",(function(){return y})),i.d(t,"IncrementValueAction",(function(){return T})),i.d(t,"PlayAnimationAction",(function(){return E})),i.d(t,"StopAnimationAction",(function(){return S})),i.d(t,"DoNothingAction",(function(){return A})),i.d(t,"CombineAction",(function(){return P})),i.d(t,"ExecuteCodeAction",(function(){return C})),i.d(t,"SetParentAction",(function(){return R})),i.d(t,"PlaySoundAction",(function(){return I})),i.d(t,"StopSoundAction",(function(){return D})),i.d(t,"InterpolateValueAction",(function(){return G})),i.d(t,"Animatable",(function(){return ee})),i.d(t,"_IAnimationState",(function(){return k})),i.d(t,"Animation",(function(){return z})),i.d(t,"TargetedAnimation",(function(){return te})),i.d(t,"AnimationGroup",(function(){return ie})),i.d(t,"AnimationPropertiesOverride",(function(){return ne})),i.d(t,"EasingFunction",(function(){return oe})),i.d(t,"CircleEase",(function(){return ae})),i.d(t,"BackEase",(function(){return se})),i.d(t,"BounceEase",(function(){return ce})),i.d(t,"CubicEase",(function(){return le})),i.d(t,"ElasticEase",(function(){return ue})),i.d(t,"ExponentialEase",(function(){return he})),i.d(t,"PowerEase",(function(){return de})),i.d(t,"QuadraticEase",(function(){return fe})),i.d(t,"QuarticEase",(function(){return pe})),i.d(t,"QuinticEase",(function(){return _e})),i.d(t,"SineEase",(function(){return me})),i.d(t,"BezierCurveEase",(function(){return ge})),i.d(t,"RuntimeAnimation",(function(){return K})),i.d(t,"AnimationEvent",(function(){return ve})),i.d(t,"AnimationKeyInterpolation",(function(){return N})),i.d(t,"AnimationRange",(function(){return F})),i.d(t,"KeepAssets",(function(){return ye})),i.d(t,"InstantiatedEntries",(function(){return Te})),i.d(t,"AssetContainer",(function(){return Ee})),i.d(t,"Analyser",(function(){return Ae})),i.d(t,"AudioEngine",(function(){return Pe})),i.d(t,"AudioSceneComponent",(function(){return Ie})),i.d(t,"Sound",(function(){return xe})),i.d(t,"SoundTrack",(function(){return Oe})),i.d(t,"WeightedSound",(function(){return De})),i.d(t,"AutoRotationBehavior",(function(){return Le})),i.d(t,"BouncingBehavior",(function(){return we})),i.d(t,"FramingBehavior",(function(){return Fe})),i.d(t,"AttachToBoxBehavior",(function(){return Ue})),i.d(t,"FadeInOutBehavior",(function(){return Ve})),i.d(t,"MultiPointerScaleBehavior",(function(){return ze})),i.d(t,"PointerDragBehavior",(function(){return ke.a})),i.d(t,"SixDofDragBehavior",(function(){return He})),i.d(t,"Bone",(function(){return $})),i.d(t,"BoneIKController",(function(){return Xe})),i.d(t,"BoneLookController",(function(){return Ye})),i.d(t,"Skeleton",(function(){return tt})),i.d(t,"ArcRotateCameraGamepadInput",(function(){return st})),i.d(t,"ArcRotateCameraKeyboardMoveInput",(function(){return lt})),i.d(t,"ArcRotateCameraMouseWheelInput",(function(){return ut})),i.d(t,"ArcRotateCameraPointersInput",(function(){return dt})),i.d(t,"ArcRotateCameraVRDeviceOrientationInput",(function(){return pt})),i.d(t,"FlyCameraKeyboardInput",(function(){return _t})),i.d(t,"FlyCameraMouseInput",(function(){return mt})),i.d(t,"FollowCameraKeyboardMoveInput",(function(){return gt})),i.d(t,"FollowCameraMouseWheelInput",(function(){return vt})),i.d(t,"FollowCameraPointersInput",(function(){return bt})),i.d(t,"FreeCameraDeviceOrientationInput",(function(){return Rt})),i.d(t,"FreeCameraGamepadInput",(function(){return xt})),i.d(t,"FreeCameraKeyboardMoveInput",(function(){return yt})),i.d(t,"FreeCameraMouseInput",(function(){return Tt})),i.d(t,"FreeCameraMouseWheelInput",(function(){return At})),i.d(t,"FreeCameraTouchInput",(function(){return Pt})),i.d(t,"FreeCameraVirtualJoystickInput",(function(){return Dt})),i.d(t,"CameraInputTypes",(function(){return it})),i.d(t,"CameraInputsManager",(function(){return nt})),i.d(t,"Camera",(function(){return je.a})),i.d(t,"TargetCamera",(function(){return Lt})),i.d(t,"FreeCamera",(function(){return wt})),i.d(t,"FreeCameraInputsManager",(function(){return Ct})),i.d(t,"TouchCamera",(function(){return Ft})),i.d(t,"ArcRotateCamera",(function(){return Bt})),i.d(t,"ArcRotateCameraInputsManager",(function(){return ft})),i.d(t,"DeviceOrientationCamera",(function(){return Ut})),i.d(t,"FlyCamera",(function(){return kt})),i.d(t,"FlyCameraInputsManager",(function(){return Vt})),i.d(t,"FollowCamera",(function(){return jt})),i.d(t,"ArcFollowCamera",(function(){return Wt})),i.d(t,"FollowCameraInputsManager",(function(){return zt})),i.d(t,"GamepadCamera",(function(){return ri})),i.d(t,"AnaglyphArcRotateCamera",(function(){return mi})),i.d(t,"AnaglyphFreeCamera",(function(){return gi})),i.d(t,"AnaglyphGamepadCamera",(function(){return vi})),i.d(t,"AnaglyphUniversalCamera",(function(){return bi})),i.d(t,"StereoscopicArcRotateCamera",(function(){return Ti})),i.d(t,"StereoscopicFreeCamera",(function(){return Ei})),i.d(t,"StereoscopicGamepadCamera",(function(){return Si})),i.d(t,"StereoscopicUniversalCamera",(function(){return Ai})),i.d(t,"UniversalCamera",(function(){return ni})),i.d(t,"VirtualJoysticksCamera",(function(){return Pi})),i.d(t,"VRCameraMetrics",(function(){return Ci})),i.d(t,"VRDeviceOrientationArcRotateCamera",(function(){return Bi})),i.d(t,"VRDeviceOrientationFreeCamera",(function(){return Ui})),i.d(t,"VRDeviceOrientationGamepadCamera",(function(){return Vi})),i.d(t,"OnAfterEnteringVRObservableEvent",(function(){return hn})),i.d(t,"VRExperienceHelper",(function(){return dn})),i.d(t,"WebVRFreeCamera",(function(){return zi})),i.d(t,"Collider",(function(){return _n})),i.d(t,"DefaultCollisionCoordinator",(function(){return mn})),i.d(t,"PickingInfo",(function(){return gn.a})),i.d(t,"IntersectionInfo",(function(){return vn.a})),i.d(t,"_MeshCollisionData",(function(){return bn.a})),i.d(t,"BoundingBox",(function(){return yn.a})),i.d(t,"BoundingInfo",(function(){return Tn.a})),i.d(t,"BoundingSphere",(function(){return En.a})),i.d(t,"Octree",(function(){return An})),i.d(t,"OctreeBlock",(function(){return Sn})),i.d(t,"OctreeSceneComponent",(function(){return Mn})),i.d(t,"Ray",(function(){return Xt.a})),i.d(t,"AxesViewer",(function(){return In.AxesViewer})),i.d(t,"BoneAxesViewer",(function(){return In.BoneAxesViewer})),i.d(t,"DebugLayerTab",(function(){return In.DebugLayerTab})),i.d(t,"DebugLayer",(function(){return In.DebugLayer})),i.d(t,"PhysicsViewer",(function(){return In.PhysicsViewer})),i.d(t,"RayHelper",(function(){return In.RayHelper})),i.d(t,"SkeletonViewer",(function(){return In.SkeletonViewer})),i.d(t,"DeviceInputSystem",(function(){return Dn})),i.d(t,"DeviceType",(function(){return Pn})),i.d(t,"PointerInput",(function(){return Cn})),i.d(t,"DualShockInput",(function(){return Rn})),i.d(t,"XboxInput",(function(){return xn})),i.d(t,"SwitchInput",(function(){return On})),i.d(t,"DeviceSource",(function(){return Nn})),i.d(t,"DeviceSourceManager",(function(){return Ln})),i.d(t,"Constants",(function(){return g.a})),i.d(t,"ThinEngine",(function(){return qe.a})),i.d(t,"Engine",(function(){return Se.a})),i.d(t,"EngineStore",(function(){return x.a})),i.d(t,"NullEngineOptions",(function(){return wn.b})),i.d(t,"NullEngine",(function(){return wn.a})),i.d(t,"_OcclusionDataStorage",(function(){return Bn})),i.d(t,"_forceTransformFeedbackToBundle",(function(){return Un})),i.d(t,"EngineView",(function(){return kn})),i.d(t,"WebGLPipelineContext",(function(){return Gn.a})),i.d(t,"WebGL2ShaderProcessor",(function(){return jn.a})),i.d(t,"NativeEngine",(function(){return cr})),i.d(t,"ShaderCodeInliner",(function(){return rr})),i.d(t,"PerformanceConfigurator",(function(){return lr.a})),i.d(t,"KeyboardEventTypes",(function(){return ct.a})),i.d(t,"KeyboardInfo",(function(){return ct.b})),i.d(t,"KeyboardInfoPre",(function(){return ct.c})),i.d(t,"PointerEventTypes",(function(){return Ne.a})),i.d(t,"PointerInfoBase",(function(){return Ne.c})),i.d(t,"PointerInfoPre",(function(){return Ne.d})),i.d(t,"PointerInfo",(function(){return Ne.b})),i.d(t,"ClipboardEventTypes",(function(){return ur})),i.d(t,"ClipboardInfo",(function(){return hr})),i.d(t,"DaydreamController",(function(){return _r})),i.d(t,"GearVRController",(function(){return mr})),i.d(t,"GenericController",(function(){return gr})),i.d(t,"OculusTouchController",(function(){return vr})),i.d(t,"PoseEnabledControllerType",(function(){return Gt})),i.d(t,"PoseEnabledControllerHelper",(function(){return Qt})),i.d(t,"PoseEnabledController",(function(){return qt})),i.d(t,"ViveController",(function(){return br})),i.d(t,"WebVRController",(function(){return Gi})),i.d(t,"WindowsMotionController",(function(){return Tr})),i.d(t,"XRWindowsMotionController",(function(){return Er})),i.d(t,"StickValues",(function(){return rt})),i.d(t,"Gamepad",(function(){return ot})),i.d(t,"GenericPad",(function(){return at})),i.d(t,"GamepadManager",(function(){return ti})),i.d(t,"GamepadSystemSceneComponent",(function(){return ii})),i.d(t,"Xbox360Button",(function(){return Yt})),i.d(t,"Xbox360Dpad",(function(){return Kt})),i.d(t,"Xbox360Pad",(function(){return $t})),i.d(t,"DualShockButton",(function(){return Zt})),i.d(t,"DualShockDpad",(function(){return Jt})),i.d(t,"DualShockPad",(function(){return ei})),i.d(t,"AxisDragGizmo",(function(){return Sr.a})),i.d(t,"AxisScaleGizmo",(function(){return Rr})),i.d(t,"BoundingBoxGizmo",(function(){return Mr})),i.d(t,"Gizmo",(function(){return Pr.a})),i.d(t,"GizmoManager",(function(){return Vr})),i.d(t,"PlaneRotationGizmo",(function(){return Ir})),i.d(t,"PositionGizmo",(function(){return Fr})),i.d(t,"RotationGizmo",(function(){return Dr})),i.d(t,"ScaleGizmo",(function(){return Ur})),i.d(t,"LightGizmo",(function(){return Hr})),i.d(t,"CameraGizmo",(function(){return Kr})),i.d(t,"PlaneDragGizmo",(function(){return wr})),i.d(t,"EnvironmentHelper",(function(){return go})),i.d(t,"PhotoDome",(function(){return bo})),i.d(t,"_forceSceneHelpersToBundle",(function(){return es})),i.d(t,"VideoDome",(function(){return is})),i.d(t,"EngineInstrumentation",(function(){return rs})),i.d(t,"SceneInstrumentation",(function(){return os})),i.d(t,"_TimeToken",(function(){return Fn})),i.d(t,"EffectLayer",(function(){return cs})),i.d(t,"EffectLayerSceneComponent",(function(){return ls})),i.d(t,"GlowLayer",(function(){return ds})),i.d(t,"HighlightLayer",(function(){return _s})),i.d(t,"Layer",(function(){return bs})),i.d(t,"LayerSceneComponent",(function(){return ms})),i.d(t,"LensFlare",(function(){return ys})),i.d(t,"LensFlareSystem",(function(){return Ss})),i.d(t,"LensFlareSystemSceneComponent",(function(){return As})),i.d(t,"Light",(function(){return kr.a})),i.d(t,"ShadowLight",(function(){return zr})),i.d(t,"ShadowGenerator",(function(){return Bs})),i.d(t,"CascadedShadowGenerator",(function(){return qs})),i.d(t,"ShadowGeneratorSceneComponent",(function(){return Zs})),i.d(t,"DirectionalLight",(function(){return Gr})),i.d(t,"HemisphericLight",(function(){return ki.a})),i.d(t,"PointLight",(function(){return Js})),i.d(t,"SpotLight",(function(){return Wr})),i.d(t,"DefaultLoadingScreen",(function(){return $s})),i.d(t,"_BabylonLoaderRegistered",(function(){return Tc})),i.d(t,"BabylonFileLoaderConfiguration",(function(){return Ec})),i.d(t,"SceneLoaderAnimationGroupLoadingMode",(function(){return nr})),i.d(t,"SceneLoader",(function(){return pr})),i.d(t,"SceneLoaderFlags",(function(){return fr.a})),i.d(t,"BackgroundMaterial",(function(){return mo})),i.d(t,"ColorCurves",(function(){return xc.a})),i.d(t,"EffectFallbacks",(function(){return po.a})),i.d(t,"Effect",(function(){return ai.a})),i.d(t,"FresnelParameters",(function(){return Oc})),i.d(t,"ImageProcessingConfigurationDefines",(function(){return ji.b})),i.d(t,"ImageProcessingConfiguration",(function(){return ji.a})),i.d(t,"Material",(function(){return xo.a})),i.d(t,"MaterialDefines",(function(){return oo.a})),i.d(t,"ThinMaterialHelper",(function(){return Mc.a})),i.d(t,"MaterialHelper",(function(){return ro.a})),i.d(t,"MultiMaterial",(function(){return tc.a})),i.d(t,"PBRMaterialDefines",(function(){return pa})),i.d(t,"PBRBaseMaterial",(function(){return _a})),i.d(t,"PBRBaseSimpleMaterial",(function(){return Ic})),i.d(t,"PBRMaterial",(function(){return ma})),i.d(t,"PBRMetallicRoughnessMaterial",(function(){return Dc})),i.d(t,"PBRSpecularGlossinessMaterial",(function(){return Nc})),i.d(t,"PushMaterial",(function(){return ao.a})),i.d(t,"ShaderMaterial",(function(){return Lc.a})),i.d(t,"StandardMaterialDefines",(function(){return Wi.b})),i.d(t,"StandardMaterial",(function(){return Wi.a})),i.d(t,"BaseTexture",(function(){return Zn.a})),i.d(t,"ColorGradingTexture",(function(){return wc})),i.d(t,"CubeTexture",(function(){return no})),i.d(t,"DynamicTexture",(function(){return Hi.a})),i.d(t,"EquiRectangularCubeTexture",(function(){return Fc})),i.d(t,"HDRFiltering",(function(){return cc})),i.d(t,"HDRCubeTexture",(function(){return lc})),i.d(t,"HtmlElementTexture",(function(){return Bc})),i.d(t,"InternalTextureSource",(function(){return Qe.b})),i.d(t,"InternalTexture",(function(){return Qe.a})),i.d(t,"_DDSTextureLoader",(function(){return Sa})),i.d(t,"_ENVTextureLoader",(function(){return Aa})),i.d(t,"_KTXTextureLoader",(function(){return Oa})),i.d(t,"_TGATextureLoader",(function(){return Vc})),i.d(t,"_BasisTextureLoader",(function(){return Wc})),i.d(t,"MirrorTexture",(function(){return to})),i.d(t,"MultiRenderTarget",(function(){return Hc})),i.d(t,"TexturePacker",(function(){return Yc})),i.d(t,"TexturePackerFrame",(function(){return Xc})),i.d(t,"CustomProceduralTexture",(function(){return Zc})),i.d(t,"NoiseProceduralTexture",(function(){return $c})),i.d(t,"ProceduralTexture",(function(){return qc})),i.d(t,"ProceduralTextureSceneComponent",(function(){return Kc})),i.d(t,"RawCubeTexture",(function(){return sl})),i.d(t,"RawTexture",(function(){return et})),i.d(t,"RawTexture2DArray",(function(){return cl})),i.d(t,"RawTexture3D",(function(){return ll})),i.d(t,"RefractionTexture",(function(){return ul})),i.d(t,"RenderTargetTexture",(function(){return Ni})),i.d(t,"Texture",(function(){return Ke.a})),i.d(t,"VideoTexture",(function(){return ts})),i.d(t,"UniformBuffer",(function(){return Mi.a})),i.d(t,"MaterialFlags",(function(){return so.a})),i.d(t,"NodeMaterialBlockTargets",(function(){return el})),i.d(t,"NodeMaterialBlockConnectionPointTypes",(function(){return tl})),i.d(t,"NodeMaterialBlockConnectionPointMode",(function(){return il})),i.d(t,"NodeMaterialSystemValues",(function(){return nl})),i.d(t,"NodeMaterialModes",(function(){return rl})),i.d(t,"NodeMaterialConnectionPointCompatibilityStates",(function(){return ol})),i.d(t,"NodeMaterialConnectionPointDirection",(function(){return al})),i.d(t,"NodeMaterialConnectionPoint",(function(){return hl})),i.d(t,"NodeMaterialBlock",(function(){return fl})),i.d(t,"NodeMaterialDefines",(function(){return Ql})),i.d(t,"NodeMaterial",(function(){return ql})),i.d(t,"VertexOutputBlock",(function(){return gl})),i.d(t,"BonesBlock",(function(){return Zl})),i.d(t,"InstancesBlock",(function(){return Jl})),i.d(t,"MorphTargetsBlock",(function(){return $l})),i.d(t,"LightInformationBlock",(function(){return eu})),i.d(t,"FragmentOutputBlock",(function(){return bl})),i.d(t,"ImageProcessingBlock",(function(){return tu})),i.d(t,"PerturbNormalBlock",(function(){return iu})),i.d(t,"DiscardBlock",(function(){return nu})),i.d(t,"FrontFacingBlock",(function(){return ru})),i.d(t,"DerivativeBlock",(function(){return ou})),i.d(t,"FragCoordBlock",(function(){return au})),i.d(t,"ScreenSizeBlock",(function(){return su})),i.d(t,"FogBlock",(function(){return cu})),i.d(t,"LightBlock",(function(){return lu})),i.d(t,"TextureBlock",(function(){return uu})),i.d(t,"ReflectionTextureBlock",(function(){return du})),i.d(t,"CurrentScreenBlock",(function(){return Al})),i.d(t,"InputBlock",(function(){return Sl})),i.d(t,"AnimatedInputBlockTypes",(function(){return vl})),i.d(t,"MultiplyBlock",(function(){return Dl})),i.d(t,"AddBlock",(function(){return fu})),i.d(t,"ScaleBlock",(function(){return pu})),i.d(t,"ClampBlock",(function(){return _u})),i.d(t,"CrossBlock",(function(){return mu})),i.d(t,"DotBlock",(function(){return gu})),i.d(t,"TransformBlock",(function(){return ml})),i.d(t,"RemapBlock",(function(){return Il})),i.d(t,"NormalizeBlock",(function(){return vu})),i.d(t,"TrigonometryBlockOperations",(function(){return Hl})),i.d(t,"TrigonometryBlock",(function(){return Yl})),i.d(t,"ColorMergerBlock",(function(){return bu})),i.d(t,"VectorMergerBlock",(function(){return Ol})),i.d(t,"ColorSplitterBlock",(function(){return Wl})),i.d(t,"VectorSplitterBlock",(function(){return yu})),i.d(t,"LerpBlock",(function(){return Tu})),i.d(t,"DivideBlock",(function(){return Eu})),i.d(t,"SubtractBlock",(function(){return Su})),i.d(t,"StepBlock",(function(){return Au})),i.d(t,"OneMinusBlock",(function(){return Pu})),i.d(t,"ViewDirectionBlock",(function(){return Cu})),i.d(t,"FresnelBlock",(function(){return Ru})),i.d(t,"MaxBlock",(function(){return xu})),i.d(t,"MinBlock",(function(){return Ou})),i.d(t,"DistanceBlock",(function(){return Mu})),i.d(t,"LengthBlock",(function(){return Iu})),i.d(t,"NegateBlock",(function(){return Du})),i.d(t,"PowBlock",(function(){return Nu})),i.d(t,"RandomNumberBlock",(function(){return Lu})),i.d(t,"ArcTan2Block",(function(){return wu})),i.d(t,"SmoothStepBlock",(function(){return Fu})),i.d(t,"ReciprocalBlock",(function(){return Bu})),i.d(t,"ReplaceColorBlock",(function(){return Uu})),i.d(t,"PosterizeBlock",(function(){return ku})),i.d(t,"WaveBlockKind",(function(){return Vu})),i.d(t,"WaveBlock",(function(){return zu})),i.d(t,"GradientBlockColorStep",(function(){return Gu})),i.d(t,"GradientBlock",(function(){return ju})),i.d(t,"NLerpBlock",(function(){return Wu})),i.d(t,"WorleyNoise3DBlock",(function(){return Hu})),i.d(t,"SimplexPerlin3DBlock",(function(){return Xu})),i.d(t,"NormalBlendBlock",(function(){return Yu})),i.d(t,"Rotate2dBlock",(function(){return Ku})),i.d(t,"ReflectBlock",(function(){return Qu})),i.d(t,"RefractBlock",(function(){return qu})),i.d(t,"DesaturateBlock",(function(){return Zu})),i.d(t,"PBRMetallicRoughnessBlock",(function(){return ah})),i.d(t,"SheenBlock",(function(){return $u})),i.d(t,"AnisotropyBlock",(function(){return eh})),i.d(t,"ReflectionBlock",(function(){return th})),i.d(t,"ClearCoatBlock",(function(){return ih})),i.d(t,"RefractionBlock",(function(){return nh})),i.d(t,"SubSurfaceBlock",(function(){return rh})),i.d(t,"ParticleTextureBlock",(function(){return Pl})),i.d(t,"ParticleRampGradientBlock",(function(){return Cl})),i.d(t,"ParticleBlendMultiplyBlock",(function(){return Rl})),i.d(t,"ModBlock",(function(){return sh})),i.d(t,"NodeMaterialOptimizer",(function(){return ch})),i.d(t,"PropertyTypeForEdition",(function(){return xl})),i.d(t,"editableInPropertyPage",(function(){return Ml})),i.d(t,"EffectRenderer",(function(){return rc})),i.d(t,"EffectWrapper",(function(){return oc})),i.d(t,"ShadowDepthWrapper",(function(){return hh})),i.d(t,"Scalar",(function(){return L.a})),i.d(t,"extractMinAndMaxIndexed",(function(){return dh.b})),i.d(t,"extractMinAndMax",(function(){return dh.a})),i.d(t,"Space",(function(){return J.c})),i.d(t,"Axis",(function(){return J.a})),i.d(t,"Coordinate",(function(){return J.b})),i.d(t,"Color3",(function(){return s.a})),i.d(t,"Color4",(function(){return s.b})),i.d(t,"TmpColors",(function(){return s.c})),i.d(t,"ToGammaSpace",(function(){return Nt.b})),i.d(t,"ToLinearSpace",(function(){return Nt.c})),i.d(t,"Epsilon",(function(){return Nt.a})),i.d(t,"Frustum",(function(){return wi.a})),i.d(t,"Orientation",(function(){return re.e})),i.d(t,"BezierCurve",(function(){return re.c})),i.d(t,"Angle",(function(){return re.a})),i.d(t,"Arc2",(function(){return re.b})),i.d(t,"Path2",(function(){return re.f})),i.d(t,"Path3D",(function(){return re.g})),i.d(t,"Curve3",(function(){return re.d})),i.d(t,"Plane",(function(){return fn.a})),i.d(t,"Size",(function(){return U.a})),i.d(t,"Vector2",(function(){return a.d})),i.d(t,"Vector3",(function(){return a.e})),i.d(t,"Vector4",(function(){return a.f})),i.d(t,"Quaternion",(function(){return a.b})),i.d(t,"Matrix",(function(){return a.a})),i.d(t,"TmpVectors",(function(){return a.c})),i.d(t,"PositionNormalVertex",(function(){return Xr})),i.d(t,"PositionNormalTextureVertex",(function(){return Yr})),i.d(t,"Viewport",(function(){return yi.a})),i.d(t,"SphericalHarmonics",(function(){return Qn})),i.d(t,"SphericalPolynomial",(function(){return qn})),i.d(t,"AbstractMesh",(function(){return Ge.a})),i.d(t,"Buffer",(function(){return Qi.a})),i.d(t,"VertexBuffer",(function(){return Qi.b})),i.d(t,"DracoCompression",(function(){return mh})),i.d(t,"CSG",(function(){return Sh})),i.d(t,"Geometry",(function(){return ec.a})),i.d(t,"GroundMesh",(function(){return qi})),i.d(t,"TrailMesh",(function(){return Ah})),i.d(t,"InstancedMesh",(function(){return Ph.a})),i.d(t,"LinesMesh",(function(){return Ch.b})),i.d(t,"InstancedLinesMesh",(function(){return Ch.a})),i.d(t,"_CreationDataStorage",(function(){return be.b})),i.d(t,"_InstancesBatch",(function(){return be.c})),i.d(t,"Mesh",(function(){return be.a})),i.d(t,"VertexData",(function(){return Ki.a})),i.d(t,"MeshBuilder",(function(){return jh})),i.d(t,"SimplificationSettings",(function(){return Wh})),i.d(t,"SimplificationQueue",(function(){return Hh})),i.d(t,"SimplificationType",(function(){return zh})),i.d(t,"QuadraticErrorSimplification",(function(){return qh})),i.d(t,"SimplicationQueueSceneComponent",(function(){return Zh})),i.d(t,"Polygon",(function(){return Nh})),i.d(t,"PolygonMeshBuilder",(function(){return Lh})),i.d(t,"SubMesh",(function(){return gh.a})),i.d(t,"MeshLODLevel",(function(){return Jh.a})),i.d(t,"TransformNode",(function(){return Nr.a})),i.d(t,"BoxBuilder",(function(){return Ar.a})),i.d(t,"TiledBoxBuilder",(function(){return Oh})),i.d(t,"DiscBuilder",(function(){return xh})),i.d(t,"RibbonBuilder",(function(){return Rh.a})),i.d(t,"SphereBuilder",(function(){return xr.a})),i.d(t,"HemisphereBuilder",(function(){return jr})),i.d(t,"CylinderBuilder",(function(){return nn.a})),i.d(t,"TorusBuilder",(function(){return tn})),i.d(t,"TorusKnotBuilder",(function(){return Mh})),i.d(t,"LinesBuilder",(function(){return Or.a})),i.d(t,"PolygonBuilder",(function(){return wh})),i.d(t,"ShapeBuilder",(function(){return vc.a})),i.d(t,"LatheBuilder",(function(){return Fh})),i.d(t,"PlaneBuilder",(function(){return Lr.a})),i.d(t,"TiledPlaneBuilder",(function(){return Bh})),i.d(t,"GroundBuilder",(function(){return Ji})),i.d(t,"TubeBuilder",(function(){return Uh})),i.d(t,"PolyhedronBuilder",(function(){return Br})),i.d(t,"IcoSphereBuilder",(function(){return Vh})),i.d(t,"DecalBuilder",(function(){return kh})),i.d(t,"CapsuleBuilder",(function(){return Gh})),i.d(t,"DataBuffer",(function(){return Wn.a})),i.d(t,"WebGLDataBuffer",(function(){return $h.a})),i.d(t,"MorphTarget",(function(){return uc})),i.d(t,"MorphTargetManager",(function(){return hc})),i.d(t,"RecastJSPlugin",(function(){return ed})),i.d(t,"RecastJSCrowd",(function(){return td})),i.d(t,"Node",(function(){return B.a})),i.d(t,"Database",(function(){return nd})),i.d(t,"BaseParticleSystem",(function(){return jl})),i.d(t,"BoxParticleEmitter",(function(){return Nl})),i.d(t,"ConeParticleEmitter",(function(){return Ll})),i.d(t,"CylinderParticleEmitter",(function(){return wl})),i.d(t,"CylinderDirectedParticleEmitter",(function(){return Fl})),i.d(t,"HemisphericParticleEmitter",(function(){return Bl})),i.d(t,"PointParticleEmitter",(function(){return Ul})),i.d(t,"SphereParticleEmitter",(function(){return Vl})),i.d(t,"SphereDirectedParticleEmitter",(function(){return kl})),i.d(t,"CustomParticleEmitter",(function(){return zl})),i.d(t,"MeshParticleEmitter",(function(){return Gl})),i.d(t,"GPUParticleSystem",(function(){return vd})),i.d(t,"Particle",(function(){return cd})),i.d(t,"ParticleHelper",(function(){return yd})),i.d(t,"ParticleSystem",(function(){return dd})),i.d(t,"ParticleSystemSet",(function(){return bd})),i.d(t,"SolidParticle",(function(){return Ed})),i.d(t,"ModelShape",(function(){return Sd})),i.d(t,"DepthSortedParticle",(function(){return Ad})),i.d(t,"SolidParticleVertex",(function(){return Pd})),i.d(t,"SolidParticleSystem",(function(){return Cd})),i.d(t,"CloudPoint",(function(){return Rd})),i.d(t,"PointsGroup",(function(){return xd})),i.d(t,"PointColor",(function(){return Td})),i.d(t,"PointsCloudSystem",(function(){return Od})),i.d(t,"SubEmitterType",(function(){return id})),i.d(t,"SubEmitter",(function(){return ld})),i.d(t,"PhysicsEngine",(function(){return pc})),i.d(t,"PhysicsEngineSceneComponent",(function(){return Dd})),i.d(t,"PhysicsHelper",(function(){return Nd})),i.d(t,"PhysicsRadialExplosionEventOptions",(function(){return Ud})),i.d(t,"PhysicsUpdraftEventOptions",(function(){return Vd})),i.d(t,"PhysicsVortexEventOptions",(function(){return kd})),i.d(t,"PhysicsRadialImpulseFalloff",(function(){return Md})),i.d(t,"PhysicsUpdraftMode",(function(){return Id})),i.d(t,"PhysicsImpostor",(function(){return dc.a})),i.d(t,"PhysicsJoint",(function(){return fc.e})),i.d(t,"DistanceJoint",(function(){return fc.a})),i.d(t,"MotorEnabledJoint",(function(){return fc.d})),i.d(t,"HingeJoint",(function(){return fc.c})),i.d(t,"Hinge2Joint",(function(){return fc.b})),i.d(t,"CannonJSPlugin",(function(){return mc})),i.d(t,"AmmoJSPlugin",(function(){return bc})),i.d(t,"OimoJSPlugin",(function(){return gc})),i.d(t,"AnaglyphPostProcess",(function(){return _i})),i.d(t,"BlackAndWhitePostProcess",(function(){return Gd})),i.d(t,"BloomEffect",(function(){return Kd})),i.d(t,"BloomMergePostProcess",(function(){return Yd})),i.d(t,"BlurPostProcess",(function(){return eo})),i.d(t,"ChromaticAberrationPostProcess",(function(){return qd})),i.d(t,"CircleOfConfusionPostProcess",(function(){return Jd})),i.d(t,"ColorCorrectionPostProcess",(function(){return ef})),i.d(t,"ConvolutionPostProcess",(function(){return nf})),i.d(t,"DepthOfFieldBlurPostProcess",(function(){return rf})),i.d(t,"DepthOfFieldEffectBlurLevel",(function(){return af})),i.d(t,"DepthOfFieldEffect",(function(){return lf})),i.d(t,"DepthOfFieldMergePostProcessOptions",(function(){return sf})),i.d(t,"DepthOfFieldMergePostProcess",(function(){return cf})),i.d(t,"DisplayPassPostProcess",(function(){return hf})),i.d(t,"ExtractHighlightsPostProcess",(function(){return Hd})),i.d(t,"FilterPostProcess",(function(){return ff})),i.d(t,"FxaaPostProcess",(function(){return mf})),i.d(t,"GrainPostProcess",(function(){return vf})),i.d(t,"HighlightsPostProcess",(function(){return yf})),i.d(t,"ImageProcessingPostProcess",(function(){return Yi})),i.d(t,"MotionBlurPostProcess",(function(){return Rf})),i.d(t,"PassPostProcess",(function(){return di})),i.d(t,"PassCubePostProcess",(function(){return fi})),i.d(t,"PostProcess",(function(){return li})),i.d(t,"PostProcessManager",(function(){return Ii.a})),i.d(t,"RefractionPostProcess",(function(){return Of})),i.d(t,"DefaultRenderingPipeline",(function(){return wf})),i.d(t,"LensRenderingPipeline",(function(){return Uf})),i.d(t,"SSAO2RenderingPipeline",(function(){return Gf})),i.d(t,"SSAORenderingPipeline",(function(){return Wf})),i.d(t,"StandardRenderingPipeline",(function(){return Qf})),i.d(t,"PostProcessRenderEffect",(function(){return jd})),i.d(t,"PostProcessRenderPipeline",(function(){return Df})),i.d(t,"PostProcessRenderPipelineManager",(function(){return Nf})),i.d(t,"PostProcessRenderPipelineManagerSceneComponent",(function(){return Lf})),i.d(t,"SharpenPostProcess",(function(){return If})),i.d(t,"StereoscopicInterlacePostProcessI",(function(){return Zf})),i.d(t,"StereoscopicInterlacePostProcess",(function(){return Jf})),i.d(t,"TonemappingOperator",(function(){return ep})),i.d(t,"TonemapPostProcess",(function(){return tp})),i.d(t,"VolumetricLightScatteringPostProcess",(function(){return op})),i.d(t,"VRDistortionCorrectionPostProcess",(function(){return xi})),i.d(t,"VRMultiviewToSingleviewPostProcess",(function(){return Fi})),i.d(t,"ScreenSpaceReflectionPostProcess",(function(){return Yf})),i.d(t,"ScreenSpaceCurvaturePostProcess",(function(){return sp})),i.d(t,"ReflectionProbe",(function(){return yc})),i.d(t,"BoundingBoxRenderer",(function(){return cp})),i.d(t,"DepthRenderer",(function(){return ks})),i.d(t,"DepthRendererSceneComponent",(function(){return lp})),i.d(t,"EdgesRenderer",(function(){return dp})),i.d(t,"LineEdgesRenderer",(function(){return fp})),i.d(t,"GeometryBufferRenderer",(function(){return Sf})),i.d(t,"GeometryBufferRendererSceneComponent",(function(){return Pf})),i.d(t,"PrePassRenderer",(function(){return pp})),i.d(t,"PrePassRendererSceneComponent",(function(){return _p})),i.d(t,"SubSurfaceSceneComponent",(function(){return Tp})),i.d(t,"OutlineRenderer",(function(){return Ap})),i.d(t,"RenderingGroup",(function(){return Pp.a})),i.d(t,"RenderingGroupInfo",(function(){return Di.a})),i.d(t,"RenderingManager",(function(){return Di.b})),i.d(t,"UtilityLayerRenderer",(function(){return Cr.a})),i.d(t,"Scene",(function(){return Q.a})),i.d(t,"SceneComponentConstants",(function(){return Me.a})),i.d(t,"Stage",(function(){return Me.b})),i.d(t,"Sprite",(function(){return Cp})),i.d(t,"SpriteManager",(function(){return Ip})),i.d(t,"SpriteMap",(function(){return wp})),i.d(t,"SpritePackedManager",(function(){return Fp})),i.d(t,"SpriteSceneComponent",(function(){return Rp})),i.d(t,"AlphaState",(function(){return Bp.a})),i.d(t,"DepthCullingState",(function(){return Up.a})),i.d(t,"StencilState",(function(){return Vp.a})),i.d(t,"AndOrNotEvaluator",(function(){return kp.a})),i.d(t,"AssetTaskState",(function(){return Lp})),i.d(t,"AbstractAssetTask",(function(){return Gp})),i.d(t,"AssetsProgressEvent",(function(){return jp})),i.d(t,"ContainerAssetTask",(function(){return Wp})),i.d(t,"MeshAssetTask",(function(){return Hp})),i.d(t,"TextFileAssetTask",(function(){return Xp})),i.d(t,"BinaryFileAssetTask",(function(){return Yp})),i.d(t,"ImageAssetTask",(function(){return Kp})),i.d(t,"TextureAssetTask",(function(){return Qp})),i.d(t,"CubeTextureAssetTask",(function(){return qp})),i.d(t,"HDRCubeTextureAssetTask",(function(){return Zp})),i.d(t,"EquiRectangularCubeTextureAssetTask",(function(){return Jp})),i.d(t,"AssetsManager",(function(){return $p})),i.d(t,"BasisTranscodeConfiguration",(function(){return zc})),i.d(t,"BasisTools",(function(){return Gc})),i.d(t,"DDSTools",(function(){return Ea})),i.d(t,"expandToProperty",(function(){return w.b})),i.d(t,"serialize",(function(){return w.c})),i.d(t,"serializeAsTexture",(function(){return w.m})),i.d(t,"serializeAsColor3",(function(){return w.e})),i.d(t,"serializeAsFresnelParameters",(function(){return w.h})),i.d(t,"serializeAsVector2",(function(){return w.n})),i.d(t,"serializeAsVector3",(function(){return w.o})),i.d(t,"serializeAsMeshReference",(function(){return w.k})),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.l})),i.d(t,"serializeAsMatrix",(function(){return w.j})),i.d(t,"serializeAsCameraReference",(function(){return w.d})),i.d(t,"SerializationHelper",(function(){return w.a})),i.d(t,"Deferred",(function(){return e_})),i.d(t,"EnvironmentTextureTools",(function(){return ir})),i.d(t,"MeshExploder",(function(){return t_})),i.d(t,"FilesInput",(function(){return i_})),i.d(t,"CubeMapToSphericalPolynomialTools",(function(){return $n})),i.d(t,"HDRTools",(function(){return nc})),i.d(t,"PanoramaToCubeMapTools",(function(){return ic})),i.d(t,"KhronosTextureContainer",(function(){return Pa})),i.d(t,"EventState",(function(){return o.a})),i.d(t,"Observer",(function(){return o.d})),i.d(t,"MultiObserver",(function(){return o.b})),i.d(t,"Observable",(function(){return o.c})),i.d(t,"PerformanceMonitor",(function(){return n_.a})),i.d(t,"RollingAverage",(function(){return n_.b})),i.d(t,"PromisePolyfill",(function(){return r_.a})),i.d(t,"SceneOptimization",(function(){return o_})),i.d(t,"TextureOptimization",(function(){return a_})),i.d(t,"HardwareScalingOptimization",(function(){return s_})),i.d(t,"ShadowsOptimization",(function(){return c_})),i.d(t,"PostProcessesOptimization",(function(){return l_})),i.d(t,"LensFlaresOptimization",(function(){return u_})),i.d(t,"CustomOptimization",(function(){return h_})),i.d(t,"ParticlesOptimization",(function(){return d_})),i.d(t,"RenderTargetsOptimization",(function(){return f_})),i.d(t,"MergeMeshesOptimization",(function(){return p_})),i.d(t,"SceneOptimizerOptions",(function(){return __})),i.d(t,"SceneOptimizer",(function(){return m_})),i.d(t,"SceneSerializer",(function(){return y_})),i.d(t,"SmartArray",(function(){return oi.a})),i.d(t,"SmartArrayNoDuplicate",(function(){return oi.b})),i.d(t,"StringDictionary",(function(){return Mt.a})),i.d(t,"Tags",(function(){return T_.a})),i.d(t,"TextureTools",(function(){return E_})),i.d(t,"TGATools",(function(){return Uc})),i.d(t,"Tools",(function(){return Ce.b})),i.d(t,"className",(function(){return Ce.c})),i.d(t,"AsyncLoop",(function(){return Ce.a})),i.d(t,"VideoRecorder",(function(){return S_})),i.d(t,"JoystickAxis",(function(){return Ot})),i.d(t,"VirtualJoystick",(function(){return It})),i.d(t,"WorkerPool",(function(){return Ca})),i.d(t,"Logger",(function(){return m.a})),i.d(t,"_TypeStore",(function(){return c.a})),i.d(t,"FilesInputStore",(function(){return dr.a})),i.d(t,"DeepCopier",(function(){return O.a})),i.d(t,"PivotTools",(function(){return We.a})),i.d(t,"PrecisionDate",(function(){return q.a})),i.d(t,"ScreenshotTools",(function(){return A_})),i.d(t,"WebRequest",(function(){return V.a})),i.d(t,"InspectableType",(function(){return zp})),i.d(t,"BRDFTextureTools",(function(){return To})),i.d(t,"RGBDTextureTools",(function(){return yo})),i.d(t,"ColorGradient",(function(){return rd})),i.d(t,"Color3Gradient",(function(){return od})),i.d(t,"FactorGradient",(function(){return ad})),i.d(t,"GradientHelper",(function(){return sd})),i.d(t,"PerfCounter",(function(){return ns.a})),i.d(t,"RetryStrategy",(function(){return C_.a})),i.d(t,"CanvasGenerator",(function(){return Zi.a})),i.d(t,"LoadFileError",(function(){return Vn.b})),i.d(t,"RequestFileError",(function(){return Vn.d})),i.d(t,"ReadFileError",(function(){return Vn.c})),i.d(t,"FileTools",(function(){return Vn.a})),i.d(t,"StringTools",(function(){return io.a})),i.d(t,"DataReader",(function(){return R_})),i.d(t,"MinMaxReducer",(function(){return Gs})),i.d(t,"DepthReducer",(function(){return js})),i.d(t,"DataStorage",(function(){return x_})),i.d(t,"SceneRecorder",(function(){return O_})),i.d(t,"KhronosTextureContainer2",(function(){return Ra})),i.d(t,"Trajectory",(function(){return M_})),i.d(t,"TrajectoryClassifier",(function(){return L_})),i.d(t,"TimerState",(function(){return Ha})),i.d(t,"setAndStartTimer",(function(){return Qa})),i.d(t,"AdvancedTimer",(function(){return qa})),i.d(t,"CopyTools",(function(){return w_.a})),i.d(t,"WebXRCamera",(function(){return Ma})),i.d(t,"WebXREnterExitUIButton",(function(){return Xa})),i.d(t,"WebXREnterExitUIOptions",(function(){return Ya})),i.d(t,"WebXREnterExitUI",(function(){return Ka})),i.d(t,"WebXRExperienceHelper",(function(){return Na})),i.d(t,"WebXRInput",(function(){return Ga})),i.d(t,"WebXRInputSource",(function(){return za})),i.d(t,"WebXRManagedOutputCanvasOptions",(function(){return rn})),i.d(t,"WebXRManagedOutputCanvas",(function(){return on})),i.d(t,"WebXRState",(function(){return $i})),i.d(t,"WebXRTrackingState",(function(){return en})),i.d(t,"WebXRSessionManager",(function(){return an})),i.d(t,"WebXRDefaultExperienceOptions",(function(){return Ja})),i.d(t,"WebXRDefaultExperience",(function(){return $a})),i.d(t,"WebXRFeatureName",(function(){return Ia})),i.d(t,"WebXRFeaturesManager",(function(){return Da})),i.d(t,"WebXRAbstractFeature",(function(){return ja})),i.d(t,"WebXRHitTestLegacy",(function(){return F_})),i.d(t,"WebXRAnchorSystem",(function(){return U_})),i.d(t,"WebXRPlaneDetector",(function(){return k_})),i.d(t,"WebXRBackgroundRemover",(function(){return z_})),i.d(t,"WebXRMotionControllerTeleportation",(function(){return Za})),i.d(t,"WebXRControllerPointerSelection",(function(){return Wa})),i.d(t,"IWebXRControllerPhysicsOptions",(function(){return G_})),i.d(t,"WebXRControllerPhysics",(function(){return j_})),i.d(t,"WebXRHitTest",(function(){return W_})),i.d(t,"WebXRFeaturePointSystem",(function(){return H_})),i.d(t,"WebXRHand",(function(){return X_})),i.d(t,"WebXRHandTracking",(function(){return Y_})),i.d(t,"WebXRAbstractMotionController",(function(){return wa})),i.d(t,"WebXRControllerComponent",(function(){return La})),i.d(t,"WebXRGenericTriggerMotionController",(function(){return Fa})),i.d(t,"WebXRMicrosoftMixedRealityController",(function(){return K_})),i.d(t,"WebXRMotionControllerManager",(function(){return Va})),i.d(t,"WebXROculusTouchMotionController",(function(){return q_})),i.d(t,"WebXRHTCViveMotionController",(function(){return J_})),i.d(t,"WebXRProfiledMotionController",(function(){return Ua}));var n=i(35),r=i(91),o=i(6),a=i(0),s=i(9),c=i(11),l=function(){function e(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new o.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 n=this._condition.serialize();return n.children.push(i),t&&t.children.push(n),n}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 a.d?e.x+", "+e.y:e instanceof a.e?e.x+", "+e.y+", "+e.z:e instanceof s.a?e.r+", "+e.g+", "+e.b:e instanceof s.b?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}();c.a.RegisteredTypes["BABYLON.Action"]=l;var u=i(47),h=i(1),d=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}(),f=function(e){function t(i,n,r,o,a){void 0===a&&(a=t.IsEqual);var s=e.call(this,i)||this;return s.propertyPath=r,s.value=o,s.operator=a,s._target=n,s._effectiveTarget=s._getEffectiveTarget(n,s.propertyPath),s._property=s._getProperty(s.propertyPath),s}return Object(h.d)(t,e),Object.defineProperty(t,"IsEqual",{get:function(){return t._IsEqual},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsDifferent",{get:function(){return t._IsDifferent},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!1,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:[l._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:l._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}(d),p=function(e){function t(t,i){var n=e.call(this,t)||this;return n.predicate=i,n}return Object(h.d)(t,e),t.prototype.isValid=function(){return this.predicate()},t}(d),_=function(e){function t(t,i,n){var r=e.call(this,t)||this;return r.value=n,r._target=i,r}return Object(h.d)(t,e),t.prototype.isValid=function(){return this._target.state===this.value},t.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[l._GetTargetProperty(this._target),{name:"value",value:this.value}]})},t}(d);c.a.RegisteredTypes["BABYLON.ValueCondition"]=f,c.a.RegisteredTypes["BABYLON.PredicateCondition"]=p,c.a.RegisteredTypes["BABYLON.StateCondition"]=_;var m=i(8),g=i(2),v=function(e){function t(t,i,n,r){var o=e.call(this,t,r)||this;return o.propertyPath=n,o._target=o._effectiveTarget=i,o}return Object(h.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:[l._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},t)},t}(l),b=function(e){function t(t,i,n,r){var o=e.call(this,t,r)||this;return o.value=n,o._target=i,o}return Object(h.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:[l._GetTargetProperty(this._target),{name:"value",value:this.value}]},t)},t}(l),y=function(e){function t(t,i,n,r,o){var a=e.call(this,t,o)||this;return a.propertyPath=n,a.value=r,a._target=a._effectiveTarget=i,a}return Object(h.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:[l._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:l._SerializeValueAsString(this.value)}]},t)},t}(l),T=function(e){function t(t,i,n,r,o){var a=e.call(this,t,o)||this;return a.propertyPath=n,a.value=r,a._target=a._effectiveTarget=i,a}return Object(h.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]&&m.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:[l._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:l._SerializeValueAsString(this.value)}]},t)},t}(l),E=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,a)||this;return s.from=n,s.to=r,s.loop=o,s._target=i,s}return Object(h.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:[l._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:l._SerializeValueAsString(this.loop)||!1}]},t)},t}(l),S=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r._target=i,r}return Object(h.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:[l._GetTargetProperty(this._target)]},t)},t}(l),A=function(e){function t(t,i){return void 0===t&&(t=g.a.ACTION_NothingTrigger),e.call(this,t,i)||this}return Object(h.d)(t,e),t.prototype.execute=function(){},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},t)},t}(l),P=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r.children=i,r}return Object(h.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),n=0;n<this.children.length;n++)i.combine.push(this.children[n].serialize(null));return i},t}(l),C=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r.func=i,r}return Object(h.d)(t,e),t.prototype.execute=function(e){this.func(e)},t}(l),R=function(e){function t(t,i,n,r){var o=e.call(this,t,r)||this;return o._target=i,o._parent=n,o}return Object(h.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=a.e.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"SetParentAction",properties:[l._GetTargetProperty(this._target),l._GetTargetProperty(this._parent)]},t)},t}(l);c.a.RegisteredTypes["BABYLON.SetParentAction"]=R,c.a.RegisteredTypes["BABYLON.ExecuteCodeAction"]=C,c.a.RegisteredTypes["BABYLON.DoNothingAction"]=A,c.a.RegisteredTypes["BABYLON.StopAnimationAction"]=S,c.a.RegisteredTypes["BABYLON.PlayAnimationAction"]=E,c.a.RegisteredTypes["BABYLON.IncrementValueAction"]=T,c.a.RegisteredTypes["BABYLON.SetValueAction"]=y,c.a.RegisteredTypes["BABYLON.SetStateAction"]=b,c.a.RegisteredTypes["BABYLON.SetParentAction"]=R;var x=i(22),O=i(41),M=function(e){function t(t){var i=e.call(this)||this;return i._scene=t||x.a.LastCreatedScene,t.actionManagers.push(i),i}return Object(h.d)(t,e),t.prototype.dispose=function(){for(var e=this._scene.actionManagers.indexOf(this),i=0;i<this.actions.length;i++){var n=this.actions[i];t.Triggers[n.trigger]--,0===t.Triggers[n.trigger]&&delete t.Triggers[n.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 n=this.actions[i];if(e==n.trigger||t==n.trigger)return!0}return!1},t.prototype.hasSpecificTrigger=function(e,t){for(var i=0;i<this.actions.length;i++){var n=this.actions[i];if(n.trigger===e){if(!t)return!0;if(t(n.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:!1,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:!1,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(m.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],e._actionManager=null,!0)},t.prototype.processTrigger=function(e,i){for(var n=0;n<this.actions.length;n++){var r=this.actions[n];if(r.trigger===e){if(i&&(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger)){var o=r.getTriggerParameter();if(o&&o!==i.sourceEvent.keyCode){if(!o.toLowerCase)continue;var a=o.toLowerCase();if(a!==i.sourceEvent.key){var s=i.sourceEvent.charCode?i.sourceEvent.charCode:i.sourceEvent.keyCode;if(String.fromCharCode(s).toLowerCase()!==a)continue}}}r._executeCurrent(i)}}},t.prototype._getEffectiveTarget=function(e,t){for(var i=t.split("."),n=0;n<i.length-1;n++)e=e[i[n]];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},n=0;n<this.actions.length;n++){var r={type:0,children:new Array,name:t.GetTriggerName(this.actions[n].trigger),properties:new Array},o=this.actions[n].triggerOptions;if(o&&"number"!=typeof o)if(o.parameter instanceof Node)r.properties.push(l._GetTargetProperty(o.parameter));else{var a={};O.a.DeepCopy(o.parameter,a,["mesh"]),o.parameter&&o.parameter.mesh&&(a._meshId=o.parameter.mesh.id),r.properties.push({name:"parameter",targetType:null,value:a})}this.actions[n].serialize(r),i.children.push(r)}return i},t.Parse=function(e,i,n){var r=new t(n);null===i?n.actionManager=r:i.actionManager=r;for(var o=function(e,t,i,n){if(null===n){var r=parseFloat(t);return"true"===t||"false"===t?"true"===t:isNaN(r)?t:r}for(var o=n.split("."),c=t.split(","),l=0;l<o.length;l++)i=i[o[l]];if("boolean"==typeof i)return"true"===c[0];if("string"==typeof i)return c[0];var u=new Array;for(l=0;l<c.length;l++)u.push(parseFloat(c[l]));return i instanceof a.e?a.e.FromArray(u):i instanceof a.f?a.f.FromArray(u):i instanceof s.a?s.a.FromArray(u):i instanceof s.b?s.b.FromArray(u):parseFloat(c[0])},l=function(e,i,a,s,u){if(void 0===u&&(u=null),!e.detached){var h=new Array,p=null,_=null,m=e.combine&&e.combine.length>0;if(2===e.type?h.push(r):h.push(i),m){for(var g=new Array,v=0;v<e.combine.length;v++)l(e.combine[v],t.NothingTrigger,a,s,g);h.push(g)}else for(var b=0;b<e.properties.length;b++){var y=e.properties[b].value,T=e.properties[b].name,E=e.properties[b].targetType;"target"===T?y=p=null!==E&&"SceneProperties"===E?n:n.getNodeByName(y):"parent"===T?y=n.getNodeByName(y):"sound"===T?n.getSoundByName&&(y=n.getSoundByName(y)):"propertyPath"!==T?y=2===e.type&&"operator"===T?f[y]:o(0,y,p,"value"===T?_:null):_=y,h.push(y)}if(null===u?h.push(a):h.push(null),"InterpolateValueAction"===e.name){var S=h[h.length-2];h[h.length-1]=S,h[h.length-2]=a}var P=function(e,t){var i=c.a.GetClass("BABYLON."+e);if(i){var n=Object.create(i.prototype);return n.constructor.apply(n,t),n}}(e.name,h);if(P instanceof d&&null!==a){var C=new A(i,a);s?s.then(C):r.registerAction(C),s=C}null===u?P instanceof d?(a=P,P=s):(a=null,s?s.then(P):r.registerAction(P)):u.push(P);for(b=0;b<e.children.length;b++)l(e.children[b],i,a,P,null)}},u=0;u<e.children.length;u++){var h,p=e.children[u];if(p.properties.length>0){var _=p.properties[0].value,m=null===p.properties[0].targetType?_:n.getMeshByName(_);m._meshId&&(m.mesh=n.getMeshByID(m._meshId)),h={trigger:t[p.name],parameter:m}}else h=t[p.name];for(var g=0;g<p.children.length;g++)p.detached||l(p.children[g],h,null,null)}},t.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},t.NothingTrigger=g.a.ACTION_NothingTrigger,t.OnPickTrigger=g.a.ACTION_OnPickTrigger,t.OnLeftPickTrigger=g.a.ACTION_OnLeftPickTrigger,t.OnRightPickTrigger=g.a.ACTION_OnRightPickTrigger,t.OnCenterPickTrigger=g.a.ACTION_OnCenterPickTrigger,t.OnPickDownTrigger=g.a.ACTION_OnPickDownTrigger,t.OnDoublePickTrigger=g.a.ACTION_OnDoublePickTrigger,t.OnPickUpTrigger=g.a.ACTION_OnPickUpTrigger,t.OnPickOutTrigger=g.a.ACTION_OnPickOutTrigger,t.OnLongPressTrigger=g.a.ACTION_OnLongPressTrigger,t.OnPointerOverTrigger=g.a.ACTION_OnPointerOverTrigger,t.OnPointerOutTrigger=g.a.ACTION_OnPointerOutTrigger,t.OnEveryFrameTrigger=g.a.ACTION_OnEveryFrameTrigger,t.OnIntersectionEnterTrigger=g.a.ACTION_OnIntersectionEnterTrigger,t.OnIntersectionExitTrigger=g.a.ACTION_OnIntersectionExitTrigger,t.OnKeyDownTrigger=g.a.ACTION_OnKeyDownTrigger,t.OnKeyUpTrigger=15,t}(r.a),I=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r._sound=i,r}return Object(h.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}(l),D=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r._sound=i,r}return Object(h.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}(l);c.a.RegisteredTypes["BABYLON.PlaySoundAction"]=D,c.a.RegisteredTypes["BABYLON.StopSoundAction"]=D;var N,L=i(14),w=i(3);!function(e){e[e.STEP=1]="STEP"}(N||(N={}));var F=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}(),B=i(29),U=i(77),V=i(49),k=function(){},z=function(){function e(t,i,n,r,o,a){this.name=t,this.targetProperty=i,this.framePerSecond=n,this.dataType=r,this.loopMode=o,this.enableBlending=a,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=i.split("."),this.dataType=r,this.loopMode=void 0===o?e.ANIMATIONLOOPMODE_CYCLE:o}return e._PrepareAnimation=function(t,i,n,r,o,c,l,u){var h=void 0;if(!isNaN(parseFloat(o))&&isFinite(o)?h=e.ANIMATIONTYPE_FLOAT:o instanceof a.b?h=e.ANIMATIONTYPE_QUATERNION:o instanceof a.e?h=e.ANIMATIONTYPE_VECTOR3:o instanceof a.d?h=e.ANIMATIONTYPE_VECTOR2:o instanceof s.a?h=e.ANIMATIONTYPE_COLOR3:o instanceof s.b?h=e.ANIMATIONTYPE_COLOR4:o instanceof U.a&&(h=e.ANIMATIONTYPE_SIZE),null==h)return null;var d=new e(t,i,n,h,l),f=[{frame:0,value:o},{frame:r,value:c}];return d.setKeys(f),void 0!==u&&d.setEasingFunction(u),d},e.CreateAnimation=function(t,i,n,r){var o=new e(t+"Animation",t,n,i,e.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(r),o},e.CreateAndStartAnimation=function(t,i,n,r,o,a,s,c,l,u){var h=e._PrepareAnimation(t,n,r,o,a,s,c,l);return h?i.getScene().beginDirectAnimation(i,[h],0,o,1===h.loopMode,1,u):null},e.CreateAndStartHierarchyAnimation=function(t,i,n,r,o,a,s,c,l,u,h){var d=e._PrepareAnimation(t,r,o,a,s,c,l,u);return d?i.getScene().beginDirectHierarchyAnimation(i,n,[d],0,a,1===d.loopMode,1,h):null},e.CreateMergeAndStartAnimation=function(t,i,n,r,o,a,s,c,l,u){var h=e._PrepareAnimation(t,n,r,o,a,s,c,l);return h?(i.animations.push(h),i.getScene().beginAnimation(i,0,o,1===h.loopMode,1,u)):null},e.MakeAnimationAdditive=function(t,i,n,r,o){void 0===i&&(i=0),void 0===r&&(r=!1);var s=t;if(r&&((s=t.clone()).name=o||s.name),!s._keys.length)return s;i=i>=0?i:0;var c=0,l=s._keys[0],u=s._keys.length-1,h=s._keys[u],d={referenceValue:l.value,referencePosition:a.c.Vector3[0],referenceQuaternion:a.c.Quaternion[0],referenceScaling:a.c.Vector3[1],keyPosition:a.c.Vector3[2],keyQuaternion:a.c.Quaternion[1],keyScaling:a.c.Vector3[3]},f=!1,p=l.frame,_=h.frame;if(n){var m=s.getRange(n);m&&(p=m.from,_=m.to)}var g=l.frame===p,v=h.frame===_;if(1===s._keys.length){var b=s._getKeyValue(s._keys[0]);d.referenceValue=b.clone?b.clone():b,f=!0}else if(i<=l.frame){b=s._getKeyValue(l.value);d.referenceValue=b.clone?b.clone():b,f=!0}else if(i>=h.frame){b=s._getKeyValue(h.value);d.referenceValue=b.clone?b.clone():b,f=!0}for(var y=0;!f||!g||!v&&y<s._keys.length-1;){var T=s._keys[y],E=s._keys[y+1];if(!f&&i>=T.frame&&i<=E.frame){b=void 0;if(i===T.frame)b=s._getKeyValue(T.value);else if(i===E.frame)b=s._getKeyValue(E.value);else{var S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};b=s._interpolate(i,S)}d.referenceValue=b.clone?b.clone():b,f=!0}if(!g&&p>=T.frame&&p<=E.frame){if(p===T.frame)c=y;else if(p===E.frame)c=y+1;else{S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};var A={frame:p,value:(b=s._interpolate(p,S)).clone?b.clone():b};s._keys.splice(y+1,0,A),c=y+1}g=!0}if(!v&&_>=T.frame&&_<=E.frame){if(_===T.frame)u=y;else if(_===E.frame)u=y+1;else{S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT},A={frame:_,value:(b=s._interpolate(_,S)).clone?b.clone():b};s._keys.splice(y+1,0,A),u=y+1}v=!0}y++}s.dataType===e.ANIMATIONTYPE_QUATERNION?d.referenceValue.normalize().conjugateInPlace():s.dataType===e.ANIMATIONTYPE_MATRIX&&(d.referenceValue.decompose(d.referenceScaling,d.referenceQuaternion,d.referencePosition),d.referenceQuaternion.normalize().conjugateInPlace());for(y=c;y<=u;y++){A=s._keys[y];if(!y||s.dataType===e.ANIMATIONTYPE_FLOAT||A.value!==l.value)switch(s.dataType){case e.ANIMATIONTYPE_MATRIX:A.value.decompose(d.keyScaling,d.keyQuaternion,d.keyPosition),d.keyPosition.subtractInPlace(d.referencePosition),d.keyScaling.divideInPlace(d.referenceScaling),d.referenceQuaternion.multiplyToRef(d.keyQuaternion,d.keyQuaternion),a.a.ComposeToRef(d.keyScaling,d.keyQuaternion,d.keyPosition,A.value);break;case e.ANIMATIONTYPE_QUATERNION:d.referenceValue.multiplyToRef(A.value,A.value);break;case e.ANIMATIONTYPE_VECTOR2:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:case e.ANIMATIONTYPE_COLOR4:A.value.subtractToRef(d.referenceValue,A.value);break;case e.ANIMATIONTYPE_SIZE:A.value.width-=d.referenceValue.width,A.value.height-=d.referenceValue.height;break;default:A.value-=d.referenceValue}}return s},e.TransitionTo=function(e,t,i,n,r,o,a,s){if(void 0===s&&(s=null),a<=0)return i[e]=t,s&&s(),null;var c=r*(a/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=n.beginAnimation(i,0,c,!1);return l.onAnimationEnd=s,l},Object.defineProperty(e.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!1,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:!1,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 n in this._ranges)i&&(t+=", ",i=!1),t+=n;t+="}"}return t},e.prototype.addEvent=function(e){this._events.push(e),this._events.sort((function(e,t){return e.frame-t.frame}))},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 F(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 n=i.from,r=i.to,o=this._keys.length-1;o>=0;o--)this._keys[o].frame>=n&&this._keys[o].frame<=r&&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 L.a.Lerp(e,t,i)},e.prototype.floatInterpolateFunctionWithTangents=function(e,t,i,n,r){return L.a.Hermite(e,t,i,n,r)},e.prototype.quaternionInterpolateFunction=function(e,t,i){return a.b.Slerp(e,t,i)},e.prototype.quaternionInterpolateFunctionWithTangents=function(e,t,i,n,r){return a.b.Hermite(e,t,i,n,r).normalize()},e.prototype.vector3InterpolateFunction=function(e,t,i){return a.e.Lerp(e,t,i)},e.prototype.vector3InterpolateFunctionWithTangents=function(e,t,i,n,r){return a.e.Hermite(e,t,i,n,r)},e.prototype.vector2InterpolateFunction=function(e,t,i){return a.d.Lerp(e,t,i)},e.prototype.vector2InterpolateFunctionWithTangents=function(e,t,i,n,r){return a.d.Hermite(e,t,i,n,r)},e.prototype.sizeInterpolateFunction=function(e,t,i){return U.a.Lerp(e,t,i)},e.prototype.color3InterpolateFunction=function(e,t,i){return s.a.Lerp(e,t,i)},e.prototype.color4InterpolateFunction=function(e,t,i){return s.b.Lerp(e,t,i)},e.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},e.prototype._interpolate=function(t,i){if(i.loopMode===e.ANIMATIONLOOPMODE_CONSTANT&&i.repeatCount>0)return i.highLimitValue.clone?i.highLimitValue.clone():i.highLimitValue;var n=this._keys;if(1===n.length)return this._getKeyValue(n[0].value);var r=i.key;if(n[r].frame>=t)for(;r-1>=0&&n[r].frame>=t;)r--;for(var o=r;o<n.length;o++){var a=n[o+1];if(a.frame>=t){i.key=o;var s=n[o],c=this._getKeyValue(s.value);if(s.interpolation===N.STEP)return c;var l=this._getKeyValue(a.value),u=void 0!==s.outTangent&&void 0!==a.inTangent,h=a.frame-s.frame,d=(t-s.frame)/h,f=this.getEasingFunction();switch(null!=f&&(d=f.ease(d)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var p=u?this.floatInterpolateFunctionWithTangents(c,s.outTangent*h,l,a.inTangent*h,d):this.floatInterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return p;case e.ANIMATIONLOOPMODE_RELATIVE:return i.offsetValue*i.repeatCount+p}break;case e.ANIMATIONTYPE_QUATERNION:var _=u?this.quaternionInterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.quaternionInterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return _;case e.ANIMATIONLOOPMODE_RELATIVE:return _.addInPlace(i.offsetValue.scale(i.repeatCount))}return _;case e.ANIMATIONTYPE_VECTOR3:var m=u?this.vector3InterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.vector3InterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var g=u?this.vector2InterpolateFunctionWithTangents(c,s.outTangent.scale(h),l,a.inTangent.scale(h),d):this.vector2InterpolateFunction(c,l,d);switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_SIZE:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR3:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_COLOR4:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color4InterpolateFunction(c,l,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color4InterpolateFunction(c,l,d).add(i.offsetValue.scale(i.repeatCount))}case e.ANIMATIONTYPE_MATRIX:switch(i.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(c,l,d,i.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(n[n.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,i,n,r){return e.AllowMatrixDecomposeForInterpolation?r?(a.a.DecomposeLerpToRef(t,i,n,r),r):a.a.DecomposeLerp(t,i,n):r?(a.a.LerpToRef(t,i,n,r),r):a.a.Lerp(t,i,n)},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 n=this._ranges[i];n&&(t._ranges[i]=n.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 n=this.getKeys(),r=0;r<n.length;r++){var o=n[r],a={};switch(a.frame=o.frame,i){case e.ANIMATIONTYPE_FLOAT:a.values=[o.value],void 0!==o.inTangent&&a.values.push(o.inTangent),void 0!==o.outTangent&&(void 0===o.inTangent&&a.values.push(void 0),a.values.push(o.outTangent));break;case e.ANIMATIONTYPE_QUATERNION:case e.ANIMATIONTYPE_MATRIX:case e.ANIMATIONTYPE_VECTOR3:case e.ANIMATIONTYPE_COLOR3:case e.ANIMATIONTYPE_COLOR4:a.values=o.value.asArray(),null!=o.inTangent&&a.values.push(o.inTangent.asArray()),null!=o.outTangent&&(void 0===o.inTangent&&a.values.push(void 0),a.values.push(o.outTangent.asArray()))}t.keys.push(a)}for(var s in t.ranges=[],this._ranges){var c=this._ranges[s];if(c){var l={};l.name=s,l.from=c.from,l.to=c.to,t.ranges.push(l)}}return t},e._UniversalLerp=function(e,t,i){var n=e.constructor;return n.Lerp?n.Lerp(e,t,i):n.Slerp?n.Slerp(e,t,i):e.toFixed?e*(1-i)+i*t:t},e.Parse=function(t){var i,n,r=new e(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),o=t.dataType,c=[];for(t.enableBlending&&(r.enableBlending=t.enableBlending),t.blendingSpeed&&(r.blendingSpeed=t.blendingSpeed),n=0;n<t.keys.length;n++){var l,u,h=t.keys[n];switch(o){case e.ANIMATIONTYPE_FLOAT:i=h.values[0],h.values.length>=1&&(l=h.values[1]),h.values.length>=2&&(u=h.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(i=a.b.FromArray(h.values),h.values.length>=8){var d=a.b.FromArray(h.values.slice(4,8));d.equals(a.b.Zero())||(l=d)}if(h.values.length>=12){var f=a.b.FromArray(h.values.slice(8,12));f.equals(a.b.Zero())||(u=f)}break;case e.ANIMATIONTYPE_MATRIX:i=a.a.FromArray(h.values);break;case e.ANIMATIONTYPE_COLOR3:i=s.a.FromArray(h.values);break;case e.ANIMATIONTYPE_COLOR4:i=s.b.FromArray(h.values);break;case e.ANIMATIONTYPE_VECTOR3:default:i=a.e.FromArray(h.values)}var p={};p.frame=h.frame,p.value=i,null!=l&&(p.inTangent=l),null!=u&&(p.outTangent=u),c.push(p)}if(r.setKeys(c),t.ranges)for(n=0;n<t.ranges.length;n++)i=t.ranges[n],r.createRange(i.name,i.from,i.to);return r},e.AppendSerializedAnimations=function(e,t){w.a.AppendSerializedAnimations(e,t)},e.ParseFromFileAsync=function(e,t){var i=this;return new Promise((function(n,r){var o=new V.a;o.addEventListener("readystatechange",(function(){if(4==o.readyState)if(200==o.status){var t=JSON.parse(o.responseText);if(t.length){for(var a=new Array,s=0,c=t;s<c.length;s++){var l=c[s];a.push(i.Parse(l))}n(a)}else{a=i.Parse(t);e&&(a.name=e),n(a)}}else r("Unable to load the animation")})),o.open("GET",t),o.send()}))},e.CreateFromSnippetAsync=function(e){var t=this;return new Promise((function(i,n){var r=new V.a;r.addEventListener("readystatechange",(function(){if(4==r.readyState)if(200==r.status){var o=JSON.parse(JSON.parse(r.responseText).jsonPayload);if(o.animations){for(var a=JSON.parse(o.animations),s=new Array,c=0,l=a;c<l.length;c++){var u=l[c];s.push(t.Parse(u))}i(s)}else{a=JSON.parse(o.animation);(s=t.Parse(a)).snippetId=e,i(s)}}else n("Unable to load the snippet "+e)})),r.open("GET",t.SnippetUrl+"/"+e.replace(/#/g,"/")),r.send()}))},e.AllowMatricesInterpolation=!1,e.AllowMatrixDecomposeForInterpolation=!0,e.SnippetUrl="https://snippet.babylonjs.com",e.ANIMATIONTYPE_FLOAT=0,e.ANIMATIONTYPE_VECTOR3=1,e.ANIMATIONTYPE_QUATERNION=2,e.ANIMATIONTYPE_MATRIX=3,e.ANIMATIONTYPE_COLOR3=4,e.ANIMATIONTYPE_COLOR4=7,e.ANIMATIONTYPE_VECTOR2=5,e.ANIMATIONTYPE_SIZE=6,e.ANIMATIONLOOPMODE_RELATIVE=0,e.ANIMATIONLOOPMODE_CYCLE=1,e.ANIMATIONLOOPMODE_CONSTANT=2,e}();c.a.RegisteredTypes["BABYLON.Animation"]=z,B.a._AnimationRangeFactory=function(e,t,i){return new F(e,t,i)};var G=function(e){function t(t,i,n,r,a,s,c,l){void 0===a&&(a=1e3);var u=e.call(this,t,s)||this;return u.duration=1e3,u.onInterpolationDoneObservable=new o.c,u.propertyPath=n,u.value=r,u.duration=a,u.stopOtherAnimations=c,u.onInterpolationDone=l,u._target=u._effectiveTarget=i,u}return Object(h.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(),n=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)e=z.ANIMATIONTYPE_FLOAT;else if(this.value instanceof s.a)e=z.ANIMATIONTYPE_COLOR3;else if(this.value instanceof a.e)e=z.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof a.a)e=z.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof a.b))return void m.a.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");e=z.ANIMATIONTYPE_QUATERNION}var r=new z("InterpolateValueAction",this._property,1e3/this.duration*100,e,z.ANIMATIONLOOPMODE_CONSTANT);r.setKeys(n),this.stopOtherAnimations&&i.stopAnimation(this._effectiveTarget);i.beginDirectAnimation(this._effectiveTarget,[r],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:[l._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:l._SerializeValueAsString(this.value)},{name:"duration",value:l._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:l._SerializeValueAsString(this.stopOtherAnimations)||!1}]},t)},t}(l);c.a.RegisteredTypes["BABYLON.InterpolateValueAction"]=G;var j=Object.freeze(new a.b(0,0,0,0)),W=Object.freeze(a.e.Zero()),H=Object.freeze(a.d.Zero()),X=Object.freeze(U.a.Zero()),Y=Object.freeze(s.a.Black()),K=function(){function e(e,t,i,n){var r=this;if(this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._originalBlendValue=null,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._currentValue=null,this._currentActiveTarget=null,this._directTarget=null,this._targetPath="",this._weight=1,this._ratioOffset=0,this._previousDelay=0,this._previousRatio=0,this._targetIsArray=!1,this._animation=t,this._target=e,this._scene=i,this._host=n,this._activeTargets=[],t._runtimeAnimations.push(this),this._animationState={key:0,repeatCount:0,loopMode:this._getCorrectLoopMode()},this._animation.dataType===z.ANIMATIONTYPE_MATRIX&&(this._animationState.workValue=a.a.Zero()),this._keys=this._animation.getKeys(),this._minFrame=this._keys[0].frame,this._maxFrame=this._keys[this._keys.length-1].frame,this._minValue=this._keys[0].value,this._maxValue=this._keys[this._keys.length-1].value,0!==this._minFrame){var o={frame:0,value:this._minValue};this._keys.splice(0,0,o)}if(this._target instanceof Array){for(var s=0,c=0,l=this._target;c<l.length;c++){var u=l[c];this._preparePath(u,s),this._getOriginalValues(s),s++}this._targetIsArray=!0}else this._preparePath(this._target),this._getOriginalValues(),this._targetIsArray=!1,this._directTarget=this._activeTargets[0];var h=t.getEvents();h&&h.length>0&&h.forEach((function(e){r._events.push(e._clone())})),this._enableBlending=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending}return Object.defineProperty(e.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._currentActiveTarget},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAdditive",{get:function(){return this._host&&this._host.isAdditive},enumerable:!1,configurable:!0}),e.prototype._preparePath=function(e,t){void 0===t&&(t=0);var i=this._animation.targetPropertyPath;if(i.length>1){for(var n=e[i[0]],r=1;r<i.length-1;r++)n=n[i[r]];this._targetPath=i[i.length-1],this._activeTargets[t]=n}else this._targetPath=i[0],this._activeTargets[t]=e},Object.defineProperty(e.prototype,"animation",{get:function(){return this._animation},enumerable:!1,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,n=this._target;i<n.length;i++){var r=n[i];void 0!==this._originalValue[t]&&this._setValue(r,this._activeTargets[t],this._originalValue[t],-1,t),t++}else void 0!==this._originalValue[0]&&this._setValue(this._target,this._directTarget,this._originalValue[0],-1,0);this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0;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.setValue=function(e,t){if(this._targetIsArray)for(var i=0;i<this._target.length;i++){var n=this._target[i];this._setValue(n,this._activeTargets[i],e,t,i)}else this._setValue(this._target,this._directTarget,e,t,0)},e.prototype._getOriginalValues=function(e){var t;void 0===e&&(e=0);var i=this._activeTargets[e];(t=i.getRestPose&&"_matrix"===this._targetPath?i.getRestPose():i[this._targetPath])&&t.clone?this._originalValue[e]=t.clone():this._originalValue[e]=t},e.prototype._setValue=function(e,t,i,n,r){if(this._currentActiveTarget=t,this._weight=n,this._enableBlending&&this._blendingFactor<=1){if(!this._originalBlendValue){var o=t[this._targetPath];o.clone?this._originalBlendValue=o.clone():this._originalBlendValue=o}this._originalBlendValue.m?z.AllowMatrixDecomposeForInterpolation?this._currentValue?a.a.DecomposeLerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=a.a.DecomposeLerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue?a.a.LerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=a.a.Lerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue=z._UniversalLerp(this._originalBlendValue,i,this._blendingFactor);var s=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=s}else this._currentValue=i;-1!==n?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[r]):t[this._targetPath]=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._events;if(i.length)for(var n=0;n<i.length;n++)i[n].onlyOnce||(i[n].isDone=i[n].frame<e);this._currentFrame=e;var r=this._animation._interpolate(e,this._animationState);this.setValue(r,-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,n,r,o){void 0===o&&(o=-1);var a=this._animation,s=a.targetPropertyPath;if(!s||s.length<1)return this._stopped=!0,!1;var c=!0;(t<this._minFrame||t>this._maxFrame)&&(t=this._minFrame),(i<this._minFrame||i>this._maxFrame)&&(i=this._maxFrame);var l,u,h=i-t,d=e*(a.framePerSecond*r)/1e3+this._ratioOffset,f=0;if(this._previousDelay=e,this._previousRatio=d,!n&&i>=t&&d>=h)c=!1,f=a._getKeyValue(this._maxValue);else if(!n&&t>=i&&d<=h)c=!1,f=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==z.ANIMATIONLOOPMODE_CYCLE){var p=i.toString()+t.toString();if(!this._offsetsCache[p]){this._animationState.repeatCount=0,this._animationState.loopMode=z.ANIMATIONLOOPMODE_CYCLE;var _=a._interpolate(t,this._animationState),m=a._interpolate(i,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case z.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=m-_;break;case z.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=m.subtract(_);break;case z.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=m.subtract(_);case z.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=m.subtract(_)}this._highLimitsCache[p]=m}f=this._highLimitsCache[p],l=this._offsetsCache[p]}if(void 0===l)switch(a.dataType){case z.ANIMATIONTYPE_FLOAT:l=0;break;case z.ANIMATIONTYPE_QUATERNION:l=j;break;case z.ANIMATIONTYPE_VECTOR3:l=W;break;case z.ANIMATIONTYPE_VECTOR2:l=H;break;case z.ANIMATIONTYPE_SIZE:l=X;break;case z.ANIMATIONTYPE_COLOR3:l=Y}if(this._host&&this._host.syncRoot){var g=this._host.syncRoot;u=t+(i-t)*((g.masterFrame-g.fromFrame)/(g.toFrame-g.fromFrame))}else u=c&&0!==h?t+d%h:i;var v=this._events;if((h>0&&this.currentFrame>u||h<0&&this.currentFrame<u)&&(this._onLoop(),v.length))for(var b=0;b<v.length;b++)v[b].onlyOnce||(v[b].isDone=!1);this._currentFrame=u,this._animationState.repeatCount=0===h?0:d/h>>0,this._animationState.highLimitValue=f,this._animationState.offsetValue=l;var y=a._interpolate(u,this._animationState);if(this.setValue(y,o),v.length)for(b=0;b<v.length;b++)if(h>0&&u>=v[b].frame&&v[b].frame>=t||h<0&&u<=v[b].frame&&v[b].frame<=t){var T=v[b];T.isDone||(T.onlyOnce&&(v.splice(b,1),b--),T.isDone=!0,T.action(u))}return c||(this._stopped=!0),c},e}(),Q=i(20),q=i(57),Z=i(44),J=i(23),$=function(e){function t(t,i,n,r,o,s,c){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=null);var l=e.call(this,t,i.getScene())||this;return l.name=t,l.children=new Array,l.animations=new Array,l._index=null,l._absoluteTransform=new a.a,l._invertedAbsoluteTransform=new a.a,l._scalingDeterminant=1,l._worldTransform=new a.a,l._needToDecompose=!0,l._needToCompose=!1,l._linkedTransformNode=null,l._waitingTransformNodeId=null,l._skeleton=i,l._localMatrix=r?r.clone():a.a.Identity(),l._restPose=o||l._localMatrix.clone(),l._bindPose=l._localMatrix.clone(),l._baseMatrix=s||l._localMatrix.clone(),l._index=c,i.bones.push(l),l.setParent(n,!1),(s||r)&&l._updateDifferenceMatrix(),l}return Object(h.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:!1,configurable:!0}),t.prototype.getClassName=function(){return"Bone"},t.prototype.getSkeleton=function(){return this._skeleton},t.prototype.getParent=function(){return this._parent},t.prototype.getChildren=function(){return this.children},t.prototype.getIndex=function(){return null===this._index?this.getSkeleton().bones.indexOf(this):this._index},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.setRestPose=function(e){this._restPose.copyFrom(e)},t.prototype.getBindPose=function(){return this._bindPose},t.prototype.setBindPose=function(e){this._bindPose.copyFrom(e)},t.prototype.getWorldMatrix=function(){return this._worldTransform},t.prototype.returnToRest=function(){this._skeleton._numBonesWithLinkedTransformNode>0?this.updateMatrix(this._restPose,!1,!1):this.updateMatrix(this._restPose,!1,!0)},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++},t.prototype.getTransformNode=function(){return this._linkedTransformNode},Object.defineProperty(t.prototype,"position",{get:function(){return this._decompose(),this._localPosition},set:function(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationQuaternion",{get:function(){return this._decompose(),this._localRotation},set:function(e){this.setRotationQuaternion(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._skeleton.animationPropertiesOverride},enumerable:!1,configurable:!0}),t.prototype._decompose=function(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=a.e.Zero(),this._localRotation=a.b.Zero(),this._localPosition=a.e.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},t.prototype._compose=function(){this._needToCompose&&(this._localScaling?(this._needToCompose=!1,a.a.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix)):this._needToCompose=!1)},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._needToCompose=!1,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._childUpdateId++,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,n){void 0===i&&(i=J.c.LOCAL);var r=this.getLocalMatrix();if(i==J.c.LOCAL)r.addAtIndex(12,e.x),r.addAtIndex(13,e.y),r.addAtIndex(14,e.z);else{var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0],c=t._tmpVecs[0];this._parent?n&&o?(s.copyFrom(this._parent.getAbsoluteTransform()),s.multiplyToRef(o,s)):s.copyFrom(this._parent.getAbsoluteTransform()):a.a.IdentityToRef(s),s.setTranslationFromFloats(0,0,0),s.invert(),a.e.TransformCoordinatesToRef(e,s,c),r.addAtIndex(12,c.x),r.addAtIndex(13,c.y),r.addAtIndex(14,c.z)}this._markAsDirtyAndDecompose()},t.prototype.setPosition=function(e,i,n){void 0===i&&(i=J.c.LOCAL);var r=this.getLocalMatrix();if(i==J.c.LOCAL)r.setTranslationFromFloats(e.x,e.y,e.z);else{var o=null;n&&(o=n.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var s=t._tmpMats[0],c=t._tmpVecs[0];this._parent?(n&&o?(s.copyFrom(this._parent.getAbsoluteTransform()),s.multiplyToRef(o,s)):s.copyFrom(this._parent.getAbsoluteTransform()),s.invert()):a.a.IdentityToRef(s),a.e.TransformCoordinatesToRef(e,s,c),r.setTranslationFromFloats(c.x,c.y,c.z)}this._markAsDirtyAndDecompose()},t.prototype.setAbsolutePosition=function(e,t){this.setPosition(e,J.c.WORLD,t)},t.prototype.scale=function(e,i,n,r){void 0===r&&(r=!1);var o=this.getLocalMatrix(),s=t._tmpMats[0];a.a.ScalingToRef(e,i,n,s),s.multiplyToRef(o,o),s.invert();for(var c=0,l=this.children;c<l.length;c++){var u=(f=l[c]).getLocalMatrix();u.multiplyToRef(s,u),u.multiplyAtIndex(12,e),u.multiplyAtIndex(13,i),u.multiplyAtIndex(14,n),f._markAsDirtyAndDecompose()}if(this._markAsDirtyAndDecompose(),r)for(var h=0,d=this.children;h<d.length;h++){var f;(f=d[h]).scale(e,i,n,r)}},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,n,r,o){if(void 0===r&&(r=J.c.LOCAL),r===J.c.LOCAL){var s=t._tmpQuat;return a.b.RotationYawPitchRollToRef(e,i,n,s),void this.setRotationQuaternion(s,r,o)}var c=t._tmpMats[0];if(this._getNegativeRotationToRef(c,o)){var l=t._tmpMats[1];a.a.RotationYawPitchRollToRef(e,i,n,l),c.multiplyToRef(l,l),this._rotateWithMatrix(l,r,o)}},t.prototype.rotate=function(e,i,n,r){void 0===n&&(n=J.c.LOCAL);var o=t._tmpMats[0];o.setTranslationFromFloats(0,0,0),a.a.RotationAxisToRef(e,i,o),this._rotateWithMatrix(o,n,r)},t.prototype.setAxisAngle=function(e,i,n,r){if(void 0===n&&(n=J.c.LOCAL),n===J.c.LOCAL){var o=t._tmpQuat;return a.b.RotationAxisToRef(e,i,o),void this.setRotationQuaternion(o,n,r)}var s=t._tmpMats[0];if(this._getNegativeRotationToRef(s,r)){var c=t._tmpMats[1];a.a.RotationAxisToRef(e,i,c),s.multiplyToRef(c,c),this._rotateWithMatrix(c,n,r)}},t.prototype.setRotation=function(e,t,i){void 0===t&&(t=J.c.LOCAL),this.setYawPitchRoll(e.y,e.x,e.z,t,i)},t.prototype.setRotationQuaternion=function(e,i,n){if(void 0===i&&(i=J.c.LOCAL),i===J.c.LOCAL)return this._decompose(),this._localRotation.copyFrom(e),void this._markAsDirtyAndCompose();var r=t._tmpMats[0];if(this._getNegativeRotationToRef(r,n)){var o=t._tmpMats[1];a.a.FromQuaternionToRef(e,o),r.multiplyToRef(o,o),this._rotateWithMatrix(o,i,n)}},t.prototype.setRotationMatrix=function(e,i,n){if(void 0===i&&(i=J.c.LOCAL),i===J.c.LOCAL){var r=t._tmpQuat;return a.b.FromRotationMatrixToRef(e,r),void this.setRotationQuaternion(r,i,n)}var o=t._tmpMats[0];if(this._getNegativeRotationToRef(o,n)){var s=t._tmpMats[1];s.copyFrom(e),o.multiplyToRef(e,s),this._rotateWithMatrix(s,i,n)}},t.prototype._rotateWithMatrix=function(e,i,n){void 0===i&&(i=J.c.LOCAL);var r=this.getLocalMatrix(),o=r.m[12],a=r.m[13],s=r.m[14],c=this.getParent(),l=t._tmpMats[3],u=t._tmpMats[4];c&&i==J.c.WORLD?(n?(l.copyFrom(n.getWorldMatrix()),c.getAbsoluteTransform().multiplyToRef(l,l)):l.copyFrom(c.getAbsoluteTransform()),u.copyFrom(l),u.invert(),r.multiplyToRef(l,r),r.multiplyToRef(e,r),r.multiplyToRef(u,r)):i==J.c.WORLD&&n?(l.copyFrom(n.getWorldMatrix()),u.copyFrom(l),u.invert(),r.multiplyToRef(l,r),r.multiplyToRef(e,r),r.multiplyToRef(u,r)):r.multiplyToRef(e,r),r.setTranslationFromFloats(o,a,s),this.computeAbsoluteTransforms(),this._markAsDirtyAndDecompose()},t.prototype._getNegativeRotationToRef=function(e,i){var n=t._tmpMats[2];return e.copyFrom(this.getAbsoluteTransform()),i&&(e.multiplyToRef(i.getWorldMatrix(),e),a.a.ScalingToRef(i.scaling.x,i.scaling.y,i.scaling.z,n)),e.invert(),!isNaN(e.m[0])&&(n.multiplyAtIndex(0,this._scalingDeterminant),e.multiplyToRef(n,e),!0)},t.prototype.getPosition=function(e,t){void 0===e&&(e=J.c.LOCAL),void 0===t&&(t=null);var i=a.e.Zero();return this.getPositionToRef(e,t,i),i},t.prototype.getPositionToRef=function(e,i,n){if(void 0===e&&(e=J.c.LOCAL),e==J.c.LOCAL){var r=this.getLocalMatrix();n.x=r.m[12],n.y=r.m[13],n.z=r.m[14]}else{var o=null;i&&(o=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var a=t._tmpMats[0];i&&o?(a.copyFrom(this.getAbsoluteTransform()),a.multiplyToRef(o,a)):a=this.getAbsoluteTransform(),n.x=a.m[12],n.y=a.m[13],n.z=a.m[14]}},t.prototype.getAbsolutePosition=function(e){void 0===e&&(e=null);var t=a.e.Zero();return this.getPositionToRef(J.c.WORLD,e,t),t},t.prototype.getAbsolutePositionToRef=function(e,t){this.getPositionToRef(J.c.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,n=0;n<i;n++)t[n].computeAbsoluteTransforms()},t.prototype.getDirection=function(e,t){void 0===t&&(t=null);var i=a.e.Zero();return this.getDirectionToRef(e,t,i),i},t.prototype.getDirectionToRef=function(e,i,n){void 0===i&&(i=null);var r=null;i&&(r=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var o=t._tmpMats[0];o.copyFrom(this.getAbsoluteTransform()),i&&r&&o.multiplyToRef(r,o),a.e.TransformNormalToRef(e,o,n),n.normalize()},t.prototype.getRotation=function(e,t){void 0===e&&(e=J.c.LOCAL),void 0===t&&(t=null);var i=a.e.Zero();return this.getRotationToRef(e,t,i),i},t.prototype.getRotationToRef=function(e,i,n){void 0===e&&(e=J.c.LOCAL),void 0===i&&(i=null);var r=t._tmpQuat;this.getRotationQuaternionToRef(e,i,r),r.toEulerAnglesToRef(n)},t.prototype.getRotationQuaternion=function(e,t){void 0===e&&(e=J.c.LOCAL),void 0===t&&(t=null);var i=a.b.Identity();return this.getRotationQuaternionToRef(e,t,i),i},t.prototype.getRotationQuaternionToRef=function(e,i,n){if(void 0===e&&(e=J.c.LOCAL),void 0===i&&(i=null),e==J.c.LOCAL)this._decompose(),n.copyFrom(this._localRotation);else{var r=t._tmpMats[0],o=this.getAbsoluteTransform();i?o.multiplyToRef(i.getWorldMatrix(),r):r.copyFrom(o),r.multiplyAtIndex(0,this._scalingDeterminant),r.multiplyAtIndex(1,this._scalingDeterminant),r.multiplyAtIndex(2,this._scalingDeterminant),r.decompose(void 0,n,void 0)}},t.prototype.getRotationMatrix=function(e,t){void 0===e&&(e=J.c.LOCAL);var i=a.a.Identity();return this.getRotationMatrixToRef(e,t,i),i},t.prototype.getRotationMatrixToRef=function(e,i,n){if(void 0===e&&(e=J.c.LOCAL),e==J.c.LOCAL)this.getLocalMatrix().getRotationMatrixToRef(n);else{var r=t._tmpMats[0],o=this.getAbsoluteTransform();i?o.multiplyToRef(i.getWorldMatrix(),r):r.copyFrom(o),r.multiplyAtIndex(0,this._scalingDeterminant),r.multiplyAtIndex(1,this._scalingDeterminant),r.multiplyAtIndex(2,this._scalingDeterminant),r.getRotationMatrixToRef(n)}},t.prototype.getAbsolutePositionFromLocal=function(e,t){void 0===t&&(t=null);var i=a.e.Zero();return this.getAbsolutePositionFromLocalToRef(e,t,i),i},t.prototype.getAbsolutePositionFromLocalToRef=function(e,i,n){void 0===i&&(i=null);var r=null;i&&(r=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var o=t._tmpMats[0];i&&r?(o.copyFrom(this.getAbsoluteTransform()),o.multiplyToRef(r,o)):o=this.getAbsoluteTransform(),a.e.TransformCoordinatesToRef(e,o,n)},t.prototype.getLocalPositionFromAbsolute=function(e,t){void 0===t&&(t=null);var i=a.e.Zero();return this.getLocalPositionFromAbsoluteToRef(e,t,i),i},t.prototype.getLocalPositionFromAbsoluteToRef=function(e,i,n){void 0===i&&(i=null);var r=null;i&&(r=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var o=t._tmpMats[0];o.copyFrom(this.getAbsoluteTransform()),i&&r&&o.multiplyToRef(r,o),o.invert(),a.e.TransformCoordinatesToRef(e,o,n)},t.prototype.setCurrentPoseAsRest=function(){this.setRestPose(this.getLocalMatrix())},t._tmpVecs=Z.a.BuildArray(2,a.e.Zero),t._tmpQuat=a.b.Identity(),t._tmpMats=Z.a.BuildArray(5,a.a.Identity),t}(B.a),ee=function(){function e(e,t,i,n,r,a,s,c,l,u){void 0===i&&(i=0),void 0===n&&(n=100),void 0===r&&(r=!1),void 0===a&&(a=1),void 0===u&&(u=!1),this.target=t,this.fromFrame=i,this.toFrame=n,this.loopAnimation=r,this.onAnimationEnd=s,this.onAnimationLoop=l,this.isAdditive=u,this._localDelayOffset=null,this._pausedDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this._syncRoot=null,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new o.c,this.onAnimationLoopObservable=new o.c,this._scene=e,c&&this.appendAnimations(t,c),this._speedRatio=a,e._activeAnimatables.push(this)}return Object.defineProperty(e.prototype,"syncRoot",{get:function(){return this._syncRoot},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"masterFrame",{get:function(){return 0===this._runtimeAnimations.length?0:this._runtimeAnimations[0].currentFrame},enumerable:!1,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:!1,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:!1,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=this,n=0;n<t.length;n++){var r=t[n],o=new K(e,r,this._scene,this);o._onLoop=function(){i.onAnimationLoopObservable.notifyObservers(i),i.onAnimationLoop&&i.onAnimationLoop()},this._runtimeAnimations.push(o)}},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,n=t[0].currentFrame,r=0===this.speedRatio?0:(e-n)/i*1e3/this.speedRatio;null===this._localDelayOffset&&(this._localDelayOffset=0),this._localDelayOffset-=r}for(var o=0;o<t.length;o++)t[o].goToFrame(e)},e.prototype.pause=function(){this._paused||(this._paused=!0)},e.prototype.restart=function(){this._paused=!1},e.prototype._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 n=(o=this._runtimeAnimations).length-1;n>=0;n--){var r=o[n];e&&r.animation.name!=e||(t&&!t(r.target)||(r.dispose(),o.splice(n,1)))}0==o.length&&(this._scene._activeAnimatables.splice(i,1),this._raiseOnAnimationEnd())}}else{if((n=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(n,1);var o=this._runtimeAnimations;for(n=0;n<o.length;n++)o[n].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){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 t,i=!1,n=this._runtimeAnimations;for(t=0;t<n.length;t++){var r=n[t].animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);i=i||r}if(this.animationStarted=i,!i){if(this.disposeOnEnd)for(t=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(t,1),t=0;t<n.length;t++)n[t].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationLoop=null,this.onAnimationLoopObservable.clear(),this.onAnimationEndObservable.clear())}return i},e}();Q.a.prototype._animate=function(){if(this.animationsEnabled){var e=q.a.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=e}this.deltaTime=this.useConstantAnimationDeltaTime?16:(e-this._animationTimeLast)*this.animationTimeScale,this._animationTimeLast=e;var t=this._activeAnimatables;if(0!==t.length){this._animationTime+=this.deltaTime;for(var i=this._animationTime,n=0;n<t.length;n++){var r=t[n];!r._animate(i)&&r.disposeOnEnd&&n--}this._processLateAnimationBindings()}}},Q.a.prototype.beginWeightedAnimation=function(e,t,i,n,r,o,a,s,c,l,u){void 0===n&&(n=1),void 0===o&&(o=1),void 0===u&&(u=!1);var h=this.beginAnimation(e,t,i,r,o,a,s,!1,c,l,u);return h.weight=n,h},Q.a.prototype.beginAnimation=function(e,t,i,n,r,o,a,s,c,l,u){void 0===r&&(r=1),void 0===s&&(s=!0),void 0===u&&(u=!1),t>i&&r>0&&(r*=-1),s&&this.stopAnimation(e,void 0,c),a||(a=new ee(this,e,t,i,n,r,o,void 0,l,u));var h=!c||c(e);if(e.animations&&h&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),f=0;f<d.length;f++)this.beginAnimation(d[f],t,i,n,r,o,a,s,c,l);return a.reset(),a},Q.a.prototype.beginHierarchyAnimation=function(e,t,i,n,r,o,a,s,c,l,u,h){void 0===o&&(o=1),void 0===c&&(c=!0),void 0===h&&(h=!1);var d=e.getDescendants(t),f=[];f.push(this.beginAnimation(e,i,n,r,o,a,s,c,l,void 0,h));for(var p=0,_=d;p<_.length;p++){var m=_[p];f.push(this.beginAnimation(m,i,n,r,o,a,s,c,l,void 0,h))}return f},Q.a.prototype.beginDirectAnimation=function(e,t,i,n,r,o,a,s,c){return void 0===c&&(c=!1),void 0===o&&(o=1),i>n&&o>0&&(o*=-1),new ee(this,e,i,n,r,o,a,t,s,c)},Q.a.prototype.beginDirectHierarchyAnimation=function(e,t,i,n,r,o,a,s,c,l){void 0===l&&(l=!1);var u=e.getDescendants(t),h=[];h.push(this.beginDirectAnimation(e,i,n,r,o,a,s,c,l));for(var d=0,f=u;d<f.length;d++){var p=f[d];h.push(this.beginDirectAnimation(p,i,n,r,o,a,s,c,l))}return h},Q.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},Q.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},Q.a.prototype.stopAnimation=function(e,t,i){for(var n=0,r=this.getAllAnimatablesByTarget(e);n<r.length;n++){r[n].stop(t,i)}},Q.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()}},Q.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,totalAdditiveWeight:0,animations:[],additiveAnimations:[],originalValue:t}),e.isAdditive?(i._lateAnimationHolders[e.targetPath].additiveAnimations.push(e),i._lateAnimationHolders[e.targetPath].totalAdditiveWeight+=e.weight):(i._lateAnimationHolders[e.targetPath].animations.push(e),i._lateAnimationHolders[e.targetPath].totalWeight+=e.weight)},Q.a.prototype._processLateAnimationBindingsForMatrices=function(e){if(0===e.totalWeight&&0===e.totalAdditiveWeight)return e.originalValue;var t=1,i=a.c.Vector3[0],n=a.c.Vector3[1],r=a.c.Quaternion[0],o=0,s=e.animations[0],c=e.originalValue,l=1,u=!1;if(e.totalWeight<1)l=1-e.totalWeight,c.decompose(n,r,i);else{if(o=1,t=e.totalWeight,1==(l=s.weight/t)){if(!e.totalAdditiveWeight)return s.currentValue;u=!0}s.currentValue.decompose(n,r,i)}if(!u){n.scaleInPlace(l),i.scaleInPlace(l),r.scaleInPlace(l);for(var h=o;h<e.animations.length;h++){if(0!==(m=e.animations[h]).weight){l=m.weight/t;var d=a.c.Vector3[2],f=a.c.Vector3[3],p=a.c.Quaternion[1];m.currentValue.decompose(f,p,d),f.scaleAndAddToRef(l,n),p.scaleAndAddToRef(l,r),d.scaleAndAddToRef(l,i)}}}for(var _=0;_<e.additiveAnimations.length;_++){var m;if(0!==(m=e.additiveAnimations[_]).weight){d=a.c.Vector3[2],f=a.c.Vector3[3],p=a.c.Quaternion[1];m.currentValue.decompose(f,p,d),f.multiplyToRef(n,f),a.e.LerpToRef(n,f,m.weight,n),r.multiplyToRef(p,p),a.b.SlerpToRef(r,p,m.weight,r),d.scaleAndAddToRef(m.weight,i)}}var g=s?s._animationState.workValue:a.c.Matrix[0].clone();return a.a.ComposeToRef(n,r,i,g),g},Q.a.prototype._processLateAnimationBindingsForQuaternions=function(e,t){if(0===e.totalWeight&&0===e.totalAdditiveWeight)return t;var i=e.animations[0],n=e.originalValue,r=t;if(0===e.totalWeight&&e.totalAdditiveWeight>0)r.copyFrom(n);else if(1===e.animations.length){if(a.b.SlerpToRef(n,i.currentValue,Math.min(1,e.totalWeight),r),0===e.totalAdditiveWeight)return r}else if(e.animations.length>1){var o=1,s=void 0,c=void 0;if(e.totalWeight<1){var l=1-e.totalWeight;c=[],(s=[]).push(n),c.push(l)}else{if(2===e.animations.length&&(a.b.SlerpToRef(e.animations[0].currentValue,e.animations[1].currentValue,e.animations[1].weight/e.totalWeight,t),0===e.totalAdditiveWeight))return t;s=[],c=[],o=e.totalWeight}for(var u=0;u<e.animations.length;u++){var h=e.animations[u];s.push(h.currentValue),c.push(h.weight/o)}for(var d=0,f=0;f<s.length;)f?(d+=c[f],a.b.SlerpToRef(r,s[f],c[f]/d,r),f++):(a.b.SlerpToRef(s[f],s[f+1],c[f+1]/(c[f]+c[f+1]),t),r=t,d=c[f]+c[f+1],f+=2)}for(var p=0;p<e.additiveAnimations.length;p++){0!==(h=e.additiveAnimations[p]).weight&&(r.multiplyToRef(h.currentValue,a.c.Quaternion[0]),a.b.SlerpToRef(r,a.c.Quaternion[0],h.weight,r))}return r},Q.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 n=t._lateAnimationHolders[i],r=n.animations[0],o=n.originalValue,s=z.AllowMatrixDecomposeForInterpolation&&o.m,c=t[i];if(s)c=this._processLateAnimationBindingsForMatrices(n);else if(void 0!==o.w)c=this._processLateAnimationBindingsForQuaternions(n,c||a.b.Identity());else{var l=0,u=1;if(n.totalWeight<1)c=r&&o.scale?o.scale(1-n.totalWeight):r?o*(1-n.totalWeight):o.clone?o.clone():o;else if(r){u=n.totalWeight;var h=r.weight/u;c=1!==h?r.currentValue.scale?r.currentValue.scale(h):r.currentValue*h:r.currentValue,l=1}for(var d=l;d<n.animations.length;d++){(_=(p=n.animations[d]).weight/u)&&(p.currentValue.scaleAndAddToRef?p.currentValue.scaleAndAddToRef(_,c):c+=p.currentValue*_)}for(var f=0;f<n.additiveAnimations.length;f++){var p,_;(_=(p=n.additiveAnimations[f]).weight)&&(p.currentValue.scaleAndAddToRef?p.currentValue.scaleAndAddToRef(_,c):c+=p.currentValue*_)}}t[i]=c}t._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},$.prototype.copyAnimationRange=function(e,t,i,n,r){void 0===n&&(n=!1),void 0===r&&(r=null),0===this.animations.length&&(this.animations.push(new z(this.name,"_matrix",e.animations[0].framePerSecond,z.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));var o=e.animations[0].getRange(t);if(!o)return!1;for(var a,s,c,l=o.from,u=o.to,h=e.animations[0].getKeys(),d=e.length,f=e.getParent(),p=this.getParent(),_=n&&f&&d&&this.length&&d!==this.length,m=_&&p&&f?p.length/f.length:1,g=n&&!p&&r&&(1!==r.x||1!==r.y||1!==r.z),v=this.animations[0].getKeys(),b=0,y=h.length;b<y;b++)(a=h[b]).frame>=l&&a.frame<=u&&(n?(c=a.value.clone(),_?(s=c.getTranslation(),c.setTranslation(s.scaleInPlace(m))):g&&r?(s=c.getTranslation(),c.setTranslation(s.multiplyInPlace(r))):c=a.value):c=a.value,v.push({frame:a.frame+i,value:c}));return this.animations[0].createRange(t,l+i,u+i),!0};var te=function(){function e(){}return e.prototype.getClassName=function(){return"TargetedAnimation"},e.prototype.serialize=function(){var e={};return e.animation=this.animation.serialize(),e.targetId=this.target.id,e},e}(),ie=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._loopAnimation=!1,this._isAdditive=!1,this.onAnimationEndObservable=new o.c,this.onAnimationLoopObservable=new o.c,this.onAnimationGroupLoopObservable=new o.c,this.onAnimationGroupEndObservable=new o.c,this.onAnimationGroupPauseObservable=new o.c,this.onAnimationGroupPlayObservable=new o.c,this._scene=t||x.a.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.addAnimationGroup(this)}return Object.defineProperty(e.prototype,"from",{get:function(){return this._from},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this._to},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isPlaying",{get:function(){return this._isStarted&&!this._isPaused},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"loopAnimation",{get:function(){return this._loopAnimation},set:function(e){if(this._loopAnimation!==e){this._loopAnimation=e;for(var t=0;t<this._animatables.length;t++){this._animatables[t].loopAnimation=this._loopAnimation}}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAdditive",{get:function(){return this._isAdditive},set:function(e){if(this._isAdditive!==e){this._isAdditive=e;for(var t=0;t<this._animatables.length;t++){this._animatables[t].isAdditive=this._isAdditive}}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"targetedAnimations",{get:function(){return this._targetedAnimations},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animatables",{get:function(){return this._animatables},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this._targetedAnimations},enumerable:!1,configurable:!0}),e.prototype.addTargetedAnimation=function(e,t){var i=new te;i.animation=e,i.target=t;var n=e.getKeys();return this._from>n[0].frame&&(this._from=n[0].frame),this._to<n[n.length-1].frame&&(this._to=n[n.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 n=this._targetedAnimations[i].animation.getKeys(),r=n[0],o=n[n.length-1];if(r.frame>e){var a={frame:e,value:r.value,inTangent:r.inTangent,outTangent:r.outTangent,interpolation:r.interpolation};n.splice(0,0,a)}if(o.frame<t){a={frame:t,value:o.value,inTangent:o.inTangent,outTangent:o.outTangent,interpolation:o.interpolation};n.push(a)}}return this._from=e,this._to=t,this},e.prototype._processLoop=function(e,t,i){var n=this;e.onAnimationLoop=function(){n.onAnimationLoopObservable.notifyObservers(t),n._animationLoopFlags[i]||(n._animationLoopFlags[i]=!0,n._animationLoopCount++,n._animationLoopCount===n._targetedAnimations.length&&(n.onAnimationGroupLoopObservable.notifyObservers(n),n._animationLoopCount=0,n._animationLoopFlags=[]))}},e.prototype.start=function(e,t,i,n,r){var o=this;if(void 0===e&&(e=!1),void 0===t&&(t=1),this._isStarted||0===this._targetedAnimations.length)return this;this._loopAnimation=e,this._animationLoopCount=0,this._animationLoopFlags=[];for(var a=function(){var a=s._targetedAnimations[c],l=s._scene.beginDirectAnimation(a.target,[a.animation],void 0!==i?i:s._from,void 0!==n?n:s._to,e,t,void 0,void 0,void 0!==r?r:s._isAdditive);l.onAnimationEnd=function(){o.onAnimationEndObservable.notifyObservers(a),o._checkAnimationGroupEnded(l)},s._processLoop(l,a,c),s._animatables.push(l)},s=this,c=0;c<this._targetedAnimations.length;c++)a();if(this._speedRatio=t,void 0!==i&&void 0!==n)if(i<n&&this._speedRatio<0){var l=n;n=i,i=l}else i>n&&this._speedRatio>0&&(this._speedRatio=-t);return 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){return this.isStarted&&this._animatables.length===this._targetedAnimations.length?(void 0!==e&&(this.loopAnimation=e),this.restart()):(this.stop(),this.start(e,this._speedRatio)),this._isPaused=!1,this},e.prototype.reset=function(){if(!this._isStarted)return this.play(),this.goToFrame(0),this.stop(),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(),this.onAnimationGroupLoopObservable.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.prototype.clone=function(t,i){for(var n=new e(t||this.name,this._scene),r=0,o=this._targetedAnimations;r<o.length;r++){var a=o[r];n.addTargetedAnimation(a.animation.clone(),i?i(a.target):a.target)}return n},e.prototype.serialize=function(){var e={};e.name=this.name,e.from=this.from,e.to=this.to,e.targetedAnimations=[];for(var t=0;t<this.targetedAnimations.length;t++){var i=this.targetedAnimations[t];e.targetedAnimations[t]=i.serialize()}return e},e.Parse=function(t,i){for(var n=new e(t.name,i),r=0;r<t.targetedAnimations.length;r++){var o=t.targetedAnimations[r],a=z.Parse(o.animation),s=o.targetId;if("influence"===o.animation.property){var c=i.getMorphTargetById(s);c&&n.addTargetedAnimation(a,c)}else{var l=i.getNodeByID(s);null!=l&&n.addTargetedAnimation(a,l)}}return null!==t.from&&null!==t.to&&n.normalize(t.from,t.to),n},e.MakeAnimationAdditive=function(e,t,i,n,r){void 0===t&&(t=0),void 0===n&&(n=!1);var o=e;n&&(o=e.clone(r||o.name));for(var a=o.targetedAnimations,s=0;s<a.length;s++){var c=a[s];z.MakeAnimationAdditive(c.animation,t,i)}return o.isAdditive=!0,o},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}(),ne=function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=z.ANIMATIONLOOPMODE_CYCLE},re=i(72),oe=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}(),ae=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(oe),se=function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return Object(h.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}(oe),ce=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var n=e.call(this)||this;return n.bounces=t,n.bounciness=i,n}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var n=Math.pow(i,t),r=1-i,o=(1-n)/r+.5*n,a=e*o,s=Math.log(-a*(1-i)+1)/Math.log(i),c=Math.floor(s),l=c+1,u=(1-Math.pow(i,c))/(r*o),h=.5*(u+(1-Math.pow(i,l))/(r*o)),d=e-h,f=h-u;return-Math.pow(1/i,t-c)/(f*f)*(d-f)*(d+f)},t}(oe),le=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(oe),ue=function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var n=e.call(this)||this;return n.oscillations=t,n.springiness=i,n}return Object(h.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}(oe),he=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return Object(h.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}(oe),de=function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(oe),fe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e},t}(oe),pe=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(oe),_e=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(oe),me=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(oe),ge=function(e){function t(t,i,n,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=1);var o=e.call(this)||this;return o.x1=t,o.y1=i,o.x2=n,o.y2=r,o}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return re.c.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(oe),ve=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}(),be=i(7),ye=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t}(n.a),Te=function(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]},Ee=function(e){function t(t){var i=e.call(this)||this;return i._wasAddedToScene=!1,i.scene=t,i.sounds=[],i.effectLayers=[],i.layers=[],i.lensFlareSystems=[],i.proceduralTextures=[],i.reflectionProbes=[],t.onDisposeObservable.add((function(){i._wasAddedToScene||i.dispose()})),i}return Object(h.d)(t,e),t.prototype.instantiateModelsToScene=function(e,t){var i=this;void 0===t&&(t=!1);var n={},r={},o=new Te,a=[],s=[],c={doNotInstantiate:!0},l=function(t,i){if(n[t.uniqueId]=i.uniqueId,r[i.uniqueId]=i,e&&(i.name=e(t.name)),i instanceof be.a){var o=i;if(o.morphTargetManager){var a=t.morphTargetManager;o.morphTargetManager=a.clone();for(var s=0;s<a.numTargets;s++){var c=a.getTarget(s),l=o.morphTargetManager.getTarget(s);n[c.uniqueId]=l.uniqueId,r[l.uniqueId]=l}}}};return this.transformNodes.forEach((function(e){if(!e.parent){var t=e.instantiateHierarchy(null,c,(function(e,t){l(e,t)}));t&&o.rootNodes.push(t)}})),this.meshes.forEach((function(a){if(!a.parent){var u=a.instantiateHierarchy(null,c,(function(o,a){if(l(o,a),a.material){var c=a;if(c.material)if(t){var u=o.material;if(-1===s.indexOf(u)){var h=u.clone(e?e(u.name):"Clone of "+u.name);if(s.push(u),n[u.uniqueId]=h.uniqueId,r[h.uniqueId]=h,"MultiMaterial"===u.getClassName()){for(var d=u,f=0,p=d.subMaterials;f<p.length;f++){var _=p[f];_&&(h=_.clone(e?e(_.name):"Clone of "+_.name),s.push(_),n[_.uniqueId]=h.uniqueId,r[h.uniqueId]=h)}d.subMaterials=d.subMaterials.map((function(e){return e&&r[n[e.uniqueId]]}))}}c.material=r[n[u.uniqueId]]}else"MultiMaterial"===c.material.getClassName()?-1===i.scene.multiMaterials.indexOf(c.material)&&i.scene.addMultiMaterial(c.material):-1===i.scene.materials.indexOf(c.material)&&i.scene.addMaterial(c.material)}}));u&&o.rootNodes.push(u)}})),this.skeletons.forEach((function(t){var s=t.clone(e?e(t.name):"Clone of "+t.name);t.overrideMesh&&(s.overrideMesh=r[n[t.overrideMesh.uniqueId]]);for(var c=0,l=i.meshes;c<l.length;c++){var u=l[c];if(u.skeleton===t&&!u.isAnInstance){if(r[n[u.uniqueId]].skeleton=s,-1!==a.indexOf(s))continue;a.push(s);for(var h=0,d=s.bones;h<d.length;h++){var f=d[h];f._linkedTransformNode&&(f._linkedTransformNode=r[n[f._linkedTransformNode.uniqueId]])}}}o.skeletons.push(s)})),this.animationGroups.forEach((function(e){var t=e.clone(e.name,(function(e){return r[n[e.uniqueId]]||e}));o.animationGroups.push(t)})),o},t.prototype.addAllToScene=function(){var e=this;this._wasAddedToScene=!0,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)})),this.environmentTexture&&(this.scene.environmentTexture=this.environmentTexture);for(var t=0,i=this.scene._serializableComponents;t<i.length;t++){i[t].addFromContainer(this)}},t.prototype.removeAllFromScene=function(){var e=this;this._wasAddedToScene=!1,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)})),this.environmentTexture===this.scene.environmentTexture&&(this.scene.environmentTexture=null);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.cameras=[],this.lights.forEach((function(e){e.dispose()})),this.lights=[],this.meshes.forEach((function(e){e.dispose()})),this.meshes=[],this.skeletons.forEach((function(e){e.dispose()})),this.skeletons=[],this.animationGroups.forEach((function(e){e.dispose()})),this.animationGroups=[],this.multiMaterials.forEach((function(e){e.dispose()})),this.multiMaterials=[],this.materials.forEach((function(e){e.dispose()})),this.materials=[],this.geometries.forEach((function(e){e.dispose()})),this.geometries=[],this.transformNodes.forEach((function(e){e.dispose()})),this.transformNodes=[],this.actionManagers.forEach((function(e){e.dispose()})),this.actionManagers=[],this.textures.forEach((function(e){e.dispose()})),this.textures=[],this.reflectionProbes.forEach((function(e){e.dispose()})),this.reflectionProbes=[],this.environmentTexture&&(this.environmentTexture.dispose(),this.environmentTexture=null);for(var e=0,t=this.scene._serializableComponents;e<t.length;e++){t[e].removeFromContainer(this,!0)}},t.prototype._moveAssets=function(e,t,i){if(e)for(var n=0,r=e;n<r.length;n++){var o=r[n],a=!0;if(i)for(var s=0,c=i;s<c.length;s++){if(o===c[s]){a=!1;break}}a&&t.push(o)}},t.prototype.moveAllFromScene=function(e){for(var t in this._wasAddedToScene=!1,void 0===e&&(e=new ye),this)this.hasOwnProperty(t)&&(this[t]=this[t]||("environmentTexture"===t?null:[]),this._moveAssets(this.scene[t],this[t],e[t]));this.environmentTexture=this.scene.environmentTexture,this.removeAllFromScene()},t.prototype.createRootMesh=function(){var e=new be.a("assetContainerRootMesh",this.scene);return this.meshes.forEach((function(t){t.parent||e.addChild(t)})),this.meshes.unshift(e),e},t.prototype.mergeAnimationsTo=function(e,t,i){if(void 0===e&&(e=x.a.LastCreatedScene),void 0===i&&(i=null),!e)return m.a.Error("No scene available to merge animations to"),[];var n=i||function(t){var i=null,n=t.animations.length?t.animations[0].targetProperty:"",r=t.name.split(".").join("").split("_primitive")[0];switch(n){case"position":case"rotationQuaternion":i=e.getTransformNodeByName(t.name)||e.getTransformNodeByName(r);break;case"influence":i=e.getMorphTargetByName(t.name)||e.getMorphTargetByName(r);break;default:i=e.getNodeByName(t.name)||e.getNodeByName(r)}return i};this.getNodes().forEach((function(e){var t=n(e);if(null!==t){for(var i=function(e){for(var i=0,n=t.animations.filter((function(t){return t.targetProperty===e.targetProperty}));i<n.length;i++){var r=n[i],o=t.animations.indexOf(r,0);o>-1&&t.animations.splice(o,1)}},r=0,o=e.animations;r<o.length;r++){i(o[r])}t.animations=t.animations.concat(e.animations)}}));var r=new Array;return this.animationGroups.slice().forEach((function(e){r.push(e.clone(e.name,n)),e.animatables.forEach((function(e){e.stop()}))})),t.forEach((function(t){var i=n(t.target);i&&(e.beginAnimation(i,t.fromFrame,t.toFrame,t.loopAnimation,t.speedRatio,t.onAnimationEnd?t.onAnimationEnd:void 0,void 0,!0,void 0,t.onAnimationLoop?t.onAnimationLoop:void 0),e.stopAnimation(t.target))})),r},t}(n.a),Se=i(13),Ae=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=Se.a.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 n=t[i]/this.BARGRAPHAMPLITUDE,r=this.DEBUGCANVASSIZE.height*n,o=this.DEBUGCANVASSIZE.height-r-1,a=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),s=i/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+s+", 100%, 50%)",this._debugCanvasContext.fillRect(i*a,o,a,r)}}},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}();Se.a.AudioEngineFactory=function(e){return new Pe(e)};var Pe=function(){function e(e){var t=this;void 0===e&&(e=null),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 o.c,this.onAudioLockedObservable=new o.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$/,"")||i.canPlayType("audio/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:!1,configurable:!0}),e.prototype.lock=function(){this._triggerSuspendedState()},e.prototype.unlock=function(){this._triggerRunningState()},e.prototype._resumeAudioContext=function(){var e;return void 0!==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,m.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(),e.unlocked=!0,e.onAudioUnlockedObservable.notifyObservers(e)})).catch((function(){e._tryToRun=!1,e.unlocked=!1})))},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=".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"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":"https://cdn.babylonjs.com/Assets/audio.png")+"); 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) }",i=document.createElement("style");i.appendChild(document.createTextNode(t)),document.getElementsByTagName("head")[0].appendChild(i),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}(),Ce=i(12),Re=i(21),xe=function(){function e(t,i,n,r,s){var c,l,u,h,d=this;if(void 0===r&&(r=null),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.metadata=null,this.onEndedObservable=new o.c,this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=a.e.Zero(),this._positionInEmitterSpace=!1,this._localDirection=new a.e(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=n,e._SceneComponentInitialization(n),this._readyToPlayCallback=r,this._customAttenuationFunction=function(e,t,i,n,r){return t<i?e*(1-t/i):0},s&&(this.autoplay=s.autoplay||!1,this.loop=s.loop||!1,void 0!==s.volume&&(this._volume=s.volume),this.spatialSound=null!==(c=s.spatialSound)&&void 0!==c&&c,this.maxDistance=null!==(l=s.maxDistance)&&void 0!==l?l:100,this.useCustomAttenuation=null!==(u=s.useCustomAttenuation)&&void 0!==u&&u,this.rolloffFactor=s.rolloffFactor||1,this.refDistance=s.refDistance||1,this.distanceModel=s.distanceModel||"linear",this._playbackRate=s.playbackRate||1,this._streaming=null!==(h=s.streaming)&&void 0!==h&&h,this._length=s.length,this._offset=s.offset),Se.a.audioEngine.canUseWebAudio&&Se.a.audioEngine.audioContext){this._soundGain=Se.a.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 f=!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 p=[],_=!1;switch(this._urlType){case"MediaStream":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=Se.a.audioEngine.audioContext.createMediaStreamSource(i),this.autoplay&&this.play(0,this._offset,this._length),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"ArrayBuffer":i.byteLength>0&&(_=!0,this._soundLoaded(i));break;case"String":p.push(i);case"Array":0===p.length&&(p=i);for(var g=0;g<p.length;g++){var v=p[g];if(_=s&&s.skipCodecCheck||-1!==v.indexOf(".mp3",v.length-4)&&Se.a.audioEngine.isMP3supported||-1!==v.indexOf(".ogg",v.length-4)&&Se.a.audioEngine.isOGGsupported||-1!==v.indexOf(".wav",v.length-4)||-1!==v.indexOf(".m4a",v.length-4)||-1!==v.indexOf("blob:")){this._streaming?(this._htmlAudioElement=new Audio(v),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,Ce.b.SetCorsBehavior(v,this._htmlAudioElement),this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",(function(){d._isReadyToPlay=!0,d.autoplay&&d.play(0,d._offset,d._length),d._readyToPlayCallback&&d._readyToPlayCallback()})),document.body.appendChild(this._htmlAudioElement),this._htmlAudioElement.load()):this._scene._loadFile(v,(function(e){d._soundLoaded(e)}),void 0,!0,!0,(function(e){e&&m.a.Error("XHR "+e.status+" error on: "+v+"."),m.a.Error("Sound creation aborted."),d._scene.mainSoundTrack.removeSound(d)}));break}}break;default:f=!1}f?_||(this._isReadyToPlay=!0,this._readyToPlayCallback&&window.setTimeout((function(){d._readyToPlayCallback&&d._readyToPlayCallback()}),1e3)):m.a.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")}catch(e){m.a.Error("Unexpected error. Sound creation aborted."),this._scene.mainSoundTrack.removeSound(this)}}else this._scene.mainSoundTrack.addSound(this),Se.a.audioEngine.WarnedWebAudioUnsupported||(m.a.Error("Web Audio is not supported by your browser."),Se.a.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout((function(){d._readyToPlayCallback&&d._readyToPlayCallback()}),1e3)}return Object.defineProperty(e.prototype,"currentTime",{get:function(){if(this._htmlAudioElement)return this._htmlAudioElement.currentTime;var e=this._startOffset;return this.isPlaying&&Se.a.audioEngine.audioContext&&(e+=Se.a.audioEngine.audioContext.currentTime-this._startTime),e},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){Se.a.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;Se.a.audioEngine.audioContext&&Se.a.audioEngine.audioContext.decodeAudioData(e,(function(e){t._audioBuffer=e,t._isReadyToPlay=!0,t.autoplay&&t.play(0,t._offset,t._length),t._readyToPlayCallback&&t._readyToPlayCallback()}),(function(e){m.a.Error("Error while decoding audio data for: "+t.name+" / Error: "+e)}))},e.prototype.setAudioBuffer=function(e){Se.a.audioEngine.canUseWebAudio&&(this._audioBuffer=e,this._isReadyToPlay=!0)},e.prototype.updateOptions=function(e){var t,i,n,r,o,a,s,c,l;e&&(this.loop=null!==(t=e.loop)&&void 0!==t?t:this.loop,this.maxDistance=null!==(i=e.maxDistance)&&void 0!==i?i:this.maxDistance,this.useCustomAttenuation=null!==(n=e.useCustomAttenuation)&&void 0!==n?n:this.useCustomAttenuation,this.rolloffFactor=null!==(r=e.rolloffFactor)&&void 0!==r?r:this.rolloffFactor,this.refDistance=null!==(o=e.refDistance)&&void 0!==o?o:this.refDistance,this.distanceModel=null!==(a=e.distanceModel)&&void 0!==a?a:this.distanceModel,this._playbackRate=null!==(s=e.playbackRate)&&void 0!==s?s:this._playbackRate,this._length=null!==(c=e.length)&&void 0!==c?c:void 0,this._offset=null!==(l=e.offset)&&void 0!==l?l:void 0,this._updateSpatialParameters(),this.isPlaying&&(this._streaming&&this._htmlAudioElement?(this._htmlAudioElement.playbackRate=this._playbackRate,this._htmlAudioElement.loop!==this.loop&&(this._htmlAudioElement.loop=this.loop)):this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.loop!==this.loop&&(this._soundSource.loop=this.loop),void 0!==this._offset&&this._soundSource.loopStart!==this._offset&&(this._soundSource.loopStart=this._offset),void 0!==this._length&&this._length!==this._soundSource.loopEnd&&(this._soundSource.loopEnd=(0|this._offset)+this._length))))},e.prototype._createSpatialParameters=function(){Se.a.audioEngine.canUseWebAudio&&Se.a.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=Se.a.audioEngine.audioContext.createPanner(),this._soundPanner&&this._outputAudioNode&&(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(){Se.a.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)},e.prototype.connectToSoundTrackAudioNode=function(e){Se.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(e),this._isOutputConnected=!0)},e.prototype.setDirectionalCone=function(e,t,i){t<e?m.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(0,this._offset,this._length)))},Object.defineProperty(e.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(e){if(e!=this._coneInnerAngle){if(this._coneOuterAngle<e)return void m.a.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=e,Se.a.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle)}},enumerable:!1,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 m.a.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=e,Se.a.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneOuterAngle=this._coneOuterAngle)}},enumerable:!1,configurable:!0}),e.prototype.setPosition=function(e){this._position=e,Se.a.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,Se.a.audioEngine.canUseWebAudio&&this._connectedTransformNode&&this.isPlaying&&this._updateDirection()},e.prototype._updateDirection=function(){if(this._connectedTransformNode&&this._soundPanner){var e=this._connectedTransformNode.getWorldMatrix(),t=a.e.TransformNormal(this._localDirection,e);t.normalize(),this._soundPanner.setOrientation(t.x,t.y,t.z)}},e.prototype.updateDistanceFromListener=function(){if(Se.a.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,i){var n=this;if(this._isReadyToPlay&&this._scene.audioEnabled&&Se.a.audioEngine.audioContext)try{this._startOffset<0&&(e=-this._startOffset,this._startOffset=0);var r=e?Se.a.audioEngine.audioContext.currentTime+e:Se.a.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=Se.a.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){n._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._inputAudioNode&&this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement)(o=function(){if(Se.a.audioEngine.unlocked){var e=n._htmlAudioElement.play();void 0!==e&&e.catch((function(e){Se.a.audioEngine.lock(),(n.loop||n.autoplay)&&Se.a.audioEngine.onAudioUnlockedObservable.addOnce((function(){o()}))}))}else(n.loop||n.autoplay)&&Se.a.audioEngine.onAudioUnlockedObservable.addOnce((function(){o()}))})()}else{var o=function(){if(Se.a.audioEngine.audioContext){if(i=i||n._length,t=t||n._offset,n._soundSource){var o=n._soundSource;o.onended=function(){o.disconnect()}}if(n._soundSource=Se.a.audioEngine.audioContext.createBufferSource(),n._soundSource&&n._inputAudioNode){n._soundSource.buffer=n._audioBuffer,n._soundSource.connect(n._inputAudioNode),n._soundSource.loop=n.loop,void 0!==t&&(n._soundSource.loopStart=t),void 0!==i&&(n._soundSource.loopEnd=(0|t)+i),n._soundSource.playbackRate.value=n._playbackRate,n._soundSource.onended=function(){n._onended()},r=e?Se.a.audioEngine.audioContext.currentTime+e:Se.a.audioEngine.audioContext.currentTime;var a=n.isPaused?n._startOffset%n._soundSource.buffer.duration:t||0;n._soundSource.start(r,a,n.loop?void 0:i)}}};"suspended"===Se.a.audioEngine.audioContext.state?setTimeout((function(){"suspended"===Se.a.audioEngine.audioContext.state?(Se.a.audioEngine.lock(),(n.loop||n.autoplay)&&Se.a.audioEngine.onAudioUnlockedObservable.addOnce((function(){o()}))):o()}),500):o()}this._startTime=r,this.isPlaying=!0,this.isPaused=!1}catch(e){m.a.Error("Error while trying to play audio: "+this.name+", "+e.message)}},e.prototype._onended=function(){this.isPlaying=!1,this._startOffset=0,this.onended&&this.onended(),this.onEndedObservable.notifyObservers(this)},e.prototype.stop=function(e){var t=this;if(this.isPlaying)if(this._streaming)this._htmlAudioElement?(this._htmlAudioElement.pause(),this._htmlAudioElement.currentTime>0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(Se.a.audioEngine.audioContext&&this._soundSource){var i=e?Se.a.audioEngine.audioContext.currentTime+e:Se.a.audioEngine.audioContext.currentTime;this._soundSource.stop(i),this._soundSource.onended=function(){t.isPlaying=!1},this.isPaused||(this._startOffset=0)}},e.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():Se.a.audioEngine.audioContext&&(this.stop(0),this._startOffset+=Se.a.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){Se.a.audioEngine.canUseWebAudio&&this._soundGain&&(t&&Se.a.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(Se.a.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,Se.a.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,Se.a.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(0,this._offset,this._length))),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(this._positionInEmitterSpace)e.worldMatrixFromCache.invertToRef(a.c.Matrix[0]),this.setPosition(a.c.Matrix[0].getTranslation());else if(e.getBoundingInfo){var t=e.getBoundingInfo();this.setPosition(t.boundingSphere.centerWorld)}else this.setPosition(e.absolutePosition);Se.a.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?(r._audioBuffer=t.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play(0,t._offset,t._length)):window.setTimeout(i,300)},n={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},r=new e(this.name+"_cloned",new ArrayBuffer(0),this._scene,null,n);return this.useCustomAttenuation&&r.setAttenuationFunction(this._customAttenuationFunction),r.setPosition(this._position),r.setPlaybackRate(this._playbackRate),i(),r},e.prototype.getAudioBuffer=function(){return this._audioBuffer},e.prototype.getSoundSource=function(){return this._soundSource},e.prototype.getSoundGain=function(){return this._soundGain},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,metadata:this.metadata};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,n,r){var o,s=t.name;o=t.url?n+t.url:n+s;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(r){var u=function(){r._isReadyToPlay?(c._audioBuffer=r.getAudioBuffer(),c._isReadyToPlay=!0,c.autoplay&&c.play(0,c._offset,c._length)):window.setTimeout(u,300)};c=new e(s,new ArrayBuffer(0),i,null,l),u()}else c=new e(s,o,i,(function(){i._removePendingData(c)}),l),i._addPendingData(c);if(t.position){var h=a.e.FromArray(t.position);c.setPosition(h)}if(t.isDirectional&&(c.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=a.e.FromArray(t.localDirectionToMesh);c.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var f=i.getMeshByID(t.connectedMeshId);f&&c.attachToMesh(f)}return t.metadata&&(c.metadata=t.metadata),c},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("AudioSceneComponent")},e}(),Oe=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,!this._options.mainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return e.prototype._initializeSoundTrackAudioGraph=function(){Se.a.audioEngine.canUseWebAudio&&Se.a.audioEngine.audioContext&&(this._outputAudioNode=Se.a.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Se.a.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(Se.a.audioEngine&&Se.a.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(),Se.a.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){Se.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){if(Se.a.audioEngine.canUseWebAudio)for(var e=0;e<this.soundCollection.length;e++)this.soundCollection[e].switchPanningModelToHRTF()},e.prototype.switchPanningModelToEqualPower=function(){if(Se.a.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,Se.a.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,Se.a.audioEngine.masterGain))},e}(),Me=i(17);n.a.AddParser(Me.a.NAME_AUDIO,(function(e,t,i,n){var r,o=[];if(i.sounds=i.sounds||[],void 0!==e.sounds&&null!==e.sounds)for(var a=0,s=e.sounds.length;a<s;a++){var c=e.sounds[a];Se.a.audioEngine.canUseWebAudio?(c.url||(c.url=c.name),o[c.url]?i.sounds.push(xe.Parse(c,t,n,o[c.url])):(r=xe.Parse(c,t,n),o[c.url]=r,i.sounds.push(r))):i.sounds.push(new xe(c.name,null,t))}o=[]})),Object.defineProperty(Q.a.prototype,"mainSoundTrack",{get:function(){var e=this._getComponent(Me.a.NAME_AUDIO);return e||(e=new Ie(this),this._addComponent(e)),this._mainSoundTrack||(this._mainSoundTrack=new Oe(this,{mainTrack:!0})),this._mainSoundTrack},enumerable:!0,configurable:!0}),Q.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(Q.a.prototype,"audioEnabled",{get:function(){var e=this._getComponent(Me.a.NAME_AUDIO);return e||(e=new Ie(this),this._addComponent(e)),e.audioEnabled},set:function(e){var t=this._getComponent(Me.a.NAME_AUDIO);t||(t=new Ie(this),this._addComponent(t)),e?t.enableAudio():t.disableAudio()},enumerable:!0,configurable:!0}),Object.defineProperty(Q.a.prototype,"headphone",{get:function(){var e=this._getComponent(Me.a.NAME_AUDIO);return e||(e=new Ie(this),this._addComponent(e)),e.headphone},set:function(e){var t=this._getComponent(Me.a.NAME_AUDIO);t||(t=new Ie(this),this._addComponent(t)),e?t.switchAudioModeForHeadphones():t.switchAudioModeForNormalSpeakers()},enumerable:!0,configurable:!0}),Object.defineProperty(Q.a.prototype,"audioListenerPositionProvider",{get:function(){var e=this._getComponent(Me.a.NAME_AUDIO);return e||(e=new Ie(this),this._addComponent(e)),e.audioListenerPositionProvider},set:function(e){var t=this._getComponent(Me.a.NAME_AUDIO);if(t||(t=new Ie(this),this._addComponent(t)),"function"!=typeof e)throw new Error("The value passed to [Scene.audioListenerPositionProvider] must be a function that returns a Vector3");t.audioListenerPositionProvider=e},enumerable:!0,configurable:!0}),Object.defineProperty(Q.a.prototype,"audioPositioningRefreshRate",{get:function(){var e=this._getComponent(Me.a.NAME_AUDIO);return e||(e=new Ie(this),this._addComponent(e)),e.audioPositioningRefreshRate},set:function(e){var t=this._getComponent(Me.a.NAME_AUDIO);t||(t=new Ie(this),this._addComponent(t)),t.audioPositioningRefreshRate=e},enumerable:!0,configurable:!0});var Ie=function(){function e(e){this.name=Me.a.NAME_AUDIO,this._audioEnabled=!0,this._headphone=!1,this.audioPositioningRefreshRate=500,this._audioListenerPositionProvider=null,this._cachedCameraDirection=new a.e,this._cachedCameraPosition=new a.e,this._lastCheck=0,this.scene=e,e.soundTracks=new Array,e.sounds=new Array}return Object.defineProperty(e.prototype,"audioEnabled",{get:function(){return this._audioEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"headphone",{get:function(){return this._headphone},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"audioListenerPositionProvider",{get:function(){return this._audioListenerPositionProvider},set:function(e){this._audioListenerPositionProvider=e},enumerable:!1,configurable:!0}),e.prototype.register=function(){this.scene._afterRenderStage.registerStep(Me.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],n=0;n<i.soundCollection.length;n++)e.sounds.push(i.soundCollection[n].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,t){var i=this;void 0===t&&(t=!1),e.sounds&&e.sounds.forEach((function(e){e.stop(),e.autoplay=!1,i.scene.mainSoundTrack.removeSound(e),t&&e.dispose()}))},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,Se.a.audioEngine&&Se.a.audioEngine.audioContext&&Se.a.audioEngine.audioContext.suspend(),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,Se.a.audioEngine&&Se.a.audioEngine.audioContext&&Se.a.audioEngine.audioContext.resume(),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 t=q.a.Now;if(!(this._lastCheck&&t-this._lastCheck<this.audioPositioningRefreshRate)){this._lastCheck=t;var i=this.scene;if(this._audioEnabled&&i._mainSoundTrack&&i.soundTracks&&(0!==i._mainSoundTrack.soundCollection.length||1!==i.soundTracks.length)){var n=Se.a.audioEngine;if(n&&n.audioContext){if(this._audioListenerPositionProvider){var r=this._audioListenerPositionProvider();r.x=r.x||0,r.y=r.y||0,r.z=r.z||0,n.audioContext.listener.setPosition(r.x,r.y,r.z)}else{var o;if(o=i.activeCameras&&i.activeCameras.length>0?i.activeCameras[0]:i.activeCamera){this._cachedCameraPosition.equals(o.globalPosition)||(this._cachedCameraPosition.copyFrom(o.globalPosition),n.audioContext.listener.setPosition(o.globalPosition.x,o.globalPosition.y,o.globalPosition.z)),o.rigCameras&&o.rigCameras.length>0&&(o=o.rigCameras[0]);var s=a.a.Invert(o.getViewMatrix()),c=a.e.TransformNormal(i.useRightHandedSystem?e._CameraDirectionRH:e._CameraDirectionLH,s);c.normalize(),isNaN(c.x)||isNaN(c.y)||isNaN(c.z)||this._cachedCameraDirection.equals(c)||(this._cachedCameraDirection.copyFrom(c),n.audioContext.listener.setOrientation(c.x,c.y,c.z,0,1,0))}else n.audioContext.listener.setPosition(0,0,0)}var l;for(l=0;l<i.mainSoundTrack.soundCollection.length;l++){var u=i.mainSoundTrack.soundCollection[l];u.useCustomAttenuation&&u.updateDistanceFromListener()}if(i.soundTracks)for(l=0;l<i.soundTracks.length;l++)for(var h=0;h<i.soundTracks[l].soundCollection.length;h++)(u=i.soundTracks[l].soundCollection[h]).useCustomAttenuation&&u.updateDistanceFromListener()}}}},e._CameraDirectionLH=new a.e(0,0,-1),e._CameraDirectionRH=new a.e(0,0,1),e}();xe._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_AUDIO);t||(t=new Ie(e),e._addComponent(t))};var De=function(){function e(e,t,i){var n=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 r=0,o=0,a=i;o<a.length;o++){r+=a[o]}for(var s=r>0?1/r:0,c=0;c<this._weights.length;c++)this._weights[c]*=s;this._sounds=t;for(var l=0,u=this._sounds;l<u.length;l++){u[l].onEndedObservable.add((function(){n._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 m.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:!1,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 m.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:!1,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:!1,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,n=0;n<this._weights.length;n++)if(t<=(i+=this._weights[n])){this._currentIndex=n;break}}var r=this._sounds[this._currentIndex];r.isReady()?r.play(0,this.isPaused?void 0:e):r.autoplay=!0,this.isPlaying=!0,this.isPaused=!1},e}(),Ne=i(18),Le=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(e){this._idleRotationSpeed=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(e){this._idleRotationWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(e){this._idleRotationSpinupTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotationInProgress",{get:function(){return Math.abs(this._cameraRotationSpeed)>0},enumerable:!1,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!==Ne.a.POINTERDOWN?e.type===Ne.a.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=q.a.Now,i=0;null!=t._lastFrameTime&&(i=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var n=e-t._lastInteractionTime-t._idleRotationWaitTime,r=Math.max(Math.min(n/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*r,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=q.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}(),we=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:!1,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:!1,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=z.CreateAnimation("radius",z.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 n=z.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return i._clearAnimationLocks()}));n&&this._animatables.push(n)}},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 se(.3),e.EasingMode=oe.EASINGMODE_EASEOUT,e}(),Fe=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var i=this;this._attachedCamera=t;var n=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(e){e.type!==Ne.a.POINTERDOWN?e.type===Ne.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 n=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(n.minimumWorld,n.maximumWorld,t,i)},e.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var n=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(n.min,n.max,t,i)},e.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var n=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new a.e(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;o<e.length;o++){var s=e[o].getHierarchyBoundingVectors(!0);a.e.CheckExtends(s.min,n,r),a.e.CheckExtends(s.max,n,r)}this.zoomOnBoundingInfo(n,r,t,i)},e.prototype.zoomOnBoundingInfo=function(t,i,n,r){var o,s=this;if(void 0===n&&(n=!1),void 0===r&&(r=null),this._attachedCamera){var c=t.y,l=c+(i.y-c)*this._positionScale,u=i.subtract(t).scale(.5);if(n)o=new a.e(0,l,0);else{var h=t.add(u);o=new a.e(h.x,l,h.z)}this._vectorTransition||(this._vectorTransition=z.CreateAnimation("target",z.ANIMATIONTYPE_VECTOR3,60,e.EasingFunction)),this._betaIsAnimating=!0;var d=z.TransitionTo("target",o,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=z.CreateAnimation("radius",z.ANIMATIONTYPE_FLOAT,60,e.EasingFunction)),(d=z.TransitionTo("radius",f,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,(function(){s.stopAllAnimations(),r&&r(),s._attachedCamera&&s._attachedCamera.useInputToRestoreState&&s._attachedCamera.storeState()})))&&this._animatables.push(d)}},e.prototype._calculateLowerRadiusFromModelBoundingSphere=function(t,i){var n=i.subtract(t).length(),r=this._getFrustumSlope(),o=.5*n*this._radiusScale,a=o*Math.sqrt(1+1/(r.x*r.x)),s=o*Math.sqrt(1+1/(r.y*r.y)),c=Math.max(a,s),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=q.a.Now-this._lastInteractionTime,n=.5*Math.PI-this._defaultElevation,r=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>r&&i>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=z.CreateAnimation("beta",z.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=z.TransitionTo("beta",n,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 a.d.Zero();var t=e.getScene().getEngine().getAspectRatio(e),i=Math.tan(e.fov/2),n=i*t;return new a.d(n,i)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=q.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:!1,configurable:!0}),e.EasingFunction=new he,e.EasingMode=oe.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),Be=function(e,t,i,n){void 0===t&&(t=new a.e),void 0===i&&(i=0),void 0===n&&(n=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=n},Ue=function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new Be(a.e.Up()),new Be(a.e.Down()),new Be(a.e.Left()),new Be(a.e.Right()),new Be(a.e.Forward()),new Be(a.e.Forward().scaleInPlace(-1))],this._tmpMatrix=new a.a,this._tmpVector=new a.e,this._zeroVector=a.e.Zero(),this._lookAtTmpMatrix=new a.a}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=a.b.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),a.e.TransformCoordinatesToRef(i.direction,t._tmpMatrix,i.rotatedDirection),i.diff=a.e.GetAngleBetweenVectors(i.rotatedDirection,e,a.e.Cross(i.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore||e.diff<t.diff?e:t}),this._faceVectors[0])},e.prototype._lookAtToRef=function(e,t,i){void 0===t&&(t=new a.e(0,1,0)),a.a.LookAtLHToRef(this._zeroVector,e,t,this._lookAtTmpMatrix),this._lookAtTmpMatrix.invert(),a.b.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 n=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),a.e.TransformCoordinatesToRef(a.e.Up(),t._tmpMatrix,t._tmpVector),t._faceVectors.forEach((function(e){n.direction.x&&e.direction.x&&(e.ignore=!0),n.direction.y&&e.direction.y&&(e.ignore=!0),n.direction.z&&e.direction.z&&(e.ignore=!0)}));var r=t._closestFace(t._tmpVector);t._faceVectors.forEach((function(e){e.ignore=!1})),t.ui.position.copyFrom(e.position),n.direction.x&&(n.rotatedDirection.scaleToRef(e.scaling.x/2+t.distanceAwayFromFace,t._tmpVector),t.ui.position.addInPlace(t._tmpVector)),n.direction.y&&(n.rotatedDirection.scaleToRef(e.scaling.y/2+t.distanceAwayFromFace,t._tmpVector),t.ui.position.addInPlace(t._tmpVector)),n.direction.z&&(n.rotatedDirection.scaleToRef(e.scaling.z/2+t.distanceAwayFromFace,t._tmpVector),t.ui.position.addInPlace(t._tmpVector)),t.ui.rotationQuaternion||(t.ui.rotationQuaternion=a.b.RotationYawPitchRoll(t.ui.rotation.y,t.ui.rotation.x,t.ui.rotation.z)),n.rotatedDirection.scaleToRef(-1,t._tmpVector),t._lookAtToRef(t._tmpVector,r.rotatedDirection,t.ui.rotationQuaternion),r.direction.x&&t.ui.up.scaleToRef(t.distanceAwayFromBottomOfFace-e.scaling.x/2,t._tmpVector),r.direction.y&&t.ui.up.scaleToRef(t.distanceAwayFromBottomOfFace-e.scaling.y/2,t._tmpVector),r.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}(),Ve=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:!1,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}(),ke=i(65),ze=function(){function e(){this._startDistance=0,this._initialScale=new a.e(0,0,0),this._targetScale=new a.e(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new ke.a({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new ke.a({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!1,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}(),Ge=i(31),je=i(24),We=i(60),He=function(){function e(){this._sceneRenderObserver=null,this._targetPosition=new a.e(0,0,0),this._moving=!1,this._startingOrientation=new a.b,this._attachedToElement=!1,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new o.c,this.onDragObservable=new o.c,this.onDragEndObservable=new o.c}return Object.defineProperty(e.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},Object.defineProperty(e.prototype,"_pointerCamera",{get:function(){return this._scene.cameraToUseForPointers?this._scene.cameraToUseForPointers:this._scene.activeCamera},enumerable:!1,configurable:!0}),e.prototype.attach=function(t){var i=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new Q.a(this._scene.getEngine(),{virtual:!0}),e._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var n=null,r=new a.e(0,0,0);this._virtualOriginMesh=new Ge.a("",e._virtualScene),this._virtualOriginMesh.rotationQuaternion=new a.b,this._virtualDragMesh=new Ge.a("",e._virtualScene),this._virtualDragMesh.rotationQuaternion=new a.b;this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){if(e.type==Ne.a.POINTERDOWN){if(!i.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(u=e.pickInfo.pickedMesh,i._ownerNode==u||u.isDescendantOf(i._ownerNode))){i._pointerCamera&&i._pointerCamera.cameraRigMode==je.a.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),n=i._ownerNode,We.a._RemoveAndStorePivotPoint(n),r.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),n.computeWorldMatrix(),i._virtualDragMesh.position.copyFrom(n.absolutePosition),n.rotationQuaternion||(n.rotationQuaternion=a.b.RotationYawPitchRoll(n.rotation.y,n.rotation.x,n.rotation.z));var o=n.parent;n.setParent(null),i._virtualDragMesh.rotationQuaternion.copyFrom(n.rotationQuaternion),n.setParent(o),i._virtualOriginMesh.addChild(i._virtualDragMesh),i._targetPosition.copyFrom(i._virtualDragMesh.absolutePosition),i.dragging=!0,i.currentDraggingPointerID=e.event.pointerId,i.detachCameraControls&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.inputs.attachedToElement?(i._pointerCamera.detachControl(),i._attachedToElement=!0):i._attachedToElement=!1),We.a._RestorePivotPoint(n),i.onDragStartObservable.notifyObservers({})}}else if(e.type==Ne.a.POINTERUP||e.type==Ne.a.POINTERDOUBLETAP)i.currentDraggingPointerID==e.event.pointerId&&(i.dragging=!1,i._moving=!1,i.currentDraggingPointerID=-1,n=null,i._virtualOriginMesh.removeChild(i._virtualDragMesh),i.detachCameraControls&&i._attachedToElement&&i._pointerCamera&&!i._pointerCamera.leftCamera&&(i._pointerCamera.attachControl(!0),i._attachedToElement=!1),i.onDragEndObservable.notifyObservers({}));else if(e.type==Ne.a.POINTERMOVE&&i.currentDraggingPointerID==e.event.pointerId&&i.dragging&&e.pickInfo&&e.pickInfo.ray&&n){var s=i.zDragFactor;i._pointerCamera&&i._pointerCamera.cameraRigMode==je.a.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(i._pointerCamera.globalPosition),s=0);var c=e.pickInfo.ray.origin.subtract(r);r.copyFrom(e.pickInfo.ray.origin);var l=-a.e.Dot(c,e.pickInfo.ray.direction);i._virtualOriginMesh.addChild(i._virtualDragMesh),i._virtualDragMesh.position.z-=i._virtualDragMesh.position.z<1?l*i.zDragFactor:l*s*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),n.parent&&a.e.TransformCoordinatesToRef(i._targetPosition,a.a.Invert(n.parent.getWorldMatrix()),i._targetPosition),i._moving||i._startingOrientation.copyFrom(i._virtualDragMesh.rotationQuaternion),i._moving=!0}var u}));var o=new a.b;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(i.dragging&&i._moving&&n){if(We.a._RemoveAndStorePivotPoint(n),n.position.addInPlace(i._targetPosition.subtract(n.position).scale(i.dragDeltaRatio)),i.rotateDraggedObject){o.copyFrom(i._startingOrientation),o.x=-o.x,o.y=-o.y,o.z=-o.z,i._virtualDragMesh.rotationQuaternion.multiplyToRef(o,o),a.b.RotationYawPitchRollToRef(o.toEulerAngles("xyz").y,0,0,o),o.multiplyToRef(i._startingOrientation,o);var e=n.parent;(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&(n.setParent(null),a.b.SlerpToRef(n.rotationQuaternion,o,i.dragDeltaRatio,n.rotationQuaternion),n.setParent(e))}We.a._RestorePivotPoint(n),i.onDragObservable.notifyObservers()}}))},e.prototype.detach=function(){this._scene&&(this.detachCameraControls&&this._attachedToElement&&this._pointerCamera&&!this._pointerCamera.leftCamera&&(this._pointerCamera.attachControl(!0),this._attachedToElement=!1),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.onDragObservable.clear(),this.onDragStartObservable.clear()},e}(),Xe=function(){function e(e,t,i){if(this.targetPosition=a.e.Zero(),this.poleTargetPosition=a.e.Zero(),this.poleTargetLocalOffset=a.e.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=a.b.Identity(),this._bone1Mat=a.a.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=a.e.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var n=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,n.x>n.y&&n.x>n.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var r=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*r.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(e),c=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=a.e.Distance(s,c),this._bone2Length=a.e.Distance(c,l)}this._bone1.getRotationMatrixToRef(J.c.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:!1,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,n=this.poleTargetPosition,r=e._tmpMats[0],o=e._tmpMats[1];this.targetMesh&&i.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,n):this.poleTargetMesh&&a.e.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),n);var s=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,s),n.subtractToRef(s,h),0==h.x&&0==h.y&&0==h.z?h.y=1:h.normalize(),i.subtractToRef(s,u),u.normalize(),a.e.CrossToRef(u,h,c),c.normalize(),a.e.CrossToRef(u,c,l),l.normalize(),a.a.FromXYZAxesToRef(l,u,c,r);var f=this._bone1Length,p=this._bone2Length,_=a.e.Distance(s,i);this._maxReach>0&&(_=Math.min(this._maxReach,_));var m=(p*p+_*_-f*f)/(2*p*_),g=(_*_+f*f-p*p)/(2*_*f);m>1&&(m=1),g>1&&(g=1),m<-1&&(m=-1),g<-1&&(g=-1);var v=Math.acos(m),b=Math.acos(g),y=-v-b;if(this._rightHandedSystem)a.a.RotationYawPitchRollToRef(0,0,this._adjustRoll,o),o.multiplyToRef(r,r),a.a.RotationAxisToRef(this._bendAxis,b,o),o.multiplyToRef(r,r);else{var T=e._tmpVecs[5];T.copyFrom(this._bendAxis),T.x*=-1,a.a.RotationAxisToRef(T,-b,o),o.multiplyToRef(r,r)}this.poleAngle&&(a.a.RotationAxisToRef(u,this.poleAngle,o),r.multiplyToRef(o,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||a.b.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),a.b.FromRotationMatrixToRef(r,d),a.b.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),y=this._bone2Ang*(1-this.slerpAmount)+y*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,J.c.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,J.c.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,y,J.c.LOCAL),this._bone2Ang=y}},e._tmpVecs=[a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero(),a.e.Zero()],e._tmpQuat=a.b.Identity(),e._tmpMats=[a.a.Identity(),a.a.Identity()],e}(),Ye=function(){function e(e,t,i,n){if(this.upAxis=a.e.Up(),this.upAxisSpace=J.c.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=a.b.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=a.e.Forward(),this.mesh=e,this.bone=t,this.target=i,n&&(n.adjustYaw&&(this.adjustYaw=n.adjustYaw),n.adjustPitch&&(this.adjustPitch=n.adjustPitch),n.adjustRoll&&(this.adjustRoll=n.adjustRoll),null!=n.maxYaw?this.maxYaw=n.maxYaw:this.maxYaw=Math.PI,null!=n.minYaw?this.minYaw=n.minYaw:this.minYaw=-Math.PI,null!=n.maxPitch?this.maxPitch=n.maxPitch:this.maxPitch=Math.PI,null!=n.minPitch?this.minPitch=n.minPitch:this.minPitch=-Math.PI,null!=n.slerpAmount&&(this.slerpAmount=n.slerpAmount),null!=n.upAxis&&(this.upAxis=n.upAxis),null!=n.upAxisSpace&&(this.upAxisSpace=n.upAxisSpace),null!=n.yawAxis||null!=n.pitchAxis)){var r=J.a.Y,o=J.a.X;null!=n.yawAxis&&(r=n.yawAxis.clone()).normalize(),null!=n.pitchAxis&&(o=n.pitchAxis.clone()).normalize();var s=a.e.Cross(o,r);this._transformYawPitch=a.a.Identity(),a.a.FromXYZAxesToRef(o,r,s,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=J.c.BONE||(this.upAxisSpace=J.c.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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!1,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 n=this.target,r=e._tmpMats[0],o=e._tmpMats[1],s=this.mesh,c=t.getParent(),l=e._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==J.c.BONE&&c?(this._transformYawPitch&&a.e.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),c.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==J.c.LOCAL&&(s.getDirectionToRef(l,l),1==s.scaling.x&&1==s.scaling.y&&1==s.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==J.c.BONE&&1==l.y&&c)c.getRotationMatrixToRef(J.c.WORLD,this.mesh,d);else if(this.upAxisSpace!=J.c.LOCAL||1!=l.y||c){(_=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&a.e.TransformCoordinatesToRef(_,this._transformYawPitchInv,_),c?c.getDirectionToRef(_,this.mesh,_):s.getDirectionToRef(_,_);var p=a.e.Cross(l,_);p.normalize();var _=a.e.Cross(p,l);a.a.FromXYZAxesToRef(p,l,_,d)}else d.copyFrom(s.getWorldMatrix());d.invertToRef(f);var m=null;if(h){var g=e._tmpVecs[3];n.subtractToRef(i,g),a.e.TransformCoordinatesToRef(g,f,g),m=Math.sqrt(g.x*g.x+g.z*g.z);var v=Math.atan2(g.y,m),b=v;v>this._maxPitch?(g.y=this._maxPitchTan*m,b=this._maxPitch):v<this._minPitch&&(g.y=this._minPitchTan*m,b=this._minPitch),v!=b&&(a.e.TransformCoordinatesToRef(g,d,g),g.addInPlace(i),n=g)}if(u){g=e._tmpVecs[4];n.subtractToRef(i,g),a.e.TransformCoordinatesToRef(g,f,g);var y=Math.atan2(g.x,g.z),T=y;if((y>this._maxYaw||y<this._minYaw)&&(null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z)),this._yawRange>Math.PI?this._isAngleBetween(y,this._maxYaw,this._midYawConstraint)?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,T=this._maxYaw):this._isAngleBetween(y,this._midYawConstraint,this._minYaw)&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,T=this._minYaw):y>this._maxYaw?(g.z=this._maxYawCos*m,g.x=this._maxYawSin*m,T=this._maxYaw):y<this._minYaw&&(g.z=this._minYawCos*m,g.x=this._minYawSin*m,T=this._minYaw)),this._slerping&&this._yawRange>Math.PI){var E=e._tmpVecs[8];E.copyFrom(J.a.Z),this._transformYawPitch&&a.e.TransformCoordinatesToRef(E,this._transformYawPitchInv,E);var S=e._tmpMats[4];this._boneQuat.toRotationMatrix(S),this.mesh.getWorldMatrix().multiplyToRef(S,S),a.e.TransformCoordinatesToRef(E,S,E),a.e.TransformCoordinatesToRef(E,f,E);var A=Math.atan2(E.x,E.z);if(this._getAngleBetween(A,y)>this._getAngleBetween(A,this._midYawConstraint)){null==m&&(m=Math.sqrt(g.x*g.x+g.z*g.z));var P=this._getAngleBetween(A,this._maxYaw);this._getAngleBetween(A,this._minYaw)<P?(T=A+.75*Math.PI,g.z=Math.cos(T)*m,g.x=Math.sin(T)*m):(T=A-.75*Math.PI,g.z=Math.cos(T)*m,g.x=Math.sin(T)*m)}}y!=T&&(a.e.TransformCoordinatesToRef(g,d,g),g.addInPlace(i),n=g)}}var C=e._tmpVecs[5],R=e._tmpVecs[6],x=e._tmpVecs[7],O=e._tmpQuat;n.subtractToRef(i,C),C.normalize(),a.e.CrossToRef(l,C,R),R.normalize(),a.e.CrossToRef(C,R,x),x.normalize(),a.a.FromXYZAxesToRef(R,x,C,r),0===R.x&&0===R.y&&0===R.z||0===x.x&&0===x.y&&0===x.z||0===C.x&&0===C.y&&0===C.z||((this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(a.a.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,o),o.multiplyToRef(r,r)),this.slerpAmount<1?(this._slerping||this.bone.getRotationQuaternionToRef(J.c.WORLD,this.mesh,this._boneQuat),this._transformYawPitch&&this._transformYawPitch.multiplyToRef(r,r),a.b.FromRotationMatrixToRef(r,O),a.b.SlerpToRef(this._boneQuat,O,this.slerpAmount,this._boneQuat),this.bone.setRotationQuaternion(this._boneQuat,J.c.WORLD,this.mesh),this._slerping=!0):(this._transformYawPitch&&this._transformYawPitch.multiplyToRef(r,r),this.bone.setRotationMatrix(r,J.c.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=Z.a.BuildArray(10,a.e.Zero),e._tmpQuat=a.b.Identity(),e._tmpMats=Z.a.BuildArray(5,a.a.Identity),e}(),Ke=i(10),Qe=i(27),qe=i(26);function Ze(e,t,i,n){var r;r=n===g.a.TEXTURETYPE_FLOAT?new Float32Array(t*i*4):new Uint32Array(t*i*4);for(var o=0;o<t;o++)for(var a=0;a<i;a++){var s=3*(a*t+o),c=4*(a*t+o);r[c+0]=e[s+0],r[c+1]=e[s+1],r[c+2]=e[s+2],r[c+3]=1}return r}function Je(e){return function(t,i,n,r,o,a,s,c,l,u){void 0===l&&(l=null),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT);var h=e?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,d=e?Qe.b.Raw3D:Qe.b.Raw2DArray,f=new Qe.a(this,d);f.baseWidth=i,f.baseHeight=n,f.baseDepth=r,f.width=i,f.height=n,f.depth=r,f.format=o,f.type=u,f.generateMipMaps=a,f.samplingMode=c,e?f.is3D=!0:f.is2DArray=!0,this._doNotHandleContextLost||(f._bufferView=t),e?this.updateRawTexture3D(f,t,o,s,l,u):this.updateRawTexture2DArray(f,t,o,s,l,u),this._bindTextureDirectly(h,f,!0);var p=this._getSamplingParameters(c,a);return this._gl.texParameteri(h,this._gl.TEXTURE_MAG_FILTER,p.mag),this._gl.texParameteri(h,this._gl.TEXTURE_MIN_FILTER,p.min),a&&this._gl.generateMipmap(h),this._bindTextureDirectly(h,null),this._internalTexturesCache.push(f),f}}function $e(e){return function(t,i,n,r,o,a){void 0===o&&(o=null),void 0===a&&(a=g.a.TEXTURETYPE_UNSIGNED_INT);var s=e?this._gl.TEXTURE_3D:this._gl.TEXTURE_2D_ARRAY,c=this._getWebGLTextureType(a),l=this._getInternalFormat(n),u=this._getRGBABufferInternalSizedFormat(a,n);this._bindTextureDirectly(s,t,!0),this._unpackFlipY(void 0===r||!!r),this._doNotHandleContextLost||(t._bufferView=i,t.format=n,t.invertY=r,t._compression=o),t.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&i?this._gl.compressedTexImage3D(s,0,this.getCaps().s3tc[o],t.width,t.height,t.depth,0,i):this._gl.texImage3D(s,0,u,t.width,t.height,t.depth,0,l,c,i),t.generateMipMaps&&this._gl.generateMipmap(s),this._bindTextureDirectly(s,null),t.isReady=!0}}qe.a.prototype.updateRawTexture=function(e,t,i,n,r,o){if(void 0===r&&(r=null),void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),e){var a=this._getRGBABufferInternalSizedFormat(o,i),s=this._getInternalFormat(i),c=this._getWebGLTextureType(o);this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===n||!!n),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.type=o,e.invertY=n,e._compression=r),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),r&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[r],e.width,e.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,e.width,e.height,0,s,c,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}},qe.a.prototype.createRawTexture=function(e,t,i,n,r,o,a,s,c){void 0===s&&(s=null),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT);var l=new Qe.a(this,Qe.b.Raw);l.baseWidth=t,l.baseHeight=i,l.width=t,l.height=i,l.format=n,l.generateMipMaps=r,l.samplingMode=a,l.invertY=o,l._compression=s,l.type=c,this._doNotHandleContextLost||(l._bufferView=e),this.updateRawTexture(l,e,n,o,s,c),this._bindTextureDirectly(this._gl.TEXTURE_2D,l,!0);var u=this._getSamplingParameters(a,r);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,u.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,u.min),r&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(l),l},qe.a.prototype.createRawCubeTexture=function(e,t,i,n,r,o,a,s){void 0===s&&(s=null);var c=this._gl,l=new Qe.a(this,Qe.b.CubeRaw);l.isCube=!0,l.format=i,l.type=n,this._doNotHandleContextLost||(l._bufferViewArray=e);var u=this._getWebGLTextureType(n),h=this._getInternalFormat(i);h===c.RGB&&(h=c.RGBA),u!==c.FLOAT||this._caps.textureFloatLinearFiltering?u!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?u!==c.FLOAT||this._caps.textureFloatRender?u!==c.HALF_FLOAT||this._caps.colorBufferFloat||(r=!1,m.a.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(r=!1,m.a.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(r=!1,a=g.a.TEXTURE_NEAREST_SAMPLINGMODE,m.a.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(r=!1,a=g.a.TEXTURE_NEAREST_SAMPLINGMODE,m.a.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var d=t,f=d;l.width=d,l.height=f,!this.needPOTTextures||Ce.b.IsExponentOfTwo(l.width)&&Ce.b.IsExponentOfTwo(l.height)||(r=!1),e&&this.updateRawCubeTexture(l,e,i,n,o,s),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,l,!0),e&&r&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var p=this._getSamplingParameters(a,r);return c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,p.mag),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,p.min),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),l.generateMipMaps=r,l},qe.a.prototype.updateRawCubeTexture=function(e,t,i,n,r,o,a){void 0===o&&(o=null),void 0===a&&(a=0),e._bufferViewArray=t,e.format=i,e.type=n,e.invertY=r,e._compression=o;var s=this._gl,c=this._getWebGLTextureType(n),l=this._getInternalFormat(i),u=this._getRGBABufferInternalSizedFormat(n),h=!1;l===s.RGB&&(l=s.RGBA,h=!0),this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(void 0===r||!!r),e.width%4!=0&&s.pixelStorei(s.UNPACK_ALIGNMENT,1);for(var d=0;d<6;d++){var f=t[d];o?s.compressedTexImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+d,a,this.getCaps().s3tc[o],e.width,e.height,0,f):(h&&(f=Ze(f,e.width,e.height,n)),s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+d,a,u,e.width,e.height,0,l,c,f))}(!this.needPOTTextures||Ce.b.IsExponentOfTwo(e.width)&&Ce.b.IsExponentOfTwo(e.height))&&e.generateMipMaps&&0===a&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),e.isReady=!0},qe.a.prototype.createRawCubeTextureFromUrl=function(e,t,i,n,r,o,a,s,c,l,u,h){var d=this;void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===h&&(h=!1);var f=this._gl,p=this.createRawCubeTexture(null,i,n,r,!o,h,u,null);null==t||t._addPendingData(p),p.url=e,this._internalTexturesCache.push(p);return this._loadFile(e,(function(e){!function(e){var i=p.width,o=a(e);if(o){if(s){var l=d._getWebGLTextureType(r),u=d._getInternalFormat(n),_=d._getRGBABufferInternalSizedFormat(r),m=!1;u===f.RGB&&(u=f.RGBA,m=!0),d._bindTextureDirectly(f.TEXTURE_CUBE_MAP,p,!0),d._unpackFlipY(!1);for(var g=s(o),v=0;v<g.length;v++)for(var b=i>>v,y=0;y<6;y++){var T=g[v][y];m&&(T=Ze(T,b,b,r)),f.texImage2D(y,v,_,b,b,0,u,l,T)}d._bindTextureDirectly(f.TEXTURE_CUBE_MAP,null)}else d.updateRawCubeTexture(p,o,n,r,h);p.isReady=!0,null==t||t._removePendingData(p),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,i){null==t||t._removePendingData(p),l&&e&&l(e.status+" "+e.statusText,i)})),p},qe.a.prototype.createRawTexture2DArray=Je(!1),qe.a.prototype.createRawTexture3D=Je(!0),qe.a.prototype.updateRawTexture2DArray=$e(!1),qe.a.prototype.updateRawTexture3D=$e(!0);var et=function(e){function t(t,i,n,r,o,a,s,c,l){void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===c&&(c=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,null,o,!a,s)||this;return u.format=r,u._engine?(u._texture=u._engine.createRawTexture(t,i,n,r,a,s,c,null,l),u.wrapU=Ke.a.CLAMP_ADDRESSMODE,u.wrapV=Ke.a.CLAMP_ADDRESSMODE,u):u}return Object(h.d)(t,e),t.prototype.update=function(e){this._getEngine().updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t.CreateLuminanceTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_LUMINANCE,r,o,a,s)},t.CreateLuminanceAlphaTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,a,s)},t.CreateAlphaTexture=function(e,i,n,r,o,a,s){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),new t(e,i,n,g.a.TEXTUREFORMAT_ALPHA,r,o,a,s)},t.CreateRGBTexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,n,g.a.TEXTUREFORMAT_RGB,r,o,a,s,c)},t.CreateRGBATexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),new t(e,i,n,g.a.TEXTUREFORMAT_RGBA,r,o,a,s,c)},t.CreateRTexture=function(e,i,n,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_FLOAT),new t(e,i,n,g.a.TEXTUREFORMAT_R,r,o,a,s,c)},t}(Ke.a),tt=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=a.a.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this._waitingOverrideMeshId=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new o.c,this.bones=[],this._scene=i||x.a.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var n=this._scene.getEngine().getCaps();this._canUseTextureForBones=n.textureFloat&&n.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,"useTextureToStoreBoneMatrices",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"Skeleton"},e.prototype.getChildren=function(){return this.bones.filter((function(e){return!e.getParent()}))},e.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},e.prototype.getTransformMatrixTexture=function(e){return this.needInitialSkinMatrix&&e._transformMatrixTexture?e._transformMatrixTexture: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 n in this._ranges)i&&(t+=", ",i=!1),t+=n;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 F(e,t,i);for(var n=0,r=this.bones.length;n<r;n++)this.bones[n].animations[0]&&this.bones[n].animations[0].createRange(e,t,i)}},e.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,n=this.bones.length;i<n;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]||null},e.prototype.getAnimationRanges=function(){var e,t=[];for(e in this._ranges)t.push(this._ranges[e]);return t},e.prototype.copyAnimationRange=function(e,t,i){if(void 0===i&&(i=!1),this._ranges[t]||!e.getAnimationRange(t))return!1;var n,r,o=!0,a=this._getHighestAnimationFrame()+1,s={},c=e.bones;for(r=0,n=c.length;r<n;r++)s[c[r].name]=c[r];this.bones.length!==c.length&&(m.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(r=0,n=this.bones.length;r<n;r++){var u=this.bones[r].name,h=s[u];h?o=o&&this.bones[r].copyAnimationRange(h,t,a,i,l):(m.a.Warn("copyAnimationRange: not same rig, missing source bone "+u),o=!1)}var d=e.getAnimationRange(t);return d&&(this._ranges[t]=new F(t,d.from+a,d.to+a)),o},e.prototype.returnToRest=function(){for(var e=a.c.Vector3[0],t=a.c.Quaternion[0],i=a.c.Vector3[1],n=0;n<this.bones.length;n++){var r=this.bones[n];-1!==r._index&&(r.returnToRest(),r._linkedTransformNode&&(r.getRestPose().decompose(e,t,i),r._linkedTransformNode.position=i.clone(),r._linkedTransformNode.rotationQuaternion=t.clone(),r._linkedTransformNode.scaling=e.clone()))}},e.prototype._getHighestAnimationFrame=function(){for(var e=0,t=0,i=this.bones.length;t<i;t++)if(this.bones[t].animations[0]){var n=this.bones[t].animations[0].getHighestFrame();e<n&&(e=n)}return e},e.prototype.beginAnimation=function(e,t,i,n){var r=this.getAnimationRange(e);return r?this._scene.beginAnimation(this,r.from,r.to,t,i,n):null},e.MakeAnimationAdditive=function(e,t,i){void 0===t&&(t=0);var n=e.getAnimationRange(i);if(!n)return null;for(var r=e._scene.getAllAnimatablesByTarget(e),o=null,a=0;a<r.length;a++){var s=r[a];if(s.fromFrame===(null==n?void 0:n.from)&&s.toFrame===(null==n?void 0:n.to)){o=s;break}}var c=e.getAnimatables();for(a=0;a<c.length;a++){var l=c[a].animations;if(l)for(var u=0;u<l.length;u++)z.MakeAnimationAdditive(l[u],t,i)}return o&&(o.isAdditive=!0),e},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 n=this.bones[i];n._childUpdateId++;var r=n.getParent();if(r?n.getLocalMatrix().multiplyToRef(r.getWorldMatrix(),n.getWorldMatrix()):t?n.getLocalMatrix().multiplyToRef(t,n.getWorldMatrix()):n.getWorldMatrix().copyFrom(n.getLocalMatrix()),-1!==n._index){var o=null===n._index?i:n._index;n.getInvertedAbsoluteTransform().multiplyToArray(n.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 n=0;n<this._meshesWithPoseMatrix.length;n++){var r=this._meshesWithPoseMatrix[n],o=r.getPoseMatrix();if(r._bonesTransformMatrices&&r._bonesTransformMatrices.length===16*(this.bones.length+1)||(r._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1))),this._synchronizedWithMesh!==r){this._synchronizedWithMesh=r;for(var s=0;s<this.bones.length;s++){var c=this.bones[s];if(!c.getParent())c.getBaseMatrix().multiplyToRef(o,a.c.Matrix[1]),c._updateDifferenceMatrix(a.c.Matrix[1])}if(this.isUsingTextureForMatrices){var l=4*(this.bones.length+1);r._transformMatrixTexture&&r._transformMatrixTexture.getSize().width===l||(r._transformMatrixTexture&&r._transformMatrixTexture.dispose(),r._transformMatrixTexture=et.CreateRGBATexture(r._bonesTransformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,g.a.TEXTURE_NEAREST_SAMPLINGMODE,g.a.TEXTURETYPE_FLOAT))}}this._computeTransformMatrices(r._bonesTransformMatrices,o),this.isUsingTextureForMatrices&&r._transformMatrixTexture&&r._transformMatrixTexture.update(r._bonesTransformMatrices)}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=et.CreateRGBATexture(this._transformMatrices,4*(this.bones.length+1),1,this._scene,!1,!1,g.a.TEXTURE_NEAREST_SAMPLINGMODE,g.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 n=new e(t,i||t,this._scene);n.needInitialSkinMatrix=this.needInitialSkinMatrix,n.overrideMesh=this.overrideMesh;for(var r=0;r<this.bones.length;r++){var o=this.bones[r],a=null,s=o.getParent();if(s){var c=this.bones.indexOf(s);a=n.bones[c]}var l=new $(o.name,n,a,o.getBaseMatrix().clone(),o.getRestPose().clone());l._index=o._index,o._linkedTransformNode&&l.linkTransformNode(o._linkedTransformNode),O.a.DeepCopy(o.animations,l.animations)}if(this._ranges)for(var u in n._ranges={},this._ranges){var h=this._ranges[u];h&&(n._ranges[u]=h.clone())}return this._isDirty=!0,n},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,t,i={};i.name=this.name,i.id=this.id,this.dimensionsAtRest&&(i.dimensionsAtRest=this.dimensionsAtRest.asArray()),i.bones=[],i.needInitialSkinMatrix=this.needInitialSkinMatrix,i.overrideMeshId=null===(e=this.overrideMesh)||void 0===e?void 0:e.id;for(var n=0;n<this.bones.length;n++){var r=this.bones[n],o=r.getParent(),a={parentBoneIndex:o?this.bones.indexOf(o):-1,index:r.getIndex(),name:r.name,matrix:r.getBaseMatrix().toArray(),rest:r.getRestPose().toArray(),linkedTransformNodeId:null===(t=r.getTransformNode())||void 0===t?void 0:t.id};for(var s in i.bones.push(a),r.length&&(a.length=r.length),r.metadata&&(a.metadata=r.metadata),r.animations&&r.animations.length>0&&(a.animation=r.animations[0].serialize()),i.ranges=[],this._ranges){var c=this._ranges[s];if(c){var l={};l.name=s,l.from=c.from,l.to=c.to,i.ranges.push(l)}}}return i},e.Parse=function(t,i){var n,r=new e(t.name,t.id,i);for(t.dimensionsAtRest&&(r.dimensionsAtRest=a.e.FromArray(t.dimensionsAtRest)),r.needInitialSkinMatrix=t.needInitialSkinMatrix,t.overrideMeshId&&(r._hasWaitingData=!0,r._waitingOverrideMeshId=t.overrideMeshId),n=0;n<t.bones.length;n++){var o=t.bones[n],s=t.bones[n].index,c=null;o.parentBoneIndex>-1&&(c=r.bones[o.parentBoneIndex]);var l=o.rest?a.a.FromArray(o.rest):null,u=new $(o.name,r,c,a.a.FromArray(o.matrix),l,null,s);void 0!==o.id&&null!==o.id&&(u.id=o.id),o.length&&(u.length=o.length),o.metadata&&(u.metadata=o.metadata),o.animation&&u.animations.push(z.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(r._hasWaitingData=!0,u._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(n=0;n<t.ranges.length;n++){var h=t.ranges[n];r.createAnimationRange(h.name,h.from,h.to)}return r},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 n=this.bones[e];void 0===n._index&&(n._index=e);var r=n.getParent();r&&this._sortBones(this.bones.indexOf(r),t,i),t.push(n)}},e.prototype.setCurrentPoseAsRest=function(){this.bones.forEach((function(e){e.setCurrentPoseAsRest()}))},e}(),it={},nt=function(){function e(e){this.attachedToElement=!1,this.attached={},this.camera=e,this.checkInputs=function(){}}return e.prototype.add=function(e){var t=e.getSimpleName();this.attached[t]?m.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.attachedToElement&&e.attachControl())},e.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(),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(),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.attachedToElement&&e.attachControl(this.noPreventDefault)},e.prototype.attachElement=function(e){if(void 0===e&&(e=!1),!this.attachedToElement)for(var t in e=!je.a.ForceAttachControlToAlwaysPreventDefault&&e,this.attachedToElement=!0,this.noPreventDefault=e,this.attached)this.attached[t].attachControl(e)},e.prototype.detachElement=function(e){for(var t in void 0===e&&(e=!1),this.attached)this.attached[t].detachControl(),e&&(this.attached[t].camera=null);this.attachedToElement=!1},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.attachedToElement&&this.detachElement(!0),this.attached={},this.attachedToElement=!1,this.checkInputs=function(){}},e.prototype.serialize=function(e){var t={};for(var i in this.attached){var n=this.attached[i],r=w.a.Serialize(n);t[n.getClassName()]=r}e.inputsmgr=t},e.prototype.parse=function(e){var t=e.inputsmgr;if(t)for(var i in this.clear(),t){if(o=it[i]){var n=t[i],r=w.a.Parse((function(){return new o}),n,null);this.add(r)}}else for(var i in this.attached){var o;if(o=it[this.attached[i].getClassName()]){r=w.a.Parse((function(){return new o}),e,null);this.remove(this.attached[i]),this.add(r)}}},e}(),rt=function(e,t){this.x=e,this.y=t},ot=function(){function e(t,i,n,r,o,a,s){void 0===r&&(r=0),void 0===o&&(o=1),void 0===a&&(a=2),void 0===s&&(s=3),this.id=t,this.index=i,this.browserGamepad=n,this._leftStick={x:0,y:0},this._rightStick={x:0,y:0},this._isConnected=!0,this._invertLeftStickY=!1,this.type=e.GAMEPAD,this._leftStickAxisX=r,this._leftStickAxisY=o,this._rightStickAxisX=a,this._rightStickAxisY=s,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:!1,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:!1,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:!1,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.DUALSHOCK=4,e}(),at=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.onButtonDownObservable=new o.c,r.onButtonUpObservable=new o.c,r.type=ot.GENERIC,r._buttons=new Array(n.buttons.length),r}return Object(h.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}(ot),st=function(){function e(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40,this._yAxisScale=1}return Object.defineProperty(e.prototype,"invertYAxis",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add((function(t){t.type!==ot.POSE_ENABLED&&(e.gamepad&&t.type!==ot.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(ot.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 n=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=n&&Math.abs(n)>.005&&(e.inertialBetaOffset+=n)}}var r=this.gamepad.leftStick;if(r&&0!=r.y){var o=r.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"},Object(h.c)([Object(w.c)()],e.prototype,"gamepadRotationSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();it.ArcRotateCameraGamepadInput=st;var ct=i(66),lt=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===ct.a.KEYDOWN?(t._ctrlPressed=r.ctrlKey,t._altPressed=r.altKey,(-1!==t.keysUp.indexOf(r.keyCode)||-1!==t.keysDown.indexOf(r.keyCode)||-1!==t.keysLeft.indexOf(r.keyCode)||-1!==t.keysRight.indexOf(r.keyCode)||-1!==t.keysReset.indexOf(r.keyCode))&&(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),r.preventDefault&&(e||r.preventDefault()))):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysReset.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),r.preventDefault&&(e||r.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"},Object(h.c)([Object(w.c)()],e.prototype,"keysUp",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysDown",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysLeft",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRight",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysReset",void 0),Object(h.c)([Object(w.c)()],e.prototype,"panningSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"zoomingSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"useAltToZoom",void 0),Object(h.c)([Object(w.c)()],e.prototype,"angularSpeed",void 0),e}();it.ArcRotateCameraKeyboardMoveInput=lt;var ut=function(){function e(){this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.computeDeltaFromMouseWheelLegacyEvent=function(e,t){var i=.01*e*this.wheelDeltaPercentage*t;return e>0?i/(1+this.wheelDeltaPercentage):i*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i,n){if(i.type===Ne.a.POINTERWHEEL){var r=i.event,o=0,a=r,s=0;if(s=a.wheelDelta?a.wheelDelta:60*-(r.deltaY||r.detail),t.wheelDeltaPercentage){if((o=t.computeDeltaFromMouseWheelLegacyEvent(s,t.camera.radius))>0){for(var c=t.camera.radius,l=t.camera.inertialRadiusOffset+o,u=0;u<20&&Math.abs(l)>.001;u++)c-=l,l*=t.camera.inertia;c=L.a.Clamp(c,0,Number.MAX_VALUE),o=t.computeDeltaFromMouseWheelLegacyEvent(s,c)}}else o=s/(40*t.wheelPrecision);o&&(t.camera.inertialRadiusOffset+=o),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ne.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(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"},Object(h.c)([Object(w.c)()],e.prototype,"wheelPrecision",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();it.ArcRotateCameraMouseWheelInput=ut;var ht=function(){function e(){this.buttons=[0,1,2]}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments);var i=this.camera.getEngine(),n=i.getInputElement(),r=0,o=null;this.pointA=null,this.pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=function(a,s){var c=a.event,l="touch"===c.pointerType;if(!i.isInVRExclusivePointerMode&&(a.type===Ne.a.POINTERMOVE||-1!==t.buttons.indexOf(c.button))){var u=c.srcElement||c.target;if(t._altKey=c.altKey,t._ctrlKey=c.ctrlKey,t._metaKey=c.metaKey,t._shiftKey=c.shiftKey,t._buttonsPressed=c.buttons,i.isPointerLock){var h=c.movementX||c.mozMovementX||c.webkitMovementX||c.msMovementX||0,d=c.movementY||c.mozMovementY||c.webkitMovementY||c.msMovementY||0;t.onTouch(null,h,d),t.pointA=null,t.pointB=null}else if(a.type===Ne.a.POINTERDOWN&&u){try{u.setPointerCapture(c.pointerId)}catch(e){}null===t.pointA?t.pointA={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}:null===t.pointB&&(t.pointB={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}),t.onButtonDown(c),e||(c.preventDefault(),n&&n.focus())}else if(a.type===Ne.a.POINTERDOUBLETAP)t.onDoubleTap(c.pointerType);else if(a.type===Ne.a.POINTERUP&&u){try{u.releasePointerCapture(c.pointerId)}catch(e){}l||(t.pointB=null),i._badOS?t.pointA=t.pointB=null:t.pointB&&t.pointA&&t.pointA.pointerId==c.pointerId?(t.pointA=t.pointB,t.pointB=null):t.pointA&&t.pointB&&t.pointB.pointerId==c.pointerId?t.pointB=null:t.pointA=t.pointB=null,(0!==r||o)&&(t.onMultiTouch(t.pointA,t.pointB,r,0,o,null),r=0,o=null),t.onButtonUp(c),e||c.preventDefault()}else if(a.type===Ne.a.POINTERMOVE)if(e||c.preventDefault(),t.pointA&&null===t.pointB){h=c.clientX-t.pointA.x,d=c.clientY-t.pointA.y;t.onTouch(t.pointA,h,d),t.pointA.x=c.clientX,t.pointA.y=c.clientY}else if(t.pointA&&t.pointB){var f=t.pointA.pointerId===c.pointerId?t.pointA:t.pointB;f.x=c.clientX,f.y=c.clientY;var p=t.pointA.x-t.pointB.x,_=t.pointA.y-t.pointB.y,m=p*p+_*_,g={x:(t.pointA.x+t.pointB.x)/2,y:(t.pointA.y+t.pointB.y)/2,pointerId:c.pointerId,type:a.type};t.onMultiTouch(t.pointA,t.pointB,r,m,o,g),o=g,r=m}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ne.a.POINTERDOWN|Ne.a.POINTERUP|Ne.a.POINTERMOVE),this._onLostFocus=function(){t.pointA=t.pointB=null,r=0,o=null,t.onLostFocus()},n&&n.addEventListener("contextmenu",this.onContextMenu.bind(this),!1);var a=this.camera.getScene().getEngine().getHostWindow();a&&Ce.b.RegisterTopRootEvents(a,[{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){if(this._onLostFocus){var t=this.camera.getScene().getEngine().getHostWindow();t&&Ce.b.UnregisterTopRootEvents(t,[{name:"blur",handler:this._onLostFocus}])}if(this._observer){if(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu){var i=this.camera.getScene().getEngine().getInputElement();i&&i.removeEventListener("contextmenu",this.onContextMenu)}this._onLostFocus=null}this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0},e.prototype.getClassName=function(){return"BaseCameraPointersInput"},e.prototype.getSimpleName=function(){return"pointers"},e.prototype.onDoubleTap=function(e){},e.prototype.onTouch=function(e,t,i){},e.prototype.onMultiTouch=function(e,t,i,n,r,o){},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.onButtonDown=function(e){},e.prototype.onButtonUp=function(e){},e.prototype.onLostFocus=function(){},Object(h.c)([Object(w.c)()],e.prototype,"buttons",void 0),e}(),dt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.useNaturalPinchZoom=!1,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.onTouch=function(e,t,i){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=i/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=i/this.angularSensibilityY)},t.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,i,n,r,o){if(!(0===i&&null===r||0===n&&null===o)){var a=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.useNaturalPinchZoom?this.camera.radius=this.camera.radius*Math.sqrt(i)/Math.sqrt(n):this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(n-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(n-i)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),0!==this.panningSensibility&&r&&o){var s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/this.panningSensibility}}else{this._twoFingerActivityCount++;var l=Math.sqrt(i),u=Math.sqrt(n);if(this._isPinching||this._twoFingerActivityCount<20&&Math.abs(u-l)>this.camera.pinchToPanMaxDistance)this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(n-i)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(n-i)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0;else if(0!==this.panningSensibility&&this.multiTouchPanning&&o&&r){s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/this.panningSensibility}}}},t.prototype.onButtonDown=function(e){this._isPanClick=e.button===this.camera._panningMouseButton},t.prototype.onButtonUp=function(e){this._twoFingerActivityCount=0,this._isPinching=!1},t.prototype.onLostFocus=function(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1},Object(h.c)([Object(w.c)()],t.prototype,"buttons",void 0),Object(h.c)([Object(w.c)()],t.prototype,"angularSensibilityX",void 0),Object(h.c)([Object(w.c)()],t.prototype,"angularSensibilityY",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchPrecision",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchDeltaPercentage",void 0),Object(h.c)([Object(w.c)()],t.prototype,"useNaturalPinchZoom",void 0),Object(h.c)([Object(w.c)()],t.prototype,"panningSensibility",void 0),Object(h.c)([Object(w.c)()],t.prototype,"multiTouchPanning",void 0),Object(h.c)([Object(w.c)()],t.prototype,"multiTouchPanAndZoom",void 0),t}(ht);it.ArcRotateCameraPointersInput=dt;var ft=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addMouseWheel=function(){return this.add(new ut),this},t.prototype.addPointers=function(){return this.add(new dt),this},t.prototype.addKeyboard=function(){return this.add(new lt),this},t}(nt);ft.prototype.addVRDeviceOrientation=function(){return this.add(new pt),this};var pt=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.camera.attachControl(e);var i=this.camera.getScene().getEngine().getHostWindow();i&&("undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i.addEventListener("deviceorientation",t._deviceOrientationHandler):Ce.b.Warn("Permission not granted.")})).catch((function(e){Ce.b.Error(e)})):i.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}();it.ArcRotateCameraVRDeviceOrientationInput=pt;var _t=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;i.type===ct.a.KEYDOWN?-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysForward.indexOf(r.keyCode)&&-1===t.keysBackward.indexOf(r.keyCode)&&-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.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],n=e._computeLocalCameraSpeed();-1!==this.keysForward.indexOf(i)?e._localDirection.copyFromFloats(0,0,n):-1!==this.keysBackward.indexOf(i)?e._localDirection.copyFromFloats(0,0,-n):-1!==this.keysUp.indexOf(i)?e._localDirection.copyFromFloats(0,n,0):-1!==this.keysDown.indexOf(i)?e._localDirection.copyFromFloats(0,-n,0):-1!==this.keysRight.indexOf(i)?e._localDirection.copyFromFloats(n,0,0):-1!==this.keysLeft.indexOf(i)&&e._localDirection.copyFromFloats(-n,0,0),e.getScene().useRightHandedSystem&&(e._localDirection.z*=-1),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),a.e.TransformNormalToRef(e._localDirection,e._cameraTransformMatrix,e._transformedDirection),e.cameraDirection.addInPlace(e._transformedDirection)}},Object(h.c)([Object(w.c)()],e.prototype,"keysForward",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysBackward",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysUp",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysDown",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRight",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysLeft",void 0),e}();it.FlyCameraKeyboardInput=_t;var mt=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.noPreventDefault=e,this._observer=this.camera.getScene().onPointerObservable.add((function(e,i){t._pointerInput(e,i)}),Ne.a.POINTERDOWN|Ne.a.POINTERUP|Ne.a.POINTERMOVE),this._rollObserver=this.camera.getScene().onBeforeRenderObservable.add((function(){t.camera.rollCorrect&&t.camera.restoreRoll(t.camera.rollCorrect)}))},e.prototype.detachControl=function(e){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver),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,n=this.camera.getEngine();if(!n.isInVRExclusivePointerMode&&(this.touchEnabled||"touch"!==i.pointerType)&&(e.type===Ne.a.POINTERMOVE||-1!==this.buttons.indexOf(i.button))){var r=i.srcElement||i.target;if(e.type===Ne.a.POINTERDOWN&&r){try{r.setPointerCapture(i.pointerId)}catch(i){}this.previousPosition={x:i.clientX,y:i.clientY},this.activeButton=i.button,this.noPreventDefault||(i.preventDefault(),this.element.focus()),n.isPointerLock&&this._onMouseMove(e.event)}else if(e.type===Ne.a.POINTERUP&&r){try{r.releasePointerCapture(i.pointerId)}catch(i){}this.activeButton=-1,this.previousPosition=null,this.noPreventDefault||i.preventDefault()}else if(e.type===Ne.a.POINTERMOVE){if(!this.previousPosition)return void(n.isPointerLock&&this._onMouseMove(e.event));var o=i.clientX-this.previousPosition.x,a=i.clientY-this.previousPosition.y;this.rotateCamera(o,a),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,n=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;this.rotateCamera(i,n),this.previousPosition=null,this.noPreventDefault||e.preventDefault()}},e.prototype.rotateCamera=function(e,t){var i=this,n=this.camera;this.camera.getScene().useRightHandedSystem&&(e*=-1),n.parent&&n.parent._getWorldMatrixDeterminant()<0&&(e*=-1);var r,o=e/this.angularSensibility,s=t/this.angularSensibility,c=a.b.RotationYawPitchRoll(n.rotation.y,n.rotation.x,n.rotation.z);if(this.buttonsPitch.some((function(e){return e===i.activeButton}))&&(r=a.b.RotationAxis(J.a.X,s),c.multiplyInPlace(r)),this.buttonsYaw.some((function(e){return e===i.activeButton}))){r=a.b.RotationAxis(J.a.Y,o),c.multiplyInPlace(r);var l=n.bankedTurnLimit+n._trackRoll;if(n.bankedTurn&&-l<n.rotation.z&&n.rotation.z<l){var u=n.bankedTurnMultiplier*-o;r=a.b.RotationAxis(J.a.Z,u),c.multiplyInPlace(r)}}this.buttonsRoll.some((function(e){return e===i.activeButton}))&&(r=a.b.RotationAxis(J.a.Z,-o),n._trackRoll-=o,c.multiplyInPlace(r)),c.toEulerAnglesToRef(n.rotation)},Object(h.c)([Object(w.c)()],e.prototype,"buttons",void 0),Object(h.c)([Object(w.c)()],e.prototype,"angularSensibility",void 0),e}();it.FlyCameraMouseInput=mt;var gt=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){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===ct.a.KEYDOWN?(t._ctrlPressed=r.ctrlKey,t._altPressed=r.altKey,t._shiftPressed=r.shiftKey,(-1!==t.keysHeightOffsetIncr.indexOf(r.keyCode)||-1!==t.keysHeightOffsetDecr.indexOf(r.keyCode)||-1!==t.keysRotationOffsetIncr.indexOf(r.keyCode)||-1!==t.keysRotationOffsetDecr.indexOf(r.keyCode)||-1!==t.keysRadiusIncr.indexOf(r.keyCode)||-1!==t.keysRadiusDecr.indexOf(r.keyCode))&&(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),r.preventDefault&&(e||r.preventDefault()))):-1===t.keysHeightOffsetIncr.indexOf(r.keyCode)&&-1===t.keysHeightOffsetDecr.indexOf(r.keyCode)&&-1===t.keysRotationOffsetIncr.indexOf(r.keyCode)&&-1===t.keysRotationOffsetDecr.indexOf(r.keyCode)&&-1===t.keysRadiusIncr.indexOf(r.keyCode)&&-1===t.keysRadiusDecr.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),r.preventDefault&&(e||r.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},Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetIncr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetDecr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetModifierAlt",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysHeightOffsetModifierShift",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetIncr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetDecr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetModifierAlt",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRotationOffsetModifierShift",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusIncr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusDecr",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusModifierAlt",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusModifierCtrl",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRadiusModifierShift",void 0),Object(h.c)([Object(w.c)()],e.prototype,"heightSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"rotationSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"radiusSensibility",void 0),e}();it.FollowCameraKeyboardMoveInput=gt;var vt=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i,n){if(i.type===Ne.a.POINTERWHEEL){var r=i.event,o=0,a=Math.max(-1,Math.min(1,r.deltaY||r.wheelDelta||-r.detail));t.wheelDeltaPercentage?(console.assert(t.axisControlRadius+t.axisControlHeight+t.axisControlRotation<=1,"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: "+t.axisControlRadius+", axisControlHeightOffset: "+t.axisControlHeight+", axisControlRotationOffset: "+t.axisControlRotation),t.axisControlRadius?o=.01*a*t.wheelDeltaPercentage*t.camera.radius:t.axisControlHeight?o=.01*a*t.wheelDeltaPercentage*t.camera.heightOffset:t.axisControlRotation&&(o=.01*a*t.wheelDeltaPercentage*t.camera.rotationOffset)):o=a*t.wheelPrecision,o&&(t.axisControlRadius?t.camera.radius+=o:t.axisControlHeight?t.camera.heightOffset-=o:t.axisControlRotation&&(t.camera.rotationOffset-=o)),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ne.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(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"},Object(h.c)([Object(w.c)()],e.prototype,"axisControlRadius",void 0),Object(h.c)([Object(w.c)()],e.prototype,"axisControlHeight",void 0),Object(h.c)([Object(w.c)()],e.prototype,"axisControlRotation",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelPrecision",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();it.FollowCameraMouseWheelInput=vt;var bt=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.angularSensibilityX=1,t.angularSensibilityY=1,t.pinchPrecision=1e4,t.pinchDeltaPercentage=0,t.axisXControlRadius=!1,t.axisXControlHeight=!1,t.axisXControlRotation=!0,t.axisYControlRadius=!1,t.axisYControlHeight=!0,t.axisYControlRotation=!1,t.axisPinchControlRadius=!0,t.axisPinchControlHeight=!1,t.axisPinchControlRotation=!1,t.warningEnable=!0,t._warningCounter=0,t}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FollowCameraPointersInput"},t.prototype.onTouch=function(e,t,i){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=i/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=i/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=i/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,i,n,r,o){if(!(0===i&&null===r||0===n&&null===o)){var a=(n-i)/(this.pinchPrecision*(this.angularSensibilityX+this.angularSensibilityY)/2);this.pinchDeltaPercentage?(a*=.01*this.pinchDeltaPercentage,this.axisPinchControlRotation&&(this.camera.rotationOffset+=a*this.camera.rotationOffset),this.axisPinchControlHeight&&(this.camera.heightOffset+=a*this.camera.heightOffset),this.axisPinchControlRadius&&(this.camera.radius-=a*this.camera.radius)):(this.axisPinchControlRotation&&(this.camera.rotationOffset+=a),this.axisPinchControlHeight&&(this.camera.heightOffset+=a),this.axisPinchControlRadius&&(this.camera.radius-=a))}},t.prototype._warning=function(){if(this.warningEnable&&this._warningCounter++%100==0){var e="It probably only makes sense to control ONE camera property with each pointer axis. Set 'warningEnable = false' if you are sure. Currently enabled: ";console.assert(this.axisXControlRotation+this.axisXControlHeight+this.axisXControlRadius<=1,e+"axisXControlRotation: "+this.axisXControlRotation+", axisXControlHeight: "+this.axisXControlHeight+", axisXControlRadius: "+this.axisXControlRadius),console.assert(this.axisYControlRotation+this.axisYControlHeight+this.axisYControlRadius<=1,e+"axisYControlRotation: "+this.axisYControlRotation+", axisYControlHeight: "+this.axisYControlHeight+", axisYControlRadius: "+this.axisYControlRadius),console.assert(this.axisPinchControlRotation+this.axisPinchControlHeight+this.axisPinchControlRadius<=1,e+"axisPinchControlRotation: "+this.axisPinchControlRotation+", axisPinchControlHeight: "+this.axisPinchControlHeight+", axisPinchControlRadius: "+this.axisPinchControlRadius)}},Object(h.c)([Object(w.c)()],t.prototype,"angularSensibilityX",void 0),Object(h.c)([Object(w.c)()],t.prototype,"angularSensibilityY",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchPrecision",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchDeltaPercentage",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisXControlRadius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisXControlHeight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisXControlRotation",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisYControlRadius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisYControlHeight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisYControlRotation",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisPinchControlRadius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisPinchControlHeight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"axisPinchControlRotation",void 0),t}(ht);it.FollowCameraPointersInput=bt;var yt=function(){function e(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){t._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(i){var n,r=i.event;r.metaKey||(i.type===ct.a.KEYDOWN?-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)||(-1===(n=t._keys.indexOf(r.keyCode))&&t._keys.push(r.keyCode),e||r.preventDefault()):-1===t.keysUp.indexOf(r.keyCode)&&-1===t.keysDown.indexOf(r.keyCode)&&-1===t.keysLeft.indexOf(r.keyCode)&&-1===t.keysRight.indexOf(r.keyCode)&&-1===t.keysUpward.indexOf(r.keyCode)&&-1===t.keysDownward.indexOf(r.keyCode)||((n=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(n,1),e||r.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],n=e._computeLocalCameraSpeed();-1!==this.keysLeft.indexOf(i)?e._localDirection.copyFromFloats(-n,0,0):-1!==this.keysUp.indexOf(i)?e._localDirection.copyFromFloats(0,0,n):-1!==this.keysRight.indexOf(i)?e._localDirection.copyFromFloats(n,0,0):-1!==this.keysDown.indexOf(i)?e._localDirection.copyFromFloats(0,0,-n):-1!==this.keysUpward.indexOf(i)?e._localDirection.copyFromFloats(0,n,0):-1!==this.keysDownward.indexOf(i)&&e._localDirection.copyFromFloats(0,-n,0),e.getScene().useRightHandedSystem&&(e._localDirection.z*=-1),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),a.e.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"},Object(h.c)([Object(w.c)()],e.prototype,"keysUp",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysUpward",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysDown",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysDownward",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysLeft",void 0),Object(h.c)([Object(w.c)()],e.prototype,"keysRight",void 0),e}();it.FreeCameraKeyboardMoveInput=yt;var Tt=function(){function e(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this.previousPosition=null,this.onPointerMovedObservable=new o.c,this._allowCameraRotation=!0}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments);var i=this.camera.getEngine(),n=i.getInputElement();this._pointerInput||(this._pointerInput=function(r){var o=r.event;if(!i.isInVRExclusivePointerMode&&(t.touchEnabled||"touch"!==o.pointerType)&&(r.type===Ne.a.POINTERMOVE||-1!==t.buttons.indexOf(o.button))){var a=o.srcElement||o.target;if(r.type===Ne.a.POINTERDOWN&&a){try{a.setPointerCapture(o.pointerId)}catch(e){}t.previousPosition={x:o.clientX,y:o.clientY},e||(o.preventDefault(),n&&n.focus()),i.isPointerLock&&t._onMouseMove&&t._onMouseMove(r.event)}else if(r.type===Ne.a.POINTERUP&&a){try{a.releasePointerCapture(o.pointerId)}catch(e){}t.previousPosition=null,e||o.preventDefault()}else if(r.type===Ne.a.POINTERMOVE){if(!t.previousPosition)return void(i.isPointerLock&&t._onMouseMove&&t._onMouseMove(r.event));var s=o.clientX-t.previousPosition.x,c=o.clientY-t.previousPosition.y;t.camera.getScene().useRightHandedSystem&&(s*=-1),t.camera.parent&&t.camera.parent._getWorldMatrixDeterminant()<0&&(s*=-1),t._allowCameraRotation&&(t.camera.cameraRotation.y+=s/t.angularSensibility,t.camera.cameraRotation.x+=c/t.angularSensibility),t.onPointerMovedObservable.notifyObservers({offsetX:s,offsetY:c}),t.previousPosition={x:o.clientX,y:o.clientY},e||o.preventDefault()}}}),this._onMouseMove=function(n){if(i.isPointerLock&&!i.isInVRExclusivePointerMode){var r=n.movementX||n.mozMovementX||n.webkitMovementX||n.msMovementX||0;t.camera.getScene().useRightHandedSystem&&(r*=-1),t.camera.parent&&t.camera.parent._getWorldMatrixDeterminant()<0&&(r*=-1),t.camera.cameraRotation.y+=r/t.angularSensibility;var o=n.movementY||n.mozMovementY||n.webkitMovementY||n.msMovementY||0;t.camera.cameraRotation.x+=o/t.angularSensibility,t.previousPosition=null,e||n.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ne.a.POINTERDOWN|Ne.a.POINTERUP|Ne.a.POINTERMOVE),n&&n.addEventListener("contextmenu",this.onContextMenu.bind(this),!1)},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.detachControl=function(e){if(this._observer){if(this.camera.getScene().onPointerObservable.remove(this._observer),this.onContextMenu){var t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("contextmenu",this.onContextMenu)}this.onPointerMovedObservable&&this.onPointerMovedObservable.clear(),this._observer=null,this._onMouseMove=null,this.previousPosition=null}},e.prototype.getClassName=function(){return"FreeCameraMouseInput"},e.prototype.getSimpleName=function(){return"mouse"},Object(h.c)([Object(w.c)()],e.prototype,"buttons",void 0),Object(h.c)([Object(w.c)()],e.prototype,"angularSensibility",void 0),e}();it.FreeCameraMouseInput=Tt;var Et,St=function(){function e(){this.wheelPrecisionX=3,this.wheelPrecisionY=3,this.wheelPrecisionZ=3,this.onChangedObservable=new o.c,this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0,this._ffMultiplier=12,this._normalize=120}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(i){if(i.type===Ne.a.POINTERWHEEL){var n=i.event,r=n.deltaMode===WheelEvent.DOM_DELTA_LINE?t._ffMultiplier:1;void 0!==n.deltaY?(t._wheelDeltaX+=t.wheelPrecisionX*r*n.deltaX/t._normalize,t._wheelDeltaY-=t.wheelPrecisionY*r*n.deltaY/t._normalize,t._wheelDeltaZ+=t.wheelPrecisionZ*r*n.deltaZ/t._normalize):void 0!==n.wheelDeltaY?(t._wheelDeltaX+=t.wheelPrecisionX*r*n.wheelDeltaX/t._normalize,t._wheelDeltaY-=t.wheelPrecisionY*r*n.wheelDeltaY/t._normalize,t._wheelDeltaZ+=t.wheelPrecisionZ*r*n.wheelDeltaZ/t._normalize):n.wheelDelta&&(t._wheelDeltaY-=t.wheelPrecisionY*n.wheelDelta/t._normalize),n.preventDefault&&(e||n.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,Ne.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null),this.onChangedObservable&&this.onChangedObservable.clear()},e.prototype.checkInputs=function(){this.onChangedObservable.notifyObservers({wheelDeltaX:this._wheelDeltaX,wheelDeltaY:this._wheelDeltaY,wheelDeltaZ:this._wheelDeltaZ}),this._wheelDeltaX=0,this._wheelDeltaY=0,this._wheelDeltaZ=0},e.prototype.getClassName=function(){return"BaseCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},Object(h.c)([Object(w.c)()],e.prototype,"wheelPrecisionX",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelPrecisionY",void 0),Object(h.c)([Object(w.c)()],e.prototype,"wheelPrecisionZ",void 0),e}();!function(e){e[e.MoveRelative=0]="MoveRelative",e[e.RotateRelative=1]="RotateRelative",e[e.MoveScene=2]="MoveScene"}(Et||(Et={}));var At=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._moveRelative=a.e.Zero(),t._rotateRelative=a.e.Zero(),t._moveScene=a.e.Zero(),t._wheelXAction=Et.MoveRelative,t._wheelXActionCoordinate=J.b.X,t._wheelYAction=Et.MoveRelative,t._wheelYActionCoordinate=J.b.Z,t._wheelZAction=null,t._wheelZActionCoordinate=null,t}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FreeCameraMouseWheelInput"},Object.defineProperty(t.prototype,"wheelXMoveRelative",{get:function(){return this._wheelXAction!==Et.MoveRelative?null:this._wheelXActionCoordinate},set:function(e){null===e&&this._wheelXAction!==Et.MoveRelative||(this._wheelXAction=Et.MoveRelative,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYMoveRelative",{get:function(){return this._wheelYAction!==Et.MoveRelative?null:this._wheelYActionCoordinate},set:function(e){null===e&&this._wheelYAction!==Et.MoveRelative||(this._wheelYAction=Et.MoveRelative,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZMoveRelative",{get:function(){return this._wheelZAction!==Et.MoveRelative?null:this._wheelZActionCoordinate},set:function(e){null===e&&this._wheelZAction!==Et.MoveRelative||(this._wheelZAction=Et.MoveRelative,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelXRotateRelative",{get:function(){return this._wheelXAction!==Et.RotateRelative?null:this._wheelXActionCoordinate},set:function(e){null===e&&this._wheelXAction!==Et.RotateRelative||(this._wheelXAction=Et.RotateRelative,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYRotateRelative",{get:function(){return this._wheelYAction!==Et.RotateRelative?null:this._wheelYActionCoordinate},set:function(e){null===e&&this._wheelYAction!==Et.RotateRelative||(this._wheelYAction=Et.RotateRelative,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZRotateRelative",{get:function(){return this._wheelZAction!==Et.RotateRelative?null:this._wheelZActionCoordinate},set:function(e){null===e&&this._wheelZAction!==Et.RotateRelative||(this._wheelZAction=Et.RotateRelative,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelXMoveScene",{get:function(){return this._wheelXAction!==Et.MoveScene?null:this._wheelXActionCoordinate},set:function(e){null===e&&this._wheelXAction!==Et.MoveScene||(this._wheelXAction=Et.MoveScene,this._wheelXActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelYMoveScene",{get:function(){return this._wheelYAction!==Et.MoveScene?null:this._wheelYActionCoordinate},set:function(e){null===e&&this._wheelYAction!==Et.MoveScene||(this._wheelYAction=Et.MoveScene,this._wheelYActionCoordinate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"wheelZMoveScene",{get:function(){return this._wheelZAction!==Et.MoveScene?null:this._wheelZActionCoordinate},set:function(e){null===e&&this._wheelZAction!==Et.MoveScene||(this._wheelZAction=Et.MoveScene,this._wheelZActionCoordinate=e)},enumerable:!1,configurable:!0}),t.prototype.checkInputs=function(){if(0!==this._wheelDeltaX||0!==this._wheelDeltaY||0!=this._wheelDeltaZ){this._moveRelative.setAll(0),this._rotateRelative.setAll(0),this._moveScene.setAll(0),this._updateCamera(),this.camera.getScene().useRightHandedSystem&&(this._moveRelative.z*=-1);var t=a.a.Zero();this.camera.getViewMatrix().invertToRef(t);var i=a.e.Zero();a.e.TransformNormalToRef(this._moveRelative,t,i),this.camera.cameraRotation.x+=this._rotateRelative.x/200,this.camera.cameraRotation.y+=this._rotateRelative.y/200,this.camera.cameraDirection.addInPlace(i),this.camera.cameraDirection.addInPlace(this._moveScene),e.prototype.checkInputs.call(this)}},t.prototype._updateCamera=function(){var e=this._moveRelative,t=this._rotateRelative,i=this._moveScene,n=function(n,r,o){if(0!==n&&null!==r&&null!==o){var a=null;switch(r){case Et.MoveRelative:a=e;break;case Et.RotateRelative:a=t;break;case Et.MoveScene:a=i}switch(o){case J.b.X:a.set(n,0,0);break;case J.b.Y:a.set(0,n,0);break;case J.b.Z:a.set(0,0,n)}}};n(this._wheelDeltaX,this._wheelXAction,this._wheelXActionCoordinate),n(this._wheelDeltaY,this._wheelYAction,this._wheelYActionCoordinate),n(this._wheelDeltaZ,this._wheelZAction,this._wheelZActionCoordinate)},Object(h.c)([Object(w.c)()],t.prototype,"wheelXMoveRelative",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelYMoveRelative",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelZMoveRelative",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelXRotateRelative",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelYRotateRelative",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelZRotateRelative",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelXMoveScene",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelYMoveScene",null),Object(h.c)([Object(w.c)()],t.prototype,"wheelZMoveScene",null),t}(St);it.FreeCameraMouseWheelInput=At;var Pt=function(){function e(e){void 0===e&&(e=!1),this.allowMouse=e,this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array}return e.prototype.attachControl=function(e){var t=this;e=Ce.b.BackCompatCameraNoPreventDefault(arguments);var i=null;if(void 0===this._pointerInput&&(this._onLostFocus=function(){t._offsetX=null,t._offsetY=null},this._pointerInput=function(n){var r=n.event,o=!t.camera.getEngine().hostInformation.isMobile&&r instanceof MouseEvent;if(t.allowMouse||"mouse"!==r.pointerType&&!o)if(n.type===Ne.a.POINTERDOWN){if(e||r.preventDefault(),t._pointerPressed.push(r.pointerId),1!==t._pointerPressed.length)return;i={x:r.clientX,y:r.clientY}}else if(n.type===Ne.a.POINTERUP){if(e||r.preventDefault(),-1===(a=t._pointerPressed.indexOf(r.pointerId)))return;if(t._pointerPressed.splice(a,1),0!=a)return;i=null,t._offsetX=null,t._offsetY=null}else if(n.type===Ne.a.POINTERMOVE){if(e||r.preventDefault(),!i)return;var a;if(0!=(a=t._pointerPressed.indexOf(r.pointerId)))return;t._offsetX=r.clientX-i.x,t._offsetY=-(r.clientY-i.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ne.a.POINTERDOWN|Ne.a.POINTERUP|Ne.a.POINTERMOVE),this._onLostFocus){var n=this.camera.getEngine(),r=n.getInputElement();r&&r.addEventListener("blur",this._onLostFocus)}},e.prototype.detachControl=function(e){if(this._pointerInput){if(this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null),this._onLostFocus){var t=this.camera.getEngine().getInputElement();t&&t.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null}this._pointerPressed=[],this._offsetX=null,this._offsetY=null}},e.prototype.checkInputs=function(){if(null!==this._offsetX&&null!==this._offsetY&&(0!==this._offsetX||0!==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 a.e(0,0,t*this._offsetY/this.touchMoveSensibility);a.a.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(a.e.TransformCoordinates(i,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},Object(h.c)([Object(w.c)()],e.prototype,"touchAngularSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"touchMoveSensibility",void 0),e}();it.FreeCameraTouchInput=Pt;var Ct=function(e){function t(t){var i=e.call(this,t)||this;return i._mouseInput=null,i._mouseWheelInput=null,i}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new yt),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new Tt(e),this.add(this._mouseInput)),this},t.prototype.removeMouse=function(){return this._mouseInput&&this.remove(this._mouseInput),this},t.prototype.addMouseWheel=function(){return this._mouseWheelInput||(this._mouseWheelInput=new At,this.add(this._mouseWheelInput)),this},t.prototype.removeMouseWheel=function(){return this._mouseWheelInput&&this.remove(this._mouseWheelInput),this},t.prototype.addTouch=function(){return this.add(new Pt),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}(nt);Ct.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new Rt,this.add(this._deviceOrientationInput)),this};var Rt=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new a.b,this._alpha=0,this._beta=0,this._gamma=0,this._onDeviceOrientationChangedObservable=new o.c,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=-Ce.b.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,null!==t.alpha&&e._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTranform=new a.b(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return e.WaitForOrientationChangeAsync=function(e){return new Promise((function(t,i){var n=!1,r=function(){window.removeEventListener("deviceorientation",r),n=!0,t()};e&&setTimeout((function(){n||(window.removeEventListener("deviceorientation",r),i("WaitForOrientationChangeAsync timed out"))}),e),"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e?window.addEventListener("deviceorientation",r):Ce.b.Warn("Permission not granted.")})).catch((function(e){Ce.b.Error(e)})):window.addEventListener("deviceorientation",r)}))},Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},set:function(e){var t=this;this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new a.b),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().getEngine().getHostWindow();if(t){var i=function(){t.addEventListener("orientationchange",e._orientationChanged),t.addEventListener("deviceorientation",e._deviceOrientation),e._orientationChanged()};"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?i():Ce.b.Warn("Permission not granted.")})).catch((function(e){Ce.b.Error(e)})):i()}},e.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation),this._alpha=0},e.prototype.checkInputs=function(){this._alpha&&(a.b.RotationYawPitchRollToRef(Ce.b.ToRadians(this._alpha),Ce.b.ToRadians(this._beta),-Ce.b.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}();it.FreeCameraDeviceOrientationInput=Rt;var xt=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._yAxisScale=1,this._cameraTransform=a.a.Identity(),this._deltaTransform=a.e.Zero(),this._vector3=a.e.Zero(),this._vector2=a.d.Zero()}return Object.defineProperty(e.prototype,"invertYAxis",{get:function(){return 1!==this._yAxisScale},set:function(e){this._yAxisScale=e?-1:1},enumerable:!1,configurable:!0}),e.prototype.attachControl=function(){var e=this,t=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add((function(t){t.type!==ot.POSE_ENABLED&&(e.gamepad&&t.type!==ot.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(ot.XBOX),!this.gamepad&&t.gamepads.length&&(this.gamepad=t.gamepads[0])},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,n=t.y/this.gamepadMoveSensibility;t.x=Math.abs(i)>.005?0+i:0,t.y=Math.abs(n)>.005?0+n:0;var r=this.gamepad.rightStick;if(r){var o=r.x/this.gamepadAngularSensibility,s=r.y/this.gamepadAngularSensibility*this._yAxisScale;r.x=Math.abs(o)>.001?0+o:0,r.y=Math.abs(s)>.001?0+s:0}else r={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):a.a.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),a.e.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(r.y,r.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},Object(h.c)([Object(w.c)()],e.prototype,"gamepadAngularSensibility",void 0),Object(h.c)([Object(w.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();it.FreeCameraGamepadInput=xt;var Ot,Mt=i(112);!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(Ot||(Ot={}));var It=function(){function e(t,i){var n=this,r=Object(h.a)(Object(h.a)({},e._GetDefaultOptions()),i);if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=Ot.X,this._axisTargetedByUpAndDown=Ot.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new Mt.a,this.deltaPosition=a.e.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.style.touchAction="none",e.Canvas.setAttribute("touch-action","none");var o=e.Canvas.getContext("2d");if(!o)throw new Error("Unable to create canvas for virtual joystick");e.vjCanvasContext=o,e.vjCanvasContext.strokeStyle="#ffffff",e.vjCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e.halfWidth=e.Canvas.width/2,this.pressed=!1,this.limitToContainer=r.limitToContainer,this._joystickColor=r.color,this.containerSize=r.containerSize,this.puckSize=r.puckSize,r.position&&this.setPosition(r.position.x,r.position.y),r.puckImage&&this.setPuckImage(r.puckImage),r.containerImage&&this.setContainerImage(r.containerImage),r.alwaysVisible&&e._alwaysVisibleSticks++,this.alwaysVisible=r.alwaysVisible,this._joystickPointerID=-1,this._joystickPointerPos=new a.d(0,0),this._joystickPreviousPointerPos=new a.d(0,0),this._joystickPointerStartPos=new a.d(0,0),this._deltaJoystickVector=new a.d(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){n._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(){n._drawVirtualJoystick()}))}return e._GetDefaultOptions=function(){return{puckSize:40,containerSize:60,color:"cyan",puckImage:void 0,containerImage:void 0,position:void 0,alwaysVisible:!1,limitToContainer:!1}},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._joystickPosition?(this._joystickPointerStartPos=this._joystickPosition.clone(),this._joystickPointerPos=this._joystickPosition.clone(),this._joystickPreviousPointerPos=this._joystickPosition.clone(),this._onPointerMove(t)):(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(t){if(this._joystickPointerID==t.pointerId){if(this.limitToContainer){var i=new a.d(t.clientX-this._joystickPointerStartPos.x,t.clientY-this._joystickPointerStartPos.y),n=i.length();n>this.containerSize&&i.scaleInPlace(this.containerSize/n),this._joystickPointerPos.x=this._joystickPointerStartPos.x+i.x,this._joystickPointerPos.y=this._joystickPointerStartPos.y+i.y}else this._joystickPointerPos.x=t.clientX,this._joystickPointerPos.y=t.clientY;this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos),0<e._alwaysVisibleSticks&&(this._leftJoystick?this._joystickPointerPos.x=Math.min(e.halfWidth,this._joystickPointerPos.x):this._joystickPointerPos.x=Math.max(e.halfWidth,this._joystickPointerPos.x));var r=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case Ot.X:this.deltaPosition.x=Math.min(1,Math.max(-1,r));break;case Ot.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,r));break;case Ot.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,r))}var o=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case Ot.X:this.deltaPosition.x=Math.min(1,Math.max(-1,o));break;case Ot.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,o));break;case Ot.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,o))}}else{var s=this._touches.get(t.pointerId.toString());s&&(s.x=t.clientX,s.y=t.clientY)}},e.prototype._onPointerUp=function(t){if(this._joystickPointerID==t.pointerId)this._clearPreviousDraw(),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},Object.defineProperty(e.prototype,"containerSize",{get:function(){return this._joystickContainerSize},set:function(e){this._joystickContainerSize=e,this._clearContainerSize=~~(2.1*this._joystickContainerSize),this._clearContainerSizeOffset=~~(this._clearContainerSize/2)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"puckSize",{get:function(){return this._joystickPuckSize},set:function(e){this._joystickPuckSize=e,this._clearPuckSize=~~(2.1*this._joystickPuckSize),this._clearPuckSizeOffset=~~(this._clearPuckSize/2)},enumerable:!1,configurable:!0}),e.prototype.clearPosition=function(){this.alwaysVisible=!1,this._joystickPosition=null},Object.defineProperty(e.prototype,"alwaysVisible",{get:function(){return this._alwaysVisible},set:function(t){this._alwaysVisible!==t&&(t&&this._joystickPosition?(e._alwaysVisibleSticks++,this._alwaysVisible=!0):(e._alwaysVisibleSticks--,this._alwaysVisible=!1))},enumerable:!1,configurable:!0}),e.prototype.setPosition=function(e,t){this._joystickPointerStartPos&&this._clearPreviousDraw(),this._joystickPosition=new a.d(e,t)},e.prototype.setActionOnTouch=function(e){this._action=e},e.prototype.setAxisForLeftRight=function(e){switch(e){case Ot.X:case Ot.Y:case Ot.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=Ot.X}},e.prototype.setAxisForUpDown=function(e){switch(e){case Ot.X:case Ot.Y:case Ot.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=Ot.Y}},e.prototype._clearPreviousDraw=function(){var t=this._joystickPosition||this._joystickPointerStartPos;e.vjCanvasContext.clearRect(t.x-this._clearContainerSizeOffset,t.y-this._clearContainerSizeOffset,this._clearContainerSize,this._clearContainerSize),e.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-this._clearPuckSizeOffset,this._joystickPreviousPointerPos.y-this._clearPuckSizeOffset,this._clearPuckSize,this._clearPuckSize)},e.prototype.setContainerImage=function(e){var t=this,i=new Image;i.src=e,i.onload=function(){return t._containerImage=i}},e.prototype.setPuckImage=function(e){var t=this,i=new Image;i.src=e,i.onload=function(){return t._puckImage=i}},e.prototype._drawContainer=function(){var t=this._joystickPosition||this._joystickPointerStartPos;this._clearPreviousDraw(),this._containerImage?e.vjCanvasContext.drawImage(this._containerImage,t.x-this.containerSize,t.y-this.containerSize,2*this.containerSize,2*this.containerSize):(e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=this._joystickColor,e.vjCanvasContext.lineWidth=2,e.vjCanvasContext.arc(t.x,t.y,this.containerSize,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.strokeStyle=this._joystickColor,e.vjCanvasContext.arc(t.x,t.y,this.puckSize,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath())},e.prototype._drawPuck=function(){this._puckImage?e.vjCanvasContext.drawImage(this._puckImage,this._joystickPointerPos.x-this.puckSize,this._joystickPointerPos.y-this.puckSize,2*this.puckSize,2*this.puckSize):(e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=this._joystickColor,e.vjCanvasContext.lineWidth=2,e.vjCanvasContext.arc(this._joystickPointerPos.x,this._joystickPointerPos.y,this.puckSize,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath())},e.prototype._drawVirtualJoystick=function(){var t=this;this.alwaysVisible&&this._drawContainer(),this.pressed&&this._touches.forEach((function(i,n){n.pointerId===t._joystickPointerID?(t.alwaysVisible||t._drawContainer(),t._drawPuck(),t._joystickPreviousPointerPos=t._joystickPointerPos.clone()):(e.vjCanvasContext.clearRect(n.prevX-44,n.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(n.x,n.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),n.prevX=n.x,n.prevY=n.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._alwaysVisibleSticks=0,e}();Ct.prototype.addVirtualJoystick=function(){return this.add(new Dt),this};var Dt=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=a.a.RotationYawPitchRoll(e.rotation.y,e.rotation.x,0),n=a.e.TransformCoordinates(new a.e(this._leftjoystick.deltaPosition.x*t,this._leftjoystick.deltaPosition.y*t,this._leftjoystick.deltaPosition.z*t),i);e.cameraDirection=e.cameraDirection.add(n),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(){this._leftjoystick=new It(!0),this._leftjoystick.setAxisForUpDown(Ot.Z),this._leftjoystick.setAxisForLeftRight(Ot.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new It(!1),this._rightjoystick.setAxisForUpDown(Ot.X),this._rightjoystick.setAxisForLeftRight(Ot.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}();it.FreeCameraVirtualJoystickInput=Dt;var Nt=i(28),Lt=function(e){function t(t,i,n,r){void 0===r&&(r=!0);var o=e.call(this,t,i,n,r)||this;return o._tmpUpVector=a.e.Zero(),o._tmpTargetVector=a.e.Zero(),o.cameraDirection=new a.e(0,0,0),o.cameraRotation=new a.d(0,0),o.ignoreParentScaling=!1,o.updateUpVectorFromRotation=!1,o._tmpQuaternion=new a.b,o.rotation=new a.e(0,0,0),o.speed=2,o.noRotationConstraint=!1,o.invertRotation=!1,o.inverseRotationSpeed=.2,o.lockedTarget=null,o._currentTarget=a.e.Zero(),o._initialFocalDistance=1,o._viewMatrix=a.a.Zero(),o._camMatrix=a.a.Zero(),o._cameraTransformMatrix=a.a.Zero(),o._cameraRotationMatrix=a.a.Zero(),o._referencePoint=new a.e(0,0,1),o._transformedReferencePoint=a.e.Zero(),o._defaultUp=a.e.Up(),o._cachedRotationZ=0,o._cachedQuaternionRotationZ=0,o}return Object(h.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 a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new a.b(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+=Nt.a),this._referencePoint.normalize().scaleInPlace(this._initialFocalDistance),a.a.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&&a.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},Object.defineProperty(t.prototype,"target",{get:function(){return this.getTarget()},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),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(a.c.Matrix[0]),a.e.TransformNormalToRef(this.cameraDirection,a.c.Matrix[0],a.c.Vector3[0]),void this.position.addInPlace(a.c.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var t=this.invertRotation?-this.inverseRotationSpeed:1,i=this._decideIfNeedsToMove(),n=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),n){if(this.rotationQuaternion&&this.rotationQuaternion.toEulerAnglesToRef(this.rotation),this.rotation.x+=this.cameraRotation.x*t,this.rotation.y+=this.cameraRotation.y*t,!this.noRotationConstraint){this.rotation.x>1.570796&&(this.rotation.x=1.570796),this.rotation.x<-1.570796&&(this.rotation.x=-1.570796)}if(this.rotationQuaternion)this.rotation.lengthSquared()&&a.b.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}i&&(Math.abs(this.cameraDirection.x)<this.speed*Nt.a&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*Nt.a&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*Nt.a&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),n&&(Math.abs(this.cameraRotation.x)<this.speed*Nt.a&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*Nt.a&&(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):a.a.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},t.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return a.e.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),a.e.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this.updateUpVectorFromRotation&&(this.rotationQuaternion?J.a.Y.rotateByQuaternionToRef(this.rotationQuaternion,this.upVector):(a.b.FromEulerVectorToRef(this.rotation,this._tmpQuaternion),J.a.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.ignoreParentScaling){if(this.parent){var n=this.parent.getWorldMatrix();a.e.TransformCoordinatesToRef(e,n,this._globalPosition),a.e.TransformCoordinatesToRef(t,n,this._tmpTargetVector),a.e.TransformNormalToRef(i,n,this._tmpUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._tmpTargetVector.copyFrom(t),this._tmpUpVector.copyFrom(i);this.getScene().useRightHandedSystem?a.a.LookAtRHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix):a.a.LookAtLHToRef(this._globalPosition,this._tmpTargetVector,this._tmpUpVector,this._viewMatrix)}else if(this.getScene().useRightHandedSystem?a.a.LookAtRHToRef(e,t,i,this._viewMatrix):a.a.LookAtLHToRef(e,t,i,this._viewMatrix),this.parent){n=this.parent.getWorldMatrix();this._viewMatrix.invert(),this._viewMatrix.multiplyToRef(n,this._viewMatrix),this._viewMatrix.getTranslationToRef(this._globalPosition),this._viewMatrix.invert(),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e)},t.prototype.createRigCamera=function(e,i){if(this.cameraRigMode!==je.a.RIG_MODE_NONE){var n=new t(e,this.position.clone(),this.getScene());return n.isRigCamera=!0,n.rigParent=this,this.cameraRigMode!==je.a.RIG_MODE_VR&&this.cameraRigMode!==je.a.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new a.b),n._cameraRigParams={},n.rotationQuaternion=new a.b),n}return null},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(this.computeWorldMatrix(),this.cameraRigMode){case je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case je.a.RIG_MODE_STEREOSCOPIC_INTERLACED:var n=this.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,r=this.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*n,t),this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle*r,i);break;case je.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 n=t._TargetFocalPoint.addInPlace(this.position);a.a.TranslationToRef(-n.x,-n.y,-n.z,t._TargetTransformMatrix),t._TargetTransformMatrix.multiplyToRef(a.a.RotationAxis(i.upVector,e),t._RigCamTransformMatrix),a.a.TranslationToRef(n.x,n.y,n.z,t._TargetTransformMatrix),t._RigCamTransformMatrix.multiplyToRef(t._TargetTransformMatrix,t._RigCamTransformMatrix),a.e.TransformCoordinatesToRef(this.position,t._RigCamTransformMatrix,i.position),i.setTarget(n)},t.prototype.getClassName=function(){return"TargetCamera"},t._RigCamTransformMatrix=new a.a,t._TargetTransformMatrix=new a.a,t._TargetFocalPoint=new a.e,Object(h.c)([Object(w.o)()],t.prototype,"rotation",void 0),Object(h.c)([Object(w.c)()],t.prototype,"speed",void 0),Object(h.c)([Object(w.k)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(je.a),wt=function(e){function t(t,i,n,r){void 0===r&&(r=!0);var o=e.call(this,t,i,n,r)||this;return o.ellipsoid=new a.e(.5,1,.5),o.ellipsoidOffset=new a.e(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o._needMoveForGravity=!1,o._oldPosition=a.e.Zero(),o._diffPosition=a.e.Zero(),o._newPosition=a.e.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null);var n;n=t,o._newPosition.copyFrom(n),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>Se.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new Ct(o),o.inputs.addKeyboard().addMouse(),o}return Object(h.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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysUpward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUpward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUpward=e)},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysDownward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDownward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDownward=e)},enumerable:!1,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:!1,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:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(e){this.inputs.detachElement(),this.cameraDirection=new a.e(0,0,0),this.cameraRotation=new a.d(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?a.e.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=a.e.Zero(),this._transformedDirection=a.e.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"},Object(h.c)([Object(w.o)()],t.prototype,"ellipsoid",void 0),Object(h.c)([Object(w.o)()],t.prototype,"ellipsoidOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"checkCollisions",void 0),Object(h.c)([Object(w.c)()],t.prototype,"applyGravity",void 0),t}(Lt);B.a.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new Ft(e,a.e.Zero(),t)}}));var Ft=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.inputs.addTouch(),r._setupInputs(),r}return Object(h.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:!1,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:!1,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.touch,t=this.inputs.attached.mouse;t?t.touchEnabled=!1:e.allowMouse=!0},t}(wt);B.a.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new Bt(e,0,0,1,a.e.Zero(),t)}}));var Bt=function(e){function t(t,i,n,r,s,c,l){void 0===l&&(l=!0);var u=e.call(this,t,a.e.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=a.e.Zero(),u.panningInertia=.9,u.zoomOnFactor=1,u.targetScreenOffset=a.d.Zero(),u.allowUpsideDown=!0,u.useInputToRestoreState=!0,u._viewMatrix=new a.a,u.panningAxis=new a.e(1,1,0),u.onMeshTargetChangedObservable=new o.c,u.checkCollisions=!1,u.collisionRadius=new a.e(.5,.5,.5),u._previousPosition=a.e.Zero(),u._collisionVelocity=a.e.Zero(),u._newPosition=a.e.Zero(),u._computationVector=a.e.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 n=Math.cos(u.alpha),r=Math.sin(u.alpha),o=Math.cos(u.beta),a=Math.sin(u.beta);0===a&&(a=1e-4);var s=u._getTargetPosition();u._computationVector.copyFromFloats(u.radius*n*a,u.radius*o,u.radius*r*a),s.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,s,c),u._viewMatrix.addAtIndex(12,u.targetScreenOffset.x),u._viewMatrix.addAtIndex(13,u.targetScreenOffset.y),u._collisionTriggered=!1},u._target=a.e.Zero(),s&&u.setTarget(s),u.alpha=i,u.beta=n,u.radius=r,u.getViewMatrix(),u.inputs=new ft(u),u.inputs.addKeyboard().addMouseWheel().addPointers(),u}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._YToUpMatrix=new a.a,this._upToYMatrix=new a.a,this._upVector=a.e.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!1,configurable:!0}),t.prototype.setMatUp=function(){a.a.RotationAlignToRef(a.e.UpReadOnly,this._upVector,this._YToUpMatrix),a.a.RotationAlignToRef(this._upVector,a.e.UpReadOnly,this._upToYMatrix)},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:!1,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:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"useNaturalPinchZoom",{get:function(){var e=this.inputs.attached.pointers;return!!e&&e.useNaturalPinchZoom},set:function(e){var t=this.inputs.attached.pointers;t&&(t.useNaturalPinchZoom=e)},enumerable:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new we,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new Fe,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new Le,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!1,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new a.e(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=a.d.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(),this._storedTargetScreenOffset=this.targetScreenOffset.clone(),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.prototype._restoreStateValues.call(this)&&(this.setTarget(this._storedTarget.clone()),this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.targetScreenOffset=this._storedTargetScreenOffset.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,n){var r=this;void 0===i&&(i=!0),void 0===n&&(n=2),t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this._useCtrlForPanning=i,this._panningMouseButton=n,"boolean"==typeof arguments[0]&&(arguments.length>1&&(this._useCtrlForPanning=arguments[1]),arguments.length>2&&(this._panningMouseButton=arguments[2])),this.inputs.attachElement(t),this._reset=function(){r.inertialAlphaOffset=0,r.inertialBetaOffset=0,r.inertialRadiusOffset=0,r.inertialPanningX=0,r.inertialPanningY=0}},t.prototype.detachControl=function(e){this.inputs.detachElement(),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)<Nt.a&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<Nt.a&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*Nt.a&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){if(this._localDirection||(this._localDirection=a.e.Zero(),this._transformedDirection=a.e.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),a.e.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),a.e.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*Nt.a&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*Nt.a&&(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),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.e.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4);var e=this.alpha;0===this._computationVector.x&&0===this._computationVector.z?this.alpha=Math.PI/2: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);var t=Math.round((e-this.alpha)/(2*Math.PI));this.alpha+=2*t*Math.PI,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,e.computeWorldMatrix(),this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var n=e,r=this._getTargetPosition();if(r&&!i&&r.equals(n))return;this._targetHost=null,this._target=n,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),n=Math.sin(this.beta);0===n&&(n=1e-4),0===this.radius&&(this.radius=1e-4);var r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*n,this.radius*i,this.radius*t*n),0===this._upVector.x&&1===this._upVector.y&&0===this._upVector.z||a.e.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var o=this.getScene().collisionCoordinator;this._collider||(this._collider=o.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,o.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.negate()),this._computeViewMatrix(this._position,r,s),this._viewMatrix.addAtIndex(12,this.targetScreenOffset.x),this._viewMatrix.addAtIndex(13,this.targetScreenOffset.y)}return this._currentTarget=r,this._viewMatrix},t.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var i=be.a.MinMax(e),n=a.e.Distance(i.min,i.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:n},t)},t.prototype.focusOn=function(e,t){var i,n;if(void 0===t&&(t=!1),void 0===e.min){var r=e||this.getScene().meshes;i=be.a.MinMax(r),n=a.e.Distance(i.min,i.max)}else{i=e,n=e.distance}this._target=be.a.Center(i),t||(this.maxZ=2*n)},t.prototype.createRigCamera=function(e,i){var n=0;switch(this.cameraRigMode){case je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case je.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case je.a.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===i?1:-1);break;case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===i?-1:1)}var r=new t(e,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return r._cameraRigParams={},r.isRigCamera=!0,r.rigParent=this,r.upVector=this.upVector,r},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],i=this._rigCameras[1];switch(t.beta=i.beta=this.beta,this.cameraRigMode){case je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case je.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case je.a.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case je.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"},Object(h.c)([Object(w.c)()],t.prototype,"alpha",void 0),Object(h.c)([Object(w.c)()],t.prototype,"beta",void 0),Object(h.c)([Object(w.c)()],t.prototype,"radius",void 0),Object(h.c)([Object(w.o)("target")],t.prototype,"_target",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialAlphaOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialBetaOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialRadiusOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerAlphaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperAlphaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerBetaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperBetaLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialPanningX",void 0),Object(h.c)([Object(w.c)()],t.prototype,"inertialPanningY",void 0),Object(h.c)([Object(w.c)()],t.prototype,"pinchToPanMaxDistance",void 0),Object(h.c)([Object(w.c)()],t.prototype,"panningDistanceLimit",void 0),Object(h.c)([Object(w.o)()],t.prototype,"panningOriginTarget",void 0),Object(h.c)([Object(w.c)()],t.prototype,"panningInertia",void 0),Object(h.c)([Object(w.c)()],t.prototype,"zoomOnFactor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"targetScreenOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"allowUpsideDown",void 0),Object(h.c)([Object(w.c)()],t.prototype,"useInputToRestoreState",void 0),t}(Lt);B.a.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new Ut(e,a.e.Zero(),t)}}));var Ut=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r._tmpDragQuaternion=new a.b,r._disablePointerInputWhenUsingDeviceOrientation=!0,r._dragFactor=0,r._quaternionCache=new a.b,r.inputs.addDeviceOrientation(),r.inputs._deviceOrientationInput&&r.inputs._deviceOrientationInput._onDeviceOrientationChangedObservable.addOnce((function(){r._disablePointerInputWhenUsingDeviceOrientation&&r.inputs._mouseInput&&(r.inputs._mouseInput._allowCameraRotation=!1,r.inputs._mouseInput.onPointerMovedObservable.add((function(e){0!=r._dragFactor&&(r._initialQuaternion||(r._initialQuaternion=new a.b),a.b.FromEulerAnglesToRef(0,e.offsetX*r._dragFactor,0,r._tmpDragQuaternion),r._initialQuaternion.multiplyToRef(r._tmpDragQuaternion,r._initialQuaternion))})))})),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"disablePointerInputWhenUsingDeviceOrientation",{get:function(){return this._disablePointerInputWhenUsingDeviceOrientation},set:function(e){this._disablePointerInputWhenUsingDeviceOrientation=e},enumerable:!1,configurable:!0}),t.prototype.enableHorizontalDragging=function(e){void 0===e&&(e=1/300),this._dragFactor=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=J.a.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new a.b),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}(wt),Vt=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new _t),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new mt(e)),this},t}(nt),kt=function(e){function t(t,i,n,r){void 0===r&&(r=!0);var o=e.call(this,t,i,n,r)||this;return o.ellipsoid=new a.e(1,1,1),o.ellipsoidOffset=new a.e(0,0,0),o.checkCollisions=!1,o.applyGravity=!1,o.cameraDirection=a.e.Zero(),o._trackRoll=0,o.rollCorrect=100,o.bankedTurn=!1,o.bankedTurnLimit=Math.PI/2,o.bankedTurnMultiplier=1,o._needMoveForGravity=!1,o._oldPosition=a.e.Zero(),o._diffPosition=a.e.Zero(),o._newPosition=a.e.Zero(),o._collisionMask=-1,o._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null);var n;n=t,o._newPosition.copyFrom(n),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>Se.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&i&&o.onCollide(i))},o.inputs=new Vt(o),o.inputs.addKeyboard().addMouse(),o}return Object(h.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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t)},t.prototype.detachControl=function(){this.inputs.detachElement(),this.cameraDirection=new a.e(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?a.e.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=a.e.Zero(),this._transformedDirection=a.e.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"},Object(h.c)([Object(w.o)()],t.prototype,"ellipsoid",void 0),Object(h.c)([Object(w.o)()],t.prototype,"ellipsoidOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"checkCollisions",void 0),Object(h.c)([Object(w.c)()],t.prototype,"applyGravity",void 0),t}(Lt),zt=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new gt),this},t.prototype.addMouseWheel=function(){return this.add(new vt),this},t.prototype.addPointers=function(){return this.add(new bt),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(nt);B.a.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new jt(e,a.e.Zero(),t)}})),B.a.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new Wt(e,0,0,1,null,t)}}));var Gt,jt=function(e){function t(t,i,n,r){void 0===r&&(r=null);var o=e.call(this,t,i,n)||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=r,o.inputs=new zt(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return Object(h.d)(t,e),t.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var i=new a.a;e.rotationQuaternion.toRotationMatrix(i),t=Math.atan2(i.m[8],i.m[10])}else t=e.rotation.y;var n=Ce.b.ToRadians(this.rotationOffset)+t,r=e.getAbsolutePosition(),o=r.x+Math.sin(n)*this.radius,s=r.z+Math.cos(n)*this.radius,c=o-this.position.x,l=r.y+this.heightOffset-this.position.y,u=s-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 a.e(this.position.x+h,this.position.y+d,this.position.z+f),this.setTarget(r)}},t.prototype.attachControl=function(e,t){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),this.inputs.attachElement(t),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(),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"},Object(h.c)([Object(w.c)()],t.prototype,"radius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperRadiusLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"rotationOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerRotationOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperRotationOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"heightOffset",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lowerHeightOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"upperHeightOffsetLimit",void 0),Object(h.c)([Object(w.c)()],t.prototype,"cameraAcceleration",void 0),Object(h.c)([Object(w.c)()],t.prototype,"maxCameraSpeed",void 0),Object(h.c)([Object(w.k)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(Lt),Wt=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,a.e.Zero(),s)||this;return c.alpha=i,c.beta=n,c.radius=r,c._cartesianCoordinates=a.e.Zero(),c._meshTarget=o,c._follow(),c}return Object(h.d)(t,e),t.prototype._follow=function(){if(this._meshTarget){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._meshTarget.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}(Lt),Ht=i(38),Xt=i(39);!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"}(Gt||(Gt={}));var Yt,Kt,Qt=function(){function e(){}return e.InitiateController=function(e){for(var t=0,i=this._ControllerFactories;t<i.length;t++){var n=i[t];if(n.canCreate(e))return n.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}(),qt=function(e){function t(t){var i=e.call(this,t.id,t.index,t)||this;return i.isXR=!1,i._deviceRoomPosition=a.e.Zero(),i._deviceRoomRotationQuaternion=new a.b,i.devicePosition=a.e.Zero(),i.deviceRotationQuaternion=new a.b,i.deviceScaleFactor=1,i._trackPosition=!0,i._maxRotationDistFromHeadset=Math.PI/5,i._draggedRoomRotation=0,i._leftHandSystemQuaternion=new a.b,i._deviceToWorld=a.a.Identity(),i._pointingPoseNode=null,i._workingMatrix=a.a.Identity(),i._meshAttachedObservable=new o.c,i.type=ot.POSE_ENABLED,i.controllerType=Gt.GENERIC,i.position=a.e.Zero(),i.rotationQuaternion=new a.b,i._calculatedPosition=a.e.Zero(),i._calculatedRotation=new a.b,a.b.RotationYawPitchRollToRef(Math.PI,0,0,i._leftHandSystemQuaternion),i}return Object(h.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(){if(!this.isXR){var e=this.browserGamepad.pose;if(this.updateFromDevice(e),!this._trackPosition&&x.a.LastCreatedScene&&x.a.LastCreatedScene.activeCamera&&x.a.LastCreatedScene.activeCamera.devicePosition)if((t=x.a.LastCreatedScene.activeCamera)._computeDevicePosition(),this._deviceToWorld.setTranslation(t.devicePosition),t.deviceRotationQuaternion){var t;(t=t)._deviceRoomRotationQuaternion.toEulerAnglesToRef(a.c.Vector3[0]);var i=Math.atan2(Math.sin(a.c.Vector3[0].y-this._draggedRoomRotation),Math.cos(a.c.Vector3[0].y-this._draggedRoomRotation));if(Math.abs(i)>this._maxRotationDistFromHeadset){var n=i-(i<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=n;var r=Math.sin(-n),o=Math.cos(-n);this._calculatedPosition.x=this._calculatedPosition.x*o-this._calculatedPosition.z*r,this._calculatedPosition.z=this._calculatedPosition.x*r+this._calculatedPosition.z*o}}a.e.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),a.b.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(!this.isXR&&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&&4===t.orientation.length&&(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 a.b),!this.isXR&&(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:!1,configurable:!0}),t.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new Xt.a(a.e.Zero(),new a.e(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),i=t.getTranslation(),n=new a.e(0,0,-1),r=a.e.TransformNormal(n,t),o=a.e.Normalize(r);return new Xt.a(i,o,e)},t.POINTING_POSE="POINTING_POSE",t}(ot);!function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(Yt||(Yt={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Kt||(Kt={}));var Zt,Jt,$t=function(e){function t(t,i,n,r){void 0===r&&(r=!1);var a=e.call(this,t,i,n,0,1,2,3)||this;return a._leftTrigger=0,a._rightTrigger=0,a.onButtonDownObservable=new o.c,a.onButtonUpObservable=new o.c,a.onPadDownObservable=new o.c,a.onPadUpObservable=new o.c,a._buttonA=0,a._buttonB=0,a._buttonX=0,a._buttonY=0,a._buttonBack=0,a._buttonStart=0,a._buttonLB=0,a._buttonRB=0,a._buttonLeftStick=0,a._buttonRightStick=0,a._dPadUp=0,a._dPadDown=0,a._dPadLeft=0,a._dPadRight=0,a._isXboxOnePad=!1,a.type=ot.XBOX,a._isXboxOnePad=r,a}return Object(h.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:!1,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:!1,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,Yt.A)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,Yt.B)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,Yt.X)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,Yt.Y)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,Yt.Start)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,Yt.Back)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,Yt.LB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,Yt.RB)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Yt.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Yt.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Kt.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Kt.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Kt.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Kt.Right)},enumerable:!1,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.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}(ot);!function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.LeftStick=10]="LeftStick",e[e.RightStick=11]="RightStick"}(Zt||(Zt={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(Jt||(Jt={}));var ei=function(e){function t(t,i,n){var r=e.call(this,t.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),i,n,0,1,2,3)||this;return r._leftTrigger=0,r._rightTrigger=0,r.onButtonDownObservable=new o.c,r.onButtonUpObservable=new o.c,r.onPadDownObservable=new o.c,r.onPadUpObservable=new o.c,r._buttonCross=0,r._buttonCircle=0,r._buttonSquare=0,r._buttonTriangle=0,r._buttonShare=0,r._buttonOptions=0,r._buttonL1=0,r._buttonR1=0,r._buttonLeftStick=0,r._buttonRightStick=0,r._dPadUp=0,r._dPadDown=0,r._dPadLeft=0,r._dPadRight=0,r.type=ot.DUALSHOCK,r}return Object(h.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:!1,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:!1,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,"buttonCross",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,Zt.Cross)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonCircle",{get:function(){return this._buttonCircle},set:function(e){this._buttonCircle=this._setButtonValue(e,this._buttonCircle,Zt.Circle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonSquare",{get:function(){return this._buttonSquare},set:function(e){this._buttonSquare=this._setButtonValue(e,this._buttonSquare,Zt.Square)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonTriangle",{get:function(){return this._buttonTriangle},set:function(e){this._buttonTriangle=this._setButtonValue(e,this._buttonTriangle,Zt.Triangle)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonOptions",{get:function(){return this._buttonOptions},set:function(e){this._buttonOptions=this._setButtonValue(e,this._buttonOptions,Zt.Options)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonShare",{get:function(){return this._buttonShare},set:function(e){this._buttonShare=this._setButtonValue(e,this._buttonShare,Zt.Share)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonL1",{get:function(){return this._buttonL1},set:function(e){this._buttonL1=this._setButtonValue(e,this._buttonL1,Zt.L1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonR1",{get:function(){return this._buttonR1},set:function(e){this._buttonR1=this._setButtonValue(e,this._buttonR1,Zt.R1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Zt.LeftStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Zt.RightStick)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Jt.Up)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Jt.Down)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Jt.Left)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Jt.Right)},enumerable:!1,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this.buttonCross=this.browserGamepad.buttons[0].value,this.buttonCircle=this.browserGamepad.buttons[1].value,this.buttonSquare=this.browserGamepad.buttons[2].value,this.buttonTriangle=this.browserGamepad.buttons[3].value,this.buttonL1=this.browserGamepad.buttons[4].value,this.buttonR1=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonShare=this.browserGamepad.buttons[8].value,this.buttonOptions=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}(ot),ti=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new o.c,Ht.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new o.c((function(e){for(var i in t._babylonGamepads){var n=t._babylonGamepads[i];n&&n._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,n)}})),this._onGamepadConnectedEvent=function(e){var i,n=e.gamepad;n.index in t._babylonGamepads&&t._babylonGamepads[n.index].isConnected||(t._babylonGamepads[n.index]?((i=t._babylonGamepads[n.index]).browserGamepad=n,i._isConnected=!0):i=t._addNewGamepad(n),t.onGamepadConnectedObservable.notifyObservers(i),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var i=e.gamepad;for(var n in t._babylonGamepads)if(t._babylonGamepads[n].index===i.index){var r=t._babylonGamepads[n];r._isConnected=!1,t.onGamepadDisconnectedObservable.notifyObservers(r),r.dispose&&r.dispose();break}},this._gamepadSupport)if(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported){var i=this._scene?this._scene.getEngine().getHostWindow():window;i&&(i.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),i.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1))}else this._startMonitoringGamepads()}return Object.defineProperty(e.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!1,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=ot.XBOX);for(var t=0,i=this._babylonGamepads;t<i.length;t++){var n=i[t];if(n&&n.type===e)return n}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("054c"),n=-1!==e.id.search("Xbox One");return t=n||-1!==e.id.search("Xbox 360")||-1!==e.id.search("xinput")?new $t(e.id,e.index,e,n):i?new ei(e.id,e.index,e):e.pose?Qt.InitiateController(e):new at(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&&Se.a.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 n=this._addNewGamepad(i);this.onGamepadConnectedObservable.notifyObservers(n)}}},e}();Object.defineProperty(Q.a.prototype,"gamepadManager",{get:function(){if(!this._gamepadManager){this._gamepadManager=new ti(this);var e=this._getComponent(Me.a.NAME_GAMEPAD);e||(e=new ii(this),this._addComponent(e))}return this._gamepadManager},enumerable:!0,configurable:!0}),Ct.prototype.addGamepad=function(){return this.add(new xt),this},ft.prototype.addGamepad=function(){return this.add(new st),this};var ii=function(){function e(e){this.name=Me.a.NAME_GAMEPAD,this.scene=e}return e.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(Me.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}();B.a.AddNodeConstructor("FreeCamera",(function(e,t){return function(){return new ni(e,a.e.Zero(),t)}}));var ni=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.inputs.addGamepad(),r}return Object(h.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:!1,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:!1,configurable:!0}),t.prototype.getClassName=function(){return"UniversalCamera"},t}(Ft);je.a._createDefaultParsedCamera=function(e,t){return new ni(e,a.e.Zero(),t)},B.a.AddNodeConstructor("GamepadCamera",(function(e,t){return function(){return new ri(e,a.e.Zero(),t)}}));var ri=function(e){function t(t,i,n){return e.call(this,t,i,n)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"GamepadCamera"},t}(ni),oi=i(33),ai=i(5),si="\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}";ai.a.ShadersStore.postprocessVertexShader=si;var ci=i(102);qe.a.prototype.createRenderTargetTexture=function(e,t){var i=new ci.a;void 0!==t&&"object"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=!!t.generateDepthBuffer,i.generateStencilBuffer=!!t.generateStencilBuffer,i.type=void 0===t.type?g.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,i.format=void 0===t.format?g.a.TEXTUREFORMAT_RGBA:t.format):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=g.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i.format=g.a.TEXTUREFORMAT_RGBA),(i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE),i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var n=this._gl,r=new Qe.a(this,Qe.b.RenderTarget),o=e.width||e,a=e.height||e,s=e.layers||0,c=this._getSamplingParameters(i.samplingMode,!!i.generateMipMaps),l=0!==s?n.TEXTURE_2D_ARRAY:n.TEXTURE_2D,u=this._getRGBABufferInternalSizedFormat(i.type,i.format),h=this._getInternalFormat(i.format),d=this._getWebGLTextureType(i.type);this._bindTextureDirectly(l,r),0!==s?(r.is2DArray=!0,n.texImage3D(l,0,u,o,a,s,0,h,d,null)):n.texImage2D(l,0,u,o,a,0,h,d,null),n.texParameteri(l,n.TEXTURE_MAG_FILTER,c.mag),n.texParameteri(l,n.TEXTURE_MIN_FILTER,c.min),n.texParameteri(l,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(l,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),i.generateMipMaps&&this._gl.generateMipmap(l),this._bindTextureDirectly(l,null);var f=this._currentFramebuffer,p=n.createFramebuffer();return this._bindUnboundFramebuffer(p),r._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!i.generateStencilBuffer,i.generateDepthBuffer,o,a),r.is2DArray||n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,r._webGLTexture,0),this._bindUnboundFramebuffer(f),r._framebuffer=p,r.baseWidth=o,r.baseHeight=a,r.width=o,r.height=a,r.depth=s,r.isReady=!0,r.samples=1,r.generateMipMaps=!!i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(r),r},qe.a.prototype.createDepthStencilTexture=function(e,t){if(t.isCube){var i=e.width||e;return this._createDepthStencilCubeTexture(i,t)}return this._createDepthStencilTexture(e,t)},qe.a.prototype._createDepthStencilTexture=function(e,t){var i=this._gl,n=e.layers||0,r=0!==n?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D,o=new Qe.a(this,Qe.b.Depth);if(!this._caps.depthTextureExtension)return m.a.Error("Depth texture is not supported by your browser or hardware."),o;var a=Object(h.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t);this._bindTextureDirectly(r,o,!0),this._setupDepthStencilTexture(o,e,a.generateStencil,a.bilinearFiltering,a.comparisonFunction);var s=a.generateStencil?i.UNSIGNED_INT_24_8:i.UNSIGNED_INT,c=a.generateStencil?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,l=c;return this.webGLVersion>1&&(l=a.generateStencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24),o.is2DArray?i.texImage3D(r,0,l,o.width,o.height,n,0,c,s,null):i.texImage2D(r,0,l,o.width,o.height,0,c,s,null),this._bindTextureDirectly(r,null),o};var li=function(){function e(e,t,i,n,r,s,c,l,u,h,d,f,p,_,m){void 0===c&&(c=g.a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===h&&(h=null),void 0===d&&(d=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f="postprocess"),void 0===_&&(_=!1),void 0===m&&(m=g.a.TEXTUREFORMAT_RGBA),this.width=-1,this.height=-1,this.nodeMaterialSource=null,this._outputTexture=null,this.autoClear=!0,this.alphaMode=g.a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=g.a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new oi.a(2),this._currentRenderTextureInd=0,this._scaleRatio=new a.d(1,1),this._texelSize=a.d.Zero(),this.onActivateObservable=new o.c,this.onSizeChangedObservable=new o.c,this.onApplyObservable=new o.c,this.onBeforeRenderObservable=new o.c,this.onAfterRenderObservable=new o.c,this.name=e,null!=s?(this._camera=s,this._scene=s.getScene(),s.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):l&&(this._engine=l,this._engine.postProcesses.push(this)),this._options=r,this.renderTargetSamplingMode=c||g.a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=u||!1,this._textureType=d,this._textureFormat=m,this._samplers=n||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=f,this._parameters=i||[],this._parameters.push("scale"),this._indexParameters=p,_||this.updateEffect(h)}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){var t=this;this._samples=Math.min(e,this._engine.getCaps().maxMSAASamples),this._textures.forEach((function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)}))},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!1,configurable:!0}),e.prototype.restoreDefaultInputTexture=function(){this._forcedOutputTexture=null},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:!1,configurable:!0}),e.prototype.getClassName=function(){return"PostProcess"},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 oi.a(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,i,n,r,o,a,s){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._effect=this._engine.createEffect({vertex:null!=a?a:this._vertexUrl,fragment:null!=s?s:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,null!==e?e:"",void 0,r,o,n||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype.activate=function(e,t,i){var n=this;void 0===t&&(t=null);var r=(e=e||this._camera).getScene(),o=r.getEngine(),a=o.getCaps().maxTextureSize,s=(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||(s/=2);var u,h=this._options.width||s,d=this._options.height||c,f=this.renderTargetSamplingMode!==g.a.TEXTURE_NEAREST_LINEAR&&this.renderTargetSamplingMode!==g.a.TEXTURE_NEAREST_NEAREST&&this.renderTargetSamplingMode!==g.a.TEXTURE_LINEAR_LINEAR;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var p=o.currentViewport;p&&(h*=p.width,d*=p.height)}if((f||this.alwaysForcePOT)&&(this._options.width||(h=o.needPOTTextures?Se.a.GetExponentOfTwo(h,a,this.scaleMode):h),this._options.height||(d=o.needPOTTextures?Se.a.GetExponentOfTwo(d,a,this.scaleMode):d)),this.width!==h||this.height!==d){if(this._textures.length>0){for(var _=0;_<this._textures.length;_++)this._engine._releaseTexture(this._textures.data[_]);this._textures.reset()}this.width=h,this.height=d;var m={width:this.width,height:this.height},v={generateMipMaps:f,generateDepthBuffer:i||0===e._postProcesses.indexOf(this),generateStencilBuffer:(i||0===e._postProcesses.indexOf(this))&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType,format:this._textureFormat};this._textures.push(this._engine.createRenderTargetTexture(m,v)),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture(m,v)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}this._textures.forEach((function(e){e.samples!==n.samples&&n._engine.updateRenderTargetTextureSampleCount(e,n.samples)}))}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(s/h,c/d),this._engine.bindFramebuffer(u,0,s,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===g.a.ALPHA_DISABLE&&this._engine.clear(this.clearColor?this.clearColor:r.clearColor,r._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),u},Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._effect.isSupported},enumerable:!1,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:!1,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.setPrePassRenderer=function(e){return!!this._prePassEffectConfiguration&&(this._prePassEffectConfiguration=e.addEffectConfiguration(this._prePassEffectConfiguration),this._prePassEffectConfiguration.enabled=!0,!0)},e.prototype.dispose=function(e){var t;if(e=e||this._camera,this._disposeTextures(),this._scene&&-1!==(t=this._scene.postProcesses.indexOf(this))&&this._scene.postProcesses.splice(t,1),-1!==(t=this._engine.postProcesses.indexOf(this))&&this._engine.postProcesses.splice(t,1),e){if(e.detachPostProcess(this),0===(t=e._postProcesses.indexOf(this))&&e._postProcesses.length>0){var i=this._camera._getFirstPostProcess();i&&i.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON."+this.getClassName(),e.cameraId=this.getCamera().id,e.reusable=this._reusable,e.options=this._options,e.textureType=this._textureType,e},e.Parse=function(e,t,i){var n=c.a.GetClass(e.customType);if(!n||!n._Parse)return null;var r=t.getCameraByID(e.cameraId);return r?n._Parse(e,r,t,i):null},Object(h.c)([Object(w.c)()],e.prototype,"uniqueId",void 0),Object(h.c)([Object(w.c)()],e.prototype,"name",void 0),Object(h.c)([Object(w.c)()],e.prototype,"width",void 0),Object(h.c)([Object(w.c)()],e.prototype,"height",void 0),Object(h.c)([Object(w.c)()],e.prototype,"renderTargetSamplingMode",void 0),Object(h.c)([Object(w.f)()],e.prototype,"clearColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"autoClear",void 0),Object(h.c)([Object(w.c)()],e.prototype,"alphaMode",void 0),Object(h.c)([Object(w.c)()],e.prototype,"alphaConstants",void 0),Object(h.c)([Object(w.c)()],e.prototype,"enablePixelPerfectMode",void 0),Object(h.c)([Object(w.c)()],e.prototype,"forceFullscreenViewport",void 0),Object(h.c)([Object(w.c)()],e.prototype,"scaleMode",void 0),Object(h.c)([Object(w.c)()],e.prototype,"alwaysForcePOT",void 0),Object(h.c)([Object(w.c)("samples")],e.prototype,"_samples",void 0),Object(h.c)([Object(w.c)()],e.prototype,"adaptScaleToCurrentViewport",void 0),e}();c.a.RegisteredTypes["BABYLON.PostProcess"]=li;var ui="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";ai.a.ShadersStore.passPixelShader=ui;var hi="\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}";ai.a.ShadersStore.passCubePixelShader=hi;var di=function(e){function t(t,i,n,r,o,a,s,c){return void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),e.call(this,t,"pass",null,null,i,n,r,o,a,void 0,s,void 0,null,c)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"PassPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);c.a.RegisteredTypes["BABYLON.PassPostProcess"]=di;var fi=function(e){function t(t,i,n,r,o,a,s,c){void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"passCube",null,null,i,n,r,o,a,"#define POSITIVEX",s,void 0,null,c)||this;return l._face=0,l}return Object(h.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:!1,configurable:!0}),t.prototype.getClassName=function(){return"PassCubePostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);Se.a._RescalePostProcessFactory=function(e){return new di("rescale",1,null,g.a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,g.a.TEXTURETYPE_UNSIGNED_INT)};var pi="\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}";ai.a.ShadersStore.anaglyphPixelShader=pi;var _i=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,"anaglyph",null,["leftSampler"],i,n[1],r,o,a)||this;return s._passedProcess=n[0]._rigPostProcess,s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",s._passedProcess)})),s}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphPostProcess"},t}(li);c.a.RegisteredTypes["BABYLON.AnaglyphPostProcess"]=_i,je.a._setStereoscopicAnaglyphRigMode=function(e){e._rigCameras[0]._rigPostProcess=new di(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new _i(e.name+"_anaglyph",1,e._rigCameras)},B.a.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,i){return function(){return new mi(e,0,0,1,a.e.Zero(),i.interaxial_distance,t)}}));var mi=function(e){function t(t,i,n,r,o,a,s){var c=e.call(this,t,i,n,r,o,s)||this;return c.interaxialDistance=a,c.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(Bt);B.a.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,i){return function(){return new gi(e,a.e.Zero(),i.interaxial_distance,t)}}));var gi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(wt);B.a.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,i){return function(){return new vi(e,a.e.Zero(),i.interaxial_distance,t)}}));var vi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(ri);B.a.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,i){return function(){return new bi(e,a.e.Zero(),i.interaxial_distance,t)}}));var bi=function(e){function t(t,i,n,r){var o=e.call(this,t,i,r)||this;return o.interaxialDistance=n,o.setCameraRigMode(je.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:n}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(ni),yi=i(58);je.a._setStereoscopicRigMode=function(e){var t=e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,i=e.cameraRigMode===je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e._rigCameras[i?1:0].viewport=new yi.a(0,0,t?.5:1,t?1:.5),e._rigCameras[i?0:1].viewport=new yi.a(t?.5:0,t?0:.5,t?.5:1,t?1:.5)},B.a.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,i){return function(){return new Ti(e,0,0,1,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ti=function(e){function t(t,i,n,r,o,a,s,c){var l=e.call(this,t,i,n,r,o,c)||this;return l.interaxialDistance=a,l.isStereoscopicSideBySide=s,l.setCameraRigMode(s?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(Bt);B.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new Ei(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ei=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(wt);B.a.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,i){return function(){return new Si(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Si=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(ri);B.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new Ai(e,a.e.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var Ai=function(e){function t(t,i,n,r,o){var a=e.call(this,t,i,o)||this;return a.interaxialDistance=n,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?je.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:je.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:n}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(ni);B.a.AddNodeConstructor("VirtualJoysticksCamera",(function(e,t){return function(){return new Pi(e,a.e.Zero(),t)}}));var Pi=function(e){function t(t,i,n){var r=e.call(this,t,i,n)||this;return r.inputs.addVirtualJoystick(),r}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(wt),Ci=function(){function e(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return a.a.Translation(e,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return a.a.Translation(-e,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftPreViewMatrix",{get:function(){return a.a.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightPreViewMatrix",{get:function(){return a.a.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!1,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}(),Ri="\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}";ai.a.ShadersStore.vrDistortionCorrectionPixelShader=Ri;var xi=function(e){function t(t,i,n,r){var o=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,r.postProcessScaleFactor,i,Ke.a.BILINEAR_SAMPLINGMODE)||this;return o._isRightEye=n,o._distortionFactors=r.distortionK,o._postProcessScaleFactor=r.postProcessScaleFactor,o._lensCenterOffset=r.lensCenterOffset,o.adaptScaleToCurrentViewport=!0,o.onSizeChangedObservable.add((function(){o._scaleIn=new a.d(2,2/o.aspectRatio),o._scaleFactor=new a.d(1/o._postProcessScaleFactor*.5,1/o._postProcessScaleFactor*.5*o.aspectRatio),o._lensCenter=new a.d(o._isRightEye?.5-.5*o._lensCenterOffset:.5+.5*o._lensCenterOffset,.5)})),o.onApplyObservable.add((function(e){e.setFloat2("LensCenter",o._lensCenter.x,o._lensCenter.y),e.setFloat2("Scale",o._scaleFactor.x,o._scaleFactor.y),e.setFloat2("ScaleIn",o._scaleIn.x,o._scaleIn.y),e.setFloat4("HmdWarpParam",o._distortionFactors[0],o._distortionFactors[1],o._distortionFactors[2],o._distortionFactors[3])})),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VRDistortionCorrectionPostProcess"},t}(li),Oi="precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";ai.a.ShadersStore.vrMultiviewToSingleviewPixelShader=Oi;var Mi=i(85),Ii=i(95),Di=i(96);qe.a.prototype.createRenderTargetCubeTexture=function(e,t){var i=Object(h.a)({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:g.a.TEXTURETYPE_UNSIGNED_INT,samplingMode:g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,format:g.a.TEXTUREFORMAT_RGBA},t);i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE);var n=this._gl,r=new Qe.a(this,Qe.b.RenderTarget);this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,r,!0);var o=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MAG_FILTER,o.mag),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_MIN_FILTER,o.min),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_CUBE_MAP,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE);for(var a=0;a<6;a++)n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),e,e,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);var s=n.createFramebuffer();return this._bindUnboundFramebuffer(s),r._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,e,e),i.generateMipMaps&&n.generateMipmap(n.TEXTURE_CUBE_MAP),this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),r._framebuffer=s,r.width=e,r.height=e,r.isReady=!0,r.isCube=!0,r.samples=1,r.generateMipMaps=i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=i.generateStencilBuffer,this._internalTexturesCache.push(r),r};var Ni=function(e){function t(t,i,n,r,s,c,l,u,h,d,f,p,_){void 0===s&&(s=!0),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===u&&(u=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=!0),void 0===d&&(d=!1),void 0===f&&(f=!1),void 0===p&&(p=g.a.TEXTUREFORMAT_RGBA),void 0===_&&(_=!1);var m=e.call(this,null,n,!r)||this;return m.renderParticles=!0,m.renderSprites=!1,m.ignoreCameraViewport=!1,m.onBeforeBindObservable=new o.c,m.onAfterUnbindObservable=new o.c,m.onBeforeRenderObservable=new o.c,m.onAfterRenderObservable=new o.c,m.onClearObservable=new o.c,m.onResizeObservable=new o.c,m._currentRefreshId=-1,m._refreshRate=1,m._samples=1,m.boundingBoxPosition=a.e.Zero(),(n=m.getScene())?(m._coordinatesMode=Ke.a.PROJECTION_MODE,m.renderList=new Array,m.name=t,m.isRenderTarget=!0,m._initialSizeParameter=i,m._processSizeParameter(i),m._resizeObserver=m.getScene().getEngine().onResizeObservable.add((function(){})),m._generateMipMaps=!!r,m._doNotChangeAspectRatio=s,m._renderingManager=new Di.b(n),m._renderingManager._useSceneAutoClearSetup=!0,f||(m._renderTargetOptions={generateMipMaps:r,type:c,format:p,samplingMode:u,generateDepthBuffer:h,generateStencilBuffer:d},u===Ke.a.NEAREST_SAMPLINGMODE&&(m.wrapU=Ke.a.CLAMP_ADDRESSMODE,m.wrapV=Ke.a.CLAMP_ADDRESSMODE),_||(l?(m._texture=n.getEngine().createRenderTargetCubeTexture(m.getRenderSize(),m._renderTargetOptions),m.coordinatesMode=Ke.a.INVCUBIC_MODE,m._textureMatrix=a.a.Identity()):m._texture=n.getEngine().createRenderTargetTexture(m._size,m._renderTargetOptions))),m):m}return Object(h.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:!1,configurable:!0}),t.prototype._hookArray=function(e){var t=this,i=e.push;e.push=function(){for(var n=[],r=0;r<arguments.length;r++)n[r]=arguments[r];var o=0===e.length,a=i.apply(e,n);return o&&t.getScene()&&t.getScene().meshes.forEach((function(e){e._markSubMeshesAsLightDirty()})),a};var n=e.splice;e.splice=function(i,r){var o=n.apply(e,[i,r]);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:!1,configurable:!0}),Object.defineProperty(t.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!1,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(g.a.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthStencilTexture",{get:function(){var e;return(null===(e=this.getInternalTexture())||void 0===e?void 0:e._depthStencilTexture)||null},enumerable:!1,configurable:!0}),t.prototype.createDepthStencilTexture=function(e,t,i){void 0===e&&(e=0),void 0===t&&(t=!0),void 0===i&&(i=!1);var n=this.getInternalTexture();if(this.getScene()&&n){var r=this.getScene().getEngine();n._depthStencilTexture=r.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this.isCube})}},t.prototype._processSizeParameter=function(e){if(e.ratio){this._sizeRatio=e.ratio;var t=this._getEngine();this._size={width:this._bestReflectionRenderTargetDimension(t.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(t.getRenderHeight(),this._sizeRatio)}}else 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:!1,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:!1,configurable:!0}),t.prototype.addPostProcess=function(e){if(!this._postProcessManager){var t=this.getScene();if(!t)return;this._postProcessManager=new Ii.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.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},t.prototype.getRenderLayers=function(){var e=this._size.layers;return e||0},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!1,configurable:!0}),t.prototype.scale=function(e){var t=Math.max(1,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){var t=this.isCube;this.releaseInternalTexture();var i=this.getScene();i&&(this._processSizeParameter(e),this._texture=t?i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),s=this.getScene()){var i,n=s.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var r=0;r<this._waitingRenderList.length;r++){var o=this._waitingRenderList[r],a=s.getMeshByID(o);a&&this.renderList.push(a)}this._waitingRenderList=void 0}if(this.renderListPredicate){var s;if(this.renderList?this.renderList.length=0:this.renderList=[],!(s=this.getScene()))return;var c=s.meshes;for(r=0;r<c.length;r++){var l=c[r];this.renderListPredicate(l)&&this.renderList.push(l)}}if(this.onBeforeBindObservable.notifyObservers(this),this.activeCamera?(i=this.activeCamera,n.setViewport(this.activeCamera.viewport,this.getRenderWidth(),this.getRenderHeight()),this.activeCamera!==s.activeCamera&&s.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):(i=s.activeCamera)&&n.setViewport(i.viewport,this.getRenderWidth(),this.getRenderHeight()),this._defaultRenderListPrepared=!1,this.is2DArray)for(var u=0;u<this.getRenderLayers();u++)this.renderToTarget(0,e,t,u,i),s.incrementRenderId(),s.resetCachedMaterial();else if(this.isCube)for(var h=0;h<6;h++)this.renderToTarget(h,e,t,void 0,i),s.incrementRenderId(),s.resetCachedMaterial();else this.renderToTarget(0,e,t,void 0,i);this.onAfterUnbindObservable.notifyObservers(this),s.activeCamera&&((s.getEngine().scenes.length>1||this.activeCamera&&this.activeCamera!==s.activeCamera)&&s.setTransformMatrix(s.activeCamera.getViewMatrix(),s.activeCamera.getProjectionMatrix(!0)),n.setViewport(s.activeCamera.viewport)),s.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var i=e*t,n=Se.a.NearestPOT(i+16384/(128+i));return Math.min(Se.a.FloorPOT(e),n)},t.prototype._prepareRenderingManager=function(e,t,i,n){var r=this.getScene();if(r){this._renderingManager.reset();for(var o=r.getRenderId(),a=0;a<t;a++){var s=e[a];if(s&&!s.isBlocked){if(this.customIsReadyFunction){if(!this.customIsReadyFunction(s,this.refreshRate)){this.resetRefreshCounter();continue}}else if(!s.isReady(0===this.refreshRate)){this.resetRefreshCounter();continue}if(!s._internalAbstractMeshDataInfo._currentLODIsUpToDate&&r.activeCamera&&(s._internalAbstractMeshDataInfo._currentLOD=r.customLODSelector?r.customLODSelector(s,r.activeCamera):s.getLOD(r.activeCamera),s._internalAbstractMeshDataInfo._currentLODIsUpToDate=!0),!s._internalAbstractMeshDataInfo._currentLOD)continue;var c=s._internalAbstractMeshDataInfo._currentLOD;c._preActivateForIntermediateRendering(o);var l=void 0;if(l=!(!n||!i)&&0==(s.layerMask&i.layerMask),s.isEnabled()&&s.isVisible&&s.subMeshes&&!l&&(c!==s&&c._activate(o,!0),s._activate(o,!0)&&s.subMeshes.length)){s.isAnInstance?s._internalAbstractMeshDataInfo._actAsRegularMesh&&(c=s):c._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!1,c._internalAbstractMeshDataInfo._isActiveIntermediate=!0;for(var u=0;u<c.subMeshes.length;u++){var h=c.subMeshes[u];this._renderingManager.dispatch(h,c)}}}}for(var d=0;d<r.particleSystems.length;d++){var f=r.particleSystems[d],p=f.emitter;f.isStarted()&&p&&p.position&&p.isEnabled()&&(e.indexOf(p)>=0&&this._renderingManager.dispatchParticles(f))}}},t.prototype._bindFrameBuffer=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var i=this.getScene();if(i){var n=i.getEngine();this._texture&&n.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}},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,n,r){void 0===n&&(n=0),void 0===r&&(r=null);var o=this.getScene();if(o){var a=o.getEngine();if(this._texture){this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):t&&o.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(e,n),this.is2DArray?this.onBeforeRenderObservable.notifyObservers(n):this.onBeforeRenderObservable.notifyObservers(e);var s=null,c=this.renderList?this.renderList:o.getActiveMeshes().data,l=this.renderList?this.renderList.length:o.getActiveMeshes().length;this.getCustomRenderList&&(s=this.getCustomRenderList(this.is2DArray?n:e,c,l)),s?this._prepareRenderingManager(s,s.length,r,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(c,l,r,!this.renderList),this._defaultRenderListPrepared=!0),s=c),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(a):a.clear(this.clearColor||o.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0);for(var u=0,h=o._beforeRenderTargetDrawStage;u<h.length;u++){h[u].action(this)}this._renderingManager.render(this.customRenderFunction,s,this.renderParticles,this.renderSprites);for(var d=0,f=o._afterRenderTargetDrawStage;d<f.length;d++){f[d].action(this)}this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,e,this._postProcesses,this.ignoreCameraViewport):t&&o.postProcessManager._finalizeFrame(!1,this._texture,e),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0),i&&Ce.b.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),a),this.isCube&&5!==e?this.onAfterRenderObservable.notifyObservers(e):(this.isCube&&5===e&&a.generateMipMapsForCubemap(this._texture),this.unbindFrameBuffer(a,e))}}},t.prototype.setRenderingOrder=function(e,t,i,n){void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),this._renderingManager.setRenderingOrder(e,t,i,n)},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.onResizeObservable.clear(),this.onClearObservable.clear(),this.onAfterRenderObservable.clear(),this.onAfterUnbindObservable.clear(),this.onBeforeBindObservable.clear(),this.onBeforeRenderObservable.clear(),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 n=0,r=t.cameras;n<r.length;n++){var o=r[n];(i=o.customRenderTargets.indexOf(this))>=0&&o.customRenderTargets.splice(i,1)}this.depthStencilTexture&&this.getScene().getEngine()._releaseTexture(this.depthStencilTexture),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.prototype.getViewCount=function(){return 1},t.REFRESHRATE_RENDER_ONCE=0,t.REFRESHRATE_RENDER_ONEVERYFRAME=1,t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,t}(Ke.a);Ke.a._CreateRenderTargetTexture=function(e,t,i,n){return new Ni(e,t,i,n)};var Li=function(e){function t(t,i){void 0===i&&(i=512);var n=e.call(this,"multiview rtt",i,t,!1,!0,Qe.b.Unknown,!1,void 0,!1,!1,!0,void 0,!0)||this,r=t.getEngine().createMultiviewRenderTargetTexture(n.getRenderWidth(),n.getRenderHeight());return r.isMultiview=!0,r.format=g.a.TEXTUREFORMAT_RGBA,n._texture=r,n.samples=n._getEngine().getCaps().maxSamples||n.samples,n}return Object(h.d)(t,e),t.prototype._bindFrameBuffer=function(e){void 0===e&&(e=0),this._texture&&this.getScene().getEngine().bindMultiviewFramebuffer(this._texture)},t.prototype.getViewCount=function(){return 2},t}(Ni),wi=i(90);Se.a.prototype.createMultiviewRenderTargetTexture=function(e,t){var i=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var n=new Qe.a(this,Qe.b.Unknown,!0);return n.width=e,n.height=t,n._framebuffer=i.createFramebuffer(),n._colorTextureArray=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,n._colorTextureArray),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.RGBA8,e,t,2),n._depthStencilTextureArray=i.createTexture(),i.bindTexture(i.TEXTURE_2D_ARRAY,n._depthStencilTextureArray),i.texStorage3D(i.TEXTURE_2D_ARRAY,1,i.DEPTH32F_STENCIL8,e,t,2),n.isReady=!0,n},Se.a.prototype.bindMultiviewFramebuffer=function(e){var t=this._gl,i=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(e,void 0,void 0,void 0,!0),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,e._framebuffer),!e._colorTextureArray||!e._depthStencilTextureArray)throw"Invalid multiview frame buffer";this.getCaps().oculusMultiview?(i.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,e.samples,0,2),i.framebufferTextureMultisampleMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,e.samples,0,2)):(i.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,0,2),i.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,0,2))},je.a.prototype._useMultiviewToSingleView=!1,je.a.prototype._multiviewTexture=null,je.a.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new Li(this.getScene(),{width:e,height:t})):this._multiviewTexture=new Li(this.getScene(),{width:e,height:t})},Q.a.prototype._transformMatrixR=a.a.Zero(),Q.a.prototype._multiviewSceneUbo=null,Q.a.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=new Mi.a(this.getEngine(),void 0,!0),this._multiviewSceneUbo.addUniform("viewProjection",16),this._multiviewSceneUbo.addUniform("viewProjectionR",16),this._multiviewSceneUbo.addUniform("view",16)},Q.a.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,a.c.Matrix[0]),wi.a.GetRightPlaneToRef(a.c.Matrix[0],this._frustumPlanes[3])),this._multiviewSceneUbo&&(this._multiviewSceneUbo.updateMatrix("viewProjection",this.getTransformMatrix()),this._multiviewSceneUbo.updateMatrix("viewProjectionR",this._transformMatrixR),this._multiviewSceneUbo.updateMatrix("view",this._viewMatrix),this._multiviewSceneUbo.update())},Q.a.prototype._renderMultiviewToSingleView=function(e){e._resizeOrCreateMultiviewTexture(e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.width>0?e._rigPostProcess.width:this.getEngine().getRenderWidth(!0),e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.height>0?e._rigPostProcess.height:this.getEngine().getRenderHeight(!0)),this._multiviewSceneUbo||this._createMultiviewUbo(),e.outputRenderTarget=e._multiviewTexture,this._renderForCamera(e),e.outputRenderTarget=null;for(var t=0;t<e._rigCameras.length;t++){var i=this.getEngine();this._activeCamera=e._rigCameras[t],i.setViewport(this._activeCamera.viewport),this.postProcessManager&&(this.postProcessManager._prepareFrame(),this.postProcessManager._finalizeFrame(this._activeCamera.isIntermediate))}};var Fi=function(e){function t(t,i,n){var r=e.call(this,t,"vrMultiviewToSingleview",["imageIndex"],["multiviewSampler"],n,i,Ke.a.BILINEAR_SAMPLINGMODE)||this;return r.onSizeChangedObservable.add((function(){})),r.onApplyObservable.add((function(e){i._scene.activeCamera&&i._scene.activeCamera.isLeftCamera?e.setInt("imageIndex",0):e.setInt("imageIndex",1),e.setTexture("multiviewSampler",i._multiviewTexture)})),r}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VRMultiviewToSingleviewPostProcess"},t}(li);je.a._setVRRigMode=function(e,t){var i=t.vrCameraMetrics||Ci.GetDefault();e._rigCameras[0]._cameraRigParams.vrMetrics=i,e._rigCameras[0].viewport=new yi.a(0,0,.5,1),e._rigCameras[0]._cameraRigParams.vrWorkMatrix=new a.a,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 yi.a(.5,0,.5,1),e._rigCameras[1]._cameraRigParams.vrWorkMatrix=new a.a,e._rigCameras[1]._cameraRigParams.vrHMatrix=i.rightHMatrix,e._rigCameras[1]._cameraRigParams.vrPreViewMatrix=i.rightPreViewMatrix,e._rigCameras[1].getProjectionMatrix=e._rigCameras[1]._getVRProjectionMatrix,i.multiviewEnabled&&(e.getScene().getEngine().getCaps().multiview?(e._useMultiviewToSingleView=!0,e._rigPostProcess=new Fi("VRMultiviewToSingleview",e,i.postProcessScaleFactor)):(m.a.Warn("Multiview is not supported, falling back to standard rendering"),i.multiviewEnabled=!1)),i.compensateDistortion&&(e._rigCameras[0]._rigPostProcess=new xi("VR_Distort_Compensation_Left",e._rigCameras[0],!1,i),e._rigCameras[1]._rigPostProcess=new xi("VR_Distort_Compensation_Right",e._rigCameras[1],!0,i))},B.a.AddNodeConstructor("VRDeviceOrientationFreeCamera",(function(e,t){return function(){return new Bi(e,0,0,1,a.e.Zero(),t)}}));var Bi=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=!0),void 0===c&&(c=Ci.GetDefault());var l=e.call(this,t,i,n,r,o,a)||this;return c.compensateDistortion=s,l.setCameraRigMode(je.a.RIG_MODE_VR,{vrCameraMetrics:c}),l.inputs.addVRDeviceOrientation(),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VRDeviceOrientationArcRotateCamera"},t}(Bt);B.a.AddNodeConstructor("VRDeviceOrientationFreeCamera",(function(e,t){return function(){return new Ui(e,a.e.Zero(),t)}}));var Ui=function(e){function t(t,i,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=Ci.GetDefault());var a=e.call(this,t,i,n)||this;return o.compensateDistortion=r,a.setCameraRigMode(je.a.RIG_MODE_VR,{vrCameraMetrics:o}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VRDeviceOrientationFreeCamera"},t}(Ut);B.a.AddNodeConstructor("VRDeviceOrientationGamepadCamera",(function(e,t){return function(){return new Vi(e,a.e.Zero(),t)}}));var Vi=function(e){function t(t,i,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=Ci.GetDefault());var a=e.call(this,t,i,n,r,o)||this;return a.inputs.addGamepad(),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VRDeviceOrientationGamepadCamera"},t}(Ui),ki=i(86);je.a._setWebVRRigMode=function(e,t){if(t.vrDisplay){var i=t.vrDisplay.getEyeParameters("left"),n=t.vrDisplay.getEyeParameters("right");e._rigCameras[0].viewport=new yi.a(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 a.a,e._rigCameras[0].getProjectionMatrix=e._getWebVRProjectionMatrix,e._rigCameras[0].parent=e,e._rigCameras[0]._getViewMatrix=e._getWebVRViewMatrix,e._rigCameras[1].viewport=new yi.a(.5,0,.5,1),e._rigCameras[1].setCameraRigParameter("eyeParameters",n),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 a.a,e._rigCameras[1].getProjectionMatrix=e._getWebVRProjectionMatrix,e._rigCameras[1].parent=e,e._rigCameras[1]._getViewMatrix=e._getWebVRViewMatrix}},Object.defineProperty(Se.a.prototype,"isInVRExclusivePointerMode",{get:function(){return this._vrExclusivePointerMode},enumerable:!0,configurable:!0}),Se.a.prototype._prepareVRComponent=function(){this._vrSupported=!1,this._vrExclusivePointerMode=!1,this.onVRDisplayChangedObservable=new o.c,this.onVRRequestPresentComplete=new o.c,this.onVRRequestPresentStart=new o.c},Se.a.prototype.isVRDevicePresent=function(){return!!this._vrDisplay},Se.a.prototype.getVRDevice=function(){return this._vrDisplay},Se.a.prototype.initWebVR=function(){return this.initWebVRAsync(),this.onVRDisplayChangedObservable},Se.a.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)}))};if(!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=Se.a.QueueNewFrame(e._boundRenderFunction),t()},this._onVrDisplayPresentChange=function(){e._vrExclusivePointerMode=e._vrDisplay&&e._vrDisplay.isPresenting};var i=this.getHostWindow();i&&(i.addEventListener("vrdisplayconnect",this._onVrDisplayConnect),i.addEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),i.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange))}return this._webVRInitPromise=this._webVRInitPromise||this._getVRDisplaysAsync(),this._webVRInitPromise.then(t),this._webVRInitPromise},Se.a.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}))}))},Se.a.prototype.enableVR=function(e){var t=this;if(this._vrDisplay&&!this._vrDisplay.isPresenting){this.onVRRequestPresentStart.notifyObservers(this);var i={highRefreshRate:!!this.vrPresentationAttributes&&this.vrPresentationAttributes.highRefreshRate,foveationLevel:this.vrPresentationAttributes?this.vrPresentationAttributes.foveationLevel:1,multiview:(this.getCaps().multiview||this.getCaps().oculusMultiview)&&e.useMultiview};this._vrDisplay.requestPresent([Object(h.a)({source:this.getRenderingCanvas(),attributes:i},i)]).then((function(){t.onVRRequestPresentComplete.notifyObservers(!0),t._onVRFullScreenTriggered()})).catch((function(){t.onVRRequestPresentComplete.notifyObservers(!1)}))}},Se.a.prototype._onVRFullScreenTriggered=function(){if(this._vrDisplay&&this._vrDisplay.isPresenting){this._oldSize=new U.a(this.getRenderWidth(),this.getRenderHeight()),this._oldHardwareScaleFactor=this.getHardwareScalingLevel();var e=this._vrDisplay.getEyeParameters("left");this.setHardwareScalingLevel(1),this.setSize(2*e.renderWidth,e.renderHeight)}else this.setHardwareScalingLevel(this._oldHardwareScaleFactor),this.setSize(this._oldSize.width,this._oldSize.height)},Se.a.prototype.disableVR=function(){var e=this;this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.exitPresent().then((function(){return e._onVRFullScreenTriggered()})).catch((function(){return e._onVRFullScreenTriggered()})),Ht.a.IsWindowObjectExist()&&(window.removeEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted),window.removeEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted),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))},Se.a.prototype._connectVREvents=function(e,t){var i=this;if(this._onVRDisplayPointerRestricted=function(){e&&e.requestPointerLock()},this._onVRDisplayPointerUnrestricted=function(){if(t)t.exitPointerLock&&t.exitPointerLock();else{var e=i.getHostWindow();e.document&&e.document.exitPointerLock&&e.document.exitPointerLock()}},Ht.a.IsWindowObjectExist()){var n=this.getHostWindow();n.addEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted,!1),n.addEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted,!1)}},Se.a.prototype._submitVRFrame=function(){if(this._vrDisplay&&this._vrDisplay.isPresenting)try{this._vrDisplay.submitFrame()}catch(e){Ce.b.Warn("webVR submitFrame has had an unexpected failure: "+e)}},Se.a.prototype.isVRPresenting=function(){return this._vrDisplay&&this._vrDisplay.isPresenting},Se.a.prototype._requestVRFrame=function(){this._frameHandler=Se.a.QueueNewFrame(this._boundRenderFunction,this._vrDisplay)},B.a.AddNodeConstructor("WebVRFreeCamera",(function(e,t){return function(){return new zi(e,a.e.Zero(),t)}})),B.a.AddNodeConstructor("WebVRGamepadCamera",(function(e,t){return function(){return new zi(e,a.e.Zero(),t)}}));var zi=function(e){function t(t,i,n,r){void 0===r&&(r={});var s=e.call(this,t,i,n)||this;s.webVROptions=r,s._vrDevice=null,s.rawPose=null,s._specsVersion="1.1",s._attached=!1,s._descendants=[],s._deviceRoomPosition=a.e.Zero(),s._deviceRoomRotationQuaternion=a.b.Identity(),s._standingMatrix=null,s.devicePosition=a.e.Zero(),s.deviceRotationQuaternion=a.b.Identity(),s.deviceScaleFactor=1,s._deviceToWorld=a.a.Identity(),s._worldToDevice=a.a.Identity(),s.controllers=[],s.onControllersAttachedObservable=new o.c,s.onControllerMeshLoadedObservable=new o.c,s.onPoseUpdatedFromDeviceObservable=new o.c,s._poseSet=!1,s.rigParenting=!0,s._defaultHeight=void 0,s._detachIfAttached=function(){var e=s.getEngine().getVRDevice();e&&!e.isPresenting&&s.detachControl()},s._workingVector=a.e.Zero(),s._oneVector=a.e.One(),s._workingMatrix=a.a.Identity(),s._tmpMatrix=new a.a,s._cache.position=a.e.Zero(),r.defaultHeight&&(s._defaultHeight=r.defaultHeight,s.position.y=s._defaultHeight),s.minZ=.1,5===arguments.length&&(s.webVROptions=arguments[4]),null==s.webVROptions.trackPosition&&(s.webVROptions.trackPosition=!0),null==s.webVROptions.controllerMeshes&&(s.webVROptions.controllerMeshes=!0),null==s.webVROptions.defaultLightingOnControllers&&(s.webVROptions.defaultLightingOnControllers=!0),s.rotationQuaternion=new a.b,s.webVROptions&&s.webVROptions.positionScale&&(s.deviceScaleFactor=s.webVROptions.positionScale);var c=s.getEngine();return s._onVREnabled=function(e){e&&s.initControllers()},c.onVRRequestPresentComplete.add(s._onVREnabled),c.initWebVR().add((function(e){e.vrDisplay&&s._vrDevice!==e.vrDisplay&&(s._vrDevice=e.vrDisplay,s.setCameraRigMode(je.a.RIG_MODE_WEBVR,{parentCamera:s,vrDisplay:s._vrDevice,frameData:s._frameData,specs:s._specsVersion}),s._attached&&s.getEngine().enableVR(s.webVROptions))})),"undefined"!=typeof VRFrameData&&(s._frameData=new VRFrameData),r.useMultiview&&(s.getScene().getEngine().getCaps().multiview?(s._useMultiviewToSingleView=!0,s._rigPostProcess=new Fi("VRMultiviewToSingleview",s,1)):(m.a.Warn("Multiview is not supported, falling back to standard rendering"),s._useMultiviewToSingleView=!1)),n.onBeforeCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&(s._descendants=s.getDescendants(!0,(function(e){var t=s.controllers.some((function(t){return t._mesh===e})),i=-1!==s._rigCameras.indexOf(e);return!t&&!i})),s._descendants.forEach((function(t){t.parent=e})))})),n.onAfterCameraRenderObservable.add((function(e){e.parent===s&&s.rigParenting&&s._descendants.forEach((function(e){e.parent=s}))})),s}return Object(h.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 a.a,a.a.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 n=i[t];if(n.hand===e)return n}return null},Object.defineProperty(t.prototype,"leftController",{get:function(){return this._leftController||(this._leftController=this.getControllerByName("left")),this._leftController},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rightController",{get:function(){return this._rightController||(this._rightController=this.getControllerByName("right")),this._rightController},enumerable:!1,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&&4===e.orientation.length&&(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){t=Ce.b.BackCompatCameraNoPreventDefault(arguments),e.prototype.attachControl.call(this,t),this._attached=!0,t=!je.a.ForceAttachControlToAlwaysPreventDefault&&t,this._vrDevice&&this.getEngine().enableVR(this.webVROptions);var i=this._scene.getEngine().getHostWindow();i&&i.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),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&&(a.a.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),a.e.TransformCoordinatesToRef(this._deviceRoomPosition,this._workingMatrix,this._workingVector),this.devicePosition.subtractToRef(this._workingVector,this._workingVector),a.a.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(){a.e.TransformCoordinatesToRef(this._deviceRoomPosition,this._deviceToWorld,this.devicePosition)},t.prototype.update=function(){this._computeDevicePosition(),a.a.FromQuaternionToRef(this._deviceRoomRotationQuaternion,this._workingMatrix),this._workingMatrix.multiplyToRef(this._deviceToWorld,this._workingMatrix),a.b.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this._poseSet&&this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),e.prototype.update.call(this)},t.prototype._getViewMatrix=function(){return a.a.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 a.a.FromArrayToRef(t,0,this._webvrViewMatrix),this.getScene().useRightHandedSystem||this._webvrViewMatrix.toggleModelMatrixHandInPlace(),this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),a.e.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||a.a.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 a.a.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===ot.POSE_ENABLED){var i=t;i.defaultModel&&i.defaultModel.setEnabled(!1),"right"===i.hand&&(e._rightController=null),"left"===i.hand&&(e._leftController=null);var n=e.controllers.indexOf(i);-1!==n&&e.controllers.splice(n,1)}})),this._onGamepadConnectedObserver=t.onGamepadConnectedObservable.add((function(t){if(t.type===ot.POSE_ENABLED){var i=t;if(e.webVROptions.trackPosition||(i._disableTrackPosition(new a.e("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 ki.a("vrControllersLight",new a.e(0,1,0),e.getScene()));var n=function(e,t){var i=e.getChildren();i&&0!==i.length&&i.forEach((function(e){t.includedOnlyMeshes.push(e),n(e,t)}))};e._lightOnControllers.includedOnlyMeshes.push(t),n(t,e._lightOnControllers)}}))),i.attachToPoseControlledCamera(e),-1===e.controllers.indexOf(i)){e.controllers.push(i);for(var n=!1,r=0;r<e.controllers.length;r++)e.controllers[r].controllerType===Gt.VIVE&&(n?e.controllers[r].hand="right":(n=!0,e.controllers[r].hand="left"));e.controllers.length>=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}}))},t}(wt),Gi=function(e){function t(t){var i=e.call(this,t)||this;return i.onTriggerStateChangedObservable=new o.c,i.onMainButtonStateChangedObservable=new o.c,i.onSecondaryButtonStateChangedObservable=new o.c,i.onPadStateChangedObservable=new o.c,i.onPadValuesChangedObservable=new o.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 Object(h.d)(t,e),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!1,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._defaultModel=null,this.onTriggerStateChangedObservable.clear(),this.onMainButtonStateChangedObservable.clear(),this.onSecondaryButtonStateChangedObservable.clear(),this.onPadStateChangedObservable.clear(),this.onPadValuesChangedObservable.clear()},t}(qt),ji=i(42),Wi=i(30),Hi=i(62),Xi=(i(108),i(59),i(109),"\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}");ai.a.ShadersStore.imageProcessingPixelShader=Xi;var Yi=function(e){function t(t,i,n,r,o,a,s,c){void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,"imageProcessing",[],[],i,n,r,o,a,null,s,"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 Object(h.d)(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){e.applyByPostProcess=!0,this._attachImageProcessingConfiguration(e)},enumerable:!1,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 n=null,r=this.getEngine(),o=this.getCamera();if(o)n=o.getScene();else if(r&&r.scenes){var a=r.scenes;n=a[a.length-1]}else n=x.a.LastCreatedScene;this._imageProcessingConfiguration=n?n.imageProcessingConfiguration:new ji.a}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){i._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(t.prototype,"isSupported",{get:function(){var e=this.getEffect();return!e||e.isSupported},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingType",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!1,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"],n=["scale"];ji.a&&(ji.a.PrepareSamplers(i,this._defines),ji.a.PrepareUniforms(n,this._defines)),this.updateEffect(e,n,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)},Object(h.c)([Object(w.c)()],t.prototype,"_fromLinearSpace",void 0),t}(li),Ki=i(16),Qi=i(4);be.a._GroundMeshParser=function(e,t){return qi.Parse(e,t)};var qi=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.generateOctree=!1,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!1,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(),n=a.c.Matrix[5];i.invertToRef(n);var r=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,n,r),e=r.x,t=r.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 o=this._getFacetAt(e,t),s=-(o.x*e+o.z*t+o.w)/o.y;return a.e.TransformCoordinatesFromFloatsToRef(0,s,0,i,r),r.y},t.prototype.getNormalAtCoordinates=function(e,t){var i=new a.e(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},t.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var n=this.getWorldMatrix(),r=a.c.Matrix[5];n.invertToRef(r);var o=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,r,o),e=o.x,t=o.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 s=this._getFacetAt(e,t);return a.e.TransformNormalFromFloatsToRef(s.x,s.y,s.z,n,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),n=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[n*this._subdivisionsX+i];return t<r.slope.x*e+r.slope.y?r.facet1:r.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 n=0;n<e;n++){var r={slope:a.d.Zero(),facet1:new a.f(0,0,0,0),facet2:new a.f(0,0,0,0)};this._heightQuads[i*e+n]=r}return this},t.prototype._computeHeightQuads=function(){var e=this.getVerticesData(Qi.b.PositionKind);if(!e)return this;for(var t=a.c.Vector3[3],i=a.c.Vector3[2],n=a.c.Vector3[1],r=a.c.Vector3[0],o=a.c.Vector3[4],s=a.c.Vector3[5],c=a.c.Vector3[6],l=a.c.Vector3[7],u=a.c.Vector3[8],h=0,d=0,f=0,p=0,_=0,m=0,g=0,v=this._subdivisionsX,b=this._subdivisionsY,y=0;y<b;y++)for(var T=0;T<v;T++){h=3*T,d=y*(v+1)*3,f=(y+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],n.x=e[f+h],n.y=e[f+h+1],n.z=e[f+h+2],r.x=e[f+h+3],r.y=e[f+h+4],r.z=e[f+h+5],p=(r.z-t.z)/(r.x-t.x),_=t.z-p*t.x,i.subtractToRef(t,o),n.subtractToRef(t,s),r.subtractToRef(t,c),a.e.CrossToRef(c,s,l),a.e.CrossToRef(o,c,u),l.normalize(),u.normalize(),m=-(l.x*t.x+l.y*t.y+l.z*t.z),g=-(u.x*i.x+u.y*i.y+u.z*i.z);var E=this._heightQuads[y*v+T];E.slope.copyFromFloats(p,_),E.facet1.copyFromFloats(l.x,l.y,l.z,m),E.facet2.copyFromFloats(u.x,u.y,u.z,g)}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 n=new t(e.name,i);return n._subdivisionsX=e.subdivisionsX||1,n._subdivisionsY=e.subdivisionsY||1,n._minX=e.minX,n._maxX=e.maxX,n._minZ=e.minZ,n._maxZ=e.maxZ,n._width=e.width,n._height=e.height,n},t}(be.a),Zi=i(70);Ki.a.CreateGround=function(e){var t,i,n=[],r=[],o=[],s=[],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 a.e(i*c/u-c/2,0,(h-t)*l/h-l/2),f=new a.e(0,1,0);r.push(d.x,d.y,d.z),o.push(f.x,f.y,f.z),s.push(i/u,1-t/h)}for(t=0;t<h;t++)for(i=0;i<u;i++)n.push(i+1+(t+1)*(u+1)),n.push(i+1+t*(u+1)),n.push(i+t*(u+1)),n.push(i+(t+1)*(u+1)),n.push(i+1+(t+1)*(u+1)),n.push(i+t*(u+1));var p=new Ki.a;return p.indices=n,p.positions=r,p.normals=o,p.uvs=s,p},Ki.a.CreateTiledGround=function(e){var t,i,n,r,o=void 0!==e.xmin&&null!==e.xmin?e.xmin:-1,s=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 m=(c-o)/u.w,g=(l-s)/u.h;function v(e,n,r,o){var s=f.length/3,c=h.w+1;for(t=0;t<h.h;t++)for(i=0;i<h.w;i++){var l=[s+i+t*c,s+(i+1)+t*c,s+(i+1)+(t+1)*c,s+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=a.e.Zero(),m=new a.e(0,1,0);for(t=0;t<=h.h;t++)for(u.z=t*(o-n)/h.h+n,i=0;i<=h.w;i++)u.x=i*(r-e)/h.w+e,u.y=0,f.push(u.x,u.y,u.z),p.push(m.x,m.y,m.z),_.push(i/h.w,t/h.h)}for(n=0;n<u.h;n++)for(r=0;r<u.w;r++)v(o+r*m,s+n*g,o+(r+1)*m,s+(n+1)*g);var b=new Ki.a;return b.indices=d,b.positions=f,b.normals=p,b.uvs=_,b},Ki.a.CreateGroundFromHeightMap=function(e){var t,i,n=[],r=[],o=[],c=[],l=e.colorFilter||new s.a(.3,.59,.11),u=e.alphaFilter||0,h=!1;if(e.minHeight>e.maxHeight){h=!0;var d=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=d}for(t=0;t<=e.subdivisions;t++)for(i=0;i<=e.subdivisions;i++){var f=new a.e(i*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),p=4*(((f.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(f.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),_=e.buffer[p]/255,m=e.buffer[p+1]/255,g=e.buffer[p+2]/255,v=e.buffer[p+3]/255;h&&(_=1-_,m=1-m,g=1-g);var b=_*l.r+m*l.g+g*l.b;f.y=v>=u?e.minHeight+(e.maxHeight-e.minHeight)*b:e.minHeight-Nt.a,r.push(f.x,f.y,f.z),o.push(0,0,0),c.push(i/e.subdivisions,1-t/e.subdivisions)}for(t=0;t<e.subdivisions;t++)for(i=0;i<e.subdivisions;i++){var y=i+1+(t+1)*(e.subdivisions+1),T=i+1+t*(e.subdivisions+1),E=i+t*(e.subdivisions+1),S=i+(t+1)*(e.subdivisions+1),A=r[3*y+1]>=e.minHeight,P=r[3*T+1]>=e.minHeight,C=r[3*E+1]>=e.minHeight;A&&P&&C&&(n.push(y),n.push(T),n.push(E)),r[3*S+1]>=e.minHeight&&A&&C&&(n.push(S),n.push(y),n.push(E))}Ki.a.ComputeNormals(r,n,o);var R=new Ki.a;return R.indices=n,R.positions=r,R.normals=o,R.uvs=c,R},be.a.CreateGround=function(e,t,i,n,r,o){var a={width:t,height:i,subdivisions:n,updatable:o};return Ji.CreateGround(e,a,r)},be.a.CreateTiledGround=function(e,t,i,n,r,o,a,s,c){var l={xmin:t,zmin:i,xmax:n,zmax:r,subdivisions:o,precision:a,updatable:c};return Ji.CreateTiledGround(e,l,s)},be.a.CreateGroundFromHeightMap=function(e,t,i,n,r,o,a,s,c,l,u){var h={width:i,height:n,subdivisions:r,minHeight:o,maxHeight:a,updatable:c,onReady:l,alphaFilter:u};return Ji.CreateGroundFromHeightMap(e,t,h,s)};var Ji=function(){function e(){}return e.CreateGround=function(e,t,i){var n=new qi(e,i);return n._setReady(!1),n._subdivisionsX=t.subdivisionsX||t.subdivisions||1,n._subdivisionsY=t.subdivisionsY||t.subdivisions||1,n._width=t.width||1,n._height=t.height||1,n._maxX=n._width/2,n._maxZ=n._height/2,n._minX=-n._maxX,n._minZ=-n._maxZ,Ki.a.CreateGround(t).applyToMesh(n,t.updatable),n._setReady(!0),n},e.CreateTiledGround=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return Ki.a.CreateTiledGround(t).applyToMesh(n,t.updatable),n},e.CreateGroundFromHeightMap=function(e,t,i,n){void 0===n&&(n=null);var r=i.width||10,o=i.height||10,a=i.subdivisions||1,c=i.minHeight||0,l=i.maxHeight||1,u=i.colorFilter||new s.a(.3,.59,.11),h=i.alphaFilter||0,d=i.updatable,f=i.onReady;n=n||x.a.LastCreatedScene;var p=new qi(e,n);p._subdivisionsX=a,p._subdivisionsY=a,p._width=r,p._height=o,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1);return Ce.b.LoadImage(t,(function(e){var t=e.width,i=e.height,s=Zi.a.CreateCanvas(t,i).getContext("2d");if(!s)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!n.isDisposed){s.drawImage(e,0,0);var _=s.getImageData(0,0,t,i).data;Ki.a.CreateGroundFromHeightMap({width:r,height:o,subdivisions:a,minHeight:c,maxHeight:l,colorFilter:u,buffer:_,bufferWidth:t,bufferHeight:i,alphaFilter:h}).applyToMesh(p,d),f&&f(p),p._setReady(!0)}}),(function(){}),n.offlineProvider),p},e}();Ki.a.CreateTorus=function(e){for(var t=[],i=[],n=[],r=[],o=e.diameter||1,s=e.thickness||.5,c=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||Ki.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=a.a.Translation(o/2,0,0).multiply(a.a.RotationY(f)),_=0;_<=c;_++){var m=1-_/c,g=_*Math.PI*2/c+Math.PI,v=Math.cos(g),b=Math.sin(g),y=new a.e(v,b,0),T=y.scale(s/2),E=new a.d(d,m);T=a.e.TransformCoordinates(T,p),y=a.e.TransformNormal(y,p),i.push(T.x,T.y,T.z),n.push(y.x,y.y,y.z),r.push(E.x,E.y);var S=(h+1)%u,A=(_+1)%u;t.push(h*u+_),t.push(h*u+A),t.push(S*u+_),t.push(h*u+A),t.push(S*u+A),t.push(S*u+_)}Ki.a._ComputeSides(l,i,t,n,r,e.frontUVs,e.backUVs);var P=new Ki.a;return P.indices=t,P.positions=i,P.normals=n,P.uvs=r,P},be.a.CreateTorus=function(e,t,i,n,r,o,a){var s={diameter:t,thickness:i,tessellation:n,sideOrientation:a,updatable:o};return tn.CreateTorus(e,s,r)};var $i,en,tn=function(){function e(){}return e.CreateTorus=function(e,t,i){var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateTorus(t).applyToMesh(n,t.updatable),n},e}(),nn=i(53),rn=function(){function e(){}return e.GetDefaults=function(t){var i=new e;return i.canvasOptions={antialias:!0,depth:!0,stencil:!t||t.isStencilEnable,alpha:!0,multiview:!1,framebufferScaleFactor:1},i.newCanvasCssStyle="position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",i},e}(),on=function(){function e(e,t){var i=this;if(void 0===t&&(t=rn.GetDefaults()),this._options=t,this._canvas=null,this.xrLayer=null,this.onXRLayerInitObservable=new o.c,this._engine=e.scene.getEngine(),t.canvasElement)this._setManagedOutputCanvas(t.canvasElement);else{var n=document.createElement("canvas");n.style.cssText=this._options.newCanvasCssStyle||"position:absolute; bottom:0px;right:0px;",this._setManagedOutputCanvas(n)}e.onXRSessionInit.add((function(){i._addCanvas()})),e.onXRSessionEnded.add((function(){i._removeCanvas()}))}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype.initializeXRLayerAsync=function(e){var t=this,i=function(){var i=new XRWebGLLayer(e,t.canvasContext,t._options.canvasOptions);return t.onXRLayerInitObservable.notifyObservers(i),i};return this.canvasContext.makeXRCompatible?this.canvasContext.makeXRCompatible().then((function(){return t.xrLayer=i(),t.xrLayer})):(this.xrLayer=i(),Promise.resolve(this.xrLayer))},e.prototype._addCanvas=function(){var e=this;this._canvas&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.appendChild(this._canvas),this.xrLayer?this._setCanvasSize(!0):this.onXRLayerInitObservable.addOnce((function(t){e._setCanvasSize(!0,t)}))},e.prototype._removeCanvas=function(){this._canvas&&document.body.contains(this._canvas)&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.removeChild(this._canvas),this._setCanvasSize(!1)},e.prototype._setCanvasSize=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=this.xrLayer),this._canvas&&(e?t&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=t.framebufferWidth+"px",this._canvas.style.height=t.framebufferHeight+"px"):this._engine.setSize(t.framebufferWidth,t.framebufferHeight)):this._originalCanvasSize&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=this._originalCanvasSize.width+"px",this._canvas.style.height=this._originalCanvasSize.height+"px"):this._engine.setSize(this._originalCanvasSize.width,this._originalCanvasSize.height)))},e.prototype._setManagedOutputCanvas=function(e){this._removeCanvas(),e?(this._originalCanvasSize={width:e.offsetWidth,height:e.offsetHeight},this._canvas=e,this.canvasContext=this._canvas.getContext("webgl2"),this.canvasContext||(this.canvasContext=this._canvas.getContext("webgl"))):(this._canvas=null,this.canvasContext=null)},e}(),an=function(){function e(e){this.scene=e,this._sessionEnded=!1,this.baseLayer=null,this.currentTimestamp=-1,this.defaultHeightCompensation=1.7,this.onXRFrameObservable=new o.c,this.onXRReferenceSpaceChanged=new o.c,this.onXRSessionEnded=new o.c,this.onXRSessionInit=new o.c}return Object.defineProperty(e.prototype,"referenceSpace",{get:function(){return this._referenceSpace},set:function(e){this._referenceSpace=e,this.onXRReferenceSpaceChanged.notifyObservers(this._referenceSpace)},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._sessionEnded||this.exitXRAsync(),this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear(),this.onXRReferenceSpaceChanged.clear(),this.onXRSessionInit.clear()},e.prototype.exitXRAsync=function(){return this.session&&!this._sessionEnded?(this._sessionEnded=!0,this.session.end().catch((function(e){m.a.Warn("Could not end XR session.")}))):Promise.resolve()},e.prototype.getRenderTargetTextureForEye=function(e){return this._rttProvider.getRenderTargetForEye(e)},e.prototype.getWebXRRenderTarget=function(e){var t=this.scene.getEngine();return this._xrNavigator.xr.native?this._xrNavigator.xr.getWebXRRenderTarget(t):((e=e||rn.GetDefaults(t)).canvasElement=t.getRenderingCanvas()||void 0,new on(this,e))},e.prototype.initializeAsync=function(){return this._xrNavigator=navigator,this._xrNavigator.xr?Promise.resolve():Promise.reject("WebXR not available")},e.prototype.initializeSessionAsync=function(e,t){var i=this;return void 0===e&&(e="immersive-vr"),void 0===t&&(t={}),this._xrNavigator.xr.requestSession(e,t).then((function(e){return i.session=e,i.onXRSessionInit.notifyObservers(e),i._sessionEnded=!1,i.session.addEventListener("end",(function(){var e=i.scene.getEngine();i._sessionEnded=!0,i._rttProvider=null,e.framebufferDimensionsObject=null,e.restoreDefaultFramebuffer(),e.customAnimationFrameRequester=null,i.onXRSessionEnded.notifyObservers(null),e._renderLoop()}),{once:!0}),i.session}))},e.prototype.isSessionSupportedAsync=function(t){return e.IsSessionSupportedAsync(t)},e.prototype.resetReferenceSpace=function(){this.referenceSpace=this.baseReferenceSpace},e.prototype.runXRRenderLoop=function(){var e=this,t=this.scene.getEngine();if(t.customAnimationFrameRequester={requestAnimationFrame:this.session.requestAnimationFrame.bind(this.session),renderFunction:function(i,n){e._sessionEnded||(e.currentFrame=n,e.currentTimestamp=i,n&&(t.framebufferDimensionsObject=e.baseLayer,e.onXRFrameObservable.notifyObservers(n),t._renderLoop(),t.framebufferDimensionsObject=null))}},this._xrNavigator.xr.native)this._rttProvider=this._xrNavigator.xr.getNativeRenderTargetProvider(this.session,this._createRenderTargetTexture.bind(this));else{var i=this._createRenderTargetTexture(this.baseLayer.framebufferWidth,this.baseLayer.framebufferHeight,this.baseLayer.framebuffer);this._rttProvider={getRenderTargetForEye:function(){return i}},t.framebufferDimensionsObject=this.baseLayer}"undefined"!=typeof window&&window.cancelAnimationFrame&&window.cancelAnimationFrame(t._frameHandler),t._renderLoop()},e.prototype.setReferenceSpaceTypeAsync=function(e){var t=this;return void 0===e&&(e="local-floor"),this.session.requestReferenceSpace(e).then((function(e){return e}),(function(e){return m.a.Error("XR.requestReferenceSpace failed for the following reason: "),m.a.Error(e),m.a.Log('Defaulting to universally-supported "viewer" reference space type.'),t.session.requestReferenceSpace("viewer").then((function(e){var i=new XRRigidTransform({x:0,y:-t.defaultHeightCompensation,z:0});return e.getOffsetReferenceSpace(i)}),(function(e){throw m.a.Error(e),'XR initialization failed: required "viewer" reference space type not supported.'}))})).then((function(e){return t.session.requestReferenceSpace("viewer").then((function(i){return t.viewerReferenceSpace=i,e}))})).then((function(e){return t.referenceSpace=t.baseReferenceSpace=e,t.referenceSpace}))},e.prototype.updateRenderStateAsync=function(e){return e.baseLayer&&(this.baseLayer=e.baseLayer),this.session.updateRenderState(e)},e.IsSessionSupportedAsync=function(e){if(!navigator.xr)return Promise.resolve(!1);var t=navigator.xr.isSessionSupported||navigator.xr.supportsSession;return t?t.call(navigator.xr,e).then((function(e){var t=void 0===e||e;return Promise.resolve(t)})).catch((function(e){return m.a.Warn(e),Promise.resolve(!1)})):Promise.resolve(!1)},e.prototype._createRenderTargetTexture=function(e,t,i){void 0===i&&(i=null);var n=new Qe.a(this.scene.getEngine(),Qe.b.Unknown,!0);n.width=e,n.height=t,n._framebuffer=i;var r=new Ni("XR renderTargetTexture",{width:e,height:t},this.scene,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0);return r._texture=n,r},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"}($i||($i={})),function(e){e[e.NOT_TRACKING=0]="NOT_TRACKING",e[e.TRACKING_LOST=1]="TRACKING_LOST",e[e.TRACKING=2]="TRACKING"}(en||(en={}));var sn,cn=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=be.a.CreateTorus("gazeTracker",.0035,.0025,20,t,!1),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var n=new Wi.a("targetMat",t);n.specularColor=s.a.Black(),n.emissiveColor=new s.a(.7,.7,.7),n.backFaceCulling=!1,this._gazeTracker.material=n}}return e.prototype._getForwardRay=function(e){return new Xt.a(a.e.Zero(),new a.e(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}(),ln=function(e){function t(t,i,n){var r=e.call(this,i,n)||this;r.webVRController=t,r._laserPointer=be.a.CreateCylinder("laserPointer",1,.004,2e-4,20,1,i,!1);var o=new Wi.a("laserPointerMat",i);if(o.emissiveColor=new s.a(.7,.7,.7),o.alpha=.6,r._laserPointer.material=o,r._laserPointer.rotation.x=Math.PI/2,r._laserPointer.position.z=-.5,r._laserPointer.isVisible=!1,r._laserPointer.isPickable=!1,!t.mesh){var a=new be.a("preloadControllerMesh",i),c=new be.a(qt.POINTING_POSE,i);c.rotation.x=-.7,a.addChild(c),t.attachToMesh(a)}return r._setLaserPointerParent(t.mesh),r._meshAttachedObserver=t._meshAttachedObservable.add((function(e){r._setLaserPointerParent(e)})),r}return Object(h.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._setLaserPointerLightingDisabled=function(e){this._laserPointer.material.disableLighting=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),n=e;this.webVRController._pointingPoseNode=null;for(var r=0;r<i.length;r++)if(i[r].name&&i[r].name.indexOf(qt.POINTING_POSE)>=0){n=i[r],this.webVRController._pointingPoseNode=n;break}this._laserPointer.parent=n},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}(cn),un=function(e){function t(t,i){var n=e.call(this,i)||this;return n.getCamera=t,n}return Object(h.d)(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new Xt.a(a.e.Zero(),a.e.Forward())},t}(cn),hn=function(){},dn=function(){function e(t,i){var n=this;if(void 0===i&&(i={}),this.webVROptions=i,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.enableGazeEvenWhenNoPointerLock=!1,this.exitVROnDoubleTap=!0,this.onEnteringVRObservable=new o.c,this.onAfterEnteringVRObservable=new o.c,this.onExitingVRObservable=new o.c,this.onControllerMeshLoadedObservable=new o.c,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._teleportationMode=e.TELEPORTATIONMODE_CONSTANTTIME,this._teleportationTime=122,this._teleportationSpeed=20,this._rotationAllowed=!0,this._teleportBackwardsVector=new a.e(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new a.e(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this._gazeColor=new s.a(.7,.7,.7),this._laserColor=new s.a(.7,.7,.7),this._pickedLaserColor=new s.a(.2,.2,1),this._pickedGazeColor=new s.a(0,0,1),this.onNewMeshSelected=new o.c,this.onMeshSelectedWithController=new o.c,this.onNewMeshPicked=new o.c,this.onBeforeCameraTeleport=new o.c,this.onAfterCameraTeleport=new o.c,this.onSelectedMeshUnselected=new o.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.updateControllerLaserColor=!0,this.requestPointerLockOnFullScreen=!0,this.xrTestDone=!1,this._onResize=function(){n.moveButtonToBottomRight(),n._fullscreenVRpresenting&&n._webVRready&&n.exitVR()},this._onFullscreenChange=function(){var e=document;void 0!==e.fullscreen?n._fullscreenVRpresenting=document.fullscreen:void 0!==e.mozFullScreen?n._fullscreenVRpresenting=e.mozFullScreen:void 0!==e.webkitIsFullScreen?n._fullscreenVRpresenting=e.webkitIsFullScreen:void 0!==e.msIsFullScreen?n._fullscreenVRpresenting=e.msIsFullScreen:void 0!==document.msFullscreenElement&&(n._fullscreenVRpresenting=document.msFullscreenElement),!n._fullscreenVRpresenting&&n._inputElement&&(n.exitVR(),!n._useCustomVRButton&&n._btnVR&&(n._btnVR.style.top=n._inputElement.offsetTop+n._inputElement.offsetHeight-70+"px",n._btnVR.style.left=n._inputElement.offsetLeft+n._inputElement.offsetWidth-100+"px",n.updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){n._leftController&&n._leftController._activePointer&&n._castRayAndSelectObject(n._leftController),n._rightController&&n._rightController._activePointer&&n._castRayAndSelectObject(n._rightController),n._noControllerIsActive&&(n._scene.getEngine().isPointerLock||n.enableGazeEvenWhenNoPointerLock)?n._castRayAndSelectObject(n._cameraGazer):n._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==ot.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){n._teleportationInitialized&&n.teleportationEnabled&&(!n._leftController&&!n._rightController||n._leftController&&!n._leftController._activePointer&&n._rightController&&!n._rightController._activePointer)&&(n._checkTeleportWithRay(e,n._cameraGazer),n._checkTeleportBackwards(e,n._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){n._teleportationInitialized&&n._checkRotate(e,n._cameraGazer)})),e.type===ot.XBOX&&(e.onbuttondown((function(e){n._interactionsEnabled&&e===Yt.A&&n._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){n._interactionsEnabled&&e===Yt.A&&n._cameraGazer._selectionPointerUp()})));else{var t=e,i=new ln(t,n._scene,n._cameraGazer._gazeTracker);"right"===t.hand||n._leftController&&n._leftController.webVRController!=t?n._rightController=i:n._leftController=i,n._tryEnableInteractionOnController(i)}},this._tryEnableInteractionOnController=function(e){n._interactionsRequested&&!e._interactionsEnabled&&n._enableInteractionOnController(e),n._teleportationRequested&&!e._teleportationEnabled&&n._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof Gi&&("left"===e.hand&&null!=n._leftController&&(n._leftController.dispose(),n._leftController=null),"right"===e.hand&&null!=n._rightController&&(n._rightController.dispose(),n._rightController=null))},this._workingVector=a.e.Zero(),this._workingQuaternion=a.b.Identity(),this._workingMatrix=a.a.Identity(),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||(i.useXR=!0),void 0===i.createFallbackVRDeviceOrientationFreeCamera&&(i.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===i.createDeviceOrientationCamera&&(i.createDeviceOrientationCamera=!0),void 0===i.laserToggle&&(i.laserToggle=!0),void 0===i.defaultHeight&&(i.defaultHeight=1.7),i.useCustomVRButton&&(this._useCustomVRButton=!0,i.customVRButton&&(this._btnVR=i.customVRButton)),i.rayLength&&(this._rayLength=i.rayLength),this._defaultHeight=i.defaultHeight,i.positionScale&&(this._rayLength*=i.positionScale,this._defaultHeight*=i.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new a.e(0,this._defaultHeight,0),i.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new Ut("deviceOrientationVRHelper",this._position.clone(),t),this._scene.activeCamera&&(this._deviceOrientationCamera.minZ=this._scene.activeCamera.minZ,this._deviceOrientationCamera.maxZ=this._scene.activeCamera.maxZ,this._scene.activeCamera instanceof Lt&&this._scene.activeCamera.rotation)){var r=this._scene.activeCamera;r.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(r.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(a.b.RotationYawPitchRoll(r.rotation.y,r.rotation.x,r.rotation.z)),this._deviceOrientationCamera.rotation=r.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._inputElement&&this._scene.activeCamera.attachControl()}else this._existingCamera=this._scene.activeCamera;this.webVROptions.useXR&&navigator.xr?an.IsSessionSupportedAsync("immersive-vr").then((function(e){e?(m.a.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),t.createDefaultXRExperienceAsync({floorMeshes:i.floorMeshes||[]}).then((function(e){n.xr=e,n.xrTestDone=!0,n._cameraGazer=new un((function(){return n.xr.baseExperience.camera}),t),n.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case $i.ENTERING_XR:n.onEnteringVRObservable.notifyObservers(n),n._interactionsEnabled||n.xr.pointerSelection.detach(),n.xr.pointerSelection.displayLaserPointer=n._displayLaserPointer;break;case $i.EXITING_XR:n.onExitingVRObservable.notifyObservers(n),n._scene.getEngine().resize();break;case $i.IN_XR:n._hasEnteredVR=!0;break;case $i.NOT_IN_XR:n._hasEnteredVR=!1}}))}))):n.completeVRInit(t,i)})):this.completeVRInit(t,i)}return Object.defineProperty(e.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentVRCamera",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"webVRCamera",{get:function(){return this._webVRCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"vrButton",{get:function(){return this._btnVR},enumerable:!1,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:!1,configurable:!0}),e.prototype.completeVRInit=function(e,t){var i=this;if(this.xrTestDone=!0,t.createFallbackVRDeviceOrientationFreeCamera&&(t.useMultiview&&(t.vrDeviceOrientationCameraMetrics||(t.vrDeviceOrientationCameraMetrics=Ci.GetDefault()),t.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new Ui("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new zi("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new un((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";var n=".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url("+(window.SVGSVGElement?"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":"https://cdn.babylonjs.com/Assets/vrButton.png")+"); 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) }";n+=".babylonVRicon.vrdisplaypresenting { display: none; }";var r=document.createElement("style");r.appendChild(document.createTextNode(n)),document.getElementsByTagName("head")[0].appendChild(r),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){i.isInVRMode?i._scene.getEngine().disableVR():i.enterVR()}));var o=this._scene.getEngine().getHostWindow();o&&(o.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._hasEnteredVR&&i.exitVROnDoubleTap&&(i.exitVR(),i._fullscreenVRpresenting&&i._scene.getEngine().exitFullscreen())}),Ne.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),o.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 ae,this._circleEase.setEasingMode(oe.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){i._interactionsEnabled&&e.activeCamera===i.vrDeviceOrientationCamera&&"mouse"===t.event.pointerType&&(t.type===Ne.a.POINTERDOWN?i._cameraGazer._selectionPointerDown():t.type===Ne.a.POINTERUP&&i._cameraGazer._selectionPointerUp())})),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes}))},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){m.a.Warn("Error in your custom logic onControllerMeshLoaded: "+e)}},Object.defineProperty(e.prototype,"isInVRMode",{get:function(){return this.xr&&this.webVROptions.useXR&&this.xr.baseExperience.state===$i.IN_XR||this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!1,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 m.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(){if(this._inputElement&&!this._useCustomVRButton&&this._btnVR){var e=this._inputElement.getBoundingClientRect();this._btnVR.style.top=e.top+e.height-70+"px",this._btnVR.style.left=e.left+e.width-100+"px"}},e.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||!this._btnVR||(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(){var e=this;if(this.xr)this.xr.baseExperience.enterXRAsync("immersive-vr","local-floor",this.xr.renderTarget);else{if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(e){m.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=a.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var t=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,i=a.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-t,n=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=a.b.FromEulerAngles(0,n+i,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._scene.getEngine().onVRRequestPresentComplete.addOnce((function(t){e.onAfterEnteringVRObservable.notifyObservers({success:t})})),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().enterFullscreen(this.requestPointerLockOnFullScreen),this.updateButtonVisibility(),this._vrDeviceOrientationCamera.onViewMatrixChangedObservable.addOnce((function(){e.onAfterEnteringVRObservable.notifyObservers({success:!0})}))),this._scene.activeCamera&&this._inputElement&&this._scene.activeCamera.attachControl(),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.xr)this.xr.baseExperience.exitXRAsync();else if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){m.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._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._inputElement&&this._scene.activeCamera.attachControl(),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;var e=this._scene.getEngine();e._onVrDisplayPresentChange&&e._onVrDisplayPresentChange()}},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:!1,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;if(!this._interactionsEnabled){if(this._interactionsRequested=!0,this.xr)return void(this.xr.baseExperience.state===$i.IN_XR&&this.xr.pointerSelection.attach());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:!1,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){var t=this;if(void 0===e&&(e={}),!this._teleportationInitialized){if(this._teleportationRequested=!0,this.enableInteractions(),this.webVROptions.useXR&&(e.floorMeshes||e.floorMeshName)){var i=e.floorMeshes||[];if(!i.length){var n=this._scene.getMeshByName(e.floorMeshName);n&&i.push(n)}if(this.xr)return i.forEach((function(e){t.xr.teleportation.addFloorMesh(e)})),void(this.xr.teleportation.attached||this.xr.teleportation.attach());if(!this.xrTestDone){var r=function(){t.xrTestDone&&(t._scene.unregisterBeforeRender(r),t.xr?t.xr.teleportation.attached||t.xr.teleportation.attach():t.enableTeleportation(e))};return void this._scene.registerBeforeRender(r)}}e.floorMeshName&&(this._floorMeshName=e.floorMeshName),e.floorMeshes&&(this._floorMeshesCollection=e.floorMeshes),e.teleportationMode&&(this._teleportationMode=e.teleportationMode),e.teleportationTime&&e.teleportationTime>0&&(this._teleportationTime=e.teleportationTime),e.teleportationSpeed&&e.teleportationSpeed>0&&(this._teleportationSpeed=e.teleportationSpeed),void 0!==e.easingFunction&&(this._teleportationEasing=e.easingFunction),null!=this._leftController&&this._enableTeleportationOnController(this._leftController),null!=this._rightController&&this._enableTeleportationOnController(this._rightController);var o=new ji.a;o.vignetteColor=new s.b(0,0,0,0),o.vignetteEnabled=!0,this._postProcessMove=new Yi("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,o),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 n=e;t._noControllerIsActive&&(n=t._cameraGazer),n._pointerDownOnMeshAsked?i.value<t._padSensibilityDown&&n._selectionPointerUp():i.value>t._padSensibilityUp&&n._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=a.b.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),n=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(i=this.currentVRCamera.deviceRotationQuaternion,n=this.currentVRCamera.devicePosition),i.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,a.b.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),a.e.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var r=new Xt.a(n,this._workingVector),o=this._scene.pickWithRay(r,this._raySelectionPredicate);o&&o.pickedPoint&&o.pickedMesh&&this._isTeleportationFloor(o.pickedMesh)&&o.distance<5&&this.teleportCamera(o.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===Gt.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=be.a.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new Hi.a("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 Wi.a("TextPlaneMaterial",this._scene);i.diffuseTexture=e,this._teleportationTarget.material=i;var n=be.a.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);n.isPickable=!1,n.parent=this._teleportationTarget;var r=new z("animationInnerCircle","position.y",30,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),r.setKeys(o);var a=new me;a.setEasingMode(oe.EASINGMODE_EASEINOUT),r.setEasingFunction(a),n.animations=[],n.animations.push(r),this._scene.beginAnimation(n,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 wt){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var i=a.b.FromRotationMatrix(a.a.RotationY(Math.PI/4*this._rotationAngle)),n=new z("animationRotation","rotationQuaternion",90,z.ANIMATIONTYPE_QUATERNION,z.ANIMATIONLOOPMODE_CONSTANT),r=[];r.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),r.push({frame:6,value:i}),n.setKeys(r),n.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(n),this._postProcessMove.animations=[];var o=new z("animationPP","vignetteWeight",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:3,value:4}),s.push({frame:6,value:0}),o.setKeys(s),o.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(o);var c=new z("animationPP2","vignetteStretch",90,z.ANIMATIONTYPE_FLOAT,z.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 n=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),i);if(n){var r=a.e.Cross(J.a.Y,n),o=a.e.Cross(n,r);a.e.RotationFromAxisToRef(o,n,r,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(t){var i=this;if(this.currentVRCamera instanceof wt){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),t.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(t),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector);var n,r;if(this._teleportationMode==e.TELEPORTATIONMODE_CONSTANTSPEED){r=90;var o=a.e.Distance(this.currentVRCamera.position,this._workingVector);n=this._teleportationSpeed/o}else r=Math.round(90*this._teleportationTime/1e3),n=1;this.currentVRCamera.animations=[];var s=new z("animationCameraTeleportation","position",90,z.ANIMATIONTYPE_VECTOR3,z.ANIMATIONLOOPMODE_CONSTANT),c=[{frame:0,value:this.currentVRCamera.position},{frame:r,value:this._workingVector}];s.setKeys(c),s.setEasingFunction(this._teleportationEasing),this.currentVRCamera.animations.push(s),this._postProcessMove.animations=[];var l=Math.round(r/2),u=new z("animationPP","vignetteWeight",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),h=[];h.push({frame:0,value:0}),h.push({frame:l,value:8}),h.push({frame:r,value:0}),u.setKeys(h),this._postProcessMove.animations.push(u);var d=new z("animationPP2","vignetteStretch",90,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CONSTANT),f=[];f.push({frame:0,value:0}),f.push({frame:l,value:10}),f.push({frame:r,value:0}),d.setKeys(f),this._postProcessMove.animations.push(d),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,r,!1,n,(function(){i._webVRCamera.detachPostProcess(i._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,r,!1,n,(function(){i.onAfterCameraTeleport.notifyObservers(i._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))<Math.PI/2&&e.scaleInPlace(-1));return e},e.prototype._castRayAndSelectObject=function(e){if(this.currentVRCamera instanceof wt){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 n=1;e._gazeTracker.isVisible=!0,e._isActionableMesh&&(n=3),this.updateGazeTrackerScale&&(e._gazeTracker.scaling.x=i.distance*n,e._gazeTracker.scaling.y=i.distance*n,e._gazeTracker.scaling.z=i.distance*n);var r=this._convertNormalToDirectionOfRay(i.getNormal(),t);if(r){var o=a.e.Cross(J.a.Y,r),s=a.e.Cross(r,o);a.e.RotationFromAxisToRef(s,r,o,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(this._pickedGazeColor),this.changeLaserColor(this._pickedLaserColor),e._isActionableMesh=!0):(this.changeGazeColor(this._gazeColor),this.changeLaserColor(this._laserColor),e._isActionableMesh=!1);try{this.onNewMeshSelected.notifyObservers(i.pickedMesh);var c=e;c.webVRController&&this.onMeshSelectedWithController.notifyObservers({mesh:i.pickedMesh,controller:c.webVRController})}catch(e){m.a.Warn("Error while raising onNewMeshSelected or onMeshSelectedWithController: "+e)}}else this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,this.changeGazeColor(this._gazeColor),this.changeLaserColor(this._laserColor)}else this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,this.changeGazeColor(this._gazeColor),this.changeLaserColor(this._laserColor)}},e.prototype._notifySelectedMeshUnselected=function(e){e&&this.onSelectedMeshUnselected.notifyObservers(e)},e.prototype.setLaserColor=function(e,t){void 0===t&&(t=this._pickedLaserColor),this._laserColor=e,this._pickedLaserColor=t},e.prototype.setLaserLightingState=function(e){void 0===e&&(e=!0),this._leftController&&this._leftController._setLaserPointerLightingDisabled(!e),this._rightController&&this._rightController._setLaserPointerLightingDisabled(!e)},e.prototype.setGazeColor=function(e,t){void 0===t&&(t=this._pickedGazeColor),this._gazeColor=e,this._pickedGazeColor=t},e.prototype.changeLaserColor=function(e){this.updateControllerLaserColor&&(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&&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.xr&&this.xr.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.TELEPORTATIONMODE_CONSTANTTIME=0,e.TELEPORTATIONMODE_CONSTANTSPEED=1,e}(),fn=i(64),pn=(sn={root:0,found:!1},function(e,t,i,n){sn.root=0,sn.found=!1;var r=t*t-4*e*i;if(r<0)return sn;var o=Math.sqrt(r),a=(-t-o)/(2*e),s=(-t+o)/(2*e);if(a>s){var c=s;s=a,a=c}return a>0&&a<n?(sn.root=a,sn.found=!0,sn):s>0&&s<n?(sn.root=s,sn.found=!0,sn):sn}),_n=function(){function e(){this._collisionPoint=a.e.Zero(),this._planeIntersectionPoint=a.e.Zero(),this._tempVector=a.e.Zero(),this._tempVector2=a.e.Zero(),this._tempVector3=a.e.Zero(),this._tempVector4=a.e.Zero(),this._edge=a.e.Zero(),this._baseToVertex=a.e.Zero(),this._destinationPoint=a.e.Zero(),this._slidePlaneNormal=a.e.Zero(),this._displacementVector=a.e.Zero(),this._radius=a.e.One(),this._retry=0,this._basePointWorld=a.e.Zero(),this._velocityWorld=a.e.Zero(),this._normalizedVelocity=a.e.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!1,configurable:!0}),e.prototype._initialize=function(e,t,i){this._velocity=t,a.e.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,n,r){t.subtractToRef(e,this._tempVector),i.subtractToRef(e,this._tempVector2),a.e.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var o=a.e.Dot(this._tempVector4,r);return!(o<0)&&(n.subtractToRef(e,this._tempVector3),a.e.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((o=a.e.Dot(this._tempVector4,r))<0)&&(a.e.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),(o=a.e.Dot(this._tempVector4,r))>=0))},e.prototype._canDoCollision=function(e,t,i,n){var r=a.e.Distance(this._basePointWorld,e),o=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(r>this._velocityWorldLength+o+t)&&!!function(e,t,i,n){return!(e.x>i.x+n)&&(!(i.x-n>t.x)&&(!(e.y>i.y+n)&&(!(i.y-n>t.y)&&(!(e.z>i.z+n)&&!(i.z-n>t.z)))))}(i,n,this._basePointWorld,this._velocityWorldLength+o)},e.prototype._testTriangle=function(e,t,i,n,r,o,s){var c,l=!1;t||(t=[]),t[e]||(t[e]=new fn.a(0,0,0,0),t[e].copyFromPoints(i,n,r));var u=t[e];if(o||u.isFrontFacingTo(this._normalizedVelocity,0)){var h=u.signedDistanceTo(this._basePoint),d=a.e.Dot(u.normal,this._velocity);if(0==d){if(Math.abs(h)>=1)return;l=!0,c=0}else{var f=(1-h)/d;if((c=(-1-h)/d)>f){var p=f;f=c,c=p}if(c>1||f<0)return;c<0&&(c=0),c>1&&(c=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(l||(this._basePoint.subtractToRef(u.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(c,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,i,n,r,u.normal)&&(_=!0,m=c,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this._velocity.lengthSquared(),v=g;this._basePoint.subtractToRef(i,this._tempVector);var b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,T=pn(v,b,y,m);T.found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(n,this._tempVector),b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(T=pn(v,b,y,m)).found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(r,this._tempVector),b=2*a.e.Dot(this._velocity,this._tempVector),y=this._tempVector.lengthSquared()-1,(T=pn(v,b,y,m)).found&&(m=T.root,_=!0,this._collisionPoint.copyFrom(r)),n.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex);var E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex);if(v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found){var P=(S*T.root-A)/E;P>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),i.addToRef(this._edge,this._collisionPoint))}r.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex),v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found&&(P=(S*T.root-A)/E)>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),n.addToRef(this._edge,this._collisionPoint)),i.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),E=this._edge.lengthSquared(),S=a.e.Dot(this._edge,this._velocity),A=a.e.Dot(this._edge,this._baseToVertex),v=E*-g+S*S,b=E*(2*a.e.Dot(this._velocity,this._baseToVertex))-2*S*A,y=E*(1-this._baseToVertex.lengthSquared())+A*A,(T=pn(v,b,y,m)).found&&(P=(S*T.root-A)/E)>=0&&P<=1&&(m=T.root,_=!0,this._edge.scaleInPlace(P),r.addToRef(this._edge,this._collisionPoint))}if(_){var C=m*this._velocity.length();(!this.collisionFound||C<this._nearestDistance)&&(s.collisionResponse&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this._nearestDistance=C,this.collisionFound=!0),this.collidedMesh=s)}}},e.prototype._collide=function(e,t,i,n,r,o,a,s){if(i&&0!==i.length)for(c=n;c<r;c+=3){l=t[i[c]-o],u=t[i[c+1]-o],h=t[i[c+2]-o];this._testTriangle(c,e,h,u,l,a,s)}else for(var c=0;c<t.length;c+=3){var l=t[c],u=t[c+1],h=t[c+2];this._testTriangle(c,e,h,u,l,a,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(fn.a.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,t)},e}(),mn=function(){function e(){this._scaledPosition=a.e.Zero(),this._scaledVelocity=a.e.Zero(),this._finalPosition=a.e.Zero()}return e.prototype.getNewPosition=function(e,t,i,n,r,o,a){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,n,this._finalPosition,r),this._finalPosition.multiplyInPlace(i._radius),o(a,this._finalPosition,i.collidedMesh)},e.prototype.createCollider=function(){return new _n},e.prototype.init=function(e){this._scene=e},e.prototype._collideWithWorld=function(e,t,i,n,r,o){void 0===o&&(o=null);var a=10*Se.a.CollisionsEpsilon;if(i._retry>=n)r.copyFrom(e);else{var s=o?o.collisionMask:i.collisionMask;i._initialize(e,t,a);for(var c=o&&o.surroundingMeshes||this._scene.meshes,l=0;l<c.length;l++){var u=c[l];u.isEnabled()&&u.checkCollisions&&u.subMeshes&&u!==o&&0!=(s&u.collisionGroup)&&u._checkCollision(i)}i.collisionFound?(0===t.x&&0===t.y&&0===t.z||i._getResponse(e,t),t.length()<=a?r.copyFrom(e):(i._retry++,this._collideWithWorld(e,t,i,n,r,o))):e.addToRef(t,r)}},e}();Q.a.CollisionCoordinatorFactory=function(){return new mn};var gn=i(54),vn=i(114),bn=i(147),yn=i(103),Tn=i(43),En=i(113),Sn=function(){function e(e,t,i,n,r,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=n,this._maxDepth=r,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!1,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(yn.a.IsInFrustum(this._boundingVectors,e)){if(this.blocks){for(var n=0;n<this.blocks.length;n++){this.blocks[n].select(e,t,i)}return}i?t.concat(this.entries):t.concatWithNoDuplicate(this.entries)}},e.prototype.intersects=function(e,t,i,n){if(yn.a.IntersectsSphere(this._minPoint,this._maxPoint,e,t)){if(this.blocks){for(var r=0;r<this.blocks.length;r++){this.blocks[r].intersects(e,t,i,n)}return}n?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,n,r,o,s,c,l){c.blocks=new Array;for(var u=new a.e((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)),r,o+1,s,l);p.addEntries(n),c.blocks.push(p)}},e}(),An=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 oi.b(1024),this._creationFunc=e}return e.prototype.update=function(e,t,i){Sn._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 n=0;n<this.blocks.length;n++){this.blocks[n].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}();Q.a.prototype.createOrUpdateSelectionOctree=function(e,t){void 0===e&&(e=64),void 0===t&&(t=2);var i=this._getComponent(Me.a.NAME_OCTREE);i||(i=new Mn(this),this._addComponent(i)),this._selectionOctree||(this._selectionOctree=new An(An.CreationFuncForMeshes,e,t));var n=this.getWorldExtends();return this._selectionOctree.update(n.min,n.max,this.meshes),this._selectionOctree},Object.defineProperty(Q.a.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Ge.a.prototype.createOrUpdateSubmeshesOctree=function(e,t){void 0===e&&(e=64),void 0===t&&(t=2);var i=this.getScene(),n=i._getComponent(Me.a.NAME_OCTREE);n||(n=new Mn(i),i._addComponent(n)),this._submeshesOctree||(this._submeshesOctree=new An(An.CreationFuncForSubMeshes,e,t)),this.computeWorldMatrix(!0);var r=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(r.minimumWorld,r.maximumWorld,this.subMeshes),this._submeshesOctree};var Pn,Cn,Rn,xn,On,Mn=function(){function e(e){this.name=Me.a.NAME_OCTREE,this.checksIsEnabled=!0,this._tempRay=new Xt.a(a.e.Zero(),new a.e(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 n=i.dynamicContent.indexOf(t);-1!==n&&i.dynamicContent.splice(n,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?(Xt.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}(),In=i(99);!function(e){e[e.Generic=0]="Generic",e[e.Keyboard=1]="Keyboard",e[e.Mouse=2]="Mouse",e[e.Touch=3]="Touch",e[e.DualShock=4]="DualShock",e[e.Xbox=5]="Xbox",e[e.Switch=6]="Switch"}(Pn||(Pn={})),function(e){e[e.Horizontal=0]="Horizontal",e[e.Vertical=1]="Vertical",e[e.LeftClick=2]="LeftClick",e[e.MiddleClick=3]="MiddleClick",e[e.RightClick=4]="RightClick",e[e.BrowserBack=5]="BrowserBack",e[e.BrowserForward=6]="BrowserForward"}(Cn||(Cn={})),function(e){e[e.Cross=0]="Cross",e[e.Circle=1]="Circle",e[e.Square=2]="Square",e[e.Triangle=3]="Triangle",e[e.L1=4]="L1",e[e.R1=5]="R1",e[e.L2=6]="L2",e[e.R2=7]="R2",e[e.Share=8]="Share",e[e.Options=9]="Options",e[e.L3=10]="L3",e[e.R3=11]="R3",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.TouchPad=17]="TouchPad",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(Rn||(Rn={})),function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.LB=4]="LB",e[e.RB=5]="RB",e[e.LT=6]="LT",e[e.RT=7]="RT",e[e.Back=8]="Back",e[e.Start=9]="Start",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.LStickXAxis=17]="LStickXAxis",e[e.LStickYAxis=18]="LStickYAxis",e[e.RStickXAxis=19]="RStickXAxis",e[e.RStickYAxis=20]="RStickYAxis"}(xn||(xn={})),function(e){e[e.B=0]="B",e[e.A=1]="A",e[e.Y=2]="Y",e[e.X=3]="X",e[e.L=4]="L",e[e.R=5]="R",e[e.ZL=6]="ZL",e[e.ZR=7]="ZR",e[e.Minus=8]="Minus",e[e.Plus=9]="Plus",e[e.LS=10]="LS",e[e.RS=11]="RS",e[e.DPadUp=12]="DPadUp",e[e.DPadDown=13]="DPadDown",e[e.DPadLeft=14]="DPadLeft",e[e.DPadRight=15]="DPadRight",e[e.Home=16]="Home",e[e.Capture=17]="Capture",e[e.LStickXAxis=18]="LStickXAxis",e[e.LStickYAxis=19]="LStickYAxis",e[e.RStickXAxis=20]="RStickXAxis",e[e.RStickYAxis=21]="RStickYAxis"}(On||(On={}));var Dn=function(){function e(e){this.onDeviceDisconnected=function(){},this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._keyboardDownEvent=function(e){},this._keyboardUpEvent=function(e){},this._pointerMoveEvent=function(e){},this._pointerDownEvent=function(e){},this._pointerUpEvent=function(e){},this._gamepadConnectedEvent=function(e){},this._gamepadDisconnectedEvent=function(e){},this._onDeviceConnected=function(){};var t=e.getInputElement();t&&(this._elementToAttachTo=t,this._handleKeyActions(),this._handlePointerActions(),this._handleGamepadActions(),this._checkForConnectedDevices())}return Object.defineProperty(e.prototype,"onDeviceConnected",{get:function(){return this._onDeviceConnected},set:function(e){this._onDeviceConnected=e;for(var t=0;t<this._inputs.length;t++)if(this._inputs[t])for(var i=0;i<this._inputs[t].length;i++)this._inputs[t][i]&&this._onDeviceConnected(t,i)},enumerable:!1,configurable:!0}),e.Create=function(t){return"undefined"!=typeof _native&&_native.DeviceInputSystem?new _native.DeviceInputSystem(t):new e(t)},e.prototype.pollInput=function(e,t,i){var n=this._inputs[e][t];if(!n)throw"Unable to find device "+Pn[e];if(this._updateDevice(e,t,i),void 0===n[i])throw"Unable to find input "+i+" for device "+Pn[e]+" in slot "+t;return n[i]},e.prototype.dispose=function(){this._keyboardActive&&(window.removeEventListener("keydown",this._keyboardDownEvent),window.removeEventListener("keyup",this._keyboardUpEvent)),this._pointerActive&&(this._elementToAttachTo.removeEventListener("pointermove",this._pointerMoveEvent),this._elementToAttachTo.removeEventListener("pointerdown",this._pointerDownEvent),this._elementToAttachTo.removeEventListener("pointerup",this._pointerUpEvent)),window.removeEventListener("gamepadconnected",this._gamepadConnectedEvent),window.removeEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)},e.prototype._checkForConnectedDevices=function(){for(var e=0,t=navigator.getGamepads();e<t.length;e++){var i=t[e];i&&this._addGamePad(i)}matchMedia("(pointer:fine)").matches&&this._addPointerDevice(Pn.Mouse,0,0,0)},e.prototype._addGamePad=function(e){var t=this._getGamepadDeviceType(e.id),i=e.index;this._registerDevice(t,i,e.buttons.length+e.axes.length),this._gamepads=this._gamepads||new Array(e.index+1),this._gamepads[i]=t},e.prototype._addPointerDevice=function(t,i,n,r){this._pointerActive=!0,this._registerDevice(t,i,e._MAX_POINTER_INPUTS);var o=this._inputs[t][i];o[0]=n,o[1]=r},e.prototype._registerDevice=function(e,t,i){if(this._inputs[e]||(this._inputs[e]=[]),!this._inputs[e][t]){for(var n=new Array(i),r=0;r<i;r++)n[r]=0;this._inputs[e][t]=n,this.onDeviceConnected(e,t)}},e.prototype._unregisterDevice=function(e,t){this._inputs[e][t]&&(delete this._inputs[e][t],this.onDeviceDisconnected(e,t))},e.prototype._handleKeyActions=function(){var t=this;this._keyboardDownEvent=function(i){t._keyboardActive||(t._keyboardActive=!0,t._registerDevice(Pn.Keyboard,0,e._MAX_KEYCODES));var n=t._inputs[Pn.Keyboard][0];n&&(t.onInputChanged&&t.onInputChanged(Pn.Keyboard,0,i.keyCode,n[i.keyCode],1),n[i.keyCode]=1)},this._keyboardUpEvent=function(e){var i=t._inputs[Pn.Keyboard][0];i&&(t.onInputChanged&&t.onInputChanged(Pn.Keyboard,0,e.keyCode,i[e.keyCode],0),i[e.keyCode]=0)},window.addEventListener("keydown",this._keyboardDownEvent),window.addEventListener("keyup",this._keyboardUpEvent)},e.prototype._handlePointerActions=function(){var e=this;this._pointerMoveEvent=function(t){var i="mouse"==t.pointerType?Pn.Mouse:Pn.Touch,n="mouse"==t.pointerType?0:t.pointerId;e._inputs[i]||(e._inputs[i]=[]),e._inputs[i][n]||e._addPointerDevice(i,n,t.clientX,t.clientY);var r=e._inputs[i][n];r&&(e.onInputChanged&&(e.onInputChanged(i,n,0,r[0],t.clientX),e.onInputChanged(i,n,1,r[1],t.clientY)),r[0]=t.clientX,r[1]=t.clientY)},this._pointerDownEvent=function(t){var i="mouse"==t.pointerType?Pn.Mouse:Pn.Touch,n="mouse"==t.pointerType?0:t.pointerId;e._inputs[i]||(e._inputs[i]=[]),e._inputs[i][n]||e._addPointerDevice(i,n,t.clientX,t.clientY);var r=e._inputs[i][n];r&&(e.onInputChanged&&(e.onInputChanged(i,n,0,r[0],t.clientX),e.onInputChanged(i,n,1,r[1],t.clientY),e.onInputChanged(i,n,t.button+2,r[t.button+2],1)),r[0]=t.clientX,r[1]=t.clientY,r[t.button+2]=1)},this._pointerUpEvent=function(t){var i="mouse"==t.pointerType?Pn.Mouse:Pn.Touch,n="mouse"==t.pointerType?0:t.pointerId,r=e._inputs[i][n];r&&(e.onInputChanged&&e.onInputChanged(i,n,t.button+2,r[t.button+2],0),r[0]=t.clientX,r[1]=t.clientY,r[t.button+2]=0),"mouse"!=t.pointerType&&e._unregisterDevice(i,n)},this._elementToAttachTo.addEventListener("pointermove",this._pointerMoveEvent),this._elementToAttachTo.addEventListener("pointerdown",this._pointerDownEvent),this._elementToAttachTo.addEventListener("pointerup",this._pointerUpEvent)},e.prototype._handleGamepadActions=function(){var e=this;this._gamepadConnectedEvent=function(t){e._addGamePad(t.gamepad)},this._gamepadDisconnectedEvent=function(t){if(e._gamepads){var i=e._getGamepadDeviceType(t.gamepad.id),n=t.gamepad.index;e._unregisterDevice(i,n),delete e._gamepads[n]}},window.addEventListener("gamepadconnected",this._gamepadConnectedEvent),window.addEventListener("gamepaddisconnected",this._gamepadDisconnectedEvent)},e.prototype._updateDevice=function(e,t,i){var n=navigator.getGamepads()[t];if(n&&e==this._gamepads[t]){var r=this._inputs[e][t];i>=n.buttons.length?r[i]=n.axes[i-n.buttons.length].valueOf():r[i]=n.buttons[i].value}},e.prototype._getGamepadDeviceType=function(e){return-1!==e.indexOf("054c")?Pn.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?Pn.Xbox:-1!==e.indexOf("057e")?Pn.Switch:Pn.Generic},e._MAX_KEYCODES=255,e._MAX_POINTER_INPUTS=7,e}(),Nn=function(){function e(e,t,i){void 0===i&&(i=0),this.deviceType=t,this.deviceSlot=i,this.onInputChangedObservable=new o.c,this._deviceInputSystem=e}return e.prototype.getInput=function(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)},e}(),Ln=function(){function e(e){var t=this;this.onDeviceConnectedObservable=new o.c((function(e){t.getDevices().forEach((function(i){t.onDeviceConnectedObservable.notifyObserver(e,i)}))})),this.onDeviceDisconnectedObservable=new o.c;var i=Object.keys(Pn).length/2;this._devices=new Array(i),this._firstDevice=new Array(i),this._deviceInputSystem=Dn.Create(e),this._deviceInputSystem.onDeviceConnected=function(e,i){t._addDevice(e,i),t.onDeviceConnectedObservable.notifyObservers(t.getDeviceSource(e,i))},this._deviceInputSystem.onDeviceDisconnected=function(e,i){var n=t.getDeviceSource(e,i);t._removeDevice(e,i),t.onDeviceDisconnectedObservable.notifyObservers(n)},this._deviceInputSystem.onInputChanged||(this._deviceInputSystem.onInputChanged=function(e,i,n,r,o){var a;null===(a=t.getDeviceSource(e,i))||void 0===a||a.onInputChangedObservable.notifyObservers({inputIndex:n,previousState:r,currentState:o})})}return e.prototype.getDeviceSource=function(e,t){if(void 0===t){if(void 0===this._firstDevice[e])return null;t=this._firstDevice[e]}return this._devices[e]&&void 0!==this._devices[e][t]?this._devices[e][t]:null},e.prototype.getDeviceSources=function(e){return this._devices[e].filter((function(e){return!!e}))},e.prototype.getDevices=function(){var e=new Array;return this._devices.forEach((function(t){e.push.apply(e,t)})),e},e.prototype.dispose=function(){this.onDeviceConnectedObservable.clear(),this.onDeviceDisconnectedObservable.clear(),this._deviceInputSystem.dispose()},e.prototype._addDevice=function(e,t){this._devices[e]||(this._devices[e]=new Array),this._devices[e][t]||(this._devices[e][t]=new Nn(this._deviceInputSystem,e,t),this._updateFirstDevices(e))},e.prototype._removeDevice=function(e,t){delete this._devices[e][t],this._updateFirstDevices(e)},e.prototype._updateFirstDevices=function(e){switch(e){case Pn.Keyboard:case Pn.Mouse:this._firstDevice[e]=0;break;case Pn.Touch:case Pn.DualShock:case Pn.Xbox:case Pn.Switch:case Pn.Generic:var t=this._devices[e];delete this._firstDevice[e];for(var i=0;i<t.length;i++)if(t[i]){this._firstDevice[e]=i;break}}},e}(),wn=i(168),Fn=(i(123),function(){this._timeElapsedQueryEnded=!1}),Bn=function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=Ge.a.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=Ge.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE};Se.a.prototype.createQuery=function(){return this._gl.createQuery()},Se.a.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},Se.a.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},Se.a.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},Se.a.prototype.beginOcclusionQuery=function(e,t){var i=this._getGlAlgorithmType(e);return this._gl.beginQuery(i,t),this},Se.a.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},Se.a.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},Se.a.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},Se.a.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},Se.a.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},Se.a.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var i=new Fn;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},Se.a.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 n=this._gl.getParameter(i.GPU_DISJOINT_EXT),r=!1;if(e._endTimeQuery?r=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(r=this._getTimeQueryAvailability(e._timeElapsedQuery)),r&&!n){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var a=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-a,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},Se.a.prototype._getGlAlgorithmType=function(e){return e===Ge.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(Ge.a.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},set:function(e){this._occlusionDataStorage.isOcclusionQueryInProgress=e},enumerable:!1,configurable:!0}),Object.defineProperty(Ge.a.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new Bn),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(Ge.a.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(Ge.a.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Ge.a.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Ge.a.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),Ge.a.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===Ge.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!==Ge.a.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var n=this.getScene();if(n.getBoundingBoxRenderer){var r=n.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),r.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded};var Un=!0;Se.a.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},Se.a.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},Se.a.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},Se.a.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},Se.a.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},Se.a.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},Se.a.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)};i(126);qe.a.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){var n=this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0);this._unpackFlipY(!i);try{if(void 0===this._videoTextureSupported&&(this._gl.getError(),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=Zi.a.CreateCanvas(e.width,e.height);var r=e._workingCanvas.getContext("2d");if(!r)throw new Error("Unable to get 2d context");e._workingContext=r,e._workingCanvas.width=e.width,e._workingCanvas.height=e.height}e._workingContext.clearRect(0,0,e.width,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),n||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},qe.a.prototype.restoreSingleAttachment=function(){var e=this._gl;this.bindAttachments([e.BACK])},qe.a.prototype.buildTextureLayout=function(e){for(var t=this._gl,i=[],n=0;n<e.length;n++)e[n]?i.push(t["COLOR_ATTACHMENT"+n]):i.push(t.NONE);return i},qe.a.prototype.bindAttachments=function(e){this._gl.drawBuffers(e)},qe.a.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var n=this._gl,r=e[0]._attachments,o=r.length;if(e[0]._MSAAFramebuffer){n.bindFramebuffer(n.READ_FRAMEBUFFER,e[0]._MSAAFramebuffer),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,e[0]._framebuffer);for(var a=0;a<o;a++){for(var s=e[a],c=0;c<o;c++)r[c]=n.NONE;r[a]=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],n.readBuffer(r[a]),n.drawBuffers(r),n.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,n.COLOR_BUFFER_BIT,n.NEAREST)}for(a=0;a<o;a++)r[a]=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];n.drawBuffers(r)}for(a=0;a<o;a++){!(s=e[a]).generateMipMaps||t||s.isCube||(this._bindTextureDirectly(n.TEXTURE_2D,s,!0),n.generateMipmap(n.TEXTURE_2D),this._bindTextureDirectly(n.TEXTURE_2D,null))}i&&(e[0]._MSAAFramebuffer&&this._bindUnboundFramebuffer(e[0]._framebuffer),i()),this._bindUnboundFramebuffer(null)},qe.a.prototype.createMultipleRenderTarget=function(e,t){var i=!1,n=!0,r=!1,o=!1,a=1,s=g.a.TEXTURETYPE_UNSIGNED_INT,c=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,l=new Array,u=new Array;void 0!==t&&(i=void 0!==t.generateMipMaps&&t.generateMipMaps,n=void 0===t.generateDepthBuffer||t.generateDepthBuffer,r=void 0!==t.generateStencilBuffer&&t.generateStencilBuffer,o=void 0!==t.generateDepthTexture&&t.generateDepthTexture,a=t.textureCount||1,t.types&&(l=t.types),t.samplingModes&&(u=t.samplingModes));var h=this._gl,d=h.createFramebuffer();this._bindUnboundFramebuffer(d);for(var f=e.width||e,p=e.height||e,_=[],v=[],b=this._setupFramebufferDepthAttachments(r,n,f,p),y=0;y<a;y++){var T=u[y]||c,E=l[y]||s;(E!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(E!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(T=g.a.TEXTURE_NEAREST_SAMPLINGMODE);var S=this._getSamplingParameters(T,i);E!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(E=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var A=new Qe.a(this,Qe.b.MultiRenderTarget),P=h[this.webGLVersion>1?"COLOR_ATTACHMENT"+y:"COLOR_ATTACHMENT"+y+"_WEBGL"];_.push(A),v.push(P),h.activeTexture(h["TEXTURE"+y]),h.bindTexture(h.TEXTURE_2D,A._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,S.mag),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,S.min),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(E),f,p,0,h.RGBA,this._getWebGLTextureType(E),null),h.framebufferTexture2D(h.DRAW_FRAMEBUFFER,P,h.TEXTURE_2D,A._webGLTexture,0),i&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(h.TEXTURE_2D,null),A._framebuffer=d,A._depthStencilBuffer=b,A.baseWidth=f,A.baseHeight=p,A.width=f,A.height=p,A.isReady=!0,A.samples=1,A.generateMipMaps=i,A.samplingMode=T,A.type=E,A._generateDepthBuffer=n,A._generateStencilBuffer=r,A._attachments=v,A._textureArray=_,this._internalTexturesCache.push(A)}if(o&&this._caps.depthTextureExtension){var C=new Qe.a(this,Qe.b.MultiRenderTarget);h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,C._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this.webGLVersion<2?h.DEPTH_COMPONENT:h.DEPTH_COMPONENT16,f,p,0,h.DEPTH_COMPONENT,h.UNSIGNED_SHORT,null),h.framebufferTexture2D(h.FRAMEBUFFER,h.DEPTH_ATTACHMENT,h.TEXTURE_2D,C._webGLTexture,0),C._framebuffer=d,C.baseWidth=f,C.baseHeight=p,C.width=f,C.height=p,C.isReady=!0,C.samples=1,C.generateMipMaps=i,C.samplingMode=h.NEAREST,C._generateDepthBuffer=n,C._generateStencilBuffer=r,_.push(C),this._internalTexturesCache.push(C)}return h.drawBuffers(v),this._bindUnboundFramebuffer(null),this.resetTextureCache(),_},qe.a.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e[0].samples===t)return t;var i=e[0]._attachments.length;if(0===i)return 1;var n=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e[0]._depthStencilBuffer&&(n.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(n.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var r=0;r<i;r++)e[r]._MSAARenderBuffer&&(n.deleteRenderbuffer(e[r]._MSAARenderBuffer),e[r]._MSAARenderBuffer=null);if(t>1&&n.renderbufferStorageMultisample){var o=n.createFramebuffer();if(!o)throw new Error("Unable to create multi sampled framebuffer");this._bindUnboundFramebuffer(o);var a=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),s=[];for(r=0;r<i;r++){var c=e[r],l=n[this.webGLVersion>1?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],u=n.createRenderbuffer();if(!u)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,u),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(c.type),c.width,c.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,l,n.RENDERBUFFER,u),c._MSAAFramebuffer=o,c._MSAARenderBuffer=u,c.samples=t,c._depthStencilBuffer=a,n.bindRenderbuffer(n.RENDERBUFFER,null),s.push(l)}n.drawBuffers(s)}else this._bindUnboundFramebuffer(e[0]._framebuffer);return this._bindUnboundFramebuffer(null),t};var Vn=i(56);qe.a.prototype._createDepthStencilCubeTexture=function(e,t){var i=new Qe.a(this,Qe.b.Unknown);if(i.isCube=!0,1===this.webGLVersion)return m.a.Error("Depth cube texture is not supported by WebGL 1."),i;var n=Object(h.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),r=this._gl;this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,i,!0),this._setupDepthStencilTexture(i,e,n.generateStencil,n.bilinearFiltering,n.comparisonFunction);for(var o=0;o<6;o++)n.generateStencil?r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,r.DEPTH24_STENCIL8,e,e,0,r.DEPTH_STENCIL,r.UNSIGNED_INT_24_8,null):r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,r.DEPTH_COMPONENT24,e,e,0,r.DEPTH_COMPONENT,r.UNSIGNED_INT,null);return this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),i},qe.a.prototype._partialLoadFile=function(e,t,i,n,r){void 0===r&&(r=null);this._loadFile(e,(function(e){i[t]=e,i._internalCount++,6===i._internalCount&&n(i)}),void 0,void 0,!0,(function(e,t){r&&e&&r(e.status+" "+e.statusText,t)}))},qe.a.prototype._cascadeLoadFiles=function(e,t,i,n){void 0===n&&(n=null);var r=[];r._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(i[o],o,r,t,n)},qe.a.prototype._cascadeLoadImgs=function(e,t,i,n,r){void 0===n&&(n=null);var o=[];o._internalCount=0;for(var a=0;a<6;a++)this._partialLoadImg(i[a],a,o,e,t,n,r)},qe.a.prototype._partialLoadImg=function(e,t,i,n,r,o,a){var s;void 0===o&&(o=null);s=Vn.a.LoadImage(e,(function(){s&&(i[t]=s,i._internalCount++,n&&n._removePendingData(s)),6===i._internalCount&&r(i)}),(function(e,t){n&&n._removePendingData(s),o&&o(e,t)}),n?n.offlineProvider:null,a),n&&s&&n._addPendingData(s)},qe.a.prototype._setCubeMapTextureParams=function(e,t){var i=this._gl;i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e.samplingMode=t?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:g.a.TEXTURE_LINEAR_LINEAR,this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)},qe.a.prototype.createCubeTexture=function(e,t,i,n,r,o,a,s,c,l,u,h,d){var f=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!1),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=null);var p=this._gl,_=h||new Qe.a(this,Qe.b.Cube);_.isCube=!0,_.url=e,_.generateMipMaps=!n,_._lodGenerationScale=l,_._lodGenerationOffset=u,this._doNotHandleContextLost||(_._extension=s,_._files=i);var g=e;this._transformTextureUrl&&!h&&(e=this._transformTextureUrl(e));for(var v=e.lastIndexOf("."),b=s||(v>-1?e.substring(v).toLowerCase():""),y=null,T=0,E=qe.a._TextureLoaders;T<E.length;T++){var S=E[T];if(S.canLoad(b)){y=S;break}}if(y){var A=function(e){f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,_,!0),y.loadCubeData(e,_,c,r,o)};i&&6===i.length?y.supportCascades?this._cascadeLoadFiles(t,(function(e){return A(e.map((function(e){return new Uint8Array(e)})))}),i,o):o?o("Textures type does not support cascades."):m.a.Warn("Texture loader does not support cascades."):this._loadFile(e,(function(e){return A(new Uint8Array(e))}),void 0,void 0,!0,(function(h,p){e===g?o&&h&&o(h.status+" "+h.statusText,p):(m.a.Warn("Failed to load "+e+", falling back to the "+g),f.createCubeTexture(g,t,i,n,r,o,a,s,c,l,u,_,d))}))}else{if(!i)throw new Error("Cannot load cubemap because files were not defined");this._cascadeLoadImgs(t,(function(e){var t=f.needPOTTextures?qe.a.GetExponentOfTwo(e[0].width,f._caps.maxCubemapTextureSize):e[0].width,i=t,o=[p.TEXTURE_CUBE_MAP_POSITIVE_X,p.TEXTURE_CUBE_MAP_POSITIVE_Y,p.TEXTURE_CUBE_MAP_POSITIVE_Z,p.TEXTURE_CUBE_MAP_NEGATIVE_X,p.TEXTURE_CUBE_MAP_NEGATIVE_Y,p.TEXTURE_CUBE_MAP_NEGATIVE_Z];f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,_,!0),f._unpackFlipY(!1);for(var s=a?f._getInternalFormat(a):f._gl.RGBA,c=0;c<o.length;c++)if(e[c].width!==t||e[c].height!==i){if(f._prepareWorkingCanvas(),!f._workingCanvas||!f._workingContext)return void m.a.Warn("Cannot create canvas to resize texture.");f._workingCanvas.width=t,f._workingCanvas.height=i,f._workingContext.drawImage(e[c],0,0,e[c].width,e[c].height,0,0,t,i),p.texImage2D(o[c],0,s,s,p.UNSIGNED_BYTE,f._workingCanvas)}else p.texImage2D(o[c],0,s,s,p.UNSIGNED_BYTE,e[c]);n||p.generateMipmap(p.TEXTURE_CUBE_MAP),f._setCubeMapTextureParams(_,!n),_.width=t,_.height=i,_.isReady=!0,a&&(_.format=a),_.onLoadedObservable.notifyObservers(_),_.onLoadedObservable.clear(),r&&r()}),i,o)}return this._internalTexturesCache.push(_),_};i(153),i(124);var kn=function(){};Se.a.prototype.getInputElement=function(){return this.inputElement||this.getRenderingCanvas()},Se.a.prototype.registerView=function(e,t){var i=this;this.views||(this.views=[]);for(var n=0,r=this.views;n<r.length;n++){var o=r[n];if(o.target===e)return o}var a=this.getRenderingCanvas();a&&(e.width=a.width,e.height=a.height);var s={target:e,camera:t};return this.views.push(s),t&&t.onDisposeObservable.add((function(){i.unRegisterView(e)})),s},Se.a.prototype.unRegisterView=function(e){if(!this.views)return this;for(var t=0,i=this.views;t<i.length;t++){var n=i[t];if(n.target===e){var r=this.views.indexOf(n);-1!==r&&this.views.splice(r,1);break}}return this},Se.a.prototype._renderViews=function(){if(!this.views)return!1;var e=this.getRenderingCanvas();if(!e)return!1;for(var t=0,i=this.views;t<i.length;t++){var n=i[t],r=n.target,o=r.getContext("2d");if(o){var a=n.camera,s=null,c=null;if(a){if((c=a.getScene()).activeCameras&&c.activeCameras.length)continue;this.activeView=n,s=c.activeCamera,c.activeCamera=a}var l=r.width!==r.clientWidth||r.height!==r.clientHeight;if(r.clientWidth&&r.clientHeight&&l&&(r.width=r.clientWidth,r.height=r.clientHeight,e.width=r.clientWidth,e.height=r.clientHeight,this.resize()),!e.width||!e.height)return!1;this._renderFrame(),o.drawImage(e,0,0),s&&c&&(c.activeCamera=s)}}return this.activeView=null,!0};i(129);function zn(e){if(this._excludedCompressedTextures&&this._excludedCompressedTextures.some((function(t){var i="\\b"+t+"\\b";return e&&(e===t||e.match(new RegExp(i,"g")))})))return e;var t=e.lastIndexOf("."),i=e.lastIndexOf("?"),n=i>-1?e.substring(i,e.length):"";return(t>-1?e.substring(0,t):e)+this._textureFormatInUse+n}Object.defineProperty(Se.a.prototype,"texturesSupported",{get:function(){var e=new Array;return this._caps.astc&&e.push("-astc.ktx"),this._caps.s3tc&&e.push("-dxt.ktx"),this._caps.pvrtc&&e.push("-pvrtc.ktx"),this._caps.etc2&&e.push("-etc2.ktx"),this._caps.etc1&&e.push("-etc1.ktx"),e},enumerable:!0,configurable:!0}),Object.defineProperty(Se.a.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse||null},enumerable:!0,configurable:!0}),Se.a.prototype.setCompressedTextureExclusions=function(e){this._excludedCompressedTextures=e},Se.a.prototype.setTextureFormatToUse=function(e){for(var t=this.texturesSupported,i=0,n=t.length;i<n;i++)for(var r=0,o=e.length;r<o;r++)if(t[i]===e[r].toLowerCase())return this._transformTextureUrl=zn.bind(this),this._textureFormatInUse=t[i];return this._textureFormatInUse="",this._transformTextureUrl=null,null};var Gn=i(144),jn=i(118),Wn=i(89),Hn=[Math.sqrt(1/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(3/(4*Math.PI)),-Math.sqrt(3/(4*Math.PI)),Math.sqrt(15/(4*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(5/(16*Math.PI)),-Math.sqrt(15/(4*Math.PI)),Math.sqrt(15/(16*Math.PI))],Xn=[function(e){return 1},function(e){return e.y},function(e){return e.z},function(e){return e.x},function(e){return e.x*e.y},function(e){return e.y*e.z},function(e){return 3*e.z*e.z-1},function(e){return e.x*e.z},function(e){return e.x*e.x-e.y*e.y}],Yn=function(e,t){return Hn[e]*Xn[e](t)},Kn=[Math.PI,2*Math.PI/3,2*Math.PI/3,2*Math.PI/3,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4,Math.PI/4],Qn=function(){function e(){this.preScaled=!1,this.l00=a.e.Zero(),this.l1_1=a.e.Zero(),this.l10=a.e.Zero(),this.l11=a.e.Zero(),this.l2_2=a.e.Zero(),this.l2_1=a.e.Zero(),this.l20=a.e.Zero(),this.l21=a.e.Zero(),this.l22=a.e.Zero()}return e.prototype.addLight=function(e,t,i){var n=new a.e(t.r,t.g,t.b).scale(i);this.l00=this.l00.add(n.scale(Yn(0,e))),this.l1_1=this.l1_1.add(n.scale(Yn(1,e))),this.l10=this.l10.add(n.scale(Yn(2,e))),this.l11=this.l11.add(n.scale(Yn(3,e))),this.l2_2=this.l2_2.add(n.scale(Yn(4,e))),this.l2_1=this.l2_1.add(n.scale(Yn(5,e))),this.l20=this.l20.add(n.scale(Yn(6,e))),this.l21=this.l21.add(n.scale(Yn(7,e))),this.l22=this.l22.add(n.scale(Yn(8,e)))},e.prototype.scaleInPlace=function(e){this.l00.scaleInPlace(e),this.l1_1.scaleInPlace(e),this.l10.scaleInPlace(e),this.l11.scaleInPlace(e),this.l2_2.scaleInPlace(e),this.l2_1.scaleInPlace(e),this.l20.scaleInPlace(e),this.l21.scaleInPlace(e),this.l22.scaleInPlace(e)},e.prototype.convertIncidentRadianceToIrradiance=function(){this.l00.scaleInPlace(Kn[0]),this.l1_1.scaleInPlace(Kn[1]),this.l10.scaleInPlace(Kn[2]),this.l11.scaleInPlace(Kn[3]),this.l2_2.scaleInPlace(Kn[4]),this.l2_1.scaleInPlace(Kn[5]),this.l20.scaleInPlace(Kn[6]),this.l21.scaleInPlace(Kn[7]),this.l22.scaleInPlace(Kn[8])},e.prototype.convertIrradianceToLambertianRadiance=function(){this.scaleInPlace(1/Math.PI)},e.prototype.preScaleForRendering=function(){this.preScaled=!0,this.l00.scaleInPlace(Hn[0]),this.l1_1.scaleInPlace(Hn[1]),this.l10.scaleInPlace(Hn[2]),this.l11.scaleInPlace(Hn[3]),this.l2_2.scaleInPlace(Hn[4]),this.l2_1.scaleInPlace(Hn[5]),this.l20.scaleInPlace(Hn[6]),this.l21.scaleInPlace(Hn[7]),this.l22.scaleInPlace(Hn[8])},e.FromArray=function(t){var i=new e;return a.e.FromArrayToRef(t[0],0,i.l00),a.e.FromArrayToRef(t[1],0,i.l1_1),a.e.FromArrayToRef(t[2],0,i.l10),a.e.FromArrayToRef(t[3],0,i.l11),a.e.FromArrayToRef(t[4],0,i.l2_2),a.e.FromArrayToRef(t[5],0,i.l2_1),a.e.FromArrayToRef(t[6],0,i.l20),a.e.FromArrayToRef(t[7],0,i.l21),a.e.FromArrayToRef(t[8],0,i.l22),i},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.l22=t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)),i.l1_1.scaleInPlace(-1),i.l11.scaleInPlace(-1),i.l2_1.scaleInPlace(-1),i.l21.scaleInPlace(-1),i.scaleInPlace(Math.PI),i},e}(),qn=function(){function e(){this.x=a.e.Zero(),this.y=a.e.Zero(),this.z=a.e.Zero(),this.xx=a.e.Zero(),this.yy=a.e.Zero(),this.zz=a.e.Zero(),this.xy=a.e.Zero(),this.yz=a.e.Zero(),this.zx=a.e.Zero()}return Object.defineProperty(e.prototype,"preScaledHarmonics",{get:function(){return this._harmonics||(this._harmonics=Qn.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics},enumerable:!1,configurable:!0}),e.prototype.addAmbient=function(e){var t=new a.e(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.scaleInPlace=function(e){this.x.scaleInPlace(e),this.y.scaleInPlace(e),this.z.scaleInPlace(e),this.xx.scaleInPlace(e),this.yy.scaleInPlace(e),this.zz.scaleInPlace(e),this.yz.scaleInPlace(e),this.zx.scaleInPlace(e),this.xy.scaleInPlace(e)},e.FromHarmonics=function(t){var i=new e;return i._harmonics=t,i.x=t.l11.scale(1.02333).scale(-1),i.y=t.l1_1.scale(1.02333).scale(-1),i.z=t.l10.scale(1.02333),i.xx=t.l00.scale(.886277).subtract(t.l20.scale(.247708)).add(t.l22.scale(.429043)),i.yy=t.l00.scale(.886277).subtract(t.l20.scale(.247708)).subtract(t.l22.scale(.429043)),i.zz=t.l00.scale(.886277).add(t.l20.scale(.495417)),i.yz=t.l2_1.scale(.858086).scale(-1),i.zx=t.l21.scale(.858086).scale(-1),i.xy=t.l2_2.scale(.858086),i.scaleInPlace(1/Math.PI),i},e.FromArray=function(t){var i=new e;return a.e.FromArrayToRef(t[0],0,i.x),a.e.FromArrayToRef(t[1],0,i.y),a.e.FromArrayToRef(t[2],0,i.z),a.e.FromArrayToRef(t[3],0,i.xx),a.e.FromArrayToRef(t[4],0,i.yy),a.e.FromArrayToRef(t[5],0,i.zz),a.e.FromArrayToRef(t[6],0,i.yz),a.e.FromArrayToRef(t[7],0,i.zx),a.e.FromArrayToRef(t[8],0,i.xy),i},e}(),Zn=i(52),Jn=function(e,t,i,n){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=n},$n=function(){function e(){}return e.ConvertCubeMapTextureToSphericalPolynomial=function(e){if(!e.isCube)return null;var t,i,n=e.getSize().width,r=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),s=e.readPixels(5),c=e.gammaSpace,l=g.a.TEXTUREFORMAT_RGBA,u=g.a.TEXTURETYPE_UNSIGNED_INT;e.textureType!=g.a.TEXTURETYPE_FLOAT&&e.textureType!=g.a.TEXTURETYPE_HALF_FLOAT||(u=g.a.TEXTURETYPE_FLOAT);var h={size:n,right:r,left:o,up:t,down:i,front:a,back:s,format:l,type:u,gammaSpace:c};return this.ConvertCubeMapToSphericalPolynomial(h)},e.ConvertCubeMapToSphericalPolynomial=function(e){for(var t=new Qn,i=0,n=2/e.size,r=n,o=.5*n-1,a=0;a<6;a++)for(var c=this.FileFaces[a],l=e[c.name],u=o,h=e.format===g.a.TEXTUREFORMAT_RGBA?4:3,d=0;d<e.size;d++){for(var f=o,p=0;p<e.size;p++){var _=c.worldAxisForFileX.scale(f).add(c.worldAxisForFileY.scale(u)).add(c.worldAxisForNormal);_.normalize();var m=Math.pow(1+f*f+u*u,-1.5),v=l[d*e.size*h+p*h+0],b=l[d*e.size*h+p*h+1],y=l[d*e.size*h+p*h+2];isNaN(v)&&(v=0),isNaN(b)&&(b=0),isNaN(y)&&(y=0),e.type===g.a.TEXTURETYPE_UNSIGNED_INT&&(v/=255,b/=255,y/=255),e.gammaSpace&&(v=Math.pow(L.a.Clamp(v),Nt.c),b=Math.pow(L.a.Clamp(b),Nt.c),y=Math.pow(L.a.Clamp(y),Nt.c));v=L.a.Clamp(v,0,4096),b=L.a.Clamp(b,0,4096),y=L.a.Clamp(y,0,4096);var T=new s.a(v,b,y);t.addLight(_,T,m),i+=m,f+=n}u+=r}var E=6*(4*Math.PI)/6/i;return t.scaleInPlace(E),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),qn.FromHarmonics(t)},e.FileFaces=[new Jn("right",new a.e(1,0,0),new a.e(0,0,-1),new a.e(0,-1,0)),new Jn("left",new a.e(-1,0,0),new a.e(0,0,1),new a.e(0,-1,0)),new Jn("up",new a.e(0,1,0),new a.e(1,0,0),new a.e(0,0,1)),new Jn("down",new a.e(0,-1,0),new a.e(1,0,0),new a.e(0,0,-1)),new Jn("front",new a.e(0,0,1),new a.e(1,0,0),new a.e(0,-1,0)),new Jn("back",new a.e(0,0,-1),new a.e(-1,0,0),new a.e(0,-1,0))],e}();Object.defineProperty(Zn.a.prototype,"sphericalPolynomial",{get:function(){if(this._texture){if(this._texture._sphericalPolynomial)return this._texture._sphericalPolynomial;if(this._texture.isReady)return this._texture._sphericalPolynomial=$n.ConvertCubeMapTextureToSphericalPolynomial(this),this._texture._sphericalPolynomial}return null},set:function(e){this._texture&&(this._texture._sphericalPolynomial=e)},enumerable:!0,configurable:!0});var er="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";ai.a.ShadersStore.rgbdEncodePixelShader=er;var tr="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";ai.a.ShadersStore.rgbdDecodePixelShader=tr;var ir=function(){function e(){}return e.GetEnvInfo=function(t){for(var i=new DataView(t.buffer,t.byteOffset,t.byteLength),n=0,r=0;r<e._MagicBytes.length;r++)if(i.getUint8(n++)!==e._MagicBytes[r])return m.a.Error("Not a babylon environment map"),null;for(var o="",a=0;a=i.getUint8(n++);)o+=String.fromCharCode(a);var s=JSON.parse(o);return s.specular&&(s.specular.specularDataPosition=n,s.specular.lodGenerationScale=s.specular.lodGenerationScale||.8),s},e.CreateEnvTextureAsync=function(t){var i=this,n=t.getInternalTexture();if(!n)return Promise.reject("The cube texture is invalid.");var r=n.getEngine();if(r&&r.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===g.a.TEXTURETYPE_UNSIGNED_INT)return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");var o=r.getRenderingCanvas();if(!o)return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");var a=g.a.TEXTURETYPE_FLOAT;if(!r.getCaps().textureFloatRender&&(a=g.a.TEXTURETYPE_HALF_FLOAT,!r.getCaps().textureHalfFloatRender))return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");var s=n.width,c=new Q.a(r),l={},u=[],h=L.a.Log2(n.width);h=Math.round(h);for(var d=function(e){for(var i=Math.pow(2,h-e),n=function(n){var s=t.readPixels(n,e),h=r.createRawTexture(s,i,i,g.a.TEXTUREFORMAT_RGBA,!1,!1,g.a.TEXTURE_NEAREST_SAMPLINGMODE,null,a),d=new Promise((function(t,a){var s=new li("rgbdEncode","rgbdEncode",null,null,1,null,g.a.TEXTURE_NEAREST_SAMPLINGMODE,r,!1,void 0,g.a.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);s.getEffect().executeWhenCompiled((function(){s.onApply=function(e){e._bindTexture("textureSampler",h)};var a=r.getRenderWidth(),u=r.getRenderHeight();r.setSize(i,i),c.postProcessManager.directRender([s],null),Ce.b.ToBlob(o,(function(i){var r=new FileReader;r.onload=function(i){var r=i.target.result;l[6*e+n]=r,t()},r.readAsArrayBuffer(i)})),r.setSize(a,u)}))}));u.push(d)},s=0;s<6;s++)n(s)},f=0;f<=h;f++)d(f);return Promise.all(u).then((function(){c.dispose();for(var n={version:1,width:s,irradiance:i._CreateEnvTextureIrradiance(t),specular:{mipmaps:[],lodGenerationScale:t.lodGenerationScale}},r=0,o=0;o<=h;o++)for(var a=0;a<6;a++){var u=l[6*o+a].byteLength;n.specular.mipmaps.push({length:u,position:r}),r+=u}for(var d=JSON.stringify(n),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 m=e._MagicBytes.length+r+f.byteLength,g=new ArrayBuffer(m),v=new Uint8Array(g),b=new DataView(g),y=0;for(o=0;o<e._MagicBytes.length;o++)b.setUint8(y++,e._MagicBytes[o]);v.set(new Uint8Array(f),y),y+=f.byteLength;for(o=0;o<=h;o++)for(a=0;a<6;a++){var T=l[6*o+a];v.set(new Uint8Array(T),y),y+=T.byteLength}return g}))},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.CreateImageDataArrayBufferViews=function(e,t){if(1!==t.version)throw new Error('Unsupported babylon environment map version "'+t.version+'"');var i=t.specular,n=L.a.Log2(t.width);if(n=Math.round(n)+1,i.mipmaps.length!==6*n)throw new Error('Unsupported specular mipmaps number "'+i.mipmaps.length+'"');for(var r=new Array(n),o=0;o<n;o++){r[o]=new Array(6);for(var a=0;a<6;a++){var s=i.mipmaps[6*o+a];r[o][a]=new Uint8Array(e.buffer,e.byteOffset+i.specularDataPosition+s.position,s.length)}}return r},e.UploadEnvLevelsAsync=function(t,i,n){if(1!==n.version)throw new Error('Unsupported babylon environment map version "'+n.version+'"');var r=n.specular;if(!r)return Promise.resolve();t._lodGenerationScale=r.lodGenerationScale;var o=e.CreateImageDataArrayBufferViews(i,n);return e.UploadLevelsAsync(t,o)},e._OnImageReadyAsync=function(e,t,i,n,r,o,a,s,c,l,u){return new Promise((function(h,d){if(i){var f=t.createTexture(null,!0,!0,null,g.a.TEXTURE_NEAREST_SAMPLINGMODE,null,(function(e){d(e)}),e);n.getEffect().executeWhenCompiled((function(){n.onApply=function(e){e._bindTexture("textureSampler",f),e.setFloat2("scale",1,1)},t.scenes[0].postProcessManager.directRender([n],l,!0,o,a),t.restoreDefaultFramebuffer(),f.dispose(),URL.revokeObjectURL(r),h()}))}else{if(t._uploadImageToTexture(u,e,o,a),s){var p=c[a];p&&t._uploadImageToTexture(p._texture,e,o,0)}h()}}))},e.UploadLevelsAsync=function(e,t){var i=this;if(!Ce.b.IsExponentOfTwo(e.width))throw new Error("Texture size must be a power of two");var n=Math.round(L.a.Log2(e.width))+1,r=e.getEngine(),o=!1,a=!1,s=null,c=null,l=null,u=r.getCaps();if(e.format=g.a.TEXTUREFORMAT_RGBA,e.type=g.a.TEXTURETYPE_UNSIGNED_INT,e.generateMipMaps=!0,e._cachedAnisotropicFilteringLevel=null,r.updateTextureSamplingMode(g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,e),u.textureLOD?r.webGLVersion<2?o=!1:u.textureHalfFloatRender&&u.textureHalfFloatLinearFiltering?(o=!0,e.type=g.a.TEXTURETYPE_HALF_FLOAT):u.textureFloatRender&&u.textureFloatLinearFiltering&&(o=!0,e.type=g.a.TEXTURETYPE_FLOAT):(o=!1,a=!0,l={}),o)s=new li("rgbdDecode","rgbdDecode",null,null,1,null,g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,r,!1,void 0,e.type,void 0,null,!1),e._isRGBD=!1,e.invertY=!1,c=r.createRenderTargetCubeTexture(e.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,type:e.type,format:g.a.TEXTUREFORMAT_RGBA});else if(e._isRGBD=!0,e.invertY=!0,a)for(var h=e._lodGenerationScale,d=e._lodGenerationOffset,f=0;f<3;f++){var p=(n-1)*h+d,_=d+(p-d)*(1-f/2),m=Math.round(Math.min(Math.max(_,0),p)),v=new Qe.a(r,Qe.b.Temp);v.isCube=!0,v.invertY=!0,v.generateMipMaps=!1,r.updateTextureSamplingMode(g.a.TEXTURE_LINEAR_LINEAR,v);var b=new Zn.a(null);switch(b.isCube=!0,b._texture=v,l[m]=b,f){case 0:e._lodTextureLow=b;break;case 1:e._lodTextureMid=b;break;case 2:e._lodTextureHigh=b}}var y=[],T=function(n){for(var u=function(u){var h=t[n][u],d=new Blob([h],{type:"image/png"}),f=URL.createObjectURL(d),p=void 0;if("undefined"==typeof Image)p=createImageBitmap(d).then((function(t){return i._OnImageReadyAsync(t,r,o,s,f,u,n,a,l,c,e)}));else{var _=new Image;_.src=f,p=new Promise((function(t,h){_.onload=function(){i._OnImageReadyAsync(_,r,o,s,f,u,n,a,l,c,e).then((function(){return t()})).catch((function(e){h(e)}))},_.onerror=function(e){h(e)}}))}y.push(p)},h=0;h<6;h++)u(h)};for(f=0;f<t.length;f++)T(f);if(t.length<n){var E=void 0,S=Math.pow(2,n-1-t.length),A=S*S*4;switch(e.type){case g.a.TEXTURETYPE_UNSIGNED_INT:E=new Uint8Array(A);break;case g.a.TEXTURETYPE_HALF_FLOAT:E=new Uint16Array(A);break;case g.a.TEXTURETYPE_FLOAT:E=new Float32Array(A)}for(f=t.length;f<n;f++)for(var P=0;P<6;P++)r._uploadArrayBufferViewToTexture(e,E,P,f)}return Promise.all(y).then((function(){c&&(r._releaseFramebufferObjects(c),r._releaseTexture(e),c._swapAndDie(e)),s&&s.dispose(),a&&(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&&m.a.Warn('Unsupported babylon environment map version "'+t.version+'"');var i=t.irradiance;if(i){var n=new qn;a.e.FromArrayToRef(i.x,0,n.x),a.e.FromArrayToRef(i.y,0,n.y),a.e.FromArrayToRef(i.z,0,n.z),a.e.FromArrayToRef(i.xx,0,n.xx),a.e.FromArrayToRef(i.yy,0,n.yy),a.e.FromArrayToRef(i.zz,0,n.zz),a.e.FromArrayToRef(i.yz,0,n.yz),a.e.FromArrayToRef(i.zx,0,n.zx),a.e.FromArrayToRef(i.xy,0,n.xy),e._sphericalPolynomial=n}},e._UpdateRGBDAsync=function(t,i,n,r,o){return t._source=Qe.b.CubeRawRGBD,t._bufferViewArrayArray=i,t._lodGenerationScale=r,t._lodGenerationOffset=o,t._sphericalPolynomial=n,e.UploadLevelsAsync(t,i).then((function(){t.isReady=!0}))},e._MagicBytes=[134,22,135,150,246,214,150,54],e}();Qe.a._UpdateRGBDAsync=ir._UpdateRGBDAsync;var nr,rr=function(){function e(e,t){void 0===t&&(t=20),this.debug=!1,this._sourceCode=e,this._numMaxIterations=t,this._functionDescr=[],this.inlineToken="#define inline"}return Object.defineProperty(e.prototype,"code",{get:function(){return this._sourceCode},enumerable:!1,configurable:!0}),e.prototype.processCode=function(){this.debug&&console.log("Start inlining process (code size="+this._sourceCode.length+")..."),this._collectFunctions(),this._processInlining(this._numMaxIterations),this.debug&&console.log("End of inlining process.")},e.prototype._collectFunctions=function(){for(var t=0;t<this._sourceCode.length;){var i=this._sourceCode.indexOf(this.inlineToken,t);if(i<0)break;var n=this._sourceCode.indexOf("(",i+this.inlineToken.length);if(n<0)this.debug&&console.warn("Could not find the opening parenthesis after the token. startIndex="+t),t=i+this.inlineToken.length;else{var r=e._RegexpFindFunctionNameAndType.exec(this._sourceCode.substring(i+this.inlineToken.length,n));if(r){var o=[r[3],r[4]],a=o[0],s=o[1],c=this._extractBetweenMarkers("(",")",this._sourceCode,n);if(c<0)this.debug&&console.warn("Could not extract the parameters the function '"+s+"' (type="+a+"). funcParamsStartIndex="+n),t=i+this.inlineToken.length;else{var l=this._sourceCode.substring(n+1,c),u=this._skipWhitespaces(this._sourceCode,c+1);if(u!==this._sourceCode.length){var h=this._extractBetweenMarkers("{","}",this._sourceCode,u);if(h<0)this.debug&&console.warn("Could not extract the body of the function '"+s+"' (type="+a+"). funcBodyStartIndex="+u),t=i+this.inlineToken.length;else{for(var d=this._sourceCode.substring(u,h+1),f=this._removeComments(l).split(","),p=[],_=0;_<f.length;++_){var m=f[_].trim(),g=m.lastIndexOf(" ");g>=0&&p.push(m.substring(g+1))}"void"!==a&&p.push("return"),this._functionDescr.push({name:s,type:a,parameters:p,body:d,callIndex:0}),t=h+1;var v=i>0?this._sourceCode.substring(0,i):"",b=h+1<this._sourceCode.length-1?this._sourceCode.substring(h+1):"";this._sourceCode=v+b,t-=h+1-i}}else this.debug&&console.warn("Could not extract the body of the function '"+s+"' (type="+a+"). funcParamsEndIndex="+c),t=i+this.inlineToken.length}}else this.debug&&console.warn("Could not extract the name/type of the function from: "+this._sourceCode.substring(i+this.inlineToken.length,n)),t=i+this.inlineToken.length}}this.debug&&console.log("Collect functions: "+this._functionDescr.length+" functions found. functionDescr=",this._functionDescr)},e.prototype._processInlining=function(e){for(void 0===e&&(e=20);e-- >=0&&this._replaceFunctionCallsByCode(););return this.debug&&console.log("numMaxIterations is "+e+" after inlining process"),e>=0},e.prototype._extractBetweenMarkers=function(e,t,i,n){for(var r=n,o=0,a="";r<i.length;){var s=i.charAt(r);if(a)s===a?'"'===a||"'"===a?"\\"!==i.charAt(r-1)&&(a=""):a="":"*/"===a&&"*"===s&&r+1<i.length&&("/"===i.charAt(r+1)&&(a=""),""===a&&r++);else switch(s){case e:o++;break;case t:o--;break;case'"':case"'":case"`":a=s;break;case"/":if(r+1<i.length){var c=i.charAt(r+1);"/"===c?a="\n":"*"===c&&(a="*/")}}if(r++,0===o)break}return 0===o?r-1:-1},e.prototype._skipWhitespaces=function(e,t){for(;t<e.length;){var i=e[t];if(" "!==i&&"\n"!==i&&"\r"!==i&&"\t"!==i&&"\n"!==i&&" "!==i)break;t++}return t},e.prototype._removeComments=function(e){for(var t=0,i="",n=!1,r=[];t<e.length;){var o=e.charAt(t);if(i)o===i?'"'===i||"'"===i?("\\"!==e.charAt(t-1)&&(i=""),r.push(o)):(i="",n=!1):"*/"===i&&"*"===o&&t+1<e.length?("/"===e.charAt(t+1)&&(i=""),""===i&&(n=!1,t++)):n||r.push(o);else{switch(o){case'"':case"'":case"`":i=o;break;case"/":if(t+1<e.length){var a=e.charAt(t+1);"/"===a?(i="\n",n=!0):"*"===a&&(i="*/",n=!0)}}n||r.push(o)}t++}return r.join("")},e.prototype._replaceFunctionCallsByCode=function(){for(var e=!1,t=0,i=this._functionDescr;t<i.length;t++)for(var n=i[t],r=n.name,o=n.type,a=n.parameters,s=n.body,c=0;c<this._sourceCode.length;){var l=this._sourceCode.indexOf(r,c);if(l<0)break;var u=this._skipWhitespaces(this._sourceCode,l+r.length);if(u!==this._sourceCode.length&&"("===this._sourceCode.charAt(u)){var h=this._extractBetweenMarkers("(",")",this._sourceCode,u);if(h<0)this.debug&&console.warn("Could not extract the parameters of the function call. Function '"+r+"' (type="+o+"). callParamsStartIndex="+u),c=l+r.length;else{for(var d=this._sourceCode.substring(u+1,h),f=this._removeComments(d).split(","),p=[],_=0;_<f.length;++_){var m=f[_].trim();p.push(m)}var g="void"!==o?r+"_"+n.callIndex++:null;if(g&&p.push(g+" ="),p.length===a.length){c=h+1;var v=this._replaceNames(s,a,p),b=l>0?this._sourceCode.substring(0,l):"",y=h+1<this._sourceCode.length-1?this._sourceCode.substring(h+1):"";if(g){var T=this._findBackward(this._sourceCode,l-1,"\n");b=this._sourceCode.substring(0,T+1);var E=this._sourceCode.substring(T+1,l);this._sourceCode=b+o+" "+g+";\n"+v+"\n"+E+g+y,this.debug&&console.log("Replace function call by code. Function '"+r+"' (type="+o+"). injectDeclarationIndex="+T)}else this._sourceCode=b+v+y,c+=v.length-(h+1-l),this.debug&&console.log("Replace function call by code. Function '"+r+"' (type="+o+"). functionCallIndex="+l);e=!0}else this.debug&&console.warn("Invalid function call: not the same number of parameters for the call than the number expected by the function. Function '"+r+"' (type="+o+"). function parameters="+a+", call parameters="+p),c=l+r.length}}else c=l+r.length}return e},e.prototype._findBackward=function(e,t,i){for(;t>=0&&e.charAt(t)!==i;)t--;return t},e.prototype._escapeRegExp=function(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")},e.prototype._replaceNames=function(e,t,i){for(var n=0;n<t.length;++n){var r=new RegExp(this._escapeRegExp(t[n]),"g"),o=i[n];e=e.replace(r,o)}return e},e._RegexpFindFunctionNameAndType=/((\s+?)(\w+)\s+(\w+)\s*?)$/,e}(),or=function(){function e(){this.isAsync=!1,this.isReady=!1}return e.prototype._getVertexShaderCode=function(){return null},e.prototype._getFragmentShaderCode=function(){return null},e.prototype._handlesSpectorRebuildCallback=function(e){throw new Error("Not implemented")},e}(),ar=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t}(Wn.a),sr=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t.prototype.getInternalTexture=function(){return this},t.prototype.getViewCount=function(){return 1},t}(Qe.a),cr=function(e){function t(){var t=e.call(this,null)||this;return t._native=new _native.Engine,t.INVALID_HANDLE=65535,t._boundBuffersVertexArray=null,t._currentDepthTest=t._native.DEPTH_TEST_LEQUAL,t._webGLVersion=2,t.disableUniformBuffers=!0,t._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,maxFragmentUniformVectors:16,maxVertexUniformVectors:16,standardDerivatives:!0,astc:null,pvrtc:null,etc1:null,etc2:null,bptc:null,maxAnisotropy:16,uintIndices:!0,fragmentDepthSupported:!1,highPrecisionShaderSupported:!0,colorBufferFloat:!1,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!0,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!0,instancedArrays:!1,canUseTimestampForTimerQuery:!1,blendMinMax:!1,maxMSAASamples:1},Ce.b.Log("Babylon Native (v"+Se.a.Version+") launched"),Ce.b.LoadScript=function(e,t,i,n){Ce.b.LoadFile(e,(function(e){Function(e).apply(null),t&&t()}),void 0,void 0,!1,(function(e,t){i&&i("LoadScript Error",t)}))},"undefined"==typeof URL&&(window.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(window.Blob=function(){}),t._shaderProcessor=new jn.a,t}return Object(h.d)(t,e),t.prototype.getHardwareScalingLevel=function(){return 1},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._boundBuffersVertexArray&&this._native.deleteVertexArray(this._boundBuffersVertexArray),this._native.dispose()},t.prototype._queueNewFrame=function(e,t){return t.requestAnimationFrame&&t!==window?t.requestAnimationFrame(e):this._native.requestAnimationFrame(e),0},t.prototype._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._currentFramebuffer&&this._native.unbindFramebuffer(this._currentFramebuffer),e&&this._native.bindFramebuffer(e),this._currentFramebuffer=e)},t.prototype.getHostDocument=function(){return null},t.prototype.clear=function(e,t,i,n){void 0===n&&(n=!1);var r=0;t&&e&&(this._native.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),r|=this._native.CLEAR_FLAG_COLOR),i&&(this._native.clearDepth(1),r|=this._native.CLEAR_FLAG_DEPTH),n&&(this._native.clearStencil(0),r|=this._native.CLEAR_FLAG_STENCIL),this._native.clear(r)},t.prototype.createIndexBuffer=function(e,t){var i=this._normalizeIndexData(e),n=new ar;if(n.references=1,n.is32Bits=4===i.BYTES_PER_ELEMENT,i.length){if(n.nativeIndexBuffer=this._native.createIndexBuffer(i,null!=t&&t),n.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native index buffer.")}else n.nativeVertexBuffer=this.INVALID_HANDLE;return n},t.prototype.createVertexBuffer=function(e,t){var i=new ar;if(i.references=1,i.nativeVertexBuffer=this._native.createVertexBuffer(ArrayBuffer.isView(e)?e:new Float32Array(e),null!=t&&t),i.nativeVertexBuffer===this.INVALID_HANDLE)throw new Error("Could not create a native vertex buffer.");return i},t.prototype._recordVertexArrayObject=function(e,t,i,n){i&&this._native.recordIndexBuffer(e,i.nativeIndexBuffer);for(var r=n.getAttributesNames(),o=0;o<r.length;o++){var a=n.getAttributeLocation(o);if(a>=0){var s=t[r[o]];if(s){var c=s.getBuffer();c&&this._native.recordVertexBuffer(e,c.nativeVertexBuffer,a,s.byteOffset,s.byteStride,s.getSize(),this._getNativeAttribType(s.type),s.normalized)}}}},t.prototype.bindBuffers=function(e,t,i){this._boundBuffersVertexArray&&this._native.deleteVertexArray(this._boundBuffersVertexArray),this._boundBuffersVertexArray=this._native.createVertexArray(),this._recordVertexArrayObject(this._boundBuffersVertexArray,e,t,i),this._native.bindVertexArray(this._boundBuffersVertexArray)},t.prototype.recordVertexArrayObject=function(e,t,i){var n=this._native.createVertexArray();return this._recordVertexArrayObject(n,e,t,i),n},t.prototype.bindVertexArrayObject=function(e){this._native.bindVertexArray(e)},t.prototype.releaseVertexArrayObject=function(e){this._native.deleteVertexArray(e)},t.prototype.getAttributes=function(e,t){var i=e;return this._native.getAttributes(i.nativeProgram,t)},t.prototype.drawElementsType=function(e,t,i,n){this._drawCalls.addCount(1,!1),this._native.drawIndexed(e,t,i)},t.prototype.drawArraysType=function(e,t,i,n){this._drawCalls.addCount(1,!1),this._native.draw(e,t,i)},t.prototype.createPipelineContext=function(){return new or},t.prototype._preparePipelineContext=function(e,t,i,n,r,o,a){var s=e;s.nativeProgram=n?this.createRawShaderProgram(e,t,i,void 0,a):this.createShaderProgram(e,t,i,o,void 0,a)},t.prototype._isRenderingStateCompiled=function(e){return!0},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){t()},t.prototype.createRawShaderProgram=function(e,t,i,n,r){throw void 0===r&&(r=null),new Error("Not Supported")},t.prototype.createShaderProgram=function(e,t,i,n,r,o){void 0===o&&(o=null),this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=new rr(t);a.processCode(),t=a.code;var s=new rr(i);s.processCode(),i=s.code,t=qe.a._ConcatenateShader(t,n),i=qe.a._ConcatenateShader(i,n);var c=this._native.createProgram(t,i);return this.onAfterShaderCompilationObservable.notifyObservers(this),c},t.prototype._setProgram=function(e){this._currentProgram!==e&&(this._native.setProgram(e),this._currentProgram=e)},t.prototype._releaseEffect=function(e){},t.prototype._deletePipelineContext=function(e){},t.prototype.getUniforms=function(e,t){var i=e;return this._native.getUniforms(i.nativeProgram,t)},t.prototype.bindUniformBlock=function(e,t,i){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.nativeProgram);for(var i=e.getSamplers(),n=0;n<i.length;n++){var r=e.getUniform(i[n]);r&&(this._boundUniforms[n]=r)}this._currentEffect=null},t.prototype.setMatrix=function(e,t){e&&this._native.setMatrix(e,t.toArray())},t.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._native.getRenderWidth()},t.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._native.getRenderHeight()},t.prototype.setViewport=function(e,t,i){this._cachedViewport=e,this._native.setViewPort(e.x,e.y,e.width,e.height)},t.prototype.setState=function(e,t,i,n){void 0===t&&(t=0),void 0===n&&(n=!1),this._native.setState(e,t,n)},t.prototype.setZOffset=function(e){this._native.setZOffset(e)},t.prototype.getZOffset=function(){return this._native.getZOffset()},t.prototype.setDepthBuffer=function(e){this._native.setDepthTest(e?this._currentDepthTest:this._native.DEPTH_TEST_ALWAYS)},t.prototype.getDepthWrite=function(){return this._native.getDepthWrite()},t.prototype.setDepthFunctionToGreater=function(){this._currentDepthTest=this._native.DEPTH_TEST_GREATER,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthFunctionToGreaterOrEqual=function(){this._currentDepthTest=this._native.DEPTH_TEST_GEQUAL,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthFunctionToLess=function(){this._currentDepthTest=this._native.DEPTH_TEST_LESS,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthFunctionToLessOrEqual=function(){this._currentDepthTest=this._native.DEPTH_TEST_LEQUAL,this._native.setDepthTest(this._currentDepthTest)},t.prototype.setDepthWrite=function(e){this._native.setDepthWrite(e)},t.prototype.setColorWrite=function(e){this._native.setColorWrite(e),this._colorWrite=e},t.prototype.getColorWrite=function(){return this._colorWrite},t.prototype.setAlphaConstants=function(e,t,i,n){throw new Error("Setting alpha blend constant color not yet implemented.")},t.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(e=this._getNativeAlphaMode(e),this._native.setBlendMode(e),t||this.setDepthWrite(e===g.a.ALPHA_DISABLE),this._alphaMode=e)},t.prototype.getAlphaMode=function(){return this._alphaMode},t.prototype.setInt=function(e,t){return!!e&&(this._native.setInt(e,t),!0)},t.prototype.setIntArray=function(e,t){return!!e&&(this._native.setIntArray(e,t),!0)},t.prototype.setIntArray2=function(e,t){return!!e&&(this._native.setIntArray2(e,t),!0)},t.prototype.setIntArray3=function(e,t){return!!e&&(this._native.setIntArray3(e,t),!0)},t.prototype.setIntArray4=function(e,t){return!!e&&(this._native.setIntArray4(e,t),!0)},t.prototype.setFloatArray=function(e,t){return!!e&&(this._native.setFloatArray(e,t),!0)},t.prototype.setFloatArray2=function(e,t){return!!e&&(this._native.setFloatArray2(e,t),!0)},t.prototype.setFloatArray3=function(e,t){return!!e&&(this._native.setFloatArray3(e,t),!0)},t.prototype.setFloatArray4=function(e,t){return!!e&&(this._native.setFloatArray4(e,t),!0)},t.prototype.setArray=function(e,t){return!!e&&(this._native.setFloatArray(e,t),!0)},t.prototype.setArray2=function(e,t){return!!e&&(this._native.setFloatArray2(e,t),!0)},t.prototype.setArray3=function(e,t){return!!e&&(this._native.setFloatArray3(e,t),!0)},t.prototype.setArray4=function(e,t){return!!e&&(this._native.setFloatArray4(e,t),!0)},t.prototype.setMatrices=function(e,t){return!!e&&(this._native.setMatrices(e,t),!0)},t.prototype.setMatrix3x3=function(e,t){return!!e&&(this._native.setMatrix3x3(e,t),!0)},t.prototype.setMatrix2x2=function(e,t){return!!e&&(this._native.setMatrix2x2(e,t),!0)},t.prototype.setFloat=function(e,t){return!!e&&(this._native.setFloat(e,t),!0)},t.prototype.setFloat2=function(e,t,i){return!!e&&(this._native.setFloat2(e,t,i),!0)},t.prototype.setFloat3=function(e,t,i,n){return!!e&&(this._native.setFloat3(e,t,i,n),!0)},t.prototype.setFloat4=function(e,t,i,n,r){return!!e&&(this._native.setFloat4(e,t,i,n,r),!0)},t.prototype.setColor3=function(e,t){return!!e&&(this._native.setFloat3(e,t.r,t.g,t.b),!0)},t.prototype.setColor4=function(e,t,i){return!!e&&(this._native.setFloat4(e,t.r,t.g,t.b,i),!0)},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._createTexture=function(){return this._native.createTexture()},t.prototype._deleteTexture=function(e){this._native.deleteTexture(e)},t.prototype.updateDynamicTexture=function(e,i,n,r,o){void 0===r&&(r=!1);this.createTexture("data:my_image_name",!0,n,null,Ke.a.BILINEAR_SAMPLINGMODE,void 0,void 0,"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAYSURBVChTY/z//z8DPsAEpXGC4aCAgQEAGGMDDWwwgqsAAAAASUVORK5CYII=",e,t.TEXTUREFORMAT_RGBA,null,void 0)},t.prototype.createTexture=function(e,t,i,n,r,o,a,s,c,l,u,h,d){var f=this;void 0===r&&(r=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=null);var p="data:"===(e=e||"").substr(0,5),_=p&&-1!==e.indexOf(";base64,"),v=c||new Qe.a(this,Qe.b.Url),b=e;!this._transformTextureUrl||_||c||s||(e=this._transformTextureUrl(e));for(var y=e.lastIndexOf("."),T=u||(y>-1?e.substring(y).toLowerCase():""),E=null,S=0,A=Se.a._TextureLoaders;S<A.length;S++){var P=A[S];if(P.canLoad(T)){E=P;break}}n&&n._addPendingData(v),v.url=e,v.generateMipMaps=!t,v.samplingMode=r,v.invertY=i,this.doNotHandleContextLost||(v._buffer=s);var C=null;o&&!c&&(C=v.onLoadedObservable.add(o)),c||this._internalTexturesCache.push(v);if(E)throw new Error("Loading textures from IInternalTextureLoader not yet implemented.");var R=function(e){var o=v._webGLTexture;o?f._native.loadTexture(o,e,!t,i,(function(){v.baseWidth=f._native.getTextureWidth(o),v.baseHeight=f._native.getTextureHeight(o),v.width=v.baseWidth,v.height=v.baseHeight,v.isReady=!0;var e=f._getNativeSamplingMode(r);f._native.setTextureSampling(o,e),n&&n._removePendingData(v),v.onLoadedObservable.notifyObservers(v),v.onLoadedObservable.clear()}),(function(){throw new Error("Could not load a native texture.")})):n&&n._removePendingData(v)};if(p)if(s instanceof ArrayBuffer)R(new Uint8Array(s));else if(ArrayBuffer.isView(s))R(s);else{if("string"!=typeof s)throw new Error("Unsupported buffer type");R(new Uint8Array(Ce.b.DecodeBase64(s)))}else _?R(new Uint8Array(Ce.b.DecodeBase64(e))):this._loadFile(e,(function(e){return R(new Uint8Array(e))}),void 0,void 0,!0,(function(i,c){!function(i,c){n&&n._removePendingData(v),e===b?(C&&v.onLoadedObservable.remove(C),x.a.UseFallbackTexture&&f.createTexture(x.a.FallbackTexture,t,v.invertY,n,r,null,a,s,v),a&&a((i||"Unknown error")+(x.a.UseFallbackTexture?" - Fallback texture was used":""),c)):(m.a.Warn("Failed to load "+e+", falling back to "+b),f.createTexture(b,t,v.invertY,n,r,o,a,s,v,l,u,h,d))}("Unable to load "+(i&&i.responseURL,c))}));return v},t.prototype._createDepthStencilTexture=function(e,t){var i=new sr(this,Qe.b.Depth),n=e.width||e,r=e.height||e,o=this._native.createDepthTexture(i._webGLTexture,n,r);return i._framebuffer=o,i},t.prototype._releaseFramebufferObjects=function(e){},t.prototype.createCubeTexture=function(e,t,i,n,r,o,a,s,c,l,u,h){var d=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!1),void 0===l&&(l=0),void 0===u&&(u=0),void 0===h&&(h=null);var f=h||new Qe.a(this,Qe.b.Cube);f.isCube=!0,f.url=e,f.generateMipMaps=!n,f._lodGenerationScale=l,f._lodGenerationOffset=u,this._doNotHandleContextLost||(f._extension=s,f._files=i);var p=e.lastIndexOf(".");if(".env"===(s||(p>-1?e.substring(p).toLowerCase():""))){if(i&&6===i.length)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,(function(e){return function(e){var t=ir.GetEnvInfo(e);if(f.width=t.width,f.height=t.width,ir.UploadEnvSpherical(f,t),1!==t.version)throw new Error('Unsupported babylon environment map version "'+t.version+'"');var i=t.specular;if(!i)throw new Error("Nothing else parsed so far");f._lodGenerationScale=i.lodGenerationScale;var n=ir.CreateImageDataArrayBufferViews(e,t);f.format=g.a.TEXTUREFORMAT_RGBA,f.type=g.a.TEXTURETYPE_UNSIGNED_INT,f.generateMipMaps=!0,f.getEngine().updateTextureSamplingMode(Ke.a.TRILINEAR_SAMPLINGMODE,f),f._isRGBD=!0,f.invertY=!0,d._native.loadCubeTextureWithMips(f._webGLTexture,n,(function(){f.isReady=!0,r&&r()}),(function(){throw new Error("Could not load a native cube texture.")}))}(new Uint8Array(e))}),void 0,void 0,!0,(function(e,t){o&&e&&o(e.status+" "+e.statusText,t)}))}else{if(!i||6!==i.length)throw new Error("Cannot load cubemap because 6 files were not defined");var _=[i[0],i[3],i[1],i[4],i[2],i[5]];Promise.all(_.map((function(e){return Ce.b.LoadFileAsync(e).then((function(e){return new Uint8Array(e)}))}))).then((function(e){return new Promise((function(t,i){d._native.loadCubeTexture(f._webGLTexture,e,!n,t,i)}))})).then((function(){f.isReady=!0,r&&r()}),(function(e){o&&o("Failed to load cubemap: "+e.message,e)}))}return this._internalTexturesCache.push(f),f},t.prototype.createRenderTargetTexture=function(e,t){var i=new ci.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?g.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,i.format=void 0===t.format?g.a.TEXTUREFORMAT_RGBA:t.format):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=g.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i.format=g.a.TEXTUREFORMAT_RGBA),(i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==g.a.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE);var n=new sr(this,Qe.b.RenderTarget),r=e.width||e,o=e.height||e;i.type!==g.a.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=g.a.TEXTURETYPE_UNSIGNED_INT,m.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var a=this._native.createFramebuffer(n._webGLTexture,r,o,this._getNativeTextureFormat(i.format,i.type),i.samplingMode,!!i.generateStencilBuffer,i.generateDepthBuffer,!!i.generateMipMaps);return n._framebuffer=a,n.baseWidth=r,n.baseHeight=o,n.width=r,n.height=o,n.isReady=!0,n.samples=1,n.generateMipMaps=!!i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(n),n},t.prototype.updateTextureSamplingMode=function(e,t){if(t._webGLTexture){var i=this._getNativeSamplingMode(e);this._native.setTextureSampling(t._webGLTexture,i)}t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,i,n,r){if(t)throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");if(i||n)throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");e._depthStencilTexture?this._bindUnboundFramebuffer(e._depthStencilTexture._framebuffer):this._bindUnboundFramebuffer(e._framebuffer)},t.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),t&&m.a.Warn("Disabling mipmap generation not yet supported in NativeEngine. Ignoring."),i&&i(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){return this.createVertexBuffer(e,!0)},t.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0);var n=e,r=this._normalizeIndexData(t);n.is32Bits=4===r.BYTES_PER_ELEMENT,this._native.updateDynamicIndexBuffer(n.nativeIndexBuffer,r,i)},t.prototype.updateDynamicVertexBuffer=function(e,t,i,n){var r=e,o=ArrayBuffer.isView(t)?t:new Float32Array(t);this._native.updateDynamicVertexBuffer(r.nativeVertexBuffer,o,null!=i?i:0,null!=n?n:o.byteLength)},t.prototype._setTexture=function(e,t,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1);var r,o=this._boundUniforms[e];if(!o)return!1;if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._native.setTexture(o,null)),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;return r=n?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,this._activeChannel=e,!(!r||!r._webGLTexture)&&(this._native.setTextureWrapMode(r._webGLTexture,this._getAddressMode(t.wrapU),this._getAddressMode(t.wrapV),this._getAddressMode(t.wrapR)),this._updateAnisotropicLevel(t),this._native.setTexture(o,r._webGLTexture),!0)},t.prototype._updateAnisotropicLevel=function(e){var t=e.getInternalTexture(),i=e.anisotropicFilteringLevel;t&&t._webGLTexture&&t._cachedAnisotropicFilteringLevel!==i&&(this._native.setTextureAnisotropicLevel(t._webGLTexture,i),t._cachedAnisotropicFilteringLevel=i)},t.prototype._getAddressMode=function(e){switch(e){case g.a.TEXTURE_WRAP_ADDRESSMODE:return this._native.ADDRESS_MODE_WRAP;case g.a.TEXTURE_CLAMP_ADDRESSMODE:return this._native.ADDRESS_MODE_CLAMP;case g.a.TEXTURE_MIRROR_ADDRESSMODE:return this._native.ADDRESS_MODE_MIRROR;default:throw new Error("Unexpected wrap mode: "+e+".")}},t.prototype._bindTexture=function(e,t){var i=this._boundUniforms[e];i&&this._native.setTexture(i,t._webGLTexture)},t.prototype._deleteBuffer=function(e){e.nativeIndexBuffer&&(this._native.deleteIndexBuffer(e.nativeIndexBuffer),delete e.nativeIndexBuffer),e.nativeVertexBuffer&&(this._native.deleteVertexBuffer(e.nativeVertexBuffer),delete e.nativeVertexBuffer)},t.prototype.releaseEffects=function(){},t.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){throw void 0===o&&(o=0),void 0===a&&(a=0),new Error("_uploadCompressedDataToTextureDirectly not implemented.")},t.prototype._uploadDataToTextureDirectly=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error("_uploadDataToTextureDirectly not implemented.")},t.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._uploadImageToTexture=function(e,t,i,n){throw void 0===i&&(i=0),void 0===n&&(n=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._getNativeSamplingMode=function(e){switch(e){case g.a.TEXTURE_NEAREST_NEAREST:return this._native.TEXTURE_NEAREST_NEAREST;case g.a.TEXTURE_LINEAR_LINEAR:return this._native.TEXTURE_LINEAR_LINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:return this._native.TEXTURE_LINEAR_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:return this._native.TEXTURE_NEAREST_NEAREST_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:return this._native.TEXTURE_NEAREST_LINEAR_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:return this._native.TEXTURE_NEAREST_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_LINEAR:return this._native.TEXTURE_NEAREST_LINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:return this._native.TEXTURE_NEAREST_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:return this._native.TEXTURE_LINEAR_NEAREST_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:return this._native.TEXTURE_LINEAR_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:return this._native.TEXTURE_LINEAR_LINEAR_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST:return this._native.TEXTURE_LINEAR_NEAREST;default:throw new Error("Unsupported sampling mode: "+e+".")}},t.prototype._getNativeTextureFormat=function(e,t){if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_UNSIGNED_INT)return this._native.TEXTURE_FORMAT_RGBA8;if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_FLOAT)return this._native.TEXTURE_FORMAT_RGBA32F;throw new Error("Unsupported texture format or type: format "+e+", type "+t+".")},t.prototype._getNativeAlphaMode=function(e){switch(e){case g.a.ALPHA_DISABLE:return this._native.ALPHA_DISABLE;case g.a.ALPHA_ADD:return this._native.ALPHA_ADD;case g.a.ALPHA_COMBINE:return this._native.ALPHA_COMBINE;case g.a.ALPHA_SUBTRACT:return this._native.ALPHA_SUBTRACT;case g.a.ALPHA_MULTIPLY:return this._native.ALPHA_MULTIPLY;case g.a.ALPHA_MAXIMIZED:return this._native.ALPHA_MAXIMIZED;case g.a.ALPHA_ONEONE:return this._native.ALPHA_ONEONE;case g.a.ALPHA_PREMULTIPLIED:return this._native.ALPHA_PREMULTIPLIED;case g.a.ALPHA_PREMULTIPLIED_PORTERDUFF:return this._native.ALPHA_PREMULTIPLIED_PORTERDUFF;case g.a.ALPHA_INTERPOLATE:return this._native.ALPHA_INTERPOLATE;case g.a.ALPHA_SCREENMODE:return this._native.ALPHA_SCREENMODE;default:throw new Error("Unsupported alpha mode: "+e+".")}},t.prototype._getNativeAttribType=function(e){switch(e){case Qi.b.UNSIGNED_BYTE:return this._native.ATTRIB_TYPE_UINT8;case Qi.b.SHORT:return this._native.ATTRIB_TYPE_INT16;case Qi.b.FLOAT:return this._native.ATTRIB_TYPE_FLOAT;default:throw new Error("Unsupported attribute type: "+e+".")}},t}(Se.a),lr=i(74),ur=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),hr=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return ur.COPY;case 86:return ur.PASTE;case 88:return ur.CUT;default:return-1}},e}(),dr=i(83),fr=i(69);!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(nr||(nr={}));var pr=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return fr.a.ForceFullSceneLoadingForIncremental},set:function(e){fr.a.ForceFullSceneLoadingForIncremental=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return fr.a.ShowLoadingScreen},set:function(e){fr.a.ShowLoadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return fr.a.loggingLevel},set:function(e){fr.a.loggingLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return fr.a.CleanBoneMatrixWeights},set:function(e){fr.a.CleanBoneMatrixWeights=e},enumerable:!1,configurable:!0}),e.GetDefaultPlugin=function(){return e._registeredPlugins[".babylon"]},e._GetPluginForExtension=function(t){var i=e._registeredPlugins[t];return i||(m.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: https://doc.babylonjs.com/how_to/load_from_any_file_type"),e.GetDefaultPlugin())},e._GetPluginForDirectLoad=function(t){for(var i in e._registeredPlugins){var n=e._registeredPlugins[i].plugin;if(n.canDirectLoad&&n.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 n=t.lastIndexOf("."),r=t.substring(n,t.length).toLowerCase();return e._GetPluginForExtension(r)},e._GetDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},e._LoadData=function(t,i,n,r,o,a,s){var c,l=e._GetDirectLoad(t.name),u=s?e._GetPluginForExtension(s):l?e._GetPluginForDirectLoad(t.name):e._GetPluginForFilename(t.name);if(!(c=void 0!==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.";if(e.OnPluginActivatedObservable.notifyObservers(c),l){if(c.directLoad){var h=c.directLoad(i,l);h.then?h.then((function(e){n(c,e)})).catch((function(e){o("Error in directLoad of _loadData: "+e,e)})):n(c,h)}else n(c,l);return c}var d=u.isBinary,f=function(e,t){i.isDisposed?o("Scene has been disposed"):n(c,e,t)},p=null,_=!1,m=c.onDisposeObservable;m&&m.add((function(){_=!0,p&&(p.abort(),p=null),a()}));var g=function(){if(!_){var e=function(e,t){f(e,t?t.responseURL:void 0)},n=function(e){o(e.message,e)};p=c.requestFile?c.requestFile(i,t.url,e,r,d,n):i._requestFile(t.url,e,r,!0,d,n)}},v=t.file||dr.a.FilesToLoad[t.name.toLowerCase()];if(-1===t.rootUrl.indexOf("file:")||-1!==t.rootUrl.indexOf("file:")&&!v){var b=i.getEngine(),y=b.enableOfflineSupport;if(y){for(var T=!1,E=0,S=i.disableOfflineSupportExceptionRules;E<S.length;E++){if(S[E].test(t.url)){T=!0;break}}y=!T}y&&Se.a.OfflineProviderFactory?i.offlineProvider=Se.a.OfflineProviderFactory(t.url,g,b.disableManifestCheck):g()}else if(v){var A=function(e){o(e.message,e)};p=c.readFile?c.readFile(i,v,f,r,d,A):i._readFile(v,f,r,d,A)}else o("Unable to find file named "+t.name);return c},e._GetFileInfo=function(e,t){var i,n,r=null;if(t)if(t.name){var o=t;i=e+o.name,n=o.name,r=o}else{var a=t;if("/"===a.substr(0,1))return Ce.b.Error("Wrong sceneFilename parameter"),null;i=e+a,n=a}else i=e,n=Ce.b.GetFilename(e),e=Ce.b.GetFolderPath(e);return{url:i,rootUrl:e,name:n,file:r}},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 n=t.extensions;Object.keys(n).forEach((function(i){e._registeredPlugins[i.toLowerCase()]={plugin:t,isBinary:n[i].isBinary}}))}},e.ImportMesh=function(t,i,n,r,o,a,s,c){if(void 0===n&&(n=""),void 0===r&&(r=x.a.LastCreatedScene),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===c&&(c=null),!r)return m.a.Error("No scene available to import mesh to"),null;var l=e._GetFileInfo(i,n);if(!l)return null;var u={};r._addPendingData(u);var h=function(){r._removePendingData(u)},d=function(e,t){var i="Unable to import meshes from "+l.url+": "+e;s?s(r,i,t):m.a.Error(i),h()},f=a?function(e){try{a(e)}catch(e){d("Error in onProgress callback: "+e,e)}}:void 0,p=function(e,t,i,n,a,s,c){if(r.importedMeshesFiles.push(l.url),o)try{o(e,t,i,n,a,s,c)}catch(e){d("Error in onSuccess callback: "+e,e)}r._removePendingData(u)};return e._LoadData(l,r,(function(e,i,n){if(e.rewriteRootURL&&(l.rootUrl=e.rewriteRootURL(l.rootUrl,n)),e.importMesh){var o=e,a=new Array,s=new Array,c=new Array;if(!o.importMesh(t,r,i,l.rootUrl,a,s,c,d))return;r.loadingPluginName=e.name,p(a,s,c,[],[],[],[])}else{e.importMeshAsync(t,r,i,l.rootUrl,f,l.name).then((function(t){r.loadingPluginName=e.name,p(t.meshes,t.particleSystems,t.skeletons,t.animationGroups,t.transformNodes,t.geometries,t.lights)})).catch((function(e){d(e.message,e)}))}}),f,d,h,c)},e.ImportMeshAsync=function(t,i,n,r,o,a){return void 0===n&&(n=""),void 0===r&&(r=x.a.LastCreatedScene),void 0===o&&(o=null),void 0===a&&(a=null),new Promise((function(s,c){e.ImportMesh(t,i,n,r,(function(e,t,i,n,r,o,a){s({meshes:e,particleSystems:t,skeletons:i,animationGroups:n,transformNodes:r,geometries:o,lights:a})}),o,(function(e,t,i){c(i||new Error(t))}),a)}))},e.Load=function(t,i,n,r,o,a,s){return void 0===i&&(i=""),void 0===n&&(n=x.a.LastCreatedEngine),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),n?e.Append(t,i,new Q.a(n),r,o,a,s):(Ce.b.Error("No engine available"),null)},e.LoadAsync=function(t,i,n,r,o){return void 0===i&&(i=""),void 0===n&&(n=x.a.LastCreatedEngine),void 0===r&&(r=null),void 0===o&&(o=null),new Promise((function(a,s){e.Load(t,i,n,(function(e){a(e)}),r,(function(e,t,i){s(i||new Error(t))}),o)}))},e.Append=function(t,i,n,r,o,a,s){var c=this;if(void 0===i&&(i=""),void 0===n&&(n=x.a.LastCreatedScene),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),!n)return m.a.Error("No scene available to append to"),null;var l=e._GetFileInfo(t,i);if(!l)return null;e.ShowLoadingScreen&&!this._showingLoadingScreen&&(this._showingLoadingScreen=!0,n.getEngine().displayLoadingUI(),n.executeWhenReady((function(){n.getEngine().hideLoadingUI(),c._showingLoadingScreen=!1})));var u={};n._addPendingData(u);var h=function(){n._removePendingData(u)},d=function(e,t){var i="Unable to load from "+l.url+(e?": "+e:"");a?a(n,i,t):m.a.Error(i),h()},f=o?function(e){try{o(e)}catch(e){d("Error in onProgress callback",e)}}:void 0,p=function(){if(r)try{r(n)}catch(e){d("Error in onSuccess callback",e)}n._removePendingData(u)};return e._LoadData(l,n,(function(e,t){if(e.load){if(!e.load(n,t,l.rootUrl,d))return;n.loadingPluginName=e.name,p()}else{e.loadAsync(n,t,l.rootUrl,f,l.name).then((function(){n.loadingPluginName=e.name,p()})).catch((function(e){d(e.message,e)}))}}),f,d,h,s)},e.AppendAsync=function(t,i,n,r,o){return void 0===i&&(i=""),void 0===n&&(n=x.a.LastCreatedScene),void 0===r&&(r=null),void 0===o&&(o=null),new Promise((function(a,s){e.Append(t,i,n,(function(e){a(e)}),r,(function(e,t,i){s(i||new Error(t))}),o)}))},e.LoadAssetContainer=function(t,i,n,r,o,a,s){if(void 0===i&&(i=""),void 0===n&&(n=x.a.LastCreatedScene),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),!n)return m.a.Error("No scene available to load asset container to"),null;var c=e._GetFileInfo(t,i);if(!c)return null;var l={};n._addPendingData(l);var u=function(){n._removePendingData(l)},h=function(e,t){var i="Unable to load assets from "+c.url+(e?": "+e:"");t&&t.message&&(i+=" ("+t.message+")"),a?a(n,i,t):m.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(r)try{r(e)}catch(e){h("Error in onSuccess callback",e)}n._removePendingData(l)};return e._LoadData(c,n,(function(e,t){if(e.loadAssetContainer){var i=e.loadAssetContainer(n,t,c.rootUrl,h);if(!i)return;n.loadingPluginName=e.name,f(i)}else if(e.loadAssetContainerAsync){e.loadAssetContainerAsync(n,t,c.rootUrl,d,c.name).then((function(t){n.loadingPluginName=e.name,f(t)})).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.")}),d,h,u,s)},e.LoadAssetContainerAsync=function(t,i,n,r,o){return void 0===i&&(i=""),void 0===n&&(n=x.a.LastCreatedScene),void 0===r&&(r=null),void 0===o&&(o=null),new Promise((function(a,s){e.LoadAssetContainer(t,i,n,(function(e){a(e)}),r,(function(e,t,i){s(i||new Error(t))}),o)}))},e.ImportAnimations=function(e,t,i,n,r,o,a,s,c,l){if(void 0===t&&(t=""),void 0===i&&(i=x.a.LastCreatedScene),void 0===n&&(n=!0),void 0===r&&(r=nr.Clean),void 0===o&&(o=null),void 0===a&&(a=null),void 0===s&&(s=null),void 0===c&&(c=null),void 0===l&&(l=null),i){if(n){for(var u=0,h=i.animatables;u<h.length;u++){h[u].reset()}i.stopAllAnimations(),i.animationGroups.slice().forEach((function(e){e.dispose()})),i.getNodes().forEach((function(e){e.animations&&(e.animations=[])}))}else switch(r){case nr.Clean:i.animationGroups.slice().forEach((function(e){e.dispose()}));break;case nr.Stop:i.animationGroups.forEach((function(e){e.stop()}));break;case nr.Sync:i.animationGroups.forEach((function(e){e.reset(),e.restart()}));break;case nr.NoSync:break;default:return void m.a.Error("Unknown animation group loading mode value '"+r+"'")}var d=i.animatables.length;this.LoadAssetContainer(e,t,i,(function(e){e.mergeAnimationsTo(i,i.animatables.slice(d),o),e.dispose(),i.onAnimationFileImportedObservable.notifyObservers(i),a&&a(i)}),s,c,l)}else m.a.Error("No scene available to load animations to")},e.ImportAnimationsAsync=function(t,i,n,r,o,a,s,c,l,u){return void 0===i&&(i=""),void 0===n&&(n=x.a.LastCreatedScene),void 0===r&&(r=!0),void 0===o&&(o=nr.Clean),void 0===a&&(a=null),void 0===s&&(s=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=null),new Promise((function(s,l){e.ImportAnimations(t,i,n,r,o,a,(function(e){s(e)}),c,(function(e,t,i){l(i||new Error(t))}),u)}))},e.NO_LOGGING=g.a.SCENELOADER_NO_LOGGING,e.MINIMAL_LOGGING=g.a.SCENELOADER_MINIMAL_LOGGING,e.SUMMARY_LOGGING=g.a.SCENELOADER_SUMMARY_LOGGING,e.DETAILED_LOGGING=g.a.SCENELOADER_DETAILED_LOGGING,e.OnPluginActivatedObservable=new o.c,e._registeredPlugins={},e._showingLoadingScreen=!1,e}(),_r=function(e){function t(t){var i=e.call(this,t)||this;return i.controllerType=Gt.DAYDREAM,i}return Object(h.d)(t,e),t.prototype.initControllerMesh=function(e,i){var n=this;pr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,(function(e){n._defaultModel=e[1],n.attachToMesh(n._defaultModel),i&&i(n._defaultModel)}))},t.prototype._handleButtonChange=function(e,t,i){if(0===e){var n=this.onTriggerStateChangedObservable;n&&n.notifyObservers(t)}else m.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}(Gi);Qt._ControllerFactories.push({canCreate:function(e){return 0===e.id.indexOf(_r.GAMEPAD_ID_PREFIX)},create:function(e){return new _r(e)}});var mr=function(e){function t(t){var i=e.call(this,t)||this;return i._buttonIndexToObservableNameMap=["onPadStateChangedObservable","onTriggerStateChangedObservable"],i.controllerType=Gt.GEAR_VR,i._calculatedPosition=new a.e("left"==i.hand?-.15:.15,-.5,.25),i._disableTrackPosition(i._calculatedPosition),i}return Object(h.d)(t,e),t.prototype.initControllerMesh=function(e,i){var n=this;pr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,(function(t){var r=new be.a("",e);t[1].parent=r,t[1].position.z=-.15,n._defaultModel=r,n.attachToMesh(n._defaultModel),i&&i(n._defaultModel)}))},t.prototype._handleButtonChange=function(e,t,i){if(e<this._buttonIndexToObservableNameMap.length){var n=this[this._buttonIndexToObservableNameMap[e]];n&&n.notifyObservers(t)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t.GAMEPAD_ID_PREFIX="Gear VR",t}(Gi);Qt._ControllerFactories.push({canCreate:function(e){return 0===e.id.indexOf(mr.GAMEPAD_ID_PREFIX)||-1!==e.id.indexOf("Oculus Go")||-1!==e.id.indexOf("Vive Focus")},create:function(e){return new mr(e)}});var gr=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),t.prototype.initControllerMesh=function(e,i){var n=this;pr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,(function(e){n._defaultModel=e[1],n.attachToMesh(n._defaultModel),i&&i(n._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}(Gi);Qt._DefaultControllerFactory=function(e){return new gr(e)};var vr=function(e){function t(t){var i=e.call(this,t)||this;return i.onSecondaryTriggerStateChangedObservable=new o.c,i.onThumbRestChangedObservable=new o.c,i.controllerType=Gt.OCULUS,i}return Object(h.d)(t,e),t.prototype.initControllerMesh=function(e,i){var n,r=this;n="left"===this.hand?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,pr.ImportMesh("",t._IsQuest?t.QUEST_MODEL_BASE_URL:t.MODEL_BASE_URL,n,e,(function(e){r._defaultModel=t._IsQuest?e[0]:e[1],r.attachToMesh(r._defaultModel),i&&i(r._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:!1,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:!1,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:!1,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:!1,configurable:!0}),t.prototype._handleButtonChange=function(e,i,n){var r=i,o="right"===this.hand?-1:1;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(r);case 1:return!t._IsQuest&&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!t._IsQuest&&this._defaultModel&&(this._defaultModel.getChildren()[4].position.x=o*r.value*.0035),void this.onSecondaryTriggerStateChangedObservable.notifyObservers(r);case 3:return!t._IsQuest&&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!t._IsQuest&&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.QUEST_MODEL_BASE_URL="https://controllers.babylonjs.com/oculusQuest/",t._IsQuest=!1,t}(Gi);Qt._ControllerFactories.push({canCreate:function(e){return Se.a.LastCreatedEngine&&Se.a.LastCreatedEngine._vrDisplay&&"Oculus Quest"===Se.a.LastCreatedEngine._vrDisplay.displayName&&(vr._IsQuest=!0),-1!==e.id.indexOf("Oculus Touch")},create:function(e){return new vr(e)}});var br=function(e){function t(t){var i=e.call(this,t)||this;return i.controllerType=Gt.VIVE,i._invertLeftStickY=!0,i}return Object(h.d)(t,e),t.prototype.initControllerMesh=function(e,i){var n=this;pr.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,(function(e){n._defaultModel=e[1],n.attachToMesh(n._defaultModel),i&&i(n._defaultModel)}))},Object.defineProperty(t.prototype,"onLeftButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onRightButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!1,configurable:!0}),t.prototype._handleButtonChange=function(e,t,i){var n=t;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(n);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[6].rotation.x=.15*-n.value),void this.onTriggerStateChangedObservable.notifyObservers(n);case 2:return void this.onMainButtonStateChangedObservable.notifyObservers(n);case 3:return this._defaultModel&&(n.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(n)}},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(Gi);Qt._ControllerFactories.push({canCreate:function(e){return-1!==e.id.toLowerCase().indexOf("openvr")},create:function(e){return new br(e)}});var yr=function(){this.buttonMeshes={},this.axisMeshes={}},Tr=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:qt.POINTING_POSE},i.onTrackpadChangedObservable=new o.c,i.onTrackpadValuesChangedObservable=new o.c,i.trackpad={x:0,y:0},i.controllerType=Gt.WINDOWS,i._loadedMeshInfo=null,i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"onTriggerButtonStateChangedObservable",{get:function(){return this.onTriggerStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onGripButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onThumbstickButtonStateChangedObservable",{get:function(){return this.onPadStateChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTouchpadButtonStateChangedObservable",{get:function(){return this.onTrackpadChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onTouchpadValuesChangedObservable",{get:function(){return this.onTrackpadValuesChangedObservable},enumerable:!1,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[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_X")],this.trackpad.y=this.browserGamepad.axes[this._mapping.axisMeshNames.indexOf("TOUCHPAD_TOUCH_Y")],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 n=this._mapping.buttons[e];if(n){this._updateTrackpad();var r=this[this._mapping.buttonObservableNames[n]];r&&r.notifyObservers(t),this._lerpButtonTransform(n,t.value)}},t.prototype._lerpButtonTransform=function(e,t){if(this._loadedMeshInfo){var i=this._loadedMeshInfo.buttonMeshes[e];i&&i.unpressed.rotationQuaternion&&i.pressed.rotationQuaternion&&i.value.rotationQuaternion&&(a.b.SlerpToRef(i.unpressed.rotationQuaternion,i.pressed.rotationQuaternion,t,i.value.rotationQuaternion),a.e.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 n=.5*t+.5;a.b.SlerpToRef(i.min.rotationQuaternion,i.max.rotationQuaternion,n,i.value.rotationQuaternion),a.e.LerpToRef(i.min.position,i.max.position,n,i.value.position)}}},t.prototype.initControllerMesh=function(e,i,n){var r,o,a=this;if(void 0===n&&(n=!1),pr.IsPluginForExtensionAvailable(".glb")){var s="default";if(this.id&&!n){var c=this.id.match(t.GAMEPAD_ID_PATTERN);s=c&&c[0]||s}o="left"===this.hand?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,r=t.MODEL_BASE_URL+s+"/"}else m.a.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),r=gr.MODEL_BASE_URL,o=gr.MODEL_FILENAME;pr.ImportMesh("",r,o,e,(function(t){a._loadedMeshInfo=a.processModel(e,t),a._loadedMeshInfo&&(a._defaultModel=a._loadedMeshInfo.rootNode,a.attachToMesh(a._defaultModel),i&&i(a._defaultModel))}),null,(function(e,t){m.a.Log(t),m.a.Warn("Failed to retrieve controller model from the remote server: "+r+o),n||a.initControllerMesh(e,i,!0)}))},t.prototype.processModel=function(e,t){for(var i=null,n=new be.a(this.id+" "+this.hand,e),r=null,o=0;o<t.length;o++){var a=t[o];if(!a.parent){a.isPickable=!1,r=a;break}}return r?(r.setParent(n),i=this.createMeshInfo(n)):m.a.Warn("Could not find root node in model file."),i},t.prototype.createMeshInfo=function(e){var t,i=new yr;for(i.rootNode=e,i.buttonMeshes={},i.axisMeshes={},t=0;t<this._mapping.buttons.length;t++){var n=this._mapping.buttonMeshNames[this._mapping.buttons[t]];if(n){var r=l(e,n);if(r){var o={index:t,value:u(r,"VALUE"),pressed:u(r,"PRESSED"),unpressed:u(r,"UNPRESSED")};o.value&&o.pressed&&o.unpressed?i.buttonMeshes[this._mapping.buttons[t]]=o:m.a.Warn("Missing button submesh under mesh with name: "+n+"(VALUE: "+!!o.value+", PRESSED: "+!!o.pressed+", UNPRESSED:"+!!o.unpressed+")")}else m.a.Warn("Missing button mesh with name: "+n)}else m.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 a=this._mapping.axisMeshNames[t];if(a){var s=l(e,a);if(s){var c={index:t,value:u(s,"VALUE"),min:u(s,"MIN"),max:u(s,"MAX")};c.value&&c.min&&c.max?i.axisMeshes[t]=c:m.a.Warn("Missing axis submesh under mesh with name: "+a+"(VALUE: "+!!c.value+", MIN: "+!!c.min+", MAX:"+!!c.max+")")}else m.a.Warn("Missing axis mesh with name: "+a)}else m.a.Log("Skipping unknown axis at index: "+t)}return i.pointingPoseNode=l(e,this._mapping.pointingPoseMeshName),i.pointingPoseNode?this._pointingPoseNode=i.pointingPoseNode:m.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(),n=i.getTranslation(),r=new a.e(0,0,-1),o=a.e.TransformNormal(r,i),s=a.e.Normalize(o);return new Xt.a(n,s,t)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onTrackpadChangedObservable.clear(),this.onTrackpadValuesChangedObservable.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}(Gi),Er=function(e){function t(t){var i=e.call(this,t)||this;return i._mapping={buttons:["trigger","grip","trackpad","thumbstick","menu"],buttonMeshNames:{trigger:"SELECT",menu:"MENU",grip:"GRASP",thumbstick:"THUMBSTICK_PRESS",trackpad:"TOUCHPAD_PRESS"},buttonObservableNames:{trigger:"onTriggerStateChangedObservable",menu:"onSecondaryButtonStateChangedObservable",grip:"onMainButtonStateChangedObservable",thumbstick:"onThumbstickStateChangedObservable",trackpad:"onTrackpadChangedObservable"},axisMeshNames:["TOUCHPAD_TOUCH_X","TOUCHPAD_TOUCH_Y","THUMBSTICK_X","THUMBSTICK_Y"],pointingPoseMeshName:qt.POINTING_POSE},i.thumbstickValues={x:0,y:0},i.onThumbstickStateChangedObservable=new o.c,i.onThumbstickValuesChangedObservable=new o.c,i.onTrackpadChangedObservable=i.onPadStateChangedObservable,i.onTrackpadValuesChangedObservable=i.onPadValuesChangedObservable,i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"onThumbstickButtonStateChangedObservable",{get:function(){return this.onThumbstickStateChangedObservable},enumerable:!1,configurable:!0}),t.prototype._updateTrackpad=function(){!this.browserGamepad.axes||this.browserGamepad.axes[2]==this.thumbstickValues.x&&this.browserGamepad.axes[3]==this.thumbstickValues.y||(this.trackpad.x=this.browserGamepad.axes[2],this.trackpad.y=this.browserGamepad.axes[3],this.onThumbstickValuesChangedObservable.notifyObservers(this.trackpad))},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onThumbstickStateChangedObservable.clear(),this.onThumbstickValuesChangedObservable.clear()},t}(Tr);Qt._ControllerFactories.push({canCreate:function(e){return 0===e.id.indexOf(Tr.GAMEPAD_ID_PREFIX)},create:function(e){return new Tr(e)}});var Sr=i(75),Ar=i(63),Pr=i(51),Cr=i(36),Rr=function(e){function t(t,i,n,r,c){var l,u,h,d,f,p,_;void 0===i&&(i=s.a.Gray()),void 0===n&&(n=Cr.a.DefaultUtilityLayer),void 0===r&&(r=null),void 0===c&&(c=1);var m=e.call(this,n)||this;m._pointerObserver=null,m.snapDistance=0,m.onSnapObservable=new o.c,m.uniformScaling=!1,m.sensitivity=1,m._isEnabled=!0,m._parent=null,m._dragging=!1,m._tmpVector=new a.e,m._tmpMatrix=new a.a,m._tmpMatrix2=new a.a,m._parent=r,m._coloredMaterial=new Wi.a("",n.utilityLayerScene),m._coloredMaterial.diffuseColor=i,m._coloredMaterial.specularColor=i.subtract(new s.a(.1,.1,.1)),m._hoverMaterial=new Wi.a("",n.utilityLayerScene),m._hoverMaterial.diffuseColor=s.a.Yellow(),m._disableMaterial=new Wi.a("",n.utilityLayerScene),m._disableMaterial.diffuseColor=s.a.Gray(),m._disableMaterial.alpha=.4,m._gizmoMesh=new be.a("axis",n.utilityLayerScene);var g=m._createGizmoMesh(m._gizmoMesh,c),v=g.arrowMesh,b=g.arrowTail,y=m._createGizmoMesh(m._gizmoMesh,c+4,!0);m._gizmoMesh.lookAt(m._rootMesh.position.add(t)),m._rootMesh.addChild(m._gizmoMesh),m._gizmoMesh.scaling.scaleInPlace(1/3);var T=v.position.clone(),E=b.position.clone(),S=b.scaling.clone(),A=function(e){var t=e*(3/m._rootMesh.scaling.length())*6;v.position.z+=t/3.5,b.scaling.y+=t,b.position.z=v.position.z/2},P=function(){v.position.set(T.x,T.y,T.z),b.position.set(E.x,E.y,E.z),b.scaling.set(S.x,S.y,S.z),m._dragging=!1};m.dragBehavior=new ke.a({dragAxis:t}),m.dragBehavior.moveAttached=!1,m._rootMesh.addBehavior(m.dragBehavior);var C=0,R=new a.e,x={snapDistance:0};m.dragBehavior.onDragObservable.add((function(e){if(m.attachedNode){var i=m.sensitivity*e.dragDistance*(3*m.scaleRatio/m._rootMesh.scaling.length()),n=!1,r=0;m.uniformScaling?(m.attachedNode.getWorldMatrix().decompose(R),R.normalize(),R.y<0&&R.scaleInPlace(-1)):R.copyFrom(t),0==m.snapDistance?R.scaleToRef(i,R):(C+=i,Math.abs(C)>m.snapDistance?(r=Math.floor(Math.abs(C)/m.snapDistance),C<0&&(r*=-1),C%=m.snapDistance,R.scaleToRef(m.snapDistance*r,R),n=!0):R.scaleInPlace(0)),a.a.ScalingToRef(1+R.x,1+R.y,1+R.z,m._tmpMatrix2),m._tmpMatrix2.multiplyToRef(m.attachedNode.getWorldMatrix(),m._tmpMatrix),m._tmpMatrix.decompose(m._tmpVector);Math.abs(m._tmpVector.x)<1e5&&Math.abs(m._tmpVector.y)<1e5&&Math.abs(m._tmpVector.z)<1e5&&m.attachedNode.getWorldMatrix().copyFrom(m._tmpMatrix),n&&(x.snapDistance=m.snapDistance*r,m.onSnapObservable.notifyObservers(x)),m._matrixChanged()}})),m.dragBehavior.onDragStartObservable.add((function(){m._dragging=!0})),m.dragBehavior.onDragObservable.add((function(e){return A(e.dragDistance)})),m.dragBehavior.onDragEndObservable.add(P),null===(h=null===(u=null===(l=null==r?void 0:r.uniformScaleGizmo)||void 0===l?void 0:l.dragBehavior)||void 0===u?void 0:u.onDragObservable)||void 0===h||h.add((function(e){return A(e.delta.y)})),null===(p=null===(f=null===(d=null==r?void 0:r.uniformScaleGizmo)||void 0===d?void 0:d.dragBehavior)||void 0===f?void 0:f.onDragEndObservable)||void 0===p||p.add(P);var O={gizmoMeshes:[v,b],colliderMeshes:[y.arrowMesh,y.arrowTail],material:m._coloredMaterial,hoverMaterial:m._hoverMaterial,disableMaterial:m._disableMaterial,active:!1};null===(_=m._parent)||void 0===_||_.addToAxisCache(m._gizmoMesh,O),m._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!m._customMeshSet&&(m._isHovered=!(-1==O.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!m._parent)){var i=m._isHovered||m._dragging?m._hoverMaterial:m._coloredMaterial;O.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}}));var M=n._getSharedGizmoLight();return M.includedOnlyMeshes=M.includedOnlyMeshes.concat(m._rootMesh.getChildMeshes()),m}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,i){void 0===i&&(i=!1);var n=Ar.a.CreateBox("yPosMesh",{size:.4*(1+(t-1)/4)},this.gizmoLayer.utilityLayerScene),r=nn.a.CreateCylinder("cylinder",{diameterTop:.005*t,height:.275,diameterBottom:.005*t,tessellation:96},this.gizmoLayer.utilityLayerScene);return n.scaling.scaleInPlace(.1),n.material=this._coloredMaterial,n.rotation.x=Math.PI/2,n.position.z+=.3,r.material=this._coloredMaterial,r.position.z+=.1375,r.rotation.x=Math.PI/2,i&&(n.visibility=0,r.visibility=0),e.addChild(n),e.addChild(r),{arrowMesh:n,arrowTail:r}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh,this.attachedNode=this._parent.attachedNode):(this.attachedMesh=null,this.attachedNode=null)},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t.prototype.setCustomMesh=function(t,i){var n=this;void 0===i&&(i=!1),e.prototype.setCustomMesh.call(this,t),i&&(this._rootMesh.getChildMeshes().forEach((function(e){e.material=n._coloredMaterial,e.color&&(e.color=n._coloredMaterial.diffuseColor)})),this._customMeshSet=!1)},t}(Pr.a),xr=i(45),Or=i(40),Mr=function(e){function t(t,i){void 0===t&&(t=s.a.Gray()),void 0===i&&(i=Cr.a.DefaultKeepDepthUtilityLayer);var n=e.call(this,i)||this;n._boundingDimensions=new a.e(1,1,1),n._renderObserver=null,n._pointerObserver=null,n._scaleDragSpeed=.2,n._tmpQuaternion=new a.b,n._tmpVector=new a.e(0,0,0),n._tmpRotationMatrix=new a.a,n.ignoreChildren=!1,n.includeChildPredicate=null,n.rotationSphereSize=.1,n.scaleBoxSize=.1,n.fixedDragMeshScreenSize=!1,n.fixedDragMeshBoundsSize=!1,n.fixedDragMeshScreenSizeDistanceFactor=10,n.onDragStartObservable=new o.c,n.onScaleBoxDragObservable=new o.c,n.onScaleBoxDragEndObservable=new o.c,n.onRotationSphereDragObservable=new o.c,n.onRotationSphereDragEndObservable=new o.c,n.scalePivot=null,n._existingMeshScale=new a.e,n._dragMesh=null,n.pointerDragBehavior=new ke.a,n.updateScale=!1,n._anchorMesh=new Ge.a("anchor",i.utilityLayerScene),n.coloredMaterial=new Wi.a("",i.utilityLayerScene),n.coloredMaterial.disableLighting=!0,n.hoverColoredMaterial=new Wi.a("",i.utilityLayerScene),n.hoverColoredMaterial.disableLighting=!0,n._lineBoundingBox=new Ge.a("",i.utilityLayerScene),n._lineBoundingBox.rotationQuaternion=new a.b;var r=[];r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,0),new a.e(n._boundingDimensions.x,0,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,0),new a.e(0,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,0),new a.e(0,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,0,0),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,0,0),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,n._boundingDimensions.y,0),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,n._boundingDimensions.y,0),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(0,0,n._boundingDimensions.z),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(0,n._boundingDimensions.y,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,0,n._boundingDimensions.z)]},i.utilityLayerScene)),r.push(Or.a.CreateLines("lines",{points:[new a.e(n._boundingDimensions.x,n._boundingDimensions.y,n._boundingDimensions.z),new a.e(n._boundingDimensions.x,n._boundingDimensions.y,0)]},i.utilityLayerScene)),r.forEach((function(e){e.color=t,e.position.addInPlace(new a.e(-n._boundingDimensions.x/2,-n._boundingDimensions.y/2,-n._boundingDimensions.z/2)),e.isPickable=!1,n._lineBoundingBox.addChild(e)})),n._rootMesh.addChild(n._lineBoundingBox),n.setColor(t),n._rotateSpheresParent=new Ge.a("",i.utilityLayerScene),n._rotateSpheresParent.rotationQuaternion=new a.b;for(var c=function(e){var t=xr.a.CreateSphere("",{diameter:1},i.utilityLayerScene);t.rotationQuaternion=new a.b,t.material=l.coloredMaterial,(f=new ke.a({})).moveAttached=!1,f.updateDragPlane=!1,t.addBehavior(f);var r=new a.e(1,0,0),o=0;f.onDragStartObservable.add((function(){r.copyFrom(t.forward),o=0})),f.onDragObservable.add((function(t){if(n.onRotationSphereDragObservable.notifyObservers({}),n.attachedMesh){var i=n.attachedMesh.parent;if(i&&i.scaling&&i.scaling.isNonUniformWithinEpsilon(.001))return void m.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");We.a._RemoveAndStorePivotPoint(n.attachedMesh);var s=r,c=t.dragPlaneNormal.scale(a.e.Dot(t.dragPlaneNormal,s)),l=s.subtract(c).normalizeToNew(),u=a.e.Dot(l,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());u=u/n._boundingDimensions.length()*n._anchorMesh.scaling.length(),n.attachedMesh.rotationQuaternion||(n.attachedMesh.rotationQuaternion=a.b.RotationYawPitchRoll(n.attachedMesh.rotation.y,n.attachedMesh.rotation.x,n.attachedMesh.rotation.z)),n._anchorMesh.rotationQuaternion||(n._anchorMesh.rotationQuaternion=a.b.RotationYawPitchRoll(n._anchorMesh.rotation.y,n._anchorMesh.rotation.x,n._anchorMesh.rotation.z)),o+=u,Math.abs(o)<=2*Math.PI&&(e>=8?a.b.RotationYawPitchRollToRef(0,0,u,n._tmpQuaternion):e>=4?a.b.RotationYawPitchRollToRef(u,0,0,n._tmpQuaternion):a.b.RotationYawPitchRollToRef(0,u,0,n._tmpQuaternion),n._anchorMesh.addChild(n.attachedMesh),n._anchorMesh.rotationQuaternion.multiplyToRef(n._tmpQuaternion,n._anchorMesh.rotationQuaternion),n._anchorMesh.removeChild(n.attachedMesh),n.attachedMesh.setParent(i)),n.updateBoundingBox(),We.a._RestorePivotPoint(n.attachedMesh)}n._updateDummy()})),f.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({}),n._selectNode(t)})),f.onDragEndObservable.add((function(){n.onRotationSphereDragEndObservable.notifyObservers({}),n._selectNode(null),n._updateDummy()})),l._rotateSpheresParent.addChild(t)},l=this,u=0;u<12;u++)c(u);n._rootMesh.addChild(n._rotateSpheresParent),n._scaleBoxesParent=new Ge.a("",i.utilityLayerScene),n._scaleBoxesParent.rotationQuaternion=new a.b;for(var h=0;h<3;h++)for(var d=0;d<3;d++)for(var f,p=function(){var e=(1===h?1:0)+(1===d?1:0)+(1===g?1:0);if(1===e||3===e)return"continue";var t=Ar.a.CreateBox("",{size:1},i.utilityLayerScene);t.material=_.coloredMaterial,t.metadata=2===e;var r=new a.e(h-1,d-1,g-1).normalize();(f=new ke.a({dragAxis:r})).updateDragPlane=!1,f.moveAttached=!1,t.addBehavior(f),f.onDragObservable.add((function(i){if(n.onScaleBoxDragObservable.notifyObservers({}),n.attachedMesh){var o=n.attachedMesh.parent;if(o&&o.scaling&&o.scaling.isNonUniformWithinEpsilon(.001))return void m.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");We.a._RemoveAndStorePivotPoint(n.attachedMesh);var s=i.dragDistance/n._boundingDimensions.length()*n._anchorMesh.scaling.length(),c=new a.e(s,s,s);2===e&&(c.x*=Math.abs(r.x),c.y*=Math.abs(r.y),c.z*=Math.abs(r.z)),c.scaleInPlace(n._scaleDragSpeed),n.updateBoundingBox(),n.scalePivot?(n.attachedMesh.getWorldMatrix().getRotationMatrixToRef(n._tmpRotationMatrix),n._boundingDimensions.scaleToRef(.5,n._tmpVector),a.e.TransformCoordinatesToRef(n._tmpVector,n._tmpRotationMatrix,n._tmpVector),n._anchorMesh.position.subtractInPlace(n._tmpVector),n._boundingDimensions.multiplyToRef(n.scalePivot,n._tmpVector),a.e.TransformCoordinatesToRef(n._tmpVector,n._tmpRotationMatrix,n._tmpVector),n._anchorMesh.position.addInPlace(n._tmpVector)):(t.absolutePosition.subtractToRef(n._anchorMesh.position,n._tmpVector),n._anchorMesh.position.subtractInPlace(n._tmpVector)),n._anchorMesh.addChild(n.attachedMesh),n._anchorMesh.scaling.addInPlace(c),(n._anchorMesh.scaling.x<0||n._anchorMesh.scaling.y<0||n._anchorMesh.scaling.z<0)&&n._anchorMesh.scaling.subtractInPlace(c),n._anchorMesh.removeChild(n.attachedMesh),n.attachedMesh.setParent(o),We.a._RestorePivotPoint(n.attachedMesh)}n._updateDummy()})),f.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({}),n._selectNode(t)})),f.onDragEndObservable.add((function(){n.onScaleBoxDragEndObservable.notifyObservers({}),n._selectNode(null),n._updateDummy()})),_._scaleBoxesParent.addChild(t)},_=this,g=0;g<3;g++)p();n._rootMesh.addChild(n._scaleBoxesParent);var v=new Array;return n._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){v[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=v[e.event.pointerId]&&(v[e.event.pointerId].material=n.coloredMaterial,delete v[e.event.pointerId]):n._rotateSpheresParent.getChildMeshes().concat(n._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(v[e.event.pointerId]=t,t.material=n.hoverColoredMaterial)}))})),n._renderObserver=n.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){n.attachedMesh&&!n._existingMeshScale.equals(n.attachedMesh.scaling)?n.updateBoundingBox():(n.fixedDragMeshScreenSize||n.fixedDragMeshBoundsSize)&&(n._updateRotationSpheres(),n._updateScaleBoxes()),n._dragMesh&&n.attachedMesh&&n.pointerDragBehavior.dragging&&(n._lineBoundingBox.position.rotateByQuaternionToRef(n._rootMesh.rotationQuaternion,n._tmpVector),n.attachedMesh.setAbsolutePosition(n._dragMesh.position.add(n._tmpVector.scale(-1))))})),n.updateBoundingBox(),n}return Object(h.d)(t,e),t.prototype.setColor=function(e){this.coloredMaterial.emissiveColor=e,this.hoverColoredMaterial.emissiveColor=e.clone().add(new s.a(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach((function(t){t.color&&(t.color=e)}))},t.prototype._attachedNodeChanged=function(e){var t=this;if(e){We.a._RemoveAndStorePivotPoint(e);var i=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(i),We.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){We.a._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null);var t=null;this.attachedMesh.skeleton&&(t=this.attachedMesh.skeleton.overrideMesh,this.attachedMesh.skeleton.overrideMesh=null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=a.b.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=a.b.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 i=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);i.max.subtractToRef(i.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((i.max.x+i.min.x)/2,(i.max.y+i.min.y)/2,(i.max.z+i.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.attachedMesh.skeleton&&(this.attachedMesh.skeleton.overrideMesh=t)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),We.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 n=0;n<2;n++){var r=4*t+2*i+n;if(0==t&&(e[r].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*i,this._boundingDimensions.z*n),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Right()).normalizeToNew().add(e[r].position))),1==t&&(e[r].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y/2,this._boundingDimensions.z*n),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Up()).normalizeToNew().add(e[r].position))),2==t&&(e[r].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y*n,this._boundingDimensions.z/2),e[r].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(a.e.Cross(e[r].position.normalizeToNew(),a.e.Forward()).normalizeToNew().add(e[r].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var o=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[r].scaling.set(o,o,o)}else this.fixedDragMeshBoundsSize?e[r].scaling.set(this.rotationSphereSize*this._boundingDimensions.x,this.rotationSphereSize*this._boundingDimensions.y,this.rotationSphereSize*this._boundingDimensions.z):e[r].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0,i=0;i<3;i++)for(var n=0;n<3;n++)for(var r=0;r<3;r++){var o=(1===i?1:0)+(1===n?1:0)+(1===r?1:0);if(1!==o&&3!==o){if(e[t])if(e[t].position.set(this._boundingDimensions.x*(i/2),this._boundingDimensions.y*(n/2),this._boundingDimensions.z*(r/2)),e[t].position.addInPlace(new a.e(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[t].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var s=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[t].scaling.set(s,s,s)}else this.fixedDragMeshBoundsSize?e[t].scaling.set(this.scaleBoxSize*this._boundingDimensions.x,this.scaleBoxSize*this._boundingDimensions.y,this.scaleBoxSize*this._boundingDimensions.z):e[t].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize);t++}}},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,t){void 0===t&&(t=!1),this._scaleBoxesParent.getChildMeshes().forEach((function(i,n){var r=e;t&&!0===i.metadata&&(r=!1),i.setEnabled(r)}))},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=be.a.CreateBox("dummy",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new a.b,this.pointerDragBehavior.useObjectOrientationForDragging=!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=a.b.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var i=e.position.clone(),n=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var r=Ar.a.CreateBox("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,r.scaling),0===r.scaling.y&&(r.scaling.y=Nt.a),0===r.scaling.x&&(r.scaling.x=Nt.a),0===r.scaling.z&&(r.scaling.z=Nt.a),r.position.set((o.max.x+o.min.x)/2,(o.max.y+o.min.y)/2,(o.max.z+o.min.z)/2),e.addChild(r),e.rotationQuaternion.copyFrom(n),e.position.copyFrom(i),e.removeChild(r),r.addChild(e),r.visibility=0,r},t.prototype.setCustomMesh=function(e){m.a.Error("Custom meshes are not supported on this gizmo")},t}(Pr.a),Ir=function(e){function t(t,i,n,r,c,l,u){var h;void 0===i&&(i=s.a.Gray()),void 0===n&&(n=Cr.a.DefaultUtilityLayer),void 0===r&&(r=32),void 0===c&&(c=null),void 0===l&&(l=!1),void 0===u&&(u=1);var d=e.call(this,n)||this;d._pointerObserver=null,d.snapDistance=0,d.onSnapObservable=new o.c,d._isEnabled=!0,d._parent=null,d._dragging=!1,d._parent=c,d._coloredMaterial=new Wi.a("",n.utilityLayerScene),d._coloredMaterial.diffuseColor=i,d._coloredMaterial.specularColor=i.subtract(new s.a(.1,.1,.1)),d._hoverMaterial=new Wi.a("",n.utilityLayerScene),d._hoverMaterial.diffuseColor=s.a.Yellow(),d._disableMaterial=new Wi.a("",n.utilityLayerScene),d._disableMaterial.diffuseColor=s.a.Gray(),d._disableMaterial.alpha=.4,d._gizmoMesh=new be.a("",n.utilityLayerScene);var f=d._createGizmoMesh(d._gizmoMesh,u,r),p=f.rotationMesh,_=f.collider,m=[];d._rotationCircle=d.setupRotationCircle(m,d._gizmoMesh),d._gizmoMesh.lookAt(d._rootMesh.position.add(t)),d._rootMesh.addChild(d._gizmoMesh),d._gizmoMesh.scaling.scaleInPlace(1/3),d.dragBehavior=new ke.a({dragPlaneNormal:t}),d.dragBehavior.moveAttached=!1,d.dragBehavior.maxDragAngle=9*Math.PI/20,d.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,d._rootMesh.addBehavior(d.dragBehavior);var g=0,v=new a.e,b=new a.e,y=new a.a,T=new a.e,E=new a.e;d.dragBehavior.onDragStartObservable.add((function(e){if(d.attachedNode){v.copyFrom(e.dragPlanePoint);var t=new a.e(0,0,1),i=d._rotationCircle.getDirection(t);i.normalize(),d._gizmoMesh.removeChild(d._rotationCircle),v.copyFrom(e.dragPlanePoint),b=e.dragPlanePoint;var n=d._rotationCircle.getAbsolutePosition().clone(),r=d._rotationCircle.getAbsolutePosition().clone().addInPlace(i),o=e.dragPlanePoint,s=a.e.GetAngleBetweenVectors(r.subtract(n),o.subtract(n),d._rotationCircle.up);d._rotationCircle.addRotation(0,s,0),d._dragging=!0}})),d.dragBehavior.onDragEndObservable.add((function(){g=0,d.updateRotationCircle(d._rotationCircle,m,g,b),d._gizmoMesh.addChild(d._rotationCircle),d._dragging=!1}));var S={snapDistance:0},A=0,P=new a.a,C=new a.b;d.dragBehavior.onDragObservable.add((function(e){if(d.attachedNode){var i=new a.e(1,1,1),r=new a.b(0,0,0,1),o=new a.e(0,0,0);d.attachedNode.getWorldMatrix().decompose(i,r,o);var s=e.dragPlanePoint.subtract(o).normalize(),c=v.subtract(o).normalize(),l=a.e.Cross(s,c),u=a.e.Dot(s,c),h=Math.atan2(l.length(),u);T.copyFrom(t),E.copyFrom(t),d.updateGizmoRotationToMatchAttachedMesh&&(r.toRotationMatrix(y),E=a.e.TransformCoordinates(T,y));var f=!1;if(n.utilityLayerScene.activeCamera){var p=n.utilityLayerScene.activeCamera.position.subtract(o);a.e.Dot(p,E)>0&&(T.scaleInPlace(-1),E.scaleInPlace(-1),f=!0)}a.e.Dot(E,l)>0&&(h=-h);var _=!1;if(0!=d.snapDistance)if(A+=h,Math.abs(A)>d.snapDistance){var R=Math.floor(Math.abs(A)/d.snapDistance);A<0&&(R*=-1),A%=d.snapDistance,h=d.snapDistance*R,_=!0}else h=0;g+=f?-h:h,d.updateRotationCircle(d._rotationCircle,m,g,b);var x=Math.sin(h/2);if(C.set(T.x*x,T.y*x,T.z*x,Math.cos(h/2)),P.determinant()>0){var O=new a.e;C.toEulerAnglesToRef(O),a.b.RotationYawPitchRollToRef(O.y,-O.x,-O.z,C)}d.updateGizmoRotationToMatchAttachedMesh?r.multiplyToRef(C,r):C.multiplyToRef(r,r),d.attachedNode.getWorldMatrix().copyFrom(a.a.Compose(i,r,o)),v.copyFrom(e.dragPlanePoint),_&&(S.snapDistance=h,d.onSnapObservable.notifyObservers(S)),d._matrixChanged()}}));var R=n._getSharedGizmoLight();R.includedOnlyMeshes=R.includedOnlyMeshes.concat(d._rootMesh.getChildMeshes(!1));var x={colliderMeshes:[_],gizmoMeshes:[p],material:d._coloredMaterial,hoverMaterial:d._hoverMaterial,disableMaterial:d._disableMaterial,active:!1};return null===(h=d._parent)||void 0===h||h.addToAxisCache(d._gizmoMesh,x),d._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!d._customMeshSet&&(d._isHovered=!(-1==x.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!d._parent)){var i=d._isHovered||d._dragging?d._hoverMaterial:d._coloredMaterial;x.gizmoMeshes.forEach((function(e){e.material=i,e.color&&(e.color=i.diffuseColor)}))}})),d}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,i){var n=be.a.CreateTorus("ignore",.6,.03*t,i,this.gizmoLayer.utilityLayerScene);n.visibility=0;var r=be.a.CreateTorus("",.6,.005*t,i,this.gizmoLayer.utilityLayerScene);return r.material=this._coloredMaterial,r.rotation.x=Math.PI/2,n.rotation.x=Math.PI/2,e.addChild(r),e.addChild(n),{rotationMesh:r,collider:n}},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.setupRotationCircle=function(e,i){for(var n=t._CircleConstants.pi2/t._CircleConstants.tessellation,r=-Math.PI/2;r<Math.PI/2-1.5;r+=n/2){for(var o=[],c=0;c<t._CircleConstants.pi2*t._CircleConstants.rotationCircleRange+.01;c+=n)if(c<0){var l=t._CircleConstants.radius*Math.sin(c)*Math.cos(r),u=t._CircleConstants.radius*Math.cos(c)*Math.cos(r);o.push(new a.e(l,0,u))}else o.push(new a.e(0,0,0));e.push(o)}var h=new Wi.a("",this.gizmoLayer.utilityLayerScene);h.diffuseColor=s.a.Yellow(),h.backFaceCulling=!1;var d=be.a.CreateRibbon("rotationCircle",e,!1,!1,0,this.gizmoLayer.utilityLayerScene,!0);return d.material=h,d.material.alpha=.25,d.rotation.x=Math.PI/2,i.addChild(d),d},t.prototype.updateRotationPath=function(e,i){for(var n=t._CircleConstants.pi2/t._CircleConstants.tessellation,r=0,o=-Math.PI/2;o<Math.PI/2-1.5;o+=n/2){var a=e[r];if(a)for(var s=0,c=0;c<t._CircleConstants.pi2*t._CircleConstants.rotationCircleRange+.01;c+=n){if(a[s])if(c<Math.abs(i)){var l=i>0?c:-1*c,u=i>0?o:-1*o;a[s].set(t._CircleConstants.radius*Math.sin(l)*Math.cos(u),0,t._CircleConstants.radius*Math.cos(l)*Math.cos(u))}else a[s].set(0,0,0);s++}r++}},t.prototype.updateRotationCircle=function(e,t,i,n){this.updateRotationPath(t,i),be.a.CreateRibbon("rotationCircle",t,!1,!1,0,this.gizmoLayer.utilityLayerScene,void 0,void 0,e.geometry?e:void 0)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedMesh=this._parent.attachedMesh):this.attachedMesh=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),this._gizmoMesh&&this._gizmoMesh.dispose(),this._rotationCircle&&this._rotationCircle.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t._CircleConstants={radius:.3,pi2:2*Math.PI,tessellation:70,rotationCircleRange:4},t}(Pr.a),Dr=function(e){function t(t,i,n,r,c){void 0===t&&(t=Cr.a.DefaultUtilityLayer),void 0===i&&(i=32),void 0===n&&(n=!1),void 0===r&&(r=1);var l=e.call(this,t)||this;return l.onDragStartObservable=new o.c,l.onDragEndObservable=new o.c,l._observables=[],l._gizmoAxisCache=new Map,l.xGizmo=new Ir(new a.e(1,0,0),s.a.Red().scale(.5),t,i,l,n,r),l.yGizmo=new Ir(new a.e(0,1,0),s.a.Green().scale(.5),t,i,l,n,r),l.zGizmo=new Ir(new a.e(0,0,1),s.a.Blue().scale(.5),t,i,l,n,r),[l.xGizmo,l.yGizmo,l.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){l.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){l.onDragEndObservable.notifyObservers({})}))})),l.attachedMesh=null,l.attachedNode=null,c?c.addToAxisCache(l._gizmoAxisCache):Pr.a.GizmoAxisPointerObserver(t,l._gizmoAxisCache),l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,this._checkBillboardTransform(),[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),t.prototype._checkBillboardTransform=function(){this._nodeAttached&&this._nodeAttached.billboardMode&&console.log("Rotation Gizmo will not work with transforms in billboard mode.")},Object.defineProperty(t.prototype,"isHovered",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,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:!1,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:!1,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:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.dispose=function(){var e=this;this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear(),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)}))},t.prototype.setCustomMesh=function(e){m.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}(Pr.a),Nr=i(46),Lr=i(84),wr=function(e){function t(i,n,r,c){var l;void 0===n&&(n=s.a.Gray()),void 0===r&&(r=Cr.a.DefaultUtilityLayer),void 0===c&&(c=null);var u=e.call(this,r)||this;u._pointerObserver=null,u.snapDistance=0,u.onSnapObservable=new o.c,u._isEnabled=!1,u._parent=null,u._dragging=!1,u._parent=c,u._coloredMaterial=new Wi.a("",r.utilityLayerScene),u._coloredMaterial.diffuseColor=n,u._coloredMaterial.specularColor=n.subtract(new s.a(.1,.1,.1)),u._hoverMaterial=new Wi.a("",r.utilityLayerScene),u._hoverMaterial.diffuseColor=s.a.Yellow(),u._disableMaterial=new Wi.a("",r.utilityLayerScene),u._disableMaterial.diffuseColor=s.a.Gray(),u._disableMaterial.alpha=.4,u._gizmoMesh=t._CreatePlane(r.utilityLayerScene,u._coloredMaterial),u._gizmoMesh.lookAt(u._rootMesh.position.add(i)),u._gizmoMesh.scaling.scaleInPlace(1/3),u._gizmoMesh.parent=u._rootMesh;var h=0,d=new a.e,f={snapDistance:0};u.dragBehavior=new ke.a({dragPlaneNormal:i}),u.dragBehavior.moveAttached=!1,u._rootMesh.addBehavior(u.dragBehavior),u.dragBehavior.onDragObservable.add((function(e){if(u.attachedNode){if(0==u.snapDistance)u.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z);else if(h+=e.dragDistance,Math.abs(h)>u.snapDistance){var t=Math.floor(Math.abs(h)/u.snapDistance);h%=u.snapDistance,e.delta.normalizeToRef(d),d.scaleInPlace(u.snapDistance*t),u.attachedNode.getWorldMatrix().addTranslationFromFloats(d.x,d.y,d.z),f.snapDistance=u.snapDistance*t,u.onSnapObservable.notifyObservers(f)}u._matrixChanged()}})),u.dragBehavior.onDragStartObservable.add((function(){u._dragging=!0})),u.dragBehavior.onDragEndObservable.add((function(){u._dragging=!1}));var p=r._getSharedGizmoLight();p.includedOnlyMeshes=p.includedOnlyMeshes.concat(u._rootMesh.getChildMeshes(!1));var _={gizmoMeshes:u._gizmoMesh.getChildMeshes(),colliderMeshes:u._gizmoMesh.getChildMeshes(),material:u._coloredMaterial,hoverMaterial:u._hoverMaterial,disableMaterial:u._disableMaterial,active:!1};return null===(l=u._parent)||void 0===l||l.addToAxisCache(u._gizmoMesh,_),u._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!u._customMeshSet&&(u._isHovered=!(-1==_.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!u._parent)){var i=u._isHovered||u._dragging?u._hoverMaterial:u._coloredMaterial;_.gizmoMeshes.forEach((function(e){e.material=i}))}})),u}return Object(h.d)(t,e),t._CreatePlane=function(e,t){var i=new Nr.a("plane",e),n=Lr.a.CreatePlane("dragPlane",{width:.1375,height:.1375,sideOrientation:2},e);return n.material=t,n.parent=i,i},t.prototype._attachedNodeChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e,e?this._parent&&(this.attachedNode=this._parent.attachedNode):this.attachedNode=null},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this),this._gizmoMesh&&this._gizmoMesh.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()}))},t}(Pr.a),Fr=function(e){function t(t,i,n){void 0===t&&(t=Cr.a.DefaultUtilityLayer),void 0===i&&(i=1);var r=e.call(this,t)||this;return r._meshAttached=null,r._nodeAttached=null,r._observables=[],r._gizmoAxisCache=new Map,r.onDragStartObservable=new o.c,r.onDragEndObservable=new o.c,r._planarGizmoEnabled=!1,r.xGizmo=new Sr.a(new a.e(1,0,0),s.a.Red().scale(.5),t,r,i),r.yGizmo=new Sr.a(new a.e(0,1,0),s.a.Green().scale(.5),t,r,i),r.zGizmo=new Sr.a(new a.e(0,0,1),s.a.Blue().scale(.5),t,r,i),r.xPlaneGizmo=new wr(new a.e(1,0,0),s.a.Red().scale(.5),r.gizmoLayer,r),r.yPlaneGizmo=new wr(new a.e(0,1,0),s.a.Green().scale(.5),r.gizmoLayer,r),r.zPlaneGizmo=new wr(new a.e(0,0,1),s.a.Blue().scale(.5),r.gizmoLayer,r),[r.xGizmo,r.yGizmo,r.zGizmo,r.xPlaneGizmo,r.yPlaneGizmo,r.zPlaneGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){r.onDragEndObservable.notifyObservers({})}))})),r.attachedMesh=null,n?n.addToAxisCache(r._gizmoAxisCache):Pr.a.GizmoAxisPointerObserver(t,r._gizmoAxisCache),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=null,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"planarGizmoEnabled",{get:function(){return this._planarGizmoEnabled},set:function(e){var t=this;this._planarGizmoEnabled=e,[this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(i){i&&(i.isEnabled=e,e&&(i.attachedMesh?i.attachedMesh=t.attachedMesh:i.attachedNode=t.attachedNode))}),this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.updateGizmoRotationToMatchAttachedMesh=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.snapDistance=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(t){t&&(t.scaleRatio=e)}))},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.xPlaneGizmo,this.yPlaneGizmo,this.zPlaneGizmo].forEach((function(e){e&&e.dispose()})),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)})),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){m.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,gizmo.xPlaneGizmo, gizmo.yPlaneGizmo, gizmo.zPlaneGizmo)")},t}(Pr.a);Ki.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,n,r,o,c,l,u=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,h=e.size,d=e.sizeX||h||1,f=e.sizeY||h||1,p=e.sizeZ||h||1,_=e.custom||t[u],m=_.face.length,g=e.faceUV||new Array(m),v=e.faceColors,b=void 0===e.flat||e.flat,y=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE,T=new Array,E=new Array,S=new Array,A=new Array,P=new Array,C=0,R=0,x=new Array,O=0,M=0;if(b)for(M=0;M<m;M++)v&&void 0===v[M]&&(v[M]=new s.b(1,1,1,1)),g&&void 0===g[M]&&(g[M]=new a.f(0,0,1,1));if(b)for(M=0;M<m;M++){var I=_.face[M].length;for(r=2*Math.PI/I,o=.5*Math.tan(r/2),c=.5,O=0;O<I;O++)T.push(_.vertex[_.face[M][O]][0]*d,_.vertex[_.face[M][O]][1]*f,_.vertex[_.face[M][O]][2]*p),x.push(C),C++,i=g[M].x+(g[M].z-g[M].x)*(.5+o),n=g[M].y+(g[M].w-g[M].y)*(c-.5),A.push(i,n),l=o*Math.cos(r)-c*Math.sin(r),c=o*Math.sin(r)+c*Math.cos(r),o=l,v&&P.push(v[M].r,v[M].g,v[M].b,v[M].a);for(O=0;O<I-2;O++)E.push(x[0+R],x[O+2+R],x[O+1+R]);R+=I}else{for(O=0;O<_.vertex.length;O++)T.push(_.vertex[O][0]*d,_.vertex[O][1]*f,_.vertex[O][2]*p),A.push(0,0);for(M=0;M<m;M++)for(O=0;O<_.face[M].length-2;O++)E.push(_.face[M][0],_.face[M][O+2],_.face[M][O+1])}Ki.a.ComputeNormals(T,E,S),Ki.a._ComputeSides(y,T,E,S,A,e.frontUVs,e.backUVs);var D=new Ki.a;return D.positions=T,D.indices=E,D.normals=S,D.uvs=A,v&&b&&(D.colors=P),D},be.a.CreatePolyhedron=function(e,t,i){return Br.CreatePolyhedron(e,t,i)};var Br=function(){function e(){}return e.CreatePolyhedron=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreatePolyhedron(t).applyToMesh(n,t.updatable),n},e}(),Ur=function(e){function t(t,i,n){void 0===t&&(t=Cr.a.DefaultUtilityLayer),void 0===i&&(i=1);var r=e.call(this,t)||this;return r._meshAttached=null,r._nodeAttached=null,r._sensitivity=1,r._observables=[],r._gizmoAxisCache=new Map,r.onDragStartObservable=new o.c,r.onDragEndObservable=new o.c,r.uniformScaleGizmo=r._createUniformScaleMesh(),r.xGizmo=new Rr(new a.e(1,0,0),s.a.Red().scale(.5),t,r,i),r.yGizmo=new Rr(new a.e(0,1,0),s.a.Green().scale(.5),t,r,i),r.zGizmo=new Rr(new a.e(0,0,1),s.a.Blue().scale(.5),t,r,i),[r.xGizmo,r.yGizmo,r.zGizmo,r.uniformScaleGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){r.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){r.onDragEndObservable.notifyObservers({})}))})),r.attachedMesh=null,r.attachedNode=null,n?n.addToAxisCache(r._gizmoAxisCache):Pr.a.GizmoAxisPointerObserver(t,r._gizmoAxisCache),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this._meshAttached},set:function(e){this._meshAttached=e,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t.isEnabled?t.attachedMesh=e:t.attachedMesh=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"attachedNode",{get:function(){return this._nodeAttached},set:function(e){this._meshAttached=null,this._nodeAttached=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t.isEnabled?t.attachedNode=e:t.attachedNode=null}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isHovered",{get:function(){var e=!1;return[this.xGizmo,this.yGizmo,this.zGizmo].forEach((function(t){e=e||t.isHovered})),e},enumerable:!1,configurable:!0}),t.prototype._createUniformScaleMesh=function(){this._coloredMaterial=new Wi.a("",this.gizmoLayer.utilityLayerScene),this._coloredMaterial.diffuseColor=s.a.Gray(),this._hoverMaterial=new Wi.a("",this.gizmoLayer.utilityLayerScene),this._hoverMaterial.diffuseColor=s.a.Yellow(),this._disableMaterial=new Wi.a("",this.gizmoLayer.utilityLayerScene),this._disableMaterial.diffuseColor=s.a.Gray(),this._disableMaterial.alpha=.4;var e=new Rr(new a.e(0,1,0),s.a.Gray().scale(.5),this.gizmoLayer,this);e.updateGizmoRotationToMatchAttachedMesh=!1,e.uniformScaling=!0,this._uniformScalingMesh=Br.CreatePolyhedron("uniform",{type:1},e.gizmoLayer.utilityLayerScene),this._uniformScalingMesh.scaling.scaleInPlace(.01),this._uniformScalingMesh.visibility=0,this._octahedron=Br.CreatePolyhedron("",{type:1},e.gizmoLayer.utilityLayerScene),this._octahedron.scaling.scaleInPlace(.007),this._uniformScalingMesh.addChild(this._octahedron),e.setCustomMesh(this._uniformScalingMesh,!0);var t=this.gizmoLayer._getSharedGizmoLight();t.includedOnlyMeshes=t.includedOnlyMeshes.concat(this._octahedron);var i={gizmoMeshes:[this._octahedron,this._uniformScalingMesh],colliderMeshes:[this._uniformScalingMesh],material:this._coloredMaterial,hoverMaterial:this._hoverMaterial,disableMaterial:this._disableMaterial,active:!1};return this.addToAxisCache(e._rootMesh,i),e},Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this._updateGizmoRotationToMatchAttachedMesh},set:function(e){e?(this._updateGizmoRotationToMatchAttachedMesh=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.updateGizmoRotationToMatchAttachedMesh=e)}))):m.a.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.")},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this._snapDistance},set:function(e){this._snapDistance=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.snapDistance=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this._scaleRatio},set:function(e){this._scaleRatio=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.scaleRatio=e)}))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sensitivity",{get:function(){return this._sensitivity},set:function(e){this._sensitivity=e,[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(t){t&&(t.sensitivity=e)}))},enumerable:!1,configurable:!0}),t.prototype.addToAxisCache=function(e,t){this._gizmoAxisCache.set(e,t)},t.prototype.dispose=function(){var e=this;[this.xGizmo,this.yGizmo,this.zGizmo,this.uniformScaleGizmo].forEach((function(e){e&&e.dispose()})),this._observables.forEach((function(t){e.gizmoLayer.utilityLayerScene.onPointerObservable.remove(t)})),this.onDragStartObservable.clear(),this.onDragEndObservable.clear(),[this._uniformScalingMesh,this._octahedron].forEach((function(e){e&&e.dispose()})),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()}))},t}(Pr.a),Vr=function(){function e(e,t,i,n){void 0===t&&(t=1),void 0===i&&(i=Cr.a.DefaultUtilityLayer),void 0===n&&(n=Cr.a.DefaultKeepDepthUtilityLayer),this.scene=e,this.clearGizmoOnEmptyPointerEvent=!1,this.onAttachedToMeshObservable=new o.c,this.onAttachedToNodeObservable=new o.c,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObservers=[],this._attachedMesh=null,this._attachedNode=null,this._boundingBoxColor=s.a.FromHexString("#0984e3"),this._thickness=1,this._gizmoAxisCache=new Map,this.boundingBoxDragBehavior=new He,this.attachableMeshes=null,this.attachableNodes=null,this.usePointerToAttachGizmos=!0,this._defaultUtilityLayer=i,this._defaultKeepDepthUtilityLayer=n,this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,this._thickness=t,this.gizmos={positionGizmo:null,rotationGizmo:null,scaleGizmo:null,boundingBoxGizmo:null};var r=this._attachToMeshPointerObserver(e),a=Pr.a.GizmoAxisPointerObserver(this._defaultUtilityLayer,this._gizmoAxisCache);this._pointerObservers=[r,a]}return Object.defineProperty(e.prototype,"keepDepthUtilityLayer",{get:function(){return this._defaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"utilityLayer",{get:function(){return this._defaultUtilityLayer},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isHovered",{get:function(){var e=!1;for(var t in this.gizmos){var i=this.gizmos[t];if(i&&i.isHovered){e=!0;break}}return e},enumerable:!1,configurable:!0}),e.prototype._attachToMeshPointerObserver=function(e){var t=this;return e.onPointerObservable.add((function(e){if(t.usePointerToAttachGizmos&&e.type==Ne.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 n=!1;t.attachableMeshes.forEach((function(e){i&&(i==e||i.isDescendantOf(e))&&(i=e,n=!0)})),n||(i=null)}i instanceof Ge.a?t._attachedMesh!=i&&t.attachToMesh(i):t.clearGizmoOnEmptyPointerEvent&&t.attachToMesh(null)}else t.clearGizmoOnEmptyPointerEvent&&t.attachToMesh(null)}))},e.prototype.attachToMesh=function(e){for(var t in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=e,this._attachedNode=null,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)},e.prototype.attachToNode=function(e){for(var t in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=null,this._attachedNode=e,this.gizmos){var i=this.gizmos[t];i&&this._gizmosEnabled[t]&&(i.attachedNode=e)}this.boundingBoxGizmoEnabled&&this._attachedNode&&this._attachedNode.addBehavior(this.boundingBoxDragBehavior),this.onAttachedToNodeObservable.notifyObservers(e)},Object.defineProperty(e.prototype,"positionGizmoEnabled",{get:function(){return this._gizmosEnabled.positionGizmo},set:function(e){e?(this.gizmos.positionGizmo||(this.gizmos.positionGizmo=new Fr(this._defaultUtilityLayer,this._thickness,this)),this._attachedNode?this.gizmos.positionGizmo.attachedNode=this._attachedNode:this.gizmos.positionGizmo.attachedMesh=this._attachedMesh):this.gizmos.positionGizmo&&(this.gizmos.positionGizmo.attachedNode=null),this._gizmosEnabled.positionGizmo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotationGizmoEnabled",{get:function(){return this._gizmosEnabled.rotationGizmo},set:function(e){e?(this.gizmos.rotationGizmo||(this.gizmos.rotationGizmo=new Dr(this._defaultUtilityLayer,32,!1,this._thickness,this)),this._attachedNode?this.gizmos.rotationGizmo.attachedNode=this._attachedNode:this.gizmos.rotationGizmo.attachedMesh=this._attachedMesh):this.gizmos.rotationGizmo&&(this.gizmos.rotationGizmo.attachedNode=null),this._gizmosEnabled.rotationGizmo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scaleGizmoEnabled",{get:function(){return this._gizmosEnabled.scaleGizmo},set:function(e){e?(this.gizmos.scaleGizmo=this.gizmos.scaleGizmo||new Ur(this._defaultUtilityLayer,this._thickness,this),this._attachedNode?this.gizmos.scaleGizmo.attachedNode=this._attachedNode:this.gizmos.scaleGizmo.attachedMesh=this._attachedMesh):this.gizmos.scaleGizmo&&(this.gizmos.scaleGizmo.attachedNode=null),this._gizmosEnabled.scaleGizmo=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"boundingBoxGizmoEnabled",{get:function(){return this._gizmosEnabled.boundingBoxGizmo},set:function(e){e?(this.gizmos.boundingBoxGizmo=this.gizmos.boundingBoxGizmo||new Mr(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),this._attachedMesh?this.gizmos.boundingBoxGizmo.attachedMesh=this._attachedMesh:this.gizmos.boundingBoxGizmo.attachedNode=this._attachedNode,this._attachedMesh?(this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)):this._attachedNode&&(this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this._attachedNode.addBehavior(this.boundingBoxDragBehavior))):this.gizmos.boundingBoxGizmo&&(this._attachedMesh?this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior):this._attachedNode&&this._attachedNode.removeBehavior(this.boundingBoxDragBehavior),this.gizmos.boundingBoxGizmo.attachedNode=null),this._gizmosEnabled.boundingBoxGizmo=e},enumerable:!1,configurable:!0}),e.prototype.addToAxisCache=function(e){var t=this;e.size>0&&e.forEach((function(e,i){t._gizmoAxisCache.set(i,e)}))},e.prototype.dispose=function(){var e=this;for(var t in this._pointerObservers.forEach((function(t){e.scene.onPointerObservable.remove(t)})),this.gizmos){var i=this.gizmos[t];i&&i.dispose()}this._defaultKeepDepthUtilityLayer.dispose(),this._defaultUtilityLayer.dispose(),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},e}(),kr=i(48),zr=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._needProjectionMatrixCompute=!0,t}return Object(h.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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=a.e.Zero()),a.e.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=a.e.Zero()),a.e.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=a.e.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=a.e.Cross(this.direction,J.a.Y),t=a.e.Cross(e,this.direction);return a.e.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=a.e.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=a.a.Identity()),a.a.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._worldMatrixDeterminantIsDirty=!0,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},Object(h.c)([Object(w.o)()],t.prototype,"position",null),Object(h.c)([Object(w.o)()],t.prototype,"direction",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowMinZ",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowMaxZ",null),t}(kr.a);B.a.AddNodeConstructor("Light_Type_1",(function(e,t){return function(){return new Gr(e,a.e.Zero(),t)}}));var Gr=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r._shadowFrustumSize=0,r._shadowOrthoScale=.1,r.autoUpdateExtends=!0,r.autoCalcShadowZBounds=!1,r._orthoLeft=Number.MAX_VALUE,r._orthoRight=Number.MIN_VALUE,r._orthoTop=Number.MIN_VALUE,r._orthoBottom=Number.MAX_VALUE,r.position=i.scale(-1),r.direction=i,r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DirectionalLight"},t.prototype.getTypeID=function(){return kr.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&&a.a.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 n=this.getScene().activeCamera;if(n){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var r=a.e.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var o=Number.MAX_VALUE,s=Number.MIN_VALUE,c=0;c<i.length;c++){var l=i[c];if(l)for(var u=l.getBoundingInfo().boundingBox,h=0;h<u.vectorsWorld.length;h++)a.e.TransformCoordinatesToRef(u.vectorsWorld[h],t,r),r.x<this._orthoLeft&&(this._orthoLeft=r.x),r.y<this._orthoBottom&&(this._orthoBottom=r.y),r.x>this._orthoRight&&(this._orthoRight=r.x),r.y>this._orthoTop&&(this._orthoTop=r.y),this.autoCalcShadowZBounds&&(r.z<o&&(o=r.z),r.z>s&&(s=r.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=o,this._shadowMaxZ=s)}var d=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;a.a.OrthoOffCenterLHToRef(this._orthoLeft-d*this.shadowOrthoScale,this._orthoRight+d*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,e)}},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",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.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.transferToNodeMaterialEffect=function(e,t){return this.computeTransformedInformation()?(e.setFloat3(t,this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z),this):(e.setFloat3(t,this.direction.x,this.direction.y,this.direction.z),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},Object(h.c)([Object(w.c)()],t.prototype,"shadowFrustumSize",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowOrthoScale",null),Object(h.c)([Object(w.c)()],t.prototype,"autoUpdateExtends",void 0),Object(h.c)([Object(w.c)()],t.prototype,"autoCalcShadowZBounds",void 0),t}(zr);be.a.CreateHemisphere=function(e,t,i,n){var r={segments:t,diameter:i};return jr.CreateHemisphere(e,r,n)};var jr=function(){function e(){}return e.CreateHemisphere=function(e,t,i){t.diameter||(t.diameter=1),t.segments||(t.segments=16);var n=xr.a.CreateSphere("",{slice:.5,diameter:t.diameter,segments:t.segments},i),r=be.a.CreateDisc("",t.diameter/2,3*t.segments+(4-t.segments),i);r.rotation.x=-Math.PI/2,r.parent=n;var o=be.a.MergeMeshes([r,n],!0);return o.name=e,o},e}();B.a.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new Wr(e,a.e.Zero(),a.e.Zero(),0,0,t)}}));var Wr=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,s)||this;return c._innerAngle=0,c._projectionTextureMatrix=a.a.Zero(),c._projectionTextureLightNear=1e-6,c._projectionTextureLightFar=1e3,c._projectionTextureUpDirection=a.e.Up(),c._projectionTextureViewLightDirty=!0,c._projectionTextureProjectionLightDirty=!0,c._projectionTextureDirty=!0,c._projectionTextureViewTargetVector=a.e.Zero(),c._projectionTextureViewLightMatrix=a.a.Zero(),c._projectionTextureProjectionLightMatrix=a.a.Zero(),c._projectionTextureScalingMatrix=a.a.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),c.position=i,c.direction=n,c.angle=r,c.exponent=o,c}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){var i=this;this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady()&&(t._IsProceduralTexture(this._projectionTexture)?this._projectionTexture.getEffect().executeWhenCompiled((function(){i._markMeshesAsLightDirty()})):t._IsTexture(this._projectionTexture)&&this._projectionTexture.onLoadObservable.addOnce((function(){i._markMeshesAsLightDirty()}))))},enumerable:!1,configurable:!0}),t._IsProceduralTexture=function(e){return void 0!==e.onGeneratedObservable},t._IsTexture=function(e){return void 0!==e.onLoadObservable},t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return kr.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 n=this.getScene().activeCamera;if(n){this._shadowAngleScale=this._shadowAngleScale||1;var r=this._shadowAngleScale*this._angle;a.a.PerspectiveFovLHToRef(r,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),a.a.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),n=-i*t,r=1/Math.tan(this._angle/2);a.a.FromValuesToRef(r/1,0,0,0,0,r,0,0,0,0,i,1,0,0,n,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){if(this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTexture instanceof Ke.a){var e=this._projectionTexture.uScale/2,t=this._projectionTexture.vScale/2;a.a.FromValuesToRef(e,0,0,0,0,t,0,0,0,0,.5,0,.5,.5,.5,1,this._projectionTextureScalingMatrix)}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",4),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.transferTexturesToEffect=function(e,t){return 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.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=a.e.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),i=a.e.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},t.prototype.transferToNodeMaterialEffect=function(e,t){var i;return i=this.computeTransformedInformation()?a.e.Normalize(this.transformedDirection):a.e.Normalize(this.direction),this.getScene().useRightHandedSystem?e.setFloat3(t,-i.x,-i.y,-i.z):e.setFloat3(t,i.x,i.y,i.z),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||!this.projectionTexture.isReady())},Object(h.c)([Object(w.c)()],t.prototype,"angle",null),Object(h.c)([Object(w.c)()],t.prototype,"innerAngle",null),Object(h.c)([Object(w.c)()],t.prototype,"shadowAngleScale",null),Object(h.c)([Object(w.c)()],t.prototype,"exponent",void 0),Object(h.c)([Object(w.c)()],t.prototype,"projectionTextureLightNear",null),Object(h.c)([Object(w.c)()],t.prototype,"projectionTextureLightFar",null),Object(h.c)([Object(w.c)()],t.prototype,"projectionTextureUpDirection",null),Object(h.c)([Object(w.m)("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(zr),Hr=function(e){function t(t){void 0===t&&(t=Cr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._cachedPosition=new a.e,i._cachedForward=new a.e(0,0,1),i._pointerObserver=null,i.onClickedObservable=new o.c,i._light=null,i.attachedMesh=new Ge.a("",i.gizmoLayer.utilityLayerScene),i._attachedMeshParent=new Nr.a("parent",i.gizmoLayer.utilityLayerScene),i.attachedMesh.parent=i._attachedMeshParent,i._material=new Wi.a("light",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new s.a(.5,.5,.5),i._material.specularColor=new s.a(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._light&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._light))}),Ne.a.POINTERDOWN),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"light",{get:function(){return this._light},set:function(e){var i=this;if(this._light=e,e){this._lightMesh&&this._lightMesh.dispose(),e instanceof ki.a?this._lightMesh=t._CreateHemisphericLightMesh(this.gizmoLayer.utilityLayerScene):this._lightMesh=e instanceof Gr?t._CreateDirectionalLightMesh(this.gizmoLayer.utilityLayerScene):e instanceof Wr?t._CreateSpotLightMesh(this.gizmoLayer.utilityLayerScene):t._CreatePointLightMesh(this.gizmoLayer.utilityLayerScene),this._lightMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._lightMesh.parent=this._rootMesh;var n=this.gizmoLayer._getSharedGizmoLight();n.includedOnlyMeshes=n.includedOnlyMeshes.concat(this._lightMesh.getChildMeshes(!1)),this._lightMesh.rotationQuaternion=new a.b,this.attachedMesh.reservedDataStore||(this.attachedMesh.reservedDataStore={}),this.attachedMesh.reservedDataStore.lightGizmo=this,e.parent&&this._attachedMeshParent.freezeWorldMatrix(e.parent.getWorldMatrix()),e.position&&(this.attachedMesh.position.copyFrom(e.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)),e.direction&&(this.attachedMesh.setDirection(e.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(this.attachedMesh.forward)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){e.prototype._update.call(this),this._light&&(this._light.parent&&this._attachedMeshParent.freezeWorldMatrix(this._light.parent.getWorldMatrix()),this._light.position&&(this.attachedMesh.position.equals(this._cachedPosition)?(this.attachedMesh.position.copyFrom(this._light.position),this.attachedMesh.computeWorldMatrix(!0),this._cachedPosition.copyFrom(this.attachedMesh.position)):(this._light.position.copyFrom(this.attachedMesh.position),this._cachedPosition.copyFrom(this.attachedMesh.position))),this._light.direction&&(a.e.DistanceSquared(this.attachedMesh.forward,this._cachedForward)>1e-4?(this._light.direction.copyFrom(this.attachedMesh.forward),this._cachedForward.copyFrom(this.attachedMesh.forward)):a.e.DistanceSquared(this.attachedMesh.forward,this._light.direction)>1e-4&&(this.attachedMesh.setDirection(this._light.direction),this.attachedMesh.computeWorldMatrix(!0),this._cachedForward.copyFrom(this.attachedMesh.forward))))},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._material.dispose(),e.prototype.dispose.call(this),this._attachedMeshParent.dispose()},t._CreateHemisphericLightMesh=function(e){var i=new be.a("hemisphereLight",e),n=jr.CreateHemisphere(i.name,{segments:10,diameter:1},e);n.position.z=-.15,n.rotation.x=Math.PI/2,n.parent=i;var r=this._CreateLightLines(3,e);return r.parent=i,r.position.z,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreatePointLightMesh=function(e){var i=new be.a("pointLight",e),n=xr.a.CreateSphere(i.name,{segments:10,diameter:1},e);return n.rotation.x=Math.PI/2,n.parent=i,this._CreateLightLines(5,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateSpotLightMesh=function(e){var i=new be.a("spotLight",e);xr.a.CreateSphere(i.name,{segments:10,diameter:1},e).parent=i;var n=jr.CreateHemisphere(i.name,{segments:10,diameter:2},e);return n.parent=i,n.rotation.x=-Math.PI/2,this._CreateLightLines(2,e).parent=i,i.scaling.scaleInPlace(t._Scale),i.rotation.x=Math.PI/2,i},t._CreateDirectionalLightMesh=function(e){var i=new be.a("directionalLight",e),n=new be.a(i.name,e);n.parent=i,xr.a.CreateSphere(i.name,{diameter:1.2,segments:10},e).parent=n;var r=be.a.CreateCylinder(i.name,6,.3,.3,6,1,e);r.parent=n,(o=r.clone(i.name)).scaling.y=.5,o.position.x+=1.25,(a=r.clone(i.name)).scaling.y=.5,a.position.x+=-1.25;var o,a,s=be.a.CreateCylinder(i.name,1,0,.6,6,1,e);return s.position.y+=3,s.parent=n,(o=s.clone(i.name)).position.y=1.5,o.position.x+=1.25,(a=s.clone(i.name)).position.y=1.5,a.position.x+=-1.25,n.scaling.scaleInPlace(t._Scale),n.rotation.z=Math.PI/2,n.rotation.y=Math.PI/2,i},t._Scale=.007,t._CreateLightLines=function(e,t){var i=new be.a("root",t);i.rotation.x=Math.PI/2;var n=new be.a("linePivot",t);n.parent=i;var r=be.a.CreateCylinder("line",2,.2,.3,6,1,t);if(r.position.y=r.scaling.y/2+1.2,r.parent=n,e<2)return n;for(var o=0;o<4;o++){(a=n.clone("lineParentClone")).rotation.z=Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}if(e<3)return i;for(o=0;o<4;o++){(a=n.clone("linePivotClone")).rotation.z=Math.PI/2,a.rotation.y=Math.PI/2*o}if(e<4)return i;for(o=0;o<4;o++){var a;(a=n.clone("linePivotClone")).rotation.z=Math.PI+Math.PI/4,a.rotation.y=Math.PI/2+Math.PI/2*o,a.getChildMeshes()[0].scaling.y=.5,a.getChildMeshes()[0].scaling.x=a.getChildMeshes()[0].scaling.z=.8,a.getChildMeshes()[0].position.y=a.getChildMeshes()[0].scaling.y/2+1.2}return e<5||((a=n.clone("linePivotClone")).rotation.z=Math.PI),i},t}(Pr.a),Xr=function(){function e(e,t){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e}(),Yr=function(){function e(e,t,i){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Up()),void 0===i&&(i=a.d.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}(),Kr=function(e){function t(t){void 0===t&&(t=Cr.a.DefaultUtilityLayer);var i=e.call(this,t)||this;return i._pointerObserver=null,i.onClickedObservable=new o.c,i._camera=null,i._invProjection=new a.a,i._material=new Wi.a("cameraGizmoMaterial",i.gizmoLayer.utilityLayerScene),i._material.diffuseColor=new s.a(.5,.5,.5),i._material.specularColor=new s.a(.1,.1,.1),i._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){i._camera&&(i._isHovered=!(!e.pickInfo||-1==i._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),i._isHovered&&0===e.event.button&&i.onClickedObservable.notifyObservers(i._camera))}),Ne.a.POINTERDOWN),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"displayFrustum",{get:function(){return this._cameraLinesMesh.isEnabled()},set:function(e){this._cameraLinesMesh.setEnabled(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"camera",{get:function(){return this._camera},set:function(e){var i=this;if(this._camera=e,this.attachedNode=e,e){this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._cameraMesh=t._CreateCameraMesh(this.gizmoLayer.utilityLayerScene),this._cameraLinesMesh=t._CreateCameraFrustum(this.gizmoLayer.utilityLayerScene),this._cameraMesh.getChildMeshes(!1).forEach((function(e){e.material=i._material})),this._cameraMesh.parent=this._rootMesh,this._cameraLinesMesh.parent=this._rootMesh,this.gizmoLayer.utilityLayerScene.activeCamera&&this.gizmoLayer.utilityLayerScene.activeCamera.maxZ<1.5*e.maxZ&&(this.gizmoLayer.utilityLayerScene.activeCamera.maxZ=1.5*e.maxZ),this.attachedNode.reservedDataStore||(this.attachedNode.reservedDataStore={}),this.attachedNode.reservedDataStore.cameraGizmo=this;var n=this.gizmoLayer._getSharedGizmoLight();n.includedOnlyMeshes=n.includedOnlyMeshes.concat(this._cameraMesh.getChildMeshes(!1)),this._update()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._update=function(){e.prototype._update.call(this),this._camera&&(this._camera.getProjectionMatrix().invertToRef(this._invProjection),this._cameraLinesMesh.setPivotMatrix(this._invProjection,!1),this._cameraLinesMesh.scaling.x=1/this._rootMesh.scaling.x,this._cameraLinesMesh.scaling.y=1/this._rootMesh.scaling.y,this._cameraLinesMesh.scaling.z=1/this._rootMesh.scaling.z,this._cameraMesh.parent=null,this._cameraMesh.rotation.y=.5*Math.PI*(this._camera.getScene().useRightHandedSystem?1:-1),this._cameraMesh.parent=this._rootMesh)},t.prototype.dispose=function(){this.onClickedObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this._cameraMesh&&this._cameraMesh.dispose(),this._cameraLinesMesh&&this._cameraLinesMesh.dispose(),this._material.dispose(),e.prototype.dispose.call(this)},t._CreateCameraMesh=function(e){var i=new be.a("rootCameraGizmo",e),n=new be.a(i.name,e);n.parent=i,Ar.a.CreateBox(i.name,{width:1,height:.8,depth:.5},e).parent=n;var r=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.8,diameterBottom:.8},e);r.parent=n,r.position.y=.3,r.position.x=-.6,r.rotation.x=.5*Math.PI;var o=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.6,diameterBottom:.6},e);o.parent=n,o.position.y=.5,o.position.x=.4,o.rotation.x=.5*Math.PI;var a=nn.a.CreateCylinder(i.name,{height:.5,diameterTop:.5,diameterBottom:.5},e);return a.parent=n,a.position.y=0,a.position.x=.6,a.rotation.z=.5*Math.PI,i.scaling.scaleInPlace(t._Scale),n.position.x=-.9,i},t._CreateCameraFrustum=function(e){var t=new be.a("rootCameraGizmo",e),i=new be.a(t.name,e);i.parent=t;for(var n=0;n<4;n+=2)for(var r=0;r<4;r+=2){var o;(o=Or.a.CreateLines("lines",{points:[new a.e(-1+r,-1+n,-1),new a.e(-1+r,-1+n,1)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Or.a.CreateLines("lines",{points:[new a.e(-1,-1+r,-1+n),new a.e(1,-1+r,-1+n)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Or.a.CreateLines("lines",{points:[new a.e(-1+r,-1,-1+n),new a.e(-1+r,1,-1+n)]},e)).parent=i,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1}return t},t._Scale=.05,t}(Pr.a);ai.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Qr="vec4 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}";ai.a.IncludesShadersStore.packingFunctions=Qr;var qr="#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";ai.a.IncludesShadersStore.kernelBlurFragment=qr;var Zr="#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";ai.a.IncludesShadersStore.kernelBlurFragment2=Zr;var Jr="\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\n#include<packingFunctions>\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}";ai.a.ShadersStore.kernelBlurPixelShader=Jr;ai.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var $r="\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}";ai.a.ShadersStore.kernelBlurVertexShader=$r;var eo=function(e){function t(t,i,n,r,o,a,s,c,l,u,h){void 0===a&&(a=Ke.a.BILINEAR_SAMPLINGMODE),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=""),void 0===h&&(h=!1);var d=e.call(this,t,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],r,o,a,s,c,null,l,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return d.blockCompilation=h,d._packedFloat=!1,d._staticDefines="",d._staticDefines=u,d.direction=i,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=n,d}return Object(h.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:!1,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:!1,configurable:!0}),t.prototype.getClassName=function(){return"BlurPostProcess"},t.prototype.updateEffect=function(e,t,i,n,r,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._updateParameters(r,o)},t.prototype._updateParameters=function(t,i){for(var n=this._kernel,r=(n-1)/2,o=[],a=[],s=0,c=0;c<n;c++){var l=c/(n-1),u=this._gaussianWeight(2*l-1);o[c]=c-r,a[c]=u,s+=u}for(c=0;c<a.length;c++)a[c]/=s;var h=[],d=[],f=[];for(c=0;c<=r;c+=2){var p=Math.min(c+1,Math.floor(r));if(c===p)f.push({o:o[c],w:a[c]});else{var _=p===r,m=a[c]+a[p]*(_?.5:1),g=o[c]+1/(1+a[c]/a[p]);0===g?(f.push({o:o[c],w:a[c]}),f.push({o:o[c+1],w:a[c+1]})):(f.push({o:g,w:m}),f.push({o:-g,w:m}))}}for(c=0;c<f.length;c++)d[c]=f[c].o,h[c]=f[c].w;o=d,a=h;var v=this.getEngine().getCaps().maxVaryingVectors,b=Math.max(v,0)-1,y=Math.min(o.length,b),T="";T+=this._staticDefines,-1!=this._staticDefines.indexOf("DOF")&&(T+="#define CENTER_WEIGHT "+this._glslFloat(a[y-1])+"\r\n",y--);for(c=0;c<y;c++)T+="#define KERNEL_OFFSET"+c+" "+this._glslFloat(o[c])+"\r\n",T+="#define KERNEL_WEIGHT"+c+" "+this._glslFloat(a[c])+"\r\n";var E=0;for(c=b;c<o.length;c++)T+="#define KERNEL_DEP_OFFSET"+E+" "+this._glslFloat(o[c])+"\r\n",T+="#define KERNEL_DEP_WEIGHT"+E+" "+this._glslFloat(a[c])+"\r\n",E++;this.packedFloat&&(T+="#define PACKEDFLOAT 1"),this.blockCompilation=!1,e.prototype.updateEffect.call(this,T,null,null,{varyingCount:y,depCount:E},t,i)},t.prototype._nearestBestKernel=function(e){for(var t=Math.round(e),i=0,n=[t,t-1,t+1,t-2,t+2];i<n.length;i++){var r=n[i];if(r%2!=0&&Math.floor(r/2)%2==0&&r>0)return Math.max(r,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._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.direction,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,void 0,!1)}),e,n,r)},Object(h.c)([Object(w.c)("kernel")],t.prototype,"_kernel",void 0),Object(h.c)([Object(w.c)("packedFloat")],t.prototype,"_packedFloat",void 0),Object(h.c)([Object(w.n)()],t.prototype,"direction",void 0),t}(li);c.a.RegisteredTypes["BABYLON.BlurPostProcess"]=eo;var to=function(e){function t(t,i,n,r,o,s,c){void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=Ke.a.BILINEAR_SAMPLINGMODE),void 0===c&&(c=!0);var l=e.call(this,t,i,n,r,!0,o,!1,s,c)||this;return l.scene=n,l.mirrorPlane=new fn.a(0,1,0,1),l._transformMatrix=a.a.Zero(),l._mirrorMatrix=a.a.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=n.imageProcessingConfiguration.onUpdateParameters.add((function(){l._updateGammaSpace})),l.onBeforeRenderObservable.add((function(){a.a.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=n.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),n.setTransformMatrix(l._transformMatrix,n.getProjectionMatrix()),n.clipPlane=l.mirrorPlane,n.getEngine().cullBackFaces=!1,n._mirroredCameraPosition=a.e.TransformCoordinates(n.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){n.setTransformMatrix(l._savedViewMatrix,n.getProjectionMatrix()),n.getEngine().cullBackFaces=!0,n._mirroredCameraPosition=null,n.clipPlane=null})),l}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!1,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?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT;this._blurX=new eo("horizontal blur",new a.d(1,0),this._blurKernelX,this._blurRatio,null,Ke.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 eo("vertical blur",new a.d(0,1),this._blurKernelY,this._blurRatio,null,Ke.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(),n=new t(this.name,i.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.mirrorPlane=this.mirrorPlane.clone(),this.renderList&&(n.renderList=this.renderList.slice(0)),n},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}(Ni);Ke.a._CreateMirror=function(e,t,i,n){return new to(e,t,i,n)};var io=i(34),no=function(e){function t(t,i,n,r,s,c,l,u,h,d,f,p,_,m){var v;void 0===n&&(n=null),void 0===r&&(r=!1),void 0===s&&(s=null),void 0===c&&(c=null),void 0===l&&(l=null),void 0===u&&(u=g.a.TEXTUREFORMAT_RGBA),void 0===h&&(h=!1),void 0===d&&(d=null),void 0===f&&(f=!1),void 0===p&&(p=.8),void 0===_&&(_=0);var b=e.call(this,i)||this;if(b.onLoadObservable=new o.c,b.boundingBoxPosition=a.e.Zero(),b._rotationY=0,b._files=null,b._forcedExtension=null,b._extensions=null,b.name=t,b.url=t,b._noMipmap=r,b.hasAlpha=!1,b._format=u,b.isCube=!0,b._textureMatrix=a.a.Identity(),b._createPolynomials=f,b.coordinatesMode=Ke.a.CUBIC_MODE,b._extensions=n,b._files=s,b._forcedExtension=d,b._loaderOptions=m,!t&&!s)return b;var y=t.lastIndexOf("."),T=d||(y>-1?t.substring(y).toLowerCase():""),E=".dds"===T,S=".env"===T;if(S?(b.gammaSpace=!1,b._prefiltered=!1,b.anisotropicFilteringLevel=1):(b._prefiltered=h,h&&(b.gammaSpace=!1,b.anisotropicFilteringLevel=1)),b._texture=b._getFromCache(t,r),!s&&(S||E||n||(n=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[],n))for(var A=0;A<n.length;A++)s.push(t+n[A]);b._files=s;var P=function(){b.onLoadObservable.notifyObservers(b),c&&c()};if(b._texture)b._texture.isReady?Ce.b.SetImmediate((function(){return P()})):b._texture.onLoadedObservable.add((function(){return P()}));else{var C=b.getScene();(null==C?void 0:C.useDelayedTextureLoading)?b.delayLoadState=g.a.DELAYLOADSTATE_NOTLOADED:(b._texture=h?b._getEngine().createPrefilteredCubeTexture(t,C,p,_,c,l,u,d,b._createPolynomials):b._getEngine().createCubeTexture(t,C,s,r,c,l,b._format,d,!1,p,_,null,m),null===(v=b._texture)||void 0===v||v.onLoadedObservable.add((function(){return b.onLoadObservable.notifyObservers(b)})))}return b}return Object(h.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(g.a.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(a.a.RotationY(this._rotationY))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!1,configurable:!0}),t.CreateFromImages=function(e,i,n){var r="";return e.forEach((function(e){return r+=e})),new t(r,i,null,n,e)},t.CreateFromPrefilteredData=function(e,i,n,r){void 0===n&&(n=null),void 0===r&&(r=!0);var o=i.useDelayedTextureLoading;i.useDelayedTextureLoading=!1;var a=new t(e,i,null,!1,null,null,null,void 0,!0,n,r);return i.useDelayedTextureLoading=o,a},t.prototype.getClassName=function(){return"CubeTexture"},t.prototype.updateURL=function(e,t,i,n){var r;void 0===n&&(n=!1),this.url&&(this.releaseInternalTexture(),null===(r=this.getScene())||void 0===r||r.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag)),this.name&&!io.a.StartsWith(this.name,"data:")||(this.name=e),this.url=e,this.delayLoadState=g.a.DELAYLOADSTATE_NOTLOADED,this._prefiltered=n,this._prefiltered&&(this.gammaSpace=!1,this.anisotropicFilteringLevel=1),this._forcedExtension=t||null,i&&(this._delayedOnLoad=i),this.delayLoad(t)},t.prototype.delayLoad=function(e){var t,i=this;if(this.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=g.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),!this._texture)){var n=this.getScene();this._prefiltered?this._texture=this._getEngine().createPrefilteredCubeTexture(this.url,n,.8,0,this._delayedOnLoad,void 0,this._format,e,this._createPolynomials):this._texture=this._getEngine().createCubeTexture(this.url,n,this._files,this._noMipmap,this._delayedOnLoad,null,this._format,e,!1,0,0,null,this._loaderOptions),null===(t=this._texture)||void 0===t||t.onLoadedObservable.add((function(){return i.onLoadObservable.notifyObservers(i)}))}},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var t,i=this;e.updateFlag!==this._textureMatrix.updateFlag&&(e.isIdentity()!==this._textureMatrix.isIdentity()&&(null===(t=this.getScene())||void 0===t||t.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(i)}))),this._textureMatrix=e)},t.Parse=function(e,i,n){var r=w.a.Parse((function(){var r=!1;return e.prefiltered&&(r=e.prefiltered),new t(n+e.name,i,e.extensions,!1,e.files||null,null,null,void 0,r,e.forcedExtension)}),e,i);if(e.boundingBoxPosition&&(r.boundingBoxPosition=a.e.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(r.boundingBoxSize=a.e.FromArray(e.boundingBoxSize)),e.animations)for(var o=0;o<e.animations.length;o++){var s=e.animations[o],l=c.a.GetClass("BABYLON.Animation");l&&r.animations.push(l.Parse(s))}return r},t.prototype.clone=function(){var e=this,i=0,n=w.a.Clone((function(){var n=new t(e.url,e.getScene()||e._getEngine(),e._extensions,e._noMipmap,e._files);return i=n.uniqueId,n}),this);return n.uniqueId=i,n},Object(h.c)([Object(w.c)()],t.prototype,"url",void 0),Object(h.c)([Object(w.c)("rotationY")],t.prototype,"rotationY",null),Object(h.c)([Object(w.c)("files")],t.prototype,"_files",void 0),Object(h.c)([Object(w.c)("forcedExtension")],t.prototype,"_forcedExtension",void 0),Object(h.c)([Object(w.c)("extensions")],t.prototype,"_extensions",void 0),Object(h.c)([Object(w.j)("textureMatrix")],t.prototype,"_textureMatrix",void 0),t}(Zn.a);Ke.a._CubeTextureParser=no.Parse,c.a.RegisteredTypes["BABYLON.CubeTexture"]=no;var ro=i(15),oo=i(76),ao=i(87),so=i(19),co=" 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";ai.a.IncludesShadersStore.backgroundFragmentDeclaration=co;var lo="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;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";ai.a.IncludesShadersStore.backgroundUboDeclaration=lo;i(131),i(106),i(107),i(154),i(130),i(115),i(125),i(110),i(135),i(136);var uo="#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)*pow5(saturate(1.0-VdotN));\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#ifndef BACKMAT_SHADOWONLY\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=saturate(reflectionLOD);\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(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#else\nvec4 color=vec4(vPrimaryColor.rgb,(1.0-clamp(globalShadow,0.,1.))*alpha);\n#endif\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";ai.a.ShadersStore.backgroundPixelShader=uo;var ho="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";ai.a.IncludesShadersStore.backgroundVertexDeclaration=ho;i(78),i(79),i(117),i(137),i(80),i(81),i(111),i(157),i(138);var fo="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\nvPositionUVW=position;\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\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";ai.a.ShadersStore.backgroundVertexShader=fo;var po=i(67),_o=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.BACKMAT_SHADOWONLY=!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.MULTIVIEW=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.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.CLIPPLANE5=!1,t.CLIPPLANE6=!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 Object(h.d)(t,e),t}(oo.a),mo=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.primaryColor=s.a.White(),n._primaryColorShadowLevel=0,n._primaryColorHighlightLevel=0,n.reflectionTexture=null,n.reflectionBlur=0,n.diffuseTexture=null,n._shadowLights=null,n.shadowLights=null,n.shadowLevel=0,n.sceneCenter=a.e.Zero(),n.opacityFresnel=!0,n.reflectionFresnel=!1,n.reflectionFalloffDistance=0,n.reflectionAmount=1,n.reflectionReflectance0=.05,n.reflectionReflectance90=.5,n.useRGBColor=!0,n.enableNoise=!1,n._fovMultiplier=1,n.useEquirectangularFOV=!1,n._maxSimultaneousLights=4,n.maxSimultaneousLights=4,n._shadowOnly=!1,n.shadowOnly=!1,n._imageProcessingObserver=null,n.switchToBGR=!1,n._renderTargets=new oi.a(16),n._reflectionControls=a.f.Zero(),n._white=s.a.White(),n._primaryShadowColor=s.a.Black(),n._primaryHighlightColor=s.a.Black(),n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),n._diffuseTexture&&n._diffuseTexture.isRenderTarget&&n._renderTargets.push(n._diffuseTexture),n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),n._renderTargets},n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"_perceptualColor",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorShadowLevel",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorHighlightLevel",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!1,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:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!1,configurable:!0}),t.prototype.needAlphaTesting=function(){return!0},t.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha||this._shadowOnly},t.prototype.isReadyForSubMesh=function(e,t,i){var n=this;if(void 0===i&&(i=!1),t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new _o);var r=this.getScene(),o=t._materialDefines;if(this._isReadyForSubMesh(t))return!0;var a=r.getEngine();if(ro.a.PrepareDefinesForLights(r,e,o,!1,this._maxSimultaneousLights),o._needNormals=!0,ro.a.PrepareDefinesForMultiview(r,o),o._areTexturesDirty){if(o._needUVs=!1,r.texturesEnabled){if(r.getEngine().getCaps().textureLOD&&(o.TEXTURELODSUPPORT=!0),this._diffuseTexture&&so.a.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;ro.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 s=this._reflectionTexture;if(s&&so.a.ReflectionTextureEnabled){if(!s.isReadyOrNotBlocking())return!1;switch(o.REFLECTION=!0,o.GAMMAREFLECTION=s.gammaSpace,o.RGBDREFLECTION=s.isRGBD,o.REFLECTIONBLUR=this._reflectionBlur>0,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,o.LODINREFLECTIONALPHA=s.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,s.coordinatesMode===Ke.a.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case Ke.a.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Ke.a.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Ke.a.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Ke.a.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0;break;case Ke.a.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Ke.a.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ke.a.CUBIC_MODE:case Ke.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_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===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.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.BACKMAT_SHADOWONLY=this._shadowOnly),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(ro.a.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),ro.a.PrepareDefinesForFrameBoundValues(r,a,o,i,null,t.getRenderingMesh().hasThinInstances),ro.a.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(r.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(Qi.b.NormalKind)||(e.createNormals(!0),m.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),r.resetCachedMaterial();var c=new po.a;o.FOG&&c.addFallback(0,"FOG"),o.POINTSIZE&&c.addFallback(1,"POINTSIZE"),o.MULTIVIEW&&c.addFallback(0,"MULTIVIEW"),ro.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights);var l=[Qi.b.PositionKind];o.NORMAL&&l.push(Qi.b.NormalKind),o.UV1&&l.push(Qi.b.UVKind),o.UV2&&l.push(Qi.b.UV2Kind),ro.a.PrepareAttributesForBones(l,e,o,c),ro.a.PrepareAttributesForInstances(l,o);var u=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix"],h=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],d=["Material","Scene"];ji.a&&(ji.a.PrepareUniforms(u,o),ji.a.PrepareSamplers(h,o)),ro.a.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var f=o.toString();t.setEffect(r.getEngine().createEffect("background",{attributes:l,uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:f,fallbacks:c,onCompiled:function(e){n.onCompiled&&n.onCompiled(e),n.bindSceneUniformBuffer(e,r.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=r.getRenderId(),t.effect._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 n=this.getScene(),r=i._materialDefines;if(r){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),ro.a.BindBonesParameters(t,this._activeEffect);var a=this._mustRebind(n,o,t.visibility);if(a){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o);var s=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(n.texturesEnabled&&(this._diffuseTexture&&so.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),ro.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&so.a.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",s.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",s.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset))),this.shadowLevel>0&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),r.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),n.texturesEnabled&&(this._diffuseTexture&&so.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&so.a.ReflectionTextureEnabled&&(r.REFLECTIONBLUR&&r.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",s):r.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",s._lodTextureMid||s),this._uniformBuffer.setTexture("reflectionSamplerLow",s._lodTextureLow||s),this._uniformBuffer.setTexture("reflectionSamplerHigh",s._lodTextureHigh||s)):this._uniformBuffer.setTexture("reflectionSampler",s),r.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)))),ro.a.BindClipPlane(this._activeEffect,n),ro.a.BindEyePosition(o,n)}!a&&this.isFrozen||(n.lightsEnabled&&ro.a.BindLights(n,t,this._activeEffect,r,this._maxSimultaneousLights,!1),this.bindView(o),ro.a.BindFogParameters(n,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._reflectionTexture===t||this._diffuseTexture===t)},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,n){return w.a.Parse((function(){return new t(e.name,i)}),e,i,n)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,Object(h.c)([Object(w.e)()],t.prototype,"_primaryColor",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),Object(h.c)([Object(w.e)()],t.prototype,"__perceptualColor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_primaryColorShadowLevel",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_primaryColorHighlightLevel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),Object(h.c)([Object(w.m)()],t.prototype,"_reflectionTexture",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionBlur",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),Object(h.c)([Object(w.m)()],t.prototype,"_diffuseTexture",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_shadowLevel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),Object(h.c)([Object(w.o)()],t.prototype,"_sceneCenter",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_opacityFresnel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionFresnel",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionFalloffDistance",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionAmount",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionReflectance0",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_reflectionReflectance90",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_useRGBColor",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_enableNoise",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_maxSimultaneousLights",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_shadowOnly",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"shadowOnly",void 0),Object(h.c)([Object(w.i)()],t.prototype,"_imageProcessingConfiguration",void 0),t}(ao.a);c.a.RegisteredTypes["BABYLON.BackgroundMaterial"]=mo;var go=function(){function e(t,i){var n=this;this._errorHandler=function(e,t){n.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=Object(h.a)(Object(h.a)({},e._getDefaultOptions()),t),this._scene=i,this.onErrorObservable=new o.c,this._setupBackground(),this._setupImageProcessing()}return e._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new s.a(.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:g.a.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new s.a(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:a.e.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skybox",{get:function(){return this._skybox},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ground",{get:function(){return this._ground},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!1,configurable:!0}),e.prototype.updateOptions=function(e){var t=Object(h.a)(Object(h.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 s.b(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 Zn.a)this._scene.environmentTexture=this._options.environmentTexture;else{var e=no.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new be.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,n=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:i,rootPosition:n};var r=this._scene.getWorldExtends((function(t){return t!==e._ground&&t!==e._rootMesh&&t!==e._skybox})),o=r.max.subtract(r.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Bt&&this._scene.activeCamera.upperRadiusLimit&&(i=t=2*this._scene.activeCamera.upperRadiusLimit);var a=o.length();a>t&&(i=t=2*a),t*=1.1,i*=1.5,(n=r.min.add(o.scale(.5))).y=r.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:i,rootPosition:n}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=be.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 mo("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=g.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(){this._groundMaterial&&(this._groundTexture||(this._options.groundTexture instanceof Zn.a?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new Ke.a(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._groundTexture.gammaSpace=!1,this._groundTexture.hasAlpha=!0,this._groundMaterial.diffuseTexture=this._groundTexture)))},e.prototype._setupGroundMirrorTexture=function(e){var t=Ke.a.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new to("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Ke.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new fn.a(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 n=this._scene.meshes[i];n!==this._ground&&n!==this._skybox&&n!==this._rootMesh&&this._groundMirror.renderList.push(n)}this._groundMirror.clearColor=new s.b(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=be.a.CreateBox("BackgroundSkybox",e.skyboxSize,this._scene,void 0,be.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 mo("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 Zn.a?this._skyboxMaterial.reflectionTexture=this._options.skyboxTexture:(this._skyboxTexture=new no(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._skyboxTexture.coordinatesMode=Ke.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}(),vo=function(e){function t(i,n,r,s,c){void 0===c&&(c=null);var l=e.call(this,i,s)||this;l.onError=c,l._halfDome=!1,l._crossEye=!1,l._useDirectMapping=!1,l._textureMode=t.MODE_MONOSCOPIC,l._onBeforeCameraRenderObserver=null,l.onLoadErrorObservable=new o.c,s=l.getScene(),i=i||"textureDome",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)||(s.activeCamera?.48*s.activeCamera.maxZ:1e3),void 0===r.useDirectMapping?l._useDirectMapping=!0:l._useDirectMapping=r.useDirectMapping,void 0===r.faceForward&&(r.faceForward=!0),l._setReady(!1),l._mesh=be.a.CreateSphere(i+"_mesh",r.resolution,r.size,s,!1,be.a.BACKSIDE);var u=l._material=new mo(i+"_material",s);u.useEquirectangularFOV=!0,u.fovMultiplier=1,u.opacityFresnel=!1;var h=l._initTexture(n,s,r);if(l.texture=h,l._mesh.material=u,l._mesh.parent=l,l._halfDomeMask=xr.a.CreateSphere("",{slice:.5,diameter:.98*r.size,segments:2*r.resolution,sideOrientation:be.a.BACKSIDE},s),l._halfDomeMask.rotate(J.a.X,-Math.PI/2),l._halfDomeMask.parent=l._mesh,l._halfDome=!!r.halfDomeMode,l._halfDomeMask.setEnabled(l._halfDome),l._crossEye=!!r.crossEyeMode,l._texture.anisotropicFilteringLevel=1,l._texture.onLoadObservable.addOnce((function(){l._setReady(!0)})),r.faceForward&&s.activeCamera){var d=s.activeCamera,f=a.e.Forward(),p=a.e.TransformNormal(f,d.getViewMatrix());p.normalize(),l.rotation.y=Math.acos(a.e.Dot(f,p))}return l._changeTextureMode(l._textureMode),l}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){this._texture!==e&&(this._texture=e,this._useDirectMapping?(this._texture.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._texture.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._material.diffuseTexture=this._texture):(this._texture.coordinatesMode=Ke.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,this._texture.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._material.reflectionTexture=this._texture),this._changeTextureMode(this._textureMode))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mesh",{get:function(){return this._mesh},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textureMode",{get:function(){return this._textureMode},set:function(e){this._textureMode!==e&&this._changeTextureMode(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"halfDome",{get:function(){return this._halfDome},set:function(e){this._halfDome=e,this._halfDomeMask.setEnabled(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"crossEye",{get:function(){return this._crossEye},set:function(e){this._crossEye=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},enumerable:!1,configurable:!0}),t.prototype._changeTextureMode=function(e){var i=this;switch(this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._textureMode=e,this._texture.uScale=1,this._texture.vScale=1,this._texture.uOffset=0,this._texture.vOffset=0,this._texture.vAng=0,e){case t.MODE_MONOSCOPIC:this._halfDome&&(this._texture.uScale=2,this._texture.uOffset=-1);break;case t.MODE_SIDEBYSIDE:this._texture.uScale=this._halfDome?.99999:.5;var n=this._halfDome?0:.5,r=this._halfDome?-.5:0;this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){var t=e.isRightCamera;i._crossEye&&(t=!t),i._texture.uOffset=t?n:r}));break;case t.MODE_TOPBOTTOM:this._texture.vScale=this._halfDome?.99999:.5,this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){var t=e.isRightCamera;i._crossEye&&(t=!t),i._texture.vOffset=t?.5:0}))}},t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._texture.dispose(),this._mesh.dispose(),this._material.dispose(),this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this.onLoadErrorObservable.clear(),e.prototype.dispose.call(this,t,i)},t.MODE_MONOSCOPIC=0,t.MODE_TOPBOTTOM=1,t.MODE_SIDEBYSIDE=2,t}(Nr.a),bo=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"photoTexture",{get:function(){return this.texture},set:function(e){this.texture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageMode",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,t,i){var n=this;return new Ke.a(e,t,!i.generateMipMaps,!this._useDirectMapping,void 0,void 0,(function(e,t){n.onLoadErrorObservable.notifyObservers(e||"Unknown error occured"),n.onError&&n.onError(e,t)}))},t.MODE_MONOSCOPIC=vo.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=vo.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=vo.MODE_SIDEBYSIDE,t}(vo),yo=function(){function e(){}return e.ExpandRGBDTexture=function(e){var t=e._texture;if(t&&e.isRGBD){var i=t.getEngine(),n=i.getCaps(),r=!1;n.textureHalfFloatRender&&n.textureHalfFloatLinearFiltering?(r=!0,t.type=g.a.TEXTURETYPE_HALF_FLOAT):n.textureFloatRender&&n.textureFloatLinearFiltering&&(r=!0,t.type=g.a.TEXTURETYPE_FLOAT),r&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1),e.onLoadObservable.addOnce((function(){if(r){var n=new li("rgbdDecode","rgbdDecode",null,null,1,null,g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!1,void 0,t.type,void 0,null,!1),o=i.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:g.a.TEXTUREFORMAT_RGBA});n.getEffect().executeWhenCompiled((function(){n.onApply=function(e){e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([n],o,!0),i.restoreDefaultFramebuffer(),i._releaseTexture(t),i._releaseFramebufferObjects(o),n&&n.dispose(),o._swapAndDie(t),t.isReady=!0}))}}))}},e}(),To=function(){function e(){}return e.GetEnvironmentBRDFTexture=function(e){if(!e.environmentBRDFTexture){var t=e.useDelayedTextureLoading;e.useDelayedTextureLoading=!1;var i=e._blockEntityCollection;e._blockEntityCollection=!1;var n=Ke.a.CreateFromBase64String(this._environmentBRDFBase64Texture,"EnvironmentBRDFTexture"+this._instanceNumber++,e,!0,!1,Ke.a.BILINEAR_SAMPLINGMODE);e._blockEntityCollection=i;var r=e.getEngine().getLoadedTexturesCache(),o=r.indexOf(n.getInternalTexture());-1!==o&&r.splice(o,1),n.isRGBD=!0,n.wrapU=Ke.a.CLAMP_ADDRESSMODE,n.wrapV=Ke.a.CLAMP_ADDRESSMODE,e.environmentBRDFTexture=n,e.useDelayedTextureLoading=t,yo.ExpandRGBDTexture(n)}return e.environmentBRDFTexture},e._instanceNumber=0,e._environmentBRDFBase64Texture="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR42u29yY5tWXIlZnbuiSaTbZFUkZRKrCKhElASQA0EoQABgn6hJvoXzfUP+gP9hWb6Bg00IgRoQJaKqUxmZmTEe8/v0uB2u7Fm2T7HIyIrnz88uPvt3f2a2WrMbOvf/u3PvvzP/sUf/N6//i8vf/lv/3v5H//d//Sb//Uq/5u8yf8hV/m/5Cp/L1f5hVzlG7nKJ7mKyJuIXN/hPwqXI/g++zq6rPI5u8z+WqfLre+zy7PrVv9L8brsMiGvk8XLmM/sdfHXal4e3ad6GXPdyu2ij8u/+uv/5cuf/OSLfdtEfvUr+dnf/d0X//t3H/7bf/hP//N/928h/0Yg/4VA/kogfyGQP5Wr/IFAvhbIlwK5CGQTPP+9z5uPeePJSW+yo2+s/GtN30Rnv1E+f5zxof9R/lSXv/nr//mrr3+i+5dfyX7ZZQP07Tffys//8R/l/9TtX7790T/7r/8G8pdy+/8XAvnnAvkzgfwzgfyxQP5AIL8vkJ8K5KsmMVzu1U7p5PA5AXxOAJ8TwPf7sX/51ZeXfcemqnp9w/W77/S7X/6T/vzf/7383RWCX3/z05/9i3/13/0PX//eX/2FyP8tIv+PiPy9iPy/IvIzEfm5iPxCRH4lIt/c/393//9BRD6KyKf7f488fP74/PH544dJAF9cLl98IZfLBZtuqterXr/7Dt9982v95S9+Lv+gF/3i7Spv/8lf/vnf/vGf/dF/JfKnIvLnIvLvReQ/NEngn0TklyLy6/v/34jIt00iGJOBlxAsdvv54/PH5493SQCXy9t2ueh2ueimKorrFbjq9eNH+fDtb+TXv/ol/vHyhX4Fxfbx7euPf/Lnf/PfiPyeiPyhiPxxkwB+fk8AvxzQgJcIrGTwFsiAEXH4/PH54/PHUgLY7whgu2C7bLqpQgHB2xvePn6SDx8+6G9+84384vKF/IPu8iVU9Y/+7C/+jWxffiHytYj8VER+X0T+oEEBvxqQwCMJeIngo5EI3goIwVMIPn98/vj8ESaAbbtu2ybbvl8u2ybbdtluSECA65u8ffqIDx8+6G++/VZ/efkV/sO261dQXP7wT/7kX8vl8qXIFyLylbySwe/dE0CLAr65B/9vGn0gQwRMMqgmhM/J4fPH548eAezbZd/lsm3YtssNAYiqiogAAkCvb5/k46cP8u2HD/rrb7+R/2/b9Wu9yJe//8d/9Ney6S5yEZFdRL68/38khG/uKOCnAwoYkcCoEXwkEgGDDq7CeQfyOTl8/vhd1QCum26ybZtu2yabbrKpQvXue1yvuF6v+vbpTT5+/CDffviAX1++1V9sO77WXb/66R/+4V/dgkbllQi+aBLBV/dE8LWRALwkYCWCNyMZXElkwLTMeMkga/P4/PH547ccAVwuctkvdxSw6bbdtYDbTfSZBN7e8PHTR/3u4wf55vKd/nL7DX6mu3791U9//5+/gkNFZGuSgZUQvnKowKgLWLTAQgRtEniTuEfwaELw0MJvf3LQzynud+53uG+X6y3gN9kul+2y6XVT1U27JCDAFVc8ksAn/e7jR/nN5YP+avtWfq6Xy9f7Vz/9w1dgRYngiyYhfNkkgzYBWHTg44AEMmqQUYQKOmDaiCIa8TmsfmzB+DnZDQjgcpGLbti2y3bZHjRAdRMVvb/dcYU8kcDbPQlsH/CrbddfbF98+RPZfvLFnAQeieCRDC5DMvju/vmD4JkEvjRQgKULeGggowdHkAHTYxihg89vu88I5UeGAPSOAFTlrgPopiqbKPSmCKreUoAAkCcSePukHz590m8vH+WbD9/JP335k6/+tA86KxFchv8jMvhiogE4JQm8XhfKqOAqx5qRPyeGzx8/cgSwbXcUoLJtim27C4Oi93+4v6VxQwKAvl2v+Hj9pB8+fZJvt4/yzfbF9lPdv/wJnsE2BogmyeCRED40tGFvksIXiSbgiYSRRpDNDZ6BDI6ghM+J4fPHeyKAO+zX7cb9t4tedMMNAQju5V+f1uAtBSiu1zsduMrHy5t8ePsk3376KN98sX/xE5FPAnm7/782o0DiUINXMkCXCB7/P94/e87AWUmARQWVvgMuKej9t1RLBp+Tw+ePgwngsutFFdu26WXbbl+rSvdfbnqAiuA23QcBgCugV1zl7e1NPm5v+LC96XfbJ/1W9y++fgXjA3bDYXV+MuhRwSPwL3JLMFYC+HS/LU8HYrGwIhwyNOF12SvgM4SgztdifP85MXz+KGsA2C6X7aJ6bXSAOwrY5OYIqGy3d5uq4P5GhABXuV6veLvRAf10fZMPb2/y3b7vX7+g+9v98/WOBq7GG7RNAlYy+Dgkhhb+Xxp0sE8IAC4SGAP/TbgVJK/PoJPBnAiwPKxsXfbbnRg+i3s/JAK4Q/4b9NfLtomBAqCickMBjy7BuywAUVyv8na94tMjCVzf9KNcLl/0SeA6oAEYb1i9g+FtSALb/bKL8/+t+wxXFMyswqiHoK4ToIgKqslgpg1qUC0QoYbvJZg/B/q5v4szHmPX7YEAsD0CX25OwEUVm9xag1+agKg+nxQArnKjAtDr9U0+Xd/k4/UqH7bL5YsewrcBBiMJZPRAp6TwQgWfjM9vgRbgUYGL8AvLWH2gqhesCokeUmCSwPsnhs8fP2YNYMO2XeSmAWxy2VQaXeDmDIhApf33rD4PTUCuV+DtCn27XuXT5ir8VmCJ2G5BpBM8/r/dEcJb8/0lEQMtJHA5TAlqNuLRhJChhEpSqFabH3di+G1AGj+W1/dyAR4IYJNNnuLf6+tWC9CHHiAtFhAIFLjK2/Uqn65X+SS67aK+3QeTDoy/IG2ogQ7fb/dAtz5vBgrYGqrwNtCHsVfgIvwK07OTQBURVNCBFpKCOjqCHn5L/67TgTN+fpySAC56nwSUi256kXsSuFGAVyLoUIDo8/Pz7fdoErr/v17lk162HbgHvFpIYDfoAJJfW4sGPjkU4VNAF8ZEcLmLhdc7kljdY1y1Dq9yLiI4IiRqcLujb138KIPn80ejATwRwIbtBvn1cqv+2J78/5EI5N4cJA8qIPcmwRsKAHDF9WYP6mV7VmrgLuTpxYTcMEW0LAmoQxFsuvAI8tv/a/C5fV2ZMMiKg++FCM7RDPRu8ebWY7VG6VJi+Bzk35MI2LsAckMAgwvQ0gC5DQjd3ABg2HQLAPpEAlZ1Bu7VV7MGHDFRAbo3VKsTbAY9sPWC/uvx86gBbDK3D1eEQS8pbAeSgSwmhepnJb6uBv/o/PzHLzxWA/X7TH77De5j6AGQi6o0CUGfCOD2X7cXAlCFQABtEsGLDtxuOyQB2UTQBKZe5GUPXgkUYCUAbZJRhBDeuq8xBf+bgwbehDm+BFQi2IJksOocvA8ysIMfxluVcRsY/eB3JzH8GFDAXQO48X/dcIf9jyDHptIigDsFkEe066tBSETQUYF7ElDdYEBytN4+rk9UcBPfrKaZqFHWcw3i4J8/X4ev2//bSXqAhwTay6OEIPLD2Ipt8OtAGzxkwLw9WVFRjTc/qC6H3+YK/b1oAA0KuOizHfieCLaHHiAb5NYTIC9EMEbZrVEQt1xwhVy1UfBh8PUOquMizwaap3tQXfY5B//tea/NZdfhsvbz+PURQTDSGWB87VX/7WSd4KxjUqrIgE0IUkoKGnhIvwvawpGf6eECXJ7tv4qbA7DJgwpsKthEmmYgfaAAffYF3HLxo0vwNjJ0SwRWMG4db4eh1gPNm18vQ+us/0eGmxDemu/fnM/X4evq/8342ksGHgLY5LyT/zg0wM8lcMjgGFXwqIOVFJBQw99eCvF9oZL9Mfl3QwAvIXDsBRC9R+fz8x0FPBLB0xJEpwUobrfAkARgIAF41h3wQgP6QAmX5E/7eI43IxGwwf/moIkRyWRJQIPgt9CA9b39nzt4bYUWjAlCjWDPgv8IEjgLJfzuaAsrv9VdVG4OwOXW/fdoA35qAdL0BDwvf6AAUVHd8LIEu94A3K+Q+2YxaB84MOH62P//qoo38fCRDERE2zf0JfmDa+MieElAjcDPKz+mRKCOtdgGtXaBjgNJ4H2owSpNeAW/rRH4CaHSpMwnBYYycjgSJwfie9CR6mPu20Uv8kABF206AvXlBMiIBPSlB9wjBW1fwEuSb94296VCqgMaGCt/G1BbExi3IG+r3a3J6P48Gv/J0YmEYoiGY7V/SxwFCwGoE/xa0AJ0CEiV9QPCJb1OJ5F1VTjEY2/MO9AEJvj1BJTQpqLfTlGwjABuzT962e4IoKnyrdh3+/6mzDVJ4PHOxj0JqGKoy20+wBMN6D1gLWi9NQHfVP5MEEPzjGYy8BMAOnTAJgEr8HUIejRo5xrA5xkR5AngmiSHs+zDDAmMgWzTg55GSJEmHE8IvWPAoYTfhWak/Wn/bQ0CGLSAjv83SUEfKp5q24LXuQICpzrjrgWoza8xVE00CQCORdhMJuTUT/rjuls0gO4Iby8BIEgK6gS7BsGuTtDrScH/fR68biUHNVGBnxjeNyHEvQe/ve3LZQqgG3rof6cEclsNflG9J4KtaQ8WHcVBHS1BtHE4QP9OBMS98mpbKTeDW7dJwRsnHpMBTFJpV4I+b0kY/NqInVFSyBLANbnMSgBM8F+Fqfxq/h657/Up+GaBnwV9hRqc9bZ/vA6vu+T9E8KPJWns94UfTeCj2QXwCHS9dNL8Xf3Ho/rfewSeFODGDV69AU0y6NFAE1DP3qK++rdB7/1HRxf86gT376zOr99T/h/ioBiXWQkgQgVeIrCC/WomhDmQK+hASI2ARQZKooHMLdCJwGEBBXC3+uERwg+VOHZ9ioAt9H80AI06wGgJ3nQA3BoCut6AhxYwgcPOFnxuFnrphk+NIKIGrWPQtgz3b0i7Y6D5rs1GKqTop0nQX52vmQC4BkjA+r4a7Kx9WLENGeegkhSETBCrNXIMdi/444Rw1n6E96ry7OPuj8UfLxtQ78NA2iSBbg7gIiIbdDLsb5agPhLC3RkYKv8NDbS2YGsatNRAG2oQwf9ZIOydgy1MAzBkAw8UwEEIDzSAqdPQ6za0PkeJAMH3Z0wXniUSZoHvBXU2mcjQgv56TedIKglCpIoQfgwCIjOytd8WgN0bfxoR8Fn9Gx0Aj5Zgq0lIZbsH/ibSJoFnS+C98g9ooHEELI3gliy25yONIiE6pb0NfBlyNEYyENoodkKwgl6I6s8kARgJ4ZoEfuYWHLEJa0LhSBXm7kImGeSfVdoJ1DO2G7WXsehAptupSOoyrCSF904k+6vt98X/ZcM98Hsd4JYIXhQAIg3/f9AAUYhsLQKAtkHVBnzjCKhOoYl2ym+iBtvzDzQ2DLXJ4PUmbJHAVnBQX4jkxfvHhNDqAdHXGQJgv0aSDGItgOseHIU+K9hXnIJzkoGlEKzNHagTdJ6VWEUH4iCKH4fd2AwDPaYBm4Wgng4gQ9V/CoGiuNmD04AQtNGMGzSAAQ2I2pzfogY9LRh7BrbOh4+D30sAencljFu2CUFrwY8UAWRfWwGvVOVfbx2uIILM0pwDv082dUTw8hYs8L+uIWiHGpWgClnAa1lMPJogovvvbePPs/q3Xr++kgCsfgB5oQF9WYKPJqEn6G+OE3i5AqouF59FQOmahQC8rlPLj38kg1c2f30vw+XaoIX24/pMGIgSBoZqoH3wo0sIIGlA9PWcCPrAtpPB8eBf6x1o6cHra+2+tpIFP4PgBfxZtZUJfo4qxELT948D9ucK8Mt9+ccjIQw6QJcEbrD/1g340ATuDgDkFfx6twSf1f9xvuBECYxq/7ythQQGm+5JDx6Brw4CkMGT3wgscCUoQ4sU2t6DR2ciBjTgtcpenQoZVX9NuL4Owc+dVaDursYVkVALX+shjSBKBuvCYDUZjE5BdNkxdHAUBexyHwB6NP7Iyw7sxUDViwge1t+mz8B/LAvVx/c3PeBBCToB8IUGOgqA3iV4yUg6UAOxaUFHDx6CYS8SorMOue0CCJGAf5YfRhoAI+A1CvwxqNkAY5yAIx2EQmkFfeWOXi+nEdSQQA0ZHMEItiagJArQxDXIrj8nCfQi4HZPAttrIahso9oPQ/2/JwV5JQU8zw+7I4D7/sBn4EO6rjw0FR+i3Z9fHtahzsFvJgM0X+tmVH5vaYiNDGAigewAz+gyNLThnjCURQFR1b9d3lZvnVqmj9mEPDKIUIC4KCCjBXywS4N+otp/Hk3QVthOkwEKlV9PQwXjT7s/zwF4Qf9toAAzFdjuaEB6S7D1//U5FIQu2MevO0rQQH8ZmoXE6B/IkgE60XCjVoq8gt2iCG0S8L5GdxkM1cGsfsCMArSCAnrr7dzAZxCEEpepvB8tqHJ/q+bmJGGts/AcAXFOMMeTwC7Pw0B6CtCtA2vWgonqBQJFSwH0JQK29OB2kvgj2HHXAoyeAIsCQO0kMNECAhFMqCBf8mElAkyBbX1tJQP2RJ/ha0gpAfS9l+/5n00CkrQpq0MZbOdAuxmMvHswog62jZj7BnYQe19b14kxNq2D/ehX/p68HEcF+x3yP7z/V/A/q/5DA3i5A/dzA5pdgbKp3v3/wQF4Bb70WkCTHGRAA6+KL0bFl6FJaFw0ImZwm6igSwbbwPn9RMBWf3sN2JgA/BVh/Rg0kQBgePf6HglAHLFQwqQQOwDjbdVxNZjR4iM6Qa3WxwvNxh0JFb3g/WzFQQS8b/ttKcDWoABtUMAd8j9hf0MB2uDXhzX4CHj03L9DBU3Qjz0C0l4mLSLQPicOOwZoVCB6P6dA7nDbGkVuxcNr8PU2JQO4wX5trEqmccZaHU4q8oCDFOpzAnOwqyMIMktNNNAHouDGxO37DgArQZzlmp/14W1QlqHTMaIIx7SCx0+5yza7AKJ3IXBrNAHVDcMZAU/BT/vgv/ULPOA+XiLggAREDF2g0ci6xNDRglegd7P7TWWH5oJfayliEg7bScQRBVgI4Ookg/F6rvpLWP29swREqA3CaG8/FpKqS8DTAV4TiBqIqtxfzaQRLys5I0XEFIFrPbZRQb+16Fgi2LvJv8EFUPW1gGfQv1T/F/d/HBnccP7rAwnIIyHI4ArgWeGbU4eHy6Tx/EeTZIb5bo/BsMBjmjBE08f/RB0PHYBd9eVRAGY7cHRwiBf8WeCPHY1bgBTa9xKTELzEkQX9CPtl0gJiqsAmCT7I8xbjivh3JGFI+D2nBcSJQJ8agDX+O9iBL7UfG4bzAkcaICrbtYHz1ycSmGmAjJfL3CMgT3tQpmrfB7gxSzC1DnvdhQMieG47u75+kTouKNkM8c/+vq/Q7ZYjO/hhVvRq8F/9gGfhP8aqE9EIdR6LTwJ1h0BItyDqB8iFwuNqASscRnYioxOg9ApvnYA35f8e9Ohbfe8J4rknoFkO0lmA2gmAG0YK0DkB4ieEjiLoMD8wBzom27ANZkzIoU8EMHk/uo1mzeVoEoRWKn8L/62EYAX/lsB7D/LXg74uAMr9oGivJ0CNJCGD6i9DhZdQF+gtOp4S+NODRzsDVbhdgv4BqTMNyIL9SCKwL9/FGPp5oQKxIf8A/UX6r231H7YIqLML0Ae2GtrADOvRQH5b/MPE9dt9BGLNG8jVTAQvIaK5TtvvvWQgDvyXIClUA78S9Nfg7VtIBlO7cbsEYkQDMot+ygQ7QwmOawTHnAM2XUSnJvPIYRYMmYPS+sv3J+cfP3d04JYIXsF/EwMbBKB9Q9AY+BiSwFj9mzrSXmcJhFPVHySTbgHJCPvRQ/z7G/SVUETsg0ZF+i3CRoCjhf7y1A9mOiDD7TwdwEoEXjLwAv+avLE2B7Jnb+OqDpBoAchoQJskxKnss0vu7Q2YhcDv4ySeLOg9GsCKiUIihP7yfW7zbTsBh0TQfN0iAWn9f72Z56/Ax9P7j5OAH/Qvv3/QxKfk0DgDuP+R3USg3bzBC7bO/QT9Eeh9QvDPG7glBQzJwK740lAFFgFk8P88CqDGAa223YckWYhr+c0BPdwetl2ocnsfzePAWcVnnAIp6gDVhDLyfV4nqFEDPxHsbWD3k4BDkN+pARqKMLYBPzYEvxp9xmCHQQdgWH/9EtH2TIFpu3AH/cdGydv1j0TQbRrq+D/mLcX3ZACZ15bF378CG0My6Kq/zoGOQwhASDFwFbxyNGBuSxbCEhQ/uEPe/6gAERWQObCVVfjPpQX+rexxYhYFxIkgpgX7Y/vPs+Pvxf9vwt8kAs7i32t3QCP+3SPaTwIytQXP38u0PESm+YER+o9B3vr8mETAUfDrEkPI80ck0FZ0dXh9U+HRbhey0cAc2H7A4y4egoD6y8JfkBiigLdFP8v2W00E8deT2IeAKujZ/QAVKpAtKI20gLWksHedfgPcb+0+NEHefd9vB9rayi8h7J91gBbaw20MsnWAF5xHkyDUCOoXp+yrOwwxcKj0aL6fFppaaKDv6OpHR5sgx5BAlK/+fYhuP1D196o8e7lFBaKqv5YIMnFQpd0FGVR35RJCnCDaABaXBtgbiSwtICMtalKC+1JQ6bx/PLcDPQL91QFodQNKpwOgF/9eqcBxBBqRcKAAVk+ArQOMx1RYGgB6naDhlK+uQQwJYx4meQbxtNnYQwMjt/d4f3M9ZE4UOld1LAh99fbfzOxiEkKFCkTJIUIMUeVnJ/9sDt8/e1NEJOi9oVHDGYhgnSLss9DX2IAqw1zALUncKcDr0FB5NP+0cBQNrEezDiyiADPkt9qGpwoPdL0AGPx/NOKeyf3b9WJNdfcFv6bKd2cLMJVfJ6Y3B6wB9WFUfWWEwKMfGiQL+3bz9XGQz2EHKhF41GCtZyDi/gUCsNhYoAr3UNJ58YidHKqnMb/6AB5J4N73/4L+t7mAkeeP3P+1LNSB/l0SkMEd8DcEuUlguEw6t2AU/PCE/q++Akw6QFf1u6SBrj1ZnnhG50AfkoGIdf7gJv1KcSfgzWWkQ9U33Z3tHXYASKJ9e/YhU90rvD+q9Ej69/wxYJVs506Eg/r3DkMDzEdDBRGgcZay49XihLA30P+l8N+hf1f57/0AoxbQbwYaan/rBMirE9Dk+sBzTkC8JNDEUlv5McB8PP19Y01Gayep+hC/2zvQ/2HGLAurowsNGlA1cnqGGzeH5weiYLZm7h3QQC4O2tXdhvMMk1ZS5ebpgI8eMrPvPGkwaxayk8Yc6PMOBPEdC1XZ+2UfbfOPtxLMQQAG9BcZFoF0gp/RKjxe7+oAw9T7ZPWhgedodgz0gf5KBtrtIZhQAZpAV1Bi36w6t98qVfH7hqGI318lLCjLCUFlxRHwqYEH9a2qb4XjWvDT7kBwfbZA5P0+PNuRuW1yf4yNQH3zzwv6b70QOJ0G9OT/dhoYRUGT15uQH/71MjQLtQlxfDuiCXrtM+SkA+icQdH6sU/xz7Ze7FlubV4TpoTQ2osdpaEjtqADmEU7OkBEFoLeC3IWFFeswJXKXzkboNL+wzcFHU8hTGKIboO7CLi1/P+5F+gydQhuvRbwEgxvtACmANikhLTbj0gCYk8KdlYgmj+4Ymaod7TwahwadICuX0Cm2fE5iNHPK0x/CDV66Kyg1MnqjNFBnhBoLQCgUULfaVe5nq/6EQWY67bXCszUb+7232fVPz51iGB12owK9peyP1T4raMFF/OEYJP792mgXYfZ04GHMAhBkCSmSj+dKqRPgVFGHbpLEGMiGFeQWfSgrY52VxaeDUPSNJI0P7NoisG729HHl78z6hxfs9rV3m4JjgM/lsui2qmThjCfDFSb+I9vwUqG5wwL55U7C+6ot8B+7N2o6r3q37T9trfpjgmTvv7PSQATLLeRAOZhIJHBQfDQQJPBdUwEbVW3+L08EcEE/9G4ANrCeWcnPKRHDupbNynMx5AA9IRYLmrc/YLSiD5EaEBS/s/TgnU9ILcH19n+CpHwegLejx7Mn/d25fdN+e9U/1vgb7bqf08MOtf8EXxaoh+GY8L6gDfhvs4i6HQ7seYI2sv1GchdMsBIG3xlvxcCRzdgCPTn+6q/TW00VE8Q9FaFv+R2VlOM1vm/hhjhDCdgNflVKME5B47I9xT8z0YgPAJ8myb/LqHy36j/Mwqw9AALxuO1JVjiuQAYLcFzIhiEPe05fk8tRjGw7yWQbsfuLAT2VqOId1osnr0F49VM8INACPHDoBz4B5mqqSnUgyh3ArjXxfQH5BbgUS8gP7aU+w0zHD9GGD0CGHf+P1p/DeivlhU4BbxR9a2kYFR58YaDZCUR2P0DMmgED2eg77puegy6PgDphEB0CwlG/i9d+/Hs34pBEQrBn0W51mqGnJAk3ACCHeiqkQ1XFQA5AlKH7Lk8yJKWY3/nym14h2C3JvxeMwD9ZVMz0BPMi1n1RbKl1cYhIVblF3G0ATsRiCMUvoK9//OgcwYMoe+ZKOLlC6/Xk50br9NFz9fanqA8UIYSpCwlBO4kHc4WLLBfBHVaKwKgLQjmP4Un61Vq+3s7Bsyi0WztmLjJwJwFeE0I2vD/1Q6MVwefxfUf32skCPbCnxQqf+QMPEUDHZ7vGeyj020JgkPXXwsldA7SYR1RE3h94NvNtugswcgxXEkIcBPCGZ1rmrgDC0A4K88nm2fn/eTnpQtWyZfybRoK8Dro4zYDIMGsf7saTBzvX0SMbkAD6o9CYbsfMK38cJKD9l2FJt9/VGs0h5Gib33pxMKWNsigFUh3G2un+/N1WUglI/EEx8fq27vUNnwsiOoKecL7kQS8VnWAGCFUgn6dBtQhv40CmIYggwK0uwDHRGAuBXVdfwzHUjZzATLMAoyJ4FmBhzaWBlrHld9CCWpPHRqofBqMReMGTJ78q9rDes1Tv7/0m0v0AFHXNR6P6g30SHivin7V1BOhh3iWPwvps/yE836L2XiwnUT8x2iHgfqhnwn667QHEE8oLQjEvtEW7GYBZDrDVkwNIO4G5GiBDf9fGoFM6n+vbEtzXwP6u9AduaWnGYSLAlVdl/AU+ikrSeEIKgwdaZ4AACAASURBVKj4/wtgHcHtdO2nWKcBkPfxcvnNQvsj2Me9f02r76T8q0IBn9OLKfz1HX8yVXQYGoAB/2UeBQ5/5kCL6+H/OGGoRnLSwdd3oH8r7KkGTbgIxEwVWvnF8KOpHnyzfF9Jod5Px+IF1h8owyitDw/XEgRb5bPqbt1uvn7qBIQ16vtS/u+DP3cR7CH0WWJgd5mTJKYgNzoGjQrfvu99NDBC+bnyW1x/qhTatv2OaMKgJWPvv5kwnMgxHYGFRtJW8VMl3uP+MgoqSZyWFKr7+KIDw1d6+IiOgZI4+d5iYL3imzbgyO+tph9t2oSBxOM3ugHtPoFZ1LM0hF4kXNEBssvVgPdjdXZWK7uKvyS3q1Xb1WQwtVDqSUggq+Vw3t56JA2cz7PXOwGNW1ecwxPhfe3QEUsDsFaAz8jg0nf+iZMAHNg/XSazDuC18Iq1HBRrOsAQ8NLB+16g614jmuSgs3bROxE55D+WDDQNA4ivdMJ9M1b309UqknaDU8ObV9/PwmMPATvTMAxpABLBzugUtV9bLdhNDQA+7B9tQJ06/7QNDHGSwtgZOCIA47InIoDdROQGtt0U1HI3GaoUnCnC/rzBMQJteN17+VaAzYNA7e+PFqHQUyXPUYB7iQYa5ZFjq1Zqpx8Uqu/XT7+6BWC1Xaj0GlBIwMoHu7UzcI/6/Acb8KIq+hzmGWmAYnADrIpvKP7TZeLaf0LAeQkGgebbq9FToI44p654F47tekKkI0L5PQNZPsDwPBpy/ni+wKMN76Vav4+2cFZFf8+JwAraMt0DFB7beA/u4Zz/a+RXx0M/ct4/jwaNAS8G17eSwmta0Fhx0VRxJkHMivso+onMXr+YwdWKbgioy1jp4x4AzIKg5lEA7wvHEYCRmdx11TAuT6lDLVl4KvXkAET9P4RT8H2u+lg9EPQIpw+/NpJ7RwE8HaDv/Mu4f3OdNkq/EfAiEiOANjEALvcWL9gfFV4NZbgbQc6qPky4Pm35QZxtH1f4j+P/jXuaYPcWwIEH/fmEPBoAO4m4LGxV3txOQqDU+dXgey+UwSzuqP++uImO/u/6ogCb7wTc1n61sL+vZi87rxnrNas+giTg6QLzaUCjIp6JfhwtGI7AjBBB9JjDY4ePYVR6ZPgN4owVv6Q2N5hhVHwNeYrM+w6dN6K1sMHZm/Ce7bHe3dzKr1xw1w4JrSQMZtgnoQHlr18fzunAszD4qurNUg/TDqzx/lfCaO6t4tACMUQ6P6htWjDPC1hCoZ8kpODzJ70MUR9AODcgwyqyPhmE+wfHYB/hvSqt6qeXUShhXH+d9SR8DzrDaZZdpSp/HxqLMQuATgDU/qDPRgOIeT8cvz/h/XC6BtE7ACLOWPE0KIS4UUjmZaJ2grBphiWgT41BUVWZfP3AnEIT6OrfoF122l2rMycBoU5i/OXoUZ4/aglsXwLzHNU++FVF3qikOj5HXm2PBitT1WuvJRAB+6O//W0/PY8vQH5IrAsMs/WuVmAdHBrQgrbOxJShXwRSsu08h8JMBpo0+aDTALwV4tbswgzHrftG/dJKIAQb5h9KCssWIMeto+GYqG12/HWGjx8kzqNJaa0noMWOr2KwW01AMwJoNvhMQda2/RKQP/3ecABM3g9uD6BY68Ntz9+nDOMb5iV+hIE+dP/Zs/wwJhJ9mgBnohBuStABUXjugF3hkXF9ZZJAjefKdHZCc389LoStKvIl7QIEb1d9RyciQgFDI9Cjyccc/23Aam7/PZJBhgDgin5CtQvbCzX8ip9YgIFtOAt+w0owp/hOiCWgEGbVHuYjRigPGR/YOnEoqPDoV5z5YqB3mRq2ox5ICmSSgAP1Ne+XV2NE+/vuFbCTRADxtS70VRBCjgBk2OyDUQiUgfl77b7DwaHm2rAZ7osRSOOUoHgKfNBSLI767+oDYrfwZvqChSpGfj3pFwZFsCJg2jeIQQBUiyI4WgD68ww4qO8khuWkkIuDrxWv2nv+UTBpJYiPd0KemTA8qqFiuUF1jWS3BoG6pADJq751JqBI0wvAVPyMQvjcX1zbELltKK+zBiXRFiRxG+b7q3M9xuLdzR8g0gCGNzSM5gNYfqGO9CBT8OHct6oB3KsSDBisUnwsFuISQaRHxDSv0vptt2oeLHMERfRn/FG/Cx01EpgIQG8LP+/i37PKw53xn6sYCM4/JwSRrCnIeB1ZkLsawDhaPKv/njU3wnZ/dBdGE8+YTHSG8+ofGgIjsC19YnwdM/KAnTSsqj6ig7uGgIPw3nYFzhhIIvriAxFP9CQd4HSlnzgxONIdrE7A8ZDPx9fjib8ifgegNIliRgdx95+E1T7+3nQVNNhEzDgGA3T2rEDLduwtPpuuouPcs8swwXFjdTaMKt+jA5gUAQPcf95KJQxYU0cYxEDvsBSmYuukp7AwnqniC9Afa5z8vboI68ImT0t26CvwBzSggkj447r9IojvCn7U92J/Hw0QSdwZKNNjxPCfSxRqnATkdwpOwh88oc4J8KTSm/wdbZjrc+4iFP8YO0/5JJDCfaijK5xVXevqfg6zGRrQf83chvX4aRfAE//6vv5+6490U4ADdO7QgM/5bcHP/n4OtCQhBEFeDWSvos8DPq8/IwzLzjpa8/U6MMSkBklDm8e0mn3QIY7XG1Om8wzN48y7HwhOK3P0/ZwUQHHv4psbdoVeb9VlAjChBCdtDDpOKTh9ZfcagOYq31RFjN4/gwBYzp8lAwYNwBELhZoxECeZxMlAzWGdCRV0fQWGHo8+8Kx+AAxnCIzowAxy9KvNepWfsfp4RR9kUrD88CPVTuXRybhqqTHcnxEGndsgub1Gdug8yz9fHt3Hpl57x/mfCOC29FOSQ7/noAZR5W3Ob24UMpuPYAYiQrQgk1gnFoUIKr4vKFpV15pHUJO3Y5rfH3UFHU4bGkU+NKJ9f2hJyOMxDBDpjAgwiYqvk5TqNl9EH2Arb6fA3yaA4cBtPWewhkEcIQJBlGzYp6zRmr1v+e3Fv27xpzvyI44NGDkCIi7CGNV9Dw0M8NtHC2vUwHINumCGNG8erxOwtQINsW88Tlwdoc+F85nI559ngEDpt2F/Uu3hiXYrkN/pBFS26hYDAkFgErMK67y9mGBA3L5ore5izf8b3n805MOq/t7XU4WHv1DUF/5gugCSOAIW/59uMwl6CHWAib8bvfxWl9/rBGEMTTwDfG+ezEYG4yk6FvRPuPwE+wvc39IRjENWM+/cm5b0W4Pf4WuKUnw/vD6eDbB1ETs5vl77Dhnm/51g6wPWwQAqxnivgQaeS3gy/u/1H4hpTPrIgHAN0mSgXUX13YP5PMIuQAfBr/f70cdeE+QoCX3i8nFMLcAjInBoAIYqt1LhC1WdtvmSab28AYffaeivCB+ohdYQgfUa/WS4ToMsNLHLc9nnvPZLwn1/EefPVf+U/xvnCVSEQEkEQEnEQJO7S7RvYDxNeNYKrG7DKMhtsQ8cMmhgPKKKj+F7CiHYFR5KIIPxOmg5IVAtu3ACQSPh7CzUQOgAej5CWEkIe3vgxz0ROGO//qYfz/dnLT+ZxDr4QW0eNCJBorCFOVC312Ec2TiY5Bk0cAaQmiA1VH1MOwDHQ0kHdEDDf+2UTWhS4Z8diQMicLx8MLBfverLcP/jQzF0P8EJj5+NGK9RCz755S6F/f1+X/gxeP+Wsedv+vF8/54aSPJYFjIQd624MDz/UDLQnr8HU3ztKHRf8Qeno1vyAQJBaLcMtTV3cvgP56COCqd/QP9xLgBkH4BxO13n4hNUDtACC6G1S3zqooZ6Ba4lp/zcAFb7iERKQwQcF39IFJjdXECGADw0IE4gg674pYAnk4HoHPx54tD5daO5vxrugSkMjgiiqc7TVKAT6AT8R4ckbHEQCYR/IZBxJgA+XZjsR7vaoRpIxWqeqfXuGC2CxwudicwePEB1kNkaZCuwyF0DuKv/4sz9mzP/Qxdg3BDkBTMC8Q+loD6UGBzx0Kz6eAX/KArOQTlPHFoI4vVtf4rNuLrca9edRn4xBP7k8w+9AgZCgBfEUZWfEs8iFNZ3UO7TqmkjCO/rWdgco/yIqHcQWaC2EGTzgz5y/iXQAvyx3riyxxV/JeBriaGB9OrTA5g9/eokM+37GszqfA/UZk9iW5UnCtBqBl3XoNN6Ag/+zy6A5evPAp+TIFDn15gQw9rjrOzFX0s2JBVAxa/nP1a6AsNWYGjPNGPLTQgBsNUFvOA3Ht9o/rGDN0tWOCcxJGp+f7++kkP7PxcGv1+GjkaLt/fawpwwerQxBJNW4b+PJsYEgiAYYdEAGIlDNaAbRkIgK3ut0jKByp+8yz23X6GttmBmjwDvChgiYLP5V/zhH6/110sGcKo5CkggCngxnIPoPja0j2B+1BRkiYJiviaLJqghDI63G2nAgAxMCuDdnoD0wIQm+urMB3VuAwbBrFGgGgnhAFqg9+ujKsLxB3qGCQNEEtPinIQlAj4WgIw7/iXc9V/x/yUWFs2KH504bAh4aYWf4TrTLGTy9YbftyLeVOWNfYNyt/ji29mQnqMAltU3ioTtbX343yv/1u0YPUBz6zB702tQucnX0gWaFh6DgPdmhXaapGotw0SFz1qDiTMdd8h45HfcqCPRUhA3+NmKz1l9teCPaMd4urGaewRitNBDdahR5c3AfQmDCFT9vmtQEwqAYXX4XI2n23Z9B/Yb1FL+LWox6wHGbZSo6FR1LzyG+3hriSZvWT6jfXhl2cmQZJDrAbuYAqAHo1GA/EOgD8eGcU7A8eDvH4fQBuAhBL/Zp/vamPTrRENDGLTV/7E1WEPLDlP/PwzU4YhusIMUgfIPAr6Dhv5R4y2r8ldFwiFoYHnmr8TAHbhRQSZOctH598ZYhqt6wP7q/ouqe77RJxvzFYaji/z4vna4v5cUMDXqDAJ5ytktqtBDckyjvJg04hl16LB0xFfyMfD77PZjErGQRRjYIfSvoAXntks0ok8MsUC4KARWnYPlJBeIgLeFrUgDOHYCag0/XNAbWgRwQuLAsaQwIhC1g7+jCNKuT38JfnYSyTi+QQEwwHeT4/dWHYxJPxfOj5oAnRQqgU3YgGZSOaDyK3n/qkDYBKptzR3oD6B4fyRKjp2AzSl80YR/3P+/1vBjX18Jbu+YsrMRgbqPP8zrDLTAaupphfeZtyPs9BPztpLSBZjowF3woYRwBwOWaqbev15b7X4RWsiqYiY6ZkFEIoUwUA2OrkeEQE8HYNyD/rl3m88jCGgO/nPW3xy8x4Q/HBcM1dYg5q8N+B/SBSYhtD0EY1PRGLDoKIBHF3yLz4H/gSYQJRETgqeB2d4vC8L2NVnQn4PoVJJAcP0inahAfdXVI8CFszjRagCTtRdV7Sr895NBpRKXIT64RMFw/iw5eChhEvmmyUIH+k+Qu3cLzOAN6ILlFvgWnx3YWFDz0f38ze9GlfP6UQ3ojEY0gtqRIEbA5/WgQFhsEuIeL75uTzvqHktAWfj/OD6sQXssROcGiRgFn0QVkld7OznMDT7CJKzhMIqxW9B+LCOQdH4uyxIcE49VTSeLj0wKjzcp2oDXQA8YoDEGBLMW0BJw+eAxXejPV/IXd59/tp5rVyYXDw5BlRetSpQAcvgfOwVM8ObzBq/AQ2wX4lwkQV3vNhYFfn2LFgaoDU1ogqsfqGkJYmrj9Tr22KQwBLzbLuzDeA9yzyJjVRfwegWq0H+FThDPA6ZhZwX2M2Kh4waovCzAWJTzD/qY00c+6PM8coz08VNqglzx54LfHuTJK7z2rwX35ABLg1DzsZ7Qv7l/f2yXDlbf4C/irg0MJ0aCuD0wP74MrxfdFlX7tq+vtRdCpvt599EG9Yz3V+P+Oj/n4zLruZHcJ7oMt/MNp9eD6HEeFb6/TMfbWo85Pb79HJo8t3371/PuIAZqMvjPC34nVV6ZB4hEuA7AzA5cfU0y2n6ux89D/35/n2/vWY5Bf0qwf3tPLISO1Tap9qzFB6eap/beqI94NCCbGwgqOItY3CGl446CaQ8i2Q9g0AvmgJOnBoAA0gu17tsKtKS7D4udgCYERy2QIceCX/P7mBW+g/7D9S6Mn50CS0eAoQPDcBjopIA5+EcxEjLweRjXq0UbLIjcBxsGx2IZvlf0ATjz/6qypAmY7bhrk4ahsIis6ccXKHdueAfUgk+RWPCLh42c6zEeKyJpRTdRAOqBbl/Wq/uT+q+Fx3FoTIuCzc6+hN8j4veGjuAnhSE5gKnco3A3XwYlq2sq+lmP4yEOpqEoG0M+mGDYuYT0pKCFHgLHKt3T7T9p8GcWH+n1UwGa8X6kQt2x4CeqPexegT6o/Z4Cr313PHdgrsS2ZReLfpKIf+IMFnmVmwxQ9AhithYT73+p2s+JIVfrjwiHnpAZrSsr9CMstQXP1+1+510N/q8E/YoekMN9OMFvi5LvkRDsy9rgFCOoPdpgaQIWBZjf5KCSQszZJ1ivTvLokpen6tsJAVND0NFqb6GUGg2Im4Dyx9Pn7/0dm4pADAslJzTv+dKNrAPQ0wyySm7bj1RQgbAXsRa4R+mBJzpaQmHLmy0BLoL+Nh2ZRca8uUc6P37k97n451fvTieAE8BdZ2ItqFEK6oOJIYPsiU4woo140Oh+H/UC++gatHYcOFT+2y3AYvD1rM/fpxdUcsAi70c0OxAEP45X/hymE9XeoC0zfYhbcqfbhs09HpwnKMDR6g0mmYyKth/UcLl9ITGQ8N1S6s+gA1HvQCc2pluPvN2Br8SyZyfyxPP/VhCi1L1HWX2CQCuAE8TIq/sBYdANZmTIwqq0sb0HIzhhugBeUpBZLFyA8y+EErsBUYDZHYN9QAAooQwOws+uQlhdESSSqk5Qsh8LSYI6LDS1AbmOvLlRBqQIeITvM36+TP63VfE5hFClCTr9zEyVFwS3STQBy66DMHB+PJWIrfgGnYBx2dTboPa2X49GaBVlePA7CFx4iaGi4ns0aLVjMGvtPTDtmO4XEE8E5Kb/8qYai+NHl60LgAICcUCoJPVeiYG6Pxw/X9VFNVbFn9FNPzXoIRDTyzcpREYB5Fm1EQQn3KRi9wKApR8Tz48SwxnV3qM0q7ZhpdKvr0zfY+gO4oQf+EGPFYW/Xf5hwWsUgxiBbShGoGIx+D2eH1h2EeR3UQMH4zMaUKr4033nzkSkfQADelFbLOQCalxdxvN8mInhPas9bxtGJw29Fx3Y8429MAS0fL33Oeo7qFZeiToCC3B/VSNYuU0fgDnkhxGgMFdxiYEY7MYel+OHPH30IMeVFK1C79l+QdXVpFqHlMAXEf3EYDyfkkGdNvJ8f3RAXU0jpgM7jMNA5yCrtfzOicKG/M9bgEkEjqqPPDEcDfqVwGZv6zcO9avDfOhf4OmLFd9OLBHHdxp51HvOBlnAoQksYjASA1xnIhPsapTCPjbsGB2YevpPpgM73EYeSYIftgPgte6CWesVBB9QEgfnWYMgoeC8ql69bWoRIqYHvSIv/u26bj/jdqZ9KSGk74JRo6QS9PuTiSHm6Z62kLUGH0UO4rwWrhtRETkR4iKRdI8giJ2D2nUCMjsA0TXiVDb98NAf/rCMlajA9wesWHZrAe1dlwRyVI2jx4KkyUHSx7YDe6YD4tOC6XW01puEdAJwaEJzf1uATHi6ZlSCpBQscsh6C1xRcWEG4bCFeKcAVhVlDu54JQIkTT21hptIT/Afk0kMcS9BKfjBJozcDXCrtgbWXxbMAw3INQIxtQJPAGwXmYaBbYh4SCsuKwLOAQ5awKskCMmRg8P3xwlBfbosQaDqyZqBkyQe1CLQACoTgN4qbyHsPwkTiF2pYaj6MAXBmUosQHnUEYCsBL3MW39SNKMJ5PfoBsT33DVJCEbFnBCMOkHfvj6Xq8uw+dgRIhGgAiUqf5QgKDFyhe8nnYrlqn9sG1GoAfirubygX4H+8IM1CmQrMFAJ5ExzKIp54nPoVU2Auh6eBShDlTV4u5c4HE/fVvjFrsII0Ik6QX+Iq68jB19ziLoKC27FYe0gC+j1RSS+BgB7AvAM3m8HLdy5fV60C8RMVuhD1ieQB32MCCq0QPJuvuw5IHF/geMKwOPdpmsxBwVEfGEOgeincJqNmuSFIPhPq/xM81CWIIi+gCFBqDX3QPYd2OcCRo6GZBoA3AM+00aesAOQ7/2Pe/vBCXoguD4OBD1WfPwClzcui12AuH+gC0gEwW72KfjBCQRBr05D0IQc7N8PzOCMehPWK384MPVDJQim7yDdoiRTItzzFV/ZOX9sYFetP0fsQzb6O7wOoFjxk89YoQXv+BmSN+yYHYO+BsDRAXHhuJXsEFbdIEGZQWUkNVNzGA9NZUVBIQL7jASR0AclE4Pb7JN3BO72mG92+o8UG3nybj+mASh0FsLKn9GPxDrEcS2Au35BzHO1BksriIJdpqWjKR1wlpR4fN977rZqI+XbYjYDgVDpcYQalOYKMiuQbB3G6Pu/HlMbi9a0EMkksXtjvvXTfgMKAEZRN/i/O7yD8Da2S2Bdh3ICWfp8yuMkYl5a4df4vVWt4UF0yyqEnaT6swYyWB8/j111Y1ERS9oB0SLMtBGDEBD1PEHwtdjUEAHnqmoHU4wCDAoAS+lHwtu9eQLUAgmxVvAuMB9cELMV3m8EUtcBYYI9nkNIEEJYrQeUHfnzzRyC39j8CgSkir/E0P2odnAmAqDnDIhqrtV9BDNS2POjv/0pwKr6z1h/PMz3uf9ykFYq9TtoAXSwpz0HljdvBCVAPY6t7osv6gFhMpkX13rcfXQMIpuTsfTibkfOPRAC2meLRipI4mDPwMD5x+v3+Ey+qEfACwoUEkKQSMZxYJDz9R68PyP43yvo2aYf881rNQbZgRU/jp80QnW/hdXqJxMvCFxXQSNHpE8QiF4XI+wFfQcw7VL2Md7RRajsKgh2D+6SLAKPF356+/7yXYBTUgFy/38StUjFHweD+iiHh8/LV/i/TSvGk4L5x7F6AsIKbgb4C0YjgdGRIToGUx7cgS3JKP8pRcgak95BJGQbjaJdBYQ1qHYnYHL8F45QgHx2gLMQ2cDxBD/4SeR0LSDi5XzPQNjM4ySE/HGG6g+ugltLNSARn281BPtNO72eJLjdX4ITSEgpQvJYFEUg24f1qAYQNQdxx6Q/RcB85j9f+03zf2QV33IDPHegNgPABTfqFR8cZK9TA7/ll0EQbUUHW8Gr1d+MSadia+LRHwhunv87yWoJ3h/pRDwJAbDNQQFd2P2mH4kP/wDT/ZeN3CK3+ZjvgVpw4r20AMafb58j4N1UMknuj6iCx883PU9g2VHVH5JX2eEcPghSgRBCKPzK0Q3fknwPN0Hk0CyC0zBkz//7duEetgFjVtypASDI4CsknYJgYDhqsBxxy29+eyxrAZX75EEf8f+CkOcijMDDHx4ASYGGu8WHgPwpHJc0qOG8FgFTuVk0cRZVePFwHEIUEu8xSHoL5qWg4I7/HgOKXe2dcnu2SSdCGIDTA+AcxY1zYL6Q6AAFu+/1GvjKPSeEoJV3NiM4Dz9C6oWkEav+NWjPWXNOIkKgNTi2I8LeBgaZHJxqrC4oNXoB9pzzMws/OW3ghSyQJgjbygOVEDhoj4nHLld8HPD6UUMFVLIgKrTL7cFoBRLQgEdXIseZ2/HhFPKbk4d5tYWwwR0nIFQSD2P5gQhs6meVfB+Bkyz2fOIvX/zxqsSODuAGIOLtPNnmIPCrv6Kqvgz3q4tCwNl9lWYfnsdHj2HTgQw5IBHwULmfSu1jEV3gDFSxTBmqSEVqiYK2IkWcRiAkwV/cyW9YhqHXDw9dkNQAcO6HFNJT7oChfrPUYc3KY17zAd+evAwF2w5SCKLV4EuCEKsKfjBVWHu9Q9Arh4CoBqEMWYBsNX7YgKP/69uC3M7/mOOz232QT+ox4iCyJGEFP4oBHd+GVvXBwX35nqp7qeIbV6L6tdZub3ueJ+gBIKgC6S5gOQFxDoGr+Bv2nzqbknd7ph/EmXzO0o+kZdc/wqvQkAOUffVMzKtYgx5Vob1/+HAfCdzHSiXHenX35/2JTr3KZ9Ruj2lYiMhLIFoNyMq9hFroeYMTE0bSLbhb4l3YlFPa6hMd2jk8dmrDgdQCnC4/+ANFlYTB6ATlx2GDGXP1rvL+SnWHw+cJes5/rRWt4H2pw9GklD4uSMpwasIQiaYR92gIyFX5S8dtRZt/nCAH48VXW3hRE/HKOsGquj8EM85Q9cfeAV4XwNGAlmIFIwPYrfLKuxV476RRetzcdeAsRSZhiHizCKEIOHn3EMOWy5X4uIJnXX6sFiBFLaBm/THOQAkVJK9j6TKwiSDTBWpwHkSPQJX7U959uAkoaTUuug6oQCBz1Zlxm0OJSIoIw04M+7zCGuYiznCfHww9AN6Ir+HXA7lfn2oBSJ2FOOh8SzINfmcAyITq8JX/sOMPx6A9LeYtVfwgCBZhdu25OB9/XmWWNPUEPD5dUuJ68wd1AqD2+w1PI9KxE9BW5t3z/igdYGWiL7L+wPv9jgVY8f0ZcbCKCuLAHN+c5wa69Zpr0J9t2KnpAGzyiAIPiFalJ8/xXrrA6Y+/8NoDnWCPNwFJzf5DpVkHte8hx76P+HU1+HEytEeSEIzAsu5r6wPJGu6oLz8VrKofXLce+ywIHhNa/Dmw8LrptWXZ4NKZm4pr/QQ7Qk8ehMrPtAF7PQCD309QgRgRZMKgAbFREAfBBXNalbHA9cEHMo4IgIUuPjjBWEUFEQpYTkhVO43eRiynJw9Jjj8TOUIlJExK+0wA4gWgQvcFBHAc7P4/u78/Ff4CC5ATB3P3oUwFClYgcALcxzp/B9Ez4DUV8RjBbsCBrMH4dLNwIDaCGhA6o3pXksdBvYBsktrXDgNJKAFy1Z+ZGIy5NXgXoBT8a3ZgVSPIUAMV6DjLxhsV8wX4n4ibbONObHNyCr8Z4FinNFjg8ziiF5zSV8A99u7Zdf5OisvVaAAAG3VJREFU/kIPAJLWX3hUIFD6o7MD4WkHIMXBk4IftSrPNBJVk0OoC7ice8HGS8XBKDoz/YFBLaQi392lGpCMJfhD9xVkx5Xbj73P9V4m1j0v73x9FjDDPlYvATkgFAVWcdNvJBamliOjAwRV0EpeRymAe717kMYRyy/j5FwFBX0fP7Dyx8gq8wn2ZXi8GfGYR+lFcGJSxa3Y84WgzBHetlU4cvKY44Ps4iP9fsgsPGEhQTAcHqwwGCj61SoPexKwasXFqtxq8qhD9SixoBBYcJEDNzmIoi3J7QkoJActVHocTVpPBCDhElAvMDK1PT/Sq3DwB/ygmyB9GNhYDH4so4Foy48kkPtZfZEv1PQTxYpyX0EI3Bu+/5krcN8fgwVdwWu2JNVNWAk+PcOOPMNdGFyAZ5Aj6gicgzNfwuHZg0HrLxBWfjSRl88fVCo/apX/IBrIvf65ZxtEoK9Bec4KZIPLe76osQns46NwW0pUPCPAyMc4A/KXOwZzFLGbAqD5xhhbgBcWfoJBAlarcCSQgdQJ+Movnih4gjZQTw51rz588y/ZgxVUEAQ8soCfX8OR26JwujCLGFAMsOjnwGrlPuQw9D/PPv8BYVR7pG/eeFtQpsLzR2KFI8SwKj9KlX++HeLOPuSBKrKeHBi7L4b+Kx184+ptAp4Trcscv69oARVYzWgaK01H1X0K3zNSmARKtxXYHvwJuT+8gLGGWgpHcWOmBeljFB2Ckg6wiAYOqfxEK3GMCAj6kIiTWdCBCXhkjUKMgJcLk271N9uLSbtvvK0S69OXAvoA5z94VsFubbmZvx4QAnXgBnJxENyQjy38wef81uPhxMpPJIQzr5ckuUTKe0wZyN57iFTWga8GvCwlh5UqvYgmaNV9XSxEVWs40kkosFwA70RgNOu8mLZfR6wDiwRa35y7j08NksqPQhcfkRBK/J8R75Iz+9C8gJpqzwiIeZII3QnYOkJWbVEI5jNuA+o2BwK82ifwnpSgHwaC+GNAdmW2VXfC+vPu6wR6lBj84C9WfvivZyUhZMJlJhjSukDlFJ3g4AvGJfC1iEpQJ/CaEd7G9wds7p71+odruKrHip/C7RdsxeVjzIxhoNkFGOW/+sk/YVAGtltfzZAIfzix8gcHhZCXpcGN2u69qWqD9OlRFAy7x2fQBhHUiETB+DocqvArYt98f+AEAXApsEmEcNLC0t2uPHCqPQIXwHYDfI4/9+8LMpchqr5HK39MJSrBXwnutNqjovjHFdq+fcHLp7YLR4mGgduW5hFpAXUoL4cTTuW5HJSkB5PC0S7A+8c+837DyoM1J9iv/po/o3BunlDqPjOSO/YbLFd+FGy9sxKFeT8b+nLNPrkAyD53FtT27yUS32yqUaEGTMBiASGcZ0FmK8nWxbvjC1q6WQC4VdWdAcBY8eFoAzIrC0b7Wt8wlPcIdE1FhUWeKU1Igv8Q/0dl4k/NnYSxdlDon8diUDeuQB4c8XVzcahRgyyZmNC+LAgeCfSVALde8/t1DCYawNoePGT83wlOpFUdOZKwxn89OsMEf0X8CxJCBN/dwKbFwkSMgx0ACJJDJD4iC1JEYh6XcEqVHpx4+J4I4UiAl26r5x64sttvSlAn3LBuQCz6edU8C+J5epBrC4YP52EFDgHrCw1B0eU9bOaTgh3wmYvQV3Oqqcf53XnVNXUBELX1xtSgFrirlII5d3HFulxBCNEfZx0h7K2f34XwdHpuYQcguN189Ow/nPXclaUcqMH5leCXjKOjbv3F0a7i2ZaRHmBe5zwnhA9S736ZC8AH8LHkg/T5znYgmES1dtuzGo92qwHIquiWX+4KgVLd8utv9Ml1BQNhEJW/FOgweiTguCUoQHkEwYhjfQIgm8eAzPKzHqAG5xGiiPyxeGRRaYetUpDVpHVC1T9bHGyaknb/TQTnuG7rDYwYCUT7/cMjtILzA+Go/FPw581F/mWeTkDuBsBCAK8ki+A29nMzPn4Rzjv6QV7xWW4fzQFUxb9jQQ1qc28kMi4mDl1NBr4usIsz5ltZqNm7AeJXfuTHd7nioLEyPBISU+8/tP1AC4Il/n+YGmjg2NiBRdl6yCw//zG5ph7bqaBuz8B4VMU/TqSsNPbwCeZA1cdxyG9SgKzRZPL+GXFOiH1/SFZ9wX8M3zUgvH8a4rMBjZj/h1W9MrwTiN6MlsCKiI4gycBzgV/xUaQGjGDHwHiYi0VIzeEAasCpNuL76AC7BIEl7i4AIxnAfoMxk35eJbZ68wWEUChs8IPz/EEE9BkUoNA4RCWSLJkY1h0Y/dG9bVCtUVPe7QRhtStXG4nOECDfUxc4Uw/Ik8JkA9o9+a83IrfHH11EdFUWc4phNgVFWkPsIHBnCvCCYBSgqEN9qtoXuwHhByYoJJA7BxIkkRwpDGgAHo+vQ3ZGOwCFJCJKUAx4MBpFZWvReeLgtBBkDDQu2OJxXa7SE/P4ZiUPHABjY1DsFIhPAaygWewiXK72hHjow/k8gCL6gKES8qcDZ7A+EhYlWCPGCX1wXIwzkQEKt8cP6iqkC0FEhFj/ZYtvXCtwuBLcDT5wXN+9H6ZEIkTwV/x/s78fXFX3siWHEKrC3tw7EFZ31Ll7ttknQyEMGgAqCaVe1bGk8r8nFWCQQR0h7CY0dsU/mIeIuA1AGCo02Q0YVXxub36sG1Qgfo0CBBUXxap+ECFEycQVyViBEBFPt14TK9rZHB9EwMG7DPXOv0OVHkdtx7OSCXfb3av4CFZGTwQBwT7/hKPHE4PzpJ4L4+FM9r1n8B+B+9R9I4Fu9brYUZgCunZWNxdQgIs8mASBQ4F8hJpEiaf4GPihk8FdAxin/kybjZjTj+mAQy6ihZ9whDvHAWB6BKrBXQr+5SBfqPaINwiz12UIwoTmbPACZY/fshBBBKNlW8ZCHwH/cVKSOZMm4Mxk4OwE9JeB+EFkn1IzcPQoiSB4vGgNeJSoik1A7m0TCmE/HrggB+/1M12C1Z18ACGoIeH1pH2IhAqFWgBq+kDFEWAvA3X8tpW0cnSD5WAOriOHhnYraF1eLTkS8P/QsHUBdtMPnOrMaANJE9AZiaKWII5Ue/8PTHn/UcCSTgIF2xN4zdmAQYIAKeBFl6FiO0aKfq5jcImHfPwTxcEdRmD3LcFoAva1Hdjm9UgGggI9YOoPkOBYLsT8HlG3nucMDGkOOJ8CkNOELdSO7D5qqAeJYBb2GpABgRi2gxLITgrOQ9C937HgB+0i7MeRx3gfPWCXLtgbLJAu/gCFBPzRX8eADJqCvA3FViC/BlOQC4LZyrBq8BdQAOUKoKjqR7v7EFfVFMojPgEoSlJesNIePyLHwW9NRgq7E6HvUN8A0yj0wyWDHRZ3J2A1jHdMyu3hCGwSDwdRir7h9VP7AKLgPoMCgKziOFLtrUm8aIFHlgxYfz8WBYUU55iAXauo+evJaIK/NTgRJM9sUcZRzcCnMdNKMJc7usnAyrpxHYkTRHK+n1HxS01LheAHqRWwKIDqLvQC0+PupHZgBawfVGsiniTVHwZHRqbUI/D4Cd+ftgyLAR1ehkIiqaKFw7MJEwUIuK5zsu4svoFYCFKgBJZACBuppOId2RDkPZas8H9kULcA9a0KTCQDGtpnzT+RMJiOGseHl4BQ1C29AWUXIIf/OIwwqoNEK3SCuA7FRiBrE9B4/PcrGJ1OQNj83F4Xbol/TgVHfMiIZLAdcaVkgh8sLrd+liNQH/FqsNTfj15m1J0X+ffZuq/gTY7QnvIfJz6UzBJLs83ItQpt3RfZz5iuGfNPajpngUm0R8DoA5jDlzsOTAwZjzsC3Jjxg7H914PjlcskGdghgx9HG4OOQH34uwQyzz61/0qiYNQjXxECuWYbGM/DrjtPH/Mw/K+gBLLSA+cEfPr4MroArzcDuybbr8Zc72i2UnzeHnTgzD4Ug78SzIvCoARVOQxaFFR3TzWnkkHUVFShEuqKxZnKz4p4YYcf8ZhYhuu8wFgSHcuuwCJagI4bgchJQK/qe9c/RT6nGcg6KGREJpb+MI0EY/b0jcsni3AJBeCQNsBOFVYoApcM2Aom4VFgIRdHpeIG8D3YaxBD+qCiQ+rBOSVnci8hzkAG1t/pgHA4uwDzmu8xFKkkkIqCfkIRs204r/hiDgutoAAcowBMZ9+KS0CcXVBOHCvJw2jMQSJyeoeExF2DuTuRcuWAo9sefyUQ6/oBaIjPtiRH1KvQKvygAHb171d+vc4GRMDPoxN/kL5pwlVh1mBQ1quQJAJ5j0TgOAis+h8d3mnC8xTKE34+8sDNjyVXE6nFMN+H39TQDmocHScENvN74LoGScGU4f7g6IG3n3C3qnG6JBS+Z5tHOOzRYQx+u7MZmAl0OSsRLAS/VIKfRAWU92+12aaVPksGDBWQuCMvgNy2M2Mt8EwqbjosZAec5xLEAmXmcFTHiOWARWglpNpjdEtBQRxJJU5VL5/7F1X86XntXgUK4q+KggsUoIIK8oA+kgy4+zLaACqQGTVOX6MBWdehL6BxHn+tlyBMDGAqufd7WOX5WTJwKYDfXJJP2GXDPk7Tj5Ed7BOG7DMFaBRAJgI/+H2Ngeb2SKb0zkoGlQBHkefDr7xMA5HZeJPtKIzyApI9gmnPgf1c3mulfhe0gFekDCdNFnrOwi4Gs6eTACNjB+Uegcgojog4V25P8bctRYY6RL8AJklE9ACFAGZdBEahd4d4CmghFhbzcwaXYH5qTlS6DY+KfNH5Avzjo2JJ0poDkSCMxLn73H/eB+ifvgvyIFCWAji7BWC8hd0qj0FziMdrS70BlVbgamIgcmotGZDNPwm0L9l5iHv7WRoAFx57ScFS2r2iwot8oKu8l+TOCOg2mZ2nFdjTgOFQENzKkJ8OjEnsE8f6AzyXwT6MNF3RDRnuj0Lwo6wTlBMDIyqaz6G+RiLJMg/KUrQV/rh9uH0tWduwoxmky0kSMQ+rnXxZsGadgnxfgk1pCnsIsGYltvfdzTOBIclIsN8MLAGcz5gBwj94AE8DuC9Molip/JGwB57nRyJiyD3pyk6q5ij+3TzRLohcqyqCEQBTepF15+WVmW8SEr5jMUUkx3oMIsrH3ndwAQganKzyMpOJNxMQooGBYwcByw7axIhgPRGEr6GSGJhkAELoQ1YRg+dPeD5IIRDIqq5PA2Jh0Rq0YcS8XBi0ghGRFpCtWTdum5+yLOsQf2EuYY8AfnbQZDgCjHxBSKwTGpt8QCIDVH3/4H5OwEvldhliINwAFLsEyyIfGKV+vm3eEehVqKTdNxtDiPoLHCRiuwTJxCECxMDqDjTvZ63KaPKvRgV2i/F3ohm88V8LN8hgJcXD5pVGIPPNn9EBqSQC0I4AMxBUcQNCkarkFgSn/oCs9GCVep4eUG5BRAOcQOCWlGSc3If0IFqRfURQGRrKewPKEJ9sLnIowKCcw+f48N6UHjqYtgInaCCkBbPSj8VEkCr2g8U43wY1xX/BNkwreQrzg+oaJghOCGTU8RBxuIp6VFOGoEXgEsBLIgV6gBgxoLSI5CgiYNT+GBHsU01GthrceiMUtv9KgAYktgVNeGrBbtiOQVi9x8WjiAW7UNUnm4Vet7WtsFgDCDYEwQ/EVL1PnQf/xCDLTowTh4c4HPRDoQaiwhKIAae4B7xgCBydI/CDPOrevK0FR4p6w3VfoXgQiB3T1N8Y1PCD0X19JqcHGfzB5WkQE4p/kdeXBcEVUXEIFqSij82lMyrWq/7c+LFHA7z5/dwOHHg8s/Y8C2CmhbmALtare+4UWLfb25BmXABKABTniC8gRAP2yvDAiUAsElnrxFzITQa/sAFecAOY7zPV/8jMQHSbWAiUPGkQNABhw85xrSCv+mMSzFR8+7mjw01A8f4F8S/td4jnDHYxpT8/OEyV3gz2+GTfdAeAszswfJNGlQhEIjB0Bls0BKn4Iw7WKu9f1gmSagmvqleEwJwnZwjO7npz1HdCJ1hS/mlBcRXyF3i/M7NxqJFoeH27z7nnJaBmpUZKHsTbGUc1ALEoIGsGYl9ixS50gjAT/VhB8IzvGTrBVfWEz1MzAkRFTtecW731VdjNQPukVdhdn0Y8d/a7WYH6i/TBPBzUFwAlHwtGHOQISrgb1AMUgDETTA3+THAdeRJhg59V/Ektofa9I8wxVICkC7QQSAd2O3cftzPzdMK6aA4iZI4ILfYRbb9RgqICt2AxVnYZ4kkBvHOBxT/zN9ybHx/f5Ql2fkGCX6ANm6F8WCfqAS+Eq5AGcHJd2IFHagTMHAAj+mWBnDXuc81CjhsAi5dL2K8QCYI1aJ/PJtSSxEFXASv7C2I3ZB9/a0j/7nDn/j1pHsz9Jr8fNpxPBUAUUYD4wz5GBlmyAiORjtAIGDFwzSUwqiNZ1d1tPiB7/Q9VeI9KeJU16/knkEeQJEALjY4rkp74fCZiMDSA/PgvT/aT2gYgp5E/P29AKBQAo6TRth5T4VesQFb0i4K7RA2MZpgyFXCEQHCOixuYMPgy2L7+45ezSSKt2oUkURlpXkEMOLSiXPuDQZjk63N5bmzOSxQdLHX7AhwUEA0BAeQPJIQzkAuFlOK/GtyLdiGDKEBdllQ7YouxV2Xdwza9So4Kp5Z0yAgUhTlJgFzSFrznIHYIwKcCu2/L3LsCg6UI1b1/CA+ApIV5/32HqOIjdQusE4azip5Wc1b0q/QGIAlaWEJbXP3r/L+AEipw/+BtkQVY9fIM2i/ZhgVEgJO6DZ1ksVtlYdoQAPhVO0oKmYBmnAYco4DRCRB3TwCziptaE0auER9/VzRqKNOEYINOQg2m1l9GpGNQAhh1v6UmxNQh2M4+LmlUzll0OTjYQOaGlZAEMCrdhmBphaMBwBADrSQQc3//He8KgFETT7p6BHnjj2X9EXsDjrgBS6ihoAmcSQVYmE4JgYWFpp1waAQRoqDzxDhU+HxSnZHz/9JEY6Y5MJA+cwoWrt99+U3Mc/9g/NQTFaigAEtwB1yBzwzucZSX7RZEILhR1d5GDCsBLVUdIQvsldZfEJt5i/MHx2hGJZFkVVyK242iFeh58oBUFqIQbkfp2DV2X0CkAYgv1sU+P+I/HmBu8nErugdRnUWhfp+A/ddlbEH3uQlBsNobUEMHasK1HOYn8BEEvCUaiuigXRIKj+sGOPA4KAWz9/s7WxcgB4+a6/fI2osEwv4yOENAiPf+wQhbc/5f0gGisWuQaRFmGoIqguARWsBQgTTocDLMT5OJUQnhqdCEig+/EShKSEgTVV0MBMnz04BcshPnLk/+OaV0/dwKzB4QUt1NB6uTDfGOP+cNm9mEsBAFiM7AQh9AKVEU75vy68jeOxrUC4mDEuYO0oLqoSdHaEF2eXYYSm0V+oEOwpLmYFOF3Z4CmAeBTIGueiIw2xoKPzDBJVBXQ5g5O8/twwA+QguIjJt3+g0NQEcDfUXgO5gsqlTBLkQLdl86K3CWneitQ8sg/5oWAUJP2C3V3RoEyji5n4b9lB4t9pz2CA+cAFn1Z9I/uzYsU/ELtEBOCHYQQqGcFejV+yeuRJX31zsKV5IGjway9z6PLDxKwNEPsBuOEiqw57jGgOtZ1Y++T50AuMFl7hPIbhskiOwsATtRoc7rS7dXrpcgrMCGJca6ELJo+Y0be0BW5ZKGcFz4y8W9BduwcDnK9iO5fagsKpp9ANnvDPxeP8THNyIVFo1AMas8Qk5v2Ytm0LCCYAXqn+wQsPTBh/5Bcnne14Os3uCQt28vsK1WUESJFviBgAW//3u9PLxusXchcCR2WsNzv/ImvgZzzkUByDUAIrjTvmSHAowpJBQE4SUlxMxnARlQbIqkArVAJ6pBBvELCCKlkyCDAP45BYfEPfcUpfMch3Vn4bheYK4E66BxAxHSVd5INgEPgU/NBCDfNQ8Ho1CoINAPQAW/QT8OCIZlNFCB84XhoDChFByHGjx35v9BLgyhmojqHYb5QYXnuAecvua0hZe6BV9f7v4ibvgvamrmAc1TmaEir0LQ9h97eYAYVoM/nWA60i8Q3Ifezha9BqaaL3zvqd6IAuwwLSCCuCLuJWch4h30giPtyiAphKEBcCu9BV5wwzkMxID8rhMwdwMhcSFgrBT3RUTQboAUg3+p+Qe1IGarOioVnazmefV3lHpwA0AcLWCahUiXwePHWJsP+GH1gnp/we5KfOhJAbsj0H/BIEb04TbrTPsAyb2LLu93KwfCvn5PLAwrOXAa72eEQRo1CNdw5IprsAZ3hApy9zlcITG2vpCihsRSYxNS+J4vdBZ6B52eqRcQ/QXmSjAWSfa/5GA5qEg4iJFtm624AqXLrSA2gx8p1Mdqcghv41S0lSp/xAYs9gakQc4Ie2RTUYwYgt748mV+FU1Xgp14eW3XYZ6cdqGTNHwHICTwEeTPl0jEZwIgP9gDEaogeg5IHWCF+1eoAhvEKPB/EAeTRsM/pSAP5wjWEUMM1/NJRhwJbpJSgK7S7zF3EOsI5jBQBK9DV80Z8Y0COzvmWzJXgDl40KEC6cqvqgi4OB5cpgLFYK/1CvDiItXqC6/S87wfAUfPtxqfGNzlYaOjlf1IsHPPvffHgDAoEeEST4ZLZUd/RSo91/BjXY5ggWgQ4In3fyj4mUqPrInHOCLKO3wUwRsfyXpt1nEIRLrqcWeTuk7bigsbid1zD4iDRQtnIdQsyIXnFCn1I9D7ADgxEhOvR5AJosoUbu1FkJyYCi9OhQERoIx+4AX/YqUXQhtYEwKN4Cy1HntLMmtaAQpqfrT/UCoLSxeswjA5UWPPi0mjajUWxMTdVusNvt/ChMdmILK5IRMFu90BMEzFYHdg2GAgeYVHMMJIBTA7EFTx/5fpgTFXz9w/en0ZjD8kCDoKPNGwlB01BmoWQbh+AxR689mBponGJOr9OwmMu3dtJ/ylW1Tik4ElUPmR9RqII+pVhD9ychABMQ51gOIZg+/G+5mGIzLB1JJC5WhzYjhJ7IWmLDpA8jzsAafUPkB2WnFBF4iSxkq1ty7f25rv/+EQLOxs2oUdTSA9HIR9swdBlCcFe9owPC3XWDDC0ISVzsEVbSCF/sWdA5Fu4HJqankp2SeQCYYrImNalfmhpVxYrGkUS4LeSUjg8dD7+D7w/ybIfy7vlB9/HJ978zr7/45Qgajzj+4EjIK/ULHPRAOlKr/aG0AFcqCyu0GcW45Igh6JMJmhA49/U+cEssHNJhtXDC1MOya3j/sAiAGcrEtqtgjBD6wEzSDc7D8o6C8rIqAZyPk+NQoNLAZ1hR64Yl1FBY648smUYKnSg1Xwk/0DyRyArByMUobyByhCcPnOaPyoegREFS4jNfYAw+IHCjdC1J2WDZBke/OyN85J24WiXwDYPoJyYuCD238ulvuzwt6KgHf0shWKsqCFFGjB/w8HU8eeTED9wAAAAABJRU5ErkJggg==",e}(),Eo=function(){function e(t){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indexOfRefraction=e._DefaultIndexOfRefraction,this.indexOfRefraction=e._DefaultIndexOfRefraction,this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._textureRoughness=null,this.textureRoughness=null,this._remapF0OnInterfaceChange=!0,this.remapF0OnInterfaceChange=!0,this._bumpTexture=null,this.bumpTexture=null,this._isTintEnabled=!1,this.isTintEnabled=!1,this.tintColor=s.a.White(),this.tintColorAtDistance=1,this.tintThickness=1,this._tintTexture=null,this.tintTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=t}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t,i,n){if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&so.a.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&so.a.ClearCoatTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1;if(i.getCaps().standardDerivatives&&this._bumpTexture&&so.a.ClearCoatBumpTextureEnabled&&!n&&!this._bumpTexture.isReady())return!1;if(this._isTintEnabled&&this._tintTexture&&so.a.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(t,i){var n;this._isEnabled?(t.CLEARCOAT=!0,t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL=null!==this._texture&&this._texture._texture===(null===(n=this._textureRoughness)||void 0===n?void 0:n._texture)&&this._texture.checkTransformsAreIdentical(this._textureRoughness),t.CLEARCOAT_REMAP_F0=this._remapF0OnInterfaceChange,t._areTexturesDirty&&i.texturesEnabled&&(this._texture&&so.a.ClearCoatTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._texture,t,"CLEARCOAT_TEXTURE"):t.CLEARCOAT_TEXTURE=!1,this._textureRoughness&&so.a.ClearCoatTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._textureRoughness,t,"CLEARCOAT_TEXTURE_ROUGHNESS"):t.CLEARCOAT_TEXTURE_ROUGHNESS=!1,this._bumpTexture&&so.a.ClearCoatBumpTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._bumpTexture,t,"CLEARCOAT_BUMP"):t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_DEFAULTIOR=this._indexOfRefraction===e._DefaultIndexOfRefraction,this._isTintEnabled?(t.CLEARCOAT_TINT=!0,this._tintTexture&&so.a.ClearCoatTintTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._tintTexture,t,"CLEARCOAT_TINT_TEXTURE"):t.CLEARCOAT_TINT_TEXTURE=!1):(t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1))):(t.CLEARCOAT=!1,t.CLEARCOAT_TEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS=!1,t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1,t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL=!1)},e.prototype.bindForSubMesh=function(e,t,i,n,r,o,a,s){var c,l,u,h,d,f,p,_,m=s._materialDefines,g=m.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL;if(!e.useUbo||!r||!e.isSync){g&&so.a.ClearCoatTextureEnabled?(e.updateFloat4("vClearCoatInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),ro.a.BindTextureMatrix(this._texture,e,"clearCoat")):(this._texture||this._textureRoughness)&&so.a.ClearCoatTextureEnabled&&(e.updateFloat4("vClearCoatInfos",null!==(l=null===(c=this._texture)||void 0===c?void 0:c.coordinatesIndex)&&void 0!==l?l:0,null!==(h=null===(u=this._texture)||void 0===u?void 0:u.level)&&void 0!==h?h:0,null!==(f=null===(d=this._textureRoughness)||void 0===d?void 0:d.coordinatesIndex)&&void 0!==f?f:0,null!==(_=null===(p=this._textureRoughness)||void 0===p?void 0:p.level)&&void 0!==_?_:0),this._texture&&ro.a.BindTextureMatrix(this._texture,e,"clearCoat"),!this._textureRoughness||g||m.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE||ro.a.BindTextureMatrix(this._textureRoughness,e,"clearCoatRoughness")),this._bumpTexture&&i.getCaps().standardDerivatives&&so.a.ClearCoatTextureEnabled&&!n&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),ro.a.BindTextureMatrix(this._bumpTexture,e,"clearCoatBump"),t._mirroredCameraPosition?e.updateFloat2("vClearCoatTangentSpaceParams",o?1:-1,a?1:-1):e.updateFloat2("vClearCoatTangentSpaceParams",o?-1:1,a?-1:1)),this._tintTexture&&so.a.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),ro.a.BindTextureMatrix(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);var v=1-this._indexOfRefraction,b=1+this._indexOfRefraction,y=Math.pow(-v/b,2),T=1/this._indexOfRefraction;e.updateFloat4("vClearCoatRefractionParams",y,T,v,b),this._isTintEnabled&&(e.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),e.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}t.texturesEnabled&&(this._texture&&so.a.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._textureRoughness&&!g&&!m.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE&&so.a.ClearCoatTextureEnabled&&e.setTexture("clearCoatRoughnessSampler",this._textureRoughness),this._bumpTexture&&i.getCaps().standardDerivatives&&so.a.ClearCoatBumpTextureEnabled&&!n&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&so.a.ClearCoatTintTextureEnabled&&e.setTexture("clearCoatTintSampler",this._tintTexture))},e.prototype.hasTexture=function(e){return this._texture===e||(this._textureRoughness===e||(this._bumpTexture===e||this._tintTexture===e))},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness),this._bumpTexture&&e.push(this._bumpTexture),this._tintTexture&&e.push(this._tintTexture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)},e.prototype.dispose=function(e){var t,i,n,r;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose(),null===(n=this._bumpTexture)||void 0===n||n.dispose(),null===(r=this._tintTexture)||void 0===r||r.dispose())},e.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},e.AddFallbacks=function(e,t,i){return e.CLEARCOAT_BUMP&&t.addFallback(i++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(i++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(i++,"CLEARCOAT"),i},e.AddUniforms=function(e){e.push("vClearCoatTangentSpaceParams","vClearCoatParams","vClearCoatRefractionParams","vClearCoatTintParams","clearCoatColorAtDistance","clearCoatMatrix","clearCoatRoughnessMatrix","clearCoatBumpMatrix","clearCoatTintMatrix","vClearCoatInfos","vClearCoatBumpInfos","vClearCoatTintInfos")},e.AddSamplers=function(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vClearCoatParams",2),e.addUniform("vClearCoatRefractionParams",4),e.addUniform("vClearCoatInfos",4),e.addUniform("clearCoatMatrix",16),e.addUniform("clearCoatRoughnessMatrix",16),e.addUniform("vClearCoatBumpInfos",2),e.addUniform("vClearCoatTangentSpaceParams",2),e.addUniform("clearCoatBumpMatrix",16),e.addUniform("vClearCoatTintParams",4),e.addUniform("clearCoatColorAtDistance",1),e.addUniform("vClearCoatTintInfos",2),e.addUniform("clearCoatTintMatrix",16)},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},e._DefaultIndexOfRefraction=1.5,Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)()],e.prototype,"intensity",void 0),Object(h.c)([Object(w.c)()],e.prototype,"roughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useRoughnessFromMainTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"textureRoughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"remapF0OnInterfaceChange",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"bumpTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTintEnabled",void 0),Object(h.c)([Object(w.e)()],e.prototype,"tintColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"tintColorAtDistance",void 0),Object(h.c)([Object(w.c)()],e.prototype,"tintThickness",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"tintTexture",void 0),e}(),So=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new a.d(1,0),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&so.a.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t,i){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!t.isVerticesDataPresent(Qi.b.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&i.texturesEnabled&&(this._texture&&so.a.AnisotropicTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1)},e.prototype.bindForSubMesh=function(e,t,i){e.useUbo&&i&&e.isSync||(this._texture&&so.a.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),ro.a.BindTextureMatrix(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&so.a.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},e.AddFallbacks=function(e,t,i){return e.ANISOTROPIC&&t.addFallback(i++,"ANISOTROPIC"),i},e.AddUniforms=function(e){e.push("vAnisotropy","vAnisotropyInfos","anisotropyMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vAnisotropy",3),e.addUniform("vAnisotropyInfos",2),e.addUniform("anisotropyMatrix",16)},e.AddSamplers=function(e){e.push("anisotropySampler")},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)()],e.prototype,"intensity",void 0),Object(h.c)([Object(w.n)()],e.prototype,"direction",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),Ao=function(){function e(t){this._useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this._useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this.useSpecularGlossinessInputEnergyConservation=e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION,this._internalMarkAllSubMeshesAsMiscDirty=t}return e.prototype._markAllSubMeshesAsMiscDirty=function(){this._internalMarkAllSubMeshesAsMiscDirty()},e.prototype.prepareDefines=function(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics,e.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=this._useSpecularGlossinessInputEnergyConservation},e.prototype.getClassName=function(){return"PBRBRDFConfiguration"},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},e.DEFAULT_USE_ENERGY_CONSERVATION=!0,e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,e.DEFAULT_USE_SPHERICAL_HARMONICS=!0,e.DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION=!0,Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useEnergyConservation",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSmithVisibilityHeightCorrelated",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSphericalHarmonics",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSpecularGlossinessInputEnergyConservation",void 0),e}(),Po=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=s.a.White(),this._texture=null,this.texture=null,this._useRoughnessFromMainTexture=!0,this.useRoughnessFromMainTexture=!0,this._roughness=null,this.roughness=null,this._textureRoughness=null,this.textureRoughness=null,this._albedoScaling=!1,this.albedoScaling=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&so.a.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&so.a.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){var i;this._isEnabled?(e.SHEEN=this._isEnabled,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e.SHEEN_ROUGHNESS=null!==this._roughness,e.SHEEN_ALBEDOSCALING=this._albedoScaling,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=this._useRoughnessFromMainTexture,e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=null!==this._texture&&this._texture._texture===(null===(i=this._textureRoughness)||void 0===i?void 0:i._texture)&&this._texture.checkTransformsAreIdentical(this._textureRoughness),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&so.a.SheenTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._texture,e,"SHEEN_TEXTURE"):e.SHEEN_TEXTURE=!1,this._textureRoughness&&so.a.SheenTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._textureRoughness,e,"SHEEN_TEXTURE_ROUGHNESS"):e.SHEEN_TEXTURE_ROUGHNESS=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS=!1,e.SHEEN_LINKWITHALBEDO=!1,e.SHEEN_ROUGHNESS=!1,e.SHEEN_ALBEDOSCALING=!1,e.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,e.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1)},e.prototype.bindForSubMesh=function(e,t,i,n){var r,o,a,s,c,l,u,h,d=n._materialDefines,f=d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;e.useUbo&&i&&e.isSync||(f&&so.a.SheenTextureEnabled?(e.updateFloat4("vSheenInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),ro.a.BindTextureMatrix(this._texture,e,"sheen")):(this._texture||this._textureRoughness)&&so.a.SheenTextureEnabled&&(e.updateFloat4("vSheenInfos",null!==(o=null===(r=this._texture)||void 0===r?void 0:r.coordinatesIndex)&&void 0!==o?o:0,null!==(s=null===(a=this._texture)||void 0===a?void 0:a.level)&&void 0!==s?s:0,null!==(l=null===(c=this._textureRoughness)||void 0===c?void 0:c.coordinatesIndex)&&void 0!==l?l:0,null!==(h=null===(u=this._textureRoughness)||void 0===u?void 0:u.level)&&void 0!==h?h:0),this._texture&&ro.a.BindTextureMatrix(this._texture,e,"sheen"),!this._textureRoughness||f||d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE||ro.a.BindTextureMatrix(this._textureRoughness,e,"sheenRoughness")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity),null!==this._roughness&&e.updateFloat("vSheenRoughness",this._roughness)),t.texturesEnabled&&(this._texture&&so.a.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!f&&!d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&so.a.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))},e.prototype.hasTexture=function(e){return this._texture===e||this._textureRoughness===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._textureRoughness&&this._textureRoughness.animations&&this._textureRoughness.animations.length>0&&e.push(this._textureRoughness)},e.prototype.dispose=function(e){var t,i;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(i=this._textureRoughness)||void 0===i||i.dispose())},e.prototype.getClassName=function(){return"PBRSheenConfiguration"},e.AddFallbacks=function(e,t,i){return e.SHEEN&&t.addFallback(i++,"SHEEN"),i},e.AddUniforms=function(e){e.push("vSheenColor","vSheenRoughness","vSheenInfos","sheenMatrix","sheenRoughnessMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vSheenColor",4),e.addUniform("vSheenRoughness",1),e.addUniform("vSheenInfos",4),e.addUniform("sheenMatrix",16),e.addUniform("sheenRoughnessMatrix",16)},e.AddSamplers=function(e){e.push("sheenSampler"),e.push("sheenRoughnessSampler")},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkSheenWithAlbedo",void 0),Object(h.c)([Object(w.c)()],e.prototype,"intensity",void 0),Object(h.c)([Object(w.e)()],e.prototype,"color",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useRoughnessFromMainTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"roughness",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"textureRoughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"albedoScaling",void 0),e}(),Co=function(){function e(e,t,i){this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isScatteringEnabled=!1,this.isScatteringEnabled=!1,this._scatteringDiffusionProfileIndex=0,this.refractionIntensity=1,this.translucencyIntensity=1,this.useAlbedoToTintRefraction=!1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1.5,this.indexOfRefraction=1.5,this._volumeIndexOfRefraction=-1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.tintColor=s.a.White(),this.tintColorAtDistance=1,this.diffusionDistance=s.a.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._useMaskFromThicknessTextureGltf=!1,this.useMaskFromThicknessTextureGltf=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e,this._internalMarkScenePrePassDirty=t,this._scene=i}return Object.defineProperty(e.prototype,"scatteringDiffusionProfile",{get:function(){return this._scene.subSurfaceConfiguration?this._scene.subSurfaceConfiguration.ssDiffusionProfileColors[this._scatteringDiffusionProfileIndex]:null},set:function(e){this._scene.enableSubSurfaceForPrePass()&&e&&(this._scatteringDiffusionProfileIndex=this._scene.subSurfaceConfiguration.addDiffusionProfile(e))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"volumeIndexOfRefraction",{get:function(){return this._volumeIndexOfRefraction>=1?this._volumeIndexOfRefraction:this._indexOfRefraction},set:function(e){this._volumeIndexOfRefraction=e>=1?e:-1},enumerable:!1,configurable:!0}),e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype._markScenePrePassDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var i=this._getRefractionTexture(t);if(i&&so.a.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){if(e._areTexturesDirty&&(e.SUBSURFACE=!1,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=!1,e.SS_REFRACTION=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_LINEARSPECULARREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,e.SS_ALBEDOFORREFRACTIONTINT=!1,(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)&&(e.SUBSURFACE=!0,e._areTexturesDirty&&t.texturesEnabled&&this._thicknessTexture&&so.a.ThicknessTextureEnabled&&ro.a.PrepareDefinesForMergedUV(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),e.SS_MASK_FROM_THICKNESS_TEXTURE=this._useMaskFromThicknessTexture,e.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=this._useMaskFromThicknessTextureGltf),this._isRefractionEnabled&&t.texturesEnabled)){var i=this._getRefractionTexture(t);i&&so.a.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=i.isCube,e.SS_GAMMAREFRACTION=i.gammaSpace,e.SS_RGBDREFRACTION=i.isRGBD,e.SS_LINEARSPECULARREFRACTION=i.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=i.invertZ,e.SS_LODINREFRACTIONALPHA=i.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction)}},e.prototype.bindForSubMesh=function(e,t,i,n,r,o){var a=this._getRefractionTexture(t);if(!e.useUbo||!n||!e.isSync){if(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),ro.a.BindTextureMatrix(this._thicknessTexture,e,"thickness")),e.updateFloat2("vThicknessParam",this.minimumThickness,this.maximumThickness-this.minimumThickness),a&&so.a.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",a.getReflectionTextureMatrix());var s=1;a.isCube||a.depth&&(s=a.depth);var c=a.getSize().width,l=this.volumeIndexOfRefraction;e.updateFloat4("vRefractionInfos",a.level,1/l,s,this._invertRefractionY?-1:1),e.updateFloat3("vRefractionMicrosurfaceInfos",c,a.lodGenerationScale,a.lodGenerationOffset),o&&e.updateFloat2("vRefractionFilteringInfo",c,L.a.Log2(c))}this.isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,this.tintColorAtDistance),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0)}t.texturesEnabled&&(this._thicknessTexture&&so.a.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),a&&so.a.RefractionTextureEnabled&&(r?e.setTexture("refractionSampler",a):(e.setTexture("refractionSampler",a._lodTextureMid||a),e.setTexture("refractionSamplerLow",a._lodTextureLow||a),e.setTexture("refractionSamplerHigh",a._lodTextureHigh||a))))},e.prototype.unbind=function(e){return!(!this._refractionTexture||!this._refractionTexture.isRenderTarget)&&(e.setTexture("refractionSampler",null),!0)},e.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(e.prototype,"disableAlphaBlending",{get:function(){return this.isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!1,configurable:!0}),e.prototype.fillRenderTargetTextures=function(e){so.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},e.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e},e.prototype.hasRenderTargetTextures=function(){return!!(so.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},e.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture)},e.prototype.getAnimatables=function(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture)},e.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose())},e.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},e.AddFallbacks=function(e,t,i){return e.SS_SCATTERING&&t.addFallback(i++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(i++,"SS_TRANSLUCENCY"),i},e.AddUniforms=function(e){e.push("vDiffusionDistance","vTintColor","vSubSurfaceIntensity","vRefractionMicrosurfaceInfos","vRefractionFilteringInfo","vRefractionInfos","vThicknessInfos","vThicknessParam","refractionMatrix","thicknessMatrix","scatteringDiffusionProfile")},e.AddSamplers=function(e){e.push("thicknessSampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh")},e.PrepareUniformBuffer=function(e){e.addUniform("vRefractionMicrosurfaceInfos",3),e.addUniform("vRefractionFilteringInfo",2),e.addUniform("vRefractionInfos",4),e.addUniform("refractionMatrix",16),e.addUniform("vThicknessInfos",2),e.addUniform("thicknessMatrix",16),e.addUniform("vThicknessParam",2),e.addUniform("vDiffusionDistance",3),e.addUniform("vTintColor",4),e.addUniform("vSubSurfaceIntensity",3),e.addUniform("scatteringDiffusionProfile",1)},e.prototype.copyTo=function(e){w.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return w.a.Serialize(this)},e.prototype.parse=function(e,t,i){var n=this;w.a.Parse((function(){return n}),e,t,i)},Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isRefractionEnabled",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTranslucencyEnabled",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markScenePrePassDirty")],e.prototype,"isScatteringEnabled",void 0),Object(h.c)([Object(w.c)()],e.prototype,"_scatteringDiffusionProfileIndex",void 0),Object(h.c)([Object(w.c)()],e.prototype,"refractionIntensity",void 0),Object(h.c)([Object(w.c)()],e.prototype,"translucencyIntensity",void 0),Object(h.c)([Object(w.c)()],e.prototype,"useAlbedoToTintRefraction",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"thicknessTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"refractionTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),Object(h.c)([Object(w.c)()],e.prototype,"_volumeIndexOfRefraction",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"volumeIndexOfRefraction",null),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"invertRefractionY",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkRefractionWithTransparency",void 0),Object(h.c)([Object(w.c)()],e.prototype,"minimumThickness",void 0),Object(h.c)([Object(w.c)()],e.prototype,"maximumThickness",void 0),Object(h.c)([Object(w.e)()],e.prototype,"tintColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"tintColorAtDistance",void 0),Object(h.c)([Object(w.e)()],e.prototype,"diffusionDistance",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useMaskFromThicknessTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useMaskFromThicknessTextureGltf",void 0),e}(),Ro=i(105),xo=i(25),Oo=(i(160),"uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec4 vMetallicReflectanceFactors;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\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(SS_REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REALTIME_FILTERING\nuniform vec2 vReflectionFilteringInfo;\n#endif\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\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_ROUGHNESS\nuniform float vSheenRoughness;\n#endif\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#ifdef REALTIME_FILTERING\nuniform vec2 vRefractionFilteringInfo;\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif\n#ifdef PREPASS\n#ifdef PREPASS_IRRADIANCE\nuniform float scatteringDiffusionProfile;\n#endif\n#endif");ai.a.IncludesShadersStore.pbrFragmentDeclaration=Oo;var Mo="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 vec2 vReflectionInfos;\nuniform vec2 vReflectionFilteringInfo;\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 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec4 vMetallicReflectanceFactors;\nuniform vec2 vMetallicReflectanceInfos;\nuniform mat4 metallicReflectanceMatrix;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec4 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform mat4 clearCoatRoughnessMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform float vSheenRoughness;\nuniform vec4 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform mat4 sheenRoughnessMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec2 vRefractionFilteringInfo;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\nuniform float scatteringDiffusionProfile;\nuniform vec4 vDetailInfos;\nuniform mat4 detailMatrix;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";ai.a.IncludesShadersStore.pbrUboDeclaration=Mo;var Io="uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\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";ai.a.IncludesShadersStore.pbrFragmentExtraDeclaration=Io;var Do="#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#ifdef METALLIC_REFLECTANCE\n#if METALLIC_REFLECTANCEDIRECTUV == 1\n#define vMetallicReflectanceUV vMainUV1\n#elif METALLIC_REFLECTANCEDIRECTUV == 2\n#define vMetallicReflectanceUV vMainUV2\n#else\nvarying vec2 vMetallicReflectanceUV;\n#endif\nuniform sampler2D metallicReflectanceSampler;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE)\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS)\n#if CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 1\n#define vClearCoatRoughnessUV vMainUV1\n#elif CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 2\n#define vClearCoatRoughnessUV vMainUV2\n#else\nvarying vec2 vClearCoatRoughnessUV;\n#endif\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform sampler2D clearCoatSampler;\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D clearCoatRoughnessSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\n#if SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 1\n#define vSheenRoughnessUV vMainUV1\n#elif SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 2\n#define vSheenRoughnessUV vMainUV2\n#else\nvarying vec2 vSheenRoughnessUV;\n#endif\n#endif\n#ifdef SHEEN_TEXTURE\nuniform sampler2D sheenSampler;\n#endif\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D sheenRoughnessSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\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#ifdef USEIRRADIANCEMAP\nuniform samplerCube irradianceSampler;\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 sampler2D reflectionSamplerLow;\nuniform sampler2D reflectionSamplerHigh;\n#endif\n#ifdef USEIRRADIANCEMAP\nuniform sampler2D irradianceSampler;\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#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\n#ifdef SS_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 sampler2D refractionSamplerLow;\nuniform sampler2D refractionSamplerHigh;\n#endif\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\n#define vThicknessUV vMainUV1\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\n#define vThicknessUV vMainUV2\n#else\nvarying vec2 vThicknessUV;\n#endif\nuniform sampler2D thicknessSampler;\n#endif\n#endif";ai.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=Do;i(116);ai.a.IncludesShadersStore.subSurfaceScatteringFunctions="bool testLightingForSSS(float diffusionProfile)\n{\nreturn diffusionProfile<1.;\n}";var No="\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\nvec3 hemisphereCosSample(vec2 u) {\n\nfloat phi=2.*PI*u.x;\nfloat cosTheta2=1.-u.y;\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\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\n\nvec3 hemisphereImportanceSampleDggx(vec2 u,float a) {\n\nfloat phi=2.*PI*u.x;\n\nfloat cosTheta2=(1.-u.y)/(1.+(a+1.)*((a-1.)*u.y));\nfloat cosTheta=sqrt(cosTheta2);\nfloat sinTheta=sqrt(1.-cosTheta2);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\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\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 hemisphereImportanceSampleDCharlie(vec2 u,float a) {\n\nfloat phi=2.*PI*u.x;\nfloat sinTheta=pow(u.y,a/(2.*a+1.));\nfloat cosTheta=sqrt(1.-sinTheta*sinTheta);\nreturn vec3(sinTheta*cos(phi),sinTheta*sin(phi),cosTheta);\n}";ai.a.IncludesShadersStore.importanceSampling=No;var Lo="\n#define RECIPROCAL_PI2 0.15915494\n#define RECIPROCAL_PI 0.31830988618\n\n#define MINIMUMVARIANCE 0.0005\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\n}\nfloat fresnelGrazingReflectance(float reflectance0) {\n\n\nfloat reflectance90=saturate(reflectance0*25.0);\nreturn reflectance90;\n}\nvec2 getAARoughnessFactors(vec3 normalVector) {\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalVector.xyz);\nvec3 nDfdy=dFdy(normalVector.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(saturate(slopeSquare),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n#ifdef ANISOTROPIC\n\n\nvec2 getAnisotropicRoughness(float alphaG,float anisotropy) {\nfloat alphaT=max(alphaG*(1.0+anisotropy),MINIMUMVARIANCE);\nfloat alphaB=max(alphaG*(1.0-anisotropy),MINIMUMVARIANCE);\nreturn vec2(alphaT,alphaB);\n}\n\n\nvec3 getAnisotropicBentNormals(const vec3 T,const vec3 B,const vec3 N,const vec3 V,float anisotropy) {\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? B : T;\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),V);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(N,anisotropicFrameNormal,abs(anisotropy)));\nreturn anisotropicNormal;\n\n}\n#endif\n#if defined(CLEARCOAT) || defined(SS_REFRACTION)\n\n\n\nvec3 cocaLambert(vec3 alpha,float distance) {\nreturn exp(-alpha*distance);\n}\n\nvec3 cocaLambert(float NdotVRefract,float NdotLRefract,vec3 alpha,float thickness) {\nreturn cocaLambert(alpha,(thickness*((NdotLRefract+NdotVRefract)/(NdotLRefract*NdotVRefract))));\n}\n\nvec3 computeColorAtDistanceInMedia(vec3 color,float distance) {\nreturn -log(color)/distance;\n}\nvec3 computeClearCoatAbsorption(float NdotVRefract,float NdotLRefract,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 clearCoatAbsorption=mix(vec3(1.0),\ncocaLambert(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness),\nclearCoatIntensity);\nreturn clearCoatAbsorption;\n}\n#endif\n\n\n\n\n#ifdef MICROSURFACEAUTOMATIC\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#endif";ai.a.IncludesShadersStore.pbrHelperFunctions=Lo;var wo="#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n\n\n\n\n\n\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+vSphericalL1_1*(normal.y)\n+vSphericalL10*(normal.z)\n+vSphericalL11*(normal.x)\n+vSphericalL2_2*(normal.y*normal.x)\n+vSphericalL2_1*(normal.y*normal.z)\n+vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+vSphericalL21*(normal.z*normal.x)\n+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\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;\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\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\n#endif";ai.a.IncludesShadersStore.harmonicsFunctions=wo;var Fo="\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotLUnclamped;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\nresult.NdotLUnclamped=dot(N,result.L);\nresult.NdotL=saturateEps(result.NdotLUnclamped);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=saturateEps(result.NdotL);\nresult.NdotLUnclamped=result.NdotL;\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=saturate(dot(V,result.H));\n#endif\nreturn result;\n}";ai.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=Fo;var Bo="float 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/maxEps(lightDistanceSquared);\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nfloat lightDistanceFalloff=1.0/maxEps(lightDistanceSquared);\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=saturate(1.0-factor*factor);\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=maxEps(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=saturate(cd*lightAngleScale+lightAngleOffset);\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}";ai.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=Bo;var Uo="\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n\n\n\n#ifdef MS_BRDF_ENERGY_CONSERVATION\n\n\nvec3 getEnergyConservationFactor(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\nreturn 1.0+specularEnvironmentR0*(1.0/environmentBrdf.y-1.0);\n}\n#endif\n#ifdef ENVIRONMENTBRDF\nvec3 getBRDFLookup(float NdotV,float perceptualRoughness) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(environmentBrdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 specularEnvironmentR90,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=(specularEnvironmentR90-specularEnvironmentR0)*environmentBrdf.x+specularEnvironmentR0*environmentBrdf.y;\n\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+specularEnvironmentR90*environmentBrdf.y;\n#endif\nreturn reflectance;\n}\nvec3 getReflectanceFromBRDFLookup(const vec3 specularEnvironmentR0,const vec3 environmentBrdf) {\n#ifdef BRDF_V_HEIGHT_CORRELATED\nvec3 reflectance=mix(environmentBrdf.xxx,environmentBrdf.yyy,specularEnvironmentR0);\n#else\nvec3 reflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#endif\nreturn reflectance;\n}\n#endif\n\n#if !defined(ENVIRONMENTBRDF) || defined(REFLECTIONMAP_SKYBOX) || defined(ALPHAFRESNEL)\nvec3 getReflectanceFromAnalyticalBRDFLookup_Jones(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)*pow5(saturate(1.0-VdotN));\n}\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\n\nvec3 getSheenReflectanceFromBRDFLookup(const vec3 reflectance0,const vec3 environmentBrdf) {\nvec3 sheenEnvironmentReflectance=reflectance0*environmentBrdf.b;\nreturn sheenEnvironmentReflectance;\n}\n#endif\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow5(1.0-VdotH);\n}\n#ifdef CLEARCOAT\n\n\n\n\n\nvec3 getR0RemappedForClearCoat(vec3 f0) {\n#ifdef CLEARCOAT_DEFAULTIOR\n#ifdef MOBILE\nreturn saturate(f0*(f0*0.526868+0.529324)-0.0482256);\n#else\nreturn saturate(f0*(f0*(0.941892-0.263008*f0)+0.346479)-0.0285998);\n#endif\n#else\nvec3 s=sqrt(f0);\nvec3 t=(vClearCoatRefractionParams.z+vClearCoatRefractionParams.w*s)/(vClearCoatRefractionParams.w+vClearCoatRefractionParams.z*s);\nreturn t*t;\n#endif\n}\n#endif\n\n\n\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}\n#ifdef SHEEN\n\n\nfloat normalDistributionFunction_CharlieSheen(float NdotH,float alphaG)\n{\nfloat invR=1./alphaG;\nfloat cos2h=NdotH*NdotH;\nfloat sin2h=1.-cos2h;\nreturn (2.+invR)*pow(sin2h,invR*.5)/(2.*PI);\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat normalDistributionFunction_BurleyGGX_Anisotropic(float NdotH,float TdotH,float BdotH,const vec2 alphaTB) {\nfloat a2=alphaTB.x*alphaTB.y;\nvec3 v=vec3(alphaTB.y*TdotH,alphaTB.x*BdotH,a2*NdotH);\nfloat v2=dot(v,v);\nfloat w2=a2/v2;\nreturn a2*w2*w2*RECIPROCAL_PI;\n}\n#endif\n\n\n\n\n#ifdef BRDF_V_HEIGHT_CORRELATED\n\n\n\nfloat smithVisibility_GGXCorrelated(float NdotL,float NdotV,float alphaG) {\n#ifdef MOBILE\n\nfloat GGXV=NdotL*(NdotV*(1.0-alphaG)+alphaG);\nfloat GGXL=NdotV*(NdotL*(1.0-alphaG)+alphaG);\nreturn 0.5/(GGXV+GGXL);\n#else\nfloat a2=alphaG*alphaG;\nfloat GGXV=NdotL*sqrt(NdotV*(NdotV-a2*NdotV)+a2);\nfloat GGXL=NdotV*sqrt(NdotL*(NdotL-a2*NdotL)+a2);\nreturn 0.5/(GGXV+GGXL);\n#endif\n}\n#else\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\n#ifdef MOBILE\n\nreturn 1.0/(dot+alphaG+(1.0-alphaG)*dot ));\n#else\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n#endif\n}\nfloat smithVisibility_TrowbridgeReitzGGXFast(float NdotL,float NdotV,float alphaG)\n{\nfloat visibility=smithVisibilityG1_TrowbridgeReitzGGXFast(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGXFast(NdotV,alphaG);\n\nreturn visibility;\n}\n#endif\n#ifdef ANISOTROPIC\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotL,float NdotV,float TdotV,float BdotV,float TdotL,float BdotL,const vec2 alphaTB) {\nfloat lambdaV=NdotL*length(vec3(alphaTB.x*TdotV,alphaTB.y*BdotV,NdotV));\nfloat lambdaL=NdotV*length(vec3(alphaTB.x*TdotL,alphaTB.y*BdotL,NdotL));\nfloat v=0.5/(lambdaV+lambdaL);\nreturn v;\n}\n#endif\n#ifdef CLEARCOAT\nfloat visibility_Kelemen(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\n}\n#endif\n#ifdef SHEEN\n\n\n\nfloat visibility_Ashikhmin(float NdotL,float NdotV)\n{\nreturn 1./(4.*(NdotL+NdotV-NdotL*NdotV));\n}\n\n#endif\n\n\n\n\n\n\n\nfloat diffuseBRDF_Burley(float NdotL,float NdotV,float VdotH,float roughness) {\n\n\nfloat diffuseFresnelNV=pow5(saturateEps(1.0-NdotL));\nfloat diffuseFresnelNL=pow5(saturateEps(1.0-NdotV));\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/PI;\n}\n#ifdef SS_TRANSLUCENCY\n\n\nvec3 transmittanceBRDF_Burley(const vec3 tintColor,const vec3 diffusionDistance,float thickness) {\nvec3 S=1./maxEps(diffusionDistance);\nvec3 temp=exp((-0.333333333*thickness)*S);\nreturn tintColor.rgb*0.25*(temp*temp*temp+3.0*temp);\n}\n\n\nfloat computeWrappedDiffuseNdotL(float NdotL,float w) {\nfloat t=1.0+w;\nfloat invt2=1.0/square(t);\nreturn saturate((NdotL+w)*invt2);\n}\n#endif\n";ai.a.IncludesShadersStore.pbrBRDFFunctions=Uo;var Vo="#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#ifdef WEBGL2\n\n\nfloat radicalInverse_VdC(uint bits)\n{\nbits=(bits << 16u) | (bits >> 16u);\nbits=((bits & 0x55555555u) << 1u) | ((bits & 0xAAAAAAAAu) >> 1u);\nbits=((bits & 0x33333333u) << 2u) | ((bits & 0xCCCCCCCCu) >> 2u);\nbits=((bits & 0x0F0F0F0Fu) << 4u) | ((bits & 0xF0F0F0F0u) >> 4u);\nbits=((bits & 0x00FF00FFu) << 8u) | ((bits & 0xFF00FF00u) >> 8u);\nreturn float(bits)*2.3283064365386963e-10;\n}\nvec2 hammersley(uint i,uint N)\n{\nreturn vec2(float(i)/float(N),radicalInverse_VdC(i));\n}\n#else\nfloat vanDerCorpus(int n,int base)\n{\nfloat invBase=1.0/float(base);\nfloat denom=1.0;\nfloat result=0.0;\nfor(int i=0; i<32; ++i)\n{\nif(n>0)\n{\ndenom=mod(float(n),2.0);\nresult+=denom*invBase;\ninvBase=invBase/2.0;\nn=int(float(n)/2.0);\n}\n}\nreturn result;\n}\nvec2 hammersley(int i,int N)\n{\nreturn vec2(float(i)/float(N),vanDerCorpus(i,2));\n}\n#endif\nfloat log4(float x) {\nreturn log2(x)/2.;\n}\nconst float NUM_SAMPLES_FLOAT=float(NUM_SAMPLES);\nconst float NUM_SAMPLES_FLOAT_INVERSED=1./NUM_SAMPLES_FLOAT;\nconst float K=4.;\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\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\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\n\n\n\n\n#define inline\nvec3 irradiance(samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nvec3 result=vec3(0.0);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\n#ifdef WEBGL2\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{\nvec2 Xi=hammersley(i,NUM_SAMPLES);\nvec3 Ls=hemisphereCosSample(Xi);\nLs=normalize(Ls);\nvec3 Ns=vec3(0.,0.,1.);\nfloat NoL=dot(Ns,Ls);\nif (NoL>0.) {\nfloat pdf_inversed=PI/NoL;\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(l,0.0,maxLevel);\nvec3 c=textureCubeLodEXT(inputTexture,tbn*Ls,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c;\n}\n}\nresult=result*NUM_SAMPLES_FLOAT_INVERSED;\nreturn result;\n}\n#define inline\nvec3 radiance(float alphaG,samplerCube inputTexture,vec3 inputN,vec2 filteringInfo)\n{\nvec3 n=normalize(inputN);\nif (alphaG == 0.) {\nvec3 c=textureCube(inputTexture,n).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nreturn c;\n}\nvec3 result=vec3(0.);\nvec3 tangent=abs(n.z)<0.999 ? vec3(0.,0.,1.) : vec3(1.,0.,0.);\ntangent=normalize(cross(tangent,n));\nvec3 bitangent=cross(n,tangent);\nmat3 tbn=mat3(tangent,bitangent,n);\nfloat maxLevel=filteringInfo.y;\nfloat dim0=filteringInfo.x;\nfloat omegaP=(4.*PI)/(6.*dim0*dim0);\nfloat weight=0.;\n#ifdef WEBGL2\nfor(uint i=0u; i<NUM_SAMPLES; ++i)\n#else\nfor(int i=0; i<NUM_SAMPLES; ++i)\n#endif\n{\nvec2 Xi=hammersley(i,NUM_SAMPLES);\nvec3 H=hemisphereImportanceSampleDggx(Xi,alphaG);\nfloat NoV=1.;\nfloat NoH=H.z;\nfloat NoH2=H.z*H.z;\nfloat NoL=2.*NoH2-1.;\nvec3 L=vec3(2.*NoH*H.x,2.*NoH*H.y,NoL);\nL=normalize(L);\nif (NoL>0.) {\nfloat pdf_inversed=4./normalDistributionFunction_TrowbridgeReitzGGX(NoH,alphaG);\nfloat omegaS=NUM_SAMPLES_FLOAT_INVERSED*pdf_inversed;\nfloat l=log4(omegaS)-log4(omegaP)+log4(K);\nfloat mipLevel=clamp(float(l),0.0,maxLevel);\nweight+=NoL;\nvec3 c=textureCubeLodEXT(inputTexture,tbn*L,mipLevel).rgb;\n#ifdef GAMMA_INPUT\nc=toLinearSpace(c);\n#endif\nresult+=c*NoL;\n}\n}\nresult=result/weight;\nreturn result;\n}\n#endif\n#endif";ai.a.IncludesShadersStore.hdrFilteringFunctions=Vo;var ko="#define CLEARCOATREFLECTANCE90 1.0\n\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\n#endif\n#ifdef SHEEN\nvec3 sheen;\n#endif\n};\n\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance) {\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=saturate(lightRoughness+roughness);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nvec3 computeHemisphericDiffuseLighting(preLightingInfo info,vec3 lightColor,vec3 groundColor) {\nreturn mix(groundColor,lightColor,info.NdotL);\n}\nvec3 computeDiffuseLighting(preLightingInfo info,vec3 lightColor) {\nfloat diffuseTerm=diffuseBRDF_Burley(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\n#define inline\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}\n#ifdef SS_TRANSLUCENCY\nvec3 computeDiffuseAndTransmittedLighting(preLightingInfo info,vec3 lightColor,vec3 transmittance) {\nfloat NdotL=absEps(info.NdotLUnclamped);\n\nfloat wrapNdotL=computeWrappedDiffuseNdotL(NdotL,0.02);\n\nfloat trAdapt=step(0.,info.NdotLUnclamped);\nvec3 transmittanceNdotL=mix(transmittance*wrapNdotL,vec3(wrapNdotL),trAdapt);\nfloat diffuseTerm=diffuseBRDF_Burley(NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*transmittanceNdotL*info.attenuation*lightColor;\n}\n#endif\n#ifdef SPECULARTERM\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\n#ifdef BRDF_V_HEIGHT_CORRELATED\nfloat smithVisibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat smithVisibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef ANISOTROPIC\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat TdotH=dot(T,info.H);\nfloat BdotH=dot(B,info.H);\nfloat TdotV=dot(T,V);\nfloat BdotV=dot(B,V);\nfloat TdotL=dot(T,info.L);\nfloat BdotL=dot(B,info.L);\nfloat alphaG=convertRoughnessToAverageSlope(info.roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,square(geometricRoughnessFactor));\nvec3 fresnel=fresnelSchlickGGX(info.VdotH,reflectance0,reflectance90);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat smithVisibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*smithVisibility;\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n#ifdef CLEARCOAT\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=saturateEps(dot(Ncc,info.L));\nfloat NccdotH=saturateEps(dot(Ncc,info.H));\nfloat clearCoatRoughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat fresnel=fresnelSchlickGGX(info.VdotH,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NccdotH,alphaG);\nfloat kelemenVisibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*kelemenVisibility;\nreturn vec4(\nclearCoatTerm*info.attenuation*NccdotL*lightColor,\n1.0-fresnel\n);\n}\nvec3 computeClearCoatLightingAbsorption(float NdotVRefract,vec3 L,vec3 Ncc,vec3 clearCoatColor,float clearCoatThickness,float clearCoatIntensity) {\nvec3 LRefract=-refract(L,Ncc,vClearCoatRefractionParams.y);\nfloat NdotLRefract=saturateEps(dot(Ncc,LRefract));\nvec3 absorption=computeClearCoatAbsorption(NdotVRefract,NdotLRefract,clearCoatColor,clearCoatThickness,clearCoatIntensity);\nreturn absorption;\n}\n#endif\n#ifdef SHEEN\nvec3 computeSheenLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=saturateEps(dot(N,info.H));\nfloat roughness=max(info.roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n\n\nfloat fresnel=1.;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\n\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\n\nfloat sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";ai.a.IncludesShadersStore.pbrDirectLightingFunctions=ko;var zo="#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=cubeMapDimensionPixels*microsurfaceAverageSlope;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat getLinearLodFromRoughness(float cubeMapDimensionPixels,float roughness) {\nfloat lod=log2(cubeMapDimensionPixels)*roughness;\nreturn lod;\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(RADIANCEOCCLUSION)\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn saturate(square(temp)-1.0+ambientOcclusion);\n}\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(HORIZONOCCLUSION)\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal,vec3 geometricNormal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,geometricNormal));\nreturn square(temp);\n}\n#endif\n\n\n\n\n#if defined(LODINREFLECTIONALPHA) || defined(SS_LODINREFRACTIONALPHA)\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));\nreturn getLodFromAlphaG(cubeMapDimensionPixels,microsurfaceAverageSlope);\n}\n#endif";ai.a.IncludesShadersStore.pbrIBLFunctions=zo;i(132),i(133);var Go="struct albedoOpacityOutParams\n{\nvec3 surfaceAlbedo;\nfloat alpha;\n};\n#define pbr_inline\nvoid albedoOpacityBlock(\nconst in vec4 vAlbedoColor,\n#ifdef ALBEDO\nconst in vec4 albedoTexture,\nconst in vec2 albedoInfos,\n#endif\n#ifdef OPACITY\nconst in vec4 opacityMap,\nconst in vec2 vOpacityInfos,\n#endif\n#ifdef DETAIL\nconst in vec4 detailColor,\nconst in vec4 vDetailInfos,\n#endif\nout albedoOpacityOutParams outParams\n)\n{\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\n#ifdef GAMMAALBEDO\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\n#else\nsurfaceAlbedo*=albedoTexture.rgb;\n#endif\nsurfaceAlbedo*=albedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n#ifdef DETAIL\nfloat detailAlbedo=2.0*mix(0.5,detailColor.r,vDetailInfos.y);\nsurfaceAlbedo.rgb=surfaceAlbedo.rgb*detailAlbedo*detailAlbedo;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALBEDO\n\n#ifdef OPACITY\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(SS_LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\noutParams.surfaceAlbedo=surfaceAlbedo;\noutParams.alpha=alpha;\n}\n";ai.a.IncludesShadersStore.pbrBlockAlbedoOpacity=Go;var jo="struct reflectivityOutParams\n{\nfloat microSurface;\nfloat roughness;\nvec3 surfaceReflectivityColor;\n#ifdef METALLICWORKFLOW\nvec3 surfaceAlbedo;\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\nvec3 ambientOcclusionColor;\n#endif\n#if DEBUGMODE>0\nvec4 surfaceMetallicColorMap;\nvec4 surfaceReflectivityColorMap;\nvec2 metallicRoughness;\nvec3 metallicF0;\n#endif\n};\n#define pbr_inline\nvoid reflectivityBlock(\nconst in vec4 vReflectivityColor,\n#ifdef METALLICWORKFLOW\nconst in vec3 surfaceAlbedo,\nconst in vec4 metallicReflectanceFactors,\n#endif\n#ifdef REFLECTIVITY\nconst in vec3 reflectivityInfos,\nconst in vec4 surfaceMetallicOrReflectivityColorMap,\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\nconst in vec3 ambientOcclusionColorIn,\n#endif\n#ifdef MICROSURFACEMAP\nconst in vec4 microSurfaceTexel,\n#endif\n#ifdef DETAIL\nconst in vec4 detailColor,\nconst in vec4 vDetailInfos,\n#endif\nout reflectivityOutParams outParams\n)\n{\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\n#if DEBUGMODE>0\noutParams.surfaceMetallicColorMap=surfaceMetallicOrReflectivityColorMap;\n#endif\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r,surfaceMetallicOrReflectivityColorMap.r);\noutParams.ambientOcclusionColor=mix(ambientOcclusionColorIn,aoStoreInMetalMap,reflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicOrReflectivityColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicOrReflectivityColorMap.g;\n#endif\n#endif\n#endif\n#ifdef DETAIL\nfloat detailRoughness=mix(0.5,detailColor.b,vDetailInfos.w);\nfloat loLerp=mix(0.,metallicRoughness.g,detailRoughness*2.);\nfloat hiLerp=mix(metallicRoughness.g,1.,(detailRoughness-0.5)*2.);\nmetallicRoughness.g=mix(loLerp,hiLerp,step(detailRoughness,0.5));\n#endif\n#ifdef MICROSURFACEMAP\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n#if DEBUGMODE>0\noutParams.metallicRoughness=metallicRoughness;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_METALLICROUGHNESS\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef FROSTBITE_REFLECTANCE\n\n\n\n\n\n\noutParams.surfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\nvec3 metallicF0=metallicReflectanceFactors.rgb;\n#if DEBUGMODE>0\noutParams.metallicF0=metallicF0;\n#endif\n\noutParams.surfaceAlbedo=mix(baseColor.rgb*(1.0-metallicF0),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(metallicF0,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nsurfaceReflectivityColor*=surfaceMetallicOrReflectivityColorMap.rgb;\n#if DEBUGMODE>0\noutParams.surfaceReflectivityColorMap=surfaceMetallicOrReflectivityColorMap;\n#endif\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceMetallicOrReflectivityColorMap.a;\nmicroSurface*=reflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_MICROSURFACE\n#endif\n#endif\n#endif\n\nmicroSurface=saturate(microSurface);\n\nfloat roughness=1.-microSurface;\noutParams.microSurface=microSurface;\noutParams.roughness=roughness;\noutParams.surfaceReflectivityColor=surfaceReflectivityColor;\n}\n";ai.a.IncludesShadersStore.pbrBlockReflectivity=jo;var Wo="struct ambientOcclusionOutParams\n{\nvec3 ambientOcclusionColor;\n#if DEBUGMODE>0\nvec3 ambientOcclusionColorMap;\n#endif\n};\n#define pbr_inline\nvoid ambientOcclusionBlock(\n#ifdef AMBIENT\nconst in vec3 ambientOcclusionColorMap_,\nconst in vec4 vAmbientInfos,\n#endif\nout ambientOcclusionOutParams outParams\n)\n{\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=ambientOcclusionColorMap_*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#if DEBUGMODE>0\noutParams.ambientOcclusionColorMap=ambientOcclusionColorMap;\n#endif\n#endif\noutParams.ambientOcclusionColor=ambientOcclusionColor;\n}\n";ai.a.IncludesShadersStore.pbrBlockAmbientOcclusion=Wo;var Ho="#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\nstruct alphaFresnelOutParams\n{\nfloat alpha;\n};\n#define pbr_inline\nvoid alphaFresnelBlock(\nconst in vec3 normalW,\nconst in vec3 viewDirectionW,\nconst in float alpha,\nconst in float microSurface,\nout alphaFresnelOutParams outParams\n)\n{\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\noutParams.alpha=getReflectanceFromAnalyticalBRDFLookup_Jones(saturate(dot(viewDirectionW,normalForward)),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (outParams.alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\noutParams.alpha=1.0;\n#endif\n#endif\n}\n#endif\n#endif\n";ai.a.IncludesShadersStore.pbrBlockAlphaFresnel=Ho;var Xo="#ifdef ANISOTROPIC\nstruct anisotropicOutParams\n{\nfloat anisotropy;\nvec3 anisotropicTangent;\nvec3 anisotropicBitangent;\nvec3 anisotropicNormal;\n#if DEBUGMODE>0\nvec3 anisotropyMapData;\n#endif\n};\n#define pbr_inline\nvoid anisotropicBlock(\nconst in vec3 vAnisotropy,\n#ifdef ANISOTROPIC_TEXTURE\nconst in vec3 anisotropyMapData,\n#endif\nconst in mat3 TBN,\nconst in vec3 normalW,\nconst in vec3 viewDirectionW,\nout anisotropicOutParams outParams\n)\n{\nfloat anisotropy=vAnisotropy.b;\nvec3 anisotropyDirection=vec3(vAnisotropy.xy,0.);\n#ifdef ANISOTROPIC_TEXTURE\nanisotropy*=anisotropyMapData.b;\nanisotropyDirection.rg*=anisotropyMapData.rg*2.0-1.0;\n#if DEBUGMODE>0\noutParams.anisotropyMapData=anisotropyMapData;\n#endif\n#endif\nmat3 anisoTBN=mat3(normalize(TBN[0]),normalize(TBN[1]),normalize(TBN[2]));\nvec3 anisotropicTangent=normalize(anisoTBN*anisotropyDirection);\nvec3 anisotropicBitangent=normalize(cross(anisoTBN[2],anisotropicTangent));\noutParams.anisotropy=anisotropy;\noutParams.anisotropicTangent=anisotropicTangent;\noutParams.anisotropicBitangent=anisotropicBitangent;\noutParams.anisotropicNormal=getAnisotropicBentNormals(anisotropicTangent,anisotropicBitangent,normalW,viewDirectionW,anisotropy);\n}\n#endif\n";ai.a.IncludesShadersStore.pbrBlockAnisotropic=Xo;var Yo="#ifdef REFLECTION\nstruct reflectionOutParams\n{\nvec4 environmentRadiance;\nvec3 environmentIrradiance;\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords;\n#else\nvec2 reflectionCoords;\n#endif\n#ifdef SS_TRANSLUCENCY\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nvec3 irradianceVector;\n#endif\n#endif\n#endif\n};\n#define pbr_inline\nvoid createReflectionCoords(\nconst in vec3 vPositionW,\nconst in vec3 normalW,\n#ifdef ANISOTROPIC\nconst in anisotropicOutParams anisotropicOut,\n#endif\n#ifdef REFLECTIONMAP_3D\nout vec3 reflectionCoords\n#else\nout vec2 reflectionCoords\n#endif\n)\n{\n#ifdef ANISOTROPIC\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),anisotropicOut.anisotropicNormal);\n#else\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nreflectionCoords=reflectionVector;\n#else\nreflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n}\n#define pbr_inline\n#define inline\nvoid sampleReflectionTexture(\nconst in float alphaG,\nconst in vec3 vReflectionMicrosurfaceInfos,\nconst in vec2 vReflectionInfos,\nconst in vec3 vReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nconst in float NdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nconst in float roughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSampler,\nconst vec3 reflectionCoords,\n#else\nconst in sampler2D reflectionSampler,\nconst vec2 reflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSamplerLow,\nconst in samplerCube reflectionSamplerHigh,\n#else\nconst in sampler2D reflectionSamplerLow,\nconst in sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nconst in vec2 vReflectionFilteringInfo,\n#endif\nout vec4 environmentRadiance\n)\n{\n\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#elif defined(LINEARSPECULARREFLECTION)\nfloat reflectionLOD=getLinearLodFromRoughness(vReflectionMicrosurfaceInfos.x,roughness);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG);\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\n#ifdef REALTIME_FILTERING\nenvironmentRadiance=vec4(radiance(alphaG,reflectionSampler,reflectionCoords,vReflectionFilteringInfo),1.0);\n#else\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#endif\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x));\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentMid=sampleReflection(reflectionSampler,reflectionCoords);\nif (lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nenvironmentRadiance=mix(\nenvironmentMid,\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\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\n}\n#define pbr_inline\n#define inline\nvoid reflectionBlock(\nconst in vec3 vPositionW,\nconst in vec3 normalW,\nconst in float alphaG,\nconst in vec3 vReflectionMicrosurfaceInfos,\nconst in vec2 vReflectionInfos,\nconst in vec3 vReflectionColor,\n#ifdef ANISOTROPIC\nconst in anisotropicOutParams anisotropicOut,\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nconst in float NdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nconst in float roughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSampler,\n#else\nconst in sampler2D reflectionSampler,\n#endif\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nconst in vec3 vEnvironmentIrradiance,\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nconst in mat4 reflectionMatrix,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube irradianceSampler,\n#else\nconst in sampler2D irradianceSampler,\n#endif\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSamplerLow,\nconst in samplerCube reflectionSamplerHigh,\n#else\nconst in sampler2D reflectionSamplerLow,\nconst in sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nconst in vec2 vReflectionFilteringInfo,\n#endif\nout reflectionOutParams outParams\n)\n{\n\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=vec3(0.);\n#else\nvec2 reflectionCoords=vec2(0.);\n#endif\ncreateReflectionCoords(\nvPositionW,\nnormalW,\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\nreflectionCoords\n);\nsampleReflectionTexture(\nalphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nroughness,\n#endif\n#ifdef REFLECTIONMAP_3D\nreflectionSampler,\nreflectionCoords,\n#else\nreflectionSampler,\nreflectionCoords,\n#endif\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentRadiance\n);\n\nvec3 environmentIrradiance=vec3(0.,0.,0.);\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\n#ifdef ANISOTROPIC\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(anisotropicOut.anisotropicNormal,0)).xyz;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#endif\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;\n#endif\n#if defined(REALTIME_FILTERING)\nenvironmentIrradiance=irradiance(reflectionSampler,irradianceVector,vReflectionFilteringInfo);\n#else\nenvironmentIrradiance=computeEnvironmentIrradiance(irradianceVector);\n#endif\n#ifdef SS_TRANSLUCENCY\noutParams.irradianceVector=irradianceVector;\n#endif\n#endif\n#elif defined(USEIRRADIANCEMAP)\nvec4 environmentIrradiance4=sampleReflection(irradianceSampler,reflectionCoords);\nenvironmentIrradiance=environmentIrradiance4.rgb;\n#ifdef RGBDREFLECTION\nenvironmentIrradiance.rgb=fromRGBD(environmentIrradiance4);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentIrradiance.rgb=toLinearSpace(environmentIrradiance.rgb);\n#endif\n#endif\nenvironmentIrradiance*=vReflectionColor.rgb;\noutParams.environmentRadiance=environmentRadiance;\noutParams.environmentIrradiance=environmentIrradiance;\noutParams.reflectionCoords=reflectionCoords;\n}\n#endif\n";ai.a.IncludesShadersStore.pbrBlockReflection=Yo;var Ko="#ifdef SHEEN\nstruct sheenOutParams\n{\nfloat sheenIntensity;\nvec3 sheenColor;\nfloat sheenRoughness;\n#ifdef SHEEN_LINKWITHALBEDO\nvec3 surfaceAlbedo;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfloat sheenAlbedoScaling;\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nvec3 finalSheenRadianceScaled;\n#endif\n#if DEBUGMODE>0\nvec4 sheenMapData;\nvec3 sheenEnvironmentReflectance;\n#endif\n};\n#define pbr_inline\n#define inline\nvoid sheenBlock(\nconst in vec4 vSheenColor,\n#ifdef SHEEN_ROUGHNESS\nconst in float vSheenRoughness,\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nconst in vec4 sheenMapRoughnessData,\n#endif\n#endif\nconst in float roughness,\n#ifdef SHEEN_TEXTURE\nconst in vec4 sheenMapData,\n#endif\nconst in float reflectance,\n#ifdef SHEEN_LINKWITHALBEDO\nconst in vec3 baseColor,\nconst in vec3 surfaceAlbedo,\n#endif\n#ifdef ENVIRONMENTBRDF\nconst in float NdotV,\nconst in vec3 environmentBrdf,\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nconst in vec2 AARoughnessFactors,\nconst in vec3 vReflectionMicrosurfaceInfos,\nconst in vec2 vReflectionInfos,\nconst in vec3 vReflectionColor,\nconst in vec4 vLightingIntensity,\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSampler,\nconst in vec3 reflectionCoords,\n#else\nconst in sampler2D reflectionSampler,\nconst in vec2 reflectionCoords,\n#endif\nconst in float NdotVUnclamped,\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSamplerLow,\nconst in samplerCube reflectionSamplerHigh,\n#else\nconst in sampler2D reflectionSamplerLow,\nconst in sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nconst in vec2 vReflectionFilteringInfo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nconst in float seo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\nconst in float eho,\n#endif\n#endif\nout sheenOutParams outParams\n)\n{\nfloat sheenIntensity=vSheenColor.a;\n#ifdef SHEEN_TEXTURE\n#if DEBUGMODE>0\noutParams.sheenMapData=sheenMapData;\n#endif\n#endif\n#ifdef SHEEN_LINKWITHALBEDO\nfloat sheenFactor=pow5(1.0-sheenIntensity);\nvec3 sheenColor=baseColor.rgb*(1.0-sheenFactor);\nfloat sheenRoughness=sheenIntensity;\noutParams.surfaceAlbedo=surfaceAlbedo*sheenFactor;\n#ifdef SHEEN_TEXTURE\nsheenIntensity*=sheenMapData.a;\n#endif\n#else\nvec3 sheenColor=vSheenColor.rgb;\n#ifdef SHEEN_TEXTURE\nsheenColor.rgb*=sheenMapData.rgb;\n#endif\n#ifdef SHEEN_ROUGHNESS\nfloat sheenRoughness=vSheenRoughness;\n#ifdef SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE\n#if defined(SHEEN_TEXTURE)\nsheenRoughness*=sheenMapData.a;\n#endif\n#elif defined(SHEEN_TEXTURE_ROUGHNESS)\n#ifdef SHEEN_TEXTURE_ROUGHNESS_IDENTICAL\nsheenRoughness*=sheenMapData.a;\n#else\nsheenRoughness*=sheenMapRoughnessData.a;\n#endif\n#endif\n#else\nfloat sheenRoughness=roughness;\n#ifdef SHEEN_TEXTURE\nsheenIntensity*=sheenMapData.a;\n#endif\n#endif\n\n#if !defined(SHEEN_ALBEDOSCALING)\nsheenIntensity*=(1.-reflectance);\n#endif\n\nsheenColor*=sheenIntensity;\n#endif\n\n#ifdef ENVIRONMENTBRDF\n\n#ifdef SHEEN_ROUGHNESS\nvec3 environmentSheenBrdf=getBRDFLookup(NdotV,sheenRoughness);\n#else\nvec3 environmentSheenBrdf=environmentBrdf;\n#endif\n\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nfloat sheenAlphaG=convertRoughnessToAverageSlope(sheenRoughness);\n#ifdef SPECULARAA\n\nsheenAlphaG+=AARoughnessFactors.y;\n#endif\nvec4 environmentSheenRadiance=vec4(0.,0.,0.,0.);\nsampleReflectionTexture(\nsheenAlphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nsheenRoughness,\n#endif\nreflectionSampler,\nreflectionCoords,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentSheenRadiance\n);\nvec3 sheenEnvironmentReflectance=getSheenReflectanceFromBRDFLookup(sheenColor,environmentSheenBrdf);\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nsheenEnvironmentReflectance*=seo;\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\nsheenEnvironmentReflectance*=eho;\n#endif\n#if DEBUGMODE>0\noutParams.sheenEnvironmentReflectance=sheenEnvironmentReflectance;\n#endif\noutParams.finalSheenRadianceScaled=\nenvironmentSheenRadiance.rgb *\nsheenEnvironmentReflectance *\nvLightingIntensity.z;\n\n\n\n\n\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\n\n\n\noutParams.sheenAlbedoScaling=1.0-sheenIntensity*max(max(sheenColor.r,sheenColor.g),sheenColor.b)*environmentSheenBrdf.b;\n#endif\n\noutParams.sheenIntensity=sheenIntensity;\noutParams.sheenColor=sheenColor;\noutParams.sheenRoughness=sheenRoughness;\n}\n#endif\n";ai.a.IncludesShadersStore.pbrBlockSheen=Ko;var Qo="struct clearcoatOutParams\n{\nvec3 specularEnvironmentR0;\nfloat conservationFactor;\nvec3 clearCoatNormalW;\nvec2 clearCoatAARoughnessFactors;\nfloat clearCoatIntensity;\nfloat clearCoatRoughness;\n#ifdef REFLECTION\nvec3 finalClearCoatRadianceScaled;\n#endif\n#ifdef CLEARCOAT_TINT\nvec3 absorption;\nfloat clearCoatNdotVRefract;\nvec3 clearCoatColor;\nfloat clearCoatThickness;\n#endif\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nvec3 energyConservationFactorClearCoat;\n#endif\n#if DEBUGMODE>0\nmat3 TBNClearCoat;\nvec2 clearCoatMapData;\nvec4 clearCoatTintMapData;\nvec4 environmentClearCoatRadiance;\nfloat clearCoatNdotV;\nvec3 clearCoatEnvironmentReflectance;\n#endif\n};\n#ifdef CLEARCOAT\n#define pbr_inline\n#define inline\nvoid clearcoatBlock(\nconst in vec3 vPositionW,\nconst in vec3 geometricNormalW,\nconst in vec3 viewDirectionW,\nconst in vec2 vClearCoatParams,\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nconst in vec4 clearCoatMapRoughnessData,\n#endif\nconst in vec3 specularEnvironmentR0,\n#ifdef CLEARCOAT_TEXTURE\nconst in vec2 clearCoatMapData,\n#endif\n#ifdef CLEARCOAT_TINT\nconst in vec4 vClearCoatTintParams,\nconst in float clearCoatColorAtDistance,\nconst in vec4 vClearCoatRefractionParams,\n#ifdef CLEARCOAT_TINT_TEXTURE\nconst in vec4 clearCoatTintMapData,\n#endif\n#endif\n#ifdef CLEARCOAT_BUMP\nconst in vec2 vClearCoatBumpInfos,\nconst in vec4 clearCoatBumpMapData,\nconst in vec2 vClearCoatBumpUV,\n#if defined(TANGENT) && defined(NORMAL)\nconst in mat3 vTBN,\n#else\nconst in vec2 vClearCoatTangentSpaceParams,\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nconst in mat4 normalMatrix,\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nconst in vec3 faceNormal,\n#endif\n#ifdef REFLECTION\nconst in vec3 vReflectionMicrosurfaceInfos,\nconst in vec2 vReflectionInfos,\nconst in vec3 vReflectionColor,\nconst in vec4 vLightingIntensity,\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSampler,\n#else\nconst in sampler2D reflectionSampler,\n#endif\n#ifndef LODBASEDMICROSFURACE\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube reflectionSamplerLow,\nconst in samplerCube reflectionSamplerHigh,\n#else\nconst in sampler2D reflectionSamplerLow,\nconst in sampler2D reflectionSamplerHigh,\n#endif\n#endif\n#ifdef REALTIME_FILTERING\nconst in vec2 vReflectionFilteringInfo,\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\nconst in float ambientMonochrome,\n#endif\n#endif\nout clearcoatOutParams outParams\n)\n{\n\nfloat clearCoatIntensity=vClearCoatParams.x;\nfloat clearCoatRoughness=vClearCoatParams.y;\n#ifdef CLEARCOAT_TEXTURE\nclearCoatIntensity*=clearCoatMapData.x;\n#ifdef CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE\nclearCoatRoughness*=clearCoatMapData.y;\n#endif\n#if DEBUGMODE>0\noutParams.clearCoatMapData=clearCoatMapData;\n#endif\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL\nclearCoatRoughness*=clearCoatMapData.y;\n#else\nclearCoatRoughness*=clearCoatMapRoughnessData.y;\n#endif\n#endif\noutParams.clearCoatIntensity=clearCoatIntensity;\noutParams.clearCoatRoughness=clearCoatRoughness;\n#ifdef CLEARCOAT_TINT\nvec3 clearCoatColor=vClearCoatTintParams.rgb;\nfloat clearCoatThickness=vClearCoatTintParams.a;\n#ifdef CLEARCOAT_TINT_TEXTURE\nclearCoatColor*=clearCoatTintMapData.rgb;\nclearCoatThickness*=clearCoatTintMapData.a;\n#if DEBUGMODE>0\noutParams.clearCoatTintMapData=clearCoatTintMapData;\n#endif\n#endif\noutParams.clearCoatColor=computeColorAtDistanceInMedia(clearCoatColor,clearCoatColorAtDistance);\noutParams.clearCoatThickness=clearCoatThickness;\n#endif\n\n\n\n\n#ifdef CLEARCOAT_REMAP_F0\nvec3 specularEnvironmentR0Updated=getR0RemappedForClearCoat(specularEnvironmentR0);\n#else\nvec3 specularEnvironmentR0Updated=specularEnvironmentR0;\n#endif\noutParams.specularEnvironmentR0=mix(specularEnvironmentR0,specularEnvironmentR0Updated,clearCoatIntensity);\n\nvec3 clearCoatNormalW=geometricNormalW;\n#ifdef CLEARCOAT_BUMP\n#ifdef NORMALXYSCALE\nfloat clearCoatNormalScale=1.0;\n#else\nfloat clearCoatNormalScale=vClearCoatBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBNClearCoat=vTBN;\n#else\nmat3 TBNClearCoat=cotangent_frame(clearCoatNormalW*clearCoatNormalScale,vPositionW,vClearCoatBumpUV,vClearCoatTangentSpaceParams);\n#endif\n#if DEBUGMODE>0\noutParams.TBNClearCoat=TBNClearCoat;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nclearCoatNormalW=normalize(clearCoatBumpMapData.xyz*2.0-1.0);\nclearCoatNormalW=normalize(mat3(normalMatrix)*clearCoatNormalW);\n#else\nclearCoatNormalW=perturbNormal(TBNClearCoat,clearCoatBumpMapData.xyz,vClearCoatBumpInfos.y);\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nclearCoatNormalW*=sign(dot(clearCoatNormalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nclearCoatNormalW=gl_FrontFacing ? clearCoatNormalW : -clearCoatNormalW;\n#endif\noutParams.clearCoatNormalW=clearCoatNormalW;\n\noutParams.clearCoatAARoughnessFactors=getAARoughnessFactors(clearCoatNormalW.xyz);\n\nfloat clearCoatNdotVUnclamped=dot(clearCoatNormalW,viewDirectionW);\n\nfloat clearCoatNdotV=absEps(clearCoatNdotVUnclamped);\n#if DEBUGMODE>0\noutParams.clearCoatNdotV=clearCoatNdotV;\n#endif\n#ifdef CLEARCOAT_TINT\n\nvec3 clearCoatVRefract=-refract(vPositionW,clearCoatNormalW,vClearCoatRefractionParams.y);\n\noutParams.clearCoatNdotVRefract=absEps(dot(clearCoatNormalW,clearCoatVRefract));\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec3 environmentClearCoatBrdf=getBRDFLookup(clearCoatNdotV,clearCoatRoughness);\n#endif\n\n#if defined(REFLECTION)\nfloat clearCoatAlphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\n#ifdef SPECULARAA\n\nclearCoatAlphaG+=outParams.clearCoatAARoughnessFactors.y;\n#endif\nvec4 environmentClearCoatRadiance=vec4(0.,0.,0.,0.);\nvec3 clearCoatReflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),clearCoatNormalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nclearCoatReflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 clearCoatReflectionCoords=clearCoatReflectionVector;\n#else\nvec2 clearCoatReflectionCoords=clearCoatReflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nclearCoatReflectionCoords/=clearCoatReflectionVector.z;\n#endif\nclearCoatReflectionCoords.y=1.0-clearCoatReflectionCoords.y;\n#endif\nsampleReflectionTexture(\nclearCoatAlphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nclearCoatNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nclearCoatRoughness,\n#endif\nreflectionSampler,\nclearCoatReflectionCoords,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nenvironmentClearCoatRadiance\n);\n#if DEBUGMODE>0\noutParams.environmentClearCoatRadiance=environmentClearCoatRadiance;\n#endif\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromBRDFLookup(vec3(vClearCoatRefractionParams.x),environmentClearCoatBrdf);\n#ifdef RADIANCEOCCLUSION\nfloat clearCoatSeo=environmentRadianceOcclusion(ambientMonochrome,clearCoatNdotVUnclamped);\nclearCoatEnvironmentReflectance*=clearCoatSeo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat clearCoatEho=environmentHorizonOcclusion(-viewDirectionW,clearCoatNormalW,geometricNormalW);\nclearCoatEnvironmentReflectance*=clearCoatEho;\n#endif\n#endif\n#endif\n#else\n\nvec3 clearCoatEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n#if DEBUGMODE>0\noutParams.clearCoatEnvironmentReflectance=clearCoatEnvironmentReflectance;\n#endif\noutParams.finalClearCoatRadianceScaled=\nenvironmentClearCoatRadiance.rgb *\nclearCoatEnvironmentReflectance *\nvLightingIntensity.z;\n#endif\n#if defined(CLEARCOAT_TINT)\n\noutParams.absorption=computeClearCoatAbsorption(outParams.clearCoatNdotVRefract,outParams.clearCoatNdotVRefract,outParams.clearCoatColor,clearCoatThickness,clearCoatIntensity);\n#endif\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,vClearCoatRefractionParams.x,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\noutParams.conservationFactor=(1.-fresnelIBLClearCoat);\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\noutParams.energyConservationFactorClearCoat=getEnergyConservationFactor(outParams.specularEnvironmentR0,environmentClearCoatBrdf);\n#endif\n}\n#endif\n";ai.a.IncludesShadersStore.pbrBlockClearcoat=Qo;var qo="struct subSurfaceOutParams\n{\nvec3 specularEnvironmentReflectance;\n#ifdef SS_REFRACTION\nvec3 finalRefraction;\nvec3 surfaceAlbedo;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nfloat alpha;\n#endif\n#ifdef REFLECTION\nfloat refractionFactorForIrradiance;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nvec3 transmittance;\nfloat translucencyIntensity;\n#ifdef REFLECTION\nvec3 refractionIrradiance;\n#endif\n#endif\n#if DEBUGMODE>0\nvec4 thicknessMap;\nvec4 environmentRefraction;\nvec3 refractionTransmittance;\n#endif\n};\n#ifdef SUBSURFACE\n#define pbr_inline\n#define inline\nvoid subSurfaceBlock(\nconst in vec3 vSubSurfaceIntensity,\nconst in vec2 vThicknessParam,\nconst in vec4 vTintColor,\nconst in vec3 normalW,\nconst in vec3 specularEnvironmentReflectance,\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nconst in vec4 thicknessMap,\n#endif\n#ifdef REFLECTION\n#ifdef SS_TRANSLUCENCY\nconst in mat4 reflectionMatrix,\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nconst in vec3 irradianceVector_,\n#endif\n#if defined(REALTIME_FILTERING)\nconst in samplerCube reflectionSampler,\nconst in vec2 vReflectionFilteringInfo,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\n#ifdef REFLECTIONMAP_3D\nconst in samplerCube irradianceSampler,\n#else\nconst in sampler2D irradianceSampler,\n#endif\n#endif\n#endif\n#endif\n#ifdef SS_REFRACTION\nconst in vec3 vPositionW,\nconst in vec3 viewDirectionW,\nconst in mat4 view,\nconst in vec3 surfaceAlbedo,\nconst in vec4 vRefractionInfos,\nconst in mat4 refractionMatrix,\nconst in vec3 vRefractionMicrosurfaceInfos,\nconst in vec4 vLightingIntensity,\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nconst in float alpha,\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nconst in float NdotVUnclamped,\n#endif\n#ifdef SS_LINEARSPECULARREFRACTION\nconst in float roughness,\n#else\nconst in float alphaG,\n#endif\n#ifdef SS_REFRACTIONMAP_3D\nconst in samplerCube refractionSampler,\n#ifndef LODBASEDMICROSFURACE\nconst in samplerCube refractionSamplerLow,\nconst in samplerCube refractionSamplerHigh,\n#endif\n#else\nconst in sampler2D refractionSampler,\n#ifndef LODBASEDMICROSFURACE\nconst in sampler2D refractionSamplerLow,\nconst in sampler2D refractionSamplerHigh,\n#endif\n#endif\n#ifdef ANISOTROPIC\nconst in anisotropicOutParams anisotropicOut,\n#endif\n#ifdef REALTIME_FILTERING\nconst in vec2 vRefractionFilteringInfo,\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nconst in vec3 vDiffusionDistance,\n#endif\nout subSurfaceOutParams outParams\n)\n{\noutParams.specularEnvironmentReflectance=specularEnvironmentReflectance;\n\n\n\n#ifdef SS_REFRACTION\nfloat refractionIntensity=vSubSurfaceIntensity.x;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nrefractionIntensity*=(1.0-alpha);\n\noutParams.alpha=1.0;\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nfloat translucencyIntensity=vSubSurfaceIntensity.y;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nfloat thickness=thicknessMap.r*vThicknessParam.y+vThicknessParam.x;\n#if DEBUGMODE>0\noutParams.thicknessMap=thicknessMap;\n#endif\n#ifdef SS_MASK_FROM_THICKNESS_TEXTURE\n#ifdef SS_REFRACTION\nrefractionIntensity*=thicknessMap.g;\n#endif\n#ifdef SS_TRANSLUCENCY\ntranslucencyIntensity*=thicknessMap.b;\n#endif\n#elif defined(SS_MASK_FROM_THICKNESS_TEXTURE_GLTF)\n#ifdef SS_REFRACTION\nrefractionIntensity*=thicknessMap.r;\n#elif defined(SS_TRANSLUCENCY)\ntranslucencyIntensity*=thicknessMap.r;\n#endif\nthickness=thicknessMap.g*vThicknessParam.y+vThicknessParam.x;\n#endif\n#else\nfloat thickness=vThicknessParam.y;\n#endif\n\n\n\n#ifdef SS_TRANSLUCENCY\nthickness=maxEps(thickness);\nvec3 transmittance=transmittanceBRDF_Burley(vTintColor.rgb,vDiffusionDistance,thickness);\ntransmittance*=translucencyIntensity;\noutParams.transmittance=transmittance;\noutParams.translucencyIntensity=translucencyIntensity;\n#endif\n\n\n\n#ifdef SS_REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicOut.anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef SS_REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef SS_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 SS_LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#elif defined(SS_LINEARSPECULARREFRACTION)\nfloat refractionLOD=getLinearLodFromRoughness(vRefractionMicrosurfaceInfos.x,roughness);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef SS_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\n#ifdef REALTIME_FILTERING\nenvironmentRefraction=vec4(radiance(alphaG,refractionSampler,refractionCoords,vRefractionFilteringInfo),1.0);\n#else\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#endif\n#else\nfloat lodRefractionNormalized=saturate(refractionLOD/log2(vRefractionMicrosurfaceInfos.x));\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 SS_RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef SS_GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n\n\n#ifdef SS_REFRACTION\nvec3 refractionTransmittance=vec3(refractionIntensity);\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\n\n\n\n\n\nrefractionTransmittance*=cocaLambert(volumeAlbedo,thickness);\n#elif defined(SS_LINKREFRACTIONTOTRANSPARENCY)\n\nfloat maxChannel=max(max(surfaceAlbedo.r,surfaceAlbedo.g),surfaceAlbedo.b);\nvec3 volumeAlbedo=saturate(maxChannel*surfaceAlbedo);\n\nenvironmentRefraction.rgb*=volumeAlbedo;\n#else\n\nvec3 volumeAlbedo=computeColorAtDistanceInMedia(vTintColor.rgb,vTintColor.w);\nrefractionTransmittance*=cocaLambert(volumeAlbedo,vThicknessParam.y);\n#endif\n#ifdef SS_ALBEDOFORREFRACTIONTINT\n\nenvironmentRefraction.rgb*=surfaceAlbedo.rgb;\n#endif\n\noutParams.surfaceAlbedo=surfaceAlbedo*(1.-refractionIntensity);\n#ifdef REFLECTION\n\noutParams.refractionFactorForIrradiance=(1.-refractionIntensity);\n\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\noutParams.specularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,refractionIntensity);\n\nrefractionTransmittance*=1.0-outParams.specularEnvironmentReflectance;\n#if DEBUGMODE>0\noutParams.refractionTransmittance=refractionTransmittance;\n#endif\noutParams.finalRefraction=environmentRefraction.rgb*refractionTransmittance*vLightingIntensity.z;\n#if DEBUGMODE>0\noutParams.environmentRefraction=environmentRefraction;\n#endif\n#endif\n\n\n\n#if defined(REFLECTION) && defined(SS_TRANSLUCENCY)\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX) || !defined(USESPHERICALFROMREFLECTIONMAP)\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\n#ifdef INVERTCUBICMAP\nirradianceVector.y*=-1.0;\n#endif\n#else\nvec3 irradianceVector=irradianceVector_;\n#endif\n#if defined(USESPHERICALFROMREFLECTIONMAP)\n#if defined(REALTIME_FILTERING)\nvec3 refractionIrradiance=irradiance(reflectionSampler,-irradianceVector,vReflectionFilteringInfo);\n#else\nvec3 refractionIrradiance=computeEnvironmentIrradiance(-irradianceVector);\n#endif\n#elif defined(USEIRRADIANCEMAP)\n#ifdef REFLECTIONMAP_3D\nvec3 irradianceCoords=irradianceVector;\n#else\nvec2 irradianceCoords=irradianceVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nirradianceCoords/=irradianceVector.z;\n#endif\nirradianceCoords.y=1.0-irradianceCoords.y;\n#endif\nvec4 refractionIrradiance=sampleReflection(irradianceSampler,-irradianceCoords);\n#ifdef RGBDREFLECTION\nrefractionIrradiance.rgb=fromRGBD(refractionIrradiance);\n#endif\n#ifdef GAMMAREFLECTION\nrefractionIrradiance.rgb=toLinearSpace(refractionIrradiance.rgb);\n#endif\n#else\nvec4 refractionIrradiance=vec4(0.);\n#endif\nrefractionIrradiance.rgb*=transmittance;\noutParams.refractionIrradiance=refractionIrradiance.rgb;\n#endif\n}\n#endif\n";ai.a.IncludesShadersStore.pbrBlockSubSurface=qo;var Zo="vec3 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\nvec3 geometricNormalW=normalW;\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\ngeometricNormalW=gl_FrontFacing ? geometricNormalW : -geometricNormalW;\n#endif\n";ai.a.IncludesShadersStore.pbrBlockNormalGeometric=Zo;i(134);var Jo="#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";ai.a.IncludesShadersStore.pbrBlockNormalFinal=Jo;i(162);var $o="#ifdef LIGHTMAP\nvec4 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset);\n#ifdef RGBDLIGHTMAP\nlightmapColor.rgb=fromRGBD(lightmapColor);\n#endif\n#ifdef GAMMALIGHTMAP\nlightmapColor.rgb=toLinearSpace(lightmapColor.rgb);\n#endif\nlightmapColor.rgb*=vLightmapInfos.y;\n#endif\n";ai.a.IncludesShadersStore.pbrBlockLightmapInit=$o;var ea="float NdotVUnclamped=dot(normalW,viewDirectionW);\n\nfloat NdotV=absEps(NdotVUnclamped);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#if defined(ENVIRONMENTBRDF)\n\nvec3 environmentBrdf=getBRDFLookup(NdotV,roughness);\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=aoOut.ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(aoOut.ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW,geometricNormalW);\n#endif\n#endif\n#endif\n#endif\n";ai.a.IncludesShadersStore.pbrBlockGeometryInfo=ea;var ta="float reflectance=max(max(reflectivityOut.surfaceReflectivityColor.r,reflectivityOut.surfaceReflectivityColor.g),reflectivityOut.surfaceReflectivityColor.b);\nvec3 specularEnvironmentR0=reflectivityOut.surfaceReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec3 specularEnvironmentR90=vec3(metallicReflectanceFactors.a);\n#else\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0);\n#endif\n\n#ifdef ALPHAFRESNEL\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nspecularEnvironmentR90=specularEnvironmentR90*reflectance90;\n#endif\n";ai.a.IncludesShadersStore.pbrBlockReflectance0=ta;var ia="#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\nvec3 specularEnvironmentReflectance=getReflectanceFromBRDFLookup(clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,environmentBrdf);\n#ifdef RADIANCEOCCLUSION\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=getReflectanceFromAnalyticalBRDFLookup_Jones(NdotV,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n#ifdef CLEARCOAT\nspecularEnvironmentReflectance*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nspecularEnvironmentReflectance*=clearcoatOut.absorption;\n#endif\n#endif\n";ai.a.IncludesShadersStore.pbrBlockReflectance=ia;var na="vec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef CLEARCOAT\nvec3 clearCoatBase=vec3(0.,0.,0.);\n#endif\n#ifdef SHEEN\nvec3 sheenBase=vec3(0.,0.,0.);\n#endif\n\npreLightingInfo preInfo;\nlightingInfo info;\nfloat shadow=1.;\n#if defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\nvec3 absorption=vec3(0.);\n#endif\n";ai.a.IncludesShadersStore.pbrBlockDirectLighting=na;var ra="\n\n\n\n#if defined(ENVIRONMENTBRDF)\n#ifdef MS_BRDF_ENERGY_CONSERVATION\nvec3 energyConservationFactor=getEnergyConservationFactor(clearcoatOut.specularEnvironmentR0,environmentBrdf);\n#endif\n#endif\n#ifndef METALLICWORKFLOW\n#ifdef SPECULAR_GLOSSINESS_ENERGY_CONSERVATION\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n#endif\n#endif\n#if defined(SHEEN) && defined(SHEEN_ALBEDOSCALING) && defined(ENVIRONMENTBRDF)\nsurfaceAlbedo.rgb=sheenOut.sheenAlbedoScaling*surfaceAlbedo.rgb;\n#endif\n\n#ifdef REFLECTION\nvec3 finalIrradiance=reflectionOut.environmentIrradiance;\n#if defined(CLEARCOAT)\nfinalIrradiance*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nfinalIrradiance*=clearcoatOut.absorption;\n#endif\n#endif\n#if defined(SS_REFRACTION)\nfinalIrradiance*=subSurfaceOut.refractionFactorForIrradiance;\n#endif\n#if defined(SS_TRANSLUCENCY)\nfinalIrradiance*=(1.0-subSurfaceOut.translucencyIntensity);\nfinalIrradiance+=subSurfaceOut.refractionIrradiance;\n#endif\nfinalIrradiance*=surfaceAlbedo.rgb;\nfinalIrradiance*=vLightingIntensity.z;\nfinalIrradiance*=aoOut.ambientOcclusionColor;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalSpecularScaled*=energyConservationFactor;\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfinalSpecularScaled*=sheenOut.sheenAlbedoScaling;\n#endif\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=reflectionOut.environmentRadiance.rgb;\nfinalRadiance*=subSurfaceOut.specularEnvironmentReflectance;\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalRadianceScaled*=energyConservationFactor;\n#endif\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF) && defined(SHEEN_ALBEDOSCALING)\nfinalRadianceScaled*=sheenOut.sheenAlbedoScaling;\n#endif\n#endif\n\n#ifdef SHEEN\nvec3 finalSheen=sheenBase*sheenOut.sheenColor;\nfinalSheen=max(finalSheen,0.0);\nvec3 finalSheenScaled=finalSheen*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(CLEARCOAT) && defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.conservationFactor;\n#if defined(CLEARCOAT_TINT)\nsheenOut.finalSheenRadianceScaled*=clearcoatOut.absorption;\n#endif\n#endif\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n#if defined(ENVIRONMENTBRDF) && defined(MS_BRDF_ENERGY_CONSERVATION)\nfinalClearCoatScaled*=clearcoatOut.energyConservationFactorClearCoat;\n#endif\n#ifdef SS_REFRACTION\nsubSurfaceOut.finalRefraction*=clearcoatOut.conservationFactor;\n#ifdef CLEARCOAT_TINT\nsubSurfaceOut.finalRefraction*=clearcoatOut.absorption;\n#endif\n#endif\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#if defined(CLEARCOAT)\nluminanceOverAlpha+=getLuminance(clearcoatOut.finalClearCoatRadianceScaled);\n#endif\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(CLEARCOAT) && defined(CLEARCOATOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalClearCoatScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA) || defined(CLEARCOATOVERALPHA)\nalpha=saturate(alpha+luminanceOverAlpha*luminanceOverAlpha);\n#endif\n#endif\n";ai.a.IncludesShadersStore.pbrBlockFinalLitComponents=ra;var oa="\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\nfinalDiffuse*=vLightingIntensity.x;\n\nvec3 finalAmbient=vAmbientColor;\nfinalAmbient*=surfaceAlbedo.rgb;\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\nfinalEmissive*=vLightingIntensity.y;\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),aoOut.ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=aoOut.ambientOcclusionColor;\n#endif\nfinalAmbient*=aoOut.ambientOcclusionColor;\nfinalDiffuse*=ambientOcclusionForDirectDiffuse;\n";ai.a.IncludesShadersStore.pbrBlockFinalUnlitComponents=oa;var aa="vec4 finalColor=vec4(\nfinalAmbient +\nfinalDiffuse +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance +\n#endif\n#ifdef SPECULARTERM\nfinalSpecularScaled +\n#endif\n#ifdef SHEEN\nfinalSheenScaled +\n#endif\n#ifdef CLEARCOAT\nfinalClearCoatScaled +\n#endif\n#ifdef REFLECTION\nfinalRadianceScaled +\n#if defined(SHEEN) && defined(ENVIRONMENTBRDF)\nsheenOut.finalSheenRadianceScaled +\n#endif\n#ifdef CLEARCOAT\nclearcoatOut.finalClearCoatRadianceScaled +\n#endif\n#endif\n#ifdef SS_REFRACTION\nsubSurfaceOut.finalRefraction +\n#endif\n#endif\nfinalEmissive,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor.rgb;\n#else\nfinalColor.rgb+=lightmapColor.rgb;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\n\nfinalColor=max(finalColor,0.0);\n";ai.a.IncludesShadersStore.pbrBlockFinalColorComposition=aa;i(155);var sa="#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\nfinalColor.a*=visibility;\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\n";ai.a.IncludesShadersStore.pbrBlockImageProcessing=sa;var ca="#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w>=vDebugMode.x) {\n\n#if DEBUGMODE == 1\ngl_FragColor.rgb=vPositionW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 2 && defined(NORMAL)\ngl_FragColor.rgb=vNormalW.rgb;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 3 && defined(BUMP) || DEBUGMODE == 3 && defined(PARALLAX) || DEBUGMODE == 3 && defined(ANISOTROPIC)\n\ngl_FragColor.rgb=TBN[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 4 && defined(BUMP) || DEBUGMODE == 4 && defined(PARALLAX) || DEBUGMODE == 4 && defined(ANISOTROPIC)\n\ngl_FragColor.rgb=TBN[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 5\n\ngl_FragColor.rgb=normalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 6 && defined(MAINUV1)\ngl_FragColor.rgb=vec3(vMainUV1,0.0);\n#elif DEBUGMODE == 7 && defined(MAINUV2)\ngl_FragColor.rgb=vec3(vMainUV2,0.0);\n#elif DEBUGMODE == 8 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[0];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 9 && defined(CLEARCOAT) && defined(CLEARCOAT_BUMP)\n\ngl_FragColor.rgb=clearcoatOut.TBNClearCoat[1];\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 10 && defined(CLEARCOAT)\n\ngl_FragColor.rgb=clearcoatOut.clearCoatNormalW;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 11 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicNormal;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 12 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicTangent;\n#define DEBUGMODE_NORMALIZE\n#elif DEBUGMODE == 13 && defined(ANISOTROPIC)\ngl_FragColor.rgb=anisotropicOut.anisotropicBitangent;\n#define DEBUGMODE_NORMALIZE\n\n#elif DEBUGMODE == 20 && defined(ALBEDO)\ngl_FragColor.rgb=albedoTexture.rgb;\n#elif DEBUGMODE == 21 && defined(AMBIENT)\ngl_FragColor.rgb=aoOut.ambientOcclusionColorMap.rgb;\n#elif DEBUGMODE == 22 && defined(OPACITY)\ngl_FragColor.rgb=opacityMap.rgb;\n#elif DEBUGMODE == 23 && defined(EMISSIVE)\ngl_FragColor.rgb=emissiveColorTex.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 24 && defined(LIGHTMAP)\ngl_FragColor.rgb=lightmapColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 25 && defined(REFLECTIVITY) && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.surfaceMetallicColorMap.rgb;\n#elif DEBUGMODE == 26 && defined(REFLECTIVITY) && !defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.surfaceReflectivityColorMap.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 27 && defined(CLEARCOAT) && defined(CLEARCOAT_TEXTURE)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatMapData.rg,0.0);\n#elif DEBUGMODE == 28 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\ngl_FragColor.rgb=clearcoatOut.clearCoatTintMapData.rgb;\n#elif DEBUGMODE == 29 && defined(SHEEN) && defined(SHEEN_TEXTURE)\ngl_FragColor.rgb=sheenOut.sheenMapData.rgb;\n#elif DEBUGMODE == 30 && defined(ANISOTROPIC) && defined(ANISOTROPIC_TEXTURE)\ngl_FragColor.rgb=anisotropicOut.anisotropyMapData.rgb;\n#elif DEBUGMODE == 31 && defined(SUBSURFACE) && defined(SS_THICKNESSANDMASK_TEXTURE)\ngl_FragColor.rgb=subSurfaceOut.thicknessMap.rgb;\n\n#elif DEBUGMODE == 40 && defined(SS_REFRACTION)\n\ngl_FragColor.rgb=subSurfaceOut.environmentRefraction.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 41 && defined(REFLECTION)\ngl_FragColor.rgb=reflectionOut.environmentRadiance.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 42 && defined(CLEARCOAT) && defined(REFLECTION)\ngl_FragColor.rgb=clearcoatOut.environmentClearCoatRadiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 50\ngl_FragColor.rgb=diffuseBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 51 && defined(SPECULARTERM)\ngl_FragColor.rgb=specularBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 52 && defined(CLEARCOAT)\ngl_FragColor.rgb=clearCoatBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 53 && defined(SHEEN)\ngl_FragColor.rgb=sheenBase.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 54 && defined(REFLECTION)\ngl_FragColor.rgb=reflectionOut.environmentIrradiance.rgb;\n#define DEBUGMODE_GAMMA\n\n#elif DEBUGMODE == 60\ngl_FragColor.rgb=surfaceAlbedo.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 61\ngl_FragColor.rgb=clearcoatOut.specularEnvironmentR0;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 62 && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=vec3(reflectivityOut.metallicRoughness.r);\n#elif DEBUGMODE == 71 && defined(METALLICWORKFLOW)\ngl_FragColor.rgb=reflectivityOut.metallicF0;\n#elif DEBUGMODE == 63\ngl_FragColor.rgb=vec3(roughness);\n#elif DEBUGMODE == 64\ngl_FragColor.rgb=vec3(alphaG);\n#elif DEBUGMODE == 65\ngl_FragColor.rgb=vec3(NdotV);\n#elif DEBUGMODE == 66 && defined(CLEARCOAT) && defined(CLEARCOAT_TINT)\ngl_FragColor.rgb=clearcoatOut.clearCoatColor.rgb;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 67 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatRoughness);\n#elif DEBUGMODE == 68 && defined(CLEARCOAT)\ngl_FragColor.rgb=vec3(clearcoatOut.clearCoatNdotV);\n#elif DEBUGMODE == 69 && defined(SUBSURFACE) && defined(SS_TRANSLUCENCY)\ngl_FragColor.rgb=subSurfaceOut.transmittance;\n#elif DEBUGMODE == 70 && defined(SUBSURFACE) && defined(SS_REFRACTION)\ngl_FragColor.rgb=subSurfaceOut.refractionTransmittance;\n\n#elif DEBUGMODE == 80 && defined(RADIANCEOCCLUSION)\ngl_FragColor.rgb=vec3(seo);\n#elif DEBUGMODE == 81 && defined(HORIZONOCCLUSION)\ngl_FragColor.rgb=vec3(eho);\n#elif DEBUGMODE == 82 && defined(MS_BRDF_ENERGY_CONSERVATION)\ngl_FragColor.rgb=vec3(energyConservationFactor);\n#elif DEBUGMODE == 83 && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=specularEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 84 && defined(CLEARCOAT) && defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\ngl_FragColor.rgb=clearcoatOut.clearCoatEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 85 && defined(SHEEN) && defined(REFLECTION)\ngl_FragColor.rgb=sheenOut.sheenEnvironmentReflectance;\n#define DEBUGMODE_GAMMA\n#elif DEBUGMODE == 86 && defined(ALPHABLEND)\ngl_FragColor.rgb=vec3(luminanceOverAlpha);\n#elif DEBUGMODE == 87\ngl_FragColor.rgb=vec3(alpha);\n#endif\ngl_FragColor.rgb*=vDebugMode.y;\n#ifdef DEBUGMODE_NORMALIZE\ngl_FragColor.rgb=normalize(gl_FragColor.rgb)*0.5+0.5;\n#endif\n#ifdef DEBUGMODE_GAMMA\ngl_FragColor.rgb=toGammaSpace(gl_FragColor.rgb);\n#endif\ngl_FragColor.a=1.0;\n#ifdef PREPASS\ngl_FragData[0]=toLinearSpace(gl_FragColor);\ngl_FragData[1]=vec4(0.,0.,0.,0.);\n#endif\nreturn;\n}\n#endif";ai.a.IncludesShadersStore.pbrDebug=ca;var la="#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n#include<prePassDeclaration>[SCENE_MRT_COUNT]\nprecision highp float;\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE\n#endif\n\n#include<__decl__pbrFragment>\n#include<pbrFragmentExtraDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<pbrFragmentSamplersDeclaration>\n#include<imageProcessingDeclaration>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<importanceSampling>\n#include<pbrHelperFunctions>\n#include<imageProcessingFunctions>\n#include<shadowsFragmentFunctions>\n#include<harmonicsFunctions>\n#include<pbrDirectLightingSetupFunctions>\n#include<pbrDirectLightingFalloffFunctions>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\n#include<pbrDirectLightingFunctions>\n#include<pbrIBLFunctions>\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\n#ifdef REFLECTION\n#include<reflectionFunction>\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\n#include<pbrBlockAlbedoOpacity>\n#include<pbrBlockReflectivity>\n#include<pbrBlockAmbientOcclusion>\n#include<pbrBlockAlphaFresnel>\n#include<pbrBlockAnisotropic>\n#include<pbrBlockReflection>\n#include<pbrBlockSheen>\n#include<pbrBlockClearcoat>\n#include<pbrBlockSubSurface>\n\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\n\n#include<pbrBlockNormalGeometric>\n#include<bumpFragment>\n#include<pbrBlockNormalFinal>\n\nalbedoOpacityOutParams albedoOpacityOut;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#endif\nalbedoOpacityBlock(\nvAlbedoColor,\n#ifdef ALBEDO\nalbedoTexture,\nvAlbedoInfos,\n#endif\n#ifdef OPACITY\nopacityMap,\nvOpacityInfos,\n#endif\n#ifdef DETAIL\ndetailColor,\nvDetailInfos,\n#endif\nalbedoOpacityOut\n);\nvec3 surfaceAlbedo=albedoOpacityOut.surfaceAlbedo;\nfloat alpha=albedoOpacityOut.alpha;\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\n#include<depthPrePass>\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\nambientOcclusionOutParams aoOut;\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb;\n#endif\nambientOcclusionBlock(\n#ifdef AMBIENT\nambientOcclusionColorMap,\nvAmbientInfos,\n#endif\naoOut\n);\n#include<pbrBlockLightmapInit>\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nvec3 baseColor=surfaceAlbedo;\nreflectivityOutParams reflectivityOut;\n#if defined(REFLECTIVITY)\nvec4 surfaceMetallicOrReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nvec4 baseReflectivity=surfaceMetallicOrReflectivityColorMap;\n#ifndef METALLICWORKFLOW\nsurfaceMetallicOrReflectivityColorMap=toLinearSpace(surfaceMetallicOrReflectivityColorMap);\nsurfaceMetallicOrReflectivityColorMap.rgb*=vReflectivityInfos.y;\n#endif\n#endif\n#if defined(MICROSURFACEMAP)\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\n#endif\n#ifdef METALLICWORKFLOW\nvec4 metallicReflectanceFactors=vMetallicReflectanceFactors;\n#ifdef METALLIC_REFLECTANCE\nvec4 metallicReflectanceFactorsMap=texture2D(metallicReflectanceSampler,vMetallicReflectanceUV+uvOffset);\nmetallicReflectanceFactorsMap=toLinearSpace(metallicReflectanceFactorsMap);\nmetallicReflectanceFactors*=metallicReflectanceFactorsMap;\n#endif\n#endif\nreflectivityBlock(\nvReflectivityColor,\n#ifdef METALLICWORKFLOW\nsurfaceAlbedo,\nmetallicReflectanceFactors,\n#endif\n#ifdef REFLECTIVITY\nvReflectivityInfos,\nsurfaceMetallicOrReflectivityColorMap,\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\naoOut.ambientOcclusionColor,\n#endif\n#ifdef MICROSURFACEMAP\nmicroSurfaceTexel,\n#endif\n#ifdef DETAIL\ndetailColor,\nvDetailInfos,\n#endif\nreflectivityOut\n);\nfloat microSurface=reflectivityOut.microSurface;\nfloat roughness=reflectivityOut.roughness;\n#ifdef METALLICWORKFLOW\nsurfaceAlbedo=reflectivityOut.surfaceAlbedo;\n#endif\n#if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\naoOut.ambientOcclusionColor=reflectivityOut.ambientOcclusionColor;\n#endif\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\nalphaFresnelOutParams alphaFresnelOut;\nalphaFresnelBlock(\nnormalW,\nviewDirectionW,\nalpha,\nmicroSurface,\nalphaFresnelOut\n);\nalpha=alphaFresnelOut.alpha;\n#endif\n#endif\n\n#include<pbrBlockGeometryInfo>\n\n#ifdef ANISOTROPIC\nanisotropicOutParams anisotropicOut;\n#ifdef ANISOTROPIC_TEXTURE\nvec3 anisotropyMapData=texture2D(anisotropySampler,vAnisotropyUV+uvOffset).rgb*vAnisotropyInfos.y;\n#endif\nanisotropicBlock(\nvAnisotropy,\n#ifdef ANISOTROPIC_TEXTURE\nanisotropyMapData,\n#endif\nTBN,\nnormalW,\nviewDirectionW,\nanisotropicOut\n);\n#endif\n\n#ifdef REFLECTION\nreflectionOutParams reflectionOut;\nreflectionBlock(\nvPositionW,\nnormalW,\nalphaG,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nNdotVUnclamped,\n#endif\n#ifdef LINEARSPECULARREFLECTION\nroughness,\n#endif\nreflectionSampler,\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nvEnvironmentIrradiance,\n#endif\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nreflectionMatrix,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\nirradianceSampler,\n#endif\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\nreflectionOut\n);\n#endif\n\n#include<pbrBlockReflectance0>\n\n#ifdef SHEEN\nsheenOutParams sheenOut;\n#ifdef SHEEN_TEXTURE\nvec4 sheenMapData=toLinearSpace(texture2D(sheenSampler,vSheenUV+uvOffset))*vSheenInfos.y;\n#endif\n#if defined(SHEEN_ROUGHNESS) && defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nvec4 sheenMapRoughnessData=texture2D(sheenRoughnessSampler,vSheenRoughnessUV+uvOffset)*vSheenInfos.w;\n#endif\nsheenBlock(\nvSheenColor,\n#ifdef SHEEN_ROUGHNESS\nvSheenRoughness,\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && !defined(SHEEN_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE)\nsheenMapRoughnessData,\n#endif\n#endif\nroughness,\n#ifdef SHEEN_TEXTURE\nsheenMapData,\n#endif\nreflectance,\n#ifdef SHEEN_LINKWITHALBEDO\nbaseColor,\nsurfaceAlbedo,\n#endif\n#ifdef ENVIRONMENTBRDF\nNdotV,\nenvironmentBrdf,\n#endif\n#if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\nAARoughnessFactors,\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\nvLightingIntensity,\nreflectionSampler,\nreflectionOut.reflectionCoords,\nNdotVUnclamped,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(RADIANCEOCCLUSION)\nseo,\n#endif\n#if !defined(REFLECTIONMAP_SKYBOX) && defined(HORIZONOCCLUSION) && defined(BUMP) && defined(REFLECTIONMAP_3D)\neho,\n#endif\n#endif\nsheenOut\n);\n#ifdef SHEEN_LINKWITHALBEDO\nsurfaceAlbedo=sheenOut.surfaceAlbedo;\n#endif\n#endif\n\nclearcoatOutParams clearcoatOut;\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nvec2 clearCoatMapData=texture2D(clearCoatSampler,vClearCoatUV+uvOffset).rg*vClearCoatInfos.y;\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nvec4 clearCoatMapRoughnessData=texture2D(clearCoatRoughnessSampler,vClearCoatRoughnessUV+uvOffset)*vClearCoatInfos.w;\n#endif\n#if defined(CLEARCOAT_TINT) && defined(CLEARCOAT_TINT_TEXTURE)\nvec4 clearCoatTintMapData=toLinearSpace(texture2D(clearCoatTintSampler,vClearCoatTintUV+uvOffset));\n#endif\n#ifdef CLEARCOAT_BUMP\nvec4 clearCoatBumpMapData=texture2D(clearCoatBumpSampler,vClearCoatBumpUV+uvOffset);\n#endif\nclearcoatBlock(\nvPositionW,\ngeometricNormalW,\nviewDirectionW,\nvClearCoatParams,\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL) && !defined(CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE)\nclearCoatMapRoughnessData,\n#endif\nspecularEnvironmentR0,\n#ifdef CLEARCOAT_TEXTURE\nclearCoatMapData,\n#endif\n#ifdef CLEARCOAT_TINT\nvClearCoatTintParams,\nclearCoatColorAtDistance,\nvClearCoatRefractionParams,\n#ifdef CLEARCOAT_TINT_TEXTURE\nclearCoatTintMapData,\n#endif\n#endif\n#ifdef CLEARCOAT_BUMP\nvClearCoatBumpInfos,\nclearCoatBumpMapData,\nvClearCoatBumpUV,\n#if defined(TANGENT) && defined(NORMAL)\nvTBN,\n#else\nvClearCoatTangentSpaceParams,\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nnormalMatrix,\n#endif\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nfaceNormal,\n#endif\n#ifdef REFLECTION\nvReflectionMicrosurfaceInfos,\nvReflectionInfos,\nvReflectionColor,\nvLightingIntensity,\nreflectionSampler,\n#ifndef LODBASEDMICROSFURACE\nreflectionSamplerLow,\nreflectionSamplerHigh,\n#endif\n#ifdef REALTIME_FILTERING\nvReflectionFilteringInfo,\n#endif\n#endif\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n#ifdef RADIANCEOCCLUSION\nambientMonochrome,\n#endif\n#endif\nclearcoatOut\n);\n#else\nclearcoatOut.specularEnvironmentR0=specularEnvironmentR0;\n#endif\n\n#include<pbrBlockReflectance>\n\nsubSurfaceOutParams subSurfaceOut;\n#ifdef SUBSURFACE\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nvec4 thicknessMap=texture2D(thicknessSampler,vThicknessUV+uvOffset);\n#endif\nsubSurfaceBlock(\nvSubSurfaceIntensity,\nvThicknessParam,\nvTintColor,\nnormalW,\nspecularEnvironmentReflectance,\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nthicknessMap,\n#endif\n#ifdef REFLECTION\n#ifdef SS_TRANSLUCENCY\nreflectionMatrix,\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\nreflectionOut.irradianceVector,\n#endif\n#if defined(REALTIME_FILTERING)\nreflectionSampler,\nvReflectionFilteringInfo,\n#endif\n#endif\n#ifdef USEIRRADIANCEMAP\nirradianceSampler,\n#endif\n#endif\n#endif\n#ifdef SS_REFRACTION\nvPositionW,\nviewDirectionW,\nview,\nsurfaceAlbedo,\nvRefractionInfos,\nrefractionMatrix,\nvRefractionMicrosurfaceInfos,\nvLightingIntensity,\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nalpha,\n#endif\n#ifdef SS_LODINREFRACTIONALPHA\nNdotVUnclamped,\n#endif\n#ifdef SS_LINEARSPECULARREFRACTION\nroughness,\n#else\nalphaG,\n#endif\nrefractionSampler,\n#ifndef LODBASEDMICROSFURACE\nrefractionSamplerLow,\nrefractionSamplerHigh,\n#endif\n#ifdef ANISOTROPIC\nanisotropicOut,\n#endif\n#ifdef REALTIME_FILTERING\nvRefractionFilteringInfo,\n#endif\n#endif\n#ifdef SS_TRANSLUCENCY\nvDiffusionDistance,\n#endif\nsubSurfaceOut\n);\n#ifdef SS_REFRACTION\nsurfaceAlbedo=subSurfaceOut.surfaceAlbedo;\n#ifdef SS_LINKREFRACTIONTOTRANSPARENCY\nalpha=subSurfaceOut.alpha;\n#endif\n#endif\n#else\nsubSurfaceOut.specularEnvironmentReflectance=specularEnvironmentReflectance;\n#endif\n\n#include<pbrBlockDirectLighting>\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#include<pbrBlockFinalLitComponents>\n#endif\n#include<pbrBlockFinalUnlitComponents>\n#include<pbrBlockFinalColorComposition>\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#include<pbrBlockImageProcessing>\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\n#ifdef PREPASS\n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,1.0);\n#endif\n#ifdef PREPASS_VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[PREPASS_VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef PREPASS_IRRADIANCE\nvec3 irradiance=finalDiffuse;\n#ifndef UNLIT\n#ifdef REFLECTION\nirradiance+=finalIrradiance;\n#endif\n#endif\nvec3 sqAlbedo=sqrt(surfaceAlbedo);\n#ifdef SS_SCATTERING\ngl_FragData[0]=vec4(finalColor.rgb-irradiance,finalColor.a);\nirradiance/=sqAlbedo;\n#else\ngl_FragData[0]=finalColor;\nfloat scatteringDiffusionProfile=255.;\n#endif\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(irradiance,scatteringDiffusionProfile/255.);\n#else\ngl_FragData[0]=vec4(finalColor.rgb,finalColor.a);\n#endif\n#ifdef PREPASS_DEPTHNORMAL\ngl_FragData[PREPASS_DEPTHNORMAL_INDEX]=vec4(vViewPos.z,(view*vec4(normalW,0.0)).rgb);\n#endif\n#ifdef PREPASS_ALBEDO\ngl_FragData[PREPASS_ALBEDO_INDEX]=vec4(sqAlbedo,1.0);\n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(REFLECTIVITY)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(baseReflectivity.rgb,1.0);\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,1.0);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=finalColor;\n#endif\n#include<pbrDebug>\n}\n";ai.a.ShadersStore.pbrPixelShader=la;var ua="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 METALLIC_REFLECTANCE\nuniform vec2 vMetallicReflectanceInfos;\nuniform mat4 metallicReflectanceMatrix;\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 REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\n#endif\n\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) || defined(CLEARCOAT_TEXTURE_ROUGHNESS)\nuniform vec4 vClearCoatInfos;\n#endif\n#ifdef CLEARCOAT_TEXTURE\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_TEXTURE_ROUGHNESS\nuniform mat4 clearCoatRoughnessMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) || defined(SHEEN_TEXTURE_ROUGHNESS)\nuniform vec4 vSheenInfos;\n#endif\n#ifdef SHEEN_TEXTURE\nuniform mat4 sheenMatrix;\n#endif\n#ifdef SHEEN_TEXTURE_ROUGHNESS\nuniform mat4 sheenRoughnessMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\n#endif\n#endif\n";ai.a.IncludesShadersStore.pbrVertexDeclaration=ua;i(163),i(164),i(93),i(94),i(100),i(165),i(156),i(158);var ha="precision highp float;\n#include<__decl__pbrVertex>\n#define CUSTOM_VERTEX_BEGIN\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#include<prePassVertexDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(DETAIL) && DETAILDIRECTUV == 0\nvarying vec2 vDetailUV;\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(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0\nvarying vec2 vMetallicReflectanceUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0\nvarying vec2 vClearCoatRoughnessUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatTintUV;\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nvarying vec2 vSheenUV;\n#endif\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0\nvarying vec2 vSheenRoughnessUV;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nvarying vec2 vAnisotropyUV;\n#endif\n#endif\n#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nvarying vec2 vThicknessUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\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>\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#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#include<prePassVertex>\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvNormalW=normalUpdated/vec3(dot(normalWorld[0],normalWorld[0]),dot(normalWorld[1],normalWorld[1]),dot(normalWorld[2],normalWorld[2]));\nvNormalW=normalize(normalWorld*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\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=computeEnvironmentIrradiance(reflectionVector);\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_WORLDPOS\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#if DEBUGMODE>0\nvClipSpacePosition=gl_Position;\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 uvUpdated=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(DETAIL) && DETAILDIRECTUV == 0\nif (vDetailInfos.x == 0.)\n{\nvDetailUV=vec2(detailMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvDetailUV=vec2(detailMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,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(uvUpdated,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(METALLIC_REFLECTANCE) && METALLIC_REFLECTANCEDIRECTUV == 0\nif (vMetallicReflectanceInfos.x == 0.)\n{\nvMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvMetallicReflectanceUV=vec2(metallicReflectanceMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nif (vClearCoatInfos.x == 0.)\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvClearCoatUV=vec2(clearCoatMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV == 0\nif (vClearCoatInfos.z == 0.)\n{\nvClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvClearCoatRoughnessUV=vec2(clearCoatRoughnessMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nif (vClearCoatBumpInfos.x == 0.)\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvClearCoatBumpUV=vec2(clearCoatBumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(CLEARCOAT_TINT_TEXTURE) && CLEARCOAT_TINT_TEXTUREDIRECTUV == 0\nif (vClearCoatTintInfos.x == 0.)\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvClearCoatTintUV=vec2(clearCoatTintMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SHEEN\n#if defined(SHEEN_TEXTURE) && SHEEN_TEXTUREDIRECTUV == 0\nif (vSheenInfos.x == 0.)\n{\nvSheenUV=vec2(sheenMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvSheenUV=vec2(sheenMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SHEEN_TEXTURE_ROUGHNESS) && SHEEN_TEXTURE_ROUGHNESSDIRECTUV == 0\nif (vSheenInfos.z == 0.)\n{\nvSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvSheenRoughnessUV=vec2(sheenRoughnessMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef ANISOTROPIC\n#if defined(ANISOTROPIC_TEXTURE) && ANISOTROPIC_TEXTUREDIRECTUV == 0\nif (vAnisotropyInfos.x == 0.)\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvAnisotropyUV=vec2(anisotropyMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#endif\n#ifdef SUBSURFACE\n#if defined(SS_THICKNESSANDMASK_TEXTURE) && SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 0\nif (vThicknessInfos.x == 0.)\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uvUpdated,1.0,0.0));\n}\nelse\n{\nvThicknessUV=vec2(thicknessMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\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#define CUSTOM_VERTEX_MAIN_END\n}";ai.a.ShadersStore.pbrVertexShader=ha;var da=i(92),fa={effect:null,subMesh:null},pa=function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.NUM_SAMPLES="0",t.REALTIME_FILTERING=!1,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.GAMMAALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.DETAIL=!1,t.DETAILDIRECTUV=0,t.DETAIL_NORMALBLENDMETHOD=0,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.METALLIC_REFLECTANCE=!1,t.METALLIC_REFLECTANCEDIRECTUV=0,t.ENVIRONMENTBRDF=!1,t.ENVIRONMENTBRDF_RGBD=!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.RGBDLIGHTMAP=!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_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USEIRRADIANCEMAP=!1,t.SPHERICAL_HARMONICS=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.LINEARSPECULARREFLECTION=!1,t.RADIANCEOCCLUSION=!1,t.HORIZONOCCLUSION=!1,t.INSTANCES=!1,t.THIN_INSTANCES=!1,t.PREPASS=!1,t.PREPASS_IRRADIANCE=!1,t.PREPASS_IRRADIANCE_INDEX=-1,t.PREPASS_ALBEDO=!1,t.PREPASS_ALBEDO_INDEX=-1,t.PREPASS_DEPTHNORMAL=!1,t.PREPASS_DEPTHNORMAL_INDEX=-1,t.PREPASS_POSITION=!1,t.PREPASS_POSITION_INDEX=-1,t.PREPASS_VELOCITY=!1,t.PREPASS_VELOCITY_INDEX=-1,t.PREPASS_REFLECTIVITY=!1,t.PREPASS_REFLECTIVITY_INDEX=-1,t.SCENE_MRT_COUNT=0,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.BONES_VELOCITY_ENABLED=!1,t.NONUNIFORMSCALING=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_UV=!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.MULTIVIEW=!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.CLIPPLANE5=!1,t.CLIPPLANE6=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.SPECULARAA=!1,t.CLEARCOAT=!1,t.CLEARCOAT_DEFAULTIOR=!1,t.CLEARCOAT_TEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS=!1,t.CLEARCOAT_TEXTUREDIRECTUV=0,t.CLEARCOAT_TEXTURE_ROUGHNESSDIRECTUV=0,t.CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t.CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL=!1,t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_BUMPDIRECTUV=0,t.CLEARCOAT_REMAP_F0=!0,t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1,t.CLEARCOAT_TINT_TEXTUREDIRECTUV=0,t.ANISOTROPIC=!1,t.ANISOTROPIC_TEXTURE=!1,t.ANISOTROPIC_TEXTUREDIRECTUV=0,t.BRDF_V_HEIGHT_CORRELATED=!1,t.MS_BRDF_ENERGY_CONSERVATION=!1,t.SPECULAR_GLOSSINESS_ENERGY_CONSERVATION=!1,t.SHEEN=!1,t.SHEEN_TEXTURE=!1,t.SHEEN_TEXTURE_ROUGHNESS=!1,t.SHEEN_TEXTUREDIRECTUV=0,t.SHEEN_TEXTURE_ROUGHNESSDIRECTUV=0,t.SHEEN_LINKWITHALBEDO=!1,t.SHEEN_ROUGHNESS=!1,t.SHEEN_ALBEDOSCALING=!1,t.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE=!1,t.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL=!1,t.SUBSURFACE=!1,t.SS_REFRACTION=!1,t.SS_TRANSLUCENCY=!1,t.SS_SCATTERING=!1,t.SS_THICKNESSANDMASK_TEXTURE=!1,t.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,t.SS_REFRACTIONMAP_3D=!1,t.SS_REFRACTIONMAP_OPPOSITEZ=!1,t.SS_LODINREFRACTIONALPHA=!1,t.SS_GAMMAREFRACTION=!1,t.SS_RGBDREFRACTION=!1,t.SS_LINEARSPECULARREFRACTION=!1,t.SS_LINKREFRACTIONTOTRANSPARENCY=!1,t.SS_ALBEDOFORREFRACTIONTINT=!1,t.SS_MASK_FROM_THICKNESS_TEXTURE=!1,t.SS_MASK_FROM_THICKNESS_TEXTURE_GLTF=!1,t.UNLIT=!1,t.DEBUGMODE=0,t.rebuild(),t}return Object(h.d)(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0},t}(oo.a),_a=function(e){function t(i,n){var r=e.call(this,i,n)||this;return r._directIntensity=1,r._emissiveIntensity=1,r._environmentIntensity=1,r._specularIntensity=1,r._lightingInfos=new a.f(r._directIntensity,r._emissiveIntensity,r._environmentIntensity,r._specularIntensity),r._disableBumpMap=!1,r._albedoTexture=null,r._ambientTexture=null,r._ambientTextureStrength=1,r._ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,r._opacityTexture=null,r._reflectionTexture=null,r._emissiveTexture=null,r._reflectivityTexture=null,r._metallicTexture=null,r._metallic=null,r._roughness=null,r._metallicF0Factor=1,r._metallicReflectanceColor=s.a.White(),r._metallicReflectanceTexture=null,r._microSurfaceTexture=null,r._bumpTexture=null,r._lightmapTexture=null,r._ambientColor=new s.a(0,0,0),r._albedoColor=new s.a(1,1,1),r._reflectivityColor=new s.a(1,1,1),r._reflectionColor=new s.a(1,1,1),r._emissiveColor=new s.a(0,0,0),r._microSurface=.9,r._useLightmapAsShadowmap=!1,r._useHorizonOcclusion=!0,r._useRadianceOcclusion=!0,r._useAlphaFromAlbedoTexture=!1,r._useSpecularOverAlpha=!0,r._useMicroSurfaceFromReflectivityMapAlpha=!1,r._useRoughnessFromMetallicTextureAlpha=!0,r._useRoughnessFromMetallicTextureGreen=!1,r._useMetallnessFromMetallicTextureBlue=!1,r._useAmbientOcclusionFromMetallicTextureRed=!1,r._useAmbientInGrayScale=!1,r._useAutoMicroSurfaceFromReflectivityMap=!1,r._lightFalloff=t.LIGHTFALLOFF_PHYSICAL,r._useRadianceOverAlpha=!0,r._useObjectSpaceNormalMap=!1,r._useParallax=!1,r._useParallaxOcclusion=!1,r._parallaxScaleBias=.05,r._disableLighting=!1,r._maxSimultaneousLights=4,r._invertNormalMapX=!1,r._invertNormalMapY=!1,r._twoSidedLighting=!1,r._alphaCutOff=.4,r._forceAlphaTest=!1,r._useAlphaFresnel=!1,r._useLinearAlphaFresnel=!1,r._environmentBRDFTexture=null,r._forceIrradianceInFragment=!1,r._realTimeFiltering=!1,r._realTimeFilteringQuality=g.a.TEXTURE_FILTERING_QUALITY_LOW,r._forceNormalForward=!1,r._enableSpecularAntiAliasing=!1,r._imageProcessingObserver=null,r._renderTargets=new oi.a(16),r._globalAmbientColor=new s.a(0,0,0),r._useLogarithmicDepth=!1,r._unlit=!1,r._debugMode=0,r.debugMode=0,r.debugLimit=-1,r.debugFactor=1,r.clearCoat=new Eo(r._markAllSubMeshesAsTexturesDirty.bind(r)),r.anisotropy=new So(r._markAllSubMeshesAsTexturesDirty.bind(r)),r.brdf=new Ao(r._markAllSubMeshesAsMiscDirty.bind(r)),r.sheen=new Po(r._markAllSubMeshesAsTexturesDirty.bind(r)),r.detailMap=new da.a(r._markAllSubMeshesAsTexturesDirty.bind(r)),r._rebuildInParallel=!1,r._attachImageProcessingConfiguration(null),r.getRenderTargetTextures=function(){return r._renderTargets.reset(),so.a.ReflectionTextureEnabled&&r._reflectionTexture&&r._reflectionTexture.isRenderTarget&&r._renderTargets.push(r._reflectionTexture),r.subSurface.fillRenderTargetTextures(r._renderTargets),r._renderTargets},r._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(n),r.subSurface=new Co(r._markAllSubMeshesAsTexturesDirty.bind(r),r._markScenePrePassDirty.bind(r),n),r.prePassConfiguration=new Ro.a,r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"realTimeFiltering",{get:function(){return this._realTimeFiltering},set:function(e){this._realTimeFiltering=e,this.markAsDirty(g.a.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"realTimeFilteringQuality",{get:function(){return this._realTimeFilteringQuality},set:function(e){this._realTimeFilteringQuality=e,this.markAsDirty(g.a.MATERIAL_TextureDirtyFlag)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canRenderToMRT",{get:function(){return!0},enumerable:!1,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,"hasRenderTargetTextures",{get:function(){return!!(so.a.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||this.subSurface.hasRenderTargetTextures()},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"_disableAlphaBlending",{get:function(){return this.subSurface.disableAlphaBlending||this._transparencyMode===t.PBRMATERIAL_OPAQUE||this._transparencyMode===t.PBRMATERIAL_ALPHATEST},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this.subSurface.disableAlphaBlending&&(this._hasAlphaChannel()&&(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._hasAlphaChannel=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha||null!=this._opacityTexture},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,t,i){if(t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new pa);var n=t._materialDefines;if(this._isReadyForSubMesh(t))return!0;var r=this.getScene(),o=r.getEngine();if(n._areTexturesDirty&&r.texturesEnabled){if(this._albedoTexture&&so.a.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&so.a.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&so.a.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var a=this._getReflectionTexture();if(a&&so.a.ReflectionTextureEnabled){if(!a.isReadyOrNotBlocking())return!1;if(a.irradianceTexture&&!a.irradianceTexture.isReadyOrNotBlocking())return!1}if(this._lightmapTexture&&so.a.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&so.a.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(so.a.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._metallicReflectanceTexture&&!this._metallicReflectanceTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(!(this.subSurface.isReadyForSubMesh(n,r)&&this.clearCoat.isReadyForSubMesh(n,r,o,this._disableBumpMap)&&this.sheen.isReadyForSubMesh(n,r)&&this.anisotropy.isReadyForSubMesh(n,r)&&this.detailMap.isReadyForSubMesh(n,r)))return!1;if(n._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;o.getCaps().standardDerivatives||e.isVerticesDataPresent(Qi.b.NormalKind)||(e.createNormals(!0),m.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var s=t.effect,c=n._areLightsDisposed,l=this._prepareEffect(e,n,this.onCompiled,this.onError,i,null,t.getRenderingMesh().hasThinInstances);if(l)if(this._onEffectCreatedObservable&&(fa.effect=l,fa.subMesh=t,this._onEffectCreatedObservable.notifyObservers(fa)),this.allowShaderHotSwapping&&s&&!l.isReady()){if(l=s,this._rebuildInParallel=!0,n.markAsUnprocessed(),c)return n._areLightsDisposed=!0,!1}else this._rebuildInParallel=!1,r.resetCachedMaterial(),t.setEffect(l,n),this.buildUniformLayout();return!(!t.effect||!t.effect.isReady())&&(n._renderId=r.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},t.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},t.prototype._prepareEffect=function(e,t,i,n,r,o,a){if(void 0===i&&(i=null),void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=null),this._prepareDefines(e,t,r,o,a),!t.isDirty)return null;t.markAsProcessed();var s=this.getScene().getEngine(),c=new po.a,l=0;t.USESPHERICALINVERTEX&&c.addFallback(l++,"USESPHERICALINVERTEX"),t.FOG&&c.addFallback(l,"FOG"),t.SPECULARAA&&c.addFallback(l,"SPECULARAA"),t.POINTSIZE&&c.addFallback(l,"POINTSIZE"),t.LOGARITHMICDEPTH&&c.addFallback(l,"LOGARITHMICDEPTH"),t.PARALLAX&&c.addFallback(l,"PARALLAX"),t.PARALLAXOCCLUSION&&c.addFallback(l++,"PARALLAXOCCLUSION"),l=So.AddFallbacks(t,c,l),l=So.AddFallbacks(t,c,l),l=Co.AddFallbacks(t,c,l),l=Po.AddFallbacks(t,c,l),t.ENVIRONMENTBRDF&&c.addFallback(l++,"ENVIRONMENTBRDF"),t.TANGENT&&c.addFallback(l++,"TANGENT"),t.BUMP&&c.addFallback(l++,"BUMP"),l=ro.a.HandleFallbacksForShadows(t,c,this._maxSimultaneousLights,l++),t.SPECULARTERM&&c.addFallback(l++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&c.addFallback(l++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&c.addFallback(l++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&c.addFallback(l++,"LIGHTMAP"),t.NORMAL&&c.addFallback(l++,"NORMAL"),t.AMBIENT&&c.addFallback(l++,"AMBIENT"),t.EMISSIVE&&c.addFallback(l++,"EMISSIVE"),t.VERTEXCOLOR&&c.addFallback(l++,"VERTEXCOLOR"),t.MORPHTARGETS&&c.addFallback(l++,"MORPHTARGETS"),t.MULTIVIEW&&c.addFallback(0,"MULTIVIEW");var u=[Qi.b.PositionKind];t.NORMAL&&u.push(Qi.b.NormalKind),t.TANGENT&&u.push(Qi.b.TangentKind),t.UV1&&u.push(Qi.b.UVKind),t.UV2&&u.push(Qi.b.UV2Kind),t.VERTEXCOLOR&&u.push(Qi.b.ColorKind),ro.a.PrepareAttributesForBones(u,e,t,c),ro.a.PrepareAttributesForInstances(u,t),ro.a.PrepareAttributesForMorphTargets(u,e,t);var h="pbr",d=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vMetallicReflectanceFactors","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vReflectionFilteringInfo","vMetallicReflectanceInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX_ZZ","vSphericalYY_ZZ","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vSphericalL00","vSphericalL1_1","vSphericalL10","vSphericalL11","vSphericalL2_2","vSphericalL2_1","vSphericalL20","vSphericalL21","vSphericalL22","vReflectionMicrosurfaceInfos","vTangentSpaceParams","boneTextureWidth","vDebugMode"],f=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler"],p=["Material","Scene"];da.a.AddUniforms(d),da.a.AddSamplers(f),Co.AddUniforms(d),Co.AddSamplers(f),Eo.AddUniforms(d),Eo.AddSamplers(f),So.AddUniforms(d),So.AddSamplers(f),Po.AddUniforms(d),Po.AddSamplers(f),Ro.a.AddUniforms(d),Ro.a.AddSamplers(d),ji.a&&(ji.a.PrepareUniforms(d,t),ji.a.PrepareSamplers(f,t)),ro.a.PrepareUniformsAndSamplersList({uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});var _={};this.customShaderNameResolve&&(h=this.customShaderNameResolve(h,d,p,f,t,u,_));var m=t.toString();return s.createEffect(h,{attributes:u,uniformsNames:d,uniformBuffersNames:p,samplers:f,defines:m,fallbacks:c,onCompiled:i,onError:n,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS},processFinalCode:_.processFinalCode,multiTarget:t.PREPASS},s)},t.prototype._prepareDefines=function(e,i,n,r,o){void 0===n&&(n=null),void 0===r&&(r=null),void 0===o&&(o=!1);var a=this.getScene(),s=a.getEngine();if(ro.a.PrepareDefinesForLights(a,e,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,ro.a.PrepareDefinesForMultiview(a,i),ro.a.PrepareDefinesForPrePass(a,i,this.canRenderToMRT),i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){if(i._needUVs=!1,a.texturesEnabled){a.getEngine().getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&so.a.DiffuseTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._albedoTexture,i,"ALBEDO"),i.GAMMAALBEDO=this._albedoTexture.gammaSpace):i.ALBEDO=!1,this._ambientTexture&&so.a.AmbientTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&so.a.OpacityTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;var c=this._getReflectionTexture();if(c&&so.a.ReflectionTextureEnabled){switch(i.REFLECTION=!0,i.GAMMAREFLECTION=c.gammaSpace,i.RGBDREFLECTION=c.isRGBD,i.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!c.invertZ:c.invertZ,i.LODINREFLECTIONALPHA=c.lodLevelInAlpha,i.LINEARSPECULARREFLECTION=c.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(i.NUM_SAMPLES=""+this.realTimeFilteringQuality,s.webGLVersion>1&&(i.NUM_SAMPLES=i.NUM_SAMPLES+"u"),i.REALTIME_FILTERING=!0):i.REALTIME_FILTERING=!1,c.coordinatesMode===Ke.a.INVCUBIC_MODE&&(i.INVERTCUBICMAP=!0),i.REFLECTIONMAP_3D=c.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,c.coordinatesMode){case Ke.a.EXPLICIT_MODE:i.REFLECTIONMAP_EXPLICIT=!0;break;case Ke.a.PLANAR_MODE:i.REFLECTIONMAP_PLANAR=!0;break;case Ke.a.PROJECTION_MODE:i.REFLECTIONMAP_PROJECTION=!0;break;case Ke.a.SKYBOX_MODE:i.REFLECTIONMAP_SKYBOX=!0;break;case Ke.a.SPHERICAL_MODE:i.REFLECTIONMAP_SPHERICAL=!0;break;case Ke.a.EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Ke.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Ke.a.CUBIC_MODE:case Ke.a.INVCUBIC_MODE:default:i.REFLECTIONMAP_CUBIC=!0,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!!c.boundingBoxSize}c.coordinatesMode!==Ke.a.SKYBOX_MODE&&(c.irradianceTexture?(i.USEIRRADIANCEMAP=!0,i.USESPHERICALFROMREFLECTIONMAP=!1):c.isCube&&(i.USESPHERICALFROMREFLECTIONMAP=!0,i.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||a.getEngine().getCaps().maxVaryingVectors<=8?i.USESPHERICALINVERTEX=!1:i.USESPHERICALINVERTEX=!0))}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_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.USEIRRADIANCEMAP=!1,i.USESPHERICALINVERTEX=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.LODINREFLECTIONALPHA=!1,i.GAMMAREFLECTION=!1,i.RGBDREFLECTION=!1,i.LINEARSPECULARREFLECTION=!1;this._lightmapTexture&&so.a.LightmapTextureEnabled?(ro.a.PrepareDefinesForMergedUV(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,i.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):i.LIGHTMAP=!1,this._emissiveTexture&&so.a.EmissiveTextureEnabled?ro.a.PrepareDefinesForMergedUV(this._emissiveTexture,i,"EMISSIVE"):i.EMISSIVE=!1,so.a.SpecularTextureEnabled?(this._metallicTexture?(ro.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?(ro.a.PrepareDefinesForMergedUV(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):i.REFLECTIVITY=!1,this._metallicReflectanceTexture?ro.a.PrepareDefinesForMergedUV(this._metallicReflectanceTexture,i,"METALLIC_REFLECTANCE"):i.METALLIC_REFLECTANCE=!1,this._microSurfaceTexture?ro.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),a.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&so.a.BumpTextureEnabled&&!this._disableBumpMap?(ro.a.PrepareDefinesForMergedUV(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&so.a.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):i.BUMP=!1,this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled?(i.ENVIRONMENTBRDF=!0,i.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(i.ENVIRONMENTBRDF=!1,i.ENVIRONMENTBRDF_RGBD=!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.SPECULARAA=a.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(i._areTexturesDirty||i._areMiscDirty)&&(i.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),i.PREMULTIPLYALPHA=this.alphaMode===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,i.ALPHABLEND=this.needAlphaBlendingForMesh(e),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),i._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(ro.a.PrepareDefinesForMisc(e,a,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,i),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(Qi.b.NormalKind),i.DEBUGMODE=this._debugMode),this.detailMap.prepareDefines(i,a),this.subSurface.prepareDefines(i,a),this.clearCoat.prepareDefines(i,a),this.anisotropy.prepareDefines(i,e,a),this.brdf.prepareDefines(i),this.sheen.prepareDefines(i,a),ro.a.PrepareDefinesForFrameBoundValues(a,s,i,!!n,r,o),ro.a.PrepareDefinesForAttributes(e,i,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,i){var n=this,r=Object(h.a)({clipPlane:!1,useInstances:!1},i),o=new pa,a=this._prepareEffect(e,o,void 0,void 0,r.useInstances,r.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(fa.effect=a,fa.subMesh=null,this._onEffectCreatedObservable.notifyObservers(fa)),a.isReady()?t&&t(this):a.onCompileObservable.add((function(){t&&t(n)}))},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionFilteringInfo",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("reflectionMatrix",16),e.addUniform("vReflectionColor",3),e.addUniform("vAlbedoColor",4),e.addUniform("vLightingIntensity",4),e.addUniform("vReflectionMicrosurfaceInfos",3),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),e.addUniform("vMetallicReflectanceFactors",4),e.addUniform("vMetallicReflectanceInfos",2),e.addUniform("metallicReflectanceMatrix",16),Eo.PrepareUniformBuffer(e),So.PrepareUniformBuffer(e),Po.PrepareUniformBuffer(e),Co.PrepareUniformBuffer(e),da.a.PrepareUniformBuffer(e),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this.subSurface.unbind(this._activeEffect)&&(t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),r=i._materialDefines;if(r){var o=i.effect;if(o){this._activeEffect=o,r.INSTANCES&&!r.THIN_INSTANCES||this.bindOnlyWorldMatrix(e),this.prePassConfiguration.bindForSubMesh(this._activeEffect,n,t,e,this.isFrozen),r.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var a=this._mustRebind(n,o,t.visibility);ro.a.BindBonesParameters(t,this._activeEffect,this.prePassConfiguration);var c=null,l=this._uniformBuffer;if(a){var u=n.getEngine();if(l.bindToEffect(o,"Material"),this.bindViewProjection(o),c=this._getReflectionTexture(),!l.useUbo||!this.isFrozen||!l.isSync){if(n.texturesEnabled){if(this._albedoTexture&&so.a.DiffuseTextureEnabled&&(l.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),ro.a.BindTextureMatrix(this._albedoTexture,l,"albedo")),this._ambientTexture&&so.a.AmbientTextureEnabled&&(l.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),ro.a.BindTextureMatrix(this._ambientTexture,l,"ambient")),this._opacityTexture&&so.a.OpacityTextureEnabled&&(l.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ro.a.BindTextureMatrix(this._opacityTexture,l,"opacity")),c&&so.a.ReflectionTextureEnabled){if(l.updateMatrix("reflectionMatrix",c.getReflectionTextureMatrix()),l.updateFloat2("vReflectionInfos",c.level,0),c.boundingBoxSize){var h=c;l.updateVector3("vReflectionPosition",h.boundingBoxPosition),l.updateVector3("vReflectionSize",h.boundingBoxSize)}if(this.realTimeFiltering){var d=c.getSize().width;l.updateFloat2("vReflectionFilteringInfo",d,L.a.Log2(d))}if(!r.USEIRRADIANCEMAP){var f=c.sphericalPolynomial;if(r.USESPHERICALFROMREFLECTIONMAP&&f)if(r.SPHERICAL_HARMONICS){var p=f.preScaledHarmonics;this._activeEffect.setVector3("vSphericalL00",p.l00),this._activeEffect.setVector3("vSphericalL1_1",p.l1_1),this._activeEffect.setVector3("vSphericalL10",p.l10),this._activeEffect.setVector3("vSphericalL11",p.l11),this._activeEffect.setVector3("vSphericalL2_2",p.l2_2),this._activeEffect.setVector3("vSphericalL2_1",p.l2_1),this._activeEffect.setVector3("vSphericalL20",p.l20),this._activeEffect.setVector3("vSphericalL21",p.l21),this._activeEffect.setVector3("vSphericalL22",p.l22)}else this._activeEffect.setFloat3("vSphericalX",f.x.x,f.x.y,f.x.z),this._activeEffect.setFloat3("vSphericalY",f.y.x,f.y.y,f.y.z),this._activeEffect.setFloat3("vSphericalZ",f.z.x,f.z.y,f.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",f.xx.x-f.zz.x,f.xx.y-f.zz.y,f.xx.z-f.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",f.yy.x-f.zz.x,f.yy.y-f.zz.y,f.yy.z-f.zz.z),this._activeEffect.setFloat3("vSphericalZZ",f.zz.x,f.zz.y,f.zz.z),this._activeEffect.setFloat3("vSphericalXY",f.xy.x,f.xy.y,f.xy.z),this._activeEffect.setFloat3("vSphericalYZ",f.yz.x,f.yz.y,f.yz.z),this._activeEffect.setFloat3("vSphericalZX",f.zx.x,f.zx.y,f.zx.z)}l.updateFloat3("vReflectionMicrosurfaceInfos",c.getSize().width,c.lodGenerationScale,c.lodGenerationOffset)}this._emissiveTexture&&so.a.EmissiveTextureEnabled&&(l.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ro.a.BindTextureMatrix(this._emissiveTexture,l,"emissive")),this._lightmapTexture&&so.a.LightmapTextureEnabled&&(l.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ro.a.BindTextureMatrix(this._lightmapTexture,l,"lightmap")),so.a.SpecularTextureEnabled&&(this._metallicTexture?(l.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),ro.a.BindTextureMatrix(this._metallicTexture,l,"reflectivity")):this._reflectivityTexture&&(l.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),ro.a.BindTextureMatrix(this._reflectivityTexture,l,"reflectivity")),this._metallicReflectanceTexture&&(l.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),ro.a.BindTextureMatrix(this._metallicReflectanceTexture,l,"metallicReflectance")),this._microSurfaceTexture&&(l.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),ro.a.BindTextureMatrix(this._microSurfaceTexture,l,"microSurfaceSampler"))),this._bumpTexture&&u.getCaps().standardDerivatives&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&(l.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),ro.a.BindTextureMatrix(this._bumpTexture,l,"bump"),n._mirroredCameraPosition?l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):l.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&l.updateFloat("pointSize",this.pointSize),r.METALLICWORKFLOW){s.c.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,s.c.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,l.updateColor4("vReflectivityColor",s.c.Color3[0],1);var _=this.subSurface.indexOfRefraction,m=Math.pow((_-1)/(_+1),2);this._metallicReflectanceColor.scaleToRef(m*this._metallicF0Factor,s.c.Color3[0]);var g=this._metallicF0Factor;l.updateColor4("vMetallicReflectanceFactors",s.c.Color3[0],g)}else l.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);l.updateColor3("vEmissiveColor",so.a.EmissiveTextureEnabled?this._emissiveColor:s.a.BlackReadOnly),l.updateColor3("vReflectionColor",this._reflectionColor),!r.SS_REFRACTION&&this.subSurface.linkRefractionWithTransparency?l.updateColor4("vAlbedoColor",this._albedoColor,1):l.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*n.environmentIntensity,this._lightingInfos.w=this._specularIntensity,l.updateVector4("vLightingIntensity",this._lightingInfos)}l.updateFloat("visibility",t.visibility),n.texturesEnabled&&(this._albedoTexture&&so.a.DiffuseTextureEnabled&&l.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&so.a.AmbientTextureEnabled&&l.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&so.a.OpacityTextureEnabled&&l.setTexture("opacitySampler",this._opacityTexture),c&&so.a.ReflectionTextureEnabled&&(r.LODBASEDMICROSFURACE?l.setTexture("reflectionSampler",c):(l.setTexture("reflectionSampler",c._lodTextureMid||c),l.setTexture("reflectionSamplerLow",c._lodTextureLow||c),l.setTexture("reflectionSamplerHigh",c._lodTextureHigh||c)),r.USEIRRADIANCEMAP&&l.setTexture("irradianceSampler",c.irradianceTexture)),r.ENVIRONMENTBRDF&&l.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&so.a.EmissiveTextureEnabled&&l.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&so.a.LightmapTextureEnabled&&l.setTexture("lightmapSampler",this._lightmapTexture),so.a.SpecularTextureEnabled&&(this._metallicTexture?l.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&l.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&l.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._microSurfaceTexture&&l.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&u.getCaps().standardDerivatives&&so.a.BumpTextureEnabled&&!this._disableBumpMap&&l.setTexture("bumpSampler",this._bumpTexture)),this.detailMap.bindForSubMesh(l,n,this.isFrozen),this.subSurface.bindForSubMesh(l,n,u,this.isFrozen,r.LODBASEDMICROSFURACE,this.realTimeFiltering),this.clearCoat.bindForSubMesh(l,n,u,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY,i),this.anisotropy.bindForSubMesh(l,n,this.isFrozen),this.sheen.bindForSubMesh(l,n,this.isFrozen,i),ro.a.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var v=n._forcedViewPosition?n._forcedViewPosition:n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition,b=n.useRightHandedSystem===(null!=n._mirroredCameraPosition);o.setFloat4("vEyePosition",v.x,v.y,v.z,b?-1:1),o.setColor3("vAmbientColor",this._globalAmbientColor),o.setFloat2("vDebugMode",this.debugLimit,this.debugFactor)}!a&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&ro.a.BindLights(n,t,this._activeEffect,r,this._maxSimultaneousLights,this._rebuildInParallel),(n.fogEnabled&&t.applyFog&&n.fogMode!==Q.a.FOGMODE_NONE||c)&&this.bindView(o),ro.a.BindFogParameters(n,t,this._activeEffect,!0),r.NUM_MORPH_INFLUENCERS&&ro.a.BindMorphTargetParameters(t,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),ro.a.BindLogDepth(r,this._activeEffect,n)),l.update(),this._afterBind(t,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.detailMap.getAnimatables(e),this.subSurface.getAnimatables(e),this.clearCoat.getAnimatables(e),this.sheen.getAnimatables(e),this.anisotropy.getAnimatables(e),e},t.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},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._metallicReflectanceTexture&&t.push(this._metallicReflectanceTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this.detailMap.getActiveTextures(t),this.subSurface.getActiveTextures(t),this.clearCoat.getActiveTextures(t),this.sheen.getActiveTextures(t),this.anisotropy.getActiveTextures(t),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._metallicReflectanceTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this.detailMap.hasTexture(t)||this.subSurface.hasTexture(t)||this.clearCoat.hasTexture(t)||this.sheen.hasTexture(t)||this.anisotropy.hasTexture(t))))))))))))},t.prototype.setPrePassRenderer=function(e){if(this.subSurface.isScatteringEnabled){var t=this.getScene().enableSubSurfaceForPrePass();return t&&(t.enabled=!0),!0}return!1},t.prototype.dispose=function(t,i){var n,r,o,a,s,c,l,u,h,d,f;i&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),null===(n=this._albedoTexture)||void 0===n||n.dispose(),null===(r=this._ambientTexture)||void 0===r||r.dispose(),null===(o=this._opacityTexture)||void 0===o||o.dispose(),null===(a=this._reflectionTexture)||void 0===a||a.dispose(),null===(s=this._emissiveTexture)||void 0===s||s.dispose(),null===(c=this._metallicTexture)||void 0===c||c.dispose(),null===(l=this._reflectivityTexture)||void 0===l||l.dispose(),null===(u=this._bumpTexture)||void 0===u||u.dispose(),null===(h=this._lightmapTexture)||void 0===h||h.dispose(),null===(d=this._metallicReflectanceTexture)||void 0===d||d.dispose(),null===(f=this._microSurfaceTexture)||void 0===f||f.dispose()),this.detailMap.dispose(i),this.subSurface.dispose(i),this.clearCoat.dispose(i),this.sheen.dispose(i),this.anisotropy.dispose(i),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,i)},t.PBRMATERIAL_OPAQUE=xo.a.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=xo.a.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=xo.a.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=xo.a.MATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,Object(h.c)([Object(w.i)()],t.prototype,"_imageProcessingConfiguration",void 0),Object(h.c)([Object(w.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),Object(h.c)([Object(w.c)()],t.prototype,"useLogarithmicDepth",null),t}(ao.a),ma=function(e){function t(i,n){var r=e.call(this,i,n)||this;return r.directIntensity=1,r.emissiveIntensity=1,r.environmentIntensity=1,r.specularIntensity=1,r.disableBumpMap=!1,r.ambientTextureStrength=1,r.ambientTextureImpactOnAnalyticalLights=t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,r.metallicF0Factor=1,r.metallicReflectanceColor=s.a.White(),r.ambientColor=new s.a(0,0,0),r.albedoColor=new s.a(1,1,1),r.reflectivityColor=new s.a(1,1,1),r.reflectionColor=new s.a(1,1,1),r.emissiveColor=new s.a(0,0,0),r.microSurface=1,r.useLightmapAsShadowmap=!1,r.useAlphaFromAlbedoTexture=!1,r.forceAlphaTest=!1,r.alphaCutOff=.4,r.useSpecularOverAlpha=!0,r.useMicroSurfaceFromReflectivityMapAlpha=!1,r.useRoughnessFromMetallicTextureAlpha=!0,r.useRoughnessFromMetallicTextureGreen=!1,r.useMetallnessFromMetallicTextureBlue=!1,r.useAmbientOcclusionFromMetallicTextureRed=!1,r.useAmbientInGrayScale=!1,r.useAutoMicroSurfaceFromReflectivityMap=!1,r.useRadianceOverAlpha=!0,r.useObjectSpaceNormalMap=!1,r.useParallax=!1,r.useParallaxOcclusion=!1,r.parallaxScaleBias=.05,r.disableLighting=!1,r.forceIrradianceInFragment=!1,r.maxSimultaneousLights=4,r.invertNormalMapX=!1,r.invertNormalMapY=!1,r.twoSidedLighting=!1,r.useAlphaFresnel=!1,r.useLinearAlphaFresnel=!1,r.environmentBRDFTexture=null,r.forceNormalForward=!1,r.enableSpecularAntiAliasing=!1,r.useHorizonOcclusion=!0,r.useRadianceOcclusion=!0,r.unlit=!1,r._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(n),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"refractionTexture",{get:function(){return this.subSurface.refractionTexture},set:function(e){this.subSurface.refractionTexture=e,e?this.subSurface.isRefractionEnabled=!0:this.subSurface.linkRefractionWithTransparency||(this.subSurface.isRefractionEnabled=!1)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"invertRefractionY",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"linkRefractionWithTransparency",{get:function(){return this.subSurface.linkRefractionWithTransparency},set:function(e){this.subSurface.linkRefractionWithTransparency=e,e&&(this.subSurface.isRefractionEnabled=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===_a.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_a.LIGHTFALLOFF_PHYSICAL:_a.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===_a.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?_a.LIGHTFALLOFF_GLTF:_a.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.clone=function(e){var i=this,n=w.a.Clone((function(){return new t(e,i.getScene())}),this);return n.id=e,n.name=e,this.clearCoat.copyTo(n.clearCoat),this.anisotropy.copyTo(n.anisotropy),this.brdf.copyTo(n.brdf),this.sheen.copyTo(n.sheen),this.subSurface.copyTo(n.subSurface),n},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.PBRMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,i,n){var r=w.a.Parse((function(){return new t(e.name,i)}),e,i,n);return e.clearCoat&&r.clearCoat.parse(e.clearCoat,i,n),e.anisotropy&&r.anisotropy.parse(e.anisotropy,i,n),e.brdf&&r.brdf.parse(e.brdf,i,n),e.sheen&&r.sheen.parse(e.sheen,i,n),e.subSurface&&r.subSurface.parse(e.subSurface,i,n),r},t.PBRMATERIAL_OPAQUE=_a.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=_a.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=_a.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=_a.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=_a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),Object(h.c)([Object(w.e)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceColor",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(h.c)([Object(w.e)("ambient"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),Object(h.c)([Object(w.e)("albedo"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),Object(h.c)([Object(w.e)("reflectivity"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),Object(h.c)([Object(w.e)("reflection"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),Object(h.c)([Object(w.e)("emissive"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),Object(h.c)([Object(w.c)()],t.prototype,"usePhysicalLightFalloff",null),Object(h.c)([Object(w.c)()],t.prototype,"useGLTFLightFalloff",null),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(_a);c.a.RegisteredTypes["BABYLON.PBRMaterial"]=ma;function ga(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var va=ga("DXT1"),ba=ga("DXT3"),ya=ga("DXT5"),Ta=ga("DX10"),Ea=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e.buffer,e.byteOffset,31),i=new Int32Array(e.buffer,e.byteOffset,35),n=1;131072&t[2]&&(n=Math.max(1,t[7]));var r=t[21],o=r===Ta?i[32]:0,a=g.a.TEXTURETYPE_UNSIGNED_INT;switch(r){case 113:a=g.a.TEXTURETYPE_HALF_FLOAT;break;case 116:a=g.a.TEXTURETYPE_FLOAT;break;case Ta:if(10===o){a=g.a.TEXTURETYPE_HALF_FLOAT;break}if(2===o){a=g.a.TEXTURETYPE_FLOAT;break}}return{width:t[4],height:t[3],mipmapCount:n,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:r===va||r===ba||r===ya,dxgiFormat:o,textureType:a}},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],n=i>>16&32768,r=i>>12&2047,o=i>>23&255;return o<103?n:o>142?(n|=31744,n|=(255==o?0:1)&&8388607&i):o<113?n|=((r|=2048)>>114-o)+(r>>113-o&1):(n|=o-112<<10|r>>1,n+=1&r)},e._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,n=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(n/Math.pow(2,10)):31==i?n?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+n/Math.pow(2,10))},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,i,n,r,o,a){for(var s=new Float32Array(r),c=new Uint16Array(o,n),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);s[l]=e._FromHalfFloat(c[d]),s[l+1]=e._FromHalfFloat(c[d+1]),s[l+2]=e._FromHalfFloat(c[d+2]),e.StoreLODInAlphaChannel?s[l+3]=a:s[l+3]=e._FromHalfFloat(c[d+3]),l+=4}return s},e._GetHalfFloatRGBAArrayBuffer=function(t,i,n,r,o,a){if(e.StoreLODInAlphaChannel){for(var s=new Uint16Array(r),c=new Uint16Array(o,n),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);s[l]=c[d],s[l+1]=c[d+1],s[l+2]=c[d+2],s[l+3]=e._ToHalfFloat(a),l+=4}return s}return new Uint16Array(o,n,r)},e._GetFloatRGBAArrayBuffer=function(t,i,n,r,o,a){if(e.StoreLODInAlphaChannel){for(var s=new Float32Array(r),c=new Float32Array(o,n),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);s[l]=c[d],s[l+1]=c[d+1],s[l+2]=c[d+2],s[l+3]=a,l+=4}return s}return new Float32Array(o,n,r)},e._GetFloatAsUIntRGBAArrayBuffer=function(t,i,n,r,o,a){for(var s=new Uint8Array(r),c=new Float32Array(o,n),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);s[l]=255*L.a.Clamp(c[d]),s[l+1]=255*L.a.Clamp(c[d+1]),s[l+2]=255*L.a.Clamp(c[d+2]),e.StoreLODInAlphaChannel?s[l+3]=a:s[l+3]=255*L.a.Clamp(c[d+3]),l+=4}return s},e._GetHalfFloatAsUIntRGBAArrayBuffer=function(t,i,n,r,o,a){for(var s=new Uint8Array(r),c=new Uint16Array(o,n),l=0,u=0;u<i;u++)for(var h=0;h<t;h++){var d=4*(h+u*t);s[l]=255*L.a.Clamp(e._FromHalfFloat(c[d])),s[l+1]=255*L.a.Clamp(e._FromHalfFloat(c[d+1])),s[l+2]=255*L.a.Clamp(e._FromHalfFloat(c[d+2])),e.StoreLODInAlphaChannel?s[l+3]=a:s[l+3]=255*L.a.Clamp(e._FromHalfFloat(c[d+3])),l+=4}return s},e._GetRGBAArrayBuffer=function(e,t,i,n,r,o,a,s,c){for(var l=new Uint8Array(n),u=new Uint8Array(r,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+a],l[h+2]=u[p+s],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,n,r,o,a,s){for(var c=new Uint8Array(n),l=new Uint8Array(r,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+a],c[u+2]=l[f+s],u+=3}return c},e._GetLuminanceArrayBuffer=function(e,t,i,n,r){for(var o=new Uint8Array(n),a=new Uint8Array(r,i),s=0,c=0;c<t;c++)for(var l=0;l<e;l++){var u=l+c*e;o[s]=a[u],s++}return o},e.UploadDDSLevels=function(t,i,n,r,o,a,s,c){void 0===s&&(s=-1);var l=null;r.sphericalPolynomial&&(l=new Array);var u,h,d,f,p,_,v,b=t.getCaps().s3tc,y=new Int32Array(n.buffer,n.byteOffset,31),T=0,E=0,S=1;if(542327876===y[0])if(r.isFourCC||r.isRGB||r.isLuminance)if(!r.isCompressed||b){var A=y[22];f=y[1]+4;var P,C=!1;if(r.isFourCC)switch(u=y[21]){case va:S=8,E=b.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case ba:S=16,E=b.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case ya:S=16,E=b.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case 113:case 116:C=!0;break;case Ta:f+=20;var R=!1;switch(r.dxgiFormat){case 10:case 2:C=!0,R=!0;break;case 88:r.isRGB=!0,r.isFourCC=!1,A=32,R=!0}if(R)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 x=e._ExtractLongWordOrder(y[23]),O=e._ExtractLongWordOrder(y[24]),M=e._ExtractLongWordOrder(y[25]),I=e._ExtractLongWordOrder(y[26]);C&&(E=t._getRGBABufferInternalSizedFormat(r.textureType)),_=1,131072&y[2]&&!1!==o&&(_=Math.max(1,y[7]));for(var D=c||0;D<a;D++){for(h=y[4],d=y[3],v=0;v<_;++v){if(-1===s||s===v){var N=-1===s?v:0;if(!r.isCompressed&&r.isFourCC){i.format=g.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,n.byteOffset+f,T,n.buffer,N),l&&0==N&&l.push(e._GetFloatRGBAArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,N))):64===A&&(L=e._GetHalfFloatAsUIntRGBAArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,N),l&&0==N&&l.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,N))),i.type=g.a.TEXTURETYPE_UNSIGNED_INT):128===A?(i.type=g.a.TEXTURETYPE_FLOAT,L=e._GetFloatRGBAArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,N),l&&0==N&&l.push(L)):64!==A||t.getCaps().textureHalfFloat?(i.type=g.a.TEXTURETYPE_HALF_FLOAT,L=e._GetHalfFloatRGBAArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,N),l&&0==N&&l.push(e._GetHalfFloatAsFloatRGBAArrayBuffer(h,d,f,T,n.buffer,N))):(i.type=g.a.TEXTURETYPE_FLOAT,L=e._GetHalfFloatAsFloatRGBAArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,N),l&&0==N&&l.push(L)),L&&t._uploadDataToTextureDirectly(i,L,D,N)}else if(r.isRGB)i.type=g.a.TEXTURETYPE_UNSIGNED_INT,24===A?(i.format=g.a.TEXTUREFORMAT_RGB,T=h*d*3,p=e._GetRGBArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,x,O,M),t._uploadDataToTextureDirectly(i,p,D,N)):(i.format=g.a.TEXTUREFORMAT_RGBA,T=h*d*4,p=e._GetRGBAArrayBuffer(h,d,n.byteOffset+f,T,n.buffer,x,O,M,I),t._uploadDataToTextureDirectly(i,p,D,N));else if(r.isLuminance){var w=t._getUnpackAlignement(),F=h;T=Math.floor((h+w-1)/w)*w*(d-1)+F,p=e._GetLuminanceArrayBuffer(h,d,n.byteOffset+f,T,n.buffer),i.format=g.a.TEXTUREFORMAT_LUMINANCE,i.type=g.a.TEXTURETYPE_UNSIGNED_INT,t._uploadDataToTextureDirectly(i,p,D,N)}else T=Math.max(4,h)/4*Math.max(4,d)/4*S,p=new Uint8Array(n.buffer,n.byteOffset+f,T),i.type=g.a.TEXTURETYPE_UNSIGNED_INT,t._uploadCompressedDataToTextureDirectly(i,E,h,d,p,D,N)}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?r.sphericalPolynomial=$n.ConvertCubeMapToSphericalPolynomial({size:y[4],right:l[0],left:l[1],up:l[2],down:l[3],front:l[4],back:l[5],format:g.a.TEXTUREFORMAT_RGBA,type:g.a.TEXTURETYPE_FLOAT,gammaSpace:!1}):r.sphericalPolynomial=void 0}else m.a.Error("Compressed textures are not supported on this platform.");else m.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else m.a.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();qe.a.prototype.createPrefilteredCubeTexture=function(e,t,i,n,r,o,a,s,c){var l=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=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 qn,o._source=Qe.b.CubePrefiltered,l.getCaps().textureLOD)r&&r(o);else{var a=l._gl,s=e.width;if(s){for(var u=[],h=0;h<3;h++){var d=1-h/2,f=n,p=L.a.Log2(s)*i+n,_=f+(p-f)*d,v=Math.round(Math.min(Math.max(_,0),p)),b=new Qe.a(l,Qe.b.Temp);if(b.type=o.type,b.format=o.format,b.width=Math.pow(2,Math.max(L.a.Log2(s)-v,0)),b.height=b.width,b.isCube=!0,l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,b,!0),b.samplingMode=g.a.TEXTURE_LINEAR_LINEAR,a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),e.isDDS){var y=e.info,T=e.data;l._unpackFlipY(y.isCompressed),Ea.UploadDDSLevels(l,b,T,y,!0,6,v)}else m.a.Warn("DDS is the only prefiltered cube map supported so far.");l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var E=new Zn.a(t);E.isCube=!0,E._texture=b,b.isReady=!0,u.push(E)}o._lodTextureHigh=u[2],o._lodTextureMid=u[1],o._lodTextureLow=u[0],r&&r(o)}}}else r&&r(null)}),o,a,s,c,i,n)};var Sa=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,".dds")},e.prototype.loadCubeData=function(e,t,i,n,r){var o,a=t.getEngine(),s=!1;if(Array.isArray(e))for(var c=0;c<e.length;c++){var l=e[c];o=Ea.GetDDSInfo(l),t.width=o.width,t.height=o.height,s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Ea.UploadDDSLevels(a,t,l,o,s,6,-1,c),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t)}else{var u=e;o=Ea.GetDDSInfo(u),t.width=o.width,t.height=o.height,i&&(o.sphericalPolynomial=new qn),s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),Ea.UploadDDSLevels(a,t,u,o,s,6),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(t,s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,i){var n=Ea.GetDDSInfo(e),r=(n.isRGB||n.isLuminance||n.mipmapCount>1)&&t.generateMipMaps&&n.width>>n.mipmapCount-1==1;i(n.width,n.height,r,n.isFourCC,(function(){Ea.UploadDDSLevels(t.getEngine(),t,e,n,r,1)}))},e}();Se.a._TextureLoaders.push(new Sa);var Aa=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,".env")},e.prototype.loadCubeData=function(e,t,i,n,r){if(!Array.isArray(e)){var o=ir.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,ir.UploadEnvSpherical(t,o),ir.UploadEnvLevelsAsync(t,e,o).then((function(){t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()}))):r&&r("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,i){throw".env not supported in 2d."},e}();Se.a._TextureLoaders.push(new Aa);var Pa=function(){function e(t,i,n,r){if(this.data=t,this.isInvalid=!1,!e.IsValid(t))return this.isInvalid=!0,void m.a.Error("texture missing KTX identifier");var o=Uint32Array.BYTES_PER_ELEMENT,a=new DataView(this.data.buffer,this.data.byteOffset+12,13*o),s=67305985===a.getUint32(0,!0);this.glType=a.getUint32(1*o,s),this.glTypeSize=a.getUint32(2*o,s),this.glFormat=a.getUint32(3*o,s),this.glInternalFormat=a.getUint32(4*o,s),this.glBaseInternalFormat=a.getUint32(5*o,s),this.pixelWidth=a.getUint32(6*o,s),this.pixelHeight=a.getUint32(7*o,s),this.pixelDepth=a.getUint32(8*o,s),this.numberOfArrayElements=a.getUint32(9*o,s),this.numberOfFaces=a.getUint32(10*o,s),this.numberOfMipmapLevels=a.getUint32(11*o,s),this.bytesOfKeyValueData=a.getUint32(12*o,s),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:m.a.Error("number of faces expected"+i+", but found "+this.numberOfFaces):m.a.Error("texture arrays not currently supported"):m.a.Error("only 2D textures currently supported")):m.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 n=e.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,o=this.pixelHeight,a=i?this.numberOfMipmapLevels:1,s=0;s<a;s++){var c=new Int32Array(this.data.buffer,this.data.byteOffset+n,1)[0];n+=4;for(var l=0;l<this.numberOfFaces;l++){var u=new Uint8Array(this.data.buffer,this.data.byteOffset+n,c);t.getEngine()._uploadCompressedDataToTextureDirectly(t,this.glInternalFormat,r,o,u,l,s),n+=c,n+=3-(c+3)%4}r=Math.max(1,.5*r),o=Math.max(1,.5*o)}},e.IsValid=function(e){if(e.byteLength>=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&49===t[5]&&49===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.HEADER_LEN=64,e.COMPRESSED_2D=0,e.COMPRESSED_3D=1,e.TEX_2D=2,e.TEX_3D=3,e}(),Ca=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()}this._workerInfos=[],this._pendingActions=[]},e.prototype.push=function(e){for(var t=0,i=this._workerInfos;t<i.length;t++){var n=i[t];if(!n.active)return void this._execute(n,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}(),Ra=function(){function e(t,i){void 0===i&&(i=e.DefaultNumWorkers),this._engine=t,e._Initialized||e._CreateWorkerPool(i)}return e.GetDefaultNumWorkers=function(){return"object"==typeof navigator&&navigator.hardwareConcurrency?Math.min(Math.floor(.5*navigator.hardwareConcurrency),4):1},e._CreateWorkerPool=function(t){this._Initialized=!0,t&&"function"==typeof Worker?e._WorkerPoolPromise=new Promise((function(i){for(var n="("+xa+")()",r=URL.createObjectURL(new Blob([n],{type:"application/javascript"})),o=new Array(t),a=0;a<o.length;a++)o[a]=new Promise((function(t,i){var n=new Worker(r),o=function(e){n.removeEventListener("error",o),n.removeEventListener("message",a),i(e)},a=function(e){"init"===e.data.action&&(n.removeEventListener("error",o),n.removeEventListener("message",a),t(n))};n.addEventListener("error",o),n.addEventListener("message",a),n.postMessage({action:"init",urls:e.URLConfig})}));Promise.all(o).then((function(e){i(new Ca(e))}))})):(KTX2DECODER.MSCTranscoder.UseFromWorkerThread=!1,KTX2DECODER.WASMMemoryManager.LoadBinariesFromCurrentThread=!0)},e.prototype.uploadAsync=function(t,i,n){var r=this,o=this._engine.getCaps(),a={astc:!!o.astc,bptc:!!o.bptc,s3tc:!!o.s3tc,pvrtc:!!o.pvrtc,etc2:!!o.etc2,etc1:!!o.etc1};return e._WorkerPoolPromise?e._WorkerPoolPromise.then((function(e){return new Promise((function(o,s){e.push((function(e,c){var l=function(t){e.removeEventListener("error",l),e.removeEventListener("message",u),s(t),c()},u=function(t){if("decoded"===t.data.action){if(e.removeEventListener("error",l),e.removeEventListener("message",u),t.data.success)try{r._createTexture(t.data.decodedData,i,n),o()}catch(e){s({message:e})}else s({message:t.data.msg});c()}};e.addEventListener("error",l),e.addEventListener("message",u),e.postMessage({action:"decode",data:t,caps:a,options:n})}))}))})):new Promise((function(n,a){e._Ktx2Decoder||(e._Ktx2Decoder=new KTX2DECODER.KTX2Decoder),e._Ktx2Decoder.decode(t,o).then((function(e){r._createTexture(e,i),n()})).catch((function(e){a({message:e})}))}))},e.prototype.dispose=function(){e._WorkerPoolPromise&&e._WorkerPoolPromise.then((function(e){e.dispose()})),delete e._WorkerPoolPromise},e.prototype._createTexture=function(e,t,i){if(this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D,t),i&&(i.transcodedFormat=e.transcodedFormat,i.isInGammaSpace=e.isInGammaSpace,i.transcoderName=e.transcoderName),32856===e.transcodedFormat?(t.type=g.a.TEXTURETYPE_UNSIGNED_BYTE,t.format=g.a.TEXTUREFORMAT_RGBA):t.format=e.transcodedFormat,t._gammaSpace=e.isInGammaSpace,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(var n=0;n<e.mipmaps.length;++n){var r=e.mipmaps[n];if(!r||!r.data)throw new Error("KTX2 container - could not transcode one of the image");32856===e.transcodedFormat?(t.width=r.width,t.height=r.height,this._engine._uploadDataToTextureDirectly(t,r.data,0,n,void 0,!0)):this._engine._uploadCompressedDataToTextureDirectly(t,e.transcodedFormat,r.width,r.height,r.data,0,n)}t.width=e.mipmaps[0].width,t.height=e.mipmaps[0].height,t.generateMipMaps=e.mipmaps.length>1,t.isReady=!0,this._engine._bindTextureDirectly(this._engine._gl.TEXTURE_2D,null)},e.IsValid=function(e){if(e.byteLength>=12){var t=new Uint8Array(e.buffer,e.byteOffset,12);if(171===t[0]&&75===t[1]&&84===t[2]&&88===t[3]&&32===t[4]&&50===t[5]&&48===t[6]&&187===t[7]&&13===t[8]&&10===t[9]&&26===t[10]&&10===t[11])return!0}return!1},e.URLConfig={jsDecoderModule:"https://preview.babylonjs.com/babylon.ktx2Decoder.js",wasmUASTCToASTC:null,wasmUASTCToBC7:null,wasmUASTCToRGBA_UNORM:null,wasmUASTCToRGBA_SRGB:null,jsMSCTranscoder:null,wasmMSCTranscoder:null},e.DefaultNumWorkers=e.GetDefaultNumWorkers(),e}();function xa(){var e;onmessage=function(t){switch(t.data.action){case"init":var i=t.data.urls;importScripts(i.jsDecoderModule),null!==i.wasmUASTCToASTC&&(KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL=i.wasmUASTCToASTC),null!==i.wasmUASTCToBC7&&(KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL=i.wasmUASTCToBC7),null!==i.wasmUASTCToRGBA_UNORM&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=i.wasmUASTCToRGBA_UNORM),null!==i.wasmUASTCToRGBA_SRGB&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=i.wasmUASTCToRGBA_SRGB),null!==i.jsMSCTranscoder&&(KTX2DECODER.MSCTranscoder.JSModuleURL=i.jsMSCTranscoder),null!==i.wasmMSCTranscoder&&(KTX2DECODER.MSCTranscoder.WasmModuleURL=i.wasmMSCTranscoder),e=new KTX2DECODER.KTX2Decoder,postMessage({action:"init"});break;case"decode":e.decode(t.data.data,t.data.caps,t.data.options).then((function(e){for(var t=[],i=0;i<e.mipmaps.length;++i){var n=e.mipmaps[i];n&&n.data&&t.push(n.data.buffer)}postMessage({action:"decoded",success:!0,decodedData:e},t)})).catch((function(e){postMessage({action:"decoded",success:!1,msg:e})}))}}}var Oa=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t){return io.a.EndsWith(e,".ktx")||io.a.EndsWith(e,".ktx2")||"image/ktx"===t||"image/ktx2"===t},e.prototype.loadCubeData=function(e,t,i,n,r){if(!Array.isArray(e)){t._invertVScale=!t.invertY;var o=t.getEngine(),a=new Pa(e,6),s=a.numberOfMipmapLevels>1&&t.generateMipMaps;o._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,o._setCubeMapTextureParams(t,s),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()}},e.prototype.loadData=function(e,t,i,n){if(Pa.IsValid(e)){t._invertVScale=!t.invertY;var r=new Pa(e,1);i(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,(function(){r.uploadLevels(t,t.generateMipMaps)}),r.isInvalid)}else if(Ra.IsValid(e)){new Ra(t.getEngine()).uploadAsync(e,t,n).then((function(){i(t.width,t.height,t.generateMipMaps,!0,(function(){}),!1)}),(function(e){m.a.Warn("Failed to load KTX2 texture data: "+e.message),i(0,0,!1,!1,(function(){}),!0)}))}else m.a.Error("texture missing KTX identifier"),i(0,0,!1,!1,(function(){}),!0)},e}();Se.a._TextureLoaders.unshift(new Oa);var Ma=function(e){function t(t,i,n){var r=e.call(this,t,a.e.Zero(),i)||this;return r._xrSessionManager=n,r._firstFrame=!1,r._referenceQuaternion=a.b.Identity(),r._referencedPosition=new a.e,r._xrInvPositionCache=new a.e,r._xrInvQuaternionCache=a.b.Identity(),r._trackingState=en.NOT_TRACKING,r.onBeforeCameraTeleport=new o.c,r.onAfterCameraTeleport=new o.c,r.onTrackingStateChanged=new o.c,r.compensateOnFirstFrame=!0,r._rotate180=new a.b(0,1,0,0),r.minZ=.1,r.rotationQuaternion=new a.b,r.cameraRigMode=je.a.RIG_MODE_CUSTOM,r.updateUpVectorFromRotation=!0,r._updateNumberOfRigCameras(1),r.freezeProjectionMatrix(),r._xrSessionManager.onXRSessionInit.add((function(){r._referencedPosition.copyFromFloats(0,0,0),r._referenceQuaternion.copyFromFloats(0,0,0,1),r._firstFrame=r.compensateOnFirstFrame})),r._xrSessionManager.onXRFrameObservable.add((function(e){r._firstFrame&&r._updateFromXRSession(),r._updateReferenceSpace(),r._updateFromXRSession()}),void 0,!0),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"trackingState",{get:function(){return this._trackingState},enumerable:!1,configurable:!0}),t.prototype._setTrackingState=function(e){this._trackingState!==e&&(this._trackingState=e,this.onTrackingStateChanged.notifyObservers(e))},Object.defineProperty(t.prototype,"realWorldHeight",{get:function(){var e=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.baseReferenceSpace);return e&&e.transform?e.transform.position.y:0},enumerable:!1,configurable:!0}),t.prototype._updateForDualEyeDebugging=function(){this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new yi.a(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new yi.a(.5,0,.5,1),this.rigCameras[1].outputRenderTarget=null},t.prototype.setTransformationFromNonVRCamera=function(e,t){(void 0===e&&(e=this.getScene().activeCamera),void 0===t&&(t=!0),e&&e!==this)&&(e.computeWorldMatrix().decompose(void 0,this.rotationQuaternion,this.position),this.position.y=0,a.b.FromEulerAnglesToRef(0,this.rotationQuaternion.toEulerAngles().y,0,this.rotationQuaternion),this._firstFrame=!0,t&&this._xrSessionManager.resetReferenceSpace())},t.prototype.getClassName=function(){return"WebXRCamera"},t.prototype._updateFromXRSession=function(){var e=this,t=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);if(t){var i=t.emulatedPosition?en.TRACKING_LOST:en.TRACKING;if(this._setTrackingState(i),t.transform){var n=t.transform.position;this._referencedPosition.set(n.x,n.y,n.z);var r=t.transform.orientation;this._referenceQuaternion.set(r.x,r.y,r.z,r.w),this._scene.useRightHandedSystem||(this._referencedPosition.z*=-1,this._referenceQuaternion.z*=-1,this._referenceQuaternion.w*=-1),this._firstFrame?(this._firstFrame=!1,this.position.y+=this._referencedPosition.y,this._referenceQuaternion.copyFromFloats(0,0,0,1)):(this.rotationQuaternion.copyFrom(this._referenceQuaternion),this.position.copyFrom(this._referencedPosition))}this.rigCameras.length!==t.views.length&&this._updateNumberOfRigCameras(t.views.length),t.views.forEach((function(t,i){var n=e.rigCameras[i];n.isLeftCamera||n.isRightCamera||("right"===t.eye?n._isRightCamera=!0:"left"===t.eye&&(n._isLeftCamera=!0));var r=t.transform.position,o=t.transform.orientation;if(n.position.set(r.x,r.y,r.z),n.rotationQuaternion.set(o.x,o.y,o.z,o.w),e._scene.useRightHandedSystem?n.rotationQuaternion.multiplyInPlace(e._rotate180):(n.position.z*=-1,n.rotationQuaternion.z*=-1,n.rotationQuaternion.w*=-1),a.a.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,n._projectionMatrix),e._scene.useRightHandedSystem||n._projectionMatrix.toggleProjectionMatrixHandInPlace(),0===i&&e._projectionMatrix.copyFrom(n._projectionMatrix),e._xrSessionManager.session.renderState.baseLayer){var s=e._xrSessionManager.session.renderState.baseLayer.getViewport(t),c=e._xrSessionManager.session.renderState.baseLayer.framebufferWidth,l=e._xrSessionManager.session.renderState.baseLayer.framebufferHeight;n.viewport.width=s.width/c,n.viewport.height=s.height/l,n.viewport.x=s.x/c,n.viewport.y=s.y/l}n.outputRenderTarget=e._xrSessionManager.getRenderTargetTextureForEye(t.eye)}))}else this._setTrackingState(en.NOT_TRACKING)},t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.length<e;){var t=new Lt("XR-RigCamera: "+this.rigCameras.length,a.e.Zero(),this.getScene());t.minZ=.1,t.rotationQuaternion=new a.b,t.updateUpVectorFromRotation=!0,t.isRigCamera=!0,t.rigParent=this,t.freezeProjectionMatrix(),this.rigCameras.push(t)}for(;this.rigCameras.length>e;){var i=this.rigCameras.pop();i&&i.dispose()}},t.prototype._updateReferenceSpace=function(){this.position.equals(this._referencedPosition)&&this.rotationQuaternion.equals(this._referenceQuaternion)||(this.position.subtractToRef(this._referencedPosition,this._referencedPosition),this._referenceQuaternion.conjugateInPlace(),this._referenceQuaternion.multiplyToRef(this.rotationQuaternion,this._referenceQuaternion),this._updateReferenceSpaceOffset(this._referencedPosition,this._referenceQuaternion.normalize()))},t.prototype._updateReferenceSpaceOffset=function(e,t,i){if(void 0===i&&(i=!1),this._xrSessionManager.referenceSpace&&this._xrSessionManager.currentFrame){this._xrInvPositionCache.copyFrom(e),t?this._xrInvQuaternionCache.copyFrom(t):this._xrInvQuaternionCache.copyFromFloats(0,0,0,1),this._scene.useRightHandedSystem||(this._xrInvPositionCache.z*=-1,this._xrInvQuaternionCache.z*=-1,this._xrInvQuaternionCache.w*=-1),this._xrInvPositionCache.negateInPlace(),this._xrInvQuaternionCache.conjugateInPlace(),this._xrInvPositionCache.rotateByQuaternionToRef(this._xrInvQuaternionCache,this._xrInvPositionCache),i&&(this._xrInvPositionCache.y=0);var n=new XRRigidTransform({x:this._xrInvPositionCache.x,y:this._xrInvPositionCache.y,z:this._xrInvPositionCache.z},{x:this._xrInvQuaternionCache.x,y:this._xrInvQuaternionCache.y,z:this._xrInvQuaternionCache.z,w:this._xrInvQuaternionCache.w}),r=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(n),o=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(r);if(o){var s=new a.e(o.transform.position.x,o.transform.position.y,o.transform.position.z);this._scene.useRightHandedSystem||(s.z*=-1),this.position.subtractToRef(s,s),this._scene.useRightHandedSystem||(s.z*=-1),s.negateInPlace();var c=new XRRigidTransform({x:s.x,y:s.y,z:s.z});this._xrSessionManager.referenceSpace=r.getOffsetReferenceSpace(c)}}},t}(wt),Ia=function(){function e(){}return e.ANCHOR_SYSTEM="xr-anchor-system",e.BACKGROUND_REMOVER="xr-background-remover",e.HIT_TEST="xr-hit-test",e.PHYSICS_CONTROLLERS="xr-physics-controller",e.PLANE_DETECTION="xr-plane-detection",e.POINTER_SELECTION="xr-controller-pointer-selection",e.TELEPORTATION="xr-controller-teleportation",e.FEATURE_POINTS="xr-feature-points",e.HAND_TRACKING="xr-hand-tracking",e}(),Da=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];!i.enabled||i.featureImplementation.attached||i.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var i=t._features[e];i.enabled&&i.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,i,n){void 0===i&&(i=1),void 0===n&&(n=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:i},i>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=i),n&&(this._AvailableFeatures[e].stable=i),this._AvailableFeatures[e][i]=t},e.ConstructFeature=function(e,t,i,n){void 0===t&&(t=1);var r=this._AvailableFeatures[e][t];if(!r)throw new Error("feature not found");return r(i,n)},e.GetAvailableFeatures=function(){return Object.keys(this._AvailableFeatures)},e.GetAvailableVersions=function(e){return Object.keys(this._AvailableFeatures[e])},e.GetLatestVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].latest||-1},e.GetStableVersionOfFeature=function(e){return this._AvailableFeatures[e]&&this._AvailableFeatures[e].stable||-1},e.prototype.attachFeature=function(e){var t=this._features[e];t&&t.enabled&&!t.featureImplementation.attached&&t.featureImplementation.attach()},e.prototype.detachFeature=function(e){var t=this._features[e];t&&t.featureImplementation.attached&&t.featureImplementation.detach()},e.prototype.disableFeature=function(e){var t="string"==typeof e?e:e.Name,i=this._features[t];return!(!i||!i.enabled)&&(i.enabled=!1,this.detachFeature(t),i.featureImplementation.dispose(),!0)},e.prototype.dispose=function(){var e=this;this.getEnabledFeatures().forEach((function(t){e.disableFeature(t),e._features[t].featureImplementation.dispose()}))},e.prototype.enableFeature=function(t,i,n,r,o){var a=this;void 0===i&&(i="latest"),void 0===n&&(n={}),void 0===r&&(r=!0),void 0===o&&(o=!0);var s="string"==typeof t?t:t.Name,c=0;if("string"==typeof i){if(!i)throw new Error("Error in provided version - "+s+" ("+i+")");if(-1===(c="stable"===i?e.GetStableVersionOfFeature(s):"latest"===i?e.GetLatestVersionOfFeature(s):+i)||isNaN(c))throw new Error("feature not found - "+s+" ("+i+")")}else c=i;var l=this._features[s],u=e.ConstructFeature(s,c,this._xrSessionManager,n);if(!u)throw new Error("feature not found - "+s);l&&this.disableFeature(s);var h=u();if(h.dependsOn&&!h.dependsOn.every((function(e){return!!a._features[e]})))throw new Error("Dependant features missing. Make sure the following features are enabled - "+h.dependsOn.join(", "));if(h.isCompatible())return this._features[s]={featureImplementation:h,enabled:!0,version:c,required:o},r?this._xrSessionManager.session&&!this._features[s].featureImplementation.attached&&this.attachFeature(s):this._features[s].featureImplementation.disableAutoAttach=!0,this._features[s].featureImplementation;if(o)throw new Error("required feature not compatible");return Ce.b.Warn("Feature "+s+" not compatible with the current environment/browser and was not enabled."),h},e.prototype.getEnabledFeature=function(e){return this._features[e]&&this._features[e].featureImplementation},e.prototype.getEnabledFeatures=function(){return Object.keys(this._features)},e.prototype.extendXRSessionInitObject=function(e){var t=this;return this.getEnabledFeatures().forEach((function(i){var n=t._features[i],r=n.featureImplementation.xrNativeFeatureName;r&&(n.required?(e.requiredFeatures=e.requiredFeatures||[],-1===e.requiredFeatures.indexOf(r)&&e.requiredFeatures.push(r)):(e.optionalFeatures=e.optionalFeatures||[],-1===e.optionalFeatures.indexOf(r)&&e.optionalFeatures.push(r)))})),e},e._AvailableFeatures={},e}(),Na=function(){function e(e){var t=this;this.scene=e,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.onInitialXRPoseSetObservable=new o.c,this.onStateChangedObservable=new o.c,this.state=$i.NOT_IN_XR,this.sessionManager=new an(e),this.camera=new Ma("",e,this.sessionManager),this.featuresManager=new Da(this.sessionManager),e.onDisposeObservable.add((function(){t.exitXRAsync()}))}return e.CreateAsync=function(t){var i=new e(t);return i.sessionManager.initializeAsync().then((function(){return i._supported=!0,i})).catch((function(e){throw i._setState($i.NOT_IN_XR),i.dispose(),e}))},e.prototype.dispose=function(){this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),this._nonVRCamera&&(this.scene.activeCamera=this._nonVRCamera)},e.prototype.enterXRAsync=function(e,t,i,n){var r=this;if(void 0===i&&(i=this.sessionManager.getWebXRRenderTarget()),void 0===n&&(n={}),!this._supported)throw"WebXR not supported in this browser or environment";return this._setState($i.ENTERING_XR),"viewer"!==t&&"local"!==t&&(n.optionalFeatures=n.optionalFeatures||[],n.optionalFeatures.push(t)),this.featuresManager.extendXRSessionInitObject(n),"immersive-ar"===e&&"unbounded"!==t&&m.a.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),this.sessionManager.initializeSessionAsync(e,n).then((function(){return r.sessionManager.setReferenceSpaceTypeAsync(t)})).then((function(){return i.initializeXRLayerAsync(r.sessionManager.session)})).then((function(){return r.sessionManager.updateRenderStateAsync({depthFar:r.camera.maxZ,depthNear:r.camera.minZ,baseLayer:i.xrLayer})})).then((function(){return r.sessionManager.runXRRenderLoop(),r._originalSceneAutoClear=r.scene.autoClear,r._nonVRCamera=r.scene.activeCamera,r.scene.activeCamera=r.camera,"immersive-ar"!==e?r._nonXRToXRCamera():(r.scene.autoClear=!1,r.camera.compensateOnFirstFrame=!1),r.sessionManager.onXRSessionEnded.addOnce((function(){r.camera.rigCameras.forEach((function(e){e.outputRenderTarget=null})),r.scene.autoClear=r._originalSceneAutoClear,r.scene.activeCamera=r._nonVRCamera,"immersive-ar"!==e&&r.camera.compensateOnFirstFrame&&(r._nonVRCamera.setPosition?r._nonVRCamera.setPosition(r.camera.position):r._nonVRCamera.position.copyFrom(r.camera.position)),r._setState($i.NOT_IN_XR)})),r.sessionManager.onXRFrameObservable.addOnce((function(){r._setState($i.IN_XR)})),r.sessionManager})).catch((function(e){throw console.log(e),console.log(e.message),r._setState($i.NOT_IN_XR),e}))},e.prototype.exitXRAsync=function(){return this.state!==$i.IN_XR?Promise.resolve():(this._setState($i.EXITING_XR),this.sessionManager.exitXRAsync())},e.prototype._nonXRToXRCamera=function(){this.camera.setTransformationFromNonVRCamera(this._nonVRCamera),this.onInitialXRPoseSetObservable.notifyObservers(this.camera)},e.prototype._setState=function(e){this.state!==e&&(this.state=e,this.onStateChangedObservable.notifyObservers(this.state))},e}(),La=function(){function e(e,t,i,n){void 0===i&&(i=-1),void 0===n&&(n=[]),this.id=e,this.type=t,this._buttonIndex=i,this._axesIndices=n,this._axes={x:0,y:0},this._changes={},this._currentValue=0,this._hasChanges=!1,this._pressed=!1,this._touched=!1,this.onAxisValueChangedObservable=new o.c,this.onButtonStateChangedObservable=new o.c}return Object.defineProperty(e.prototype,"axes",{get:function(){return this._axes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"changes",{get:function(){return this._changes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasChanges",{get:function(){return this._hasChanges},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pressed",{get:function(){return this._pressed},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"touched",{get:function(){return this._touched},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"value",{get:function(){return this._currentValue},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.onAxisValueChangedObservable.clear(),this.onButtonStateChangedObservable.clear()},e.prototype.isAxes=function(){return 0!==this._axesIndices.length},e.prototype.isButton=function(){return-1!==this._buttonIndex},e.prototype.update=function(e){var t=!1,i=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var n=e.buttons[this._buttonIndex];if(!n)return;this._currentValue!==n.value&&(this.changes.value={current:n.value,previous:this._currentValue},t=!0,this._currentValue=n.value),this._touched!==n.touched&&(this.changes.touched={current:n.touched,previous:this._touched},t=!0,this._touched=n.touched),this._pressed!==n.pressed&&(this.changes.pressed={current:n.pressed,previous:this._pressed},t=!0,this._pressed=n.pressed)}this.isAxes()&&(this._axes.x!==e.axes[this._axesIndices[0]]&&(this.changes.axes={current:{x:e.axes[this._axesIndices[0]],y:this._axes.y},previous:{x:this._axes.x,y:this._axes.y}},this._axes.x=e.axes[this._axesIndices[0]],i=!0),this._axes.y!==e.axes[this._axesIndices[1]]&&(this.changes.axes?this.changes.axes.current.y=e.axes[this._axesIndices[1]]:this.changes.axes={current:{x:this._axes.x,y:e.axes[this._axesIndices[1]]},previous:{x:this._axes.x,y:this._axes.y}},this._axes.y=e.axes[this._axesIndices[1]],i=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),i&&(this._hasChanges=!0,this.onAxisValueChangedObservable.notifyObservers(this._axes))},e.BUTTON_TYPE="button",e.SQUEEZE_TYPE="squeeze",e.THUMBSTICK_TYPE="thumbstick",e.TOUCHPAD_TYPE="touchpad",e.TRIGGER_TYPE="trigger",e}(),wa=function(){function e(e,t,i,n,r){var a=this;void 0===r&&(r=!1),this.scene=e,this.layout=t,this.gamepadObject=i,this.handedness=n,this._initComponent=function(e){if(e){var t=a.layout.components[e],i=t.type,n=t.gamepadIndices.button,r=[];void 0!==t.gamepadIndices.xAxis&&void 0!==t.gamepadIndices.yAxis&&r.push(t.gamepadIndices.xAxis,t.gamepadIndices.yAxis),a.components[e]=new La(e,i,n,r)}},this._modelReady=!1,this.components={},this.disableAnimation=!1,this.onModelLoadedObservable=new o.c,t.components&&Object.keys(t.components).forEach(this._initComponent)}return e.prototype.dispose=function(){var e=this;this.getComponentIds().forEach((function(t){return e.getComponent(t).dispose()})),this.rootMesh&&this.rootMesh.dispose()},e.prototype.getAllComponentsOfType=function(e){var t=this;return this.getComponentIds().map((function(e){return t.components[e]})).filter((function(t){return t.type===e}))},e.prototype.getComponent=function(e){return this.components[e]},e.prototype.getComponentIds=function(){return Object.keys(this.components)},e.prototype.getComponentOfType=function(e){return this.getAllComponentsOfType(e)[0]||null},e.prototype.getMainComponent=function(){return this.getComponent(this.layout.selectComponentId)},e.prototype.loadModel=function(){return Object(h.b)(this,void 0,void 0,(function(){var e,t,i=this;return Object(h.e)(this,(function(n){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?m.a.Warn("Falling back to generic models"):t=this._getFilenameAndPath(),[2,new Promise((function(n,r){pr.ImportMesh("",t.path,t.filename,i.scene,(function(t){e?i._getGenericParentMesh(t):i._setRootMesh(t),i._processLoadedModel(t),i._modelReady=!0,i.onModelLoadedObservable.notifyObservers(i),n(!0)}),null,(function(e,n){m.a.Log(n),m.a.Warn("Failed to retrieve controller model of type "+i.profileId+" from the remote server: "+t.path+t.filename),r(n)}))}))]}))}))},e.prototype.updateFromXRFrame=function(e){var t=this;this.getComponentIds().forEach((function(e){return t.getComponent(e).update(t.gamepadObject)})),this.updateModel(e)},Object.defineProperty(e.prototype,"handness",{get:function(){return this.handedness},enumerable:!1,configurable:!0}),e.prototype.pulse=function(e,t,i){return void 0===i&&(i=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[i]?this.gamepadObject.hapticActuators[i].pulse(e,t):Promise.resolve(!1)},e.prototype._getChildByName=function(e,t){return e.getChildren((function(e){return e.name===t}),!1)[0]},e.prototype._getImmediateChildByName=function(e,t){return e.getChildren((function(e){return e.name==t}),!0)[0]},e.prototype._lerpTransform=function(e,t,i){if(e.minMesh&&e.maxMesh&&e.valueMesh&&e.minMesh.rotationQuaternion&&e.maxMesh.rotationQuaternion&&e.valueMesh.rotationQuaternion){var n=i?.5*t+.5:t;a.b.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,n,e.valueMesh.rotationQuaternion),a.e.LerpToRef(e.minMesh.position,e.maxMesh.position,n,e.valueMesh.position)}},e.prototype.updateModel=function(e){this._modelReady&&this._updateModel(e)},e.prototype._getGenericFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},e.prototype._getGenericParentMesh=function(e){var t=this;this.rootMesh=new be.a(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.parent||(e.isPickable=!1,e.setParent(t.rootMesh))})),this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0)},e}(),Fa=function(e){function t(i,n,r){var o=e.call(this,i,Ba[r],n,r)||this;return o.profileId=t.ProfileId,o}return Object(h.d)(t,e),t.prototype._getFilenameAndPath=function(){return{filename:"generic.babylon",path:"https://controllers.babylonjs.com/generic/"}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){},t.prototype._setRootMesh=function(e){var t=this;this.rootMesh=new be.a(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.isPickable=!1,e.parent||e.setParent(t.rootMesh)})),this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0)},t.prototype._updateModel=function(){},t.ProfileId="generic-trigger",t}(wa),Ba={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-right",assetPath:"right.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-trigger-none",assetPath:"none.glb"}},Ua=function(e){function t(t,i,n,r){var o=e.call(this,t,n.layouts[i.handedness||"none"],i.gamepad,i.handedness)||this;return o._repositoryUrl=r,o._buttonMeshMapping={},o._touchDots={},o.profileId=n.profileId,o}return Object(h.d)(t,e),t.prototype.dispose=function(){var t=this;e.prototype.dispose.call(this),Object.keys(this._touchDots).forEach((function(e){t._touchDots[e].dispose()}))},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:this._repositoryUrl+"/profiles/"+this.profileId+"/"}},t.prototype._getModelLoadingConstraints=function(){var e=pr.IsPluginForExtensionAvailable(".glb");return e||m.a.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var t=this;this.getComponentIds().forEach((function(e){var i=t.layout.components[e];t._buttonMeshMapping[e]={mainMesh:t._getChildByName(t.rootMesh,i.rootNodeName),states:{}},Object.keys(i.visualResponses).forEach((function(n){var r=i.visualResponses[n];if("transform"===r.valueNodeProperty)t._buttonMeshMapping[e].states[n]={valueMesh:t._getChildByName(t.rootMesh,r.valueNodeName),minMesh:t._getChildByName(t.rootMesh,r.minNodeName),maxMesh:t._getChildByName(t.rootMesh,r.maxNodeName)};else{var o=i.type===La.TOUCHPAD_TYPE&&i.touchPointNodeName?i.touchPointNodeName:r.valueNodeName;if(t._buttonMeshMapping[e].states[n]={valueMesh:t._getChildByName(t.rootMesh,o)},i.type===La.TOUCHPAD_TYPE&&!t._touchDots[n]){var a=xr.a.CreateSphere(n+"dot",{diameter:.0015,segments:8},t.scene);a.material=new Wi.a(n+"mat",t.scene),a.material.diffuseColor=s.a.Red(),a.parent=t._buttonMeshMapping[e].states[n].valueMesh||null,a.isVisible=!1,t._touchDots[n]=a}}}))}))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new be.a(this.profileId+"-"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i<e.length;i++){var n=e[i];n.isPickable=!1,n.parent||(t=n)}t&&t.setParent(this.rootMesh),this.scene.useRightHandedSystem||this.rootMesh.rotate(J.a.Y,Math.PI,J.c.WORLD)},t.prototype._updateModel=function(e){var t=this;this.disableAnimation||this.getComponentIds().forEach((function(e){var i=t.getComponent(e);if(i.hasChanges){var n=t._buttonMeshMapping[e],r=t.layout.components[e];Object.keys(r.visualResponses).forEach((function(e){var o=r.visualResponses[e],a=i.value;if("xAxis"===o.componentProperty?a=i.axes.x:"yAxis"===o.componentProperty&&(a=i.axes.y),"transform"===o.valueNodeProperty)t._lerpTransform(n.states[e],a,"button"!==o.componentProperty);else{var s=n.states[e].valueMesh;s&&(s.isVisible=i.touched||i.pressed),t._touchDots[e]&&(t._touchDots[e].isVisible=i.touched||i.pressed)}}))}}))},t}(wa),Va=function(){function e(){}return e.ClearProfilesCache=function(){this._ProfilesList=null,this._ProfileLoadingPromises={}},e.DefaultFallbacks=function(){this.RegisterFallbacksForProfileId("google-daydream",["generic-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive-focus",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("htc-vive",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("magicleap-one",["generic-trigger-squeeze-touchpad"]),this.RegisterFallbacksForProfileId("windows-mixed-reality",["generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("microsoft-mixed-reality",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-go",["generic-trigger-touchpad"]),this.RegisterFallbacksForProfileId("oculus-touch-v2",["oculus-touch","generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("oculus-touch",["generic-trigger-squeeze-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-gearvr",["windows-mixed-reality","generic-trigger-squeeze-touchpad-thumbstick"]),this.RegisterFallbacksForProfileId("samsung-odyssey",["generic-touchpad"]),this.RegisterFallbacksForProfileId("valve-index",["generic-trigger-squeeze-touchpad-thumbstick"])},e.FindFallbackWithProfileId=function(e){var t=this._Fallbacks[e]||[];return t.unshift(e),t},e.GetMotionControllerWithXRInput=function(e,t,i){var n=this,r=[];if(i&&r.push(i),r.push.apply(r,e.profiles||[]),r.length&&!r[0]&&r.pop(),e.gamepad&&e.gamepad.id)switch(e.gamepad.id){case e.gamepad.id.match(/oculus touch/gi)?e.gamepad.id:void 0:r.push("oculus-touch-v2")}var o=r.indexOf("windows-mixed-reality");if(-1!==o&&r.splice(o,0,"microsoft-mixed-reality"),r.length||r.push("generic-trigger"),this.UseOnlineRepository){var a=this.PrioritizeOnlineRepository?this._LoadProfileFromRepository:this._LoadProfilesFromAvailableControllers,s=this.PrioritizeOnlineRepository?this._LoadProfilesFromAvailableControllers:this._LoadProfileFromRepository;return a.call(this,r,e,t).catch((function(){return s.call(n,r,e,t)}))}return this._LoadProfilesFromAvailableControllers(r,e,t)},e.RegisterController=function(e,t){this._AvailableControllers[e]=t},e.RegisterFallbacksForProfileId=function(e,t){var i;this._Fallbacks[e]?(i=this._Fallbacks[e]).push.apply(i,t):this._Fallbacks[e]=t},e.UpdateProfilesList=function(){return this._ProfilesList=Ce.b.LoadFileAsync(this.BaseRepositoryUrl+"/profiles/profilesList.json",!1).then((function(e){return JSON.parse(e.toString())})),this._ProfilesList},e._LoadProfileFromRepository=function(e,t,i){var n=this;return Promise.resolve().then((function(){return n._ProfilesList?n._ProfilesList:n.UpdateProfilesList()})).then((function(t){for(var i=0;i<e.length;++i)if(e[i]&&t[e[i]])return e[i];throw new Error("neither controller "+e[0]+" nor all fallbacks were found in the repository,")})).then((function(e){return n._ProfileLoadingPromises[e]||(n._ProfileLoadingPromises[e]=Ce.b.LoadFileAsync(n.BaseRepositoryUrl+"/profiles/"+e+"/profile.json",!1).then((function(e){return JSON.parse(e)}))),n._ProfileLoadingPromises[e]})).then((function(e){return new Ua(i,t,e,n.BaseRepositoryUrl)}))},e._LoadProfilesFromAvailableControllers=function(e,t,i){for(var n=0;n<e.length;++n)if(e[n])for(var r=this.FindFallbackWithProfileId(e[n]),o=0;o<r.length;++o){var a=this._AvailableControllers[r[o]];if(a)return Promise.resolve(a(t,i))}throw new Error("no controller requested was found in the available controllers list")},e._AvailableControllers={},e._Fallbacks={},e._ProfileLoadingPromises={},e.BaseRepositoryUrl="https://immersive-web.github.io/webxr-input-profiles/packages/viewer/dist",e.PrioritizeOnlineRepository=!0,e.UseOnlineRepository=!0,e}();Va.RegisterController(Fa.ProfileId,(function(e,t){return new Fa(t,e.gamepad,e.handedness)})),Va.DefaultFallbacks();var ka=0,za=function(){function e(e,t,i){var n=this;void 0===i&&(i={}),this._scene=e,this.inputSource=t,this._options=i,this._tmpVector=new a.e,this._disposed=!1,this.onDisposeObservable=new o.c,this.onMeshLoadedObservable=new o.c,this.onMotionControllerInitObservable=new o.c,this._uniqueId="controller-"+ka+++"-"+t.targetRayMode+"-"+t.handedness,this.pointer=new Ge.a(this._uniqueId+"-pointer",e),this.pointer.rotationQuaternion=new a.b,this.inputSource.gripSpace&&(this.grip=new Ge.a(this._uniqueId+"-grip",this._scene),this.grip.rotationQuaternion=new a.b),this._tmpVector.set(0,0,this._scene.useRightHandedSystem?-1:1),this.inputSource.gamepad&&Va.GetMotionControllerWithXRInput(t,e,this._options.forceControllerProfile).then((function(e){n.motionController=e,n.onMotionControllerInitObservable.notifyObservers(e),n._options.doNotLoadControllerMesh||n.motionController.loadModel().then((function(e){var t;e&&n.motionController&&n.motionController.rootMesh&&(n._options.renderingGroupId&&(n.motionController.rootMesh.renderingGroupId=n._options.renderingGroupId,n.motionController.rootMesh.getChildMeshes(!1).forEach((function(e){return e.renderingGroupId=n._options.renderingGroupId}))),n.onMeshLoadedObservable.notifyObservers(n.motionController.rootMesh),n.motionController.rootMesh.parent=n.grip||n.pointer,n.motionController.disableAnimation=!!n._options.disableMotionControllerAnimation),n._disposed&&(null===(t=n.motionController)||void 0===t||t.dispose())}))}),(function(){Ce.b.Warn("Could not find a matching motion controller for the registered input source")}))}return Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this.grip&&this.grip.dispose(),this.motionController&&this.motionController.dispose(),this.pointer.dispose(),this.onMotionControllerInitObservable.clear(),this.onMeshLoadedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._disposed=!0},e.prototype.getWorldPointerRayToRef=function(e,t){void 0===t&&(t=!1);var i=t&&this.grip?this.grip:this.pointer;a.e.TransformNormalToRef(this._tmpVector,i.getWorldMatrix(),e.direction),e.direction.normalize(),e.origin.copyFrom(i.absolutePosition),e.length=1e3},e.prototype.updateFromXRFrame=function(e,t){var i=e.getPose(this.inputSource.targetRaySpace,t);if(i){var n=i.transform.position;this.pointer.position.set(n.x,n.y,n.z);var r=i.transform.orientation;this.pointer.rotationQuaternion.set(r.x,r.y,r.z,r.w),this._scene.useRightHandedSystem||(this.pointer.position.z*=-1,this.pointer.rotationQuaternion.z*=-1,this.pointer.rotationQuaternion.w*=-1)}if(this.inputSource.gripSpace&&this.grip){var o=e.getPose(this.inputSource.gripSpace,t);if(o){n=o.transform.position;var a=o.transform.orientation;this.grip.position.set(n.x,n.y,n.z),this.grip.rotationQuaternion.set(a.x,a.y,a.z,a.w),this._scene.useRightHandedSystem||(this.grip.position.z*=-1,this.grip.rotationQuaternion.z*=-1,this.grip.rotationQuaternion.w*=-1)}}this.motionController&&this.motionController.updateFromXRFrame(e)},e}(),Ga=function(){function e(e,t,i){var n=this;if(void 0===i&&(i={}),this.xrSessionManager=e,this.xrCamera=t,this.options=i,this.controllers=[],this.onControllerAddedObservable=new o.c,this.onControllerRemovedObservable=new o.c,this._onInputSourcesChange=function(e){n._addAndRemoveControllers(e.added,e.removed)},this._sessionEndedObserver=this.xrSessionManager.onXRSessionEnded.add((function(){n._addAndRemoveControllers([],n.controllers.map((function(e){return e.inputSource})))})),this._sessionInitObserver=this.xrSessionManager.onXRSessionInit.add((function(e){e.addEventListener("inputsourceschange",n._onInputSourcesChange)})),this._frameObserver=this.xrSessionManager.onXRFrameObservable.add((function(e){n.controllers.forEach((function(t){t.updateFromXRFrame(e,n.xrSessionManager.referenceSpace)}))})),this.options.customControllersRepositoryURL&&(Va.BaseRepositoryUrl=this.options.customControllersRepositoryURL),Va.UseOnlineRepository=!this.options.disableOnlineControllerRepository,Va.UseOnlineRepository)try{Va.UpdateProfilesList().catch((function(){Va.UseOnlineRepository=!1}))}catch(e){Va.UseOnlineRepository=!1}}return e.prototype._addAndRemoveControllers=function(e,t){for(var i=this,n=this.controllers.map((function(e){return e.inputSource})),r=0,o=e;r<o.length;r++){var a=o[r];if(-1===n.indexOf(a)){var s=new za(this.xrSessionManager.scene,a,Object(h.a)(Object(h.a)({},this.options.controllerOptions||{}),{forceControllerProfile:this.options.forceInputProfile,doNotLoadControllerMesh:this.options.doNotLoadControllerMeshes,disableMotionControllerAnimation:this.options.disableControllerAnimation}));this.controllers.push(s),this.onControllerAddedObservable.notifyObservers(s)}}var c=[],l=[];this.controllers.forEach((function(e){-1===t.indexOf(e.inputSource)?c.push(e):l.push(e)})),this.controllers=c,l.forEach((function(e){i.onControllerRemovedObservable.notifyObservers(e),e.dispose()}))},e.prototype.dispose=function(){this.controllers.forEach((function(e){e.dispose()})),this.xrSessionManager.onXRFrameObservable.remove(this._frameObserver),this.xrSessionManager.onXRSessionInit.remove(this._sessionInitObserver),this.xrSessionManager.onXRSessionEnded.remove(this._sessionEndedObserver),this.onControllerAddedObservable.clear(),this.onControllerRemovedObservable.clear()},e}(),ja=function(){function e(e){this._xrSessionManager=e,this._attached=!1,this._removeOnDetach=[],this.isDisposed=!1,this.disableAutoAttach=!1,this.xrNativeFeatureName=""}return Object.defineProperty(e.prototype,"attached",{get:function(){return this._attached},enumerable:!1,configurable:!0}),e.prototype.attach=function(e){var t=this;if(this.isDisposed)return!1;if(e)this.attached&&this.detach();else if(this.attached)return!1;return this._attached=!0,this._addNewAttachObserver(this._xrSessionManager.onXRFrameObservable,(function(e){return t._onXRFrame(e)})),!0},e.prototype.detach=function(){return this._attached?(this._attached=!1,this._removeOnDetach.forEach((function(e){e.observable.remove(e.observer)})),!0):(this.disableAutoAttach=!0,!1)},e.prototype.dispose=function(){this.detach(),this.isDisposed=!0},e.prototype.isCompatible=function(){return!0},e.prototype._addNewAttachObserver=function(e,t){this._removeOnDetach.push({observable:e,observer:e.add(t)})},e}(),Wa=function(e){function t(i,n){var r=e.call(this,i)||this;return r._options=n,r._attachController=function(e){if(!r._controllers[e.uniqueId]){var i=r._generateNewMeshPair(e.pointer),n=i.laserPointer,o=i.selectionMesh;switch(r._controllers[e.uniqueId]={xrController:e,laserPointer:n,selectionMesh:o,meshUnderPointer:null,pick:null,tmpRay:new Xt.a(new a.e,new a.e),id:t._idCounter++},r._attachedController?!r._options.enablePointerSelectionOnAllControllers&&r._options.preferredHandedness&&e.inputSource.handedness===r._options.preferredHandedness&&(r._attachedController=e.uniqueId):r._options.enablePointerSelectionOnAllControllers||(r._attachedController=e.uniqueId),e.inputSource.targetRayMode){case"tracked-pointer":return r._attachTrackedPointerRayMode(e);case"gaze":return r._attachGazeMode(e);case"screen":return r._attachScreenRayMode(e)}}},r._controllers={},r._tmpVectorForPickCompare=new a.e,r.disablePointerLighting=!0,r.disableSelectionMeshLighting=!0,r.displayLaserPointer=!0,r.displaySelectionMesh=!0,r.laserPointerPickedColor=new s.a(.9,.9,.9),r.laserPointerDefaultColor=new s.a(.7,.7,.7),r.selectionMeshDefaultColor=new s.a(.8,.8,.8),r.selectionMeshPickedColor=new s.a(.3,.3,1),r._identityMatrix=a.a.Identity(),r._screenCoordinatesRef=a.e.Zero(),r._viewportRef=new yi.a(0,0,0,0),r._scene=r._xrSessionManager.scene,r}return Object(h.d)(t,e),t.prototype.attach=function(){var i=this;if(!e.prototype.attach.call(this))return!1;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(e){i._detachController(e.uniqueId)})),this._scene.constantlyUpdateMeshUnderPointer=!0,this._options.gazeCamera){var n=this._options.gazeCamera,r=this._generateNewMeshPair(n),o=r.laserPointer,s=r.selectionMesh;this._controllers.camera={webXRCamera:n,laserPointer:o,selectionMesh:s,meshUnderPointer:null,pick:null,tmpRay:new Xt.a(new a.e,new a.e),id:t._idCounter++},this._attachGazeMode()}return!0},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach((function(e){t._detachController(e)})),!0)},t.prototype.getMeshUnderPointer=function(e){return this._controllers[e]?this._controllers[e].meshUnderPointer:null},t.prototype.getXRControllerByPointerId=function(e){for(var t=Object.keys(this._controllers),i=0;i<t.length;++i)if(this._controllers[t[i]].id===e)return this._controllers[t[i]].xrController||null;return null},t.prototype._onXRFrame=function(e){var t=this;Object.keys(this._controllers).forEach((function(e){var i,n=t._controllers[e];if(!t._options.enablePointerSelectionOnAllControllers&&e!==t._attachedController)return n.selectionMesh.isVisible=!1,n.laserPointer.isVisible=!1,void(n.pick=null);if(n.laserPointer.isVisible=t.displayLaserPointer,n.xrController)i=n.xrController.pointer.position,n.xrController.getWorldPointerRayToRef(n.tmpRay);else{if(!n.webXRCamera)return;i=n.webXRCamera.position,n.webXRCamera.getForwardRayToRef(n.tmpRay)}if(t._options.maxPointerDistance&&(n.tmpRay.length=t._options.maxPointerDistance),!t._options.disableScenePointerVectorUpdate&&i){var r=t._xrSessionManager.scene,o=t._options.xrInput.xrCamera;o&&(o.viewport.toGlobalToRef(r.getEngine().getRenderWidth(),r.getEngine().getRenderHeight(),t._viewportRef),a.e.ProjectToRef(i,t._identityMatrix,r.getTransformMatrix(),t._viewportRef,t._screenCoordinatesRef),r.pointerX=t._screenCoordinatesRef.x,r.pointerY=t._screenCoordinatesRef.y)}n.pick=t._scene.pickWithRay(n.tmpRay,t._scene.pointerMovePredicate||t.raySelectionPredicate);var s=n.pick;if(s&&s.pickedPoint&&s.hit){t._updatePointerDistance(n.laserPointer,s.distance),n.selectionMesh.position.copyFrom(s.pickedPoint),n.selectionMesh.scaling.x=Math.sqrt(s.distance),n.selectionMesh.scaling.y=Math.sqrt(s.distance),n.selectionMesh.scaling.z=Math.sqrt(s.distance);var c=t._convertNormalToDirectionOfRay(s.getNormal(!0),n.tmpRay);if(n.selectionMesh.position.copyFrom(s.pickedPoint),c){var l=a.e.Cross(J.a.Y,c),u=a.e.Cross(c,l);a.e.RotationFromAxisToRef(u,c,l,n.selectionMesh.rotation),n.selectionMesh.position.addInPlace(c.scale(.001))}n.selectionMesh.isVisible=t.displaySelectionMesh,n.meshUnderPointer=s.pickedMesh}else n.selectionMesh.isVisible=!1,t._updatePointerDistance(n.laserPointer,1),n.meshUnderPointer=null}))},t.prototype._attachGazeMode=function(e){var t=this,i=this._controllers[e&&e.uniqueId||"camera"],n=this._options.timeToSelect||3e3,r=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Cr.a.DefaultUtilityLayer.utilityLayerScene:this._scene,o=new gn.a,a=tn.CreateTorus("selection",{diameter:.0525,thickness:.015,tessellation:20},r);a.isVisible=!1,a.isPickable=!1,a.parent=i.selectionMesh;var s=0,c=!1;i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){if(i.pick){if(i.laserPointer.material.alpha=0,a.isVisible=!1,i.pick.hit)if(t._pickingMoved(o,i.pick))c&&(t._options.disablePointerUpOnTouchOut||t._scene.simulatePointerUp(i.pick,{pointerId:i.id})),c=!1,s=0;else if(s>n/10&&(a.isVisible=!0),(s+=t._scene.getEngine().getDeltaTime())>=n)t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),c=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),a.isVisible=!1;else{var e=1-s/n;a.scaling.set(e,e,e)}else c=!1,s=0;t._scene.simulatePointerMove(i.pick,{pointerId:i.id}),o=i.pick}})),void 0!==this._options.renderingGroupId&&(a.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce((function(){i.pick&&!t._options.disablePointerUpOnTouchOut&&c&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),a.dispose()}))},t.prototype._attachScreenRayMode=function(e){var t=this,i=this._controllers[e.uniqueId],n=!1;i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){!i.pick||t._options.disablePointerUpOnTouchOut&&n||(n?t._scene.simulatePointerMove(i.pick,{pointerId:i.id}):(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),n=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id})))})),e.onDisposeObservable.addOnce((function(){i.pick&&n&&!t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(i.pick,{pointerId:i.id})}))},t.prototype._attachTrackedPointerRayMode=function(e){var t=this,i=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);if(i.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){i.laserPointer.material.disableLighting=t.disablePointerLighting,i.selectionMesh.material.disableLighting=t.disableSelectionMeshLighting,i.pick&&t._scene.simulatePointerMove(i.pick,{pointerId:i.id})})),e.inputSource.gamepad){var n=function(n){t._options.overrideButtonId&&(i.selectionComponent=n.getComponent(t._options.overrideButtonId)),i.selectionComponent||(i.selectionComponent=n.getMainComponent()),i.onButtonChangedObserver=i.selectionComponent.onButtonStateChangedObservable.add((function(n){if(n.changes.pressed){var r=n.changes.pressed.current;i.pick?(t._options.enablePointerSelectionOnAllControllers||e.uniqueId===t._attachedController)&&(r?(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor):(t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)):!r||t._options.enablePointerSelectionOnAllControllers||t._options.disableSwitchOnClick||(t._attachedController=e.uniqueId)}}))};e.motionController?n(e.motionController):e.onMotionControllerInitObservable.add(n)}else{var r=function(e){i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerDown(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,i.laserPointer.material.emissiveColor=t.laserPointerPickedColor)},o=function(e){i.xrController&&e.inputSource===i.xrController.inputSource&&i.pick&&(t._scene.simulatePointerUp(i.pick,{pointerId:i.id}),i.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,i.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)};i.eventListeners={selectend:o,selectstart:r},this._xrSessionManager.session.addEventListener("selectstart",r),this._xrSessionManager.session.addEventListener("selectend",o)}},t.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))<Math.PI/2&&e.scaleInPlace(-1));return e},t.prototype._detachController=function(e){var t=this,i=this._controllers[e];if(i&&(i.selectionComponent&&i.onButtonChangedObserver&&i.selectionComponent.onButtonStateChangedObservable.remove(i.onButtonChangedObserver),i.onFrameObserver&&this._xrSessionManager.onXRFrameObservable.remove(i.onFrameObserver),i.eventListeners&&Object.keys(i.eventListeners).forEach((function(e){var n=i.eventListeners&&i.eventListeners[e];n&&t._xrSessionManager.session.removeEventListener(e,n)})),i.selectionMesh.dispose(),i.laserPointer.dispose(),delete this._controllers[e],this._attachedController===e)){var n=Object.keys(this._controllers);n.length?this._attachedController=n[0]:this._attachedController=""}},t.prototype._generateNewMeshPair=function(e){var t=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Cr.a.DefaultUtilityLayer.utilityLayerScene:this._scene,i=nn.a.CreateCylinder("laserPointer",{height:1,diameterTop:2e-4,diameterBottom:.004,tessellation:20,subdivisions:1},t);i.parent=e;var n=new Wi.a("laserPointerMat",t);n.emissiveColor=this.laserPointerDefaultColor,n.alpha=.7,i.material=n,i.rotation.x=Math.PI/2,this._updatePointerDistance(i,1),i.isPickable=!1;var r=tn.CreateTorus("gazeTracker",{diameter:.0105,thickness:.0075,tessellation:20},t);r.bakeCurrentTransformIntoVertices(),r.isPickable=!1,r.isVisible=!1;var o=new Wi.a("targetMat",t);return o.specularColor=s.a.Black(),o.emissiveColor=this.selectionMeshDefaultColor,o.backFaceCulling=!1,r.material=o,void 0!==this._options.renderingGroupId&&(i.renderingGroupId=this._options.renderingGroupId,r.renderingGroupId=this._options.renderingGroupId),{laserPointer:i,selectionMesh:r}},t.prototype._pickingMoved=function(e,t){var i;if(!e.hit||!t.hit)return!0;if(!(e.pickedMesh&&e.pickedPoint&&t.pickedMesh&&t.pickedPoint))return!0;if(e.pickedMesh!==t.pickedMesh)return!0;null===(i=e.pickedPoint)||void 0===i||i.subtractToRef(t.pickedPoint,this._tmpVectorForPickCompare),this._tmpVectorForPickCompare.set(Math.abs(this._tmpVectorForPickCompare.x),Math.abs(this._tmpVectorForPickCompare.y),Math.abs(this._tmpVectorForPickCompare.z));var n=.01*(this._options.gazeModePointerMovedFactor||1)*t.distance;return this._tmpVectorForPickCompare.length()>n},t.prototype._updatePointerDistance=function(e,t){void 0===t&&(t=100),e.scaling.y=t,this._scene.useRightHandedSystem&&(t*=-1),e.position.z=t/2+.05},Object.defineProperty(t.prototype,"lasterPointerDefaultColor",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._idCounter=200,t.Name=Ia.POINTER_SELECTION,t.Version=1,t}(ja);Da.AddWebXRFeature(Wa.Name,(function(e,t){return function(){return new Wa(e,t)}}),Wa.Version,!0);var Ha,Xa=function(){function e(e,t,i){this.element=e,this.sessionMode=t,this.referenceSpaceType=i}return e.prototype.update=function(e){},e}(),Ya=function(){},Ka=function(){function e(e,t){var i=this;if(this.scene=e,this.options=t,this._activeButton=null,this._buttons=[],this.activeButtonChangedObservable=new o.c,this.overlay=document.createElement("div"),this.overlay.classList.add("xr-button-overlay"),this.overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;","undefined"!=typeof window&&window.location&&"http:"===window.location.protocol&&Ce.b.Warn("WebXR can only be served over HTTPS"),t.customButtons)this._buttons=t.customButtons;else{var n=t.sessionMode||"immersive-vr",r=t.referenceSpaceType||"local-floor",a=".babylonVRicon { color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url("+("undefined"==typeof SVGSVGElement?"https://cdn.babylonjs.com/Assets/vrButton.png":"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) }";a+='.babylonVRicon.vrdisplaypresenting { background-image: none;} .vrdisplaypresenting::after { content: "EXIT"} .xr-error::after { content: "ERROR"}';var s=document.createElement("style");s.appendChild(document.createTextNode(a)),document.getElementsByTagName("head")[0].appendChild(s);var c=document.createElement("button");c.className="babylonVRicon",c.title=n+" - "+r,this._buttons.push(new Xa(c,n,r)),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",c.className="babylonVRicon"+(e===this?" vrdisplaypresenting":"")},this._updateButtons(null)}var l=e.getEngine().getInputElement();l&&l.parentNode&&(l.parentNode.appendChild(this.overlay),e.onDisposeObservable.addOnce((function(){i.dispose()})))}return e.CreateAsync=function(t,i,n){var r=this,o=new e(t,n),a=o._buttons.map((function(e){return i.sessionManager.isSessionSupportedAsync(e.sessionMode)}));return i.onStateChangedObservable.add((function(e){e==$i.NOT_IN_XR&&o._updateButtons(null)})),Promise.all(a).then((function(e){return e.forEach((function(e,t){e?(o.overlay.appendChild(o._buttons[t].element),o._buttons[t].element.onclick=function(){return Object(h.b)(r,void 0,void 0,(function(){var e,r,a;return Object(h.e)(this,(function(s){switch(s.label){case 0:return i.state!=$i.IN_XR?[3,2]:[4,i.exitXRAsync()];case 1:return s.sent(),o._updateButtons(null),[3,6];case 2:if(i.state!=$i.NOT_IN_XR)return[3,6];if(!n.renderTarget)return[3,6];s.label=3;case 3:return s.trys.push([3,5,,6]),[4,i.enterXRAsync(o._buttons[t].sessionMode,o._buttons[t].referenceSpaceType,n.renderTarget,{optionalFeatures:n.optionalFeatures,requiredFeatures:n.requiredFeatures})];case 4:return s.sent(),o._updateButtons(o._buttons[t]),[3,6];case 5:return e=s.sent(),o._updateButtons(null),r=o._buttons[t].element,a=r.title,r.title="Error entering XR session : "+a,r.classList.add("xr-error"),n.onError&&n.onError(e),[3,6];case 6:return[2]}}))}))}):Ce.b.Warn('Session mode "'+o._buttons[t].sessionMode+'" not supported in browser')})),o}))},e.prototype.dispose=function(){var e=this.scene.getEngine().getInputElement();e&&e.parentNode&&e.parentNode.contains(this.overlay)&&e.parentNode.removeChild(this.overlay),this.activeButtonChangedObservable.clear()},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}();function Qa(e){var t,i=0,n=Date.now();e.observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{};var r=e.contextObservable.add((function(t){var o=Date.now(),a={startTime:n,currentTime:o,deltaTime:i=o-n,completeRate:i/e.timeout,payload:t};e.onTick&&e.onTick(a),e.breakCondition&&e.breakCondition()&&(e.contextObservable.remove(r),e.onAborted&&e.onAborted(a)),i>=e.timeout&&(e.contextObservable.remove(r),e.onEnded&&e.onEnded(a))}),e.observableParameters.mask,e.observableParameters.insertFirst,e.observableParameters.scope);return r}!function(e){e[e.INIT=0]="INIT",e[e.STARTED=1]="STARTED",e[e.ENDED=2]="ENDED"}(Ha||(Ha={}));var qa=function(){function e(e){var t,i,n=this;this.onEachCountObservable=new o.c,this.onTimerAbortedObservable=new o.c,this.onTimerEndedObservable=new o.c,this.onStateChangedObservable=new o.c,this._observer=null,this._breakOnNextTick=!1,this._tick=function(e){var t=Date.now();n._timer=t-n._startTime;var i={startTime:n._startTime,currentTime:t,deltaTime:n._timer,completeRate:n._timer/n._timeToEnd,payload:e},r=n._breakOnNextTick||n._breakCondition(i);r||n._timer>=n._timeToEnd?n._stop(i,r):n.onEachCountObservable.notifyObservers(i)},this._setState(Ha.INIT),this._contextObservable=e.contextObservable,this._observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{},this._breakCondition=null!==(i=e.breakCondition)&&void 0!==i?i:function(){return!1},e.onEnded&&this.onTimerEndedObservable.add(e.onEnded),e.onTick&&this.onEachCountObservable.add(e.onTick),e.onAborted&&this.onTimerAbortedObservable.add(e.onAborted)}return Object.defineProperty(e.prototype,"breakCondition",{set:function(e){this._breakCondition=e},enumerable:!1,configurable:!0}),e.prototype.clearObservables=function(){this.onEachCountObservable.clear(),this.onTimerAbortedObservable.clear(),this.onTimerEndedObservable.clear(),this.onStateChangedObservable.clear()},e.prototype.start=function(e){if(void 0===e&&(e=this._timeToEnd),this._state===Ha.STARTED)throw new Error("Timer already started. Please stop it before starting again");this._timeToEnd=e,this._startTime=Date.now(),this._timer=0,this._observer=this._contextObservable.add(this._tick,this._observableParameters.mask,this._observableParameters.insertFirst,this._observableParameters.scope),this._setState(Ha.STARTED)},e.prototype.stop=function(){this._state===Ha.STARTED&&(this._breakOnNextTick=!0)},e.prototype.dispose=function(){this._observer&&this._contextObservable.remove(this._observer),this.clearObservables()},e.prototype._setState=function(e){this._state=e,this.onStateChangedObservable.notifyObservers(this._state)},e.prototype._stop=function(e,t){void 0===t&&(t=!1),this._contextObservable.remove(this._observer),this._setState(Ha.ENDED),t?this.onTimerAbortedObservable.notifyObservers(e):this.onTimerEndedObservable.notifyObservers(e)},e}(),Za=function(e){function t(t,i){var n=e.call(this,t)||this;return n._options=i,n._controllers={},n._snappedToPoint=!1,n._tmpRay=new Xt.a(new a.e,new a.e),n._tmpVector=new a.e,n._tmpQuaternion=new a.b,n.backwardsMovementEnabled=!0,n.backwardsTeleportationDistance=.7,n.parabolicCheckRadius=5,n.parabolicRayEnabled=!0,n.straightRayEnabled=!0,n.rotationAngle=Math.PI/8,n._rotationEnabled=!0,n._attachController=function(e){if(!(n._controllers[e.uniqueId]||n._options.forceHandedness&&e.inputSource.handedness!==n._options.forceHandedness)){n._controllers[e.uniqueId]={xrController:e,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0}};var t=n._controllers[e.uniqueId];if("tracked-pointer"===t.xrController.inputSource.targetRayMode&&t.xrController.inputSource.gamepad){var i=function(){if(e.motionController){var i=e.motionController.getComponentOfType(La.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(La.TOUCHPAD_TYPE);if(!i||n._options.useMainComponentOnly){var r=e.motionController.getMainComponent();if(!r)return;t.teleportationComponent=r,t.onButtonChangedObserver=r.onButtonStateChangedObservable.add((function(){r.changes.pressed&&(r.changes.pressed.current?(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Qa({timeout:n._options.timeToTeleport||3e3,contextObservable:n._xrSessionManager.onXRFrameObservable,breakCondition:function(){return!r.pressed},onEnded:function(){n._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}})):(t.teleportationState.forward=!1,n._currentTeleportationControllerId=""))}))}else t.teleportationComponent=i,t.onAxisChangedObserver=i.onAxisValueChangedObservable.add((function(i){if(i.y<=.7&&t.teleportationState.backwards&&(t.teleportationState.backwards=!1),i.y>.7&&!t.teleportationState.forward&&n.backwardsMovementEnabled&&!n.snapPointsOnly&&!t.teleportationState.backwards){t.teleportationState.backwards=!0,n._tmpQuaternion.copyFrom(n._options.xrInput.xrCamera.rotationQuaternion),n._tmpQuaternion.toEulerAnglesToRef(n._tmpVector),n._tmpVector.x=0,n._tmpVector.z=0,a.b.FromEulerVectorToRef(n._tmpVector,n._tmpQuaternion),n._tmpVector.set(0,0,n.backwardsTeleportationDistance*(n._xrSessionManager.scene.useRightHandedSystem?1:-1)),n._tmpVector.rotateByQuaternionToRef(n._tmpQuaternion,n._tmpVector),n._tmpVector.addInPlace(n._options.xrInput.xrCamera.position),n._tmpRay.origin.copyFrom(n._tmpVector),n._tmpRay.length=n._options.xrInput.xrCamera.realWorldHeight+.1,n._tmpRay.direction.set(0,-1,0);var r=n._xrSessionManager.scene.pickWithRay(n._tmpRay,(function(e){return-1!==n._floorMeshes.indexOf(e)}));r&&r.pickedPoint&&(n._options.xrInput.xrCamera.position.x=r.pickedPoint.x,n._options.xrInput.xrCamera.position.z=r.pickedPoint.z)}if(i.y<-.7&&!n._currentTeleportationControllerId&&!t.teleportationState.rotating&&(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),i.x){if(t.teleportationState.forward)n._currentTeleportationControllerId===t.xrController.uniqueId&&(n.rotationEnabled?setTimeout((function(){t.teleportationState.currentRotation=Math.atan2(i.x,i.y*(n._xrSessionManager.scene.useRightHandedSystem?1:-1))})):t.teleportationState.currentRotation=0);else if(!t.teleportationState.rotating&&Math.abs(i.x)>.7){t.teleportationState.rotating=!0;var o=n.rotationAngle*(i.x>0?1:-1)*(n._xrSessionManager.scene.useRightHandedSystem?-1:1);n._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(a.b.FromEulerAngles(0,o,0))}}else t.teleportationState.rotating=!1;0===i.x&&0===i.y&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}))}};e.motionController?i():e.onMotionControllerInitObservable.addOnce((function(){i()}))}else n._xrSessionManager.scene.onPointerObservable.add((function(i){i.type===Ne.a.POINTERDOWN?(t.teleportationState.forward=!0,n._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=n._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Qa({timeout:n._options.timeToTeleport||3e3,contextObservable:n._xrSessionManager.onXRFrameObservable,onEnded:function(){n._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&n._teleportForward(e.uniqueId)}})):i.type===Ne.a.POINTERUP&&(t.teleportationState.forward=!1,n._currentTeleportationControllerId="")}))}},n._options.teleportationTargetMesh||n._createDefaultTargetMesh(),n._floorMeshes=n._options.floorMeshes||[],n._snapToPositions=n._options.snapPositions||[],n._setTargetMeshVisibility(!1),n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"rotationEnabled",{get:function(){return this._rotationEnabled},set:function(e){if(this._rotationEnabled=e,this._options.teleportationTargetMesh){var t=this._options.teleportationTargetMesh.getChildMeshes(!1,(function(e){return"rotationCone"===e.name}));t[0]&&t[0].setEnabled(e)}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"teleportationTargetMesh",{get:function(){return this._options.teleportationTargetMesh||null},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"snapPointsOnly",{get:function(){return!!this._options.snapPointsOnly},set:function(e){this._options.snapPointsOnly=e},enumerable:!1,configurable:!0}),t.prototype.addFloorMesh=function(e){this._floorMeshes.push(e)},t.prototype.addSnapPoint=function(e){this._snapToPositions.push(e)},t.prototype.attach=function(){var t=this;return!!e.prototype.attach.call(this)&&(this._currentTeleportationControllerId="",this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(e){t._detachController(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach((function(e){t._detachController(e)})),this._setTargetMeshVisibility(!1),this._currentTeleportationControllerId="",this._controllers={},!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.dispose(!1,!0)},t.prototype.removeFloorMesh=function(e){var t=this._floorMeshes.indexOf(e);-1!==t&&this._floorMeshes.splice(t,1)},t.prototype.removeFloorMeshByName=function(e){var t=this._xrSessionManager.scene.getMeshByName(e);t&&this.removeFloorMesh(t)},t.prototype.removeSnapPoint=function(e){var t=this._snapToPositions.indexOf(e);if(-1===t)for(var i=0;i<this._snapToPositions.length;++i)if(this._snapToPositions[i].equals(e)){t=i;break}return-1!==t&&(this._snapToPositions.splice(t,1),!0)},t.prototype.setSelectionFeature=function(e){this._selectionFeature=e},t.prototype._onXRFrame=function(e){var t=this,i=this._xrSessionManager.currentFrame,n=this._xrSessionManager.scene;if(this.attach&&i){var r=this._options.teleportationTargetMesh;if(this._currentTeleportationControllerId){if(!r)return;r.rotationQuaternion=r.rotationQuaternion||new a.b;var o=this._controllers[this._currentTeleportationControllerId];if(o&&o.teleportationState.forward){a.b.RotationYawPitchRollToRef(o.teleportationState.currentRotation+o.teleportationState.baseRotation,0,0,r.rotationQuaternion);var s=!1;if(o.xrController.getWorldPointerRayToRef(this._tmpRay),this.straightRayEnabled){if((c=n.pickWithRay(this._tmpRay,(function(e){if(t._options.pickBlockerMeshes&&-1!==t._options.pickBlockerMeshes.indexOf(e))return!0;var i=t._floorMeshes.indexOf(e);return-1!==i&&t._floorMeshes[i].absolutePosition.y<t._options.xrInput.xrCamera.position.y})))&&c.pickedMesh&&this._options.pickBlockerMeshes&&-1!==this._options.pickBlockerMeshes.indexOf(c.pickedMesh))return;c&&c.pickedPoint&&(s=!0,this._setTargetMeshPosition(c.pickedPoint),this._setTargetMeshVisibility(!0),this._showParabolicPath(c))}if(this.parabolicRayEnabled&&!s){var c,l=o.xrController.pointer.rotationQuaternion.toEulerAngles().x,u=Math.PI/2-Math.abs(l)+1,h=this.parabolicCheckRadius*u;if(this._tmpRay.origin.addToRef(this._tmpRay.direction.scale(2*h),this._tmpVector),this._tmpVector.y=this._tmpRay.origin.y,this._tmpRay.origin.addInPlace(this._tmpRay.direction.scale(h)),this._tmpVector.subtractToRef(this._tmpRay.origin,this._tmpRay.direction),this._tmpRay.direction.normalize(),(c=n.pickWithRay(this._tmpRay,(function(e){return!(!t._options.pickBlockerMeshes||-1===t._options.pickBlockerMeshes.indexOf(e))||-1!==t._floorMeshes.indexOf(e)})))&&c.pickedMesh&&this._options.pickBlockerMeshes&&-1!==this._options.pickBlockerMeshes.indexOf(c.pickedMesh))return;c&&c.pickedPoint&&(s=!0,this._setTargetMeshPosition(c.pickedPoint),this._setTargetMeshVisibility(!0),this._showParabolicPath(c))}this._setTargetMeshVisibility(s)}else this._setTargetMeshVisibility(!1)}else this._setTargetMeshVisibility(!1)}},t.prototype._createDefaultTargetMesh=function(){this._options.defaultTargetMeshOptions=this._options.defaultTargetMeshOptions||{};var e=this._options.useUtilityLayer?this._options.customUtilityLayerScene||Cr.a.DefaultUtilityLayer.utilityLayerScene:this._xrSessionManager.scene,t=Ji.CreateGround("teleportationTarget",{width:2,height:2,subdivisions:2},e);t.isPickable=!1;var i=new Hi.a("teleportationPlaneDynamicTexture",512,e,!0);i.hasAlpha=!0;var n=i.getContext();n.beginPath(),n.arc(256,256,200,0,2*Math.PI,!1),n.fillStyle=this._options.defaultTargetMeshOptions.teleportationFillColor||"#444444",n.fill(),n.lineWidth=10,n.strokeStyle=this._options.defaultTargetMeshOptions.teleportationBorderColor||"#FFFFFF",n.stroke(),n.closePath(),i.update();var r=new Wi.a("teleportationPlaneMaterial",e);r.diffuseTexture=i,t.material=r;var o=tn.CreateTorus("torusTeleportation",{diameter:.75,thickness:.1,tessellation:20},e);if(o.isPickable=!1,o.parent=t,!this._options.defaultTargetMeshOptions.disableAnimation){var a=new z("animationInnerCircle","position.y",30,z.ANIMATIONTYPE_FLOAT,z.ANIMATIONLOOPMODE_CYCLE),c=[];c.push({frame:0,value:0}),c.push({frame:30,value:.4}),c.push({frame:60,value:0}),a.setKeys(c);var l=new me;l.setEasingMode(oe.EASINGMODE_EASEINOUT),a.setEasingFunction(l),o.animations=[],o.animations.push(a),e.beginAnimation(o,0,60,!0)}var u=nn.a.CreateCylinder("rotationCone",{diameterTop:0,tessellation:4},e);if(u.isPickable=!1,u.scaling.set(.5,.12,.2),u.rotate(J.a.X,Math.PI/2),u.position.z=.6,u.parent=o,this._options.defaultTargetMeshOptions.torusArrowMaterial)o.material=this._options.defaultTargetMeshOptions.torusArrowMaterial,u.material=this._options.defaultTargetMeshOptions.torusArrowMaterial;else{var h=new Wi.a("torusConsMat",e);h.disableLighting=!!this._options.defaultTargetMeshOptions.disableLighting,h.disableLighting?h.emissiveColor=new s.a(.3,.3,1):h.diffuseColor=new s.a(.3,.3,1),h.alpha=.9,o.material=h,u.material=h,this._teleportationRingMaterial=h}void 0!==this._options.renderingGroupId&&(t.renderingGroupId=this._options.renderingGroupId,o.renderingGroupId=this._options.renderingGroupId,u.renderingGroupId=this._options.renderingGroupId),this._options.teleportationTargetMesh=t},t.prototype._detachController=function(e){var t=this._controllers[e];t&&(t.teleportationComponent&&(t.onAxisChangedObserver&&t.teleportationComponent.onAxisValueChangedObservable.remove(t.onAxisChangedObserver),t.onButtonChangedObserver&&t.teleportationComponent.onButtonStateChangedObservable.remove(t.onButtonChangedObserver)),delete this._controllers[e])},t.prototype._findClosestSnapPointWithRadius=function(e,t){void 0===t&&(t=this._options.snapToPositionRadius||.8);var i=null,n=Number.MAX_VALUE;if(this._snapToPositions.length){var r=t*t;this._snapToPositions.forEach((function(t){var o=a.e.DistanceSquared(t,e);o<=r&&o<n&&(n=o,i=t)}))}return i},t.prototype._setTargetMeshPosition=function(e){if(this._options.teleportationTargetMesh){var t=this._findClosestSnapPointWithRadius(e);this._snappedToPoint=!!t,this.snapPointsOnly&&!this._snappedToPoint&&this._teleportationRingMaterial?this._teleportationRingMaterial.diffuseColor.set(1,.3,.3):this.snapPointsOnly&&this._snappedToPoint&&this._teleportationRingMaterial&&this._teleportationRingMaterial.diffuseColor.set(.3,.3,1),this._options.teleportationTargetMesh.position.copyFrom(t||e),this._options.teleportationTargetMesh.position.y+=.01}},t.prototype._setTargetMeshVisibility=function(e){this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.isVisible!==e&&(this._options.teleportationTargetMesh.isVisible=e,this._options.teleportationTargetMesh.getChildren(void 0,!1).forEach((function(t){t.isVisible=e})),e?this._selectionFeature&&this._selectionFeature.detach():(this._quadraticBezierCurve&&(this._quadraticBezierCurve.dispose(),this._quadraticBezierCurve=null),this._selectionFeature&&this._selectionFeature.attach()))},t.prototype._showParabolicPath=function(e){if(e.pickedPoint){var t=this._controllers[this._currentTeleportationControllerId],i=re.d.CreateQuadraticBezier(t.xrController.pointer.absolutePosition,e.ray.origin,e.pickedPoint,25);this._options.generateRayPathMesh?this._quadraticBezierCurve=this._options.generateRayPathMesh(i.getPoints()):this._quadraticBezierCurve=Or.a.CreateLines("teleportation path line",{points:i.getPoints(),instance:this._quadraticBezierCurve,updatable:!0}),this._quadraticBezierCurve.isPickable=!1}},t.prototype._teleportForward=function(e){var t=this._controllers[e];if(t&&t.teleportationState.forward&&(t.teleportationState.forward=!1,this._currentTeleportationControllerId="",(!this.snapPointsOnly||this._snappedToPoint)&&this._options.teleportationTargetMesh&&this._options.teleportationTargetMesh.isVisible)){var i=this._options.xrInput.xrCamera.realWorldHeight;this._options.xrInput.xrCamera.onBeforeCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position),this._options.xrInput.xrCamera.position.copyFrom(this._options.teleportationTargetMesh.position),this._options.xrInput.xrCamera.position.y+=i,this._options.xrInput.xrCamera.rotationQuaternion.multiplyInPlace(a.b.FromEulerAngles(0,t.teleportationState.currentRotation-(this._xrSessionManager.scene.useRightHandedSystem?Math.PI:0),0)),this._options.xrInput.xrCamera.onAfterCameraTeleport.notifyObservers(this._options.xrInput.xrCamera.position)}},t.Name=Ia.TELEPORTATION,t.Version=1,t}(ja);Da.AddWebXRFeature(Za.Name,(function(e,t){return function(){return new Za(e,t)}}),Za.Version,!0);var Ja=function(){},$a=function(){function e(){}return e.CreateAsync=function(t,i){void 0===i&&(i={});var n=new e;return Na.CreateAsync(t).then((function(e){if(n.baseExperience=e,i.ignoreNativeCameraTransformation&&(n.baseExperience.camera.compensateOnFirstFrame=!1),n.input=new Ga(e.sessionManager,e.camera,Object(h.a)({controllerOptions:{renderingGroupId:i.renderingGroupId}},i.inputOptions||{})),n.pointerSelection=n.baseExperience.featuresManager.enableFeature(Wa.Name,i.useStablePlugins?"stable":"latest",{xrInput:n.input,renderingGroupId:i.renderingGroupId}),i.disableTeleportation||(n.teleportation=n.baseExperience.featuresManager.enableFeature(Za.Name,i.useStablePlugins?"stable":"latest",{floorMeshes:i.floorMeshes,xrInput:n.input,renderingGroupId:i.renderingGroupId}),n.teleportation.setSelectionFeature(n.pointerSelection)),n.renderTarget=n.baseExperience.sessionManager.getWebXRRenderTarget(i.outputCanvasOptions),!i.disableDefaultUI){var r=Object(h.a)({renderTarget:n.renderTarget},i.uiOptions||{});return i.optionalFeatures&&("boolean"==typeof i.optionalFeatures?r.optionalFeatures=["hit-test","anchors","plane-detection","hand-tracking"]:r.optionalFeatures=i.optionalFeatures),Ka.CreateAsync(t,n.baseExperience,r).then((function(e){n.enterExitUI=e}))}})).then((function(){return n})).catch((function(e){return m.a.Error("Error initializing XR"),m.a.Error(e),n}))},e.prototype.dispose=function(){this.baseExperience&&this.baseExperience.dispose(),this.input&&this.input.dispose(),this.enterExitUI&&this.enterExitUI.dispose(),this.renderTarget&&this.renderTarget.dispose()},e}(),es=!0;Q.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 ki.a("default light",a.e.Up(),this)},Q.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 n,r=this.getWorldExtends((function(e){return e.isVisible&&e.isEnabled()})),o=r.max.subtract(r.min),s=r.min.add(o.scale(.5)),c=1.5*o.length();if(isFinite(c)||(c=1,s.copyFromFloats(0,0,0)),e){var l=new Bt("default camera",-Math.PI/2,Math.PI/2,c,s,this);l.lowerRadiusLimit=.01*c,l.wheelPrecision=100/c,n=l}else{var u=new wt("default camera",new a.e(s.x,s.y,-c),this);u.setTarget(s),n=u}n.minZ=.01*c,n.maxZ=1e3*c,n.speed=.2*c,this.activeCamera=n;var h=this.getEngine().getInputElement();i&&h&&n.attachControl()}},Q.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)},Q.a.prototype.createDefaultSkybox=function(e,t,i,n,r){if(void 0===t&&(t=!1),void 0===i&&(i=1e3),void 0===n&&(n=0),void 0===r&&(r=!0),!e)return m.a.Warn("Can not create default skybox without environment texture."),null;r&&e&&(this.environmentTexture=e);var o=be.a.CreateBox("hdrSkyBox",i,this);if(t){var a=new ma("skyBox",this);a.backFaceCulling=!1,a.reflectionTexture=e.clone(),a.reflectionTexture&&(a.reflectionTexture.coordinatesMode=Ke.a.SKYBOX_MODE),a.microSurface=1-n,a.disableLighting=!0,a.twoSidedLighting=!0,o.infiniteDistance=!0,o.material=a}else{var s=new Wi.a("skyBox",this);s.backFaceCulling=!1,s.reflectionTexture=e.clone(),s.reflectionTexture&&(s.reflectionTexture.coordinatesMode=Ke.a.SKYBOX_MODE),s.disableLighting=!0,o.infiniteDistance=!0,o.material=s}return o.isPickable=!1,o},Q.a.prototype.createDefaultEnvironment=function(e){return go?new go(e,this):null},Q.a.prototype.createDefaultVRExperience=function(e){return void 0===e&&(e={}),new dn(this,e)},Q.a.prototype.createDefaultXRExperienceAsync=function(e){return void 0===e&&(e={}),$a.CreateAsync(this,e).then((function(e){return e}))};var ts=function(e){function t(t,i,n,r,o,a,s){void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===s&&(s={autoPlay:!0,loop:!0,autoUpdateTexture:!0});var c=e.call(this,null,n,!r,o)||this;c._onUserActionRequestedObservable=null,c._stillImageCaptured=!1,c._displayingPosterTexture=!1,c._frameId=-1,c._currentSrc=null,c._createInternalTexture=function(){if(null!=c._texture){if(!c._displayingPosterTexture)return;c._texture.dispose(),c._displayingPosterTexture=!1}if(!c._getEngine().needPOTTextures||Ce.b.IsExponentOfTwo(c.video.videoWidth)&&Ce.b.IsExponentOfTwo(c.video.videoHeight)?(c.wrapU=Ke.a.WRAP_ADDRESSMODE,c.wrapV=Ke.a.WRAP_ADDRESSMODE):(c.wrapU=Ke.a.CLAMP_ADDRESSMODE,c.wrapV=Ke.a.CLAMP_ADDRESSMODE,c._generateMipMaps=!1),c._texture=c._getEngine().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,i=c.video.muted;c.video.muted=!0,c.video.onplaying=function(){c.video.muted=i,c.video.onplaying=e,c._texture.isReady=!0,c._updateInternalTexture(),t||c.video.pause(),c.onLoadObservable.hasObservers()&&c.onLoadObservable.notifyObservers(c)};var n=c.video.play();n?n.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(){if(null!=c._texture&&c._texture.isReady&&!(c.video.readyState<c.video.HAVE_CURRENT_DATA||c._displayingPosterTexture)){var e=c.getScene().getFrameId();c._frameId!==e&&(c._frameId=e,c._getEngine().updateVideoTexture(c._texture,c.video,c._invertY))}},c._generateMipMaps=r,c._initialSamplingMode=a,c.autoUpdateTexture=s.autoUpdateTexture,c._currentSrc=i,c.name=t||c._getName(i),c.video=c._getVideo(i),c._settings=s,s.poster&&(c.video.poster=s.poster),void 0!==s.autoPlay&&(c.video.autoplay=s.autoPlay),void 0!==s.loop&&(c.video.loop=s.loop),void 0!==s.muted&&(c.video.muted=s.muted),c.video.setAttribute("playsinline",""),c.video.addEventListener("paused",c._updateInternalTexture),c.video.addEventListener("seeked",c._updateInternalTexture),c.video.addEventListener("emptied",c.reset),c._createInternalTextureOnEvent=s.poster&&!s.autoPlay?"play":"canplay",c.video.addEventListener(c._createInternalTextureOnEvent,c._createInternalTexture),s.autoPlay&&c.video.play();var l=c.video.readyState>=c.video.HAVE_CURRENT_DATA;return!s.poster||s.autoPlay&&l?l&&c._createInternalTexture():(c._texture=c._getEngine().createTexture(s.poster,!1,!c.invertY,n),c._displayingPosterTexture=!0),c}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new o.c),this._onUserActionRequestedObservable},enumerable:!1,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 Ce.b.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(Ce.b.SetCorsBehavior(e,t),t.src=e):(Ce.b.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,this._currentSrc=e},t.prototype.clone=function(){return new t(this.name,this._currentSrc,this.getScene(),this._generateMipMaps,this.invertY,this.samplingMode,this._settings)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._currentSrc=null,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.CreateFromStreamAsync=function(e,i){var n=document.createElement("video");return e.getEngine()._badOS&&(document.body.appendChild(n),n.style.transform="scale(0.0001, 0.0001)",n.style.opacity="0",n.style.position="fixed",n.style.bottom="0px",n.style.right="0px"),n.setAttribute("autoplay",""),n.setAttribute("muted","true"),n.setAttribute("playsinline",""),n.muted=!0,void 0!==n.mozSrcObject?n.mozSrcObject=i:"object"==typeof n.srcObject?n.srcObject=i:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,n.src=window.URL&&window.URL.createObjectURL(i)),new Promise((function(i){var r=function(){i(new t("video",n,e,!0,!0)),n.removeEventListener("playing",r)};n.addEventListener("playing",r),n.play()}))},t.CreateFromWebCamAsync=function(e,t,i){var n,r=this;return void 0===i&&(i=!1),t&&t.deviceId&&(n={exact:t.deviceId}),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:t,audio:i}).then((function(t){return r.CreateFromStreamAsync(e,t)})):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:n,width:{min:t&&t.minWidth||256,max:t&&t.maxWidth||640},height:{min:t&&t.minHeight||256,max:t&&t.maxHeight||480}},audio:i},(function(t){return r.CreateFromStreamAsync(e,t)}),(function(e){m.a.Error(e.name)})),Promise.reject("No support for userMedia on this device"))},t.CreateFromWebCam=function(e,t,i,n){void 0===n&&(n=!1),this.CreateFromWebCamAsync(e,i,n).then((function(e){t&&t(e)})).catch((function(e){m.a.Error(e.name)}))},t}(Ke.a),is=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._texture},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"videoMode",{get:function(){return this.textureMode},set:function(e){this.textureMode=e},enumerable:!1,configurable:!0}),t.prototype._initTexture=function(e,t,i){var n=this,r={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},o=new ts((this.name||"videoDome")+"_texture",e,t,i.generateMipMaps,this._useDirectMapping,Ke.a.TRILINEAR_SAMPLINGMODE,r);return i.clickToPlay&&(t.onPointerUp=function(){n._texture.video.play()}),o},t.MODE_MONOSCOPIC=vo.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=vo.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=vo.MODE_SIDEBYSIDE,t}(vo),ns=i(55),rs=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new ns.a,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new ns.a,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!1,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:!1,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}(),os=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new ns.a,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new ns.a,this._captureFrameTime=!1,this._frameTime=new ns.a,this._captureRenderTime=!1,this._renderTime=new ns.a,this._captureInterFrameTime=!1,this._interFrameTime=new ns.a,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new ns.a,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new ns.a,this._capturePhysicsTime=!1,this._physicsTime=new ns.a,this._captureAnimationsTime=!1,this._animationsTime=new ns.a,this._captureCameraRenderTime=!1,this._cameraRenderTime=new ns.a,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&&(Ce.b.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()})),this._onAfterRenderObserver=e.onAfterRenderObservable.add((function(){t._captureFrameTime&&(Ce.b.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:!1,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(){Ce.b.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Ce.b.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!1,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(){Ce.b.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Ce.b.EndPerformanceCounter("Physics"),t._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!1,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(),Ce.b.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Ce.b.EndPerformanceCounter("Main render")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!1,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(),Ce.b.StartPerformanceCounter("Rendering camera "+e.name)})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Ce.b.EndPerformanceCounter("Rendering camera "+e.name)}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!1,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}(),as="#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\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\nvoid main(void)\n{\nvec4 finalColor=glowColor;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\n#ifdef GLOW\n\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef HIGHLIGHT\n\nfinalColor.a=albedoTexture.a;\n#endif\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 HIGHLIGHT\n\ngl_FragColor.a=glowColor.a;\n#endif\n}";ai.a.ShadersStore.glowMapGenerationPixelShader=as;var ss="\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#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\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(uvUpdated,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(uvUpdated,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(uvUpdated,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}";ai.a.ShadersStore.glowMapGenerationVertexShader=ss;var cs=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 s.b},this.neutralColor=new s.b,this.isEnabled=!0,this.disableBoundingBoxesFromEffectLayer=!1,this.onDisposeObservable=new o.c,this.onBeforeRenderMainTextureObservable=new o.c,this.onBeforeComposeObservable=new o.c,this.onBeforeRenderMeshToEffect=new o.c,this.onAfterRenderMeshToEffect=new o.c,this.onAfterComposeObservable=new o.c,this.onSizeChangedObservable=new o.c,this.name=t,this._scene=i||x.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._generateVertexBuffer()}return Object.defineProperty(e.prototype,"camera",{get:function(){return this._effectLayerOptions.camera},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._effectLayerOptions.renderingGroupId},set:function(e){this._effectLayerOptions.renderingGroupId=e},enumerable:!1,configurable:!0}),e.prototype._init=function(e){this._effectLayerOptions=Object(h.a)({mainTextureRatio:.5,alphaBlendingMode:g.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._generateVertexBuffer=function(){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1);var t=new Qi.b(this._engine,e,Qi.b.PositionKind,!1,!1,2);this._vertexBuffers[Qi.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?Se.a.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?Se.a.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 Ni("HighlightLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,g.a.TEXTURETYPE_UNSIGNED_INT),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.customRenderFunction=function(t,i,n,r){var o;e.onBeforeRenderMainTextureObservable.notifyObservers(e);var a=e._scene.getEngine();if(r.length){for(a.setColorWrite(!1),o=0;o<r.length;o++)e._renderSubMesh(r.data[o]);a.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]);var s=a.getAlphaMode();for(o=0;o<n.length;o++)e._renderSubMesh(n.data[o],!0);a.setAlphaMode(s)},this._mainTexture.onClearObservable.add((function(t){t.clear(e.neutralColor,!0,!0,!0)}));var t=this._scene.getBoundingBoxRenderer().enabled;this._mainTexture.onBeforeBindObservable.add((function(){e._scene.getBoundingBoxRenderer().enabled=!e.disableBoundingBoxesFromEffectLayer&&t})),this._mainTexture.onAfterUnbindObservable.add((function(){e._scene.getBoundingBoxRenderer().enabled=t}))},e.prototype._addCustomEffectDefines=function(e){},e.prototype._isReady=function(e,t,i){var n=e.getMaterial();if(!n)return!1;if(!n.isReadyForSubMesh(e.getMesh(),e,t))return!1;var r=[],o=[Qi.b.PositionKind],a=e.getMesh(),s=!1,c=!1;if(n){var l=n.needAlphaTesting(),u=n.getAlphaTestTexture(),h=u&&u.hasAlpha&&(n.useAlphaFromDiffuseTexture||n._useAlphaFromAlbedoTexture);u&&(l||h)&&(r.push("#define DIFFUSE"),a.isVerticesDataPresent(Qi.b.UV2Kind)&&1===u.coordinatesIndex?(r.push("#define DIFFUSEUV2"),c=!0):a.isVerticesDataPresent(Qi.b.UVKind)&&(r.push("#define DIFFUSEUV1"),s=!0),l&&(r.push("#define ALPHATEST"),r.push("#define ALPHATESTVALUE 0.4")));var d=n.opacityTexture;d&&(r.push("#define OPACITY"),a.isVerticesDataPresent(Qi.b.UV2Kind)&&1===d.coordinatesIndex?(r.push("#define OPACITYUV2"),c=!0):a.isVerticesDataPresent(Qi.b.UVKind)&&(r.push("#define OPACITYUV1"),s=!0))}i&&(r.push("#define EMISSIVE"),a.isVerticesDataPresent(Qi.b.UV2Kind)&&1===i.coordinatesIndex?(r.push("#define EMISSIVEUV2"),c=!0):a.isVerticesDataPresent(Qi.b.UVKind)&&(r.push("#define EMISSIVEUV1"),s=!0)),a.isVerticesDataPresent(Qi.b.ColorKind)&&a.hasVertexAlpha&&(o.push(Qi.b.ColorKind),r.push("#define VERTEXALPHA")),s&&(o.push(Qi.b.UVKind),r.push("#define UV1")),c&&(o.push(Qi.b.UV2Kind),r.push("#define UV2"));var f=new po.a;if(a.useBones&&a.computeBonesUsingShaders){o.push(Qi.b.MatricesIndicesKind),o.push(Qi.b.MatricesWeightsKind),a.numBoneInfluencers>4&&(o.push(Qi.b.MatricesIndicesExtraKind),o.push(Qi.b.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers);var p=a.skeleton;p&&p.isUsingTextureForMatrices?r.push("#define BONETEXTURE"):r.push("#define BonesPerMesh "+(p?p.bones.length+1:0)),a.numBoneInfluencers>0&&f.addCPUSkinningFallback(0,a)}else r.push("#define NUM_BONE_INFLUENCERS 0");var _=a.morphTargetManager,m=0;_&&_.numInfluencers>0&&(r.push("#define MORPHTARGETS"),m=_.numInfluencers,r.push("#define NUM_MORPH_INFLUENCERS "+m),ro.a.PrepareAttributesForMorphTargetsInfluencers(o,a,m)),t&&(r.push("#define INSTANCES"),ro.a.PushAttributesForInstances(o),e.getRenderingMesh().hasThinInstances&&r.push("#define THIN_INSTANCES")),this._addCustomEffectDefines(r);var g=r.join("\n");return this._cachedDefines!==g&&(this._cachedDefines=g,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","glowColor","morphTargetInfluences","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity"],["diffuseSampler","emissiveSampler","opacitySampler","boneSampler"],g,f,void 0,void 0,{maxSimultaneousMorphTargets:m})),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 n=i.getAlphaMode();i.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),this._internalRender(e),i.setAlphaMode(n),this.onAfterComposeObservable.notifyObservers(this);var r=this._mainTexture.getSize();this._setMainTextureSize(),r.width===this._mainTextureDesiredSize.width&&r.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,t){var i,n=this;if(void 0===t&&(t=!1),this.shouldRender()){var r=e.getMaterial(),o=e.getMesh(),a=e.getReplacementMesh(),s=e.getRenderingMesh(),c=e.getEffectiveMesh(),l=this._scene,u=l.getEngine();if(c._internalAbstractMeshDataInfo._isActiveIntermediate=!1,r&&this._canRenderMesh(s,r)){var h=null!==(i=s.overrideMaterialSideOrientation)&&void 0!==i?i:r.sideOrientation;s._getWorldMatrixDeterminant()<0&&(h=h===xo.a.ClockWiseSideOrientation?xo.a.CounterClockWiseSideOrientation:xo.a.ClockWiseSideOrientation);var d=h===xo.a.ClockWiseSideOrientation;u.setState(r.backFaceCulling,r.zOffset,void 0,d);var f=s._getInstancesRenderList(e._id,!!a);if(!f.mustReturn&&this._shouldRenderMesh(s)){var p=f.hardwareInstancedRendering[e._id]||s.hasThinInstances;if(this._setEmissiveTextureAndColor(s,e,r),this.onBeforeRenderMeshToEffect.notifyObservers(o),this._useMeshMaterial(s))s.render(e,p,a||void 0);else if(this._isReady(e,p,this._emissiveTextureAndColor.texture)){u.enableEffect(this._effectLayerMapGenerationEffect),s._bind(e,this._effectLayerMapGenerationEffect,xo.a.TriangleFillMode),this._effectLayerMapGenerationEffect.setMatrix("viewProjection",l.getTransformMatrix()),this._effectLayerMapGenerationEffect.setMatrix("world",c.getWorldMatrix()),this._effectLayerMapGenerationEffect.setFloat4("glowColor",this._emissiveTextureAndColor.color.r,this._emissiveTextureAndColor.color.g,this._emissiveTextureAndColor.color.b,this._emissiveTextureAndColor.color.a);var _=r.needAlphaTesting(),m=r.getAlphaTestTexture(),g=m&&m.hasAlpha&&(r.useAlphaFromDiffuseTexture||r._useAlphaFromAlbedoTexture);if(m&&(_||g))this._effectLayerMapGenerationEffect.setTexture("diffuseSampler",m),(v=m.getTextureMatrix())&&this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix",v);var v,b=r.opacityTexture;if(b)this._effectLayerMapGenerationEffect.setTexture("opacitySampler",b),this._effectLayerMapGenerationEffect.setFloat("opacityIntensity",b.level),(v=b.getTextureMatrix())&&this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix",v);if(this._emissiveTextureAndColor.texture&&(this._effectLayerMapGenerationEffect.setTexture("emissiveSampler",this._emissiveTextureAndColor.texture),this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix",this._emissiveTextureAndColor.texture.getTextureMatrix())),s.useBones&&s.computeBonesUsingShaders&&s.skeleton){var y=s.skeleton;if(y.isUsingTextureForMatrices){var T=y.getTransformMatrixTexture(s);if(!T)return;this._effectLayerMapGenerationEffect.setTexture("boneSampler",T),this._effectLayerMapGenerationEffect.setFloat("boneTextureWidth",4*(y.bones.length+1))}else this._effectLayerMapGenerationEffect.setMatrices("mBones",y.getTransformMatrices(s))}ro.a.BindMorphTargetParameters(s,this._effectLayerMapGenerationEffect),t&&u.setAlphaMode(r.alphaMode),s._processRendering(c,e,this._effectLayerMapGenerationEffect,r.fillMode,f,p,(function(e,t){return n._effectLayerMapGenerationEffect.setMatrix("world",t)}))}else this._mainTexture.resetRefreshCounter();this.onAfterRenderMeshToEffect.notifyObservers(o)}}}},e.prototype._useMeshMaterial=function(e){return!1},e.prototype._rebuild=function(){var e=this._vertexBuffers[Qi.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[Qi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[Qi.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.onBeforeRenderMeshToEffect.clear(),this.onAfterRenderMeshToEffect.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},e.prototype.getClassName=function(){return"EffectLayer"},e.Parse=function(e,t,i){return Ce.b.Instantiate(e.customType).Parse(e,t,i)},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("EffectLayerSceneComponent")},Object(h.c)([Object(w.c)()],e.prototype,"name",void 0),Object(h.c)([Object(w.f)()],e.prototype,"neutralColor",void 0),Object(h.c)([Object(w.c)()],e.prototype,"isEnabled",void 0),Object(h.c)([Object(w.d)()],e.prototype,"camera",null),Object(h.c)([Object(w.c)()],e.prototype,"renderingGroupId",null),Object(h.c)([Object(w.c)()],e.prototype,"disableBoundingBoxesFromEffectLayer",void 0),e}();n.a.AddParser(Me.a.NAME_EFFECTLAYER,(function(e,t,i,n){if(e.effectLayers){i.effectLayers||(i.effectLayers=new Array);for(var r=0;r<e.effectLayers.length;r++){var o=cs.Parse(e.effectLayers[r],t,n);i.effectLayers.push(o)}}})),n.a.prototype.removeEffectLayer=function(e){var t=this.effectLayers.indexOf(e);return-1!==t&&this.effectLayers.splice(t,1),t},n.a.prototype.addEffectLayer=function(e){this.effectLayers.push(e)};var ls=function(){function e(e){this.name=Me.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(Me.a.STEP_ISREADYFORMESH_EFFECTLAYER,this,this._isReadyForMesh),this.scene._cameraDrawRenderTargetStage.registerStep(Me.a.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER,this,this._renderMainTexture),this.scene._beforeCameraDrawStage.registerStep(Me.a.STEP_BEFORECAMERADRAW_EFFECTLAYER,this,this._setStencil),this.scene._afterRenderingGroupDrawStage.registerStep(Me.a.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW,this,this._drawRenderingGroup),this.scene._afterCameraDrawStage.registerStep(Me.a.STEP_AFTERCAMERADRAW_EFFECTLAYER,this,this._setStencilBack),this.scene._afterCameraDrawStage.registerStep(Me.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 n=i[t];n.serialize&&e.effectLayers.push(n.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,t){var i=this;e.effectLayers&&e.effectLayers.forEach((function(e){i.scene.removeEffectLayer(e),t&&e.dispose()}))},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,n=this.scene.effectLayers;i<n.length;i++){var r=n[i];if(r.hasMesh(e))for(var o=0,a=e.subMeshes;o<a.length;o++){var s=a[o];if(!r.isReady(s,t))return!1}}return!0},e.prototype._renderMainTexture=function(e){this._renderEffects=!1,this._needStencil=!1;var t=!1,i=this.scene.effectLayers;if(i&&i.length>0){this._previousStencilState=this._engine.getStencilBuffer();for(var n=0,r=i;n<r.length;n++){var o=r[n];if(o.shouldRender()&&(!o.camera||o.camera.cameraRigMode===je.a.RIG_MODE_NONE&&e===o.camera||o.camera.cameraRigMode!==je.a.RIG_MODE_NONE&&o.camera._rigCameras.indexOf(e)>-1)){this._renderEffects=!0,this._needStencil=this._needStencil||o.needStencil();var a=o._mainTexture;a._shouldRender()&&(this.scene.incrementRenderId(),a.render(!1,!1),t=!0)}}this.scene.incrementRenderId()}return t},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 n=t[i];n.renderingGroupId===e&&n.shouldRender()&&n.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}();cs._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_EFFECTLAYER);t||(t=new ls(e),e._addComponent(t))};var us="\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}";ai.a.ShadersStore.glowMapMergePixelShader=us;var hs="\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}";ai.a.ShadersStore.glowMapMergeVertexShader=hs;n.a.prototype.getGlowLayerByName=function(e){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===e&&this.effectLayers[t].getEffectName()===ds.EffectName)return this.effectLayers[t];return null};var ds=function(e){function t(i,n,r){var o=e.call(this,i,n)||this;return o._intensity=1,o._includedOnlyMeshes=[],o._excludedMeshes=[],o._meshesUsingTheirOwnMaterials=[],o.neutralColor=new s.b(0,0,0,1),o._options=Object(h.a)({mainTextureRatio:t.DefaultTextureRatio,blurKernelSize:32,mainTextureFixedSize:void 0,camera:null,mainTextureSamples:1,renderingGroupId:-1},r),o._init({alphaBlendingMode:g.a.ALPHA_ADD,camera:o._options.camera,mainTextureFixedSize:o._options.mainTextureFixedSize,mainTextureRatio:o._options.mainTextureRatio,renderingGroupId:o._options.renderingGroupId}),o}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!1,configurable:!0}),t.prototype.getEffectName=function(){return t.EffectName},t.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[Qi.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?Se.a.GetExponentOfTwo(t,this._maxSize):t,i=this._engine.needPOTTextures?Se.a.GetExponentOfTwo(i,this._maxSize):i;var n=0;n=this._engine.getCaps().textureHalfFloatRender?g.a.TEXTURETYPE_HALF_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INT,this._blurTexture1=new Ni("GlowLayerBlurRTT",{width:t,height:i},this._scene,!1,!0,n),this._blurTexture1.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;var r=Math.floor(t/2),o=Math.floor(i/2);this._blurTexture2=new Ni("GlowLayerBlurRTT2",{width:r,height:o},this._scene,!1,!0,n),this._blurTexture2.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2],this._horizontalBlurPostprocess1=new eo("GlowLayerHBP1",new a.d(1,0),this._options.blurKernelSize/2,{width:t,height:i},null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._horizontalBlurPostprocess1.width=t,this._horizontalBlurPostprocess1.height=i,this._horizontalBlurPostprocess1.onApplyObservable.add((function(t){t.setTexture("textureSampler",e._mainTexture)})),this._verticalBlurPostprocess1=new eo("GlowLayerVBP1",new a.d(0,1),this._options.blurKernelSize/2,{width:t,height:i},null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._horizontalBlurPostprocess2=new eo("GlowLayerHBP2",new a.d(1,0),this._options.blurKernelSize/2,{width:r,height:o},null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._horizontalBlurPostprocess2.width=r,this._horizontalBlurPostprocess2.height=o,this._horizontalBlurPostprocess2.onApplyObservable.add((function(t){t.setTexture("textureSampler",e._blurTexture1)})),this._verticalBlurPostprocess2=new eo("GlowLayerVBP2",new a.d(0,1),this._options.blurKernelSize/2,{width:r,height:o},null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),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();if(t){e._scene.postProcessManager.directRender(e._postProcesses1,t,!0);var i=e._blurTexture2.getInternalTexture();i&&e._scene.postProcessManager.directRender(e._postProcesses2,i,!0),e._engine.unBindFramebuffer(null!=i?i:t,!0)}})),this._postProcesses.map((function(e){e.autoClear=!1}))},t.prototype.isReady=function(t,i){var n=t.getMaterial(),r=t.getRenderingMesh();if(!n||!r)return!1;var o=n.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(xo.a.TriangleFillMode,0,6),t.setStencilBuffer(i)},t.prototype._setEmissiveTextureAndColor=function(e,t,i){var n=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(n=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*n,i.emissiveColor.g*n,i.emissiveColor.b*n,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._useMeshMaterial=function(e){return 0!=this._meshesUsingTheirOwnMaterials.length&&this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId)>-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){this._meshesUsingTheirOwnMaterials.push(e.uniqueId)},t.prototype.unReferenceMeshFromUsingItsOwnMaterial=function(e){for(var t=this._meshesUsingTheirOwnMaterials.indexOf(e.uniqueId);t>=0;)this._meshesUsingTheirOwnMaterials.splice(t,1),t=this._meshesUsingTheirOwnMaterials.indexOf(e.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,n){var r,o=w.a.Parse((function(){return new t(e.name,i,e.options)}),e,i,n);for(r=0;r<e.excludedMeshes.length;r++){(a=i.getMeshByID(e.excludedMeshes[r]))&&o.addExcludedMesh(a)}for(r=0;r<e.includedMeshes.length;r++){var a;(a=i.getMeshByID(e.includedMeshes[r]))&&o.addIncludedOnlyMesh(a)}return o},t.EffectName="GlowLayer",t.DefaultBlurKernelSize=32,t.DefaultTextureRatio=.5,Object(h.c)([Object(w.c)()],t.prototype,"blurKernelSize",null),Object(h.c)([Object(w.c)()],t.prototype,"intensity",null),Object(h.c)([Object(w.c)("options")],t.prototype,"_options",void 0),t}(cs);c.a.RegisteredTypes["BABYLON.GlowLayer"]=ds;var fs="\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}";ai.a.ShadersStore.glowBlurPostProcessPixelShader=fs;n.a.prototype.getHighlightLayerByName=function(e){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===e&&this.effectLayers[t].getEffectName()===_s.EffectName)return this.effectLayers[t];return null};var ps=function(e){function t(t,i,n,r,o,a,s,c){void 0===a&&(a=Ke.a.BILINEAR_SAMPLINGMODE);var l=e.call(this,t,"glowBlurPostProcess",["screenSize","direction","blurWidth"],null,r,o,a,s,c)||this;return l.direction=i,l.kernel=n,l.onApplyObservable.add((function(e){e.setFloat2("screenSize",l.width,l.height),e.setVector2("direction",l.direction),e.setFloat("blurWidth",l.kernel)})),l}return Object(h.d)(t,e),t}(li),_s=function(e){function t(i,n,r){var a=e.call(this,i,n)||this;return a.name=i,a.innerGlow=!0,a.outerGlow=!0,a.onBeforeBlurObservable=new o.c,a.onAfterBlurObservable=new o.c,a._instanceGlowingMeshStencilReference=t.GlowingMeshStencilReference++,a._meshes={},a._excludedMeshes={},a.neutralColor=t.NeutralColor,a._engine.isStencilEnable||m.a.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new Engine(canvas, antialias, { stencil: true }"),a._options=Object(h.a)({mainTextureRatio:.5,blurTextureSizeRatio:.5,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:g.a.ALPHA_COMBINE,camera:null,renderingGroupId:-1},r),a._init({alphaBlendingMode:a._options.alphaBlendingMode,camera:a._options.camera,mainTextureFixedSize:a._options.mainTextureFixedSize,mainTextureRatio:a._options.mainTextureRatio,renderingGroupId:a._options.renderingGroupId}),a._shouldRender=!1,a}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"blurHorizontalSize",{get:function(){return this._horizontalBlurPostprocess.kernel},set:function(e){this._horizontalBlurPostprocess.kernel=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurVerticalSize",{get:function(){return this._verticalBlurPostprocess.kernel},set:function(e){this._verticalBlurPostprocess.kernel=e},enumerable:!1,configurable:!0}),t.prototype.getEffectName=function(){return t.EffectName},t.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[Qi.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?Se.a.GetExponentOfTwo(t,this._maxSize):t,i=this._engine.needPOTTextures?Se.a.GetExponentOfTwo(i,this._maxSize):i;var n=0;n=this._engine.getCaps().textureHalfFloatRender?g.a.TEXTURETYPE_HALF_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INT,this._blurTexture=new Ni("HighlightLayerBlurRTT",{width:t,height:i},this._scene,!1,!0,n),this._blurTexture.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(Ke.a.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._options.alphaBlendingMode===g.a.ALPHA_COMBINE?(this._downSamplePostprocess=new di("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._downSamplePostprocess.onApplyObservable.add((function(t){t.setTexture("textureSampler",e._mainTexture)})),this._horizontalBlurPostprocess=new ps("HighlightLayerHBP",new a.d(1,0),this._options.blurHorizontalSize,1,null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._horizontalBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",t,i)})),this._verticalBlurPostprocess=new ps("HighlightLayerVBP",new a.d(0,1),this._options.blurVerticalSize,1,null,Ke.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 eo("HighlightLayerHBP",new a.d(1,0),this._options.blurHorizontalSize/2,{width:t,height:i},null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._horizontalBlurPostprocess.width=t,this._horizontalBlurPostprocess.height=i,this._horizontalBlurPostprocess.onApplyObservable.add((function(t){t.setTexture("textureSampler",e._mainTexture)})),this._verticalBlurPostprocess=new eo("HighlightLayerVBP",new a.d(0,1),this._options.blurVerticalSize/2,{width:t,height:i},null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),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._engine.unBindFramebuffer(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 n=t.getMaterial(),r=t.getRenderingMesh();if(!n||!r||!this._meshes)return!1;var o=null,a=this._meshes[r.uniqueId];return a&&a.glowEmissiveOnly&&n&&(o=n.emissiveTexture),e.prototype._isReady.call(this,t,i,o)},t.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture);var t=this._engine;t.cacheStencilState(),t.setStencilOperationPass(g.a.REPLACE),t.setStencilOperationFail(g.a.KEEP),t.setStencilOperationDepthFail(g.a.KEEP),t.setStencilMask(0),t.setStencilBuffer(!0),t.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(e.setFloat("offset",0),t.setStencilFunction(g.a.NOTEQUAL),t.drawElementsType(xo.a.TriangleFillMode,0,6)),this.innerGlow&&(e.setFloat("offset",1),t.setStencilFunction(g.a.EQUAL),t.drawElementsType(xo.a.TriangleFillMode,0,6)),t.restoreStencilState()},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._canRenderMesh=function(e,t){return!0},t.prototype._addCustomEffectDefines=function(e){e.push("#define HIGHLIGHT")},t.prototype._setEmissiveTextureAndColor=function(e,t,i){var n=this._meshes[e.uniqueId];n?this._emissiveTextureAndColor.color.set(n.color.r,n.color.g,n.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),n&&n.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 n=this;if(void 0===i&&(i=!1),this._meshes){var r=this._meshes[e.uniqueId];r?r.color=t:(this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeBindObservable.add((function(e){n.isEnabled&&(n._excludedMeshes&&n._excludedMeshes[e.uniqueId]?n._defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(n._instanceGlowingMeshStencilReference))})),observerDefault:e.onAfterRenderObservable.add((function(e){n.isEnabled&&n._defaultStencilReference(e)})),glowEmissiveOnly:i},e.onDisposeObservable.add((function(){n._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.removeAllMeshes=function(){if(this._meshes)for(var e in this._meshes)if(this._meshes.hasOwnProperty(e)){var t=this._meshes[e];t&&this.removeMesh(t.mesh)}},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 n in this._excludedMeshes){var r=this._excludedMeshes[n];r&&e.excludedMeshes.push(r.mesh.id)}return e},t.Parse=function(e,i,n){var r,o=w.a.Parse((function(){return new t(e.name,i,e.options)}),e,i,n);for(r=0;r<e.excludedMeshes.length;r++){(a=i.getMeshByID(e.excludedMeshes[r]))&&o.addExcludedMesh(a)}for(r=0;r<e.meshes.length;r++){var a,c=e.meshes[r];(a=i.getMeshByID(c.meshId))&&o.addMesh(a,s.a.FromArray(c.color),c.glowEmissiveOnly)}return o},t.EffectName="HighlightLayer",t.NeutralColor=new s.b(0,0,0,0),t.GlowingMeshStencilReference=2,t.NormalMeshStencilReference=1,Object(h.c)([Object(w.c)()],t.prototype,"innerGlow",void 0),Object(h.c)([Object(w.c)()],t.prototype,"outerGlow",void 0),Object(h.c)([Object(w.c)()],t.prototype,"blurHorizontalSize",null),Object(h.c)([Object(w.c)()],t.prototype,"blurVerticalSize",null),Object(h.c)([Object(w.c)("options")],t.prototype,"_options",void 0),t}(cs);c.a.RegisteredTypes["BABYLON.HighlightLayer"]=_s;var ms=function(){function e(e){this.name=Me.a.NAME_LAYER,this.scene=e,this._engine=e.getEngine(),e.layers=new Array}return e.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(Me.a.STEP_BEFORECAMERADRAW_LAYER,this,this._drawCameraBackground),this.scene._afterCameraDrawStage.registerStep(Me.a.STEP_AFTERCAMERADRAW_LAYER,this,this._drawCameraForeground),this.scene._beforeRenderTargetDrawStage.registerStep(Me.a.STEP_BEFORERENDERTARGETDRAW_LAYER,this,this._drawRenderTargetBackground),this.scene._afterRenderTargetDrawStage.registerStep(Me.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,n=t;i<n.length;i++){var r=n[i];e(r)&&r.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,n){return e.renderTargetTextures.length>0&&e.isBackground===t&&e.renderTargetTextures.indexOf(n)>-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.prototype.addFromContainer=function(e){var t=this;e.layers&&e.layers.forEach((function(e){t.scene.layers.push(e)}))},e.prototype.removeFromContainer=function(e,t){var i=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var n=i.scene.layers.indexOf(e);-1!==n&&i.scene.layers.splice(n,1),t&&e.dispose()}))},e}(),gs="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\n\n#include<helperFunctions>\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef LINEAR\nbaseColor.rgb=toGammaSpace(baseColor.rgb);\n#endif\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}";ai.a.ShadersStore.layerPixelShader=gs;var vs="\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}";ai.a.ShadersStore.layerVertexShader=vs;var bs=function(){function e(e,t,i,n,r){this.name=e,this.scale=new a.d(1,1),this.offset=new a.d(0,0),this.alphaBlendingMode=g.a.ALPHA_COMBINE,this.layerMask=268435455,this.renderTargetTextures=[],this.renderOnlyInRenderTargetTextures=!1,this._vertexBuffers={},this.onDisposeObservable=new o.c,this.onBeforeRenderObservable=new o.c,this.onAfterRenderObservable=new o.c,this.texture=t?new Ke.a(t,i,!0):null,this.isBackground=void 0===n||n,this.color=void 0===r?new s.b(1,1,1,1):r,this._scene=i||x.a.LastCreatedScene;var c=this._scene._getComponent(Me.a.NAME_LAYER);c||(c=new ms(this._scene),this._scene._addComponent(c)),this._scene.layers.push(this);var l=this._scene.getEngine(),u=[];u.push(1,1),u.push(-1,1),u.push(-1,-1),u.push(1,-1);var h=new Qi.b(l,u,Qi.b.PositionKind,!1,!1,2);this._vertexBuffers[Qi.b.PositionKind]=h,this._createIndexBuffer()}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!1,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[Qi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){var e=this._scene.getEngine(),t="";this.alphaTest&&(t="#define ALPHATEST"),this.texture&&!this.texture.gammaSpace&&(t+="\r\n#define LINEAR"),this._previousDefines!==t&&(this._previousDefines=t,this._effect=e.createEffect("layer",[Qi.b.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],t));var i=this._effect;if(i&&i.isReady()&&this.texture&&this.texture.isReady()){e=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(i),e.setState(!1),i.setTexture("textureSampler",this.texture),i.setMatrix("textureMatrix",this.texture.getTextureMatrix()),i.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),i.setVector2("offset",this.offset),i.setVector2("scale",this.scale),e.bindBuffers(this._vertexBuffers,this._indexBuffer,i),this.alphaTest?e.drawElementsType(xo.a.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(xo.a.TriangleFillMode,0,6),e.setAlphaMode(g.a.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[Qi.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}(),ys=function(){function e(e,t,i,n,r){this.size=e,this.position=t,this.alphaMode=g.a.ALPHA_ONEONE,this.color=i||new s.a(1,1,1),this.texture=n?new Ke.a(n,r.getScene(),!0):null,this._system=r,r.lensFlares.push(this)}return e.AddFlare=function(t,i,n,r,o){return new e(t,i,n,r,o)},e.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},e}(),Ts="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}";ai.a.ShadersStore.lensFlarePixelShader=Ts;var Es="\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}";ai.a.ShadersStore.lensFlareVertexShader=Es;var Ss=function(){function e(t,i,n){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=n||x.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=i,this.id=t,n.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return n.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&n.activeCamera.layerMask)};var r=n.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[Qi.b.PositionKind]=new Qi.b(r,o,Qi.b.PositionKind,!1,!1,2);var a=[];a.push(0),a.push(1),a.push(2),a.push(0),a.push(2),a.push(3),this._indexBuffer=r.createIndexBuffer(a),this._effect=r.createEffect("lensFlare",[Qi.b.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!1,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=a.e.Project(t,a.a.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=a.e.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 Xt.a(this._scene.activeCamera.globalPosition,e),n=this._scene.pickWithRay(i,this.meshesSelectionPredicate,!0);return!n||!n.hit||n.distance>t},e.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var e,t,i=this._scene.getEngine(),n=this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0),i.getRenderHeight(!0));if(!this.computeEffectivePosition(n))return!1;if(!this._isVisible())return!1;var r=(e=this._positionX<this.borderLimit+n.x?this.borderLimit+n.x-this._positionX:this._positionX>n.x+n.width-this.borderLimit?this._positionX-n.x-n.width+this.borderLimit:0)>(t=this._positionY<this.borderLimit+n.y?this.borderLimit+n.y-this._positionY:this._positionY>n.y+n.height-this.borderLimit?this._positionY-n.y-n.height+this.borderLimit:0)?e:t;(r-=this.viewportBorder)>this.borderLimit&&(r=this.borderLimit);var o=1-L.a.Clamp(r/this.borderLimit,0,1);if(o<0)return!1;o>1&&(o=1),this.viewportBorder>0&&(n.x+=this.viewportBorder,n.y+=this.viewportBorder,n.width-=2*this.viewportBorder,n.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var s=n.x+n.width/2,c=n.y+n.height/2,l=s-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];if(!d.texture||d.texture.isReady()){i.setAlphaMode(d.alphaMode);var f=s-l*d.position,p=c-u*d.position,_=d.size,m=d.size*i.getAspectRatio(this._scene.activeCamera,!0),v=f/(n.width+2*n.x)*2-1,b=1-p/(n.height+2*n.y)*2,y=a.a.FromValues(_/2,0,0,0,0,m/2,0,0,0,0,1,0,v,b,0,1);this._effect.setMatrix("viewportMatrix",y),this._effect.setTexture("textureSampler",d.texture),this._effect.setFloat4("color",d.color.r*o,d.color.g*o,d.color.b*o,1),i.drawElementsType(xo.a.TriangleFillMode,0,6)}}return i.setDepthBuffer(!0),i.setAlphaMode(g.a.ALPHA_DISABLE),!0},e.prototype.dispose=function(){var e=this._vertexBuffers[Qi.b.PositionKind];for(e&&(e.dispose(),this._vertexBuffers[Qi.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,n){var r=i.getLastEntryByID(t.emitterId),o=t.name||"lensFlareSystem#"+t.emitterId,a=new e(o,r,i);a.id=t.id||o,a.borderLimit=t.borderLimit;for(var c=0;c<t.flares.length;c++){var l=t.flares[c];ys.AddFlare(l.size,l.position,s.a.FromArray(l.color),l.textureName?n+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:Ce.b.GetFilename(i.texture?i.texture.name:"")})}return e},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("LensFlareSystemSceneComponent")},e}();n.a.AddParser(Me.a.NAME_LENSFLARESYSTEM,(function(e,t,i,n){if(void 0!==e.lensFlareSystems&&null!==e.lensFlareSystems){i.lensFlareSystems||(i.lensFlareSystems=new Array);for(var r=0,o=e.lensFlareSystems.length;r<o;r++){var a=e.lensFlareSystems[r],s=Ss.Parse(a,t,n);i.lensFlareSystems.push(s)}}})),n.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},n.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},n.a.prototype.removeLensFlareSystem=function(e){var t=this.lensFlareSystems.indexOf(e);return-1!==t&&this.lensFlareSystems.splice(t,1),t},n.a.prototype.addLensFlareSystem=function(e){this.lensFlareSystems.push(e)};var As=function(){function e(e){this.name=Me.a.NAME_LENSFLARESYSTEM,this.scene=e,e.lensFlareSystems=new Array}return e.prototype.register=function(){this.scene._afterCameraDrawStage.registerStep(Me.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,t){var i=this;e.lensFlareSystems&&e.lensFlareSystems.forEach((function(e){i.scene.removeLensFlareSystem(e),t&&e.dispose()}))},e.prototype.serialize=function(e){e.lensFlareSystems=[];for(var t=0,i=this.scene.lensFlareSystems;t<i.length;t++){var n=i[t];e.lensFlareSystems.push(n.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;Ce.b.StartPerformanceCounter("Lens flares",t.length>0);for(var i=0,n=t;i<n.length;i++){var r=n[i];0!=(e.layerMask&r.layerMask)&&r.render()}Ce.b.EndPerformanceCounter("Lens flares",t.length>0)}},e}();Ss._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_LENSFLARESYSTEM);t||(t=new As(e),e._addComponent(t))};var Ps="\n\n\n\n\nfloat bayerDither2(vec2 _P) {\nreturn mod(2.0*_P.y+_P.x+1.0,4.0);\n}\n\n\nfloat bayerDither4(vec2 _P) {\nvec2 P1=mod(_P,2.0);\nvec2 P2=floor(0.5*mod(_P,4.0));\nreturn 4.0*bayerDither2(P1)+bayerDither2(P2);\n}\n\nfloat bayerDither8(vec2 _P) {\nvec2 P1=mod(_P,2.0);\nvec2 P2=floor(0.5*mod(_P,4.0));\nvec2 P4=floor(0.25*mod(_P,8.0));\nreturn 4.0*(4.0*bayerDither2(P1)+bayerDither2(P2))+bayerDither2(P4);\n}\n";ai.a.IncludesShadersStore.bayerDitherFunctions=Ps;var Cs="#if SM_FLOAT == 0\n#include<packingFunctions>\n#endif\n#if SM_SOFTTRANSPARENTSHADOW == 1\n#include<bayerDitherFunctions>\nuniform float softTransparentShadowSM;\n#endif\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE == 1\nuniform vec3 lightDataSM;\nvarying vec3 vPositionWSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\nvarying float zSM;\n#endif\n";ai.a.IncludesShadersStore.shadowMapFragmentDeclaration=Cs;var Rs=" float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\n#if SM_USEDISTANCE == 1\ndepthSM=clamp(((length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);\n#else\ndepthSM=clamp(((zSM+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x,0.0,1.0);\n#endif\ngl_FragDepth=depthSM;\n#elif SM_USEDISTANCE == 1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/(depthValuesSM.y)+biasAndScaleSM.x;\n#endif\n#if SM_ESM == 1\ndepthSM=clamp(exp(-min(87.,biasAndScaleSM.z*depthSM)),0.,1.);\n#endif\n#if SM_FLOAT == 1\ngl_FragColor=vec4(depthSM,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depthSM);\n#endif\nreturn;";ai.a.IncludesShadersStore.shadowMapFragment=Rs;var xs="#include<shadowMapFragmentDeclaration>\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<clipPlaneFragmentDeclaration>\nvoid main(void)\n{\n#include<clipPlaneFragment>\n#ifdef ALPHATEST\nfloat alphaFromAlphaTexture=texture2D(diffuseSampler,vUV).a;\nif (alphaFromAlphaTexture<0.4)\ndiscard;\n#endif\n#if SM_SOFTTRANSPARENTSHADOW == 1\n#ifdef ALPHATEST\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alphaFromAlphaTexture) discard;\n#else\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM) discard;\n#endif\n#endif\n#include<shadowMapFragment>\n}";ai.a.ShadersStore.shadowMapPixelShader=xs;var Os="#if SM_NORMALBIAS == 1\nuniform vec3 lightDataSM;\n#endif\nuniform vec3 biasAndScaleSM;\nuniform vec2 depthValuesSM;\nvarying float vDepthMetricSM;\n#if SM_USEDISTANCE == 1\nvarying vec3 vPositionWSM;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\nvarying float zSM;\n#endif\n";ai.a.IncludesShadersStore.shadowMapVertexDeclaration=Os;var Ms="\n#if SM_NORMALBIAS == 1\n#if SM_DIRECTIONINLIGHTDATA == 1\nvec3 worldLightDirSM=normalize(-lightDataSM.xyz);\n#else\nvec3 directionToLightSM=lightDataSM.xyz-worldPos.xyz;\nvec3 worldLightDirSM=normalize(directionToLightSM);\n#endif\nfloat ndlSM=dot(vNormalW,worldLightDirSM);\nfloat sinNLSM=sqrt(1.0-ndlSM*ndlSM);\nfloat normalBiasSM=biasAndScaleSM.y*sinNLSM;\nworldPos.xyz-=vNormalW*normalBiasSM;\n#endif\n";ai.a.IncludesShadersStore.shadowMapVertexNormalBias=Ms;var Is="#if SM_USEDISTANCE == 1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE == 1\n\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w;\n#endif\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\nzSM=gl_Position.z;\ngl_Position.z=0.0;\n#elif SM_USEDISTANCE == 0\n\nvDepthMetricSM=((gl_Position.z+depthValuesSM.x)/(depthValuesSM.y))+biasAndScaleSM.x;\n#endif\n";ai.a.IncludesShadersStore.shadowMapVertexMetric=Is;var Ds="\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\n#include<helperFunctions>\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<shadowMapVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n#ifdef NORMAL\nmat3 normWorldSM=mat3(finalWorld);\n#if defined(INSTANCES) && defined(THIN_INSTANCES)\nvec3 vNormalW=normalUpdated/vec3(dot(normWorldSM[0],normWorldSM[0]),dot(normWorldSM[1],normWorldSM[1]),dot(normWorldSM[2],normWorldSM[2]));\nvNormalW=normalize(normWorldSM*vNormalW);\n#else\n#ifdef NONUNIFORMSCALING\nnormWorldSM=transposeMat3(inverseMat3(normWorldSM));\n#endif\nvec3 vNormalW=normalize(normWorldSM*normalUpdated);\n#endif\n#endif\n#include<shadowMapVertexNormalBias>\n\ngl_Position=viewProjection*worldPos;\n#include<shadowMapVertexMetric>\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<clipPlaneVertex>\n}";ai.a.ShadersStore.shadowMapVertexShader=Ds;var Ns="\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}";ai.a.ShadersStore.depthBoxBlurPixelShader=Ns;var Ls="#if SM_SOFTTRANSPARENTSHADOW == 1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";ai.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow=Ls;var ws=new a.a,Fs=new a.a,Bs=function(){function e(t,i,n){this.onBeforeShadowMapRenderObservable=new o.c,this.onAfterShadowMapRenderObservable=new o.c,this.onBeforeShadowMapRenderMeshObservable=new o.c,this.onAfterShadowMapRenderMeshObservable=new o.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.enableSoftTransparentShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=a.e.Zero(),this._viewMatrix=a.a.Zero(),this._projectionMatrix=a.a.Zero(),this._transformMatrix=a.a.Zero(),this._cachedPosition=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new a.e(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=a.a.Identity(),this._mapSize=t,this._light=i,this._scene=i.getScene(),i._shadowGenerator=this,this.id=i.id,e._SceneComponentInitialization(this._scene);var r=this._scene.getEngine().getCaps();n?r.textureFloatRender&&r.textureFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_FLOAT:r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_HALF_FLOAT:this._textureType=g.a.TEXTURETYPE_UNSIGNED_INT:r.textureHalfFloatRender&&r.textureHalfFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_HALF_FLOAT:r.textureFloatRender&&r.textureFloatLinearFiltering?this._textureType=g.a.TEXTURETYPE_FLOAT:this._textureType=g.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!1,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:!1,configurable:!0}),e.prototype._validateFilter=function(e){return e},Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){if(t=this._validateFilter(t),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:!1,configurable:!0}),Object.defineProperty(e.prototype,"usePoissonSampling",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){var i=this._validateFilter(e.FILTER_POISSONSAMPLING);(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var i=this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){var i=this._validateFilter(e.FILTER_PCF);(t||this.filter===e.FILTER_PCF)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality!==e&&(this._filteringQuality=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useContactHardeningShadow",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){var i=this._validateFilter(e.FILTER_PCSS);(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?i:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"darkness",{get:function(){return this._darkness},set:function(e){this.setDarkness(e)},enumerable:!1,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},Object.defineProperty(e.prototype,"transparencyShadow",{get:function(){return this._transparencyShadow},set:function(e){this.setTransparencyShadow(e)},enumerable:!1,configurable:!0}),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.getClassName=function(){return e.CLASSNAME},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 n=0,r=e.getChildren();n<r.length;n++){var o=r[n];this.removeShadowCaster(o)}return this},e.prototype.getLight=function(){return this._light},Object.defineProperty(e.prototype,"mapSize",{get:function(){return this._mapSize},set:function(e){this._mapSize=e,this._light._markMeshesAsLightDirty(),this.recreateShadowMap()},enumerable:!1,configurable:!0}),e.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},e.prototype._createTargetRenderTexture=function(){this._scene.getEngine().webGLVersion>1?(this._shadowMap=new Ni(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(g.a.LESS,!0)):this._shadowMap=new Ni(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube())},e.prototype._initializeShadowMap=function(){var t=this;if(this._createTargetRenderTexture(),null!==this._shadowMap){this._shadowMap.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._storedUniqueId&&(this._shadowMap.uniqueId=this._storedUniqueId),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.customIsReadyFunction=function(e,t){return!0};var i=this._scene.getEngine();this._shadowMap.onBeforeRenderObservable.add((function(n){if(t._currentFaceIndex=n,t._filter===e.FILTER_PCF&&i.setColorWrite(!1),t._scene.getSceneUniformBuffer().useUbo){var r=t._scene.getSceneUniformBuffer();r.updateMatrix("viewProjection",t.getTransformMatrix()),r.updateMatrix("view",t._viewMatrix),r.update()}})),this._shadowMap.onAfterUnbindObservable.add((function(){if(t._scene.getSceneUniformBuffer().useUbo){var n=t._scene.getSceneUniformBuffer();n.updateMatrix("viewProjection",t._scene.getTransformMatrix()),n.updateMatrix("view",t._scene.getViewMatrix()),n.update()}if(t._filter===e.FILTER_PCF&&i.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var r=t.getShadowMapForRendering();if(r){var o=r.getInternalTexture();t._scene.postProcessManager.directRender(t._blurPostProcesses,o,!0),i.unBindFramebuffer(o,!0)}}}));var n=new s.b(0,0,0,0),r=new s.b(1,1,1,1);this._shadowMap.onClearObservable.add((function(i){t._filter===e.FILTER_PCF?i.clear(r,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?i.clear(n,!0,!0,!1):i.clear(r,!0,!0,!1)})),this._shadowMap.onResizeObservable.add((function(e){t._storedUniqueId=t._shadowMap.uniqueId,t._mapSize=e.getRenderSize(),t._light._markMeshesAsLightDirty(),t.recreateShadowMap()}));for(var o=Di.b.MIN_RENDERINGGROUPS;o<Di.b.MAX_RENDERINGGROUPS;o++)this._shadowMap.setRenderingAutoClearDepthStencil(o,!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 Ni(this._light.name+"_shadowMap2",i,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new eo(this._light.name+"KernelBlurX",new a.d(1,0),this.blurKernel,1,null,Ke.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 eo(this._light.name+"KernelBlurY",new a.d(0,1),this.blurKernel,1,null,Ke.a.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===g.a.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new li(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,Ke.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,n){var r,o=this._scene.getEngine(),a=o.getColorWrite();if(n.length){for(o.setColorWrite(!1),r=0;r<n.length;r++)this._renderSubMeshForShadowMap(n.data[r]);o.setColorWrite(a)}for(r=0;r<e.length;r++)this._renderSubMeshForShadowMap(e.data[r]);for(r=0;r<t.length;r++)this._renderSubMeshForShadowMap(t.data[r]);if(this._transparencyShadow)for(r=0;r<i.length;r++)this._renderSubMeshForShadowMap(i.data[r],!0);else for(r=0;r<i.length;r++)i.data[r].getEffectiveMesh()._internalAbstractMeshDataInfo._isActiveIntermediate=!1},e.prototype._bindCustomEffectForRenderSubMeshForShadowMap=function(e,t,i,n){var r,o,a,s,c,l;t.setMatrix(null!==(r=null==i?void 0:i.viewProjection)&&void 0!==r?r:"viewProjection",this.getTransformMatrix()),t.setMatrix(null!==(o=null==i?void 0:i.view)&&void 0!==o?o:"view",this._viewMatrix),t.setMatrix(null!==(a=null==i?void 0:i.projection)&&void 0!==a?a:"projection",this._projectionMatrix);var u=n.getWorldMatrix();t.setMatrix(null!==(s=null==i?void 0:i.world)&&void 0!==s?s:"world",u),u.multiplyToRef(this.getTransformMatrix(),ws),t.setMatrix(null!==(c=null==i?void 0:i.worldViewProjection)&&void 0!==c?c:"worldViewProjection",ws),u.multiplyToRef(this._viewMatrix,Fs),t.setMatrix(null!==(l=null==i?void 0:i.worldView)&&void 0!==l?l:"worldView",Fs)},e.prototype._renderSubMeshForShadowMap=function(e,t){var i,n;void 0===t&&(t=!1);var r=e.getRenderingMesh(),o=e.getEffectiveMesh(),a=this._scene,s=a.getEngine(),c=e.getMaterial();if(o._internalAbstractMeshDataInfo._isActiveIntermediate=!1,c&&0!==e.verticesCount&&e._renderId!==a.getRenderId()){s.setState(c.backFaceCulling);var l=r._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!l.mustReturn){var u=s.getCaps().instancedArrays&&(null!==l.visibleInstances[e._id]&&void 0!==l.visibleInstances[e._id]||r.hasThinInstances);if(!this.customAllowRendering||this.customAllowRendering(e))if(this.isReady(e,u,t)){e._renderId=a.getRenderId();var h=null===(i=r.material)||void 0===i?void 0:i.shadowDepthWrapper,d=null!==(n=null==h?void 0:h.getEffect(e,this))&&void 0!==n?n:this._effect;if(s.enableEffect(d),r._bind(e,d,c.fillMode),this.getTransformMatrix(),d.setFloat3("biasAndScaleSM",this.bias,this.normalBias,this.depthScale),this.getLight().getTypeID()===kr.a.LIGHTTYPEID_DIRECTIONALLIGHT?d.setVector3("lightDataSM",this._cachedDirection):d.setVector3("lightDataSM",this._cachedPosition),a.activeCamera&&d.setFloat2("depthValuesSM",this.getLight().getDepthMinZ(a.activeCamera),this.getLight().getDepthMinZ(a.activeCamera)+this.getLight().getDepthMaxZ(a.activeCamera)),t&&this.enableSoftTransparentShadow&&d.setFloat("softTransparentShadowSM",o.visibility),h)e._effectOverride=d,h.standalone?h.baseMaterial.bindForSubMesh(o.getWorldMatrix(),r,e):c.bindForSubMesh(o.getWorldMatrix(),r,e),e._effectOverride=null;else{if(d.setMatrix("viewProjection",this.getTransformMatrix()),c&&c.needAlphaTesting()){var f=c.getAlphaTestTexture();f&&(d.setTexture("diffuseSampler",f),d.setMatrix("diffuseMatrix",f.getTextureMatrix()||this._defaultTextureMatrix))}if(r.useBones&&r.computeBonesUsingShaders&&r.skeleton){var p=r.skeleton;if(p.isUsingTextureForMatrices){var _=p.getTransformMatrixTexture(r);if(!_)return;d.setTexture("boneSampler",_),d.setFloat("boneTextureWidth",4*(p.bones.length+1))}else d.setMatrices("mBones",p.getTransformMatrices(r))}ro.a.BindMorphTargetParameters(r,d),ro.a.BindClipPlane(d,a)}this._bindCustomEffectForRenderSubMeshForShadowMap(e,d,null==h?void 0:h._matriceNames,o),this.forceBackFacesOnly&&s.setState(!0,0,!1,!0),this.onBeforeShadowMapRenderMeshObservable.notifyObservers(r),this.onBeforeShadowMapRenderObservable.notifyObservers(d),r._processRendering(o,e,d,c.fillMode,l,u,(function(e,t){return d.setMatrix("world",t)})),this.forceBackFacesOnly&&s.setState(!0,0,!1,!1),this.onAfterShadowMapRenderObservable.notifyObservers(d),this.onAfterShadowMapRenderMeshObservable.notifyObservers(r)}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(Ke.a.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode(Ke.a.BILINEAR_SAMPLINGMODE))},e.prototype.forceCompilation=function(e,t){var i=this,n=Object(h.a)({useInstances:!1},t),r=this.getShadowMap();if(r){var o=r.renderList;if(o){for(var a=new Array,s=0,c=o;s<c.length;s++){var l=c[s];a.push.apply(a,l.subMeshes)}if(0!==a.length){var u=0,d=function(){var t,r;if(i._scene&&i._scene.getEngine()){for(;i.isReady(a[u],n.useInstances,null!==(r=null===(t=a[u].getMaterial())||void 0===t?void 0:t.needAlphaBlendingForMesh(a[u].getMesh()))&&void 0!==r&&r);)if(++u>=a.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._isReadyCustomDefines=function(e,t,i){},e.prototype._prepareShadowDefines=function(e,t,i,n){i.push("#define SM_FLOAT "+(this._textureType!==g.a.TEXTURETYPE_UNSIGNED_INT?"1":"0")),i.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),i.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));var r=e.getMesh();return i.push("#define SM_NORMALBIAS "+(this.normalBias&&r.isVerticesDataPresent(Qi.b.NormalKind)?"1":"0")),i.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===kr.a.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),i.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),i.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&n?"1":"0")),this._isReadyCustomDefines(i,e,t),i},e.prototype.isReady=function(e,t,i){var n=e.getMaterial(),r=null==n?void 0:n.shadowDepthWrapper,o=[];if(this._prepareShadowDefines(e,t,o,i),r){if(!r.isReadyForSubMesh(e,o,this,t))return!1}else{var a=[Qi.b.PositionKind],s=e.getMesh();if(this.normalBias&&s.isVerticesDataPresent(Qi.b.NormalKind)&&(a.push(Qi.b.NormalKind),o.push("#define NORMAL"),s.nonUniformScaling&&o.push("#define NONUNIFORMSCALING")),n&&n.needAlphaTesting()){var c=n.getAlphaTestTexture();if(c){if(!c.isReady())return!1;o.push("#define ALPHATEST"),s.isVerticesDataPresent(Qi.b.UVKind)&&(a.push(Qi.b.UVKind),o.push("#define UV1")),s.isVerticesDataPresent(Qi.b.UV2Kind)&&1===c.coordinatesIndex&&(a.push(Qi.b.UV2Kind),o.push("#define UV2"))}}var l=new po.a;if(s.useBones&&s.computeBonesUsingShaders&&s.skeleton){a.push(Qi.b.MatricesIndicesKind),a.push(Qi.b.MatricesWeightsKind),s.numBoneInfluencers>4&&(a.push(Qi.b.MatricesIndicesExtraKind),a.push(Qi.b.MatricesWeightsExtraKind));var u=s.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),s.numBoneInfluencers>0&&l.addCPUSkinningFallback(0,s),u.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(u.bones.length+1))}else o.push("#define NUM_BONE_INFLUENCERS 0");var h=s.morphTargetManager,d=0;h&&h.numInfluencers>0&&(o.push("#define MORPHTARGETS"),d=h.numInfluencers,o.push("#define NUM_MORPH_INFLUENCERS "+d),ro.a.PrepareAttributesForMorphTargetsInfluencers(a,s,d));var f=this._scene;if(f.clipPlane&&o.push("#define CLIPPLANE"),f.clipPlane2&&o.push("#define CLIPPLANE2"),f.clipPlane3&&o.push("#define CLIPPLANE3"),f.clipPlane4&&o.push("#define CLIPPLANE4"),f.clipPlane5&&o.push("#define CLIPPLANE5"),f.clipPlane6&&o.push("#define CLIPPLANE6"),t&&(o.push("#define INSTANCES"),ro.a.PushAttributesForInstances(a),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(var p=0,_=this.customShaderOptions.defines;p<_.length;p++){var m=_[p];-1===o.indexOf(m)&&o.push(m)}var g=o.join("\n");if(this._cachedDefines!==g){this._cachedDefines=g;var v="shadowMap",b=["world","mBones","viewProjection","diffuseMatrix","lightDataSM","depthValuesSM","biasAndScaleSM","morphTargetInfluences","boneTextureWidth","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","softTransparentShadowSM"],y=["diffuseSampler","boneSampler"];if(this.customShaderOptions){if(v=this.customShaderOptions.shaderName,this.customShaderOptions.attributes)for(var T=0,E=this.customShaderOptions.attributes;T<E.length;T++){var S=E[T];-1===a.indexOf(S)&&a.push(S)}if(this.customShaderOptions.uniforms)for(var A=0,P=this.customShaderOptions.uniforms;A<P.length;A++){var C=P[A];-1===b.indexOf(C)&&b.push(C)}if(this.customShaderOptions.samplers)for(var R=0,x=this.customShaderOptions.samplers;R<x.length;R++){var O=x[R];-1===y.indexOf(O)&&y.push(O)}}this._effect=this._scene.getEngine().createEffect(v,a,b,y,g,l,void 0,void 0,{maxSimultaneousMorphTargets:d})}if(!this._effect.isReady())return!1}return(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 n=this._scene,r=this._light;n.shadowsEnabled&&r.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),r.needCube()&&(t["SHADOWCUBE"+i]=!0))},e.prototype.bindShadowLight=function(t,i){var n=this._light,r=this._scene;if(r.shadowsEnabled&&n.shadowEnabled){var o=r.activeCamera;if(o){var a=this.getShadowMap();a&&(n.needCube()||i.setMatrix("lightMatrix"+t,this.getTransformMatrix()),this._filter===e.FILTER_PCF?(i.setDepthStencilTexture("shadowSampler"+t,this.getShadowMapForRendering()),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a.getSize().width,1/a.getSize().width,this.frustumEdgeFalloff,t)):this._filter===e.FILTER_PCSS?(i.setDepthStencilTexture("shadowSampler"+t,this.getShadowMapForRendering()),i.setTexture("depthSampler"+t,this.getShadowMapForRendering()),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/a.getSize().width,this._contactHardeningLightSizeUVRatio*a.getSize().width,this.frustumEdgeFalloff,t)):(i.setTexture("shadowSampler"+t,this.getShadowMapForRendering()),n._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/a.getSize().width,this.depthScale,this.frustumEdgeFalloff,t)),n._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),a.e.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs(a.e.Dot(this._lightDirection,a.e.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),a.a.LookAtLHToRef(t,t.add(this._lightDirection),a.e.Up(),this._viewMatrix);var i=this.getShadowMap();if(i){var n=i.renderList;n&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,n)}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()),this.onBeforeShadowMapRenderMeshObservable.clear(),this.onBeforeShadowMapRenderObservable.clear(),this.onAfterShadowMapRenderMeshObservable.clear(),this.onAfterShadowMapRenderObservable.clear()},e.prototype.serialize=function(){var e={},t=this.getShadowMap();if(!t)return e;if(e.className=this.getClassName(),e.lightId=this._light.id,e.id=this._light.id,e.mapSize=t.getRenderSize(),e.forceBackFacesOnly=this.forceBackFacesOnly,e.darkness=this.getDarkness(),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.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.filteringQuality=this.filteringQuality,e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.depthScale=this.depthScale,e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.renderList=[],t.renderList)for(var i=0;i<t.renderList.length;i++){var n=t.renderList[i];e.renderList.push(n.id)}return e},e.Parse=function(t,i,n){for(var r=i.getLightByID(t.lightId),o=n?n(t.mapSize,r):new e(t.mapSize,r),a=o.getShadowMap(),s=0;s<t.renderList.length;s++){i.getMeshesByID(t.renderList[s]).forEach((function(e){a&&(a.renderList||(a.renderList=[]),a.renderList.push(e))}))}return void 0!==t.id&&(o.id=t.id),o.forceBackFacesOnly=!!t.forceBackFacesOnly,void 0!==t.darkness&&o.setDarkness(t.darkness),t.transparencyShadow&&o.setTransparencyShadow(!0),void 0!==t.frustumEdgeFalloff&&(o.frustumEdgeFalloff=t.frustumEdgeFalloff),void 0!==t.bias&&(o.bias=t.bias),void 0!==t.normalBias&&(o.normalBias=t.normalBias),t.usePercentageCloserFiltering?o.usePercentageCloserFiltering=!0:t.useContactHardeningShadow?o.useContactHardeningShadow=!0:t.usePoissonSampling?o.usePoissonSampling=!0:t.useExponentialShadowMap?o.useExponentialShadowMap=!0:t.useBlurExponentialShadowMap?o.useBlurExponentialShadowMap=!0:t.useCloseExponentialShadowMap?o.useCloseExponentialShadowMap=!0:t.useBlurCloseExponentialShadowMap?o.useBlurCloseExponentialShadowMap=!0:t.useVarianceShadowMap?o.useExponentialShadowMap=!0:t.useBlurVarianceShadowMap&&(o.useBlurExponentialShadowMap=!0),void 0!==t.contactHardeningLightSizeUVRatio&&(o.contactHardeningLightSizeUVRatio=t.contactHardeningLightSizeUVRatio),void 0!==t.filteringQuality&&(o.filteringQuality=t.filteringQuality),t.depthScale&&(o.depthScale=t.depthScale),t.blurScale&&(o.blurScale=t.blurScale),t.blurBoxOffset&&(o.blurBoxOffset=t.blurBoxOffset),t.useKernelBlur&&(o.useKernelBlur=t.useKernelBlur),t.blurKernel&&(o.blurKernel=t.blurKernel),o},e.CLASSNAME="ShadowGenerator",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 Re.a.WarnImport("ShadowGeneratorSceneComponent")},e}(),Us="#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\n#ifdef PACKED\n#include<packingFunctions>\n#endif\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#ifdef NONLINEARDEPTH\n#ifdef PACKED\ngl_FragColor=pack(gl_FragCoord.z);\n#else\ngl_FragColor=vec4(gl_FragCoord.z,0.0,0.0,0.0);\n#endif\n#else\n#ifdef PACKED\ngl_FragColor=pack(vDepthMetric);\n#else\ngl_FragColor=vec4(vDepthMetric,0.0,0.0,1.0);\n#endif\n#endif\n}";ai.a.ShadersStore.depthPixelShader=Us;var Vs="\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\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{\nvec3 positionUpdated=position;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";ai.a.ShadersStore.depthVertexShader=Vs;var ks=function(){function e(t,i,n,r){var o=this;void 0===i&&(i=g.a.TEXTURETYPE_FLOAT),void 0===n&&(n=null),void 0===r&&(r=!1),this.enabled=!0,this.useOnlyInActiveCamera=!1,this._scene=t,this._storeNonLinearDepth=r,this.isPacked=i===g.a.TEXTURETYPE_UNSIGNED_BYTE,this.isPacked?this._clearColor=new s.b(1,1,1,1):this._clearColor=new s.b(1,0,0,1),e._SceneComponentInitialization(this._scene),this._camera=n;var a=t.getEngine(),c=this.isPacked||1===a.webGLVersion?g.a.TEXTUREFORMAT_RGBA:g.a.TEXTUREFORMAT_R;this._depthMap=new Ni("depthMap",{width:a.getRenderWidth(),height:a.getRenderHeight()},this._scene,!1,!0,i,!1,void 0,void 0,void 0,void 0,c),this._depthMap.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._depthMap.wrapV=Ke.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(o._clearColor,!0,!0,!0)}));var l=function(e){var t=e.getRenderingMesh(),i=e.getEffectiveMesh(),n=o._scene,r=n.getEngine(),a=e.getMaterial();if(i._internalAbstractMeshDataInfo._isActiveIntermediate=!1,a&&0!==e.verticesCount&&e._renderId!==n.getRenderId()){r.setState(a.backFaceCulling,0,!1,n.useRightHandedSystem);var s=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!s.mustReturn){var c=r.getCaps().instancedArrays&&(null!==s.visibleInstances[e._id]&&void 0!==s.visibleInstances[e._id]||t.hasThinInstances),l=o._camera||n.activeCamera;if(o.isReady(e,c)&&l){if(e._renderId=n.getRenderId(),r.enableEffect(o._effect),t._bind(e,o._effect,a.fillMode),o._effect.setMatrix("viewProjection",n.getTransformMatrix()),o._effect.setFloat2("depthValues",l.minZ,l.minZ+l.maxZ),a&&a.needAlphaTesting()){var u=a.getAlphaTestTexture();u&&(o._effect.setTexture("diffuseSampler",u),o._effect.setMatrix("diffuseMatrix",u.getTextureMatrix()))}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&o._effect.setMatrices("mBones",t.skeleton.getTransformMatrices(t)),ro.a.BindMorphTargetParameters(t,o._effect),t._processRendering(i,e,o._effect,a.fillMode,s,c,(function(e,t){return o._effect.setMatrix("world",t)}))}}}};this._depthMap.customRenderFunction=function(e,t,i,n){var r;if(n.length){for(a.setColorWrite(!1),r=0;r<n.length;r++)l(n.data[r]);a.setColorWrite(!0)}for(r=0;r<e.length;r++)l(e.data[r]);for(r=0;r<t.length;r++)l(t.data[r])}}return e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i.disableDepthWrite)return!1;var n=[],r=[Qi.b.PositionKind],o=e.getMesh();i&&i.needAlphaTesting()&&i.getAlphaTestTexture()&&(n.push("#define ALPHATEST"),o.isVerticesDataPresent(Qi.b.UVKind)&&(r.push(Qi.b.UVKind),n.push("#define UV1")),o.isVerticesDataPresent(Qi.b.UV2Kind)&&(r.push(Qi.b.UV2Kind),n.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders?(r.push(Qi.b.MatricesIndicesKind),r.push(Qi.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(r.push(Qi.b.MatricesIndicesExtraKind),r.push(Qi.b.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),n.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var a=o.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,n.push("#define MORPHTARGETS"),n.push("#define NUM_MORPH_INFLUENCERS "+s),ro.a.PrepareAttributesForMorphTargetsInfluencers(r,o,s)),t&&(n.push("#define INSTANCES"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push("#define THIN_INSTANCES")),this._storeNonLinearDepth&&n.push("#define NONLINEARDEPTH"),this.isPacked&&n.push("#define PACKED");var c=n.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this._scene.getEngine().createEffect("depth",r,["world","mBones","viewProjection","diffuseMatrix","depthValues","morphTargetInfluences"],["diffuseSampler"],c,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){this._depthMap.dispose()},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("DepthRendererSceneComponent")},e}(),zs="attribute vec2 vUV;\nuniform sampler2D textureSampler;\n#if defined(INITIAL)\nuniform sampler2D sourceTexture;\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nfloat f1=texelFetch(sourceTexture,coord,0).r;\nfloat f2=texelFetch(sourceTexture,coord+ivec2(1,0),0).r;\nfloat f3=texelFetch(sourceTexture,coord+ivec2(1,1),0).r;\nfloat f4=texelFetch(sourceTexture,coord+ivec2(0,1),0).r;\nfloat minz=min(min(min(f1,f2),f3),f4);\n#ifdef DEPTH_REDUX\nfloat maxz=max(max(max(sign(1.0-f1)*f1,sign(1.0-f2)*f2),sign(1.0-f3)*f3),sign(1.0-f4)*f4);\n#else\nfloat maxz=max(max(max(f1,f2),f3),f4);\n#endif\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(MAIN)\nuniform vec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*(texSize-1.0));\nvec2 f1=texelFetch(textureSampler,coord,0).rg;\nvec2 f2=texelFetch(textureSampler,coord+ivec2(1,0),0).rg;\nvec2 f3=texelFetch(textureSampler,coord+ivec2(1,1),0).rg;\nvec2 f4=texelFetch(textureSampler,coord+ivec2(0,1),0).rg;\nfloat minz=min(min(min(f1.x,f2.x),f3.x),f4.x);\nfloat maxz=max(max(max(f1.y,f2.y),f3.y),f4.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(ONEBEFORELAST)\nuniform ivec2 texSize;\nvoid main(void)\n{\nivec2 coord=ivec2(vUV*vec2(texSize-1));\nvec2 f1=texelFetch(textureSampler,coord % texSize,0).rg;\nvec2 f2=texelFetch(textureSampler,(coord+ivec2(1,0)) % texSize,0).rg;\nvec2 f3=texelFetch(textureSampler,(coord+ivec2(1,1)) % texSize,0).rg;\nvec2 f4=texelFetch(textureSampler,(coord+ivec2(0,1)) % texSize,0).rg;\nfloat minz=min(f1.x,f2.x);\nfloat maxz=max(f1.y,f2.y);\nglFragColor=vec4(minz,maxz,0.,0.);\n}\n#elif defined(LAST)\nvoid main(void)\n{\ndiscard;\nglFragColor=vec4(0.);\n}\n#endif\n";ai.a.ShadersStore.minmaxReduxPixelShader=zs;var Gs=function(){function e(e){this.onAfterReductionPerformed=new o.c,this._forceFullscreenViewport=!0,this._activated=!1,this._camera=e,this._postProcessManager=new Ii.a(e.getScene())}return Object.defineProperty(e.prototype,"sourceTexture",{get:function(){return this._sourceTexture},enumerable:!1,configurable:!0}),e.prototype.setSourceTexture=function(e,t,i,n){var r=this;if(void 0===i&&(i=g.a.TEXTURETYPE_HALF_FLOAT),void 0===n&&(n=!0),e!==this._sourceTexture){this.dispose(!1),this._sourceTexture=e,this._reductionSteps=[],this._forceFullscreenViewport=n;var o=this._camera.getScene(),a=new li("Initial reduction phase","minmaxRedux",["texSize"],["sourceTexture"],1,null,g.a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define INITIAL"+(t?"\n#define DEPTH_REDUX":""),i,void 0,void 0,void 0,g.a.TEXTUREFORMAT_RG);a.autoClear=!1,a.forceFullscreenViewport=n;var s=this._sourceTexture.getRenderWidth(),c=this._sourceTexture.getRenderHeight();a.onApply=function(e,t){return function(i){i.setTexture("sourceTexture",r._sourceTexture),i.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,c),this._reductionSteps.push(a);for(var l=1;s>1||c>1;){s=Math.max(Math.round(s/2),1),c=Math.max(Math.round(c/2),1);var u=new li("Reduction phase "+l,"minmaxRedux",["texSize"],null,{width:s,height:c},null,g.a.TEXTURE_NEAREST_NEAREST,o.getEngine(),!1,"#define "+(1==s&&1==c?"LAST":1==s||1==c?"ONEBEFORELAST":"MAIN"),i,void 0,void 0,void 0,g.a.TEXTUREFORMAT_RG);if(u.autoClear=!1,u.forceFullscreenViewport=n,u.onApply=function(e,t){return function(i){1==e||1==t?i.setIntArray2("texSize",new Int32Array([e,t])):i.setFloatArray2("texSize",new Float32Array([e,t]))}}(s,c),this._reductionSteps.push(u),l++,1==s&&1==c){u.onAfterRenderObservable.add(function(e,t,i){var n=new Float32Array(4*e*t),a={min:0,max:0};return function(){o.getEngine()._readTexturePixels(i.inputTexture,e,t,-1,0,n),a.min=n[0],a.max=n[1],r.onAfterReductionPerformed.notifyObservers(a)}}(s,c,u))}}}},Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._sourceTexture?this._sourceTexture.refreshRate:-1},set:function(e){this._sourceTexture&&(this._sourceTexture.refreshRate=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"activated",{get:function(){return this._activated},enumerable:!1,configurable:!0}),e.prototype.activate=function(){var e=this;!this._onAfterUnbindObserver&&this._sourceTexture&&(this._onAfterUnbindObserver=this._sourceTexture.onAfterUnbindObservable.add((function(){e._reductionSteps[0].activate(e._camera),e._postProcessManager.directRender(e._reductionSteps,e._reductionSteps[0].inputTexture,e._forceFullscreenViewport),e._camera.getScene().getEngine().unBindFramebuffer(e._reductionSteps[0].inputTexture,!1)})),this._activated=!0)},e.prototype.deactivate=function(){this._onAfterUnbindObserver&&this._sourceTexture&&(this._sourceTexture.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=null,this._activated=!1)},e.prototype.dispose=function(e){if(void 0===e&&(e=!0),e&&this.onAfterReductionPerformed.clear(),this.deactivate(),this._reductionSteps){for(var t=0;t<this._reductionSteps.length;++t)this._reductionSteps[t].dispose();this._reductionSteps=null}this._postProcessManager&&e&&this._postProcessManager.dispose(),this._sourceTexture=null},e}(),js=function(e){function t(t){return e.call(this,t)||this}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"depthRenderer",{get:function(){return this._depthRenderer},enumerable:!1,configurable:!0}),t.prototype.setDepthRenderer=function(t,i,n){void 0===t&&(t=null),void 0===i&&(i=g.a.TEXTURETYPE_HALF_FLOAT),void 0===n&&(n=!0);var r=this._camera.getScene();this._depthRenderer&&(delete r._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null),null===t&&(r._depthRenderer||(r._depthRenderer={}),(t=this._depthRenderer=new ks(r,i,this._camera,!1)).enabled=!1,this._depthRendererId="minmax"+this._camera.id,r._depthRenderer[this._depthRendererId]=t),e.prototype.setSourceTexture.call(this,t.getDepthMap(),!0,i,n)},t.prototype.setSourceTexture=function(t,i,n,r){void 0===n&&(n=g.a.TEXTURETYPE_HALF_FLOAT),void 0===r&&(r=!0),e.prototype.setSourceTexture.call(this,t,i,n,r)},t.prototype.activate=function(){this._depthRenderer&&(this._depthRenderer.enabled=!0),e.prototype.activate.call(this)},t.prototype.deactivate=function(){e.prototype.deactivate.call(this),this._depthRenderer&&(this._depthRenderer.enabled=!1)},t.prototype.dispose=function(t){if(void 0===t&&(t=!0),e.prototype.dispose.call(this,t),this._depthRenderer&&t){var i=this._depthRenderer.getDepthMap().getScene();i&&delete i._depthRenderer[this._depthRendererId],this._depthRenderer.dispose(),this._depthRenderer=null}},t}(Gs),Ws=a.e.Up(),Hs=a.e.Zero(),Xs=new a.e,Ys=new a.e,Ks=new a.a,Qs=new a.a,qs=function(e){function t(i,n,r){var o=this;if(t.IsSupported)return(o=e.call(this,i,n,r)||this).usePercentageCloserFiltering=!0,o;m.a.Error("CascadedShadowMap needs WebGL 2 support.")}return Object(h.d)(t,e),t.prototype._validateFilter=function(e){return e===Bs.FILTER_NONE||e===Bs.FILTER_PCF||e===Bs.FILTER_PCSS?e:(console.error('Unsupported filter "'+e+'"!'),Bs.FILTER_NONE)},Object.defineProperty(t.prototype,"numCascades",{get:function(){return this._numCascades},set:function(e){(e=Math.min(Math.max(e,t.MIN_CASCADES_COUNT),t.MAX_CASCADES_COUNT))!==this._numCascades&&(this._numCascades=e,this.recreateShadowMap())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"freezeShadowCastersBoundingInfo",{get:function(){return this._freezeShadowCastersBoundingInfo},set:function(e){this._freezeShadowCastersBoundingInfoObservable&&e&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),this._freezeShadowCastersBoundingInfoObservable||e||(this._freezeShadowCastersBoundingInfoObservable=this._scene.onBeforeRenderObservable.add(this._computeShadowCastersBoundingInfo.bind(this))),this._freezeShadowCastersBoundingInfo=e,e&&this._computeShadowCastersBoundingInfo()},enumerable:!1,configurable:!0}),t.prototype._computeShadowCastersBoundingInfo=function(){if(this._scbiMin.copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._scbiMax.copyFromFloats(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),this._shadowMap&&this._shadowMap.renderList){for(var e=this._shadowMap.renderList,t=0;t<e.length;t++){if(r=e[t]){var i=r.getBoundingInfo().boundingBox;this._scbiMin.minimizeInPlace(i.minimumWorld),this._scbiMax.maximizeInPlace(i.maximumWorld)}}var n=this._scene.meshes;for(t=0;t<n.length;t++){var r;if((r=n[t])&&r.isVisible&&r.isEnabled&&r.receiveShadows){i=r.getBoundingInfo().boundingBox;this._scbiMin.minimizeInPlace(i.minimumWorld),this._scbiMax.maximizeInPlace(i.maximumWorld)}}}this._shadowCastersBoundingInfo.reConstruct(this._scbiMin,this._scbiMax)},Object.defineProperty(t.prototype,"shadowCastersBoundingInfo",{get:function(){return this._shadowCastersBoundingInfo},set:function(e){this._shadowCastersBoundingInfo=e},enumerable:!1,configurable:!0}),t.prototype.setMinMaxDistance=function(e,t){this._minDistance===e&&this._maxDistance===t||(e>t&&(e=0,t=1),e<0&&(e=0),t>1&&(t=1),this._minDistance=e,this._maxDistance=t,this._breaksAreDirty=!0)},Object.defineProperty(t.prototype,"minDistance",{get:function(){return this._minDistance},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"maxDistance",{get:function(){return this._maxDistance},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return t.CLASSNAME},t.prototype.getCascadeMinExtents=function(e){return e>=0&&e<this._numCascades?this._cascadeMinExtents[e]:null},t.prototype.getCascadeMaxExtents=function(e){return e>=0&&e<this._numCascades?this._cascadeMaxExtents[e]:null},Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._scene&&this._scene.activeCamera?this._shadowMaxZ:0},set:function(e){this._scene&&this._scene.activeCamera?this._shadowMaxZ===e||e<this._scene.activeCamera.minZ||e>this._scene.activeCamera.maxZ||(this._shadowMaxZ=e,this._light._markMeshesAsLightDirty(),this._breaksAreDirty=!0):this._shadowMaxZ=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"debug",{get:function(){return this._debug},set:function(e){this._debug=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthClamp",{get:function(){return this._depthClamp},set:function(e){this._depthClamp=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cascadeBlendPercentage",{get:function(){return this._cascadeBlendPercentage},set:function(e){this._cascadeBlendPercentage=e,this._light._markMeshesAsLightDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lambda",{get:function(){return this._lambda},set:function(e){var t=Math.min(Math.max(e,0),1);this._lambda!=t&&(this._lambda=t,this._breaksAreDirty=!0)},enumerable:!1,configurable:!0}),t.prototype.getCascadeViewMatrix=function(e){return e>=0&&e<this._numCascades?this._viewMatrices[e]:null},t.prototype.getCascadeProjectionMatrix=function(e){return e>=0&&e<this._numCascades?this._projectionMatrices[e]:null},t.prototype.getCascadeTransformMatrix=function(e){return e>=0&&e<this._numCascades?this._transformMatrices[e]:null},t.prototype.setDepthRenderer=function(e){this._depthRenderer=e,this._depthReducer&&this._depthReducer.setDepthRenderer(this._depthRenderer)},Object.defineProperty(t.prototype,"autoCalcDepthBounds",{get:function(){return this._autoCalcDepthBounds},set:function(e){var t=this,i=this._scene.activeCamera;if(i){if(this._autoCalcDepthBounds=e,!e)return this._depthReducer&&this._depthReducer.deactivate(),void this.setMinMaxDistance(0,1);this._depthReducer||(this._depthReducer=new js(i),this._depthReducer.onAfterReductionPerformed.add((function(e){var i=e.min,n=e.max;i>=n&&(i=0,n=1),i==t._minDistance&&n==t._maxDistance||t.setMinMaxDistance(i,n)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,t,i;return null!==(i=null===(t=null===(e=this._depthReducer)||void 0===e?void 0:e.depthRenderer)||void 0===t?void 0:t.getDepthMap().refreshRate)&&void 0!==i?i:-1},set:function(e){var t;(null===(t=this._depthReducer)||void 0===t?void 0:t.depthRenderer)&&(this._depthReducer.depthRenderer.getDepthMap().refreshRate=e)},enumerable:!1,configurable:!0}),t.prototype.splitFrustum=function(){this._breaksAreDirty=!0},t.prototype._splitFrustum=function(){var e=this._scene.activeCamera;if(e){for(var t=e.minZ,i=e.maxZ,n=i-t,r=this._minDistance,o=t+r*n,a=t+(this._shadowMaxZ<i&&this._shadowMaxZ>=t?Math.min((this._shadowMaxZ-t)/(i-t),this._maxDistance):this._maxDistance)*n,s=a-o,c=a/o,l=0;l<this._cascades.length;++l){var u=(l+1)/this._numCascades,h=o*Math.pow(c,u),d=o+s*u,f=this._lambda*(h-d)+d;this._cascades[l].prevBreakDistance=0===l?r:this._cascades[l-1].breakDistance,this._cascades[l].breakDistance=(f-t)/n,this._viewSpaceFrustumsZ[l]=t+this._cascades[l].breakDistance*n,this._frustumLengths[l]=(this._cascades[l].breakDistance-this._cascades[l].prevBreakDistance)*n}this._breaksAreDirty=!1}},t.prototype._computeMatrices=function(){if(this._scene.activeCamera){a.e.NormalizeToRef(this._light.getShadowDirection(0),this._lightDirection),1===Math.abs(a.e.Dot(this._lightDirection,a.e.Up()))&&(this._lightDirection.z=1e-13),this._cachedDirection.copyFrom(this._lightDirection);for(var e=0;e<this._numCascades;++e){this._computeFrustumInWorldSpace(e),this._computeCascadeFrustum(e),this._cascadeMaxExtents[e].subtractToRef(this._cascadeMinExtents[e],Xs),this._frustumCenter[e].addToRef(this._lightDirection.scale(this._cascadeMinExtents[e].z),this._shadowCameraPos[e]),a.a.LookAtLHToRef(this._shadowCameraPos[e],this._frustumCenter[e],Ws,this._viewMatrices[e]);var t=0,i=Xs.z,n=this._shadowCastersBoundingInfo;n.update(this._viewMatrices[e]),i=Math.min(i,n.boundingBox.maximumWorld.z),t=this._depthClamp&&this.filter!==Bs.FILTER_PCSS?Math.max(t,n.boundingBox.minimumWorld.z):Math.min(t,n.boundingBox.minimumWorld.z),a.a.OrthoOffCenterLHToRef(this._cascadeMinExtents[e].x,this._cascadeMaxExtents[e].x,this._cascadeMinExtents[e].y,this._cascadeMaxExtents[e].y,t,i,this._projectionMatrices[e]),this._cascadeMinExtents[e].z=t,this._cascadeMaxExtents[e].z=i,this._viewMatrices[e].multiplyToRef(this._projectionMatrices[e],this._transformMatrices[e]),a.e.TransformCoordinatesToRef(Hs,this._transformMatrices[e],Xs),Xs.scaleInPlace(this._mapSize/2),Ys.copyFromFloats(Math.round(Xs.x),Math.round(Xs.y),Math.round(Xs.z)),Ys.subtractInPlace(Xs).scaleInPlace(2/this._mapSize),a.a.TranslationToRef(Ys.x,Ys.y,0,Ks),this._projectionMatrices[e].multiplyToRef(Ks,this._projectionMatrices[e]),this._viewMatrices[e].multiplyToRef(this._projectionMatrices[e],this._transformMatrices[e]),this._transformMatrices[e].copyToArray(this._transformMatricesAsArray,16*e)}}},t.prototype._computeFrustumInWorldSpace=function(e){if(this._scene.activeCamera){var i=this._cascades[e].prevBreakDistance,n=this._cascades[e].breakDistance;this._scene.activeCamera.getViewMatrix();for(var r=a.a.Invert(this._scene.activeCamera.getTransformationMatrix()),o=0;o<t.frustumCornersNDCSpace.length;++o)a.e.TransformCoordinatesToRef(t.frustumCornersNDCSpace[o],r,this._frustumCornersWorldSpace[e][o]);for(o=0;o<t.frustumCornersNDCSpace.length/2;++o)Xs.copyFrom(this._frustumCornersWorldSpace[e][o+4]).subtractInPlace(this._frustumCornersWorldSpace[e][o]),Ys.copyFrom(Xs).scaleInPlace(i),Xs.scaleInPlace(n),Xs.addInPlace(this._frustumCornersWorldSpace[e][o]),this._frustumCornersWorldSpace[e][o+4].copyFrom(Xs),this._frustumCornersWorldSpace[e][o].addInPlace(Ys)}},t.prototype._computeCascadeFrustum=function(e){if(this._cascadeMinExtents[e].copyFromFloats(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cascadeMaxExtents[e].copyFromFloats(Number.MIN_VALUE,Number.MIN_VALUE,Number.MIN_VALUE),this._frustumCenter[e].copyFromFloats(0,0,0),this._scene.activeCamera){for(var t=0;t<this._frustumCornersWorldSpace[e].length;++t)this._frustumCenter[e].addInPlace(this._frustumCornersWorldSpace[e][t]);if(this._frustumCenter[e].scaleInPlace(1/this._frustumCornersWorldSpace[e].length),this.stabilizeCascades){var i=0;for(t=0;t<this._frustumCornersWorldSpace[e].length;++t){var n=this._frustumCornersWorldSpace[e][t].subtractToRef(this._frustumCenter[e],Xs).length();i=Math.max(i,n)}i=Math.ceil(16*i)/16,this._cascadeMaxExtents[e].copyFromFloats(i,i,i),this._cascadeMinExtents[e].copyFromFloats(-i,-i,-i)}else{var r=this._frustumCenter[e];this._frustumCenter[e].addToRef(this._lightDirection,Xs),a.a.LookAtLHToRef(r,Xs,Ws,Ks);for(t=0;t<this._frustumCornersWorldSpace[e].length;++t)a.e.TransformCoordinatesToRef(this._frustumCornersWorldSpace[e][t],Ks,Xs),this._cascadeMinExtents[e].minimizeInPlace(Xs),this._cascadeMaxExtents[e].maximizeInPlace(Xs)}}},Object.defineProperty(t,"IsSupported",{get:function(){var e=x.a.LastCreatedEngine;return!!e&&1!=e.webGLVersion},enumerable:!1,configurable:!0}),t.prototype._initializeGenerator=function(){var i,n,r,o,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T,E;this.penumbraDarkness=null!==(i=this.penumbraDarkness)&&void 0!==i?i:1,this._numCascades=null!==(n=this._numCascades)&&void 0!==n?n:t.DEFAULT_CASCADES_COUNT,this.stabilizeCascades=null!==(r=this.stabilizeCascades)&&void 0!==r&&r,this._freezeShadowCastersBoundingInfoObservable=null!==(o=this._freezeShadowCastersBoundingInfoObservable)&&void 0!==o?o:null,this.freezeShadowCastersBoundingInfo=null!==(s=this.freezeShadowCastersBoundingInfo)&&void 0!==s&&s,this._scbiMin=null!==(c=this._scbiMin)&&void 0!==c?c:new a.e(0,0,0),this._scbiMax=null!==(l=this._scbiMax)&&void 0!==l?l:new a.e(0,0,0),this._shadowCastersBoundingInfo=null!==(u=this._shadowCastersBoundingInfo)&&void 0!==u?u:new Tn.a(new a.e(0,0,0),new a.e(0,0,0)),this._breaksAreDirty=null===(h=this._breaksAreDirty)||void 0===h||h,this._minDistance=null!==(d=this._minDistance)&&void 0!==d?d:0,this._maxDistance=null!==(f=this._maxDistance)&&void 0!==f?f:1,this._currentLayer=null!==(p=this._currentLayer)&&void 0!==p?p:0,this._shadowMaxZ=null!==(g=null!==(_=this._shadowMaxZ)&&void 0!==_?_:null===(m=this._scene.activeCamera)||void 0===m?void 0:m.maxZ)&&void 0!==g?g:1e4,this._debug=null!==(v=this._debug)&&void 0!==v&&v,this._depthClamp=null===(b=this._depthClamp)||void 0===b||b,this._cascadeBlendPercentage=null!==(y=this._cascadeBlendPercentage)&&void 0!==y?y:.1,this._lambda=null!==(T=this._lambda)&&void 0!==T?T:.5,this._autoCalcDepthBounds=null!==(E=this._autoCalcDepthBounds)&&void 0!==E&&E,e.prototype._initializeGenerator.call(this)},t.prototype._createTargetRenderTexture=function(){var e={width:this._mapSize,height:this._mapSize,layers:this.numCascades};this._shadowMap=new Ni(this._light.name+"_shadowMap",e,this._scene,!1,!0,this._textureType,!1,void 0,!1,!1,void 0),this._shadowMap.createDepthStencilTexture(g.a.LESS,!0)},t.prototype._initializeShadowMap=function(){var i=this;if(e.prototype._initializeShadowMap.call(this),null!==this._shadowMap){this._transformMatricesAsArray=new Float32Array(16*this._numCascades),this._viewSpaceFrustumsZ=new Array(this._numCascades),this._frustumLengths=new Array(this._numCascades),this._lightSizeUVCorrection=new Array(2*this._numCascades),this._depthCorrection=new Array(this._numCascades),this._cascades=[],this._viewMatrices=[],this._projectionMatrices=[],this._transformMatrices=[],this._cascadeMinExtents=[],this._cascadeMaxExtents=[],this._frustumCenter=[],this._shadowCameraPos=[],this._frustumCornersWorldSpace=[];for(var n=0;n<this._numCascades;++n){this._cascades[n]={prevBreakDistance:0,breakDistance:0},this._viewMatrices[n]=a.a.Zero(),this._projectionMatrices[n]=a.a.Zero(),this._transformMatrices[n]=a.a.Zero(),this._cascadeMinExtents[n]=new a.e,this._cascadeMaxExtents[n]=new a.e,this._frustumCenter[n]=new a.e,this._shadowCameraPos[n]=new a.e,this._frustumCornersWorldSpace[n]=new Array(t.frustumCornersNDCSpace.length);for(var r=0;r<t.frustumCornersNDCSpace.length;++r)this._frustumCornersWorldSpace[n][r]=new a.e}this._shadowMap.onBeforeRenderObservable.add((function(e){if(i._currentLayer=e,i._scene.getSceneUniformBuffer().useUbo){var t=i._scene.getSceneUniformBuffer();t.updateMatrix("viewProjection",i.getCascadeTransformMatrix(e)),t.updateMatrix("view",i.getCascadeViewMatrix(e)),t.update()}})),this._shadowMap.onBeforeBindObservable.add((function(){i._breaksAreDirty&&i._splitFrustum(),i._computeMatrices()})),this._splitFrustum()}},t.prototype._bindCustomEffectForRenderSubMeshForShadowMap=function(e,t,i,n){var r,o,a,s,c,l;t.setMatrix(null!==(r=null==i?void 0:i.viewProjection)&&void 0!==r?r:"viewProjection",this.getCascadeTransformMatrix(this._currentLayer)),t.setMatrix(null!==(o=null==i?void 0:i.view)&&void 0!==o?o:"view",this.getCascadeViewMatrix(this._currentLayer)),t.setMatrix(null!==(a=null==i?void 0:i.projection)&&void 0!==a?a:"projection",this.getCascadeProjectionMatrix(this._currentLayer));var u=n.getWorldMatrix();t.setMatrix(null!==(s=null==i?void 0:i.world)&&void 0!==s?s:"world",u),u.multiplyToRef(this.getCascadeTransformMatrix(this._currentLayer),Ks),t.setMatrix(null!==(c=null==i?void 0:i.worldViewProjection)&&void 0!==c?c:"worldViewProjection",Ks),u.multiplyToRef(this.getCascadeViewMatrix(this._currentLayer),Qs),t.setMatrix(null!==(l=null==i?void 0:i.worldView)&&void 0!==l?l:"worldView",Qs)},t.prototype._isReadyCustomDefines=function(e,t,i){e.push("#define SM_DEPTHCLAMP "+(this._depthClamp&&this._filter!==Bs.FILTER_PCSS?"1":"0"))},t.prototype.prepareDefines=function(t,i){e.prototype.prepareDefines.call(this,t,i);var n=this._scene,r=this._light;if(n.shadowsEnabled&&r.shadowEnabled){t["SHADOWCSM"+i]=!0,t["SHADOWCSMDEBUG"+i]=this.debug,t["SHADOWCSMNUM_CASCADES"+i]=this.numCascades,t["SHADOWCSM_RIGHTHANDED"+i]=n.useRightHandedSystem;var o=n.activeCamera;o&&this._shadowMaxZ<o.maxZ&&(t["SHADOWCSMUSESHADOWMAXZ"+i]=!0),0===this.cascadeBlendPercentage&&(t["SHADOWCSMNOBLEND"+i]=!0)}},t.prototype.bindShadowLight=function(e,t){var i=this._light,n=this._scene;if(n.shadowsEnabled&&i.shadowEnabled){var r=n.activeCamera;if(r){var o=this.getShadowMap();if(o){var a=o.getSize().width;if(t.setMatrices("lightMatrix"+e,this._transformMatricesAsArray),t.setArray("viewFrustumZ"+e,this._viewSpaceFrustumsZ),t.setFloat("cascadeBlendFactor"+e,0===this.cascadeBlendPercentage?1e4:1/this.cascadeBlendPercentage),t.setArray("frustumLengths"+e,this._frustumLengths),this._filter===Bs.FILTER_PCF)t.setDepthStencilTexture("shadowSampler"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a,1/a,this.frustumEdgeFalloff,e);else if(this._filter===Bs.FILTER_PCSS){for(var s=0;s<this._numCascades;++s)this._lightSizeUVCorrection[2*s+0]=0===s?1:(this._cascadeMaxExtents[0].x-this._cascadeMinExtents[0].x)/(this._cascadeMaxExtents[s].x-this._cascadeMinExtents[s].x),this._lightSizeUVCorrection[2*s+1]=0===s?1:(this._cascadeMaxExtents[0].y-this._cascadeMinExtents[0].y)/(this._cascadeMaxExtents[s].y-this._cascadeMinExtents[s].y),this._depthCorrection[s]=0===s?1:(this._cascadeMaxExtents[s].z-this._cascadeMinExtents[s].z)/(this._cascadeMaxExtents[0].z-this._cascadeMinExtents[0].z);t.setDepthStencilTexture("shadowSampler"+e,o),t.setTexture("depthSampler"+e,o),t.setArray2("lightSizeUVCorrection"+e,this._lightSizeUVCorrection),t.setArray("depthCorrection"+e,this._depthCorrection),t.setFloat("penumbraDarkness"+e,this.penumbraDarkness),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/a,this._contactHardeningLightSizeUVRatio*a,this.frustumEdgeFalloff,e)}else t.setTexture("shadowSampler"+e,o),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),a,1/a,this.frustumEdgeFalloff,e);i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(r),this.getLight().getDepthMinZ(r)+this.getLight().getDepthMaxZ(r),e)}}}},t.prototype.getTransformMatrix=function(){return this.getCascadeTransformMatrix(0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._freezeShadowCastersBoundingInfoObservable&&(this._scene.onBeforeRenderObservable.remove(this._freezeShadowCastersBoundingInfoObservable),this._freezeShadowCastersBoundingInfoObservable=null),this._depthReducer&&(this._depthReducer.dispose(),this._depthReducer=null)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this),i=this.getShadowMap();if(!i)return t;if(t.numCascades=this._numCascades,t.debug=this._debug,t.stabilizeCascades=this.stabilizeCascades,t.lambda=this._lambda,t.cascadeBlendPercentage=this.cascadeBlendPercentage,t.depthClamp=this._depthClamp,t.autoCalcDepthBounds=this.autoCalcDepthBounds,t.shadowMaxZ=this._shadowMaxZ,t.penumbraDarkness=this.penumbraDarkness,t.freezeShadowCastersBoundingInfo=this._freezeShadowCastersBoundingInfo,t.minDistance=this.minDistance,t.maxDistance=this.maxDistance,t.renderList=[],i.renderList)for(var n=0;n<i.renderList.length;n++){var r=i.renderList[n];t.renderList.push(r.id)}return t},t.Parse=function(e,i){var n=Bs.Parse(e,i,(function(e,i){return new t(e,i)}));return void 0!==e.numCascades&&(n.numCascades=e.numCascades),void 0!==e.debug&&(n.debug=e.debug),void 0!==e.stabilizeCascades&&(n.stabilizeCascades=e.stabilizeCascades),void 0!==e.lambda&&(n.lambda=e.lambda),void 0!==e.cascadeBlendPercentage&&(n.cascadeBlendPercentage=e.cascadeBlendPercentage),void 0!==e.depthClamp&&(n.depthClamp=e.depthClamp),void 0!==e.autoCalcDepthBounds&&(n.autoCalcDepthBounds=e.autoCalcDepthBounds),void 0!==e.shadowMaxZ&&(n.shadowMaxZ=e.shadowMaxZ),void 0!==e.penumbraDarkness&&(n.penumbraDarkness=e.penumbraDarkness),void 0!==e.freezeShadowCastersBoundingInfo&&(n.freezeShadowCastersBoundingInfo=e.freezeShadowCastersBoundingInfo),void 0!==e.minDistance&&void 0!==e.maxDistance&&n.setMinMaxDistance(e.minDistance,e.maxDistance),n},t.frustumCornersNDCSpace=[new a.e(-1,1,-1),new a.e(1,1,-1),new a.e(1,-1,-1),new a.e(-1,-1,-1),new a.e(-1,1,1),new a.e(1,1,1),new a.e(1,-1,1),new a.e(-1,-1,1)],t.CLASSNAME="CascadedShadowGenerator",t.DEFAULT_CASCADES_COUNT=4,t.MIN_CASCADES_COUNT=2,t.MAX_CASCADES_COUNT=4,t._SceneComponentInitialization=function(e){throw Re.a.WarnImport("ShadowGeneratorSceneComponent")},t}(Bs);n.a.AddParser(Me.a.NAME_SHADOWGENERATOR,(function(e,t){if(void 0!==e.shadowGenerators&&null!==e.shadowGenerators)for(var i=0,n=e.shadowGenerators.length;i<n;i++){var r=e.shadowGenerators[i];r.className===qs.CLASSNAME?qs.Parse(r,t):Bs.Parse(r,t)}}));var Zs=function(){function e(e){this.name=Me.a.NAME_SHADOWGENERATOR,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Me.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 n=i[t].getShadowGenerator();n&&e.shadowGenerators.push(n.serialize())}},e.prototype.addFromContainer=function(e){},e.prototype.removeFromContainer=function(e,t){},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 n=t.lights[i],r=n.getShadowGenerator();if(n.isEnabled()&&n.shadowEnabled&&r){var o=r.getShadowMap();-1!==t.textures.indexOf(o)&&e.push(o)}}},e}();Bs._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_SHADOWGENERATOR);t||(t=new Zs(e),e._addComponent(t))},B.a.AddNodeConstructor("Light_Type_0",(function(e,t){return function(){return new Js(e,a.e.Zero(),t)}}));var Js=function(e){function t(t,i,n){var r=e.call(this,t,n)||this;return r._shadowAngle=Math.PI/2,r.position=i,r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!1,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:!1,configurable:!0}),t.prototype.getClassName=function(){return"PointLight"},t.prototype.getTypeID=function(){return kr.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 a.e(1,0,0);case 1:return new a.e(-1,0,0);case 2:return new a.e(0,-1,0);case 3:return new a.e(0,1,0);case 4:return new a.e(0,0,1);case 5:return new a.e(0,0,-1)}return a.e.Zero()},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){var n=this.getScene().activeCamera;n&&a.a.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),e)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",4),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.transferToNodeMaterialEffect=function(e,t){return this.computeTransformedInformation()?e.setFloat3(t,this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z):e.setFloat3(t,this.position.x,this.position.y,this.position.z),this},t.prototype.prepareLightSpecificDefines=function(e,t){e["POINTLIGHT"+t]=!0},Object(h.c)([Object(w.c)()],t.prototype,"shadowAngle",null),t}(zr),$s=function(){function e(e,t,i){var n=this;void 0===t&&(t=""),void 0===i&&(i="black"),this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=n._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(n._renderingCanvas).position;n._loadingDiv&&(n._loadingDiv.style.position="fixed"===t?"fixed":"absolute",n._loadingDiv.style.left=e.left+"px",n._loadingDiv.style.top=e.top+"px",n._loadingDiv.style.width=e.width+"px",n._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._loadingDiv.style.display="grid",this._loadingDiv.style.gridTemplateRows="100%",this._loadingDiv.style.gridTemplateColumns="100%",this._loadingDiv.style.justifyItems="center",this._loadingDiv.style.alignItems="center",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.style.zIndex="1",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var t=document.createElement("style");t.type="text/css";t.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(t);var i=!!window.SVGSVGElement,n=new Image;e.DefaultLogoUrl?n.src=e.DefaultLogoUrl:n.src=i?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxODAuMTcgMjA4LjA0Ij48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2ZmZjt9LmNscy0ye2ZpbGw6I2UwNjg0Yjt9LmNscy0ze2ZpbGw6I2JiNDY0Yjt9LmNscy00e2ZpbGw6I2UwZGVkODt9LmNscy01e2ZpbGw6I2Q1ZDJjYTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPkJhYnlsb25Mb2dvPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iUGFnZV9FbGVtZW50cyIgZGF0YS1uYW1lPSJQYWdlIEVsZW1lbnRzIj48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05MC4wOSwwLDAsNTJWMTU2bDkwLjA5LDUyLDkwLjA4LTUyVjUyWiIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtMiIgcG9pbnRzPSIxODAuMTcgNTIuMDEgMTUxLjk3IDM1LjczIDEyNC44NSA1MS4zOSAxNTMuMDUgNjcuNjcgMTgwLjE3IDUyLjAxIi8+PHBvbHlnb24gY2xhc3M9ImNscy0yIiBwb2ludHM9IjI3LjEyIDY3LjY3IDExNy4yMSAxNS42NiA5MC4wOCAwIDAgNTIuMDEgMjcuMTIgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTIiIHBvaW50cz0iNjEuODkgMTIwLjMgOTAuMDggMTM2LjU4IDExOC4yOCAxMjAuMyA5MC4wOCAxMDQuMDIgNjEuODkgMTIwLjMiLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDE1My4wNSAxNDAuMzcgOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyAwIDUyLjAxIDAgMTU2LjAzIDkwLjA4IDIwOC4wNCAxODAuMTcgMTU2LjAzIDE4MC4xNyA1Mi4wMSAxNTMuMDUgNjcuNjciLz48cG9seWdvbiBjbGFzcz0iY2xzLTMiIHBvaW50cz0iOTAuMDggNzEuNDYgNjEuODkgODcuNzQgNjEuODkgMTIwLjMgOTAuMDggMTA0LjAyIDExOC4yOCAxMjAuMyAxMTguMjggODcuNzQgOTAuMDggNzEuNDYiLz48cG9seWdvbiBjbGFzcz0iY2xzLTQiIHBvaW50cz0iMTUzLjA1IDY3LjY3IDExOC4yOCA4Ny43NCAxMTguMjggMTIwLjMgOTAuMDggMTM2LjU4IDkwLjA4IDE3Ni43MiAxNTMuMDUgMTQwLjM3IDE1My4wNSA2Ny42NyIvPjxwb2x5Z29uIGNsYXNzPSJjbHMtNSIgcG9pbnRzPSIyNy4xMiA2Ny42NyA2MS44OSA4Ny43NCA2MS44OSAxMjAuMyA5MC4wOCAxMzYuNTggOTAuMDggMTc2LjcyIDI3LjEyIDE0MC4zNyAyNy4xMiA2Ny42NyIvPjwvZz48L2c+PC9zdmc+":"https://cdn.babylonjs.com/Assets/babylonLogo.png",n.style.width="150px",n.style.gridColumn="1",n.style.gridRow="1",n.style.top="50%",n.style.left="50%",n.style.transform="translate(-50%, -50%)",n.style.position="absolute";var r=document.createElement("div");r.style.width="300px",r.style.gridColumn="1",r.style.gridRow="1",r.style.top="50%",r.style.left="50%",r.style.transform="translate(-50%, -50%)",r.style.position="absolute";var o=new Image;if(e.DefaultSpinnerUrl?o.src=e.DefaultSpinnerUrl:o.src=i?"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzOTIgMzkyIj48ZGVmcz48c3R5bGU+LmNscy0xe2ZpbGw6I2UwNjg0Yjt9LmNscy0ye2ZpbGw6bm9uZTt9PC9zdHlsZT48L2RlZnM+PHRpdGxlPlNwaW5uZXJJY29uPC90aXRsZT48ZyBpZD0iTGF5ZXJfMiIgZGF0YS1uYW1lPSJMYXllciAyIj48ZyBpZD0iU3Bpbm5lciI+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNDAuMjEsMTI2LjQzYzMuNy03LjMxLDcuNjctMTQuNDQsMTItMjEuMzJsMy4zNi01LjEsMy41Mi01YzEuMjMtMS42MywyLjQxLTMuMjksMy42NS00LjkxczIuNTMtMy4yMSwzLjgyLTQuNzlBMTg1LjIsMTg1LjIsMCwwLDEsODMuNCw2Ny40M2EyMDgsMjA4LDAsMCwxLDE5LTE1LjY2YzMuMzUtMi40MSw2Ljc0LTQuNzgsMTAuMjUtN3M3LjExLTQuMjgsMTAuNzUtNi4zMmM3LjI5LTQsMTQuNzMtOCwyMi41My0xMS40OSwzLjktMS43Miw3Ljg4LTMuMywxMi00LjY0YTEwNC4yMiwxMDQuMjIsMCwwLDEsMTIuNDQtMy4yMyw2Mi40NCw2Mi40NCwwLDAsMSwxMi43OC0xLjM5QTI1LjkyLDI1LjkyLDAsMCwxLDE5NiwyMS40NGE2LjU1LDYuNTUsMCwwLDEsMi4wNSw5LDYuNjYsNi42NiwwLDAsMS0xLjY0LDEuNzhsLS40MS4yOWEyMi4wNywyMi4wNywwLDAsMS01Ljc4LDMsMzAuNDIsMzAuNDIsMCwwLDEtNS42NywxLjYyLDM3LjgyLDM3LjgyLDAsMCwxLTUuNjkuNzFjLTEsMC0xLjkuMTgtMi44NS4yNmwtMi44NS4yNHEtNS43Mi41MS0xMS40OCwxLjFjLTMuODQuNC03LjcxLjgyLTExLjU4LDEuNGExMTIuMzQsMTEyLjM0LDAsMCwwLTIyLjk0LDUuNjFjLTMuNzIsMS4zNS03LjM0LDMtMTAuOTQsNC42NHMtNy4xNCwzLjUxLTEwLjYsNS41MUExNTEuNiwxNTEuNiwwLDAsMCw2OC41Niw4N0M2Ny4yMyw4OC40OCw2Niw5MCw2NC42NCw5MS41NnMtMi41MSwzLjE1LTMuNzUsNC43M2wtMy41NCw0LjljLTEuMTMsMS42Ni0yLjIzLDMuMzUtMy4zMyw1YTEyNywxMjcsMCwwLDAtMTAuOTMsMjEuNDksMS41OCwxLjU4LDAsMSwxLTMtMS4xNVM0MC4xOSwxMjYuNDcsNDAuMjEsMTI2LjQzWiIvPjxyZWN0IGNsYXNzPSJjbHMtMiIgd2lkdGg9IjM5MiIgaGVpZ2h0PSIzOTIiLz48L2c+PC9nPjwvc3ZnPg==":"https://cdn.babylonjs.com/Assets/loadingIcon.png",o.style.animation="spin1 0.75s infinite linear",o.style.webkitAnimation="spin1 0.75s infinite linear",o.style.transformOrigin="50% 50%",o.style.webkitTransformOrigin="50% 50%",!i){var a={w:16,h:18.5},s={w:30,h:30};n.style.width=a.w+"vh",n.style.height=a.h+"vh",n.style.left="calc(50% - "+a.w/2+"vh)",n.style.top="calc(50% - "+a.h/2+"vh)",o.style.width=s.w+"vh",o.style.height=s.h+"vh",o.style.left="calc(50% - "+s.w/2+"vh)",o.style.top="calc(50% - "+s.h/2+"vh)"}r.appendChild(o),this._loadingDiv.appendChild(n),this._loadingDiv.appendChild(r),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:!1,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:!1,configurable:!0}),e.DefaultLogoUrl="",e.DefaultSpinnerUrl="",e}();Se.a.DefaultLoadingScreenFactory=function(e){return new $s(e)};var ec=i(71),tc=i(68),ic=function(){function e(){}return e.ConvertPanoramaToCubemap=function(e,t,i,n){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*i*3)throw"ConvertPanoramaToCubemap: input size is wrong";return{front:this.CreateCubemapTexture(n,this.FACE_FRONT,e,t,i),back:this.CreateCubemapTexture(n,this.FACE_BACK,e,t,i),left:this.CreateCubemapTexture(n,this.FACE_LEFT,e,t,i),right:this.CreateCubemapTexture(n,this.FACE_RIGHT,e,t,i),up:this.CreateCubemapTexture(n,this.FACE_UP,e,t,i),down:this.CreateCubemapTexture(n,this.FACE_DOWN,e,t,i),size:n,type:g.a.TEXTURETYPE_FLOAT,format:g.a.TEXTUREFORMAT_RGB,gammaSpace:!1}},e.CreateCubemapTexture=function(e,t,i,n,r){for(var o=new ArrayBuffer(e*e*4*3),a=new Float32Array(o),s=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 m=this.CalcProjectionSpherical(_,i,n,r);a[h*e*3+3*p+0]=m.r,a[h*e*3+3*p+1]=m.g,a[h*e*3+3*p+2]=m.b,d=d.add(s),f=f.add(c)}u+=l}return a},e.CalcProjectionSpherical=function(e,t,i,n){for(var r=Math.atan2(e.z,e.x),o=Math.acos(e.y);r<-Math.PI;)r+=2*Math.PI;for(;r>Math.PI;)r-=2*Math.PI;var a=r/Math.PI,s=o/Math.PI;a=.5*a+.5;var c=Math.round(a*i);c<0?c=0:c>=i&&(c=i-1);var l=Math.round(s*n);l<0?l=0:l>=n&&(l=n-1);var u=n-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_LEFT=[new a.e(-1,-1,-1),new a.e(1,-1,-1),new a.e(-1,1,-1),new a.e(1,1,-1)],e.FACE_RIGHT=[new a.e(1,-1,1),new a.e(-1,-1,1),new a.e(1,1,1),new a.e(-1,1,1)],e.FACE_FRONT=[new a.e(1,-1,-1),new a.e(1,-1,1),new a.e(1,1,-1),new a.e(1,1,1)],e.FACE_BACK=[new a.e(-1,-1,1),new a.e(-1,-1,-1),new a.e(-1,1,1),new a.e(-1,1,-1)],e.FACE_DOWN=[new a.e(1,1,-1),new a.e(1,1,1),new a.e(-1,1,-1),new a.e(-1,1,1)],e.FACE_UP=[new a.e(-1,-1,-1),new a.e(-1,-1,1),new a.e(1,-1,-1),new a.e(1,-1,1)],e}(),nc=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,n,r,o){r>0?(r=this.Ldexp(1,r-136),e[o+0]=t*r,e[o+1]=i*r,e[o+2]=n*r):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var i="",n="",r=t;r<e.length-t&&"\n"!=(n=String.fromCharCode(e[r]));r++)i+=n;return i},e.RGBE_ReadHeader=function(e){var t,i,n=this.readStringLine(e,0);if("#"!=n[0]||"?"!=n[1])throw"Bad HDR Format.";var r=!1,o=!1,a=0;do{a+=n.length+1,"FORMAT=32-bit_rle_rgbe"==(n=this.readStringLine(e,a))?o=!0:0==n.length&&(r=!0)}while(!r);if(!o)throw"HDR Bad header format, unsupported FORMAT";a+=n.length+1,n=this.readStringLine(e,a);var s=/^\-Y (.*) \+X (.*)$/g.exec(n);if(!s||s.length<3)throw"HDR Bad header format, no size";if(i=parseInt(s[2]),t=parseInt(s[1]),i<8||i>32767)throw"HDR Bad header format, unsupported size";return{height:t,width:i,dataPosition:a+=n.length+1}},e.GetCubeMapTextureData=function(e,t){var i=new Uint8Array(e),n=this.RGBE_ReadHeader(i),r=this.RGBE_ReadPixels(i,n);return ic.ConvertPanoramaToCubemap(r,n.width,n.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,n,r,o,a,s=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),m=new Float32Array(_);s>0;){if(i=e[l++],n=e[l++],r=e[l++],o=e[l++],2!=i||2!=n||128&r||t.width<8||t.width>32767)return this.RGBE_ReadPixels_NOT_RLE(e,t);if((r<<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++],n=e[l++],i>128){if(0==(a=i-128)||a>h-u)throw"HDR Bad Format, bad scanline data (run)";for(;a-- >0;)p[u++]=n}else{if(0==(a=i)||a>h-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=n,--a>0)for(var g=0;g<a;g++)p[u++]=e[l++]}for(d=0;d<c;d++)i=p[d],n=p[d+c],r=p[d+2*c],o=p[d+3*c],this.Rgbe2float(m,i,n,r,o,(t.height-s)*c*3+3*d);s--}return m},e.RGBE_ReadPixels_NOT_RLE=function(e,t){for(var i,n,r,o,a,s=t.height,c=t.width,l=t.dataPosition,u=new ArrayBuffer(t.width*t.height*4*3),h=new Float32Array(u);s>0;){for(a=0;a<t.width;a++)i=e[l++],n=e[l++],r=e[l++],o=e[l++],this.Rgbe2float(h,i,n,r,o,(t.height-s)*c*3+3*a);s--}return h},e}(),rc=function(){function e(t,i){var n;void 0===i&&(i=e._DefaultOptions),this.engine=t,this._fullscreenViewport=new yi.a(0,0,1,1),i=Object(h.a)(Object(h.a)({},e._DefaultOptions),i),this._vertexBuffers=((n={})[Qi.b.PositionKind]=new Qi.b(t,i.positions,Qi.b.PositionKind,!1,!1,2),n),this._indexBuffer=t.createIndexBuffer(i.indices)}return e.prototype.setViewport=function(e){void 0===e&&(e=this._fullscreenViewport),this.engine.setViewport(e)},e.prototype.bindBuffers=function(e){this.engine.bindBuffers(this._vertexBuffers,this._indexBuffer,e)},e.prototype.applyEffectWrapper=function(e){this.engine.depthCullingState.depthTest=!1,this.engine.stencilState.stencilTest=!1,this.engine.enableEffect(e.effect),this.bindBuffers(e.effect),e.onApplyObservable.notifyObservers({})},e.prototype.restoreStates=function(){this.engine.depthCullingState.depthTest=!0,this.engine.stencilState.stencilTest=!0},e.prototype.draw=function(){this.engine.drawElementsType(g.a.MATERIAL_TriangleFillMode,0,6)},e.prototype.isRenderTargetTexture=function(e){return void 0!==e.renderList},e.prototype.render=function(e,t){if(void 0===t&&(t=null),e.effect.isReady()){this.setViewport();var i=null===t?null:this.isRenderTargetTexture(t)?t.getInternalTexture():t;i&&this.engine.bindFramebuffer(i),this.applyEffectWrapper(e),this.draw(),i&&this.engine.unBindFramebuffer(i),this.restoreStates()}},e.prototype.dispose=function(){var e=this._vertexBuffers[Qi.b.PositionKind];e&&(e.dispose(),delete this._vertexBuffers[Qi.b.PositionKind]),this._indexBuffer&&this.engine._releaseBuffer(this._indexBuffer)},e._DefaultOptions={positions:[1,1,-1,1,-1,-1,1,-1],indices:[0,1,2,0,2,3]},e}(),oc=function(){function e(e){var t,i=this;this.onApplyObservable=new o.c;var n=e.uniformNames||[];e.vertexShader?t={fragmentSource:e.fragmentShader,vertexSource:e.vertexShader,spectorName:e.name||"effectWrapper"}:(n.push("scale"),t={fragmentSource:e.fragmentShader,vertex:"postprocess",spectorName:e.name||"effectWrapper"},this.onApplyObservable.add((function(){i.effect.setFloat2("scale",1,1)})));var r=e.defines?e.defines.join("\n"):"";e.useShaderStore?(t.fragment=t.fragmentSource,t.vertex||(t.vertex=t.vertexSource),delete t.fragmentSource,delete t.vertexSource,this.effect=e.engine.createEffect(t.spectorName,e.attributeNames||["position"],n,e.samplerNames,r,void 0,e.onCompiled)):this.effect=new ai.a(t,e.attributeNames||["position"],n,e.samplerNames,e.engine,r,void 0,e.onCompiled)}return e.prototype.dispose=function(){this.effect.dispose()},e}(),ac="\nattribute vec2 position;\n\nvarying vec3 direction;\n\nuniform vec3 up;\nuniform vec3 right;\nuniform vec3 front;\nvoid main(void) {\nmat3 view=mat3(up,right,front);\ndirection=view*vec3(position,1.0);\ngl_Position=vec4(position,0.0,1.0);\n}";ai.a.ShadersStore.hdrFilteringVertexShader=ac;var sc="#include<helperFunctions>\n#include<importanceSampling>\n#include<pbrBRDFFunctions>\n#include<hdrFilteringFunctions>\nuniform float alphaG;\nuniform samplerCube inputTexture;\nuniform vec2 vFilteringInfo;\nuniform float hdrScale;\nvarying vec3 direction;\nvoid main() {\nvec3 color=radiance(alphaG,inputTexture,direction,vFilteringInfo);\ngl_FragColor=vec4(color*hdrScale,1.0);\n}";ai.a.ShadersStore.hdrFilteringPixelShader=sc;var cc=function(){function e(e,t){void 0===t&&(t={}),this._lodGenerationOffset=0,this._lodGenerationScale=.8,this.quality=g.a.TEXTURE_FILTERING_QUALITY_OFFLINE,this.hdrScale=1,this._engine=e,this.hdrScale=t.hdrScale||this.hdrScale,this.quality=t.hdrScale||this.quality}return e.prototype._createRenderTarget=function(e){var t=g.a.TEXTURETYPE_UNSIGNED_BYTE;this._engine.getCaps().textureHalfFloatRender?t=g.a.TEXTURETYPE_HALF_FLOAT:this._engine.getCaps().textureFloatRender&&(t=g.a.TEXTURETYPE_FLOAT);var i=this._engine.createRenderTargetCubeTexture(e,{format:g.a.TEXTUREFORMAT_RGBA,type:t,generateMipMaps:!1,generateDepthBuffer:!1,generateStencilBuffer:!1,samplingMode:g.a.TEXTURE_NEAREST_SAMPLINGMODE});return this._engine.updateTextureWrappingMode(i,g.a.TEXTURE_CLAMP_ADDRESSMODE,g.a.TEXTURE_CLAMP_ADDRESSMODE,g.a.TEXTURE_CLAMP_ADDRESSMODE),this._engine.updateTextureSamplingMode(g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,i,!0),i},e.prototype._prefilterInternal=function(e){var t=e.getSize().width,i=Math.round(L.a.Log2(t))+1,n=this._effectWrapper.effect,r=this._createRenderTarget(t);this._effectRenderer.setViewport();var o=e.getInternalTexture();o&&this._engine.updateTextureSamplingMode(g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,o,!0),this._effectRenderer.applyEffectWrapper(this._effectWrapper);var s=[[new a.e(0,0,-1),new a.e(0,-1,0),new a.e(1,0,0)],[new a.e(0,0,1),new a.e(0,-1,0),new a.e(-1,0,0)],[new a.e(1,0,0),new a.e(0,0,1),new a.e(0,1,0)],[new a.e(1,0,0),new a.e(0,0,-1),new a.e(0,-1,0)],[new a.e(1,0,0),new a.e(0,-1,0),new a.e(0,0,1)],[new a.e(-1,0,0),new a.e(0,-1,0),new a.e(0,0,-1)]];n.setFloat("hdrScale",this.hdrScale),n.setFloat2("vFilteringInfo",e.getSize().width,i),n.setTexture("inputTexture",e);for(var c=0;c<6;c++){n.setVector3("up",s[c][0]),n.setVector3("right",s[c][1]),n.setVector3("front",s[c][2]);for(var l=0;l<i;l++){this._engine.bindFramebuffer(r,c,void 0,void 0,!0,l),this._effectRenderer.applyEffectWrapper(this._effectWrapper);var u=Math.pow(2,(l-this._lodGenerationOffset)/this._lodGenerationScale)/t;0===l&&(u=0),n.setFloat("alphaG",u),this._effectRenderer.draw()}}return this._effectRenderer.restoreStates(),this._engine.restoreDefaultFramebuffer(),this._engine._releaseFramebufferObjects(r),this._engine._releaseTexture(e._texture),r._swapAndDie(e._texture),e._prefiltered=!0,e},e.prototype._createEffect=function(e,t){var i=[];return e.gammaSpace&&i.push("#define GAMMA_INPUT"),i.push("#define NUM_SAMPLES "+this.quality+"u"),new oc({engine:this._engine,name:"hdrFiltering",vertexShader:"hdrFiltering",fragmentShader:"hdrFiltering",samplerNames:["inputTexture"],uniformNames:["vSampleDirections","vWeights","up","right","front","vFilteringInfo","hdrScale","alphaG"],useShaderStore:!0,defines:i,onCompiled:t})},e.prototype.isReady=function(e){return e.isReady()&&this._effectWrapper.effect.isReady()},e.prototype.prefilter=function(e,t){var i=this;if(void 0===t&&(t=null),1!==this._engine.webGLVersion)return new Promise((function(n){i._effectRenderer=new rc(i._engine),i._effectWrapper=i._createEffect(e),i._effectWrapper.effect.executeWhenCompiled((function(){i._prefilterInternal(e),i._effectRenderer.dispose(),i._effectWrapper.dispose(),n(),t&&t()}))}));m.a.Warn("HDR prefiltering is not available in WebGL 1., you can use real time filtering instead.")},e}(),lc=function(e){function t(t,i,n,r,o,s,c,l,u){var h;void 0===r&&(r=!1),void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===c&&(c=!1),void 0===l&&(l=null),void 0===u&&(u=null);var d=e.call(this,i)||this;return d._generateHarmonics=!0,d._onLoad=null,d._onError=null,d._isBlocking=!0,d._rotationY=0,d.boundingBoxPosition=a.e.Zero(),t?(d._coordinatesMode=Ke.a.CUBIC_MODE,d.name=t,d.url=t,d.hasAlpha=!1,d.isCube=!0,d._textureMatrix=a.a.Identity(),d._prefilterOnLoad=c,d._onLoad=l,d._onError=u,d.gammaSpace=s,d._noMipmap=r,d._size=n,d._generateHarmonics=o,d._texture=d._getFromCache(t,d._noMipmap),d._texture?l&&(d._texture.isReady?Ce.b.SetImmediate((function(){return l()})):d._texture.onLoadedObservable.add(l)):(null===(h=d.getScene())||void 0===h?void 0:h.useDelayedTextureLoading)?d.delayLoadState=g.a.DELAYLOADSTATE_NOTLOADED:d.loadTexture(),d):d}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(a.a.RotationY(this._rotationY))},enumerable:!1,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(g.a.MATERIAL_TextureDirtyFlag)}},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"HDRCubeTexture"},t.prototype.loadTexture=function(){var e=this,i=this._getEngine();if(this._getEngine().webGLVersion>=2&&this._prefilterOnLoad){var n=this._onLoad,r=new cc(i);this._onLoad=function(){r.prefilter(e,n)}}this._texture=i.createRawCubeTextureFromUrl(this.url,this.getScene(),this._size,g.a.TEXTUREFORMAT_RGB,i.getCaps().textureFloat?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,(function(n){e.lodGenerationOffset=0,e.lodGenerationScale=.8;var r=nc.GetCubeMapTextureData(n,e._size);if(e._generateHarmonics){var o=$n.ConvertCubeMapToSphericalPolynomial(r);e.sphericalPolynomial=o}for(var a=[],s=null,c=0;c<6;c++){if(!i.getCaps().textureFloat){var l=new ArrayBuffer(e._size*e._size*3);s=new Uint8Array(l)}var u=r[t._facesMapping[c]];if(e.gammaSpace||s)for(var h=0;h<e._size*e._size;h++)if(e.gammaSpace&&(u[3*h+0]=Math.pow(u[3*h+0],Nt.b),u[3*h+1]=Math.pow(u[3*h+1],Nt.b),u[3*h+2]=Math.pow(u[3*h+2],Nt.b)),s){var d=Math.max(255*u[3*h+0],0),f=Math.max(255*u[3*h+1],0),p=Math.max(255*u[3*h+2],0),_=Math.max(Math.max(d,f),p);if(_>255){var m=255/_;d*=m,f*=m,p*=m}s[3*h+0]=d,s[3*h+1]=f,s[3*h+2]=p}s?a.push(s):a.push(u)}return a}),null,this._onLoad,this._onError)},t.prototype.clone=function(){var e=new t(this.url,this.getScene()||this._getEngine(),this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return e.level=this.level,e.wrapU=this.wrapU,e.wrapV=this.wrapV,e.coordinatesIndex=this.coordinatesIndex,e.coordinatesMode=this.coordinatesMode,e},t.prototype.delayLoad=function(){this.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=g.a.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,i=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&(null===(t=this.getScene())||void 0===t||t.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(i)})))},t.Parse=function(e,i,n){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(n+e.name,i,e.size,e.noMipmap,e.generateHarmonics,e.useInGammaSpace)).name=e.name,r.hasAlpha=e.hasAlpha,r.level=e.level,r.coordinatesMode=e.coordinatesMode,r.isBlocking=e.isBlocking),r&&(e.boundingBoxPosition&&(r.boundingBoxPosition=a.e.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(r.boundingBoxSize=a.e.FromArray(e.boundingBoxSize)),e.rotationY&&(r.rotationY=e.rotationY)),r},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}(Zn.a);c.a.RegisteredTypes["BABYLON.HDRCubeTexture"]=lc;var uc=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._uvs=null,this._uniqueId=0,this.onInfluenceChanged=new o.c,this._onDataLayoutChanged=new o.c,this._animationPropertiesOverride=null,this._scene=i||x.a.LastCreatedScene,this.influence=t,this._scene&&(this._uniqueId=this._scene.getUniqueId())}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:!1,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:!1,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasUVs",{get:function(){return!!this._uvs},enumerable:!1,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.setUVs=function(e){var t=this.hasUVs;this._uvs=e,t!==this.hasUVs&&this._onDataLayoutChanged.notifyObservers(void 0)},e.prototype.getUVs=function(){return this._uvs},e.prototype.clone=function(){var t=this,i=w.a.Clone((function(){return new e(t.name,t.influence,t._scene)}),this);return i._positions=this._positions,i._normals=this._normals,i._tangents=this._tangents,i._uvs=this._uvs,i},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())),this.hasUVs&&(e.uvs=Array.prototype.slice.call(this.getUVs())),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.uvs&&i.setUVs(t.uvs),t.animations)for(var n=0;n<t.animations.length;n++){var r=t.animations[n],o=c.a.GetClass("BABYLON.Animation");o&&i.animations.push(o.Parse(r))}return i},e.FromMesh=function(t,i,n){i||(i=t.name);var r=new e(i,n,t.getScene());return r.setPositions(t.getVerticesData(Qi.b.PositionKind)),t.isVerticesDataPresent(Qi.b.NormalKind)&&r.setNormals(t.getVerticesData(Qi.b.NormalKind)),t.isVerticesDataPresent(Qi.b.TangentKind)&&r.setTangents(t.getVerticesData(Qi.b.TangentKind)),t.isVerticesDataPresent(Qi.b.UVKind)&&r.setUVs(t.getVerticesData(Qi.b.UVKind)),r},Object(h.c)([Object(w.c)()],e.prototype,"id",void 0),e}(),hc=function(){function e(e){void 0===e&&(e=null),this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new oi.a(16),this._supportsNormals=!1,this._supportsTangents=!1,this._supportsUVs=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,this.enableNormalMorphing=!0,this.enableTangentMorphing=!0,this.enableUVMorphing=!0,e||(e=x.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"vertexCount",{get:function(){return this._vertexCount},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsNormals",{get:function(){return this._supportsNormals&&this.enableNormalMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsTangents",{get:function(){return this._supportsTangents&&this.enableTangentMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsUVs",{get:function(){return this._supportsUVs&&this.enableUVMorphing},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numTargets",{get:function(){return this._targets.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"numInfluencers",{get:function(){return this._activeTargets.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"influences",{get:function(){return this._influences},enumerable:!1,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.clone=function(){for(var t=new e(this._scene),i=0,n=this._targets;i<n.length;i++){var r=n[i];t.addTarget(r.clone())}return t.enableNormalMorphing=this.enableNormalMorphing,t.enableTangentMorphing=this.enableTangentMorphing,t.enableUVMorphing=this.enableUVMorphing,t},e.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t<i.length;t++){var n=i[t];e.targets.push(n.serialize())}return e},e.prototype._syncActiveTargets=function(e){var t=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0,this._supportsUVs=!0,this._vertexCount=0;for(var i=0,n=this._targets;i<n.length;i++){var r=n[i];if(0!==r.influence){this._activeTargets.push(r),this._tempInfluences[t++]=r.influence,this._supportsNormals=this._supportsNormals&&r.hasNormals,this._supportsTangents=this._supportsTangents&&r.hasTangents,this._supportsUVs=this._supportsUVs&&r.hasUVs;var o=r.getPositions();if(o){var a=o.length/3;if(0===this._vertexCount)this._vertexCount=a;else if(this._vertexCount!==a)return void m.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 s=0;s<t;s++)this._influences[s]=this._tempInfluences[s];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 n=new e(i);n._uniqueId=t.id;for(var r=0,o=t.targets;r<o.length;r++){var a=o[r];n.addTarget(uc.Parse(a))}return n},e}(),dc=i(32),fc=i(50),pc=function(){function e(t,i){if(void 0===i&&(i=e.DefaultPluginFactory()),this._physicsPlugin=i,this._impostors=[],this._joints=[],this._subTimeStep=0,!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new a.e(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return e.DefaultPluginFactory=function(){throw Re.a.WarnImport("CannonJSPlugin")},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.setSubTimeStep=function(e){void 0===e&&(e=0),this._subTimeStep=e},e.prototype.getSubTimeStep=function(){return this._subTimeStep},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);t>-1&&(this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e))},e.prototype.addJoint=function(e,t,i){var n={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(n),this._physicsPlugin.generateJoint(n)},e.prototype.removeJoint=function(e,t,i){var n=this._joints.filter((function(n){return n.connectedImpostor===t&&n.joint===i&&n.mainImpostor===e}));n.length&&this._physicsPlugin.removeJoint(n[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.prototype.raycast=function(e,t){return this._physicsPlugin.raycast(e,t)},e.Epsilon=.001,e}(),_c=function(){function e(){this._hasHit=!1,this._hitDistance=0,this._hitNormalWorld=a.e.Zero(),this._hitPointWorld=a.e.Zero(),this._rayFromWorld=a.e.Zero(),this._rayToWorld=a.e.Zero()}return Object.defineProperty(e.prototype,"hasHit",{get:function(){return this._hasHit},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hitDistance",{get:function(){return this._hitDistance},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hitNormalWorld",{get:function(){return this._hitNormalWorld},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hitPointWorld",{get:function(){return this._hitPointWorld},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rayFromWorld",{get:function(){return this._rayFromWorld},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rayToWorld",{get:function(){return this._rayToWorld},enumerable:!1,configurable:!0}),e.prototype.setHitData=function(e,t){this._hasHit=!0,this._hitNormalWorld=new a.e(e.x,e.y,e.z),this._hitPointWorld=new a.e(t.x,t.y,t.z)},e.prototype.setHitDistance=function(e){this._hitDistance=e},e.prototype.calculateHitDistance=function(){this._hitDistance=a.e.Distance(this._rayFromWorld,this._hitPointWorld)},e.prototype.reset=function(e,t){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Zero()),this._rayFromWorld=e,this._rayToWorld=t,this._hasHit=!1,this._hitDistance=0,this._hitNormalWorld=a.e.Zero(),this._hitPointWorld=a.e.Zero()},e}(),mc=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._physicsBodysToRemoveAfterStep=new Array,this._firstFrame=!0,this._minus90X=new a.b(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new a.b(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=a.e.Zero(),this._tmpDeltaPosition=a.e.Zero(),this._tmpUnityRotation=new a.b,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,this._cannonRaycastResult=new this.BJSCANNON.RaycastResult,this._raycastResult=new _c):m.a.Error("CannonJS is not available. Please make sure you included the js file.")}return e.prototype.setGravity=function(e){var t=e;this.world.gravity.set(t.x,t.y,t.z)},e.prototype.setTimeStep=function(e){this._fixedTimeStep=e},e.prototype.getTimeStep=function(){return this._fixedTimeStep},e.prototype.executeStep=function(e,t){if(this._firstFrame){this._firstFrame=!1;for(var i=0,n=t;i<n.length;i++){var r=n[i];r.type!=dc.a.HeightmapImpostor&&r.type!==dc.a.PlaneImpostor&&r.beforeStep()}}this.world.step(this._useDeltaForWorldStep?e:this._fixedTimeStep),this._removeMarkedPhysicsBodiesFromWorld()},e.prototype._removeMarkedPhysicsBodiesFromWorld=function(){var e=this;this._physicsBodysToRemoveAfterStep.length>0&&(this._physicsBodysToRemoveAfterStep.forEach((function(t){e.world.remove(t)})),this._physicsBodysToRemoveAfterStep=[])},e.prototype.applyImpulse=function(e,t,i){var n=new this.BJSCANNON.Vec3(i.x,i.y,i.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,n)},e.prototype.applyForce=function(e,t,i){var n=new this.BJSCANNON.Vec3(i.x,i.y,i.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(r,n)},e.prototype.generatePhysicsBody=function(e){if(this._removeMarkedPhysicsBodiesFromWorld(),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 n=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),r={mass:e.getParam("mass"),material:n},o=e.getParam("nativeOptions");for(var a in o)o.hasOwnProperty(a)&&(r[a]=o[a]);e.physicsBody=new this.BJSCANNON.Body(r),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){var n=i[t];e.physicsBody[t].set(n.x,n.y,n.z)})),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,i=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],n=e.object.rotationQuaternion;if(i.length){var r=function(i){if(n&&i.rotationQuaternion){var o=i.getPhysicsImpostor();if(o)if(o.parent!==e){var a=i.getAbsolutePosition().subtract(i.parent.getAbsolutePosition()),s=i.rotationQuaternion;o.physicsBody&&(t.removePhysicsBody(o),o.physicsBody=null),o.parent=e,o.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(o),new t.BJSCANNON.Vec3(a.x,a.y,a.z),new t.BJSCANNON.Quaternion(s.x,s.y,s.z,s.w)),e.physicsBody.mass+=o.getParam("mass")}n.multiplyInPlace(i.rotationQuaternion),i.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(r)}};i.filter((function(e){return!!e.physicsImpostor})).forEach(r)}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),-1===this._physicsBodysToRemoveAfterStep.indexOf(e.physicsBody)&&this._physicsBodysToRemoveAfterStep.push(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var n,r=e.joint.jointData,o={pivotA:r.mainPivot?(new this.BJSCANNON.Vec3).set(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z):null,pivotB:r.connectedPivot?(new this.BJSCANNON.Vec3).set(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z):null,axisA:r.mainAxis?(new this.BJSCANNON.Vec3).set(r.mainAxis.x,r.mainAxis.y,r.mainAxis.z):null,axisB:r.connectedAxis?(new this.BJSCANNON.Vec3).set(r.connectedAxis.x,r.connectedAxis.y,r.connectedAxis.z):null,maxForce:r.nativeParams.maxForce,collideConnected:!!r.collision};switch(e.joint.type){case fc.e.HingeJoint:case fc.e.Hinge2Joint:n=new this.BJSCANNON.HingeConstraint(t,i,o);break;case fc.e.DistanceJoint:n=new this.BJSCANNON.DistanceConstraint(t,i,r.maxDistance||2);break;case fc.e.SpringJoint:var a=r;n=new this.BJSCANNON.Spring(t,i,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case fc.e.LockJoint:n=new this.BJSCANNON.LockConstraint(t,i,o);break;case fc.e.PointToPointJoint:case fc.e.BallAndSocketJoint:default:n=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotB,o.maxForce)}n.collideConnected=!!r.collision,e.joint.physicsJoint=n,e.joint.type!==fc.e.SpringJoint?this.world.addConstraint(n):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){n.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==fc.e.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,i){var n,r;for(n=0;n<this._physicsMaterials.length;n++)if((r=this._physicsMaterials[n]).friction===t&&r.restitution===i)return r;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<pc.Epsilon?pc.Epsilon:e},e.prototype._createShape=function(e){var t,i=e.object,n=e.getObjectExtendSize();switch(e.type){case dc.a.SphereImpostor:var r=n.x,o=n.y,s=n.z;t=new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(r),this._checkWithEpsilon(o),this._checkWithEpsilon(s))/2);break;case dc.a.CylinderImpostor:var c=e.getParam("nativeOptions");c||(c={});var l=void 0!==c.radiusTop?c.radiusTop:this._checkWithEpsilon(n.x)/2,u=void 0!==c.radiusBottom?c.radiusBottom:this._checkWithEpsilon(n.x)/2,h=void 0!==c.height?c.height:this._checkWithEpsilon(n.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 p=new this.BJSCANNON.Vec3(0,0,0);t.transformAllPoints(p,f);break;case dc.a.BoxImpostor:var _=n.scale(.5);t=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(_.x),this._checkWithEpsilon(_.y),this._checkWithEpsilon(_.z)));break;case dc.a.PlaneImpostor:m.a.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),t=new this.BJSCANNON.Plane;break;case dc.a.MeshImpostor:var g=i.getVerticesData?i.getVerticesData(Qi.b.PositionKind):[],v=i.getIndices?i.getIndices():[];if(!g)return;var b=i.position.clone(),y=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,S=i.computeWorldMatrix(!0),A=new Array;for(E=0;E<g.length;E+=3)a.e.TransformCoordinates(a.e.FromArray(g,E),S).toArray(A,E);m.a.Warn("MeshImpostor only collides against spheres."),t=new this.BJSCANNON.Trimesh(A,v),i.position.copyFrom(b),y&&i.rotation&&i.rotation.copyFrom(y),T&&i.rotationQuaternion&&i.rotationQuaternion.copyFrom(T);break;case dc.a.HeightmapImpostor:var P=i.position.clone(),C=i.rotation&&i.rotation.clone(),R=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),C&&i.rotation&&i.rotation.copyFrom(C),R&&i.rotationQuaternion&&i.rotationQuaternion.copyFrom(R),i.computeWorldMatrix(!0);break;case dc.a.ParticleImpostor:t=new this.BJSCANNON.Particle;break;case dc.a.NoImpostor:t=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0,0,0))}return t},e.prototype._createHeightmap=function(e,t){var i,n=e.getVerticesData(Qi.b.PositionKind),r=e.computeWorldMatrix(!0),o=new Array;for(i=0;i<n.length;i+=3)a.e.TransformCoordinates(a.e.FromArray(n,i),r).toArray(o,i);n=o;for(var s=new Array,c=t||~~(Math.sqrt(n.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<n.length;f+=3){var p=Math.round(n[f+0]/d+c/2),_=Math.round(-1*(n[f+1]/d-c/2)),m=-n[f+2]+h;s[p]||(s[p]=[]),s[p][_]||(s[p][_]=m),s[p][_]=Math.max(m,s[p][_])}for(p=0;p<=c;++p){if(!s[p]){for(var g=1;!s[(p+g)%c];)g++;s[p]=s[(p+g)%c].slice()}for(_=0;_<=c;++_)if(!s[p][_]){var v;for(g=1;void 0===v;)v=s[p][(_+g++)%c];s[p][_]=v}}var b=new this.BJSCANNON.Heightfield(s,{elementSize:d});return b.minY=h,b},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 n=t.rotationQuaternion;if(n){if(e.type!==dc.a.PlaneImpostor&&e.type!==dc.a.HeightmapImpostor||(n=n.multiply(this._minus90X),e.setDeltaRotation(this._plus90X)),e.type===dc.a.HeightmapImpostor){var r=t,o=r.getBoundingInfo(),s=r.rotationQuaternion;r.rotationQuaternion=this._tmpUnityRotation,r.computeWorldMatrix(!0);var c=i.clone(),l=r.getPivotMatrix();l=l?l.clone():a.a.Identity();var u=a.a.Translation(o.boundingBox.extendSizeWorld.x,0,-o.boundingBox.extendSizeWorld.z);r.setPreTransformMatrix(u),r.computeWorldMatrix(!0);var h=o.boundingBox.centerWorld.subtract(i).subtract(r.position).negate();this._tmpPosition.copyFromFloats(h.x,h.y-o.boundingBox.extendSizeWorld.y,h.z),this._tmpDeltaPosition.copyFrom(o.boundingBox.centerWorld.subtract(c)),this._tmpDeltaPosition.y+=o.boundingBox.extendSizeWorld.y,r.rotationQuaternion=s,r.setPreTransformMatrix(l),r.computeWorldMatrix(!0)}else e.type===dc.a.MeshImpostor&&this._tmpDeltaPosition.copyFromFloats(0,0,0);e.setDeltaPosition(this._tmpDeltaPosition),e.physicsBody.position.set(this._tmpPosition.x,this._tmpPosition.y,this._tmpPosition.z),e.physicsBody.quaternion.set(n.x,n.y,n.z,n.w)}}},e.prototype.setTransformationFromPhysicsBody=function(e){if(e.object.position.set(e.physicsBody.position.x,e.physicsBody.position.y,e.physicsBody.position.z),e.object.rotationQuaternion){var t=e.physicsBody.quaternion;e.object.rotationQuaternion.set(t.x,t.y,t.z,t.w)}},e.prototype.setPhysicsBodyTransformation=function(e,t,i){e.physicsBody.position.set(t.x,t.y,t.z),e.physicsBody.quaternion.set(i.x,i.y,i.z,i.w)},e.prototype.isSupported=function(){return void 0!==this.BJSCANNON},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.velocity.set(t.x,t.y,t.z)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.set(t.x,t.y,t.z)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.velocity;return t?new a.e(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new a.e(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,n){n||(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,n,r){if(r=r||10,0===(n=n||0))this.internalStep(i),this.time+=i;else{var o=Math.floor((this.time+n)/i)-Math.floor(this.time/i);o=Math.min(o,r)||1;for(var a=performance.now(),s=0;s!==o&&(this.internalStep(i),!(performance.now()-a>1e3*i));s++);this.time+=n;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.set(d.position.x,d.position.y,d.position.z),d.interpolatedQuaternion.set(d.quaternion.x,d.quaternion.y,d.quaternion.z,d.quaternion.w))}}}},e.prototype.raycast=function(e,t){return this._cannonRaycastResult.reset(),this.world.raycastClosest(e,t,{},this._cannonRaycastResult),this._raycastResult.reset(e,t),this._cannonRaycastResult.hasHit&&(this._raycastResult.setHitData({x:this._cannonRaycastResult.hitNormalWorld.x,y:this._cannonRaycastResult.hitNormalWorld.y,z:this._cannonRaycastResult.hitNormalWorld.z},{x:this._cannonRaycastResult.hitPointWorld.x,y:this._cannonRaycastResult.hitPointWorld.y,z:this._cannonRaycastResult.hitPointWorld.z}),this._raycastResult.setHitDistance(this._cannonRaycastResult.distance)),this._raycastResult},e}();pc.DefaultPluginFactory=function(){return new mc};var gc=function(){function e(e,t,i){void 0===e&&(e=!0),void 0===i&&(i=OIMO),this._useDeltaForWorldStep=e,this.name="OimoJSPlugin",this._fixedTimeStep=1/60,this._tmpImpostorsArray=[],this._tmpPositionVector=a.e.Zero(),this.BJSOIMO=i,this.world=new this.BJSOIMO.World({iterations:t}),this.world.clear(),this._raycastResult=new _c}return e.prototype.setGravity=function(e){this.world.gravity.set(e.x,e.y,e.z)},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.timeStep=this._useDeltaForWorldStep?e:this._fixedTimeStep,this.world.step(),t.forEach((function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e}));for(var n=this.world.contacts;null!==n;)if(!n.touching||n.body1.sleeping||n.body2.sleeping){var r=this._tmpImpostorsArray[+n.body1.name],o=this._tmpImpostorsArray[+n.body2.name];r&&o?(r.onCollide({body:o.physicsBody,point:null}),o.onCollide({body:r.physicsBody,point:null}),n=n.next):n=n.next}else n=n.next},e.prototype.applyImpulse=function(e,t,i){var n=e.physicsBody.mass;e.physicsBody.applyImpulse(i.scale(this.world.invScale),t.scale(this.world.invScale*n))},e.prototype.applyForce=function(e,t,i){m.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")||.001,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},n=[e];(s=e.object).getChildMeshes&&s.getChildMeshes().forEach((function(e){e.physicsImpostor&&n.push(e.physicsImpostor)}));var r=function(e){return Math.max(e,pc.Epsilon)},o=new a.b;n.forEach((function(n){if(n.object.rotationQuaternion){var a=n.object.rotationQuaternion;o.copyFrom(a),n.object.rotationQuaternion.set(0,0,0,1),n.object.computeWorldMatrix(!0);var s=o.toEulerAngles(),c=n.getObjectExtendSize();if(n===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=n.object.position.clone();i.posShape.push(u.x),i.posShape.push(u.y),i.posShape.push(u.z),i.rotShape.push(57.29577951308232*s.x,57.29577951308232*s.y,57.29577951308232*s.z)}switch(n.object.rotationQuaternion.copyFrom(o),n.type){case dc.a.ParticleImpostor:m.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case dc.a.SphereImpostor:var h=c.x,d=c.y,f=c.z,p=Math.max(r(h),r(d),r(f))/2;i.type.push("sphere"),i.size.push(p),i.size.push(p),i.size.push(p);break;case dc.a.CylinderImpostor:var _=r(c.x)/2,g=r(c.y);i.type.push("cylinder"),i.size.push(_),i.size.push(g),i.size.push(g);break;case dc.a.PlaneImpostor:case dc.a.BoxImpostor:default:_=r(c.x),g=r(c.y);var v=r(c.z);i.type.push("box"),i.size.push(_),i.size.push(g),i.size.push(v)}n.object.rotationQuaternion=a}})),e.physicsBody=this.world.add(i),e.physicsBody.resetQuaternion(o),e.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var s;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 n,r=e.joint.jointData,o=r.nativeParams||{},a={body1:t,body2:i,axe1:o.axe1||(r.mainAxis?r.mainAxis.asArray():null),axe2:o.axe2||(r.connectedAxis?r.connectedAxis.asArray():null),pos1:o.pos1||(r.mainPivot?r.mainPivot.asArray():null),pos2:o.pos2||(r.connectedPivot?r.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||r.collision,spring:o.spring,world:this.world};switch(e.joint.type){case fc.e.BallAndSocketJoint:n="jointBall";break;case fc.e.SpringJoint:m.a.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var s=r;a.min=s.length||a.min,a.max=Math.max(a.min,a.max);case fc.e.DistanceJoint:n="jointDistance",a.max=r.maxDistance;break;case fc.e.PrismaticJoint:n="jointPrisme";break;case fc.e.SliderJoint:n="jointSlide";break;case fc.e.WheelJoint:n="jointWheel";break;case fc.e.HingeJoint:default:n="jointHinge"}a.type=n,e.joint.physicsJoint=this.world.add(a)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){m.a.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){if(!e.physicsBody.sleeping){if(e.physicsBody.shapes.next){for(var t=e.physicsBody.shapes;t.next;)t=t.next;e.object.position.set(t.position.x,t.position.y,t.position.z)}else{var i=e.physicsBody.getPosition();e.object.position.set(i.x,i.y,i.z)}if(e.object.rotationQuaternion){var n=e.physicsBody.getQuaternion();e.object.rotationQuaternion.set(n.x,n.y,n.z,n.w)}}},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var n=e.physicsBody;e.physicsBody.shapes.next||(n.position.set(t.x,t.y,t.z),n.orientation.set(i.x,i.y,i.z,i.w),n.syncShapes(),n.awake())},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.set(t.x,t.y,t.z)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.set(t.x,t.y,t.z)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new a.e(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new a.e(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,n){void 0!==i?m.a.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter"):i=1e6,t*=-1;var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setMotor(t,i)},e.prototype.setLimit=function(e,t,i,n){var r=n?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.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.prototype.raycast=function(e,t){return m.a.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(e,t),this._raycastResult},e}(),vc=i(97),bc=function(){function e(e,t,i){var n=this;void 0===e&&(e=!0),void 0===t&&(t=Ammo),void 0===i&&(i=null),this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new a.b,this._tmpContactCallbackResult=!1,this._tmpContactPoint=new a.e,this._tmpMatrix=new a.a,"function"==typeof t?t(this.bjsAMMO):this.bjsAMMO=t,this.isSupported()?(this._collisionConfiguration=new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,this._dispatcher=new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),this._overlappingPairCache=i||new this.bjsAMMO.btDbvtBroadphase,this._solver=new this.bjsAMMO.btSequentialImpulseConstraintSolver,this._softBodySolver=new this.bjsAMMO.btDefaultSoftBodySolver,this.world=new this.bjsAMMO.btSoftRigidDynamicsWorld(this._dispatcher,this._overlappingPairCache,this._solver,this._collisionConfiguration,this._softBodySolver),this._tmpAmmoConcreteContactResultCallback=new this.bjsAMMO.ConcreteContactResultCallback,this._tmpAmmoConcreteContactResultCallback.addSingleResult=function(e,t,i,r){var o=(e=n.bjsAMMO.wrapPointer(e,Ammo.btManifoldPoint)).getPositionWorldOnA();n._tmpContactPoint.x=o.x(),n._tmpContactPoint.y=o.y(),n._tmpContactPoint.z=o.z(),n._tmpContactCallbackResult=!0},this._raycastResult=new _c,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),this._tmpAmmoVectorD=new this.bjsAMMO.btVector3(0,0,0)):m.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),this.world.getWorldInfo().set_m_gravity(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,n=t;i<n.length;i++){var r=n[i];r.soft||r.beforeStep()}this._stepSimulation(this._useDeltaForWorldStep?e:this._timeStep,this._maxSteps,this._fixedTimeStep);for(var o=0,a=t;o<a.length;o++){var s=a[o];if(s.soft?this._afterSoftStep(s):s.afterStep(),s._onPhysicsCollideCallbacks.length>0&&this._isImpostorInContact(s))for(var c=0,l=s._onPhysicsCollideCallbacks;c<l.length;c++)for(var u=0,h=l[c].otherImpostors;u<h.length;u++){var d=h[u];(s.physicsBody.isActive()||d.physicsBody.isActive())&&this._isImpostorPairInContact(s,d)&&(s.onCollide({body:d.physicsBody,point:this._tmpContactPoint}),d.onCollide({body:s.physicsBody,point:this._tmpContactPoint}))}}},e.prototype._afterSoftStep=function(e){e.type===dc.a.RopeImpostor?this._ropeStep(e):this._softbodyOrClothStep(e)},e.prototype._ropeStep=function(e){for(var t,i,n,r,o=e.physicsBody.get_m_nodes(),s=o.size(),c=new Array,l=0;l<s;l++)i=(t=o.at(l).get_m_x()).x(),n=t.y(),r=t.z(),c.push(new a.e(i,n,r));var u=e.object,h=e.getParam("shape");e._isFromLine?e.object=Or.a.CreateLines("lines",{points:c,instance:u}):e.object=vc.a.ExtrudeShape("ext",{shape:h,path:c,instance:u})},e.prototype._softbodyOrClothStep=function(e){var t=e.type===dc.a.ClothImpostor?1:-1,i=e.object,n=i.getVerticesData(Qi.b.PositionKind);n||(n=[]);var r=i.getVerticesData(Qi.b.NormalKind);r||(r=[]);for(var o,a,s,c,l,u,h,d,f=n.length/3,p=e.physicsBody.get_m_nodes(),_=0;_<f;_++){var m;s=(a=(o=p.at(_)).get_m_x()).x(),c=a.y(),l=a.z()*t,u=(m=o.get_m_n()).x(),h=m.y(),d=m.z()*t,n[3*_]=s,n[3*_+1]=c,n[3*_+2]=l,r[3*_]=u,r[3*_+1]=h,r[3*_+2]=d}var g=new Ki.a;g.positions=n,g.normals=r,g.uvs=i.getVerticesData(Qi.b.UVKind),g.colors=i.getVerticesData(Qi.b.ColorKind),i&&i.getIndices&&(g.indices=i.getIndices()),g.applyToMesh(i)},e.prototype.applyImpulse=function(e,t,i){if(e.soft)m.a.Warn("Cannot be applied to a soft body");else{e.physicsBody.activate();var n=this._tmpAmmoVectorA,r=this._tmpAmmoVectorB;e.object&&e.object.getWorldMatrix&&i.subtractInPlace(e.object.getWorldMatrix().getTranslation()),n.setValue(i.x,i.y,i.z),r.setValue(t.x,t.y,t.z),e.physicsBody.applyImpulse(r,n)}},e.prototype.applyForce=function(e,t,i){if(e.soft)m.a.Warn("Cannot be applied to a soft body");else{e.physicsBody.activate();var n=this._tmpAmmoVectorA,r=this._tmpAmmoVectorB;e.object&&e.object.getWorldMatrix&&i.subtractInPlace(e.object.getWorldMatrix().getTranslation()),n.setValue(i.x,i.y,i.z),r.setValue(t.x,t.y,t.z),e.physicsBody.applyForce(r,n)}},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),n=t.getParam("mass");if(t._pluginData.mass=n,t.soft)i.get_m_cfg().set_collisions(17),i.get_m_cfg().set_kDP(t.getParam("damping")),this.bjsAMMO.castObject(i,this.bjsAMMO.btCollisionObject).getCollisionShape().setMargin(t.getParam("margin")),i.setActivationState(e.DISABLE_DEACTIVATION_FLAG),this.world.addSoftBody(i,1,-1),t.physicsBody=i,t._pluginData.toDispose.push(i),this.setBodyPressure(t,0),t.type===dc.a.SoftbodyImpostor&&this.setBodyPressure(t,t.getParam("pressure")),this.setBodyStiffness(t,t.getParam("stiffness")),this.setBodyVelocityIterations(t,t.getParam("velocityIterations")),this.setBodyPositionIterations(t,t.getParam("positionIterations"));else{var r=new this.bjsAMMO.btVector3(0,0,0),o=new this.bjsAMMO.btTransform;o.setIdentity(),0!==n&&i.calculateLocalInertia(n,r),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 a=new this.bjsAMMO.btDefaultMotionState(o),s=new this.bjsAMMO.btRigidBodyConstructionInfo(n,a,i,r),c=new this.bjsAMMO.btRigidBody(s);0===n&&(c.setCollisionFlags(c.getCollisionFlags()|e.KINEMATIC_FLAG),c.setActivationState(e.DISABLE_DEACTIVATION_FLAG)),t.type!=dc.a.NoImpostor||i.getChildShape||c.setCollisionFlags(c.getCollisionFlags()|e.DISABLE_COLLISION_FLAG);var l=t.getParam("group"),u=t.getParam("mask");l&&u?this.world.addRigidBody(c,l,u):this.world.addRigidBody(c),t.physicsBody=c,t._pluginData.toDispose=t._pluginData.toDispose.concat([c,s,a,o,r,i])}this.setBodyRestitution(t,t.getParam("restitution")),this.setBodyFriction(t,t.getParam("friction"))}},e.prototype.removePhysicsBody=function(e){var t=this;this.world&&(e.soft?this.world.removeSoftBody(e.physicsBody):this.world.removeRigidBody(e.physicsBody),e._pluginData&&(e._pluginData.toDispose.forEach((function(e){t.bjsAMMO.destroy(e)})),e._pluginData.toDispose=[]))},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var n,r=e.joint.jointData;switch(r.mainPivot||(r.mainPivot=new a.e(0,0,0)),r.connectedPivot||(r.connectedPivot=new a.e(0,0,0)),e.joint.type){case fc.e.DistanceJoint:var o=r.maxDistance;o&&(r.mainPivot=new a.e(0,-o/2,0),r.connectedPivot=new a.e(0,o/2,0)),n=new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));break;case fc.e.HingeJoint:r.mainAxis||(r.mainAxis=new a.e(0,0,0)),r.connectedAxis||(r.connectedAxis=new a.e(0,0,0));var s=new this.bjsAMMO.btVector3(r.mainAxis.x,r.mainAxis.y,r.mainAxis.z),c=new this.bjsAMMO.btVector3(r.connectedAxis.x,r.connectedAxis.y,r.connectedAxis.z);n=new this.bjsAMMO.btHingeConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z),s,c);break;case fc.e.BallAndSocketJoint:n=new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z));break;default:m.a.Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint"),n=new this.bjsAMMO.btPoint2PointConstraint(t,i,new this.bjsAMMO.btVector3(r.mainPivot.x,r.mainPivot.y,r.mainPivot.z),new this.bjsAMMO.btVector3(r.connectedPivot.x,r.connectedPivot.y,r.connectedPivot.z))}this.world.addConstraint(n,!e.joint.jointData.collision),e.joint.physicsJoint=n}},e.prototype.removeJoint=function(e){this.world&&this.world.removeConstraint(e.joint.physicsJoint)},e.prototype._addMeshVerts=function(e,t,i){var n=this,r=0;if(i&&i.getIndices&&i.getWorldMatrix&&i.getChildMeshes){var o=i.getIndices();o||(o=[]);var s=i.getVerticesData(Qi.b.PositionKind);s||(s=[]),i.computeWorldMatrix(!1);for(var c=o.length/3,l=0;l<c;l++){for(var u=[],h=0;h<3;h++){var d,f=new a.e(s[3*o[3*l+h]+0],s[3*o[3*l+h]+1],s[3*o[3*l+h]+2]);a.a.ScalingToRef(i.scaling.x,i.scaling.y,i.scaling.z,this._tmpMatrix),f=a.e.TransformCoordinates(f,this._tmpMatrix),(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]),r++}i.getChildMeshes().forEach((function(i){r+=n._addMeshVerts(e,t,i)}))}return r},e.prototype._softVertexData=function(e){var t=e.object;if(t&&t.getIndices&&t.getWorldMatrix&&t.getChildMeshes){var i=t.getIndices();i||(i=[]);var n=t.getVerticesData(Qi.b.PositionKind);n||(n=[]);var r=t.getVerticesData(Qi.b.NormalKind);r||(r=[]),t.computeWorldMatrix(!1);for(var o=[],s=[],c=0;c<n.length;c+=3){var l=new a.e(n[c],n[c+1],n[c+2]),u=new a.e(r[c],r[c+1],r[c+2]);l=a.e.TransformCoordinates(l,t.getWorldMatrix()),u=a.e.TransformNormal(u,t.getWorldMatrix()),o.push(l.x,l.y,l.z),s.push(u.x,u.y,u.z)}var h=new Ki.a;return h.positions=o,h.normals=s,h.uvs=t.getVerticesData(Qi.b.UVKind),h.colors=t.getVerticesData(Qi.b.ColorKind),t&&t.getIndices&&(h.indices=t.getIndices()),h.applyToMesh(t),t.position=a.e.Zero(),t.rotationQuaternion=null,t.rotation=a.e.Zero(),t.computeWorldMatrix(!0),h}return Ki.a.ExtractFromMesh(t)},e.prototype._createSoftbody=function(e){var t=e.object;if(t&&t.getIndices){var i=t.getIndices();i||(i=[]);var n=this._softVertexData(e),r=n.positions,o=n.normals;if(null===r||null===o)return new this.bjsAMMO.btCompoundShape;for(var s=[],c=[],l=0;l<r.length;l+=3){var u=new a.e(r[l],r[l+1],r[l+2]),h=new a.e(o[l],o[l+1],o[l+2]);s.push(u.x,u.y,-u.z),c.push(h.x,h.y,-h.z)}var d=(new this.bjsAMMO.btSoftBodyHelpers).CreateFromTriMesh(this.world.getWorldInfo(),s,t.getIndices(),i.length/3,!0),f=r.length/3,p=d.get_m_nodes();for(l=0;l<f;l++){var _;(_=p.at(l).get_m_n()).setX(c[3*l]),_.setY(c[3*l+1]),_.setZ(c[3*l+2])}return d}},e.prototype._createCloth=function(e){var t=e.object;if(t&&t.getIndices){var i=t.getIndices();i||(i=[]);var n=this._softVertexData(e),r=n.positions,o=n.normals;if(null===r||null===o)return new this.bjsAMMO.btCompoundShape;var a=r.length,s=Math.sqrt(a/3);e.segments=s;var c=s-1;return this._tmpAmmoVectorA.setValue(r[0],r[1],r[2]),this._tmpAmmoVectorB.setValue(r[3*c],r[3*c+1],r[3*c+2]),this._tmpAmmoVectorD.setValue(r[a-3],r[a-2],r[a-1]),this._tmpAmmoVectorC.setValue(r[a-3-3*c],r[a-2-3*c],r[a-1-3*c]),(new this.bjsAMMO.btSoftBodyHelpers).CreatePatch(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,this._tmpAmmoVectorC,this._tmpAmmoVectorD,s,s,e.getParam("fixedPoints"),!0)}},e.prototype._createRope=function(e){var t,i,n=this._softVertexData(e),r=n.positions,o=n.normals;if(null===r||null===o)return new this.bjsAMMO.btCompoundShape;n.applyToMesh(e.object,!0),e._isFromLine=!0;if(0===o.map((function(e){return e*e})).reduce((function(e,t){return e+t})))i=(t=r.length)/3-1,this._tmpAmmoVectorA.setValue(r[0],r[1],r[2]),this._tmpAmmoVectorB.setValue(r[t-3],r[t-2],r[t-1]);else{e._isFromLine=!1;var a=e.getParam("path");if(null===e.getParam("shape"))return m.a.Warn("No shape available for extruded mesh"),new this.bjsAMMO.btCompoundShape;if(r.length%(3*a.length)!=0)return m.a.Warn("Path does not match extrusion"),new this.bjsAMMO.btCompoundShape;i=(t=a.length)-1,this._tmpAmmoVectorA.setValue(a[0].x,a[0].y,a[0].z),this._tmpAmmoVectorB.setValue(a[t-1].x,a[t-1].y,a[t-1].z)}e.segments=i;var s=e.getParam("fixedPoints");s=s>3?3:s;var c=(new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,i-1,s);return c.get_m_cfg().set_collisions(17),c},e.prototype._createCustom=function(e){var t=null;return this.onCreateCustomShape&&(t=this.onCreateCustomShape(e)),null==t&&(t=new this.bjsAMMO.btCompoundShape),t},e.prototype._addHullVerts=function(e,t,i){var n=this,r=0;if(i&&i.getIndices&&i.getWorldMatrix&&i.getChildMeshes){var o=i.getIndices();o||(o=[]);var s=i.getVerticesData(Qi.b.PositionKind);s||(s=[]),i.computeWorldMatrix(!1);for(var c=o.length/3,l=0;l<c;l++){for(var u=[],h=0;h<3;h++){var d,f=new a.e(s[3*o[3*l+h]+0],s[3*o[3*l+h]+1],s[3*o[3*l+h]+2]);a.a.ScalingToRef(i.scaling.x,i.scaling.y,i.scaling.z,this._tmpMatrix),f=a.e.TransformCoordinates(f,this._tmpMatrix),(d=0==h?this._tmpAmmoVectorA:1==h?this._tmpAmmoVectorB:this._tmpAmmoVectorC).setValue(f.x,f.y,f.z),u.push(d)}e.addPoint(u[0],!0),e.addPoint(u[1],!0),e.addPoint(u[2],!0),r++}i.getChildMeshes().forEach((function(i){r+=n._addHullVerts(e,t,i)}))}return r},e.prototype._createShape=function(e,t){var i=this;void 0===t&&(t=!1);var n,r=e.object,o=e.getObjectExtendSize();if(!t){var s=e.object.getChildMeshes?e.object.getChildMeshes(!0):[];n=new this.bjsAMMO.btCompoundShape;var c=0;if(s.forEach((function(e){var t=e.getPhysicsImpostor();if(t){if(t.type==dc.a.MeshImpostor)throw"A child MeshImpostor is not supported. Only primitive impostors are supported as children (eg. box or sphere)";var r=i._createShape(t),o=e.parent.getWorldMatrix().clone(),s=new a.e;o.decompose(s),i._tmpAmmoTransform.getOrigin().setValue(e.position.x*s.x,e.position.y*s.y,e.position.z*s.z),i._tmpAmmoQuaternion.setValue(e.rotationQuaternion.x,e.rotationQuaternion.y,e.rotationQuaternion.z,e.rotationQuaternion.w),i._tmpAmmoTransform.setRotation(i._tmpAmmoQuaternion),n.addChildShape(i._tmpAmmoTransform,r),t.dispose(),c++}})),c>0){if(e.type!=dc.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),n.addChildShape(this._tmpAmmoTransform,l))}return n}this.bjsAMMO.destroy(n),n=null}switch(e.type){case dc.a.SphereImpostor:if(L.a.WithinEpsilon(o.x,o.y,1e-4)&&L.a.WithinEpsilon(o.x,o.z,1e-4))n=new this.bjsAMMO.btSphereShape(o.x/2);else{var u=[new this.bjsAMMO.btVector3(0,0,0)];(n=new this.bjsAMMO.btMultiSphereShape(u,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x/2,o.y/2,o.z/2))}break;case dc.a.CapsuleImpostor:n=new this.bjsAMMO.btCapsuleShape(o.x/2,o.y/2);break;case dc.a.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),n=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case dc.a.PlaneImpostor:case dc.a.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),n=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case dc.a.MeshImpostor:if(0==e.getParam("mass")){var h=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(h);var d=this._addMeshVerts(h,r,r);n=0==d?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(h);break}case dc.a.ConvexHullImpostor:var f=new this.bjsAMMO.btConvexHullShape;0==(d=this._addHullVerts(f,r,r))?(e._pluginData.toDispose.push(f),n=new this.bjsAMMO.btCompoundShape):n=f;break;case dc.a.NoImpostor:n=new this.bjsAMMO.btSphereShape(o.x/2);break;case dc.a.CustomImpostor:n=this._createCustom(e);break;case dc.a.SoftbodyImpostor:n=this._createSoftbody(e);break;case dc.a.ClothImpostor:n=this._createCloth(e);break;case dc.a.RopeImpostor:n=this._createRope(e);break;default:m.a.Warn("The impostor type is not currently supported by the ammo plugin.")}return n},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 n=e.physicsBody.getWorldTransform();if(Math.abs(n.getOrigin().x()-t.x)>Nt.a||Math.abs(n.getOrigin().y()-t.y)>Nt.a||Math.abs(n.getOrigin().z()-t.z)>Nt.a||Math.abs(n.getRotation().x()-i.x)>Nt.a||Math.abs(n.getRotation().y()-i.y)>Nt.a||Math.abs(n.getRotation().z()-i.z)>Nt.a||Math.abs(n.getRotation().w()-i.w)>Nt.a)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),n.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(i.x,i.y,i.z,i.w),n.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(n),0==e.mass){var r=e.physicsBody.getMotionState();r&&r.setWorldTransform(n)}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.soft?e.physicsBody.linearVelocity(this._tmpAmmoVectorA):e.physicsBody.setLinearVelocity(this._tmpAmmoVectorA)},e.prototype.setAngularVelocity=function(e,t){this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),e.soft?e.physicsBody.angularVelocity(this._tmpAmmoVectorA):e.physicsBody.setAngularVelocity(this._tmpAmmoVectorA)},e.prototype.getLinearVelocity=function(e){if(e.soft)var t=e.physicsBody.linearVelocity();else t=e.physicsBody.getLinearVelocity();if(!t)return null;var i=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},e.prototype.getAngularVelocity=function(e){if(e.soft)var t=e.physicsBody.angularVelocity();else t=e.physicsBody.getAngularVelocity();if(!t)return null;var i=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),i},e.prototype.setBodyMass=function(e,t){e.soft?e.physicsBody.setTotalMass(t,!1):e.physicsBody.setMassProps(t),e._pluginData.mass=t},e.prototype.getBodyMass=function(e){return e._pluginData.mass||0},e.prototype.getBodyFriction=function(e){return e._pluginData.friction||0},e.prototype.setBodyFriction=function(e,t){e.soft?e.physicsBody.get_m_cfg().set_kDF(t):e.physicsBody.setFriction(t),e._pluginData.friction=t},e.prototype.getBodyRestitution=function(e){return e._pluginData.restitution||0},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.setRestitution(t),e._pluginData.restitution=t},e.prototype.getBodyPressure=function(e){return e.soft?e._pluginData.pressure||0:(m.a.Warn("Pressure is not a property of a rigid body"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===dc.a.SoftbodyImpostor?(e.physicsBody.get_m_cfg().set_kPR(t),e._pluginData.pressure=t):(e.physicsBody.get_m_cfg().set_kPR(0),e._pluginData.pressure=0):m.a.Warn("Pressure can only be applied to a softbody")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:(m.a.Warn("Stiffness is not a property of a rigid body"),0)},e.prototype.setBodyStiffness=function(e,t){e.soft?(t=(t=t<0?0:t)>1?1:t,e.physicsBody.get_m_materials().at(0).set_m_kLST(t),e._pluginData.stiffness=t):m.a.Warn("Stiffness cannot be applied to a rigid body")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:(m.a.Warn("Velocity iterations is not a property of a rigid body"),0)},e.prototype.setBodyVelocityIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_viterations(t),e._pluginData.velocityIterations=t):m.a.Warn("Velocity iterations cannot be applied to a rigid body")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:(m.a.Warn("Position iterations is not a property of a rigid body"),0)},e.prototype.setBodyPositionIterations=function(e,t){e.soft?(t=t<0?0:t,e.physicsBody.get_m_cfg().set_piterations(t),e._pluginData.positionIterations=t):m.a.Warn("Position iterations cannot be applied to a rigid body")},e.prototype.appendAnchor=function(e,t,i,n,r,o){void 0===r&&(r=1),void 0===o&&(o=!1);var a=e.segments,s=Math.round((a-1)*i)+a*(a-1-Math.round((a-1)*n));e.physicsBody.appendAnchor(s,t.physicsBody,o,r)},e.prototype.appendHook=function(e,t,i,n,r){void 0===n&&(n=1),void 0===r&&(r=!1);var o=Math.round(e.segments*i);e.physicsBody.appendAnchor(o,t.physicsBody,r,n)},e.prototype.sleepBody=function(e){m.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){m.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},e.prototype.setMotor=function(e,t,i,n){e.physicsJoint.enableAngularMotor(!0,t,i)},e.prototype.setLimit=function(e,t,i){m.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(){this.bjsAMMO.destroy(this.world),this.bjsAMMO.destroy(this._solver),this.bjsAMMO.destroy(this._overlappingPairCache),this.bjsAMMO.destroy(this._dispatcher),this.bjsAMMO.destroy(this._collisionConfiguration),this.bjsAMMO.destroy(this._tmpAmmoVectorA),this.bjsAMMO.destroy(this._tmpAmmoVectorB),this.bjsAMMO.destroy(this._tmpAmmoVectorC),this.bjsAMMO.destroy(this._tmpAmmoTransform),this.bjsAMMO.destroy(this._tmpAmmoQuaternion),this.bjsAMMO.destroy(this._tmpAmmoConcreteContactResultCallback),this.world=null},e.prototype.raycast=function(e,t){this._tmpAmmoVectorRCA=new this.bjsAMMO.btVector3(e.x,e.y,e.z),this._tmpAmmoVectorRCB=new this.bjsAMMO.btVector3(t.x,t.y,t.z);var i=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);return this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,i),this._raycastResult.reset(e,t),i.hasHit()&&(this._raycastResult.setHitData({x:i.get_m_hitNormalWorld().x(),y:i.get_m_hitNormalWorld().y(),z:i.get_m_hitNormalWorld().z()},{x:i.get_m_hitPointWorld().x(),y:i.get_m_hitPointWorld().y(),z:i.get_m_hitPointWorld().z()}),this._raycastResult.calculateHitDistance()),this.bjsAMMO.destroy(i),this.bjsAMMO.destroy(this._tmpAmmoVectorRCA),this.bjsAMMO.destroy(this._tmpAmmoVectorRCB),this._raycastResult},e.DISABLE_COLLISION_FLAG=4,e.KINEMATIC_FLAG=2,e.DISABLE_DEACTIVATION_FLAG=4,e}();n.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},n.a.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var yc=function(){function e(e,t,i,n,r){var o=this;void 0===n&&(n=!0),void 0===r&&(r=!1),this.name=e,this._viewMatrix=a.a.Identity(),this._target=a.e.Zero(),this._add=a.e.Zero(),this._invertYAxis=!1,this.position=a.e.Zero(),this._scene=i,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this);var s=g.a.TEXTURETYPE_UNSIGNED_BYTE;if(r){var c=this._scene.getEngine().getCaps();c.textureHalfFloatRender?s=g.a.TEXTURETYPE_HALF_FLOAT:c.textureFloatRender&&(s=g.a.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new Ni(e,t,i,n,!0,s,!0),this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(e){case 0:o._add.copyFromFloats(1,0,0);break;case 1:o._add.copyFromFloats(-1,0,0);break;case 2:o._add.copyFromFloats(0,o._invertYAxis?1:-1,0);break;case 3:o._add.copyFromFloats(0,o._invertYAxis?-1:1,0);break;case 4:o._add.copyFromFloats(0,0,1);break;case 5:o._add.copyFromFloats(0,0,-1)}o._attachedMesh&&o.position.copyFrom(o._attachedMesh.getAbsolutePosition()),o.position.addToRef(o._add,o._target),a.a.LookAtLHToRef(o.position,o._target,a.e.Up(),o._viewMatrix),i.activeCamera&&(o._projectionMatrix=a.a.PerspectiveFovLH(Math.PI/2,1,i.activeCamera.minZ,i.activeCamera.maxZ),i.setTransformMatrix(o._viewMatrix,o._projectionMatrix)),i._forcedViewPosition=o.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!1,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!1,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,n){var r=null;if(i.reflectionProbes)for(var o=0;o<i.reflectionProbes.length;o++){var a=i.reflectionProbes[o];if(a.name===t.name){r=a;break}}return(r=w.a.Parse((function(){return r||new e(t.name,t.renderTargetSize,i,t._generateMipMaps)}),t,i,n)).cubeTexture._waitingRenderList=t.renderList,t._attachedMesh&&r.attachToMesh(i.getMeshByID(t._attachedMesh)),r},Object(h.c)([Object(w.k)()],e.prototype,"_attachedMesh",void 0),Object(h.c)([Object(w.o)()],e.prototype,"position",void 0),e}(),Tc=!0,Ec=function(){function e(){}return e.LoaderInjectedPhysicsEngine=void 0,e}(),Sc=function(e,t,i,n){for(var r=0,o=t.materials.length;r<o;r++){var a=t.materials[r];if(a.id===e)return xo.a.Parse(a,i,n)}return null},Ac=function(e,t,i){for(var n in t)if(e.name===t[n])return i.push(e.id),!0;return!(!e.parentId||-1===i.indexOf(e.parentId))&&(i.push(e.id),!0)},Pc=function(e,t){return e+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")},Cc=function(e,t){var i=t;if(t._waitingData.lods){if(t._waitingData.lods.ids&&t._waitingData.lods.ids.length>0){var n=t._waitingData.lods.ids,r=i.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=n.length){var a=o.length>n.length?o[o.length-1]:0;i.setEnabled(!1);for(var s=0;s<n.length;s++){var c=n[s],l=e.getMeshByID(c);null!=l&&i.addLODLevel(o[s],l)}a>0&&i.addLODLevel(a,null),!0===r&&i.setEnabled(!0)}else Ce.b.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},Rc=function(e,t,i,r,o){void 0===o&&(o=!1);var a=new Ee(e),s="importScene has failed JSON parse";try{var l=JSON.parse(t);s="";var u,h,d=pr.loggingLevel===pr.DETAILED_LOGGING;if(void 0!==l.environmentTexture&&null!==l.environmentTexture){var f=void 0===l.isPBR||l.isPBR;if(l.environmentTextureType&&"BABYLON.HDRCubeTexture"===l.environmentTextureType){var p=l.environmentTextureSize?l.environmentTextureSize:128,_=new lc((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e,p,!0,!f);l.environmentTextureRotationY&&(_.rotationY=l.environmentTextureRotationY),e.environmentTexture=_}else if(io.a.EndsWith(l.environmentTexture,".env")){var g=new no((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e);l.environmentTextureRotationY&&(g.rotationY=l.environmentTextureRotationY),e.environmentTexture=g}else{var v=no.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g)?"":i)+l.environmentTexture,e);l.environmentTextureRotationY&&(v.rotationY=l.environmentTextureRotationY),e.environmentTexture=v}if(!0===l.createDefaultSkybox){var b=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,y=l.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,f,b,y)}a.environmentTexture=e.environmentTexture}if(void 0!==l.environmentIntensity&&null!==l.environmentIntensity&&(e.environmentIntensity=l.environmentIntensity),void 0!==l.lights&&null!==l.lights)for(u=0,h=l.lights.length;u<h;u++){var T=l.lights[u],E=kr.a.Parse(T,e);E&&(a.lights.push(E),s+=0===u?"\n\tLights:":"",s+="\n\t\t"+E.toString(d))}if(void 0!==l.reflectionProbes&&null!==l.reflectionProbes)for(u=0,h=l.reflectionProbes.length;u<h;u++){var S=l.reflectionProbes[u],A=yc.Parse(S,e,i);A&&(a.reflectionProbes.push(A),s+=0===u?"\n\tReflection Probes:":"",s+="\n\t\t"+A.toString(d))}if(void 0!==l.animations&&null!==l.animations)for(u=0,h=l.animations.length;u<h;u++){var P=l.animations[u],C=c.a.GetClass("BABYLON.Animation");if(C){var R=C.Parse(P);e.animations.push(R),a.animations.push(R),s+=0===u?"\n\tAnimations:":"",s+="\n\t\t"+R.toString(d)}}if(void 0!==l.materials&&null!==l.materials)for(u=0,h=l.materials.length;u<h;u++){var x=l.materials[u],O=xo.a.Parse(x,e,i);if(O)a.materials.push(O),s+=0===u?"\n\tMaterials:":"",s+="\n\t\t"+O.toString(d),O.getActiveTextures().forEach((function(e){-1==a.textures.indexOf(e)&&a.textures.push(e)}))}if(void 0!==l.multiMaterials&&null!==l.multiMaterials)for(u=0,h=l.multiMaterials.length;u<h;u++){var I=l.multiMaterials[u],D=tc.a.ParseMultiMaterial(I,e);a.multiMaterials.push(D),s+=0===u?"\n\tMultiMaterials:":"",s+="\n\t\t"+D.toString(d),D.getActiveTextures().forEach((function(e){-1==a.textures.indexOf(e)&&a.textures.push(e)}))}if(void 0!==l.morphTargetManagers&&null!==l.morphTargetManagers)for(var N=0,L=l.morphTargetManagers;N<L.length;N++){var w=L[N];a.morphTargetManagers.push(hc.Parse(w,e))}if(void 0!==l.skeletons&&null!==l.skeletons)for(u=0,h=l.skeletons.length;u<h;u++){var F=l.skeletons[u],B=tt.Parse(F,e);a.skeletons.push(B),s+=0===u?"\n\tSkeletons:":"",s+="\n\t\t"+B.toString(d)}var U=l.geometries;if(null!=U){var V=new Array,k=U.vertexData;if(null!=k)for(u=0,h=k.length;u<h;u++){var z=k[u];V.push(ec.a.Parse(z,e,i))}V.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 G=l.transformNodes[u],j=Nr.a.Parse(G,e,i);a.transformNodes.push(j)}if(void 0!==l.meshes&&null!==l.meshes)for(u=0,h=l.meshes.length;u<h;u++){var W=l.meshes[u],H=be.a.Parse(W,e,i);if(a.meshes.push(H),H.hasInstances)for(var X=0,Y=H.instances;X<Y.length;X++){var K=Y[X];a.meshes.push(K)}s+=0===u?"\n\tMeshes:":"",s+="\n\t\t"+H.toString(d)}if(void 0!==l.cameras&&null!==l.cameras)for(u=0,h=l.cameras.length;u<h;u++){var Q=l.cameras[u],q=je.a.Parse(Q,e);a.cameras.push(q),s+=0===u?"\n\tCameras:":"",s+="\n\t\t"+q.toString(d)}if(void 0!==l.postProcesses&&null!==l.postProcesses)for(u=0,h=l.postProcesses.length;u<h;u++){var Z=l.postProcesses[u],J=li.Parse(Z,e,i);J&&(a.postProcesses.push(J),s+=0===u?"\nPostprocesses:":"",s+="\n\t\t"+J.toString())}if(void 0!==l.animationGroups&&null!==l.animationGroups)for(u=0,h=l.animationGroups.length;u<h;u++){var $=l.animationGroups[u],ee=ie.Parse($,e);a.animationGroups.push(ee),s+=0===u?"\n\tAnimationGroups:":"",s+="\n\t\t"+ee.toString(d)}for(u=0,h=e.cameras.length;u<h;u++){(q=e.cameras[u])._waitingParentId&&(q.parent=e.getLastEntryByID(q._waitingParentId),q._waitingParentId=null)}for(u=0,h=e.lights.length;u<h;u++){var te=e.lights[u];te&&te._waitingParentId&&(te.parent=e.getLastEntryByID(te._waitingParentId),te._waitingParentId=null)}for(u=0,h=e.transformNodes.length;u<h;u++){var ne=e.transformNodes[u];ne._waitingParentId&&(ne.parent=e.getLastEntryByID(ne._waitingParentId),ne._waitingParentId=null)}for(u=0,h=e.meshes.length;u<h;u++){(H=e.meshes[u])._waitingParentId&&(H.parent=e.getLastEntryByID(H._waitingParentId),H._waitingParentId=null),H._waitingData.lods&&Cc(e,H)}for(u=0,h=e.skeletons.length;u<h;u++){(B=e.skeletons[u])._hasWaitingData&&(null!=B.bones&&B.bones.forEach((function(t){if(t._waitingTransformNodeId){var i=e.getLastEntryByID(t._waitingTransformNodeId);i&&t.linkTransformNode(i),t._waitingTransformNodeId=null}})),B._waitingOverrideMeshId&&(B.overrideMesh=e.getMeshByID(B._waitingOverrideMeshId),B._waitingOverrideMeshId=null),B._hasWaitingData=null)}for(u=0,h=e.meshes.length;u<h;u++){var re=e.meshes[u];re._waitingData.freezeWorldMatrix?(re.freezeWorldMatrix(),re._waitingData.freezeWorldMatrix=null):re.computeWorldMatrix(!0)}for(u=0,h=e.lights.length;u<h;u++){var oe=e.lights[u];if(oe._excludedMeshesIds.length>0){for(var ae=0;ae<oe._excludedMeshesIds.length;ae++){var se=e.getMeshByID(oe._excludedMeshesIds[ae]);se&&oe.excludedMeshes.push(se)}oe._excludedMeshesIds=[]}if(oe._includedOnlyMeshesIds.length>0){for(var ce=0;ce<oe._includedOnlyMeshesIds.length;ce++){var le=e.getMeshByID(oe._includedOnlyMeshesIds[ce]);le&&oe.includedOnlyMeshes.push(le)}oe._includedOnlyMeshesIds=[]}}for(n.a.Parse(l,e,a,i),u=0,h=e.meshes.length;u<h;u++){(H=e.meshes[u])._waitingData.actions&&(M.Parse(H._waitingData.actions,H,e),H._waitingData.actions=null)}void 0!==l.actions&&null!==l.actions&&M.Parse(l.actions,null,e)}catch(e){var ue=Pc("loadAssets",l?l.producer:"Unknown")+s;if(!r)throw m.a.Log(ue),e;r(ue,e)}finally{o||a.removeAllFromScene(),null!==s&&pr.loggingLevel!==pr.NO_LOGGING&&m.a.Log(Pc("loadAssets",l?l.producer:"Unknown")+(pr.loggingLevel!==pr.MINIMAL_LOGGING?s:""))}return a};pr.RegisterPlugin({name:"babylon.js",extensions:".babylon",canDirectLoad:function(e){return-1!==e.indexOf("babylon")},importMesh:function(e,t,i,r,o,a,s,c){var l="importMesh has failed JSON parse";try{var u=JSON.parse(i);l="";var h=pr.loggingLevel===pr.DETAILED_LOGGING;e?Array.isArray(e)||(e=[e]):e=null;var d=new Array;if(void 0!==u.meshes&&null!==u.meshes){var f,p,_,g=[],v=[];for(f=0,p=u.meshes.length;f<p;f++){var b=u.meshes[f];if(null===e||Ac(b,e,d)){if(null!==e&&delete e[e.indexOf(b.name)],void 0!==b.geometryId&&null!==b.geometryId&&void 0!==u.geometries&&null!==u.geometries){var y=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach((function(e){!0!==y&&u.geometries[e]&&Array.isArray(u.geometries[e])&&u.geometries[e].forEach((function(i){if(i.id===b.geometryId){switch(e){case"vertexData":ec.a.Parse(i,t,r)}y=!0}}))})),!1===y&&m.a.Warn("Geometry not found for mesh "+b.id)}if(b.materialId){var T=-1!==v.indexOf(b.materialId);if(!1===T&&void 0!==u.multiMaterials&&null!==u.multiMaterials)for(var E=0,S=u.multiMaterials.length;E<S;E++){var A=u.multiMaterials[E];if(A.id===b.materialId){for(var P=0,C=A.materials.length;P<C;P++){var R,x=A.materials[P];v.push(x),(R=Sc(x,u,t,r))&&(l+="\n\tMaterial "+R.toString(h))}v.push(A.id);var O=tc.a.ParseMultiMaterial(A,t);O&&(T=!0,l+="\n\tMulti-Material "+O.toString(h));break}}if(!1===T)v.push(b.materialId),(R=Sc(b.materialId,u,t,r))?l+="\n\tMaterial "+R.toString(h):m.a.Warn("Material not found for mesh "+b.id)}if(b.skeletonId>-1&&void 0!==u.skeletons&&null!==u.skeletons)if(!1===g.indexOf(b.skeletonId)>-1)for(var M=0,I=u.skeletons.length;M<I;M++){var D=u.skeletons[M];if(D.id===b.skeletonId){var N=tt.Parse(D,t);s.push(N),g.push(D.id),l+="\n\tSkeleton "+N.toString(h)}}if(void 0!==u.morphTargetManagers&&null!==u.morphTargetManagers)for(var L=0,w=u.morphTargetManagers;L<w.length;L++){var F=w[L];hc.Parse(F,t)}var B=be.a.Parse(b,t,r);o.push(B),l+="\n\tMesh "+B.toString(h)}}for(f=0,p=t.meshes.length;f<p;f++)(_=t.meshes[f])._waitingParentId&&(_.parent=t.getLastEntryByID(_._waitingParentId),_._waitingParentId=null),_._waitingData.lods&&Cc(t,_);for(f=0,p=t.skeletons.length;f<p;f++){(N=t.skeletons[f])._hasWaitingData&&(null!=N.bones&&N.bones.forEach((function(e){if(e._waitingTransformNodeId){var i=t.getLastEntryByID(e._waitingTransformNodeId);i&&e.linkTransformNode(i),e._waitingTransformNodeId=null}})),N._waitingOverrideMeshId&&(N.overrideMesh=t.getMeshByID(N._waitingOverrideMeshId),N._waitingOverrideMeshId=null),N._hasWaitingData=null)}for(f=0,p=t.meshes.length;f<p;f++)(_=t.meshes[f])._waitingData.freezeWorldMatrix?(_.freezeWorldMatrix(),_._waitingData.freezeWorldMatrix=null):_.computeWorldMatrix(!0)}if(void 0!==u.particleSystems&&null!==u.particleSystems){var U=n.a.GetIndividualParser(Me.a.NAME_PARTICLESYSTEM);if(U)for(f=0,p=u.particleSystems.length;f<p;f++){var V=u.particleSystems[f];-1!==d.indexOf(V.emitterId)&&a.push(U(V,t,r))}}return!0}catch(e){var k=Pc("importMesh",u?u.producer:"Unknown")+l;if(!c)throw m.a.Log(k),e;c(k,e)}finally{null!==l&&pr.loggingLevel!==pr.NO_LOGGING&&m.a.Log(Pc("importMesh",u?u.producer:"Unknown")+(pr.loggingLevel!==pr.MINIMAL_LOGGING?l:""))}return!1},load:function(e,t,i,n){var r="importScene has failed JSON parse";try{var o=JSON.parse(t);if(r="",void 0!==o.useDelayedTextureLoading&&null!==o.useDelayedTextureLoading&&(e.useDelayedTextureLoading=o.useDelayedTextureLoading&&!pr.ForceFullSceneLoadingForIncremental),void 0!==o.autoClear&&null!==o.autoClear&&(e.autoClear=o.autoClear),void 0!==o.clearColor&&null!==o.clearColor&&(e.clearColor=s.b.FromArray(o.clearColor)),void 0!==o.ambientColor&&null!==o.ambientColor&&(e.ambientColor=s.a.FromArray(o.ambientColor)),void 0!==o.gravity&&null!==o.gravity&&(e.gravity=a.e.FromArray(o.gravity)),o.fogMode&&0!==o.fogMode)switch(e.fogMode=o.fogMode,e.fogColor=s.a.FromArray(o.fogColor),e.fogStart=o.fogStart,e.fogEnd=o.fogEnd,e.fogDensity=o.fogDensity,r+="\tFog mode for scene: ",e.fogMode){case 1:r+="exp\n";break;case 2:r+="exp2\n";break;case 3:r+="linear\n"}if(o.physicsEnabled){var c;"cannon"===o.physicsEngine?c=new mc(void 0,void 0,Ec.LoaderInjectedPhysicsEngine):"oimo"===o.physicsEngine?c=new gc(void 0,Ec.LoaderInjectedPhysicsEngine):"ammo"===o.physicsEngine&&(c=new bc(void 0,Ec.LoaderInjectedPhysicsEngine,void 0)),r="\tPhysics engine "+(o.physicsEngine?o.physicsEngine:"oimo")+" enabled\n";var l=o.physicsGravity?a.e.FromArray(o.physicsGravity):null;e.enablePhysics(l,c)}return void 0!==o.metadata&&null!==o.metadata&&(e.metadata=o.metadata),void 0!==o.collisionsEnabled&&null!==o.collisionsEnabled&&(e.collisionsEnabled=o.collisionsEnabled),!!Rc(e,t,i,n,!0)&&(o.autoAnimate&&e.beginAnimation(e,o.autoAnimateFrom,o.autoAnimateTo,o.autoAnimateLoop,o.autoAnimateSpeed||1),void 0!==o.activeCameraID&&null!==o.activeCameraID&&e.setActiveCameraByID(o.activeCameraID),!0)}catch(e){var u=Pc("importScene",o?o.producer:"Unknown")+r;if(!n)throw m.a.Log(u),e;n(u,e)}finally{null!==r&&pr.loggingLevel!==pr.NO_LOGGING&&m.a.Log(Pc("importScene",o?o.producer:"Unknown")+(pr.loggingLevel!==pr.MINIMAL_LOGGING?r:""))}return!1},loadAssetContainer:function(e,t,i,n){return Rc(e,t,i,n)}});var xc=i(121),Oc=function(){function e(e){void 0===e&&(e={}),this._isEnabled=!0,this.bias=void 0===e.bias?0:e.bias,this.power=void 0===e.power?1:e.power,this.leftColor=e.leftColor||s.a.White(),this.rightColor=e.rightColor||s.a.Black(),!1===e.isEnabled&&(this.isEnabled=!1)}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,Se.a.MarkAllMaterialsAsDirty(g.a.MATERIAL_FresnelDirtyFlag|g.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),e.prototype.clone=function(){var t=new e;return O.a.DeepCopy(this,t),t},e.prototype.equals=function(e){return e&&this.bias===e.bias&&this.power===e.power&&this.leftColor.equals(e.leftColor)&&this.rightColor.equals(e.rightColor)&&this.isEnabled===e.isEnabled},e.prototype.serialize=function(){return{isEnabled:this.isEnabled,leftColor:this.leftColor.asArray(),rightColor:this.rightColor.asArray(),bias:this.bias,power:this.power}},e.Parse=function(t){return new e({isEnabled:t.isEnabled,leftColor:s.a.FromArray(t.leftColor),rightColor:s.a.FromArray(t.rightColor),bias:t.bias,power:t.power||1})},e}();w.a._FresnelParametersParser=Oc.Parse;var Mc=i(119),Ic=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new s.a(0,0,0),n.occlusionStrength=1,n.useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!0,n._useAmbientInGrayScale=!0,n}return Object(h.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:!1,configurable:!0}),t.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],t.prototype,"environmentTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],t.prototype,"normalTexture",void 0),Object(h.c)([Object(w.e)("emissive"),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],t.prototype,"occlusionStrength",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],t.prototype,"occlusionTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],t.prototype,"alphaCutOff",void 0),Object(h.c)([Object(w.c)()],t.prototype,"doubleSided",null),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),t}(_a),Dc=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n._useRoughnessFromMetallicTextureAlpha=!1,n._useRoughnessFromMetallicTextureGreen=!0,n._useMetallnessFromMetallicTextureBlue=!0,n.metallic=1,n.roughness=1,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},t.prototype.clone=function(e){var i=this,n=w.a.Clone((function(){return new t(e,i.getScene())}),this);return n.id=e,n.name=e,this.clearCoat.copyTo(n.clearCoat),this.anisotropy.copyTo(n.anisotropy),this.brdf.copyTo(n.brdf),this.sheen.copyTo(n.sheen),this.subSurface.copyTo(n.subSurface),n},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.PBRMetallicRoughnessMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,i,n){var r=w.a.Parse((function(){return new t(e.name,i)}),e,i,n);return e.clearCoat&&r.clearCoat.parse(e.clearCoat,i,n),e.anisotropy&&r.anisotropy.parse(e.anisotropy,i,n),e.brdf&&r.brdf.parse(e.brdf,i,n),e.sheen&&r.sheen.parse(e.sheen,i,n),e.subSurface&&r.subSurface.parse(e.subSurface,i,n),r},Object(h.c)([Object(w.e)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),t}(Ic);c.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"]=Dc;var Nc=function(e){function t(t,i){var n=e.call(this,t,i)||this;return n._useMicroSurfaceFromReflectivityMapAlpha=!0,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},t.prototype.clone=function(e){var i=this,n=w.a.Clone((function(){return new t(e,i.getScene())}),this);return n.id=e,n.name=e,this.clearCoat.copyTo(n.clearCoat),this.anisotropy.copyTo(n.anisotropy),this.brdf.copyTo(n.brdf),this.sheen.copyTo(n.sheen),this.subSurface.copyTo(n.subSurface),n},t.prototype.serialize=function(){var e=w.a.Serialize(this);return e.customType="BABYLON.PBRSpecularGlossinessMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e.subSurface=this.subSurface.serialize(),e},t.Parse=function(e,i,n){var r=w.a.Parse((function(){return new t(e.name,i)}),e,i,n);return e.clearCoat&&r.clearCoat.parse(e.clearCoat,i,n),e.anisotropy&&r.anisotropy.parse(e.anisotropy,i,n),e.brdf&&r.brdf.parse(e.brdf,i,n),e.sheen&&r.sheen.parse(e.sheen,i,n),e.subSurface&&r.subSurface.parse(e.subSurface,i,n),r},Object(h.c)([Object(w.e)("diffuse"),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"diffuseColor",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"diffuseTexture",void 0),Object(h.c)([Object(w.e)("specular"),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],t.prototype,"specularColor",void 0),Object(h.c)([Object(w.c)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_microSurface")],t.prototype,"glossiness",void 0),Object(h.c)([Object(w.m)(),Object(w.b)("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],t.prototype,"specularGlossinessTexture",void 0),t}(Ic);c.a.RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"]=Nc;var Lc=i(73),wc=function(e){function t(t,i,n){void 0===n&&(n=null);var r=e.call(this,i)||this;if(!t)return r;if(r._textureMatrix=a.a.Identity(),r.name=t,r.url=t,r._onLoad=n,r._texture=r._getFromCache(t,!0),r._texture)r._triggerOnLoad();else{var o=r.getScene();o&&o.useDelayedTextureLoading?r.delayLoadState=g.a.DELAYLOADSTATE_NOTLOADED:r.loadTexture()}return r}return Object(h.d)(t,e),t.prototype._triggerOnLoad=function(){this._onLoad&&this._onLoad()},t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.load3dlTexture=function(){var e,i=this,n=this._getEngine();e=1===n.webGLVersion?n.createRawTexture(null,1,1,g.a.TEXTUREFORMAT_RGBA,!1,!1,g.a.TEXTURE_BILINEAR_SAMPLINGMODE,null,g.a.TEXTURETYPE_UNSIGNED_INT):n.createRawTexture3D(null,1,1,1,g.a.TEXTUREFORMAT_RGBA,!1,!1,g.a.TEXTURE_BILINEAR_SAMPLINGMODE,null,g.a.TEXTURETYPE_UNSIGNED_INT),this._texture=e,this._texture.isReady=!1,this.isCube=!1,this.is3D=n.webGLVersion>1,this.wrapU=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapV=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.wrapR=g.a.TEXTURE_CLAMP_ADDRESSMODE,this.anisotropicFilteringLevel=1;var r=function(r){if("string"==typeof r){for(var o,a=null,s=null,c=r.split("\n"),l=0,u=0,h=0,d=0,f=0,p=0;p<c.length;p++)if(o=c[p],t._noneEmptyLineRegex.test(o)&&0!==o.indexOf("#")){var _=o.split(" ");if(0!==l){if(0!=l){var m=Math.max(parseInt(_[0]),0),v=Math.max(parseInt(_[1]),0),b=Math.max(parseInt(_[2]),0);f=Math.max(m,f),f=Math.max(v,f),f=Math.max(b,f);var y=4*(u+d*l+h*l*l);s&&(s[y+0]=m,s[y+1]=v,s[y+2]=b),++h%l==0&&(h=0,++d%l==0&&(u++,d=0))}}else l=_.length,a=new Uint8Array(l*l*l*4),s=new Float32Array(l*l*l*4)}if(s&&a)for(p=0;p<s.length;p++)if(p>0&&(p+1)%4==0)a[p]=255;else{var T=s[p];a[p]=T/f*255}e.is3D?(e.updateSize(l,l,l),n.updateRawTexture3D(e,a,g.a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(l*l,l),n.updateRawTexture(e,a,g.a.TEXTUREFORMAT_RGBA,!1)),e.isReady=!0,i._triggerOnLoad()}},o=this.getScene();return o?o._loadFile(this.url,r):n._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()||this._getEngine());return e.level=this.level,e},t.prototype.delayLoad=function(){this.delayLoadState===g.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=g.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},t.Parse=function(e,i){var n=null;return e.name&&!e.isRenderTarget&&((n=new t(e.name,i)).name=e.name,n.level=e.level),n},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}(Zn.a);c.a.RegisteredTypes["BABYLON.ColorGradingTexture"]=wc;var Fc=function(e){function t(t,i,n,r,o,a,s){void 0===r&&(r=!1),void 0===o&&(o=!0),void 0===a&&(a=null),void 0===s&&(s=null);var c=e.call(this,i)||this;if(c._onLoad=null,c._onError=null,!t)throw new Error("Image url is not set");return c._coordinatesMode=Ke.a.CUBIC_MODE,c.name=t,c.url=t,c._size=n,c._noMipmap=r,c.gammaSpace=o,c._onLoad=a,c._onError=s,c.hasAlpha=!1,c.isCube=!0,c._texture=c._getFromCache(t,c._noMipmap),c._texture?a&&(c._texture.isReady?Ce.b.SetImmediate((function(){return a()})):c._texture.onLoadedObservable.add(a)):i.useDelayedTextureLoading?c.delayLoadState=g.a.DELAYLOADSTATE_NOTLOADED:c.loadImage(c.loadTexture.bind(c),c._onError),c}return Object(h.d)(t,e),t.prototype.loadImage=function(e,t){var i=this,n=document.createElement("canvas"),r=new Image;r.addEventListener("load",(function(){i._width=r.width,i._height=r.height,n.width=i._width,n.height=i._height;var t=n.getContext("2d");t.drawImage(r,0,0);var o=t.getImageData(0,0,r.width,r.height);i._buffer=o.data.buffer,n.remove(),e()})),r.addEventListener("error",(function(e){t&&t(i.getClassName()+" could not be loaded",e)})),r.src=this.url},t.prototype.loadTexture=function(){var e=this,i=this.getScene();i&&(this._texture=i.getEngine().createRawCubeTextureFromUrl(this.url,i,this._size,g.a.TEXTUREFORMAT_RGB,i.getEngine().getCaps().textureFloat?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INTEGER,this._noMipmap,(function(){for(var i=e.getFloat32ArrayFromArrayBuffer(e._buffer),n=ic.ConvertPanoramaToCubemap(i,e._width,e._height,e._size),r=[],o=0;o<6;o++){var a=n[t._FacesMapping[o]];r.push(a)}return r}),null,this._onLoad,this._onError))},t.prototype.getFloat32ArrayFromArrayBuffer=function(e){for(var t=new DataView(e),i=new Float32Array(3*e.byteLength/4),n=0,r=0;r<e.byteLength;r++)(r+1)%4!=0&&(i[n++]=t.getUint8(r)/255);return i},t.prototype.getClassName=function(){return"EquiRectangularCubeTexture"},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=new t(this.url,e,this._size,this._noMipmap,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._FacesMapping=["right","left","up","down","front","back"],t}(Zn.a),Bc=function(e){function t(i,n,r){var o=e.call(this,r.scene||r.engine)||this;return n&&(r.engine||r.scene)?(r=Object(h.a)(Object(h.a)({},t.DefaultOptions),r),o._generateMipMaps=r.generateMipMaps,o._samplingMode=r.samplingMode,o._textureMatrix=a.a.Identity(),o.name=i,o.element=n,o._isVideo=n instanceof HTMLVideoElement,o.anisotropicFilteringLevel=1,o._createInternalTexture(),o):o}return Object(h.d)(t,e),t.prototype._createInternalTexture=function(){var e=0,t=0;this._isVideo?(e=this.element.videoWidth,t=this.element.videoHeight):(e=this.element.width,t=this.element.height);var i=this._getEngine();i&&(this._texture=i.createDynamicTexture(e,t,this._generateMipMaps,this._samplingMode)),this.update()},t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.update=function(e){void 0===e&&(e=null);var t=this._getEngine();if(null!=this._texture&&null!=t)if(this._isVideo){var i=this.element;if(i.readyState<i.HAVE_CURRENT_DATA)return;t.updateVideoTexture(this._texture,i,null===e||e)}else{var n=this.element;t.updateDynamicTexture(this._texture,n,null===e||e,!1)}},t.DefaultOptions={generateMipMaps:!1,samplingMode:g.a.TEXTURE_BILINEAR_SAMPLINGMODE,engine:null,scene:null},t}(Zn.a),Uc=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)m.a.Error("Unable to load TGA file - Not enough data to contain header");else{var n=18,r=e.GetTGAHeader(i);if(r.id_length+n>i.length)m.a.Error("Unable to load TGA file - Not enough data");else{n+=r.id_length;var o,a=!1,s=!1,c=!1;switch(r.image_type){case e._TYPE_RLE_INDEXED:a=!0;case e._TYPE_INDEXED:s=!0;break;case e._TYPE_RLE_RGB:a=!0;case e._TYPE_RGB:break;case e._TYPE_RLE_GREY:a=!0;case e._TYPE_GREY:c=!0}var l,u,h,d,f,p,_,g=r.pixel_size>>3,v=r.width*r.height*g;if(s&&(l=i.subarray(n,n+=r.colormap_length*(r.colormap_size>>3))),a){var b,y,T;o=new Uint8Array(v);for(var E=0,S=new Uint8Array(g);n<v&&E<v;)if(y=1+(127&(b=i[n++])),128&b){for(T=0;T<g;++T)S[T]=i[n++];for(T=0;T<y;++T)o.set(S,E+T*g);E+=g*y}else{for(y*=g,T=0;T<y;++T)o[E+T]=i[n++];E+=y}}else o=i.subarray(n,n+=s?r.width*r.height:v);switch((r.flags&e._ORIGIN_MASK)>>e._ORIGIN_SHIFT){default:case e._ORIGIN_UL:u=0,d=1,_=r.width,h=0,f=1,p=r.height;break;case e._ORIGIN_BL:u=0,d=1,_=r.width,h=r.height-1,f=-1,p=-1;break;case e._ORIGIN_UR:u=r.width-1,d=-1,_=-1,h=0,f=1,p=r.height;break;case e._ORIGIN_BR:u=r.width-1,d=-1,_=-1,h=r.height-1,f=-1,p=-1}var A=e["_getImageData"+(c?"Grey":"")+r.pixel_size+"bits"](r,l,o,h,f,p,u,d,_);t.getEngine()._uploadDataToTextureDirectly(t,A)}}},e._getImageData8bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=t,p=e.width,_=e.height,m=0,g=new Uint8Array(p*_*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,m++)l=d[m],g[4*(u+p*h)+3]=255,g[4*(u+p*h)+2]=f[3*l+0],g[4*(u+p*h)+1]=f[3*l+1],g[4*(u+p*h)+0]=f[3*l+2];return g},e._getImageData16bits=function(e,t,i,n,r,o,a,s,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,_+=2){var g=255*((31744&(l=d[_+0]+(d[_+1]<<8)))>>10)/31|0,v=255*((992&l)>>5)/31|0,b=255*(31&l)/31|0;m[4*(u+f*h)+0]=g,m[4*(u+f*h)+1]=v,m[4*(u+f*h)+2]=b,m[4*(u+f*h)+3]=32768&l?0:255}return m},e._getImageData24bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,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,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,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,n,r,o,a,s,c){var l,u,h,d=i,f=e.width,p=e.height,_=0,m=new Uint8Array(f*p*4);for(h=n;h!==o;h+=r)for(u=a;u!==c;u+=s,_++)l=d[_],m[4*(u+f*h)+0]=l,m[4*(u+f*h)+1]=l,m[4*(u+f*h)+2]=l,m[4*(u+f*h)+3]=255;return m},e._getImageDataGrey16bits=function(e,t,i,n,r,o,a,s,c){var l,u,h=i,d=e.width,f=e.height,p=0,_=new Uint8Array(d*f*4);for(u=n;u!==o;u+=r)for(l=a;l!==c;l+=s,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}(),Vc=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,".tga")},e.prototype.loadCubeData=function(e,t,i,n,r){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,i){var n=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=Uc.GetTGAHeader(n);i(r.width,r.height,t.generateMipMaps,!1,(function(){Uc.UploadContent(t,n)}))},e}();Se.a._TextureLoaders.push(new Vc);var kc,zc=function(){};!function(e){e[e.cTFETC1=0]="cTFETC1",e[e.cTFBC1=1]="cTFBC1",e[e.cTFBC4=2]="cTFBC4",e[e.cTFPVRTC1_4_OPAQUE_ONLY=3]="cTFPVRTC1_4_OPAQUE_ONLY",e[e.cTFBC7_M6_OPAQUE_ONLY=4]="cTFBC7_M6_OPAQUE_ONLY",e[e.cTFETC2=5]="cTFETC2",e[e.cTFBC3=6]="cTFBC3",e[e.cTFBC5=7]="cTFBC5"}(kc||(kc={}));var Gc=function(){function e(){}return e.GetInternalFormatFromBasisFormat=function(e){if(e===kc.cTFETC1)return 36196;if(e===kc.cTFBC1)return 33776;if(e===kc.cTFBC3)return 33779;throw"The chosen Basis transcoder format is not currently supported"},e._CreateWorkerAsync=function(){var t=this;return this._WorkerPromise||(this._WorkerPromise=new Promise((function(i){t._Worker?i(t._Worker):Ce.b.LoadFileAsync(e.WasmModuleURL).then((function(n){var r=URL.createObjectURL(new Blob(["("+jc+")()"],{type:"application/javascript"}));t._Worker=new Worker(r);var o=function(e){"init"===e.data.action&&(t._Worker.removeEventListener("message",o),i(t._Worker))};t._Worker.addEventListener("message",o),t._Worker.postMessage({action:"init",url:e.JSModuleURL,wasmBinary:n})}))}))),this._WorkerPromise},e.TranscodeAsync=function(e,t){var i=this,n=e instanceof ArrayBuffer?new Uint8Array(e):e;return new Promise((function(e,r){i._CreateWorkerAsync().then((function(){var o=i._actionId++,a=function(t){"transcode"===t.data.action&&t.data.id===o&&(i._Worker.removeEventListener("message",a),t.data.success?e(t.data):r("Transcode is not supported on this device"))};i._Worker.addEventListener("message",a);var s=new Uint8Array(n.byteLength);s.set(new Uint8Array(n.buffer,n.byteOffset,n.byteLength)),i._Worker.postMessage({action:"transcode",id:o,imageData:s,config:t,ignoreSupportedFormats:i._IgnoreSupportedFormats},[s.buffer])}))}))},e.LoadTextureFromTranscodeResult=function(t,i){for(var n,r=t.getEngine(),o=function(){if(n=i.fileInfo.images[a].levels[0],t._invertVScale=t.invertY,-1===i.format)if(t.type=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.format=g.a.TEXTUREFORMAT_RGB,r.webGLVersion<2&&(L.a.Log2(n.width)%1!=0||L.a.Log2(n.height)%1!=0)){var o=new Qe.a(r,Qe.b.Temp);t._invertVScale=t.invertY,o.type=g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,o.format=g.a.TEXTUREFORMAT_RGB,o.width=n.width+3&-4,o.height=n.height+3&-4,r._bindTextureDirectly(r._gl.TEXTURE_2D,o,!0),r._uploadDataToTextureDirectly(o,n.transcodedPixels,a,0,g.a.TEXTUREFORMAT_RGB,!0),r._rescaleTexture(o,t,r.scenes[0],r._getInternalFormat(g.a.TEXTUREFORMAT_RGB),(function(){r._releaseTexture(o),r._bindTextureDirectly(r._gl.TEXTURE_2D,t,!0)}))}else t._invertVScale=!t.invertY,t.width=n.width+3&-4,t.height=n.height+3&-4,r._uploadDataToTextureDirectly(t,n.transcodedPixels,a,0,g.a.TEXTUREFORMAT_RGB,!0);else t.width=n.width,t.height=n.height,i.fileInfo.images[a].levels.forEach((function(n,o){r._uploadCompressedDataToTextureDirectly(t,e.GetInternalFormatFromBasisFormat(i.format),n.width,n.height,n.transcodedPixels,a,o)})),r.webGLVersion<2&&(L.a.Log2(t.width)%1!=0||L.a.Log2(t.height)%1!=0)&&(Ce.b.Warn("Loaded .basis texture width and height are not a power of two. Texture wrapping will be set to Texture.CLAMP_ADDRESSMODE as other modes are not supported with non power of two dimensions in webGL 1."),t._cachedWrapU=Ke.a.CLAMP_ADDRESSMODE,t._cachedWrapV=Ke.a.CLAMP_ADDRESSMODE)},a=0;a<i.fileInfo.images.length;a++)o()},e._IgnoreSupportedFormats=!1,e.JSModuleURL="https://preview.babylonjs.com/basisTranscoder/basis_transcoder.js",e.WasmModuleURL="https://preview.babylonjs.com/basisTranscoder/basis_transcoder.wasm",e._WorkerPromise=null,e._Worker=null,e._actionId=0,e}();function jc(){var e=0,t=1,i=5,n=6,r=null;function o(e,t,i,n,r){var o=e.getImageTranscodedSizeInBytes(t,i,n),a=new Uint8Array(o);if(!e.transcodeImage(a,t,i,n,1,0))return null;r&&(a=function(e,t,i,n){for(var r=new Uint16Array(4),o=new Uint16Array(i*n),a=i/4,s=n/4,c=0;c<s;c++)for(var l=0;l<a;l++){var u=t+8*(c*a+l);r[0]=e[u]|e[u+1]<<8,r[1]=e[u+2]|e[u+3]<<8,r[2]=(2*(31&r[0])+1*(31&r[1]))/3|(2*(2016&r[0])+1*(2016&r[1]))/3&2016|(2*(63488&r[0])+1*(63488&r[1]))/3&63488,r[3]=(2*(31&r[1])+1*(31&r[0]))/3|(2*(2016&r[1])+1*(2016&r[0]))/3&2016|(2*(63488&r[1])+1*(63488&r[0]))/3&63488;for(var h=0;h<4;h++){var d=e[u+4+h],f=(4*c+h)*i+4*l;o[f++]=r[3&d],o[f++]=r[d>>2&3],o[f++]=r[d>>4&3],o[f++]=r[d>>6&3]}}return o}(a,0,e.getImageWidth(t,i)+3&-4,e.getImageHeight(t,i)+3&-4));return a}onmessage=function(a){if("init"===a.data.action)r||(Module={wasmBinary:a.data.wasmBinary},importScripts(a.data.url),r=new Promise((function(e){Module.onRuntimeInitialized=function(){Module.initializeBasis(),e()}}))),r.then((function(){postMessage({action:"init"})}));else if("transcode"===a.data.action){var s=a.data.config,c=a.data.imageData,l=new Module.BasisFile(c),u=function(e){for(var t=e.getHasAlpha(),i=e.getNumImages(),n=[],r=0;r<i;r++){for(var o={levels:[]},a=e.getNumLevels(r),s=0;s<a;s++){var c={width:e.getImageWidth(r,s),height:e.getImageHeight(r,s)};o.levels.push(c)}n.push(o)}return{hasAlpha:t,images:n}}(l),h=a.data.ignoreSupportedFormats?null:function(r,o){var a=null;r.supportedCompressionFormats&&(r.supportedCompressionFormats.etc1?a=e:r.supportedCompressionFormats.s3tc?a=o.hasAlpha?n:t:r.supportedCompressionFormats.pvrtc||r.supportedCompressionFormats.etc2&&(a=i));return a}(a.data.config,u),d=!1;null===h&&(d=!0,h=u.hasAlpha?n:t);var f=!0;l.startTranscoding()||(f=!1);for(var p=[],_=0;_<u.images.length&&f;_++){var m=u.images[_];if(void 0===s.loadSingleImage||s.loadSingleImage===_){var g=m.levels.length;!1===s.loadMipmapLevels&&(g=1);for(var v=0;v<g;v++){var b=m.levels[v],y=o(l,_,v,h,d);if(!y){f=!1;break}b.transcodedPixels=y,p.push(b.transcodedPixels.buffer)}}}l.close(),l.delete(),d&&(h=-1),f?postMessage({action:"transcode",success:f,id:a.data.id,fileInfo:u,format:h},p):postMessage({action:"transcode",success:f,id:a.data.id})}}}var Wc=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return io.a.EndsWith(e,".basis")},e.prototype.loadCubeData=function(e,t,i,n,r){if(!Array.isArray(e)){var o=t.getEngine().getCaps(),a={supportedCompressionFormats:{etc1:!!o.etc1,s3tc:!!o.s3tc,pvrtc:!!o.pvrtc,etc2:!!o.etc2}};Gc.TranscodeAsync(e,a).then((function(e){var i=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;Gc.LoadTextureFromTranscodeResult(t,e),t.getEngine()._setCubeMapTextureParams(t,i),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),n&&n()})).catch((function(e){Ce.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0}))}},e.prototype.loadData=function(e,t,i){var n=t.getEngine().getCaps(),r={supportedCompressionFormats:{etc1:!!n.etc1,s3tc:!!n.s3tc,pvrtc:!!n.pvrtc,etc2:!!n.etc2}};Gc.TranscodeAsync(e,r).then((function(e){var n=e.fileInfo.images[0].levels[0],r=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;i(n.width,n.height,r,-1!==e.format,(function(){Gc.LoadTextureFromTranscodeResult(t,e)}))})).catch((function(e){Ce.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),i(0,0,!1,!1,(function(){}))}))},e}();Se.a._TextureLoaders.push(new Wc);var Hc=function(e){function t(t,i,n,r,o){var a=this,s=!(!o||!o.generateMipMaps)&&o.generateMipMaps,c=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,l=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio;if((a=e.call(this,t,i,r,s,l)||this).isSupported){var u=[],h=[];a._initTypes(n,u,h,o);var d=!o||void 0===o.generateDepthBuffer||o.generateDepthBuffer,f=!(!o||void 0===o.generateStencilBuffer)&&o.generateStencilBuffer;return a._size=i,a._multiRenderTargetOptions={samplingModes:h,generateMipMaps:s,generateDepthBuffer:d,generateStencilBuffer:f,generateDepthTexture:c,types:u,textureCount:n},a._count=n,a._createInternalTextures(),a._createTextures(),a}a.dispose()}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"isSupported",{get:function(){return this._getEngine().webGLVersion>1||this._getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"count",{get:function(){return this._count},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!1,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:!1,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:!1,configurable:!0}),t.prototype._initTypes=function(e,t,i,n){for(var r=0;r<e;r++)n&&n.types&&void 0!==n.types[r]?t.push(n.types[r]):t.push(n&&n.defaultType?n.defaultType:g.a.TEXTURETYPE_UNSIGNED_INT),n&&n.samplingModes&&void 0!==n.samplingModes[r]?i.push(n.samplingModes[r]):i.push(Ke.a.BILINEAR_SAMPLINGMODE)},t.prototype._rebuild=function(e){void 0===e&&(e=!1),this.releaseInternalTextures(),this._createInternalTextures(),e&&this._createTextures();for(var t=0;t<this._internalTextures.length;t++){this._textures[t]._texture=this._internalTextures[t]}this._texture=this._internalTextures[0],1!==this.samples&&this._getEngine().updateMultipleRenderTargetTextureSampleCount(this._internalTextures,this.samples)},t.prototype._createInternalTextures=function(){this._internalTextures=this._getEngine().createMultipleRenderTarget(this._size,this._multiRenderTargetOptions)},t.prototype._createTextures=function(){this._textures=[];for(var e=0;e<this._internalTextures.length;e++){var t=new Ke.a(null,this.getScene());t._texture=this._internalTextures[e],this._textures.push(t)}this._texture=this._internalTextures[0]},t.prototype.replaceTexture=function(e,t){e._texture&&(this._textures[t]=e,this._internalTextures[t]=e._texture)},Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=this._getEngine().updateMultipleRenderTargetTextureSampleCount(this._internalTextures,e))},enumerable:!1,configurable:!0}),t.prototype.resize=function(e){this._size=e,this._rebuild()},t.prototype.updateCount=function(e,t){this._multiRenderTargetOptions.textureCount=e,this._count=e;var i=[],n=[];this._initTypes(e,i,n,t),this._multiRenderTargetOptions.types=i,this._multiRenderTargetOptions.samplingModes=n,this._rebuild(!0)},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}(Ni),Xc=function(e,t,i){this.id=e,this.scale=t,this.offset=i},Yc=function(){function e(t,i,n,r){var o,a,c,l,u,h,d,f,p,_,m,g,v;return this.name=t,this.meshes=i,this.scene=r,this.options=n,this.options.map=null!==(o=this.options.map)&&void 0!==o?o:["ambientTexture","bumpTexture","diffuseTexture","emissiveTexture","lightmapTexture","opacityTexture","reflectionTexture","refractionTexture","specularTexture"],this.options.uvsIn=null!==(a=this.options.uvsIn)&&void 0!==a?a:Qi.b.UVKind,this.options.uvsOut=null!==(c=this.options.uvsOut)&&void 0!==c?c:Qi.b.UVKind,this.options.layout=null!==(l=this.options.layout)&&void 0!==l?l:e.LAYOUT_STRIP,this.options.layout===e.LAYOUT_COLNUM&&(this.options.colnum=null!==(u=this.options.colnum)&&void 0!==u?u:8),this.options.updateInputMeshes=null===(h=this.options.updateInputMeshes)||void 0===h||h,this.options.disposeSources=null===(d=this.options.disposeSources)||void 0===d||d,this._expecting=0,this.options.fillBlanks=null===(f=this.options.fillBlanks)||void 0===f||f,!0===this.options.fillBlanks&&(this.options.customFillColor=null!==(p=this.options.customFillColor)&&void 0!==p?p:"black"),this.options.frameSize=null!==(_=this.options.frameSize)&&void 0!==_?_:256,this.options.paddingRatio=null!==(m=this.options.paddingRatio)&&void 0!==m?m:.0115,this._paddingValue=Math.ceil(this.options.frameSize*this.options.paddingRatio),this._paddingValue%2!=0&&this._paddingValue++,this.options.paddingMode=null!==(g=this.options.paddingMode)&&void 0!==g?g:e.SUBUV_WRAP,this.options.paddingMode===e.SUBUV_COLOR&&(this.options.paddingColor=null!==(v=this.options.paddingColor)&&void 0!==v?v:new s.b(0,0,0,1)),this.sets={},this.frames=[],this}return e.prototype._createFrames=function(e){for(var t=this,i=this._calculateSize(),n=new a.d(1,1).divide(i),r=0,o=this._expecting,c=this.meshes.length,l=Object.keys(this.sets),u=0;u<l.length;u++){var h=l[u],d=new Hi.a(this.name+".TexturePack."+h+"Set",{width:i.x,height:i.y},this.scene,!0,Ke.a.TRILINEAR_SAMPLINGMODE,Se.a.TEXTUREFORMAT_RGBA),f=d.getContext();f.fillStyle="rgba(0,0,0,0)",f.fillRect(0,0,i.x,i.y),d.update(!1),this.sets[h]=d}var p=this.options.frameSize||256,_=this._paddingValue,m=p+2*_;for(u=0;u<c;u++)for(var g=this.meshes[u].material,v=function(a){var c=new Hi.a("temp",m,b.scene,!0),h=c.getContext(),d=b._getFrameOffset(u),f=function(){r++,c.update(!1);var a=h.getImageData(0,0,m,m),s=t.sets[v];if(s.getContext().putImageData(a,i.x*d.x,i.y*d.y),c.dispose(),s.update(!1),r==o)return t._calculateMeshUVFrames(p,_,i,n,t.options.updateInputMeshes||!1),void e()},v=l[a]||"_blank";if(g&&null!==g[v]){var y=g[v],T=new Image;y instanceof Hi.a?T.src=y.getContext().canvas.toDataURL("image/png"):T.src=y.url,Ce.b.SetCorsBehavior(T.src,T),T.onload=function(){h.fillStyle="rgba(0,0,0,0)",h.fillRect(0,0,m,m),c.update(!1),h.setTransform(1,0,0,-1,0,0);var e=[0,0,1,0,1,1,0,1,-1,1,-1,0,-2,0,-1,1,-1];switch(t.options.paddingMode){case 0:for(var i=0;i<9;i++)h.drawImage(T,0,0,T.width,T.height,_+p*e[i],_+p*e[i+1]-m,p,p);break;case 1:for(var n=0;n<_;n++)h.drawImage(T,0,0,T.width,T.height,n+p*e[0],_-m,p,p),h.drawImage(T,0,0,T.width,T.height,2*_-n,_-m,p,p),h.drawImage(T,0,0,T.width,T.height,_,n-m,p,p),h.drawImage(T,0,0,T.width,T.height,_,2*_-n-m,p,p);h.drawImage(T,0,0,T.width,T.height,_+p*e[0],_+p*e[1]-m,p,p);break;case 2:h.fillStyle=(t.options.paddingColor||s.a.Black()).toHexString(),h.fillRect(0,0,m,-m),h.clearRect(_,_,p,p),h.drawImage(T,0,0,T.width,T.height,_+p*e[0],_+p*e[1]-m,p,p)}h.setTransform(1,0,0,1,0,0),f()}}else h.fillStyle="rgba(0,0,0,0)",b.options.fillBlanks&&(h.fillStyle=b.options.customFillColor),h.fillRect(0,0,m,m),f()},b=this,y=0;y<l.length;y++)v(y)},e.prototype._calculateSize=function(){var e=this.meshes.length||0,t=this.options.frameSize||0,i=this._paddingValue||0;switch(this.options.layout){case 0:return new a.d(t*e+2*i*e,t+2*i);case 1:var n=Math.max(2,Math.ceil(Math.sqrt(e))),r=t*n+2*i*n;return new a.d(r,r);case 2:var o=this.options.colnum||1,s=Math.max(1,Math.ceil(e/o));return new a.d(t*o+2*i*o,t*s+2*i*s)}return a.d.Zero()},e.prototype._calculateMeshUVFrames=function(e,t,i,n,r){for(var o=this.meshes.length,s=0;s<o;s++){var c=this.meshes[s],l=new a.d(e/i.x,e/i.y),u=n.clone().scale(t),h=this._getFrameOffset(s).add(u),d=new Xc(s,l,h);this.frames.push(d),r&&(this._updateMeshUV(c,s),this._updateTextureReferences(c))}},e.prototype._getFrameOffset=function(e){var t,i,n,r=this.meshes.length;switch(this.options.layout){case 0:return t=1/r,new a.d(e*t,0);case 1:var o=Math.max(2,Math.ceil(Math.sqrt(r)));return n=e-(i=Math.floor(e/o))*o,t=1/o,new a.d(n*t,i*t);case 2:var s=this.options.colnum||1,c=Math.max(1,Math.ceil(r/s));return i=e-(n=Math.floor(e/c))*c,t=new a.d(1/s,1/c),new a.d(n*t.x,i*t.y)}return a.d.Zero()},e.prototype._updateMeshUV=function(e,t){var i=this.frames[t],n=e.getVerticesData(this.options.uvsIn||Qi.b.UVKind),r=[],o=0;n.length&&(o=n.length||0);for(var a=0;a<o;a+=2)r.push(n[a]*i.scale.x+i.offset.x,n[a+1]*i.scale.y+i.offset.y);e.setVerticesData(this.options.uvsOut||Qi.b.UVKind,r)},e.prototype._updateTextureReferences=function(e,t){void 0===t&&(t=!1);for(var i=e.material,n=Object.keys(this.sets),r=function(e){e.dispose&&e.dispose()},o=0;o<n.length;o++){var a=n[o];if(t)null!==i[a]&&r(i[a]),i[a]=this.sets[a];else{if(!i)return;null!==i[a]&&(r(i[a]),i[a]=this.sets[a])}}},e.prototype.setMeshToFrame=function(e,t,i){void 0===i&&(i=!1),this._updateMeshUV(e,t),i&&this._updateTextureReferences(e,!0)},e.prototype.processAsync=function(){var e=this;return new Promise((function(t,i){try{if(0===e.meshes.length)return void t();for(var n=0,r=function(i){var r=e.meshes[i],o=r.material;if(!o)return++n===e.meshes.length?{value:e._createFrames(t)}:"continue";o.forceCompilationAsync(r).then((function(){!function(i){if(n++,e.options.map){for(var r=0;r<e.options.map.length;r++){null!==i[e.options.map[r]]&&(e.sets[e.options.map[r]]||(e.sets[e.options.map[r]]=!0),e._expecting++)}n===e.meshes.length&&e._createFrames(t)}}(o)}))},o=0;o<e.meshes.length;o++){var a=r(o);if("object"==typeof a)return a.value}}catch(e){return i(e)}}))},e.prototype.dispose=function(){for(var e=Object.keys(this.sets),t=0;t<e.length;t++){var i=e[t];this.sets[i].dispose()}},e.prototype.download=function(e,t){var i=this;void 0===e&&(e="png"),void 0===t&&(t=1),setTimeout((function(){var n={name:i.name,sets:{},options:{},frames:[]},r=Object.keys(i.sets),o=Object.keys(i.options);try{for(var a=0;a<r.length;a++){var s=r[a],c=i.sets[s];n.sets[s]=c.getContext().canvas.toDataURL("image/"+e,t)}for(a=0;a<o.length;a++){var l=o[a];n.options[l]=i.options[l]}for(a=0;a<i.frames.length;a++){var u=i.frames[a];n.frames.push(u.scale.x,u.scale.y,u.offset.x,u.offset.y)}}catch(e){return void m.a.Warn("Unable to download: "+e)}var h="data:text/json;charset=utf-8,"+encodeURIComponent(JSON.stringify(n,null,4)),d=document.createElement("a");d.setAttribute("href",h),d.setAttribute("download",i.name+"_texurePackage.json"),document.body.appendChild(d),d.click(),d.remove()}),0)},e.prototype.updateFromJSON=function(e){try{var t=JSON.parse(e);this.name=t.name;for(var i=Object.keys(t.options),n=0;n<i.length;n++)this.options[i[n]]=t.options[i[n]];for(n=0;n<t.frames.length;n+=4){var r=new Xc(n/4,new a.d(t.frames[n],t.frames[n+1]),new a.d(t.frames[n+2],t.frames[n+3]));this.frames.push(r)}var o=Object.keys(t.sets);for(n=0;n<o.length;n++){var s=new Ke.a(t.sets[o[n]],this.scene,!1,!1);this.sets[o[n]]=s}}catch(e){m.a.Warn("Unable to update from JSON: "+e)}},e.LAYOUT_STRIP=0,e.LAYOUT_POWER2=1,e.LAYOUT_COLNUM=2,e.SUBUV_WRAP=0,e.SUBUV_EXTEND=1,e.SUBUV_COLOR=2,e}(),Kc=function(){function e(e){this.name=Me.a.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(Me.a.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){Ce.b.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()}Ce.b.EndPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0)}},e}(),Qc="\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}";ai.a.ShadersStore.proceduralVertexShader=Qc;var qc=function(e){function t(t,i,n,r,a,s,c,l){void 0===a&&(a=null),void 0===s&&(s=!0),void 0===c&&(c=!1),void 0===l&&(l=g.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,null,r,!s)||this;u.isEnabled=!0,u.autoClear=!0,u.onGeneratedObservable=new o.c,u.onBeforeGenerationObservable=new o.c,u.nodeMaterialSource=null,u._textures={},u._currentRefreshId=-1,u._frameId=-1,u._refreshRate=1,u._vertexBuffers={},u._uniforms=new Array,u._samplers=new Array,u._floats={},u._ints={},u._floatsArrays={},u._colors3={},u._colors4={},u._vectors2={},u._vectors3={},u._matrices={},u._fallbackTextureUsed=!1,u._cachedDefines="",u._contentUpdateId=-1;var h=(r=u.getScene()||x.a.LastCreatedScene)._getComponent(Me.a.NAME_PROCEDURALTEXTURE);h||(h=new Kc(r),r._addComponent(h)),r.proceduralTextures.push(u),u._fullEngine=r.getEngine(),u.name=t,u.isRenderTarget=!0,u._size=i,u._generateMipMaps=s,u.setFragment(n),u._fallbackTexture=a,c?(u._texture=u._fullEngine.createRenderTargetCubeTexture(i,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:l}),u.setFloat("face",0)):u._texture=u._fullEngine.createRenderTargetTexture(i,{generateMipMaps:s,generateDepthBuffer:!1,generateStencilBuffer:!1,type:l});var d=[];return d.push(1,1),d.push(-1,1),d.push(-1,-1),d.push(1,-1),u._vertexBuffers[Qi.b.PositionKind]=new Qi.b(u._fullEngine,d,Qi.b.PositionKind,!1,!1,2),u._createIndexBuffer(),u}return Object(h.d)(t,e),t.prototype.getEffect=function(){return this._effect},t.prototype.getContent=function(){return this._contentData&&this._frameId===this._contentUpdateId||(this._contentData=this.readPixels(0,0,this._contentData),this._contentUpdateId=this._frameId),this._contentData},t.prototype._createIndexBuffer=function(){var e=this._fullEngine,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[Qi.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===Ni.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=Ni.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){void 0!==this._effect&&this._effect.dispose()},t.prototype._getDefines=function(){return""},t.prototype.isReady=function(){var e,t=this,i=this._fullEngine;if(this.nodeMaterialSource)return this._effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var n=this._getDefines();return!(!this._effect||n!==this._cachedDefines||!this._effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=n,this._effect=i.createEffect(e,[Qi.b.PositionKind],this._uniforms,this._samplers,n,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:!1,configurable:!0}),t.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId||this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,this._frameId++,!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._fullEngine.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._fullEngine;if(i.enableEffect(this._effect),this.onBeforeGenerationObservable.notifyObservers(this),i.setState(!1),!this.nodeMaterialSource){for(var n in this._textures)this._effect.setTexture(n,this._textures[n]);for(n in this._ints)this._effect.setInt(n,this._ints[n]);for(n in this._floats)this._effect.setFloat(n,this._floats[n]);for(n in this._floatsArrays)this._effect.setArray(n,this._floatsArrays[n]);for(n in this._colors3)this._effect.setColor3(n,this._colors3[n]);for(n in this._colors4){var r=this._colors4[n];this._effect.setFloat4(n,r.r,r.g,r.b,r.a)}for(n in this._vectors2)this._effect.setVector2(n,this._vectors2[n]);for(n in this._vectors3)this._effect.setVector3(n,this._vectors3[n]);for(n in this._matrices)this._effect.setMatrix(n,this._matrices[n])}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(xo.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(xo.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 n=this._vertexBuffers[Qi.b.PositionKind];n&&(n.dispose(),this._vertexBuffers[Qi.b.PositionKind]=null),this._indexBuffer&&this._fullEngine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),this.onGeneratedObservable.clear(),this.onBeforeGenerationObservable.clear(),e.prototype.dispose.call(this)}},Object(h.c)([Object(w.c)()],t.prototype,"isEnabled",void 0),Object(h.c)([Object(w.c)()],t.prototype,"autoClear",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_generateMipMaps",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_size",void 0),Object(h.c)([Object(w.c)()],t.prototype,"refreshRate",null),t}(Ke.a);c.a.RegisteredTypes["BABYLON.ProceduralTexture"]=qc;var Zc=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,n,null,r,o,a)||this;return s._animate=!0,s._time=0,s._texturePath=i,s._loadJson(i),s.refreshRate=1,s}return Object(h.d)(t,e),t.prototype._loadJson=function(e){var t=this,i=function(){try{t.setFragment(t._texturePath)}catch(e){m.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},n=e+"/config.json",r=new V.a;r.open("GET",n),r.addEventListener("load",(function(){if(200===r.status||r.responseText&&r.responseText.length>0)try{t._config=JSON.parse(r.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),r.addEventListener("error",(function(){i()}),!1);try{r.send()}catch(e){m.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 Ke.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 s.a(t.r,t.g,t.b));break;case"color4":this.setColor4(t.name,new s.b(t.r,t.g,t.b,t.a));break;case"vector2":this.setVector2(t.name,new a.d(t.x,t.y));break;case"vector3":this.setVector3(t.name,new a.e(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:!1,configurable:!0}),t}(qc),Jc="\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";ai.a.ShadersStore.noisePixelShader=Jc;var $c=function(e){function t(t,i,n,r,o){void 0===i&&(i=256),void 0===n&&(n=x.a.LastCreatedScene);var a=e.call(this,t,i,"noise",n,r,o)||this;return a.time=0,a.brightness=.2,a.octaves=3,a.persistence=.8,a.animationSpeedFactor=1,a.autoClear=!1,a._updateShaderUniforms(),a}return Object(h.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.time=this.time,e},t.prototype.clone=function(){var e=this.getSize(),i=new t(this.name,e.width,this.getScene(),this._fallbackTexture?this._fallbackTexture:void 0,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.coordinatesMode=this.coordinatesMode,i.brightness=this.brightness,i.octaves=this.octaves,i.persistence=this.persistence,i.animationSpeedFactor=this.animationSpeedFactor,i.time=this.time,i},t.Parse=function(e,i){var n,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.time=null!==(n=e.time)&&void 0!==n?n:0,r},t}(qc);c.a.RegisteredTypes["BABYLON.NoiseProceduralTexture"]=$c;var el,tl,il,nl,rl,ol,al,sl=function(e){function t(t,i,n,r,o,a,s,c,l){void 0===r&&(r=g.a.TEXTUREFORMAT_RGBA),void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1),void 0===s&&(s=!1),void 0===c&&(c=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null);var u=e.call(this,"",t)||this;return u._texture=t.getEngine().createRawCubeTexture(i,n,r,o,a,s,c,l),u}return Object(h.d)(t,e),t.prototype.update=function(e,t,i,n,r){void 0===r&&(r=null),this._texture.getEngine().updateRawCubeTexture(this._texture,e,t,i,n,r)},t.prototype.updateRGBDAsync=function(e,i,n,r){return void 0===i&&(i=null),void 0===n&&(n=.8),void 0===r&&(r=0),t._UpdateRGBDAsync(this._texture,e,i,n,r)},t.prototype.clone=function(){var e=this;return w.a.Clone((function(){var i=e.getScene(),n=e._texture,r=new t(i,n._bufferViewArray,n.width,n.format,n.type,n.generateMipMaps,n.invertY,n.samplingMode,n._compression);return n.source===Qe.b.CubeRawRGBD&&r.updateRGBDAsync(n._bufferViewArrayArray,n._sphericalPolynomial,n._lodGenerationScale,n._lodGenerationOffset),r}),this)},t._UpdateRGBDAsync=function(e,t,i,n,r){return e._source=Qe.b.CubeRawRGBD,e._bufferViewArrayArray=t,e._lodGenerationScale=n,e._lodGenerationOffset=r,e._sphericalPolynomial=i,ir.UploadLevelsAsync(e,t).then((function(){e.isReady=!0}))},t}(no),cl=function(e){function t(t,i,n,r,o,a,s,c,l,u){void 0===s&&(s=!0),void 0===c&&(c=!1),void 0===l&&(l=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT);var h=e.call(this,null,a,!s,c)||this;return h.format=o,h._texture=a.getEngine().createRawTexture2DArray(t,i,n,r,o,s,c,l,null,u),h.is2DArray=!0,h}return Object(h.d)(t,e),t.prototype.update=function(e){this._texture&&this._getEngine().updateRawTexture2DArray(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t}(Ke.a),ll=function(e){function t(t,i,n,r,o,a,s,c,l,u){void 0===s&&(s=!0),void 0===c&&(c=!1),void 0===l&&(l=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT);var h=e.call(this,null,a,!s,c)||this;return h.format=o,h._texture=a.getEngine().createRawTexture3D(t,i,n,r,o,s,c,l,null,u),h.is3D=!0,h}return Object(h.d)(t,e),t.prototype.update=function(e){this._texture&&this._getEngine().updateRawTexture3D(this._texture,e,this._texture.format,this._texture.invertY,null,this._texture.type)},t}(Ke.a),ul=function(e){function t(t,i,n,r){var o=e.call(this,t,i,n,r,!0)||this;return o.refractionPlane=new fn.a(0,1,0,1),o.depth=2,o.onBeforeRenderObservable.add((function(){n.clipPlane=o.refractionPlane})),o.onAfterRenderObservable.add((function(){n.clipPlane=null})),o}return Object(h.d)(t,e),t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var i=this.getSize(),n=new t(this.name,i.width,e,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.refractionPlane=this.refractionPlane.clone(),this.renderList&&(n.renderList=this.renderList.slice(0)),n.depth=this.depth,n},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}(Ni);!function(e){e[e.Vertex=1]="Vertex",e[e.Fragment=2]="Fragment",e[e.Neutral=4]="Neutral",e[e.VertexAndFragment=3]="VertexAndFragment"}(el||(el={})),function(e){e[e.Float=1]="Float",e[e.Int=2]="Int",e[e.Vector2=4]="Vector2",e[e.Vector3=8]="Vector3",e[e.Vector4=16]="Vector4",e[e.Color3=32]="Color3",e[e.Color4=64]="Color4",e[e.Matrix=128]="Matrix",e[e.Object=256]="Object",e[e.AutoDetect=1024]="AutoDetect",e[e.BasedOnInput=2048]="BasedOnInput"}(tl||(tl={})),function(e){e[e.Uniform=0]="Uniform",e[e.Attribute=1]="Attribute",e[e.Varying=2]="Varying",e[e.Undefined=3]="Undefined"}(il||(il={})),function(e){e[e.World=1]="World",e[e.View=2]="View",e[e.Projection=3]="Projection",e[e.ViewProjection=4]="ViewProjection",e[e.WorldView=5]="WorldView",e[e.WorldViewProjection=6]="WorldViewProjection",e[e.CameraPosition=7]="CameraPosition",e[e.FogColor=8]="FogColor",e[e.DeltaTime=9]="DeltaTime"}(nl||(nl={})),function(e){e[e.Material=0]="Material",e[e.PostProcess=1]="PostProcess",e[e.Particle=2]="Particle",e[e.ProceduralTexture=3]="ProceduralTexture"}(rl||(rl={})),function(e){e[e.Compatible=0]="Compatible",e[e.TypeIncompatible=1]="TypeIncompatible",e[e.TargetIncompatible=2]="TargetIncompatible"}(ol||(ol={})),function(e){e[e.Input=0]="Input",e[e.Output=1]="Output"}(al||(al={}));var hl=function(){function e(e,t,i){this._connectedPoint=null,this._endpoints=new Array,this._typeConnectionSource=null,this._linkedConnectionSource=null,this._acceptedConnectionPointType=null,this._type=tl.Float,this._enforceAssociatedVariableName=!1,this.needDualDirectionValidation=!1,this.acceptedConnectionPointTypes=new Array,this.excludedConnectionPointTypes=new Array,this.onConnectionObservable=new o.c,this.isExposedOnFrame=!1,this.exposedPortPosition=-1,this._prioritizeVertex=!1,this._target=el.VertexAndFragment,this._ownerBlock=t,this.name=e,this._direction=i}return e.AreEquivalentTypes=function(e,t){switch(e){case tl.Vector3:if(t===tl.Color3)return!0;break;case tl.Vector4:if(t===tl.Color4)return!0;break;case tl.Color3:if(t===tl.Vector3)return!0;break;case tl.Color4:if(t===tl.Vector4)return!0}return!1},Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"associatedVariableName",{get:function(){return this._ownerBlock.isInput?this._ownerBlock.associatedVariableName:this._enforceAssociatedVariableName&&this._associatedVariableName||!this._connectedPoint?this._associatedVariableName:this._connectedPoint.associatedVariableName},set:function(e){this._associatedVariableName=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"innerType",{get:function(){return this._linkedConnectionSource&&this._linkedConnectionSource.isConnected?this.type:this._type},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"type",{get:function(){if(this._type===tl.AutoDetect){if(this._ownerBlock.isInput)return this._ownerBlock.type;if(this._connectedPoint)return this._connectedPoint.type;if(this._linkedConnectionSource&&this._linkedConnectionSource.isConnected)return this._linkedConnectionSource.type}return this._type===tl.BasedOnInput&&this._typeConnectionSource?this._typeConnectionSource.type:this._type},set:function(e){this._type=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._prioritizeVertex&&this._ownerBlock?this._target!==el.VertexAndFragment?this._target:this._ownerBlock.target===el.Fragment?el.Fragment:el.Vertex:this._target},set:function(e){this._target=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnected",{get:function(){return null!==this.connectedPoint||this.hasEndpoints},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnectedToInputBlock",{get:function(){return null!==this.connectedPoint&&this.connectedPoint.ownerBlock.isInput},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectInputBlock",{get:function(){return this.isConnectedToInputBlock?this.connectedPoint.ownerBlock:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectedPoint",{get:function(){return this._connectedPoint},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ownerBlock",{get:function(){return this._ownerBlock},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"sourceBlock",{get:function(){return this._connectedPoint?this._connectedPoint.ownerBlock:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"connectedBlocks",{get:function(){return 0===this._endpoints.length?[]:this._endpoints.map((function(e){return e.ownerBlock}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"endpoints",{get:function(){return this._endpoints},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasEndpoints",{get:function(){return this._endpoints&&this._endpoints.length>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnectedInVertexShader",{get:function(){if(this.target===el.Vertex)return!0;if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e<t.length;e++){var i=t[e];if(i.ownerBlock.target===el.Vertex)return!0;if(i.target===el.Vertex)return!0;if((i.ownerBlock.target===el.Neutral||i.ownerBlock.target===el.VertexAndFragment)&&i.ownerBlock.outputs.some((function(e){return e.isConnectedInVertexShader})))return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isConnectedInFragmentShader",{get:function(){if(this.target===el.Fragment)return!0;if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e<t.length;e++){var i=t[e];if(i.ownerBlock.target===el.Fragment)return!0;if((i.ownerBlock.target===el.Neutral||i.ownerBlock.target===el.VertexAndFragment)&&i.ownerBlock.outputs.some((function(e){return e.isConnectedInFragmentShader})))return!0}return!1},enumerable:!1,configurable:!0}),e.prototype.createCustomInputBlock=function(){return null},e.prototype.getClassName=function(){return"NodeMaterialConnectionPoint"},e.prototype.canConnectTo=function(e){return this.checkCompatibilityState(e)===ol.Compatible},e.prototype.checkCompatibilityState=function(t){if(this._ownerBlock.target===el.Fragment){var i=t.ownerBlock;if(i.target===el.Vertex)return ol.TargetIncompatible;for(var n=0,r=i.outputs;n<r.length;n++){if(r[n].isConnectedInVertexShader)return ol.TargetIncompatible}}return this.type!==t.type&&t.innerType!==tl.AutoDetect?e.AreEquivalentTypes(this.type,t.type)||t.acceptedConnectionPointTypes&&-1!==t.acceptedConnectionPointTypes.indexOf(this.type)||t._acceptedConnectionPointType&&e.AreEquivalentTypes(t._acceptedConnectionPointType.type,this.type)?ol.Compatible:ol.TypeIncompatible:t.excludedConnectionPointTypes&&-1!==t.excludedConnectionPointTypes.indexOf(this.type)?1:ol.Compatible},e.prototype.connectTo=function(e,t){if(void 0===t&&(t=!1),!t&&!this.canConnectTo(e))throw"Cannot connect these two connectors.";return this._endpoints.push(e),e._connectedPoint=this,this._enforceAssociatedVariableName=!1,this.onConnectionObservable.notifyObservers(e),e.onConnectionObservable.notifyObservers(this),this},e.prototype.disconnectFrom=function(e){var t=this._endpoints.indexOf(e);return-1===t||(this._endpoints.splice(t,1),e._connectedPoint=null,this._enforceAssociatedVariableName=!1,e._enforceAssociatedVariableName=!1),this},e.prototype.serialize=function(e){void 0===e&&(e=!0);var t={};return t.name=this.name,t.displayName=this.displayName,e&&this.connectedPoint&&(t.inputName=this.name,t.targetBlockId=this.connectedPoint.ownerBlock.uniqueId,t.targetConnectionName=this.connectedPoint.name,t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),(this.isExposedOnFrame||this.exposedPortPosition>=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t},e.prototype.dispose=function(){this.onConnectionObservable.clear()},e}(),dl=i(152),fl=function(){function e(e,t,i,n){void 0===t&&(t=el.Vertex),void 0===i&&(i=!1),void 0===n&&(n=!1),this._isFinalMerger=!1,this._isInput=!1,this._name="",this._isUnique=!1,this.inputsAreExclusive=!1,this._codeVariableName="",this._inputs=new Array,this._outputs=new Array,this.comments="",this.visibleInInspector=!1,this._target=t,this._isFinalMerger=i,this._isInput=n,this._name=e,this.uniqueId=dl.a.UniqueId}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this.validateBlockName(e)&&(this._name=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUnique",{get:function(){return this._isUnique},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFinalMerger",{get:function(){return this._isFinalMerger},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"buildId",{get:function(){return this._buildId},set:function(e){this._buildId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._target},set:function(e){0==(this._target&e)&&(this._target=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputs",{get:function(){return this._inputs},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"outputs",{get:function(){return this._outputs},enumerable:!1,configurable:!0}),e.prototype.getInputByName=function(e){var t=this._inputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.getOutputByName=function(e){var t=this._outputs.filter((function(t){return t.name===e}));return t.length?t[0]:null},e.prototype.initialize=function(e){},e.prototype.bind=function(e,t,i,n){},e.prototype._declareOutput=function(e,t){return t._getGLType(e.type)+" "+e.associatedVariableName},e.prototype._writeVariable=function(e){return e.connectedPoint?""+e.associatedVariableName:"0."},e.prototype._writeFloat=function(e){var t=e.toString();return-1===t.indexOf(".")&&(t+=".0"),""+t},e.prototype.getClassName=function(){return"NodeMaterialBlock"},e.prototype.registerInput=function(e,t,i,n,r){return void 0===i&&(i=!1),(r=null!=r?r:new hl(e,this,al.Input)).type=t,r.isOptional=i,n&&(r.target=n),this._inputs.push(r),this},e.prototype.registerOutput=function(e,t,i,n){return(n=null!=n?n:new hl(e,this,al.Output)).type=t,i&&(n.target=i),this._outputs.push(n),this},e.prototype.getFirstAvailableInput=function(e){void 0===e&&(e=null);for(var t=0,i=this._inputs;t<i.length;t++){var n=i[t];if(!(n.connectedPoint||e&&e.type!==n.type&&n.type!==tl.AutoDetect))return n}return null},e.prototype.getFirstAvailableOutput=function(e){void 0===e&&(e=null);for(var t=0,i=this._outputs;t<i.length;t++){var n=i[t];if(!e||!e.target||e.target===el.Neutral||0!=(e.target&n.target))return n}return null},e.prototype.getSiblingOutput=function(e){var t=this._outputs.indexOf(e);return-1===t||t>=this._outputs.length?null:this._outputs[t+1]},e.prototype.connectTo=function(e,t){if(0!==this._outputs.length){for(var i=t&&t.output?this.getOutputByName(t.output):this.getFirstAvailableOutput(e),n=!0;n;){var r=t&&t.input?e.getInputByName(t.input):e.getFirstAvailableInput(i);if(i&&r&&i.canConnectTo(r))i.connectTo(r),n=!1;else{if(!i)throw"Unable to find a compatible match";i=this.getSiblingOutput(i)}}return this}},e.prototype._buildBlock=function(e){},e.prototype.updateUniformsAndSamples=function(e,t,i,n){},e.prototype.provideFallbacks=function(e,t){},e.prototype.initializeDefines=function(e,t,i,n){void 0===n&&(n=!1)},e.prototype.prepareDefines=function(e,t,i,n,r){void 0===n&&(n=!1)},e.prototype.autoConfigure=function(e){},e.prototype.replaceRepeatableContent=function(e,t,i,n){},e.prototype.isReady=function(e,t,i,n){return void 0===n&&(n=!1),!0},e.prototype._linkConnectionTypes=function(e,t,i){void 0===i&&(i=!1),i?this._inputs[t]._acceptedConnectionPointType=this._inputs[e]:this._inputs[e]._linkedConnectionSource=this._inputs[t],this._inputs[t]._linkedConnectionSource=this._inputs[e]},e.prototype._processBuild=function(e,t,i,n){e.build(t,n);var r=null!=t._vertexState,o=e._buildTarget===el.Vertex&&e.target!==el.VertexAndFragment;if(r&&(0==(e.target&e._buildTarget)||0==(e.target&i.target)||this.target!==el.VertexAndFragment&&o)&&(!e.isInput&&t.target!==e._buildTarget||e.isInput&&e.isAttribute&&!e._noContextSwitch)){var a=i.connectedPoint;t._vertexState._emitVaryingFromString("v_"+a.associatedVariableName,t._getGLType(a.type))&&(t._vertexState.compilationString+="v_"+a.associatedVariableName+" = "+a.associatedVariableName+";\r\n"),i.associatedVariableName="v_"+a.associatedVariableName,i._enforceAssociatedVariableName=!0}},e.prototype.validateBlockName=function(e){for(var t=0,i=["position","normal","tangent","particle_positionw","uv","uv2","position2d","particle_uv","matricesIndices","matricesWeights","world0","world1","world2","world3","particle_color","particle_texturemask"];t<i.length;t++){if(e===i[t])return!1}return!0},e.prototype.build=function(e,t){if(this._buildId===e.sharedData.buildId)return!0;if(!this.isInput)for(var i=0,n=this._outputs;i<n.length;i++){(l=n[i]).associatedVariableName||(l.associatedVariableName=e._getFreeVariableName(l.name))}for(var r=0,o=this._inputs;r<o.length;r++){var a=o[r];if(a.connectedPoint){if(this.target!==el.Neutral){if(0==(a.target&this.target))continue;if(0==(a.target&e.target))continue}(d=a.connectedPoint.ownerBlock)&&d!==this&&this._processBuild(d,e,a,t)}else a.isOptional||e.sharedData.checks.notConnectedNonOptionalInputs.push(a)}if(this._buildId===e.sharedData.buildId)return!0;if(e.sharedData.verbose&&console.log((e.target===el.Vertex?"Vertex shader":"Fragment shader")+": Building "+this.name+" ["+this.getClassName()+"]"),this.isFinalMerger)switch(e.target){case el.Vertex:e.sharedData.checks.emitVertex=!0;break;case el.Fragment:e.sharedData.checks.emitFragment=!0}!this.isInput&&e.sharedData.emitComments&&(e.compilationString+="\r\n//"+this.name+"\r\n"),this._buildBlock(e),this._buildId=e.sharedData.buildId,this._buildTarget=e.target;for(var s=0,c=this._outputs;s<c.length;s++){var l;if(0!=((l=c[s]).target&e.target))for(var u=0,h=l.endpoints;u<h.length;u++){var d,f=h[u];(d=f.ownerBlock)&&0!=(d.target&e.target)&&-1!==t.indexOf(d)&&this._processBuild(d,e,f,t)}}return!1},e.prototype._inputRename=function(e){return e},e.prototype._outputRename=function(e){return e},e.prototype._dumpPropertiesCode=function(){return this._codeVariableName+".visibleInInspector = "+this.visibleInInspector+";\r\n"},e.prototype._dumpCode=function(e,t){var i;t.push(this);var n=this.name.replace(/[^A-Za-z_]+/g,"");if(this._codeVariableName=n||this.getClassName()+"_"+this.uniqueId,-1!==e.indexOf(this._codeVariableName)){var r=0;do{r++,this._codeVariableName=n+r}while(-1!==e.indexOf(this._codeVariableName))}e.push(this._codeVariableName),i="\r\n// "+this.getClassName()+"\r\n",this.comments&&(i+="// "+this.comments+"\r\n"),i+="var "+this._codeVariableName+" = new BABYLON."+this.getClassName()+'("'+this.name+'");\r\n',i+=this._dumpPropertiesCode();for(var o=0,a=this.inputs;o<a.length;o++){var s=a[o];if(s.isConnected){var c=s.connectedPoint.ownerBlock;-1===t.indexOf(c)&&(i+=c._dumpCode(e,t))}}for(var l=0,u=this.outputs;l<u.length;l++){var h=u[l];if(h.hasEndpoints)for(var d=0,f=h.endpoints;d<f.length;d++){(c=f[d].ownerBlock)&&-1===t.indexOf(c)&&(i+=c._dumpCode(e,t))}}return i},e.prototype._dumpCodeForOutputConnections=function(e){var t="";if(-1!==e.indexOf(this))return t;e.push(this);for(var i=0,n=this.inputs;i<n.length;i++){var r=n[i];if(r.isConnected){var o=r.connectedPoint,a=o.ownerBlock;t+=a._dumpCodeForOutputConnections(e),t+=a._codeVariableName+"."+a._outputRename(o.name)+".connectTo("+this._codeVariableName+"."+this._inputRename(r.name)+");\r\n"}}return t},e.prototype.clone=function(e,t){void 0===t&&(t="");var i=this.serialize(),n=c.a.GetClass(i.customType);if(n){var r=new n;return r._deserialize(i,e,t),r}return null},e.prototype.serialize=function(){var e={};e.customType="BABYLON."+this.getClassName(),e.id=this.uniqueId,e.name=this.name,e.comments=this.comments,e.visibleInInspector=this.visibleInInspector,e.inputs=[],e.outputs=[];for(var t=0,i=this.inputs;t<i.length;t++){var n=i[t];e.inputs.push(n.serialize())}for(var r=0,o=this.outputs;r<o.length;r++){var a=o[r];e.outputs.push(a.serialize(!1))}return e},e.prototype._deserialize=function(e,t,i){this.name=e.name,this.comments=e.comments,this.visibleInInspector=!!e.visibleInInspector,this._deserializePortDisplayNamesAndExposedOnFrame(e)},e.prototype._deserializePortDisplayNamesAndExposedOnFrame=function(e){var t=this,i=e.inputs,n=e.outputs;i&&i.forEach((function(e,i){e.displayName&&(t.inputs[i].displayName=e.displayName),e.isExposedOnFrame&&(t.inputs[i].isExposedOnFrame=e.isExposedOnFrame,t.inputs[i].exposedPortPosition=e.exposedPortPosition)})),n&&n.forEach((function(e,i){e.displayName&&(t.outputs[i].displayName=e.displayName),e.isExposedOnFrame&&(t.outputs[i].isExposedOnFrame=e.isExposedOnFrame,t.outputs[i].exposedPortPosition=e.exposedPortPosition)}))},e.prototype.dispose=function(){for(var e=0,t=this.inputs;e<t.length;e++){t[e].dispose()}for(var i=0,n=this.outputs;i<n.length;i++){n[i].dispose()}},e}(),pl=function(){function e(){this.supportUniformBuffers=!1,this.attributes=new Array,this.uniforms=new Array,this.constants=new Array,this.samplers=new Array,this.functions={},this.extensions={},this.counters={},this._attributeDeclaration="",this._uniformDeclaration="",this._constantDeclaration="",this._samplerDeclaration="",this._varyingTransfer="",this._injectAtEnd="",this._repeatableContentAnchorIndex=0,this._builtCompilationString="",this.compilationString=""}return e.prototype.finalize=function(e){var t=e.sharedData.emitComments,i=this.target===el.Fragment;this.compilationString="\r\n"+(t?"//Entry point\r\n":"")+"void main(void) {\r\n"+this.compilationString,this._constantDeclaration&&(this.compilationString="\r\n"+(t?"//Constants\r\n":"")+this._constantDeclaration+"\r\n"+this.compilationString);var n="";for(var r in this.functions)n+=this.functions[r]+"\r\n";for(var o in this.compilationString="\r\n"+n+"\r\n"+this.compilationString,!i&&this._varyingTransfer&&(this.compilationString=this.compilationString+"\r\n"+this._varyingTransfer),this._injectAtEnd&&(this.compilationString=this.compilationString+"\r\n"+this._injectAtEnd),this.compilationString=this.compilationString+"\r\n}",this.sharedData.varyingDeclaration&&(this.compilationString="\r\n"+(t?"//Varyings\r\n":"")+this.sharedData.varyingDeclaration+"\r\n"+this.compilationString),this._samplerDeclaration&&(this.compilationString="\r\n"+(t?"//Samplers\r\n":"")+this._samplerDeclaration+"\r\n"+this.compilationString),this._uniformDeclaration&&(this.compilationString="\r\n"+(t?"//Uniforms\r\n":"")+this._uniformDeclaration+"\r\n"+this.compilationString),this._attributeDeclaration&&!i&&(this.compilationString="\r\n"+(t?"//Attributes\r\n":"")+this._attributeDeclaration+"\r\n"+this.compilationString),this.compilationString="precision highp float;\r\n"+this.compilationString,this.extensions){var a=this.extensions[o];this.compilationString="\r\n"+a+"\r\n"+this.compilationString}this._builtCompilationString=this.compilationString},Object.defineProperty(e.prototype,"_repeatableContentAnchor",{get:function(){return"###___ANCHOR"+this._repeatableContentAnchorIndex+++"___###"},enumerable:!1,configurable:!0}),e.prototype._getFreeVariableName=function(e){return e=e.replace(/[^a-zA-Z_]+/g,""),void 0===this.sharedData.variableNames[e]?(this.sharedData.variableNames[e]=0,"output"===e||"texture"===e?e+this.sharedData.variableNames[e]:e):(this.sharedData.variableNames[e]++,e+this.sharedData.variableNames[e])},e.prototype._getFreeDefineName=function(e){return void 0===this.sharedData.defineNames[e]?this.sharedData.defineNames[e]=0:this.sharedData.defineNames[e]++,e+this.sharedData.defineNames[e]},e.prototype._excludeVariableName=function(e){this.sharedData.variableNames[e]=0},e.prototype._emit2DSampler=function(e){this.samplers.indexOf(e)<0&&(this._samplerDeclaration+="uniform sampler2D "+e+";\r\n",this.samplers.push(e))},e.prototype._getGLType=function(e){switch(e){case tl.Float:return"float";case tl.Int:return"int";case tl.Vector2:return"vec2";case tl.Color3:case tl.Vector3:return"vec3";case tl.Color4:case tl.Vector4:return"vec4";case tl.Matrix:return"mat4"}return""},e.prototype._emitExtension=function(e,t,i){void 0===i&&(i=""),this.extensions[e]||(i&&(t="#if "+i+"\r\n"+t+"\r\n#endif"),this.extensions[e]=t)},e.prototype._emitFunction=function(e,t,i){this.functions[e]||(this.sharedData.emitComments&&(t=i+"\r\n"+t),this.functions[e]=t)},e.prototype._emitCodeFromInclude=function(e,t,i){if(i&&i.repeatKey)return"#include<"+e+">[0.."+i.repeatKey+"]\r\n";var n=ai.a.IncludesShadersStore[e]+"\r\n";if(this.sharedData.emitComments&&(n=t+"\r\n"+n),!i)return n;if(i.replaceStrings)for(var r=0;r<i.replaceStrings.length;r++){var o=i.replaceStrings[r];n=n.replace(o.search,o.replace)}return n},e.prototype._emitFunctionFromInclude=function(e,t,i,n){void 0===n&&(n="");var r=e+n;if(!this.functions[r]){if(!(i&&(i.removeAttributes||i.removeUniforms||i.removeVaryings||i.removeIfDef||i.replaceStrings)))return i&&i.repeatKey?this.functions[r]="#include<"+e+">[0.."+i.repeatKey+"]\r\n":this.functions[r]="#include<"+e+">\r\n",void(this.sharedData.emitComments&&(this.functions[r]=t+"\r\n"+this.functions[r]));if(this.functions[r]=ai.a.IncludesShadersStore[e],this.sharedData.emitComments&&(this.functions[r]=t+"\r\n"+this.functions[r]),i.removeIfDef&&(this.functions[r]=this.functions[r].replace(/^\s*?#ifdef.+$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#endif.*$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#else.*$/gm,""),this.functions[r]=this.functions[r].replace(/^\s*?#elif.*$/gm,"")),i.removeAttributes&&(this.functions[r]=this.functions[r].replace(/^\s*?attribute.+$/gm,"")),i.removeUniforms&&(this.functions[r]=this.functions[r].replace(/^\s*?uniform.+$/gm,"")),i.removeVaryings&&(this.functions[r]=this.functions[r].replace(/^\s*?varying.+$/gm,"")),i.replaceStrings)for(var o=0;o<i.replaceStrings.length;o++){var a=i.replaceStrings[o];this.functions[r]=this.functions[r].replace(a.search,a.replace)}}},e.prototype._registerTempVariable=function(e){return-1===this.sharedData.temps.indexOf(e)&&(this.sharedData.temps.push(e),!0)},e.prototype._emitVaryingFromString=function(e,t,i,n){return void 0===i&&(i=""),void 0===n&&(n=!1),-1===this.sharedData.varyings.indexOf(e)&&(this.sharedData.varyings.push(e),i&&(io.a.StartsWith(i,"defined(")?this.sharedData.varyingDeclaration+="#if "+i+"\r\n":this.sharedData.varyingDeclaration+=(n?"#ifndef":"#ifdef")+" "+i+"\r\n"),this.sharedData.varyingDeclaration+="varying "+t+" "+e+";\r\n",i&&(this.sharedData.varyingDeclaration+="#endif\r\n"),!0)},e.prototype._emitUniformFromString=function(e,t,i,n){void 0===i&&(i=""),void 0===n&&(n=!1),-1===this.uniforms.indexOf(e)&&(this.uniforms.push(e),i&&(io.a.StartsWith(i,"defined(")?this._uniformDeclaration+="#if "+i+"\r\n":this._uniformDeclaration+=(n?"#ifndef":"#ifdef")+" "+i+"\r\n"),this._uniformDeclaration+="uniform "+t+" "+e+";\r\n",i&&(this._uniformDeclaration+="#endif\r\n"))},e.prototype._emitFloat=function(e){return e.toString()===e.toFixed(0)?e+".0":e.toString()},e}(),_l=function(){function e(){this.temps=new Array,this.varyings=new Array,this.varyingDeclaration="",this.inputBlocks=new Array,this.textureBlocks=new Array,this.bindableBlocks=new Array,this.blocksWithFallbacks=new Array,this.blocksWithDefines=new Array,this.repeatableContentBlocks=new Array,this.dynamicUniformBlocks=new Array,this.blockingBlocks=new Array,this.animatedInputs=new Array,this.variableNames={},this.defineNames={},this.hints={needWorldViewMatrix:!1,needWorldViewProjectionMatrix:!1,needAlphaBlending:!1,needAlphaTesting:!1},this.checks={emitVertex:!1,emitFragment:!1,notConnectedNonOptionalInputs:new Array},this.allowEmptyVertexProgram=!1,this.variableNames.position=0,this.variableNames.normal=0,this.variableNames.tangent=0,this.variableNames.uv=0,this.variableNames.uv2=0,this.variableNames.uv3=0,this.variableNames.uv4=0,this.variableNames.uv4=0,this.variableNames.uv5=0,this.variableNames.uv6=0,this.variableNames.color=0,this.variableNames.matricesIndices=0,this.variableNames.matricesWeights=0,this.variableNames.matricesIndicesExtra=0,this.variableNames.matricesWeightsExtra=0,this.variableNames.diffuseBase=0,this.variableNames.specularBase=0,this.variableNames.worldPos=0,this.variableNames.shadow=0,this.variableNames.view=0,this.variableNames.vTBN=0,this.defineNames.MAINUV0=0,this.defineNames.MAINUV1=0,this.defineNames.MAINUV2=0,this.defineNames.MAINUV3=0,this.defineNames.MAINUV4=0,this.defineNames.MAINUV5=0,this.defineNames.MAINUV6=0,this.defineNames.MAINUV7=0}return e.prototype.emitErrors=function(){var e="";this.checks.emitVertex||this.allowEmptyVertexProgram||(e+="NodeMaterial does not have a vertex output. You need to at least add a block that generates a glPosition value.\r\n"),this.checks.emitFragment||(e+="NodeMaterial does not have a fragment output. You need to at least add a block that generates a glFragColor value.\r\n");for(var t=0,i=this.checks.notConnectedNonOptionalInputs;t<i.length;t++){var n=i[t];e+="input "+n.name+" from block "+n.ownerBlock.name+"["+n.ownerBlock.getClassName()+"] is not connected and is not optional.\r\n"}if(e)throw"Build of NodeMaterial failed:\r\n"+e},e}(),ml=function(e){function t(t){var i=e.call(this,t,el.Vertex)||this;return i.complementW=1,i.complementZ=0,i.registerInput("vector",tl.AutoDetect),i.registerInput("transform",tl.Matrix),i.registerOutput("output",tl.Vector4),i.registerOutput("xyz",tl.Vector3),i._inputs[0].onConnectionObservable.add((function(e){if(e.ownerBlock.isInput){var t=e.ownerBlock;"normal"!==t.name&&"tangent"!==t.name||(i.complementW=0)}})),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"TransformBlock"},Object.defineProperty(t.prototype,"vector",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transform",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.vector,n=this.transform;if(i.connectedPoint){if(0===this.complementW){var r="//"+this.name;t._emitFunctionFromInclude("helperFunctions",r),t.sharedData.blocksWithDefines.push(this);var o=t._getFreeVariableName(n.associatedVariableName+"_NUS");switch(t.compilationString+="mat3 "+o+" = mat3("+n.associatedVariableName+");\r\n",t.compilationString+="#ifdef NONUNIFORMSCALING\r\n",t.compilationString+=o+" = transposeMat3(inverseMat3("+o+"));\r\n",t.compilationString+="#endif\r\n",i.connectedPoint.type){case tl.Vector2:t.compilationString+=this._declareOutput(this.output,t)+" = vec4("+o+" * vec3("+i.associatedVariableName+", "+this._writeFloat(this.complementZ)+"), "+this._writeFloat(this.complementW)+");\r\n";break;case tl.Vector3:case tl.Color3:t.compilationString+=this._declareOutput(this.output,t)+" = vec4("+o+" * "+i.associatedVariableName+", "+this._writeFloat(this.complementW)+");\r\n";break;default:t.compilationString+=this._declareOutput(this.output,t)+" = vec4("+o+" * "+i.associatedVariableName+".xyz, "+this._writeFloat(this.complementW)+");\r\n"}}else{o=n.associatedVariableName;switch(i.connectedPoint.type){case tl.Vector2:t.compilationString+=this._declareOutput(this.output,t)+" = "+o+" * vec4("+i.associatedVariableName+", "+this._writeFloat(this.complementZ)+", "+this._writeFloat(this.complementW)+");\r\n";break;case tl.Vector3:case tl.Color3:t.compilationString+=this._declareOutput(this.output,t)+" = "+o+" * vec4("+i.associatedVariableName+", "+this._writeFloat(this.complementW)+");\r\n";break;default:t.compilationString+=this._declareOutput(this.output,t)+" = "+o+" * "+i.associatedVariableName+";\r\n"}}this.xyz.hasEndpoints&&(t.compilationString+=this._declareOutput(this.xyz,t)+" = "+this.output.associatedVariableName+".xyz;\r\n")}return this},t.prototype.prepareDefines=function(e,t,i,n,r){void 0===n&&(n=!1),e.nonUniformScaling&&i.setValue("NONUNIFORMSCALING",!0)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.complementZ=this.complementZ,t.complementW=this.complementW,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.complementZ=void 0!==t.complementZ?t.complementZ:0,this.complementW=void 0!==t.complementW?t.complementW:1},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".complementZ = "+this.complementZ+";\r\n";return e+=this._codeVariableName+".complementW = "+this.complementW+";\r\n"},t}(fl);c.a.RegisteredTypes["BABYLON.TransformBlock"]=ml;var gl=function(e){function t(t){var i=e.call(this,t,el.Vertex,!0)||this;return i.registerInput("vector",tl.Vector4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VertexOutputBlock"},Object.defineProperty(t.prototype,"vector",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.vector;return t.compilationString+="gl_Position = "+i.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.VertexOutputBlock"]=gl;var vl,bl=function(e){function t(t){var i=e.call(this,t,el.Fragment,!0)||this;return i.registerInput("rgba",tl.Color4,!0),i.registerInput("rgb",tl.Color3,!0),i.registerInput("a",tl.Float,!0),i.rgb.acceptedConnectionPointTypes.push(tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FragmentOutputBlock"},Object.defineProperty(t.prototype,"rgba",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.rgba,n=this.rgb,r=this.a;if(t.sharedData.hints.needAlphaBlending=i.isConnected||r.isConnected,i.connectedPoint)r.isConnected?t.compilationString+="gl_FragColor = vec4("+i.associatedVariableName+".rgb, "+r.associatedVariableName+");\r\n":t.compilationString+="gl_FragColor = "+i.associatedVariableName+";\r\n";else if(n.connectedPoint){var o="1.0";r.connectedPoint&&(o=r.associatedVariableName),n.connectedPoint.type===tl.Float?t.compilationString+="gl_FragColor = vec4("+n.associatedVariableName+", "+n.associatedVariableName+", "+n.associatedVariableName+", "+o+");\r\n":t.compilationString+="gl_FragColor = vec4("+n.associatedVariableName+", "+o+");\r\n"}else t.sharedData.checks.notConnectedNonOptionalInputs.push(i);return this},t}(fl);c.a.RegisteredTypes["BABYLON.FragmentOutputBlock"]=bl,function(e){e[e.None=0]="None",e[e.Time=1]="Time"}(vl||(vl={}));var yl={position2d:"position",particle_uv:"vUV",particle_color:"vColor",particle_texturemask:"textureMask",particle_positionw:"vPositionW"},Tl={particle_uv:!0,particle_color:!0,particle_texturemask:!0,particle_positionw:!0},El={particle_texturemask:!0},Sl=function(e){function t(t,i,n){void 0===i&&(i=el.Vertex),void 0===n&&(n=tl.AutoDetect);var r=e.call(this,t,i,!1,!0)||this;return r._mode=il.Undefined,r._animationType=vl.None,r.min=0,r.max=0,r.isBoolean=!1,r.matrixMode=0,r._systemValue=null,r.isConstant=!1,r.groupInInspector="",r.onValueChangedObservable=new o.c,r.convertToGammaSpace=!1,r.convertToLinearSpace=!1,r._type=n,r.setDefaultValue(),r.registerOutput("output",n),r}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"type",{get:function(){if(this._type===tl.AutoDetect){if(this.isUniform&&null!=this.value){if(!isNaN(this.value))return this._type=tl.Float,this._type;switch(this.value.getClassName()){case"Vector2":return this._type=tl.Vector2,this._type;case"Vector3":return this._type=tl.Vector3,this._type;case"Vector4":return this._type=tl.Vector4,this._type;case"Color3":return this._type=tl.Color3,this._type;case"Color4":return this._type=tl.Color4,this._type;case"Matrix":return this._type=tl.Matrix,this._type}}if(this.isAttribute)switch(this.name){case"position":case"normal":case"tangent":case"particle_positionw":return this._type=tl.Vector3,this._type;case"uv":case"uv2":case"position2d":case"particle_uv":return this._type=tl.Vector2,this._type;case"matricesIndices":case"matricesWeights":case"world0":case"world1":case"world2":case"world3":return this._type=tl.Vector4,this._type;case"color":case"particle_color":case"particle_texturemask":return this._type=tl.Color4,this._type}if(this.isSystemValue)switch(this._systemValue){case nl.World:case nl.WorldView:case nl.WorldViewProjection:case nl.View:case nl.ViewProjection:case nl.Projection:return this._type=tl.Matrix,this._type;case nl.CameraPosition:return this._type=tl.Vector3,this._type;case nl.FogColor:return this._type=tl.Color3,this._type;case nl.DeltaTime:return this._type=tl.Float,this._type}}return this._type},enumerable:!1,configurable:!0}),t.prototype.validateBlockName=function(t){return!!this.isAttribute||e.prototype.validateBlockName.call(this,t)},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.setAsAttribute=function(e){return this._mode=il.Attribute,e&&(this.name=e),this},t.prototype.setAsSystemValue=function(e){return this.systemValue=e,this},Object.defineProperty(t.prototype,"value",{get:function(){return this._storedValue},set:function(e){this.type===tl.Float&&(this.isBoolean?e=e?1:0:this.min!==this.max&&(e=Math.max(this.min,e),e=Math.min(this.max,e))),this._storedValue=e,this._mode=il.Uniform,this.onValueChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"valueCallback",{get:function(){return this._valueCallback},set:function(e){this._valueCallback=e,this._mode=il.Uniform},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"associatedVariableName",{get:function(){return this._associatedVariableName},set:function(e){this._associatedVariableName=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"animationType",{get:function(){return this._animationType},set:function(e){this._animationType=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUndefined",{get:function(){return this._mode===il.Undefined},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isUniform",{get:function(){return this._mode===il.Uniform},set:function(e){this._mode=e?il.Uniform:il.Undefined,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isAttribute",{get:function(){return this._mode===il.Attribute},set:function(e){this._mode=e?il.Attribute:il.Undefined,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isVarying",{get:function(){return this._mode===il.Varying},set:function(e){this._mode=e?il.Varying:il.Undefined,this.associatedVariableName=""},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isSystemValue",{get:function(){return null!=this._systemValue},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"systemValue",{get:function(){return this._systemValue},set:function(e){this._mode=il.Uniform,this.associatedVariableName="",this._systemValue=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"InputBlock"},t.prototype.animate=function(e){switch(this._animationType){case vl.Time:this.type===tl.Float&&(this.value+=.01*e.getAnimationRatio())}},t.prototype._emitDefine=function(e){return"!"===e[0]?"#ifndef "+e.substring(1)+"\r\n":"#ifdef "+e+"\r\n"},t.prototype.initialize=function(e){this.associatedVariableName=""},t.prototype.setDefaultValue=function(){switch(this.type){case tl.Float:this.value=0;break;case tl.Vector2:this.value=a.d.Zero();break;case tl.Vector3:this.value=a.e.Zero();break;case tl.Vector4:this.value=a.f.Zero();break;case tl.Color3:this.value=s.a.White();break;case tl.Color4:this.value=new s.b(1,1,1,1);break;case tl.Matrix:this.value=a.a.Identity()}},t.prototype._emitConstant=function(e){switch(this.type){case tl.Float:return""+e._emitFloat(this.value);case tl.Vector2:return"vec2("+this.value.x+", "+this.value.y+")";case tl.Vector3:return"vec3("+this.value.x+", "+this.value.y+", "+this.value.z+")";case tl.Vector4:return"vec4("+this.value.x+", "+this.value.y+", "+this.value.z+", "+this.value.w+")";case tl.Color3:return s.c.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&s.c.Color3[0].toGammaSpaceToRef(s.c.Color3[0]),this.convertToLinearSpace&&s.c.Color3[0].toLinearSpaceToRef(s.c.Color3[0]),"vec3("+s.c.Color3[0].r+", "+s.c.Color3[0].g+", "+s.c.Color3[0].b+")";case tl.Color4:return s.c.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&s.c.Color4[0].toGammaSpaceToRef(s.c.Color4[0]),this.convertToLinearSpace&&s.c.Color4[0].toLinearSpaceToRef(s.c.Color4[0]),"vec4("+s.c.Color4[0].r+", "+s.c.Color4[0].g+", "+s.c.Color4[0].b+", "+s.c.Color4[0].a+")"}return""},Object.defineProperty(t.prototype,"_noContextSwitch",{get:function(){return Tl[this.name]},enumerable:!1,configurable:!0}),t.prototype._emit=function(e,t){var i;if(this.isUniform){if(this.associatedVariableName||(this.associatedVariableName=e._getFreeVariableName("u_"+this.name)),this.isConstant){if(-1!==e.constants.indexOf(this.associatedVariableName))return;return e.constants.push(this.associatedVariableName),void(e._constantDeclaration+=this._declareOutput(this.output,e)+" = "+this._emitConstant(e)+";\r\n")}if(-1!==e.uniforms.indexOf(this.associatedVariableName))return;e.uniforms.push(this.associatedVariableName),t&&(e._uniformDeclaration+=this._emitDefine(t)),e._uniformDeclaration+="uniform "+e._getGLType(this.type)+" "+this.associatedVariableName+";\r\n",t&&(e._uniformDeclaration+="#endif\r\n");var n=e.sharedData.hints;if(null!==this._systemValue&&void 0!==this._systemValue)switch(this._systemValue){case nl.WorldView:n.needWorldViewMatrix=!0;break;case nl.WorldViewProjection:n.needWorldViewProjectionMatrix=!0}else this._animationType!==vl.None&&e.sharedData.animatedInputs.push(this)}else if(this.isAttribute){if(this.associatedVariableName=null!==(i=yl[this.name])&&void 0!==i?i:this.name,this.target===el.Vertex&&e._vertexState)return void(Tl[this.name]?El[this.name]?e._emitUniformFromString(this.associatedVariableName,e._getGLType(this.type),t):e._emitVaryingFromString(this.associatedVariableName,e._getGLType(this.type),t):this._emit(e._vertexState,t));if(-1!==e.attributes.indexOf(this.associatedVariableName))return;e.attributes.push(this.associatedVariableName),Tl[this.name]?El[this.name]?e._emitUniformFromString(this.associatedVariableName,e._getGLType(this.type),t):e._emitVaryingFromString(this.associatedVariableName,e._getGLType(this.type),t):(t&&(e._attributeDeclaration+=this._emitDefine(t)),e._attributeDeclaration+="attribute "+e._getGLType(this.type)+" "+this.associatedVariableName+";\r\n",t&&(e._attributeDeclaration+="#endif\r\n"))}},t.prototype._transmitWorld=function(e,t,i,n){if(this._systemValue){var r=this.associatedVariableName;switch(this._systemValue){case nl.World:e.setMatrix(r,t);break;case nl.WorldView:e.setMatrix(r,i);break;case nl.WorldViewProjection:e.setMatrix(r,n)}}},t.prototype._transmit=function(e,t){if(!this.isAttribute){var i=this.associatedVariableName;if(this._systemValue)switch(this._systemValue){case nl.World:case nl.WorldView:case nl.WorldViewProjection:return;case nl.View:e.setMatrix(i,t.getViewMatrix());break;case nl.Projection:e.setMatrix(i,t.getProjectionMatrix());break;case nl.ViewProjection:e.setMatrix(i,t.getTransformMatrix());break;case nl.CameraPosition:ro.a.BindEyePosition(e,t,i);break;case nl.FogColor:e.setColor3(i,t.fogColor);break;case nl.DeltaTime:e.setFloat(i,t.deltaTime/1e3)}else{var n=this._valueCallback?this._valueCallback():this._storedValue;if(null!==n)switch(this.type){case tl.Float:e.setFloat(i,n);break;case tl.Int:e.setInt(i,n);break;case tl.Color3:s.c.Color3[0].set(this.value.r,this.value.g,this.value.b),this.convertToGammaSpace&&s.c.Color3[0].toGammaSpaceToRef(s.c.Color3[0]),this.convertToLinearSpace&&s.c.Color3[0].toLinearSpaceToRef(s.c.Color3[0]),e.setColor3(i,s.c.Color3[0]);break;case tl.Color4:s.c.Color4[0].set(this.value.r,this.value.g,this.value.b,this.value.a),this.convertToGammaSpace&&s.c.Color4[0].toGammaSpaceToRef(s.c.Color4[0]),this.convertToLinearSpace&&s.c.Color4[0].toLinearSpaceToRef(s.c.Color4[0]),e.setDirectColor4(i,s.c.Color4[0]);break;case tl.Vector2:e.setVector2(i,n);break;case tl.Vector3:e.setVector3(i,n);break;case tl.Vector4:e.setVector4(i,n);break;case tl.Matrix:e.setMatrix(i,n)}}}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),(this.isUniform||this.isSystemValue)&&t.sharedData.inputBlocks.push(this),this._emit(t)},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName;if(this.isAttribute)return e+'.setAsAttribute("'+this.name+'");\r\n';if(this.isSystemValue)return e+".setAsSystemValue(BABYLON.NodeMaterialSystemValues."+nl[this._systemValue]+");\r\n";if(this.isUniform){var t=[],i="";switch(this.type){case tl.Float:i=""+this.value;break;case tl.Vector2:i="new BABYLON.Vector2("+this.value.x+", "+this.value.y+")";break;case tl.Vector3:i="new BABYLON.Vector3("+this.value.x+", "+this.value.y+", "+this.value.z+")";break;case tl.Vector4:i="new BABYLON.Vector4("+this.value.x+", "+this.value.y+", "+this.value.z+", "+this.value.w+")";break;case tl.Color3:i="new BABYLON.Color3("+this.value.r+", "+this.value.g+", "+this.value.b+")",this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case tl.Color4:i="new BABYLON.Color4("+this.value.r+", "+this.value.g+", "+this.value.b+", "+this.value.a+")",this.convertToGammaSpace&&(i+=".toGammaSpace()"),this.convertToLinearSpace&&(i+=".toLinearSpace()");break;case tl.Matrix:i="BABYLON.Matrix.FromArray(["+this.value.m+"])"}return t.push(e+".value = "+i),this.type===tl.Float&&t.push(e+".min = "+this.min,e+".max = "+this.max,e+".isBoolean = "+this.isBoolean,e+".matrixMode = "+this.matrixMode,e+".animationType = BABYLON.AnimatedInputBlockTypes."+vl[this.animationType]),t.push(e+".isConstant = "+this.isConstant),t.push(""),t.join(";\r\n")}return""},t.prototype.dispose=function(){this.onValueChangedObservable.clear(),e.prototype.dispose.call(this)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.type=this.type,t.mode=this._mode,t.systemValue=this._systemValue,t.animationType=this._animationType,t.min=this.min,t.max=this.max,t.isBoolean=this.isBoolean,t.matrixMode=this.matrixMode,t.isConstant=this.isConstant,t.groupInInspector=this.groupInInspector,t.convertToGammaSpace=this.convertToGammaSpace,t.convertToLinearSpace=this.convertToLinearSpace,null!=this._storedValue&&this._mode===il.Uniform&&(this._storedValue.asArray?(t.valueType="BABYLON."+this._storedValue.getClassName(),t.value=this._storedValue.asArray()):(t.valueType="number",t.value=this._storedValue)),t},t.prototype._deserialize=function(t,i,n){if(this._mode=t.mode,e.prototype._deserialize.call(this,t,i,n),this._type=t.type,this._systemValue=t.systemValue||t.wellKnownValue,this._animationType=t.animationType,this.min=t.min||0,this.max=t.max||0,this.isBoolean=!!t.isBoolean,this.matrixMode=t.matrixMode||0,this.isConstant=!!t.isConstant,this.groupInInspector=t.groupInInspector||"",this.convertToGammaSpace=!!t.convertToGammaSpace,this.convertToLinearSpace=!!t.convertToLinearSpace,t.valueType)if("number"===t.valueType)this._storedValue=t.value;else{var r=c.a.GetClass(t.valueType);r&&(this._storedValue=r.FromArray(t.value))}},t}(fl);c.a.RegisteredTypes["BABYLON.InputBlock"]=Sl;var Al=function(e){function t(t){var i=e.call(this,t,el.VertexAndFragment)||this;return i._samplerName="textureSampler",i.convertToGammaSpace=!1,i.convertToLinearSpace=!1,i._isUnique=!1,i.registerInput("uv",tl.Vector2,!1,el.VertexAndFragment),i.registerOutput("rgba",tl.Color4,el.Neutral),i.registerOutput("rgb",tl.Color3,el.Neutral),i.registerOutput("r",tl.Float,el.Neutral),i.registerOutput("g",tl.Float,el.Neutral),i.registerOutput("b",tl.Float,el.Neutral),i.registerOutput("a",tl.Float,el.Neutral),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[0]._prioritizeVertex=!1,i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"CurrentScreenBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("textureSampler")},Object.defineProperty(t.prototype,"target",{get:function(){return this.uv.isConnected?this.uv.sourceBlock.isInput?el.VertexAndFragment:el.Fragment:el.VertexAndFragment},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,t,i){i.setValue(this._linearDefineName,this.convertToGammaSpace,!0),i.setValue(this._gammaDefineName,this.convertToLinearSpace,!0)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype._injectVertexCode=function(e){var t=this.uv;t.connectedPoint.ownerBlock.isInput&&(t.connectedPoint.ownerBlock.isAttribute||e._emitUniformFromString(t.associatedVariableName,"vec2"));if(this._mainUVName="vMain"+t.associatedVariableName,e._emitVaryingFromString(this._mainUVName,"vec2"),e.compilationString+=this._mainUVName+" = "+t.associatedVariableName+".xy;\r\n",this._outputs.some((function(e){return e.isConnectedInVertexShader}))){this._writeTextureRead(e,!0);for(var i=0,n=this._outputs;i<n.length;i++){var r=n[i];r.hasEndpoints&&this._writeOutput(e,r,r.name,!0)}}},t.prototype._writeTextureRead=function(e,t){void 0===t&&(t=!1);var i=this.uv;if(t){if(e.target===el.Fragment)return;e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+");\r\n"}else this.uv.ownerBlock.target!==el.Fragment?e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this._mainUVName+");\r\n":e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+");\r\n"},t.prototype._writeOutput=function(e,t,i,n){if(void 0===n&&(n=!1),n){if(e.target===el.Fragment)return;e.compilationString+=this._declareOutput(t,e)+" = "+this._tempTextureRead+"."+i+";\r\n"}else this.uv.ownerBlock.target!==el.Fragment?(e.compilationString+=this._declareOutput(t,e)+" = "+this._tempTextureRead+"."+i+";\r\n",e.compilationString+="#ifdef "+this._linearDefineName+"\r\n",e.compilationString+=t.associatedVariableName+" = toGammaSpace("+t.associatedVariableName+");\r\n",e.compilationString+="#endif\r\n",e.compilationString+="#ifdef "+this._gammaDefineName+"\r\n",e.compilationString+=t.associatedVariableName+" = toLinearSpace("+t.associatedVariableName+");\r\n",e.compilationString+="#endif\r\n"):e.compilationString+=this._declareOutput(t,e)+" = "+this._tempTextureRead+"."+i+";\r\n"},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),this._tempTextureRead=t._getFreeVariableName("tempTextureRead"),t.sharedData.blockingBlocks.indexOf(this)<0&&t.sharedData.blockingBlocks.push(this),t.sharedData.textureBlocks.indexOf(this)<0&&t.sharedData.textureBlocks.push(this),t.sharedData.blocksWithDefines.indexOf(this)<0&&t.sharedData.blocksWithDefines.push(this),t.target!==el.Fragment)return t._emit2DSampler(this._samplerName),void this._injectVertexCode(t);if(this._outputs.some((function(e){return e.isConnectedInFragmentShader}))){t._emit2DSampler(this._samplerName),this._linearDefineName=t._getFreeDefineName("ISLINEAR"),this._gammaDefineName=t._getFreeDefineName("ISGAMMA");var i="//"+this.name;t._emitFunctionFromInclude("helperFunctions",i),this._writeTextureRead(t);for(var n=0,r=this._outputs;n<r.length;n++){var o=r[n];o.hasEndpoints&&this._writeOutput(t,o,o.name)}return this}},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.convertToGammaSpace=this.convertToGammaSpace,t.convertToLinearSpace=this.convertToLinearSpace,this.texture&&(t.texture=this.texture.serialize()),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.convertToGammaSpace=t.convertToGammaSpace,this.convertToLinearSpace=!!t.convertToLinearSpace,t.texture&&(n=0===t.texture.url.indexOf("data:")?"":n,this.texture=Ke.a.Parse(t.texture,i,n))},t}(fl);c.a.RegisteredTypes["BABYLON.CurrentScreenBlock"]=Al;var Pl=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i._samplerName="diffuseSampler",i.convertToGammaSpace=!1,i.convertToLinearSpace=!1,i._isUnique=!1,i.registerInput("uv",tl.Vector2,!1,el.VertexAndFragment),i.registerOutput("rgba",tl.Color4,el.Neutral),i.registerOutput("rgb",tl.Color3,el.Neutral),i.registerOutput("r",tl.Float,el.Neutral),i.registerOutput("g",tl.Float,el.Neutral),i.registerOutput("b",tl.Float,el.Neutral),i.registerOutput("a",tl.Float,el.Neutral),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ParticleTextureBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("diffuseSampler")},t.prototype.autoConfigure=function(e){if(!this.uv.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"particle_uv"===e.name}));t||(t=new Sl("uv")).setAsAttribute("particle_uv"),t.output.connectTo(this.uv)}},t.prototype.prepareDefines=function(e,t,i){i.setValue(this._linearDefineName,this.convertToGammaSpace,!0),i.setValue(this._gammaDefineName,this.convertToLinearSpace,!0)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype._writeOutput=function(e,t,i){e.compilationString+=this._declareOutput(t,e)+" = "+this._tempTextureRead+"."+i+";\r\n",e.compilationString+="#ifdef "+this._linearDefineName+"\r\n",e.compilationString+=t.associatedVariableName+" = toGammaSpace("+t.associatedVariableName+");\r\n",e.compilationString+="#endif\r\n",e.compilationString+="#ifdef "+this._gammaDefineName+"\r\n",e.compilationString+=t.associatedVariableName+" = toLinearSpace("+t.associatedVariableName+");\r\n",e.compilationString+="#endif\r\n"},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target!==el.Vertex){this._tempTextureRead=t._getFreeVariableName("tempTextureRead"),t._emit2DSampler(this._samplerName),t.sharedData.blockingBlocks.push(this),t.sharedData.textureBlocks.push(this),t.sharedData.blocksWithDefines.push(this),this._linearDefineName=t._getFreeDefineName("ISLINEAR"),this._gammaDefineName=t._getFreeDefineName("ISGAMMA");var i="//"+this.name;t._emitFunctionFromInclude("helperFunctions",i),t.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this.uv.associatedVariableName+");\r\n";for(var n=0,r=this._outputs;n<r.length;n++){var o=r[n];o.hasEndpoints&&this._writeOutput(t,o,o.name)}return this}},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.convertToGammaSpace=this.convertToGammaSpace,t.convertToLinearSpace=this.convertToLinearSpace,this.texture&&(t.texture=this.texture.serialize()),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.convertToGammaSpace=t.convertToGammaSpace,this.convertToLinearSpace=!!t.convertToLinearSpace,t.texture&&(n=0===t.texture.url.indexOf("data:")?"":n,this.texture=Ke.a.Parse(t.texture,i,n))},t}(fl);c.a.RegisteredTypes["BABYLON.ParticleTextureBlock"]=Pl;var Cl=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i._isUnique=!0,i.registerInput("color",tl.Color4,!1,el.Fragment),i.registerOutput("rampColor",tl.Color4,el.Fragment),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ParticleRampGradientBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rampColor",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("remapRanges"),e._excludeVariableName("rampSampler"),e._excludeVariableName("baseColor"),e._excludeVariableName("alpha"),e._excludeVariableName("remappedColorIndex"),e._excludeVariableName("rampColor"),e._excludeVariableName("finalAlpha")},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target!==el.Vertex)return t._emit2DSampler("rampSampler"),t._emitVaryingFromString("remapRanges","vec4","RAMPGRADIENT"),t.compilationString+="\n #ifdef RAMPGRADIENT\n vec4 baseColor = "+this.color.associatedVariableName+";\n float alpha = "+this.color.associatedVariableName+".a;\n\n float remappedColorIndex = clamp((alpha - remapRanges.x) / remapRanges.y, 0.0, 1.0);\n\n vec4 rampColor = texture2D(rampSampler, vec2(1.0 - remappedColorIndex, 0.));\n baseColor.rgb *= rampColor.rgb;\n\n // Remapped alpha\n float finalAlpha = baseColor.a;\n baseColor.a = clamp((alpha * rampColor.a - remapRanges.z) / remapRanges.w, 0.0, 1.0);\n\n "+this._declareOutput(this.rampColor,t)+" = baseColor;\n #else\n "+this._declareOutput(this.rampColor,t)+" = "+this.color.associatedVariableName+";\n #endif\n ",this},t}(fl);c.a.RegisteredTypes["BABYLON.ParticleRampGradientBlock"]=Cl;var Rl=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i._isUnique=!0,i.registerInput("color",tl.Color4,!1,el.Fragment),i.registerInput("alphaTexture",tl.Float,!1,el.Fragment),i.registerInput("alphaColor",tl.Float,!1,el.Fragment),i.registerOutput("blendColor",tl.Color4,el.Fragment),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ParticleBlendMultiplyBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alphaTexture",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alphaColor",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blendColor",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("sourceAlpha")},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target!==el.Vertex)return t.compilationString+="\n #ifdef BLENDMULTIPLYMODE\n "+this._declareOutput(this.blendColor,t)+";\n float sourceAlpha = "+this.alphaColor.associatedVariableName+" * "+this.alphaTexture.associatedVariableName+";\n "+this.blendColor.associatedVariableName+".rgb = "+this.color.associatedVariableName+".rgb * sourceAlpha + vec3(1.0) * (1.0 - sourceAlpha);\n "+this.blendColor.associatedVariableName+".a = "+this.color.associatedVariableName+".a;\n #else\n "+this._declareOutput(this.blendColor,t)+" = "+this.color.associatedVariableName+";\n #endif\n ",this},t}(fl);c.a.RegisteredTypes["BABYLON.ParticleBlendMultiplyBlock"]=Rl;var xl,Ol=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("xyz ",tl.Vector3,!0),i.registerInput("xy ",tl.Vector2,!0),i.registerInput("x",tl.Float,!0),i.registerInput("y",tl.Float,!0),i.registerInput("z",tl.Float,!0),i.registerInput("w",tl.Float,!0),i.registerOutput("xyzw",tl.Vector4),i.registerOutput("xyz",tl.Vector3),i.registerOutput("xy",tl.Vector2),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VectorMergerBlock"},Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"w",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xy",{get:function(){return this.xyOut},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this.xyzOut},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.x,n=this.y,r=this.z,o=this.w,a=this.xyIn,s=this.xyzIn,c=this._outputs[0],l=this._outputs[1],u=this._outputs[2];return s.isConnected?c.hasEndpoints?t.compilationString+=this._declareOutput(c,t)+" = vec4("+s.associatedVariableName+", "+(o.isConnected?this._writeVariable(o):"0.0")+");\r\n":l.hasEndpoints?t.compilationString+=this._declareOutput(l,t)+" = "+s.associatedVariableName+";\r\n":u.hasEndpoints&&(t.compilationString+=this._declareOutput(u,t)+" = "+s.associatedVariableName+".xy;\r\n"):a.isConnected?c.hasEndpoints?t.compilationString+=this._declareOutput(c,t)+" = vec4("+a.associatedVariableName+", "+(r.isConnected?this._writeVariable(r):"0.0")+", "+(o.isConnected?this._writeVariable(o):"0.0")+");\r\n":l.hasEndpoints?t.compilationString+=this._declareOutput(l,t)+" = vec3("+a.associatedVariableName+", "+(r.isConnected?this._writeVariable(r):"0.0")+");\r\n":u.hasEndpoints&&(t.compilationString+=this._declareOutput(u,t)+" = "+a.associatedVariableName+";\r\n"):c.hasEndpoints?t.compilationString+=this._declareOutput(c,t)+" = vec4("+(i.isConnected?this._writeVariable(i):"0.0")+", "+(n.isConnected?this._writeVariable(n):"0.0")+", "+(r.isConnected?this._writeVariable(r):"0.0")+", "+(o.isConnected?this._writeVariable(o):"0.0")+");\r\n":l.hasEndpoints?t.compilationString+=this._declareOutput(l,t)+" = vec3("+(i.isConnected?this._writeVariable(i):"0.0")+", "+(n.isConnected?this._writeVariable(n):"0.0")+", "+(r.isConnected?this._writeVariable(r):"0.0")+");\r\n":u.hasEndpoints&&(t.compilationString+=this._declareOutput(u,t)+" = vec2("+(i.isConnected?this._writeVariable(i):"0.0")+", "+(n.isConnected?this._writeVariable(n):"0.0")+");\r\n"),this},t}(fl);function Ml(e,t,i,n){return void 0===t&&(t=xl.Boolean),void 0===i&&(i="PROPERTIES"),function(r,o){var a=r._propStore;a||(a=[],r._propStore=a),a.push({propertyName:o,displayName:e,type:t,groupName:i,options:null!=n?n:{}})}}c.a.RegisteredTypes["BABYLON.VectorMergerBlock"]=Ol,function(e){e[e.Boolean=0]="Boolean",e[e.Float=1]="Float",e[e.Vector2=2]="Vector2",e[e.List=3]="List"}(xl||(xl={}));var Il=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.sourceRange=new a.d(-1,1),i.targetRange=new a.d(0,1),i.registerInput("input",tl.AutoDetect),i.registerInput("sourceMin",tl.Float,!0),i.registerInput("sourceMax",tl.Float,!0),i.registerInput("targetMin",tl.Float,!0),i.registerInput("targetMax",tl.Float,!0),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"RemapBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMin",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sourceMax",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMin",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"targetMax",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=this.sourceMin.isConnected?this.sourceMin.associatedVariableName:this._writeFloat(this.sourceRange.x),r=this.sourceMax.isConnected?this.sourceMax.associatedVariableName:this._writeFloat(this.sourceRange.y),o=this.targetMin.isConnected?this.targetMin.associatedVariableName:this._writeFloat(this.targetRange.x),a=this.targetMax.isConnected?this.targetMax.associatedVariableName:this._writeFloat(this.targetRange.y);return t.compilationString+=this._declareOutput(i,t)+" = "+o+" + ("+this._inputs[0].associatedVariableName+" - "+n+") * ("+a+" - "+o+") / ("+r+" - "+n+");\r\n",this},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".sourceRange = new BABYLON.Vector2("+this.sourceRange.x+", "+this.sourceRange.y+");\r\n";return e+=this._codeVariableName+".targetRange = new BABYLON.Vector2("+this.targetRange.x+", "+this.targetRange.y+");\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.sourceRange=this.sourceRange.asArray(),t.targetRange=this.targetRange.asArray(),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.sourceRange=a.d.FromArray(t.sourceRange),this.targetRange=a.d.FromArray(t.targetRange)},Object(h.c)([Ml("From",xl.Vector2)],t.prototype,"sourceRange",void 0),Object(h.c)([Ml("To",xl.Vector2)],t.prototype,"targetRange",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.RemapBlock"]=Il;var Dl=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"MultiplyBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = "+this.left.associatedVariableName+" * "+this.right.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.MultiplyBlock"]=Dl;var Nl=function(){function e(){this.direction1=new a.e(0,1,0),this.direction2=new a.e(0,1,0),this.minEmitBox=new a.e(-.5,-.5,-.5),this.maxEmitBox=new a.e(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=L.a.RandomRange(this.direction1.x,this.direction2.x),o=L.a.RandomRange(this.direction1.y,this.direction2.y),s=L.a.RandomRange(this.direction1.z,this.direction2.z);if(n)return t.x=r,t.y=o,void(t.z=s);a.e.TransformNormalFromFloatsToRef(r,o,s,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=L.a.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),o=L.a.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),s=L.a.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);if(n)return t.x=r,t.y=o,void(t.z=s);a.e.TransformCoordinatesFromFloatsToRef(r,o,s,e,t)},e.prototype.clone=function(){var t=new e;return O.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){a.e.FromArrayToRef(e.direction1,0,this.direction1),a.e.FromArrayToRef(e.direction2,0,this.direction2),a.e.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),a.e.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),Ll=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!1,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,n){n?a.c.Vector3[0].copyFrom(i._localPosition).normalize():i.position.subtractToRef(e.getTranslation(),a.c.Vector3[0]).normalize();var r=L.a.RandomRange(0,this.directionRandomizer),o=L.a.RandomRange(0,this.directionRandomizer),s=L.a.RandomRange(0,this.directionRandomizer);t.x=a.c.Vector3[0].x+r,t.y=a.c.Vector3[0].y+o,t.z=a.c.Vector3[0].z+s,t.normalize()},e.prototype.startPositionFunction=function(e,t,i,n){var r,o=L.a.RandomRange(0,2*Math.PI);r=this.emitFromSpawnPointOnly?1e-4:1-(r=L.a.RandomRange(0,this.heightRange))*r;var s=this._radius-L.a.RandomRange(0,this._radius*this.radiusRange),c=(s*=r)*Math.sin(o),l=s*Math.cos(o),u=r*this._height;if(n)return t.x=c,t.y=u,void(t.z=l);a.e.TransformCoordinatesFromFloatsToRef(c,u,l,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return O.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.radiusRange=this.radiusRange,e.heightRange=this.heightRange,e.emitFromSpawnPointOnly=this.emitFromSpawnPointOnly,e},e.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer,this.radiusRange=void 0!==e.radiusRange?e.radiusRange:1,this.heightRange=void 0!==e.radiusRange?e.heightRange:1,this.emitFromSpawnPointOnly=void 0!==e.emitFromSpawnPointOnly&&e.emitFromSpawnPointOnly},e}(),wl=function(){function e(e,t,i,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===n&&(n=0),this.radius=e,this.height=t,this.radiusRange=i,this.directionRandomizer=n}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=i.position.subtract(e.getTranslation()).normalize(),o=L.a.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),s=Math.atan2(r.x,r.z);s+=L.a.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,r.y=o,r.x=Math.sin(s),r.z=Math.cos(s),r.normalize(),n?t.copyFrom(r):a.e.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=L.a.RandomRange(-this.height/2,this.height/2),o=L.a.RandomRange(0,2*Math.PI),s=L.a.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),c=Math.sqrt(s)*this.radius,l=c*Math.cos(o),u=c*Math.sin(o);n?t.copyFromFloats(l,r,u):a.e.TransformCoordinatesFromFloatsToRef(l,r,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return O.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}(),Fl=function(e){function t(t,i,n,r,o){void 0===t&&(t=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===r&&(r=new a.e(0,1,0)),void 0===o&&(o=new a.e(0,1,0));var s=e.call(this,t,i,n)||this;return s.direction1=r,s.direction2=o,s}return Object(h.d)(t,e),t.prototype.startDirectionFunction=function(e,t,i){var n=L.a.RandomRange(this.direction1.x,this.direction2.x),r=L.a.RandomRange(this.direction1.y,this.direction2.y),o=L.a.RandomRange(this.direction1.z,this.direction2.z);a.e.TransformNormalFromFloatsToRef(n,r,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return O.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}(wl),Bl=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,n){var r=i.position.subtract(e.getTranslation()).normalize(),o=L.a.RandomRange(0,this.directionRandomizer),s=L.a.RandomRange(0,this.directionRandomizer),c=L.a.RandomRange(0,this.directionRandomizer);r.x+=o,r.y+=s,r.z+=c,r.normalize(),n?t.copyFrom(r):a.e.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=this.radius-L.a.RandomRange(0,this.radius*this.radiusRange),o=L.a.RandomRange(0,1),s=L.a.RandomRange(0,2*Math.PI),c=Math.acos(2*o-1),l=r*Math.cos(s)*Math.sin(c),u=r*Math.cos(c),h=r*Math.sin(s)*Math.sin(c);n?t.copyFromFloats(l,Math.abs(u),h):a.e.TransformCoordinatesFromFloatsToRef(l,Math.abs(u),h,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return O.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}(),Ul=function(){function e(){this.direction1=new a.e(0,1,0),this.direction2=new a.e(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=L.a.RandomRange(this.direction1.x,this.direction2.x),o=L.a.RandomRange(this.direction1.y,this.direction2.y),s=L.a.RandomRange(this.direction1.z,this.direction2.z);n?t.copyFromFloats(r,o,s):a.e.TransformNormalFromFloatsToRef(r,o,s,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){n?t.copyFromFloats(0,0,0):a.e.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return O.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){a.e.FromArrayToRef(e.direction1,0,this.direction1),a.e.FromArrayToRef(e.direction2,0,this.direction2)},e}(),Vl=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,n){var r=i.position.subtract(e.getTranslation()).normalize(),o=L.a.RandomRange(0,this.directionRandomizer),s=L.a.RandomRange(0,this.directionRandomizer),c=L.a.RandomRange(0,this.directionRandomizer);r.x+=o,r.y+=s,r.z+=c,r.normalize(),n?t.copyFrom(r):a.e.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=this.radius-L.a.RandomRange(0,this.radius*this.radiusRange),o=L.a.RandomRange(0,1),s=L.a.RandomRange(0,2*Math.PI),c=Math.acos(2*o-1),l=r*Math.cos(s)*Math.sin(c),u=r*Math.cos(c),h=r*Math.sin(s)*Math.sin(c);n?t.copyFromFloats(l,u,h):a.e.TransformCoordinatesFromFloatsToRef(l,u,h,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return O.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}(),kl=function(e){function t(t,i,n){void 0===t&&(t=1),void 0===i&&(i=new a.e(0,1,0)),void 0===n&&(n=new a.e(0,1,0));var r=e.call(this,t)||this;return r.direction1=i,r.direction2=n,r}return Object(h.d)(t,e),t.prototype.startDirectionFunction=function(e,t,i){var n=L.a.RandomRange(this.direction1.x,this.direction2.x),r=L.a.RandomRange(this.direction1.y,this.direction2.y),o=L.a.RandomRange(this.direction1.z,this.direction2.z);a.e.TransformNormalFromFloatsToRef(n,r,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return O.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}(Vl),zl=function(){function e(){this.particlePositionGenerator=function(){},this.particleDestinationGenerator=function(){}}return e.prototype.startDirectionFunction=function(e,t,i,n){var r=a.c.Vector3[0];if(this.particleDestinationGenerator){this.particleDestinationGenerator(-1,i,r);var o=a.c.Vector3[1];r.subtractToRef(i.position,o),o.scaleToRef(1/i.lifeTime,r)}else r.set(0,0,0);n?t.copyFrom(r):a.e.TransformNormalToRef(r,e,t)},e.prototype.startPositionFunction=function(e,t,i,n){var r=a.c.Vector3[0];this.particlePositionGenerator?this.particlePositionGenerator(-1,i,r):r.set(0,0,0),n?t.copyFrom(r):a.e.TransformCoordinatesToRef(r,e,t)},e.prototype.clone=function(){var t=new e;return O.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){},e.prototype.getEffectDefines=function(){return"#define CUSTOMEMITTER"},e.prototype.getClassName=function(){return"CustomParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e},e.prototype.parse=function(e){},e}(),Gl=function(){function e(e){void 0===e&&(e=null),this._indices=null,this._positions=null,this._normals=null,this._storedNormal=a.e.Zero(),this._mesh=null,this.direction1=new a.e(0,1,0),this.direction2=new a.e(0,1,0),this.useMeshNormalsForDirection=!0,this.mesh=e}return Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this._mesh!==e&&(this._mesh=e,e?(this._indices=e.getIndices(),this._positions=e.getVerticesData(Qi.b.PositionKind),this._normals=e.getVerticesData(Qi.b.NormalKind)):(this._indices=null,this._positions=null,this._normals=null))},enumerable:!1,configurable:!0}),e.prototype.startDirectionFunction=function(e,t,i,n){if(this.useMeshNormalsForDirection&&this._normals)a.e.TransformNormalToRef(this._storedNormal,e,t);else{var r=L.a.RandomRange(this.direction1.x,this.direction2.x),o=L.a.RandomRange(this.direction1.y,this.direction2.y),s=L.a.RandomRange(this.direction1.z,this.direction2.z);n?t.copyFromFloats(r,o,s):a.e.TransformNormalFromFloatsToRef(r,o,s,e,t)}},e.prototype.startPositionFunction=function(e,t,i,n){if(this._indices&&this._positions){var r=3*Math.random()*(this._indices.length/3)|0,o=Math.random(),s=Math.random()*(1-o),c=1-o-s,l=this._indices[r],u=this._indices[r+1],h=this._indices[r+2],d=a.c.Vector3[0],f=a.c.Vector3[1],p=a.c.Vector3[2],_=a.c.Vector3[3];a.e.FromArrayToRef(this._positions,3*l,d),a.e.FromArrayToRef(this._positions,3*u,f),a.e.FromArrayToRef(this._positions,3*h,p),_.x=o*d.x+s*f.x+c*p.x,_.y=o*d.y+s*f.y+c*p.y,_.z=o*d.z+s*f.z+c*p.z,n?t.copyFromFloats(_.x,_.y,_.z):a.e.TransformCoordinatesFromFloatsToRef(_.x,_.y,_.z,e,t),this.useMeshNormalsForDirection&&this._normals&&(a.e.FromArrayToRef(this._normals,3*l,d),a.e.FromArrayToRef(this._normals,3*u,f),a.e.FromArrayToRef(this._normals,3*h,p),this._storedNormal.x=o*d.x+s*f.x+c*p.x,this._storedNormal.y=o*d.y+s*f.y+c*p.y,this._storedNormal.z=o*d.z+s*f.z+c*p.z)}},e.prototype.clone=function(){var t=new e(this.mesh);return O.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""},e.prototype.getClassName=function(){return"MeshParticleEmitter"},e.prototype.serialize=function(){var e,t={};return t.type=this.getClassName(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.meshId=null===(e=this.mesh)||void 0===e?void 0:e.id,t.useMeshNormalsForDirection=this.useMeshNormalsForDirection,t},e.prototype.parse=function(e,t){a.e.FromArrayToRef(e.direction1,0,this.direction1),a.e.FromArrayToRef(e.direction2,0,this.direction2),e.meshId&&t&&(this.mesh=t.getLastMeshByID(e.meshId)),this.useMeshNormalsForDirection=e.useMeshNormalsForDirection},e}(),jl=function(){function e(t){this.animations=[],this.renderingGroupId=0,this.emitter=a.e.Zero(),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 a.e(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 a.d(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new a.e(0,0,0),this.gravity=a.e.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 s.b(1,1,1,1),this.color2=new s.b(1,1,1,1),this.colorDead=new s.b(0,0,0,1),this.textureMask=new s.b(1,1,1,1),this._isSubEmitter=!1,this.billboardMode=g.a.PARTICLES_BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new ji.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!1,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:a.e.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:a.e.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:a.e.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:a.e.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!1,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(!e&&this._scene?this._imageProcessingConfiguration=this._scene.imageProcessingConfiguration:this._imageProcessingConfiguration=e)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var n=0,r=0,o=t;r<o.length;r++){if(o[r].gradient===e){t.splice(n,1);break}n++}return i&&i.dispose(),this},e.prototype.createPointEmitter=function(e,t){var i=new Ul;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 Bl(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 Vl(e,t);return this.particleEmitterType=i,i},e.prototype.createDirectedSphereEmitter=function(e,t,i){void 0===e&&(e=1),void 0===t&&(t=new a.e(0,1,0)),void 0===i&&(i=new a.e(0,1,0));var n=new kl(e,t,i);return this.particleEmitterType=n,n},e.prototype.createCylinderEmitter=function(e,t,i,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===n&&(n=0);var r=new wl(e,t,i,n);return this.particleEmitterType=r,r},e.prototype.createDirectedCylinderEmitter=function(e,t,i,n,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===n&&(n=new a.e(0,1,0)),void 0===r&&(r=new a.e(0,1,0));var o=new Fl(e,t,i,n,r);return this.particleEmitterType=o,o},e.prototype.createConeEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=Math.PI/4);var i=new Ll(e,t);return this.particleEmitterType=i,i},e.prototype.createBoxEmitter=function(e,t,i,n){var r=new Nl;return this.particleEmitterType=r,this.direction1=e,this.direction2=t,this.minEmitBox=i,this.maxEmitBox=n,r},e.BLENDMODE_ONEONE=0,e.BLENDMODE_STANDARD=1,e.BLENDMODE_ADD=2,e.BLENDMODE_MULTIPLY=3,e.BLENDMODE_MULTIPLYADD=4,e}(),Wl=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("rgba",tl.Color4,!0),i.registerInput("rgb ",tl.Color3,!0),i.registerOutput("rgb",tl.Color3),i.registerOutput("r",tl.Float),i.registerOutput("g",tl.Float),i.registerOutput("b",tl.Float),i.registerOutput("a",tl.Float),i.inputsAreExclusive=!0,i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ColorSplitterBlock"},Object.defineProperty(t.prototype,"rgba",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){return"rgb "===e?"rgbIn":e},t.prototype._outputRename=function(e){return"rgb"===e?"rgbOut":e},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.rgba.isConnected?this.rgba:this.rgbIn;if(i.isConnected){var n=this._outputs[0],r=this._outputs[1],o=this._outputs[2],a=this._outputs[3],s=this._outputs[4];return n.hasEndpoints&&(t.compilationString+=this._declareOutput(n,t)+" = "+i.associatedVariableName+".rgb;\r\n"),r.hasEndpoints&&(t.compilationString+=this._declareOutput(r,t)+" = "+i.associatedVariableName+".r;\r\n"),o.hasEndpoints&&(t.compilationString+=this._declareOutput(o,t)+" = "+i.associatedVariableName+".g;\r\n"),a.hasEndpoints&&(t.compilationString+=this._declareOutput(a,t)+" = "+i.associatedVariableName+".b;\r\n"),s.hasEndpoints&&(t.compilationString+=this._declareOutput(s,t)+" = "+i.associatedVariableName+".a;\r\n"),this}},t}(fl);c.a.RegisteredTypes["BABYLON.ColorSplitterBlock"]=Wl;var Hl,Xl=i(104);!function(e){e[e.Cos=0]="Cos",e[e.Sin=1]="Sin",e[e.Abs=2]="Abs",e[e.Exp=3]="Exp",e[e.Exp2=4]="Exp2",e[e.Round=5]="Round",e[e.Floor=6]="Floor",e[e.Ceiling=7]="Ceiling",e[e.Sqrt=8]="Sqrt",e[e.Log=9]="Log",e[e.Tan=10]="Tan",e[e.ArcTan=11]="ArcTan",e[e.ArcCos=12]="ArcCos",e[e.ArcSin=13]="ArcSin",e[e.Fract=14]="Fract",e[e.Sign=15]="Sign",e[e.Radians=16]="Radians",e[e.Degrees=17]="Degrees"}(Hl||(Hl={}));var Yl=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.operation=Hl.Cos,i.registerInput("input",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"TrigonometryBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n="";switch(this.operation){case Hl.Cos:n="cos";break;case Hl.Sin:n="sin";break;case Hl.Abs:n="abs";break;case Hl.Exp:n="exp";break;case Hl.Exp2:n="exp2";break;case Hl.Round:n="round";break;case Hl.Floor:n="floor";break;case Hl.Ceiling:n="ceil";break;case Hl.Sqrt:n="sqrt";break;case Hl.Log:n="log";break;case Hl.Tan:n="tan";break;case Hl.ArcTan:n="atan";break;case Hl.ArcCos:n="acos";break;case Hl.ArcSin:n="asin";break;case Hl.Fract:n="fract";break;case Hl.Sign:n="sign";break;case Hl.Radians:n="radians";break;case Hl.Degrees:n="degrees"}return t.compilationString+=this._declareOutput(i,t)+" = "+n+"("+this.input.associatedVariableName+");\r\n",this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.operation=this.operation,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.operation=t.operation},t.prototype._dumpPropertiesCode=function(){return this._codeVariableName+".operation = BABYLON.TrigonometryBlockOperations."+Hl[this.operation]+";\r\n"},t}(fl);c.a.RegisteredTypes["BABYLON.TrigonometryBlock"]=Yl;var Kl={effect:null,subMesh:null},Ql=function(e){function t(){var t=e.call(this)||this;return t.NORMAL=!1,t.TANGENT=!1,t.UV1=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.BONETEXTURE=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_UV=!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.EXPOSURE=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.BUMPDIRECTUV=0,t.rebuild(),t}return Object(h.d)(t,e),t.prototype.setValue=function(e,t,i){void 0===i&&(i=!1),void 0===this[e]&&this._keys.push(e),i&&this[e]!==t&&this.markAsUnprocessed(),this[e]=t},t}(oo.a),ql=function(e){function t(i,n,r){void 0===r&&(r={});var s=e.call(this,i,n||Se.a.LastCreatedScene)||this;return s._buildId=t._BuildIdGenerator++,s._buildWasSuccessful=!1,s._cachedWorldViewMatrix=new a.a,s._cachedWorldViewProjectionMatrix=new a.a,s._optimizers=new Array,s._animationFrame=-1,s.BJSNODEMATERIALEDITOR=s._getGlobalNodeMaterialEditor(),s.editorData=null,s.ignoreAlpha=!1,s.maxSimultaneousLights=4,s.onBuildObservable=new o.c,s._vertexOutputNodes=new Array,s._fragmentOutputNodes=new Array,s.attachedBlocks=new Array,s._mode=rl.Material,s._options=Object(h.a)({emitComments:!1},r),s._attachImageProcessingConfiguration(null),s}return Object(h.d)(t,e),t.prototype._getGlobalNodeMaterialEditor=function(){return"undefined"!=typeof NODEEDITOR?NODEEDITOR:"undefined"!=typeof BABYLON&&void 0!==BABYLON.NodeEditor?BABYLON:void 0},Object.defineProperty(t.prototype,"options",{get:function(){return this._options},set:function(e){this._options=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"mode",{get:function(){return this._mode},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"NodeMaterial"},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()}))))},t.prototype.getBlockByName=function(e){for(var t=null,i=0,n=this.attachedBlocks;i<n.length;i++){var r=n[i];if(r.name===e){if(t)return Ce.b.Warn("More than one block was found with the name `"+e+"`"),t;t=r}}return t},t.prototype.getBlockByPredicate=function(e){for(var t=0,i=this.attachedBlocks;t<i.length;t++){var n=i[t];if(e(n))return n}return null},t.prototype.getInputBlockByPredicate=function(e){for(var t=0,i=this.attachedBlocks;t<i.length;t++){var n=i[t];if(n.isInput&&e(n))return n}return null},t.prototype.getInputBlocks=function(){for(var e=[],t=0,i=this.attachedBlocks;t<i.length;t++){var n=i[t];n.isInput&&e.push(n)}return e},t.prototype.registerOptimizer=function(e){if(!(this._optimizers.indexOf(e)>-1))return this._optimizers.push(e),this},t.prototype.unregisterOptimizer=function(e){var t=this._optimizers.indexOf(e);if(-1!==t)return this._optimizers.splice(t,1),this},t.prototype.addOutputNode=function(e){if(null===e.target)throw"This node is not meant to be an output node. You may want to explicitly set its target value.";return 0!=(e.target&el.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&el.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&el.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&el.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=el.Vertex,this._vertexOutputNodes.push(e),this},t.prototype._removeVertexOutputNode=function(e){var t=this._vertexOutputNodes.indexOf(e);if(-1!==t)return this._vertexOutputNodes.splice(t,1),this},t.prototype._addFragmentOutputNode=function(e){if(-1===this._fragmentOutputNodes.indexOf(e))return e.target=el.Fragment,this._fragmentOutputNodes.push(e),this},t.prototype._removeFragmentOutputNode=function(e){var t=this._fragmentOutputNodes.indexOf(e);if(-1!==t)return this._fragmentOutputNodes.splice(t,1),this},t.prototype.needAlphaBlending=function(){return!this.ignoreAlpha&&(this.alpha<1||this._sharedData&&this._sharedData.hints.needAlphaBlending)},t.prototype.needAlphaTesting=function(){return this._sharedData&&this._sharedData.hints.needAlphaTesting},t.prototype._initializeBlock=function(e,t,i){if(e.initialize(t),e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var n=e.getClassName(),r=0,o=this.attachedBlocks;r<o.length;r++){if(o[r].getClassName()===n)throw"Cannot have multiple blocks of type "+n+" in the same NodeMaterial"}this.attachedBlocks.push(e)}for(var a=0,s=e.inputs;a<s.length;a++){var c=s[a];c.associatedVariableName="";var l=c.connectedPoint;if(l){var u=l.ownerBlock;u!==e&&((u.target===el.VertexAndFragment||t.target===el.Fragment&&u.target===el.Vertex&&u._preparationId!==this._buildId)&&i.push(u),this._initializeBlock(u,t,i))}}for(var h=0,d=e.outputs;h<d.length;h++){d[h].associatedVariableName=""}},t.prototype._resetDualBlocks=function(e,t){e.target===el.VertexAndFragment&&(e.buildId=t);for(var i=0,n=e.inputs;i<n.length;i++){var r=n[i].connectedPoint;if(r){var o=r.ownerBlock;o!==e&&this._resetDualBlocks(o,t)}}},t.prototype.removeBlock=function(e){var t=this.attachedBlocks.indexOf(e);t>-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e){void 0===e&&(e=!1),this._buildWasSuccessful=!1;var i=this.getScene().getEngine(),n=this._mode===rl.Particle;if(0===this._vertexOutputNodes.length&&!n)throw"You must define at least one vertexOutputNode";if(0===this._fragmentOutputNodes.length)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new pl,this._vertexCompilationState.supportUniformBuffers=i.supportsUniformBuffers,this._vertexCompilationState.target=el.Vertex,this._fragmentCompilationState=new pl,this._fragmentCompilationState.supportUniformBuffers=i.supportsUniformBuffers,this._fragmentCompilationState.target=el.Fragment,this._sharedData=new _l,this._vertexCompilationState.sharedData=this._sharedData,this._fragmentCompilationState.sharedData=this._sharedData,this._sharedData.buildId=this._buildId,this._sharedData.emitComments=this._options.emitComments,this._sharedData.verbose=e,this._sharedData.scene=this.getScene(),this._sharedData.allowEmptyVertexProgram=n;for(var r=[],o=[],a=0,s=this._vertexOutputNodes;a<s.length;a++){var c=s[a];r.push(c),this._initializeBlock(c,this._vertexCompilationState,o)}for(var l=0,u=this._fragmentOutputNodes;l<u.length;l++){var h=u[l];o.push(h),this._initializeBlock(h,this._fragmentCompilationState,r)}this.optimize();for(var d=0,f=r;d<f.length;d++){(c=f[d]).build(this._vertexCompilationState,r)}this._fragmentCompilationState.uniforms=this._vertexCompilationState.uniforms.slice(0),this._fragmentCompilationState._uniformDeclaration=this._vertexCompilationState._uniformDeclaration,this._fragmentCompilationState._constantDeclaration=this._vertexCompilationState._constantDeclaration,this._fragmentCompilationState._vertexState=this._vertexCompilationState;for(var p=0,_=o;p<_.length;p++){h=_[p];this._resetDualBlocks(h,this._buildId-1)}for(var m=0,g=o;m<g.length;m++){(h=g[m]).build(this._fragmentCompilationState,o)}this._vertexCompilationState.finalize(this._vertexCompilationState),this._fragmentCompilationState.finalize(this._fragmentCompilationState),this._buildId=t._BuildIdGenerator++,this._sharedData.emitErrors(),e&&(console.log("Vertex shader:"),console.log(this._vertexCompilationState.compilationString),console.log("Fragment shader:"),console.log(this._fragmentCompilationState.compilationString)),this._buildWasSuccessful=!0,this.onBuildObservable.notifyObservers(this);for(var v=0,b=this.getScene().meshes;v<b.length;v++){var y=b[v];if(y.subMeshes)for(var T=0,E=y.subMeshes;T<E.length;T++){var S=E[T];if(S.getMaterial()===this&&S._materialDefines){var A=S._materialDefines;A.markAllAsDirty(),A.reset()}}}},t.prototype.optimize=function(){for(var e=0,t=this._optimizers;e<t.length;e++){t[e].optimize(this._vertexOutputNodes,this._fragmentOutputNodes)}},t.prototype._prepareDefinesForAttributes=function(e,t){var i=t.NORMAL,n=t.TANGENT,r=t.UV1;t.NORMAL=e.isVerticesDataPresent(Qi.b.NormalKind),t.TANGENT=e.isVerticesDataPresent(Qi.b.TangentKind),t.UV1=e.isVerticesDataPresent(Qi.b.UVKind),i===t.NORMAL&&n===t.TANGENT&&r===t.UV1||t.markAsAttributesDirty()},t.prototype.createPostProcess=function(e,t,i,n,r,o,a){return void 0===t&&(t=1),void 0===i&&(i=g.a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=g.a.TEXTUREFORMAT_RGBA),this.mode!==rl.PostProcess?(console.log("Incompatible material mode"),null):this._createEffectForPostProcess(null,e,t,i,n,r,o,a)},t.prototype.createEffectForPostProcess=function(e){this._createEffectForPostProcess(e)},t.prototype._createEffectForPostProcess=function(e,t,i,n,r,o,a,s){var c=this;void 0===i&&(i=1),void 0===n&&(n=g.a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===a&&(a=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=g.a.TEXTUREFORMAT_RGBA);var l=this.name+this._buildId,u=new Ql,h=new Ge.a(l+"PostProcess",this.getScene()),d=this._buildId;return this._processDefines(h,u),ai.a.RegisterShader(l,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString),e?e.updateEffect(u.toString(),this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,{maxSimultaneousLights:this.maxSimultaneousLights},void 0,void 0,l,l):e=new li(this.name+"PostProcess",l,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,i,t,n,r,o,u.toString(),a,l,{maxSimultaneousLights:this.maxSimultaneousLights},!1,s),e.nodeMaterialSource=this,e.onApplyObservable.add((function(t){d!==c._buildId&&(delete ai.a.ShadersStore[l+"VertexShader"],delete ai.a.ShadersStore[l+"PixelShader"],l=c.name+c._buildId,u.markAsUnprocessed(),d=c._buildId),c._processDefines(h,u)&&(ai.a.RegisterShader(l,c._fragmentCompilationState._builtCompilationString,c._vertexCompilationState._builtCompilationString),Xl.a.SetImmediate((function(){return e.updateEffect(u.toString(),c._fragmentCompilationState.uniforms,c._fragmentCompilationState.samplers,{maxSimultaneousLights:c.maxSimultaneousLights},void 0,void 0,l,l)}))),c._checkInternals(t)})),e},t.prototype.createProceduralTexture=function(e,t){var i=this;if(this.mode!==rl.ProceduralTexture)return console.log("Incompatible material mode"),null;var n=this.name+this._buildId,r=new qc(n,e,null,t),o=new Ge.a(n+"Procedural",this.getScene());o.reservedDataStore={hidden:!0};var a=new Ql,s=this._processDefines(o,a);ai.a.RegisterShader(n,this._fragmentCompilationState._builtCompilationString,this._vertexCompilationState._builtCompilationString);var c=this.getScene().getEngine().createEffect({vertexElement:n,fragmentElement:n},[Qi.b.PositionKind],this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,a.toString(),null==s?void 0:s.fallbacks,void 0);r.nodeMaterialSource=this,r._effect=c;var l=this._buildId;return r.onBeforeGenerationObservable.add((function(){l!==i._buildId&&(delete ai.a.ShadersStore[n+"VertexShader"],delete ai.a.ShadersStore[n+"PixelShader"],n=i.name+i._buildId,a.markAsUnprocessed(),l=i._buildId);var e=i._processDefines(o,a);e&&(ai.a.RegisterShader(n,i._fragmentCompilationState._builtCompilationString,i._vertexCompilationState._builtCompilationString),Xl.a.SetImmediate((function(){c=i.getScene().getEngine().createEffect({vertexElement:n,fragmentElement:n},[Qi.b.PositionKind],i._fragmentCompilationState.uniforms,i._fragmentCompilationState.samplers,a.toString(),null==e?void 0:e.fallbacks,void 0),r._effect=c}))),i._checkInternals(c)})),r},t.prototype._createEffectForParticles=function(e,t,i,n,r,o,a,s){var c=this;void 0===s&&(s="");var l=this.name+this._buildId+"_"+t;o||(o=new Ql),a||(a=this.getScene().getMeshByName(this.name+"Particle"))||((a=new Ge.a(this.name+"Particle",this.getScene())).reservedDataStore={hidden:!0});var u=this._buildId,h=[],d=s;if(!r){var f=this._processDefines(a,o);ai.a.RegisterShader(l,this._fragmentCompilationState._builtCompilationString),e.fillDefines(h,t),d=h.join("\n"),r=this.getScene().getEngine().createEffectForParticles(l,this._fragmentCompilationState.uniforms,this._fragmentCompilationState.samplers,o.toString()+"\n"+d,null==f?void 0:f.fallbacks,i,n,e),e.setCustomEffect(r,t)}r.onBindObservable.add((function(r){u!==c._buildId&&(delete ai.a.ShadersStore[l+"PixelShader"],l=c.name+c._buildId+"_"+t,o.markAsUnprocessed(),u=c._buildId),h.length=0,e.fillDefines(h,t);var s=h.join("\n");s!==d&&(o.markAsUnprocessed(),d=s);var f=c._processDefines(a,o);if(f)return ai.a.RegisterShader(l,c._fragmentCompilationState._builtCompilationString),r=c.getScene().getEngine().createEffectForParticles(l,c._fragmentCompilationState.uniforms,c._fragmentCompilationState.samplers,o.toString()+"\n"+d,null==f?void 0:f.fallbacks,i,n,e),e.setCustomEffect(r,t),void c._createEffectForParticles(e,t,i,n,r,o,a,d);c._checkInternals(r)}))},t.prototype._checkInternals=function(e){if(this._sharedData.animatedInputs){var t=this.getScene(),i=t.getFrameId();if(this._animationFrame!==i){for(var n=0,r=this._sharedData.animatedInputs;n<r.length;n++){r[n].animate(t)}this._animationFrame=i}}for(var o=0,a=this._sharedData.bindableBlocks;o<a.length;o++){a[o].bind(e,this)}for(var s=0,c=this._sharedData.inputBlocks;s<c.length;s++){c[s]._transmit(e,this.getScene())}},t.prototype.createEffectForParticles=function(e,t,i){this.mode===rl.Particle?(this._createEffectForParticles(e,jl.BLENDMODE_ONEONE,t,i),this._createEffectForParticles(e,jl.BLENDMODE_MULTIPLY,t,i)):console.log("Incompatible material mode")},t.prototype._processDefines=function(e,t,i,n){var r=this;void 0===i&&(i=!1);var o=null;if(this._sharedData.blocksWithDefines.forEach((function(n){n.initializeDefines(e,r,t,i)})),this._sharedData.blocksWithDefines.forEach((function(o){o.prepareDefines(e,r,t,i,n)})),t.isDirty){var a=t._areLightsDisposed;t.markAsProcessed(),this._vertexCompilationState.compilationString=this._vertexCompilationState._builtCompilationString,this._fragmentCompilationState.compilationString=this._fragmentCompilationState._builtCompilationString,this._sharedData.repeatableContentBlocks.forEach((function(i){i.replaceRepeatableContent(r._vertexCompilationState,r._fragmentCompilationState,e,t)}));var s=[];this._sharedData.dynamicUniformBlocks.forEach((function(e){e.updateUniformsAndSamples(r._vertexCompilationState,r,t,s)}));var c=this._vertexCompilationState.uniforms;this._fragmentCompilationState.uniforms.forEach((function(e){-1===c.indexOf(e)&&c.push(e)}));var l=this._vertexCompilationState.samplers;this._fragmentCompilationState.samplers.forEach((function(e){-1===l.indexOf(e)&&l.push(e)}));var u=new po.a;this._sharedData.blocksWithFallbacks.forEach((function(t){t.provideFallbacks(e,u)})),o={lightDisposed:a,uniformBuffers:s,mergedUniforms:c,mergedSamplers:l,fallbacks:u}}return o},t.prototype.isReadyForSubMesh=function(e,t,i){var n=this;if(void 0===i&&(i=!1),!this._buildWasSuccessful)return!1;var r=this.getScene();if(this._sharedData.animatedInputs){var o=r.getFrameId();if(this._animationFrame!==o){for(var a=0,s=this._sharedData.animatedInputs;a<s.length;a++){s[a].animate(r)}this._animationFrame=o}}if(t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new Ql);var c=t._materialDefines;if(this._isReadyForSubMesh(t))return!0;var l=r.getEngine();if(this._prepareDefinesForAttributes(e,c),this._sharedData.blockingBlocks.some((function(t){return!t.isReady(e,n,c,i)})))return!1;var u=this._processDefines(e,c,i,t);if(u){var h=t.effect,d=c.toString(),f=l.createEffect({vertex:"nodeMaterial"+this._buildId,fragment:"nodeMaterial"+this._buildId,vertexSource:this._vertexCompilationState.compilationString,fragmentSource:this._fragmentCompilationState.compilationString},{attributes:this._vertexCompilationState.attributes,uniformsNames:u.mergedUniforms,uniformBuffersNames:u.uniformBuffers,samplers:u.mergedSamplers,defines:d,fallbacks:u.fallbacks,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this.maxSimultaneousLights,maxSimultaneousMorphTargets:c.NUM_MORPH_INFLUENCERS}},l);if(f)if(this._onEffectCreatedObservable&&(Kl.effect=f,Kl.subMesh=t,this._onEffectCreatedObservable.notifyObservers(Kl)),this.allowShaderHotSwapping&&h&&!f.isReady()){if(f=h,c.markAsUnprocessed(),u.lightDisposed)return c._areLightsDisposed=!0,!1}else r.resetCachedMaterial(),t.setEffect(f,c)}return!(!t.effect||!t.effect.isReady())&&(c._renderId=r.getRenderId(),t.effect._wasPreviouslyReady=!0,!0)},Object.defineProperty(t.prototype,"compiledShaders",{get:function(){return"// Vertex shader\r\n"+this._vertexCompilationState.compilationString+"\r\n\r\n// Fragment shader\r\n"+this._fragmentCompilationState.compilationString},enumerable:!1,configurable:!0}),t.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();if(this._activeEffect){var i=this._sharedData.hints;i.needWorldViewMatrix&&e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),i.needWorldViewProjectionMatrix&&e.multiplyToRef(t.getTransformMatrix(),this._cachedWorldViewProjectionMatrix);for(var n=0,r=this._sharedData.inputBlocks;n<r.length;n++){r[n]._transmitWorld(this._activeEffect,e,this._cachedWorldViewMatrix,this._cachedWorldViewProjectionMatrix)}}},t.prototype.bindForSubMesh=function(e,t,i){var n=this.getScene(),r=i.effect;if(r){if(this._activeEffect=r,this.bindOnlyWorldMatrix(e),this._mustRebind(n,r,t.visibility)){var o=this._sharedData;if(r&&n.getCachedEffect()!==r){for(var a=0,s=o.bindableBlocks;a<s.length;a++){s[a].bind(r,this,t,i)}for(var c=0,l=o.inputBlocks;c<l.length;c++){l[c]._transmit(r,n)}}}this._afterBind(t,this._activeEffect)}},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._sharedData&&t.push.apply(t,this._sharedData.textureBlocks.filter((function(e){return e.texture})).map((function(e){return e.texture}))),t},t.prototype.getTextureBlocks=function(){return this._sharedData?this._sharedData.textureBlocks:[]},t.prototype.hasTexture=function(t){if(e.prototype.hasTexture.call(this,t))return!0;if(!this._sharedData)return!1;for(var i=0,n=this._sharedData.textureBlocks;i<n.length;i++){if(n[i].texture===t)return!0}return!1},t.prototype.dispose=function(t,i,n){if(i)for(var r=0,o=this._sharedData.textureBlocks.filter((function(e){return e.texture})).map((function(e){return e.texture}));r<o.length;r++){o[r].dispose()}for(var a=0,s=this.attachedBlocks;a<s.length;a++){s[a].dispose()}this.onBuildObservable.clear(),e.prototype.dispose.call(this,t,i,n)},t.prototype._createNodeEditor=function(){this.BJSNODEMATERIALEDITOR=this.BJSNODEMATERIALEDITOR||this._getGlobalNodeMaterialEditor(),this.BJSNODEMATERIALEDITOR.NodeEditor.Show({nodeMaterial:this})},t.prototype.edit=function(e){var i=this;return new Promise((function(n,r){if(void 0===i.BJSNODEMATERIALEDITOR){var o=e&&e.editorURL?e.editorURL:t.EditorURL;Ce.b.LoadScript(o,(function(){i._createNodeEditor(),n()}))}else i._createNodeEditor(),n()}))},t.prototype.clear=function(){this._vertexOutputNodes=[],this._fragmentOutputNodes=[],this.attachedBlocks=[]},t.prototype.setToDefault=function(){this.clear(),this.editorData=null;var e=new Sl("Position");e.setAsAttribute("position");var t=new Sl("World");t.setAsSystemValue(BABYLON.NodeMaterialSystemValues.World);var i=new ml("WorldPos");e.connectTo(i),t.connectTo(i);var n=new Sl("ViewProjection");n.setAsSystemValue(BABYLON.NodeMaterialSystemValues.ViewProjection);var r=new ml("WorldPos * ViewProjectionTransform");i.connectTo(r),n.connectTo(r);var o=new gl("VertexOutput");r.connectTo(o);var a=new Sl("color");a.value=new s.b(.8,.8,.8,1);var c=new bl("FragmentOutput");a.connectTo(c),this.addOutputNode(o),this.addOutputNode(c),this._mode=rl.Material},t.prototype.setToDefaultPostProcess=function(){this.clear(),this.editorData=null;var e=new Sl("Position");e.setAsAttribute("position2d");var t=new Sl("Constant1");t.isConstant=!0,t.value=1;var i=new Ol("Position3D");e.connectTo(i),t.connectTo(i,{input:"w"});var n=new gl("VertexOutput");i.connectTo(n);var r=new Sl("Scale");r.visibleInInspector=!0,r.value=new a.d(1,1);var o=new Il("uv0");e.connectTo(o);var s=new Dl("UV scale");o.connectTo(s),r.connectTo(s);var c=new Al("CurrentScreen");s.connectTo(c),c.texture=new Ke.a("https://assets.babylonjs.com/nme/currentScreenPostProcess.png",this.getScene());var l=new bl("FragmentOutput");c.connectTo(l,{output:"rgba"}),this.addOutputNode(n),this.addOutputNode(l),this._mode=rl.PostProcess},t.prototype.setToDefaultProceduralTexture=function(){this.clear(),this.editorData=null;var e=new Sl("Position");e.setAsAttribute("position2d");var t=new Sl("Constant1");t.isConstant=!0,t.value=1;var i=new Ol("Position3D");e.connectTo(i),t.connectTo(i,{input:"w"});var n=new gl("VertexOutput");i.connectTo(n);var r=new Sl("Time");r.value=0,r.min=0,r.max=0,r.isBoolean=!1,r.matrixMode=0,r.animationType=vl.Time,r.isConstant=!1;var o=new Sl("Color3");o.value=new s.a(1,1,1),o.isConstant=!1;var a=new bl("FragmentOutput"),c=new Ol("VectorMerger");c.visibleInInspector=!1;var l=new Yl("Cos");l.operation=Hl.Cos,e.connectTo(c),r.output.connectTo(l.input),l.output.connectTo(c.z),c.xyzOut.connectTo(a.rgb),this.addOutputNode(n),this.addOutputNode(a),this._mode=rl.ProceduralTexture},t.prototype.setToDefaultParticle=function(){this.clear(),this.editorData=null;var e=new Sl("uv");e.setAsAttribute("particle_uv");var t=new Pl("ParticleTexture");e.connectTo(t);var i=new Sl("Color");i.setAsAttribute("particle_color");var n=new Dl("Texture * Color");t.connectTo(n),i.connectTo(n);var r=new Cl("ParticleRampGradient");n.connectTo(r);var o=new Wl("ColorSplitter");i.connectTo(o);var a=new Rl("ParticleBlendMultiply");r.connectTo(a),t.connectTo(a,{output:"a"}),o.connectTo(a,{output:"a"});var s=new bl("FragmentOutput");a.connectTo(s),this.addOutputNode(s),this._mode=rl.Particle},t.prototype.loadAsync=function(e){var t=this;return this.getScene()._loadFileAsync(e).then((function(e){var i=JSON.parse(e);t.loadFromSerialization(i,"")}))},t.prototype._gatherBlocks=function(e,t){if(-1===t.indexOf(e)){t.push(e);for(var i=0,n=e.inputs;i<n.length;i++){var r=n[i].connectedPoint;if(r){var o=r.ownerBlock;o!==e&&this._gatherBlocks(o,t)}}}},t.prototype.generateCode=function(){for(var e=[],t=[],i=[],n=0,r=this._vertexOutputNodes;n<r.length;n++){var o=r[n];this._gatherBlocks(o,t)}for(var a=[],s=0,c=this._fragmentOutputNodes;s<c.length;s++){o=c[s];this._gatherBlocks(o,a)}for(var l='var nodeMaterial = new BABYLON.NodeMaterial("'+(this.name||"node material")+'");\r\n',u=0,h=t;u<h.length;u++){(E=h[u]).isInput&&-1===e.indexOf(E)&&(l+=E._dumpCode(i,e))}for(var d=0,f=a;d<f.length;d++){(E=f[d]).isInput&&-1===e.indexOf(E)&&(l+=E._dumpCode(i,e))}e=[],l+="\r\n// Connections\r\n";for(var p=0,_=this._vertexOutputNodes;p<_.length;p++){l+=(E=_[p])._dumpCodeForOutputConnections(e)}for(var m=0,g=this._fragmentOutputNodes;m<g.length;m++){l+=(E=g[m])._dumpCodeForOutputConnections(e)}l+="\r\n// Output nodes\r\n";for(var v=0,b=this._vertexOutputNodes;v<b.length;v++){l+="nodeMaterial.addOutputNode("+(E=b[v])._codeVariableName+");\r\n"}for(var y=0,T=this._fragmentOutputNodes;y<T.length;y++){var E;l+="nodeMaterial.addOutputNode("+(E=T[y])._codeVariableName+");\r\n"}return l+="nodeMaterial.build();\r\n"},t.prototype.serialize=function(e){var t=e?{}:w.a.Serialize(this);t.editorData=JSON.parse(JSON.stringify(this.editorData));var i=[];if(e)i=e;else{t.customType="BABYLON.NodeMaterial",t.outputNodes=[];for(var n=0,r=this._vertexOutputNodes;n<r.length;n++){var o=r[n];this._gatherBlocks(o,i),t.outputNodes.push(o.uniqueId)}for(var a=0,s=this._fragmentOutputNodes;a<s.length;a++){o=s[a];this._gatherBlocks(o,i),-1===t.outputNodes.indexOf(o.uniqueId)&&t.outputNodes.push(o.uniqueId)}}t.blocks=[];for(var c=0,l=i;c<l.length;c++){var u=l[c];t.blocks.push(u.serialize())}if(!e)for(var h=0,d=this.attachedBlocks;h<d.length;h++){u=d[h];-1===i.indexOf(u)&&t.blocks.push(u.serialize())}return t},t.prototype._restoreConnections=function(e,t,i){for(var n=0,r=e.outputs;n<r.length;n++)for(var o=r[n],a=0,s=t.blocks;a<s.length;a++){var c=s[a],l=i[c.id];if(l)for(var u=0,h=c.inputs;u<h.length;u++){var d=h[u];if(i[d.targetBlockId]!==e||d.targetConnectionName!==o.name);else{var f=l.getInputByName(d.inputName);if(!f||f.isConnected)continue;o.connectTo(f,!0),this._restoreConnections(l,t,i)}}}},t.prototype.loadFromSerialization=function(e,t,i){var n;void 0===t&&(t=""),void 0===i&&(i=!1),i||this.clear();for(var r={},o=0,a=e.blocks;o<a.length;o++){var s=a[o],l=c.a.GetClass(s.customType);if(l)(h=new l)._deserialize(s,this.getScene(),t),r[s.id]=h,this.attachedBlocks.push(h)}for(var u=0;u<e.blocks.length;u++){var h;(h=r[e.blocks[u].id])&&(h.inputs.length&&!i||this._restoreConnections(h,e,r))}if(e.outputNodes)for(var d=0,f=e.outputNodes;d<f.length;d++){var p=f[d];this.addOutputNode(r[p])}if(e.locations||e.editorData&&e.editorData.locations){for(var _=e.locations||e.editorData.locations,m=0,g=_;m<g.length;m++){var v=g[m];r[v.blockId]&&(v.blockId=r[v.blockId].uniqueId)}i&&this.editorData&&this.editorData.locations&&_.concat(this.editorData.locations),e.locations?this.editorData={locations:_}:(this.editorData=e.editorData,this.editorData.locations=_);var b=[];for(var y in r)b[y]=r[y].uniqueId;this.editorData.map=b}this.comment=e.comment,i||(this._mode=null!==(n=e.mode)&&void 0!==n?n:rl.Material)},t.prototype.clone=function(e){var i=this,n=this.serialize(),r=w.a.Clone((function(){return new t(e,i.getScene(),i.options)}),this);return r.id=e,r.name=e,r.loadFromSerialization(n),r.build(),r},t.Parse=function(e,i,n){void 0===n&&(n="");var r=w.a.Parse((function(){return new t(e.name,i)}),e,i,n);return r.loadFromSerialization(e,n),r.build(),r},t.ParseFromFileAsync=function(e,i,n){var r=new t(e,n);return new Promise((function(e,t){return r.loadAsync(i).then((function(){r.build(),e(r)})).catch(t)}))},t.ParseFromSnippetAsync=function(e,i,n,r){var o=this;return void 0===n&&(n=""),"_BLANK"===e?Promise.resolve(this.CreateDefault("blank",i)):new Promise((function(a,s){var c=new V.a;c.addEventListener("readystatechange",(function(){if(4==c.readyState)if(200==c.status){var o=JSON.parse(JSON.parse(c.responseText).jsonPayload),l=JSON.parse(o.nodeMaterial);r||((r=w.a.Parse((function(){return new t(e,i)}),l,i,n)).uniqueId=i.getUniqueId()),r.loadFromSerialization(l),r.snippetId=e;try{r.build(),a(r)}catch(e){s(e)}}else s("Unable to load the snippet "+e)})),c.open("GET",o.SnippetUrl+"/"+e.replace(/#/g,"/")),c.send()}))},t.CreateDefault=function(e,i){var n=new t(e,i);return n.setToDefault(),n.build(),n},t._BuildIdGenerator=0,t.EditorURL="https://unpkg.com/babylonjs-node-editor@"+Se.a.Version+"/babylon.nodeEditor.js",t.SnippetUrl="https://snippet.babylonjs.com",t.IgnoreTexturesAtLoadTime=!1,Object(h.c)([Object(w.c)("mode")],t.prototype,"_mode",void 0),Object(h.c)([Object(w.c)("comment")],t.prototype,"comment",void 0),t}(ao.a);c.a.RegisteredTypes["BABYLON.NodeMaterial"]=ql;var Zl=function(e){function t(t){var i=e.call(this,t,el.Vertex)||this;return i.registerInput("matricesIndices",tl.Vector4),i.registerInput("matricesWeights",tl.Vector4),i.registerInput("matricesIndicesExtra",tl.Vector4,!0),i.registerInput("matricesWeightsExtra",tl.Vector4,!0),i.registerInput("world",tl.Matrix),i.registerOutput("output",tl.Matrix),i}return Object(h.d)(t,e),t.prototype.initialize=function(e){e._excludeVariableName("boneSampler"),e._excludeVariableName("boneTextureWidth"),e._excludeVariableName("mBones"),e._excludeVariableName("BonesPerMesh")},t.prototype.getClassName=function(){return"BonesBlock"},Object.defineProperty(t.prototype,"matricesIndices",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesWeights",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesIndicesExtra",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"matricesWeightsExtra",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.matricesIndices.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"matricesIndices"===e.name}));t||(t=new Sl("matricesIndices")).setAsAttribute("matricesIndices"),t.output.connectTo(this.matricesIndices)}if(!this.matricesWeights.isConnected){var i=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"matricesWeights"===e.name}));i||(i=new Sl("matricesWeights")).setAsAttribute("matricesWeights"),i.output.connectTo(this.matricesWeights)}if(!this.world.isConnected){var n=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.World}));n||(n=new Sl("world")).setAsSystemValue(nl.World),n.output.connectTo(this.world)}},t.prototype.provideFallbacks=function(e,t){e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton&&t.addCPUSkinningFallback(0,e)},t.prototype.bind=function(e,t,i){ro.a.BindBonesParameters(i,e)},t.prototype.prepareDefines=function(e,t,i){i._areAttributesDirty&&ro.a.PrepareDefinesForBones(e,i)},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),t.sharedData.blocksWithFallbacks.push(this),t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this),t.uniforms.push("boneTextureWidth"),t.uniforms.push("mBones"),t.samplers.push("boneSampler");var i="//"+this.name;t._emitFunctionFromInclude("bonesDeclaration",i,{removeAttributes:!0,removeUniforms:!1,removeVaryings:!0,removeIfDef:!1});var n=t._getFreeVariableName("influence");t.compilationString+=t._emitCodeFromInclude("bonesVertex",i,{replaceStrings:[{search:/finalWorld=finalWorld\*influence;/,replace:""},{search:/influence/gm,replace:n}]});var r=this._outputs[0],o=this.world;return t.compilationString+="#if NUM_BONE_INFLUENCERS>0\r\n",t.compilationString+=this._declareOutput(r,t)+" = "+o.associatedVariableName+" * "+n+";\r\n",t.compilationString+="#else\r\n",t.compilationString+=this._declareOutput(r,t)+" = "+o.associatedVariableName+";\r\n",t.compilationString+="#endif\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.BonesBlock"]=Zl;var Jl=function(e){function t(t){var i=e.call(this,t,el.Vertex)||this;return i.registerInput("world0",tl.Vector4),i.registerInput("world1",tl.Vector4),i.registerInput("world2",tl.Vector4),i.registerInput("world3",tl.Vector4),i.registerInput("world",tl.Matrix,!0),i.registerOutput("output",tl.Matrix),i.registerOutput("instanceID",tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"InstancesBlock"},Object.defineProperty(t.prototype,"world0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world2",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world3",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"instanceID",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.world0.connectedPoint){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"world0"===e.name}));t||(t=new Sl("world0")).setAsAttribute("world0"),t.output.connectTo(this.world0)}if(!this.world1.connectedPoint){var i=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"world1"===e.name}));i||(i=new Sl("world1")).setAsAttribute("world1"),i.output.connectTo(this.world1)}if(!this.world2.connectedPoint){var n=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"world2"===e.name}));n||(n=new Sl("world2")).setAsAttribute("world2"),n.output.connectTo(this.world2)}if(!this.world3.connectedPoint){var r=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"world3"===e.name}));r||(r=new Sl("world3")).setAsAttribute("world3"),r.output.connectTo(this.world3)}if(!this.world.connectedPoint){var o=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"world"===e.name}));o||(o=new Sl("world")).setAsSystemValue(nl.World),o.output.connectTo(this.world)}this.world.define="!INSTANCES || THIN_INSTANCES"},t.prototype.prepareDefines=function(e,t,i,n,r){void 0===n&&(n=!1);var o=!1;i.INSTANCES!==n&&(i.setValue("INSTANCES",n),o=!0),r&&i.THIN_INSTANCES!==!!(null==r?void 0:r.getRenderingMesh().hasThinInstances)&&(i.setValue("THIN_INSTANCES",!!(null==r?void 0:r.getRenderingMesh().hasThinInstances)),o=!0),o&&i.markAsUnprocessed()},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),t.sharedData.blocksWithDefines.push(this);var i=this._outputs[0],n=this._outputs[1],r=this.world0,o=this.world1,a=this.world2,s=this.world3;return t.compilationString+="#ifdef INSTANCES\r\n",t.compilationString+=this._declareOutput(i,t)+" = mat4("+r.associatedVariableName+", "+o.associatedVariableName+", "+a.associatedVariableName+", "+s.associatedVariableName+");\r\n",t.compilationString+="#ifdef THIN_INSTANCES\r\n",t.compilationString+=i.associatedVariableName+" = "+this.world.associatedVariableName+" * "+i.associatedVariableName+";\r\n",t.compilationString+="#endif\r\n",t.compilationString+=this._declareOutput(n,t)+" = float(gl_InstanceID);\r\n",t.compilationString+="#else\r\n",t.compilationString+=this._declareOutput(i,t)+" = "+this.world.associatedVariableName+";\r\n",t.compilationString+=this._declareOutput(n,t)+" = 0.0;\r\n",t.compilationString+="#endif\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.InstancesBlock"]=Jl;var $l=function(e){function t(t){var i=e.call(this,t,el.Vertex)||this;return i.registerInput("position",tl.Vector3),i.registerInput("normal",tl.Vector3),i.registerInput("tangent",tl.Vector3),i.registerInput("uv",tl.Vector2),i.registerOutput("positionOutput",tl.Vector3),i.registerOutput("normalOutput",tl.Vector3),i.registerOutput("tangentOutput",tl.Vector3),i.registerOutput("uvOutput",tl.Vector2),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"MorphTargetsBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangent",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"positionOutput",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalOutput",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tangentOutput",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uvOutput",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("morphTargetInfluences")},t.prototype.autoConfigure=function(e){if(!this.position.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"position"===e.name}));t||(t=new Sl("position")).setAsAttribute(),t.output.connectTo(this.position)}if(!this.normal.isConnected){var i=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"normal"===e.name}));i||(i=new Sl("normal")).setAsAttribute("normal"),i.output.connectTo(this.normal)}if(!this.tangent.isConnected){var n=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"tangent"===e.name}));n||(n=new Sl("tangent")).setAsAttribute("tangent"),n.output.connectTo(this.tangent)}if(!this.uv.isConnected){var r=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"uv"===e.name}));r||(r=new Sl("uv")).setAsAttribute("uv"),r.output.connectTo(this.uv)}},t.prototype.prepareDefines=function(e,t,i){i._areAttributesDirty&&ro.a.PrepareDefinesForMorphTargets(e,i)},t.prototype.bind=function(e,t,i){i&&i.morphTargetManager&&i.morphTargetManager.numInfluencers>0&&ro.a.BindMorphTargetParameters(i,e)},t.prototype.replaceRepeatableContent=function(e,t,i,n){for(var r=this.position,o=this.normal,a=this.tangent,s=this.uv,c=this.positionOutput,l=this.normalOutput,u=this.tangentOutput,h=this.uvOutput,d=e,f=n.NUM_MORPH_INFLUENCERS,p=i.morphTargetManager,_=p&&p.supportsNormals&&n.NORMAL,m=p&&p.supportsTangents&&n.TANGENT,g=p&&p.supportsUVs&&n.UV1,v="",b=0;b<f;b++)v+="#ifdef MORPHTARGETS\r\n",v+=c.associatedVariableName+" += (position"+b+" - "+r.associatedVariableName+") * morphTargetInfluences["+b+"];\r\n",_&&(v+="#ifdef MORPHTARGETS_NORMAL\r\n",v+=l.associatedVariableName+" += (normal"+b+" - "+o.associatedVariableName+") * morphTargetInfluences["+b+"];\r\n",v+="#endif\r\n"),m&&(v+="#ifdef MORPHTARGETS_TANGENT\r\n",v+=u.associatedVariableName+".xyz += (tangent"+b+" - "+a.associatedVariableName+".xyz) * morphTargetInfluences["+b+"];\r\n",v+="#endif\r\n"),g&&(v+="#ifdef MORPHTARGETS_UV\r\n",v+=h.associatedVariableName+".xy += (uv_"+b+" - "+s.associatedVariableName+".xy) * morphTargetInfluences["+b+"];\r\n",v+="#endif\r\n"),v+="#endif\r\n";if(d.compilationString=d.compilationString.replace(this._repeatableContentAnchor,v),f>0)for(b=0;b<f;b++)d.attributes.push(Qi.b.PositionKind+b),_&&d.attributes.push(Qi.b.NormalKind+b),m&&d.attributes.push(Qi.b.TangentKind+b),g&&d.attributes.push(Qi.b.UVKind+"_"+b)},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),t.sharedData.blocksWithDefines.push(this),t.sharedData.bindableBlocks.push(this),t.sharedData.repeatableContentBlocks.push(this);var i=this.position,n=this.normal,r=this.tangent,o=this.uv,a=this.positionOutput,s=this.normalOutput,c=this.tangentOutput,l=this.uvOutput,u="//"+this.name;return t.uniforms.push("morphTargetInfluences"),t._emitFunctionFromInclude("morphTargetsVertexGlobalDeclaration",u),t._emitFunctionFromInclude("morphTargetsVertexDeclaration",u,{repeatKey:"maxSimultaneousMorphTargets"}),t.compilationString+=this._declareOutput(a,t)+" = "+i.associatedVariableName+";\r\n",t.compilationString+="#ifdef NORMAL\r\n",t.compilationString+=this._declareOutput(s,t)+" = "+n.associatedVariableName+";\r\n",t.compilationString+="#else\r\n",t.compilationString+=this._declareOutput(s,t)+" = vec3(0., 0., 0.);\r\n",t.compilationString+="#endif\r\n",t.compilationString+="#ifdef TANGENT\r\n",t.compilationString+=this._declareOutput(c,t)+" = "+r.associatedVariableName+";\r\n",t.compilationString+="#else\r\n",t.compilationString+=this._declareOutput(c,t)+" = vec3(0., 0., 0.);\r\n",t.compilationString+="#endif\r\n",t.compilationString+="#ifdef UV1\r\n",t.compilationString+=this._declareOutput(l,t)+" = "+o.associatedVariableName+";\r\n",t.compilationString+="#else\r\n",t.compilationString+=this._declareOutput(l,t)+" = vec2(0., 0.);\r\n",t.compilationString+="#endif\r\n",this._repeatableContentAnchor=t._repeatableContentAnchor,t.compilationString+=this._repeatableContentAnchor,this},t}(fl);c.a.RegisteredTypes["BABYLON.MorphTargetsBlock"]=$l;var eu=function(e){function t(t){var i=e.call(this,t,el.Vertex)||this;return i.registerInput("worldPosition",tl.Vector4,!1,el.Vertex),i.registerOutput("direction",tl.Vector3),i.registerOutput("color",tl.Color3),i.registerOutput("intensity",tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"LightInformationBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"intensity",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.bind=function(e,t,i){if(i){this.light&&this.light.isDisposed&&(this.light=null);var n=this.light,r=t.getScene();if(!n&&r.lights.length&&(n=r.lights[0]),!n||!n.isEnabled)return e.setFloat3(this._lightDataUniformName,0,0,0),void e.setFloat4(this._lightColorUniformName,0,0,0,0);n.transferToNodeMaterialEffect(e,this._lightDataUniformName),e.setColor4(this._lightColorUniformName,n.diffuse,n.intensity)}},t.prototype.prepareDefines=function(e,t,i){if(i._areLightsDirty){var n=this.light;i.setValue(this._lightTypeDefineName,!!(n&&n instanceof Js))}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var i=this.direction,n=this.color,r=this.intensity;return this._lightDataUniformName=t._getFreeVariableName("lightData"),this._lightColorUniformName=t._getFreeVariableName("lightColor"),this._lightTypeDefineName=t._getFreeDefineName("LIGHTPOINTTYPE"),t._emitUniformFromString(this._lightDataUniformName,"vec3"),t._emitUniformFromString(this._lightColorUniformName,"vec4"),t.compilationString+="#ifdef "+this._lightTypeDefineName+"\r\n",t.compilationString+=this._declareOutput(i,t)+" = normalize("+this.worldPosition.associatedVariableName+".xyz - "+this._lightDataUniformName+");\r\n",t.compilationString+="#else\r\n",t.compilationString+=this._declareOutput(i,t)+" = "+this._lightDataUniformName+";\r\n",t.compilationString+="#endif\r\n",t.compilationString+=this._declareOutput(n,t)+" = "+this._lightColorUniformName+".rgb;\r\n",t.compilationString+=this._declareOutput(r,t)+" = "+this._lightColorUniformName+".a;\r\n",this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.light&&(t.lightId=this.light.id),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),t.lightId&&(this.light=i.getLightByID(t.lightId))},t}(fl);c.a.RegisteredTypes["BABYLON.LightInformationBlock"]=eu;var tu=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i.registerInput("color",tl.Color4),i.registerOutput("output",tl.Color4),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color3),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ImageProcessingBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.initialize=function(e){e._excludeVariableName("exposureLinear"),e._excludeVariableName("contrast"),e._excludeVariableName("vInverseScreenSize"),e._excludeVariableName("vignetteSettings1"),e._excludeVariableName("vignetteSettings2"),e._excludeVariableName("vCameraColorCurveNegative"),e._excludeVariableName("vCameraColorCurveNeutral"),e._excludeVariableName("vCameraColorCurvePositive"),e._excludeVariableName("txColorTransform"),e._excludeVariableName("colorTransformSettings")},t.prototype.isReady=function(e,t,i){return!(i._areImageProcessingDirty&&t.imageProcessingConfiguration&&!t.imageProcessingConfiguration.isReady())},t.prototype.prepareDefines=function(e,t,i){i._areImageProcessingDirty&&t.imageProcessingConfiguration&&t.imageProcessingConfiguration.prepareDefines(i)},t.prototype.bind=function(e,t,i){i&&t.imageProcessingConfiguration&&t.imageProcessingConfiguration.bind(e)},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t),t.sharedData.blocksWithDefines.push(this),t.sharedData.blockingBlocks.push(this),t.sharedData.bindableBlocks.push(this),t.uniforms.push("exposureLinear"),t.uniforms.push("contrast"),t.uniforms.push("vInverseScreenSize"),t.uniforms.push("vignetteSettings1"),t.uniforms.push("vignetteSettings2"),t.uniforms.push("vCameraColorCurveNegative"),t.uniforms.push("vCameraColorCurveNeutral"),t.uniforms.push("vCameraColorCurvePositive"),t.uniforms.push("txColorTransform"),t.uniforms.push("colorTransformSettings");var i=this.color,n=this._outputs[0],r="//"+this.name;return t._emitFunctionFromInclude("helperFunctions",r),t._emitFunctionFromInclude("imageProcessingDeclaration",r),t._emitFunctionFromInclude("imageProcessingFunctions",r),i.connectedPoint.type===tl.Color4||i.connectedPoint.type===tl.Vector4?t.compilationString+=this._declareOutput(n,t)+" = "+i.associatedVariableName+";\r\n":t.compilationString+=this._declareOutput(n,t)+" = vec4("+i.associatedVariableName+", 1.0);\r\n",t.compilationString+="#ifdef IMAGEPROCESSINGPOSTPROCESS\r\n",t.compilationString+=n.associatedVariableName+".rgb = toLinearSpace("+i.associatedVariableName+".rgb);\r\n",t.compilationString+="#else\r\n",t.compilationString+="#ifdef IMAGEPROCESSING\r\n",t.compilationString+=n.associatedVariableName+".rgb = toLinearSpace("+i.associatedVariableName+".rgb);\r\n",t.compilationString+=n.associatedVariableName+" = applyImageProcessing("+n.associatedVariableName+");\r\n",t.compilationString+="#endif\r\n",t.compilationString+="#endif\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ImageProcessingBlock"]=tu;var iu=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i._tangentSpaceParameterName="",i.invertX=!1,i.invertY=!1,i.registerInput("worldPosition",tl.Vector4,!1),i.registerInput("worldNormal",tl.Vector4,!1),i.registerInput("worldTangent",tl.Vector4,!0),i.registerInput("uv",tl.Vector2,!1),i.registerInput("normalMapColor",tl.Color3,!1),i.registerInput("strength",tl.Float,!1),i.registerOutput("output",tl.Vector4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"PerturbNormalBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMapColor",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"strength",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(e,t,i){i.setValue("BUMP",!0)},t.prototype.bind=function(e,t,i){t.getScene()._mirroredCameraPosition?e.setFloat2(this._tangentSpaceParameterName,this.invertX?1:-1,this.invertY?1:-1):e.setFloat2(this._tangentSpaceParameterName,this.invertX?-1:1,this.invertY?-1:1)},t.prototype.autoConfigure=function(e){if(!this.uv.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"uv"===e.name}));t||(t=new Sl("uv")).setAsAttribute(),t.output.connectTo(this.uv)}if(!this.strength.isConnected){var i=new Sl("strength");i.value=1,i.output.connectTo(this.strength)}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i="//"+this.name,n=this.uv,r=this.worldPosition,o=this.worldNormal,a=this.worldTangent;t.sharedData.blocksWithDefines.push(this),t.sharedData.bindableBlocks.push(this),this._tangentSpaceParameterName=t._getFreeDefineName("tangentSpaceParameter"),t._emitUniformFromString(this._tangentSpaceParameterName,"vec2");var s=this.strength.isConnectedToInputBlock&&this.strength.connectInputBlock.isConstant?""+t._emitFloat(1/this.strength.connectInputBlock.value):"1.0 / "+this.strength.associatedVariableName;t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var c={search:/defined\(TANGENT\)/g,replace:a.isConnected?"defined(TANGENT)":"defined(IGNORE)"};return a.isConnected&&(t.compilationString+="vec3 tbnNormal = normalize("+o.associatedVariableName+".xyz);\r\n",t.compilationString+="vec3 tbnTangent = normalize("+a.associatedVariableName+".xyz);\r\n",t.compilationString+="vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",t.compilationString+="mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),t._emitFunctionFromInclude("bumpFragmentMainFunctions",i,{replaceStrings:[c]}),t._emitFunctionFromInclude("bumpFragmentFunctions",i,{replaceStrings:[{search:/vBumpInfos.y/g,replace:s},{search:/vTangentSpaceParams/g,replace:this._tangentSpaceParameterName},{search:/vPositionW/g,replace:r.associatedVariableName+".xyz"}]}),t.compilationString+=this._declareOutput(this.output,t)+" = vec4(0.);\r\n",t.compilationString+=t._emitCodeFromInclude("bumpFragment",i,{replaceStrings:[{search:/perturbNormal\(TBN,vBumpUV\+uvOffset\)/g,replace:"perturbNormal(TBN, "+this.normalMapColor.associatedVariableName+")"},{search:/vBumpInfos.y/g,replace:s},{search:/vBumpUV/g,replace:n.associatedVariableName},{search:/vPositionW/g,replace:r.associatedVariableName+".xyz"},{search:/normalW=/g,replace:this.output.associatedVariableName+".xyz = "},{search:/mat3\(normalMatrix\)\*normalW/g,replace:"mat3(normalMatrix) * "+this.output.associatedVariableName+".xyz"},{search:/normalW/g,replace:o.associatedVariableName+".xyz"},c]}),this},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".invertX = "+this.invertX+";\r\n";return e+=this._codeVariableName+".invertY = "+this.invertY+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.invertX=this.invertX,t.invertY=this.invertY,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.invertX=t.invertX,this.invertY=t.invertY},Object(h.c)([Ml("Invert X axis",xl.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertX",void 0),Object(h.c)([Ml("Invert Y axis",xl.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertY",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.PerturbNormalBlock"]=iu;var nu=function(e){function t(t){var i=e.call(this,t,el.Fragment,!0)||this;return i.registerInput("value",tl.Float,!0),i.registerInput("cutoff",tl.Float,!0),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DiscardBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cutoff",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.sharedData.hints.needAlphaTesting=!0,this.cutoff.isConnected&&this.value.isConnected)return t.compilationString+="if ("+this.value.associatedVariableName+" < "+this.cutoff.associatedVariableName+") discard;\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.DiscardBlock"]=nu;var ru=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i.registerOutput("output",tl.Float,el.Fragment),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FrontFacingBlock"},Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===el.Vertex)throw"FrontFacingBlock must only be used in a fragment shader";var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = gl_FrontFacing ? 1.0 : 0.0;\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.FrontFacingBlock"]=ru;var ou=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i.registerInput("input",tl.AutoDetect,!1),i.registerOutput("dx",tl.BasedOnInput),i.registerOutput("dy",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._outputs[1]._typeConnectionSource=i._inputs[0],i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DerivativeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dx",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dy",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=this._outputs[1];return t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),i.hasEndpoints&&(t.compilationString+=this._declareOutput(i,t)+" = dFdx("+this.input.associatedVariableName+");\r\n"),n.hasEndpoints&&(t.compilationString+=this._declareOutput(n,t)+" = dFdy("+this.input.associatedVariableName+");\r\n"),this},t}(fl);c.a.RegisteredTypes["BABYLON.DerivativeBlock"]=ou;var au=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i.registerOutput("xy",tl.Vector2,el.Fragment),i.registerOutput("xyz",tl.Vector3,el.Fragment),i.registerOutput("xyzw",tl.Vector4,el.Fragment),i.registerOutput("x",tl.Float,el.Fragment),i.registerOutput("y",tl.Float,el.Fragment),i.registerOutput("z",tl.Float,el.Fragment),i.registerOutput("w",tl.Float,el.Fragment),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FragCoordBlock"},Object.defineProperty(t.prototype,"xy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyz",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),t.prototype.writeOutputs=function(e){for(var t="",i=0,n=this._outputs;i<n.length;i++){var r=n[i];r.hasEndpoints&&(t+=this._declareOutput(r,e)+" = gl_FragCoord."+r.name+";\r\n")}return t},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===el.Vertex)throw"FragCoordBlock must only be used in a fragment shader";return t.compilationString+=this.writeOutputs(t),this},t}(fl);c.a.RegisteredTypes["BABYLON.FragCoordBlock"]=au;var su=function(e){function t(t){var i=e.call(this,t,el.Fragment)||this;return i.registerOutput("xy",tl.Vector2,el.Fragment),i.registerOutput("x",tl.Float,el.Fragment),i.registerOutput("y",tl.Float,el.Fragment),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ScreenSizeBlock"},Object.defineProperty(t.prototype,"xy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.bind=function(e,t,i){var n=this._scene.getEngine();e.setFloat2(this._varName,n.getRenderWidth(),n.getRenderWidth())},t.prototype.writeOutputs=function(e,t){for(var i="",n=0,r=this._outputs;n<r.length;n++){var o=r[n];o.hasEndpoints&&(i+=this._declareOutput(o,e)+" = "+t+"."+o.name+";\r\n")}return i},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),this._scene=t.sharedData.scene,t.target===el.Vertex)throw"ScreenSizeBlock must only be used in a fragment shader";return t.sharedData.bindableBlocks.push(this),this._varName=t._getFreeVariableName("screenSize"),t._emitUniformFromString(this._varName,"vec2"),t.compilationString+=this.writeOutputs(t,this._varName),this},t}(fl);c.a.RegisteredTypes["BABYLON.ScreenSizeBlock"]=su;var cu=function(e){function t(t){var i=e.call(this,t,el.VertexAndFragment,!0)||this;return i.registerInput("worldPosition",tl.Vector4,!1,el.Vertex),i.registerInput("view",tl.Matrix,!1,el.Vertex),i.registerInput("input",tl.Color3,!1,el.Fragment),i.registerInput("fogColor",tl.Color3,!1,el.Fragment),i.registerOutput("output",tl.Color3,el.Fragment),i.input.acceptedConnectionPointTypes.push(tl.Color4),i.fogColor.acceptedConnectionPointTypes.push(tl.Color4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FogBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fogColor",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.view.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.View}));t||(t=new Sl("view")).setAsSystemValue(nl.View),t.output.connectTo(this.view)}if(!this.fogColor.isConnected){var i=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.FogColor}));i||(i=new Sl("fogColor",void 0,tl.Color3)).setAsSystemValue(nl.FogColor),i.output.connectTo(this.fogColor)}},t.prototype.prepareDefines=function(e,t,i){var n=e.getScene();i.setValue("FOG",t.fogEnabled&&ro.a.GetFogState(e,n))},t.prototype.bind=function(e,t,i){if(i){var n=i.getScene();e.setFloat4(this._fogParameters,n.fogMode,n.fogStart,n.fogEnd,n.fogDensity)}},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===el.Fragment){t.sharedData.blocksWithDefines.push(this),t.sharedData.bindableBlocks.push(this),t._emitFunctionFromInclude("fogFragmentDeclaration","//"+this.name,{removeUniforms:!0,removeVaryings:!0,removeIfDef:!1,replaceStrings:[{search:/float CalcFogFactor\(\)/,replace:"float CalcFogFactor(vec3 vFogDistance, vec4 vFogInfos)"}]});var i=t._getFreeVariableName("fog"),n=this.input,r=this.fogColor;this._fogParameters=t._getFreeVariableName("fogParameters");var o=this._outputs[0];t._emitUniformFromString(this._fogParameters,"vec4"),t.compilationString+="#ifdef FOG\r\n",t.compilationString+="float "+i+" = CalcFogFactor("+this._fogDistanceName+", "+this._fogParameters+");\r\n",t.compilationString+=this._declareOutput(o,t)+" = "+i+" * "+n.associatedVariableName+".rgb + (1.0 - "+i+") * "+r.associatedVariableName+".rgb;\r\n",t.compilationString+="#else\r\n"+this._declareOutput(o,t)+" = "+n.associatedVariableName+".rgb;\r\n",t.compilationString+="#endif\r\n"}else{var a=this.worldPosition,s=this.view;this._fogDistanceName=t._getFreeVariableName("vFogDistance"),t._emitVaryingFromString(this._fogDistanceName,"vec3"),t.compilationString+=this._fogDistanceName+" = ("+s.associatedVariableName+" * "+a.associatedVariableName+").xyz;\r\n"}return this},t}(fl);c.a.RegisteredTypes["BABYLON.FogBlock"]=cu;var lu=function(e){function t(t){var i=e.call(this,t,el.VertexAndFragment)||this;return i._isUnique=!0,i.registerInput("worldPosition",tl.Vector4,!1,el.Vertex),i.registerInput("worldNormal",tl.Vector4,!1,el.Fragment),i.registerInput("cameraPosition",tl.Vector3,!1,el.Fragment),i.registerInput("glossiness",tl.Float,!0,el.Fragment),i.registerInput("glossPower",tl.Float,!0,el.Fragment),i.registerInput("diffuseColor",tl.Color3,!0,el.Fragment),i.registerInput("specularColor",tl.Color3,!0,el.Fragment),i.registerInput("view",tl.Matrix,!0),i.registerOutput("diffuseOutput",tl.Color3,el.Fragment),i.registerOutput("specularOutput",tl.Color3,el.Fragment),i.registerOutput("shadow",tl.Float,el.Fragment),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"LightBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glossiness",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glossPower",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseColor",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularColor",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseOutput",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularOutput",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadow",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.cameraPosition.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.CameraPosition}));t||(t=new Sl("cameraPosition")).setAsSystemValue(nl.CameraPosition),t.output.connectTo(this.cameraPosition)}},t.prototype.prepareDefines=function(e,t,i){if(i._areLightsDirty){var n=e.getScene();if(this.light){var r={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};ro.a.PrepareDefinesForLight(n,e,this.light,this._lightId,i,!0,r),r.needRebuild&&i.rebuild()}else ro.a.PrepareDefinesForLights(n,e,i,!0,t.maxSimultaneousLights)}},t.prototype.updateUniformsAndSamples=function(e,t,i,n){for(var r=0;r<t.maxSimultaneousLights&&i["LIGHT"+r];r++){var o=e.uniforms.indexOf("vLightData"+r)>=0;ro.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+r],n,o)}},t.prototype.bind=function(e,t,i){if(i){var n=i.getScene();this.light?ro.a.BindLight(this.light,this._lightId,n,e,!0):ro.a.BindLights(n,i,e,!0,t.maxSimultaneousLights)}},t.prototype._injectVertexCode=function(e){var t=this.worldPosition,i="//"+this.name;this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var n="v_"+t.associatedVariableName;e._emitVaryingFromString(n,"vec4")&&(e.compilationString+=n+" = "+t.associatedVariableName+";\r\n"),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:t.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = "+t.associatedVariableName+";\r\n",this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+";\r\n"),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",i,{repeatKey:"maxSimultaneousLights"}))},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===el.Fragment){t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var i="//"+this.name,n=this.worldPosition;t._emitFunctionFromInclude("helperFunctions",i),t._emitFunctionFromInclude("lightsFragmentFunctions",i,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+n.associatedVariableName+".xyz"}]}),t._emitFunctionFromInclude("shadowsFragmentFunctions",i,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+n.associatedVariableName+".xyz"}]}),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",i,{repeatKey:"maxSimultaneousLights"}),0===this._lightId&&(t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize("+this.cameraPosition.associatedVariableName+" - v_"+n.associatedVariableName+".xyz);\r\n"),t.compilationString+="lightingInfo info;\r\n",t.compilationString+="float shadow = 1.;\r\n",t.compilationString+="float glossiness = "+(this.glossiness.isConnected?this.glossiness.associatedVariableName:"1.0")+" * "+(this.glossPower.isConnected?this.glossPower.associatedVariableName:"1024.0")+";\r\n",t.compilationString+="vec3 diffuseBase = vec3(0., 0., 0.);\r\n",t.compilationString+="vec3 specularBase = vec3(0., 0., 0.);\r\n",t.compilationString+="vec3 normalW = "+this.worldNormal.associatedVariableName+".xyz;\r\n"),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",i,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",i,{repeatKey:"maxSimultaneousLights"});var r=this.diffuseOutput,o=this.specularOutput;return t.compilationString+=this._declareOutput(r,t)+" = diffuseBase"+(this.diffuseColor.isConnected?" * "+this.diffuseColor.associatedVariableName:"")+";\r\n",o.hasEndpoints&&(t.compilationString+=this._declareOutput(o,t)+" = specularBase"+(this.specularColor.isConnected?" * "+this.specularColor.associatedVariableName:"")+";\r\n"),this.shadow.hasEndpoints&&(t.compilationString+=this._declareOutput(this.shadow,t)+" = shadow;\r\n"),this}this._injectVertexCode(t)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.light&&(t.lightId=this.light.id),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),t.lightId&&(this.light=i.getLightByID(t.lightId))},t}(fl);c.a.RegisteredTypes["BABYLON.LightBlock"]=lu;var uu=function(e){function t(t,i){void 0===i&&(i=!1);var n=e.call(this,t,i?el.Fragment:el.VertexAndFragment)||this;return n.convertToGammaSpace=!1,n.convertToLinearSpace=!1,n._fragmentOnly=i,n.registerInput("uv",tl.Vector2,!1,el.VertexAndFragment),n.registerOutput("rgba",tl.Color4,el.Neutral),n.registerOutput("rgb",tl.Color3,el.Neutral),n.registerOutput("r",tl.Float,el.Neutral),n.registerOutput("g",tl.Float,el.Neutral),n.registerOutput("b",tl.Float,el.Neutral),n.registerOutput("a",tl.Float,el.Neutral),n._inputs[0].acceptedConnectionPointTypes.push(tl.Vector3),n._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),n._inputs[0]._prioritizeVertex=!i,n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"TextureBlock"},Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){if(this._fragmentOnly)return el.Fragment;if(!this.uv.isConnected)return el.VertexAndFragment;if(this.uv.sourceBlock.isInput)return el.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===el.Fragment)return el.Fragment;if(e.target===el.Vertex)return el.VertexAndFragment;if(e.target===el.Neutral||e.target===el.VertexAndFragment){var t=e.ownerBlock;e=null;for(var i=0,n=t.inputs;i<n.length;i++){var r=n[i];if(r.connectedPoint){e=r.connectedPoint;break}}}}return el.VertexAndFragment},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.uv.isConnected)if(e.mode===rl.PostProcess){(t=e.getBlockByPredicate((function(e){return"uv"===e.name})))&&t.connectTo(this)}else{var t,i=e.mode===rl.Particle?"particle_uv":"uv";(t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&e.name===i})))||(t=new Sl("uv")).setAsAttribute(i),t.output.connectTo(this.uv)}},t.prototype.initializeDefines=function(e,t,i,n){void 0===n&&(n=!1),i._areTexturesDirty&&i.setValue(this._mainUVDefineName,!1)},t.prototype.prepareDefines=function(e,t,i){if(i._areTexturesDirty){if(!this.texture||!this.texture.getTextureMatrix)return i.setValue(this._defineName,!1),void i.setValue(this._mainUVDefineName,!0);i.setValue(this._linearDefineName,this.convertToGammaSpace),i.setValue(this._gammaDefineName,this.convertToLinearSpace),this._isMixed&&(this.texture.getTextureMatrix().isIdentityAs3x2()?(i.setValue(this._defineName,!1),i.setValue(this._mainUVDefineName,!0)):i.setValue(this._defineName,!0))}},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.bind=function(e,t,i){this.texture&&(this._isMixed&&(e.setFloat(this._textureInfoName,this.texture.level),e.setMatrix(this._textureTransformName,this.texture.getTextureMatrix())),e.setTexture(this._samplerName,this.texture))},Object.defineProperty(t.prototype,"_isMixed",{get:function(){return this.target!==el.Fragment},enumerable:!1,configurable:!0}),t.prototype._injectVertexCode=function(e){var t=this.uv;(this._defineName=e._getFreeDefineName("UVTRANSFORM"),this._mainUVDefineName="VMAIN"+t.associatedVariableName.toUpperCase(),t.connectedPoint.ownerBlock.isInput)&&(t.connectedPoint.ownerBlock.isAttribute||e._emitUniformFromString(t.associatedVariableName,"vec2"));if(this._mainUVName="vMain"+t.associatedVariableName,this._transformedUVName=e._getFreeVariableName("transformedUV"),this._textureTransformName=e._getFreeVariableName("textureTransform"),this._textureInfoName=e._getFreeVariableName("textureInfoName"),e._emitVaryingFromString(this._transformedUVName,"vec2",this._defineName),e._emitVaryingFromString(this._mainUVName,"vec2",this._mainUVDefineName),e._emitUniformFromString(this._textureTransformName,"mat4",this._defineName),e.compilationString+="#ifdef "+this._defineName+"\r\n",e.compilationString+=this._transformedUVName+" = vec2("+this._textureTransformName+" * vec4("+t.associatedVariableName+".xy, 1.0, 0.0));\r\n",e.compilationString+="#elif defined("+this._mainUVDefineName+")\r\n",e.compilationString+=this._mainUVName+" = "+t.associatedVariableName+".xy;\r\n",e.compilationString+="#endif\r\n",this._outputs.some((function(e){return e.isConnectedInVertexShader}))){this._writeTextureRead(e,!0);for(var i=0,n=this._outputs;i<n.length;i++){var r=n[i];r.hasEndpoints&&this._writeOutput(e,r,r.name,!0)}}},t.prototype._writeTextureRead=function(e,t){void 0===t&&(t=!1);var i=this.uv;if(t){if(e.target===el.Fragment)return;e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+");\r\n"}else this.uv.ownerBlock.target!==el.Fragment?(e.compilationString+="#ifdef "+this._defineName+"\r\n",e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this._transformedUVName+");\r\n",e.compilationString+="#elif defined("+this._mainUVDefineName+")\r\n",e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+this._mainUVName+");\r\n",e.compilationString+="#endif\r\n"):e.compilationString+="vec4 "+this._tempTextureRead+" = texture2D("+this._samplerName+", "+i.associatedVariableName+");\r\n"},t.prototype._writeOutput=function(e,t,i,n){if(void 0===n&&(n=!1),n){if(e.target===el.Fragment)return;e.compilationString+=this._declareOutput(t,e)+" = "+this._tempTextureRead+"."+i+";\r\n"}else if(this.uv.ownerBlock.target!==el.Fragment){var r=" * "+this._textureInfoName;e.compilationString+=this._declareOutput(t,e)+" = "+this._tempTextureRead+"."+i+r+";\r\n","a"!==i&&(e.compilationString+="#ifdef "+this._linearDefineName+"\r\n",e.compilationString+=t.associatedVariableName+" = toGammaSpace("+t.associatedVariableName+");\r\n",e.compilationString+="#endif\r\n",e.compilationString+="#ifdef "+this._gammaDefineName+"\r\n",e.compilationString+=t.associatedVariableName+" = toLinearSpace("+t.associatedVariableName+");\r\n",e.compilationString+="#endif\r\n")}else e.compilationString+=this._declareOutput(t,e)+" = "+this._tempTextureRead+"."+i+";\r\n"},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),(t.target===el.Vertex||this._fragmentOnly)&&(this._tempTextureRead=t._getFreeVariableName("tempTextureRead")),(!this._isMixed&&t.target===el.Fragment||this._isMixed&&t.target===el.Vertex)&&(this._samplerName=t._getFreeVariableName(this.name+"Sampler"),t._emit2DSampler(this._samplerName),t.sharedData.blockingBlocks.push(this),t.sharedData.textureBlocks.push(this),t.sharedData.blocksWithDefines.push(this),t.sharedData.bindableBlocks.push(this)),t.target===el.Fragment){if(this._outputs.some((function(e){return e.isConnectedInFragmentShader}))){this._isMixed&&t._emit2DSampler(this._samplerName),this._linearDefineName=t._getFreeDefineName("ISLINEAR"),this._gammaDefineName=t._getFreeDefineName("ISGAMMA");var i="//"+this.name;t._emitFunctionFromInclude("helperFunctions",i),this._isMixed&&t._emitUniformFromString(this._textureInfoName,"float"),this._writeTextureRead(t);for(var n=0,r=this._outputs;n<r.length;n++){var o=r[n];o.hasEndpoints&&this._writeOutput(t,o,o.name)}return this}}else this._injectVertexCode(t)},t.prototype._dumpPropertiesCode=function(){if(!this.texture)return"";var e=this._codeVariableName+'.texture = new BABYLON.Texture("'+this.texture.name+'", null);\r\n';return e+=this._codeVariableName+".texture.wrapU = "+this.texture.wrapU+";\r\n",e+=this._codeVariableName+".texture.wrapV = "+this.texture.wrapV+";\r\n",e+=this._codeVariableName+".texture.uAng = "+this.texture.uAng+";\r\n",e+=this._codeVariableName+".texture.vAng = "+this.texture.vAng+";\r\n",e+=this._codeVariableName+".texture.wAng = "+this.texture.wAng+";\r\n",e+=this._codeVariableName+".texture.uOffset = "+this.texture.uOffset+";\r\n",e+=this._codeVariableName+".texture.vOffset = "+this.texture.vOffset+";\r\n",e+=this._codeVariableName+".texture.uScale = "+this.texture.uScale+";\r\n",e+=this._codeVariableName+".texture.vScale = "+this.texture.vScale+";\r\n",e+=this._codeVariableName+".convertToGammaSpace = "+this.convertToGammaSpace+";\r\n",e+=this._codeVariableName+".convertToLinearSpace = "+this.convertToLinearSpace+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.convertToGammaSpace=this.convertToGammaSpace,t.convertToLinearSpace=this.convertToLinearSpace,t.fragmentOnly=this._fragmentOnly,this.texture&&!this.texture.isRenderTarget&&(t.texture=this.texture.serialize()),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.convertToGammaSpace=t.convertToGammaSpace,this.convertToLinearSpace=!!t.convertToLinearSpace,this._fragmentOnly=!!t.fragmentOnly,t.texture&&!ql.IgnoreTexturesAtLoadTime&&(n=0===t.texture.url.indexOf("data:")?"":n,this.texture=Ke.a.Parse(t.texture,i,n))},t}(fl);c.a.RegisteredTypes["BABYLON.TextureBlock"]=uu;var hu=function(e){function t(t){return e.call(this,t,el.VertexAndFragment)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ReflectionTextureBaseBlock"},t.prototype._getTexture=function(){return this.texture},t.prototype.autoConfigure=function(e){if(!this.position.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.isAttribute&&"position"===e.name}));t||(t=new Sl("position")).setAsAttribute(),t.output.connectTo(this.position)}if(!this.world.isConnected){var i=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.World}));i||(i=new Sl("world")).setAsSystemValue(nl.World),i.output.connectTo(this.world)}if(this.view&&!this.view.isConnected){var n=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.View}));n||(n=new Sl("view")).setAsSystemValue(nl.View),n.output.connectTo(this.view)}},t.prototype.prepareDefines=function(e,t,i){if(i._areTexturesDirty){var n=this._getTexture();n&&n.getTextureMatrix&&(i.setValue(this._define3DName,n.isCube,!0),i.setValue(this._defineLocalCubicName,!!n.boundingBoxSize,!0),i.setValue(this._defineExplicitName,n.coordinatesMode===g.a.TEXTURE_EXPLICIT_MODE,!0),i.setValue(this._defineSkyboxName,n.coordinatesMode===g.a.TEXTURE_SKYBOX_MODE,!0),i.setValue(this._defineCubicName,n.coordinatesMode===g.a.TEXTURE_CUBIC_MODE||n.coordinatesMode===g.a.TEXTURE_INVCUBIC_MODE,!0),i.setValue("INVERTCUBICMAP",n.coordinatesMode===g.a.TEXTURE_INVCUBIC_MODE,!0),i.setValue(this._defineSphericalName,n.coordinatesMode===g.a.TEXTURE_SPHERICAL_MODE,!0),i.setValue(this._definePlanarName,n.coordinatesMode===g.a.TEXTURE_PLANAR_MODE,!0),i.setValue(this._defineProjectionName,n.coordinatesMode===g.a.TEXTURE_PROJECTION_MODE,!0),i.setValue(this._defineEquirectangularName,n.coordinatesMode===g.a.TEXTURE_EQUIRECTANGULAR_MODE,!0),i.setValue(this._defineEquirectangularFixedName,n.coordinatesMode===g.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,!0),i.setValue(this._defineMirroredEquirectangularFixedName,n.coordinatesMode===g.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,!0))}},t.prototype.isReady=function(){var e=this._getTexture();return!(e&&!e.isReadyOrNotBlocking())},t.prototype.bind=function(e,t,i){var n=this._getTexture();i&&n&&(e.setMatrix(this._reflectionMatrixName,n.getReflectionTextureMatrix()),n.isCube?e.setTexture(this._cubeSamplerName,n):e.setTexture(this._2DSamplerName,n))},t.prototype.handleVertexSide=function(e){this._define3DName=e._getFreeDefineName("REFLECTIONMAP_3D"),this._defineCubicName=e._getFreeDefineName("REFLECTIONMAP_CUBIC"),this._defineSphericalName=e._getFreeDefineName("REFLECTIONMAP_SPHERICAL"),this._definePlanarName=e._getFreeDefineName("REFLECTIONMAP_PLANAR"),this._defineProjectionName=e._getFreeDefineName("REFLECTIONMAP_PROJECTION"),this._defineExplicitName=e._getFreeDefineName("REFLECTIONMAP_EXPLICIT"),this._defineEquirectangularName=e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR"),this._defineLocalCubicName=e._getFreeDefineName("USE_LOCAL_REFLECTIONMAP_CUBIC"),this._defineMirroredEquirectangularFixedName=e._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"),this._defineEquirectangularFixedName=e._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED"),this._defineSkyboxName=e._getFreeDefineName("REFLECTIONMAP_SKYBOX"),this._defineOppositeZ=e._getFreeDefineName("REFLECTIONMAP_OPPOSITEZ"),this._reflectionMatrixName=e._getFreeVariableName("reflectionMatrix"),e._emitUniformFromString(this._reflectionMatrixName,"mat4");var t="",i="v_"+this.worldPosition.associatedVariableName;return e._emitVaryingFromString(i,"vec4")&&(t+=i+" = "+this.worldPosition.associatedVariableName+";\r\n"),this._positionUVWName=e._getFreeVariableName("positionUVW"),this._directionWName=e._getFreeVariableName("directionW"),e._emitVaryingFromString(this._positionUVWName,"vec3",this._defineSkyboxName)&&(t+="#ifdef "+this._defineSkyboxName+"\r\n",t+=this._positionUVWName+" = "+this.position.associatedVariableName+".xyz;\r\n",t+="#endif\r\n"),e._emitVaryingFromString(this._directionWName,"vec3","defined("+this._defineEquirectangularFixedName+") || defined("+this._defineMirroredEquirectangularFixedName+")")&&(t+="#if defined("+this._defineEquirectangularFixedName+") || defined("+this._defineMirroredEquirectangularFixedName+")\r\n",t+=this._directionWName+" = normalize(vec3("+this.world.associatedVariableName+" * vec4("+this.position.associatedVariableName+".xyz, 0.0)));\r\n",t+="#endif\r\n"),t},t.prototype.handleFragmentSideInits=function(e){e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),this._cubeSamplerName=e._getFreeVariableName(this.name+"CubeSampler"),e.samplers.push(this._cubeSamplerName),this._2DSamplerName=e._getFreeVariableName(this.name+"2DSampler"),e.samplers.push(this._2DSamplerName),e._samplerDeclaration+="#ifdef "+this._define3DName+"\r\n",e._samplerDeclaration+="uniform samplerCube "+this._cubeSamplerName+";\r\n",e._samplerDeclaration+="#else\r\n",e._samplerDeclaration+="uniform sampler2D "+this._2DSamplerName+";\r\n",e._samplerDeclaration+="#endif\r\n",e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this);var t="//"+this.name;e._emitFunction("ReciprocalPI","#define RECIPROCAL_PI2 0.15915494",""),e._emitFunctionFromInclude("reflectionFunction",t,{replaceStrings:[{search:/vec3 computeReflectionCoords/g,replace:"void DUMMYFUNC"}]}),this._reflectionColorName=e._getFreeVariableName("reflectionColor"),this._reflectionVectorName=e._getFreeVariableName("reflectionUVW"),this._reflectionCoordsName=e._getFreeVariableName("reflectionCoords")},t.prototype.handleFragmentSideCodeReflectionCoords=function(e,t,i){void 0===i&&(i=!1),t||(t="v_"+this.worldPosition.associatedVariableName);var n=this._reflectionMatrixName,r="normalize("+this._directionWName+")",o=""+this._positionUVWName,a=""+this.cameraPosition.associatedVariableName,s=""+this.view.associatedVariableName;e+=".xyz";var c="\n #ifdef "+this._defineMirroredEquirectangularFixedName+"\n vec3 "+this._reflectionVectorName+" = computeMirroredFixedEquirectangularCoords("+t+", "+e+", "+r+");\n #endif\n\n #ifdef "+this._defineEquirectangularFixedName+"\n vec3 "+this._reflectionVectorName+" = computeFixedEquirectangularCoords("+t+", "+e+", "+r+");\n #endif\n\n #ifdef "+this._defineEquirectangularName+"\n vec3 "+this._reflectionVectorName+" = computeEquirectangularCoords("+t+", "+e+", "+a+".xyz, "+n+");\n #endif\n\n #ifdef "+this._defineSphericalName+"\n vec3 "+this._reflectionVectorName+" = computeSphericalCoords("+t+", "+e+", "+s+", "+n+");\n #endif\n\n #ifdef "+this._definePlanarName+"\n vec3 "+this._reflectionVectorName+" = computePlanarCoords("+t+", "+e+", "+a+".xyz, "+n+");\n #endif\n\n #ifdef "+this._defineCubicName+"\n #ifdef "+this._defineLocalCubicName+"\n vec3 "+this._reflectionVectorName+" = computeCubicLocalCoords("+t+", "+e+", "+a+".xyz, "+n+", vReflectionSize, vReflectionPosition);\n #else\n vec3 "+this._reflectionVectorName+" = computeCubicCoords("+t+", "+e+", "+a+".xyz, "+n+");\n #endif\n #endif\n\n #ifdef "+this._defineProjectionName+"\n vec3 "+this._reflectionVectorName+" = computeProjectionCoords("+t+", "+s+", "+n+");\n #endif\n\n #ifdef "+this._defineSkyboxName+"\n vec3 "+this._reflectionVectorName+" = computeSkyBoxCoords("+o+", "+n+");\n #endif\n\n #ifdef "+this._defineExplicitName+"\n vec3 "+this._reflectionVectorName+" = vec3(0, 0, 0);\n #endif\n\n #ifdef "+this._defineOppositeZ+"\n "+this._reflectionVectorName+".z *= -1.0;\n #endif\r\n";return i||(c+="\n #ifdef "+this._define3DName+"\n vec3 "+this._reflectionCoordsName+" = "+this._reflectionVectorName+";\n #else\n vec2 "+this._reflectionCoordsName+" = "+this._reflectionVectorName+".xy;\n #ifdef "+this._defineProjectionName+"\n "+this._reflectionCoordsName+" /= "+this._reflectionVectorName+".z;\n #endif\n "+this._reflectionCoordsName+".y = 1.0 - "+this._reflectionCoordsName+".y;\n #endif\r\n"),c},t.prototype.handleFragmentSideCodeReflectionColor=function(e,t){void 0===t&&(t=".rgb");var i="vec"+(0===t.length?"4":t.length-1)+" "+this._reflectionColorName+";\n #ifdef "+this._define3DName+"\r\n";return i+=e?this._reflectionColorName+" = textureCubeLodEXT("+this._cubeSamplerName+", "+this._reflectionVectorName+", "+e+")"+t+";\r\n":this._reflectionColorName+" = textureCube("+this._cubeSamplerName+", "+this._reflectionVectorName+")"+t+";\r\n",i+="\n #else\r\n",i+=e?this._reflectionColorName+" = texture2DLodEXT("+this._2DSamplerName+", "+this._reflectionCoordsName+", "+e+")"+t+";\r\n":this._reflectionColorName+" = texture2D("+this._2DSamplerName+", "+this._reflectionCoordsName+")"+t+";\r\n",i+="#endif\r\n"},t.prototype.writeOutputs=function(e,t){var i="";if(e.target===el.Fragment)for(var n=0,r=this._outputs;n<r.length;n++){var o=r[n];o.hasEndpoints&&(i+=this._declareOutput(o,e)+" = "+t+"."+o.name+";\r\n")}return i},t.prototype._buildBlock=function(t){return e.prototype._buildBlock.call(this,t),this},t.prototype._dumpPropertiesCode=function(){return this.texture?(e=this.texture.isCube?this._codeVariableName+'.texture = new BABYLON.CubeTexture("'+this.texture.name+'");\r\n':this._codeVariableName+'.texture = new BABYLON.Texture("'+this.texture.name+'");\r\n',e+=this._codeVariableName+".texture.coordinatesMode = "+this.texture.coordinatesMode+";\r\n"):"";var e},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.texture&&(t.texture=this.texture.serialize()),t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),t.texture&&(n=0===t.texture.url.indexOf("data:")?"":n,t.texture.isCube?this.texture=no.Parse(t.texture,i,n):this.texture=Ke.a.Parse(t.texture,i,n))},t}(fl);c.a.RegisteredTypes["BABYLON.ReflectionTextureBaseBlock"]=hu;var du=function(e){function t(t){var i=e.call(this,t)||this;return i.registerInput("position",tl.Vector3,!1,el.Vertex),i.registerInput("worldPosition",tl.Vector4,!1,el.Vertex),i.registerInput("worldNormal",tl.Vector4,!1,el.Fragment),i.registerInput("world",tl.Matrix,!1,el.Vertex),i.registerInput("cameraPosition",tl.Vector3,!1,el.Fragment),i.registerInput("view",tl.Matrix,!1,el.Fragment),i.registerOutput("rgb",tl.Color3,el.Fragment),i.registerOutput("rgba",tl.Color4,el.Fragment),i.registerOutput("r",tl.Float,el.Fragment),i.registerOutput("g",tl.Float,el.Fragment),i.registerOutput("b",tl.Float,el.Fragment),i.registerOutput("a",tl.Float,el.Fragment),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ReflectionTextureBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(t){if(e.prototype.autoConfigure.call(this,t),!this.cameraPosition.isConnected){var i=t.getInputBlockByPredicate((function(e){return e.systemValue===nl.CameraPosition}));i||(i=new Sl("cameraPosition")).setAsSystemValue(nl.CameraPosition),i.output.connectTo(this.cameraPosition)}},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),!this.texture)return t.compilationString+=this.writeOutputs(t,"vec3(0.)"),this;if(t.target!==el.Fragment)return t.compilationString+=this.handleVertexSide(t),this;this.handleFragmentSideInits(t);var i=t._getFreeVariableName("normalWUnit");return t.compilationString+="vec4 "+i+" = normalize("+this.worldNormal.associatedVariableName+");\r\n",t.compilationString+=this.handleFragmentSideCodeReflectionCoords(i),t.compilationString+=this.handleFragmentSideCodeReflectionColor(void 0,""),t.compilationString+=this.writeOutputs(t,this._reflectionColorName),this},t}(hu);c.a.RegisteredTypes["BABYLON.ReflectionTextureBlock"]=du;var fu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AddBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = "+this.left.associatedVariableName+" + "+this.right.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.AddBlock"]=fu;var pu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("input",tl.AutoDetect),i.registerInput("factor",tl.Float),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ScaleBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"factor",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = "+this.input.associatedVariableName+" * "+this.factor.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ScaleBlock"]=pu;var _u=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.minimum=0,i.maximum=1,i.registerInput("value",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ClampBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = clamp("+this.value.associatedVariableName+", "+this._writeFloat(this.minimum)+", "+this._writeFloat(this.maximum)+");\r\n",this},t.prototype._dumpPropertiesCode=function(){var e=this._codeVariableName+".minimum = "+this.minimum+";\r\n";return e+=this._codeVariableName+".maximum = "+this.maximum+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.minimum=this.minimum,t.maximum=this.maximum,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.minimum=t.minimum,this.maximum=t.maximum},Object(h.c)([Ml("Minimum",xl.Float)],t.prototype,"minimum",void 0),Object(h.c)([Ml("Maximum",xl.Float)],t.prototype,"maximum",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.ClampBlock"]=_u;var mu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.Vector3),i._linkConnectionTypes(0,1),i._inputs[0].excludedConnectionPointTypes.push(tl.Float),i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i._inputs[0].excludedConnectionPointTypes.push(tl.Vector2),i._inputs[1].excludedConnectionPointTypes.push(tl.Float),i._inputs[1].excludedConnectionPointTypes.push(tl.Matrix),i._inputs[1].excludedConnectionPointTypes.push(tl.Vector2),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"CrossBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = cross("+this.left.associatedVariableName+".xyz, "+this.right.associatedVariableName+".xyz);\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.CrossBlock"]=mu;var gu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.Float),i._linkConnectionTypes(0,1),i._inputs[0].excludedConnectionPointTypes.push(tl.Float),i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i._inputs[1].excludedConnectionPointTypes.push(tl.Float),i._inputs[1].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DotBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = dot("+this.left.associatedVariableName+", "+this.right.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.DotBlock"]=gu;var vu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("input",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(tl.Float),i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"NormalizeBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=this._inputs[0];return t.compilationString+=this._declareOutput(i,t)+" = normalize("+n.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.NormalizeBlock"]=vu;var bu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("rgb ",tl.Color3,!0),i.registerInput("r",tl.Float,!0),i.registerInput("g",tl.Float,!0),i.registerInput("b",tl.Float,!0),i.registerInput("a",tl.Float,!0),i.registerOutput("rgba",tl.Color4),i.registerOutput("rgb",tl.Color3),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ColorMergerBlock"},Object.defineProperty(t.prototype,"rgbIn",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"r",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"g",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"b",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"a",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgba",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgbOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"rgb",{get:function(){return this.rgbOut},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.r,n=this.g,r=this.b,o=this.a,a=this.rgbIn,s=this._outputs[0],c=this._outputs[1];return a.isConnected?s.hasEndpoints?t.compilationString+=this._declareOutput(s,t)+" = vec4("+a.associatedVariableName+", "+(o.isConnected?this._writeVariable(o):"0.0")+");\r\n":c.hasEndpoints&&(t.compilationString+=this._declareOutput(c,t)+" = "+a.associatedVariableName+";\r\n"):s.hasEndpoints?t.compilationString+=this._declareOutput(s,t)+" = vec4("+(i.isConnected?this._writeVariable(i):"0.0")+", "+(n.isConnected?this._writeVariable(n):"0.0")+", "+(r.isConnected?this._writeVariable(r):"0.0")+", "+(o.isConnected?this._writeVariable(o):"0.0")+");\r\n":c.hasEndpoints&&(t.compilationString+=this._declareOutput(c,t)+" = vec3("+(i.isConnected?this._writeVariable(i):"0.0")+", "+(n.isConnected?this._writeVariable(n):"0.0")+", "+(r.isConnected?this._writeVariable(r):"0.0")+");\r\n"),this},t}(fl);c.a.RegisteredTypes["BABYLON.ColorMergerBlock"]=bu;var yu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("xyzw",tl.Vector4,!0),i.registerInput("xyz ",tl.Vector3,!0),i.registerInput("xy ",tl.Vector2,!0),i.registerOutput("xyz",tl.Vector3),i.registerOutput("xy",tl.Vector2),i.registerOutput("x",tl.Float),i.registerOutput("y",tl.Float),i.registerOutput("z",tl.Float),i.registerOutput("w",tl.Float),i.inputsAreExclusive=!0,i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VectorSplitterBlock"},Object.defineProperty(t.prototype,"xyzw",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzIn",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyIn",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyzOut",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"xyOut",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"z",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"w",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),t.prototype._inputRename=function(e){switch(e){case"xy ":return"xyIn";case"xyz ":return"xyzIn";default:return e}},t.prototype._outputRename=function(e){switch(e){case"xy":return"xyOut";case"xyz":return"xyzOut";default:return e}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this.xyzw.isConnected?this.xyzw:this.xyzIn.isConnected?this.xyzIn:this.xyIn,n=this._outputs[0],r=this._outputs[1],o=this._outputs[2],a=this._outputs[3],s=this._outputs[4],c=this._outputs[5];return n.hasEndpoints&&(i===this.xyIn?t.compilationString+=this._declareOutput(n,t)+" = vec3("+i.associatedVariableName+", 0.0);\r\n":t.compilationString+=this._declareOutput(n,t)+" = "+i.associatedVariableName+".xyz;\r\n"),r.hasEndpoints&&(t.compilationString+=this._declareOutput(r,t)+" = "+i.associatedVariableName+".xy;\r\n"),o.hasEndpoints&&(t.compilationString+=this._declareOutput(o,t)+" = "+i.associatedVariableName+".x;\r\n"),a.hasEndpoints&&(t.compilationString+=this._declareOutput(a,t)+" = "+i.associatedVariableName+".y;\r\n"),s.hasEndpoints&&(t.compilationString+=this._declareOutput(s,t)+" = "+i.associatedVariableName+".z;\r\n"),c.hasEndpoints&&(t.compilationString+=this._declareOutput(c,t)+" = "+i.associatedVariableName+".w;\r\n"),this},t}(fl);c.a.RegisteredTypes["BABYLON.VectorSplitterBlock"]=yu;var Tu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerInput("gradient",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._linkConnectionTypes(1,2,!0),i._inputs[2].acceptedConnectionPointTypes.push(tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"LerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = mix("+this.left.associatedVariableName+" , "+this.right.associatedVariableName+", "+this.gradient.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.LerpBlock"]=Tu;var Eu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DivideBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = "+this.left.associatedVariableName+" / "+this.right.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.DivideBlock"]=Eu;var Su=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"SubtractBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = "+this.left.associatedVariableName+" - "+this.right.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.SubtractBlock"]=Su;var Au=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("value",tl.Float),i.registerInput("edge",tl.Float),i.registerOutput("output",tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = step("+this.edge.associatedVariableName+", "+this.value.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.StepBlock"]=Au;var Pu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("input",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._outputs[0].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"OneMinusBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = 1. - "+this.input.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.OneMinusBlock"]=Pu,c.a.RegisteredTypes["BABYLON.OppositeBlock"]=Pu;var Cu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("worldPosition",tl.Vector4),i.registerInput("cameraPosition",tl.Vector3),i.registerOutput("output",tl.Vector3),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ViewDirectionBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.cameraPosition.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.CameraPosition}));t||(t=new Sl("cameraPosition")).setAsSystemValue(nl.CameraPosition),t.output.connectTo(this.cameraPosition)}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = normalize("+this.cameraPosition.associatedVariableName+" - "+this.worldPosition.associatedVariableName+".xyz);\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ViewDirectionBlock"]=Cu;i(161);var Ru=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("worldNormal",tl.Vector4),i.registerInput("viewDirection",tl.Vector3),i.registerInput("bias",tl.Float),i.registerInput("power",tl.Float),i.registerOutput("fresnel",tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FresnelBlock"},Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"viewDirection",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bias",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"power",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fresnel",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.viewDirection.isConnected){var t=new Cu("View direction");t.output.connectTo(this.viewDirection),t.autoConfigure(e)}if(!this.bias.isConnected){var i=new Sl("bias");i.value=0,i.output.connectTo(this.bias)}if(!this.power.isConnected){var n=new Sl("power");n.value=1,n.output.connectTo(this.power)}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i="//"+this.name;return t._emitFunctionFromInclude("fresnelFunction",i,{removeIfDef:!0}),t.compilationString+=this._declareOutput(this.fresnel,t)+" = computeFresnelTerm("+this.viewDirection.associatedVariableName+".xyz, "+this.worldNormal.associatedVariableName+".xyz, "+this.bias.associatedVariableName+", "+this.power.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.FresnelBlock"]=Ru;var xu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"MaxBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = max("+this.left.associatedVariableName+", "+this.right.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.MaxBlock"]=xu;var Ou=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"MinBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = min("+this.left.associatedVariableName+", "+this.right.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.MinBlock"]=Ou;var Mu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.Float),i._linkConnectionTypes(0,1),i._inputs[0].excludedConnectionPointTypes.push(tl.Float),i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i._inputs[1].excludedConnectionPointTypes.push(tl.Float),i._inputs[1].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DistanceBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = length("+this.left.associatedVariableName+" - "+this.right.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.DistanceBlock"]=Mu;var Iu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("value",tl.AutoDetect),i.registerOutput("output",tl.Float),i._inputs[0].excludedConnectionPointTypes.push(tl.Float),i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"LengthBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = length("+this.value.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.LengthBlock"]=Iu;var Du=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("value",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"NegateBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = -1.0 * "+this.value.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.NegateBlock"]=Du;var Nu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("value",tl.AutoDetect),i.registerInput("power",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"PowBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"power",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = pow("+this.value.associatedVariableName+", "+this.power.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.PowBlock"]=Nu;var Lu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("seed",tl.Vector2),i.registerOutput("output",tl.Float),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"RandomNumberBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n="//"+this.name;return t._emitFunctionFromInclude("helperFunctions",n),t.compilationString+=this._declareOutput(i,t)+" = getRand("+this.seed.associatedVariableName+".xy);\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.RandomNumberBlock"]=Lu;var wu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("x",tl.Float),i.registerInput("y",tl.Float),i.registerOutput("output",tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ArcTan2Block"},Object.defineProperty(t.prototype,"x",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = atan("+this.x.associatedVariableName+", "+this.y.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ArcTan2Block"]=wu;var Fu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("value",tl.AutoDetect),i.registerInput("edge0",tl.Float),i.registerInput("edge1",tl.Float),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"SmoothStepBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge0",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edge1",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = smoothstep("+this.edge0.associatedVariableName+", "+this.edge1.associatedVariableName+", "+this.value.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.SmoothStepBlock"]=Fu;var Bu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("input",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._outputs[0].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ReciprocalBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = 1. / "+this.input.associatedVariableName+";\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ReciprocalBlock"]=Bu;var Uu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("value",tl.AutoDetect),i.registerInput("reference",tl.AutoDetect),i.registerInput("distance",tl.Float),i.registerInput("replacement",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._linkConnectionTypes(0,3),i._inputs[0].excludedConnectionPointTypes.push(tl.Float),i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i._inputs[1].excludedConnectionPointTypes.push(tl.Float),i._inputs[1].excludedConnectionPointTypes.push(tl.Matrix),i._inputs[3].excludedConnectionPointTypes.push(tl.Float),i._inputs[3].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ReplaceColorBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reference",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"distance",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"replacement",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+";\r\n",t.compilationString+="if (length("+this.value.associatedVariableName+" - "+this.reference.associatedVariableName+") < "+this.distance.associatedVariableName+") {\r\n",t.compilationString+=i.associatedVariableName+" = "+this.replacement.associatedVariableName+";\r\n",t.compilationString+="} else {\r\n",t.compilationString+=i.associatedVariableName+" = "+this.value.associatedVariableName+";\r\n",t.compilationString+="}\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ReplaceColorBlock"]=Uu;var Vu,ku=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("value",tl.AutoDetect),i.registerInput("steps",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i._inputs[1].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"PosterizeBlock"},Object.defineProperty(t.prototype,"value",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"steps",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = floor("+this.value.associatedVariableName+" / (1.0 / "+this.steps.associatedVariableName+")) * (1.0 / "+this.steps.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.PosterizeBlock"]=ku,function(e){e[e.SawTooth=0]="SawTooth",e[e.Square=1]="Square",e[e.Triangle=2]="Triangle"}(Vu||(Vu={}));var zu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.kind=Vu.SawTooth,i.registerInput("input",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._inputs[0].excludedConnectionPointTypes.push(tl.Matrix),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"WaveBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];switch(this.kind){case Vu.SawTooth:t.compilationString+=this._declareOutput(i,t)+" = "+this.input.associatedVariableName+" - floor(0.5 + "+this.input.associatedVariableName+");\r\n";break;case Vu.Square:t.compilationString+=this._declareOutput(i,t)+" = 1.0 - 2.0 * round(fract("+this.input.associatedVariableName+"));\r\n";break;case Vu.Triangle:t.compilationString+=this._declareOutput(i,t)+" = 2.0 * abs(2.0 * ("+this.input.associatedVariableName+" - floor(0.5 + "+this.input.associatedVariableName+"))) - 1.0;\r\n"}return this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.kind=this.kind,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.kind=t.kind},t}(fl);c.a.RegisteredTypes["BABYLON.WaveBlock"]=zu;var Gu=function(){function e(e,t){this.step=e,this.color=t}return Object.defineProperty(e.prototype,"step",{get:function(){return this._step},set:function(e){this._step=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){return this._color},set:function(e){this._color=e},enumerable:!1,configurable:!0}),e}(),ju=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.colorSteps=[new Gu(0,s.a.Black()),new Gu(1,s.a.White())],i.onValueChangedObservable=new o.c,i.registerInput("gradient",tl.Float),i.registerOutput("output",tl.Color3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector2),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color4),i}return Object(h.d)(t,e),t.prototype.colorStepsUpdated=function(){this.onValueChangedObservable.notifyObservers(this)},t.prototype.getClassName=function(){return"GradientBlock"},Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._writeColorConstant=function(e){var t=this.colorSteps[e];return"vec3("+t.color.r+", "+t.color.g+", "+t.color.b+")"},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];if(this.colorSteps.length&&this.gradient.connectedPoint){var n=t._getFreeVariableName("gradientTempColor"),r=t._getFreeVariableName("gradientTempPosition");t.compilationString+="vec3 "+n+" = "+this._writeColorConstant(0)+";\r\n",t.compilationString+="float "+r+";\r\n";var o=this.gradient.associatedVariableName;this.gradient.connectedPoint.type!==tl.Float&&(o+=".x");for(var a=1;a<this.colorSteps.length;a++){var s=this.colorSteps[a],c=this.colorSteps[a-1];t.compilationString+=r+" = clamp(("+o+" - "+t._emitFloat(c.step)+") / ("+t._emitFloat(s.step)+" - "+t._emitFloat(c.step)+"), 0.0, 1.0) * step("+t._emitFloat(a)+", "+t._emitFloat(this.colorSteps.length-1)+");\r\n",t.compilationString+=n+" = mix("+n+", "+this._writeColorConstant(a)+", "+r+");\r\n"}return t.compilationString+=this._declareOutput(i,t)+" = "+n+";\r\n",this}t.compilationString+=this._declareOutput(i,t)+" = vec3(0., 0., 0.);\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);t.colorSteps=[];for(var i=0,n=this.colorSteps;i<n.length;i++){var r=n[i];t.colorSteps.push({step:r.step,color:{r:r.color.r,g:r.color.g,b:r.color.b}})}return t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.colorSteps=[];for(var r=0,o=t.colorSteps;r<o.length;r++){var a=o[r];this.colorSteps.push(new Gu(a.step,new s.a(a.color.r,a.color.g,a.color.b)))}},t.prototype._dumpPropertiesCode=function(){for(var e="",t=0,i=this.colorSteps;t<i.length;t++){var n=i[t];e+=this._codeVariableName+".colorSteps.push(new BABYLON.GradientBlockColorStep("+n.step+", new BABYLON.Color3("+n.color.r+", "+n.color.g+", "+n.color.b+")));\r\n"}return e},t}(fl);c.a.RegisteredTypes["BABYLON.GradientBlock"]=ju;var Wu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerInput("gradient",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i._linkConnectionTypes(1,2,!0),i._inputs[2].acceptedConnectionPointTypes.push(tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"NLerpBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"gradient",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = normalize(mix("+this.left.associatedVariableName+" , "+this.right.associatedVariableName+", "+this.gradient.associatedVariableName+"));\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.NLerpBlock"]=Wu;var Hu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.manhattanDistance=!1,i.registerInput("seed",tl.Vector3),i.registerInput("jitter",tl.Float),i.registerOutput("output",tl.Vector2),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"WorleyNoise3DBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"jitter",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),this.seed.isConnected&&this._outputs[0].hasEndpoints){return" return mod((34.0 * x + 1.0) * x, 289.0);\r\n","}\r\n\r\n","vec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r\n"," return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r\n","}\r\n\r\n","vec2 worley(vec3 P, float jitter, bool manhattanDistance){\r\n"," float K = 0.142857142857; // 1/7\r\n"," float Ko = 0.428571428571; // 1/2-K/2\r\n"," float K2 = 0.020408163265306; // 1/(7*7)\r\n"," float Kz = 0.166666666667; // 1/6\r\n"," float Kzo = 0.416666666667; // 1/2-1/6*2\r\n","\r\n"," vec3 Pi = mod(floor(P), 289.0);\r\n"," vec3 Pf = fract(P) - 0.5;\r\n","\r\n"," vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r\n"," vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r\n"," vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r\n","\r\n"," vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r\n"," vec3 p1 = permute(p + Pi.y - 1.0);\r\n"," vec3 p2 = permute(p + Pi.y);\r\n"," vec3 p3 = permute(p + Pi.y + 1.0);\r\n","\r\n"," vec3 p11 = permute(p1 + Pi.z - 1.0);\r\n"," vec3 p12 = permute(p1 + Pi.z);\r\n"," vec3 p13 = permute(p1 + Pi.z + 1.0);\r\n","\r\n"," vec3 p21 = permute(p2 + Pi.z - 1.0);\r\n"," vec3 p22 = permute(p2 + Pi.z);\r\n"," vec3 p23 = permute(p2 + Pi.z + 1.0);\r\n","\r\n"," vec3 p31 = permute(p3 + Pi.z - 1.0);\r\n"," vec3 p32 = permute(p3 + Pi.z);\r\n"," vec3 p33 = permute(p3 + Pi.z + 1.0);\r\n","\r\n"," vec3 ox11 = fract(p11*K) - Ko;\r\n"," vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r\n"," vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r\n","\r\n"," vec3 ox12 = fract(p12*K) - Ko;\r\n"," vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r\n"," vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r\n","\r\n"," vec3 ox13 = fract(p13*K) - Ko;\r\n"," vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r\n"," vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r\n","\r\n"," vec3 ox21 = fract(p21*K) - Ko;\r\n"," vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r\n"," vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r\n","\r\n"," vec3 ox22 = fract(p22*K) - Ko;\r\n"," vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r\n"," vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r\n","\r\n"," vec3 ox23 = fract(p23*K) - Ko;\r\n"," vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r\n"," vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r\n","\r\n"," vec3 ox31 = fract(p31*K) - Ko;\r\n"," vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r\n"," vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r\n","\r\n"," vec3 ox32 = fract(p32*K) - Ko;\r\n"," vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r\n"," vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r\n","\r\n"," vec3 ox33 = fract(p33*K) - Ko;\r\n"," vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r\n"," vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r\n","\r\n"," vec3 dx11 = Pfx + jitter*ox11;\r\n"," vec3 dy11 = Pfy.x + jitter*oy11;\r\n"," vec3 dz11 = Pfz.x + jitter*oz11;\r\n","\r\n"," vec3 dx12 = Pfx + jitter*ox12;\r\n"," vec3 dy12 = Pfy.x + jitter*oy12;\r\n"," vec3 dz12 = Pfz.y + jitter*oz12;\r\n","\r\n"," vec3 dx13 = Pfx + jitter*ox13;\r\n"," vec3 dy13 = Pfy.x + jitter*oy13;\r\n"," vec3 dz13 = Pfz.z + jitter*oz13;\r\n","\r\n"," vec3 dx21 = Pfx + jitter*ox21;\r\n"," vec3 dy21 = Pfy.y + jitter*oy21;\r\n"," vec3 dz21 = Pfz.x + jitter*oz21;\r\n","\r\n"," vec3 dx22 = Pfx + jitter*ox22;\r\n"," vec3 dy22 = Pfy.y + jitter*oy22;\r\n"," vec3 dz22 = Pfz.y + jitter*oz22;\r\n","\r\n"," vec3 dx23 = Pfx + jitter*ox23;\r\n"," vec3 dy23 = Pfy.y + jitter*oy23;\r\n"," vec3 dz23 = Pfz.z + jitter*oz23;\r\n","\r\n"," vec3 dx31 = Pfx + jitter*ox31;\r\n"," vec3 dy31 = Pfy.z + jitter*oy31;\r\n"," vec3 dz31 = Pfz.x + jitter*oz31;\r\n","\r\n"," vec3 dx32 = Pfx + jitter*ox32;\r\n"," vec3 dy32 = Pfy.z + jitter*oy32;\r\n"," vec3 dz32 = Pfz.y + jitter*oz32;\r\n","\r\n"," vec3 dx33 = Pfx + jitter*ox33;\r\n"," vec3 dy33 = Pfy.z + jitter*oy33;\r\n"," vec3 dz33 = Pfz.z + jitter*oz33;\r\n","\r\n"," vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r\n"," vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r\n"," vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r\n"," vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r\n"," vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r\n"," vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r\n"," vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r\n"," vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r\n"," vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r\n","\r\n"," vec3 d1a = min(d11, d12);\r\n"," d12 = max(d11, d12);\r\n"," d11 = min(d1a, d13); // Smallest now not in d12 or d13\r\n"," d13 = max(d1a, d13);\r\n"," d12 = min(d12, d13); // 2nd smallest now not in d13\r\n"," vec3 d2a = min(d21, d22);\r\n"," d22 = max(d21, d22);\r\n"," d21 = min(d2a, d23); // Smallest now not in d22 or d23\r\n"," d23 = max(d2a, d23);\r\n"," d22 = min(d22, d23); // 2nd smallest now not in d23\r\n"," vec3 d3a = min(d31, d32);\r\n"," d32 = max(d31, d32);\r\n"," d31 = min(d3a, d33); // Smallest now not in d32 or d33\r\n"," d33 = max(d3a, d33);\r\n"," d32 = min(d32, d33); // 2nd smallest now not in d33\r\n"," vec3 da = min(d11, d21);\r\n"," d21 = max(d11, d21);\r\n"," d11 = min(da, d31); // Smallest now in d11\r\n"," d31 = max(da, d31); // 2nd smallest now not in d31\r\n"," d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r\n"," d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r\n"," d12 = min(d12, d21); // 2nd smallest now not in d21\r\n"," d12 = min(d12, d22); // nor in d22\r\n"," d12 = min(d12, d31); // nor in d31\r\n"," d12 = min(d12, d32); // nor in d32\r\n"," d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r\n"," d11.y = min(d11.y,d12.z); // Only two more to go\r\n"," d11.y = min(d11.y,d11.z); // Done! (Phew!)\r\n"," return sqrt(d11.xy); // F1, F2\r\n","}\r\n\r\n",t._emitFunction("worley3D","vec3 permute(vec3 x){\r\n return mod((34.0 * x + 1.0) * x, 289.0);\r\n}\r\n\r\nvec3 dist(vec3 x, vec3 y, vec3 z, bool manhattanDistance){\r\n return manhattanDistance ? abs(x) + abs(y) + abs(z) : (x * x + y * y + z * z);\r\n}\r\n\r\nvec2 worley(vec3 P, float jitter, bool manhattanDistance){\r\n float K = 0.142857142857; // 1/7\r\n float Ko = 0.428571428571; // 1/2-K/2\r\n float K2 = 0.020408163265306; // 1/(7*7)\r\n float Kz = 0.166666666667; // 1/6\r\n float Kzo = 0.416666666667; // 1/2-1/6*2\r\n\r\n vec3 Pi = mod(floor(P), 289.0);\r\n vec3 Pf = fract(P) - 0.5;\r\n\r\n vec3 Pfx = Pf.x + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfy = Pf.y + vec3(1.0, 0.0, -1.0);\r\n vec3 Pfz = Pf.z + vec3(1.0, 0.0, -1.0);\r\n\r\n vec3 p = permute(Pi.x + vec3(-1.0, 0.0, 1.0));\r\n vec3 p1 = permute(p + Pi.y - 1.0);\r\n vec3 p2 = permute(p + Pi.y);\r\n vec3 p3 = permute(p + Pi.y + 1.0);\r\n\r\n vec3 p11 = permute(p1 + Pi.z - 1.0);\r\n vec3 p12 = permute(p1 + Pi.z);\r\n vec3 p13 = permute(p1 + Pi.z + 1.0);\r\n\r\n vec3 p21 = permute(p2 + Pi.z - 1.0);\r\n vec3 p22 = permute(p2 + Pi.z);\r\n vec3 p23 = permute(p2 + Pi.z + 1.0);\r\n\r\n vec3 p31 = permute(p3 + Pi.z - 1.0);\r\n vec3 p32 = permute(p3 + Pi.z);\r\n vec3 p33 = permute(p3 + Pi.z + 1.0);\r\n\r\n vec3 ox11 = fract(p11*K) - Ko;\r\n vec3 oy11 = mod(floor(p11*K), 7.0)*K - Ko;\r\n vec3 oz11 = floor(p11*K2)*Kz - Kzo; // p11 < 289 guaranteed\r\n\r\n vec3 ox12 = fract(p12*K) - Ko;\r\n vec3 oy12 = mod(floor(p12*K), 7.0)*K - Ko;\r\n vec3 oz12 = floor(p12*K2)*Kz - Kzo;\r\n\r\n vec3 ox13 = fract(p13*K) - Ko;\r\n vec3 oy13 = mod(floor(p13*K), 7.0)*K - Ko;\r\n vec3 oz13 = floor(p13*K2)*Kz - Kzo;\r\n\r\n vec3 ox21 = fract(p21*K) - Ko;\r\n vec3 oy21 = mod(floor(p21*K), 7.0)*K - Ko;\r\n vec3 oz21 = floor(p21*K2)*Kz - Kzo;\r\n\r\n vec3 ox22 = fract(p22*K) - Ko;\r\n vec3 oy22 = mod(floor(p22*K), 7.0)*K - Ko;\r\n vec3 oz22 = floor(p22*K2)*Kz - Kzo;\r\n\r\n vec3 ox23 = fract(p23*K) - Ko;\r\n vec3 oy23 = mod(floor(p23*K), 7.0)*K - Ko;\r\n vec3 oz23 = floor(p23*K2)*Kz - Kzo;\r\n\r\n vec3 ox31 = fract(p31*K) - Ko;\r\n vec3 oy31 = mod(floor(p31*K), 7.0)*K - Ko;\r\n vec3 oz31 = floor(p31*K2)*Kz - Kzo;\r\n\r\n vec3 ox32 = fract(p32*K) - Ko;\r\n vec3 oy32 = mod(floor(p32*K), 7.0)*K - Ko;\r\n vec3 oz32 = floor(p32*K2)*Kz - Kzo;\r\n\r\n vec3 ox33 = fract(p33*K) - Ko;\r\n vec3 oy33 = mod(floor(p33*K), 7.0)*K - Ko;\r\n vec3 oz33 = floor(p33*K2)*Kz - Kzo;\r\n\r\n vec3 dx11 = Pfx + jitter*ox11;\r\n vec3 dy11 = Pfy.x + jitter*oy11;\r\n vec3 dz11 = Pfz.x + jitter*oz11;\r\n\r\n vec3 dx12 = Pfx + jitter*ox12;\r\n vec3 dy12 = Pfy.x + jitter*oy12;\r\n vec3 dz12 = Pfz.y + jitter*oz12;\r\n\r\n vec3 dx13 = Pfx + jitter*ox13;\r\n vec3 dy13 = Pfy.x + jitter*oy13;\r\n vec3 dz13 = Pfz.z + jitter*oz13;\r\n\r\n vec3 dx21 = Pfx + jitter*ox21;\r\n vec3 dy21 = Pfy.y + jitter*oy21;\r\n vec3 dz21 = Pfz.x + jitter*oz21;\r\n\r\n vec3 dx22 = Pfx + jitter*ox22;\r\n vec3 dy22 = Pfy.y + jitter*oy22;\r\n vec3 dz22 = Pfz.y + jitter*oz22;\r\n\r\n vec3 dx23 = Pfx + jitter*ox23;\r\n vec3 dy23 = Pfy.y + jitter*oy23;\r\n vec3 dz23 = Pfz.z + jitter*oz23;\r\n\r\n vec3 dx31 = Pfx + jitter*ox31;\r\n vec3 dy31 = Pfy.z + jitter*oy31;\r\n vec3 dz31 = Pfz.x + jitter*oz31;\r\n\r\n vec3 dx32 = Pfx + jitter*ox32;\r\n vec3 dy32 = Pfy.z + jitter*oy32;\r\n vec3 dz32 = Pfz.y + jitter*oz32;\r\n\r\n vec3 dx33 = Pfx + jitter*ox33;\r\n vec3 dy33 = Pfy.z + jitter*oy33;\r\n vec3 dz33 = Pfz.z + jitter*oz33;\r\n\r\n vec3 d11 = dist(dx11, dy11, dz11, manhattanDistance);\r\n vec3 d12 =dist(dx12, dy12, dz12, manhattanDistance);\r\n vec3 d13 = dist(dx13, dy13, dz13, manhattanDistance);\r\n vec3 d21 = dist(dx21, dy21, dz21, manhattanDistance);\r\n vec3 d22 = dist(dx22, dy22, dz22, manhattanDistance);\r\n vec3 d23 = dist(dx23, dy23, dz23, manhattanDistance);\r\n vec3 d31 = dist(dx31, dy31, dz31, manhattanDistance);\r\n vec3 d32 = dist(dx32, dy32, dz32, manhattanDistance);\r\n vec3 d33 = dist(dx33, dy33, dz33, manhattanDistance);\r\n\r\n vec3 d1a = min(d11, d12);\r\n d12 = max(d11, d12);\r\n d11 = min(d1a, d13); // Smallest now not in d12 or d13\r\n d13 = max(d1a, d13);\r\n d12 = min(d12, d13); // 2nd smallest now not in d13\r\n vec3 d2a = min(d21, d22);\r\n d22 = max(d21, d22);\r\n d21 = min(d2a, d23); // Smallest now not in d22 or d23\r\n d23 = max(d2a, d23);\r\n d22 = min(d22, d23); // 2nd smallest now not in d23\r\n vec3 d3a = min(d31, d32);\r\n d32 = max(d31, d32);\r\n d31 = min(d3a, d33); // Smallest now not in d32 or d33\r\n d33 = max(d3a, d33);\r\n d32 = min(d32, d33); // 2nd smallest now not in d33\r\n vec3 da = min(d11, d21);\r\n d21 = max(d11, d21);\r\n d11 = min(da, d31); // Smallest now in d11\r\n d31 = max(da, d31); // 2nd smallest now not in d31\r\n d11.xy = (d11.x < d11.y) ? d11.xy : d11.yx;\r\n d11.xz = (d11.x < d11.z) ? d11.xz : d11.zx; // d11.x now smallest\r\n d12 = min(d12, d21); // 2nd smallest now not in d21\r\n d12 = min(d12, d22); // nor in d22\r\n d12 = min(d12, d31); // nor in d31\r\n d12 = min(d12, d32); // nor in d32\r\n d11.yz = min(d11.yz,d12.xy); // nor in d12.yz\r\n d11.y = min(d11.y,d12.z); // Only two more to go\r\n d11.y = min(d11.y,d11.z); // Done! (Phew!)\r\n return sqrt(d11.xy); // F1, F2\r\n}\r\n\r\n","// Worley3D"),t.compilationString+=this._declareOutput(this._outputs[0],t)+" = worley("+this.seed.associatedVariableName+", "+this.jitter.associatedVariableName+", "+this.manhattanDistance+");\r\n",this}},t.prototype._dumpPropertiesCode=function(){return this._codeVariableName+".manhattanDistance = "+this.manhattanDistance+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.manhattanDistance=this.manhattanDistance,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.manhattanDistance=t.manhattanDistance},Object(h.c)([Ml("Use Manhattan Distance",xl.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"manhattanDistance",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.WorleyNoise3DBlock"]=Hu;var Xu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("seed",tl.Vector3),i.registerOutput("output",tl.Float),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"SimplexPerlin3DBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),this.seed.isConnected&&this._outputs[0].hasEndpoints){return"const float UNSKEWFACTOR = 1.0/6.0;\r\n","const float SIMPLEX_CORNER_POS = 0.5;\r\n","const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r\n","float SimplexPerlin3D( vec3 P ){\r\n"," P *= SIMPLEX_TETRAHADRON_HEIGHT;\r\n"," vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );"," vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r\n"," vec3 g = step(x0.yzx, x0.xyz);\r\n"," vec3 l = 1.0 - g;\r\n"," vec3 Pi_1 = min( g.xyz, l.zxy );\r\n"," vec3 Pi_2 = max( g.xyz, l.zxy );\r\n"," vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r\n"," vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r\n"," vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r\n"," vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r\n"," vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r\n"," vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r\n"," Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r\n"," vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r\n"," vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r\n"," Pt *= Pt;\r\n"," vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r\n"," Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r\n"," const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r\n"," const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r\n"," vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r\n"," vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r\n"," Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r\n"," Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r\n"," vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r\n"," vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r\n"," vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r\n"," vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\r\n"," const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r\n"," vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r\n"," kernel_weights = max(0.5 - kernel_weights, 0.0);\r\n"," kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r\n"," return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r\n","}\r\n",t._emitFunction("SimplexPerlin3D","const float SKEWFACTOR = 1.0/3.0;\r\nconst float UNSKEWFACTOR = 1.0/6.0;\r\nconst float SIMPLEX_CORNER_POS = 0.5;\r\nconst float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r\nfloat SimplexPerlin3D( vec3 P ){\r\n P *= SIMPLEX_TETRAHADRON_HEIGHT;\r\n vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) ); vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r\n vec3 g = step(x0.yzx, x0.xyz);\r\n vec3 l = 1.0 - g;\r\n vec3 Pi_1 = min( g.xyz, l.zxy );\r\n vec3 Pi_2 = max( g.xyz, l.zxy );\r\n vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r\n vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r\n vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r\n vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r\n vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r\n vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r\n Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r\n vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r\n vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r\n Pt *= Pt;\r\n vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r\n Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r\n const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r\n const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r\n vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r\n vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r\n Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r\n Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r\n vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r\n vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r\n vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r\n vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\r\n const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r\n vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r\n kernel_weights = max(0.5 - kernel_weights, 0.0);\r\n kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r\n return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r\n}\r\n","// SimplexPerlin3D"),t.compilationString+=this._declareOutput(this._outputs[0],t)+" = SimplexPerlin3D("+this.seed.associatedVariableName+");\r\n",this}},t}(fl);c.a.RegisteredTypes["BABYLON.SimplexPerlin3DBlock"]=Xu;var Yu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("normalMap0",tl.Vector3),i.registerInput("normalMap1",tl.Vector3),i.registerOutput("output",tl.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color4),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[1].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[1].acceptedConnectionPointTypes.push(tl.Color4),i._inputs[1].acceptedConnectionPointTypes.push(tl.Vector4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"NormalBlendBlock"},Object.defineProperty(t.prototype,"normalMap0",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMap1",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=this._inputs[0],r=this._inputs[1],o=t._getFreeVariableName("stepR"),a=t._getFreeVariableName("stepG");return t.compilationString+="float "+o+" = step(0.5, "+n.associatedVariableName+".r);\r\n",t.compilationString+="float "+a+" = step(0.5, "+n.associatedVariableName+".g);\r\n",t.compilationString+=this._declareOutput(i,t)+";\r\n",t.compilationString+=i.associatedVariableName+".r = (1.0 - "+o+") * "+n.associatedVariableName+".r * "+r.associatedVariableName+".r * 2.0 + "+o+" * (1.0 - "+n.associatedVariableName+".r) * (1.0 - "+r.associatedVariableName+".r) * 2.0;\r\n",t.compilationString+=i.associatedVariableName+".g = (1.0 - "+a+") * "+n.associatedVariableName+".g * "+r.associatedVariableName+".g * 2.0 + "+a+" * (1.0 - "+n.associatedVariableName+".g) * (1.0 - "+r.associatedVariableName+".g) * 2.0;\r\n",t.compilationString+=i.associatedVariableName+".b = "+n.associatedVariableName+".b * "+r.associatedVariableName+".b;\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.NormalBlendBlock"]=Yu;var Ku=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("input",tl.Vector2),i.registerInput("angle",tl.Float),i.registerOutput("output",tl.Vector2),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"Rotate2dBlock"},Object.defineProperty(t.prototype,"input",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"angle",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.angle.isConnected){var t=new Sl("angle");t.value=0,t.output.connectTo(this.angle)}},t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=this.angle,r=this.input;return t.compilationString+=this._declareOutput(i,t)+" = vec2(cos("+n.associatedVariableName+") * "+r.associatedVariableName+".x - sin("+n.associatedVariableName+") * "+r.associatedVariableName+".y, sin("+n.associatedVariableName+") * "+r.associatedVariableName+".x + cos("+n.associatedVariableName+") * "+r.associatedVariableName+".y);\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.Rotate2dBlock"]=Ku;var Qu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("incident",tl.Vector3),i.registerInput("normal",tl.Vector3),i.registerOutput("output",tl.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color4),i._inputs[1].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[1].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[1].acceptedConnectionPointTypes.push(tl.Color4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ReflectBlock"},Object.defineProperty(t.prototype,"incident",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = reflect("+this.incident.associatedVariableName+".xyz, "+this.normal.associatedVariableName+".xyz);\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ReflectBlock"]=Qu;var qu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("incident",tl.Vector3),i.registerInput("normal",tl.Vector3),i.registerInput("ior",tl.Float),i.registerOutput("output",tl.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[0].acceptedConnectionPointTypes.push(tl.Color4),i._inputs[1].acceptedConnectionPointTypes.push(tl.Vector4),i._inputs[1].acceptedConnectionPointTypes.push(tl.Color3),i._inputs[1].acceptedConnectionPointTypes.push(tl.Color4),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"RefractBlock"},Object.defineProperty(t.prototype,"incident",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ior",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = refract("+this.incident.associatedVariableName+".xyz, "+this.normal.associatedVariableName+".xyz, "+this.ior.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.RefractBlock"]=qu;var Zu=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("color",tl.Color3),i.registerInput("level",tl.Float),i.registerOutput("output",tl.Color3),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DesaturateBlock"},Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"level",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0],n=this.color.associatedVariableName,r=t._getFreeVariableName("colorMin"),o=t._getFreeVariableName("colorMax"),a=t._getFreeVariableName("colorMerge");return t.compilationString+="float "+r+" = min(min("+n+".x, "+n+".y), "+n+".z);\r\n",t.compilationString+="float "+o+" = max(max("+n+".x, "+n+".y), "+n+".z);\r\n",t.compilationString+="float "+a+" = 0.5 * ("+r+" + "+o+");\r\n",t.compilationString+=this._declareOutput(i,t)+" = mix("+n+", vec3("+a+", "+a+", "+a+"), "+this.level.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.DesaturateBlock"]=Zu;var Ju=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,i,n)||this;return s._blockType=r,s._blockName=o,s._nameForCheking=a,s._nameForCheking||(s._nameForCheking=t),s.needDualDirectionValidation=!0,s}return Object(h.d)(t,e),t.prototype.checkCompatibilityState=function(e){return e instanceof t&&e.name===this._nameForCheking?ol.Compatible:ol.TypeIncompatible},t.prototype.createCustomInputBlock=function(){return[new this._blockType(this._blockName),this.name]},t}(hl),$u=function(e){function t(i){var n=e.call(this,i,el.Fragment)||this;return n.albedoScaling=!1,n.linkSheenWithAlbedo=!1,n._isUnique=!0,n.registerInput("intensity",tl.Float,!0,el.Fragment),n.registerInput("color",tl.Color3,!0,el.Fragment),n.registerInput("roughness",tl.Float,!0,el.Fragment),n.registerOutput("sheen",tl.Object,el.Fragment,new Ju("sheen",n,al.Output,t,"SheenBlock")),n}return Object(h.d)(t,e),t.prototype.initialize=function(e){e._excludeVariableName("sheenOut"),e._excludeVariableName("sheenMapData"),e._excludeVariableName("vSheenColor"),e._excludeVariableName("vSheenRoughness")},t.prototype.getClassName=function(){return"SheenBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheen",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.prepareDefines=function(t,i,n){e.prototype.prepareDefines.call(this,t,i,n),n.setValue("SHEEN",!0),n.setValue("SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE",!0,!0),n.setValue("SHEEN_LINKWITHALBEDO",this.linkSheenWithAlbedo,!0),n.setValue("SHEEN_ROUGHNESS",this.roughness.isConnected,!0),n.setValue("SHEEN_ALBEDOSCALING",this.albedoScaling,!0)},t.prototype.getCode=function(e){return"#ifdef SHEEN\n sheenOutParams sheenOut;\n\n vec4 vSheenColor = vec4("+(this.color.isConnected?this.color.associatedVariableName:"vec3(1.)")+", "+(this.intensity.isConnected?this.intensity.associatedVariableName:"1.")+");\n\n sheenBlock(\n vSheenColor,\n #ifdef SHEEN_ROUGHNESS\n "+(this.roughness.isConnected?this.roughness.associatedVariableName:"0.")+",\n #endif\n roughness,\n #ifdef SHEEN_TEXTURE\n vec4(0.),\n #endif\n reflectance,\n #ifdef SHEEN_LINKWITHALBEDO\n baseColor,\n surfaceAlbedo,\n #endif\n #ifdef ENVIRONMENTBRDF\n NdotV,\n environmentBrdf,\n #endif\n #if defined(REFLECTION) && defined(ENVIRONMENTBRDF)\n AARoughnessFactors,\n "+(null==e?void 0:e._vReflectionMicrosurfaceInfosName)+",\n "+(null==e?void 0:e._vReflectionInfosName)+",\n "+(null==e?void 0:e.reflectionColor)+",\n vLightingIntensity,\n #ifdef "+(null==e?void 0:e._define3DName)+"\n "+(null==e?void 0:e._cubeSamplerName)+",\n #else\n "+(null==e?void 0:e._2DSamplerName)+",\n #endif\n reflectionOut.reflectionCoords,\n NdotVUnclamped,\n #ifndef LODBASEDMICROSFURACE\n #ifdef "+(null==e?void 0:e._define3DName)+"\n "+(null==e?void 0:e._cubeSamplerName)+",\n "+(null==e?void 0:e._cubeSamplerName)+",\n #else\n "+(null==e?void 0:e._2DSamplerName)+",\n "+(null==e?void 0:e._2DSamplerName)+",\n #endif\n #endif\n #if !defined("+(null==e?void 0:e._defineSkyboxName)+") && defined(RADIANCEOCCLUSION)\n seo,\n #endif\n #if !defined("+(null==e?void 0:e._defineSkyboxName)+") && defined(HORIZONOCCLUSION) && defined(BUMP) && defined("+(null==e?void 0:e._define3DName)+")\n eho,\n #endif\n #endif\n sheenOut\n );\n\n #ifdef SHEEN_LINKWITHALBEDO\n surfaceAlbedo = sheenOut.surfaceAlbedo;\n #endif\n #endif\r\n"},t.prototype._buildBlock=function(e){return e.target===el.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return t+=this._codeVariableName+".albedoScaling = "+this.albedoScaling+";\r\n",t+=this._codeVariableName+".linkSheenWithAlbedo = "+this.linkSheenWithAlbedo+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.albedoScaling=this.albedoScaling,t.linkSheenWithAlbedo=this.linkSheenWithAlbedo,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.albedoScaling=t.albedoScaling,this.linkSheenWithAlbedo=t.linkSheenWithAlbedo},Object(h.c)([Ml("Albedo scaling",xl.Boolean,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"albedoScaling",void 0),Object(h.c)([Ml("Link sheen with albedo",xl.Boolean,"PROPERTIES",{notifiers:{update:!0}})],t.prototype,"linkSheenWithAlbedo",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.SheenBlock"]=$u;var eh=function(e){function t(i){var n=e.call(this,i,el.Fragment)||this;return n._isUnique=!0,n.registerInput("intensity",tl.Float,!0,el.Fragment),n.registerInput("direction",tl.Vector2,!0,el.Fragment),n.registerInput("uv",tl.Vector2,!0),n.registerInput("worldTangent",tl.Vector4,!0),n.registerOutput("anisotropy",tl.Object,el.Fragment,new Ju("anisotropy",n,al.Output,t,"AnisotropyBlock")),n}return Object(h.d)(t,e),t.prototype.initialize=function(e){e._excludeVariableName("anisotropicOut"),e._excludeVariableName("TBN")},t.prototype.getClassName=function(){return"AnisotropyBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"direction",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anisotropy",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._generateTBNSpace=function(e){var t="",i="//"+this.name,n=this.uv,r=this.worldPositionConnectionPoint,o=this.worldNormalConnectionPoint,a=this.worldTangent;n.isConnected||console.error("You must connect the 'uv' input of the Anisotropy block!"),e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var s={search:/defined\(TANGENT\)/g,replace:a.isConnected?"defined(TANGENT)":"defined(IGNORE)"};return a.isConnected&&(t+="vec3 tbnNormal = normalize("+o.associatedVariableName+".xyz);\r\n",t+="vec3 tbnTangent = normalize("+a.associatedVariableName+".xyz);\r\n",t+="vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",t+="mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),t+="\n #if defined("+(a.isConnected?"TANGENT":"IGNORE")+") && defined(NORMAL)\n mat3 TBN = vTBN;\n #else\n mat3 TBN = cotangent_frame("+o.associatedVariableName+".xyz, v_"+r.associatedVariableName+".xyz, "+(n.isConnected?n.associatedVariableName:"vec2(0.)")+", vec2(1., 1.));\n #endif\r\n",e._emitFunctionFromInclude("bumpFragmentMainFunctions",i,{replaceStrings:[s]}),t},t.prototype.getCode=function(e,t){void 0===t&&(t=!1);var i="";t&&(i+=this._generateTBNSpace(e));var n=this.intensity.isConnected?this.intensity.associatedVariableName:"1.0";return i+="anisotropicOutParams anisotropicOut;\n anisotropicBlock(\n vec3("+(this.direction.isConnected?this.direction.associatedVariableName:"vec2(1., 0.)")+", "+n+"),\n #ifdef ANISOTROPIC_TEXTURE\n vec3(0.),\n #endif\n TBN,\n normalW,\n viewDirectionW,\n anisotropicOut\n );\r\n"},t.prototype.prepareDefines=function(t,i,n){e.prototype.prepareDefines.call(this,t,i,n),n.setValue("ANISOTROPIC",!0),n.setValue("ANISOTROPIC_TEXTURE",!1,!0)},t.prototype._buildBlock=function(e){return e.target===el.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t}(fl);c.a.RegisteredTypes["BABYLON.AnisotropyBlock"]=eh;var th=function(e){function t(i){var n=e.call(this,i)||this;return n.useSphericalHarmonics=!0,n.forceIrradianceInFragment=!1,n._isUnique=!0,n.registerInput("position",tl.Vector3,!1,el.Vertex),n.registerInput("world",tl.Matrix,!1,el.Vertex),n.registerInput("color",tl.Color3,!0,el.Fragment),n.registerOutput("reflection",tl.Object,el.Fragment,new Ju("reflection",n,al.Output,t,"ReflectionBlock")),n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ReflectionBlock"},Object.defineProperty(t.prototype,"position",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this.worldPositionConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this.worldNormalConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"world",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this.cameraPositionConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this.viewConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"color",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflection",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTexture",{get:function(){return!!this._getTexture()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionColor",{get:function(){return this.color.isConnected?this.color.associatedVariableName:"vec3(1., 1., 1.)"},enumerable:!1,configurable:!0}),t.prototype._getTexture=function(){return this.texture?this.texture:this._scene.environmentTexture},t.prototype.prepareDefines=function(t,i,n){e.prototype.prepareDefines.call(this,t,i,n);var r=this._getTexture(),o=r&&r.getTextureMatrix;n.setValue("REFLECTION",o,!0),o&&(n.setValue(this._defineLODReflectionAlpha,r.lodLevelInAlpha,!0),n.setValue(this._defineLinearSpecularReflection,r.linearSpecularLOD,!0),n.setValue(this._defineOppositeZ,this._scene.useRightHandedSystem?!r.invertZ:r.invertZ,!0),n.setValue("SPHERICAL_HARMONICS",this.useSphericalHarmonics,!0),n.setValue("GAMMAREFLECTION",r.gammaSpace,!0),n.setValue("RGBDREFLECTION",r.isRGBD,!0),r&&r.coordinatesMode!==Ke.a.SKYBOX_MODE&&r.isCube&&(n.setValue("USESPHERICALFROMREFLECTIONMAP",!0),n.setValue("USEIRRADIANCEMAP",!1),this.forceIrradianceInFragment||this._scene.getEngine().getCaps().maxVaryingVectors<=8?n.setValue("USESPHERICALINVERTEX",!1):n.setValue("USESPHERICALINVERTEX",!0)))},t.prototype.bind=function(t,i,n,r){e.prototype.bind.call(this,t,i,n);var o=this._getTexture();if(o&&r){o.isCube?t.setTexture(this._cubeSamplerName,o):t.setTexture(this._2DSamplerName,o);var a=o.getSize().width;t.setFloat3(this._vReflectionMicrosurfaceInfosName,a,o.lodGenerationScale,o.lodGenerationOffset),t.setFloat2(this._vReflectionFilteringInfoName,a,L.a.Log2(a));var s=r._materialDefines,c=o.sphericalPolynomial;if(s.USESPHERICALFROMREFLECTIONMAP&&c)if(s.SPHERICAL_HARMONICS){var l=c.preScaledHarmonics;t.setVector3("vSphericalL00",l.l00),t.setVector3("vSphericalL1_1",l.l1_1),t.setVector3("vSphericalL10",l.l10),t.setVector3("vSphericalL11",l.l11),t.setVector3("vSphericalL2_2",l.l2_2),t.setVector3("vSphericalL2_1",l.l2_1),t.setVector3("vSphericalL20",l.l20),t.setVector3("vSphericalL21",l.l21),t.setVector3("vSphericalL22",l.l22)}else t.setFloat3("vSphericalX",c.x.x,c.x.y,c.x.z),t.setFloat3("vSphericalY",c.y.x,c.y.y,c.y.z),t.setFloat3("vSphericalZ",c.z.x,c.z.y,c.z.z),t.setFloat3("vSphericalXX_ZZ",c.xx.x-c.zz.x,c.xx.y-c.zz.y,c.xx.z-c.zz.z),t.setFloat3("vSphericalYY_ZZ",c.yy.x-c.zz.x,c.yy.y-c.zz.y,c.yy.z-c.zz.z),t.setFloat3("vSphericalZZ",c.zz.x,c.zz.y,c.zz.z),t.setFloat3("vSphericalXY",c.xy.x,c.xy.y,c.xy.z),t.setFloat3("vSphericalYZ",c.yz.x,c.yz.y,c.yz.z),t.setFloat3("vSphericalZX",c.zx.x,c.zx.y,c.zx.z)}},t.prototype.handleVertexSide=function(t){var i=e.prototype.handleVertexSide.call(this,t);t._emitFunctionFromInclude("harmonicsFunctions","//"+this.name,{replaceStrings:[{search:/uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,replace:""},{search:/uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,replace:""}]});var n=t._getFreeVariableName("reflectionVector");return this._vEnvironmentIrradianceName=t._getFreeVariableName("vEnvironmentIrradiance"),t._emitVaryingFromString(this._vEnvironmentIrradianceName,"vec3","defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)"),t._emitUniformFromString("vSphericalL00","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL1_1","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL10","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL11","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL2_2","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL2_1","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL20","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL21","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalL22","vec3","SPHERICAL_HARMONICS"),t._emitUniformFromString("vSphericalX","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalY","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalZ","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalXX_ZZ","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalYY_ZZ","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalZZ","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalXY","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalYZ","vec3","SPHERICAL_HARMONICS",!0),t._emitUniformFromString("vSphericalZX","vec3","SPHERICAL_HARMONICS",!0),i+="#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\n vec3 "+n+" = vec3("+this._reflectionMatrixName+" * vec4(normalize("+this.worldNormal.associatedVariableName+").xyz, 0)).xyz;\n #ifdef "+this._defineOppositeZ+"\n "+n+".z *= -1.0;\n #endif\n "+this._vEnvironmentIrradianceName+" = computeEnvironmentIrradiance("+n+");\n #endif\r\n"},t.prototype.getCode=function(e,t){var i="";this.handleFragmentSideInits(e),e._emitFunctionFromInclude("harmonicsFunctions","//"+this.name,{replaceStrings:[{search:/uniform vec3 vSphericalL00;[\s\S]*?uniform vec3 vSphericalL22;/g,replace:""},{search:/uniform vec3 vSphericalX;[\s\S]*?uniform vec3 vSphericalZX;/g,replace:""}]}),e._emitFunction("sampleReflection","\n #ifdef "+this._define3DName+"\n #define sampleReflection(s, c) textureCube(s, c)\n #else\n #define sampleReflection(s, c) texture2D(s, c)\n #endif\r\n","//"+this.name),e._emitFunction("sampleReflectionLod","\n #ifdef "+this._define3DName+"\n #define sampleReflectionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleReflectionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\r\n","//"+this.name);var n="\n vec3 computeReflectionCoordsPBR(vec4 worldPos, vec3 worldNormal) {\n "+this.handleFragmentSideCodeReflectionCoords("worldNormal","worldPos",!0)+"\n return "+this._reflectionVectorName+";\n }\r\n";return e._emitFunction("computeReflectionCoordsPBR",n,"//"+this.name),this._vReflectionMicrosurfaceInfosName=e._getFreeVariableName("vReflectionMicrosurfaceInfos"),e._emitUniformFromString(this._vReflectionMicrosurfaceInfosName,"vec3"),this._vReflectionInfosName=e._getFreeVariableName("vReflectionInfos"),this._vReflectionFilteringInfoName=e._getFreeVariableName("vReflectionFilteringInfo"),e._emitUniformFromString(this._vReflectionFilteringInfoName,"vec2"),i+="#ifdef REFLECTION\n vec2 "+this._vReflectionInfosName+" = vec2(1., 0.);\n\n reflectionOutParams reflectionOut;\n\n reflectionBlock(\n v_"+this.worldPosition.associatedVariableName+".xyz,\n "+t+",\n alphaG,\n "+this._vReflectionMicrosurfaceInfosName+",\n "+this._vReflectionInfosName+",\n "+this.reflectionColor+",\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #if defined("+this._defineLODReflectionAlpha+") && !defined("+this._defineSkyboxName+")\n NdotVUnclamped,\n #endif\n #ifdef "+this._defineLinearSpecularReflection+"\n roughness,\n #endif\n #ifdef "+this._define3DName+"\n "+this._cubeSamplerName+",\n #else\n "+this._2DSamplerName+",\n #endif\n #if defined(NORMAL) && defined(USESPHERICALINVERTEX)\n "+this._vEnvironmentIrradianceName+",\n #endif\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n "+this._reflectionMatrixName+",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler, // ** not handled **\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef "+this._define3DName+"\n "+this._cubeSamplerName+",\n "+this._cubeSamplerName+",\n #else\n "+this._2DSamplerName+",\n "+this._2DSamplerName+",\n #endif\n #endif\n #ifdef REALTIME_FILTERING\n "+this._vReflectionFilteringInfoName+",\n #endif\n reflectionOut\n );\n #endif\r\n"},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,e.target!==el.Fragment&&(this._defineLODReflectionAlpha=e._getFreeDefineName("LODINREFLECTIONALPHA"),this._defineLinearSpecularReflection=e._getFreeDefineName("LINEARSPECULARREFLECTION")),this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return this.texture&&(t+=this._codeVariableName+".texture.gammaSpace = "+this.texture.gammaSpace+");\r\n"),t+=this._codeVariableName+".useSphericalHarmonics = "+this.useSphericalHarmonics+";\r\n",t+=this._codeVariableName+".forceIrradianceInFragment = "+this.forceIrradianceInFragment+";\r\n"},t.prototype.serialize=function(){var t,i,n=e.prototype.serialize.call(this);return n.useSphericalHarmonics=this.useSphericalHarmonics,n.forceIrradianceInFragment=this.forceIrradianceInFragment,n.gammaSpace=null===(i=null===(t=this.texture)||void 0===t?void 0:t.gammaSpace)||void 0===i||i,n},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),this.useSphericalHarmonics=t.useSphericalHarmonics,this.forceIrradianceInFragment=t.forceIrradianceInFragment,this.texture&&(this.texture.gammaSpace=t.gammaSpace)},Object(h.c)([Ml("Spherical Harmonics",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useSphericalHarmonics",void 0),Object(h.c)([Ml("Force irradiance in fragment",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"forceIrradianceInFragment",void 0),t}(hu);c.a.RegisteredTypes["BABYLON.ReflectionBlock"]=th;var ih=function(e){function t(i){var n=e.call(this,i,el.Fragment)||this;return n.remapF0OnInterfaceChange=!0,n._isUnique=!0,n.registerInput("intensity",tl.Float,!1,el.Fragment),n.registerInput("roughness",tl.Float,!0,el.Fragment),n.registerInput("indexOfRefraction",tl.Float,!0,el.Fragment),n.registerInput("normalMapColor",tl.Color3,!0,el.Fragment),n.registerInput("uv",tl.Vector2,!0,el.Fragment),n.registerInput("tintColor",tl.Color3,!0,el.Fragment),n.registerInput("tintAtDistance",tl.Float,!0,el.Fragment),n.registerInput("tintThickness",tl.Float,!0,el.Fragment),n.registerInput("worldTangent",tl.Vector4,!0),n.registerOutput("clearcoat",tl.Object,el.Fragment,new Ju("clearcoat",n,al.Output,t,"ClearCoatBlock")),n}return Object(h.d)(t,e),t.prototype.initialize=function(e){e._excludeVariableName("clearcoatOut"),e._excludeVariableName("vClearCoatParams"),e._excludeVariableName("vClearCoatTintParams"),e._excludeVariableName("vClearCoatRefractionParams"),e._excludeVariableName("vClearCoatTangentSpaceParams")},t.prototype.getClassName=function(){return"ClearCoatBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"normalMapColor",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"uv",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintColor",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintAtDistance",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintThickness",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldTangent",{get:function(){return this._inputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoat",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.intensity.isConnected){var t=new Sl("ClearCoat intensity",el.Fragment,tl.Float);t.value=1,t.output.connectTo(this.intensity)}},t.prototype.prepareDefines=function(t,i,n){e.prototype.prepareDefines.call(this,t,i,n),n.setValue("CLEARCOAT",!0),n.setValue("CLEARCOAT_TEXTURE",!1,!0),n.setValue("CLEARCOAT_USE_ROUGHNESS_FROM_MAINTEXTURE",!0,!0),n.setValue("CLEARCOAT_TINT",this.tintColor.isConnected||this.tintThickness.isConnected||this.tintAtDistance.isConnected,!0),n.setValue("CLEARCOAT_BUMP",this.normalMapColor.isConnected,!0),n.setValue("CLEARCOAT_DEFAULTIOR",!this.indexOfRefraction.isConnected||this.indexOfRefraction.connectInputBlock.value===Eo._DefaultIndexOfRefraction,!0),n.setValue("CLEARCOAT_REMAP_F0",this.remapF0OnInterfaceChange,!0)},t.prototype.bind=function(t,i,n,r){var o,a;e.prototype.bind.call(this,t,i,n);var s=null!==(a=null===(o=this.indexOfRefraction.connectInputBlock)||void 0===o?void 0:o.value)&&void 0!==a?a:Eo._DefaultIndexOfRefraction,c=1-s,l=1+s,u=Math.pow(-c/l,2),h=1/s;t.setFloat4("vClearCoatRefractionParams",u,h,c,l);var d=this.clearcoat.hasEndpoints?this.clearcoat.endpoints[0].ownerBlock:null,f=(null==d?void 0:d.perturbedNormal.isConnected)?d.perturbedNormal.connectedPoint.ownerBlock:null;this._scene._mirroredCameraPosition?t.setFloat2("vClearCoatTangentSpaceParams",(null==f?void 0:f.invertX)?1:-1,(null==f?void 0:f.invertY)?1:-1):t.setFloat2("vClearCoatTangentSpaceParams",(null==f?void 0:f.invertX)?-1:1,(null==f?void 0:f.invertY)?-1:1)},t.prototype._generateTBNSpace=function(e,t,i){var n="",r="//"+this.name,o=this.worldTangent;e._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable");var a={search:/defined\(TANGENT\)/g,replace:o.isConnected?"defined(TANGENT)":"defined(IGNORE)"};return o.isConnected&&(n+="vec3 tbnNormal = normalize("+i+".xyz);\r\n",n+="vec3 tbnTangent = normalize("+o.associatedVariableName+".xyz);\r\n",n+="vec3 tbnBitangent = cross(tbnNormal, tbnTangent);\r\n",n+="mat3 vTBN = mat3(tbnTangent, tbnBitangent, tbnNormal);\r\n"),e._emitFunctionFromInclude("bumpFragmentMainFunctions",r,{replaceStrings:[a]}),n},t.GetCode=function(e,t,i,n,r,o,a){var s="",c=(null==t?void 0:t.intensity.isConnected)?t.intensity.associatedVariableName:"1.",l=(null==t?void 0:t.roughness.isConnected)?t.roughness.associatedVariableName:"0.",u=(null==t?void 0:t.normalMapColor.isConnected)?t.normalMapColor.associatedVariableName:"vec3(0.)",h=(null==t?void 0:t.uv.isConnected)?t.uv.associatedVariableName:"vec2(0.)",d=(null==t?void 0:t.tintColor.isConnected)?t.tintColor.associatedVariableName:"vec3(1.)",f=(null==t?void 0:t.tintThickness.isConnected)?t.tintThickness.associatedVariableName:"1.",p=(null==t?void 0:t.tintAtDistance.isConnected)?t.tintAtDistance.associatedVariableName:"1.";return t&&(e._emitUniformFromString("vClearCoatRefractionParams","vec4"),e._emitUniformFromString("vClearCoatTangentSpaceParams","vec2")),r&&t&&(s+=t._generateTBNSpace(e,n,a),o=t.worldTangent.isConnected),s+="clearcoatOutParams clearcoatOut;\n\n #ifdef CLEARCOAT\n vec2 vClearCoatParams = vec2("+c+", "+l+");\n vec4 vClearCoatTintParams = vec4("+d+", "+f+");\n\n clearcoatBlock(\n "+n+".xyz,\n geometricNormalW,\n viewDirectionW,\n vClearCoatParams,\n specularEnvironmentR0,\n #ifdef CLEARCOAT_TEXTURE\n vec2(0.),\n #endif\n #ifdef CLEARCOAT_TINT\n vClearCoatTintParams,\n "+p+",\n vClearCoatRefractionParams,\n #ifdef CLEARCOAT_TINT_TEXTURE\n vec4(0.),\n #endif\n #endif\n #ifdef CLEARCOAT_BUMP\n vec2(0., 1.),\n vec4("+u+", 0.),\n "+h+",\n #if defined("+(o?"TANGENT":"IGNORE")+") && defined(NORMAL)\n vTBN,\n #else\n vClearCoatTangentSpaceParams,\n #endif\n #ifdef OBJECTSPACE_NORMALMAP\n normalMatrix,\n #endif\n #endif\n #if defined(FORCENORMALFORWARD) && defined(NORMAL)\n faceNormal,\n #endif\n #ifdef REFLECTION\n "+(null==i?void 0:i._vReflectionMicrosurfaceInfosName)+",\n "+(null==i?void 0:i._vReflectionInfosName)+",\n "+(null==i?void 0:i.reflectionColor)+",\n vLightingIntensity,\n #ifdef "+(null==i?void 0:i._define3DName)+"\n "+(null==i?void 0:i._cubeSamplerName)+",\n #else\n "+(null==i?void 0:i._2DSamplerName)+",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef "+(null==i?void 0:i._define3DName)+"\n "+(null==i?void 0:i._cubeSamplerName)+",\n "+(null==i?void 0:i._cubeSamplerName)+",\n #else\n "+(null==i?void 0:i._2DSamplerName)+",\n "+(null==i?void 0:i._2DSamplerName)+",\n #endif\n #endif\n #endif\n #if defined(ENVIRONMENTBRDF) && !defined("+(null==i?void 0:i._defineSkyboxName)+")\n #ifdef RADIANCEOCCLUSION\n ambientMonochrome,\n #endif\n #endif\n clearcoatOut\n );\n #else\n clearcoatOut.specularEnvironmentR0 = specularEnvironmentR0;\n #endif\r\n"},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,e.target===el.Fragment&&(e.sharedData.bindableBlocks.push(this),e.sharedData.blocksWithDefines.push(this)),this},t.prototype._dumpPropertiesCode=function(){var e="";return e+=this._codeVariableName+".remapF0OnInterfaceChange = "+this.remapF0OnInterfaceChange+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.remapF0OnInterfaceChange=this.remapF0OnInterfaceChange,t},t.prototype._deserialize=function(t,i,n){var r;e.prototype._deserialize.call(this,t,i,n),this.remapF0OnInterfaceChange=null===(r=t.remapF0OnInterfaceChange)||void 0===r||r},Object(h.c)([Ml("Remap F0 on interface change",xl.Boolean,"ADVANCED")],t.prototype,"remapF0OnInterfaceChange",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.ClearCoatBlock"]=ih;var nh=function(e){function t(i){var n=e.call(this,i,el.Fragment)||this;return n.linkRefractionWithTransparency=!1,n.invertRefractionY=!1,n._isUnique=!0,n.registerInput("intensity",tl.Float,!1,el.Fragment),n.registerInput("tintAtDistance",tl.Float,!0,el.Fragment),n.registerOutput("refraction",tl.Object,el.Fragment,new Ju("refraction",n,al.Output,t,"RefractionBlock")),n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"RefractionBlock"},Object.defineProperty(t.prototype,"intensity",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintAtDistance",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this.viewConnectionPoint},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refraction",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasTexture",{get:function(){return!!this._getTexture()},enumerable:!1,configurable:!0}),t.prototype._getTexture=function(){return this.texture?this.texture:this._scene.environmentTexture},t.prototype.autoConfigure=function(e){if(!this.intensity.isConnected){var t=new Sl("Refraction intensity",el.Fragment,tl.Float);t.value=1,t.output.connectTo(this.intensity)}if(this.view&&!this.view.isConnected){var i=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.View}));i||(i=new Sl("view")).setAsSystemValue(nl.View),i.output.connectTo(this.view)}},t.prototype.prepareDefines=function(t,i,n){e.prototype.prepareDefines.call(this,t,i,n);var r=this._getTexture(),o=r&&r.getTextureMatrix;n.setValue("SS_REFRACTION",o,!0),o&&(n.setValue(this._define3DName,r.isCube,!0),n.setValue(this._defineLODRefractionAlpha,r.lodLevelInAlpha,!0),n.setValue(this._defineLinearSpecularRefraction,r.linearSpecularLOD,!0),n.setValue(this._defineOppositeZ,this._scene.useRightHandedSystem?!r.invertZ:r.invertZ,!0),n.setValue("SS_LINKREFRACTIONTOTRANSPARENCY",this.linkRefractionWithTransparency,!0),n.setValue("SS_GAMMAREFRACTION",r.gammaSpace,!0),n.setValue("SS_RGBDREFRACTION",r.isRGBD,!0))},t.prototype.isReady=function(){var e=this._getTexture();return!(e&&!e.isReadyOrNotBlocking())},t.prototype.bind=function(t,i,n,r){var o,a;e.prototype.bind.call(this,t,i,n);var s=this._getTexture();if(s){s.isCube?t.setTexture(this._cubeSamplerName,s):t.setTexture(this._2DSamplerName,s),t.setMatrix(this._refractionMatrixName,s.getReflectionTextureMatrix());var c=1;s.isCube||s.depth&&(c=s.depth);var l=null!==(a=null===(o=this.indexOfRefractionConnectionPoint.connectInputBlock)||void 0===o?void 0:o.value)&&void 0!==a?a:1.5;t.setFloat4(this._vRefractionInfosName,s.level,1/l,c,this.invertRefractionY?-1:1),t.setFloat3(this._vRefractionMicrosurfaceInfosName,s.getSize().width,s.lodGenerationScale,s.lodGenerationOffset);var u=s.getSize().width;t.setFloat2(this._vRefractionFilteringInfoName,u,L.a.Log2(u))}},t.prototype.getCode=function(e){return e.sharedData.blockingBlocks.push(this),e.sharedData.textureBlocks.push(this),this._cubeSamplerName=e._getFreeVariableName(this.name+"CubeSampler"),e.samplers.push(this._cubeSamplerName),this._2DSamplerName=e._getFreeVariableName(this.name+"2DSampler"),e.samplers.push(this._2DSamplerName),this._define3DName=e._getFreeDefineName("SS_REFRACTIONMAP_3D"),e._samplerDeclaration+="#ifdef "+this._define3DName+"\r\n",e._samplerDeclaration+="uniform samplerCube "+this._cubeSamplerName+";\r\n",e._samplerDeclaration+="#else\r\n",e._samplerDeclaration+="uniform sampler2D "+this._2DSamplerName+";\r\n",e._samplerDeclaration+="#endif\r\n",e.sharedData.blocksWithDefines.push(this),e.sharedData.bindableBlocks.push(this),this._defineLODRefractionAlpha=e._getFreeDefineName("SS_LODINREFRACTIONALPHA"),this._defineLinearSpecularRefraction=e._getFreeDefineName("SS_LINEARSPECULARREFRACTION"),this._defineOppositeZ=e._getFreeDefineName("SS_REFRACTIONMAP_OPPOSITEZ"),this._refractionMatrixName=e._getFreeVariableName("refractionMatrix"),e._emitUniformFromString(this._refractionMatrixName,"mat4"),e._emitFunction("sampleRefraction","\n #ifdef "+this._define3DName+"\n #define sampleRefraction(s, c) textureCube(s, c)\n #else\n #define sampleRefraction(s, c) texture2D(s, c)\n #endif\r\n","//"+this.name),e._emitFunction("sampleRefractionLod","\n #ifdef "+this._define3DName+"\n #define sampleRefractionLod(s, c, l) textureCubeLodEXT(s, c, l)\n #else\n #define sampleRefractionLod(s, c, l) texture2DLodEXT(s, c, l)\n #endif\r\n","//"+this.name),this._vRefractionMicrosurfaceInfosName=e._getFreeVariableName("vRefractionMicrosurfaceInfos"),e._emitUniformFromString(this._vRefractionMicrosurfaceInfosName,"vec3"),this._vRefractionInfosName=e._getFreeVariableName("vRefractionInfos"),e._emitUniformFromString(this._vRefractionInfosName,"vec4"),this._vRefractionFilteringInfoName=e._getFreeVariableName("vRefractionFilteringInfo"),e._emitUniformFromString(this._vRefractionFilteringInfoName,"vec2"),""},t.prototype._buildBlock=function(e){return this._scene=e.sharedData.scene,this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return this.texture&&(t=this.texture.isCube?this._codeVariableName+'.texture = new BABYLON.CubeTexture("'+this.texture.name+'");\r\n':this._codeVariableName+'.texture = new BABYLON.Texture("'+this.texture.name+'");\r\n',t+=this._codeVariableName+".texture.coordinatesMode = "+this.texture.coordinatesMode+";\r\n"),t+=this._codeVariableName+".linkRefractionWithTransparency = "+this.linkRefractionWithTransparency+";\r\n",t+=this._codeVariableName+".invertRefractionY = "+this.invertRefractionY+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.texture&&(t.texture=this.texture.serialize()),t.linkRefractionWithTransparency=this.linkRefractionWithTransparency,t.invertRefractionY=this.invertRefractionY,t},t.prototype._deserialize=function(t,i,n){e.prototype._deserialize.call(this,t,i,n),t.texture&&(n=0===t.texture.url.indexOf("data:")?"":n,t.texture.isCube?this.texture=no.Parse(t.texture,i,n):this.texture=Ke.a.Parse(t.texture,i,n)),this.linkRefractionWithTransparency=t.linkRefractionWithTransparency,this.invertRefractionY=t.invertRefractionY},Object(h.c)([Ml("Link refraction to transparency",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"linkRefractionWithTransparency",void 0),Object(h.c)([Ml("Invert refraction Y",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"invertRefractionY",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.RefractionBlock"]=nh;var rh=function(e){function t(i){var n=e.call(this,i,el.Fragment)||this;return n._isUnique=!0,n.registerInput("thickness",tl.Float,!1,el.Fragment),n.registerInput("tintColor",tl.Color3,!0,el.Fragment),n.registerInput("translucencyIntensity",tl.Float,!0,el.Fragment),n.registerInput("translucencyDiffusionDist",tl.Color3,!0,el.Fragment),n.registerInput("refraction",tl.Object,!0,el.Fragment,new Ju("refraction",n,al.Input,nh,"RefractionBlock")),n.registerOutput("subsurface",tl.Object,el.Fragment,new Ju("subsurface",n,al.Output,t,"SubSurfaceBlock")),n}return Object(h.d)(t,e),t.prototype.initialize=function(e){e._excludeVariableName("subSurfaceOut"),e._excludeVariableName("vThicknessParam"),e._excludeVariableName("vTintColor"),e._excludeVariableName("vSubSurfaceIntensity")},t.prototype.getClassName=function(){return"SubSurfaceBlock"},Object.defineProperty(t.prototype,"thickness",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"tintColor",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translucencyIntensity",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"translucencyDiffusionDist",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refraction",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subsurface",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.thickness.isConnected){var t=new Sl("SubSurface thickness",el.Fragment,tl.Float);t.value=0,t.output.connectTo(this.thickness)}},t.prototype.prepareDefines=function(t,i,n){e.prototype.prepareDefines.call(this,t,i,n);var r=this.translucencyDiffusionDist.isConnected||this.translucencyIntensity.isConnected;n.setValue("SUBSURFACE",r||this.refraction.isConnected,!0),n.setValue("SS_TRANSLUCENCY",r,!0),n.setValue("SS_THICKNESSANDMASK_TEXTURE",!1,!0),n.setValue("SS_MASK_FROM_THICKNESS_TEXTURE",!1,!0),n.setValue("SS_MASK_FROM_THICKNESS_TEXTURE_GLTF",!1,!0)},t.GetCode=function(e,t,i,n){var r,o,a,s,c,l,u,h,d,f,p,_,m,g,v,b,y="",T=(null==t?void 0:t.thickness.isConnected)?t.thickness.associatedVariableName:"0.",E=(null==t?void 0:t.tintColor.isConnected)?t.tintColor.associatedVariableName:"vec3(1.)",S=(null==t?void 0:t.translucencyIntensity.isConnected)?null==t?void 0:t.translucencyIntensity.associatedVariableName:"1.",A=(null==t?void 0:t.translucencyDiffusionDist.isConnected)?null==t?void 0:t.translucencyDiffusionDist.associatedVariableName:"vec3(1.)",P=(null==t?void 0:t.refraction.isConnected)?null===(r=null==t?void 0:t.refraction.connectedPoint)||void 0===r?void 0:r.ownerBlock:null,C=(null==P?void 0:P.tintAtDistance.isConnected)?P.tintAtDistance.associatedVariableName:"1.",R=(null==P?void 0:P.intensity.isConnected)?P.intensity.associatedVariableName:"1.",x=(null==P?void 0:P.view.isConnected)?P.view.associatedVariableName:"";return y+=null!==(o=null==P?void 0:P.getCode(e))&&void 0!==o?o:"",y+="subSurfaceOutParams subSurfaceOut;\n\n #ifdef SUBSURFACE\n vec2 vThicknessParam = vec2(0., "+T+");\n vec4 vTintColor = vec4("+E+", "+C+");\n vec3 vSubSurfaceIntensity = vec3("+R+", "+S+", 0.);\n\n subSurfaceBlock(\n vSubSurfaceIntensity,\n vThicknessParam,\n vTintColor,\n normalW,\n specularEnvironmentReflectance,\n #ifdef SS_THICKNESSANDMASK_TEXTURE\n vec4(0.),\n #endif\n #ifdef REFLECTION\n #ifdef SS_TRANSLUCENCY\n "+(null==i?void 0:i._reflectionMatrixName)+",\n #ifdef USESPHERICALFROMREFLECTIONMAP\n #if !defined(NORMAL) || !defined(USESPHERICALINVERTEX)\n reflectionOut.irradianceVector,\n #endif\n #if defined(REALTIME_FILTERING)\n "+(null==i?void 0:i._cubeSamplerName)+",\n "+(null==i?void 0:i._vReflectionFilteringInfoName)+",\n #endif\n #endif\n #ifdef USEIRRADIANCEMAP\n irradianceSampler,\n #endif\n #endif\n #endif\n #ifdef SS_REFRACTION\n "+n+".xyz,\n viewDirectionW,\n "+x+",\n surfaceAlbedo,\n "+(null!==(a=null==P?void 0:P._vRefractionInfosName)&&void 0!==a?a:"")+",\n "+(null!==(s=null==P?void 0:P._refractionMatrixName)&&void 0!==s?s:"")+",\n "+(null!==(c=null==P?void 0:P._vRefractionMicrosurfaceInfosName)&&void 0!==c?c:"")+",\n vLightingIntensity,\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha,\n #endif\n #ifdef "+(null!==(l=null==P?void 0:P._defineLODRefractionAlpha)&&void 0!==l?l:"IGNORE")+"\n NdotVUnclamped,\n #endif\n #ifdef "+(null!==(u=null==P?void 0:P._defineLinearSpecularRefraction)&&void 0!==u?u:"IGNORE")+"\n roughness,\n #else\n alphaG,\n #endif\n #ifdef "+(null!==(h=null==P?void 0:P._define3DName)&&void 0!==h?h:"IGNORE")+"\n "+(null!==(d=null==P?void 0:P._cubeSamplerName)&&void 0!==d?d:"")+",\n #else\n "+(null!==(f=null==P?void 0:P._2DSamplerName)&&void 0!==f?f:"")+",\n #endif\n #ifndef LODBASEDMICROSFURACE\n #ifdef "+(null!==(p=null==P?void 0:P._define3DName)&&void 0!==p?p:"IGNORE")+"\n "+(null!==(_=null==P?void 0:P._cubeSamplerName)&&void 0!==_?_:"")+",\n "+(null!==(m=null==P?void 0:P._cubeSamplerName)&&void 0!==m?m:"")+",\n #else\n "+(null!==(g=null==P?void 0:P._2DSamplerName)&&void 0!==g?g:"")+",\n "+(null!==(v=null==P?void 0:P._2DSamplerName)&&void 0!==v?v:"")+",\n #endif\n #endif\n #ifdef ANISOTROPIC\n anisotropicOut,\n #endif\n #ifdef REALTIME_FILTERING\n "+(null!==(b=null==P?void 0:P._vRefractionFilteringInfoName)&&void 0!==b?b:"")+",\n #endif\n #endif\n #ifdef SS_TRANSLUCENCY\n "+A+",\n #endif\n subSurfaceOut\n );\n\n #ifdef SS_REFRACTION\n surfaceAlbedo = subSurfaceOut.surfaceAlbedo;\n #ifdef SS_LINKREFRACTIONTOTRANSPARENCY\n alpha = subSurfaceOut.alpha;\n #endif\n #endif\n #else\n subSurfaceOut.specularEnvironmentReflectance = specularEnvironmentReflectance;\n #endif\r\n"},t.prototype._buildBlock=function(e){return e.target===el.Fragment&&e.sharedData.blocksWithDefines.push(this),this},t}(fl);c.a.RegisteredTypes["BABYLON.SubSurfaceBlock"]=rh;var oh={ambientClr:["finalAmbient",""],diffuseDir:["finalDiffuse",""],specularDir:["finalSpecularScaled","!defined(UNLIT) && defined(SPECULARTERM)"],clearcoatDir:["finalClearCoatScaled","!defined(UNLIT) && defined(CLEARCOAT)"],sheenDir:["finalSheenScaled","!defined(UNLIT) && defined(SHEEN)"],diffuseInd:["finalIrradiance","!defined(UNLIT) && defined(REFLECTION)"],specularInd:["finalRadianceScaled","!defined(UNLIT) && defined(REFLECTION)"],clearcoatInd:["clearcoatOut.finalClearCoatRadianceScaled","!defined(UNLIT) && defined(REFLECTION) && defined(CLEARCOAT)"],sheenInd:["sheenOut.finalSheenRadianceScaled","!defined(UNLIT) && defined(REFLECTION) && defined(SHEEN) && defined(ENVIRONMENTBRDF)"],refraction:["subSurfaceOut.finalRefraction","!defined(UNLIT) && defined(SS_REFRACTION)"],lighting:["finalColor.rgb",""],shadow:["shadow",""],alpha:["alpha",""]},ah=function(e){function t(t){var i=e.call(this,t,el.VertexAndFragment)||this;return i._environmentBRDFTexture=null,i._metallicReflectanceColor=s.a.White(),i._metallicF0Factor=1,i.directIntensity=1,i.environmentIntensity=1,i.specularIntensity=1,i.lightFalloff=0,i.useAlphaTest=!1,i.alphaTestCutoff=.5,i.useAlphaBlending=!1,i.useRadianceOverAlpha=!0,i.useSpecularOverAlpha=!0,i.enableSpecularAntiAliasing=!1,i.realTimeFiltering=!1,i.realTimeFilteringQuality=g.a.TEXTURE_FILTERING_QUALITY_LOW,i.useEnergyConservation=!0,i.useRadianceOcclusion=!0,i.useHorizonOcclusion=!0,i.unlit=!1,i.forceNormalForward=!1,i.debugMode=0,i.debugLimit=0,i.debugFactor=1,i._isUnique=!0,i.registerInput("worldPosition",tl.Vector4,!1,el.Vertex),i.registerInput("worldNormal",tl.Vector4,!1,el.Fragment),i.registerInput("view",tl.Matrix,!1),i.registerInput("cameraPosition",tl.Vector3,!1,el.Fragment),i.registerInput("perturbedNormal",tl.Vector4,!0,el.Fragment),i.registerInput("baseColor",tl.Color3,!0,el.Fragment),i.registerInput("metallic",tl.Float,!1,el.Fragment),i.registerInput("roughness",tl.Float,!1,el.Fragment),i.registerInput("ambientOcc",tl.Float,!0,el.Fragment),i.registerInput("opacity",tl.Float,!0,el.Fragment),i.registerInput("indexOfRefraction",tl.Float,!0,el.Fragment),i.registerInput("ambientColor",tl.Color3,!0,el.Fragment),i.registerInput("reflection",tl.Object,!0,el.Fragment,new Ju("reflection",i,al.Input,th,"ReflectionBlock")),i.registerInput("clearcoat",tl.Object,!0,el.Fragment,new Ju("clearcoat",i,al.Input,ih,"ClearCoatBlock")),i.registerInput("sheen",tl.Object,!0,el.Fragment,new Ju("sheen",i,al.Input,$u,"SheenBlock")),i.registerInput("subsurface",tl.Object,!0,el.Fragment,new Ju("subsurface",i,al.Input,rh,"SubSurfaceBlock")),i.registerInput("anisotropy",tl.Object,!0,el.Fragment,new Ju("anisotropy",i,al.Input,eh,"AnisotropyBlock")),i.registerOutput("ambientClr",tl.Color3,el.Fragment),i.registerOutput("diffuseDir",tl.Color3,el.Fragment),i.registerOutput("specularDir",tl.Color3,el.Fragment),i.registerOutput("clearcoatDir",tl.Color3,el.Fragment),i.registerOutput("sheenDir",tl.Color3,el.Fragment),i.registerOutput("diffuseInd",tl.Color3,el.Fragment),i.registerOutput("specularInd",tl.Color3,el.Fragment),i.registerOutput("clearcoatInd",tl.Color3,el.Fragment),i.registerOutput("sheenInd",tl.Color3,el.Fragment),i.registerOutput("refraction",tl.Color3,el.Fragment),i.registerOutput("lighting",tl.Color3,el.Fragment),i.registerOutput("shadow",tl.Float,el.Fragment),i.registerOutput("alpha",tl.Float,el.Fragment),i}return Object(h.d)(t,e),t.prototype.initialize=function(e){e._excludeVariableName("vLightingIntensity"),e._excludeVariableName("geometricNormalW"),e._excludeVariableName("normalW"),e._excludeVariableName("faceNormal"),e._excludeVariableName("albedoOpacityOut"),e._excludeVariableName("surfaceAlbedo"),e._excludeVariableName("alpha"),e._excludeVariableName("aoOut"),e._excludeVariableName("baseColor"),e._excludeVariableName("reflectivityOut"),e._excludeVariableName("microSurface"),e._excludeVariableName("roughness"),e._excludeVariableName("NdotVUnclamped"),e._excludeVariableName("NdotV"),e._excludeVariableName("alphaG"),e._excludeVariableName("AARoughnessFactors"),e._excludeVariableName("environmentBrdf"),e._excludeVariableName("ambientMonochrome"),e._excludeVariableName("seo"),e._excludeVariableName("eho"),e._excludeVariableName("environmentRadiance"),e._excludeVariableName("irradianceVector"),e._excludeVariableName("environmentIrradiance"),e._excludeVariableName("diffuseBase"),e._excludeVariableName("specularBase"),e._excludeVariableName("preInfo"),e._excludeVariableName("info"),e._excludeVariableName("shadow"),e._excludeVariableName("finalDiffuse"),e._excludeVariableName("finalAmbient"),e._excludeVariableName("ambientOcclusionForDirectDiffuse"),e._excludeVariableName("finalColor"),e._excludeVariableName("vClipSpacePosition"),e._excludeVariableName("vDebugMode")},t.prototype.getClassName=function(){return"PBRMetallicRoughnessBlock"},Object.defineProperty(t.prototype,"worldPosition",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"worldNormal",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"view",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"cameraPosition",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"perturbedNormal",{get:function(){return this._inputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"baseColor",{get:function(){return this._inputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"metallic",{get:function(){return this._inputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"roughness",{get:function(){return this._inputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ambientOcc",{get:function(){return this._inputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"opacity",{get:function(){return this._inputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return this._inputs[10]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ambientColor",{get:function(){return this._inputs[11]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflection",{get:function(){return this._inputs[12]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoat",{get:function(){return this._inputs[13]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheen",{get:function(){return this._inputs[14]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"subsurface",{get:function(){return this._inputs[15]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"anisotropy",{get:function(){return this._inputs[16]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ambientClr",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseDir",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularDir",{get:function(){return this._outputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoatDir",{get:function(){return this._outputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheenDir",{get:function(){return this._outputs[4]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"diffuseIndirect",{get:function(){return this._outputs[5]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"specularIndirect",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"clearcoatIndirect",{get:function(){return this._outputs[7]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sheenIndirect",{get:function(){return this._outputs[8]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"refraction",{get:function(){return this._outputs[9]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lighting",{get:function(){return this._outputs[10]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"shadow",{get:function(){return this._outputs[11]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this._outputs[12]},enumerable:!1,configurable:!0}),t.prototype.autoConfigure=function(e){if(!this.cameraPosition.isConnected){var t=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.CameraPosition}));t||(t=new Sl("cameraPosition")).setAsSystemValue(nl.CameraPosition),t.output.connectTo(this.cameraPosition)}if(!this.view.isConnected){var i=e.getInputBlockByPredicate((function(e){return e.systemValue===nl.View}));i||(i=new Sl("view")).setAsSystemValue(nl.View),i.output.connectTo(this.view)}},t.prototype.prepareDefines=function(e,t,i){i.setValue("PBR",!0),i.setValue("METALLICWORKFLOW",!0),i.setValue("DEBUGMODE",this.debugMode,!0),i.setValue("NORMALXYSCALE",!0),i.setValue("BUMP",this.perturbedNormal.isConnected,!0),i.setValue("LODBASEDMICROSFURACE",this._scene.getEngine().getCaps().textureLOD),i.setValue("ALBEDO",!1,!0),i.setValue("OPACITY",this.opacity.isConnected,!0),i.setValue("AMBIENT",!0,!0),i.setValue("AMBIENTINGRAYSCALE",!1,!0),i.setValue("REFLECTIVITY",!1,!0),i.setValue("AOSTOREINMETALMAPRED",!1,!0),i.setValue("METALLNESSSTOREINMETALMAPBLUE",!1,!0),i.setValue("ROUGHNESSSTOREINMETALMAPALPHA",!1,!0),i.setValue("ROUGHNESSSTOREINMETALMAPGREEN",!1,!0),this.lightFalloff===_a.LIGHTFALLOFF_STANDARD?(i.setValue("USEPHYSICALLIGHTFALLOFF",!1),i.setValue("USEGLTFLIGHTFALLOFF",!1)):this.lightFalloff===_a.LIGHTFALLOFF_GLTF?(i.setValue("USEPHYSICALLIGHTFALLOFF",!1),i.setValue("USEGLTFLIGHTFALLOFF",!0)):(i.setValue("USEPHYSICALLIGHTFALLOFF",!0),i.setValue("USEGLTFLIGHTFALLOFF",!1));var n=this.alphaTestCutoff.toString();if(i.setValue("ALPHABLEND",this.useAlphaBlending,!0),i.setValue("ALPHAFROMALBEDO",!1,!0),i.setValue("ALPHATEST",this.useAlphaTest,!0),i.setValue("ALPHATESTVALUE",n.indexOf(".")<0?n+".":n,!0),i.setValue("OPACITYRGB",!1,!0),i.setValue("RADIANCEOVERALPHA",this.useRadianceOverAlpha,!0),i.setValue("SPECULAROVERALPHA",this.useSpecularOverAlpha,!0),i.setValue("SPECULARAA",this._scene.getEngine().getCaps().standardDerivatives&&this.enableSpecularAntiAliasing,!0),i.setValue("REALTIME_FILTERING",this.realTimeFiltering,!0),this._scene.getEngine().webGLVersion>1?i.setValue("NUM_SAMPLES",this.realTimeFilteringQuality+"u",!0):i.setValue("NUM_SAMPLES",""+this.realTimeFilteringQuality,!0),i.setValue("BRDF_V_HEIGHT_CORRELATED",!0),i.setValue("MS_BRDF_ENERGY_CONSERVATION",this.useEnergyConservation,!0),i.setValue("RADIANCEOCCLUSION",this.useRadianceOcclusion,!0),i.setValue("HORIZONOCCLUSION",this.useHorizonOcclusion,!0),i.setValue("UNLIT",this.unlit,!0),i.setValue("FORCENORMALFORWARD",this.forceNormalForward,!0),this._environmentBRDFTexture&&so.a.ReflectionTextureEnabled?(i.setValue("ENVIRONMENTBRDF",!0),i.setValue("ENVIRONMENTBRDF_RGBD",this._environmentBRDFTexture.isRGBD,!0)):(i.setValue("ENVIRONMENTBRDF",!1),i.setValue("ENVIRONMENTBRDF_RGBD",!1)),i._areLightsDirty){var r=e.getScene();if(this.light){var o={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};ro.a.PrepareDefinesForLight(r,e,this.light,this._lightId,i,!0,o),o.needRebuild&&i.rebuild()}else ro.a.PrepareDefinesForLights(r,e,i,!0,t.maxSimultaneousLights),i._needNormals=!0,ro.a.PrepareDefinesForMultiview(r,i)}},t.prototype.updateUniformsAndSamples=function(e,t,i,n){for(var r=0;r<t.maxSimultaneousLights&&i["LIGHT"+r];r++){var o=e.uniforms.indexOf("vLightData"+r)>=0;ro.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,i["PROJECTEDLIGHTTEXTURE"+r],n,o)}},t.prototype.bind=function(e,t,i){var n,r;if(i){var o=i.getScene();this.light?ro.a.BindLight(this.light,this._lightId,o,e,!0):ro.a.BindLights(o,i,e,!0,t.maxSimultaneousLights),e.setTexture(this._environmentBrdfSamplerName,this._environmentBRDFTexture),e.setFloat2("vDebugMode",this.debugLimit,this.debugFactor);var a=this._scene.ambientColor;a&&e.setColor3("ambientFromScene",a);var c=o.useRightHandedSystem===(null!=o._mirroredCameraPosition);e.setFloat(this._invertNormalName,c?-1:1),e.setFloat4("vLightingIntensity",this.directIntensity,1,this.environmentIntensity*this._scene.environmentIntensity,this.specularIntensity);var l=null!==(r=null===(n=this.indexOfRefraction.connectInputBlock)||void 0===n?void 0:n.value)&&void 0!==r?r:1.5,u=Math.pow((l-1)/(l+1),2);this._metallicReflectanceColor.scaleToRef(u*this._metallicF0Factor,s.c.Color3[0]);var h=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,s.c.Color3[0],h)}},t.prototype._injectVertexCode=function(e){var t,i,n=this.worldPosition,r="//"+this.name;this.light?(this._lightId=(void 0!==e.counters.lightCounter?e.counters.lightCounter:-1)+1,e.counters.lightCounter=this._lightId,e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",r,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",r,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var o="v_"+n.associatedVariableName;e._emitVaryingFromString(o,"vec4")&&(e.compilationString+=o+" = "+n.associatedVariableName+";\r\n");var a=this.reflection.isConnected?null===(t=this.reflection.connectedPoint)||void 0===t?void 0:t.ownerBlock:null;a&&(a.viewConnectionPoint=this.view),e.compilationString+=null!==(i=null==a?void 0:a.handleVertexSide(e))&&void 0!==i?i:"",e._emitUniformFromString("vDebugMode","vec2","defined(IGNORE) || DEBUGMODE > 0"),e._emitUniformFromString("ambientFromScene","vec3"),e._emitVaryingFromString("vClipSpacePosition","vec4","defined(IGNORE) || DEBUGMODE > 0")&&(e._injectAtEnd+="#if DEBUGMODE > 0\r\n",e._injectAtEnd+="vClipSpacePosition = gl_Position;\r\n",e._injectAtEnd+="#endif\r\n"),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",r,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:n.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = "+n.associatedVariableName+";\r\n",this.view.isConnected&&(e.compilationString+="mat4 view = "+this.view.associatedVariableName+";\r\n"),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",r,{repeatKey:"maxSimultaneousLights"}))},t.prototype._getAlbedoOpacityCode=function(){var e="albedoOpacityOutParams albedoOpacityOut;\r\n";return e+="albedoOpacityBlock(\n vec4("+(this.baseColor.isConnected?this.baseColor.associatedVariableName:"vec3(1.)")+", 1.),\n #ifdef ALBEDO\n vec4(1.),\n vec2(1., 1.),\n #endif\n #ifdef OPACITY\n vec4("+(this.opacity.isConnected?this.opacity.associatedVariableName:"1.")+"),\n vec2(1., 1.),\n #endif\n albedoOpacityOut\n );\n\n vec3 surfaceAlbedo = albedoOpacityOut.surfaceAlbedo;\n float alpha = albedoOpacityOut.alpha;\r\n"},t.prototype._getAmbientOcclusionCode=function(){var e="ambientOcclusionOutParams aoOut;\r\n";return e+="ambientOcclusionBlock(\n #ifdef AMBIENT\n vec3("+(this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:"1.")+"),\n vec4(0., 1.0, 1.0, 0.),\n #endif\n aoOut\n );\r\n"},t.prototype._getReflectivityCode=function(e){var t="reflectivityOutParams reflectivityOut;\r\n";return this._vMetallicReflectanceFactorsName=e._getFreeVariableName("vMetallicReflectanceFactors"),e._emitUniformFromString(this._vMetallicReflectanceFactorsName,"vec4"),t+="vec3 baseColor = surfaceAlbedo;\n\n reflectivityBlock(\n vec4("+this.metallic.associatedVariableName+", "+this.roughness.associatedVariableName+", 0., 0.),\n #ifdef METALLICWORKFLOW\n surfaceAlbedo,\n "+this._vMetallicReflectanceFactorsName+",\n #endif\n #ifdef REFLECTIVITY\n vec3(0., 0., 1.),\n vec4(1.),\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor,\n #endif\n #ifdef MICROSURFACEMAP\n microSurfaceTexel, <== not handled!\n #endif\n reflectivityOut\n );\n\n float microSurface = reflectivityOut.microSurface;\n float roughness = reflectivityOut.roughness;\n\n #ifdef METALLICWORKFLOW\n surfaceAlbedo = reflectivityOut.surfaceAlbedo;\n #endif\n #if defined(METALLICWORKFLOW) && defined(REFLECTIVITY) && defined(AOSTOREINMETALMAPRED)\n aoOut.ambientOcclusionColor = reflectivityOut.ambientOcclusionColor;\n #endif\r\n"},t.prototype._buildBlock=function(t){var i,n,r,o,a,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T,E,S,A,P,C,R,x,O,M,I,D,N,L,w,F,B,U,V,k;e.prototype._buildBlock.call(this,t),this._scene=t.sharedData.scene,this._environmentBRDFTexture||(this._environmentBRDFTexture=To.GetEnvironmentBRDFTexture(this._scene));var z=this.reflection.isConnected?null===(i=this.reflection.connectedPoint)||void 0===i?void 0:i.ownerBlock:null;if(z&&(z.worldPositionConnectionPoint=this.worldPosition,z.cameraPositionConnectionPoint=this.cameraPosition,z.worldNormalConnectionPoint=this.worldNormal),t.target!==el.Fragment)return this._injectVertexCode(t),this;t.sharedData.bindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var G="//"+this.name,j="v_"+this.worldPosition.associatedVariableName,W=this.perturbedNormal;this._environmentBrdfSamplerName=t._getFreeVariableName("environmentBrdfSampler"),t._emit2DSampler(this._environmentBrdfSamplerName),t.sharedData.hints.needAlphaBlending=t.sharedData.hints.needAlphaBlending||this.useAlphaBlending,t.sharedData.hints.needAlphaTesting=t.sharedData.hints.needAlphaTesting||this.useAlphaTest,t._emitExtension("lod","#extension GL_EXT_shader_texture_lod : enable","defined(LODBASEDMICROSFURACE)"),t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",G,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",G,{repeatKey:"maxSimultaneousLights"}),t._emitFunctionFromInclude("helperFunctions",G),t._emitFunctionFromInclude("importanceSampling",G),t._emitFunctionFromInclude("pbrHelperFunctions",G),t._emitFunctionFromInclude("imageProcessingFunctions",G),t._emitFunctionFromInclude("shadowsFragmentFunctions",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrDirectLightingSetupFunctions",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions",G),t._emitFunctionFromInclude("pbrBRDFFunctions",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(n=null==z?void 0:z._defineSkyboxName)&&void 0!==n?n:"REFLECTIONMAP_SKYBOX"}]}),t._emitFunctionFromInclude("hdrFilteringFunctions",G),t._emitFunctionFromInclude("pbrDirectLightingFunctions",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"}]}),t._emitFunctionFromInclude("pbrIBLFunctions",G),t._emitFunctionFromInclude("pbrBlockAlbedoOpacity",G),t._emitFunctionFromInclude("pbrBlockReflectivity",G),t._emitFunctionFromInclude("pbrBlockAmbientOcclusion",G),t._emitFunctionFromInclude("pbrBlockAlphaFresnel",G),t._emitFunctionFromInclude("pbrBlockAnisotropic",G),t._emitUniformFromString("vLightingIntensity","vec4"),this._vNormalWName=t._getFreeVariableName("vNormalW"),t.compilationString+="vec4 "+this._vNormalWName+" = normalize("+this.worldNormal.associatedVariableName+");\r\n",t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize("+this.cameraPosition.associatedVariableName+" - "+j+".xyz);\r\n"),t.compilationString+="vec3 geometricNormalW = "+this._vNormalWName+".xyz;\r\n",t.compilationString+="vec3 normalW = "+(W.isConnected?"normalize("+W.associatedVariableName+".xyz)":"geometricNormalW")+";\r\n",this._invertNormalName=t._getFreeVariableName("invertNormal"),t._emitUniformFromString(this._invertNormalName,"float"),t.compilationString+=t._emitCodeFromInclude("pbrBlockNormalFinal",G,{replaceStrings:[{search:/vPositionW/g,replace:j+".xyz"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),t.compilationString+=this._getAlbedoOpacityCode(),t.compilationString+=t._emitCodeFromInclude("depthPrePass",G),t.compilationString+=this._getAmbientOcclusionCode(),t.compilationString+=t._emitCodeFromInclude("pbrBlockLightmapInit",G),t.compilationString+="#ifdef UNLIT\n vec3 diffuseBase = vec3(1., 1., 1.);\n #else\r\n",t.compilationString+=this._getReflectivityCode(t),t.compilationString+=t._emitCodeFromInclude("pbrBlockGeometryInfo",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(r=null==z?void 0:z._defineSkyboxName)&&void 0!==r?r:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:null!==(o=null==z?void 0:z._define3DName)&&void 0!==o?o:"REFLECTIONMAP_3D"}]});var H=this.anisotropy.isConnected?null===(a=this.anisotropy.connectedPoint)||void 0===a?void 0:a.ownerBlock:null;H&&(H.worldPositionConnectionPoint=this.worldPosition,H.worldNormalConnectionPoint=this.worldNormal,t.compilationString+=H.getCode(t,!this.perturbedNormal.isConnected)),z&&z.hasTexture&&(t.compilationString+=z.getCode(t,H?"anisotropicOut.anisotropicNormal":"normalW")),t._emitFunctionFromInclude("pbrBlockReflection",G,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:null!==(s=null==z?void 0:z._define3DName)&&void 0!==s?s:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(c=null==z?void 0:z._defineOppositeZ)&&void 0!==c?c:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(l=null==z?void 0:z._defineProjectionName)&&void 0!==l?l:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(u=null==z?void 0:z._defineSkyboxName)&&void 0!==u?u:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(h=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==h?h:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(d=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==d?d:"LINEARSPECULARREFLECTION"},{search:/vReflectionFilteringInfo/g,replace:null!==(f=null==z?void 0:z._vReflectionFilteringInfoName)&&void 0!==f?f:"vReflectionFilteringInfo"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance0",G,{replaceStrings:[{search:/metallicReflectanceFactors/g,replace:this._vMetallicReflectanceFactorsName}]});var X=this.sheen.isConnected?null===(p=this.sheen.connectedPoint)||void 0===p?void 0:p.ownerBlock:null;X&&(t.compilationString+=X.getCode(z)),t._emitFunctionFromInclude("pbrBlockSheen",G,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(_=null==z?void 0:z._define3DName)&&void 0!==_?_:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(m=null==z?void 0:z._defineSkyboxName)&&void 0!==m?m:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(g=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==g?g:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(v=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==v?v:"LINEARSPECULARREFLECTION"}]});var Y=this.clearcoat.isConnected?null===(b=this.clearcoat.connectedPoint)||void 0===b?void 0:b.ownerBlock:null,K=!this.perturbedNormal.isConnected&&!this.anisotropy.isConnected,Q=this.perturbedNormal.isConnected&&(null===(y=this.perturbedNormal.connectedPoint)||void 0===y?void 0:y.ownerBlock).worldTangent.isConnected,q=this.anisotropy.isConnected&&(null===(T=this.anisotropy.connectedPoint)||void 0===T?void 0:T.ownerBlock).worldTangent.isConnected,Z=Q||!this.perturbedNormal.isConnected&&q;t.compilationString+=ih.GetCode(t,Y,z,j,K,Z,this.worldNormal.associatedVariableName),K&&(Z=null!==(E=null==Y?void 0:Y.worldTangent.isConnected)&&void 0!==E&&E),t._emitFunctionFromInclude("pbrBlockClearcoat",G,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:null!==(S=null==z?void 0:z._define3DName)&&void 0!==S?S:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(A=null==z?void 0:z._defineOppositeZ)&&void 0!==A?A:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(P=null==z?void 0:z._defineProjectionName)&&void 0!==P?P:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(C=null==z?void 0:z._defineSkyboxName)&&void 0!==C?C:"REFLECTIONMAP_SKYBOX"},{search:/LODINREFLECTIONALPHA/g,replace:null!==(R=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==R?R:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(x=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==x?x:"LINEARSPECULARREFLECTION"},{search:/defined\(TANGENT\)/g,replace:Z?"defined(TANGENT)":"defined(IGNORE)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance",G,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(O=null==z?void 0:z._defineSkyboxName)&&void 0!==O?O:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:null!==(M=null==z?void 0:z._define3DName)&&void 0!==M?M:"REFLECTIONMAP_3D"}]});var J=this.subsurface.isConnected?null===(I=this.subsurface.connectedPoint)||void 0===I?void 0:I.ownerBlock:null,$=this.subsurface.isConnected?null===(N=(null===(D=this.subsurface.connectedPoint)||void 0===D?void 0:D.ownerBlock).refraction.connectedPoint)||void 0===N?void 0:N.ownerBlock:null;$&&($.viewConnectionPoint=this.view,$.indexOfRefractionConnectionPoint=this.indexOfRefraction),t.compilationString+=rh.GetCode(t,J,z,j),t._emitFunctionFromInclude("pbrBlockSubSurface",G,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(L=null==z?void 0:z._define3DName)&&void 0!==L?L:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(w=null==z?void 0:z._defineOppositeZ)&&void 0!==w?w:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(F=null==z?void 0:z._defineProjectionName)&&void 0!==F?F:"REFLECTIONMAP_PROJECTION"},{search:/SS_REFRACTIONMAP_3D/g,replace:null!==(B=null==$?void 0:$._define3DName)&&void 0!==B?B:"SS_REFRACTIONMAP_3D"},{search:/SS_LODINREFRACTIONALPHA/g,replace:null!==(U=null==$?void 0:$._defineLODRefractionAlpha)&&void 0!==U?U:"SS_LODINREFRACTIONALPHA"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:null!==(V=null==$?void 0:$._defineLinearSpecularRefraction)&&void 0!==V?V:"SS_LINEARSPECULARREFRACTION"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:null!==(k=null==$?void 0:$._defineOppositeZ)&&void 0!==k?k:"SS_REFRACTIONMAP_OPPOSITEZ"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockDirectLighting",G),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",G,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",G,{repeatKey:"maxSimultaneousLights"}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalLitComponents",G),t.compilationString+="#endif\r\n";var ee=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:"vec3(0., 0., 0.)",te=_a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();-1===te.indexOf(".")&&(te+="."),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalUnlitComponents",G,{replaceStrings:[{search:/vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,replace:""},{search:/vAmbientColor/g,replace:ee+" * ambientFromScene"},{search:/vAmbientInfos\.w/g,replace:te}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalColorComposition",G,{replaceStrings:[{search:/finalEmissive/g,replace:"vec3(0.)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockImageProcessing",G,{replaceStrings:[{search:/visibility/g,replace:"1."}]}),t.compilationString+=t._emitCodeFromInclude("pbrDebug",G,{replaceStrings:[{search:/vNormalW/g,replace:this._vNormalWName},{search:/vPositionW/g,replace:j},{search:/albedoTexture\.rgb;/g,replace:"vec3(1.);\r\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r\n"}]});for(var ie=0,ne=this._outputs;ie<ne.length;ie++){var re=ne[ie];if(re.hasEndpoints){var oe=oh[re.name];if(oe){var ae=oe[0],se=oe[1];se&&(t.compilationString+="#if "+se+"\r\n"),t.compilationString+=this._declareOutput(re,t)+" = "+ae+";\r\n",se&&(t.compilationString+="#else\r\n",t.compilationString+=this._declareOutput(re,t)+" = vec3(0.);\r\n",t.compilationString+="#endif\r\n")}else console.error("There's no remapping for the "+re.name+" end point! No code generated")}}return this},t.prototype._dumpPropertiesCode=function(){var e="";return e+=this._codeVariableName+".lightFalloff = "+this.lightFalloff+";\r\n",e+=this._codeVariableName+".useAlphaTest = "+this.useAlphaTest+";\r\n",e+=this._codeVariableName+".alphaTestCutoff = "+this.alphaTestCutoff+";\r\n",e+=this._codeVariableName+".useAlphaBlending = "+this.useAlphaBlending+";\r\n",e+=this._codeVariableName+".useRadianceOverAlpha = "+this.useRadianceOverAlpha+";\r\n",e+=this._codeVariableName+".useSpecularOverAlpha = "+this.useSpecularOverAlpha+";\r\n",e+=this._codeVariableName+".enableSpecularAntiAliasing = "+this.enableSpecularAntiAliasing+";\r\n",e+=this._codeVariableName+".realTimeFiltering = "+this.realTimeFiltering+";\r\n",e+=this._codeVariableName+".realTimeFilteringQuality = "+this.realTimeFilteringQuality+";\r\n",e+=this._codeVariableName+".useEnergyConservation = "+this.useEnergyConservation+";\r\n",e+=this._codeVariableName+".useRadianceOcclusion = "+this.useRadianceOcclusion+";\r\n",e+=this._codeVariableName+".useHorizonOcclusion = "+this.useHorizonOcclusion+";\r\n",e+=this._codeVariableName+".unlit = "+this.unlit+";\r\n",e+=this._codeVariableName+".forceNormalForward = "+this.forceNormalForward+";\r\n",e+=this._codeVariableName+".debugMode = "+this.debugMode+";\r\n",e+=this._codeVariableName+".debugLimit = "+this.debugLimit+";\r\n",e+=this._codeVariableName+".debugFactor = "+this.debugFactor+";\r\n"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.light&&(t.lightId=this.light.id),t.lightFalloff=this.lightFalloff,t.useAlphaTest=this.useAlphaTest,t.alphaTestCutoff=this.alphaTestCutoff,t.useAlphaBlending=this.useAlphaBlending,t.useRadianceOverAlpha=this.useRadianceOverAlpha,t.useSpecularOverAlpha=this.useSpecularOverAlpha,t.enableSpecularAntiAliasing=this.enableSpecularAntiAliasing,t.realTimeFiltering=this.realTimeFiltering,t.realTimeFilteringQuality=this.realTimeFilteringQuality,t.useEnergyConservation=this.useEnergyConservation,t.useRadianceOcclusion=this.useRadianceOcclusion,t.useHorizonOcclusion=this.useHorizonOcclusion,t.unlit=this.unlit,t.forceNormalForward=this.forceNormalForward,t.debugMode=this.debugMode,t.debugLimit=this.debugLimit,t.debugFactor=this.debugFactor,t},t.prototype._deserialize=function(t,i,n){var r,o;e.prototype._deserialize.call(this,t,i,n),t.lightId&&(this.light=i.getLightByID(t.lightId)),this.lightFalloff=null!==(r=t.lightFalloff)&&void 0!==r?r:0,this.useAlphaTest=t.useAlphaTest,this.alphaTestCutoff=t.alphaTestCutoff,this.useAlphaBlending=t.useAlphaBlending,this.useRadianceOverAlpha=t.useRadianceOverAlpha,this.useSpecularOverAlpha=t.useSpecularOverAlpha,this.enableSpecularAntiAliasing=t.enableSpecularAntiAliasing,this.realTimeFiltering=!!t.realTimeFiltering,this.realTimeFilteringQuality=null!==(o=t.realTimeFilteringQuality)&&void 0!==o?o:g.a.TEXTURE_FILTERING_QUALITY_LOW,this.useEnergyConservation=t.useEnergyConservation,this.useRadianceOcclusion=t.useRadianceOcclusion,this.useHorizonOcclusion=t.useHorizonOcclusion,this.unlit=t.unlit,this.forceNormalForward=!!t.forceNormalForward,this.debugMode=t.debugMode,this.debugLimit=t.debugLimit,this.debugFactor=t.debugFactor},Object(h.c)([Ml("Direct lights",xl.Float,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"directIntensity",void 0),Object(h.c)([Ml("Environment lights",xl.Float,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"environmentIntensity",void 0),Object(h.c)([Ml("Specular highlights",xl.Float,"INTENSITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"specularIntensity",void 0),Object(h.c)([Ml("Light falloff",xl.List,"LIGHTING & COLORS",{notifiers:{update:!0},options:[{label:"Physical",value:_a.LIGHTFALLOFF_PHYSICAL},{label:"GLTF",value:_a.LIGHTFALLOFF_GLTF},{label:"Standard",value:_a.LIGHTFALLOFF_STANDARD}]})],t.prototype,"lightFalloff",void 0),Object(h.c)([Ml("Alpha Testing",xl.Boolean,"OPACITY")],t.prototype,"useAlphaTest",void 0),Object(h.c)([Ml("Alpha CutOff",xl.Float,"OPACITY",{min:0,max:1,notifiers:{update:!0}})],t.prototype,"alphaTestCutoff",void 0),Object(h.c)([Ml("Alpha blending",xl.Boolean,"OPACITY")],t.prototype,"useAlphaBlending",void 0),Object(h.c)([Ml("Radiance over alpha",xl.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"useRadianceOverAlpha",void 0),Object(h.c)([Ml("Specular over alpha",xl.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"useSpecularOverAlpha",void 0),Object(h.c)([Ml("Specular anti-aliasing",xl.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"enableSpecularAntiAliasing",void 0),Object(h.c)([Ml("Realtime filtering",xl.Boolean,"RENDERING",{notifiers:{update:!0}})],t.prototype,"realTimeFiltering",void 0),Object(h.c)([Ml("Realtime filtering quality",xl.List,"RENDERING",{notifiers:{update:!0},options:[{label:"Low",value:g.a.TEXTURE_FILTERING_QUALITY_LOW},{label:"Medium",value:g.a.TEXTURE_FILTERING_QUALITY_MEDIUM},{label:"High",value:g.a.TEXTURE_FILTERING_QUALITY_HIGH}]})],t.prototype,"realTimeFilteringQuality",void 0),Object(h.c)([Ml("Energy Conservation",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useEnergyConservation",void 0),Object(h.c)([Ml("Radiance occlusion",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useRadianceOcclusion",void 0),Object(h.c)([Ml("Horizon occlusion",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"useHorizonOcclusion",void 0),Object(h.c)([Ml("Unlit",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"unlit",void 0),Object(h.c)([Ml("Force normal forward",xl.Boolean,"ADVANCED",{notifiers:{update:!0}})],t.prototype,"forceNormalForward",void 0),Object(h.c)([Ml("Debug mode",xl.List,"DEBUG",{notifiers:{update:!0},options:[{label:"None",value:0},{label:"Normalized position",value:1},{label:"Normals",value:2},{label:"Tangents",value:3},{label:"Bitangents",value:4},{label:"Bump Normals",value:5},{label:"ClearCoat Normals",value:8},{label:"ClearCoat Tangents",value:9},{label:"ClearCoat Bitangents",value:10},{label:"Anisotropic Normals",value:11},{label:"Anisotropic Tangents",value:12},{label:"Anisotropic Bitangents",value:13},{label:"Env Refraction",value:40},{label:"Env Reflection",value:41},{label:"Env Clear Coat",value:42},{label:"Direct Diffuse",value:50},{label:"Direct Specular",value:51},{label:"Direct Clear Coat",value:52},{label:"Direct Sheen",value:53},{label:"Env Irradiance",value:54},{label:"Surface Albedo",value:60},{label:"Reflectance 0",value:61},{label:"Metallic",value:62},{label:"Metallic F0",value:71},{label:"Roughness",value:63},{label:"AlphaG",value:64},{label:"NdotV",value:65},{label:"ClearCoat Color",value:66},{label:"ClearCoat Roughness",value:67},{label:"ClearCoat NdotV",value:68},{label:"Transmittance",value:69},{label:"Refraction Transmittance",value:70},{label:"SEO",value:80},{label:"EHO",value:81},{label:"Energy Factor",value:82},{label:"Specular Reflectance",value:83},{label:"Clear Coat Reflectance",value:84},{label:"Sheen Reflectance",value:85},{label:"Luminance Over Alpha",value:86},{label:"Alpha",value:87}]})],t.prototype,"debugMode",void 0),Object(h.c)([Ml("Split position",xl.Float,"DEBUG",{min:-1,max:1,notifiers:{update:!0}})],t.prototype,"debugLimit",void 0),Object(h.c)([Ml("Output factor",xl.Float,"DEBUG",{min:0,max:5,notifiers:{update:!0}})],t.prototype,"debugFactor",void 0),t}(fl);c.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessBlock"]=ah;var sh=function(e){function t(t){var i=e.call(this,t,el.Neutral)||this;return i.registerInput("left",tl.AutoDetect),i.registerInput("right",tl.AutoDetect),i.registerOutput("output",tl.BasedOnInput),i._outputs[0]._typeConnectionSource=i._inputs[0],i._linkConnectionTypes(0,1),i}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ModBlock"},Object.defineProperty(t.prototype,"left",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"right",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"output",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var i=this._outputs[0];return t.compilationString+=this._declareOutput(i,t)+" = mod("+this.left.associatedVariableName+", "+this.right.associatedVariableName+");\r\n",this},t}(fl);c.a.RegisteredTypes["BABYLON.ModBlock"]=sh;var ch=function(){function e(){}return e.prototype.optimize=function(e,t){},e}(),lh=i(120),uh=function(){function e(){this.mm=new Map}return e.prototype.get=function(e,t){var i=this.mm.get(e);if(void 0!==i)return i.get(t)},e.prototype.set=function(e,t,i){var n=this.mm.get(e);void 0===n&&this.mm.set(e,n=new Map),n.set(t,i)},e}(),hh=function(){function e(e,t,i){var n=this;this._baseMaterial=e,this._scene=t,this._options=i,this._subMeshToEffect=new Map,this._subMeshToDepthEffect=new uh,this._meshes=new Map;var r="NodeMaterial"===e.getClassName()?"u_":"";if(r){this._matriceNames={world:r+"World",view:r+"View",projection:r+"Projection",viewProjection:r+"ViewProjection",worldView:r+"WorldxView",worldViewProjection:r+"WorldxViewxProjection"};for(var o=e.getInputBlocks(),a=0;a<o.length;++a)switch(o[a]._systemValue){case nl.World:this._matriceNames.world=o[a].associatedVariableName;break;case nl.View:this._matriceNames.view=o[a].associatedVariableName;break;case nl.Projection:this._matriceNames.projection=o[a].associatedVariableName;break;case nl.ViewProjection:this._matriceNames.viewProjection=o[a].associatedVariableName;break;case nl.WorldView:this._matriceNames.worldView=o[a].associatedVariableName;break;case nl.WorldViewProjection:this._matriceNames.worldViewProjection=o[a].associatedVariableName}}else this._matriceNames={world:r+"world",view:r+"view",projection:r+"projection",viewProjection:r+"viewProjection",worldView:r+"worldView",worldViewProjection:r+"worldViewProjection"};this._onEffectCreatedObserver=this._baseMaterial.onEffectCreatedObservable.add((function(e){var t,i=null===(t=e.subMesh)||void 0===t?void 0:t.getMesh();i&&!n._meshes.has(i)&&n._meshes.set(i,i.onDisposeObservable.add((function(e){for(var t=n._subMeshToEffect.keys(),i=t.next();!0!==i.done;i=t.next()){var r=i.value;(null==r?void 0:r.getMesh())===e&&(n._subMeshToEffect.delete(r),n._subMeshToDepthEffect.mm.delete(r))}}))),n._subMeshToEffect.set(e.subMesh,e.effect),n._subMeshToDepthEffect.mm.delete(e.subMesh)}))}return Object.defineProperty(e.prototype,"standalone",{get:function(){var e,t;return null!==(t=null===(e=this._options)||void 0===e?void 0:e.standalone)&&void 0!==t&&t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"baseMaterial",{get:function(){return this._baseMaterial},enumerable:!1,configurable:!0}),e.prototype.getEffect=function(e,t){var i,n,r,o,a,s;return null!==(s=null!==(r=null===(n=null===(i=this._subMeshToDepthEffect.mm.get(e))||void 0===i?void 0:i.get(t))||void 0===n?void 0:n.depthEffect)&&void 0!==r?r:null===(a=null===(o=this._subMeshToDepthEffect.mm.get(null))||void 0===o?void 0:o.get(t))||void 0===a?void 0:a.depthEffect)&&void 0!==s?s:null},e.prototype.isReadyForSubMesh=function(e,t,i,n){var r,o;return this.standalone&&this._baseMaterial.isReadyForSubMesh(e.getMesh(),e,n),null!==(o=null===(r=this._makeEffect(e,t,i))||void 0===r?void 0:r.isReady())&&void 0!==o&&o},e.prototype.dispose=function(){this._baseMaterial.onEffectCreatedObservable.remove(this._onEffectCreatedObserver),this._onEffectCreatedObserver=null;for(var e=this._meshes.entries(),t=e.next();!0!==t.done;t=e.next()){var i=t.value,n=i[0],r=i[1];n.onDisposeObservable.remove(r)}},e.prototype._makeEffect=function(e,t,i){var n,r=null!==(n=this._subMeshToEffect.get(e))&&void 0!==n?n:this._subMeshToEffect.get(null);if(!r)return null;var o=this._subMeshToDepthEffect.get(e,i);o||(o={depthEffect:null,depthDefines:"",token:lh.a.RandomId()},this._subMeshToDepthEffect.set(e,i,o));var a=t.join("\n");if(o.depthEffect&&a===o.depthDefines)return o.depthEffect;o.depthDefines=a;var s=r.rawVertexSourceCode,c=r.rawFragmentSourceCode,l=this._options&&this._options.remappedVariables?"#include<shadowMapVertexNormalBias>("+this._options.remappedVariables.join(",")+")":ai.a.IncludesShadersStore.shadowMapVertexNormalBias,u=this._options&&this._options.remappedVariables?"#include<shadowMapVertexMetric>("+this._options.remappedVariables.join(",")+")":ai.a.IncludesShadersStore.shadowMapVertexMetric,h=this._options&&this._options.remappedVariables?"#include<shadowMapFragmentSoftTransparentShadow>("+this._options.remappedVariables.join(",")+")":ai.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow,d=ai.a.IncludesShadersStore.shadowMapFragment;s=(s=-1!==(s=(s=s.replace(/void\s+?main/g,ai.a.IncludesShadersStore.shadowMapVertexDeclaration+"\r\nvoid main")).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,l)).indexOf("#define SHADOWDEPTH_METRIC")?s.replace(/#define SHADOWDEPTH_METRIC/g,u):s.replace(/}\s*$/g,u+"\r\n}")).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var f=c.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||c.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,p=-1!==c.indexOf("#define SHADOWDEPTH_FRAGMENT"),_="";f?c=c.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,h):_=h+"\r\n",c=c.replace(/void\s+?main/g,ai.a.IncludesShadersStore.shadowMapFragmentDeclaration+"\r\nvoid main"),p?c=c.replace(/#define SHADOWDEPTH_FRAGMENT/g,d):_+=d+"\r\n",_&&(c=c.replace(/}\s*$/g,_+"}")),c=c.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var m=r.getUniformNames().slice();return m.push("biasAndScaleSM","depthValuesSM","lightDataSM","softTransparentShadowSM"),o.depthEffect=this._scene.getEngine().createEffect({vertexSource:s,fragmentSource:c,vertexToken:o.token,fragmentToken:o.token},{attributes:r.getAttributesNames(),uniformsNames:m,uniformBuffersNames:r.getUniformBuffersNames(),samplers:r.getSamplers(),defines:a+"\n"+r.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:r.getIndexParameters()},this._scene.getEngine()),o.depthEffect},e}(),dh=i(101);function fh(e,t,i,n,r){var o=new e.DecoderBuffer;o.Init(t,t.byteLength);var a,s,c=new e.Decoder;try{var l=c.GetEncodedGeometryType(o);switch(l){case e.TRIANGULAR_MESH:a=new e.Mesh,s=c.DecodeBufferToMesh(o,a);break;case e.POINT_CLOUD:a=new e.PointCloud,s=c.DecodeBufferToPointCloud(o,a);break;default:throw new Error("Invalid geometry type "+l)}if(!s.ok()||!a.ptr)throw new Error(s.error_msg());if(l===e.TRIANGULAR_MESH){var u=3*a.num_faces(),h=4*u,d=e._malloc(h);try{c.GetTrianglesUInt32Array(a,h,d);var f=new Uint32Array(u);f.set(new Uint32Array(e.HEAPF32.buffer,d,u)),n(f)}finally{e._free(d)}}var p=function(t,i){var n=i.num_components(),o=a.num_points(),s=o*n,l=s*Float32Array.BYTES_PER_ELEMENT,u=e._malloc(l);try{c.GetAttributeDataArrayForAllPoints(a,i,e.DT_FLOAT32,l,u);var h=new Float32Array(e.HEAPF32.buffer,u,s);if("color"===t&&3===n){for(var d=new Float32Array(4*o),f=0,p=0;f<d.length;f+=4,p+=n)d[f+0]=h[p+0],d[f+1]=h[p+1],d[f+2]=h[p+2],d[f+3]=1;r(t,d)}else{(d=new Float32Array(s)).set(new Float32Array(e.HEAPF32.buffer,u,s)),r(t,d)}}finally{e._free(u)}};if(i)for(var _ in i){var m=i[_];p(_,c.GetAttributeByUniqueId(a,m))}else{var g={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"};for(var _ in g){if(-1!==(m=c.GetAttributeId(a,e[g[_]])))p(_,c.GetAttribute(a,m))}}}finally{a&&e.destroy(a),e.destroy(c),e.destroy(o)}}function ph(){var e;onmessage=function(t){var i=t.data;switch(i.id){case"init":var n=i.decoder;n.url&&(importScripts(n.url),e=DracoDecoderModule({wasmBinary:n.wasmBinary})),postMessage("done");break;case"decodeMesh":if(!e)throw new Error("Draco decoder module is not available");e.then((function(e){fh(e,i.dataView,i.attributes,(function(e){postMessage({id:"indices",value:e},[e.buffer])}),(function(e,t){postMessage({id:e,value:t},[t.buffer])})),postMessage("done")}))}}}function _h(e){return"object"!=typeof document||"string"!=typeof e?e:Ce.b.GetAbsoluteUrl(e)}var mh=function(){function e(t){void 0===t&&(t=e.DefaultNumWorkers);var i=e.Configuration.decoder,n=i.wasmUrl&&i.wasmBinaryUrl&&"object"==typeof WebAssembly?{url:i.wasmUrl,wasmBinaryPromise:Ce.b.LoadFileAsync(_h(i.wasmBinaryUrl))}:{url:i.fallbackUrl,wasmBinaryPromise:Promise.resolve(void 0)};t&&"function"==typeof Worker?this._workerPoolPromise=n.wasmBinaryPromise.then((function(e){for(var i=fh+"("+ph+")()",r=URL.createObjectURL(new Blob([i],{type:"application/javascript"})),o=new Array(t),a=0;a<o.length;a++)o[a]=new Promise((function(t,i){var o=new Worker(r),a=function(e){o.removeEventListener("error",a),o.removeEventListener("message",s),i(e)},s=function(e){"done"===e.data&&(o.removeEventListener("error",a),o.removeEventListener("message",s),t(o))};o.addEventListener("error",a),o.addEventListener("message",s),o.postMessage({id:"init",decoder:{url:_h(n.url),wasmBinary:e}})}));return Promise.all(o).then((function(e){return new Ca(e)}))})):this._decoderModulePromise=n.wasmBinaryPromise.then((function(e){if(!n.url)throw new Error("Draco decoder module is not available");return Ce.b.LoadScriptAsync(n.url).then((function(){return t=e,new Promise((function(e){DracoDecoderModule({wasmBinary:t}).then((function(t){e({module:t})}))}));var t}))}))}return Object.defineProperty(e,"DecoderAvailable",{get:function(){var t=e.Configuration.decoder;return!!(t.wasmUrl&&t.wasmBinaryUrl&&"object"==typeof WebAssembly||t.fallbackUrl)},enumerable:!1,configurable:!0}),e.GetDefaultNumWorkers=function(){return"object"==typeof navigator&&navigator.hardwareConcurrency?Math.min(Math.floor(.5*navigator.hardwareConcurrency),4):1},Object.defineProperty(e,"Default",{get:function(){return e._Default||(e._Default=new e),e._Default},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){this._workerPoolPromise&&this._workerPoolPromise.then((function(e){e.dispose()})),delete this._workerPoolPromise,delete this._decoderModulePromise},e.prototype.whenReadyAsync=function(){return this._workerPoolPromise?this._workerPoolPromise.then((function(){})):this._decoderModulePromise?this._decoderModulePromise.then((function(){})):Promise.resolve()},e.prototype.decodeMeshAsync=function(e,t){var i=e instanceof ArrayBuffer?new Uint8Array(e):e;if(this._workerPoolPromise)return this._workerPoolPromise.then((function(e){return new Promise((function(n,r){e.push((function(e,o){var a=new Ki.a,s=function(t){e.removeEventListener("error",s),e.removeEventListener("message",c),r(t),o()},c=function(t){"done"===t.data?(e.removeEventListener("error",s),e.removeEventListener("message",c),n(a),o()):"indices"===t.data.id?a.indices=t.data.value:a.set(t.data.value,t.data.id)};e.addEventListener("error",s),e.addEventListener("message",c);var l=new Uint8Array(i.byteLength);l.set(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)),e.postMessage({id:"decodeMesh",dataView:l,attributes:t},[l.buffer])}))}))}));if(this._decoderModulePromise)return this._decoderModulePromise.then((function(e){var n=new Ki.a;return fh(e.module,i,t,(function(e){n.indices=e}),(function(e,t){n.set(t,e)})),n}));throw new Error("Draco decoder module is not available")},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.DefaultNumWorkers=e.GetDefaultNumWorkers(),e._Default=null,e}(),gh=i(61),vh=0,bh=function(){function e(e,t,i,n){this.pos=e,this.normal=t,this.uv=i,this.vertColor=n}return e.prototype.clone=function(){var t,i;return new e(this.pos.clone(),this.normal.clone(),null===(t=this.uv)||void 0===t?void 0:t.clone(),null===(i=this.vertColor)||void 0===i?void 0:i.clone())},e.prototype.flip=function(){this.normal=this.normal.scale(-1)},e.prototype.interpolate=function(t,i){return new e(a.e.Lerp(this.pos,t.pos,i),a.e.Lerp(this.normal,t.normal,i),this.uv&&t.uv?a.d.Lerp(this.uv,t.uv,i):void 0,this.vertColor&&t.vertColor?s.b.Lerp(this.vertColor,t.vertColor,i):void 0)},e}(),yh=function(){function e(e,t){this.normal=e,this.w=t}return e.FromPoints=function(t,i,n){var r=n.subtract(t),o=i.subtract(t);if(0===r.lengthSquared()||0===o.lengthSquared())return null;var s=a.e.Normalize(a.e.Cross(r,o));return new e(s,a.e.Dot(s,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,n,r,o){var s,c,l=0,u=[];for(s=0;s<t.vertices.length;s++){var h=(c=a.e.Dot(this.normal,t.vertices[s].pos)-this.w)<-e.EPSILON?2:c>e.EPSILON?1:0;l|=h,u.push(h)}switch(l){case 0:(a.e.Dot(this.normal,t.plane.normal)>0?i:n).push(t);break;case 1:r.push(t);break;case 2:o.push(t);break;case 3:var d,f=[],p=[];for(s=0;s<t.vertices.length;s++){var _=(s+1)%t.vertices.length,m=u[s],g=u[_],v=t.vertices[s],b=t.vertices[_];if(2!==m&&f.push(v),1!==m&&p.push(2!==m?v.clone():v),3==(m|g)){c=(this.w-a.e.Dot(this.normal,v.pos))/a.e.Dot(this.normal,b.pos.subtract(v.pos));var y=v.interpolate(b,c);f.push(y),p.push(y.clone())}}f.length>=3&&(d=new Th(f,t.shared)).plane&&r.push(d),p.length>=3&&(d=new Th(p,t.shared)).plane&&o.push(d)}},e.EPSILON=1e-5,e}(),Th=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=yh.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}(),Eh=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,n=0;n<e.length;n++)this.plane.splitPolygon(e[n],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,n=new Array,r=0;r<t.length;r++)this.plane.splitPolygon(t[r],this.polygons,this.polygons,i,n);i.length&&(this.front||(this.front=new e),this.front.build(i)),n.length&&(this.back||(this.back=new e),this.back.build(n))}},e}(),Sh=function(){function e(){this.polygons=new Array}return e.FromMesh=function(t){var i,n,r,o,c,l,u,h,d,f=void 0,p=void 0,_=new Array,m=null;if(!(t instanceof be.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&&(m=t.rotationQuaternion.clone()),d=t.scaling.clone();for(var g=t.getIndices(),v=t.getVerticesData(Qi.b.PositionKind),b=t.getVerticesData(Qi.b.NormalKind),y=t.getVerticesData(Qi.b.UVKind),T=t.getVerticesData(Qi.b.ColorKind),E=t.subMeshes,S=0,A=E.length;S<A;S++)for(var P=E[S].indexStart,C=E[S].indexCount+E[S].indexStart;P<C;P+=3){c=[];for(var R=0;R<3;R++){var x=new a.e(b[3*g[P+R]],b[3*g[P+R]+1],b[3*g[P+R]+2]);y&&(f=new a.d(y[2*g[P+R]],y[2*g[P+R]+1])),T&&(p=new s.b(T[4*g[P+R]],T[4*g[P+R]+1],T[4*g[P+R]+2],T[4*g[P+R]+3]));var O=new a.e(v[3*g[P+R]],v[3*g[P+R]+1],v[3*g[P+R]+2]);r=a.e.TransformCoordinates(O,l),n=a.e.TransformNormal(x,l),i=new bh(r,n,f,p),c.push(i)}(o=new Th(c,{subMeshId:S,meshId:vh,materialIndex:E[S].materialIndex})).plane&&_.push(o)}var M=e.FromPolygons(_);return M.matrix=l,M.position=u,M.rotation=h,M.scaling=d,M.rotationQuaternion=m,vh++,M},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 Eh(this.clone().polygons),n=new Eh(t.clone().polygons);return i.clipTo(n),n.clipTo(i),n.invert(),n.clipTo(i),n.invert(),i.build(n.allPolygons()),e.FromPolygons(i.allPolygons()).copyTransformAttributes(this)},e.prototype.unionInPlace=function(e){var t=new Eh(this.polygons),i=new Eh(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 Eh(this.clone().polygons),n=new Eh(t.clone().polygons);return i.invert(),i.clipTo(n),n.clipTo(i),n.invert(),n.clipTo(i),n.invert(),i.build(n.allPolygons()),i.invert(),e.FromPolygons(i.allPolygons()).copyTransformAttributes(this)},e.prototype.subtractInPlace=function(e){var t=new Eh(this.polygons),i=new Eh(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 Eh(this.clone().polygons),n=new Eh(t.clone().polygons);return i.invert(),n.clipTo(i),n.invert(),i.clipTo(n),n.clipTo(i),i.build(n.allPolygons()),i.invert(),e.FromPolygons(i.allPolygons()).copyTransformAttributes(this)},e.prototype.intersectInPlace=function(e){var t=new Eh(this.polygons),i=new Eh(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 n=this.matrix.clone();n.invert();var r,o,c,l=new be.a(e,t),u=[],h=[],d=[],f=null,p=null,_=a.e.Zero(),m=a.e.Zero(),g=a.d.Zero(),v=new s.b(0,0,0,0),b=this.polygons,y=[0,0,0],T={},E=0,S={};i&&b.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 A=0,P=b.length;A<P;A++){S[(r=b[A]).shared.meshId]||(S[r.shared.meshId]={}),S[r.shared.meshId][r.shared.subMeshId]||(S[r.shared.meshId][r.shared.subMeshId]={indexStart:1/0,indexEnd:-1/0,materialIndex:r.shared.materialIndex}),c=S[r.shared.meshId][r.shared.subMeshId];for(var C=2,R=r.vertices.length;C<R;C++){y[0]=0,y[1]=C-1,y[2]=C;for(var x=0;x<3;x++){_.copyFrom(r.vertices[y[x]].pos),m.copyFrom(r.vertices[y[x]].normal),r.vertices[y[x]].uv&&(f||(f=[]),g.copyFrom(r.vertices[y[x]].uv)),r.vertices[y[x]].vertColor&&(p||(p=[]),v.copyFrom(r.vertices[y[x]].vertColor));var O=a.e.TransformCoordinates(_,n),M=a.e.TransformNormal(m,n);o=T[O.x+","+O.y+","+O.z];var I=!1;f&&f[2*o]!==g.x&&f[2*o+1]!==g.y&&(I=!0);var D=!1;p&&p[4*o]!==v.r&&p[4*o+1]!==v.g&&p[4*o+2]!==v.b&&p[4*o+3]!==v.a&&(D=!0),(void 0===o||d[3*o]!==M.x||d[3*o+1]!==M.y||d[3*o+2]!==M.z||I||D)&&(u.push(O.x,O.y,O.z),f&&f.push(g.x,g.y),d.push(m.x,m.y,m.z),p&&p.push(v.r,v.g,v.b,v.a),o=T[O.x+","+O.y+","+O.z]=u.length/3-1),h.push(o),c.indexStart=Math.min(E,c.indexStart),c.indexEnd=Math.max(E,c.indexEnd),E++}}}if(l.setVerticesData(Qi.b.PositionKind,u),l.setVerticesData(Qi.b.NormalKind,d),f&&l.setVerticesData(Qi.b.UVKind,f),p&&l.setVerticesData(Qi.b.ColorKind,p),l.setIndices(h,null),i){var N,L=0;for(var w in l.subMeshes=new Array,S){for(var F in N=-1,S[w])c=S[w][F],gh.a.CreateFromIndices(c.materialIndex+L,c.indexStart,c.indexEnd-c.indexStart+1,l),N=Math.max(c.materialIndex,N);L+=++N}}return l},e.prototype.toMesh=function(e,t,i,n){void 0===t&&(t=null);var r=this.buildMeshGeometry(e,i,n);return r.material=t,r.position.copyFrom(this.position),r.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(r.rotationQuaternion=this.rotationQuaternion.clone()),r.scaling.copyFrom(this.scaling),r.computeWorldMatrix(!0),r},e}(),Ah=function(e){function t(t,i,n,r,o,s){void 0===r&&(r=1),void 0===o&&(o=60),void 0===s&&(s=!0);var c=e.call(this,t,n)||this;c._sectionPolygonPointsCount=4,c._running=!1,c._autoStart=s,c._generator=i,c._diameter=r,c._length=o,c._sectionVectors=[],c._sectionNormalVectors=[];for(var l=0;l<c._sectionPolygonPointsCount;l++)c._sectionVectors[l]=a.e.Zero(),c._sectionNormalVectors[l]=a.e.Zero();return c._createMesh(),c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"TrailMesh"},t.prototype._createMesh=function(){var e=new Ki.a,t=[],i=[],n=[],r=a.e.Zero();r=this._generator instanceof Ge.a&&this._generator._boundingInfo?this._generator._boundingInfo.boundingBox.centerWorld:this._generator.position;for(var o=2*Math.PI/this._sectionPolygonPointsCount,s=0;s<this._sectionPolygonPointsCount;s++)t.push(r.x+Math.cos(s*o)*this._diameter,r.y+Math.sin(s*o)*this._diameter,r.z);for(s=1;s<=this._length;s++){for(var c=0;c<this._sectionPolygonPointsCount;c++)t.push(r.x+Math.cos(c*o)*this._diameter,r.y+Math.sin(c*o)*this._diameter,r.z);var l=t.length/3-2*this._sectionPolygonPointsCount;for(c=0;c<this._sectionPolygonPointsCount-1;c++)n.push(l+c,l+c+this._sectionPolygonPointsCount,l+c+this._sectionPolygonPointsCount+1),n.push(l+c,l+c+this._sectionPolygonPointsCount+1,l+c+1);n.push(l+this._sectionPolygonPointsCount-1,l+this._sectionPolygonPointsCount-1+this._sectionPolygonPointsCount,l+this._sectionPolygonPointsCount),n.push(l+this._sectionPolygonPointsCount-1,l+this._sectionPolygonPointsCount,l)}Ki.a.ComputeNormals(t,n,i),e.positions=t,e.normals=i,e.indices=n,e.applyToMesh(this,!0),this._autoStart&&this.start()},t.prototype.start=function(){var e=this;this._running||(this._running=!0,this._beforeRenderObserver=this.getScene().onBeforeRenderObservable.add((function(){e.update()})))},t.prototype.stop=function(){this._beforeRenderObserver&&this._running&&(this._running=!1,this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver))},t.prototype.update=function(){var e=this.getVerticesData(Qi.b.PositionKind),t=this.getVerticesData(Qi.b.NormalKind),i=this._generator.getWorldMatrix();if(e&&t){for(var n=3*this._sectionPolygonPointsCount;n<e.length;n++)e[n-3*this._sectionPolygonPointsCount]=e[n]-t[n]/this._length*this._diameter;for(n=3*this._sectionPolygonPointsCount;n<t.length;n++)t[n-3*this._sectionPolygonPointsCount]=t[n];var r=e.length-3*this._sectionPolygonPointsCount,o=2*Math.PI/this._sectionPolygonPointsCount;for(n=0;n<this._sectionPolygonPointsCount;n++)this._sectionVectors[n].copyFromFloats(Math.cos(n*o)*this._diameter,Math.sin(n*o)*this._diameter,0),this._sectionNormalVectors[n].copyFromFloats(Math.cos(n*o),Math.sin(n*o),0),a.e.TransformCoordinatesToRef(this._sectionVectors[n],i,this._sectionVectors[n]),a.e.TransformNormalToRef(this._sectionNormalVectors[n],i,this._sectionNormalVectors[n]);for(n=0;n<this._sectionPolygonPointsCount;n++)e[r+3*n]=this._sectionVectors[n].x,e[r+3*n+1]=this._sectionVectors[n].y,e[r+3*n+2]=this._sectionVectors[n].z,t[r+3*n]=this._sectionNormalVectors[n].x,t[r+3*n+1]=this._sectionNormalVectors[n].y,t[r+3*n+2]=this._sectionNormalVectors[n].z;this.updateVerticesData(Qi.b.PositionKind,e,!0,!1),this.updateVerticesData(Qi.b.NormalKind,t,!0,!1)}},t.prototype.clone=function(e,i){return void 0===e&&(e=""),new t(e,void 0===i?this._generator:i,this.getScene(),this._diameter,this._length,this._autoStart)},t.prototype.serialize=function(t){e.prototype.serialize.call(this,t)},t.Parse=function(e,i){return new t(e.name,e._generator,i,e._diameter,e._length,e._autoStart)},t}(be.a),Ph=i(151),Ch=i(98),Rh=i(82);Ki.a.CreateDisc=function(e){var t=new Array,i=new Array,n=new Array,r=new Array,o=e.radius||.5,a=e.tessellation||64,s=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,c=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE;t.push(0,0,0),r.push(.5,.5);for(var l=2*Math.PI*s,u=1===s?l/a:l/(a-1),h=0,d=0;d<a;d++){var f=Math.cos(h),p=Math.sin(h),_=(f+1)/2,m=(1-p)/2;t.push(o*f,o*p,0),r.push(_,m),h+=u}1===s&&(t.push(t[3],t[4],t[5]),r.push(r[2],r[3]));for(var g=t.length/3,v=1;v<g-1;v++)i.push(v+1,0,v);Ki.a.ComputeNormals(t,i,n),Ki.a._ComputeSides(c,t,i,n,r,e.frontUVs,e.backUVs);var b=new Ki.a;return b.indices=i,b.positions=t,b.normals=n,b.uvs=r,b},be.a.CreateDisc=function(e,t,i,n,r,o){void 0===n&&(n=null);var a={radius:t,tessellation:i,sideOrientation:o,updatable:r};return xh.CreateDisc(e,a,n)};var xh=function(){function e(){}return e.CreateDisc=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateDisc(t).applyToMesh(n,t.updatable),n},e}();Ki.a.CreateTiledBox=function(e){for(var t=e.faceUV||new Array(6),i=e.faceColors,n=e.pattern||be.a.NO_FLIP,r=e.width||e.size||1,o=e.height||e.size||1,c=e.depth||e.size||1,l=e.tileWidth||e.tileSize||1,u=e.tileHeight||e.tileSize||1,h=e.alignHorizontal||0,d=e.alignVertical||0,f=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE,p=0;p<6;p++)void 0===t[p]&&(t[p]=new a.f(0,0,1,1)),i&&void 0===i[p]&&(i[p]=new s.b(1,1,1,1));var _=r/2,m=o/2,g=c/2,v=[];for(p=0;p<2;p++)v[p]=Ki.a.CreateTiledPlane({pattern:n,tileWidth:l,tileHeight:u,width:r,height:o,alignVertical:d,alignHorizontal:h,sideOrientation:f});for(p=2;p<4;p++)v[p]=Ki.a.CreateTiledPlane({pattern:n,tileWidth:l,tileHeight:u,width:c,height:o,alignVertical:d,alignHorizontal:h,sideOrientation:f});var b=d;d===be.a.BOTTOM?b=be.a.TOP:d===be.a.TOP&&(b=be.a.BOTTOM);for(p=4;p<6;p++)v[p]=Ki.a.CreateTiledPlane({pattern:n,tileWidth:l,tileHeight:u,width:r,height:c,alignVertical:b,alignHorizontal:h,sideOrientation:f});var y=[],T=[],E=[],S=[],A=[],P=[],C=[],R=[],x=0,O=0,M=0;for(p=0;p<6;p++){x=v[p].positions.length;P[p]=[],C[p]=[];for(var I=0;I<x/3;I++)P[p].push(new a.e(v[p].positions[3*I],v[p].positions[3*I+1],v[p].positions[3*I+2])),C[p].push(new a.e(v[p].normals[3*I],v[p].normals[3*I+1],v[p].normals[3*I+2]));O=v[p].uvs.length,R[p]=[];for(var D=0;D<O;D+=2)R[p][D]=t[p].x+(t[p].z-t[p].x)*v[p].uvs[D],R[p][D+1]=t[p].y+(t[p].w-t[p].y)*v[p].uvs[D+1];if(E=E.concat(R[p]),S=S.concat(v[p].indices.map((function(e){return e+M}))),M+=P[p].length,i)for(var N=0;N<4;N++)A.push(i[p].r,i[p].g,i[p].b,i[p].a)}var L=new a.e(0,0,g),w=a.a.RotationY(Math.PI);y=P[0].map((function(e){return a.e.TransformNormal(e,w).add(L)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]),T=C[0].map((function(e){return a.e.TransformNormal(e,w)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]),y=y.concat(P[1].map((function(e){return e.subtract(L)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),T=T.concat(C[1].map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var F=new a.e(_,0,0),B=a.a.RotationY(-Math.PI/2);y=y.concat(P[2].map((function(e){return a.e.TransformNormal(e,B).add(F)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),T=T.concat(C[2].map((function(e){return a.e.TransformNormal(e,B)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var U=a.a.RotationY(Math.PI/2);y=y.concat(P[3].map((function(e){return a.e.TransformNormal(e,U).subtract(F)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),T=T.concat(C[3].map((function(e){return a.e.TransformNormal(e,U)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var V=new a.e(0,m,0),k=a.a.RotationX(Math.PI/2);y=y.concat(P[4].map((function(e){return a.e.TransformNormal(e,k).add(V)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),T=T.concat(C[4].map((function(e){return a.e.TransformNormal(e,k)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[]));var z=a.a.RotationX(-Math.PI/2);y=y.concat(P[5].map((function(e){return a.e.TransformNormal(e,z).subtract(V)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),T=T.concat(C[5].map((function(e){return a.e.TransformNormal(e,z)})).map((function(e){return[e.x,e.y,e.z]})).reduce((function(e,t){return e.concat(t)}),[])),Ki.a._ComputeSides(f,y,S,T,E);var G=new Ki.a;if(G.indices=S,G.positions=y,G.normals=T,G.uvs=E,i){var j=f===Ki.a.DOUBLESIDE?A.concat(A):A;G.colors=j}return G};var Oh=function(){function e(){}return e.CreateTiledBox=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateTiledBox(t).applyToMesh(n,t.updatable),n},e}();Ki.a.CreateTorusKnot=function(e){var t,i,n=new Array,r=new Array,o=new Array,s=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||Ki.a.DEFAULTSIDE,_=function(e){var t=Math.cos(e),i=Math.sin(e),n=f/d*e,r=Math.cos(n),o=c*(2+r)*.5*t,s=c*(2+r)*i*.5,l=c*Math.sin(n)*.5;return new a.e(o,s,l)};for(t=0;t<=u;t++){var m=t%u/u*2*d*Math.PI,g=_(m),v=_(m+.01),b=v.subtract(g),y=v.add(g),T=a.e.Cross(b,y);for(y=a.e.Cross(T,b),T.normalize(),y.normalize(),i=0;i<h;i++){var E=i%h/h*2*Math.PI,S=-l*Math.cos(E),A=l*Math.sin(E);r.push(g.x+S*y.x+A*T.x),r.push(g.y+S*y.y+A*T.y),r.push(g.z+S*y.z+A*T.z),s.push(t/u),s.push(i/h)}}for(t=0;t<u;t++)for(i=0;i<h;i++){var P=(i+1)%h,C=t*h+i,R=(t+1)*h+i,x=(t+1)*h+P,O=t*h+P;n.push(O),n.push(R),n.push(C),n.push(O),n.push(x),n.push(R)}Ki.a.ComputeNormals(r,n,o),Ki.a._ComputeSides(p,r,n,o,s,e.frontUVs,e.backUVs);var M=new Ki.a;return M.indices=n,M.positions=r,M.normals=o,M.uvs=s,M},be.a.CreateTorusKnot=function(e,t,i,n,r,o,a,s,c,l){var u={radius:t,tube:i,radialSegments:n,tubularSegments:r,p:o,q:a,sideOrientation:l,updatable:c};return Mh.CreateTorusKnot(e,u,s)};var Mh=function(){function e(){}return e.CreateTorusKnot=function(e,t,i){var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateTorusKnot(t).applyToMesh(n,t.updatable),n},e}(),Ih=function(e){function t(t,i){var n=e.call(this,t.x,t.y)||this;return n.index=i,n}return Object(h.d)(t,e),t}(a.d),Dh=function(){function e(){this.elements=new Array}return e.prototype.add=function(e){var t=this,i=new Array;return e.forEach((function(e){var n=new Ih(e,t.elements.length);i.push(n),t.elements.push(n)})),i},e.prototype.computeBounds=function(){var e=new a.d(this.elements[0].x,this.elements[0].y),t=new a.d(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}(),Nh=function(){function e(){}return e.Rectangle=function(e,t,i,n){return[new a.d(e,t),new a.d(i,t),new a.d(i,n),new a.d(e,n)]},e.Circle=function(e,t,i,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=32);for(var r=new Array,o=0,s=2*Math.PI/n,c=0;c<n;c++)r.push(new a.d(t+Math.cos(o)*e,i+Math.sin(o)*e)),o-=s;return r},e.Parse=function(e){var t,i=e.split(/[^-+eE\.\d]+/).map(parseFloat).filter((function(e){return!isNaN(e)})),n=[];for(t=0;t<(2147483646&i.length);t+=2)n.push(new a.d(i[t],i[t+1]));return n},e.StartingAt=function(e,t){return re.f.StartingAt(e,t)},e}(),Lh=function(){function e(e,t,i,n){var r;void 0===n&&(n=earcut),this._points=new Dh,this._outlinepoints=new Dh,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this.bjsEarcut=n,this._name=e,this._scene=i||Se.a.LastCreatedScene,r=t instanceof re.f?t.getPoints():t,this._addToepoint(r),this._points.add(r),this._outlinepoints.add(r),void 0===this.bjsEarcut&&m.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 n=i[t];this._epoints.push(n.x,n.y)}},e.prototype.addHole=function(e){this._points.add(e);var t=new Dh;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){void 0===e&&(e=!1),void 0===t&&(t=0);var i=new be.a(this._name,this._scene),n=this.buildVertexData(t);return i.setVerticesData(Qi.b.PositionKind,n.positions,e),i.setVerticesData(Qi.b.NormalKind,n.normals,e),i.setVerticesData(Qi.b.UVKind,n.uvs,e),i.setIndices(n.indices),i},e.prototype.buildVertexData=function(e){var t=this;void 0===e&&(e=0);var i=new Ki.a,n=new Array,r=new Array,o=new Array,a=this._points.computeBounds();this._points.elements.forEach((function(e){n.push(0,1,0),r.push(e.x,0,e.y),o.push((e.x-a.min.x)/a.width,(e.y-a.min.y)/a.height)}));for(var s=new Array,c=this.bjsEarcut(this._epoints,this._eholes,2),l=0;l<c.length;l++)s.push(c[l]);if(e>0){var u=r.length/3;this._points.elements.forEach((function(t){n.push(0,-1,0),r.push(t.x,-e,t.y),o.push(1-(t.x-a.min.x)/a.width,1-(t.y-a.min.y)/a.height)}));var h=s.length;for(l=0;l<h;l+=3){var d=s[l+0],f=s[l+1],p=s[l+2];s.push(p+u),s.push(f+u),s.push(d+u)}this.addSide(r,n,o,s,a,this._outlinepoints,e,!1),this._holes.forEach((function(i){t.addSide(r,n,o,s,a,i,e,!0)}))}return i.indices=s,i.positions=r,i.normals=n,i.uvs=o,i},e.prototype.addSide=function(e,t,i,n,r,o,s,c){for(var l=e.length/3,u=0,h=0;h<o.elements.length;h++){var d,f=o.elements[h];d=h+1>o.elements.length-1?o.elements[0]:o.elements[h+1],e.push(f.x,0,f.y),e.push(f.x,-s,f.y),e.push(d.x,0,d.y),e.push(d.x,-s,d.y);var p=new a.e(f.x,0,f.y),_=new a.e(d.x,0,d.y).subtract(p),m=new a.e(0,1,0),g=a.e.Cross(_,m);g=g.normalize(),i.push(u/r.width,0),i.push(u/r.width,1),u+=_.length(),i.push(u/r.width,0),i.push(u/r.width,1),c?(t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),t.push(g.x,g.y,g.z),n.push(l),n.push(l+2),n.push(l+1),n.push(l+1),n.push(l+2),n.push(l+3)):(t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),t.push(-g.x,-g.y,-g.z),n.push(l),n.push(l+1),n.push(l+2),n.push(l+1),n.push(l+3),n.push(l+2)),l+=4}},e}();Ki.a.CreatePolygon=function(e,t,i,n,r,o,c){for(var l=i||new Array(3),u=n,h=[],d=c||!1,f=0;f<3;f++)void 0===l[f]&&(l[f]=new a.f(0,0,1,1)),u&&void 0===u[f]&&(u[f]=new s.b(1,1,1,1));var p=e.getVerticesData(Qi.b.PositionKind),_=e.getVerticesData(Qi.b.NormalKind),m=e.getVerticesData(Qi.b.UVKind),g=e.getIndices(),v=p.length/9,b=0,y=0,T=0,E=0,S=[0];if(d)for(var A=v;A<p.length/3;A+=4)y=p[3*(A+2)]-p[3*A],T=p[3*(A+2)+2]-p[3*A+2],E+=Math.sqrt(y*y+T*T),S.push(E);A=0;for(var P=0,C=0;C<_.length;C+=3)Math.abs(_[C+1])<.001&&(P=1),Math.abs(_[C+1]-1)<.001&&(P=0),Math.abs(_[C+1]+1)<.001&&(P=2),A=C/3,1===P?(b=A-v,m[2*A]=b%4<1.5?d?l[P].x+(l[P].z-l[P].x)*S[Math.floor(b/4)]/E:l[P].x:d?l[P].x+(l[P].z-l[P].x)*S[Math.floor(b/4)+1]/E:l[P].z,m[2*A+1]=b%2==0?l[P].w:l[P].y):(m[2*A]=(1-m[2*A])*l[P].x+m[2*A]*l[P].z,m[2*A+1]=(1-m[2*A+1])*l[P].y+m[2*A+1]*l[P].w),u&&h.push(u[P].r,u[P].g,u[P].b,u[P].a);Ki.a._ComputeSides(t,p,g,_,m,r,o);var R=new Ki.a;if(R.indices=g,R.positions=p,R.normals=_,R.uvs=m,u){var x=t===Ki.a.DOUBLESIDE?h.concat(h):h;R.colors=x}return R},be.a.CreatePolygon=function(e,t,i,n,r,o,a){void 0===a&&(a=earcut);var s={shape:t,holes:n,updatable:r,sideOrientation:o};return wh.CreatePolygon(e,s,i,a)},be.a.ExtrudePolygon=function(e,t,i,n,r,o,a,s){void 0===s&&(s=earcut);var c={shape:t,holes:r,depth:i,updatable:o,sideOrientation:a};return wh.ExtrudePolygon(e,c,n,s)};var wh=function(){function e(){}return e.CreatePolygon=function(e,t,i,n){void 0===i&&(i=null),void 0===n&&(n=earcut),t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation);for(var r=t.shape,o=t.holes||[],s=t.depth||0,c=[],l=[],u=0;u<r.length;u++)c[u]=new a.d(r[u].x,r[u].z);c[0].equalsWithEpsilon(c[c.length-1],1e-8)&&c.pop();for(var h=new Lh(e,c,i||x.a.LastCreatedScene,n),d=0;d<o.length;d++){l=[];for(var f=0;f<o[d].length;f++)l.push(new a.d(o[d][f].x,o[d][f].z));h.addHole(l)}var p=h.build(t.updatable,s);return p._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreatePolygon(p,t.sideOrientation,t.faceUV,t.faceColors,t.frontUVs,t.backUVs,t.wrap).applyToMesh(p,t.updatable),p},e.ExtrudePolygon=function(t,i,n,r){return void 0===n&&(n=null),void 0===r&&(r=earcut),e.CreatePolygon(t,i,n,r)},e}();be.a.CreateLathe=function(e,t,i,n,r,o,a){var s={shape:t,radius:i,tessellation:n,sideOrientation:a,updatable:o};return Fh.CreateLathe(e,s,r)};var Fh=function(){function e(){}return e.CreateLathe=function(e,t,i){void 0===i&&(i=null);var n,r=t.arc?t.arc<=0||t.arc>1?1:t.arc:1,o=void 0===t.closed||t.closed,s=t.shape,c=t.radius||1,l=t.tessellation||64,u=t.clip||0,h=t.updatable,d=be.a._GetDefaultSideOrientation(t.sideOrientation),f=t.cap||be.a.NO_CAP,p=2*Math.PI,_=new Array,m=t.invertUV||!1,g=0,v=0,b=p/l*r,y=new Array;for(g=0;g<=l-u;g++){y=[];for(f!=be.a.CAP_START&&f!=be.a.CAP_ALL||(y.push(new a.e(0,s[0].y,0)),y.push(new a.e(Math.cos(g*b)*s[0].x*c,s[0].y,Math.sin(g*b)*s[0].x*c))),v=0;v<s.length;v++)n=new a.e(Math.cos(g*b)*s[v].x*c,s[v].y,Math.sin(g*b)*s[v].x*c),y.push(n);f!=be.a.CAP_END&&f!=be.a.CAP_ALL||(y.push(new a.e(Math.cos(g*b)*s[s.length-1].x*c,s[s.length-1].y,Math.sin(g*b)*s[s.length-1].x*c)),y.push(new a.e(0,s[s.length-1].y,0))),_.push(y)}return Rh.a.CreateRibbon(e,{pathArray:_,closeArray:o,sideOrientation:d,updatable:h,invertUV:m,frontUVs:t.frontUVs,backUVs:t.backUVs},i)},e}();Ki.a.CreateTiledPlane=function(e){var t=e.pattern||be.a.NO_FLIP,i=e.tileWidth||e.tileSize||1,n=e.tileHeight||e.tileSize||1,r=e.alignHorizontal||0,o=e.alignVertical||0,a=e.width||e.size||1,s=Math.floor(a/i),c=a-s*i,l=e.height||e.size||1,u=Math.floor(l/n),h=l-u*n,d=i*s/2,f=n*u/2,p=0,_=0,m=0,g=0,v=0,b=0;if(c>0||h>0){m=-d,g=-f;v=d,b=f;switch(r){case be.a.CENTER:m-=c/=2,v+=c;break;case be.a.LEFT:v+=c,p=-c/2;break;case be.a.RIGHT:m-=c,p=c/2}switch(o){case be.a.CENTER:g-=h/=2,b+=h;break;case be.a.BOTTOM:b+=h,_=-h/2;break;case be.a.TOP:g-=h,_=h/2}}var y=[],T=[],E=[];E[0]=[0,0,1,0,1,1,0,1],E[1]=[0,0,1,0,1,1,0,1],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(E[1]=[1,1,0,1,0,0,1,0]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(E[1]=[1,0,0,0,0,1,1,1]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(E[1]=[0,1,1,1,1,0,0,0]);for(var S=[],A=[],P=[],C=0,R=0;R<u;R++)for(var x=0;x<s;x++)y.push(x*i-d+p,R*n-f+_,0),y.push((x+1)*i-d+p,R*n-f+_,0),y.push((x+1)*i-d+p,(R+1)*n-f+_,0),y.push(x*i-d+p,(R+1)*n-f+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),S=t===be.a.FLIP_TILE||t===be.a.ROTATE_TILE||t===be.a.FLIP_N_ROTATE_TILE?S.concat(E[(x%2+R%2)%2]):t===be.a.FLIP_ROW||t===be.a.ROTATE_ROW||t===be.a.FLIP_N_ROTATE_ROW?S.concat(E[R%2]):S.concat(E[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1),C+=4;if(c>0||h>0){var O,M,I,D,N=h>0&&(o===be.a.CENTER||o===be.a.TOP),L=h>0&&(o===be.a.CENTER||o===be.a.BOTTOM),w=c>0&&(r===be.a.CENTER||r===be.a.RIGHT),F=c>0&&(r===be.a.CENTER||r===be.a.LEFT),B=[];if(N&&w&&(y.push(m+p,g+_,0),y.push(-d+p,g+_,0),y.push(-d+p,g+h+_,0),y.push(m+p,g+h+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=1-c/i,M=1-h/n,I=1,M,I,D=1,O,D],t===be.a.ROTATE_ROW&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t===be.a.FLIP_ROW&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),t===be.a.FLIP_N_ROTATE_ROW&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),N&&F&&(y.push(d+p,g+_,0),y.push(v+p,g+_,0),y.push(v+p,g+h+_,0),y.push(d+p,g+h+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=0,M=1-h/n,I=c/i,M,I,D=1,O,D],(t===be.a.ROTATE_ROW||t===be.a.ROTATE_TILE&&s%2==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW||t===be.a.FLIP_TILE&&s%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW||t===be.a.FLIP_N_ROTATE_TILE&&s%2==0)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&w&&(y.push(m+p,f+_,0),y.push(-d+p,f+_,0),y.push(-d+p,b+_,0),y.push(m+p,b+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=1-c/i,M=0,I=1,M,I,D=h/n,O,D],(t===be.a.ROTATE_ROW&&u%2==1||t===be.a.ROTATE_TILE&&u%1==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW&&u%2==1||t===be.a.FLIP_TILE&&u%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW&&u%2==1||t===be.a.FLIP_N_ROTATE_TILE&&u%2==0)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),L&&F&&(y.push(d+p,f+_,0),y.push(v+p,f+_,0),y.push(v+p,b+_,0),y.push(d+p,b+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,B=[O=0,M=0,I=c/i,M,I,D=h/n,O,D],(t===be.a.ROTATE_ROW&&u%2==1||t===be.a.ROTATE_TILE&&(u+s)%2==1)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===be.a.FLIP_ROW&&u%2==1||t===be.a.FLIP_TILE&&(u+s)%2==1)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===be.a.FLIP_N_ROTATE_ROW&&u%2==1||t===be.a.FLIP_N_ROTATE_TILE&&(u+s)%2==1)&&(B=[O,1-M,I,1-M,I,1-D,O,1-D]),S=S.concat(B),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)),N){var U=[];O=0,M=1-h/n,I=1,D=1,U[0]=[O,M,I,M,I,D,O,D],U[1]=[O,M,I,M,I,D,O,D],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(U[1]=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(U[1]=[1-O,M,1-I,M,1-I,D,1-O,D]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(U[1]=[O,1-M,I,1-M,I,1-D,O,1-D]);for(x=0;x<s;x++)y.push(x*i-d+p,g+_,0),y.push((x+1)*i-d+p,g+_,0),y.push((x+1)*i-d+p,g+h+_,0),y.push(x*i-d+p,g+h+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,S=t===be.a.FLIP_TILE||t===be.a.ROTATE_TILE||t===be.a.FLIP_N_ROTATE_TILE?S.concat(U[(x+1)%2]):t===be.a.FLIP_ROW||t===be.a.ROTATE_ROW||t===be.a.FLIP_N_ROTATE_ROW?S.concat(U[1]):S.concat(U[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(L){var V=[];O=0,M=0,I=1,D=h/n,V[0]=[O,M,I,M,I,D,O,D],V[1]=[O,M,I,M,I,D,O,D],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(V[1]=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(V[1]=[1-O,M,1-I,M,1-I,D,1-O,D]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(V[1]=[O,1-M,I,1-M,I,1-D,O,1-D]);for(x=0;x<s;x++)y.push(x*i-d+p,b-h+_,0),y.push((x+1)*i-d+p,b-h+_,0),y.push((x+1)*i-d+p,b+_,0),y.push(x*i-d+p,b+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,S=t===be.a.FLIP_TILE||t===be.a.ROTATE_TILE||t===be.a.FLIP_N_ROTATE_TILE?S.concat(V[(x+u)%2]):t===be.a.FLIP_ROW||t===be.a.ROTATE_ROW||t===be.a.FLIP_N_ROTATE_ROW?S.concat(V[u%2]):S.concat(V[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(w){var k=[];O=1-c/i,M=0,I=1,D=1,k[0]=[O,M,I,M,I,D,O,D],k[1]=[O,M,I,M,I,D,O,D],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(k[1]=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(k[1]=[1-O,M,1-I,M,1-I,D,1-O,D]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(k[1]=[O,1-M,I,1-M,I,1-D,O,1-D]);for(R=0;R<u;R++)y.push(m+p,R*n-f+_,0),y.push(m+c+p,R*n-f+_,0),y.push(m+c+p,(R+1)*n-f+_,0),y.push(m+p,(R+1)*n-f+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,S=t===be.a.FLIP_TILE||t===be.a.ROTATE_TILE||t===be.a.FLIP_N_ROTATE_TILE?S.concat(k[(R+1)%2]):t===be.a.FLIP_ROW||t===be.a.ROTATE_ROW||t===be.a.FLIP_N_ROTATE_ROW?S.concat(k[R%2]):S.concat(k[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}if(F){var z=[];O=0,M=0,I=c/n,D=1,z[0]=[O,M,I,M,I,D,O,D],z[1]=[O,M,I,M,I,D,O,D],t!==be.a.ROTATE_TILE&&t!==be.a.ROTATE_ROW||(z[1]=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t!==be.a.FLIP_TILE&&t!==be.a.FLIP_ROW||(z[1]=[1-O,M,1-I,M,1-I,D,1-O,D]),t!==be.a.FLIP_N_ROTATE_TILE&&t!==be.a.FLIP_N_ROTATE_ROW||(z[1]=[O,1-M,I,1-M,I,1-D,O,1-D]);for(R=0;R<u;R++)y.push(v-c+p,R*n-f+_,0),y.push(v+p,R*n-f+_,0),y.push(v+p,(R+1)*n-f+_,0),y.push(v-c+p,(R+1)*n-f+_,0),P.push(C,C+1,C+3,C+1,C+2,C+3),C+=4,S=t===be.a.FLIP_TILE||t===be.a.ROTATE_TILE||t===be.a.FLIP_N_ROTATE_TILE?S.concat(z[(R+s)%2]):t===be.a.FLIP_ROW||t===be.a.ROTATE_ROW||t===be.a.FLIP_N_ROTATE_ROW?S.concat(z[R%2]):S.concat(z[0]),A.push(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1),T.push(0,0,-1,0,0,-1,0,0,-1,0,0,-1)}}var G=0===e.sideOrientation?0:e.sideOrientation||Ki.a.DEFAULTSIDE;Ki.a._ComputeSides(G,y,P,T,S,e.frontUVs,e.backUVs);var j=new Ki.a;j.indices=P,j.positions=y,j.normals=T,j.uvs=S;var W=G===Ki.a.DOUBLESIDE?A.concat(A):A;return j.colors=W,j};var Bh=function(){function e(){}return e.CreateTiledPlane=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateTiledPlane(t).applyToMesh(n,t.updatable),n},e}();be.a.CreateTube=function(e,t,i,n,r,o,a,s,c,l){var u={path:t,radius:i,tessellation:n,radiusFunction:r,arc:1,cap:o,updatable:s,sideOrientation:c,instance:l};return Uh.CreateTube(e,u,a)};var Uh=function(){function e(){}return e.CreateTube=function(e,t,i){void 0===i&&(i=null);var n=t.path,r=t.instance,o=1;void 0!==t.radius?o=t.radius:r&&(o=r._creationDataStorage.radius);var s=t.tessellation||64,c=t.radiusFunction||null,l=t.cap||be.a.NO_CAP,u=t.invertUV||!1,h=t.updatable,d=be.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,n,r,o,s,c){for(var l,u,h,d,f=t.getTangents(),p=t.getNormals(),_=t.getDistances(),m=2*Math.PI/r*c,g=o||function(){return n},v=a.c.Matrix[0],b=s===be.a.NO_CAP||s===be.a.CAP_END?0:2,y=0;y<e.length;y++){u=g(y,_[y]),l=Array(),h=p[y];for(var T=0;T<r;T++)a.a.RotationAxisToRef(f[y],m*T,v),d=l[T]?l[T]:a.e.Zero(),a.e.TransformCoordinatesToRef(h,v,d),d.scaleInPlace(u).addInPlace(e[y]),l[T]=d;i[b]=l,b++}var E=function(t,i){for(var n=Array(),r=0;r<t;r++)n.push(e[i]);return n};switch(s){case be.a.NO_CAP:break;case be.a.CAP_START:i[0]=E(r,0),i[1]=i[2].slice(0);break;case be.a.CAP_END:i[b]=i[b-1].slice(0),i[b+1]=E(r,e.length-1);break;case be.a.CAP_ALL:i[0]=E(r,0),i[1]=i[2].slice(0),i[b]=i[b-1].slice(0),i[b+1]=E(r,e.length-1)}return i};if(r){var m=r._creationDataStorage,g=t.arc||m.arc;return p=_(n,f=m.path3D.update(n),m.pathArray,o,m.tessellation,c,m.cap,g),r=Rh.a.CreateRibbon("",{pathArray:p,instance:r}),m.path3D=f,m.pathArray=p,m.arc=g,m.radius=o,r}p=_(n,f=new re.g(n),new Array,o,s,c,l=l<0||l>3?0:l,t.arc);var v=Rh.a.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=s,v._creationDataStorage.cap=l,v._creationDataStorage.arc=t.arc,v._creationDataStorage.radius=o,v},e}();Ki.a.CreateIcoSphere=function(e){var t,i=e.sideOrientation||Ki.a.DEFAULTSIDE,n=e.radius||1,r=void 0===e.flat||e.flat,o=e.subdivisions||4,s=e.radiusX||n,c=e.radiusY||n,l=e.radiusZ||n,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],m=new Array,g=new Array,v=new Array,b=new Array,y=0,T=new Array(3),E=new Array(3);for(t=0;t<3;t++)T[t]=a.e.Zero(),E[t]=a.d.Zero();for(var S=0;S<20;S++){for(t=0;t<3;t++){var A=d[3*S+t];T[t].copyFromFloats(h[3*f[A]],h[3*f[A]+1],h[3*f[A]+2]),T[t].normalize().scaleInPlace(n),E[t].copyFromFloats(p[2*A]*(138/1024)+60/1024+_[S]*(-40/1024),p[2*A+1]*(239/1024)+26/1024+_[S]*(20/1024))}for(var P=function(e,t,i,n){var u,h=a.e.Lerp(T[0],T[2],t/o),d=a.e.Lerp(T[1],T[2],t/o),f=o===t?T[2]:a.e.Lerp(h,d,e/(o-t));if(f.normalize(),r){var p=a.e.Lerp(T[0],T[2],n/o),_=a.e.Lerp(T[1],T[2],n/o);u=a.e.Lerp(p,_,i/(o-n))}else u=new a.e(f.x,f.y,f.z);u.x/=s,u.y/=c,u.z/=l,u.normalize();var S=a.d.Lerp(E[0],E[2],t/o),A=a.d.Lerp(E[1],E[2],t/o),P=o===t?E[2]:a.d.Lerp(S,A,e/(o-t));g.push(f.x*s,f.y*c,f.z*l),v.push(u.x,u.y,u.z),b.push(P.x,P.y),m.push(y),y++},C=0;C<o;C++)for(var R=0;R+C<o;R++)P(R,C,R+1/3,C+1/3),P(R+1,C,R+1/3,C+1/3),P(R,C+1,R+1/3,C+1/3),R+C+1<o&&(P(R+1,C,R+2/3,C+2/3),P(R+1,C+1,R+2/3,C+2/3),P(R,C+1,R+2/3,C+2/3))}Ki.a._ComputeSides(i,g,m,v,b,e.frontUVs,e.backUVs);var x=new Ki.a;return x.indices=m,x.positions=g,x.normals=v,x.uvs=b,x},be.a.CreateIcoSphere=function(e,t,i){return Vh.CreateIcoSphere(e,t,i)};var Vh=function(){function e(){}return e.CreateIcoSphere=function(e,t,i){void 0===i&&(i=null);var n=new be.a(e,i);return t.sideOrientation=be.a._GetDefaultSideOrientation(t.sideOrientation),n._originalBuilderSideOrientation=t.sideOrientation,Ki.a.CreateIcoSphere(t).applyToMesh(n,t.updatable),n},e}();be.a.CreateDecal=function(e,t,i,n,r,o){var a={position:i,normal:n,size:r,angle:o};return kh.CreateDecal(e,t,a)};var kh=function(){function e(){}return e.CreateDecal=function(e,t,i){var n=t.getIndices(),r=t.getVerticesData(Qi.b.PositionKind),o=t.getVerticesData(Qi.b.NormalKind),s=i.position||a.e.Zero(),c=i.normal||a.e.Up(),l=i.size||a.e.One(),u=i.angle||0;if(!c){var h=new a.e(0,0,1),d=t.getScene().activeCamera,f=a.e.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),m=Math.atan2(c.y,_),g=a.a.RotationYawPitchRoll(p,m,u).multiply(a.a.Translation(s.x,s.y,s.z)),v=a.a.Invert(g),b=t.getWorldMatrix().multiply(v),y=new Ki.a;y.indices=[],y.positions=[],y.normals=[],y.uvs=[];for(var T=0,E=function(e){var t=new Xr;if(!n||!r||!o)return t;var i=n[e];return t.position=new a.e(r[3*i],r[3*i+1],r[3*i+2]),t.position=a.e.TransformCoordinates(t.position,b),t.normal=new a.e(o[3*i],o[3*i+1],o[3*i+2]),t.normal=a.e.TransformNormal(t.normal,b),t},S=function(e,t){if(0===e.length)return e;for(var i=.5*Math.abs(a.e.Dot(l,t)),n=function(e,n){var r=a.e.GetClipFactor(e.position,n.position,t,i);return new Xr(a.e.Lerp(e.position,n.position,r),a.e.Lerp(e.normal,n.normal,r))},r=new Array,o=0;o<e.length;o+=3){var s,c,u,h=null,d=null,f=null,p=null;switch(((s=a.e.Dot(e[o].position,t)-i>0)?1:0)+((c=a.e.Dot(e[o+1].position,t)-i>0)?1:0)+((u=a.e.Dot(e[o+2].position,t)-i>0)?1:0)){case 0:r.push(e[o]),r.push(e[o+1]),r.push(e[o+2]);break;case 1:if(s&&(h=e[o+1],d=e[o+2],f=n(e[o],h),p=n(e[o],d)),c){h=e[o],d=e[o+2],f=n(e[o+1],h),p=n(e[o+1],d),r.push(f),r.push(d.clone()),r.push(h.clone()),r.push(d.clone()),r.push(f.clone()),r.push(p);break}u&&(h=e[o],d=e[o+1],f=n(e[o+2],h),p=n(e[o+2],d)),h&&d&&f&&p&&(r.push(h.clone()),r.push(d.clone()),r.push(f),r.push(p),r.push(f.clone()),r.push(d.clone()));break;case 2:s||(d=n(h=e[o].clone(),e[o+1]),f=n(h,e[o+2]),r.push(h),r.push(d),r.push(f)),c||(d=n(h=e[o+1].clone(),e[o+2]),f=n(h,e[o]),r.push(h),r.push(d),r.push(f)),u||(d=n(h=e[o+2].clone(),e[o]),f=n(h,e[o+1]),r.push(h),r.push(d),r.push(f))}}return r},A=0;A<n.length;A+=3){var P=new Array;if(P.push(E(A)),P.push(E(A+1)),P.push(E(A+2)),P=S(P,new a.e(1,0,0)),P=S(P,new a.e(-1,0,0)),P=S(P,new a.e(0,1,0)),P=S(P,new a.e(0,-1,0)),P=S(P,new a.e(0,0,1)),0!==(P=S(P,new a.e(0,0,-1))).length)for(var C=0;C<P.length;C++){var R=P[C];y.indices.push(T),R.position.toArray(y.positions,3*T),R.normal.toArray(y.normals,3*T),y.uvs.push(.5+R.position.x/l.x),y.uvs.push(.5+R.position.y/l.y),T++}}var x=new be.a(e,t.getScene());return y.applyToMesh(x),x.position=s.clone(),x.rotation=new a.e(m,p,u),x},e}();Ki.a.CreateCapsule=function(e){void 0===e&&(e={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var t,i,n=Math.max(e.subdivisions?e.subdivisions:2,1),r=Math.max(e.tessellation?e.tessellation:16,3),o=Math.max(e.height?e.height:1,0),s=Math.max(e.radius?e.radius:.25,0),c=Math.max(e.capSubdivisions?e.capSubdivisions:6,1),l=r,u=n,h=Math.max(e.radiusTop?e.radiusTop:s,0),d=Math.max(e.radiusBottom?e.radiusBottom:s,0),f=o-(h+d),p=2*Math.PI,_=Math.max(e.topCapSubdivisions?e.topCapSubdivisions:c,1),m=Math.max(e.bottomCapSubdivisions?e.bottomCapSubdivisions:c,1),g=Math.acos((d-h)/o),v=[],b=[],y=[],T=[],E=0,S=[],A=.5*f,P=.5*Math.PI,C=a.e.Zero(),R=a.e.Zero(),x=Math.cos(g),O=Math.sin(g),M=new a.d(h*O,A+h*x).subtract(new a.d(d*O,d*x-A)).length(),I=h*g+M+d*(P-g),D=0;for(i=0;i<=_;i++){var N=[],L=P-g*(i/_);D+=h*g/_;var w=Math.cos(L),F=Math.sin(L),B=w*h;for(t=0;t<=l;t++){var U=(j=t/l)*p+0,V=Math.sin(U),k=Math.cos(U);R.x=B*V,R.y=A+F*h,R.z=B*k,b.push(R.x,R.y,R.z),C.set(w*V,F,w*k),y.push(C.x,C.y,C.z),T.push(j,1-D/I),N.push(E),E++}S.push(N)}var z=o-h-d+x*h-x*d,G=O*(d-h)/z;for(i=1;i<=u;i++){N=[];D+=M/u;B=O*(i*(d-h)/u+h);for(t=0;t<=l;t++){U=(j=t/l)*p+0,V=Math.sin(U),k=Math.cos(U);R.x=B*V,R.y=A+x*h-i*z/u,R.z=B*k,b.push(R.x,R.y,R.z),C.set(V,G,k).normalize(),y.push(C.x,C.y,C.z),T.push(j,1-D/I),N.push(E),E++}S.push(N)}for(i=1;i<=m;i++){N=[],L=P-g-(Math.PI-g)*(i/m);D+=d*g/m;w=Math.cos(L),F=Math.sin(L),B=w*d;for(t=0;t<=l;t++){var j;U=(j=t/l)*p+0,V=Math.sin(U),k=Math.cos(U);R.x=B*V,R.y=F*d-A,R.z=B*k,b.push(R.x,R.y,R.z),C.set(w*V,F,w*k),y.push(C.x,C.y,C.z),T.push(j,1-D/I),N.push(E),E++}S.push(N)}for(t=0;t<l;t++)for(i=0;i<_+u+m;i++){var W=S[i][t],H=S[i+1][t],X=S[i+1][t+1],Y=S[i][t+1];v.push(W),v.push(H),v.push(Y),v.push(H),v.push(X),v.push(Y)}if(v=v.reverse(),e.orientation&&!e.orientation.equals(a.e.Up())){var K=new a.a;e.orientation.clone().scale(.5*Math.PI).cross(a.e.Up()).toQuaternion().toRotationMatrix(K);for(var Q=a.e.Zero(),q=0;q<b.length;q+=3)Q.set(b[q],b[q+1],b[q+2]),a.e.TransformCoordinatesToRef(Q.clone(),K,Q),b[q]=Q.x,b[q+1]=Q.y,b[q+2]=Q.z}var Z=new Ki.a;return Z.positions=b,Z.normals=y,Z.uvs=T,Z.indices=v,Z},be.a.CreateCapsule=function(e,t,i){return Gh.CreateCapsule(e,t,i)};var zh,Gh=function(){function e(){}return e.CreateCapsule=function(e,t,i){void 0===t&&(t={orientation:a.e.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var n=new be.a(e,i);return Ki.a.CreateCapsule(t).applyToMesh(n),n},e}(),jh=function(){function e(){}return e.CreateBox=function(e,t,i){return void 0===i&&(i=null),Ar.a.CreateBox(e,t,i)},e.CreateTiledBox=function(e,t,i){return void 0===i&&(i=null),Oh.CreateTiledBox(e,t,i)},e.CreateSphere=function(e,t,i){return void 0===i&&(i=null),xr.a.CreateSphere(e,t,i)},e.CreateDisc=function(e,t,i){return void 0===i&&(i=null),xh.CreateDisc(e,t,i)},e.CreateIcoSphere=function(e,t,i){return void 0===i&&(i=null),Vh.CreateIcoSphere(e,t,i)},e.CreateRibbon=function(e,t,i){return void 0===i&&(i=null),Rh.a.CreateRibbon(e,t,i)},e.CreateCylinder=function(e,t,i){return void 0===i&&(i=null),nn.a.CreateCylinder(e,t,i)},e.CreateTorus=function(e,t,i){return void 0===i&&(i=null),tn.CreateTorus(e,t,i)},e.CreateTorusKnot=function(e,t,i){return void 0===i&&(i=null),Mh.CreateTorusKnot(e,t,i)},e.CreateLineSystem=function(e,t,i){return Or.a.CreateLineSystem(e,t,i)},e.CreateLines=function(e,t,i){return void 0===i&&(i=null),Or.a.CreateLines(e,t,i)},e.CreateDashedLines=function(e,t,i){return void 0===i&&(i=null),Or.a.CreateDashedLines(e,t,i)},e.ExtrudeShape=function(e,t,i){return void 0===i&&(i=null),vc.a.ExtrudeShape(e,t,i)},e.ExtrudeShapeCustom=function(e,t,i){return void 0===i&&(i=null),vc.a.ExtrudeShapeCustom(e,t,i)},e.CreateLathe=function(e,t,i){return void 0===i&&(i=null),Fh.CreateLathe(e,t,i)},e.CreateTiledPlane=function(e,t,i){return void 0===i&&(i=null),Bh.CreateTiledPlane(e,t,i)},e.CreatePlane=function(e,t,i){return void 0===i&&(i=null),Lr.a.CreatePlane(e,t,i)},e.CreateGround=function(e,t,i){return void 0===i&&(i=null),Ji.CreateGround(e,t,i)},e.CreateTiledGround=function(e,t,i){return void 0===i&&(i=null),Ji.CreateTiledGround(e,t,i)},e.CreateGroundFromHeightMap=function(e,t,i,n){return void 0===n&&(n=null),Ji.CreateGroundFromHeightMap(e,t,i,n)},e.CreatePolygon=function(e,t,i,n){return void 0===i&&(i=null),void 0===n&&(n=earcut),wh.CreatePolygon(e,t,i,n)},e.ExtrudePolygon=function(e,t,i,n){return void 0===i&&(i=null),void 0===n&&(n=earcut),wh.ExtrudePolygon(e,t,i,n)},e.CreateTube=function(e,t,i){return void 0===i&&(i=null),Uh.CreateTube(e,t,i)},e.CreatePolyhedron=function(e,t,i){return void 0===i&&(i=null),Br.CreatePolyhedron(e,t,i)},e.CreateDecal=function(e,t,i){return kh.CreateDecal(e,t,i)},e.CreateCapsule=function(e,t,i){return void 0===t&&(t={orientation:a.e.Up(),subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6}),void 0===i&&(i=null),Gh.CreateCapsule(e,t,i)},e}(),Wh=function(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i},Hh=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(n){void 0!==i.distance&&e.mesh.addLODLevel(i.distance,n),n.isVisible=!0,i.quality===e.settings[e.settings.length-1].quality&&e.successCallback&&e.successCallback(),t.executeNext()}))}));else{var i=this.getSimplifier(e);Ce.a.Run(e.settings.length,(function(t){var n,r;n=e.settings[t.index],r=function(){t.executeNext()},i.simplify(n,(function(t){void 0!==n.distance&&e.mesh.addLODLevel(n.distance,t),t.isVisible=!0,r()}))}),(function(){e.successCallback&&e.successCallback(),t.executeNext()}))}},e.prototype.getSimplifier=function(e){switch(e.simplificationType){case zh.QUADRATIC:default:return new qh(e.mesh)}},e}();!function(e){e[e.QUADRATIC=0]="QUADRATIC"}(zh||(zh={}));var Xh=function(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0},Yh=function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new Kh,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e}(),Kh=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,n,r,o,a,s,c){return this.data[e]*this.data[r]*this.data[c]+this.data[i]*this.data[n]*this.data[s]+this.data[t]*this.data[o]*this.data[a]-this.data[i]*this.data[r]*this.data[a]-this.data[e]*this.data[o]*this.data[s]-this.data[t]*this.data[n]*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,n=0;n<10;++n)i.data[n]=this.data[n]+t.data[n];return i},e.FromData=function(t,i,n,r){return new e(e.DataFromNumbers(t,i,n,r))},e.DataFromNumbers=function(e,t,i,n){return[e*e,e*t,e*i,e*n,t*t,t*i,t*n,i*i,i*n,n*n]},e}(),Qh=function(e,t){this.vertexId=e,this.triangleId=t},qh=function(){function e(e){this._mesh=e,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=Nt.a}return e.prototype.simplify=function(e,t){var i=this;this.initDecimatedMesh(),Ce.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 n=this,r=~~(this.triangles.length*e.quality),o=0,s=this.triangles.length;Ce.a.Run(this.decimationIterations,(function(e){var t,i;s-o<=r?e.breakLoop():(t=e.index,i=function(){e.executeNext()},setTimeout((function(){t%5==0&&n.updateMesh(0===t);for(var e=0;e<n.triangles.length;++e)n.triangles[e].isDirty=!1;var c=1e-9*Math.pow(t+3,n.aggressiveness);Ce.a.SyncAsyncForLoop(n.triangles.length,n.syncIterations,(function(e){var t=~~((n.triangles.length/2+e)%n.triangles.length),i=n.triangles[t];if(i&&!(i.error[3]>c||i.deleted||i.isDirty))for(var r=0;r<3;++r)if(i.error[r]<c){var s=[],l=[],u=i.vertices[r],h=i.vertices[(r+1)%3];if(u.isBorder||h.isBorder)continue;var d=a.e.Zero();n.calculateError(u,h,d);var f=new Array;if(n.isFlipped(u,h,d,s,f))continue;if(n.isFlipped(h,u,d,l,f))continue;if(s.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 _=n.references.length;o=n.updateTriangles(u,u,s,o),o=n.updateTriangles(u,h,l,o);var m=n.references.length-_;if(m<=u.triangleCount){if(m)for(var g=0;g<m;g++)n.references[u.triangleStart+g]=n.references[_+g]}else u.triangleStart=_;u.triangleCount=m;break}}),i,(function(){return s-o<=r}))}),0))}),(function(){setTimeout((function(){n.reconstructMesh(t),i()}),0)}))},e.prototype.initWithMesh=function(e,t,i){var n=this;this.vertices=[],this.triangles=[];var r=this._mesh.getVerticesData(Qi.b.PositionKind),o=this._mesh.getIndices(),s=this._mesh.subMeshes[e],c=[],l=s.verticesCount;Ce.a.SyncAsyncForLoop(l,this.syncIterations/4>>0,(function(e){if(r){var t=e+s.verticesStart,o=a.e.FromArray(r,3*t),l=function(e){if(i)for(var t=0;t<n.vertices.length;++t)if(n.vertices[t].position.equalsWithEpsilon(e,1e-4))return n.vertices[t];return null}(o)||new Yh(o,n.vertices.length);l.originalOffsets.push(t),l.id===n.vertices.length&&n.vertices.push(l),c.push(l.id)}}),(function(){Ce.a.SyncAsyncForLoop(s.indexCount/3,n.syncIterations,(function(e){if(o){var t=3*(s.indexStart/3+e),i=o[t+0],r=o[t+1],a=o[t+2],l=n.vertices[c[i-s.verticesStart]],u=n.vertices[c[r-s.verticesStart]],h=n.vertices[c[a-s.verticesStart]],d=new Xh([l,u,h]);d.originalOffset=t,n.triangles.push(d)}}),(function(){n.init(t)}))}))},e.prototype.init=function(e){var t=this;Ce.a.SyncAsyncForLoop(this.triangles.length,this.syncIterations,(function(e){var i=t.triangles[e];i.normal=a.e.Cross(i.vertices[1].position.subtract(i.vertices[0].position),i.vertices[2].position.subtract(i.vertices[0].position)).normalize();for(var n=0;n<3;n++)i.vertices[n].q.addArrayInPlace(Kh.DataFromNumbers(i.normal.x,i.normal.y,i.normal.z,-a.e.Dot(i.normal,i.vertices[0].position)))}),(function(){Ce.a.SyncAsyncForLoop(t.triangles.length,t.syncIterations,(function(e){for(var i=t.triangles[e],n=0;n<3;++n)i.error[n]=t.calculateError(i.vertices[n],i.vertices[(n+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,n,r=[];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],n=0;n<3;++n)i.vertices[n].triangleCount=1;r.push(i)}var o=this._reconstructedMesh.getVerticesData(Qi.b.PositionKind)||[],a=this._reconstructedMesh.getVerticesData(Qi.b.NormalKind)||[],s=this._reconstructedMesh.getVerticesData(Qi.b.UVKind)||[],c=this._reconstructedMesh.getVerticesData(Qi.b.ColorKind)||[],l=this._mesh.getVerticesData(Qi.b.NormalKind),u=this._mesh.getVerticesData(Qi.b.UVKind),h=this._mesh.getVerticesData(Qi.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){o.push(f.position.x),o.push(f.position.y),o.push(f.position.z),l&&l.length&&(a.push(l[3*e]),a.push(l[3*e+1]),a.push(l[3*e+2])),u&&u.length&&(s.push(u[2*e]),s.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(),m=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var g=this._reconstructedMesh.getIndices(),v=this._mesh.getIndices();for(t=0;t<r.length;++t)i=r[t],[0,1,2].forEach((function(e){var t=v[i.originalOffset+e],n=i.vertices[e].originalOffsets.indexOf(t);n<0&&(n=0),g.push(i.vertices[e].id+n+_)}));this._reconstructedMesh.setIndices(g),this._reconstructedMesh.setVerticesData(Qi.b.PositionKind,o),a.length>0&&this._reconstructedMesh.setVerticesData(Qi.b.NormalKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(Qi.b.UVKind,s),c.length>0&&this._reconstructedMesh.setVerticesData(Qi.b.ColorKind,c);var b=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],m.forEach((function(e){gh.a.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),gh.a.AddToMesh(b.materialIndex,_,d,p,3*r.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new be.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,n,r){for(var o=0;o<e.triangleCount;++o){var s=this.triangles[this.references[e.triangleStart+o].triangleId];if(!s.deleted){var c=this.references[e.triangleStart+o].vertexId,l=s.vertices[(c+1)%3],u=s.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(a.e.Dot(h,d))>.999)return!0;var f=a.e.Cross(h,d).normalize();if(n[o]=!1,a.e.Dot(f,s.normal)<.2)return!0}else n[o]=!0,r.push(s)}}return!1},e.prototype.updateTriangles=function(e,t,i,n){for(var r=n,o=0;o<t.triangleCount;++o){var a=this.references[t.triangleStart+o],s=this.triangles[a.triangleId];s.deleted||(i[o]&&s.deletePending?(s.deleted=!0,r++):(s.vertices[a.vertexId]=e,s.isDirty=!0,s.error[0]=this.calculateError(s.vertices[0],s.vertices[1])+s.borderFactor/2,s.error[1]=this.calculateError(s.vertices[1],s.vertices[2])+s.borderFactor/2,s.error[2]=this.calculateError(s.vertices[2],s.vertices[0])+s.borderFactor/2,s.error[3]=Math.min(s.error[0],s.error[1],s.error[2]),this.references.push(a)))}return r},e.prototype.identifyBorder=function(){for(var e=0;e<this.vertices.length;++e){var t,i=[],n=[],r=this.vertices[e];for(t=0;t<r.triangleCount;++t)for(var o=this.triangles[this.references[r.triangleStart+t].triangleId],a=0;a<3;a++){for(var s=0,c=o.vertices[a];s<i.length&&n[s]!==c.id;)++s;s===i.length?(i.push(1),n.push(c.id)):i[s]++}for(t=0;t<i.length;++t)1===i[t]?this.vertices[n[t]].isBorder=!0:this.vertices[n[t]].isBorder=!1}},e.prototype.updateMesh=function(e){var t,i,n,r;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],n=0;n<3;++n)(r=i.vertices[n]).triangleCount++;var a=0;for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleStart=a,a+=this.vertices[t].triangleCount,this.vertices[t].triangleCount=0;var s=new Array(3*this.triangles.length);for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],n=0;n<3;++n)s[(r=i.vertices[n]).triangleStart+r.triangleCount]=new Qh(n,t),r.triangleCount++;this.references=s,e&&this.identifyBorder()},e.prototype.vertexError=function(e,t){var i=t.x,n=t.y,r=t.z;return e.data[0]*i*i+2*e.data[1]*i*n+2*e.data[2]*i*r+2*e.data[3]*i+e.data[4]*n*n+2*e.data[5]*n*r+2*e.data[6]*n+e.data[7]*r*r+2*e.data[8]*r+e.data[9]},e.prototype.calculateError=function(e,t,i){var n=e.q.add(t.q),r=e.isBorder&&t.isBorder,o=0,s=n.det(0,1,2,1,4,5,2,5,7);if(0===s||r){var c=e.position.add(t.position).divide(new a.e(2,2,2)),l=this.vertexError(n,e.position),u=this.vertexError(n,t.position),h=this.vertexError(n,c);(o=Math.min(l,u,h))===l?i&&i.copyFrom(e.position):o===u?i&&i.copyFrom(t.position):i&&i.copyFrom(c)}else i||(i=a.e.Zero()),i.x=-1/s*n.det(1,2,3,4,5,6,5,7,8),i.y=1/s*n.det(0,2,3,1,5,6,2,7,8),i.z=-1/s*n.det(0,1,3,1,4,6,2,5,8),o=this.vertexError(n,i);return o},e}();Object.defineProperty(Q.a.prototype,"simplificationQueue",{get:function(){if(!this._simplificationQueue){this._simplificationQueue=new Hh;var e=this._getComponent(Me.a.NAME_SIMPLIFICATIONQUEUE);e||(e=new Zh(this),this._addComponent(e))}return this._simplificationQueue},set:function(e){this._simplificationQueue=e},enumerable:!0,configurable:!0}),be.a.prototype.simplify=function(e,t,i,n){return void 0===t&&(t=!0),void 0===i&&(i=zh.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:e,parallelProcessing:t,mesh:this,simplificationType:i,successCallback:n}),this};var Zh=function(){function e(e){this.name=Me.a.NAME_SIMPLIFICATIONQUEUE,this.scene=e}return e.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(Me.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}(),Jh=i(149),$h=i(88);be.a.prototype.thinInstanceAdd=function(e,t){void 0===t&&(t=!0),this._thinInstanceUpdateBufferSize("matrix",Array.isArray(e)?e.length:1);var i=this._thinInstanceDataStorage.instancesCount;if(Array.isArray(e))for(var n=0;n<e.length;++n)this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,e[n],n===e.length-1&&t);else this.thinInstanceSetMatrixAt(this._thinInstanceDataStorage.instancesCount++,e,t);return i},be.a.prototype.thinInstanceAddSelf=function(e){return void 0===e&&(e=!0),this.thinInstanceAdd(a.a.IdentityReadOnly,e)},be.a.prototype.thinInstanceRegisterAttribute=function(e,t){this.removeVerticesData(e),this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.strides[e]=t,this._userThinInstanceBuffersStorage.sizes[e]=t*Math.max(32,this._thinInstanceDataStorage.instancesCount),this._userThinInstanceBuffersStorage.data[e]=new Float32Array(this._userThinInstanceBuffersStorage.sizes[e]),this._userThinInstanceBuffersStorage.vertexBuffers[e]=new Qi.b(this.getEngine(),this._userThinInstanceBuffersStorage.data[e],e,!0,!1,t,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])},be.a.prototype.thinInstanceSetMatrixAt=function(e,t,i){if(void 0===i&&(i=!0),!this._thinInstanceDataStorage.matrixData||e>=this._thinInstanceDataStorage.instancesCount)return!1;var n=this._thinInstanceDataStorage.matrixData;return t.copyToArray(n,16*e),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[e]=t),i&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},be.a.prototype.thinInstanceSetAttributeAt=function(e,t,i,n){return void 0===n&&(n=!0),!(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[e]||t>=this._thinInstanceDataStorage.instancesCount)&&(this._thinInstanceUpdateBufferSize(e,0),this._userThinInstanceBuffersStorage.data[e].set(i,t*this._userThinInstanceBuffersStorage.strides[e]),n&&this.thinInstanceBufferUpdated(e),!0)},Object.defineProperty(be.a.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(e){var t,i;e<=(null!==(i=null===(t=this._thinInstanceDataStorage.matrixData)||void 0===t?void 0:t.length)&&void 0!==i?i:0)/16&&(this._thinInstanceDataStorage.instancesCount=e)},enumerable:!0,configurable:!0}),be.a.prototype.thinInstanceSetBuffer=function(e,t,i,n){var r,o;if(void 0===i&&(i=0),void 0===n&&(n=!1),i=i||16,"matrix"===e)if(null===(r=this._thinInstanceDataStorage.matrixBuffer)||void 0===r||r.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=t?t.length:32*i,this._thinInstanceDataStorage.matrixData=t,this._thinInstanceDataStorage.worldMatrices=null,null!==t){this._thinInstanceDataStorage.instancesCount=t.length/i;var a=new Qi.a(this.getEngine(),t,!n,i,!1,!0);this._thinInstanceDataStorage.matrixBuffer=a,this.setVerticesBuffer(a.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(a.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(a.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(a.createVertexBuffer("world3",12,4)),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)}else this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo(!0);else null===t?(null===(o=this._userThinInstanceBuffersStorage)||void 0===o?void 0:o.data[e])&&(this.removeVerticesData(e),delete this._userThinInstanceBuffersStorage.data[e],delete this._userThinInstanceBuffersStorage.strides[e],delete this._userThinInstanceBuffersStorage.sizes[e],delete this._userThinInstanceBuffersStorage.vertexBuffers[e]):(this._thinInstanceInitializeUserStorage(),this._userThinInstanceBuffersStorage.data[e]=t,this._userThinInstanceBuffersStorage.strides[e]=i,this._userThinInstanceBuffersStorage.sizes[e]=t.length,this._userThinInstanceBuffersStorage.vertexBuffers[e]=new Qi.b(this.getEngine(),t,e,!n,!1,i,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e]))},be.a.prototype.thinInstanceBufferUpdated=function(e){var t;"matrix"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount):(null===(t=this._userThinInstanceBuffersStorage)||void 0===t?void 0:t.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e],0)},be.a.prototype.thinInstancePartialBufferUpdate=function(e,t,i){var n;"matrix"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,i):(null===(n=this._userThinInstanceBuffersStorage)||void 0===n?void 0:n.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t,i)},be.a.prototype.thinInstanceGetWorldMatrices=function(){if(!this._thinInstanceDataStorage.matrixData||!this._thinInstanceDataStorage.matrixBuffer)return[];var e=this._thinInstanceDataStorage.matrixData;if(!this._thinInstanceDataStorage.worldMatrices){this._thinInstanceDataStorage.worldMatrices=new Array;for(var t=0;t<this._thinInstanceDataStorage.instancesCount;++t)this._thinInstanceDataStorage.worldMatrices[t]=a.a.FromArray(e,16*t)}return this._thinInstanceDataStorage.worldMatrices},be.a.prototype.thinInstanceRefreshBoundingInfo=function(e){if(void 0===e&&(e=!1),this._thinInstanceDataStorage.matrixData&&this._thinInstanceDataStorage.matrixBuffer){var t=this._thinInstanceDataStorage.boundingVectors;e&&(t.length=0,this.refreshBoundingInfo(!0));var i=this.getBoundingInfo(),n=this._thinInstanceDataStorage.matrixData;if(0===t.length)for(var r=0;r<i.boundingBox.vectors.length;++r)t.push(i.boundingBox.vectors[r].clone());a.c.Vector3[0].setAll(Number.POSITIVE_INFINITY),a.c.Vector3[1].setAll(Number.NEGATIVE_INFINITY);for(var o=0;o<this._thinInstanceDataStorage.instancesCount;++o){a.a.FromArrayToRef(n,16*o,a.c.Matrix[0]);for(r=0;r<t.length;++r)a.e.TransformCoordinatesToRef(t[r],a.c.Matrix[0],a.c.Vector3[2]),a.c.Vector3[0].minimizeInPlace(a.c.Vector3[2]),a.c.Vector3[1].maximizeInPlace(a.c.Vector3[2])}i.reConstruct(a.c.Vector3[0],a.c.Vector3[1]),this._updateBoundingInfo()}},be.a.prototype._thinInstanceUpdateBufferSize=function(e,t){var i,n;void 0===t&&(t=1);var r="matrix"===e;if(r||this._userThinInstanceBuffersStorage&&this._userThinInstanceBuffersStorage.strides[e]){for(var o=r?16:this._userThinInstanceBuffersStorage.strides[e],a=r?this._thinInstanceDataStorage.matrixBufferSize:this._userThinInstanceBuffersStorage.sizes[e],s=r?this._thinInstanceDataStorage.matrixData:this._userThinInstanceBuffersStorage.data[e],c=(this._thinInstanceDataStorage.instancesCount+t)*o,l=a;l<c;)l*=2;if(!s||a!=l){if(s){var u=new Float32Array(l);u.set(s,0),s=u}else s=new Float32Array(l);if(r){null===(i=this._thinInstanceDataStorage.matrixBuffer)||void 0===i||i.dispose();var h=new Qi.a(this.getEngine(),s,!0,o,!1,!0);this._thinInstanceDataStorage.matrixBuffer=h,this._thinInstanceDataStorage.matrixData=s,this._thinInstanceDataStorage.matrixBufferSize=l,this.setVerticesBuffer(h.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(h.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(h.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(h.createVertexBuffer("world3",12,4))}else null===(n=this._userThinInstanceBuffersStorage.vertexBuffers[e])||void 0===n||n.dispose(),this._userThinInstanceBuffersStorage.data[e]=s,this._userThinInstanceBuffersStorage.sizes[e]=l,this._userThinInstanceBuffersStorage.vertexBuffers[e]=new Qi.b(this.getEngine(),s,e,!0,!1,o,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])}}},be.a.prototype._thinInstanceInitializeUserStorage=function(){this._userThinInstanceBuffersStorage||(this._userThinInstanceBuffersStorage={data:{},sizes:{},vertexBuffers:{},strides:{}})},be.a.prototype._disposeThinInstanceSpecificData=function(){var e;(null===(e=this._thinInstanceDataStorage)||void 0===e?void 0:e.matrixBuffer)&&(this._thinInstanceDataStorage.matrixBuffer.dispose(),this._thinInstanceDataStorage.matrixBuffer=null)};var ed=function(){function e(e){void 0===e&&(e=Recast),this.bjsRECAST={},this.name="RecastJSPlugin",this._maximumSubStepCount=10,this._timeStep=1/60,"function"==typeof e?e(this.bjsRECAST):this.bjsRECAST=e,this.isSupported()?this.setTimeStep():m.a.Error("RecastJS is not available. Please make sure you included the js file.")}return e.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._timeStep=e},e.prototype.getTimeStep=function(){return this._timeStep},e.prototype.setMaximumSubStepCount=function(e){void 0===e&&(e=10),this._maximumSubStepCount=e},e.prototype.getMaximumSubStepCount=function(){return this._maximumSubStepCount},e.prototype.createNavMesh=function(e,t){var i,n,r,o=new this.bjsRECAST.rcConfig;o.cs=t.cs,o.ch=t.ch,o.borderSize=0,o.tileSize=0,o.walkableSlopeAngle=t.walkableSlopeAngle,o.walkableHeight=t.walkableHeight,o.walkableClimb=t.walkableClimb,o.walkableRadius=t.walkableRadius,o.maxEdgeLen=t.maxEdgeLen,o.maxSimplificationError=t.maxSimplificationError,o.minRegionArea=t.minRegionArea,o.mergeRegionArea=t.mergeRegionArea,o.maxVertsPerPoly=t.maxVertsPerPoly,o.detailSampleDist=t.detailSampleDist,o.detailSampleMaxError=t.detailSampleMaxError,this.navMesh=new this.bjsRECAST.NavMesh;var s=[],c=[],l=0;for(i=0;i<e.length;i++)if(e[i]){var u=e[i],h=u.getIndices();if(!h)continue;var d=u.getVerticesData(Qi.b.PositionKind,!1,!1);if(!d)continue;var f=u.computeWorldMatrix(!0);for(n=0;n<h.length;n++)s.push(h[n]+l);var p=a.e.Zero(),_=a.e.Zero();for(r=0;r<d.length;r+=3)a.e.FromArrayToRef(d,r,_),a.e.TransformCoordinatesToRef(_,f,p),c.push(p.x,p.y,p.z);l+=d.length/3}this.navMesh.build(c,l,s,s.length,o)},e.prototype.createDebugNavMesh=function(e){var t,i,n=this.navMesh.getDebugNavMesh(),r=n.getTriangleCount(),o=[],a=[];for(t=0;t<3*r;t++)o.push(t);for(t=0;t<r;t++)for(i=0;i<3;i++){var s=n.getTriangle(t).getPoint(i);a.push(s.x,s.y,s.z)}var c=new be.a("NavMeshDebug",e),l=new Ki.a;return l.indices=o,l.positions=a,l.applyToMesh(c,!1),c},e.prototype.getClosestPoint=function(e){var t=new this.bjsRECAST.Vec3(e.x,e.y,e.z),i=this.navMesh.getClosestPoint(t);return new a.e(i.x,i.y,i.z)},e.prototype.getClosestPointToRef=function(e,t){var i=new this.bjsRECAST.Vec3(e.x,e.y,e.z),n=this.navMesh.getClosestPoint(i);t.set(n.x,n.y,n.z)},e.prototype.getRandomPointAround=function(e,t){var i=new this.bjsRECAST.Vec3(e.x,e.y,e.z),n=this.navMesh.getRandomPointAround(i,t);return new a.e(n.x,n.y,n.z)},e.prototype.getRandomPointAroundToRef=function(e,t,i){var n=new this.bjsRECAST.Vec3(e.x,e.y,e.z),r=this.navMesh.getRandomPointAround(n,t);i.set(r.x,r.y,r.z)},e.prototype.moveAlong=function(e,t){var i=new this.bjsRECAST.Vec3(e.x,e.y,e.z),n=new this.bjsRECAST.Vec3(t.x,t.y,t.z),r=this.navMesh.moveAlong(i,n);return new a.e(r.x,r.y,r.z)},e.prototype.moveAlongToRef=function(e,t,i){var n=new this.bjsRECAST.Vec3(e.x,e.y,e.z),r=new this.bjsRECAST.Vec3(t.x,t.y,t.z),o=this.navMesh.moveAlong(n,r);i.set(o.x,o.y,o.z)},e.prototype.computePath=function(e,t){var i,n=new this.bjsRECAST.Vec3(e.x,e.y,e.z),r=new this.bjsRECAST.Vec3(t.x,t.y,t.z),o=this.navMesh.computePath(n,r),s=o.getPointCount(),c=[];for(i=0;i<s;i++){var l=o.getPoint(i);c.push(new a.e(l.x,l.y,l.z))}return c},e.prototype.createCrowd=function(e,t,i){return new td(this,e,t,i)},e.prototype.setDefaultQueryExtent=function(e){var t=new this.bjsRECAST.Vec3(e.x,e.y,e.z);this.navMesh.setDefaultQueryExtent(t)},e.prototype.getDefaultQueryExtent=function(){var e=this.navMesh.getDefaultQueryExtent();return new a.e(e.x,e.y,e.z)},e.prototype.buildFromNavmeshData=function(e){var t=e.length*e.BYTES_PER_ELEMENT,i=this.bjsRECAST._malloc(t),n=new Uint8Array(this.bjsRECAST.HEAPU8.buffer,i,t);n.set(e);var r=new this.bjsRECAST.NavmeshData;r.dataPointer=n.byteOffset,r.size=e.length,this.navMesh=new this.bjsRECAST.NavMesh,this.navMesh.buildFromNavmeshData(r),this.bjsRECAST._free(n.byteOffset)},e.prototype.getNavmeshData=function(){var e=this.navMesh.getNavmeshData(),t=new Uint8Array(this.bjsRECAST.HEAPU8.buffer,e.dataPointer,e.size),i=new Uint8Array(e.size);return i.set(t),this.navMesh.freeNavmeshData(e),i},e.prototype.getDefaultQueryExtentToRef=function(e){var t=this.navMesh.getDefaultQueryExtent();e.set(t.x,t.y,t.z)},e.prototype.dispose=function(){},e.prototype.isSupported=function(){return void 0!==this.bjsRECAST},e}(),td=function(){function e(e,t,i,n){var r=this;this.recastCrowd={},this.transforms=new Array,this.agents=new Array,this._onBeforeAnimationsObserver=null,this.bjsRECASTPlugin=e,this.recastCrowd=new this.bjsRECASTPlugin.bjsRECAST.Crowd(t,i,this.bjsRECASTPlugin.navMesh.getNavMesh()),this._scene=n,this._onBeforeAnimationsObserver=n.onBeforeAnimationsObservable.add((function(){r.update(.001*n.getEngine().getDeltaTime())}))}return e.prototype.addAgent=function(e,t,i){var n=new this.bjsRECASTPlugin.bjsRECAST.dtCrowdAgentParams;n.radius=t.radius,n.height=t.height,n.maxAcceleration=t.maxAcceleration,n.maxSpeed=t.maxSpeed,n.collisionQueryRange=t.collisionQueryRange,n.pathOptimizationRange=t.pathOptimizationRange,n.separationWeight=t.separationWeight,n.updateFlags=7,n.obstacleAvoidanceType=0,n.queryFilterType=0,n.userData=0;var r=this.recastCrowd.addAgent(new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z),n);return this.transforms.push(i),this.agents.push(r),r},e.prototype.getAgentPosition=function(e){var t=this.recastCrowd.getAgentPosition(e);return new a.e(t.x,t.y,t.z)},e.prototype.getAgentPositionToRef=function(e,t){var i=this.recastCrowd.getAgentPosition(e);t.set(i.x,i.y,i.z)},e.prototype.getAgentVelocity=function(e){var t=this.recastCrowd.getAgentVelocity(e);return new a.e(t.x,t.y,t.z)},e.prototype.getAgentVelocityToRef=function(e,t){var i=this.recastCrowd.getAgentVelocity(e);t.set(i.x,i.y,i.z)},e.prototype.getAgentNextTargetPath=function(e){var t=this.recastCrowd.getAgentNextTargetPath(e);return new a.e(t.x,t.y,t.z)},e.prototype.getAgentNextTargetPathToRef=function(e,t){var i=this.recastCrowd.getAgentNextTargetPath(e);t.set(i.x,i.y,i.z)},e.prototype.getAgentState=function(e){return this.recastCrowd.getAgentState(e)},e.prototype.overOffmeshConnection=function(e){return this.recastCrowd.overOffmeshConnection(e)},e.prototype.agentGoto=function(e,t){this.recastCrowd.agentGoto(e,new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z))},e.prototype.agentTeleport=function(e,t){this.recastCrowd.agentTeleport(e,new this.bjsRECASTPlugin.bjsRECAST.Vec3(t.x,t.y,t.z))},e.prototype.updateAgentParameters=function(e,t){var i=this.recastCrowd.getAgentParameters(e);void 0!==t.radius&&(i.radius=t.radius),void 0!==t.height&&(i.height=t.height),void 0!==t.maxAcceleration&&(i.maxAcceleration=t.maxAcceleration),void 0!==t.maxSpeed&&(i.maxSpeed=t.maxSpeed),void 0!==t.collisionQueryRange&&(i.collisionQueryRange=t.collisionQueryRange),void 0!==t.pathOptimizationRange&&(i.pathOptimizationRange=t.pathOptimizationRange),void 0!==t.separationWeight&&(i.separationWeight=t.separationWeight),this.recastCrowd.setAgentParameters(e,i)},e.prototype.removeAgent=function(e){this.recastCrowd.removeAgent(e);var t=this.agents.indexOf(e);t>-1&&(this.agents.splice(t,1),this.transforms.splice(t,1))},e.prototype.getAgents=function(){return this.agents},e.prototype.update=function(e){var t=this.bjsRECASTPlugin.getTimeStep(),i=this.bjsRECASTPlugin.getMaximumSubStepCount();if(t<=Nt.a)this.recastCrowd.update(e);else{var n=e/t;i&&n>i&&(n=i),n<1&&(n=1);for(var r=0;r<n;r++)this.recastCrowd.update(t)}for(var o=0;o<this.agents.length;o++)this.transforms[o].position=this.getAgentPosition(this.agents[o])},e.prototype.setDefaultQueryExtent=function(e){var t=new this.bjsRECASTPlugin.bjsRECAST.Vec3(e.x,e.y,e.z);this.recastCrowd.setDefaultQueryExtent(t)},e.prototype.getDefaultQueryExtent=function(){var e=this.recastCrowd.getDefaultQueryExtent();return new a.e(e.x,e.y,e.z)},e.prototype.getDefaultQueryExtentToRef=function(e){var t=this.recastCrowd.getDefaultQueryExtent();e.set(t.x,t.y,t.z)},e.prototype.dispose=function(){this.recastCrowd.destroy(),this._scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null},e}();Se.a.OfflineProviderFactory=function(e,t,i){return void 0===i&&(i=!1),new nd(e,t,i)};var id,nd=function(){function e(t,i,n){var r=this;void 0===n&&(n=!1),this._idbFactory="undefined"!=typeof window?window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB:indexedDB,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?n?(this._enableSceneOffline=!0,this._enableTexturesOffline=!0,this._manifestVersionFound=1,Ce.b.SetImmediate((function(){r._callbackManifestChecked(!0)}))):this._checkManifestFile():this._callbackManifestChecked(!0)}return Object.defineProperty(e.prototype,"enableSceneOffline",{get:function(){return this._enableSceneOffline},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableTexturesOffline",{get:function(){return this._enableTexturesOffline},enumerable:!1,configurable:!0}),e.prototype._checkManifestFile=function(){var t=this,i=function(){t._enableSceneOffline=!1,t._enableTexturesOffline=!1,t._callbackManifestChecked(!1)},n=!1,r=this._currentSceneUrl+".manifest",o=new V.a;navigator.onLine&&(n=!0,r=r+(null==r.match(/\?/)?"?":"&")+Date.now()),o.open("GET",r),o.addEventListener("load",(function(){if(200===o.status||e._ValidateXHRData(o,1))try{var n=JSON.parse(o.response);t._enableSceneOffline=n.enableSceneOffline,t._enableTexturesOffline=n.enableTexturesOffline&&e.IsUASupportingBlobStorage,n.version&&!isNaN(parseInt(n.version))&&(t._manifestVersionFound=n.version),t._callbackManifestChecked&&t._callbackManifestChecked(!0)}catch(e){i()}else i()}),!1),o.addEventListener("error",(function(){if(n){n=!1;var e=t._currentSceneUrl+".manifest";o.open("GET",e),o.send()}else i()}),!1);try{o.send()}catch(e){m.a.Error("Error on XHR send request."),this._callbackManifestChecked(!1)}},e.prototype.open=function(e,t){var i=this,n=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 r=this._idbFactory.open("babylonjs",1);r.onerror=function(){n()},r.onblocked=function(){m.a.Error("IDB request blocked. Please reload the page."),n()},r.onsuccess=function(){i._db=r.result,e()},r.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){m.a.Error("Error while creating object stores. Exception: "+e.message),n()}}}else this._isSupported=!1,t&&t()},e.prototype.loadImage=function(t,i){var n=this,r=e._ReturnFullUrlLocation(t),o=function(){n._hasReachedQuota||null===n._db?i.src=t:n._saveImageIntoDBAsync(r,i)};this._mustUpdateRessources?o():this._loadImageFromDBAsync(r,i,o)},e.prototype._loadImageFromDBAsync=function(e,t,i){if(this._isSupported&&null!==this._db){var n,r=this._db.transaction(["textures"]);r.onabort=function(){t.src=e},r.oncomplete=function(){var r;if(n){var o=window.URL||window.webkitURL;r=o.createObjectURL(n.data),t.onerror=function(){m.a.Error("Error loading image from blob URL: "+r+" switching back to web url: "+e),t.src=e},t.src=r}else i()};var o=r.objectStore("textures").get(e);o.onsuccess=function(e){n=e.target.result},o.onerror=function(){m.a.Error("Error loading texture "+e+" from DB."),t.src=e}}else m.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 n=this;if(this._isSupported){var r=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,a=new V.a;a.open("GET",t),a.responseType="blob",a.addEventListener("load",(function(){if(200===a.status&&n._db){o=a.response;var s=n._db.transaction(["textures"],"readwrite");s.onabort=function(e){try{var t=(e.srcElement||e.target).error;t&&"QuotaExceededError"===t.name&&(n._hasReachedQuota=!0)}catch(e){}r()},s.oncomplete=function(){r()};var c={textureUrl:t,data:o};try{var l=s.objectStore("textures").put(c);l.onsuccess=function(){},l.onerror=function(){r()}}catch(r){25===r.code&&(e.IsUASupportingBlobStorage=!1,n._enableTexturesOffline=!1),i.src=t}}else i.src=t}),!1),a.addEventListener("error",(function(){m.a.Error("Error in XHR request in BABYLON.Database."),i.src=t}),!1),a.send()}else i.src=t}else m.a.Error("Error: IndexedDB not supported by your browser or Babylon.js 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 n,r=this;if(this._isSupported&&this._db)try{var o=this._db.transaction(["versions"]);o.oncomplete=function(){n?r._manifestVersionFound!==n.data?(r._mustUpdateRessources=!0,i()):t(n.data):(r._mustUpdateRessources=!0,i())},o.onabort=function(){t(-1)};var a=o.objectStore("versions").get(e);a.onsuccess=function(e){n=e.target.result},a.onerror=function(){m.a.Error("Error loading version for scene "+e+" from DB."),t(-1)}}catch(e){m.a.Error("Error while accessing 'versions' object store (READ OP). Exception: "+e.message),t(-1)}else m.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),t(-1)},e.prototype._saveVersionIntoDBAsync=function(e,t){var i=this;if(this._isSupported&&!this._hasReachedQuota&&this._db)try{var n=this._db.transaction(["versions"],"readwrite");n.onabort=function(e){try{var n=e.srcElement.error;n&&"QuotaExceededError"===n.name&&(i._hasReachedQuota=!0)}catch(e){}t(-1)},n.oncomplete=function(){t(i._manifestVersionFound)};var r={sceneUrl:e,data:this._manifestVersionFound},o=n.objectStore("versions").put(r);o.onsuccess=function(){},o.onerror=function(){m.a.Error("Error in DB add version request in BABYLON.Database.")}}catch(e){m.a.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+e.message),t(-1)}else t(-1)},e.prototype.loadFile=function(t,i,n,r,o){var a=this,s=e._ReturnFullUrlLocation(t),c=function(){a._saveFileAsync(s,i,n,o,r)};this._checkVersionFromDB(s,(function(e){-1!==e?a._mustUpdateRessources?a._saveFileAsync(s,i,n,o,r):a._loadFileAsync(s,i,c):r&&r()}))},e.prototype._loadFileAsync=function(e,t,i){if(this._isSupported&&this._db){var n,r;n=-1!==e.indexOf(".babylon")?"scenes":"textures";var o=this._db.transaction([n]);o.oncomplete=function(){r?t(r.data):i()},o.onabort=function(){i()};var a=o.objectStore(n).get(e);a.onsuccess=function(e){r=e.target.result},a.onerror=function(){m.a.Error("Error loading file "+e+" from DB."),i()}}else m.a.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),t()},e.prototype._saveFileAsync=function(t,i,n,r,o){var a=this;if(this._isSupported){var s;s=-1!==t.indexOf(".babylon")?"scenes":"textures";var c,l=new V.a;l.open("GET",t+"?"+Date.now()),r&&(l.responseType="arraybuffer"),n&&(l.onprogress=n),l.addEventListener("load",(function(){if(200===l.status||l.status<400&&e._ValidateXHRData(l,r?6:1))if(c=r?l.response:l.responseText,!a._hasReachedQuota&&a._db){var n,u=a._db.transaction([s],"readwrite");u.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(a._hasReachedQuota=!0)}catch(e){}i(c)},u.oncomplete=function(){i(c)},n="scenes"===s?{sceneUrl:t,data:c,version:a._manifestVersionFound}:{textureUrl:t,data:c};try{var h=u.objectStore(s).put(n);h.onsuccess=function(){},h.onerror=function(){m.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(){m.a.Error("error on XHR request."),i()}),!1),l.send()}else m.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=Uc.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 n=new Uint8Array(e.response,0,3);return 68===n[0]&&68===n[1]&&83===n[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:/")&&"undefined"!=typeof window?e._ParseURL(window.location.href)+t:t},e}(),rd=function(){function e(e,t,i){this.gradient=e,this.color1=t,this.color2=i}return e.prototype.getColorToRef=function(e){this.color2?s.b.LerpToRef(this.color1,this.color2,Math.random(),e):e.copyFrom(this.color1)},e}(),od=function(e,t){this.gradient=e,this.color=t},ad=function(){function e(e,t,i){this.gradient=e,this.factor1=t,this.factor2=i}return e.prototype.getFactor=function(){return void 0===this.factor2||this.factor2===this.factor1?this.factor1:this.factor1+(this.factor2-this.factor1)*Math.random()},e}(),sd=function(){function e(){}return e.GetCurrentGradient=function(e,t,i){if(t[0].gradient>e)i(t[0],t[0],1);else{for(var n=0;n<t.length-1;n++){var r=t[n],o=t[n+1];if(e>=r.gradient&&e<=o.gradient)return void i(r,o,(e-r.gradient)/(o.gradient-r.gradient))}var a=t.length-1;i(t[a],t[a],1)}},e}(),cd=function(){function e(t){this.particleSystem=t,this.position=a.e.Zero(),this.direction=a.e.Zero(),this.color=new s.b(0,0,0,0),this.colorStep=new s.b(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new a.d(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new s.b(0,0,0,0),this._currentColor2=new s.b(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,n=L.a.Clamp(e*t%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+n*i|0},e.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;if(t.position.copyFrom(this.position),e.inheritDirection){var i=a.c.Vector3[0];this.direction.normalizeToRef(i),t.setDirection(i,0,Math.PI/2)}}else{e.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(e.inheritedVelocityAmount/2,a.c.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(a.c.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.id=e._Count++,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),this._localPosition&&(e._localPosition?e._localPosition.copyFrom(this._localPosition):e._localPosition=this._localPosition.clone()),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&&this.remapData?e.remapData.copyFrom(this.remapData):e.remapData=new a.f(0,0,0,0)),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"}(id||(id={}));var ld=function(){function e(e){if(this.particleSystem=e,this.type=id.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!e.emitter||!e.emitter.dispose){var t=c.a.GetClass("BABYLON.AbstractMesh");e.emitter=new t("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;if(t){if(t instanceof a.e)t=t.clone();else if(-1!==t.getClassName().indexOf("Mesh")){(t=new(c.a.GetClass("BABYLON.Mesh"))("",t.getScene())).isVisible=!1}}else t=new a.e;var i=new e(this.particleSystem.clone("",t));return i.particleSystem.name+="Clone",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 Re.a.WarnImport("ParseParticle")},e.Parse=function(t,i,n){var r=t.particleSystem,o=new e(e._ParseParticleSystem(r,i,n));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}(),ud="\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}";ai.a.ShadersStore.particlesPixelShader=ud;var hd="\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;\nvarying vec3 vPositionW;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\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.;\nvPositionW=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,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;\nvPositionW=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(vPositionW,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;\nvPositionW=(invView*vec4(viewPos,1)).xyz;\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);\nvPositionW=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(vPositionW,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) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include<clipPlaneVertex>\n}";ai.a.ShadersStore.particlesVertexShader=hd;var dd=function(e){function t(t,i,n,r,c,l){void 0===r&&(r=null),void 0===c&&(c=!1),void 0===l&&(l=.01);var u=e.call(this,t)||this;return u._inheritedVelocityOffset=new a.e,u.onDisposeObservable=new o.c,u.onStoppedObservable=new o.c,u._particles=new Array,u._stockParticles=new Array,u._newPartsExcess=0,u._vertexBuffers={},u._scaledColorStep=new s.b(0,0,0,0),u._colorDiff=new s.b(0,0,0,0),u._scaledDirection=a.e.Zero(),u._scaledGravity=a.e.Zero(),u._currentRenderId=-1,u._useInstancing=!1,u._started=!1,u._stopped=!1,u._actualFrame=0,u._currentEmitRate1=0,u._currentEmitRate2=0,u._currentStartSize1=0,u._currentStartSize2=0,u._rawTextureWidth=256,u._useRampGradients=!1,u._disposeEmitterOnDispose=!1,u.isLocal=!1,u._onBeforeDrawParticlesObservable=null,u.recycleParticle=function(e){var t=u._particles.pop();t!==e&&t.copyTo(e),u._stockParticles.push(t)},u._createParticle=function(){var e;if(0!==u._stockParticles.length?(e=u._stockParticles.pop())._reset():e=new cd(u),u._subEmitters&&u._subEmitters.length>0){var t=u._subEmitters[Math.floor(Math.random()*u._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===id.ATTACHED){var i=t.clone();e._attachedSubEmitters.push(i),i.particleSystem.start()}}))}return e},u._emitFromParticle=function(e){if(u._subEmitters&&0!==u._subEmitters.length){var t=Math.floor(Math.random()*u._subEmitters.length);u._subEmitters[t].forEach((function(t){if(t.type===id.END){var i=t.clone();e._inheritParticleInfoToSubEmitter(i),i.particleSystem._rootParticleSystem=u,u.activeSubSystems.push(i.particleSystem),i.particleSystem.start()}}))}},u._capacity=i,u._epsilon=l,u._isAnimationSheetEnabled=c,n&&"Scene"!==n.getClassName()?(u._engine=n,u.defaultProjectionMatrix=a.a.PerspectiveFovLH(.8,1,.1,100)):(u._scene=n||x.a.LastCreatedScene,u._engine=u._scene.getEngine(),u.uniqueId=u._scene.getUniqueId(),u._scene.particleSystems.push(u)),u._engine.getCaps().vertexArrayObject&&(u._vertexArrayObject=null),u._attachImageProcessingConfiguration(null),u._customEffect={0:r},u._useInstancing=u._engine.getCaps().instancedArrays,u._createIndexBuffer(),u._createVertexBuffers(),u.particleEmitterType=new Nl,u.updateFunction=function(e){var t=null,i=null;u.noiseTexture&&(t=u.noiseTexture.getSize(),i=u.noiseTexture.getContent());for(var n,r=function(){n=e[o];var r=u._scaledUpdateSpeed,c=n.age;if(n.age+=r,n.age>n.lifeTime){var l=n.age-c;r=(n.lifeTime-c)*r/l,n.age=n.lifeTime}var h=n.age/n.lifeTime;u._colorGradients&&u._colorGradients.length>0?sd.GetCurrentGradient(h,u._colorGradients,(function(e,t,i){e!==n._currentColorGradient&&(n._currentColor1.copyFrom(n._currentColor2),t.getColorToRef(n._currentColor2),n._currentColorGradient=e),s.b.LerpToRef(n._currentColor1,n._currentColor2,i,n.color)})):(n.colorStep.scaleToRef(r,u._scaledColorStep),n.color.addInPlace(u._scaledColorStep),n.color.a<0&&(n.color.a=0)),u._angularSpeedGradients&&u._angularSpeedGradients.length>0&&sd.GetCurrentGradient(h,u._angularSpeedGradients,(function(e,t,i){e!==n._currentAngularSpeedGradient&&(n._currentAngularSpeed1=n._currentAngularSpeed2,n._currentAngularSpeed2=t.getFactor(),n._currentAngularSpeedGradient=e),n.angularSpeed=L.a.Lerp(n._currentAngularSpeed1,n._currentAngularSpeed2,i)})),n.angle+=n.angularSpeed*r;var d=r;if(u._velocityGradients&&u._velocityGradients.length>0&&sd.GetCurrentGradient(h,u._velocityGradients,(function(e,t,i){e!==n._currentVelocityGradient&&(n._currentVelocity1=n._currentVelocity2,n._currentVelocity2=t.getFactor(),n._currentVelocityGradient=e),d*=L.a.Lerp(n._currentVelocity1,n._currentVelocity2,i)})),n.direction.scaleToRef(d,u._scaledDirection),u._limitVelocityGradients&&u._limitVelocityGradients.length>0&&sd.GetCurrentGradient(h,u._limitVelocityGradients,(function(e,t,i){e!==n._currentLimitVelocityGradient&&(n._currentLimitVelocity1=n._currentLimitVelocity2,n._currentLimitVelocity2=t.getFactor(),n._currentLimitVelocityGradient=e);var r=L.a.Lerp(n._currentLimitVelocity1,n._currentLimitVelocity2,i);n.direction.length()>r&&n.direction.scaleInPlace(u.limitVelocityDamping)})),u._dragGradients&&u._dragGradients.length>0&&sd.GetCurrentGradient(h,u._dragGradients,(function(e,t,i){e!==n._currentDragGradient&&(n._currentDrag1=n._currentDrag2,n._currentDrag2=t.getFactor(),n._currentDragGradient=e);var r=L.a.Lerp(n._currentDrag1,n._currentDrag2,i);u._scaledDirection.scaleInPlace(1-r)})),u.isLocal&&n._localPosition?(n._localPosition.addInPlace(u._scaledDirection),a.e.TransformCoordinatesToRef(n._localPosition,u._emitterWorldMatrix,n.position)):n.position.addInPlace(u._scaledDirection),i&&t&&n._randomNoiseCoordinates1){var f=u._fetchR(n._randomNoiseCoordinates1.x,n._randomNoiseCoordinates1.y,t.width,t.height,i),p=u._fetchR(n._randomNoiseCoordinates1.z,n._randomNoiseCoordinates2.x,t.width,t.height,i),_=u._fetchR(n._randomNoiseCoordinates2.y,n._randomNoiseCoordinates2.z,t.width,t.height,i),m=a.c.Vector3[0],g=a.c.Vector3[1];m.copyFromFloats((2*f-1)*u.noiseStrength.x,(2*p-1)*u.noiseStrength.y,(2*_-1)*u.noiseStrength.z),m.scaleToRef(r,g),n.direction.addInPlace(g)}if(u.gravity.scaleToRef(r,u._scaledGravity),n.direction.addInPlace(u._scaledGravity),u._sizeGradients&&u._sizeGradients.length>0&&sd.GetCurrentGradient(h,u._sizeGradients,(function(e,t,i){e!==n._currentSizeGradient&&(n._currentSize1=n._currentSize2,n._currentSize2=t.getFactor(),n._currentSizeGradient=e),n.size=L.a.Lerp(n._currentSize1,n._currentSize2,i)})),u._useRampGradients&&(u._colorRemapGradients&&u._colorRemapGradients.length>0&&sd.GetCurrentGradient(h,u._colorRemapGradients,(function(e,t,i){var r=L.a.Lerp(e.factor1,t.factor1,i),o=L.a.Lerp(e.factor2,t.factor2,i);n.remapData.x=r,n.remapData.y=o-r})),u._alphaRemapGradients&&u._alphaRemapGradients.length>0&&sd.GetCurrentGradient(h,u._alphaRemapGradients,(function(e,t,i){var r=L.a.Lerp(e.factor1,t.factor1,i),o=L.a.Lerp(e.factor2,t.factor2,i);n.remapData.z=r,n.remapData.w=o-r}))),u._isAnimationSheetEnabled&&n.updateCellIndex(),n._inheritParticleInfoToSubEmitters(),n.age>=n.lifeTime)return u._emitFromParticle(n),n._attachedSubEmitters&&(n._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),n._attachedSubEmitters=null),u.recycleParticle(n),o--,"continue"},o=0;o<e.length;o++)r()},u}return Object(h.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:!1,configurable:!0}),Object.defineProperty(t.prototype,"useRampGradients",{get:function(){return this._useRampGradients},set:function(e){this._useRampGradients!==e&&(this._useRampGradients=e,this._resetEffect())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"particles",{get:function(){return this._particles},enumerable:!1,configurable:!0}),t.prototype.getActiveCount=function(){return this._particles.length},t.prototype.getClassName=function(){return"ParticleSystem"},t.prototype.isStopping=function(){return this._stopped&&this.isAlive()},t.prototype.getCustomEffect=function(e){var t;return void 0===e&&(e=0),null!==(t=this._customEffect[e])&&void 0!==t?t:this._customEffect[0]},t.prototype.setCustomEffect=function(e,t){void 0===t&&(t=0),this._customEffect[t]=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new o.c),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"particles"},enumerable:!1,configurable:!0}),t.prototype._addFactorGradient=function(e,t,i,n){var r=new ad(t,i,n);e.push(r),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,n=0,r=e;n<r.length;n++){if(r[n].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._startSizeGradients,e),this},t.prototype._createRampGradientTexture=function(){if(this._rampGradients&&this._rampGradients.length&&!this._rampGradientsTexture&&this._scene){for(var e=new Uint8Array(4*this._rawTextureWidth),t=s.c.Color3[0],i=0;i<this._rawTextureWidth;i++){var n=i/this._rawTextureWidth;sd.GetCurrentGradient(n,this._rampGradients,(function(n,r,o){s.a.LerpToRef(n.color,r.color,o,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=et.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,g.a.TEXTURE_NEAREST_SAMPLINGMODE)}},t.prototype.getRampGradients=function(){return this._rampGradients},t.prototype.forceRefreshGradients=function(){this._syncRampGradientTexture()},t.prototype._syncRampGradientTexture=function(){this._rampGradients&&(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())},t.prototype.addRampGradient=function(e,t){this._rampGradients||(this._rampGradients=[]);var i=new od(e,t);return this._rampGradients.push(i),this._syncRampGradientTexture(),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 n=new rd(e,t,i);return this._colorGradients.push(n),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,n=this._colorGradients;i<n.length;i++){if(n[i].gradient===e){this._colorGradients.splice(t,1);break}t++}return this},t.prototype._fetchR=function(e,t,i,n,r){return r[4*(((e=.5*Math.abs(e)+.5)*i%i|0)+((t=.5*Math.abs(t)+.5)*n%n|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._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=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._engine;this._vertexData=new Float32Array(this._capacity*this._vertexBufferSize*(this._useInstancing?1:4)),this._vertexBuffer=new Qi.a(e,this._vertexData,!0,this._vertexBufferSize);var i=0,n=this._vertexBuffer.createVertexBuffer(Qi.b.PositionKind,i,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Qi.b.PositionKind]=n,i+=3;var r=this._vertexBuffer.createVertexBuffer(Qi.b.ColorKind,i,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Qi.b.ColorKind]=r,i+=4;var o=this._vertexBuffer.createVertexBuffer("angle",i,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.angle=o,i+=1;var a,s=this._vertexBuffer.createVertexBuffer("size",i,2,this._vertexBufferSize,this._useInstancing);if(this._vertexBuffers.size=s,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 Qi.a(e,h,!1,2),a=this._spriteBuffer.createVertexBuffer("offset",0,2)}else a=this._vertexBuffer.createVertexBuffer("offset",i,2,this._vertexBufferSize,this._useInstancing),i+=2;this._vertexBuffers.offset=a},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._engine.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 ld(i)]):i instanceof ld?e._subEmitters.push([i]):i instanceof Array&&e._subEmitters.push(i)}))},t.prototype.start=function(e){var t,i=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(){i.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){-1!==(null===(t=this.emitter)||void 0===t?void 0:t.getClassName().indexOf("Mesh"))&&this.emitter.computeWorldMatrix(!0);var n=this.noiseTexture;if(n&&n.onGeneratedObservable)n.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e<i.preWarmCycles;e++)i.animate(!0),n.render()}))}));else for(var r=0;r<this.preWarmCycles;r++)this.animate(!0)}this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped||(this.onStoppedObservable.notifyObservers(this),this._stopped=!0,e&&this._stopSubEmitters())},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,i,n,r){var o=e*this._vertexBufferSize;if(this._vertexData[o++]=i.position.x+this.worldOffset.x,this._vertexData[o++]=i.position.y+this.worldOffset.y,this._vertexData[o++]=i.position.z+this.worldOffset.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);else if(i._initialDirection){var s=i._initialDirection;this.isLocal&&(a.e.TransformNormalToRef(s,this._emitterWorldMatrix,a.c.Vector3[0]),s=a.c.Vector3[0]),0===s.x&&0===s.z&&(s.x=.001),this._vertexData[o++]=s.x,this._vertexData[o++]=s.y,this._vertexData[o++]=s.z}else{var c=i.direction;this.isLocal&&(a.e.TransformNormalToRef(c,this._emitterWorldMatrix,a.c.Vector3[0]),c=a.c.Vector3[0]),0===c.x&&0===c.z&&(c.x=.001),this._vertexData[o++]=c.x,this._vertexData[o++]=c.y,this._vertexData[o++]=c.z}this._useRampGradients&&i.remapData&&(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===n?n=this._epsilon:1===n&&(n=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon)),this._vertexData[o++]=n,this._vertexData[o++]=r)},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 n=this.emitter;this._emitterWorldMatrix=n.getWorldMatrix()}else{var r=this.emitter;this._emitterWorldMatrix=a.a.Translation(r.x,r.y,r.z)}this.updateFunction(this._particles);for(var o,c=function(){if(l._particles.length===l._capacity)return"break";if(t=l._createParticle(),l._particles.push(t),l.targetStopDuration&&l._lifeTimeGradients&&l._lifeTimeGradients.length>0){var e=L.a.Clamp(l._actualFrame/l.targetStopDuration);sd.GetCurrentGradient(e,l._lifeTimeGradients,(function(i,n){var r=i,o=n,a=r.getFactor(),s=o.getFactor(),c=(e-r.gradient)/(o.gradient-r.gradient);t.lifeTime=L.a.Lerp(a,s,c)}))}else t.lifeTime=L.a.RandomRange(l.minLifeTime,l.maxLifeTime);var n=L.a.RandomRange(l.minEmitPower,l.maxEmitPower);if(l.startPositionFunction?l.startPositionFunction(l._emitterWorldMatrix,t.position,t,l.isLocal):l.particleEmitterType.startPositionFunction(l._emitterWorldMatrix,t.position,t,l.isLocal),l.isLocal&&(t._localPosition?t._localPosition.copyFrom(t.position):t._localPosition=t.position.clone(),a.e.TransformCoordinatesToRef(t._localPosition,l._emitterWorldMatrix,t.position)),l.startDirectionFunction?l.startDirectionFunction(l._emitterWorldMatrix,t.direction,t,l.isLocal):l.particleEmitterType.startDirectionFunction(l._emitterWorldMatrix,t.direction,t,l.isLocal),0===n?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(n),l._sizeGradients&&0!==l._sizeGradients.length?(t._currentSizeGradient=l._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,l._sizeGradients.length>1?t._currentSize2=l._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=L.a.RandomRange(l.minSize,l.maxSize),t.scale.copyFromFloats(L.a.RandomRange(l.minScaleX,l.maxScaleX),L.a.RandomRange(l.minScaleY,l.maxScaleY)),l._startSizeGradients&&l._startSizeGradients[0]&&l.targetStopDuration){var r=l._actualFrame/l.targetStopDuration;sd.GetCurrentGradient(r,l._startSizeGradients,(function(e,n,r){e!==i._currentStartSizeGradient&&(i._currentStartSize1=i._currentStartSize2,i._currentStartSize2=n.getFactor(),i._currentStartSizeGradient=e);var o=L.a.Lerp(i._currentStartSize1,i._currentStartSize2,r);t.scale.scaleInPlace(o)}))}l._angularSpeedGradients&&0!==l._angularSpeedGradients.length?(t._currentAngularSpeedGradient=l._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,l._angularSpeedGradients.length>1?t._currentAngularSpeed2=l._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=L.a.RandomRange(l.minAngularSpeed,l.maxAngularSpeed),t.angle=L.a.RandomRange(l.minInitialRotation,l.maxInitialRotation),l._velocityGradients&&l._velocityGradients.length>0&&(t._currentVelocityGradient=l._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),l._velocityGradients.length>1?t._currentVelocity2=l._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=l._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),l._limitVelocityGradients.length>1?t._currentLimitVelocity2=l._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),l._dragGradients&&l._dragGradients.length>0&&(t._currentDragGradient=l._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),l._dragGradients.length>1?t._currentDrag2=l._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),l._colorGradients&&0!==l._colorGradients.length?(t._currentColorGradient=l._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),l._colorGradients.length>1?l._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(o=L.a.RandomRange(0,1),s.b.LerpToRef(l.color1,l.color2,o,t.color),l.colorDead.subtractToRef(t.color,l._colorDiff),l._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),l._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=l.startSpriteCellID,t._initialEndSpriteCellID=l.endSpriteCellID),t.direction.addInPlace(l._inheritedVelocityOffset),l._useRampGradients&&(t.remapData=new a.f(0,1,0,1)),l.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new a.e(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new a.e(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},l=this,u=0;u<e;u++){if("break"===c())break}},t._GetAttributeNamesOrOptions=function(e,t,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1);var n=[Qi.b.PositionKind,Qi.b.ColorKind,"angle","offset","size"];return e&&n.push("cellIndex"),t||n.push("direction"),i&&n.push("remapData"),n},t._GetEffectCreationOptions=function(e){void 0===e&&(e=!1);var t=["invView","view","projection","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","textureMask","translationPivot","eyePosition"];return e&&t.push("particlesInfos"),t},t.prototype.fillDefines=function(e,i){if(this._scene&&(this._scene.clipPlane&&e.push("#define CLIPPLANE"),this._scene.clipPlane2&&e.push("#define CLIPPLANE2"),this._scene.clipPlane3&&e.push("#define CLIPPLANE3"),this._scene.clipPlane4&&e.push("#define CLIPPLANE4"),this._scene.clipPlane5&&e.push("#define CLIPPLANE5"),this._scene.clipPlane6&&e.push("#define CLIPPLANE6")),this._isAnimationSheetEnabled&&e.push("#define ANIMATESHEET"),i===t.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this._useRampGradients&&e.push("#define RAMPGRADIENT"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case t.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case t.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case t.BILLBOARDMODE_ALL:e.push("#define BILLBOARDMODE_ALL")}this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e.push(this._imageProcessingConfigurationDefines.toString()))},t.prototype.fillUniformsAttributesAndSamplerNames=function(e,i,n){i.push.apply(i,t._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled,this._isBillboardBased&&this.billboardMode!==t.BILLBOARDMODE_STRETCHED,this._useRampGradients)),e.push.apply(e,t._GetEffectCreationOptions(this._isAnimationSheetEnabled)),n.push("diffuseSampler","rampSampler"),this._imageProcessingConfiguration&&(ji.a.PrepareUniforms(e,this._imageProcessingConfigurationDefines),ji.a.PrepareSamplers(n,this._imageProcessingConfigurationDefines))},t.prototype._getEffect=function(e){var t=this.getCustomEffect(e);if(t)return t;var i=[];this.fillDefines(i,e);var n=i.join("\n");if(this._cachedDefines!==n){this._cachedDefines=n;var r=[],o=[],a=[];this.fillUniformsAttributesAndSamplerNames(o,r,a),this._effect=this._engine.createEffect("particles",r,o,a,n)}return this._effect},t.prototype.animate=function(e){var t,i=this;if(void 0===e&&(e=!1),this._started){if(!e&&this._scene){if(!this.isReady())return;if(this._currentRenderId===this._scene.getFrameId())return;this._currentRenderId=this._scene.getFrameId()}var n;if(this._scaledUpdateSpeed=this.updateSpeed*(e?this.preWarmStepOffset:(null===(t=this._scene)||void 0===t?void 0:t.getAnimationRatio())||1),this.manualEmitCount>-1)n=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var r=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var o=this._actualFrame/this.targetStopDuration;sd.GetCurrentGradient(o,this._emitRateGradients,(function(e,t,n){e!==i._currentEmitRateGradient&&(i._currentEmitRate1=i._currentEmitRate2,i._currentEmitRate2=t.getFactor(),i._currentEmitRateGradient=e),r=L.a.Lerp(i._currentEmitRate1,i._currentEmitRate2,n)}))}n=r*this._scaledUpdateSpeed>>0,this._newPartsExcess+=r*this._scaledUpdateSpeed-n}if(this._newPartsExcess>1&&(n+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?n=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(n),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene&&this._scene._toBeDisposed.push(this))),!e){for(var a=0,s=0;s<this._particles.length;s++){var c=this._particles[s];this._appendParticleVertices(a,c),a+=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(){for(var e in this._createIndexBuffer(),this._vertexBuffer&&this._vertexBuffer._rebuild(),this._vertexBuffers)this._vertexBuffers[e]._rebuild()},t.prototype.isReady=function(){if(!this.emitter||this._imageProcessingConfiguration&&!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,n,r=this._getEffect(e),o=this._engine;o.enableEffect(r);var s=null!==(i=this.defaultViewMatrix)&&void 0!==i?i:this._scene.getViewMatrix();if(r.setTexture("diffuseSampler",this.particleTexture),r.setMatrix("view",s),r.setMatrix("projection",null!==(n=this.defaultProjectionMatrix)&&void 0!==n?n:this._scene.getProjectionMatrix()),this._isAnimationSheetEnabled&&this.particleTexture){var c=this.particleTexture.getBaseSize();r.setFloat3("particlesInfos",this.spriteCellWidth/c.width,this.spriteCellHeight/c.height,this.spriteCellWidth/c.width)}if(r.setVector2("translationPivot",this.translationPivot),r.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._isBillboardBased&&this._scene){var l=this._scene.activeCamera;r.setVector3("eyePosition",l.globalPosition)}this._rampGradientsTexture&&(this._rampGradients&&this._rampGradients.length||(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),r.setTexture("rampSampler",this._rampGradientsTexture));var u=r.defines;switch(this._scene&&(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6)&&Mc.a.BindClipPlane(r,this._scene),u.indexOf("#define BILLBOARDMODE_ALL")>=0&&(s.invertToRef(a.c.Matrix[0]),r.setMatrix("invView",a.c.Matrix[0])),void 0!==this._vertexArrayObject?(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,r)),this._engine.bindVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):o.bindBuffers(this._vertexBuffers,this._indexBuffer,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(r),e){case t.BLENDMODE_ADD:o.setAlphaMode(g.a.ALPHA_ADD);break;case t.BLENDMODE_ONEONE:o.setAlphaMode(g.a.ALPHA_ONEONE);break;case t.BLENDMODE_STANDARD:o.setAlphaMode(g.a.ALPHA_COMBINE);break;case t.BLENDMODE_MULTIPLY:o.setAlphaMode(g.a.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(r),this._useInstancing?o.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,this._particles.length):o.drawElementsType(g.a.MATERIAL_TriangleFillMode,0,6*this._particles.length),this._particles.length},t.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var e=this._engine;e.setState&&(e.setState(!1),this.forceDepthWrite&&e.setDepthWrite(!0));var i=0;return i=this.blendMode===t.BLENDMODE_MULTIPLYADD?this._render(t.BLENDMODE_MULTIPLY)+this._render(t.BLENDMODE_ADD):this._render(this.blendMode),this._engine.unbindInstanceAttributes(),this._engine.setAlphaMode(g.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._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=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,n=this._subEmitters[t];i<n.length;i++){n[i].dispose()}this._subEmitters=[],this.subEmitters=[]}(this._disposeEmitterOnDispose&&this.emitter&&this.emitter.dispose&&this.emitter.dispose(!0),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.clear(),this._scene)&&((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.onStoppedObservable.clear(),this.reset()},t.prototype.clone=function(e,i){var n=Object(h.a)({},this._customEffect),r=null,o=this._engine;if(o.createEffectForParticles&&null!=this.customShader){var a=(r=this.customShader).shaderOptions.defines.length>0?r.shaderOptions.defines.join("\n"):"";n[0]=o.createEffectForParticles(r.shaderPath.fragmentElement,r.shaderOptions.uniforms,r.shaderOptions.samplers,a)}var s=this.serialize(),c=t.Parse(s,this._scene||this._engine,"");return c.name=e,c.customShader=r,c._customEffect=n,void 0===i&&(i=this.emitter),this.noiseTexture&&(c.noiseTexture=this.noiseTexture.clone()),c.emitter=i,this.preventAutoStart||c.start(),c},t.prototype.serialize=function(e){void 0===e&&(e=!1);var i={};if(t._Serialize(i,this,e),i.textureMask=this.textureMask.asArray(),i.customShader=this.customShader,i.preventAutoStart=this.preventAutoStart,this.subEmitters){i.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var n=0,r=this._subEmitters;n<r.length;n++){for(var o=[],a=0,s=r[n];a<s.length;a++){var c=s[a];o.push(c.serialize())}i.subEmitters.push(o)}}return i},t._Serialize=function(e,t,i){if(e.name=t.name,e.id=t.id,e.capacity=t.getCapacity(),t.emitter.position){var n=t.emitter;e.emitterId=n.id}else{var r=t.emitter;e.emitter=r.asArray()}t.particleEmitterType&&(e.particleEmitterType=t.particleEmitterType.serialize()),t.particleTexture&&(i?e.texture=t.particleTexture.serialize():(e.textureName=t.particleTexture.name,e.invertY=!!t.particleTexture._invertY)),e.isLocal=t.isLocal,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 o=t.getColorGradients();if(o){e.colorGradients=[];for(var a=0,s=o;a<s.length;a++){var c=s[a],l={gradient:c.gradient,color1:c.color1.asArray()};c.color2?l.color2=c.color2.asArray():l.color2=c.color1.asArray(),e.colorGradients.push(l)}}var u=t.getRampGradients();if(u){e.rampGradients=[];for(var h=0,d=u;h<d.length;h++){var f=d[h];l={gradient:f.gradient,color:f.color.asArray()};e.rampGradients.push(l)}e.useRampGradients=t.useRampGradients}var p=t.getColorRemapGradients();if(p){e.colorRemapGradients=[];for(var _=0,m=p;_<m.length;_++){var g=m[_];l={gradient:g.gradient,factor1:g.factor1};void 0!==g.factor2?l.factor2=g.factor2:l.factor2=g.factor1,e.colorRemapGradients.push(l)}}var v=t.getAlphaRemapGradients();if(v){e.alphaRemapGradients=[];for(var b=0,y=v;b<y.length;b++){var T=y[b];l={gradient:T.gradient,factor1:T.factor1};void 0!==T.factor2?l.factor2=T.factor2:l.factor2=T.factor1,e.alphaRemapGradients.push(l)}}var E=t.getSizeGradients();if(E){e.sizeGradients=[];for(var S=0,A=E;S<A.length;S++){var P=A[S];l={gradient:P.gradient,factor1:P.factor1};void 0!==P.factor2?l.factor2=P.factor2:l.factor2=P.factor1,e.sizeGradients.push(l)}}var C=t.getAngularSpeedGradients();if(C){e.angularSpeedGradients=[];for(var R=0,x=C;R<x.length;R++){var O=x[R];l={gradient:O.gradient,factor1:O.factor1};void 0!==O.factor2?l.factor2=O.factor2:l.factor2=O.factor1,e.angularSpeedGradients.push(l)}}var M=t.getVelocityGradients();if(M){e.velocityGradients=[];for(var I=0,D=M;I<D.length;I++){var N=D[I];l={gradient:N.gradient,factor1:N.factor1};void 0!==N.factor2?l.factor2=N.factor2:l.factor2=N.factor1,e.velocityGradients.push(l)}}var L=t.getDragGradients();if(L){e.dragGradients=[];for(var F=0,B=L;F<B.length;F++){var U=B[F];l={gradient:U.gradient,factor1:U.factor1};void 0!==U.factor2?l.factor2=U.factor2:l.factor2=U.factor1,e.dragGradients.push(l)}}var V=t.getEmitRateGradients();if(V){e.emitRateGradients=[];for(var k=0,z=V;k<z.length;k++){var G=z[k];l={gradient:G.gradient,factor1:G.factor1};void 0!==G.factor2?l.factor2=G.factor2:l.factor2=G.factor1,e.emitRateGradients.push(l)}}var j=t.getStartSizeGradients();if(j){e.startSizeGradients=[];for(var W=0,H=j;W<H.length;W++){var X=H[W];l={gradient:X.gradient,factor1:X.factor1};void 0!==X.factor2?l.factor2=X.factor2:l.factor2=X.factor1,e.startSizeGradients.push(l)}}var Y=t.getLifeTimeGradients();if(Y){e.lifeTimeGradients=[];for(var K=0,Q=Y;K<Q.length;K++){var q=Q[K];l={gradient:q.gradient,factor1:q.factor1};void 0!==q.factor2?l.factor2=q.factor2:l.factor2=q.factor1,e.lifeTimeGradients.push(l)}}var Z=t.getLimitVelocityGradients();if(Z){e.limitVelocityGradients=[];for(var J=0,$=Z;J<$.length;J++){var ee=$[J];l={gradient:ee.gradient,factor1:ee.factor1};void 0!==ee.factor2?l.factor2=ee.factor2:l.factor2=ee.factor1,e.limitVelocityGradients.push(l)}e.limitVelocityDamping=t.limitVelocityDamping}t.noiseTexture&&(e.noiseTexture=t.noiseTexture.serialize())},t._Parse=function(e,t,i,n){var r;r=i instanceof qe.a?null:i;var o,l=c.a.GetClass("BABYLON.Texture");if(l&&r&&(e.texture?t.particleTexture=l.Parse(e.texture,r,n):e.textureName&&(t.particleTexture=new l(n+e.textureName,r,!1,void 0===e.invertY||e.invertY),t.particleTexture.name=e.textureName)),e.emitterId||0===e.emitterId||void 0!==e.emitter?e.emitterId&&r?t.emitter=r.getLastMeshByID(e.emitterId):t.emitter=a.e.FromArray(e.emitter):t.emitter=a.e.Zero(),t.isLocal=!!e.isLocal,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 u=0;u<e.animations.length;u++){var h=e.animations[u],d=c.a.GetClass("BABYLON.Animation");d&&t.animations.push(d.Parse(h))}t.beginAnimationOnStart=e.beginAnimationOnStart,t.beginAnimationFrom=e.beginAnimationFrom,t.beginAnimationTo=e.beginAnimationTo,t.beginAnimationLoop=e.beginAnimationLoop}if(e.autoAnimate&&r&&r.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=a.e.FromArray(e.gravity),e.noiseStrength&&(t.noiseStrength=a.e.FromArray(e.noiseStrength)),t.color1=s.b.FromArray(e.color1),t.color2=s.b.FromArray(e.color2),t.colorDead=s.b.FromArray(e.colorDead),t.updateSpeed=e.updateSpeed,t.targetStopDuration=e.targetStopDuration,t.blendMode=e.blendMode,e.colorGradients)for(var f=0,p=e.colorGradients;f<p.length;f++){var _=p[f];t.addColorGradient(_.gradient,s.b.FromArray(_.color1),_.color2?s.b.FromArray(_.color2):void 0)}if(e.rampGradients){for(var m=0,g=e.rampGradients;m<g.length;m++){var v=g[m];t.addRampGradient(v.gradient,s.a.FromArray(v.color))}t.useRampGradients=e.useRampGradients}if(e.colorRemapGradients)for(var b=0,y=e.colorRemapGradients;b<y.length;b++){var T=y[b];t.addColorRemapGradient(T.gradient,void 0!==T.factor1?T.factor1:T.factor,T.factor2)}if(e.alphaRemapGradients)for(var E=0,S=e.alphaRemapGradients;E<S.length;E++){var A=S[E];t.addAlphaRemapGradient(A.gradient,void 0!==A.factor1?A.factor1:A.factor,A.factor2)}if(e.sizeGradients)for(var P=0,C=e.sizeGradients;P<C.length;P++){var R=C[P];t.addSizeGradient(R.gradient,void 0!==R.factor1?R.factor1:R.factor,R.factor2)}if(e.angularSpeedGradients)for(var x=0,O=e.angularSpeedGradients;x<O.length;x++){var M=O[x];t.addAngularSpeedGradient(M.gradient,void 0!==M.factor1?M.factor1:M.factor,M.factor2)}if(e.velocityGradients)for(var I=0,D=e.velocityGradients;I<D.length;I++){var N=D[I];t.addVelocityGradient(N.gradient,void 0!==N.factor1?N.factor1:N.factor,N.factor2)}if(e.dragGradients)for(var L=0,w=e.dragGradients;L<w.length;L++){var F=w[L];t.addDragGradient(F.gradient,void 0!==F.factor1?F.factor1:F.factor,F.factor2)}if(e.emitRateGradients)for(var B=0,U=e.emitRateGradients;B<U.length;B++){var V=U[B];t.addEmitRateGradient(V.gradient,void 0!==V.factor1?V.factor1:V.factor,V.factor2)}if(e.startSizeGradients)for(var k=0,z=e.startSizeGradients;k<z.length;k++){var G=z[k];t.addStartSizeGradient(G.gradient,void 0!==G.factor1?G.factor1:G.factor,G.factor2)}if(e.lifeTimeGradients)for(var j=0,W=e.lifeTimeGradients;j<W.length;j++){var H=W[j];t.addLifeTimeGradient(H.gradient,void 0!==H.factor1?H.factor1:H.factor,H.factor2)}if(e.limitVelocityGradients){for(var X=0,Y=e.limitVelocityGradients;X<Y.length;X++){var K=Y[X];t.addLimitVelocityGradient(K.gradient,void 0!==K.factor1?K.factor1:K.factor,K.factor2)}t.limitVelocityDamping=e.limitVelocityDamping}if(e.noiseTexture&&r){var Q=c.a.GetClass("BABYLON.ProceduralTexture");t.noiseTexture=Q.Parse(e.noiseTexture,r,n)}if(e.particleEmitterType){switch(e.particleEmitterType.type){case"SphereParticleEmitter":o=new Vl;break;case"SphereDirectedParticleEmitter":o=new kl;break;case"ConeEmitter":case"ConeParticleEmitter":o=new Ll;break;case"CylinderParticleEmitter":o=new wl;break;case"CylinderDirectedParticleEmitter":o=new Fl;break;case"HemisphericParticleEmitter":o=new Bl;break;case"PointParticleEmitter":o=new Ul;break;case"MeshParticleEmitter":o=new Gl;break;case"BoxEmitter":case"BoxParticleEmitter":default:o=new Nl}o.parse(e.particleEmitterType,r)}else(o=new Nl).parse(e,r);t.particleEmitterType=o,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,n,r){void 0===r&&(r=!1);var o,a=e.name,c=null,l=null;if(o=i instanceof qe.a?i:i.getEngine(),e.customShader&&o.createEffectForParticles){var u=(l=e.customShader).shaderOptions.defines.length>0?l.shaderOptions.defines.join("\n"):"";c=o.createEffectForParticles(l.shaderPath.fragmentElement,l.shaderOptions.uniforms,l.shaderOptions.samplers,u)}var h=new t(a,e.capacity,i,c,e.isAnimationSheetEnabled);if(h.customShader=l,e.id&&(h.id=e.id),e.subEmitters){h.subEmitters=[];for(var d=0,f=e.subEmitters;d<f.length;d++){for(var p=[],_=0,m=f[d];_<m.length;_++){var g=m[_];p.push(ld.Parse(g,i,n))}h.subEmitters.push(p)}}return t._Parse(e,h,i,n),e.textureMask&&(h.textureMask=s.b.FromArray(e.textureMask)),e.preventAutoStart&&(h.preventAutoStart=e.preventAutoStart),r||h.preventAutoStart||h.start(),h},t.BILLBOARDMODE_Y=g.a.PARTICLES_BILLBOARDMODE_Y,t.BILLBOARDMODE_ALL=g.a.PARTICLES_BILLBOARDMODE_ALL,t.BILLBOARDMODE_STRETCHED=g.a.PARTICLES_BILLBOARDMODE_STRETCHED,t}(jl);ld._ParseParticleSystem=dd.Parse;ai.a.ShadersStore.gpuUpdateParticlesPixelShader="#version 300 es\nvoid main() {\ndiscard;\n}\n";var fd="#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\n#ifndef LOCAL\nuniform mat4 emitterWM;\n#endif\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;\n#ifdef CUSTOMEMITTER\nin vec3 initialPosition;\n#endif\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;\n#ifdef CUSTOMEMITTER\nout vec3 outInitialPosition;\n#endif\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 newPosition;\nvec3 newDirection;\n\nvec4 randoms=getRandomVec4(seed.x);\n\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=newAge-life;\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);\nnewPosition=vec3(0,0,0);\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nnewPosition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\nnewDirection=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);\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\nnewDirection=newPosition+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);\nnewPosition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\n\nnewDirection=newPosition+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);\nnewPosition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\nnewDirection=direction1+(direction2-direction1)*randoms3;\n#else\n\nangle=angle+((randoms3.x-0.5)*PI);\nnewDirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));\nnewDirection=normalize(newDirection);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.0001;\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;\nnewPosition=vec3(randX,randY,randZ);\n\nif (abs(cos(coneAngle)) == 1.0) {\nnewDirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\nnewDirection=normalize(newPosition+directionRandomizer*randoms3);\n}\n#elif defined(CUSTOMEMITTER)\nnewPosition=initialPosition;\noutInitialPosition=initialPosition;\n#else\n\nnewPosition=vec3(0.,0.,0.);\n\nnewDirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\n#ifdef LOCAL\noutPosition=newPosition;\n#else\noutPosition=(emitterWM*vec4(newPosition,1.)).xyz;\n#endif\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#ifndef BILLBOARD\noutInitialDirection=direction;\n#endif\n#else\n#ifdef LOCAL\nvec3 initial=newDirection;\n#else\nvec3 initial=(emitterWM*vec4(newDirection,0.)).xyz;\n#endif\noutDirection=initial*power;\n#ifndef BILLBOARD\noutInitialDirection=initial;\n#endif\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\n#if defined(CUSTOMEMITTER)\noutPosition=position+(direction-position)*ageGradient;\noutInitialPosition=initialPosition;\n#else\noutPosition=position+direction*directionScale;\n#endif\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\n#ifdef CUSTOMEMITTER\noutDirection=direction;\n#else\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\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#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#else\nfloat cellStartOffset=0.;\n#endif\nfloat ratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";ai.a.ShadersStore.gpuUpdateParticlesVertexShader=fd;var pd="#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\n#ifdef CLIPPLANE5\nin float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nin float fClipDistance6;\n#endif";ai.a.IncludesShadersStore.clipPlaneFragmentDeclaration2=pd;var _d="#version 300 es\nuniform sampler2D diffuseSampler;\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(diffuseSampler,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";ai.a.ShadersStore.gpuRenderParticlesPixelShader=_d;var md="#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\n#ifdef CLIPPLANE5\nuniform vec4 vClipPlane5;\nout float fClipDistance5;\n#endif\n#ifdef CLIPPLANE6\nuniform vec4 vClipPlane6;\nout float fClipDistance6;\n#endif";ai.a.IncludesShadersStore.clipPlaneVertexDeclaration2=md;var gd="#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\nuniform vec3 worldOffset;\n#ifdef LOCAL\nuniform mat4 emitterWM;\n#endif\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;\nout vec3 vPositionW;\n#if defined(BILLBOARD) && !defined(BILLBOARDY) && !defined(BILLBOARDSTRETCHED)\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;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\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;\n#ifdef LOCAL\nreturn ((emitterWM*vec4(position,1.0)).xyz+worldOffset)+alignedCorner;\n#else\nreturn (position+worldOffset)+alignedCorner;\n#endif\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+worldOffset)-eyePosition;\nyaxis.y=0.;\nvPositionW=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(vPositionW,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+worldOffset)-eyePosition;\nvPositionW=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(vPositionW,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\n#ifdef LOCAL\nvec4 viewPosition=view*vec4(((emitterWM*vec4(position,1.0)).xyz+worldOffset),1.0)+rotatedCorner;\n#else\nvec4 viewPosition=view*vec4((position+worldOffset),1.0)+rotatedCorner;\n#endif\nvPositionW=(invView*viewPosition).xyz;\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);\nvPositionW=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(vPositionW,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=vec4(vPositionW,1.0);\n#endif\n#include<clipPlaneVertex>\n}";ai.a.ShadersStore.gpuRenderParticlesVertexShader=gd;var vd=function(e){function t(t,i,n,r,s){void 0===r&&(r=!1),void 0===s&&(s=null);var c=e.call(this,t)||this;c.layerMask=268435455,c._accumulatedCount=0,c._targetIndex=0,c._currentRenderId=-1,c._started=!1,c._stopped=!1,c._timeDelta=0,c._actualFrame=0,c._rawTextureWidth=256,c.onDisposeObservable=new o.c,c.onStoppedObservable=new o.c,c.forceDepthWrite=!1,c._preWarmDone=!1,c.isLocal=!1,c._onBeforeDrawParticlesObservable=null,n&&"Scene"!==n.getClassName()?(c._engine=n,c.defaultProjectionMatrix=a.a.PerspectiveFovLH(.8,1,.1,100)):(c._scene=n||x.a.LastCreatedScene,c._engine=c._scene.getEngine(),c.uniqueId=c._scene.getUniqueId(),c._scene.particleSystems.push(c)),c._customEffect={0:s},c._attachImageProcessingConfiguration(null),i.randomTextureSize||delete i.randomTextureSize;var l=Object(h.a)({capacity:5e4,randomTextureSize:c._engine.getCaps().maxTextureSize},i),u=i;isFinite(u)&&(l.capacity=u),c._capacity=l.capacity,c._activeCount=l.capacity,c._currentActiveCount=0,c._isAnimationSheetEnabled=r,c._updateEffectOptions={attributes:["position","initialPosition","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:[]},c.particleEmitterType=new Nl;for(var d=Math.min(c._engine.getCaps().maxTextureSize,l.randomTextureSize),f=[],p=0;p<d;++p)f.push(Math.random()),f.push(Math.random()),f.push(Math.random()),f.push(Math.random());c._randomTexture=new et(new Float32Array(f),d,1,g.a.TEXTUREFORMAT_RGBA,n,!1,!1,g.a.TEXTURE_NEAREST_SAMPLINGMODE,g.a.TEXTURETYPE_FLOAT),c._randomTexture.wrapU=g.a.TEXTURE_WRAP_ADDRESSMODE,c._randomTexture.wrapV=g.a.TEXTURE_WRAP_ADDRESSMODE,f=[];for(p=0;p<d;++p)f.push(Math.random()),f.push(Math.random()),f.push(Math.random()),f.push(Math.random());return c._randomTexture2=new et(new Float32Array(f),d,1,g.a.TEXTUREFORMAT_RGBA,n,!1,!1,g.a.TEXTURE_NEAREST_SAMPLINGMODE,g.a.TEXTURETYPE_FLOAT),c._randomTexture2.wrapU=g.a.TEXTURE_WRAP_ADDRESSMODE,c._randomTexture2.wrapV=g.a.TEXTURE_WRAP_ADDRESSMODE,c._randomTextureSize=d,c}return Object(h.d)(t,e),Object.defineProperty(t,"IsSupported",{get:function(){return!!x.a.LastCreatedEngine&&x.a.LastCreatedEngine.webGLVersion>1},enumerable:!1,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:!1,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&(!this._imageProcessingConfiguration||this._imageProcessingConfiguration.isReady())&&this._getEffect().isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.isStopped=function(){return this._stopped},t.prototype.isStopping=function(){return!1},t.prototype.getActiveCount=function(){return this._currentActiveCount},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._scene&&this._scene.beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped||(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.getCustomEffect=function(e){var t;return void 0===e&&(e=0),null!==(t=this._customEffect[e])&&void 0!==t?t:this._customEffect[0]},t.prototype.setCustomEffect=function(e,t){void 0===t&&(t=0),this._customEffect[t]=e},Object.defineProperty(t.prototype,"onBeforeDrawParticlesObservable",{get:function(){return this._onBeforeDrawParticlesObservable||(this._onBeforeDrawParticlesObservable=new o.c),this._onBeforeDrawParticlesObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"vertexShaderName",{get:function(){return"gpuRenderParticles"},enumerable:!1,configurable:!0}),t.prototype._removeGradientAndTexture=function(t,i,n){return e.prototype._removeGradientAndTexture.call(this,t,i,n),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var n=new rd(e,t);return this._colorGradients.push(n),this._refreshColorGradient(!0),this._releaseBuffers(),this},t.prototype._refreshColorGradient=function(e){void 0===e&&(e=!1),this._colorGradients&&(e&&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))},t.prototype.forceRefreshGradients=function(){this._refreshColorGradient(),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture"),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture"),this._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture"),this._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture"),this._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture"),this.reset()},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 n=new ad(t,i);e.push(n),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._refreshFactorGradient(this._sizeGradients,"_sizeGradientsTexture",!0),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype._refreshFactorGradient=function(e,t,i){if(void 0===i&&(i=!1),e){i&&e.sort((function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}));this[t]&&(this[t].dispose(),this[t]=null)}},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._refreshFactorGradient(this._angularSpeedGradients,"_angularSpeedGradientsTexture",!0),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._refreshFactorGradient(this._velocityGradients,"_velocityGradientsTexture",!0),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._refreshFactorGradient(this._limitVelocityGradients,"_limitVelocityGradientsTexture",!0),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._refreshFactorGradient(this._dragGradients,"_dragGradientsTexture",!0),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:!1,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);var i=3;this.particleEmitterType instanceof zl&&(t.initialPosition=e.createVertexBuffer("initialPosition",i,3),i+=3),t.age=e.createVertexBuffer("age",i,1),i+=1,t.life=e.createVertexBuffer("life",i,1),i+=1,t.seed=e.createVertexBuffer("seed",i,4),i+=4,t.size=e.createVertexBuffer("size",i,3),i+=3,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 n=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),n},t.prototype._createRenderVAO=function(e,t){var i={};i.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var n=3;this.particleEmitterType instanceof zl&&(n+=3),i.age=e.createVertexBuffer("age",n,1,this._attributesStrideSize,!0),n+=1,i.life=e.createVertexBuffer("life",n,1,this._attributesStrideSize,!0),n+=5,i.size=e.createVertexBuffer("size",n,3,this._attributesStrideSize,!0),n+=3,this._colorGradientsTexture||(i.color=e.createVertexBuffer("color",n,4,this._attributesStrideSize,!0),n+=4),this.billboardMode===dd.BILLBOARDMODE_STRETCHED&&(i.direction=e.createVertexBuffer("direction",n,3,this._attributesStrideSize,!0)),n+=3,this._isBillboardBased||(i.initialDirection=e.createVertexBuffer("initialDirection",n,3,this._attributesStrideSize,!0),n+=3),i.angle=e.createVertexBuffer("angle",n,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?n++:n+=2,this._isAnimationSheetEnabled&&(i.cellIndex=e.createVertexBuffer("cellIndex",n,1,this._attributesStrideSize,!0),n+=1,this.spriteRandomStartCell&&(i.cellStartOffset=e.createVertexBuffer("cellStartOffset",n,1,this._attributesStrideSize,!0),n+=1)),this.noiseTexture&&(i.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",n,3,this._attributesStrideSize,!0),n+=3,i.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",n,3,this._attributesStrideSize,!0),n+=3),i.offset=t.createVertexBuffer("offset",0,2),i.uv=t.createVertexBuffer("uv",2,2);var r=this._engine.recordVertexArrayObject(i,null,this._getEffect());return this._engine.bindArrayBuffer(null),r},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._engine,i=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.particleEmitterType instanceof zl&&(this._attributesStrideSize+=3),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 n=this.particleEmitterType instanceof zl,r=a.c.Vector3[0],o=0;o<this._capacity;o++)i.push(0),i.push(0),i.push(0),n&&(this.particleEmitterType.particlePositionGenerator(o,null,r),i.push(r.x),i.push(r.y),i.push(r.z)),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)),n?(this.particleEmitterType.particleDestinationGenerator(o,null,r),i.push(r.x),i.push(r.y),i.push(r.z)):(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 s=new Float32Array([.5,.5,1,1,-.5,.5,0,1,-.5,-.5,0,0,.5,-.5,1,0]);this._buffer0=new Qi.a(t,i,!1,this._attributesStrideSize),this._buffer1=new Qi.a(t,i,!1,this._attributesStrideSize),this._spriteBuffer=new Qi.a(t,s,!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.isLocal&&(e+="\n#define LOCAL"),this._updateEffect&&this._updateEffectOptions.defines===e||(this._updateEffectOptions.transformFeedbackVaryings=["outPosition"],this.particleEmitterType instanceof zl&&this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"),this._updateEffectOptions.transformFeedbackVaryings.push("outAge"),this._updateEffectOptions.transformFeedbackVaryings.push("outLife"),this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"),this._updateEffectOptions.transformFeedbackVaryings.push("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 ai.a("gpuUpdateParticles",this._updateEffectOptions,this._engine))},t.prototype._getEffect=function(){var e;return null!==(e=this.getCustomEffect())&&void 0!==e?e:this._renderEffect},t.prototype.fillDefines=function(e,t){if(void 0===t&&(t=0),this._scene&&(this._scene.clipPlane&&e.push("#define CLIPPLANE"),this._scene.clipPlane2&&e.push("#define CLIPPLANE2"),this._scene.clipPlane3&&e.push("#define CLIPPLANE3"),this._scene.clipPlane4&&e.push("#define CLIPPLANE4"),this._scene.clipPlane5&&e.push("#define CLIPPLANE5"),this._scene.clipPlane6&&e.push("#define CLIPPLANE6")),this.blendMode===dd.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this.isLocal&&e.push("#define LOCAL"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case dd.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case dd.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case dd.BILLBOARDMODE_ALL:e.push("#define BILLBOARDMODE_ALL")}this._colorGradientsTexture&&e.push("#define COLORGRADIENTS"),this.isAnimationSheetEnabled&&e.push("#define ANIMATESHEET"),this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e.push(""+this._imageProcessingConfigurationDefines.toString()))},t.prototype.fillUniformsAttributesAndSamplerNames=function(e,t,i){t.push("position","age","life","size","color","offset","uv","direction","initialDirection","angle","cellIndex"),e.push("emitterWM","worldOffset","view","projection","colorDead","invView","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","sheetInfos","translationPivot","eyePosition"),i.push("diffuseSampler","colorGradientSampler"),this._imageProcessingConfiguration&&(ji.a.PrepareUniforms(e,this._imageProcessingConfigurationDefines),ji.a.PrepareSamplers(i,this._imageProcessingConfigurationDefines))},t.prototype._recreateRenderEffect=function(){var e=this.getCustomEffect();if(e)return e;var t=[];this.fillDefines(t);var i=t.join("\n");if(this._renderEffect&&this._renderEffect.defines===i)return this._renderEffect;var n=[],r=[],o=[];return this.fillUniformsAttributesAndSamplerNames(r,n,o),this._renderEffect=new ai.a("gpuRenderParticles",n,r,o,this._engine,i),this._renderEffect},t.prototype.animate=function(e){var t;void 0===e&&(e=!1),this._timeDelta=this.updateSpeed*(e?this.preWarmStepOffset:(null===(t=this._scene)||void 0===t?void 0:t.getAnimationRatio())||1),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 n=new Float32Array(this._rawTextureWidth),r=0;r<this._rawTextureWidth;r++){var o=r/this._rawTextureWidth;sd.GetCurrentGradient(o,e,(function(e,t,i){n[r]=L.a.Lerp(e.factor1,t.factor1,i)}))}this[t]=et.CreateRTexture(n,this._rawTextureWidth,1,this._scene||this._engine,!1,!1,g.a.TEXTURE_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=s.c.Color4[0],i=0;i<this._rawTextureWidth;i++){var n=i/this._rawTextureWidth;sd.GetCurrentGradient(n,this._colorGradients,(function(n,r,o){s.b.LerpToRef(n.color1,r.color1,o,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=et.CreateRGBATexture(e,this._rawTextureWidth,1,this._scene,!1,!1,g.a.TEXTURE_NEAREST_SAMPLINGMODE)}},t.prototype.render=function(e){var t,i;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&&this._scene){if(!this._preWarmDone&&this.preWarmCycles){for(var n=0;n<this.preWarmCycles;n++)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 r=0|this._accumulatedCount;this._accumulatedCount-=r,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+r)}if(!this._currentActiveCount)return 0;this._engine.enableEffect(this._updateEffect);var o,s=this._engine;if(!s.setState)throw new Error("GPU particles cannot work with a full Engine. ThinEngine is not supported");if(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){o=this.emitter.getWorldMatrix()}else{var c=this.emitter;o=a.a.Translation(c.x,c.y,c.z)}if(this.isLocal||this._updateEffect.setMatrix("emitterWM",o),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),s.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),s.setRasterizerState(!1),s.beginTransformFeedback(!0),s.drawArraysType(g.a.MATERIAL_PointListDrawMode,0,this._currentActiveCount),s.endTransformFeedback(),s.setRasterizerState(!0),s.bindTransformFeedbackBuffer(null),!e){var l=this._getEffect();this._engine.enableEffect(l);var u=(null===(t=this._scene)||void 0===t?void 0:t.getViewMatrix())||a.a.IdentityReadOnly;if(l.setMatrix("view",u),l.setMatrix("projection",null!==(i=this.defaultProjectionMatrix)&&void 0!==i?i:this._scene.getProjectionMatrix()),l.setTexture("diffuseSampler",this.particleTexture),l.setVector2("translationPivot",this.translationPivot),l.setVector3("worldOffset",this.worldOffset),this.isLocal&&l.setMatrix("emitterWM",o),this._colorGradientsTexture?l.setTexture("colorGradientSampler",this._colorGradientsTexture):l.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var h=this.particleTexture.getBaseSize();l.setFloat3("sheetInfos",this.spriteCellWidth/h.width,this.spriteCellHeight/h.height,h.width/this.spriteCellWidth)}if(this._isBillboardBased&&this._scene){var d=this._scene.activeCamera;l.setVector3("eyePosition",d.globalPosition)}var f=l.defines;if(this._scene&&(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4||this._scene.clipPlane5||this._scene.clipPlane6)&&ro.a.BindClipPlane(l,this._scene),f.indexOf("#define BILLBOARDMODE_ALL")>=0){var p=u.clone();p.invert(),l.setMatrix("invView",p)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(l),this.blendMode){case dd.BLENDMODE_ADD:this._engine.setAlphaMode(g.a.ALPHA_ADD);break;case dd.BLENDMODE_ONEONE:this._engine.setAlphaMode(g.a.ALPHA_ONEONE);break;case dd.BLENDMODE_STANDARD:this._engine.setAlphaMode(g.a.ALPHA_COMBINE);break;case dd.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(g.a.ALPHA_MULTIPLY)}this.forceDepthWrite&&s.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(l),this._engine.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(g.a.ALPHA_DISABLE)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var _=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=_,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){if(void 0===e&&(e=!0),this._scene){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.onStoppedObservable.clear(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,i){var n=this.serialize(),r=t.Parse(n,this._scene||this._engine,""),o=Object(h.a)({},this._customEffect);return r.name=e,r._customEffect=o,void 0===i&&(i=this.emitter),r.emitter=i,r.noiseTexture=this.noiseTexture,r},t.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};return dd._Serialize(t,this,e),t.activeParticleCount=this.activeParticleCount,t.randomTextureSize=this._randomTextureSize,t},t.Parse=function(e,i,n,r){void 0===r&&(r=!1);var o=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},i);return e.activeParticleCount&&(o.activeParticleCount=e.activeParticleCount),dd._Parse(e,o,i,n),e.preventAutoStart&&(o.preventAutoStart=e.preventAutoStart),r||o.preventAutoStart||o.start(),o},t}(jl),bd=function(){function e(){this.systems=new Array}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!1,configurable:!0}),e.prototype.setEmitterAsSphere=function(e,t,i){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:e,renderingGroupId:t};var n=xr.a.CreateSphere("emitterSphere",{diameter:e.diameter,segments:e.segments},i);n.renderingGroupId=t;var r=new Wi.a("emitterSphereMaterial",i);r.emissiveColor=e.color,n.material=r;for(var o=0,a=this.systems;o<a.length;o++){a[o].emitter=n}this._emitterNode=n},e.prototype.start=function(e){for(var t=0,i=this.systems;t<i.length;t++){var n=i[t];e&&(n.emitter=e),n.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(e){void 0===e&&(e=!1);for(var t={systems:[]},i=0,n=this.systems;i<n.length;i++){var r=n[i];t.systems.push(r.serialize(e))}return this._emitterNode&&(t.emitter=this._emitterCreationOptions),t},e.Parse=function(t,i,n){void 0===n&&(n=!1);var r=new e,o=this.BaseAssetsUrl+"/textures/";i=i||x.a.LastCreatedScene;for(var a=0,c=t.systems;a<c.length;a++){var l=c[a];r.systems.push(n?vd.Parse(l,i,o,!0):dd.Parse(l,i,o,!0))}if(t.emitter){var u=t.emitter.options;switch(t.emitter.kind){case"Sphere":r.setEmitterAsSphere({diameter:u.diameter,segments:u.segments,color:s.a.FromArray(u.color)},t.emitter.renderingGroupId,i)}}return r},e.BaseAssetsUrl="https://assets.babylonjs.com/particles",e}(),yd=function(){function e(){}return e.CreateDefault=function(e,t,i,n){var r;return void 0===t&&(t=500),void 0===n&&(n=!1),(r=n?new vd("default system",{capacity:t},i):new dd("default system",t,i)).emitter=e,r.particleTexture=new Ke.a("https://www.babylonjs.com/assets/Flare.png",r.getScene()),r.createConeEmitter(.1,Math.PI/4),r.color1=new s.b(1,1,1,1),r.color2=new s.b(1,1,1,1),r.colorDead=new s.b(1,1,1,0),r.minSize=.1,r.maxSize=.1,r.minEmitPower=2,r.maxEmitPower=2,r.updateSpeed=1/60,r.emitRate=30,r},e.CreateAsync=function(t,i,n){void 0===n&&(n=!1),i||(i=x.a.LastCreatedScene);var r={};return i._addPendingData(r),new Promise((function(o,a){if(n&&!vd.IsSupported)return i._removePendingData(r),a("Particle system with GPU is not supported.");Ce.b.LoadFile(e.BaseAssetsUrl+"/systems/"+t+".json",(function(e){i._removePendingData(r);var t=JSON.parse(e.toString());return o(bd.Parse(t,i,n))}),void 0,void 0,void 0,(function(){return i._removePendingData(r),a("An error occured while the creation of your particle system. Check if your type '"+t+"' exists.")}))}))},e.ExportSet=function(e){for(var t=new bd,i=0,n=e;i<n.length;i++){var r=n[i];t.systems.push(r)}return t},e.ParseFromFileAsync=function(e,t,i,n,r){return void 0===n&&(n=!1),void 0===r&&(r=""),new Promise((function(o,a){var s=new V.a;s.addEventListener("readystatechange",(function(){if(4==s.readyState)if(200==s.status){var t=JSON.parse(s.responseText),c=void 0;c=n?vd.Parse(t,i,r):dd.Parse(t,i,r),e&&(c.name=e),o(c)}else a("Unable to load the particle system")})),s.open("GET",t),s.send()}))},e.CreateFromSnippetAsync=function(e,t,i,n){var r=this;if(void 0===i&&(i=!1),void 0===n&&(n=""),"_BLANK"===e){var o=this.CreateDefault(null);return o.start(),Promise.resolve(o)}return new Promise((function(o,a){var s=new V.a;s.addEventListener("readystatechange",(function(){if(4==s.readyState)if(200==s.status){var r=JSON.parse(JSON.parse(s.responseText).jsonPayload),c=JSON.parse(r.particleSystem),l=void 0;(l=i?vd.Parse(c,t,n):dd.Parse(c,t,n)).snippetId=e,o(l)}else a("Unable to load the snippet "+e)})),s.open("GET",r.SnippetUrl+"/"+e.replace(/#/g,"/")),s.send()}))},e.BaseAssetsUrl=bd.BaseAssetsUrl,e.SnippetUrl="https://snippet.babylonjs.com",e}();n.a.AddParser(Me.a.NAME_PARTICLESYSTEM,(function(e,t,i,r){var o=n.a.GetIndividualParser(Me.a.NAME_PARTICLESYSTEM);if(o&&void 0!==e.particleSystems&&null!==e.particleSystems)for(var a=0,s=e.particleSystems.length;a<s;a++){var c=e.particleSystems[a];i.particleSystems.push(o(c,t,r))}})),n.a.AddIndividualParser(Me.a.NAME_PARTICLESYSTEM,(function(e,t,i){return e.activeParticleCount?vd.Parse(e,t,i):dd.Parse(e,t,i)})),Se.a.prototype.createEffectForParticles=function(e,t,i,n,r,o,a,s){var c;void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===n&&(n="");var l=[],u=[],h=[];return s?s.fillUniformsAttributesAndSamplerNames(u,l,h):(l=dd._GetAttributeNamesOrOptions(),u=dd._GetEffectCreationOptions()),-1===n.indexOf(" BILLBOARD")&&(n+="\n#define BILLBOARD\n"),-1===i.indexOf("diffuseSampler")&&i.push("diffuseSampler"),this.createEffect({vertex:null!==(c=null==s?void 0:s.vertexShaderName)&&void 0!==c?c:"particles",fragmentElement:e},l,u.concat(t),h.concat(i),n,r,o,a)},be.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},be.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 n=this.getScene().particleSystems[i],r=n.emitter;r.position&&-1!==t.indexOf(r)&&e.push(n)}return e};var Td,Ed=function(){function e(e,t,i,n,r,o,c,l,u,h){void 0===u&&(u=null),void 0===h&&(h=null),this.idx=0,this.id=0,this.color=new s.b(1,1,1,1),this.position=a.e.Zero(),this.rotation=a.e.Zero(),this.scaling=a.e.One(),this.uvs=new a.f(0,0,1,1),this.velocity=a.e.Zero(),this.pivot=a.e.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.materialIndex=null,this.props=null,this.cullingStrategy=Ge.a.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY,this._globalPosition=a.e.Zero(),this.idx=e,this.id=t,this._pos=i,this._ind=n,this._model=r,this.shapeId=o,this.idxInShape=c,this._sps=l,u&&(this._modelBoundingInfo=u,this._boundingInfo=new Tn.a(u.minimum,u.maximum)),null!==h&&(this.materialIndex=h)}return e.prototype.copyToRef=function(e){return e.position.copyFrom(this.position),e.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(e.rotationQuaternion?e.rotationQuaternion.copyFrom(this.rotationQuaternion):e.rotationQuaternion=this.rotationQuaternion.clone()),e.scaling.copyFrom(this.scaling),this.color&&(e.color?e.color.copyFrom(this.color):e.color=this.color.clone()),e.uvs.copyFrom(this.uvs),e.velocity.copyFrom(this.velocity),e.pivot.copyFrom(this.pivot),e.translateFromPivot=this.translateFromPivot,e.alive=this.alive,e.isVisible=this.isVisible,e.parentId=this.parentId,e.cullingStrategy=this.cullingStrategy,null!==this.materialIndex&&(e.materialIndex=this.materialIndex),this},Object.defineProperty(e.prototype,"scale",{get:function(){return this.scaling},set:function(e){this.scaling=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(e){this.rotationQuaternion=e},enumerable:!1,configurable:!0}),e.prototype.intersectsMesh=function(e){return!(!this._boundingInfo||!e._boundingInfo)&&(this._sps._bSphereOnly?En.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=a.c.Quaternion[0];var i=this.rotation;a.b.RotationYawPitchRollToRef(i.y,i.x,i.z,t)}t.toRotationMatrix(e)},e}(),Sd=function(e,t,i,n,r,o,a,s,c){this._indicesLength=0,this.shapeID=e,this._shape=t,this._indices=i,this._indicesLength=i.length,this._shapeUV=o,this._shapeColors=r,this._normals=n,this._positionFunction=a,this._vertexFunction=s,this._material=c},Ad=function(e,t,i,n){this.idx=0,this.ind=0,this.indicesLength=0,this.sqDistance=0,this.materialIndex=0,this.idx=e,this.ind=t,this.indicesLength=i,this.materialIndex=n},Pd=function(){function e(){this.position=a.e.Zero(),this.color=new s.b(1,1,1,1),this.uv=a.d.Zero()}return Object.defineProperty(e.prototype,"x",{get:function(){return this.position.x},set:function(e){this.position.x=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this.position.y},set:function(e){this.position.y=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"z",{get:function(){return this.position.z},set:function(e){this.position.z=e},enumerable:!1,configurable:!0}),e}(),Cd=function(){function e(e,t,i){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.recomputeNormals=!1,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._expandable=!1,this._shapeCounter=0,this._copy=new Ed(0,0,0,0,null,0,0,this),this._color=new s.b(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._isNotBuilt=!0,this._lastParticleId=0,this._idxOfId=[],this._multimaterialEnabled=!1,this._useModelMaterial=!1,this._depthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},this._materialSortFunction=function(e,t){return e.materialIndex-t.materialIndex},this._autoUpdateSubMeshes=!1,this.name=e,this._scene=t||x.a.LastCreatedScene,this._camera=t.activeCamera,this._pickable=!!i&&i.isPickable,this._depthSort=!!i&&i.enableDepthSort,this._multimaterialEnabled=!!i&&i.enableMultiMaterial,this._useModelMaterial=!!i&&i.useModelMaterial,this._multimaterialEnabled=!!this._useModelMaterial||this._multimaterialEnabled,this._expandable=!!i&&i.expandable,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.pickedBySubMesh=[[]],this.pickedParticles=this.pickedBySubMesh[0]),(this._depthSort||this._multimaterialEnabled)&&(this.depthSortedParticles=[]),this._multimaterialEnabled&&(this._multimaterial=new tc.a(this.name+"MultiMaterial",this._scene),this._materials=[],this._materialIndexesById={}),this._tmpVertex=new Pd}return e.prototype.buildMesh=function(){if(!this._isNotBuilt&&this.mesh)return this.mesh;if(0===this.nbParticles&&!this.mesh){var e=xh.CreateDisc("",{radius:1,tessellation:3},this._scene);this.addShape(e,1),e.dispose()}if(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.mesh){var t=new be.a(this.name,this._scene);this.mesh=t}!this._updatable&&this._multimaterialEnabled&&this._sortParticlesByMaterial(),this.recomputeNormals&&Ki.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 i=new Ki.a;if(i.indices=this._depthSort?this._indices:this._indices32,i.set(this._positions32,Qi.b.PositionKind),i.set(this._normals32,Qi.b.NormalKind),this._uvs32.length>0&&i.set(this._uvs32,Qi.b.UVKind),this._colors32.length>0&&i.set(this._colors32,Qi.b.ColorKind),i.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable)for(var n=0,r=0;r<this.nbParticles;r++)for(var o=this.particles[r],a=o._model._indicesLength,s=0;s<a;s++){if(0==s%3){var c={idx:o.idx,faceId:n};this.pickedParticles[n]=c,n++}}return this._multimaterialEnabled&&this.setMultiMaterial(this._materials),this._expandable||(this._depthSort||this._multimaterialEnabled||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0)),this._isNotBuilt=!1,this.recomputeNormals=!1,this.mesh},e.prototype.digest=function(e,t){var i=t&&t.facetNb||1,n=t&&t.number||0,r=t&&t.delta||0,o=e.getVerticesData(Qi.b.PositionKind),s=e.getIndices(),c=e.getVerticesData(Qi.b.UVKind),l=e.getVerticesData(Qi.b.ColorKind),u=e.getVerticesData(Qi.b.NormalKind),h=t&&t.storage?t.storage:null,d=0,f=s.length/3;n?(n=n>f?f:n,i=Math.round(f/n),r=0):i=i>f?f:i;for(var p=[],_=[],m=[],g=[],v=[],b=a.e.Zero(),y=i;d<f;){d>f-(i=y+Math.floor((1+r)*Math.random()))&&(i=f-d),p.length=0,_.length=0,m.length=0,g.length=0,v.length=0;for(var T=0,E=3*d;E<3*(d+i);E++){m.push(T);var S=s[E],A=3*S;if(p.push(o[A],o[A+1],o[A+2]),_.push(u[A],u[A+1],u[A+2]),c){var P=2*S;g.push(c[P],c[P+1])}if(l){var C=4*S;v.push(l[C],l[C+1],l[C+2],l[C+3])}T++}var R,x=this.nbParticles,O=this._posToShape(p),M=this._uvsToShapeUV(g),I=Ce.b.Slice(m),D=Ce.b.Slice(v),N=Ce.b.Slice(_);for(b.copyFromFloats(0,0,0),R=0;R<O.length;R++)b.addInPlace(O[R]);b.scaleInPlace(1/O.length);var L,w=new a.e(1/0,1/0,1/0),F=new a.e(-1/0,-1/0,-1/0);for(R=0;R<O.length;R++)O[R].subtractInPlace(b),w.minimizeInPlaceFromFloats(O[R].x,O[R].y,O[R].z),F.maximizeInPlaceFromFloats(O[R].x,O[R].y,O[R].z);this._particlesIntersect&&(L=new Tn.a(w,F));var B=null;this._useModelMaterial&&(B=e.material?e.material:this._setDefaultMaterial());var U=new Sd(this._shapeCounter,O,I,N,D,M,null,null,B),V=this._positions.length,k=this._indices.length;this._meshBuilder(this._index,k,O,this._positions,I,this._indices,g,this._uvs,D,this._colors,N,this._normals,x,0,null,U),this._addParticle(x,this._lastParticleId,V,k,U,this._shapeCounter,0,L,h),this.particles[this.nbParticles].position.addInPlace(b),h||(this._index+=O.length,x++,this.nbParticles++,this._lastParticleId++),this._shapeCounter++,d+=i}return this._isNotBuilt=!0,this},e.prototype._unrotateFixedNormals=function(){for(var e=0,t=0,i=a.c.Vector3[0],n=a.c.Quaternion[0],r=a.c.Matrix[0],o=0;o<this.particles.length;o++){var s=this.particles[o],c=s._model._shape;if(s.rotationQuaternion)s.rotationQuaternion.conjugateToRef(n);else{var l=s.rotation;a.b.RotationYawPitchRollToRef(l.y,l.x,l.z,n),n.conjugateInPlace()}n.toRotationMatrix(r);for(var u=0;u<c.length;u++)t=e+3*u,a.e.TransformNormalFromFloatsToRef(this._normals32[t],this._normals32[t+1],this._normals32[t+2],r,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.shapeId=0,e.materialIndex=null},e.prototype._meshBuilder=function(e,t,i,n,r,o,s,c,l,u,h,d,f,p,_,m){var g,v=0,b=0,y=0;this._resetCopy();var T=this._copy,E=!(!_||!_.storage);if(T.idx=f,T.idxInShape=p,T.shapeId=m.shapeID,this._useModelMaterial){var S=m._material.uniqueId,A=this._materialIndexesById;A.hasOwnProperty(S)||(A[S]=this._materials.length,this._materials.push(m._material));var P=A[S];T.materialIndex=P}if(_&&_.positionFunction&&(_.positionFunction(T,f,p),this._mustUnrotateFixedNormals=!0),E)return T;var C=a.c.Matrix[0],R=this._tmpVertex,x=R.position,O=R.color,M=R.uv,I=a.c.Vector3[1],D=a.c.Vector3[2],N=a.c.Vector3[3];a.a.IdentityToRef(C),T.getRotationMatrix(C),T.pivot.multiplyToRef(T.scaling,N),T.translateFromPivot?D.setAll(0):D.copyFrom(N);var L=_&&_.vertexFunction;for(g=0;g<i.length;g++){if(x.copyFrom(i[g]),T.color&&O.copyFrom(T.color),s&&M.copyFromFloats(s[v],s[v+1]),L&&_.vertexFunction(T,R,g),x.multiplyInPlace(T.scaling).subtractInPlace(N),a.e.TransformCoordinatesToRef(x,C,I),I.addInPlace(D).addInPlace(T.position),n.push(I.x,I.y,I.z),s){var w=T.uvs;c.push((w.z-w.x)*M.x+w.x,(w.w-w.y)*M.y+w.y),v+=2}if(T.color)this._color.copyFrom(O);else{var F=this._color;l&&void 0!==l[b]?(F.r=l[b],F.g=l[b+1],F.b=l[b+2],F.a=l[b+3]):(F.r=1,F.g=1,F.b=1,F.a=1)}u.push(this._color.r,this._color.g,this._color.b,this._color.a),b+=4,!this.recomputeNormals&&h&&(a.e.TransformNormalFromFloatsToRef(h[y],h[y+1],h[y+2],C,x),d.push(x.x,x.y,x.z),y+=3)}for(g=0;g<r.length;g++){var B=e+r[g];o.push(B),B>65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var U=null!==T.materialIndex?T.materialIndex:0;this.depthSortedParticles.push(new Ad(f,t,r.length,U))}return T},e.prototype._posToShape=function(e){for(var t=[],i=0;i<e.length;i+=3)t.push(a.e.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,n,r,o,a,s,c){void 0===s&&(s=null),void 0===c&&(c=null);var l=new Ed(e,t,i,n,r,o,a,this,s);return(c||this.particles).push(l),l},e.prototype.addShape=function(e,t,i){var n=e.getVerticesData(Qi.b.PositionKind),r=e.getIndices(),o=e.getVerticesData(Qi.b.UVKind),a=e.getVerticesData(Qi.b.ColorKind),s=e.getVerticesData(Qi.b.NormalKind);this.recomputeNormals=!s;var c=Ce.b.SliceToArray(r),l=Ce.b.SliceToArray(s),u=a?Ce.b.SliceToArray(a):[],h=i&&i.storage?i.storage:null,d=null;this._particlesIntersect&&(d=e.getBoundingInfo());var f=this._posToShape(n),p=this._uvsToShapeUV(o),_=i?i.positionFunction:null,m=i?i.vertexFunction:null,g=null;this._useModelMaterial&&(g=e.material?e.material:this._setDefaultMaterial());for(var v=new Sd(this._shapeCounter,f,c,l,u,p,_,m,g),b=0;b<t;b++)this._insertNewParticle(this.nbParticles,b,v,f,r,o,a,s,d,h,i);return this._shapeCounter++,this._isNotBuilt=!0,this._shapeCounter-1},e.prototype._rebuildParticle=function(e,t){void 0===t&&(t=!1),this._resetCopy();var i=this._copy;e._model._positionFunction&&e._model._positionFunction(i,e.idx,e.idxInShape);var n=a.c.Matrix[0],r=a.c.Vector3[0],o=a.c.Vector3[1],s=a.c.Vector3[2],c=a.c.Vector3[3];i.getRotationMatrix(n),e.pivot.multiplyToRef(e.scaling,c),i.translateFromPivot?s.copyFromFloats(0,0,0):s.copyFrom(c);for(var l=e._model._shape,u=0;u<l.length;u++)r.copyFrom(l[u]),e._model._vertexFunction&&e._model._vertexFunction(i,r,u),r.multiplyInPlace(i.scaling).subtractInPlace(c),a.e.TransformCoordinatesToRef(r,n,o),o.addInPlace(s).addInPlace(i.position).toArray(this._positions32,e._pos+3*u);t&&(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(e){void 0===e&&(e=!1);for(var t=0;t<this.particles.length;t++)this._rebuildParticle(this.particles[t],e);return this.mesh.updateVerticesData(Qi.b.PositionKind,this._positions32,!1,!1),this},e.prototype.removeParticles=function(e,t){var i=t-e+1;if(!this._expandable||i<=0||i>=this.nbParticles||!this._updatable)return[];var n=this.particles,r=this.nbParticles;if(t<r-1)for(var o=t+1,a=n[o]._pos-n[e]._pos,s=n[o]._ind-n[e]._ind,c=o;c<r;c++){var l=n[c];l._pos-=a,l._ind-=s}var u=n.splice(e,i);this._positions.length=0,this._indices.length=0,this._colors.length=0,this._uvs.length=0,this._normals.length=0,this._index=0,this._idxOfId.length=0,(this._depthSort||this._multimaterialEnabled)&&(this.depthSortedParticles=[]);for(var h=0,d=n.length,f=0;f<d;f++){var p=n[f],_=p._model,m=_._shape,g=_._indices,v=_._normals,b=_._shapeColors,y=_._shapeUV;p.idx=f,this._idxOfId[p.id]=f,this._meshBuilder(this._index,h,m,this._positions,g,this._indices,y,this._uvs,b,this._colors,v,this._normals,p.idx,p.idxInShape,null,_),this._index+=m.length,h+=g.length}return this.nbParticles-=i,this._isNotBuilt=!0,u},e.prototype.insertParticlesFromArray=function(e){if(!this._expandable)return this;for(var t=0,i=e[0].shapeId,n=e.length,r=0;r<n;r++){var o=e[r],a=o._model,s=a._shape,c=a._indices,l=a._shapeUV,u=a._shapeColors,h=a._normals,d=!h;this.recomputeNormals=d||this.recomputeNormals;var f=o._boundingInfo,p=this._insertNewParticle(this.nbParticles,t,a,s,c,l,u,h,f,null,null);o.copyToRef(p),t++,i!=o.shapeId&&(i=o.shapeId,t=0)}return this._isNotBuilt=!0,this},e.prototype._insertNewParticle=function(e,t,i,n,r,o,a,s,c,l,u){var h=this._positions.length,d=this._indices.length,f=this._meshBuilder(this._index,d,n,this._positions,r,this._indices,o,this._uvs,a,this._colors,s,this._normals,e,t,u,i),p=null;return this._updatable&&((p=this._addParticle(this.nbParticles,this._lastParticleId,h,d,i,this._shapeCounter,t,c,l)).position.copyFrom(f.position),p.rotation.copyFrom(f.rotation),f.rotationQuaternion&&(p.rotationQuaternion?p.rotationQuaternion.copyFrom(f.rotationQuaternion):p.rotationQuaternion=f.rotationQuaternion.clone()),f.color&&(p.color?p.color.copyFrom(f.color):p.color=f.color.clone()),p.scaling.copyFrom(f.scaling),p.uvs.copyFrom(f.uvs),null!==f.materialIndex&&(p.materialIndex=f.materialIndex),this.expandable&&(this._idxOfId[p.id]=p.idx)),l||(this._index+=n.length,this.nbParticles++,this._lastParticleId++),p},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||this._isNotBuilt)return this;this.beforeUpdateParticles(e,t,i);var n=a.c.Matrix[0],r=a.c.Matrix[1],o=this.mesh,s=this._colors32,c=this._positions32,l=this._normals32,u=this._uvs32,h=this._indices32,d=this._indices,f=this._fixedNormal32,p=a.c.Vector3,_=p[5].copyFromFloats(1,0,0),m=p[6].copyFromFloats(0,1,0),g=p[7].copyFromFloats(0,0,1),v=p[8].setAll(Number.MAX_VALUE),b=p[9].setAll(-Number.MAX_VALUE),y=p[10].setAll(0),T=this._tmpVertex,E=T.position,S=T.color,A=T.uv;if((this.billboard||this._depthSort)&&(this.mesh.computeWorldMatrix(!0),this.mesh._worldMatrix.invertToRef(r)),this.billboard){var P=p[0];this._camera.getDirectionToRef(J.a.Z,P),a.e.TransformNormalToRef(P,r,g),g.normalize();var C=this._camera.getViewMatrix(!0);a.e.TransformNormalFromFloatsToRef(C.m[1],C.m[5],C.m[9],r,m),a.e.CrossToRef(m,g,_),m.normalize(),_.normalize()}this._depthSort&&a.e.TransformCoordinatesToRef(this._camera.globalPosition,r,y),a.a.IdentityToRef(n);var R=0,x=0,O=0,M=0,I=0,D=0,N=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 L=this.mesh._boundingInfo;L&&(v.copyFrom(L.minimum),b.copyFrom(L.maximum))}var w=(x=this.particles[e]._pos)/3|0;M=4*w,D=2*w;for(var F=e;F<=t;F++){var B=this.particles[F];this.updateParticle(B);var U=B._model._shape,V=B._model._shapeUV,k=B._rotationMatrix,z=B.position,G=B.rotation,j=B.scaling,W=B._globalPosition;if(this._depthSort&&this._depthSortParticles){var H=this.depthSortedParticles[F];H.idx=B.idx,H.ind=B._ind,H.indicesLength=B._model._indicesLength,H.sqDistance=a.e.DistanceSquared(B.position,y)}if(!B.alive||B._stillInvisible&&!B.isVisible)x+=3*(N=U.length),M+=4*N,D+=2*N;else{if(B.isVisible){B._stillInvisible=!1;var X=p[12];if(B.pivot.multiplyToRef(j,X),this.billboard&&(G.x=0,G.y=0),(this._computeParticleRotation||this.billboard)&&B.getRotationMatrix(n),null!==B.parentId){var Y=this.getParticleById(B.parentId);if(Y){var K=Y._rotationMatrix,Q=Y._globalPosition,q=z.x*K[1]+z.y*K[4]+z.z*K[7],Z=z.x*K[0]+z.y*K[3]+z.z*K[6],$=z.x*K[2]+z.y*K[5]+z.z*K[8];if(W.x=Q.x+Z,W.y=Q.y+q,W.z=Q.z+$,this._computeParticleRotation||this.billboard){var ee=n.m;k[0]=ee[0]*K[0]+ee[1]*K[3]+ee[2]*K[6],k[1]=ee[0]*K[1]+ee[1]*K[4]+ee[2]*K[7],k[2]=ee[0]*K[2]+ee[1]*K[5]+ee[2]*K[8],k[3]=ee[4]*K[0]+ee[5]*K[3]+ee[6]*K[6],k[4]=ee[4]*K[1]+ee[5]*K[4]+ee[6]*K[7],k[5]=ee[4]*K[2]+ee[5]*K[5]+ee[6]*K[8],k[6]=ee[8]*K[0]+ee[9]*K[3]+ee[10]*K[6],k[7]=ee[8]*K[1]+ee[9]*K[4]+ee[10]*K[7],k[8]=ee[8]*K[2]+ee[9]*K[5]+ee[10]*K[8]}}else B.parentId=null}else if(W.x=z.x,W.y=z.y,W.z=z.z,this._computeParticleRotation||this.billboard){ee=n.m;k[0]=ee[0],k[1]=ee[1],k[2]=ee[2],k[3]=ee[4],k[4]=ee[5],k[5]=ee[6],k[6]=ee[8],k[7]=ee[9],k[8]=ee[10]}var te=p[11];for(B.translateFromPivot?te.setAll(0):te.copyFrom(X),N=0;N<U.length;N++){R=x+3*N,O=M+4*N,I=D+2*N;var ie=2*N,ne=ie+1;E.copyFrom(U[N]),this._computeParticleColor&&B.color&&S.copyFrom(B.color),this._computeParticleTexture&&A.copyFromFloats(V[ie],V[ne]),this._computeParticleVertex&&this.updateParticleVertex(B,T,N);var re=E.x*j.x-X.x,oe=E.y*j.y-X.y,ae=E.z*j.z-X.z;Z=re*k[0]+oe*k[3]+ae*k[6],q=re*k[1]+oe*k[4]+ae*k[7],$=re*k[2]+oe*k[5]+ae*k[8];Z+=te.x,q+=te.y,$+=te.z;var se=c[R]=W.x+_.x*Z+m.x*q+g.x*$,ce=c[R+1]=W.y+_.y*Z+m.y*q+g.y*$,le=c[R+2]=W.z+_.z*Z+m.z*q+g.z*$;if(this._computeBoundingBox&&(v.minimizeInPlaceFromFloats(se,ce,le),b.maximizeInPlaceFromFloats(se,ce,le)),!this._computeParticleVertex){var ue=f[R],he=f[R+1],de=f[R+2],fe=ue*k[0]+he*k[3]+de*k[6],pe=ue*k[1]+he*k[4]+de*k[7],_e=ue*k[2]+he*k[5]+de*k[8];l[R]=_.x*fe+m.x*pe+g.x*_e,l[R+1]=_.y*fe+m.y*pe+g.y*_e,l[R+2]=_.z*fe+m.z*pe+g.z*_e}if(this._computeParticleColor&&B.color){var me=this._colors32;me[O]=S.r,me[O+1]=S.g,me[O+2]=S.b,me[O+3]=S.a}if(this._computeParticleTexture){var ge=B.uvs;u[I]=A.x*(ge.z-ge.x)+ge.x,u[I+1]=A.y*(ge.w-ge.y)+ge.y}}}else for(B._stillInvisible=!0,N=0;N<U.length;N++){if(O=M+4*N,I=D+2*N,c[R=x+3*N]=c[R+1]=c[R+2]=0,l[R]=l[R+1]=l[R+2]=0,this._computeParticleColor&&B.color){var ve=B.color;s[O]=ve.r,s[O+1]=ve.g,s[O+2]=ve.b,s[O+3]=ve.a}if(this._computeParticleTexture){ge=B.uvs;u[I]=V[2*N]*(ge.z-ge.x)+ge.x,u[I+1]=V[2*N+1]*(ge.w-ge.y)+ge.y}}if(this._particlesIntersect){var be=B._boundingInfo,ye=be.boundingBox,Te=be.boundingSphere,Ee=B._modelBoundingInfo;if(!this._bSphereOnly){var Se=Ee.boundingBox.vectors,Ae=p[1],Pe=p[2];Ae.setAll(Number.MAX_VALUE),Pe.setAll(-Number.MAX_VALUE);for(var Ce=0;Ce<8;Ce++){var Re=Se[Ce].x*j.x,xe=Se[Ce].y*j.y,Oe=Se[Ce].z*j.z,Me=(Z=Re*k[0]+xe*k[3]+Oe*k[6],q=Re*k[1]+xe*k[4]+Oe*k[7],$=Re*k[2]+xe*k[5]+Oe*k[8],z.x+_.x*Z+m.x*q+g.x*$),Ie=z.y+_.y*Z+m.y*q+g.y*$,De=z.z+_.z*Z+m.z*q+g.z*$;Ae.minimizeInPlaceFromFloats(Me,Ie,De),Pe.maximizeInPlaceFromFloats(Me,Ie,De)}ye.reConstruct(Ae,Pe,o._worldMatrix)}var Ne=Ee.minimum.multiplyToRef(j,p[1]),Le=Ee.maximum.multiplyToRef(j,p[2]),we=Le.addToRef(Ne,p[3]).scaleInPlace(.5).addInPlace(W),Fe=Le.subtractToRef(Ne,p[4]).scaleInPlace(.5*this._bSphereRadiusFactor),Be=we.subtractToRef(Fe,p[1]),Ue=we.addToRef(Fe,p[2]);Te.reConstruct(Be,Ue,o._worldMatrix)}x=R+3,M=O+4,D=I+2}}if(i){if(this._computeParticleColor&&o.updateVerticesData(Qi.b.ColorKind,s,!1,!1),this._computeParticleTexture&&o.updateVerticesData(Qi.b.UVKind,u,!1,!1),o.updateVerticesData(Qi.b.PositionKind,c,!1,!1),!o.areNormalsFrozen||o.isFacetDataEnabled){if(this._computeParticleVertex||o.isFacetDataEnabled){var Ve=o.isFacetDataEnabled?o.getFacetDataParameters():null;Ki.a.ComputeNormals(c,h,l,Ve);for(var ke=0;ke<l.length;ke++)f[ke]=l[ke]}o.areNormalsFrozen||o.updateVerticesData(Qi.b.NormalKind,l,!1,!1)}if(this._depthSort&&this._depthSortParticles){var ze=this.depthSortedParticles;ze.sort(this._depthSortFunction);for(var Ge=ze.length,je=0,We=0,He=0;He<Ge;He++){var Xe=ze[He],Ye=Xe.indicesLength,Ke=Xe.ind;for(ke=0;ke<Ye;ke++){if(h[je]=d[Ke+ke],je++,this._pickable)if(0==ke%3){var Qe=this.pickedParticles[We];Qe.idx=Xe.idx,Qe.faceId=We,We++}}}o.updateIndices(h)}}return this._computeBoundingBox&&(o._boundingInfo?o._boundingInfo.reConstruct(v,b,o._worldMatrix):o._boundingInfo=new Tn.a(v,b,o._worldMatrix)),this._autoUpdateSubMeshes&&this.computeSubMeshes(),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,this.pickedBySubMesh=null,this._materials=null,this._materialIndexes=null,this._indicesByMaterial=null,this._idxOfId=null},e.prototype.pickedParticle=function(e){if(e.hit){var t=e.subMeshId,i=e.faceId,n=this.pickedBySubMesh;if(n[t]&&n[t][i])return n[t][i]}return null},e.prototype.getParticleById=function(e){var t=this.particles[e];if(t&&t.id==e)return t;var i=this.particles,n=this._idxOfId[e];if(void 0!==n)return i[n];for(var r=0,o=this.nbParticles;r<o;){var a=i[r];if(a.id==e)return a;r++}return null},e.prototype.getParticlesByShapeId=function(e){var t=[];return this.getParticlesByShapeIdToRef(e,t),t},e.prototype.getParticlesByShapeIdToRef=function(e,t){t.length=0;for(var i=0;i<this.nbParticles;i++){var n=this.particles[i];n.shapeId==e&&t.push(n)}return this},e.prototype.computeSubMeshes=function(){if(!this.mesh||!this._multimaterialEnabled)return this;var e=this.depthSortedParticles;if(this.particles.length>0)for(var t=0;t<this.particles.length;t++){var i=this.particles[t];i.materialIndex||(i.materialIndex=0);var n=e[t];n.materialIndex=i.materialIndex,n.ind=i._ind,n.indicesLength=i._model._indicesLength,n.idx=i.idx}this._sortParticlesByMaterial();var r=this._indicesByMaterial,o=this._materialIndexes,a=this.mesh;a.subMeshes=[];for(var s=a.getTotalVertices(),c=0;c<o.length;c++){var l=r[c],u=r[c+1]-l,h=o[c];new gh.a(h,0,s,l,u,a)}return this},e.prototype._sortParticlesByMaterial=function(){var e=[0];this._indicesByMaterial=e;var t=[];this._materialIndexes=t;var i=this.depthSortedParticles;i.sort(this._materialSortFunction);var n=i.length,r=this._indices32,o=this._indices,a=0,s=0,c=0,l=i[0].materialIndex;t.push(l),this._pickable&&(this.pickedBySubMesh=[[]],this.pickedParticles=this.pickedBySubMesh[0]);for(var u=0;u<n;u++){var h=i[u],d=h.indicesLength,f=h.ind;h.materialIndex!==l&&(l=h.materialIndex,e.push(c),t.push(l),this._pickable&&(a++,this.pickedBySubMesh[a]=[],s=0));for(var p=0,_=0;_<d;_++){if(r[c]=o[f+_],this._pickable)if(0==_%3){var m=this.pickedBySubMesh[a][s];m?(m.idx=h.idx,m.faceId=p):this.pickedBySubMesh[a][s]={idx:h.idx,faceId:p},s++,p++}c++}}return e.push(r.length),this._updatable&&this.mesh.updateIndices(r),this},e.prototype._setMaterialIndexesById=function(){this._materialIndexesById={};for(var e=0;e<this._materials.length;e++){var t=this._materials[e].uniqueId;this._materialIndexesById[t]=e}},e.prototype._filterUniqueMaterialId=function(e){return e.filter((function(e,t,i){return i.indexOf(e)===t}))},e.prototype._setDefaultMaterial=function(){return this._defaultMaterial||(this._defaultMaterial=new Wi.a(this.name+"DefaultMaterial",this._scene)),this._defaultMaterial},e.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},e.prototype.setVisibilityBox=function(e){var t=e/2;this.mesh._boundingInfo=new Tn.a(new a.e(-t,-t,-t),new a.e(t,t,t))},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isVisibilityBoxLocked",{get:function(){return this._isVisibilityBoxLocked},set:function(e){this._isVisibilityBoxLocked=e,this.mesh.getBoundingInfo().isLocked=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{get:function(){return this._computeParticleRotation},set:function(e){this._computeParticleRotation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleVertex",{get:function(){return this._computeParticleVertex},set:function(e){this._computeParticleVertex=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthSortParticles",{get:function(){return this._depthSortParticles},set:function(e){this._depthSortParticles=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"expandable",{get:function(){return this._expandable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"multimaterialEnabled",{get:function(){return this._multimaterialEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useModelMaterial",{get:function(){return this._useModelMaterial},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"materials",{get:function(){return this._materials},enumerable:!1,configurable:!0}),e.prototype.setMultiMaterial=function(e){this._materials=this._filterUniqueMaterialId(e),this._setMaterialIndexesById(),this._multimaterial&&this._multimaterial.dispose(),this._multimaterial=new tc.a(this.name+"MultiMaterial",this._scene);for(var t=0;t<this._materials.length;t++)this._multimaterial.subMaterials.push(this._materials[t]);this.computeSubMeshes(),this.mesh.material=this._multimaterial},Object.defineProperty(e.prototype,"multimaterial",{get:function(){return this._multimaterial},set:function(e){this._multimaterial=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"autoUpdateSubMeshes",{get:function(){return this._autoUpdateSubMeshes},set:function(e){this._autoUpdateSubMeshes=e},enumerable:!1,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 this},e.prototype.beforeUpdateParticles=function(e,t,i){},e.prototype.afterUpdateParticles=function(e,t,i){},e}(),Rd=function(){function e(e,t,i,n,r){this.idx=0,this.color=new s.b(1,1,1,1),this.position=a.e.Zero(),this.rotation=a.e.Zero(),this.uv=new a.d(0,0),this.velocity=a.e.Zero(),this.pivot=a.e.Zero(),this.translateFromPivot=!1,this._pos=0,this._ind=0,this.groupId=0,this.idxInGroup=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this._globalPosition=a.e.Zero(),this.idx=e,this._group=t,this.groupId=i,this.idxInGroup=n,this._pcs=r}return Object.defineProperty(e.prototype,"size",{get:function(){return this.size},set:function(e){this.size=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(e){this.rotationQuaternion=e},enumerable:!1,configurable:!0}),e.prototype.intersectsMesh=function(e,t){if(!e._boundingInfo)return!1;if(t=t||!1)return e.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));var i,n,r,o,a,s;i=e.getBoundingInfo().boundingBox.maximumWorld.x,n=e.getBoundingInfo().boundingBox.minimumWorld.x,r=e.getBoundingInfo().boundingBox.maximumWorld.y,o=e.getBoundingInfo().boundingBox.minimumWorld.y,a=e.getBoundingInfo().boundingBox.maximumWorld.z,s=e.getBoundingInfo().boundingBox.minimumWorld.z;var c=this.position.x+this._pcs.mesh.position.x,l=this.position.y+this._pcs.mesh.position.y,u=this.position.z+this._pcs.mesh.position.z;return n<=c&&c<=i&&o<=l&&l<=r&&s<=u&&u<=a},e.prototype.getRotationMatrix=function(e){var t;if(this.rotationQuaternion)t=this.rotationQuaternion;else{t=a.c.Quaternion[0];var i=this.rotation;a.b.RotationYawPitchRollToRef(i.y,i.x,i.z,t)}t.toRotationMatrix(e)},e}(),xd=function(e,t){this.groupID=e,this._positionFunction=t};!function(e){e[e.Color=2]="Color",e[e.UV=1]="UV",e[e.Random=0]="Random",e[e.Stated=3]="Stated"}(Td||(Td={}));var Od=function(){function e(e,t,i,n){this.particles=new Array,this.nbParticles=0,this.counter=0,this.vars={},this._promises=[],this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._updatable=!0,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._groups=new Array,this._groupCounter=0,this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeBoundingBox=!1,this._isReady=!1,this.name=e,this._size=t,this._scene=i||x.a.LastCreatedScene,n&&void 0!==n.updatable?this._updatable=n.updatable:this._updatable=!0}return e.prototype.buildMeshAsync=function(){var e=this;return Promise.all(this._promises).then((function(){return e._isReady=!0,e._buildMesh()}))},e.prototype._buildMesh=function(){0===this.nbParticles&&this.addPoints(1),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors);var e=new Ki.a;e.set(this._positions32,Qi.b.PositionKind),this._uvs32.length>0&&e.set(this._uvs32,Qi.b.UVKind);var t=0;this._colors32.length>0&&(t=1,e.set(this._colors32,Qi.b.ColorKind));var i=new be.a(this.name,this._scene);e.applyToMesh(i,this._updatable),this.mesh=i,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var n=new Wi.a("point cloud material",this._scene);return n.emissiveColor=new s.a(t,t,t),n.disableLighting=!0,n.pointsCloud=!0,n.pointSize=this._size,i.material=n,new Promise((function(e){return e(i)}))},e.prototype._addParticle=function(e,t,i,n){var r=new Rd(e,t,i,n,this);return this.particles.push(r),r},e.prototype._randomUnitVector=function(e){e.position=new a.e(Math.random(),Math.random(),Math.random()),e.color=new s.b(1,1,1,1)},e.prototype._getColorIndicesForCoord=function(e,t,i,n){var r=e._groupImageData,o=i*(4*n)+4*t,a=[o,o+1,o+2,o+3],c=a[1],l=a[2],u=a[3],h=r[a[0]],d=r[c],f=r[l],p=r[u];return new s.b(h/255,d/255,f/255,p)},e.prototype._setPointsColorOrUV=function(e,t,i,n,r,o,c){i&&e.updateFacetData();var l=2*e.getBoundingInfo().boundingSphere.radius,u=e.getVerticesData(Qi.b.PositionKind),h=e.getIndices(),d=e.getVerticesData(Qi.b.UVKind),f=e.getVerticesData(Qi.b.ColorKind),p=a.e.Zero();e.computeWorldMatrix();var _=e.getWorldMatrix();if(!_.isIdentity())for(var m=0;m<u.length/3;m++)a.e.TransformCoordinatesFromFloatsToRef(u[3*m],u[3*m+1],u[3*m+2],_,p),u[3*m]=p.x,u[3*m+1]=p.y,u[3*m+2]=p.z;var g,v,b=0,y=0,T=0,E=0,S=0,A=0,P=0,C=0,R=0,x=0,O=0,M=0,I=0,D=0,N=a.e.Zero(),w=a.e.Zero(),F=a.e.Zero(),B=a.e.Zero(),U=a.e.Zero(),V=0,k=0,z=0,G=0,j=0,W=0,H=a.d.Zero(),X=a.d.Zero(),Y=a.d.Zero(),K=a.d.Zero(),Q=a.d.Zero(),q=0,Z=0,J=0,$=0,ee=0,te=0,ie=0,ne=0,re=0,oe=0,ae=0,se=0,ce=a.f.Zero(),le=a.f.Zero(),ue=a.f.Zero(),he=a.f.Zero(),de=a.f.Zero(),fe=0,pe=0;c=c||0;var _e,me=new a.f(0,0,0,0),ge=a.e.Zero(),ve=a.e.Zero(),be=a.e.Zero(),ye=0,Te=a.e.Zero(),Ee=0,Se=0,Ae=new Xt.a(a.e.Zero(),new a.e(1,0,0)),Pe=a.e.Zero();for(y=0;y<h.length/3;y++){var Ce,Re,xe,Oe,Me,Ie,De,Ne;T=h[3*y],E=h[3*y+1],S=h[3*y+2],A=u[3*T],P=u[3*T+1],C=u[3*T+2],R=u[3*E],x=u[3*E+1],O=u[3*E+2],M=u[3*S],I=u[3*S+1],D=u[3*S+2],N.set(A,P,C),w.set(R,x,O),F.set(M,I,D),w.subtractToRef(N,B),F.subtractToRef(w,U),d&&(V=d[2*T],k=d[2*T+1],z=d[2*E],G=d[2*E+1],j=d[2*S],W=d[2*S+1],H.set(V,k),X.set(z,G),Y.set(j,W),X.subtractToRef(H,K),Y.subtractToRef(X,Q)),f&&n&&(q=f[4*T],Z=f[4*T+1],J=f[4*T+2],$=f[4*T+3],ee=f[4*E],te=f[4*E+1],ie=f[4*E+2],ne=f[4*E+3],re=f[4*S],oe=f[4*S+1],ae=f[4*S+2],se=f[4*S+3],ce.set(q,Z,J,$),le.set(ee,te,ie,ne),ue.set(re,oe,ae,se),le.subtractToRef(ce,he),ue.subtractToRef(le,de));for(var Le,we,Fe=new s.a(0,0,0),Be=new s.a(0,0,0),Ue=0;Ue<t._groupDensity[y];Ue++)b=this.particles.length,this._addParticle(b,t,this._groupCounter,y+Ue),we=this.particles[b],fe=L.a.RandomRange(0,1),pe=L.a.RandomRange(0,1),g=N.add(B.scale(fe)).add(U.scale(fe*pe)),i&&(ge=e.getFacetNormal(y).normalize().scale(-1),ve=B.clone().normalize(),be=a.e.Cross(ge,ve),ye=L.a.RandomRange(0,2*Math.PI),Te=ve.scale(Math.cos(ye)).add(be.scale(Math.sin(ye))),ye=L.a.RandomRange(.1,Math.PI/2),Pe=Te.scale(Math.cos(ye)).add(ge.scale(Math.sin(ye))),Ae.origin=g.add(Pe.scale(1e-5)),Ae.direction=Pe,Ae.length=l,(_e=Ae.intersectsMesh(e)).hit&&(Se=_e.pickedPoint.subtract(g).length(),Ee=L.a.RandomRange(0,1)*Se,g.addInPlace(Pe.scale(Ee)))),we.position=g.clone(),this._positions.push(we.position.x,we.position.y,we.position.z),void 0!==n?d&&(v=H.add(K.scale(fe)).add(Q.scale(fe*pe)),n?r&&null!==t._groupImageData?(Ce=t._groupImgWidth,Re=t._groupImgHeight,Le=this._getColorIndicesForCoord(t,Math.round(v.x*Ce),Math.round(v.y*Re),Ce),we.color=Le,this._colors.push(Le.r,Le.g,Le.b,Le.a)):f?(me=ce.add(he.scale(fe)).add(de.scale(fe*pe)),we.color=new s.b(me.x,me.y,me.z,me.w),this._colors.push(me.x,me.y,me.z,me.w)):(me=ce.set(Math.random(),Math.random(),Math.random(),1),we.color=new s.b(me.x,me.y,me.z,me.w),this._colors.push(me.x,me.y,me.z,me.w)):(we.uv=v.clone(),this._uvs.push(we.uv.x,we.uv.y))):(o?(Fe.set(o.r,o.g,o.b),xe=L.a.RandomRange(-c,c),Oe=L.a.RandomRange(-c,c),Me=(Ne=Fe.toHSV()).r,(Ie=Ne.g+xe)<0&&(Ie=0),Ie>1&&(Ie=1),(De=Ne.b+Oe)<0&&(De=0),De>1&&(De=1),s.a.HSVtoRGBToRef(Me,Ie,De,Be),me.set(Be.r,Be.g,Be.b,1)):me=ce.set(Math.random(),Math.random(),Math.random(),1),we.color=new s.b(me.x,me.y,me.z,me.w),this._colors.push(me.x,me.y,me.z,me.w))}},e.prototype._colorFromTexture=function(e,t,i){var n=this;if(null===e.material)return m.a.Warn(e.name+"has no material."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var r=e.material.getActiveTextures();if(0===r.length)return m.a.Warn(e.name+"has no useable texture."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,i,!0,!1);var o=e.clone();o.setEnabled(!1),this._promises.push(new Promise((function(e){Zn.a.WhenAllReady(r,(function(){var a=t._textureNb;return a<0&&(a=0),a>r.length-1&&(a=r.length-1),t._groupImageData=r[a].readPixels(),t._groupImgWidth=r[a].getSize().width,t._groupImgHeight=r[a].getSize().height,n._setPointsColorOrUV(o,t,i,!0,!0),o.dispose(),e()}))})))},e.prototype._calculateDensity=function(e,t,i){for(var n,r,o,s,c,l,u,h,d,f,p,_,m,g,v,b,y,T=new Array,E=a.e.Zero(),S=a.e.Zero(),A=a.e.Zero(),P=a.e.Zero(),C=a.e.Zero(),R=a.e.Zero(),x=new Array,O=0,M=i.length/3,I=0;I<M;I++)n=i[3*I],r=i[3*I+1],o=i[3*I+2],s=t[3*n],c=t[3*n+1],l=t[3*n+2],u=t[3*r],h=t[3*r+1],d=t[3*r+2],f=t[3*o],p=t[3*o+1],_=t[3*o+2],E.set(s,c,l),S.set(u,h,d),A.set(f,p,_),S.subtractToRef(E,P),A.subtractToRef(S,C),A.subtractToRef(E,R),b=((m=P.length())+(g=C.length())+(v=R.length()))/2,O+=y=Math.sqrt(b*(b-m)*(b-g)*(b-v)),x[I]=y;var D=0;for(I=0;I<M;I++)T[I]=Math.floor(e*x[I]/O),D+=T[I];var N=e-D,L=Math.floor(N/M),w=N%M;L>0&&(T=T.map((function(e){return e+L})));for(I=0;I<w;I++)T[I]+=1;return T},e.prototype.addPoints=function(e,t){void 0===t&&(t=this._randomUnitVector);for(var i,n=new xd(this._groupCounter,t),r=this.nbParticles,o=0;o<e;o++)i=this._addParticle(r,n,this._groupCounter,o),n&&n._positionFunction&&n._positionFunction(i,r,o),this._positions.push(i.position.x,i.position.y,i.position.z),i.color&&this._colors.push(i.color.r,i.color.g,i.color.b,i.color.a),i.uv&&this._uvs.push(i.uv.x,i.uv.y),r++;return this.nbParticles+=e,this._groupCounter++,this._groupCounter},e.prototype.addSurfacePoints=function(e,t,i,n,r){var o=i||Td.Random;(isNaN(o)||o<0||o>3)&&(o=Td.Random);var a=e.getVerticesData(Qi.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var l=new xd(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,c),o===Td.Color?l._textureNb=n||0:n=n||new s.b(1,1,1,1),o){case Td.Color:this._colorFromTexture(e,l,!1);break;case Td.UV:this._setPointsColorOrUV(e,l,!1,!1,!1);break;case Td.Random:this._setPointsColorOrUV(e,l,!1);break;case Td.Stated:this._setPointsColorOrUV(e,l,!1,void 0,void 0,n,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.addVolumePoints=function(e,t,i,n,r){var o=i||Td.Random;(isNaN(o)||o<0||o>3)&&(o=Td.Random);var a=e.getVerticesData(Qi.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var l=new xd(this._groupCounter,null);switch(l._groupDensity=this._calculateDensity(t,a,c),o===Td.Color?l._textureNb=n||0:n=n||new s.b(1,1,1,1),o){case Td.Color:this._colorFromTexture(e,l,!0);break;case Td.UV:this._setPointsColorOrUV(e,l,!0,!1,!1);break;case Td.Random:this._setPointsColorOrUV(e,l,!0);break;case Td.Stated:this._setPointsColorOrUV(e,l,!0,void 0,void 0,n,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},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||!this._isReady)return this;this.beforeUpdateParticles(e,t,i);var n=a.c.Matrix[0],r=this.mesh,o=this._colors32,s=this._positions32,c=this._uvs32,l=a.c.Vector3,u=l[5].copyFromFloats(1,0,0),h=l[6].copyFromFloats(0,1,0),d=l[7].copyFromFloats(0,0,1),f=l[8].setAll(Number.MAX_VALUE),p=l[9].setAll(-Number.MAX_VALUE);a.a.IdentityToRef(n);var _=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 m=this.mesh._boundingInfo;m&&(f.copyFrom(m.minimum),p.copyFrom(m.maximum))}_=0;for(var g=0,v=0,b=0,y=e;y<=t;y++){var T=this.particles[y];g=3*(_=T.idx),v=4*_,b=2*_,this.updateParticle(T);var E=T._rotationMatrix,S=T.position,A=T._globalPosition;if(this._computeParticleRotation&&T.getRotationMatrix(n),null!==T.parentId){var P=this.particles[T.parentId],C=P._rotationMatrix,R=P._globalPosition,x=S.x*C[1]+S.y*C[4]+S.z*C[7],O=S.x*C[0]+S.y*C[3]+S.z*C[6],M=S.x*C[2]+S.y*C[5]+S.z*C[8];if(A.x=R.x+O,A.y=R.y+x,A.z=R.z+M,this._computeParticleRotation){var I=n.m;E[0]=I[0]*C[0]+I[1]*C[3]+I[2]*C[6],E[1]=I[0]*C[1]+I[1]*C[4]+I[2]*C[7],E[2]=I[0]*C[2]+I[1]*C[5]+I[2]*C[8],E[3]=I[4]*C[0]+I[5]*C[3]+I[6]*C[6],E[4]=I[4]*C[1]+I[5]*C[4]+I[6]*C[7],E[5]=I[4]*C[2]+I[5]*C[5]+I[6]*C[8],E[6]=I[8]*C[0]+I[9]*C[3]+I[10]*C[6],E[7]=I[8]*C[1]+I[9]*C[4]+I[10]*C[7],E[8]=I[8]*C[2]+I[9]*C[5]+I[10]*C[8]}}else if(A.x=0,A.y=0,A.z=0,this._computeParticleRotation){I=n.m;E[0]=I[0],E[1]=I[1],E[2]=I[2],E[3]=I[4],E[4]=I[5],E[5]=I[6],E[6]=I[8],E[7]=I[9],E[8]=I[10]}var D=l[11];T.translateFromPivot?D.setAll(0):D.copyFrom(T.pivot);var N=l[0];N.copyFrom(T.position);var L=N.x-T.pivot.x,w=N.y-T.pivot.y,F=N.z-T.pivot.z,B=L*E[0]+w*E[3]+F*E[6],U=L*E[1]+w*E[4]+F*E[7],V=L*E[2]+w*E[5]+F*E[8];B+=D.x,U+=D.y,V+=D.z;var k=s[g]=A.x+u.x*B+h.x*U+d.x*V,z=s[g+1]=A.y+u.y*B+h.y*U+d.y*V,G=s[g+2]=A.z+u.z*B+h.z*U+d.z*V;if(this._computeBoundingBox&&(f.minimizeInPlaceFromFloats(k,z,G),p.maximizeInPlaceFromFloats(k,z,G)),this._computeParticleColor&&T.color){var j=T.color,W=this._colors32;W[v]=j.r,W[v+1]=j.g,W[v+2]=j.b,W[v+3]=j.a}if(this._computeParticleTexture&&T.uv){var H=T.uv,X=this._uvs32;X[b]=H.x,X[b+1]=H.y}}return i&&(this._computeParticleColor&&r.updateVerticesData(Qi.b.ColorKind,o,!1,!1),this._computeParticleTexture&&r.updateVerticesData(Qi.b.UVKind,c,!1,!1),r.updateVerticesData(Qi.b.PositionKind,s,!1,!1)),this._computeBoundingBox&&(r._boundingInfo?r._boundingInfo.reConstruct(f,p,r._worldMatrix):r._boundingInfo=new Tn.a(f,p,r._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._uvs32=null,this._colors32=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 Tn.a(new a.e(-t,-t,-t),new a.e(t,t,t))},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{set:function(e){this._computeParticleRotation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!1,configurable:!0}),e.prototype.initParticles=function(){},e.prototype.recycleParticle=function(e){return e},e.prototype.updateParticle=function(e){return e},e.prototype.beforeUpdateParticles=function(e,t,i){},e.prototype.afterUpdateParticles=function(e,t,i){},e}();Q.a.prototype.getPhysicsEngine=function(){return this._physicsEngine},Q.a.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var i=this._getComponent(Me.a.NAME_PHYSICSENGINE);i||(i=new Dd(this),this._addComponent(i));try{return this._physicsEngine=new pc(e,t),this._physicsTimeAccumulator=0,!0}catch(e){return m.a.Error(e.message),!1}},Q.a.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},Q.a.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},Q.a.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},Q.a.prototype._advancePhysicsEngineStep=function(e){if(this._physicsEngine){var t=this._physicsEngine.getSubTimeStep();if(t>0)for(this._physicsTimeAccumulator+=e;this._physicsTimeAccumulator>t;)this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(t/1e3),this.onAfterPhysicsObservable.notifyObservers(this),this._physicsTimeAccumulator-=t;else this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this)}},Object.defineProperty(Ge.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}),Ge.a.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},Ge.a.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},Ge.a.prototype.setPhysicsLinkWith=function(e,t,i,n){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,fc.e.HingeJoint,{mainPivot:t,connectedPivot:i,nativeParams:n}),this):this};var Md,Id,Dd=function(){function e(e){var t=this;this.name=Me.a.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new o.c,this.scene.onAfterPhysicsObservable=new o.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}(),Nd=function(){function e(e){this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||m.a.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return e.prototype.applyRadialExplosionImpulse=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var r=this._physicsEngine.getImpostors();if(0===r.length)return null;"number"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var o=new Ld(this._scene,t),a=Array();return r.forEach((function(t){var i=o.getImpostorHitData(t,e);i&&(t.applyImpulse(i.force,i.contactPoint),a.push({impostor:t,hitData:i}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.applyRadialExplosionForce=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var r=this._physicsEngine.getImpostors();if(0===r.length)return null;"number"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var o=new Ld(this._scene,t),a=Array();return r.forEach((function(t){var i=o.getImpostorHitData(t,e);i&&(t.applyForce(i.force,i.contactPoint),a.push({impostor:t,hitData:i}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.gravitationalField=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new Ud).radius=t,t.strength=i||t.strength,t.falloff=n||t.falloff);var r=new wd(this,this._scene,e,t);return r.dispose(!1),r},e.prototype.updraft=function(e,t,i,n,r){if(!this._physicsEngine)return m.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new Vd).radius=t,t.strength=i||t.strength,t.height=n||t.height,t.updraftMode=r||t.updraftMode);var o=new Fd(this._scene,e,t);return o.dispose(!1),o},e.prototype.vortex=function(e,t,i,n){if(!this._physicsEngine)return m.a.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;"number"==typeof t&&((t=new kd).radius=t,t.strength=i||t.strength,t.height=n||t.height);var r=new Bd(this._scene,e,t);return r.dispose(!1),r},e}(),Ld=function(){function e(e,t){this._scene=e,this._options=t,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Ud),this._options)}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.getImpostorHitData=function(e,t){if(0===e.mass)return null;if(!this._intersectsWithSphere(e,t,this._options.radius))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var i=e.getObjectCenter().subtract(t),n=new Xt.a(t,i,this._options.radius).intersectsMesh(e.object).pickedPoint;if(!n)return null;var r=a.e.Distance(t,n);if(r>this._options.radius)return null;var o=this._options.falloff===Md.Constant?this._options.strength:this._options.strength*(1-r/this._options.radius);return{force:i.multiplyByFloats(o,o,o),contactPoint:n,distanceFromOrigin:r}},e.prototype.triggerAffectedImpostorsCallback=function(e){this._options.affectedImpostorsCallback&&this._options.affectedImpostorsCallback(e)},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=xr.a.CreateSphere("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,i){var n=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new a.e(2*i,2*i,2*i),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(n,!0)},e}(),wd=function(){function e(e,t,i,n){this._physicsHelper=e,this._scene=t,this._origin=i,this._options=n,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Ud),this._options),this._tickCallback=this._tick.bind(this),this._options.strength=-1*this._options.strength}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._options);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._options);e&&(this._sphere=e.getData().sphere.clone("radialExplosionEventSphereClone"))}},e}(),Fd=function(){function e(e,t,i){this._scene=e,this._origin=t,this._options=i,this._originTop=a.e.Zero(),this._originDirection=a.e.Zero(),this._cylinderPosition=a.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(h.a)(Object(h.a)({},new Vd),this._options),this._origin.addToRef(new a.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new a.e(0,this._options.height,0),this._originTop),this._options.updraftMode===Id.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.getImpostorHitData=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;var t=e.getObjectCenter();if(this._options.updraftMode===Id.Perpendicular)var i=this._originDirection;else i=t.subtract(this._originTop);var n=a.e.Distance(this._origin,t),r=-1*this._options.strength;return{force:i.multiplyByFloats(r,r,r),contactPoint:t,distanceFromOrigin:n}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var i=e.getImpostorHitData(t);i&&t.applyForce(i.force,i.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=nn.a.CreateCylinder("updraftEventCylinder",{height:this._options.height,diameter:2*this._options.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}(),Bd=function(){function e(e,t,i){this._scene=e,this._origin=t,this._options=i,this._originTop=a.e.Zero(),this._cylinderPosition=a.e.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=Object(h.a)(Object(h.a)({},new kd),this._options),this._origin.addToRef(new a.e(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new a.e(0,this._options.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.getImpostorHitData=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 a.e(this._origin.x,t.y,this._origin.z),n=t.subtract(i),r=new Xt.a(i,n,this._options.radius).intersectsMesh(e.object),o=r.pickedPoint;if(!o)return null;var s=r.distance/this._options.radius,c=o.normalize();if(s>this._options.centripetalForceThreshold&&(c=c.negate()),s>this._options.centripetalForceThreshold)var l=c.x*this._options.centripetalForceMultiplier,u=c.y*this._options.updraftForceMultiplier,h=c.z*this._options.centripetalForceMultiplier;else{var d=a.e.Cross(i,t).normalize();l=(d.x+c.x)*this._options.centrifugalForceMultiplier,u=this._originTop.y*this._options.updraftForceMultiplier,h=(d.z+c.z)*this._options.centrifugalForceMultiplier}var f=new a.e(l,u,h);return{force:f=f.multiplyByFloats(this._options.strength,this._options.strength,this._options.strength),contactPoint:t,distanceFromOrigin:s}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var i=e.getImpostorHitData(t);i&&t.applyForce(i.force,i.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=nn.a.CreateCylinder("vortexEventCylinder",{height:this._options.height,diameter:2*this._options.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}(),Ud=function(){this.radius=5,this.strength=10,this.falloff=Md.Constant,this.sphere={segments:32,diameter:1}},Vd=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=Id.Center},kd=function(){this.radius=5,this.strength=10,this.height=10,this.centripetalForceThreshold=.7,this.centripetalForceMultiplier=5,this.centrifugalForceMultiplier=.5,this.updraftForceMultiplier=.02};!function(e){e[e.Constant=0]="Constant",e[e.Linear=1]="Linear"}(Md||(Md={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(Id||(Id={}));var zd="\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}";ai.a.ShadersStore.blackAndWhitePixelShader=zd;var Gd=function(e){function t(t,i,n,r,o,a){var s=e.call(this,t,"blackAndWhite",["degree"],null,i,n,r,o,a)||this;return s.degree=1,s.onApplyObservable.add((function(e){e.setFloat("degree",s.degree)})),s}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"BlackAndWhitePostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"degree",void 0),t}(li);c.a.RegisteredTypes["BABYLON.BlackAndWhitePostProcess"]=Gd;var jd=function(){function e(e,t,i,n){this._name=t,this._singleInstance=n||!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:!1,configurable:!0}),e.prototype._update=function(){},e.prototype._attachCameras=function(e){var t,i=this,n=Ce.b.MakeArray(e||this._cameras);if(n)for(var r=0;r<n.length;r++){var o=n[r];if(o){var a=o.name;if(t=this._singleInstance?0:a,!this._postProcesses[t]){var s=this._getPostProcesses();s&&(this._postProcesses[t]=Array.isArray(s)?s:[s])}this._indicesForCamera[a]||(this._indicesForCamera[a]=[]),this._postProcesses[t].forEach((function(e){var t=o.attachPostProcess(e);i._indicesForCamera[a].push(t)})),this._cameras[a]||(this._cameras[a]=o)}}},e.prototype._detachCameras=function(e){var t=Ce.b.MakeArray(e||this._cameras);if(t)for(var i=0;i<t.length;i++){var n=t[i],r=n.name,o=this._postProcesses[this._singleInstance?0:r];o&&o.forEach((function(e){n.detachPostProcess(e)})),this._cameras[r]&&(this._cameras[r]=null)}},e.prototype._enable=function(e){var t=this,i=Ce.b.MakeArray(e||this._cameras);if(i)for(var n=0;n<i.length;n++)for(var r=i[n],o=r.name,a=0;a<this._indicesForCamera[o].length;a++)void 0!==r._postProcesses[this._indicesForCamera[o][a]]&&null!==r._postProcesses[this._indicesForCamera[o][a]]||this._postProcesses[this._singleInstance?0:o].forEach((function(e){i[n].attachPostProcess(e,t._indicesForCamera[o][a])}))},e.prototype._disable=function(e){var t=Ce.b.MakeArray(e||this._cameras);if(t)for(var i=0;i<t.length;i++){var n=t[i],r=n.name;this._postProcesses[this._singleInstance?0:r].forEach((function(e){n.detachPostProcess(e)}))}},e.prototype.getPostProcesses=function(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null},e}(),Wd="#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}";ai.a.ShadersStore.extractHighlightsPixelShader=Wd;var Hd=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"extractHighlights",["threshold","exposure"],null,i,n,r,o,a,null,s,void 0,null,c)||this;return l.threshold=.9,l._exposure=1,l._inputPostProcess=null,l.onApplyObservable.add((function(e){l._inputPostProcess&&e.setTextureFromPostProcess("textureSampler",l._inputPostProcess),e.setFloat("threshold",Math.pow(l.threshold,Nt.b)),e.setFloat("exposure",l._exposure)})),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ExtractHighlightsPostProcess"},Object(h.c)([Object(w.c)()],t.prototype,"threshold",void 0),t}(li);c.a.RegisteredTypes["BABYLON.ExtractHighlightsPostProcess"]=Hd;var Xd="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";ai.a.ShadersStore.bloomMergePixelShader=Xd;var Yd=function(e){function t(t,i,n,r,o,a,s,c,l,u,h){void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=e.call(this,t,"bloomMerge",["bloomWeight"],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2","bloomBlur"],o,a,s,c,l,null,u,void 0,null,!0)||this;return d.weight=1,d.weight=r,d.onApplyObservable.add((function(e){e.setTextureFromPostProcess("textureSampler",i),e.setTextureFromPostProcessOutput("bloomBlur",n),e.setFloat("bloomWeight",d.weight)})),h||d.updateEffect(),d}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"BloomMergePostProcess"},Object(h.c)([Object(w.c)()],t.prototype,"weight",void 0),t}(li);c.a.RegisteredTypes["BABYLON.BloomMergePostProcess"]=Yd;var Kd=function(e){function t(t,i,n,r,o,s){void 0===o&&(o=0),void 0===s&&(s=!1);var c=e.call(this,t.getEngine(),"bloom",(function(){return c._effects}),!0)||this;return c.bloomScale=i,c._effects=[],c._downscale=new Hd("highlights",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,s),c._blurX=new eo("horizontal blur",new a.d(1,0),10,i,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,s),c._blurX.alwaysForcePOT=!0,c._blurX.autoClear=!1,c._blurY=new eo("vertical blur",new a.d(0,1),10,i,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,void 0,s),c._blurY.alwaysForcePOT=!0,c._blurY.autoClear=!1,c.kernel=r,c._effects=[c._downscale,c._blurX,c._blurY],c._merge=new Yd("bloomMerge",c._downscale,c._blurY,n,i,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,o,s),c._merge.autoClear=!1,c._effects.push(c._merge),c}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"threshold",{get:function(){return this._downscale.threshold},set:function(e){this._downscale.threshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"weight",{get:function(){return this._merge.weight},set:function(e){this._merge.weight=e},enumerable:!1,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:!1,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}(jd),Qd="\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}";ai.a.ShadersStore.chromaticAberrationPixelShader=Qd;var qd=function(e){function t(t,i,n,r,o,s,c,l,u,h){void 0===u&&(u=g.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"],[],r,o,s,c,l,null,u,void 0,null,h)||this;return d.aberrationAmount=30,d.radialIntensity=0,d.direction=new a.d(.707,.707),d.centerPosition=new a.d(.5,.5),d.screenWidth=i,d.screenHeight=n,d.onApplyObservable.add((function(e){e.setFloat("chromatic_aberration",d.aberrationAmount),e.setFloat("screen_width",i),e.setFloat("screen_height",n),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 Object(h.d)(t,e),t.prototype.getClassName=function(){return"ChromaticAberrationPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.screenWidth,e.screenHeight,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,!1)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"aberrationAmount",void 0),Object(h.c)([Object(w.c)()],t.prototype,"radialIntensity",void 0),Object(h.c)([Object(w.c)()],t.prototype,"direction",void 0),Object(h.c)([Object(w.c)()],t.prototype,"centerPosition",void 0),Object(h.c)([Object(w.c)()],t.prototype,"screenWidth",void 0),Object(h.c)([Object(w.c)()],t.prototype,"screenHeight",void 0),t}(li);c.a.RegisteredTypes["BABYLON.ChromaticAberrationPostProcess"]=qd;var Zd="\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";ai.a.ShadersStore.circleOfConfusionPixelShader=Zd;var Jd=function(e){function t(t,i,n,r,o,a,s,c,l){void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1);var u=e.call(this,t,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],n,r,o,a,s,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 m.a.Warn("No depth texture set on CircleOfConfusionPostProcess")})),u}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"CircleOfConfusionPostProcess"},Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._depthTexture=e},enumerable:!1,configurable:!0}),Object(h.c)([Object(w.c)()],t.prototype,"lensSize",void 0),Object(h.c)([Object(w.c)()],t.prototype,"fStop",void 0),Object(h.c)([Object(w.c)()],t.prototype,"focusDistance",void 0),Object(h.c)([Object(w.c)()],t.prototype,"focalLength",void 0),t}(li);c.a.RegisteredTypes["BABYLON.CircleOfConfusionPostProcess"]=Jd;var $d="\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}";ai.a.ShadersStore.colorCorrectionPixelShader=$d;var ef=function(e){function t(t,i,n,r,o,a,s){var c=e.call(this,t,"colorCorrection",null,["colorTable"],n,r,o,a,s)||this;return c._colorTableTexture=new Ke.a(i,r.getScene(),!0,!1,Ke.a.TRILINEAR_SAMPLINGMODE),c._colorTableTexture.anisotropicFilteringLevel=1,c._colorTableTexture.wrapU=Ke.a.CLAMP_ADDRESSMODE,c._colorTableTexture.wrapV=Ke.a.CLAMP_ADDRESSMODE,c.colorTableUrl=i,c.onApply=function(e){e.setTexture("colorTable",c._colorTableTexture)},c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ColorCorrectionPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.colorTableUrl,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"colorTableUrl",void 0),t}(li);c.a.RegisteredTypes["BABYLON.ColorCorrectionPostProcess"]=ef;var tf="\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}";ai.a.ShadersStore.convolutionPixelShader=tf;var nf=function(e){function t(t,i,n,r,o,a,s,c){void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,"convolution",["kernel","screenSize"],null,n,r,o,a,s,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 Object(h.d)(t,e),t.prototype.getClassName=function(){return"ConvolutionPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.kernel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType)}),e,n,r)},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],Object(h.c)([Object(w.c)()],t.prototype,"kernel",void 0),t}(li);c.a.RegisteredTypes["BABYLON.ConvolutionPostProcess"]=nf;var rf=function(e){function t(t,i,n,r,o,a,s,c,l,u,h,d,f){void 0===c&&(c=null),void 0===l&&(l=Ke.a.BILINEAR_SAMPLINGMODE),void 0===d&&(d=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===f&&(f=!1);var p=e.call(this,t,n,r,o,a,l=g.a.TEXTURE_BILINEAR_SAMPLINGMODE,u,h,d=g.a.TEXTURETYPE_UNSIGNED_INT,"#define DOF 1\r\n",f)||this;return p.direction=n,p.onApplyObservable.add((function(e){null!=c&&e.setTextureFromPostProcess("textureSampler",c),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",s),i.activeCamera&&e.setFloat2("cameraMinMaxZ",i.activeCamera.minZ,i.activeCamera.maxZ)})),p}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DepthOfFieldBlurPostProcess"},Object(h.c)([Object(w.c)()],t.prototype,"direction",void 0),t}(eo);c.a.RegisteredTypes["BABYLON.DepthOfFieldBlurPostProcess"]=rf;var of="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";ai.a.ShadersStore.depthOfFieldMergePixelShader=of;var af,sf=function(){},cf=function(e){function t(t,i,n,r,o,a,s,c,l,u,h){void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var d=e.call(this,t,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],o,a,s,c,l,null,u,void 0,null,!0)||this;return d.blurSteps=r,d.onApplyObservable.add((function(e){e.setTextureFromPostProcess("textureSampler",i),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",n),r.forEach((function(t,i){e.setTextureFromPostProcessOutput("blurStep"+(r.length-i-1),t)}))})),h||d.updateEffect(),d}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DepthOfFieldMergePostProcess"},t.prototype.updateEffect=function(t,i,n,r,o,a){void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),t||(t="",t+="#define BLUR_LEVEL "+(this.blurSteps.length-1)+"\n"),e.prototype.updateEffect.call(this,t,i,n,r,o,a)},t}(li);!function(e){e[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High"}(af||(af={}));var lf=function(e){function t(t,i,n,r,o){void 0===n&&(n=af.Low),void 0===r&&(r=0),void 0===o&&(o=!1);var s=e.call(this,t.getEngine(),"depth of field",(function(){return s._effects}),!0)||this;s._effects=[],s._circleOfConfusion=new Jd("circleOfConfusion",i,1,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o),s._depthOfFieldBlurY=[],s._depthOfFieldBlurX=[];var c=1,l=15;switch(n){case af.High:c=3,l=51;break;case af.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 rf("verticle blur",t,new a.d(0,1),u,h,null,s._circleOfConfusion,0==d?s._circleOfConfusion:null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o);f.autoClear=!1,h=.75/Math.pow(2,d);var p=new rf("horizontal blur",t,new a.d(1,0),u,h,null,s._circleOfConfusion,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o);p.autoClear=!1,s._depthOfFieldBlurY.push(f),s._depthOfFieldBlurX.push(p)}s._effects=[s._circleOfConfusion];for(d=0;d<s._depthOfFieldBlurX.length;d++)s._effects.push(s._depthOfFieldBlurY[d]),s._effects.push(s._depthOfFieldBlurX[d]);return s._dofMerge=new cf("dofMerge",s._circleOfConfusion,s._circleOfConfusion,s._depthOfFieldBlurX,h,null,Ke.a.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,r,o),s._dofMerge.autoClear=!1,s._effects.push(s._dofMerge),s}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"focalLength",{get:function(){return this._circleOfConfusion.focalLength},set:function(e){this._circleOfConfusion.focalLength=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fStop",{get:function(){return this._circleOfConfusion.fStop},set:function(e){this._circleOfConfusion.fStop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"focusDistance",{get:function(){return this._circleOfConfusion.focusDistance},set:function(e){this._circleOfConfusion.focusDistance=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"lensSize",{get:function(){return this._circleOfConfusion.lensSize},set:function(e){this._circleOfConfusion.lensSize=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DepthOfFieldEffect"},Object.defineProperty(t.prototype,"depthTexture",{set:function(e){this._circleOfConfusion.depthTexture=e},enumerable:!1,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}(jd),uf="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";ai.a.ShadersStore.displayPassPixelShader=uf;var hf=function(e){function t(t,i,n,r,o,a){return e.call(this,t,"displayPass",["passSampler"],["passSampler"],i,n,r,o,a)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"DisplayPassPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);c.a.RegisteredTypes["BABYLON.DisplayPassPostProcess"]=hf;var df="\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}";ai.a.ShadersStore.filterPixelShader=df;var ff=function(e){function t(t,i,n,r,o,a,s){var c=e.call(this,t,"filter",["kernelMatrix"],null,n,r,o,a,s)||this;return c.kernelMatrix=i,c.onApply=function(e){e.setMatrix("kernelMatrix",c.kernelMatrix)},c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"FilterPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.kernelMatrix,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.j)()],t.prototype,"kernelMatrix",void 0),t}(li);c.a.RegisteredTypes["BABYLON.FilterPostProcess"]=ff;var pf="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}";ai.a.ShadersStore.fxaaPixelShader=pf;var _f="\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}";ai.a.ShadersStore.fxaaVertexShader=_f;var mf=function(e){function t(t,i,n,r,o,a,s){void 0===n&&(n=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT);var c=e.call(this,t,"fxaa",["texelSize"],null,i,n,r||Ke.a.BILINEAR_SAMPLINGMODE,o,a,null,s,"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 Object(h.d)(t,e),t.prototype.getClassName=function(){return"FxaaPostProcess"},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._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},t}(li);c.a.RegisteredTypes["BABYLON.FxaaPostProcess"]=mf;var gf="#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}";ai.a.ShadersStore.grainPixelShader=gf;var vf=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"grain",["intensity","animatedSeed"],[],i,n,r,o,a,null,s,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 Object(h.d)(t,e),t.prototype.getClassName=function(){return"GrainPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"intensity",void 0),Object(h.c)([Object(w.c)()],t.prototype,"animated",void 0),t}(li);c.a.RegisteredTypes["BABYLON.GrainPostProcess"]=vf;var bf="\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}";ai.a.ShadersStore.highlightsPixelShader=bf;var yf=function(e){function t(t,i,n,r,o,a,s){return void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,"highlights",null,null,i,n,r,o,a,null,s)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"HighlightsPostProcess"},t}(li);ai.a.IncludesShadersStore.mrtFragmentDeclaration="#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";var Tf="#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\nprecision highp int;\n#ifdef BUMP\nvarying mat4 vWorldView;\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef NEED_UV\nvarying vec2 vUV;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef REFLECTIVITY\nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef ALPHATEST\nuniform sampler2D diffuseSampler;\n#endif\n#include<mrtFragmentDeclaration>[RENDER_TARGET_COUNT]\n#include<bumpFragmentMainFunctions>\n#include<bumpFragmentFunctions>\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nvec3 normalOutput;\n#ifdef BUMP\nvec3 normalW=normalize(vNormalW);\n#include<bumpFragment>\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#else\nnormalOutput=normalize(vNormalV);\n#endif\n#ifdef PREPASS\n#ifdef PREPASS_DEPTHNORMAL\ngl_FragData[DEPTHNORMAL_INDEX]=vec4(vViewPos.z/vViewPos.w,normalOutput);\n#endif\n#else\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\ngl_FragData[1]=vec4(normalOutput,1.0);\n#endif\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPositionW,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=abs(a-b);\nvelocity=vec2(pow(velocity.x,1.0/3.0),pow(velocity.y,1.0/3.0))*sign(a-b)*0.5+0.5;\ngl_FragData[VELOCITY_INDEX]=vec4(velocity,0.0,1.0);\n#endif\n#ifdef REFLECTIVITY\n#ifdef HAS_SPECULAR\n\nvec4 reflectivity=texture2D(reflectivitySampler,vReflectivityUV);\n#elif HAS_REFLECTIVITY\n\nvec4 reflectivity=vec4(texture2D(reflectivitySampler,vReflectivityUV).rgb,1.0);\n#else\nvec4 reflectivity=vec4(0.0,0.0,0.0,1.0);\n#endif\ngl_FragData[REFLECTIVITY_INDEX]=reflectivity;\n#endif\n}";ai.a.ShadersStore.geometryPixelShader=Tf;var Ef="precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#include<instancesDeclaration>\nattribute vec3 position;\nattribute vec3 normal;\n#ifdef NEED_UV\nvarying vec2 vUV;\n#ifdef ALPHATEST\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef BUMP\nuniform mat4 bumpMatrix;\nvarying vec2 vBumpUV;\n#endif\n#ifdef REFLECTIVITY\nuniform mat4 reflectivityMatrix;\nvarying vec2 vReflectivityUV;\n#endif\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;\n#ifdef BUMP\nvarying mat4 vWorldView;\n#endif\n#ifdef BUMP\nvarying vec3 vNormalW;\n#else\nvarying vec3 vNormalV;\n#endif\nvarying vec4 vViewPos;\n#if defined(POSITION) || defined(BUMP)\nvarying vec3 vPositionW;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorld;\nuniform mat4 previousViewProjection;\n#ifdef BONES_VELOCITY_ENABLED\n#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(positionUpdated,1.0));\n#ifdef BUMP\nvWorldView=view*finalWorld;\nvNormalW=normalUpdated;\n#else\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normalUpdated,0.0)));\n#endif\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif\n#if defined(POSITION) || defined(BUMP)\nvPositionW=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#ifdef NEED_UV\n#ifdef UV1\n#ifdef ALPHATEST\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uv;\n#endif\n#ifdef BUMP\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#ifdef ALPHATEST\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#else\nvUV=uv2;\n#endif\n#ifdef BUMP\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#endif\n#include<bumpVertex>\n}\n";ai.a.ShadersStore.geometryVertexShader=Ef;var Sf=function(){function e(t,i){void 0===i&&(i=1),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this.renderTransparentMeshes=!0,this._resizeObserver=null,this._enablePosition=!1,this._enableVelocity=!1,this._enableReflectivity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._reflectivityIndex=-1,this._depthNormalIndex=-1,this._linkedWithPrePass=!1,this._scene=t,this._ratio=i,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return e.prototype._linkPrePassRenderer=function(e){this._linkedWithPrePass=!0,this._prePassRenderer=e,this._multiRenderTarget&&(this._multiRenderTarget.onClearObservable.clear(),this._multiRenderTarget.onClearObservable.add((function(e){})))},e.prototype._unlinkPrePassRenderer=function(){this._linkedWithPrePass=!1,this._createRenderTargets()},e.prototype._resetLayout=function(){this._enablePosition=!1,this._enableReflectivity=!1,this._enableVelocity=!1,this._attachments=[]},e.prototype._forceTextureType=function(t,i){t===e.POSITION_TEXTURE_TYPE?(this._positionIndex=i,this._enablePosition=!0):t===e.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=i,this._enableVelocity=!0):t===e.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=i,this._enableReflectivity=!0):t===e.DEPTHNORMAL_TEXTURE_TYPE&&(this._depthNormalIndex=i)},e.prototype._setAttachments=function(e){this._attachments=e},e.prototype._linkInternalTexture=function(e){this._multiRenderTarget._texture=e},Object.defineProperty(e.prototype,"renderList",{get:function(){return this._multiRenderTarget.renderList},set:function(e){this._multiRenderTarget.renderList=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!1,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;case e.REFLECTIVITY_TEXTURE_TYPE:return this._reflectivityIndex;default:return-1}},Object.defineProperty(e.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enableReflectivity",{get:function(){return this._enableReflectivity},set:function(e){this._enableReflectivity=e,this._linkedWithPrePass||(this.dispose(),this._createRenderTargets())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return this._ratio},enumerable:!1,configurable:!0}),e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;var n=[],r=[Qi.b.PositionKind,Qi.b.NormalKind],o=e.getMesh();if(i){var a=!1;i.needAlphaTesting()&&(n.push("#define ALPHATEST"),a=!0),i.bumpTexture&&Wi.a.BumpTextureEnabled&&(n.push("#define BUMP"),n.push("#define BUMPDIRECTUV 0"),a=!0),this._enableReflectivity&&(i instanceof Wi.a&&i.specularTexture?(n.push("#define HAS_SPECULAR"),a=!0):i instanceof ma&&i.reflectivityTexture&&(n.push("#define HAS_REFLECTIVITY"),a=!0)),a&&(n.push("#define NEED_UV"),o.isVerticesDataPresent(Qi.b.UVKind)&&(r.push(Qi.b.UVKind),n.push("#define UV1")),o.isVerticesDataPresent(Qi.b.UV2Kind)&&(r.push(Qi.b.UV2Kind),n.push("#define UV2")))}this._linkedWithPrePass&&(n.push("#define PREPASS"),-1!==this._depthNormalIndex&&(n.push("#define DEPTHNORMAL_INDEX "+this._depthNormalIndex),n.push("#define PREPASS_DEPTHNORMAL"))),this._enablePosition&&(n.push("#define POSITION"),n.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(n.push("#define VELOCITY"),n.push("#define VELOCITY_INDEX "+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(o)&&n.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(n.push("#define REFLECTIVITY"),n.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),o.useBones&&o.computeBonesUsingShaders?(r.push(Qi.b.MatricesIndicesKind),r.push(Qi.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(r.push(Qi.b.MatricesIndicesExtraKind),r.push(Qi.b.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),n.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var s=o.morphTargetManager,c=0;s&&s.numInfluencers>0&&(c=s.numInfluencers,n.push("#define MORPHTARGETS"),n.push("#define NUM_MORPH_INFLUENCERS "+c),ro.a.PrepareAttributesForMorphTargetsInfluencers(r,o,c)),t&&(n.push("#define INSTANCES"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push("#define THIN_INSTANCES")),this._linkedWithPrePass?n.push("#define RENDER_TARGET_COUNT "+this._attachments.length):n.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var l=n.join("\n");return this._cachedDefines!==l&&(this._cachedDefines=l,this._effect=this._scene.getEngine().createEffect("geometry",r,["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","morphTargetInfluences","bumpMatrix","reflectivityMatrix","vTangentSpaceParams","vBumpInfos"],["diffuseSampler","bumpSampler","reflectivitySampler"],l,void 0,void 0,void 0,{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:c})),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:!1,configurable:!0}),e.prototype.dispose=function(){this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null);this.getGBuffer().dispose()},e.prototype._assignRenderTargetIndices=function(){var e=2;return this._enablePosition&&(this._positionIndex=e,e++),this._enableVelocity&&(this._velocityIndex=e,e++),this._enableReflectivity&&(this._reflectivityIndex=e,e++),e},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),i=this._assignRenderTargetIndices();if(this._multiRenderTarget=new Hc("gBuffer",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},i,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:g.a.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(e){e.clear(new s.b(0,0,0,1),!0,!0,!0)})),this._resizeObserver=t.onResizeObservable.add((function(){e._multiRenderTarget&&e._multiRenderTarget.resize({width:t.getRenderWidth()*e._ratio,height:t.getRenderHeight()*e._ratio})}));var n=function(t){var i=t.getRenderingMesh(),n=t.getEffectiveMesh(),r=e._scene,o=r.getEngine(),s=t.getMaterial();if(s){if(n._internalAbstractMeshDataInfo._isActiveIntermediate=!1,e._enableVelocity&&!e._previousTransformationMatrices[n.uniqueId]&&(e._previousTransformationMatrices[n.uniqueId]={world:a.a.Identity(),viewProjection:r.getTransformMatrix()},i.skeleton)){var c=i.skeleton.getTransformMatrices(i);e._previousBonesTransformationMatrices[i.uniqueId]=e._copyBonesTransformationMatrices(c,new Float32Array(c.length))}var l=i._getInstancesRenderList(t._id,!!t.getReplacementMesh());if(!l.mustReturn){var u=o.getCaps().instancedArrays&&(null!==l.visibleInstances[t._id]||i.hasThinInstances),h=n.getWorldMatrix();if(e.isReady(t,u)){if(o.enableEffect(e._effect),i._bind(t,e._effect,s.fillMode),e._effect.setMatrix("viewProjection",r.getTransformMatrix()),e._effect.setMatrix("view",r.getViewMatrix()),s){var d,f=n._instanceDataStorage;if(f.isFrozen||!s.backFaceCulling&&null===s.overrideMaterialSideOrientation)d=f.sideOrientation;else{var p=n._getWorldMatrixDeterminant();null==(d=s.overrideMaterialSideOrientation)&&(d=s.sideOrientation),p<0&&(d=d===xo.a.ClockWiseSideOrientation?xo.a.CounterClockWiseSideOrientation:xo.a.ClockWiseSideOrientation)}if(s._preBind(e._effect,d),s.needAlphaTesting()){var _=s.getAlphaTestTexture();_&&(e._effect.setTexture("diffuseSampler",_),e._effect.setMatrix("diffuseMatrix",_.getTextureMatrix()))}s.bumpTexture&&r.getEngine().getCaps().standardDerivatives&&Wi.a.BumpTextureEnabled&&(e._effect.setFloat3("vBumpInfos",s.bumpTexture.coordinatesIndex,1/s.bumpTexture.level,s.parallaxScaleBias),e._effect.setMatrix("bumpMatrix",s.bumpTexture.getTextureMatrix()),e._effect.setTexture("bumpSampler",s.bumpTexture),e._effect.setFloat2("vTangentSpaceParams",s.invertNormalMapX?-1:1,s.invertNormalMapY?-1:1)),e._enableReflectivity&&(s instanceof Wi.a&&s.specularTexture?(e._effect.setMatrix("reflectivityMatrix",s.specularTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",s.specularTexture)):s instanceof ma&&s.reflectivityTexture&&(e._effect.setMatrix("reflectivityMatrix",s.reflectivityTexture.getTextureMatrix()),e._effect.setTexture("reflectivitySampler",s.reflectivityTexture)))}i.useBones&&i.computeBonesUsingShaders&&i.skeleton&&(e._effect.setMatrices("mBones",i.skeleton.getTransformMatrices(i)),e._enableVelocity&&e._effect.setMatrices("mPreviousBones",e._previousBonesTransformationMatrices[i.uniqueId])),ro.a.BindMorphTargetParameters(i,e._effect),e._enableVelocity&&(e._effect.setMatrix("previousWorld",e._previousTransformationMatrices[n.uniqueId].world),e._effect.setMatrix("previousViewProjection",e._previousTransformationMatrices[n.uniqueId].viewProjection)),i._processRendering(n,t,e._effect,s.fillMode,l,u,(function(t,i){return e._effect.setMatrix("world",i)}))}e._enableVelocity&&(e._previousTransformationMatrices[n.uniqueId].world=h.clone(),e._previousTransformationMatrices[n.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),i.skeleton&&e._copyBonesTransformationMatrices(i.skeleton.getTransformMatrices(i),e._previousBonesTransformationMatrices[n.uniqueId]))}}};this._multiRenderTarget.customRenderFunction=function(i,r,o,a){var s;if(e._linkedWithPrePass){if(!e._prePassRenderer.enabled)return;e._scene.getEngine().bindAttachments(e._attachments)}if(a.length){for(t.setColorWrite(!1),s=0;s<a.length;s++)n(a.data[s]);t.setColorWrite(!0)}for(s=0;s<i.length;s++)n(i.data[s]);for(s=0;s<r.length;s++)n(r.data[s]);if(e.renderTransparentMeshes)for(s=0;s<o.length;s++)n(o.data[s])}}},e.prototype._copyBonesTransformationMatrices=function(e,t){for(var i=0;i<e.length;i++)t[i]=e[i];return t},e.DEPTHNORMAL_TEXTURE_TYPE=0,e.POSITION_TEXTURE_TYPE=1,e.VELOCITY_TEXTURE_TYPE=2,e.REFLECTIVITY_TEXTURE_TYPE=3,e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("GeometryBufferRendererSceneComponent")},e}(),Af=function(){this.enabled=!1,this.name="motionBlur",this.texturesRequired=[g.a.PREPASS_VELOCITY_TEXTURE_TYPE]};Object.defineProperty(Q.a.prototype,"geometryBufferRenderer",{get:function(){this._geometryBufferRenderer},set:function(e){e&&e.isSupported&&(this._geometryBufferRenderer=e)},enumerable:!0,configurable:!0}),Q.a.prototype.enableGeometryBufferRenderer=function(e){return void 0===e&&(e=1),this._geometryBufferRenderer||(this._geometryBufferRenderer=new Sf(this,e),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null)),this._geometryBufferRenderer},Q.a.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};var Pf=function(){function e(e){this.name=Me.a.NAME_GEOMETRYBUFFERRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Me.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}();Sf._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_GEOMETRYBUFFERRENDERER);t||(t=new Pf(e),e._addComponent(t))};var Cf="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float motionStrength;\nuniform float motionScale;\nuniform vec2 screenSize;\n#ifdef OBJECT_BASED\nuniform sampler2D velocitySampler;\n#else\nuniform sampler2D depthSampler;\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\n#endif\nvoid main(void)\n{\n#ifdef GEOMETRY_SUPPORTED\n#ifdef OBJECT_BASED\nvec2 texelSize=1.0/screenSize;\nvec2 velocityColor=texture2D(velocitySampler,vUV).rg*2.0-1.0;\nvec2 velocity=vec2(pow(velocityColor.r,3.0),pow(velocityColor.g,3.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);\ngl_FragColor.a=1.0;\n#else\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,SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(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#endif\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";ai.a.ShadersStore.motionBlurPixelShader=Cf;var Rf=function(e){function t(t,i,n,r,o,a,s,c,l,u){void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===u&&(u=!0);var h=e.call(this,t,"motionBlur",["motionStrength","motionScale","screenSize","inverseViewProjection","prevViewProjection"],["velocitySampler"],n,r,o,a,s,"#define GEOMETRY_SUPPORTED\n#define SAMPLES 64.0\n#define OBJECT_BASED",c,void 0,null,l)||this;return h.motionStrength=1,h._motionBlurSamples=32,h._isObjectBased=!0,h._forceGeometryBuffer=!1,h._geometryBufferRenderer=null,h._prePassRenderer=null,h._invViewProjection=null,h._previousViewProjection=null,h._forceGeometryBuffer=u,h._forceGeometryBuffer?(h._geometryBufferRenderer=i.enableGeometryBufferRenderer(),h._geometryBufferRenderer&&(h._geometryBufferRenderer.enableVelocity=!0)):(h._prePassRenderer=i.enablePrePassRenderer(),h._prePassRenderer&&(h._prePassRenderer.markAsDirty(),h._prePassEffectConfiguration=new Af)),h._applyMode(),h}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this._motionBlurSamples=e,this._updateEffect()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isObjectBased",{get:function(){return this._isObjectBased},set:function(e){this._isObjectBased!==e&&(this._isObjectBased=e,this._applyMode())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"MotionBlurPostProcess"},t.prototype.excludeSkinnedMesh=function(e){if(e.skeleton){var t=void 0;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;t=this._prePassRenderer.excludedSkinnedMesh}t.push(e)}},t.prototype.removeExcludedSkinnedMesh=function(e){if(e.skeleton){var t=void 0;if(this._geometryBufferRenderer)t=this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity;else{if(!this._prePassRenderer)return;t=this._prePassRenderer.excludedSkinnedMesh}var i=t.indexOf(e);-1!==i&&t.splice(i,1)}},t.prototype.dispose=function(t){this._geometryBufferRenderer&&(this._geometryBufferRenderer._previousTransformationMatrices={},this._geometryBufferRenderer._previousBonesTransformationMatrices={},this._geometryBufferRenderer.excludedSkinnedMeshesFromVelocity=[]),e.prototype.dispose.call(this,t)},t.prototype._applyMode=function(){var e=this;if(!this._geometryBufferRenderer&&!this._prePassRenderer)return m.a.Warn("Multiple Render Target support needed to compute object based motion blur"),this.updateEffect();this._updateEffect(),this._invViewProjection=null,this._previousViewProjection=null,this.isObjectBased?(this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=g.a.PREPASS_VELOCITY_TEXTURE_TYPE),this.onApply=function(t){return e._onApplyObjectBased(t)}):(this._invViewProjection=a.a.Identity(),this._previousViewProjection=a.a.Identity(),this._prePassRenderer&&this._prePassEffectConfiguration&&(this._prePassEffectConfiguration.texturesRequired[0]=g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE),this.onApply=function(t){return e._onApplyScreenBased(t)})},t.prototype._onApplyObjectBased=function(e){if(e.setVector2("screenSize",new a.d(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){var t=this._geometryBufferRenderer.getTextureIndex(Sf.VELOCITY_TEXTURE_TYPE);e.setTexture("velocitySampler",this._geometryBufferRenderer.getGBuffer().textures[t])}else if(this._prePassRenderer){t=this._prePassRenderer.getIndex(g.a.PREPASS_VELOCITY_TEXTURE_TYPE);e.setTexture("velocitySampler",this._prePassRenderer.prePassRT.textures[t])}},t.prototype._onApplyScreenBased=function(e){var t=this._scene.getProjectionMatrix().multiply(this._scene.getViewMatrix());if(t.invertToRef(this._invViewProjection),e.setMatrix("inverseViewProjection",this._invViewProjection),e.setMatrix("prevViewProjection",this._previousViewProjection),this._previousViewProjection=t,e.setVector2("screenSize",new a.d(this.width,this.height)),e.setFloat("motionScale",this._scene.getAnimationRatio()),e.setFloat("motionStrength",this.motionStrength),this._geometryBufferRenderer){var i=this._geometryBufferRenderer.getTextureIndex(Sf.DEPTHNORMAL_TEXTURE_TYPE);e.setTexture("depthSampler",this._geometryBufferRenderer.getGBuffer().textures[i])}else if(this._prePassRenderer){i=this._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE);e.setTexture("depthSampler",this._prePassRenderer.prePassRT.textures[i])}},t.prototype._updateEffect=function(){if(this._geometryBufferRenderer||this._prePassRenderer){var e=["#define GEOMETRY_SUPPORTED","#define SAMPLES "+this._motionBlurSamples.toFixed(1),this._isObjectBased?"#define OBJECT_BASED":"#define SCREEN_BASED"];this.updateEffect(e.join("\n"))}},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable,e.textureType,!1)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"motionStrength",void 0),Object(h.c)([Object(w.c)()],t.prototype,"motionBlurSamples",null),Object(h.c)([Object(w.c)()],t.prototype,"isObjectBased",null),t}(li);c.a.RegisteredTypes["BABYLON.MotionBlurPostProcess"]=Rf;var xf="\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}";ai.a.ShadersStore.refractionPixelShader=xf;var Of=function(e){function t(t,i,n,r,o,a,s,c,l,u){var h=e.call(this,t,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],a,s,c,l,u)||this;return h._ownRefractionTexture=!0,h.color=n,h.depth=r,h.colorLevel=o,h.refractionTextureUrl=i,h.onActivateObservable.add((function(e){h._refTexture=h._refTexture||new Ke.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 Object(h.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:!1,configurable:!0}),t.prototype.getClassName=function(){return"RefractionPostProcess"},t.prototype.dispose=function(t){this._refTexture&&this._ownRefractionTexture&&(this._refTexture.dispose(),this._refTexture=null),e.prototype.dispose.call(this,t)},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.refractionTextureUrl,e.color,e.depth,e.colorLevel,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"color",void 0),Object(h.c)([Object(w.c)()],t.prototype,"depth",void 0),Object(h.c)([Object(w.c)()],t.prototype,"colorLevel",void 0),Object(h.c)([Object(w.c)()],t.prototype,"refractionTextureUrl",void 0),t}(li);c.a.RegisteredTypes["BABYLON.RefractionPostProcess"]=Of;var Mf="\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}";ai.a.ShadersStore.sharpenPixelShader=Mf;var If=function(e){function t(t,i,n,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"sharpen",["sharpnessAmounts","screenSize"],null,i,n,r,o,a,null,s,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 Object(h.d)(t,e),t.prototype.getClassName=function(){return"SharpenPostProcess"},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"colorAmount",void 0),Object(h.c)([Object(w.c)()],t.prototype,"edgeAmount",void 0),t}(li);c.a.RegisteredTypes["BABYLON.SharpenPostProcess"]=If;var Df=function(){function e(e,t){this.engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return Object.defineProperty(e.prototype,"name",{get:function(){return this._name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cameras",{get:function(){return this._cameras},enumerable:!1,configurable:!0}),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:!1,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(Ce.b.MakeArray(t||this._cameras))},e.prototype._disableEffect=function(e,t){var i=this._renderEffects[e];i&&i._disable(Ce.b.MakeArray(t||this._cameras))},e.prototype._attachCameras=function(e,t){var i=Ce.b.MakeArray(e||this._cameras);if(i){var n,r=[];for(n=0;n<i.length;n++){var o=i[n];if(o){var a=o.name;-1===this._cameras.indexOf(o)?this._cameras[a]=o:t&&r.push(n)}}for(n=0;n<r.length;n++)e.splice(r[n],1);for(var s in this._renderEffects)this._renderEffects.hasOwnProperty(s)&&this._renderEffects[s]._attachCameras(i)}},e.prototype._detachCameras=function(e){var t=Ce.b.MakeArray(e||this._cameras);if(t){for(var i in this._renderEffects)this._renderEffects.hasOwnProperty(i)&&this._renderEffects[i]._detachCameras(t);for(var n=0;n<t.length;n++)this._cameras.splice(this._cameras.indexOf(t[n]),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++)if(this._cameras[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){if(1===this.engine.webGLVersion)return!1;var t=Object.keys(this._renderEffects);if(t.length>0){var i=this._renderEffects[t[0]].getPostProcesses();i&&(i[0].samples=e)}return!0},e.prototype.setPrePassRenderer=function(e){return!1},e.prototype.dispose=function(){},Object(h.c)([Object(w.c)()],e.prototype,"_name",void 0),e}(),Nf=function(){function e(){this._renderPipelines={}}return Object.defineProperty(e.prototype,"supportedPipelines",{get:function(){var e=[];for(var t in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(t)){var i=this._renderPipelines[t];i.isSupported&&e.push(i)}return e},enumerable:!1,configurable:!0}),e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){void 0===i&&(i=!1);var n=this._renderPipelines[e];n&&n._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 n=this._renderPipelines[e];n&&n._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var n=this._renderPipelines[e];n&&n._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(Q.a.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(Me.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new Lf(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new Nf}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var Lf=function(){function e(e){this.name=Me.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Me.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}(),wf=function(e){function t(t,i,n,r,a){void 0===t&&(t=""),void 0===i&&(i=!0),void 0===n&&(n=x.a.LastCreatedScene),void 0===a&&(a=!0);var s=e.call(this,n.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=af.Low,s._fxaaEnabled=!1,s._imageProcessingEnabled=!0,s._bloomScale=.5,s._chromaticAberrationEnabled=!1,s._grainEnabled=!1,s._buildAllowed=!0,s.onBuildObservable=new o.c,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=r||n.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._buildAllowed=a,s._scene=n;var c=s._scene.getEngine().getCaps();s._hdr=i&&(c.textureHalfFloatRender||c.textureFloatRender),s._hdr?c.textureHalfFloatRender?s._defaultPipelineTextureType=g.a.TEXTURETYPE_HALF_FLOAT:c.textureFloatRender&&(s._defaultPipelineTextureType=g.a.TEXTURETYPE_FLOAT):s._defaultPipelineTextureType=g.a.TEXTURETYPE_UNSIGNED_INT,n.postProcessRenderPipelineManager.addPipeline(s);var l=s._scene.getEngine();return s.sharpen=new If("sharpen",1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._sharpenEffect=new jd(l,s.SharpenPostProcessId,(function(){return s.sharpen}),!0),s.depthOfField=new lf(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s.bloom=new Kd(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new qd("ChromaticAberration",l.getRenderWidth(),l.getRenderHeight(),1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._chromaticAberrationEffect=new jd(l,s.ChromaticAberrationPostProcessId,(function(){return s.chromaticAberration}),!0),s.grain=new vf("Grain",1,null,Ke.a.BILINEAR_SAMPLINGMODE,l,!1,s._defaultPipelineTextureType,!0),s._grainEffect=new jd(l,s.GrainPostProcessId,(function(){return s.grain}),!0),s._resizeObserver=l.onResizeObservable.add((function(){s._hardwareScaleLevel=l.getHardwareScalingLevel(),s.bloomKernel=s.bloomKernel})),s._imageProcessingConfigurationObserver=s._scene.imageProcessingConfiguration.onUpdateParameters.add((function(){s.bloom._downscale._exposure=s._scene.imageProcessingConfiguration.exposure,s.imageProcessingEnabled!==s._scene.imageProcessingConfiguration.isEnabled&&(s._imageProcessingEnabled=s._scene.imageProcessingConfiguration.isEnabled,s._buildPipeline())})),s._buildPipeline(),s}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!1,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:!1,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:!1,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:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Kd(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:!1,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 lf(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:!1,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingEnabled",{get:function(){return this._imageProcessingEnabled},set:function(e){this._imageProcessingEnabled!==e&&(this._scene.imageProcessingConfiguration.isEnabled=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glowLayerEnabled",{get:function(){return null!=this._glowLayer},set:function(e){e&&!this._glowLayer?this._glowLayer=new ds("",this._scene):!e&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"glowLayer",{get:function(){return this._glowLayer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chromaticAberrationEnabled",{get:function(){return this._chromaticAberrationEnabled},set:function(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"grainEnabled",{get:function(){return this._grainEnabled},set:function(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DefaultRenderingPipeline"},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,n=this._cameras;i<n.length;i++){var r=n[i];(o=this._scene.enableDepthRenderer(r)).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 Yi("imageProcessing",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new jd(t,this.ImageProcessingPostProcessId,(function(){return e.imageProcessing}),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1,this.cameras&&0!==this.cameras.length||(this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.imageProcessing.getEffect()||this.imageProcessing._updateParameters()),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 mf("fxaa",1,null,Ke.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new jd(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._scene.activeCameras&&this._scene.activeCameras.length>1&&(this._scene.autoClear=!0),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&m.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0"),this.onBuildObservable.notifyObservers(this)}},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.onBuildObservable.clear(),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,n){return w.a.Parse((function(){return new t(e._name,e._name._hdr,i)}),e,i,n)},Object(h.c)([Object(w.c)()],t.prototype,"sharpenEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"bloomKernel",null),Object(h.c)([Object(w.c)()],t.prototype,"_bloomWeight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_bloomThreshold",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_hdr",void 0),Object(h.c)([Object(w.c)()],t.prototype,"bloomWeight",null),Object(h.c)([Object(w.c)()],t.prototype,"bloomThreshold",null),Object(h.c)([Object(w.c)()],t.prototype,"bloomScale",null),Object(h.c)([Object(w.c)()],t.prototype,"bloomEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"depthOfFieldEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"depthOfFieldBlurLevel",null),Object(h.c)([Object(w.c)()],t.prototype,"fxaaEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"samples",null),Object(h.c)([Object(w.c)()],t.prototype,"imageProcessingEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"glowLayerEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"chromaticAberrationEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"grainEnabled",null),t}(Df);c.a.RegisteredTypes["BABYLON.DefaultRenderingPipeline"]=wf;var Ff="\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}";ai.a.ShadersStore.lensHighlightsPixelShader=Ff;var Bf="\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";ai.a.ShadersStore.depthOfFieldPixelShader=Bf;var Uf=function(e){function t(t,i,n,r,o){void 0===r&&(r=1);var a=e.call(this,n.getEngine(),t)||this;return a.LensChromaticAberrationEffect="LensChromaticAberrationEffect",a.HighlightsEnhancingEffect="HighlightsEnhancingEffect",a.LensDepthOfFieldEffect="LensDepthOfFieldEffect",a._pentagonBokehIsEnabled=!1,a._scene=n,a._depthTexture=n.enableDepthRenderer().getDepthMap(),i.grain_texture?a._grainTexture=i.grain_texture:a._createGrainTexture(),a._edgeBlur=i.edge_blur?i.edge_blur:0,a._grainAmount=i.grain_amount?i.grain_amount:0,a._chromaticAberration=i.chromatic_aberration?i.chromatic_aberration:0,a._distortion=i.distortion?i.distortion:0,a._highlightsGain=void 0!==i.dof_gain?i.dof_gain:-1,a._highlightsThreshold=i.dof_threshold?i.dof_threshold:1,a._dofDistance=void 0!==i.dof_focus_distance?i.dof_focus_distance:-1,a._dofAperture=i.dof_aperture?i.dof_aperture:1,a._dofDarken=i.dof_darken?i.dof_darken:0,a._dofPentagon=void 0===i.dof_pentagon||i.dof_pentagon,a._blurNoise=void 0===i.blur_noise||i.blur_noise,a._createChromaticAberrationPostProcess(r),a._createHighlightsPostProcess(r),a._createDepthOfFieldPostProcess(r/4),a.addEffect(new jd(n.getEngine(),a.LensChromaticAberrationEffect,(function(){return a._chromaticAberrationPostProcess}),!0)),a.addEffect(new jd(n.getEngine(),a.HighlightsEnhancingEffect,(function(){return a._highlightsPostProcess}),!0)),a.addEffect(new jd(n.getEngine(),a.LensDepthOfFieldEffect,(function(){return a._depthOfFieldPostProcess}),!0)),-1===a._highlightsGain&&a._disableEffect(a.HighlightsEnhancingEffect,null),n.postProcessRenderPipelineManager.addPipeline(a),o&&n.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t,o),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"LensRenderingPipeline"},Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edgeBlur",{get:function(){return this._edgeBlur},set:function(e){this.setEdgeBlur(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"grainAmount",{get:function(){return this._grainAmount},set:function(e){this.setGrainAmount(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chromaticAberration",{get:function(){return this._chromaticAberration},set:function(e){this.setChromaticAberration(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dofAperture",{get:function(){return this._dofAperture},set:function(e){this.setAperture(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"edgeDistortion",{get:function(){return this._distortion},set:function(e){this.setEdgeDistortion(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dofDistortion",{get:function(){return this._dofDistance},set:function(e){this.setFocusDistance(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"darkenOutOfFocus",{get:function(){return this._dofDarken},set:function(e){this.setDarkenOutOfFocus(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"blurNoise",{get:function(){return this._blurNoise},set:function(e){this._blurNoise=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"pentagonBokeh",{get:function(){return this._pentagonBokehIsEnabled},set:function(e){e?this.enablePentagonBokeh():this.disablePentagonBokeh()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightsGain",{get:function(){return this._highlightsGain},set:function(e){this.setHighlightsGain(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"highlightsThreshold",{get:function(){return this._highlightsThreshold},set:function(e){this.setHighlightsThreshold(e)},enumerable:!1,configurable:!0}),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"),this._pentagonBokehIsEnabled=!0},t.prototype.disablePentagonBokeh=function(){this._pentagonBokehIsEnabled=!1,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 li("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],e,null,Ke.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 li("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],e,null,Ke.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 li("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,Ke.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 Hi.a("LensNoiseTexture",512,this._scene,!1,Ke.a.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=Ke.a.WRAP_ADDRESSMODE,this._grainTexture.wrapV=Ke.a.WRAP_ADDRESSMODE;for(var e,t,i,n=this._grainTexture.getContext(),r=0;r<512;r++)for(var o=0;o<512;o++)e=Math.floor(255*(t=.42,i=.58,Math.random()*(i-t)+t)),n.fillStyle="rgb("+e+", "+e+", "+e+")",n.fillRect(r,o,1,1);this._grainTexture.update(!1)},t}(Df),Vf=function(){this.enabled=!1,this.name="ssao2",this.texturesRequired=[g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE]},kf="\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;\n#ifndef GEOMETRYBUFFER\nuniform sampler2D depthNormalSampler;\n#else\nuniform sampler2D depthSampler;\nuniform sampler2D normalSampler;\n#endif\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;\n#ifndef GEOMETRYBUFFER\nfloat depth=texture2D(depthNormalSampler,vUV).r;\n#else\nfloat depth=texture2D(depthSampler,vUV).r;\n#endif\nfloat depthSign=depth/abs(depth);\ndepth=depth*depthSign;\n#ifndef GEOMETRYBUFFER\nvec3 normal=texture2D(depthNormalSampler,vUV).gba;\n#else\nvec3 normal=texture2D(normalSampler,vUV).rgb;\n#endif\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\n#ifndef GEOMETRYBUFFER\nfloat sampleDepth=abs(texture2D(depthNormalSampler,offset.xy).r);\n#else\nfloat sampleDepth=abs(texture2D(depthSampler,offset.xy).r);\n#endif\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 depthNormalSampler;\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(depthNormalSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthNormalSampler,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(depthNormalSampler,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(depthNormalSampler,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(depthNormalSampler,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(depthNormalSampler,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(depthNormalSampler,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(depthNormalSampler,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(depthNormalSampler,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";ai.a.ShadersStore.ssao2PixelShader=kf;var zf="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";ai.a.ShadersStore.ssaoCombinePixelShader=zf;var Gf=function(e){function t(t,i,n,r,o){void 0===o&&(o=!0);var a=e.call(this,i.getEngine(),t)||this;if(a.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",a.SSAORenderEffect="SSAORenderEffect",a.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",a.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",a.SSAOCombineRenderEffect="SSAOCombineRenderEffect",a.totalStrength=1,a.maxZ=100,a.minZAspect=.2,a._samples=8,a._textureSamples=1,a._forceGeometryBuffer=!1,a._expensiveBlur=!0,a.radius=2,a.base=0,a._bits=new Uint32Array(1),a._scene=i,a._ratio=n,a._forceGeometryBuffer=o,!a.isSupported)return m.a.Error("SSAO 2 needs WebGL 2 support."),a;var s=a._ratio.ssaoRatio||n,c=a._ratio.blurRatio||n;return a._forceGeometryBuffer?i.enableGeometryBufferRenderer():a._prePassRenderer=i.enablePrePassRenderer(),a._createRandomTexture(),a._originalColorPostProcess=new di("SSAOOriginalSceneColor",1,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),a._originalColorPostProcess.samples=a.textureSamples,a._createSSAOPostProcess(1),a._createBlurPostProcess(s,c),a._createSSAOCombinePostProcess(c),a.addEffect(new jd(i.getEngine(),a.SSAOOriginalSceneColorEffect,(function(){return a._originalColorPostProcess}),!0)),a.addEffect(new jd(i.getEngine(),a.SSAORenderEffect,(function(){return a._ssaoPostProcess}),!0)),a.addEffect(new jd(i.getEngine(),a.SSAOBlurHRenderEffect,(function(){return a._blurHPostProcess}),!0)),a.addEffect(new jd(i.getEngine(),a.SSAOBlurVRenderEffect,(function(){return a._blurVPostProcess}),!0)),a.addEffect(new jd(i.getEngine(),a.SSAOCombineRenderEffect,(function(){return a._ssaoCombinePostProcess}),!0)),i.postProcessRenderPipelineManager.addPipeline(a),r&&i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t,r),a}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples=e,this._ssaoPostProcess.updateEffect(this._getDefinesForSSAO()),this._sampleSphere=this._generateHemisphere()},enumerable:!1,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:!1,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","depthNormalSampler"]),this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE "+(e?"1":"0")+"\n",null,["textureSampler","depthNormalSampler"]),this._expensiveBlur=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"IsSupported",{get:function(){var e=x.a.LastCreatedEngine;return!!e&&e.webGLVersion>=2},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSAO2RenderingPipeline"},t.prototype.dispose=function(t){void 0===t&&(t=!1);for(var i=0;i<this._scene.cameras.length;i++){var n=this._scene.cameras[i];this._originalColorPostProcess.dispose(n),this._ssaoPostProcess.dispose(n),this._blurHPostProcess.dispose(n),this._blurVPostProcess.dispose(n),this._ssaoCombinePostProcess.dispose(n)}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 n=this.expensiveBlur,r=-8;r<8;r++)this._samplerOffsets.push(2*r+.5);this._blurHPostProcess=new li("BlurH","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthNormalSampler"],e,null,Ke.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE "+(n?"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),i._forceGeometryBuffer?e.setTexture("depthNormalSampler",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):e.setTexture("depthNormalSampler",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setArray("samplerOffsets",i._samplerOffsets))},this._blurVPostProcess=new li("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthNormalSampler"],t,null,Ke.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(n?"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),i._forceGeometryBuffer?e.setTexture("depthNormalSampler",i._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]):e.setTexture("depthNormalSampler",i._prePassRenderer.prePassRT.textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setArray("samplerOffsets",i._samplerOffsets))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},t.prototype._rebuild=function(){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,n=1-(.85*e+.15),r=Math.sqrt(1-n*n);return new a.e(Math.cos(i)*r,Math.sin(i)*r,n)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,i=[],n=0;n<t;){if(t<16)e=this._hemisphereSample_uniform(Math.random(),Math.random());else{var r=this._hammersley(n,t);e=this._hemisphereSample_uniform(r[0],r[1])}i.push(e.x,e.y,e.z),n++}return i},t.prototype._getDefinesForSSAO=function(){var e="#define SAMPLES "+this.samples+"\n#define SSAO";return this._forceGeometryBuffer&&(e+="\n#define GEOMETRYBUFFER"),e},t.prototype._createSSAOPostProcess=function(e){var t=this;this._sampleSphere=this._generateHemisphere();var i,n=this._getDefinesForSSAO();i=this._forceGeometryBuffer?["randomSampler","depthSampler","normalSampler"]:["randomSampler","depthNormalSampler"],this._ssaoPostProcess=new li("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","far","texelSize","xViewport","yViewport","maxZ","minZAspect"],i,e,null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,n),this._ssaoPostProcess.onApply=function(e){t._scene.activeCamera&&(e.setArray3("sampleSphere",t._sampleSphere),e.setFloat("randTextureTiles",32),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()),t._forceGeometryBuffer?(e.setTexture("depthSampler",t._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]),e.setTexture("normalSampler",t._scene.enableGeometryBufferRenderer().getGBuffer().textures[1])):e.setTexture("depthNormalSampler",t._prePassRenderer.prePassRT.textures[t._prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setTexture("randomSampler",t._randomTexture))},this._ssaoPostProcess.samples=this.textureSamples},t.prototype._createSSAOCombinePostProcess=function(e){var t=this;this._ssaoCombinePostProcess=new li("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){var i=t._scene.activeCamera.viewport;e.setVector4("viewport",a.c.Vector4[0].copyFromFloats(i.x,i.y,i.width,i.height)),e.setTextureFromPostProcessOutput("originalColor",t._originalColorPostProcess)},this._ssaoCombinePostProcess.samples=this.textureSamples,this._forceGeometryBuffer||(this._ssaoCombinePostProcess._prePassEffectConfiguration=new Vf)},t.prototype._createRandomTexture=function(){this._randomTexture=new Hi.a("SSAORandomTexture",128,this._scene,!1,Ke.a.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=Ke.a.WRAP_ADDRESSMODE,this._randomTexture.wrapV=Ke.a.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),t=function(e,t){return Math.random()*(t-e)+e},i=a.e.Zero(),n=0;n<128;n++)for(var r=0;r<128;r++)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(n,r,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,n){return w.a.Parse((function(){return new t(e._name,i,e._ratio)}),e,i,n)},Object(h.c)([Object(w.c)()],t.prototype,"totalStrength",void 0),Object(h.c)([Object(w.c)()],t.prototype,"maxZ",void 0),Object(h.c)([Object(w.c)()],t.prototype,"minZAspect",void 0),Object(h.c)([Object(w.c)("samples")],t.prototype,"_samples",void 0),Object(h.c)([Object(w.c)("textureSamples")],t.prototype,"_textureSamples",void 0),Object(h.c)([Object(w.c)()],t.prototype,"_ratio",void 0),Object(h.c)([Object(w.c)("expensiveBlur")],t.prototype,"_expensiveBlur",void 0),Object(h.c)([Object(w.c)()],t.prototype,"radius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"base",void 0),t}(Df);c.a.RegisteredTypes["BABYLON.SSAO2RenderingPipeline"]=Gf;var jf="\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";ai.a.ShadersStore.ssaoPixelShader=jf;var Wf=function(e){function t(t,i,n,r){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 a=n.ssaoRatio||n,s=n.combineRatio||n;return o._originalColorPostProcess=new di("SSAOOriginalSceneColor",s,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1),o._createSSAOPostProcess(a),o._createBlurPostProcess(a),o._createSSAOCombinePostProcess(s),o.addEffect(new jd(i.getEngine(),o.SSAOOriginalSceneColorEffect,(function(){return o._originalColorPostProcess}),!0)),o.addEffect(new jd(i.getEngine(),o.SSAORenderEffect,(function(){return o._ssaoPostProcess}),!0)),o.addEffect(new jd(i.getEngine(),o.SSAOBlurHRenderEffect,(function(){return o._blurHPostProcess}),!0)),o.addEffect(new jd(i.getEngine(),o.SSAOBlurVRenderEffect,(function(){return o._blurVPostProcess}),!0)),o.addEffect(new jd(i.getEngine(),o.SSAOCombineRenderEffect,(function(){return o._ssaoCombinePostProcess}),!0)),i.postProcessRenderPipelineManager.addPipeline(o),r&&i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(t,r),o}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"SSAORenderingPipeline"},t.prototype.dispose=function(t){void 0===t&&(t=!1);for(var i=0;i<this._scene.cameras.length;i++){var n=this._scene.cameras[i];this._originalColorPostProcess.dispose(n),this._ssaoPostProcess.dispose(n),this._blurHPostProcess.dispose(n),this._blurVPostProcess.dispose(n),this._ssaoCombinePostProcess.dispose(n)}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 eo("BlurH",new a.d(1,0),16,e,null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT),this._blurVPostProcess=new eo("BlurV",new a.d(0,1),16,e,null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,g.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 li("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],e,null,Ke.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 li("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,Ke.a.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){e.setVector4("viewport",a.c.Vector4[0].copyFromFloats(0,0,1,1)),e.setTextureFromPostProcess("originalColor",t._originalColorPostProcess)}},t.prototype._createRandomTexture=function(){this._randomTexture=new Hi.a("SSAORandomTexture",512,this._scene,!1,Ke.a.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=Ke.a.WRAP_ADDRESSMODE,this._randomTexture.wrapV=Ke.a.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),t=function(e,t){return Math.random()*(t-e)+e},i=a.e.Zero(),n=0;n<512;n++)for(var r=0;r<512;r++)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(n,r,1,1);this._randomTexture.update(!1)},Object(h.c)([Object(w.c)()],t.prototype,"totalStrength",void 0),Object(h.c)([Object(w.c)()],t.prototype,"radius",void 0),Object(h.c)([Object(w.c)()],t.prototype,"area",void 0),Object(h.c)([Object(w.c)()],t.prototype,"fallOff",void 0),Object(h.c)([Object(w.c)()],t.prototype,"base",void 0),t}(Df),Hf=function(){this.enabled=!1,this.name="screenSpaceReflections",this.texturesRequired=[g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,g.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,g.a.PREPASS_POSITION_TEXTURE_TYPE]},Xf="\n\nuniform sampler2D textureSampler;\nuniform sampler2D normalSampler;\nuniform sampler2D positionSampler;\nuniform sampler2D reflectivitySampler;\nuniform mat4 view;\nuniform mat4 projection;\nuniform float step;\nuniform float strength;\nuniform float threshold;\nuniform float roughnessFactor;\nuniform float reflectionSpecularFalloffExponent;\n\nvarying vec2 vUV;\n\nstruct ReflectionInfo {\nvec3 color;\nvec4 coords;\n};\n\nvec3 fresnelSchlick(float cosTheta,vec3 F0)\n{\nreturn F0+(1.0-F0)*pow(1.0-cosTheta,5.0);\n}\n\nReflectionInfo smoothReflectionInfo(vec3 dir,vec3 hitCoord)\n{\nReflectionInfo info;\ninfo.color=vec3(0.0);\nvec4 projectedCoord;\nfloat sampledDepth;\nfor(int i=0; i<SMOOTH_STEPS; i++)\n{\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\nsampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;\nfloat depth=sampledDepth-hitCoord.z;\ndir*=0.5;\nif(depth>0.0)\nhitCoord-=dir;\nelse\nhitCoord+=dir;\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\n}\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\n\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,1.0);\ninfo.color+=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.color/=float(SMOOTH_STEPS+1);\nreturn info;\n}\n\nReflectionInfo getReflectionInfo(vec3 dir,vec3 hitCoord)\n{\nReflectionInfo info;\nvec4 projectedCoord;\nfloat sampledDepth;\ndir*=step;\nfor(int i=0; i<REFLECTION_SAMPLES; i++)\n{\nhitCoord+=dir;\nprojectedCoord=projection*vec4(hitCoord,1.0);\nprojectedCoord.xy/=projectedCoord.w;\nprojectedCoord.xy=0.5*projectedCoord.xy+vec2(0.5);\nsampledDepth=(view*texture2D(positionSampler,projectedCoord.xy)).z;\nfloat depth=sampledDepth-hitCoord.z;\nif(((depth-dir.z)<threshold) && depth<=0.0)\n{\n#ifdef ENABLE_SMOOTH_REFLECTIONS\nreturn smoothReflectionInfo(dir,hitCoord);\n#else\ninfo.color=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,0.0);\nreturn info;\n#endif\n}\n}\ninfo.color=texture2D(textureSampler,projectedCoord.xy).rgb;\ninfo.coords=vec4(projectedCoord.xy,sampledDepth,0.0);\nreturn info;\n}\nvec3 hash(vec3 a)\n{\na=fract(a*0.8);\na+=dot(a,a.yxz+19.19);\nreturn fract((a.xxy+a.yxx)*a.zyx);\n}\nvoid main()\n{\n#ifdef SSR_SUPPORTED\n\nvec4 albedoFull=texture2D(textureSampler,vUV);\nvec3 albedo=albedoFull.rgb;\nfloat spec=texture2D(reflectivitySampler,vUV).r;\nif (spec == 0.0) {\ngl_FragColor=albedoFull;\nreturn;\n}\n\n#ifdef PREPASS_LAYOUT\nvec3 normal=(texture2D(normalSampler,vUV)).gba;\n#else\nvec3 normal=(texture2D(normalSampler,vUV)).xyz;\n#endif\nvec3 position=(view*texture2D(positionSampler,vUV)).xyz;\nvec3 reflected=normalize(reflect(normalize(position),normalize(normal)));\nfloat roughness=1.0-texture2D(reflectivitySampler,vUV).a;\nvec3 jitt=mix(vec3(0.0),hash(position),roughness)*roughnessFactor;\nReflectionInfo info=getReflectionInfo(jitt+reflected,position);\n\nvec2 dCoords=smoothstep(0.2,0.6,abs(vec2(0.5,0.5)-info.coords.xy));\nfloat screenEdgefactor=clamp(1.0-(dCoords.x+dCoords.y),0.0,1.0);\n\nvec3 F0=vec3(0.04);\nF0=mix(F0,albedo,spec);\nvec3 fresnel=fresnelSchlick(max(dot(normalize(normal),normalize(position)),0.0),F0);\n\nfloat reflectionMultiplier=clamp(pow(spec*strength,reflectionSpecularFalloffExponent)*screenEdgefactor*reflected.z,0.0,0.9);\nfloat albedoMultiplier=1.0-reflectionMultiplier;\nvec3 SSR=info.color*fresnel;\ngl_FragColor=vec4((albedo*albedoMultiplier)+(SSR*reflectionMultiplier),albedoFull.a);\n#else\ngl_FragColor=texture2D(textureSampler,vUV);\n#endif\n}\n";ai.a.ShadersStore.screenSpaceReflectionPixelShader=Xf;var Yf=function(e){function t(t,i,n,r,o,a,s,c,l,u){void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),void 0===u&&(u=!0);var h=e.call(this,t,"screenSpaceReflection",["projection","view","threshold","reflectionSpecularFalloffExponent","strength","step","roughnessFactor"],["textureSampler","normalSampler","positionSampler","reflectivitySampler"],n,r,o,a,s,"#define SSR_SUPPORTED\n#define REFLECTION_SAMPLES 64\n#define SMOOTH_STEPS 5\n",c,void 0,null,l)||this;if(h.threshold=1.2,h.strength=1,h.reflectionSpecularFalloffExponent=3,h.step=1,h.roughnessFactor=.2,h._forceGeometryBuffer=!1,h._enableSmoothReflections=!1,h._reflectionSamples=64,h._smoothSteps=5,h._forceGeometryBuffer=u,h._forceGeometryBuffer){var d=i.enableGeometryBufferRenderer();d&&d.isSupported&&(d.enablePosition=!0,d.enableReflectivity=!0,h._geometryBufferRenderer=d)}else h._prePassRenderer=i.enablePrePassRenderer(),h._prePassRenderer.markAsDirty(),h._prePassEffectConfiguration=new Hf;return h._updateEffectDefines(),h.onApply=function(e){var t=h._geometryBufferRenderer,n=h._prePassRenderer;if(n||t){if(t){var r=t.getTextureIndex(Sf.POSITION_TEXTURE_TYPE),o=t.getTextureIndex(Sf.REFLECTIVITY_TEXTURE_TYPE);e.setTexture("normalSampler",t.getGBuffer().textures[1]),e.setTexture("positionSampler",t.getGBuffer().textures[r]),e.setTexture("reflectivitySampler",t.getGBuffer().textures[o])}else{r=n.getIndex(g.a.PREPASS_POSITION_TEXTURE_TYPE),o=n.getIndex(g.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE);var a=n.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE);e.setTexture("normalSampler",n.prePassRT.textures[a]),e.setTexture("positionSampler",n.prePassRT.textures[r]),e.setTexture("reflectivitySampler",n.prePassRT.textures[o])}var s=i.activeCamera;if(s){var c=s.getViewMatrix(),l=s.getProjectionMatrix();e.setMatrix("projection",l),e.setMatrix("view",c),e.setFloat("threshold",h.threshold),e.setFloat("reflectionSpecularFalloffExponent",h.reflectionSpecularFalloffExponent),e.setFloat("strength",h.strength),e.setFloat("step",h.step),e.setFloat("roughnessFactor",h.roughnessFactor)}}},h}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ScreenSpaceReflectionPostProcess"},Object.defineProperty(t.prototype,"enableSmoothReflections",{get:function(){return this._enableSmoothReflections},set:function(e){e!==this._enableSmoothReflections&&(this._enableSmoothReflections=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"reflectionSamples",{get:function(){return this._reflectionSamples},set:function(e){e!==this._reflectionSamples&&(this._reflectionSamples=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"smoothSteps",{get:function(){return this._smoothSteps},set:function(e){e!==this._smoothSteps&&(this._smoothSteps=e,this._updateEffectDefines())},enumerable:!1,configurable:!0}),t.prototype._updateEffectDefines=function(){var e=[];(this._geometryBufferRenderer||this._prePassRenderer)&&(e.push("#define SSR_SUPPORTED"),this._prePassRenderer&&e.push("#define PREPASS_LAYOUT")),this._enableSmoothReflections&&e.push("#define ENABLE_SMOOTH_REFLECTIONS"),e.push("#define REFLECTION_SAMPLES "+(this._reflectionSamples>>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join("\n"))},t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"threshold",void 0),Object(h.c)([Object(w.c)()],t.prototype,"strength",void 0),Object(h.c)([Object(w.c)()],t.prototype,"reflectionSpecularFalloffExponent",void 0),Object(h.c)([Object(w.c)()],t.prototype,"step",void 0),Object(h.c)([Object(w.c)()],t.prototype,"roughnessFactor",void 0),Object(h.c)([Object(w.c)()],t.prototype,"enableSmoothReflections",null),Object(h.c)([Object(w.c)()],t.prototype,"reflectionSamples",null),Object(h.c)([Object(w.c)()],t.prototype,"smoothSteps",null),t}(li);c.a.RegisteredTypes["BABYLON.ScreenSpaceReflectionPostProcess"]=Yf;var Kf="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\n#include<packingFunctions>\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);\n#ifndef AUTO_EXPOSURE\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\n#endif\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";ai.a.ShadersStore.standardPixelShader=Kf;var Qf=function(e){function t(t,i,n,r,o){void 0===r&&(r=null);var a=e.call(this,i.getEngine(),t)||this;return a.downSampleX4PostProcess=null,a.brightPassPostProcess=null,a.blurHPostProcesses=[],a.blurVPostProcesses=[],a.textureAdderPostProcess=null,a.volumetricLightPostProcess=null,a.volumetricLightSmoothXPostProcess=null,a.volumetricLightSmoothYPostProcess=null,a.volumetricLightMergePostProces=null,a.volumetricLightFinalPostProcess=null,a.luminancePostProcess=null,a.luminanceDownSamplePostProcesses=[],a.hdrPostProcess=null,a.textureAdderFinalPostProcess=null,a.lensFlareFinalPostProcess=null,a.hdrFinalPostProcess=null,a.lensFlarePostProcess=null,a.lensFlareComposePostProcess=null,a.motionBlurPostProcess=null,a.depthOfFieldPostProcess=null,a.fxaaPostProcess=null,a.screenSpaceReflectionPostProcess=null,a.brightThreshold=1,a.blurWidth=512,a.horizontalBlur=!1,a.lensTexture=null,a.volumetricLightCoefficient=.2,a.volumetricLightPower=4,a.volumetricLightBlurScale=64,a.sourceLight=null,a.hdrMinimumLuminance=1,a.hdrDecreaseRate=.5,a.hdrIncreaseRate=.5,a.lensColorTexture=null,a.lensFlareStrength=20,a.lensFlareGhostDispersal=1.4,a.lensFlareHaloWidth=.7,a.lensFlareDistortionStrength=16,a.lensFlareBlurWidth=512,a.lensStarTexture=null,a.lensFlareDirtTexture=null,a.depthOfFieldDistance=10,a.depthOfFieldBlurWidth=64,a.animations=[],a._currentDepthOfFieldSource=null,a._fixedExposure=1,a._currentExposure=1,a._hdrAutoExposure=!1,a._hdrCurrentLuminance=1,a._motionStrength=1,a._isObjectBasedMotionBlur=!1,a._camerasToBeAttached=[],a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._vlsEnabled=!1,a._lensFlareEnabled=!1,a._hdrEnabled=!1,a._motionBlurEnabled=!1,a._fxaaEnabled=!1,a._screenSpaceReflectionsEnabled=!1,a._motionBlurSamples=64,a._volumetricLightStepsCount=50,a._samples=1,a._cameras=o||i.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=i,a._basePostProcess=r,a._ratio=n,a._floatTextureType=i.getEngine().getCaps().textureFloatRender?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT,i.postProcessRenderPipelineManager.addPipeline(a),a._buildPipeline(),a}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._fixedExposure},set:function(e){this._fixedExposure=e,this._currentExposure=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hdrAutoExposure",{get:function(){return this._hdrAutoExposure},set:function(e){if(this._hdrAutoExposure=e,this.hdrPostProcess){var t=["#define HDR"];e&&t.push("#define AUTO_EXPOSURE"),this.hdrPostProcess.updateEffect(t.join("\n"))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionStrength",{get:function(){return this._motionStrength},set:function(e){this._motionStrength=e,this._isObjectBasedMotionBlur&&this.motionBlurPostProcess&&(this.motionBlurPostProcess.motionStrength=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"objectBasedMotionBlur",{get:function(){return this._isObjectBasedMotionBlur},set:function(e){var t=this._isObjectBasedMotionBlur!==e;this._isObjectBasedMotionBlur=e,t&&this._buildPipeline()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!1,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 m.a.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"screenSpaceReflectionsEnabled",{get:function(){return this._screenSpaceReflectionsEnabled},set:function(e){this._screenSpaceReflectionsEnabled!==e&&(this._screenSpaceReflectionsEnabled=e,this._buildPipeline())},enumerable:!1,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:!1,configurable:!0}),Object.defineProperty(t.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&(this._isObjectBasedMotionBlur?this.motionBlurPostProcess.motionBlurSamples=e:this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+e.toFixed(1))),this._motionBlurSamples=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!1,configurable:!0}),t.prototype._buildPipeline=function(){var e=this,t=this._ratio,i=this._scene;this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._screenSpaceReflectionsEnabled&&(this.screenSpaceReflectionPostProcess=new Yf("HDRPass",i,t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess})),this.addEffect(new jd(i.getEngine(),"HDRScreenSpaceReflections",(function(){return e.screenSpaceReflectionPostProcess}),!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new li("HDRPass","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.autoClear=!this.screenSpaceReflectionPostProcess,this.originalPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.originalPostProcess})),this.addEffect(new jd(i.getEngine(),"HDRPassPostProcess",(function(){return e.originalPostProcess}),!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(i,t/4),this._createBrightPassPostProcess(i,t/4),this._createBlurPostProcesses(i,t/4,1),this._createTextureAdderPostProcess(i,t),this.textureAdderFinalPostProcess=new li("HDRDepthOfFieldSource","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),"HDRBaseDepthOfFieldSource",(function(){return e.textureAdderFinalPostProcess}),!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,t),this.volumetricLightFinalPostProcess=new li("HDRVLSFinal","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),"HDRVLSFinal",(function(){return e.volumetricLightFinalPostProcess}),!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,t),this.lensFlareFinalPostProcess=new li("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function(){return e.lensFlareFinalPostProcess}),!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,t),this.hdrFinalPostProcess=new li("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(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 mf("fxaa",1,null,Ke.a.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(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&&m.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,n=new Array(32);this.downSampleX4PostProcess=new li("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,r=i.downSampleX4PostProcess.width,o=i.downSampleX4PostProcess.height,a=-2;a<2;a++)for(var s=-2;s<2;s++)n[t]=(a+.5)*(1/r),n[t+1]=(s+.5)*(1/o),t+=2;e.setArray2("dsOffsets",n)},this.addEffect(new jd(e.getEngine(),"HDRDownSampleX4",(function(){return i.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var i=this,n=new Array(8);this.brightPassPostProcess=new li("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(e){var t=1/i.brightPassPostProcess.width,r=1/i.brightPassPostProcess.height;n[0]=-.5*t,n[1]=.5*r,n[2]=.5*t,n[3]=.5*r,n[4]=-.5*t,n[5]=-.5*r,n[6]=.5*t,n[7]=-.5*r,e.setArray2("dsOffsets",n),e.setFloat("brightThreshold",i.brightThreshold)},this.addEffect(new jd(e.getEngine(),"HDRBrightPass",(function(){return i.brightPassPostProcess}),!0))},t.prototype._createBlurPostProcesses=function(e,t,i,n){var r=this;void 0===n&&(n="blurWidth");var o=e.getEngine(),s=new eo("HDRBlurH_"+i,new a.d(1,0),this[n],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),c=new eo("HDRBlurV_"+i,new a.d(0,1),this[n],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);s.onActivateObservable.add((function(){var e=s.width/o.getRenderWidth();s.kernel=r[n]*e})),c.onActivateObservable.add((function(){var e=c.height/o.getRenderHeight();c.kernel=r.horizontalBlur?64*e:r[n]*e})),this.addEffect(new jd(e.getEngine(),"HDRBlurH"+i,(function(){return s}),!0)),this.addEffect(new jd(e.getEngine(),"HDRBlurV"+i,(function(){return c}),!0)),this.blurHPostProcesses.push(s),this.blurVPostProcesses.push(c)},t.prototype._createTextureAdderPostProcess=function(e,t){var i=this;this.textureAdderPostProcess=new li("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._vlsEnabled?i._currentDepthOfFieldSource:i.originalPostProcess),e.setTexture("lensSampler",i.lensTexture),e.setFloat("exposure",i._currentExposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new jd(e.getEngine(),"HDRTextureAdder",(function(){return i.textureAdderPostProcess}),!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var i=this,n=e.enableGeometryBufferRenderer();n.enablePosition=!0;var r=n.getGBuffer();this.volumetricLightPostProcess=new li("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var o=a.d.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",r.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),o.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),o.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),e.setVector2("depthValues",o)}},this.addEffect(new jd(e.getEngine(),"HDRVLS",(function(){return i.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new li("HDRVLSMerge","standard",[],["originalSampler"],t,null,Ke.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 jd(e.getEngine(),"HDRVLSMerge",(function(){return i.volumetricLightMergePostProces}),!0))},t.prototype._createLuminancePostProcesses=function(e,i){var n=this,r=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new li("HDRLuminance","standard",["lumOffsets"],[],{width:r,height:r},null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",i);var o=[];this.luminancePostProcess.onApply=function(e){var t=1/n.luminancePostProcess.width,i=1/n.luminancePostProcess.height;o[0]=-.5*t,o[1]=.5*i,o[2]=.5*t,o[3]=.5*i,o[4]=-.5*t,o[5]=-.5*i,o[6]=.5*t,o[7]=-.5*i,e.setArray2("lumOffsets",o)},this.addEffect(new jd(e.getEngine(),"HDRLuminance",(function(){return n.luminancePostProcess}),!0));for(var s=t.LuminanceSteps-1;s>=0;s--){r=Math.pow(3,s);var c="#define LUMINANCE_DOWN_SAMPLE\n";0===s&&(c+="#define FINAL_DOWN_SAMPLER");var l=new li("HDRLuminanceDownSample"+s,"standard",["dsOffsets","halfDestPixelSize"],[],{width:r,height:r},null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,c,i);this.luminanceDownSamplePostProcesses.push(l)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,i){var r=new Array(18);t.onApply=function(e){if(u){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)r[o]=a/u.width,r[o+1]=s/u.height,o+=2;e.setArray2("dsOffsets",r),e.setFloat("halfDestPixelSize",.5/u.width),u=i===n.luminanceDownSamplePostProcesses.length-1?n.luminancePostProcess:t}},i===n.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),i=new a.f(1/16581375,1/65025,1/255,1);n._hdrCurrentLuminance=(t[0]*i.x+t[1]*i.y+t[2]*i.z+t[3]*i.w)/100}),n.addEffect(new jd(e.getEngine(),"HDRLuminanceDownSample"+i,(function(){return t}),!0))}))},t.prototype._createHdrPostProcess=function(e,t){var i=this,n=["#define HDR"];this._hdrAutoExposure&&n.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new li("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n.join("\n"),g.a.TEXTURETYPE_UNSIGNED_INT);var r=1,o=0,a=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",i._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),r<0)r=i._hdrCurrentLuminance;else{var n=(a-o)/1e3;i._hdrCurrentLuminance<r+i.hdrDecreaseRate*n?r+=i.hdrDecreaseRate*n:i._hdrCurrentLuminance>r-i.hdrIncreaseRate*n?r-=i.hdrIncreaseRate*n:r=i._hdrCurrentLuminance}i.hdrAutoExposure?i._currentExposure=i._fixedExposure/r:(r=L.a.Clamp(r,i.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",r)),a=o,i._currentDepthOfFieldSource=i.hdrFinalPostProcess},this.addEffect(new jd(e.getEngine(),"HDR",(function(){return i.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var i=this;this.lensFlarePostProcess=new li("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(e.getEngine(),"HDRLensFlare",(function(){return i.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new li("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new jd(e.getEngine(),"HDRLensFlareCompose",(function(){return i.lensFlareComposePostProcess}),!0));var n=new a.d(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),n.x=i.lensFlarePostProcess.width,n.y=i.lensFlarePostProcess.height,e.setVector2("resolution",n),e.setFloat("distortionStrength",i.lensFlareDistortionStrength)};var r=a.a.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),o=a.a.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.lensFlarePostProcess),e.setTexture("lensDirtSampler",i.lensFlareDirtTexture),e.setTexture("lensStarSampler",i.lensStarTexture);var t=i._scene.activeCamera.getViewMatrix().getRow(0),n=i._scene.activeCamera.getViewMatrix().getRow(2),s=a.e.Dot(t.toVector3(),new a.e(1,0,0))+a.e.Dot(n.toVector3(),new a.e(0,0,1));s*=4;var c=a.a.FromValues(.5*Math.cos(s),-Math.sin(s),0,0,Math.sin(s),.5*Math.cos(s),0,0,0,0,1,0,0,0,0,1),l=o.multiply(c).multiply(r);e.setMatrix("lensStarMatrix",l),i._currentDepthOfFieldSource=i.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var i=this;this.depthOfFieldPostProcess=new li("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",g.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 jd(e.getEngine(),"HDRDepthOfField",(function(){return i.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var i=this;if(this._isObjectBasedMotionBlur){var n=new Rf("HDRMotionBlur",e,t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT);n.motionStrength=this.motionStrength,n.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=n}else{this.motionBlurPostProcess=new li("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Ke.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),g.a.TEXTURETYPE_UNSIGNED_INT);var r=0,o=a.a.Identity(),s=a.a.Identity(),c=a.a.Identity(),l=a.d.Zero();this.motionBlurPostProcess.onApply=function(t){(c=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(s),t.setMatrix("inverseViewProjection",s),t.setMatrix("prevViewProjection",o),o=c,l.x=i.motionBlurPostProcess.width,l.y=i.motionBlurPostProcess.height,t.setVector2("screenSize",l),r=e.getEngine().getFps()/60,t.setFloat("motionScale",r),t.setFloat("motionStrength",i.motionStrength),t.setTexture("depthSampler",i._getDepthTexture())}}this.addEffect(new jd(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.screenSpaceReflectionPostProcess&&this.screenSpaceReflectionPostProcess.dispose(t),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(t),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(t),this.textureAdderPostProcess&&this.textureAdderPostProcess.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.screenSpaceReflectionPostProcess=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),this.screenSpaceReflectionPostProcess&&(e.screenSpaceReflectionPostProcess=w.a.Serialize(this.screenSpaceReflectionPostProcess)),e.customType="StandardRenderingPipeline",e},t.Parse=function(e,i,n){var r=w.a.Parse((function(){return new t(e._name,i,e._ratio)}),e,i,n);return e.sourceLightId&&(r.sourceLight=i.getLightByID(e.sourceLightId)),e.screenSpaceReflectionPostProcess&&w.a.Parse((function(){return r.screenSpaceReflectionPostProcess}),e.screenSpaceReflectionPostProcess,i,n),r},t.LuminanceSteps=6,Object(h.c)([Object(w.c)()],t.prototype,"brightThreshold",void 0),Object(h.c)([Object(w.c)()],t.prototype,"blurWidth",void 0),Object(h.c)([Object(w.c)()],t.prototype,"horizontalBlur",void 0),Object(h.c)([Object(w.c)()],t.prototype,"exposure",null),Object(h.c)([Object(w.m)("lensTexture")],t.prototype,"lensTexture",void 0),Object(h.c)([Object(w.c)()],t.prototype,"volumetricLightCoefficient",void 0),Object(h.c)([Object(w.c)()],t.prototype,"volumetricLightPower",void 0),Object(h.c)([Object(w.c)()],t.prototype,"volumetricLightBlurScale",void 0),Object(h.c)([Object(w.c)()],t.prototype,"hdrMinimumLuminance",void 0),Object(h.c)([Object(w.c)()],t.prototype,"hdrDecreaseRate",void 0),Object(h.c)([Object(w.c)()],t.prototype,"hdrIncreaseRate",void 0),Object(h.c)([Object(w.c)()],t.prototype,"hdrAutoExposure",null),Object(h.c)([Object(w.m)("lensColorTexture")],t.prototype,"lensColorTexture",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lensFlareStrength",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lensFlareGhostDispersal",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lensFlareHaloWidth",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lensFlareDistortionStrength",void 0),Object(h.c)([Object(w.c)()],t.prototype,"lensFlareBlurWidth",void 0),Object(h.c)([Object(w.m)("lensStarTexture")],t.prototype,"lensStarTexture",void 0),Object(h.c)([Object(w.m)("lensFlareDirtTexture")],t.prototype,"lensFlareDirtTexture",void 0),Object(h.c)([Object(w.c)()],t.prototype,"depthOfFieldDistance",void 0),Object(h.c)([Object(w.c)()],t.prototype,"depthOfFieldBlurWidth",void 0),Object(h.c)([Object(w.c)()],t.prototype,"motionStrength",null),Object(h.c)([Object(w.c)()],t.prototype,"objectBasedMotionBlur",null),Object(h.c)([Object(w.c)()],t.prototype,"_ratio",void 0),Object(h.c)([Object(w.c)()],t.prototype,"BloomEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"DepthOfFieldEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"LensFlareEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"HDREnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"VLSEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"MotionBlurEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"fxaaEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"screenSpaceReflectionsEnabled",null),Object(h.c)([Object(w.c)()],t.prototype,"volumetricLightStepsCount",null),Object(h.c)([Object(w.c)()],t.prototype,"motionBlurSamples",null),Object(h.c)([Object(w.c)()],t.prototype,"samples",null),t}(Df);c.a.RegisteredTypes["BABYLON.StandardRenderingPipeline"]=Qf;var qf="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 useCamA;\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\nuseCamA=!useCamB;\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\n#ifdef IS_STEREOSCOPIC_INTERLACED\nfloat rowNum=floor(vUV.y/stepSize.y);\nuseCamA=mod(rowNum,2.0) == 1.0;\nuseCamB=mod(rowNum,2.0) == 0.0;\ntexCoord1=vec2(vUV.x,vUV.y);\ntexCoord2=vec2(vUV.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\nuseCamA=!useCamB;\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#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else if (useCamA){\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}else {\ndiscard;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}\n";ai.a.ShadersStore.stereoscopicInterlacePixelShader=qf;var Zf=function(e){function t(t,i,n,r,o,s,c){var l=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,i[1],o,s,c,r?"#define IS_STEREOSCOPIC_INTERLACED 1":n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return l._passedProcess=i[0]._rigPostProcess,l._stepSize=new a.d(1/l.width,1/l.height),l.onSizeChangedObservable.add((function(){l._stepSize=new a.d(1/l.width,1/l.height)})),l.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",l._passedProcess),e.setFloat2("stepSize",l._stepSize.x,l._stepSize.y)})),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcessI"},t}(li),Jf=function(e){function t(t,i,n,r,o,s){var c=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,i[1],r,o,s,n?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return c._passedProcess=i[0]._rigPostProcess,c._stepSize=new a.d(1/c.width,1/c.height),c.onSizeChangedObservable.add((function(){c._stepSize=new a.d(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 Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcess"},t}(li),$f="\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}";ai.a.ShadersStore.tonemapPixelShader=$f;var ep;!function(e){e[e.Hable=0]="Hable",e[e.Reinhard=1]="Reinhard",e[e.HejiDawson=2]="HejiDawson",e[e.Photographic=3]="Photographic"}(ep||(ep={}));var tp=function(e){function t(t,i,n,r,o,a,s){void 0===o&&(o=g.a.TEXTURE_BILINEAR_SAMPLINGMODE),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT);var c=e.call(this,t,"tonemap",["_ExposureAdjustment"],null,1,r,o,a,!0,null,s)||this;c._operator=i,c.exposureAdjustment=n;var l="#define ";return c._operator===ep.Hable?l+="HABLE_TONEMAPPING":c._operator===ep.Reinhard?l+="REINHARD_TONEMAPPING":c._operator===ep.HejiDawson?l+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":c._operator===ep.Photographic&&(l+="PHOTOGRAPHIC_TONEMAPPING"),c.updateEffect(l),c.onApply=function(e){e.setFloat("_ExposureAdjustment",c.exposureAdjustment)},c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"TonemapPostProcess"},t}(li),ip="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";ai.a.ShadersStore.volumetricLightScatteringPixelShader=ip;var np="\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\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\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#if (defined(ALPHATEST) || defined(NEED_UV)) && defined(UV1)\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}\n";ai.a.ShadersStore.volumetricLightScatteringPassVertexShader=np;var rp="#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";ai.a.ShadersStore.volumetricLightScatteringPassPixelShader=rp;var op=function(e){function t(i,n,r,o,s,c,l,u,h){void 0===s&&(s=100),void 0===c&&(c=Ke.a.BILINEAR_SAMPLINGMODE);var d=e.call(this,i,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],n.postProcessRatio||n,r,c,l,u,"#define NUM_SAMPLES "+s)||this;return d._screenCoordinates=a.d.Zero(),d.customMeshPosition=a.e.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===r?h:r.getScene()).getEngine(),d._viewPort=new yi.a(0,0,1,1).toGlobal(l.getRenderWidth(),l.getRenderHeight()),d.mesh=null!==o?o:t.CreateDefaultMesh("VolumetricLightScatteringMesh",h),d._createPass(h,n.passRatio||n),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 Object(h.d)(t,e),Object.defineProperty(t.prototype,"useDiffuseColor",{get:function(){return m.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),!1},set:function(e){m.a.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")},enumerable:!1,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 n=[],r=[Qi.b.PositionKind],o=e.getMaterial();o&&(o.needAlphaTesting()&&n.push("#define ALPHATEST"),i.isVerticesDataPresent(Qi.b.UVKind)&&(r.push(Qi.b.UVKind),n.push("#define UV1")),i.isVerticesDataPresent(Qi.b.UV2Kind)&&(r.push(Qi.b.UV2Kind),n.push("#define UV2"))),i.useBones&&i.computeBonesUsingShaders?(r.push(Qi.b.MatricesIndicesKind),r.push(Qi.b.MatricesWeightsKind),n.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),n.push("#define BonesPerMesh "+(i.skeleton?i.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0"),t&&(n.push("#define INSTANCES"),ro.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&n.push("#define THIN_INSTANCES"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._volumetricLightScatteringPass=i.getScene().getEngine().createEffect("volumetricLightScatteringPass",r,["world","mBones","viewProjection","diffuseMatrix"],["diffuseSampler"],a,void 0,void 0,void 0,{maxSimultaneousMorphTargets:i.numBoneInfluencers})),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,n=e.getEngine();this._volumetricLightScatteringRTT=new Ni("volumetricLightScatteringMap",{width:n.getRenderWidth()*t,height:n.getRenderHeight()*t},e,!1,!0,g.a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Ke.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var r=this.getCamera();r?r.customRenderTargets.push(this._volumetricLightScatteringRTT):e.customRenderTargets.push(this._volumetricLightScatteringRTT);var o,a=function(e){var t=e.getRenderingMesh(),n=e.getEffectiveMesh();if(!i._meshExcluded(t)){n._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var r=e.getMaterial();if(r){var o=t.getScene(),a=o.getEngine();a.setState(r.backFaceCulling);var s=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!s.mustReturn){var c=a.getCaps().instancedArrays&&(null!==s.visibleInstances[e._id]||t.hasThinInstances);if(i._isReady(e,c)){var l=i._volumetricLightScatteringPass;if(t===i.mesh&&(l=e.effect?e.effect:r.getEffect()),a.enableEffect(l),t._bind(e,l,r.fillMode),t===i.mesh)r.bind(n.getWorldMatrix(),t);else{if(i._volumetricLightScatteringPass.setMatrix("viewProjection",o.getTransformMatrix()),r&&r.needAlphaTesting()){var u=r.getAlphaTestTexture();i._volumetricLightScatteringPass.setTexture("diffuseSampler",u),u&&i._volumetricLightScatteringPass.setMatrix("diffuseMatrix",u.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&i._volumetricLightScatteringPass.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(n,e,i._volumetricLightScatteringPass,xo.a.TriangleFillMode,s,c,(function(e,t){return l.setMatrix("world",t)}))}}}}},c=new s.b(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){o=e.clearColor,e.clearColor=c})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){e.clearColor=o})),this._volumetricLightScatteringRTT.customRenderFunction=function(t,i,n,r){var o,s=e.getEngine();if(r.length){for(s.setColorWrite(!1),o=0;o<r.length;o++)a(r.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(n.length){for(o=0;o<n.length;o++){var c=n.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=n.data.slice(0,n.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(g.a.ALPHA_COMBINE),o=0;o<u.length;o++)a(u[o]);s.setAlphaMode(g.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 n=a.e.Project(t,a.a.Identity(),i,this._viewPort);this._screenCoordinates.x=n.x/this._viewPort.width,this._screenCoordinates.y=n.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},t.CreateDefaultMesh=function(e,t){var i=be.a.CreatePlane(e,1,t);i.billboardMode=Ge.a.BILLBOARDMODE_ALL;var n=new Wi.a(e+"Material",t);return n.emissiveColor=new s.a(1,1,1),i.material=n,i},Object(h.c)([Object(w.o)()],t.prototype,"customMeshPosition",void 0),Object(h.c)([Object(w.c)()],t.prototype,"useCustomMeshPosition",void 0),Object(h.c)([Object(w.c)()],t.prototype,"invert",void 0),Object(h.c)([Object(w.k)()],t.prototype,"mesh",void 0),Object(h.c)([Object(w.c)()],t.prototype,"excludedMeshes",void 0),Object(h.c)([Object(w.c)()],t.prototype,"exposure",void 0),Object(h.c)([Object(w.c)()],t.prototype,"decay",void 0),Object(h.c)([Object(w.c)()],t.prototype,"weight",void 0),Object(h.c)([Object(w.c)()],t.prototype,"density",void 0),t}(li);c.a.RegisteredTypes["BABYLON.VolumetricLightScatteringPostProcess"]=op;var ap="\n\nprecision highp float;\n\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D normalSampler;\nuniform float curvature_ridge;\nuniform float curvature_valley;\n#ifndef CURVATURE_OFFSET\n#define CURVATURE_OFFSET 1\n#endif\nfloat curvature_soft_clamp(float curvature,float control)\n{\nif (curvature<0.5/control)\nreturn curvature*(1.0-curvature*control);\nreturn 0.25/control;\n}\nfloat calculate_curvature(ivec2 texel,float ridge,float valley)\n{\nvec2 normal_up=texelFetchOffset(normalSampler,texel,0,ivec2(0,CURVATURE_OFFSET)).rb;\nvec2 normal_down=texelFetchOffset(normalSampler,texel,0,ivec2(0,-CURVATURE_OFFSET)).rb;\nvec2 normal_left=texelFetchOffset(normalSampler,texel,0,ivec2(-CURVATURE_OFFSET,0)).rb;\nvec2 normal_right=texelFetchOffset(normalSampler,texel,0,ivec2( CURVATURE_OFFSET,0)).rb;\nfloat normal_diff=((normal_up.g-normal_down.g)+(normal_right.r-normal_left.r));\nif (normal_diff<0.0)\nreturn -2.0*curvature_soft_clamp(-normal_diff,valley);\nreturn 2.0*curvature_soft_clamp(normal_diff,ridge);\n}\nvoid main(void)\n{\nivec2 texel=ivec2(gl_FragCoord.xy);\nvec4 baseColor=texture2D(textureSampler,vUV);\nfloat curvature=calculate_curvature(texel,curvature_ridge,curvature_valley);\nbaseColor.rgb*=curvature+1.0;\ngl_FragColor=baseColor;\n}";ai.a.ShadersStore.screenSpaceCurvaturePixelShader=ap;var sp=function(e){function t(t,i,n,r,o,a,s,c,l){void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1);var u=e.call(this,t,"screenSpaceCurvature",["curvature_ridge","curvature_valley"],["textureSampler","normalSampler"],n,r,o,a,s,void 0,c,void 0,null,l)||this;return u.ridge=1,u.valley=1,u._geometryBufferRenderer=i.enableGeometryBufferRenderer(),u._geometryBufferRenderer?u.onApply=function(e){e.setFloat("curvature_ridge",.5/Math.max(u.ridge*u.ridge,1e-4)),e.setFloat("curvature_valley",.7/Math.max(u.valley*u.valley,1e-4));var t=u._geometryBufferRenderer.getGBuffer().textures[1];e.setTexture("normalSampler",t)}:m.a.Error("Multiple Render Target support needed for screen space curvature post process. Please use IsSupported test first."),u}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ScreenSpaceCurvaturePostProcess"},Object.defineProperty(t,"IsSupported",{get:function(){var e=x.a.LastCreatedEngine;return!!e&&(e.webGLVersion>1||e.getCaps().drawBuffersExtension)},enumerable:!1,configurable:!0}),t._Parse=function(e,i,n,r){return w.a.Parse((function(){return new t(e.name,n,e.options,i,e.renderTargetSamplingMode,n.getEngine(),e.textureType,e.reusable)}),e,n,r)},Object(h.c)([Object(w.c)()],t.prototype,"ridge",void 0),Object(h.c)([Object(w.c)()],t.prototype,"valley",void 0),t}(li);c.a.RegisteredTypes["BABYLON.ScreenSpaceCurvaturePostProcess"]=sp;i(166),i(167);Object.defineProperty(Q.a.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(e){this._forceShowBoundingBoxes=e,e&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),Q.a.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new cp(this)),this._boundingBoxRenderer},Object.defineProperty(Ge.a.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(e){this._showBoundingBox=e,e&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var cp=function(){function e(e){this.name=Me.a.NAME_BOUNDINGBOXRENDERER,this.frontColor=new s.a(1,1,1),this.backColor=new s.a(.1,.1,.1),this.showBackLines=!0,this.onBeforeBoxRenderingObservable=new o.c,this.onAfterBoxRenderingObservable=new o.c,this.onResourcesReadyObservable=new o.c,this.enabled=!0,this.renderList=new oi.a(32),this._vertexBuffers={},this._fillIndexBuffer=null,this._fillIndexData=null,this.scene=e,e._addComponent(this)}return e.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(Me.a.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._preActiveMeshStage.registerStep(Me.a.STEP_PREACTIVEMESH_BOUNDINGBOXRENDERER,this,this._preActiveMesh),this.scene._evaluateSubMeshStage.registerStep(Me.a.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(Me.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._preActiveMesh=function(e){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){var t=e.getBoundingInfo();t.boundingBox._tag=e.renderingGroupId,this.renderList.push(t.boundingBox)}},e.prototype._prepareResources=function(){if(!this._colorShader){this._colorShader=new Lc.a("colorShader",this.scene,"color",{attributes:[Qi.b.PositionKind],uniforms:["world","viewProjection","color"]}),this._colorShader.reservedDataStore={hidden:!0};var e=this.scene.getEngine(),t=Ki.a.CreateBox({size:1});this._vertexBuffers[Qi.b.PositionKind]=new Qi.b(e,t.positions,Qi.b.PositionKind,!1),this._createIndexBuffer(),this._fillIndexData=t.indices,this.onResourcesReadyObservable.notifyObservers(this)}},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[Qi.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.enabled&&(this._prepareResources(),this._colorShader.isReady())){var t=this.scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var i=0;i<this.renderList.length;i++){var n=this.renderList.data[i];if(n._tag===e){this.onBeforeBoxRenderingObservable.notifyObservers(n);var r=n.minimum,o=n.maximum.subtract(r),s=r.add(o.scale(.5)),c=a.a.Scaling(o.x,o.y,o.z).multiply(a.a.Translation(s.x,s.y,s.z)).multiply(n.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(xo.a.LineListDrawMode,0,24)),t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(c),t.drawElementsType(xo.a.LineListDrawMode,0,24),this.onAfterBoxRenderingObservable.notifyObservers(n)}}this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0)}},e.prototype.renderOcclusionBoundingBox=function(e){if(this._prepareResources(),this._colorShader.isReady()&&e._boundingInfo){var t=this.scene.getEngine();this._fillIndexBuffer||(this._fillIndexBuffer=t.createIndexBuffer(this._fillIndexData)),t.setDepthWrite(!1),t.setColorWrite(!1),this._colorShader._preBind();var i=e._boundingInfo.boundingBox,n=i.minimum,r=i.maximum.subtract(n),o=n.add(r.scale(.5)),s=a.a.Scaling(r.x,r.y,r.z).multiply(a.a.Translation(o.x,o.y,o.z)).multiply(i.getWorldMatrix());t.bindBuffers(this._vertexBuffers,this._fillIndexBuffer,this._colorShader.getEffect()),t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.bind(s),t.drawElementsType(xo.a.TriangleFillMode,0,36),this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0),t.setColorWrite(!0)}},e.prototype.dispose=function(){if(this._colorShader){this.onBeforeBoxRenderingObservable.clear(),this.onAfterBoxRenderingObservable.clear(),this.onResourcesReadyObservable.clear(),this.renderList.dispose(),this._colorShader.dispose();var e=this._vertexBuffers[Qi.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[Qi.b.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer),this._fillIndexBuffer&&(this.scene.getEngine()._releaseBuffer(this._fillIndexBuffer),this._fillIndexBuffer=null)}},e}();Q.a.prototype.enableDepthRenderer=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),!(e=e||this.activeCamera))throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[e.id]){var n=!!this.getEngine().getCaps().textureFloatRender,r=0;r=!this.getEngine().getCaps().textureHalfFloatRender||i&&n?n?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_BYTE:g.a.TEXTURETYPE_HALF_FLOAT,this._depthRenderer[e.id]=new ks(this,r,e,t)}return this._depthRenderer[e.id]},Q.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 lp=function(){function e(e){this.name=Me.a.NAME_DEPTHRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Me.a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(Me.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.enabled&&!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.enabled&&i.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(i.getDepthMap())}},e}();ks._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_DEPTHRENDERER);t||(t=new lp(e),e._addComponent(t))};ai.a.ShadersStore.linePixelShader="uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";var up="#include<instancesDeclaration>\n\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 viewProjection;\nuniform float width;\nuniform float aspectRatio;\nvoid main(void) {\n#include<instancesVertex>\nmat4 worldViewProjection=viewProjection*finalWorld;\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}";ai.a.ShadersStore.lineVertexShader=up;Ge.a.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},Ge.a.prototype.enableEdgesRendering=function(e,t,i){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new dp(this,e,t,!0,i),this},Object.defineProperty(Ge.a.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),Ch.b.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new fp(this,e,t),this},Ch.a.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),Ch.b.prototype.enableEdgesRendering.apply(this,arguments),this};var hp=function(){this.edges=new Array,this.edgesConnectedCount=0},dp=function(){function e(e,t,i,n,r){var o,a=this;void 0===t&&(t=.95),void 0===i&&(i=!1),void 0===n&&(n=!0),this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._buffersForInstances={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this.customInstances=new oi.a(32),this._source=e,this._checkVerticesInsteadOfIndices=i,this._options=null!=r?r:null,this._epsilon=t,this._prepareRessources(),n&&(null===(o=null==r?void 0:r.useAlternateEdgeFinder)||void 0===o||o?this._generateEdgesLinesAlternate():this._generateEdgesLines()),this._meshRebuildObserver=this._source.onRebuildObservable.add((function(){a._rebuild()})),this._meshDisposeObserver=this._source.onDisposeObservable.add((function(){a.dispose()}))}return Object.defineProperty(e.prototype,"linesPositions",{get:function(){return this._linesPositions},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesNormals",{get:function(){return this._linesNormals},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"linesIndices",{get:function(){return this._linesIndices},enumerable:!1,configurable:!0}),e.GetShader=function(e){if(!e._edgeRenderLineShader){var t=new Lc.a("lineShader",e,"line",{attributes:["position","normal"],uniforms:["world","viewProjection","color","width","aspectRatio"]});t.disableDepthWrite=!0,t.backFaceCulling=!1,e._edgeRenderLineShader=t}return e._edgeRenderLineShader},e.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=e.GetShader(this._source.getScene()))},e.prototype._rebuild=function(){var e=this._buffers[Qi.b.PositionKind];e&&e._rebuild(),(e=this._buffers[Qi.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[Qi.b.PositionKind];e&&(e.dispose(),this._buffers[Qi.b.PositionKind]=null),(e=this._buffers[Qi.b.NormalKind])&&(e.dispose(),this._buffers[Qi.b.NormalKind]=null),this._ib&&this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},e.prototype._processEdgeForAdjacencies=function(e,t,i,n,r){return e===i&&t===n||e===n&&t===i?0:e===n&&t===r||e===r&&t===n?1:e===r&&t===i||e===i&&t===r?2:-1},e.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,n,r){var o=1e-10;return e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(n,o)||e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(i,o)?0:e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(r,o)||e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(n,o)?1:e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(i,o)||e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(r,o)?2:-1},e.prototype._checkEdge=function(e,t,i,n,r){var o;void 0===t?o=!0:o=a.e.Dot(i[e],i[t])<this._epsilon;o&&this.createLine(n,r,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._tessellateTriangle=function(e,t,i,n){var r=function(e,t,i){i>=0&&t.push(i);for(var n=0;n<e.length;++n)t.push(e[n][0])},o=0;e[1].length>=e[0].length&&e[1].length>=e[2].length?o=1:e[2].length>=e[0].length&&e[2].length>=e[1].length&&(o=2);for(var a=0;a<3;++a)a===o?e[a].sort((function(e,t){return e[1]<t[1]?-1:e[1]>t[1]?1:0})):e[a].sort((function(e,t){return e[1]>t[1]?-1:e[1]<t[1]?1:0}));var s=[],c=[];r(e[o],s,-1);for(var l=s.length,u=o+2;u>=o+1;--u)r(e[u%3],c,u!==o+2?n[i[t+(u+1)%3]]:-1);var h=c.length;i.push(n[i[t+o]],s[0],c[0]),i.push(n[i[t+(o+1)%3]],c[h-1],s[l-1]);for(var d=l<=h,f=d?l:h,p=d?h:l,_=d?l-1:h-1,m=d?0:1,g=l+h-2,v=0,b=0,y=d?s:c,T=d?c:s,E=0;g-- >0;){m?i.push(y[v],T[b]):i.push(T[b],y[v]);var S=void 0;(E+=f)>=p&&v<_?(S=y[++v],E-=p):S=T[++b],i.push(S)}i[t+0]=i[i.length-3],i[t+1]=i[i.length-2],i[t+2]=i[i.length-1],i.length=i.length-3},e.prototype._generateEdgesLinesAlternate=function(){var e,t,i,n,r,o,s,c,l,u=this._source.getVerticesData(Qi.b.PositionKind),h=this._source.getIndices();if(h&&u){Array.isArray(h)||(h=Ce.b.SliceToArray(h));var d=null===(t=null===(e=this._options)||void 0===e?void 0:e.useFastVertexMerger)||void 0===t||t,f=d?Math.round(-Math.log(null!==(n=null===(i=this._options)||void 0===i?void 0:i.epsilonVertexMerge)&&void 0!==n?n:1e-6)/Math.log(10)):null!==(o=null===(r=this._options)||void 0===r?void 0:r.epsilonVertexMerge)&&void 0!==o?o:1e-6,p=[],_=[];if(d)for(var m={},g=0;g<u.length;g+=3){var v=u[g+0],b=u[g+1],y=u[g+2];if(void 0!==m[ee=v.toFixed(f)+"|"+b.toFixed(f)+"|"+y.toFixed(f)])p.push(m[ee]);else{var T=g/3;m[ee]=T,p.push(T),_.push(T)}}else for(g=0;g<u.length;g+=3){v=u[g+0],b=u[g+1],y=u[g+2];for(var E=!1,S=0;S<g&&!E;S+=3){var A=u[S+0],P=u[S+1],C=u[S+2];if(Math.abs(v-A)<f&&Math.abs(b-P)<f&&Math.abs(y-C)<f){p.push(S/3),E=!0;break}}E||(p.push(g/3),_.push(g/3))}if(null===(s=this._options)||void 0===s?void 0:s.applyTessellation){for(var R=null!==(l=null===(c=this._options)||void 0===c?void 0:c.epsilonVertexAligned)&&void 0!==l?l:1e-6,x=[],O=0;O<h.length;O+=3)for(var M=void 0,I=0;I<3;++I){var D=p[h[O+I]],N=p[h[O+(I+1)%3]],L=p[h[O+(I+2)%3]];if(D!==N)for(var w=u[3*D+0],F=u[3*D+1],B=u[3*D+2],U=u[3*N+0],V=u[3*N+1],k=u[3*N+2],z=Math.sqrt((U-w)*(U-w)+(V-F)*(V-F)+(k-B)*(k-B)),G=0;G<_.length-1;G++){var j=_[G];if(j!==D&&j!==N&&j!==L){var W=u[3*j+0],H=u[3*j+1],X=u[3*j+2],Y=Math.sqrt((W-w)*(W-w)+(H-F)*(H-F)+(X-B)*(X-B)),K=Math.sqrt((W-U)*(W-U)+(H-V)*(H-V)+(X-k)*(X-k));Math.abs(Y+K-z)<R&&(M||(M={index:O,edgesPoints:[[],[],[]]},x.push(M)),M.edgesPoints[I].push([j,Y]))}}}for(var Q=0;Q<x.length;++Q){var q=x[Q];this._tessellateTriangle(q.edgesPoints,q.index,h,p)}x=null}var Z={};for(O=0;O<h.length;O+=3){var J=void 0;for(I=0;I<3;++I){D=p[h[O+I]],N=p[h[O+(I+1)%3]],L=p[h[O+(I+2)%3]];if(D!==N){if(a.c.Vector3[0].copyFromFloats(u[3*D+0],u[3*D+1],u[3*D+2]),a.c.Vector3[1].copyFromFloats(u[3*N+0],u[3*N+1],u[3*N+2]),a.c.Vector3[2].copyFromFloats(u[3*L+0],u[3*L+1],u[3*L+2]),J||(a.c.Vector3[1].subtractToRef(a.c.Vector3[0],a.c.Vector3[3]),a.c.Vector3[2].subtractToRef(a.c.Vector3[1],a.c.Vector3[4]),(J=a.e.Cross(a.c.Vector3[3],a.c.Vector3[4])).normalize()),D>N){var $=D;D=N,N=$}if(te=Z[ee=D+"_"+N]){if(!te.done)a.e.Dot(J,te.normal)<this._epsilon&&this.createLine(a.c.Vector3[0],a.c.Vector3[1],this._linesPositions.length/3),te.done=!0}else Z[ee]={normal:J,done:!1,index:O,i:I}}}}for(var ee in Z){var te;if(!(te=Z[ee]).done){D=p[h[te.index+te.i]],N=p[h[te.index+(te.i+1)%3]];a.c.Vector3[0].copyFromFloats(u[3*D+0],u[3*D+1],u[3*D+2]),a.c.Vector3[1].copyFromFloats(u[3*N+0],u[3*N+1],u[3*N+2]),this.createLine(a.c.Vector3[0],a.c.Vector3[1],this._linesPositions.length/3)}}var ie=this._source.getScene().getEngine();this._buffers[Qi.b.PositionKind]=new Qi.b(ie,this._linesPositions,Qi.b.PositionKind,!1),this._buffers[Qi.b.NormalKind]=new Qi.b(ie,this._linesNormals,Qi.b.NormalKind,!1,!1,4),this._buffersForInstances[Qi.b.PositionKind]=this._buffers[Qi.b.PositionKind],this._buffersForInstances[Qi.b.NormalKind]=this._buffers[Qi.b.NormalKind],this._ib=ie.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},e.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(Qi.b.PositionKind),t=this._source.getIndices();if(t&&e){var i,n,r=new Array,o=new Array;for(i=0;i<t.length;i+=3){n=new hp;var s=t[i],c=t[i+1],l=t[i+2];n.p0=new a.e(e[3*s],e[3*s+1],e[3*s+2]),n.p1=new a.e(e[3*c],e[3*c+1],e[3*c+2]),n.p2=new a.e(e[3*l],e[3*l+1],e[3*l+2]);var u=a.e.Cross(n.p1.subtract(n.p0),n.p2.subtract(n.p1));u.normalize(),o.push(u),r.push(n)}for(i=0;i<r.length;i++){n=r[i];for(var h=i+1;h<r.length;h++){var d=r[h];if(3===n.edgesConnectedCount)break;if(3!==d.edgesConnectedCount)for(var f=t[3*h],p=t[3*h+1],_=t[3*h+2],m=0;m<3;m++){var g=0;if(void 0===n.edges[m]){switch(m){case 0:g=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(n.p0,n.p1,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(t[3*i],t[3*i+1],f,p,_);break;case 1:g=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(n.p1,n.p2,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(t[3*i+1],t[3*i+2],f,p,_);break;case 2:g=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(n.p2,n.p0,d.p0,d.p1,d.p2):this._processEdgeForAdjacencies(t[3*i+2],t[3*i],f,p,_)}if(-1!==g&&(n.edges[m]=h,d.edges[g]=i,n.edgesConnectedCount++,d.edgesConnectedCount++,3===n.edgesConnectedCount))break}}}}for(i=0;i<r.length;i++){var v=r[i];this._checkEdge(i,v.edges[0],o,v.p0,v.p1),this._checkEdge(i,v.edges[1],o,v.p1,v.p2),this._checkEdge(i,v.edges[2],o,v.p2,v.p0)}var b=this._source.getScene().getEngine();this._buffers[Qi.b.PositionKind]=new Qi.b(b,this._linesPositions,Qi.b.PositionKind,!1),this._buffers[Qi.b.NormalKind]=new Qi.b(b,this._linesNormals,Qi.b.NormalKind,!1,!1,4),this._buffersForInstances[Qi.b.PositionKind]=this._buffers[Qi.b.PositionKind],this._buffersForInstances[Qi.b.NormalKind]=this._buffers[Qi.b.NormalKind],this._ib=b.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},e.prototype.isReady=function(){return this._lineShader.isReady(this._source,this._source.hasInstances&&this.customInstances.length>0||this._source.hasThinInstances)},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(g.a.ALPHA_COMBINE):t.setAlphaMode(g.a.ALPHA_DISABLE);var i=this._source.hasInstances&&this.customInstances.length>0,n=i||this._source.hasThinInstances,r=0;if(n)if(this._buffersForInstances.world0=this._source.getVertexBuffer("world0"),this._buffersForInstances.world1=this._source.getVertexBuffer("world1"),this._buffersForInstances.world2=this._source.getVertexBuffer("world2"),this._buffersForInstances.world3=this._source.getVertexBuffer("world3"),i){var o=this._source._instanceDataStorage;if(r=this.customInstances.length,!o.isFrozen){for(var a=0,s=0;s<r;++s)this.customInstances.data[s].copyToArray(o.instancesData,a),a+=16;o.instancesBuffer.updateDirectly(o.instancesData,0,r)}}else r=this._source.thinInstanceCount;t.bindBuffers(n?this._buffersForInstances:this._buffers,this._ib,this._lineShader.getEffect()),e.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),e.activeCamera.mode===je.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(xo.a.TriangleFillMode,0,this._indicesCount,r),this._lineShader.unbind(),n&&t.unbindInstanceAttributes(),this._source.getScene()._activeMeshesFrozen||this.customInstances.reset()}},e}(),fp=function(e){function t(t,i,n){void 0===i&&(i=.95),void 0===n&&(n=!1);var r=e.call(this,t,i,n,!1)||this;return r._generateEdgesLines(),r}return Object(h.d)(t,e),t.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(Qi.b.PositionKind),t=this._source.getIndices();if(t&&e){for(var i=a.c.Vector3[0],n=a.c.Vector3[1],r=t.length-1,o=0,s=0;o<r;o+=2,s+=4)a.e.FromArrayToRef(e,3*t[o],i),a.e.FromArrayToRef(e,3*t[o+1],n),this.createLine(i,n,s);var c=this._source.getScene().getEngine();this._buffers[Qi.b.PositionKind]=new Qi.b(c,this._linesPositions,Qi.b.PositionKind,!1),this._buffers[Qi.b.NormalKind]=new Qi.b(c,this._linesNormals,Qi.b.NormalKind,!1,!1,4),this._ib=c.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},t}(dp),pp=function(){function e(t){this._textureFormats=[{type:g.a.PREPASS_IRRADIANCE_TEXTURE_TYPE,format:g.a.TEXTURETYPE_HALF_FLOAT},{type:g.a.PREPASS_POSITION_TEXTURE_TYPE,format:g.a.TEXTURETYPE_HALF_FLOAT},{type:g.a.PREPASS_VELOCITY_TEXTURE_TYPE,format:g.a.TEXTURETYPE_HALF_FLOAT},{type:g.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,format:g.a.TEXTURETYPE_UNSIGNED_INT},{type:g.a.PREPASS_COLOR_TEXTURE_TYPE,format:g.a.TEXTURETYPE_HALF_FLOAT},{type:g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,format:g.a.TEXTURETYPE_HALF_FLOAT},{type:g.a.PREPASS_ALBEDO_TEXTURE_TYPE,format:g.a.TEXTURETYPE_UNSIGNED_INT}],this.excludedSkinnedMesh=[],this.excludedMaterials=[],this._textureIndices=[],this._isDirty=!1,this.mrtCount=0,this._postProcesses=[],this._clearColor=new s.b(0,0,0,0),this._effectConfigurations=[],this._mrtFormats=[],this._enabled=!1,this._useGeometryBufferFallback=!1,this.disableGammaTransform=!1,this._scene=t,this._engine=t.getEngine(),e._SceneComponentInitialization(this._scene),this._resetLayout()}return Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"samples",{get:function(){return this.prePassRT.samples},set:function(e){this.imageProcessingPostProcess||this._createCompositionEffect(),this.prePassRT.samples=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useGeometryBufferFallback",{get:function(){return this._useGeometryBufferFallback},set:function(e){if(this._useGeometryBufferFallback=e,e){if(this._geometryBuffer=this._scene.enableGeometryBufferRenderer(),!this._geometryBuffer)return void(this._useGeometryBufferFallback=!1);this._geometryBuffer.renderList=[],this._geometryBuffer._linkPrePassRenderer(this),this._updateGeometryBufferLayout()}else this._geometryBuffer&&this._geometryBuffer._unlinkPrePassRenderer(),this._geometryBuffer=null,this._scene.disableGeometryBufferRenderer()},enumerable:!1,configurable:!0}),e.prototype._initializeAttachments=function(){for(var e=[],t=[!1],i=[!0],n=0;n<this.mrtCount;n++)e.push(!0),n>0&&(t.push(!0),i.push(!1));this._multiRenderAttachments=this._engine.buildTextureLayout(e),this._clearAttachments=this._engine.buildTextureLayout(t),this._defaultAttachments=this._engine.buildTextureLayout(i)},e.prototype._createCompositionEffect=function(){this.prePassRT=new Hc("sceneprePassRT",{width:this._engine.getRenderWidth(),height:this._engine.getRenderHeight()},this.mrtCount,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:g.a.TEXTURETYPE_UNSIGNED_INT,types:this._mrtFormats}),this.prePassRT.samples=1,this._initializeAttachments(),this._useGeometryBufferFallback&&!this._geometryBuffer&&(this.useGeometryBufferFallback=!0),this.imageProcessingPostProcess=new Yi("sceneCompositionPass",1,null,void 0,this._engine),this.imageProcessingPostProcess.autoClear=!1},Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._engine.webGLVersion>1||this._scene.getEngine().getCaps().drawBuffersExtension},enumerable:!1,configurable:!0}),e.prototype.bindAttachmentsForEffect=function(e,t){if(this.enabled)if(e._multiTarget)this._engine.bindAttachments(this._multiRenderAttachments);else if(this._engine.bindAttachments(this._defaultAttachments),this._geometryBuffer){var i=t.getMaterial();i&&-1===this.excludedMaterials.indexOf(i)&&this._geometryBuffer.renderList.push(t.getRenderingMesh())}},e.prototype.restoreAttachments=function(){this.enabled&&this._defaultAttachments&&this._engine.bindAttachments(this._defaultAttachments)},e.prototype._beforeCameraDraw=function(){this._isDirty&&this._update(),this._geometryBuffer&&(this._geometryBuffer.renderList.length=0),this._bindFrameBuffer()},e.prototype._afterCameraDraw=function(){if(this._enabled){var e=this._scene.activeCamera&&this._scene.activeCamera._getFirstPostProcess();e&&this._postProcesses.length&&this._scene.postProcessManager._prepareFrame(),this._scene.postProcessManager.directRender(this._postProcesses,e?e.inputTexture:null)}},e.prototype._checkRTSize=function(){var e=this._engine.getRenderWidth(!0),t=this._engine.getRenderHeight(!0),i=this.prePassRT.getRenderWidth(),n=this.prePassRT.getRenderHeight();i===e&&n===t||(this.prePassRT.resize({width:e,height:t}),this._updateGeometryBufferLayout(),this._bindPostProcessChain())},e.prototype._bindFrameBuffer=function(){if(this._enabled){this._checkRTSize();var e=this.prePassRT.getInternalTexture();e&&this._engine.bindFramebuffer(e)}},e.prototype.clear=function(){this._enabled&&(this._bindFrameBuffer(),this._engine.clear(this._scene.clearColor,this._scene.autoClear||this._scene.forceWireframe||this._scene.forcePointsCloud,this._scene.autoClearDepthAndStencil,this._scene.autoClearDepthAndStencil),this._engine.bindAttachments(this._clearAttachments),this._engine.clear(this._clearColor,!0,!1,!1),this._engine.bindAttachments(this._defaultAttachments))},e.prototype._setState=function(e){this._enabled=e,this._scene.prePass=e,this.imageProcessingPostProcess&&(this.imageProcessingPostProcess.imageProcessingConfiguration.applyByPostProcess=e)},e.prototype._updateGeometryBufferLayout=function(){if(this._geometryBuffer){this._geometryBuffer._resetLayout();for(var e=[],t=0;t<this._mrtLayout.length;t++)e.push(!1);this._geometryBuffer._linkInternalTexture(this.prePassRT.getInternalTexture());var i=[{prePassConstant:g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,geometryBufferConstant:Sf.DEPTHNORMAL_TEXTURE_TYPE},{prePassConstant:g.a.PREPASS_POSITION_TEXTURE_TYPE,geometryBufferConstant:Sf.POSITION_TEXTURE_TYPE},{prePassConstant:g.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,geometryBufferConstant:Sf.REFLECTIVITY_TEXTURE_TYPE},{prePassConstant:g.a.PREPASS_VELOCITY_TEXTURE_TYPE,geometryBufferConstant:Sf.VELOCITY_TEXTURE_TYPE}];for(t=0;t<i.length;t++){var n=this._mrtLayout.indexOf(i[t].prePassConstant);-1!==n&&(this._geometryBuffer._forceTextureType(i[t].geometryBufferConstant,n),e[n]=!0)}this._geometryBuffer._setAttachments(this._engine.buildTextureLayout(e))}},e.prototype.addEffectConfiguration=function(e){for(var t=0;t<this._effectConfigurations.length;t++)if(this._effectConfigurations[t].name===e.name)return this._effectConfigurations[t];return this._effectConfigurations.push(e),e},e.prototype.getIndex=function(e){return this._textureIndices[e]},e.prototype._enable=function(){for(var e,t,i=this.mrtCount,n=0;n<this._effectConfigurations.length;n++)this._effectConfigurations[n].enabled&&this._enableTextures(this._effectConfigurations[n].texturesRequired);this.prePassRT&&this.mrtCount!==i&&this.prePassRT.updateCount(this.mrtCount,{types:this._mrtFormats}),this._updateGeometryBufferLayout(),this._resetPostProcessChain();for(n=0;n<this._effectConfigurations.length;n++)this._effectConfigurations[n].enabled&&(!this._effectConfigurations[n].postProcess&&this._effectConfigurations[n].createPostProcess&&this._effectConfigurations[n].createPostProcess(),this._effectConfigurations[n].postProcess&&this._postProcesses.push(this._effectConfigurations[n].postProcess));this._initializeAttachments(),this.imageProcessingPostProcess||this._createCompositionEffect();var r=!1;if(null===(e=this._scene.activeCamera)||void 0===e?void 0:e._postProcesses)for(n=0;n<this._scene.activeCamera._postProcesses.length;n++)"ImageProcessingPostProcess"===(null===(t=this._scene.activeCamera._postProcesses[n])||void 0===t?void 0:t.getClassName())&&(r=!0);r||this.disableGammaTransform||this._postProcesses.push(this.imageProcessingPostProcess),this._bindPostProcessChain(),this._setState(!0)},e.prototype._disable=function(){this._setState(!1),this._resetLayout();for(var e=0;e<this._effectConfigurations.length;e++)this._effectConfigurations[e].enabled=!1},e.prototype._resetLayout=function(){for(var e=0;e<this._textureFormats.length;e++)this._textureIndices[this._textureFormats[e].type]=-1;this._textureIndices[g.a.PREPASS_COLOR_TEXTURE_TYPE]=0,this._mrtLayout=[g.a.PREPASS_COLOR_TEXTURE_TYPE],this._mrtFormats=[g.a.TEXTURETYPE_HALF_FLOAT],this.mrtCount=1},e.prototype._resetPostProcessChain=function(){this._postProcesses=[],this.imageProcessingPostProcess&&this.imageProcessingPostProcess.restoreDefaultInputTexture();for(var e=0;e<this._effectConfigurations.length;e++)this._effectConfigurations[e].postProcess&&this._effectConfigurations[e].postProcess.restoreDefaultInputTexture()},e.prototype._bindPostProcessChain=function(){var e;if(this._postProcesses.length)this._postProcesses[0].inputTexture=this.prePassRT.getInternalTexture();else{var t=null===(e=this._scene.activeCamera)||void 0===e?void 0:e._getFirstPostProcess();t&&(t.inputTexture=this.prePassRT.getInternalTexture())}},e.prototype.markAsDirty=function(){this._isDirty=!0},e.prototype._enableTextures=function(e){for(var t=0;t<e.length;t++){var i=e[t];-1===this._textureIndices[i]&&(this._textureIndices[i]=this._mrtLayout.length,this._mrtLayout.push(i),this._mrtFormats.push(this._textureFormats[i].format),this.mrtCount++)}},e.prototype._update=function(){this._disable();for(var e=!1,t=0;t<this._scene.materials.length;t++)this._scene.materials[t].setPrePassRenderer(this)&&(e=!0);var i=this._scene.activeCamera;if(i){var n=i._postProcesses.filter((function(e){return null!=e}));if(n)for(t=0;t<n.length;t++)n[t].setPrePassRenderer(this)&&(e=!0);this._markAllMaterialsAsPrePassDirty(),this._isDirty=!1,e&&this._enable(),this.enabled||(this._engine.restoreDefaultFramebuffer(),this._engine.restoreSingleAttachment())}},e.prototype._markAllMaterialsAsPrePassDirty=function(){for(var e=this._scene.materials,t=0;t<e.length;t++)e[t].markAsDirty(xo.a.PrePassDirtyFlag)},e.prototype.dispose=function(){for(var e=0;e<this._effectConfigurations.length;e++)this._effectConfigurations[e].dispose&&this._effectConfigurations[e].dispose();this.imageProcessingPostProcess.dispose(),this.prePassRT.dispose()},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("PrePassRendererSceneComponent")},e}();Object.defineProperty(Q.a.prototype,"prePassRenderer",{get:function(){return this._prePassRenderer},set:function(e){e&&e.isSupported&&(this._prePassRenderer=e)},enumerable:!0,configurable:!0}),Q.a.prototype.enablePrePassRenderer=function(){return this._prePassRenderer||(this._prePassRenderer=new pp(this),this._prePassRenderer.isSupported||(this._prePassRenderer=null,m.a.Error("PrePassRenderer needs WebGL 2 support.\nMaybe you tried to use the following features that need the PrePassRenderer :\n + Subsurface Scattering"))),this._prePassRenderer},Q.a.prototype.disablePrePassRenderer=function(){this._prePassRenderer&&(this._prePassRenderer.dispose(),this._prePassRenderer=null)};var _p=function(){function e(e){this.name=Me.a.NAME_PREPASSRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(Me.a.STEP_BEFORECAMERADRAW_PREPASS,this,this._beforeCameraDraw),this.scene._afterCameraDrawStage.registerStep(Me.a.STEP_AFTERCAMERADRAW_PREPASS,this,this._afterCameraDraw),this.scene._beforeClearStage.registerStep(Me.a.STEP_BEFORECLEARSTAGE_PREPASS,this,this._beforeClearStage),this.scene._beforeRenderingMeshStage.registerStep(Me.a.STEP_BEFORERENDERINGMESH_PREPASS,this,this._beforeRenderingMeshStage),this.scene._afterRenderingMeshStage.registerStep(Me.a.STEP_AFTERRENDERINGMESH_PREPASS,this,this._afterRenderingMeshStage)},e.prototype._beforeCameraDraw=function(){this.scene.prePassRenderer&&this.scene.prePassRenderer._beforeCameraDraw()},e.prototype._afterCameraDraw=function(){this.scene.prePassRenderer&&this.scene.prePassRenderer._afterCameraDraw()},e.prototype._beforeClearStage=function(){this.scene.prePassRenderer&&this.scene.prePassRenderer.clear()},e.prototype._beforeRenderingMeshStage=function(e,t,i,n){if(n){var r=e.getScene();r.prePassRenderer&&r.prePassRenderer.bindAttachmentsForEffect(n,t)}},e.prototype._afterRenderingMeshStage=function(e){var t=e.getScene();t.prePassRenderer&&t.prePassRenderer.restoreAttachments()},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e}();pp._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_PREPASSRENDERER);t||(t=new _p(e),e._addComponent(t))};var mp="#define rcp(x) 1./x\n#define GOLDEN_RATIO 1.618033988749895\n#define TWO_PI 6.2831855\n\n\nvec2 Golden2dSeq(int i,float n)\n{\n\n\nreturn vec2(float(i)/n+(0.5/n),fract(float(i)*rcp(GOLDEN_RATIO)));\n}\nvec2 SampleDiskGolden(int i,int sampleCount)\n{\nvec2 f=Golden2dSeq(i,float(sampleCount));\nreturn vec2(sqrt(f.x),TWO_PI*f.y);\n}";ai.a.IncludesShadersStore.fibonacci=mp;var gp="uniform vec3 diffusionS[5];\nuniform float diffusionD[5];\nuniform float filterRadii[5];";ai.a.IncludesShadersStore.diffusionProfile=gp;var vp="\n#include<fibonacci>\n#include<helperFunctions>\n#include<subSurfaceScatteringFunctions>\n#include<diffusionProfile>\nvarying vec2 vUV;\nuniform vec2 texelSize;\nuniform sampler2D textureSampler;\nuniform sampler2D irradianceSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D albedoSampler;\nuniform vec2 viewportSize;\nuniform float metersPerUnit;\nconst float LOG2_E=1.4426950408889634;\nconst float SSS_PIXELS_PER_SAMPLE=4.;\nconst int _SssSampleBudget=40;\n#define rcp(x) 1./x\n#define Sq(x) x*x\n#define SSS_BILATERAL_FILTER true\n\n\nvec3 EvalBurleyDiffusionProfile(float r,vec3 S)\n{\nvec3 exp_13=exp2(((LOG2_E*(-1.0/3.0))*r)*S);\nvec3 expSum=exp_13*(1.+exp_13*exp_13);\nreturn (S*rcp(8.*PI))*expSum;\n}\n\n\n\n\n\n\nvec2 SampleBurleyDiffusionProfile(float u,float rcpS)\n{\nu=1.-u;\nfloat g=1.+(4.*u)*(2.*u+sqrt(1.+(4.*u)*u));\nfloat n=exp2(log2(g)*(-1.0/3.0));\nfloat p=(g*n)*n;\nfloat c=1.+p+n;\nfloat d=(3./LOG2_E*2.)+(3./LOG2_E)*log2(u);\nfloat x=(3./LOG2_E)*log2(c)-d;\n\n\n\n\n\n\nfloat rcpExp=((c*c)*c)*rcp((4.*u)*((c*c)+(4.*u)*(4.*u)));\nfloat r=x*rcpS;\nfloat rcpPdf=(8.*PI*rcpS)*rcpExp;\nreturn vec2(r,rcpPdf);\n}\n\n\nvec3 ComputeBilateralWeight(float xy2,float z,float mmPerUnit,vec3 S,float rcpPdf)\n{\n#ifndef SSS_BILATERAL_FILTER\nz=0.;\n#endif\n\n\n\nfloat r=sqrt(xy2+(z*mmPerUnit)*(z*mmPerUnit));\nfloat area=rcpPdf;\n#if SSS_CLAMP_ARTIFACT\nreturn clamp(EvalBurleyDiffusionProfile(r,S)*area,0.0,1.0);\n#else\nreturn EvalBurleyDiffusionProfile(r,S)*area;\n#endif\n}\nvoid EvaluateSample(int i,int n,vec3 S,float d,vec3 centerPosVS,float mmPerUnit,float pixelsPerMm,\nfloat phase,inout vec3 totalIrradiance,inout vec3 totalWeight)\n{\n\nfloat scale=rcp(float(n));\nfloat offset=rcp(float(n))*0.5;\n\nfloat sinPhase,cosPhase;\nsinPhase=sin(phase);\ncosPhase=cos(phase);\nvec2 bdp=SampleBurleyDiffusionProfile(float(i)*scale+offset,d);\nfloat r=bdp.x;\nfloat rcpPdf=bdp.y;\nfloat phi=SampleDiskGolden(i,n).y;\nfloat sinPhi,cosPhi;\nsinPhi=sin(phi);\ncosPhi=cos(phi);\nfloat sinPsi=cosPhase*sinPhi+sinPhase*cosPhi;\nfloat cosPsi=cosPhase*cosPhi-sinPhase*sinPhi;\nvec2 vec=r*vec2(cosPsi,sinPsi);\n\nvec2 position;\nfloat xy2;\nposition=vUV+round((pixelsPerMm*r)*vec2(cosPsi,sinPsi))*texelSize;\nxy2=r*r;\nvec4 textureSample=texture2D(irradianceSampler,position);\nfloat viewZ=texture2D(depthSampler,position).r;\nvec3 irradiance=textureSample.rgb;\nif (testLightingForSSS(textureSample.a))\n{\n\nfloat relZ=viewZ-centerPosVS.z;\nvec3 weight=ComputeBilateralWeight(xy2,relZ,mmPerUnit,S,rcpPdf);\ntotalIrradiance+=weight*irradiance;\ntotalWeight+=weight;\n}\nelse\n{\n\n\n\n\n\n\n}\n}\nvoid main(void)\n{\nvec4 irradianceAndDiffusionProfile=texture2D(irradianceSampler,vUV);\nvec3 centerIrradiance=irradianceAndDiffusionProfile.rgb;\nint diffusionProfileIndex=int(round(irradianceAndDiffusionProfile.a*255.));\nfloat centerDepth=0.;\nvec4 inputColor=texture2D(textureSampler,vUV);\nbool passedStencilTest=testLightingForSSS(irradianceAndDiffusionProfile.a);\nif (passedStencilTest)\n{\ncenterDepth=texture2D(depthSampler,vUV).r;\n}\nif (!passedStencilTest) {\ngl_FragColor=inputColor;\nreturn;\n}\nfloat distScale=1.;\nvec3 S=diffusionS[diffusionProfileIndex];\nfloat d=diffusionD[diffusionProfileIndex];\nfloat filterRadius=filterRadii[diffusionProfileIndex];\n\nvec2 centerPosNDC=vUV;\nvec2 cornerPosNDC=vUV+0.5*texelSize;\nvec3 centerPosVS=vec3(centerPosNDC*viewportSize,1.0)*centerDepth;\nvec3 cornerPosVS=vec3(cornerPosNDC*viewportSize,1.0)*centerDepth;\n\nfloat mmPerUnit=1000.*(metersPerUnit*rcp(distScale));\nfloat unitsPerMm=rcp(mmPerUnit);\n\n\nfloat unitsPerPixel=2.*abs(cornerPosVS.x-centerPosVS.x);\nfloat pixelsPerMm=rcp(unitsPerPixel)*unitsPerMm;\n\nfloat filterArea=PI*Sq(filterRadius*pixelsPerMm);\nint sampleCount=int(filterArea*rcp(SSS_PIXELS_PER_SAMPLE));\nint sampleBudget=_SssSampleBudget;\nint texturingMode=0;\nvec3 albedo=texture2D(albedoSampler,vUV).rgb;\nif (distScale == 0. || sampleCount<1)\n{\n#ifdef DEBUG_SSS_SAMPLES\nvec3 green=vec3(0.,1.,0.);\ngl_FragColor=vec4(green,1.0);\nreturn;\n#endif\ngl_FragColor=vec4(inputColor.rgb+albedo*centerIrradiance,1.0);\nreturn;\n}\n#ifdef DEBUG_SSS_SAMPLES\nvec3 red=vec3(1.,0.,0.);\nvec3 blue=vec3(0.,0.,1.);\ngl_FragColor=vec4(mix(blue,red,clamp(float(sampleCount)/float(sampleBudget),0.0,1.0)),1.0);\nreturn;\n#endif\n\nfloat phase=0.;\nint n=min(sampleCount,sampleBudget);\n\nvec3 centerWeight=vec3(0.);\nvec3 totalIrradiance=vec3(0.);\nvec3 totalWeight=vec3(0.);\nfor (int i=0; i<n; i++)\n{\n\nEvaluateSample(i,n,S,d,centerPosVS,mmPerUnit,pixelsPerMm,\nphase,totalIrradiance,totalWeight);\n}\n\ntotalWeight=max(totalWeight,HALF_MIN);\ngl_FragColor=vec4(inputColor.rgb+albedo*max(totalIrradiance/totalWeight,vec3(0.0)),1.);\n}";ai.a.ShadersStore.subSurfaceScatteringPixelShader=vp;var bp=function(e){function t(t,i,n,r,o,a,s,c){void 0===r&&(r=null),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,"subSurfaceScattering",["texelSize","viewportSize","metersPerUnit"],["diffusionS","diffusionD","filterRadii","irradianceSampler","depthSampler","albedoSampler"],n,r,o||Ke.a.BILINEAR_SAMPLINGMODE,a,s,null,c,"postprocess",void 0,!0)||this;return l._scene=i,l.updateEffect(),l.onApplyObservable.add((function(e){if(i.prePassRenderer&&i.subSurfaceConfiguration){var t=l.texelSize;e.setFloat("metersPerUnit",i.subSurfaceConfiguration.metersPerUnit),e.setFloat2("texelSize",t.x,t.y),e.setTexture("irradianceSampler",i.prePassRenderer.prePassRT.textures[i.prePassRenderer.getIndex(g.a.PREPASS_IRRADIANCE_TEXTURE_TYPE)]),e.setTexture("depthSampler",i.prePassRenderer.prePassRT.textures[i.prePassRenderer.getIndex(g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)]),e.setTexture("albedoSampler",i.prePassRenderer.prePassRT.textures[i.prePassRenderer.getIndex(g.a.PREPASS_ALBEDO_TEXTURE_TYPE)]),e.setFloat2("viewportSize",Math.tan(i.activeCamera.fov/2)*i.getEngine().getAspectRatio(i.activeCamera,!0),Math.tan(i.activeCamera.fov/2)),e.setArray3("diffusionS",i.subSurfaceConfiguration.ssDiffusionS),e.setArray("diffusionD",i.subSurfaceConfiguration.ssDiffusionD),e.setArray("filterRadii",i.subSurfaceConfiguration.ssFilterRadii)}else m.a.Error("PrePass and subsurface configuration needs to be enabled for subsurface scattering.")})),l}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"SubSurfaceScatteringPostProcess"},t}(li),yp=function(){function e(t){this._ssDiffusionS=[],this._ssFilterRadii=[],this._ssDiffusionD=[],this.enabled=!1,this.name=Me.a.NAME_SUBSURFACE,this.ssDiffusionProfileColors=[],this.metersPerUnit=1,this.texturesRequired=[g.a.PREPASS_DEPTHNORMAL_TEXTURE_TYPE,g.a.PREPASS_ALBEDO_TEXTURE_TYPE,g.a.PREPASS_COLOR_TEXTURE_TYPE,g.a.PREPASS_IRRADIANCE_TEXTURE_TYPE],this.addDiffusionProfile(new s.a(1,1,1)),this._scene=t,e._SceneComponentInitialization(this._scene)}return Object.defineProperty(e.prototype,"ssDiffusionS",{get:function(){return this._ssDiffusionS},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ssDiffusionD",{get:function(){return this._ssDiffusionD},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ssFilterRadii",{get:function(){return this._ssFilterRadii},enumerable:!1,configurable:!0}),e.prototype.addDiffusionProfile=function(e){if(this.ssDiffusionD.length>=5)return m.a.Error("You already reached the maximum number of diffusion profiles."),0;for(var t=0;t<this._ssDiffusionS.length/3;t++)if(this._ssDiffusionS[3*t]===e.r&&this._ssDiffusionS[3*t+1]===e.g&&this._ssDiffusionS[3*t+2]===e.b)return t;return this._ssDiffusionS.push(e.r,e.b,e.g),this._ssDiffusionD.push(Math.max(Math.max(e.r,e.b),e.g)),this._ssFilterRadii.push(this.getDiffusionProfileParameters(e)),this.ssDiffusionProfileColors.push(e),this._ssDiffusionD.length-1},e.prototype.createPostProcess=function(){return this.postProcess=new bp("subSurfaceScattering",this._scene,1,null,void 0,this._scene.getEngine()),this.postProcess.autoClear=!1,this.postProcess},e.prototype.clearAllDiffusionProfiles=function(){this._ssDiffusionD=[],this._ssDiffusionS=[],this._ssFilterRadii=[],this.ssDiffusionProfileColors=[]},e.prototype.dispose=function(){this.clearAllDiffusionProfiles(),this.postProcess.dispose()},e.prototype.getDiffusionProfileParameters=function(e){var t=Math.max(e.r,e.g,e.b);return this._sampleBurleyDiffusionProfile(.997,t)},e.prototype._sampleBurleyDiffusionProfile=function(e,t){var i=1+4*(e=1-e)*(2*e+Math.sqrt(1+4*e*e)),n=Math.pow(i,-1/3),r=1+i*n*n+n;return 3*Math.log(r/(4*e))*t},e._SceneComponentInitialization=function(e){throw Re.a.WarnImport("PrePassRendererSceneComponent")},e}();n.a.AddParser(Me.a.NAME_SUBSURFACE,(function(e,t){if(void 0!==e.ssDiffusionProfileColors&&null!==e.ssDiffusionProfileColors&&(t.enableSubSurfaceForPrePass(),t.subSurfaceConfiguration))for(var i=0,n=e.ssDiffusionProfileColors.length;i<n;i++){var r=e.ssDiffusionProfileColors[i];t.subSurfaceConfiguration.addDiffusionProfile(new s.a(r.r,r.g,r.b))}})),Object.defineProperty(Q.a.prototype,"subSurfaceConfiguration",{get:function(){return this._subSurfaceConfiguration},set:function(e){e&&this.enablePrePassRenderer()&&(this._subSurfaceConfiguration=e)},enumerable:!0,configurable:!0}),Q.a.prototype.enableSubSurfaceForPrePass=function(){if(this._subSurfaceConfiguration)return this._subSurfaceConfiguration;var e=this.enablePrePassRenderer();return e?(this._subSurfaceConfiguration=new yp(this),e.addEffectConfiguration(this._subSurfaceConfiguration),this._subSurfaceConfiguration):null},Q.a.prototype.disableSubSurfaceForPrePass=function(){this._subSurfaceConfiguration&&(this._subSurfaceConfiguration.dispose(),this._subSurfaceConfiguration=null)};var Tp=function(){function e(e){this.name=Me.a.NAME_PREPASSRENDERER,this.scene=e}return e.prototype.register=function(){},e.prototype.serialize=function(e){if(this.scene.subSurfaceConfiguration){var t=this.scene.subSurfaceConfiguration.ssDiffusionProfileColors;e.ssDiffusionProfileColors=[];for(var i=0;i<t.length;i++)e.ssDiffusionProfileColors.push({r:t[i].r,g:t[i].g,b:t[i].b})}},e.prototype.addFromContainer=function(e){},e.prototype.removeFromContainer=function(e,t){this.scene.prePassRenderer&&this.scene.subSurfaceConfiguration&&this.scene.subSurfaceConfiguration.clearAllDiffusionProfiles()},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e}();yp._SceneComponentInitialization=function(e){var t=e._getComponent(Me.a.NAME_SUBSURFACE);t||(t=new Tp(e),e._addComponent(t))};var Ep="#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}";ai.a.ShadersStore.outlinePixelShader=Ep;var Sp="\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\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 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\nvec3 offsetPosition=positionUpdated+(normalUpdated*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(uvUpdated,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";ai.a.ShadersStore.outlineVertexShader=Sp;Q.a.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new Ap(this)),this._outlineRenderer},Object.defineProperty(be.a.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(be.a.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var Ap=function(){function e(e){this.name=Me.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(Me.a.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(Me.a.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype.render=function(e,t,i){var n=this;void 0===i&&(i=!1);var r=this.scene,o=r.getEngine(),a=o.getCaps().instancedArrays&&(null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id]||e.getRenderingMesh().hasThinInstances);if(this.isReady(e,a)){var s=e.getMesh(),c=s._internalAbstractMeshDataInfo._actAsRegularMesh?s:null,l=e.getRenderingMesh(),u=c||l,h=e.getMaterial();if(h&&r.activeCamera){if(o.enableEffect(this._effect),h.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(r.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",i?0:l.outlineWidth),this._effect.setColor4("color",i?l.overlayColor:l.outlineColor,i?l.overlayAlpha:h.alpha),this._effect.setMatrix("viewProjection",r.getTransformMatrix()),this._effect.setMatrix("world",u.getWorldMatrix()),l.useBones&&l.computeBonesUsingShaders&&l.skeleton&&this._effect.setMatrices("mBones",l.skeleton.getTransformMatrices(l)),ro.a.BindMorphTargetParameters(l,this._effect),l._bind(e,this._effect,h.fillMode),h&&h.needAlphaTesting()){var d=h.getAlphaTestTexture();d&&(this._effect.setTexture("diffuseSampler",d),this._effect.setMatrix("diffuseMatrix",d.getTextureMatrix()))}o.setZOffset(-this.zOffset),l._processRendering(u,e,this._effect,h.fillMode,t,a,(function(e,t){n._effect.setMatrix("world",t)})),o.setZOffset(0)}}},e.prototype.isReady=function(e,t){var i=[],n=[Qi.b.PositionKind,Qi.b.NormalKind],r=e.getMesh(),o=e.getMaterial();o&&(o.needAlphaTesting()&&(i.push("#define ALPHATEST"),r.isVerticesDataPresent(Qi.b.UVKind)&&(n.push(Qi.b.UVKind),i.push("#define UV1")),r.isVerticesDataPresent(Qi.b.UV2Kind)&&(n.push(Qi.b.UV2Kind),i.push("#define UV2"))),o.useLogarithmicDepth&&i.push("#define LOGARITHMICDEPTH")),r.useBones&&r.computeBonesUsingShaders?(n.push(Qi.b.MatricesIndicesKind),n.push(Qi.b.MatricesWeightsKind),r.numBoneInfluencers>4&&(n.push(Qi.b.MatricesIndicesExtraKind),n.push(Qi.b.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),i.push("#define BonesPerMesh "+(r.skeleton?r.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0");var a=r.morphTargetManager,s=0;a&&a.numInfluencers>0&&(s=a.numInfluencers,i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+s),ro.a.PrepareAttributesForMorphTargetsInfluencers(n,r,s)),t&&(i.push("#define INSTANCES"),ro.a.PushAttributesForInstances(n),e.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES"));var c=i.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this.scene.getEngine().createEffect("outline",n,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences"],["diffuseSampler"],c,void 0,void 0,void 0,{maxSimultaneousMorphTargets:s})),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(t,i,n){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var r=i.getMaterial();r&&r.needAlphaBlendingForMesh(t)&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(g.a.REPLACE),this._engine.setStencilFunction(g.a.ALWAYS),this._engine.setStencilMask(e._StencilReference),this._engine.setStencilFunctionReference(e._StencilReference),this.render(i,n,!0),this._engine.setColorWrite(!0),this._engine.setStencilFunction(g.a.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(i,n),this._engine.setDepthWrite(this._savedDepthWrite),r&&r.needAlphaBlendingForMesh(t)&&this._engine.restoreStencilState()}},e.prototype._afterRenderingMesh=function(e,t,i){if(e.renderOverlay){var n=this._engine.getAlphaMode(),r=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(g.a.ALPHA_COMBINE),this.render(t,i,!0),this._engine.setAlphaMode(n),this._engine.setDepthWrite(this._savedDepthWrite),this._engine.alphaState.alphaBlend=r}e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,i),this._engine.setColorWrite(!0))},e._StencilReference=4,e}(),Pp=i(148),Cp=function(e){function t(t,i){var n=e.call(this)||this;return n.name=t,n.animations=new Array,n.isPickable=!1,n.useAlphaForPicking=!1,n.onDisposeObservable=new o.c,n._onAnimationEnd=null,n._endAnimation=function(){n._onAnimationEnd&&n._onAnimationEnd(),n.disposeWhenFinishedAnimating&&n.dispose()},n.color=new s.b(1,1,1,1),n.position=a.e.Zero(),n._manager=i,n._manager.sprites.push(n),n.uniqueId=n._manager.scene.getUniqueId(),n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"manager",{get:function(){return this._manager},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Sprite"},Object.defineProperty(t.prototype,"fromIndex",{get:function(){return this._fromIndex},set:function(e){this.playAnimation(e,this._toIndex,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"toIndex",{get:function(){return this._toIndex},set:function(e){this.playAnimation(this._fromIndex,e,this._loopAnimation,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"loopAnimation",{get:function(){return this._loopAnimation},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,e,this._delay,this._onAnimationEnd)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"delay",{get:function(){return Math.max(this._delay,1)},set:function(e){this.playAnimation(this._fromIndex,this._toIndex,this._loopAnimation,e,this._onAnimationEnd)},enumerable:!1,configurable:!0}),t.prototype.playAnimation=function(t,i,n,r,o){void 0===o&&(o=null),this._onAnimationEnd=o,e.prototype.playAnimation.call(this,t,i,n,r,this._endAnimation)},t.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1);this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.serialize=function(){var e={};return e.name=this.name,e.position=this.position.asArray(),e.color=this.color.asArray(),e.width=this.width,e.height=this.height,e.angle=this.angle,e.cellIndex=this.cellIndex,e.cellRef=this.cellRef,e.invertU=this.invertU,e.invertV=this.invertV,e.disposeWhenFinishedAnimating=this.disposeWhenFinishedAnimating,e.isPickable=this.isPickable,e.isVisible=this.isVisible,e.useAlphaForPicking=this.useAlphaForPicking,e.animationStarted=this.animationStarted,e.fromIndex=this.fromIndex,e.toIndex=this.toIndex,e.loopAnimation=this.loopAnimation,e.delay=this.delay,e},t.Parse=function(e,i){var n=new t(e.name,i);return n.position=a.e.FromArray(e.position),n.color=s.b.FromArray(e.color),n.width=e.width,n.height=e.height,n.angle=e.angle,n.cellIndex=e.cellIndex,n.cellRef=e.cellRef,n.invertU=e.invertU,n.invertV=e.invertV,n.disposeWhenFinishedAnimating=e.disposeWhenFinishedAnimating,n.isPickable=e.isPickable,n.isVisible=e.isVisible,n.useAlphaForPicking=e.useAlphaForPicking,n.fromIndex=e.fromIndex,n.toIndex=e.toIndex,n.loopAnimation=e.loopAnimation,n.delay=e.delay,e.animationStarted&&n.playAnimation(n.fromIndex,n.toIndex,n.loopAnimation,n.delay),n},t}(function(){function e(){this.width=1,this.height=1,this.angle=0,this.invertU=!1,this.invertV=!1,this.isVisible=!0,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._time=0,this._onBaseAnimationEnd=null,this.position={x:1,y:1,z:1},this.color={r:1,g:1,b:1,a:1}}return Object.defineProperty(e.prototype,"animationStarted",{get:function(){return this._animationStarted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fromIndex",{get:function(){return this._fromIndex},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"toIndex",{get:function(){return this._toIndex},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"loopAnimation",{get:function(){return this._loopAnimation},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"delay",{get:function(){return Math.max(this._delay,1)},enumerable:!1,configurable:!0}),e.prototype.playAnimation=function(e,t,i,n,r){this._fromIndex=e,this._toIndex=t,this._loopAnimation=i,this._delay=n||1,this._animationStarted=!0,this._onBaseAnimationEnd=r,e<t?this._direction=1:(this._direction=-1,this._toIndex=e,this._fromIndex=t),this.cellIndex=e,this._time=0},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._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex<this._fromIndex)&&(this._loopAnimation?this.cellIndex=this._direction>0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},e}());Q.a.prototype._internalPickSprites=function(e,t,i,n){if(!gn.a)return null;var r=null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var o=0;o<this.spriteManagers.length;o++){var a=this.spriteManagers[o];if(a.isPickable){var s=a.intersects(e,n,t,i);if(s&&s.hit&&(i||null==r||!(s.distance>=r.distance))&&(r=s,i))break}}return r||new gn.a},Q.a.prototype._internalMultiPickSprites=function(e,t,i){if(!gn.a)return null;var n=new Array;if(!i){if(!this.activeCamera)return null;i=this.activeCamera}if(this.spriteManagers.length>0)for(var r=0;r<this.spriteManagers.length;r++){var o=this.spriteManagers[r];if(o.isPickable){var a=o.multiIntersects(e,i,t);null!==a&&(n=n.concat(a))}}return n},Q.a.prototype.pickSprite=function(e,t,i,n,r){return this._tempSpritePickingRay?(this.createPickingRayInCameraSpaceToRef(e,t,this._tempSpritePickingRay,r),this._internalPickSprites(this._tempSpritePickingRay,i,n,r)):null},Q.a.prototype.pickSpriteWithRay=function(e,t,i,n){if(!this._tempSpritePickingRay)return null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}return Xt.a.TransformToRef(e,n.getViewMatrix(),this._tempSpritePickingRay),this._internalPickSprites(this._tempSpritePickingRay,t,i,n)},Q.a.prototype.multiPickSprite=function(e,t,i,n){return this.createPickingRayInCameraSpaceToRef(e,t,this._tempSpritePickingRay,n),this._internalMultiPickSprites(this._tempSpritePickingRay,i,n)},Q.a.prototype.multiPickSpriteWithRay=function(e,t,i){if(!this._tempSpritePickingRay)return null;if(!i){if(!this.activeCamera)return null;i=this.activeCamera}return Xt.a.TransformToRef(e,i.getViewMatrix(),this._tempSpritePickingRay),this._internalMultiPickSprites(this._tempSpritePickingRay,t,i)},Q.a.prototype.setPointerOverSprite=function(e){this._pointerOverSprite!==e&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(g.a.ACTION_OnPointerOutTrigger,u.a.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=e,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(g.a.ACTION_OnPointerOverTrigger,u.a.CreateNewFromSprite(this._pointerOverSprite,this)))},Q.a.prototype.getPointerOverSprite=function(){return this._pointerOverSprite};var Rp=function(){function e(e){this.name=Me.a.NAME_SPRITE,this.scene=e,this.scene.spriteManagers=new Array,this.scene._tempSpritePickingRay=Xt.a?Xt.a.Zero():null,this.scene.onBeforeSpritesRenderingObservable=new o.c,this.scene.onAfterSpritesRenderingObservable=new o.c,this._spritePredicate=function(e){return!!e.actionManager&&(e.isPickable&&e.actionManager.hasPointerTriggers)}}return e.prototype.register=function(){this.scene._pointerMoveStage.registerStep(Me.a.STEP_POINTERMOVE_SPRITE,this,this._pointerMove),this.scene._pointerDownStage.registerStep(Me.a.STEP_POINTERDOWN_SPRITE,this,this._pointerDown),this.scene._pointerUpStage.registerStep(Me.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,n,r){var o=this.scene.pickSprite(t,i,this._spritePredicate,n,r);return o&&(o.ray=e?e.ray:null),o},e.prototype._pointerMove=function(e,t,i,n,r){var o=this.scene;return n?o.setPointerOverSprite(null):(i=this._pickSpriteButKeepRay(i,e,t,!1,o.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite?(o.setPointerOverSprite(i.pickedSprite),o.doNotHandleCursors||(o._pointerOverSprite&&o._pointerOverSprite.actionManager&&o._pointerOverSprite.actionManager.hoverCursor?r.style.cursor=o._pointerOverSprite.actionManager.hoverCursor:r.style.cursor=o.hoverCursor)):o.setPointerOverSprite(null),i},e.prototype._pointerDown=function(e,t,i,n){var r=this.scene;if(r._pickedDownSprite=null,r.spriteManagers.length>0&&(i=r.pickSprite(e,t,this._spritePredicate,!1,r.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite&&i.pickedSprite.actionManager){switch(r._pickedDownSprite=i.pickedSprite,n.button){case 0:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnLeftPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n));break;case 1:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnCenterPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n));break;case 2:i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnRightPickTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n))}i.pickedSprite.actionManager&&i.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickDownTrigger,u.a.CreateNewFromSprite(i.pickedSprite,r,n))}return i},e.prototype._pointerUp=function(e,t,i,n){var r=this.scene;if(r.spriteManagers.length>0){var o=r.pickSprite(e,t,this._spritePredicate,!1,r.cameraToUseForPointers||void 0);o&&(o.hit&&o.pickedSprite&&o.pickedSprite.actionManager&&(o.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickUpTrigger,u.a.CreateNewFromSprite(o.pickedSprite,r,n)),o.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickTrigger,u.a.CreateNewFromSprite(o.pickedSprite,r,n)))),r._pickedDownSprite&&r._pickedDownSprite.actionManager&&r._pickedDownSprite!==o.pickedSprite&&r._pickedDownSprite.actionManager.processTrigger(g.a.ACTION_OnPickOutTrigger,u.a.CreateNewFromSprite(r._pickedDownSprite,r,n)))}return i},e}();ai.a.IncludesShadersStore.imageProcessingCompatibility="#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif";var xp="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#include<imageProcessingCompatibility>\n}";ai.a.ShadersStore.spritesPixelShader=xp;var Op="\nattribute vec4 position;\nattribute vec2 options;\nattribute vec2 offsets;\nattribute vec2 inverts;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\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=offsets.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-inverts.x),abs(1.0-offset.y-inverts.y));\nvec2 uvPlace=cellInfo.xy;\nvec2 uvSize=cellInfo.zw;\nvUV.x=uvPlace.x+uvSize.x*uvOffset.x;\nvUV.y=uvPlace.y+uvSize.y*uvOffset.y;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}";ai.a.ShadersStore.spritesVertexShader=Op;var Mp=function(){function e(e,t,i,n){if(void 0===i&&(i=.01),void 0===n&&(n=null),this.blendMode=g.a.ALPHA_COMBINE,this.autoResetAlpha=!0,this.disableDepthWrite=!1,this.fogEnabled=!0,this._useVAO=!1,this._useInstancing=!1,this._vertexBuffers={},this._capacity=t,this._epsilon=i,this._engine=e,this._useInstancing=e.getCaps().instancedArrays,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects,this._scene=n,!this._useInstancing){for(var r=[],o=0,a=0;a<t;a++)r.push(o),r.push(o+1),r.push(o+2),r.push(o),r.push(o+2),r.push(o+3),o+=4;this._indexBuffer=e.createIndexBuffer(r)}this._vertexBufferSize=this._useInstancing?16:18,this._vertexData=new Float32Array(t*this._vertexBufferSize*(this._useInstancing?1:4)),this._buffer=new Qi.a(e,this._vertexData,!0,this._vertexBufferSize);var s,c=this._buffer.createVertexBuffer(Qi.b.PositionKind,0,4,this._vertexBufferSize,this._useInstancing),l=this._buffer.createVertexBuffer("options",4,2,this._vertexBufferSize,this._useInstancing),u=6;if(this._useInstancing){var h=new Float32Array([0,0,1,0,1,1,0,1]);this._spriteBuffer=new Qi.a(e,h,!1,2),s=this._spriteBuffer.createVertexBuffer("offsets",0,2)}else s=this._buffer.createVertexBuffer("offsets",u,2,this._vertexBufferSize,this._useInstancing),u+=2;var d=this._buffer.createVertexBuffer("inverts",u,2,this._vertexBufferSize,this._useInstancing),f=this._buffer.createVertexBuffer("cellInfo",u+2,4,this._vertexBufferSize,this._useInstancing),p=this._buffer.createVertexBuffer(Qi.b.ColorKind,u+6,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Qi.b.PositionKind]=c,this._vertexBuffers.options=l,this._vertexBuffers.offsets=s,this._vertexBuffers.inverts=d,this._vertexBuffers.cellInfo=f,this._vertexBuffers[Qi.b.ColorKind]=p,this._effectBase=this._engine.createEffect("sprites",[Qi.b.PositionKind,"options","offsets","inverts","cellInfo",Qi.b.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._scene&&(this._effectFog=this._scene.getEngine().createEffect("sprites",[Qi.b.PositionKind,"options","offsets","inverts","cellInfo",Qi.b.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG"))}return Object.defineProperty(e.prototype,"capacity",{get:function(){return this._capacity},enumerable:!1,configurable:!0}),e.prototype.render=function(e,t,i,n,r){if(void 0===r&&(r=null),this.texture&&this.texture.isReady()&&e.length){var o=this._effectBase,a=!1;if(this.fogEnabled&&this._scene&&this._scene.fogEnabled&&0!==this._scene.fogMode&&(o=this._effectFog,a=!0),o.isReady()){for(var s=this._engine,c=!(!this._scene||!this._scene.useRightHandedSystem),l=this.texture.getBaseSize(),u=Math.min(this._capacity,e.length),h=0,d=!0,f=0;f<u;f++){var p=e[f];p&&p.isVisible&&(d=!1,p._animate(t),this._appendSpriteVertex(h++,p,0,0,l,c,r),this._useInstancing||(this._appendSpriteVertex(h++,p,1,0,l,c,r),this._appendSpriteVertex(h++,p,1,1,l,c,r),this._appendSpriteVertex(h++,p,0,1,l,c,r)))}if(!d){this._buffer.update(this._vertexData);var _=s.depthCullingState.cull||!0,m=s.depthCullingState.zOffset;if(c&&this._scene.getEngine().setState(_,m,!1,!1),s.enableEffect(o),o.setTexture("diffuseSampler",this.texture),o.setMatrix("view",i),o.setMatrix("projection",n),a){var v=this._scene;o.setFloat4("vFogInfos",v.fogMode,v.fogStart,v.fogEnd,v.fogDensity),o.setColor3("vFogColor",v.fogColor)}this._useVAO?(this._vertexArrayObject||(this._vertexArrayObject=s.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,o)),s.bindVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):s.bindBuffers(this._vertexBuffers,this._indexBuffer,o),s.depthCullingState.depthFunc=g.a.LEQUAL,this.disableDepthWrite||(o.setBool("alphaTest",!0),s.setColorWrite(!1),this._useInstancing?s.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,h):s.drawElementsType(g.a.MATERIAL_TriangleFillMode,0,h/4*6),s.setColorWrite(!0),o.setBool("alphaTest",!1)),s.setAlphaMode(this.blendMode),this._useInstancing?s.drawArraysType(g.a.MATERIAL_TriangleFanDrawMode,0,4,h):s.drawElementsType(g.a.MATERIAL_TriangleFillMode,0,h/4*6),this.autoResetAlpha&&s.setAlphaMode(g.a.ALPHA_DISABLE),c&&this._scene.getEngine().setState(_,m,!1,!0),s.unbindInstanceAttributes()}}}},e.prototype._appendSpriteVertex=function(e,t,i,n,r,o,a){var s=e*this._vertexBufferSize;if(0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===n?n=this._epsilon:1===n&&(n=1-this._epsilon),a)a(t,r);else{t.cellIndex||(t.cellIndex=0);var c=r.width/this.cellWidth,l=t.cellIndex/c>>0;t._xOffset=(t.cellIndex-l*c)*this.cellWidth/r.width,t._yOffset=l*this.cellHeight/r.height,t._xSize=this.cellWidth,t._ySize=this.cellHeight}this._vertexData[s]=t.position.x,this._vertexData[s+1]=t.position.y,this._vertexData[s+2]=t.position.z,this._vertexData[s+3]=t.angle,this._vertexData[s+4]=t.width,this._vertexData[s+5]=t.height,this._useInstancing?s-=2:(this._vertexData[s+6]=i,this._vertexData[s+7]=n),this._vertexData[s+8]=o?t.invertU?0:1:t.invertU?1:0,this._vertexData[s+9]=t.invertV?1:0,this._vertexData[s+10]=t._xOffset,this._vertexData[s+11]=t._yOffset,this._vertexData[s+12]=t._xSize/r.width,this._vertexData[s+13]=t._ySize/r.height,this._vertexData[s+14]=t.color.r,this._vertexData[s+15]=t.color.g,this._vertexData[s+16]=t.color.b,this._vertexData[s+17]=t.color.a},e.prototype.dispose=function(){this._buffer&&(this._buffer.dispose(),this._buffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._vertexArrayObject&&(this._engine.releaseVertexArrayObject(this._vertexArrayObject),this._vertexArrayObject=null),this.texture&&(this.texture.dispose(),this.texture=null)},e}(),Ip=function(){function e(e,t,i,n,r,a,s,c,l){var u=this;void 0===a&&(a=.01),void 0===s&&(s=Ke.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=!1),void 0===l&&(l=null),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.isPickable=!1,this.onDisposeObservable=new o.c,this.disableDepthWrite=!1,this._packedAndReady=!1,this._customUpdate=function(e,t){e.cellRef||(e.cellIndex=0);var i=e.cellIndex;"number"==typeof i&&isFinite(i)&&Math.floor(i)===i&&(e.cellRef=u._spriteMap[e.cellIndex]),e._xOffset=u._cellData[e.cellRef].frame.x/t.width,e._yOffset=u._cellData[e.cellRef].frame.y/t.height,e._xSize=u._cellData[e.cellRef].frame.w,e._ySize=u._cellData[e.cellRef].frame.h},r||(r=Se.a.LastCreatedScene),r._getComponent(Me.a.NAME_SPRITE)||r._addComponent(new Rp(r)),this._fromPacked=c,this._scene=r;var h=this._scene.getEngine();if(this._spriteRenderer=new Mp(h,i,a,r),n.width&&n.height)this.cellWidth=n.width,this.cellHeight=n.height;else{if(void 0===n)return void(this._spriteRenderer=null);this.cellWidth=n,this.cellHeight=n}this._scene.spriteManagers.push(this),this.uniqueId=this.scene.getUniqueId(),t&&(this.texture=new Ke.a(t,r,!0,!1,s)),this._fromPacked&&this._makePacked(t,l)}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"children",{get:function(){return this.sprites},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"capacity",{get:function(){return this._spriteRenderer.capacity},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){return this._spriteRenderer.texture},set:function(e){e.wrapU=Ke.a.CLAMP_ADDRESSMODE,e.wrapV=Ke.a.CLAMP_ADDRESSMODE,this._spriteRenderer.texture=e,this._textureContent=null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellWidth",{get:function(){return this._spriteRenderer.cellWidth},set:function(e){this._spriteRenderer.cellWidth=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"cellHeight",{get:function(){return this._spriteRenderer.cellHeight},set:function(e){this._spriteRenderer.cellHeight=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fogEnabled",{get:function(){return this._spriteRenderer.fogEnabled},set:function(e){this._spriteRenderer.fogEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"blendMode",{get:function(){return this._spriteRenderer.blendMode},set:function(e){this._spriteRenderer.blendMode=e},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"SpriteManager"},e.prototype._makePacked=function(e,t){var i=this;if(null!==t)try{var n=void 0;if((n="string"==typeof t?JSON.parse(t):t).frames.length){for(var r={},o=0;o<n.frames.length;o++){var a=n.frames[o];if("string"!=typeof Object.keys(a)[0])throw new Error("Invalid JSON Format. Check the frame values and make sure the name is the first parameter.");r[a[Object.keys(a)[0]]]=a}n.frames=r}var s=Reflect.ownKeys(n.frames);this._spriteMap=s,this._packedAndReady=!0,this._cellData=n.frames}catch(e){throw this._fromPacked=!1,this._packedAndReady=!1,new Error("Invalid JSON from string. Spritesheet managed with constant cell size.")}else{var c=/\./g,l=void 0;do{l=c.lastIndex,c.test(e)}while(c.lastIndex>0);var u=e.substring(0,l-1)+".json",h=new XMLHttpRequest;h.open("GET",u,!0),h.onerror=function(){m.a.Error("JSON ERROR: Unable to load JSON file."),i._fromPacked=!1,i._packedAndReady=!1},h.onload=function(){try{var e=JSON.parse(h.response),t=Reflect.ownKeys(e.frames);i._spriteMap=t,i._packedAndReady=!0,i._cellData=e.frames}catch(e){throw i._fromPacked=!1,i._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}},h.send()}},e.prototype._checkTextureAlpha=function(e,t,i,n,r){if(!e.useAlphaForPicking||!this.texture)return!0;var o=this.texture.getSize();this._textureContent||(this._textureContent=new Uint8Array(o.width*o.height*4),this.texture.readPixels(0,0,this._textureContent));var s=a.c.Vector3[0];s.copyFrom(t.direction),s.normalize(),s.scaleInPlace(i),s.addInPlace(t.origin);var c=(s.x-n.x)/(r.x-n.x)-.5,l=1-(s.y-n.y)/(r.y-n.y)-.5,u=e.angle,h=c*Math.cos(u)-l*Math.sin(u)+.5,d=c*Math.sin(u)+l*Math.cos(u)+.5,f=e._xOffset*o.width+h*e._xSize|0,p=e._yOffset*o.height+d*e._ySize|0;return this._textureContent[4*(f+p*o.width)+3]>.5},e.prototype.intersects=function(e,t,i,n){for(var r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=Number.MAX_VALUE,l=null,u=a.c.Vector3[0],h=a.c.Vector3[1],d=t.getViewMatrix(),f=0;f<r;f++){var p=this.sprites[f];if(p){if(i){if(!i(p))continue}else if(!p.isPickable)continue;if(a.e.TransformCoordinatesToRef(p.position,d,h),o.copyFromFloats(h.x-p.width/2,h.y-p.height/2,h.z),s.copyFromFloats(h.x+p.width/2,h.y+p.height/2,h.z),e.intersectsBoxMinMax(o,s)){var _=a.e.Distance(h,e.origin);if(c>_){if(!this._checkTextureAlpha(p,e,_,o,s))continue;if(c=_,l=p,n)break}}}}if(l){var m=new gn.a;d.invertToRef(a.c.Matrix[0]),m.hit=!0,m.pickedSprite=l,m.distance=c;var g=a.c.Vector3[2];return g.copyFrom(e.direction),g.normalize(),g.scaleInPlace(c),e.origin.addToRef(g,u),m.pickedPoint=a.e.TransformCoordinates(u,a.c.Matrix[0]),m}return null},e.prototype.multiIntersects=function(e,t,i){for(var n,r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=[],l=a.c.Vector3[0].copyFromFloats(0,0,0),u=a.c.Vector3[1].copyFromFloats(0,0,0),h=t.getViewMatrix(),d=0;d<r;d++){var f=this.sprites[d];if(f){if(i){if(!i(f))continue}else if(!f.isPickable)continue;if(a.e.TransformCoordinatesToRef(f.position,h,u),o.copyFromFloats(u.x-f.width/2,u.y-f.height/2,u.z),s.copyFromFloats(u.x+f.width/2,u.y+f.height/2,u.z),e.intersectsBoxMinMax(o,s)){if(n=a.e.Distance(u,e.origin),!this._checkTextureAlpha(f,e,n,o,s))continue;var p=new gn.a;c.push(p),h.invertToRef(a.c.Matrix[0]),p.hit=!0,p.pickedSprite=f,p.distance=n;var _=a.c.Vector3[2];_.copyFrom(e.direction),_.normalize(),_.scaleInPlace(n),e.origin.addToRef(_,l),p.pickedPoint=a.e.TransformCoordinates(l,a.c.Matrix[0])}}}return c},e.prototype.render=function(){if(!this._fromPacked||this._packedAndReady&&this._spriteMap&&this._cellData){var e=this._scene.getEngine().getDeltaTime();this._packedAndReady?this._spriteRenderer.render(this.sprites,e,this._scene.getViewMatrix(),this._scene.getProjectionMatrix(),this._customUpdate):this._spriteRenderer.render(this.sprites,e,this._scene.getViewMatrix(),this._scene.getProjectionMatrix())}},e.prototype.dispose=function(){this._spriteRenderer&&(this._spriteRenderer.dispose(),this._spriteRenderer=null),this._textureContent=null;var e=this._scene.spriteManagers.indexOf(this);this._scene.spriteManagers.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},e.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};t.name=this.name,t.capacity=this.capacity,t.cellWidth=this.cellWidth,t.cellHeight=this.cellHeight,this.texture&&(e?t.texture=this.texture.serialize():(t.textureUrl=this.texture.name,t.invertY=this.texture._invertY)),t.sprites=[];for(var i=0,n=this.sprites;i<n.length;i++){var r=n[i];t.sprites.push(r.serialize())}return t},e.Parse=function(t,i,n){var r=new e(t.name,"",t.capacity,{width:t.cellWidth,height:t.cellHeight},i);t.texture?r.texture=Ke.a.Parse(t.texture,i,n):t.textureName&&(r.texture=new Ke.a(n+t.textureUrl,i,!1,void 0===t.invertY||t.invertY));for(var o=0,a=t.sprites;o<a.length;o++){var s=a[o];Cp.Parse(s,r)}return r},e.ParseFromFileAsync=function(t,i,n,r){return void 0===r&&(r=""),new Promise((function(o,a){var s=new V.a;s.addEventListener("readystatechange",(function(){if(4==s.readyState)if(200==s.status){var i=JSON.parse(s.responseText),c=e.Parse(i,n||Se.a.LastCreatedScene,r);t&&(c.name=t),o(c)}else a("Unable to load the sprite manager")})),s.open("GET",i),s.send()}))},e.CreateFromSnippetAsync=function(t,i,n){var r=this;return void 0===n&&(n=""),"_BLANK"===t?Promise.resolve(new e("Default sprite manager","//playground.babylonjs.com/textures/player.png",500,64,i)):new Promise((function(o,a){var s=new V.a;s.addEventListener("readystatechange",(function(){if(4==s.readyState)if(200==s.status){var r=JSON.parse(JSON.parse(s.responseText).jsonPayload),c=JSON.parse(r.spriteManager),l=e.Parse(c,i||Se.a.LastCreatedScene,n);l.snippetId=t,o(l)}else a("Unable to load the snippet "+t)})),s.open("GET",r.SnippetUrl+"/"+t.replace(/#/g,"/")),s.send()}))},e.SnippetUrl="https://snippet.babylonjs.com",e}(),Dp="precision highp float;\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nuniform float time;\nuniform float spriteCount;\nuniform sampler2D spriteSheet;\nuniform vec2 spriteMapSize;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform sampler2D frameMap;\nuniform sampler2D tileMaps[LAYERS];\nuniform sampler2D animationMap;\nuniform vec3 colorMul;\nfloat mt;\nconst float fdStep=1./4.;\nconst float aFrameSteps=1./MAX_ANIMATION_FRAMES;\nmat4 getFrameData(float frameID){\nfloat fX=frameID/spriteCount;\nreturn mat4(\ntexture2D(frameMap,vec2(fX,0.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*1.),0.),\ntexture2D(frameMap,vec2(fX,fdStep*2.),0.),\nvec4(0.)\n);\n}\nvoid main(){\nvec4 color=vec4(0.);\nvec2 tileUV=fract(tUV);\n#ifdef FLIPU\ntileUV.y=1.0-tileUV.y;\n#endif\nvec2 tileID=floor(tUV);\nvec2 sheetUnits=1./spriteMapSize;\nfloat spriteUnits=1./spriteCount;\nvec2 stageUnits=1./stageSize;\nfor(int i=0; i<LAYERS; i++) {\nfloat frameID;\n#define LAYER_ID_SWITCH\nvec4 animationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,0.),0.);\nif(animationData.y>0.) {\nmt=mod(time*animationData.z,1.0);\nfor(float f=0.; f<MAX_ANIMATION_FRAMES; f++){\nif(animationData.y>mt){\nframeID=animationData.x;\nbreak;\n}\nanimationData=texture2D(animationMap,vec2((frameID+0.5)/spriteCount,aFrameSteps*f),0.);\n}\n}\n\nmat4 frameData=getFrameData(frameID+0.5);\nvec2 frameSize=(frameData[0].wz)/spriteMapSize;\nvec2 offset=frameData[0].xy*sheetUnits;\nvec2 ratio=frameData[2].xy/frameData[0].wz;\n\nif (frameData[2].z == 1.){\ntileUV.xy=tileUV.yx;\n}\nif (i == 0){\ncolor=texture2D(spriteSheet,tileUV*frameSize+offset);\n} else {\nvec4 nc=texture2D(spriteSheet,tileUV*frameSize+offset);\nfloat alpha=min(color.a+nc.a,1.0);\nvec3 mixed=mix(color.xyz,nc.xyz,nc.a);\ncolor=vec4(mixed,alpha);\n}\n}\ncolor.xyz*=colorMul;\ngl_FragColor=color;\n}";ai.a.ShadersStore.spriteMapPixelShader=Dp;var Np="precision highp float;\n\nattribute vec3 position;\nattribute vec3 normal;\nattribute vec2 uv;\n\nvarying vec3 vPosition;\nvarying vec2 vUV;\nvarying vec2 tUV;\nvarying vec2 stageUnits;\nvarying vec2 levelUnits;\nvarying vec2 tileID;\n\nuniform float time;\nuniform mat4 worldViewProjection;\nuniform vec2 outputSize;\nuniform vec2 stageSize;\nuniform vec2 spriteMapSize;\nuniform float stageScale;\nvoid main() {\nvec4 p=vec4( position,1. );\nvPosition=p.xyz;\nvUV=uv;\ntUV=uv*stageSize;\ngl_Position=worldViewProjection*p;\n}";ai.a.ShadersStore.spriteMapVertexShader=Np;var Lp,wp=function(){function e(e,t,i,n,r){var o=this;this.name=e,this.sprites=[],this.atlasJSON=t,this.sprites=this.atlasJSON.frames,this.spriteSheet=i,this.options=n,n.stageSize=n.stageSize||new a.d(1,1),n.outputSize=n.outputSize||n.stageSize,n.outputPosition=n.outputPosition||a.e.Zero(),n.outputRotation=n.outputRotation||a.e.Zero(),n.layerCount=n.layerCount||1,n.maxAnimationFrames=n.maxAnimationFrames||0,n.baseTile=n.baseTile||0,n.flipU=n.flipU||!1,n.colorMultiply=n.colorMultiply||new a.e(1,1,1),this._scene=r,this._frameMap=this._createFrameBuffer(),this._tileMaps=new Array;for(var s=0;s<n.layerCount;s++)this._tileMaps.push(this._createTileBuffer(null,s));this._animationMap=this._createTileAnimationBuffer(null);var c=[];c.push("#define LAYERS "+n.layerCount),n.flipU&&c.push("#define FLIPU"),c.push("#define MAX_ANIMATION_FRAMES "+n.maxAnimationFrames+".0");var l,u=ai.a.ShadersStore.spriteMapPixelShader;if(1===this._scene.getEngine().webGLVersion){l="";for(s=0;s<n.layerCount;s++)l+="if ("+s+" == i) { frameID = texture2D(tileMaps["+s+"], (tileID + 0.5) / stageSize, 0.).x; }"}else{l="switch(i) {";for(s=0;s<n.layerCount;s++)l+="case "+s+" : frameID = texture(tileMaps["+s+"], (tileID + 0.5) / stageSize, 0.).x;",l+="break;";l+="}"}ai.a.ShadersStore["spriteMap"+this.name+"PixelShader"]=u.replace("#define LAYER_ID_SWITCH",l),this._material=new Lc.a("spriteMap:"+this.name,this._scene,{vertex:"spriteMap",fragment:"spriteMap"+this.name},{defines:c,attributes:["position","normal","uv"],uniforms:["worldViewProjection","time","stageSize","outputSize","spriteMapSize","spriteCount","time","colorMul","mousePosition","curTile","flipU"],samplers:["spriteSheet","frameMap","tileMaps","animationMap"],needAlphaBlending:!0}),this._time=0,this._material.setFloat("spriteCount",this.spriteCount),this._material.setVector2("stageSize",n.stageSize),this._material.setVector2("outputSize",n.outputSize),this._material.setTexture("spriteSheet",this.spriteSheet),this._material.setVector2("spriteMapSize",new a.d(1,1)),this._material.setVector3("colorMul",n.colorMultiply);var h=0,d=function(){o.spriteSheet&&o.spriteSheet.isReady()&&o.spriteSheet._texture?o._material.setVector2("spriteMapSize",new a.d(o.spriteSheet._texture.baseWidth||1,o.spriteSheet._texture.baseHeight||1)):h<100&&setTimeout((function(){h++,d()}),100)};d(),this._material.setVector3("colorMul",n.colorMultiply),this._material.setTexture("frameMap",this._frameMap),this._material.setTextureArray("tileMaps",this._tileMaps),this._material.setTexture("animationMap",this._animationMap),this._material.setFloat("time",this._time),this._output=be.a.CreatePlane(e+":output",1,r,!0),this._output.scaling.x=n.outputSize.x,this._output.scaling.y=n.outputSize.y,this.position=n.outputPosition,this.rotation=n.outputRotation;this._scene.onBeforeRenderObservable.add((function(){o._time+=o._scene.getEngine().getDeltaTime(),o._material.setFloat("time",o._time)})),this._output.material=this._material}return Object.defineProperty(e.prototype,"spriteCount",{get:function(){return this.sprites.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"position",{get:function(){return this._output.position},set:function(e){this._output.position=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rotation",{get:function(){return this._output.rotation},set:function(e){this._output.rotation=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"animationMap",{get:function(){return this._animationMap},set:function(e){var t=e._texture._bufferView,i=this._createTileAnimationBuffer(t);this._animationMap.dispose(),this._animationMap=i,this._material.setTexture("animationMap",this._animationMap)},enumerable:!1,configurable:!0}),e.prototype.getTileID=function(){var e=this.getMousePosition();return e.multiplyInPlace(this.options.stageSize||a.d.Zero()),e.x=Math.floor(e.x),e.y=Math.floor(e.y),e},e.prototype.getMousePosition=function(){var e=this._output,t=this._scene.pick(this._scene.pointerX,this._scene.pointerY,(function(t){return t===e}));if(!t||!t.hit||!t.getTextureCoordinates)return new a.d(-1,-1);var i=t.getTextureCoordinates();return i||new a.d(-1,-1)},e.prototype._createFrameBuffer=function(){for(var e=new Array,t=0;t<this.spriteCount;t++)e.push(0,0,0,0),e.push(0,0,0,0),e.push(0,0,0,0),e.push(0,0,0,0);for(t=0;t<this.spriteCount;t++){var i=this.sprites[t].frame,n=this.sprites[t].spriteSourceSize,r=this.sprites[t].sourceSize,o=this.sprites[t].rotated?1:0,a=this.sprites[t].trimmed?1:0;e[4*t]=i.x,e[4*t+1]=i.y,e[4*t+2]=i.w,e[4*t+3]=i.h,e[4*t+4*this.spriteCount]=n.x,e[4*t+1+4*this.spriteCount]=n.y,e[4*t+3+4*this.spriteCount]=n.h,e[4*t+8*this.spriteCount]=r.w,e[4*t+1+8*this.spriteCount]=r.h,e[4*t+2+8*this.spriteCount]=o,e[4*t+3+8*this.spriteCount]=a}var s=new Float32Array(e);return et.CreateRGBATexture(s,this.spriteCount,4,this._scene,!1,!1,Ke.a.NEAREST_NEAREST,Se.a.TEXTURETYPE_FLOAT)},e.prototype._createTileBuffer=function(e,t){void 0===t&&(t=0);var i=new Array,n=this.options.stageSize.y||0,r=this.options.stageSize.x||0;if(e)i=e;else{var o=this.options.baseTile;0!=t&&(o=0);for(var a=0;a<n;a++)for(var s=0;s<4*r;s+=4)i.push(o,0,0,0)}var c=new Float32Array(i);return et.CreateRGBATexture(c,r,n,this._scene,!1,!1,Ke.a.NEAREST_NEAREST,Se.a.TEXTURETYPE_FLOAT)},e.prototype.changeTiles=function(e,t,i){var n;if(void 0===e&&(e=0),void 0===i&&(i=0),null!==(n=this._tileMaps[e]._texture._bufferView)){var r=new Array;t instanceof a.d?r.push(t):r=t;for(var o=this.options.stageSize.x||0,s=0;s<r.length;s++){var c=r[s];c.x=Math.floor(c.x),c.y=Math.floor(c.y),n[4*c.x+c.y*(4*o)]=i}var l=this._createTileBuffer(n);this._tileMaps[e].dispose(),this._tileMaps[e]=l,this._material.setTextureArray("tileMap",this._tileMaps)}},e.prototype._createTileAnimationBuffer=function(e){var t,i=new Array;if(e)t=e;else{for(var n=0;n<this.spriteCount;n++){i.push(0,0,0,0);for(var r=1;r<(this.options.maxAnimationFrames||4);)i.push(0,0,0,0),r++}t=new Float32Array(i)}return et.CreateRGBATexture(t,this.spriteCount,this.options.maxAnimationFrames||4,this._scene,!1,!1,Ke.a.NEAREST_NEAREST,Se.a.TEXTURETYPE_FLOAT)},e.prototype.addAnimationToTile=function(e,t,i,n,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=1);var o=this._animationMap._texture._bufferView,a=4*e+4*this.spriteCount*t;if(o){o[a]=i,o[a+1]=n,o[a+2]=r;var s=this._createTileAnimationBuffer(o);this._animationMap.dispose(),this._animationMap=s,this._material.setTexture("animationMap",this._animationMap)}},e.prototype.saveTileMaps=function(){for(var e="",t=0;t<this._tileMaps.length;t++)t>0&&(e+="\n\r"),e+=this._tileMaps[t]._texture._bufferView.toString();var i=document.createElement("a");i.href="data:octet/stream;charset=utf-8,"+encodeURI(e),i.target="_blank",i.download=this.name+".tilemaps",i.click(),i.remove()},e.prototype.loadTileMaps=function(e){var t=this,i=new XMLHttpRequest;i.open("GET",e);var n=this.options.layerCount||0;i.onload=function(){for(var e=i.response.split("\n\r"),r=0;r<n;r++){var o=e[r].split(",").map(Number),a=t._createTileBuffer(o);t._tileMaps[r].dispose(),t._tileMaps[r]=a}t._material.setTextureArray("tileMap",t._tileMaps)},i.send()},e.prototype.dispose=function(){this._output.dispose(),this._material.dispose(),this._animationMap.dispose(),this._tileMaps.forEach((function(e){e.dispose()})),this._frameMap.dispose()},e}(),Fp=function(e){function t(t,i,n,r,o,a,s){void 0===o&&(o=null),void 0===a&&(a=.01),void 0===s&&(s=Ke.a.TRILINEAR_SAMPLINGMODE);var c=e.call(this,t,i,n,64,r,a,s,!0,o)||this;return c.name=t,c}return Object(h.d)(t,e),t}(Ip),Bp=i(143),Up=i(141),Vp=i(142),kp=i(139);!function(e){e[e.INIT=0]="INIT",e[e.RUNNING=1]="RUNNING",e[e.DONE=2]="DONE",e[e.ERROR=3]="ERROR"}(Lp||(Lp={}));var zp,Gp=function(){function e(e){this.name=e,this._isCompleted=!1,this._taskState=Lp.INIT}return Object.defineProperty(e.prototype,"isCompleted",{get:function(){return this._isCompleted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"taskState",{get:function(){return this._taskState},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!1,configurable:!0}),e.prototype._setErrorObject=function(e,t){this._errorObject||(this._errorObject={message:e,exception:t})},e.prototype.run=function(e,t,i){var n=this;this._taskState=Lp.RUNNING,this.runTask(e,(function(){n.onDoneCallback(t,i)}),(function(e,t){n.onErrorCallback(i,e,t)}))},e.prototype.runTask=function(e,t,i){throw new Error("runTask is not implemented")},e.prototype.reset=function(){this._taskState=Lp.INIT},e.prototype.onErrorCallback=function(e,t,i){this._taskState=Lp.ERROR,this._errorObject={message:t,exception:i},this.onError&&this.onError(this,t,i),e()},e.prototype.onDoneCallback=function(e,t){try{this._taskState=Lp.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}(),jp=function(e,t,i){this.remainingCount=e,this.totalCount=t,this.task=i},Wp=function(e){function t(t,i,n,r){var o=e.call(this,t)||this;return o.name=t,o.meshesNames=i,o.rootUrl=n,o.sceneFilename=r,o}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){var n=this;pr.LoadAssetContainer(this.rootUrl,this.sceneFilename,e,(function(e){n.loadedContainer=e,n.loadedMeshes=e.meshes,n.loadedParticleSystems=e.particleSystems,n.loadedSkeletons=e.skeletons,n.loadedAnimationGroups=e.animationGroups,t()}),null,(function(e,t,n){i(t,n)}))},t}(Gp),Hp=function(e){function t(t,i,n,r){var o=e.call(this,t)||this;return o.name=t,o.meshesNames=i,o.rootUrl=n,o.sceneFilename=r,o}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){var n=this;pr.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,(function(e,i,r,o){n.loadedMeshes=e,n.loadedParticleSystems=i,n.loadedSkeletons=r,n.loadedAnimationGroups=o,t()}),null,(function(e,t,n){i(t,n)}))},t}(Gp),Xp=function(e){function t(t,i){var n=e.call(this,t)||this;return n.name=t,n.url=i,n}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){var n=this;e._loadFile(this.url,(function(e){n.text=e,t()}),void 0,!1,!1,(function(e,t){e&&i(e.status+" "+e.statusText,t)}))},t}(Gp),Yp=function(e){function t(t,i){var n=e.call(this,t)||this;return n.name=t,n.url=i,n}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){var n=this;e._loadFile(this.url,(function(e){n.data=e,t()}),void 0,!0,!0,(function(e,t){e&&i(e.status+" "+e.statusText,t)}))},t}(Gp),Kp=function(e){function t(t,i){var n=e.call(this,t)||this;return n.name=t,n.url=i,n}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){var n=this,r=new Image;Ce.b.SetCorsBehavior(this.url,r),r.onload=function(){n.image=r,t()},r.onerror=function(e){i("Error loading image",e)},r.src=this.url},t}(Gp),Qp=function(e){function t(t,i,n,r,o){void 0===r&&(r=!0),void 0===o&&(o=Ke.a.TRILINEAR_SAMPLINGMODE);var a=e.call(this,t)||this;return a.name=t,a.url=i,a.noMipmap=n,a.invertY=r,a.samplingMode=o,a}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){this.texture=new Ke.a(this.url,e,this.noMipmap,this.invertY,this.samplingMode,(function(){t()}),(function(e,t){i(e,t)}))},t}(Gp),qp=function(e){function t(t,i,n,r,o){var a=e.call(this,t)||this;return a.name=t,a.url=i,a.extensions=n,a.noMipmap=r,a.files=o,a}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){this.texture=new no(this.url,e,this.extensions,this.noMipmap,this.files,(function(){t()}),(function(e,t){i(e,t)}))},t}(Gp),Zp=function(e){function t(t,i,n,r,o,a,s){void 0===r&&(r=!1),void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=!1);var c=e.call(this,t)||this;return c.name=t,c.url=i,c.size=n,c.noMipmap=r,c.generateHarmonics=o,c.gammaSpace=a,c.reserved=s,c}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){this.texture=new lc(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,(function(){t()}),(function(e,t){i(e,t)}))},t}(Gp),Jp=function(e){function t(t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var a=e.call(this,t)||this;return a.name=t,a.url=i,a.size=n,a.noMipmap=r,a.gammaSpace=o,a}return Object(h.d)(t,e),t.prototype.runTask=function(e,t,i){this.texture=new Fc(this.url,e,this.size,this.noMipmap,this.gammaSpace,(function(){t()}),(function(e,t){i(e,t)}))},t}(Gp),$p=function(){function e(e){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new o.c,this.onTaskErrorObservable=new o.c,this.onTasksDoneObservable=new o.c,this.onProgressObservable=new o.c,this.useDefaultLoadingScreen=!0,this.autoHideLoadingUI=!0,this._scene=e}return e.prototype.addContainerTask=function(e,t,i,n){var r=new Wp(e,t,i,n);return this._tasks.push(r),r},e.prototype.addMeshTask=function(e,t,i,n){var r=new Hp(e,t,i,n);return this._tasks.push(r),r},e.prototype.addTextFileTask=function(e,t){var i=new Xp(e,t);return this._tasks.push(i),i},e.prototype.addBinaryFileTask=function(e,t){var i=new Yp(e,t);return this._tasks.push(i),i},e.prototype.addImageTask=function(e,t){var i=new Kp(e,t);return this._tasks.push(i),i},e.prototype.addTextureTask=function(e,t,i,n,r){void 0===r&&(r=Ke.a.TRILINEAR_SAMPLINGMODE);var o=new Qp(e,t,i,n,r);return this._tasks.push(o),o},e.prototype.addCubeTextureTask=function(e,t,i,n,r){var o=new qp(e,t,i,n,r);return this._tasks.push(o),o},e.prototype.addHDRCubeTextureTask=function(e,t,i,n,r,o,a){void 0===n&&(n=!1),void 0===r&&(r=!0),void 0===o&&(o=!1),void 0===a&&(a=!1);var s=new Zp(e,t,i,n,r,o,a);return this._tasks.push(s),s},e.prototype.addEquiRectangularCubeTextureAssetTask=function(e,t,i,n,r){void 0===n&&(n=!1),void 0===r&&(r=!0);var o=new Jp(e,t,i,n,r);return this._tasks.push(o),o},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 jp(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){m.a.Error("Error running progress callbacks."),console.log(e)}if(0===this._waitingTasksCount){try{var t=this._tasks.slice();this.onFinish&&this.onFinish(t);for(var i=0,n=t;i<n.length;i++){if((e=n[i]).taskState===Lp.DONE){var r=this._tasks.indexOf(e);r>-1&&this._tasks.splice(r,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){m.a.Error("Error running tasks-done callbacks."),console.log(e)}this._isLoading=!1,this.autoHideLoadingUI&&this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(e){var t=this,i=function(i,n){e._setErrorObject(i,n),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===Lp.INIT&&this._runTask(t)}return this},e.prototype.loadAsync=function(){var e=this;return new Promise((function(t,i){e._isLoading?t():(e.onTasksDoneObservable.addOnce((function(e){e&&e.length?i(e):t()})),e.load())}))},e}(),e_=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:!1,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!1,configurable:!0}),e}(),t_=function(){function e(e,t){this._meshesOrigins=[],this._toCenterVectors=[],this._scaledDirection=a.e.Zero(),this._newPosition=a.e.Zero(),this._centerPosition=a.e.Zero(),this._meshes=e.slice(),t?this._centerMesh=t:this._setCenterMesh();var i=this._meshes.indexOf(this._centerMesh);i>=0&&this._meshes.splice(i,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var n=0;n<this._meshes.length;n++)if(this._meshes[n]){var r=this._meshes[n];this._meshesOrigins[n]=r.getAbsolutePosition().clone(),this._toCenterVectors[n]=a.e.Zero(),r._boundingInfo&&this._centerMesh._boundingInfo&&r._boundingInfo.boundingBox.centerWorld.subtractToRef(this._centerMesh._boundingInfo.boundingBox.centerWorld,this._toCenterVectors[n])}}return e.prototype._setCenterMesh=function(){for(var e=a.e.Zero(),t=a.e.Zero(),i=Number.MAX_VALUE,n=0;n<this._meshes.length;n++){if(this._meshes[n])(o=(r=this._meshes[n]).getBoundingInfo())&&t.addInPlace(o.boundingBox.centerWorld)}e=t.scale(1/this._meshes.length);for(n=0;n<this._meshes.length;n++){var r,o;if(this._meshes[n])if(o=(r=this._meshes[n]).getBoundingInfo()){var s=o.boundingBox.centerWorld.subtract(e).lengthSquared();s<i&&(this._centerMesh=r,i=s)}}},e.prototype.getClassName=function(){return"MeshExploder"},e.prototype.getMeshes=function(){var e=this._meshes.slice();return e.unshift(this._centerMesh),e},e.prototype.explode=function(e){void 0===e&&(e=1);for(var t=0;t<this._meshes.length;t++)this._meshes[t]&&this._meshesOrigins[t]&&this._toCenterVectors[t]&&(this._toCenterVectors[t].scaleToRef(e,this._scaledDirection),this._meshesOrigins[t].addToRef(this._scaledDirection,this._newPosition),this._meshes[t].setAbsolutePosition(this._newPosition));this._centerMesh.setAbsolutePosition(this._centerPosition)},e}(),i_=function(){function e(e,t,i,n,r,o,a,s,c){this.onProcessFileCallback=function(){return!0},this._engine=e,this._currentScene=t,this._sceneLoadedCallback=i,this._progressCallback=n,this._additionalRenderLoopLogicCallback=r,this._textureLoadingCallback=o,this._startingProcessingFilesCallback=a,this._onReloadCallback=s,this._errorCallback=c}return Object.defineProperty(e,"FilesToLoad",{get:function(){return dr.a.FilesToLoad},enumerable:!1,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))},Object.defineProperty(e.prototype,"filesToLoad",{get:function(){return this._filesToLoad},enumerable:!1,configurable:!0}),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,n){var r=this,o=e.createReader(),a=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries((function(e){i.count+=e.length;for(var o=0,s=e;o<s.length;o++){var c=s[o];c.isFile?c.file((function(e){e.correctName=a+e.name,t.push(e),0==--i.count&&n()})):c.isDirectory&&r._traverseFolder(c,t,i,n)}0==--i.count&&n()}))},e.prototype._processFiles=function(t){for(var i=0;i<t.length;i++){var n=t[i].correctName.toLowerCase(),r=n.split(".").pop();this.onProcessFileCallback(t[i],n,r)&&(pr.IsPluginForExtensionAvailable("."+r)&&(this._sceneFileToLoad=t[i]),e.FilesToLoad[n]=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,n=[],r=e.dataTransfer?e.dataTransfer.items:null,o=0;o<this._filesToLoad.length;o++){var a=this._filesToLoad[o],s=a.name.toLowerCase(),c=void 0;if(a.correctName=s,r){var l=r[o];l.getAsEntry?c=l.getAsEntry():l.webkitGetAsEntry&&(c=l.webkitGetAsEntry())}c&&c.isDirectory?n.push(c):i.push(a)}if(0===n.length)this._processFiles(i),this._processReload();else for(var u={count:n.length},h=0,d=n;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&&(m.a.errorsCount>0&&m.a.ClearLogCache(),this._engine.stopRenderLoop()),pr.ShowLoadingScreen=!1,this._engine.displayLoadingUI(),pr.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.hideLoadingUI(),e._engine.runRenderLoop((function(){e.renderFunction()}))}))})).catch((function(t){e._engine.hideLoadingUI(),e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)}))):m.a.Error("Please provide a valid .babylon file.")},e}(),n_=i(146),r_=i(145),o_=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}(),a_=function(e){function t(t,i,n){void 0===t&&(t=0),void 0===i&&(i=1024),void 0===n&&(n=.5);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=i,r.step=n,r}return Object(h.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,n=0;n<e.textures.length;n++){var r=e.textures[n];if(r.canRescale&&!r.getContext){var o=r.getSize();Math.max(o.width,o.height)>this.maximumSize&&(r.scale(this.step),i=!1)}}return i},t}(o_),s_=function(e){function t(t,i,n){void 0===t&&(t=0),void 0===i&&(i=2),void 0===n&&(n=.25);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=i,r.step=n,r._currentScale=-1,r._directionOffset=1,r}return Object(h.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}(o_),c_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),l_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),u_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),h_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),d_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),f_=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.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}(o_),p_=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof be.a))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(t.instances.length>0)&&(!t.skeleton&&!t.hasLODLevels)))},t}return Object(h.d)(t,e),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!1,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,i,n){for(var r=e.meshes.slice(0),o=r.length,a=0;a<o;a++){var s=new Array,c=r[a];if(this._canBeMerged(c)){s.push(c);for(var l=a+1;l<o;l++){var u=r[l];this._canBeMerged(u)&&(u.material===c.material&&u.checkCollisions===c.checkCollisions&&(s.push(u),o--,r.splice(l,1),l--))}s.length<2||be.a.MergeMeshes(s,void 0,!0)}}var h=e;return h.createOrUpdateSelectionOctree&&(null!=n?n&&h.createOrUpdateSelectionOctree():t.UpdateSelectionTree&&h.createOrUpdateSelectionOctree()),!0},t._UpdateSelectionTree=!1,t}(o_),__=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 n=new h_(i);return n.onApply=e,n.onGetDescription=t,this.optimizations.push(n),this},e.LowDegradationAllowed=function(t){var i=new e(t),n=0;return i.addOptimization(new p_(n)),i.addOptimization(new c_(n)),i.addOptimization(new u_(n)),n++,i.addOptimization(new l_(n)),i.addOptimization(new d_(n)),n++,i.addOptimization(new a_(n,1024)),i},e.ModerateDegradationAllowed=function(t){var i=new e(t),n=0;return i.addOptimization(new p_(n)),i.addOptimization(new c_(n)),i.addOptimization(new u_(n)),n++,i.addOptimization(new l_(n)),i.addOptimization(new d_(n)),n++,i.addOptimization(new a_(n,512)),n++,i.addOptimization(new f_(n)),n++,i.addOptimization(new s_(n,2)),i},e.HighDegradationAllowed=function(t){var i=new e(t),n=0;return i.addOptimization(new p_(n)),i.addOptimization(new c_(n)),i.addOptimization(new u_(n)),n++,i.addOptimization(new l_(n)),i.addOptimization(new d_(n)),n++,i.addOptimization(new a_(n,256)),n++,i.addOptimization(new f_(n)),n++,i.addOptimization(new s_(n,4)),i},e}(),m_=function(){function e(e,t,i,n){var r=this;if(void 0===i&&(i=!0),void 0===n&&(n=!1),this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new o.c,this.onNewOptimizationAppliedObservable=new o.c,this.onFailureObservable=new o.c,this._options=t||new __,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),i)for(var a=0,s=0,c=this._options.optimizations;s<c.length;s++){c[s].priority=a++}this._improvementMode=n,this._scene=e||x.a.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add((function(){r._sceneDisposeObserver=null,r.dispose()}))}return Object.defineProperty(e.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(e){this._targetFrameRate=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(e){this._trackerDuration=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!1,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 n=!0,r=!0,o=0;o<i.optimizations.length;o++){var a=i.optimizations[o];a.priority===this._currentPriorityLevel&&(r=!1,n=n&&a.apply(t,this),this.onNewOptimizationAppliedObservable.notifyObservers(a))}if(r)return this._isRunning=!1,void this.onFailureObservable.notifyObservers(this);n&&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,n,r){var o=new e(t,i||__.ModerateDegradationAllowed(),!1);return n&&o.onSuccessObservable.add((function(){n()})),r&&o.onFailureObservable.add((function(){r()})),o.start(),o},e}(),g_=[],v_=function(e,t){g_[e.id]||e.doNotSerialize||(t.vertexData.push(e.serializeVerticeData()),g_[e.id]=!0)},b_=function(e,t){var i={},n=e._geometry;return n&&(e.getScene().getGeometryByID(n.id)||v_(n,t.geometries)),e.serialize&&e.serialize(i),i},y_=function(){function e(){}return e.ClearCache=function(){g_=[]},e.Serialize=function(t){var i,n,r,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 a=t.getPhysicsEngine();a&&(o.physicsEnabled=!0,o.physicsGravity=a.gravity.asArray(),o.physicsEngine=a.getPhysicsPluginName())}t.metadata&&(o.metadata=t.metadata),o.morphTargetManagers=[];for(var s=0,c=t.meshes;s<c.length;s++){var l=(b=c[s]).morphTargetManager;l&&o.morphTargetManagers.push(l.serialize())}for(o.lights=[],i=0;i<t.lights.length;i++)(n=t.lights[i]).doNotSerialize||o.lights.push(n.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.animationGroups&&t.animationGroups.length>0){o.animationGroups=[];for(var h=0;h<t.animationGroups.length;h++){var d=t.animationGroups[h];o.animationGroups.push(d.serialize())}}if(t.reflectionProbes&&t.reflectionProbes.length>0)for(o.reflectionProbes=[],i=0;i<t.reflectionProbes.length;i++){var f=t.reflectionProbes[i];o.reflectionProbes.push(f.serialize())}for(o.materials=[],o.multiMaterials=[],i=0;i<t.materials.length;i++)(r=t.materials[i]).doNotSerialize||o.materials.push(r.serialize());for(o.multiMaterials=[],i=0;i<t.multiMaterials.length;i++){var p=t.multiMaterials[i];o.multiMaterials.push(p.serialize())}for(t.environmentTexture&&(o.environmentTexture=t.environmentTexture.name),o.environmentIntensity=t.environmentIntensity,o.skeletons=[],i=0;i<t.skeletons.length;i++){var _=t.skeletons[i];_.doNotSerialize||o.skeletons.push(_.serialize())}for(o.transformNodes=[],i=0;i<t.transformNodes.length;i++)t.transformNodes[i].doNotSerialize||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=[],g_=[];var m=t.getGeometries();for(i=0;i<m.length;i++){var v=m[i];v.isReady()&&v_(v,o.geometries)}for(o.meshes=[],i=0;i<t.meshes.length;i++){var b;if((b=t.meshes[i])instanceof be.a){var y=b;y.doNotSerialize||y.delayLoadState!==g.a.DELAYLOADSTATE_LOADED&&y.delayLoadState!==g.a.DELAYLOADSTATE_NONE||o.meshes.push(b_(y,o))}}for(o.particleSystems=[],i=0;i<t.particleSystems.length;i++)o.particleSystems.push(t.particleSystems[i].serialize(!1));for(o.postProcesses=[],i=0;i<t.postProcesses.length;i++)o.postProcesses.push(t.postProcesses[i].serialize());t.actionManager&&(o.actions=t.actionManager.serialize("scene"));for(var T=0,E=t._serializableComponents;T<E.length;T++){E[T].serialize(o)}return o},e.SerializeMesh=function(t,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1);var r={};if(e.ClearCache(),t=t instanceof Array?t:[t],i||n)for(var o=0;o<t.length;++o)n&&t[o].getDescendants().forEach((function(e){e instanceof be.a&&t.indexOf(e)<0&&!e.doNotSerialize&&t.push(e)})),i&&t[o].parent&&t.indexOf(t[o].parent)<0&&!t[o].parent.doNotSerialize&&t.push(t[o].parent);return t.forEach((function(e){!function(e,t){if(e.delayLoadState===g.a.DELAYLOADSTATE_LOADED||e.delayLoadState===g.a.DELAYLOADSTATE_NONE){if(e.material&&!e.material.doNotSerialize)if(e.material instanceof tc.a){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()))},n=0,r=e.material.subMaterials;n<r.length;n++){i(r[n])}}}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=[]),v_(o,t.geometries)),e.skeleton&&!e.skeleton.doNotSerialize&&(t.skeletons=t.skeletons||[],t.skeletons.push(e.skeleton.serialize())),t.meshes=t.meshes||[],t.meshes.push(b_(e,t))}}(e,r)})),r},e}(),T_=i(37),E_=function(){function e(){}return e.CreateResizedCopy=function(e,t,i,n){void 0===n&&(n=!0);var r=e.getScene(),o=r.getEngine(),a=new Ni("resized"+e.name,{width:t,height:i},r,!e.noMipmap,!0,e._texture.type,!1,e.samplingMode,!1);a.wrapU=e.wrapU,a.wrapV=e.wrapV,a.uOffset=e.uOffset,a.vOffset=e.vOffset,a.uScale=e.uScale,a.vScale=e.vScale,a.uAng=e.uAng,a.vAng=e.vAng,a.wAng=e.wAng,a.coordinatesIndex=e.coordinatesIndex,a.level=e.level,a.anisotropicFilteringLevel=e.anisotropicFilteringLevel,a._texture.isReady=!1,e.wrapU=Ke.a.CLAMP_ADDRESSMODE,e.wrapV=Ke.a.CLAMP_ADDRESSMODE;var s=new di("pass",1,null,n?Ke.a.BILINEAR_SAMPLINGMODE:Ke.a.NEAREST_SAMPLINGMODE,o,!1,g.a.TEXTURETYPE_UNSIGNED_INT);return s.getEffect().executeWhenCompiled((function(){s.onApply=function(t){t.setTexture("textureSampler",e)};var t=a.getInternalTexture();t&&(r.postProcessManager.directRender([s],t),o.unBindFramebuffer(t),a.disposeFramebufferObjects(),s.dispose(),t.isReady=!0)})),a},e}(),S_=function(){function e(t,i){if(void 0===i&&(i=null),!e.IsSupported(t))throw"Your browser does not support recording so far.";var n=t.getRenderingCanvas();if(!n)throw"The babylon engine must have a canvas to be recorded";this._canvas=n,this._canvas.isRecording=!1,this._options=Object(h.a)(Object(h.a)({},e._defaultOptions),i);var r=this._canvas.captureStream(this._options.fps);if(this._options.audioTracks)for(var o=0,a=this._options.audioTracks;o<a.length;o++){var s=a[o];r.addTrack(s)}this._mediaRecorder=new MediaRecorder(r,{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:!1,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&&Ce.b.Download(e,this._fileName)},e._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},e}(),A_=function(){function e(){}return e.CreateScreenshot=function(t,i,n,r,o){void 0===o&&(o="image/png");var a=e._getScreenshotSize(t,i,n),s=a.height,c=a.width;if(s&&c){Ce.b._ScreenshotCanvas||(Ce.b._ScreenshotCanvas=document.createElement("canvas")),Ce.b._ScreenshotCanvas.width=c,Ce.b._ScreenshotCanvas.height=s;var l=Ce.b._ScreenshotCanvas.getContext("2d"),u=t.getRenderWidth()/t.getRenderHeight(),h=c,d=h/u;d>s&&(h=(d=s)*u);var f=Math.max(0,c-h)/2,p=Math.max(0,s-d)/2,_=t.getRenderingCanvas();l&&_&&l.drawImage(_,f,p,h,d),Ce.b.EncodeScreenshotCanvasData(r,o)}else m.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotAsync=function(t,i,n,r){return void 0===r&&(r="image/png"),new Promise((function(o,a){e.CreateScreenshot(t,i,n,(function(e){void 0!==e?o(e):a(new Error("Data is undefined"))}),r)}))},e.CreateScreenshotUsingRenderTarget=function(t,i,n,r,o,a,s,c,l,u){void 0===o&&(o="image/png"),void 0===a&&(a=1),void 0===s&&(s=!1),void 0===l&&(l=!1),void 0===u&&(u=!1);var h=e._getScreenshotSize(t,i,n),d=h.height,f=h.width,p={width:f,height:d};if(d&&f){var _=t.getRenderingCanvas();if(_){var v={width:_.width,height:_.height};t.setSize(f,d);var b=i.getScene(),y=null,T=b.activeCameras;(b.activeCamera!==i||b.activeCameras&&b.activeCameras.length)&&(y=b.activeCamera,b.activeCamera=i),b.render();var E=new Ni("screenShot",p,b,!1,!1,g.a.TEXTURETYPE_UNSIGNED_INT,!1,Ke.a.NEAREST_SAMPLINGMODE,void 0,u);E.renderList=null,E.samples=a,E.renderSprites=l,E.onAfterRenderObservable.add((function(){Ce.b.DumpFramebuffer(f,d,t,r,o,c)}));var S=function(){b.incrementRenderId(),b.resetCachedMaterial(),E.render(!0),E.dispose(),y&&(b.activeCamera=y),b.activeCameras=T,t.setSize(v.width,v.height),i.getProjectionMatrix(!0)};if(s){var A=new mf("antialiasing",1,b.activeCamera);E.addPostProcess(A),A.getEffect().isReady()?S():A.getEffect().onCompiled=function(){S()}}else S()}else m.a.Error("No rendering canvas found !")}else m.a.Error("Invalid 'size' parameter !")},e.CreateScreenshotUsingRenderTargetAsync=function(t,i,n,r,o,a,s,c){return void 0===r&&(r="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===c&&(c=!1),new Promise((function(l,u){e.CreateScreenshotUsingRenderTarget(t,i,n,(function(e){void 0!==e?l(e):u(new Error("Data is undefined"))}),r,o,a,s,c)}))},e._getScreenshotSize=function(e,t,i){var n=0,r=0;if("object"==typeof i){var o=i.precision?Math.abs(i.precision):1;i.width&&i.height?(n=i.height*o,r=i.width*o):i.width&&!i.height?(r=i.width*o,n=Math.round(r/e.getAspectRatio(t))):i.height&&!i.width?(n=i.height*o,r=Math.round(n*e.getAspectRatio(t))):(r=Math.round(e.getRenderWidth()*o),n=Math.round(r/e.getAspectRatio(t)))}else isNaN(i)||(n=i,r=i);return r&&(r=Math.floor(r)),n&&(n=Math.floor(n)),{height:0|n,width:0|r}},e}();Ce.b.CreateScreenshot=A_.CreateScreenshot,Ce.b.CreateScreenshotAsync=A_.CreateScreenshotAsync,Ce.b.CreateScreenshotUsingRenderTarget=A_.CreateScreenshotUsingRenderTarget,Ce.b.CreateScreenshotUsingRenderTargetAsync=A_.CreateScreenshotUsingRenderTargetAsync,function(e){e[e.Checkbox=0]="Checkbox",e[e.Slider=1]="Slider",e[e.Vector3=2]="Vector3",e[e.Quaternion=3]="Quaternion",e[e.Color3=4]="Color3",e[e.String=5]="String"}(zp||(zp={}));var P_,C_=i(140),R_=function(){function e(e){this.byteOffset=0,this.buffer=e}return e.prototype.loadAsync=function(e){var t=this;return this.buffer.readAsync(this.byteOffset,e).then((function(e){t._dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),t._dataByteOffset=0}))},e.prototype.readUint32=function(){var e=this._dataView.getUint32(this._dataByteOffset,!0);return this._dataByteOffset+=4,this.byteOffset+=4,e},e.prototype.readUint8Array=function(e){var t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._dataByteOffset,e);return this._dataByteOffset+=e,this.byteOffset+=e,t},e.prototype.readString=function(e){return io.a.Decode(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),x_=function(){function e(){}return e._GetStorage=function(){try{return localStorage.setItem("test",""),localStorage.removeItem("test"),localStorage}catch(t){var e={};return{getItem:function(t){var i=e[t];return void 0===i?null:i},setItem:function(t,i){e[t]=i}}}},e.ReadString=function(e,t){var i=this._Storage.getItem(e);return null!==i?i:t},e.WriteString=function(e,t){this._Storage.setItem(e,t)},e.ReadBoolean=function(e,t){var i=this._Storage.getItem(e);return null!==i?"true"===i:t},e.WriteBoolean=function(e,t){this._Storage.setItem(e,t?"true":"false")},e.ReadNumber=function(e,t){var i=this._Storage.getItem(e);return null!==i?parseFloat(i):t},e.WriteNumber=function(e,t){this._Storage.setItem(e,t.toString())},e._Storage=e._GetStorage(),e}(),O_=function(){function e(){this._trackedScene=null}return e.prototype.track=function(e){this._trackedScene=e,this._savedJSON=y_.Serialize(e)},e.prototype.getDelta=function(){if(!this._trackedScene)return null;var e=y_.Serialize(this._trackedScene),t={};for(var i in e)this._compareCollections(i,this._savedJSON[i],e[i],t);return t},e.prototype._compareArray=function(e,t,i,n){if(0===t.length&&0===i.length)return!0;if(t.length&&!isNaN(t[0])||i.length&&!isNaN(i[0])){if(t.length!==i.length)return!1;if(0===t.length)return!0;for(var r=0;r<t.length;r++)if(t[r]!==i[r])return n[e]=i,!1;return!0}var o=[],a=function(){var a=t[r],c=a.uniqueId;o.push(c);var l=i.filter((function(e){return e.uniqueId===c}));if(l.length){var u=l[0],h={};s._compareObjects(a,u,h)||(n[e]||(n[e]=[]),h.__state={id:u.id||u.name},n[e].push(h))}else{h={__state:{deleteId:a.id||a.name}};n[e].push(h)}},s=this;for(r=0;r<t.length;r++)a();for(r=0;r<i.length;r++){var c=i[r],l=c.uniqueId;-1===o.indexOf(l)&&(n[e]||(n[e]=[]),n[e].push(c))}return!0},e.prototype._compareObjects=function(e,t,i){var n=!1;for(var r in e)if(e.hasOwnProperty(r)){var o=e[r],a=t[r],s=!1;Array.isArray(o)?s=JSON.stringify(o)!==JSON.stringify(a):isNaN(o)&&"[object String]"!=Object.prototype.toString.call(o)||(s=o!==a),s&&(n=!0,i[r]=a)}return!n},e.prototype._compareCollections=function(e,t,i,n){if(t!==i&&t&&i)if(Array.isArray(t)&&Array.isArray(i)){if(this._compareArray(e,t,i,n))return}else if("object"==typeof t&&"object"==typeof i){var r={};return void(this._compareObjects(t,i,r)||(n[e]=r))}},e.GetShadowGeneratorById=function(e,t){for(var i=0,n=e.lights.map((function(e){return e.getShadowGenerator()}));i<n.length;i++){var r=n[i];if(r&&r.id===t)return r}return null},e.ApplyDelta=function(e,t){var i=this;"string"==typeof e&&(e=JSON.parse(e));var n=t;for(var r in e){var o=e[r],a=n[r];if(Array.isArray(a)||"shadowGenerators"===r)switch(r){case"cameras":this._ApplyDeltaForEntity(o,t,t.getCameraByID.bind(t),(function(e){return je.a.Parse(e,t)}));break;case"lights":this._ApplyDeltaForEntity(o,t,t.getLightByID.bind(t),(function(e){return kr.a.Parse(e,t)}));break;case"shadowGenerators":this._ApplyDeltaForEntity(o,t,(function(e){return i.GetShadowGeneratorById(t,e)}),(function(e){return Bs.Parse(e,t)}));break;case"meshes":this._ApplyDeltaForEntity(o,t,t.getMeshByID.bind(t),(function(e){return be.a.Parse(e,t,"")}));break;case"skeletons":this._ApplyDeltaForEntity(o,t,t.getSkeletonById.bind(t),(function(e){return tt.Parse(e,t)}));break;case"materials":this._ApplyDeltaForEntity(o,t,t.getMaterialByID.bind(t),(function(e){return xo.a.Parse(e,t,"")}));break;case"multiMaterials":this._ApplyDeltaForEntity(o,t,t.getMaterialByID.bind(t),(function(e){return tc.a.Parse(e,t,"")}));break;case"transformNodes":this._ApplyDeltaForEntity(o,t,t.getTransformNodeByID.bind(t),(function(e){return Nr.a.Parse(e,t,"")}));break;case"particleSystems":this._ApplyDeltaForEntity(o,t,t.getParticleSystemByID.bind(t),(function(e){return dd.Parse(e,t,"")}));break;case"morphTargetManagers":this._ApplyDeltaForEntity(o,t,t.getMorphTargetById.bind(t),(function(e){return hc.Parse(e,t)}));break;case"postProcesses":this._ApplyDeltaForEntity(o,t,t.getPostProcessByName.bind(t),(function(e){return li.Parse(e,t,"")}))}else isNaN(a)?a.fromArray&&a.fromArray(o):n[r]=o}},e._ApplyPropertiesToEntity=function(e,t){for(var i in e){var n=e[i],r=t[i];void 0!==r&&(!isNaN(r)||Array.isArray(r)?t[i]=n:r.fromArray&&r.fromArray(n))}},e._ApplyDeltaForEntity=function(e,t,i,n){for(var r=0,o=e;r<o.length;r++){var a=o[r];if(a.__state&&void 0!==a.__state.id){var s=i(a.__state.id);s&&this._ApplyPropertiesToEntity(a,s)}else if(a.__state&&void 0!==a.__state.deleteId){var c=i(a.__state.deleteId);null==c||c.dispose()}else n(a)}},e}();!function(e){var t=function(){function e(e,t,i,n){var r;void 0===t&&(t=null),void 0===i&&(i=null),void 0===n&&(n=null),t=null!=t?t:function(){return 1},i=null!=i?i:function(){return 1},n=null!=n?n:function(e,t){return e===t?0:1},this._characterToIdx=new Map,this._insertionCosts=new Array(e.length),this._deletionCosts=new Array(e.length),this._substitutionCosts=new Array(e.length);for(var o=0;o<e.length;++o){r=e[o],this._characterToIdx.set(r,o),this._insertionCosts[o]=t(r),this._deletionCosts[o]=i(r),this._substitutionCosts[o]=new Array(e.length);for(var a=o;a<e.length;++a)this._substitutionCosts[o][a]=n(r,e[a])}}return e.prototype.serialize=function(){var e={},t=new Array(this._characterToIdx.size);return this._characterToIdx.forEach((function(e,i){t[e]=i})),e.characters=t,e.insertionCosts=this._insertionCosts,e.deletionCosts=this._deletionCosts,e.substitutionCosts=this._substitutionCosts,JSON.stringify(e)},e.Deserialize=function(t){var i=JSON.parse(t),n=new e(i.characters);return n._insertionCosts=i.insertionCosts,n._deletionCosts=i.deletionCosts,n._substitutionCosts=i.substitutionCosts,n},e.prototype.getCharacterIdx=function(e){return this._characterToIdx.get(e)},e.prototype.getInsertionCost=function(e){return this._insertionCosts[e]},e.prototype.getDeletionCost=function(e){return this._deletionCosts[e]},e.prototype.getSubstitutionCost=function(e,t){var i=Math.min(e,t),n=Math.max(e,t);return this._substitutionCosts[i][n]},e}();e.Alphabet=t;var i=function(){function e(t,i){var n=this;if(t.length>e.MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+e.MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=i,this._characters=t.map((function(e){return n._alphabet.getCharacterIdx(e)}))}return e.prototype.serialize=function(){return JSON.stringify(this._characters)},e.Deserialize=function(t,i){var n=new e([],i);return n._characters=JSON.parse(t),n},e.prototype.distance=function(t){return e._distance(this,t)},e._distance=function(t,i){var n=t._alphabet;if(n!==i._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var r=t._characters,o=i._characters,a=r.length,s=o.length,c=e._costMatrix;c[0][0]=0;for(var l=0;l<a;++l)c[l+1][0]=c[l][0]+n.getInsertionCost(r[l]);for(l=0;l<s;++l)c[0][l+1]=c[0][l]+n.getInsertionCost(o[l]);for(var u=0;u<a;++u)for(var h=0;h<s;++h)e._insertionCost=c[u+1][h]+n.getInsertionCost(o[h]),e._deletionCost=c[u][h+1]+n.getDeletionCost(r[u]),e._substitutionCost=c[u][h]+n.getSubstitutionCost(r[u],o[h]),c[u+1][h+1]=Math.min(e._insertionCost,e._deletionCost,e._substitutionCost);return c[a][s]},e.MAX_SEQUENCE_LENGTH=256,e._costMatrix=Object(h.f)(Array(e.MAX_SEQUENCE_LENGTH+1)).map((function(t){return new Array(e.MAX_SEQUENCE_LENGTH+1)})),e}();e.Sequence=i}(P_||(P_={}));var M_=function(){function e(e){void 0===e&&(e=.01),this._points=[],this._segmentLength=e}return e.prototype.serialize=function(){return JSON.stringify(this)},e.Deserialize=function(t){var i=JSON.parse(t),n=new e(i._segmentLength);return n._points=i._points.map((function(e){return new a.e(e._x,e._y,e._z)})),n},e.prototype.getLength=function(){return this._points.length*this._segmentLength},e.prototype.add=function(e){var t=this,i=this._points.length;if(0===i)this._points.push(e.clone());else for(var n=function(){return t._segmentLength/a.e.Distance(t._points[i-1],e)},r=n();r<=1;r=n()){var o=this._points[i-1].scale(1-r);e.scaleAndAddToRef(r,o),this._points.push(o),++i}},e.prototype.resampleAtTargetResolution=function(t){var i=new e(this.getLength()/t);return this._points.forEach((function(e){i.add(e)})),i},e.prototype.tokenize=function(t){for(var i=[],n=new a.e,r=2;r<this._points.length;++r)e._transformSegmentDirToRef(this._points[r-2],this._points[r-1],this._points[r],n)&&i.push(e._tokenizeSegment(n,t));return i},e._transformSegmentDirToRef=function(t,i,n,r){return i.subtractToRef(t,e._forwardDir),e._forwardDir.normalize(),i.scaleToRef(-1,e._inverseFromVec),e._inverseFromVec.normalize(),!(Math.abs(a.e.Dot(e._forwardDir,e._inverseFromVec))>.98)&&(a.e.CrossToRef(e._forwardDir,e._inverseFromVec,e._upDir),e._upDir.normalize(),a.a.LookAtLHToRef(t,i,e._upDir,e._lookMatrix),n.subtractToRef(i,e._fromToVec),e._fromToVec.normalize(),a.e.TransformNormalToRef(e._fromToVec,e._lookMatrix,r),!0)},e._tokenizeSegment=function(t,i){e._bestMatch=0,e._score=a.e.Dot(t,i[0]),e._bestScore=e._score;for(var n=1;n<i.length;++n)e._score=a.e.Dot(t,i[n]),e._score>e._bestScore&&(e._bestMatch=n,e._bestScore=e._score);return e._bestMatch},e._forwardDir=new a.e,e._inverseFromVec=new a.e,e._upDir=new a.e,e._fromToVec=new a.e,e._lookMatrix=new a.a,e}(),I_=function(){function e(e){this.chars=new Array(e)}return e.Generate=function(t,i,n,r,o){void 0===t&&(t=64),void 0===i&&(i=256),void 0===n&&(n=.1),void 0===r&&(r=.001),void 0===o&&(o=[]);for(var s,c,l=new e(t),u=0;u<t;++u)l.chars[u]=new a.e(Math.random()-.5,Math.random()-.5,Math.random()-.5),l.chars[u].normalize();for(u=0;u<o.length;++u)l.chars[u].copyFrom(o[u]);for(var h,d=new a.e,f=new a.e,p=0;p<i;++p){s=(1-(h=p/(i-1)))*n+h*r;var _=function(e){d.copyFromFloats(0,0,0),l.chars.forEach((function(t){l.chars[e].subtractToRef(t,f),(c=f.lengthSquared())>1e-6&&f.scaleAndAddToRef(1/(f.lengthSquared()*c),d)})),d.scaleInPlace(s),l.chars[e].addInPlace(d),l.chars[e].normalize()};for(u=o.length;u<l.chars.length;++u)_(u)}return l},e.prototype.serialize=function(){return JSON.stringify(this.chars)},e.Deserialize=function(t){for(var i=JSON.parse(t),n=new e(i.length),r=0;r<i.length;++r)n.chars[r]=new a.e(i[r]._x,i[r]._y,i[r]._z);return n},e}(),D_=function(){function e(){this._sequences=[]}return e.prototype.serialize=function(){return JSON.stringify(this._sequences.map((function(e){return e.serialize()})))},e.Deserialize=function(t,i){var n=new e;return n._sequences=JSON.parse(t).map((function(e){return P_.Sequence.Deserialize(e,i)})),n},e.CreateFromTrajectory=function(t,i,n){return e.CreateFromTokenizationPyramid(e._getTokenizationPyramid(t,i),n)},e.CreateFromTokenizationPyramid=function(t,i){var n=new e;return n._sequences=t.map((function(e){return new P_.Sequence(e,i)})),n},e._getTokenizationPyramid=function(t,i,n){void 0===n&&(n=e.FINEST_DESCRIPTOR_RESOLUTION);for(var r=[],o=n;o>4;o=Math.floor(o/2))r.push(t.resampleAtTargetResolution(o).tokenize(i.chars));return r},e.prototype.distance=function(e){for(var t=0,i=0;i<this._sequences.length;++i)t+=Math.pow(2,i)*this._sequences[i].distance(e._sequences[i]);return t},e.FINEST_DESCRIPTOR_RESOLUTION=32,e}(),N_=function(){function e(e){void 0===e&&(e=[]),this._descriptors=e,this._centroidIdx=-1,this._averageDistance=0,this._refreshDescription()}return e.prototype.serialize=function(){var e={};return e.descriptors=this._descriptors.map((function(e){return e.serialize()})),e.centroidIdx=this._centroidIdx,e.averageDistance=this._averageDistance,JSON.stringify(e)},e.Deserialize=function(t,i){var n=JSON.parse(t),r=new e;return r._descriptors=n.descriptors.map((function(e){return D_.Deserialize(e,i)})),r._centroidIdx=n.centroidIdx,r._averageDistance=n.averageDistance,r},e.prototype.add=function(e){this._descriptors.push(e),this._refreshDescription()},e.prototype.getMatchCost=function(e){return e.distance(this._descriptors[this._centroidIdx])/this._averageDistance},e.prototype.getMatchMinimumDistance=function(e){return Math.min.apply(Math,this._descriptors.map((function(t){return t.distance(e)})))},e.prototype._refreshDescription=function(){var t,i=this;this._centroidIdx=-1;for(var n=this._descriptors.map((function(e){return t=0,i._descriptors.forEach((function(i){t+=e.distance(i)})),t})),r=0;r<n.length;++r)(this._centroidIdx<0||n[r]<n[this._centroidIdx])&&(this._centroidIdx=r);this._averageDistance=0,this._descriptors.forEach((function(e){i._averageDistance+=e.distance(i._descriptors[i._centroidIdx])})),this._descriptors.length>0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,e.MIN_AVERAGE_DISTANCE))},e.MIN_AVERAGE_DISTANCE=1,e}(),L_=function(){function e(){this._maximumAllowableMatchCost=4,this._nameToDescribedTrajectory=new Map}return e.prototype.serialize=function(){var e={};return e.maximumAllowableMatchCost=this._maximumAllowableMatchCost,e.vector3Alphabet=this._vector3Alphabet.serialize(),e.levenshteinAlphabet=this._levenshteinAlphabet.serialize(),e.nameToDescribedTrajectory=[],this._nameToDescribedTrajectory.forEach((function(t,i){e.nameToDescribedTrajectory.push(i),e.nameToDescribedTrajectory.push(t.serialize())})),JSON.stringify(e)},e.Deserialize=function(t){var i=JSON.parse(t),n=new e;n._maximumAllowableMatchCost=i.maximumAllowableMatchCost,n._vector3Alphabet=I_.Deserialize(i.vector3Alphabet),n._levenshteinAlphabet=P_.Alphabet.Deserialize(i.levenshteinAlphabet);for(var r=0;r<i.nameToDescribedTrajectory.length;r+=2)n._nameToDescribedTrajectory.set(i.nameToDescribedTrajectory[r],N_.Deserialize(i.nameToDescribedTrajectory[r+1],n._levenshteinAlphabet));return n},e.Generate=function(){for(var t=I_.Generate(64,256,.1,.001,[a.e.Forward()]),i=new Array(t.chars.length),n=0;n<i.length;++n)i[n]=n;var r=new P_.Alphabet(i,(function(e){return 0===e?0:1}),(function(e){return 0===e?0:1}),(function(e,i){return Math.min(1-a.e.Dot(t.chars[e],t.chars[i]),1)})),o=new e;return o._vector3Alphabet=t,o._levenshteinAlphabet=r,o},e.prototype.addTrajectoryToClassification=function(e,t){this._nameToDescribedTrajectory.has(t)||this._nameToDescribedTrajectory.set(t,new N_),this._nameToDescribedTrajectory.get(t).add(D_.CreateFromTrajectory(e,this._vector3Alphabet,this._levenshteinAlphabet))},e.prototype.deleteClassification=function(e){return this._nameToDescribedTrajectory.delete(e)},e.prototype.classifyTrajectory=function(e){var t=this,i=D_.CreateFromTrajectory(e,this._vector3Alphabet,this._levenshteinAlphabet),n=[];if(this._nameToDescribedTrajectory.forEach((function(e,r){e.getMatchCost(i)<t._maximumAllowableMatchCost&&n.push(r)})),0===n.length)return null;for(var r,o=0,a=this._nameToDescribedTrajectory.get(n[o]).getMatchMinimumDistance(i),s=0;s<n.length;++s)(r=this._nameToDescribedTrajectory.get(n[s]).getMatchMinimumDistance(i))<a&&(a=r,o=s);return n[o]},e}(),w_=i(150),F_=function(e){function t(i,n){void 0===n&&(n={});var r=e.call(this,i)||this;return r.options=n,r._direction=new a.e(0,0,-1),r._mat=new a.a,r._onSelectEnabled=!1,r._origin=new a.e(0,0,0),r.lastNativeXRHitResults=[],r.onHitTestResultObservable=new o.c,r._onHitTestResults=function(e){var t=e.map((function(e){var t=a.a.FromArray(e.hitMatrix);return r._xrSessionManager.scene.useRightHandedSystem||t.toggleModelMatrixHandInPlace(),r.options.worldParentNode&&t.multiplyToRef(r.options.worldParentNode.getWorldMatrix(),t),{xrHitResult:e,transformationMatrix:t}}));r.lastNativeXRHitResults=e,r.onHitTestResultObservable.notifyObservers(t)},r._onSelect=function(e){r._onSelectEnabled&&t.XRHitTestWithSelectEvent(e,r._xrSessionManager.referenceSpace)},r.xrNativeFeatureName="hit-test",Ce.b.Warn("A newer version of this plugin is available"),r}return Object(h.d)(t,e),t.XRHitTestWithRay=function(e,t,i,n){return e.requestHitTest(t,i).then((function(e){var t=n||function(e){return!!e.hitMatrix};return e.filter(t)}))},t.XRHitTestWithSelectEvent=function(e,t){var i=e.frame.getPose(e.inputSource.targetRaySpace,t);if(!i)return Promise.resolve([]);var n=new XRRay(i.transform);return this.XRHitTestWithRay(e.frame.session,n,t)},t.prototype.attach=function(){return!!e.prototype.attach.call(this)&&(this.options.testOnPointerDownOnly&&this._xrSessionManager.session.addEventListener("select",this._onSelect,!1),!0)},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._onSelectEnabled=!1,this._xrSessionManager.session.removeEventListener("select",this._onSelect),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&!this.options.testOnPointerDownOnly){var i=e.getViewerPose(this._xrSessionManager.referenceSpace);if(i){a.a.FromArrayToRef(i.transform.matrix,0,this._mat),a.e.TransformCoordinatesFromFloatsToRef(0,0,0,this._mat,this._origin),a.e.TransformCoordinatesFromFloatsToRef(0,0,-1,this._mat,this._direction),this._direction.subtractInPlace(this._origin),this._direction.normalize();var n=new XRRay({x:this._origin.x,y:this._origin.y,z:this._origin.z,w:0},{x:this._direction.x,y:this._direction.y,z:this._direction.z,w:0});t.XRHitTestWithRay(this._xrSessionManager.session,n,this._xrSessionManager.referenceSpace).then(this._onHitTestResults)}}},t.Name=Ia.HIT_TEST,t.Version=1,t}(ja);Da.AddWebXRFeature(F_.Name,(function(e,t){return function(){return new F_(e,t)}}),F_.Version,!1);var B_=0,U_=function(e){function t(t,i){void 0===i&&(i={});var n=e.call(this,t)||this;return n._options=i,n._lastFrameDetected=new Set,n._trackedAnchors=[],n._futureAnchors=[],n.onAnchorAddedObservable=new o.c,n.onAnchorRemovedObservable=new o.c,n.onAnchorUpdatedObservable=new o.c,n._tmpVector=new a.e,n._tmpQuaternion=new a.b,n.xrNativeFeatureName="anchors",n}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"referenceSpaceForFrameAnchors",{set:function(e){this._referenceSpaceForFrameAnchors=e},enumerable:!1,configurable:!0}),t.prototype._populateTmpTransformation=function(e,t){return this._tmpVector.copyFrom(e),this._tmpQuaternion.copyFrom(t),this._xrSessionManager.scene.useRightHandedSystem||(this._tmpVector.z*=-1,this._tmpQuaternion.z*=-1,this._tmpQuaternion.w*=-1),{position:this._tmpVector,rotationQuaternion:this._tmpQuaternion}},t.prototype.addAnchorPointUsingHitTestResultAsync=function(e,t,i){return void 0===t&&(t=new a.e),void 0===i&&(i=new a.b),Object(h.b)(this,void 0,void 0,(function(){var n,r,o,a=this;return Object(h.e)(this,(function(s){switch(s.label){case 0:if(this._populateTmpTransformation(t,i),n=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),e.xrHitResult.createAnchor)return[3,1];throw this.detach(),new Error("Anchors not enabled in this environment/browser");case 1:return s.trys.push([1,3,,4]),[4,e.xrHitResult.createAnchor(n)];case 2:return r=s.sent(),[2,new Promise((function(e,t){a._futureAnchors.push({nativeAnchor:r,resolved:!1,submitted:!0,xrTransformation:n,resolve:e,reject:t})}))];case 3:throw o=s.sent(),new Error(o);case 4:return[2]}}))}))},t.prototype.addAnchorAtPositionAndRotationAsync=function(e,t,i){return void 0===t&&(t=new a.b),void 0===i&&(i=!1),Object(h.b)(this,void 0,void 0,(function(){var n,r,o,a=this;return Object(h.e)(this,(function(s){switch(s.label){case 0:return this._populateTmpTransformation(e,t),n=new XRRigidTransform({x:this._tmpVector.x,y:this._tmpVector.y,z:this._tmpVector.z},{x:this._tmpQuaternion.x,y:this._tmpQuaternion.y,z:this._tmpQuaternion.z,w:this._tmpQuaternion.w}),i&&this.attached&&this._xrSessionManager.currentFrame?[4,this._createAnchorAtTransformation(n,this._xrSessionManager.currentFrame)]:[3,2];case 1:return o=s.sent(),[3,3];case 2:o=void 0,s.label=3;case 3:return r=o,[2,new Promise((function(e,t){a._futureAnchors.push({nativeAnchor:r,resolved:!1,submitted:!1,xrTransformation:n,resolve:e,reject:t})}))]}}))}))},Object.defineProperty(t.prototype,"anchors",{get:function(){return this._trackedAnchors},enumerable:!1,configurable:!0}),t.prototype.detach=function(){if(!e.prototype.detach.call(this))return!1;if(!this._options.doNotRemoveAnchorsOnSessionEnded)for(;this._trackedAnchors.length;){var t=this._trackedAnchors.pop();if(t){try{t.remove()}catch(e){}this.onAnchorRemovedObservable.notifyObservers(t)}}return!0},t.prototype.dispose=function(){this._futureAnchors.length=0,e.prototype.dispose.call(this),this.onAnchorAddedObservable.clear(),this.onAnchorRemovedObservable.clear(),this.onAnchorUpdatedObservable.clear()},t.prototype._onXRFrame=function(e){var t=this;if(this.attached&&e){var i=e.trackedAnchors;if(i){var n=this._trackedAnchors.filter((function(e){return!i.has(e.xrAnchor)})).map((function(e){return t._trackedAnchors.indexOf(e)})),r=0;n.forEach((function(e){var i=t._trackedAnchors.splice(e-r,1)[0];t.onAnchorRemovedObservable.notifyObservers(i),r++})),i.forEach((function(i){if(t._lastFrameDetected.has(i)){var n=t._findIndexInAnchorArray(i);o=t._trackedAnchors[n];try{t._updateAnchorWithXRFrame(i,o,e),o.attachedNode&&(o.attachedNode.rotationQuaternion=o.attachedNode.rotationQuaternion||new a.b,o.transformationMatrix.decompose(o.attachedNode.scaling,o.attachedNode.rotationQuaternion,o.attachedNode.position)),t.onAnchorUpdatedObservable.notifyObservers(o)}catch(e){Ce.b.Warn("Anchor could not be updated")}}else{var r={id:B_++,xrAnchor:i,remove:i.delete},o=t._updateAnchorWithXRFrame(i,r,e);t._trackedAnchors.push(o),t.onAnchorAddedObservable.notifyObservers(o);var s=t._futureAnchors.filter((function(e){return e.nativeAnchor===i}))[0];s&&(s.resolve(o),s.resolved=!0)}})),this._lastFrameDetected=i}this._futureAnchors.forEach((function(i){i.resolved||i.submitted||(t._createAnchorAtTransformation(i.xrTransformation,e).then((function(e){i.nativeAnchor=e}),(function(e){i.resolved=!0,i.reject(e)})),i.submitted=!0)}))}},t.prototype._findIndexInAnchorArray=function(e){for(var t=0;t<this._trackedAnchors.length;++t)if(this._trackedAnchors[t].xrAnchor===e)return t;return-1},t.prototype._updateAnchorWithXRFrame=function(e,t,i){var n=i.getPose(e.anchorSpace,this._xrSessionManager.referenceSpace);if(n){var r=t.transformationMatrix||new a.a;a.a.FromArrayToRef(n.transform.matrix,0,r),this._xrSessionManager.scene.useRightHandedSystem||r.toggleModelMatrixHandInPlace(),t.transformationMatrix=r,this._options.worldParentNode&&r.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),r)}return t},t.prototype._createAnchorAtTransformation=function(e,t){var i;return Object(h.b)(this,void 0,void 0,(function(){return Object(h.e)(this,(function(n){if(!t.createAnchor)throw this.detach(),new Error("Anchors are not enabled in your browser");try{return[2,t.createAnchor(e,null!==(i=this._referenceSpaceForFrameAnchors)&&void 0!==i?i:this._xrSessionManager.referenceSpace)]}catch(e){throw new Error(e)}return[2]}))}))},t.Name=Ia.ANCHOR_SYSTEM,t.Version=1,t}(ja);Da.AddWebXRFeature(U_.Name,(function(e,t){return function(){return new U_(e,t)}}),U_.Version);var V_=0,k_=function(e){function t(t,i){void 0===i&&(i={});var n=e.call(this,t)||this;return n._options=i,n._detectedPlanes=[],n._enabled=!1,n._lastFrameDetected=new Set,n.onPlaneAddedObservable=new o.c,n.onPlaneRemovedObservable=new o.c,n.onPlaneUpdatedObservable=new o.c,n.xrNativeFeatureName="plane-detection",n._xrSessionManager.session?n._init():n._xrSessionManager.onXRSessionInit.addOnce((function(){n._init()})),n}return Object(h.d)(t,e),t.prototype.detach=function(){if(!e.prototype.detach.call(this))return!1;if(!this._options.doNotRemovePlanesOnSessionEnded)for(;this._detectedPlanes.length;){var t=this._detectedPlanes.pop();t&&this.onPlaneRemovedObservable.notifyObservers(t)}return!0},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onPlaneAddedObservable.clear(),this.onPlaneRemovedObservable.clear(),this.onPlaneUpdatedObservable.clear()},t.prototype.isCompatible=function(){return"undefined"!=typeof XRPlane},t.prototype._onXRFrame=function(e){var t=this;if(this.attached&&this._enabled&&e){var i=e.worldInformation.detectedPlanes;if(i){var n=this._detectedPlanes.filter((function(e){return!i.has(e.xrPlane)})).map((function(e){return t._detectedPlanes.indexOf(e)})),r=0;n.forEach((function(e){var i=t._detectedPlanes.splice(e-r,1)[0];t.onPlaneRemovedObservable.notifyObservers(i),r++})),i.forEach((function(i){if(t._lastFrameDetected.has(i)){if(i.lastChangedTime===t._xrSessionManager.currentTimestamp){var n=t.findIndexInPlaneArray(i);o=t._detectedPlanes[n];t._updatePlaneWithXRPlane(i,o,e),t.onPlaneUpdatedObservable.notifyObservers(o)}}else{var r={id:V_++,xrPlane:i,polygonDefinition:[]},o=t._updatePlaneWithXRPlane(i,r,e);t._detectedPlanes.push(o),t.onPlaneAddedObservable.notifyObservers(o)}})),this._lastFrameDetected=i}}},t.prototype._init=function(){var e,t,i=this,n=function(){i._enabled=!0,i._detectedPlanes.length&&(i._detectedPlanes.length=0)};this._xrSessionManager.session.updateWorldTrackingState?(this._xrSessionManager.session.updateWorldTrackingState({planeDetectionState:{enabled:!0}}),n()):(null===(t=null===(e=this._xrSessionManager.session.worldTrackingState)||void 0===e?void 0:e.planeDetectionState)||void 0===t?void 0:t.enabled)&&n()},t.prototype._updatePlaneWithXRPlane=function(e,t,i){var n=this;t.polygonDefinition=e.polygon.map((function(e){var t=n._xrSessionManager.scene.useRightHandedSystem?1:-1;return new a.e(e.x,e.y,e.z*t)}));var r=i.getPose(e.planeSpace,this._xrSessionManager.referenceSpace);if(r){var o=t.transformationMatrix||new a.a;a.a.FromArrayToRef(r.transform.matrix,0,o),this._xrSessionManager.scene.useRightHandedSystem||o.toggleModelMatrixHandInPlace(),t.transformationMatrix=o,this._options.worldParentNode&&o.multiplyToRef(this._options.worldParentNode.getWorldMatrix(),o)}return t},t.prototype.findIndexInPlaneArray=function(e){for(var t=0;t<this._detectedPlanes.length;++t)if(this._detectedPlanes[t].xrPlane===e)return t;return-1},t.Name=Ia.PLANE_DETECTION,t.Version=1,t}(ja);Da.AddWebXRFeature(k_.Name,(function(e,t){return function(){return new k_(e,t)}}),k_.Version);var z_=function(e){function t(t,i){void 0===i&&(i={});var n=e.call(this,t)||this;return n.options=i,n.onBackgroundStateChangedObservable=new o.c,n}return Object(h.d)(t,e),t.prototype.attach=function(){return this._setBackgroundState(!1),e.prototype.attach.call(this)},t.prototype.detach=function(){return this._setBackgroundState(!0),e.prototype.detach.call(this)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onBackgroundStateChangedObservable.clear()},t.prototype._onXRFrame=function(e){},t.prototype._setBackgroundState=function(e){var t=this._xrSessionManager.scene;if(!this.options.ignoreEnvironmentHelper)if(this.options.environmentHelperRemovalFlags){if(this.options.environmentHelperRemovalFlags.skyBox){var i=t.getMeshByName("BackgroundSkybox");i&&i.setEnabled(e)}if(this.options.environmentHelperRemovalFlags.ground){var n=t.getMeshByName("BackgroundPlane");n&&n.setEnabled(e)}}else{var r=t.getMeshByName("BackgroundHelper");r&&r.setEnabled(e)}this.options.backgroundMeshes&&this.options.backgroundMeshes.forEach((function(t){return t.setEnabled(e)})),this.onBackgroundStateChangedObservable.notifyObservers(e)},t.Name=Ia.BACKGROUND_REMOVER,t.Version=1,t}(ja);Da.AddWebXRFeature(z_.Name,(function(e,t){return function(){return new z_(e,t)}}),z_.Version,!0);var G_=function(){},j_=function(e){function t(t,i){var n=e.call(this,t)||this;return n._options=i,n._attachController=function(e){if(!n._controllers[e.uniqueId])if(n._xrSessionManager.scene.isPhysicsEnabled()||m.a.Warn("physics engine not enabled, skipped. Please add this controller manually."),n._options.physicsProperties.useControllerMesh&&e.inputSource.gamepad)e.onMotionControllerInitObservable.addOnce((function(t){t.onModelLoadedObservable.addOnce((function(){var i=new dc.a(t.rootMesh,dc.a.MeshImpostor,Object(h.a)({mass:0},n._options.physicsProperties)),r=e.grip||e.pointer;n._controllers[e.uniqueId]={xrController:e,impostor:i,oldPos:r.position.clone(),oldRotation:r.rotationQuaternion.clone()}}))}));else{var t=n._options.physicsProperties.impostorType||dc.a.SphereImpostor,i=n._options.physicsProperties.impostorSize||.1,r=xr.a.CreateSphere("impostor-mesh-"+e.uniqueId,{diameterX:"number"==typeof i?i:i.width,diameterY:"number"==typeof i?i:i.height,diameterZ:"number"==typeof i?i:i.depth});r.isVisible=n._debugMode,r.isPickable=!1,r.rotationQuaternion=new a.b;var o=e.grip||e.pointer;r.position.copyFrom(o.position),r.rotationQuaternion.copyFrom(o.rotationQuaternion);var s=new dc.a(r,t,Object(h.a)({mass:0},n._options.physicsProperties));n._controllers[e.uniqueId]={xrController:e,impostor:s,impostorMesh:r}}},n._controllers={},n._debugMode=!1,n._delta=0,n._lastTimestamp=0,n._tmpQuaternion=new a.b,n._tmpVector=new a.e,n._options.physicsProperties||(n._options.physicsProperties={}),n}return Object(h.d)(t,e),t.prototype._enablePhysicsDebug=function(){var e=this;this._debugMode=!0,Object.keys(this._controllers).forEach((function(t){var i=e._controllers[t];i.impostorMesh&&(i.impostorMesh.isVisible=!0)}))},t.prototype.addController=function(e){this._attachController(e)},t.prototype.attach=function(){var t=this;if(!e.prototype.attach.call(this))return!1;if(!this._options.xrInput)return!0;if(this._options.xrInput.controllers.forEach(this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerAddedObservable,this._attachController),this._addNewAttachObserver(this._options.xrInput.onControllerRemovedObservable,(function(e){t._detachController(e.uniqueId)})),this._options.enableHeadsetImpostor){var i=this._options.headsetImpostorParams||{impostorType:dc.a.SphereImpostor,restitution:.8,impostorSize:.3},n=i.impostorSize||.3;this._headsetMesh=xr.a.CreateSphere("headset-mesh",{diameterX:"number"==typeof n?n:n.width,diameterY:"number"==typeof n?n:n.height,diameterZ:"number"==typeof n?n:n.depth}),this._headsetMesh.rotationQuaternion=new a.b,this._headsetMesh.isVisible=!1,this._headsetImpostor=new dc.a(this._headsetMesh,i.impostorType,Object(h.a)({mass:0},i))}return!0},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._controllers).forEach((function(e){t._detachController(e)})),this._headsetMesh&&this._headsetMesh.dispose(),!0)},t.prototype.getHeadsetImpostor=function(){return this._headsetImpostor},t.prototype.getImpostorForController=function(e){var t="string"==typeof e?e:e.uniqueId;return this._controllers[t]?this._controllers[t].impostor:null},t.prototype.setPhysicsProperties=function(e){this._options.physicsProperties=Object(h.a)(Object(h.a)({},this._options.physicsProperties),e)},t.prototype._onXRFrame=function(e){var t=this;this._delta=this._xrSessionManager.currentTimestamp-this._lastTimestamp,this._lastTimestamp=this._xrSessionManager.currentTimestamp,this._headsetMesh&&(this._headsetMesh.position.copyFrom(this._options.xrInput.xrCamera.position),this._headsetMesh.rotationQuaternion.copyFrom(this._options.xrInput.xrCamera.rotationQuaternion)),Object.keys(this._controllers).forEach((function(e){var i=t._controllers[e],n=i.xrController.grip||i.xrController.pointer,r=i.oldPos||i.impostorMesh.position,o=i.oldRotation||i.impostorMesh.rotationQuaternion;if(n.position.subtractToRef(r,t._tmpVector),t._tmpVector.scaleInPlace(1e3/t._delta),i.impostor.setLinearVelocity(t._tmpVector),t._debugMode&&console.log(t._tmpVector,"linear"),!o.equalsWithEpsilon(n.rotationQuaternion)){o.conjugateInPlace().multiplyToRef(n.rotationQuaternion,t._tmpQuaternion);var a=Math.sqrt(t._tmpQuaternion.x*t._tmpQuaternion.x+t._tmpQuaternion.y*t._tmpQuaternion.y+t._tmpQuaternion.z*t._tmpQuaternion.z);if(t._tmpVector.set(t._tmpQuaternion.x,t._tmpQuaternion.y,t._tmpQuaternion.z),a<.001)t._tmpVector.scaleInPlace(2);else{var s=2*Math.atan2(a,t._tmpQuaternion.w);t._tmpVector.scaleInPlace(s/(a*(t._delta/1e3)))}i.impostor.setAngularVelocity(t._tmpVector),t._debugMode&&console.log(t._tmpVector,t._tmpQuaternion,"angular")}r.copyFrom(n.position),o.copyFrom(n.rotationQuaternion)}))},t.prototype._detachController=function(e){var t=this._controllers[e];t&&(t.impostorMesh&&t.impostorMesh.dispose(),delete this._controllers[e])},t.Name=Ia.PHYSICS_CONTROLLERS,t.Version=1,t}(ja);Da.AddWebXRFeature(j_.Name,(function(e,t){return function(){return new j_(e,t)}}),j_.Version,!0);var W_=function(e){function t(t,i){void 0===i&&(i={});var n=e.call(this,t)||this;return n.options=i,n._tmpMat=new a.a,n._tmpPos=new a.e,n._tmpQuat=new a.b,n.initHitTestSource=function(e){if(e){var t=new XRRay(n.options.offsetRay||{}),i={space:n.options.useReferenceSpace?e:n._xrSessionManager.viewerReferenceSpace,offsetRay:t};n.options.entityTypes&&(i.entityTypes=n.options.entityTypes),i.space?n._xrSessionManager.session.requestHitTestSource(i).then((function(e){n._xrHitTestSource&&n._xrHitTestSource.cancel(),n._xrHitTestSource=e})):Ce.b.Warn("waiting for viewer reference space to initialize")}},n.autoCloneTransformation=!1,n.onHitTestResultObservable=new o.c,n.paused=!1,n.xrNativeFeatureName="hit-test",Ce.b.Warn("Hit test is an experimental and unstable feature."),n}return Object(h.d)(t,e),t.prototype.attach=function(){var t=this;if(!e.prototype.attach.call(this))return!1;if(!this._xrSessionManager.session.requestHitTestSource)return!1;if(this.options.disablePermanentHitTest||(this._xrSessionManager.referenceSpace&&this.initHitTestSource(this._xrSessionManager.referenceSpace),this._xrSessionManager.onXRReferenceSpaceChanged.add(this.initHitTestSource)),this.options.enableTransientHitTest){var i=new XRRay(this.options.transientOffsetRay||{});this._xrSessionManager.session.requestHitTestSourceForTransientInput({profile:"generic-touchscreen",offsetRay:i,entityTypes:this.options.entityTypes}).then((function(e){t._transientXrHitTestSource=e}))}return!0},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._xrHitTestSource&&(this._xrHitTestSource.cancel(),this._xrHitTestSource=null),this._xrSessionManager.onXRReferenceSpaceChanged.removeCallback(this.initHitTestSource),this._transientXrHitTestSource&&(this._transientXrHitTestSource.cancel(),this._transientXrHitTestSource=null),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onHitTestResultObservable.clear()},t.prototype._onXRFrame=function(e){var t=this;if(this.attached&&!this.paused){if(this._xrHitTestSource){var i=e.getHitTestResults(this._xrHitTestSource);this._processWebXRHitTestResult(i)}if(this._transientXrHitTestSource)e.getHitTestResultsForTransientInput(this._transientXrHitTestSource).forEach((function(e){t._processWebXRHitTestResult(e.results,e.inputSource)}))}},t.prototype._processWebXRHitTestResult=function(e,t){var i=this,n=[];e.forEach((function(e){var r=e.getPose(i._xrSessionManager.referenceSpace);if(r){var o=r.transform.position,s=r.transform.orientation;i._tmpPos.set(o.x,o.y,o.z),i._tmpQuat.set(s.x,s.y,s.z,s.w),a.a.FromFloat32ArrayToRefScaled(r.transform.matrix,0,1,i._tmpMat),i._xrSessionManager.scene.useRightHandedSystem||(i._tmpPos.z*=-1,i._tmpQuat.z*=-1,i._tmpQuat.w*=-1,i._tmpMat.toggleModelMatrixHandInPlace());var c={position:i.autoCloneTransformation?i._tmpPos.clone():i._tmpPos,rotationQuaternion:i.autoCloneTransformation?i._tmpQuat.clone():i._tmpQuat,transformationMatrix:i.autoCloneTransformation?i._tmpMat.clone():i._tmpMat,inputSource:t,isTransient:!!t,xrHitResult:e};n.push(c)}})),this.onHitTestResultObservable.notifyObservers(n)},t.Name=Ia.HIT_TEST,t.Version=2,t}(ja);Da.AddWebXRFeature(W_.Name,(function(e,t){return function(){return new W_(e,t)}}),W_.Version,!1);var H_=function(e){function t(t){var i=e.call(this,t)||this;return i._enabled=!1,i._featurePointCloud=[],i.onFeaturePointsAddedObservable=new o.c,i.onFeaturePointsUpdatedObservable=new o.c,i.xrNativeFeatureName="bjsfeature-points",i._xrSessionManager.session?i._init():i._xrSessionManager.onXRSessionInit.addOnce((function(){i._init()})),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"featurePointCloud",{get:function(){return this._featurePointCloud},enumerable:!1,configurable:!0}),t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this.featurePointCloud.length=0,!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._featurePointCloud.length=0,this.onFeaturePointsUpdatedObservable.clear(),this.onFeaturePointsAddedObservable.clear()},t.prototype._onXRFrame=function(e){if(this.attached&&this._enabled&&e){var t=e.featurePointCloud;if(t&&0!==t.length){if(t.length%5!=0)throw new Error("Received malformed feature point cloud of length: "+t.length);for(var i=t.length/5,n=new Array,r=new Array,o=0;o<i;o++){var s=5*o,c=t[s+4];this._featurePointCloud[c]?n.push(c):(this._featurePointCloud[c]={position:new a.e,confidenceValue:0},r.push(c)),this._featurePointCloud[c].position.x=t[s],this._featurePointCloud[c].position.y=t[s+1],this._featurePointCloud[c].position.z=t[s+2],this._featurePointCloud[c].confidenceValue=t[s+3]}r.length>0&&this.onFeaturePointsAddedObservable.notifyObservers(r),n.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(n)}}},t.prototype._init=function(){this._xrSessionManager.session.trySetFeaturePointCloudEnabled&&this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)&&(this._enabled=!0)},t.Name=Ia.FEATURE_POINTS,t.Version=1,t}(ja);Da.AddWebXRFeature(H_.Name,(function(e){return function(){return new H_(e)}}),H_.Version);var X_=function(){function e(e,t,i,n,r){this.xrController=e,this.trackedMeshes=t,this._handMesh=i,this._rigMapping=n,this._defaultHandMesh=!1,this._transformNodeMapping=[],this.handPartsDefinition=this.generateHandPartsDefinition(e.inputSource.hand),this._scene=t[0].getScene(),this._handMesh&&this._rigMapping?this._defaultHandMesh=!1:r||this._generateDefaultHandMesh(),this.xrController.motionController&&(this.xrController.motionController.rootMesh?this.xrController.motionController.rootMesh.setEnabled(!1):this.xrController.motionController.onModelLoadedObservable.add((function(e){e.rootMesh&&e.rootMesh.setEnabled(!1)}))),this.xrController.onMotionControllerInitObservable.add((function(e){e.onModelLoadedObservable.add((function(e){e.rootMesh&&e.rootMesh.setEnabled(!1)})),e.rootMesh&&e.rootMesh.setEnabled(!1)}))}return e.prototype.generateHandPartsDefinition=function(e){var t;return(t={}).wrist=[e.WRIST],t.thumb=[e.THUMB_METACARPAL,e.THUMB_PHALANX_PROXIMAL,e.THUMB_PHALANX_DISTAL,e.THUMB_PHALANX_TIP],t.index=[e.INDEX_METACARPAL,e.INDEX_PHALANX_PROXIMAL,e.INDEX_PHALANX_INTERMEDIATE,e.INDEX_PHALANX_DISTAL,e.INDEX_PHALANX_TIP],t.middle=[e.MIDDLE_METACARPAL,e.MIDDLE_PHALANX_PROXIMAL,e.MIDDLE_PHALANX_INTERMEDIATE,e.MIDDLE_PHALANX_DISTAL,e.MIDDLE_PHALANX_TIP],t.ring=[e.RING_METACARPAL,e.RING_PHALANX_PROXIMAL,e.RING_PHALANX_INTERMEDIATE,e.RING_PHALANX_DISTAL,e.RING_PHALANX_TIP],t.little=[e.LITTLE_METACARPAL,e.LITTLE_PHALANX_PROXIMAL,e.LITTLE_PHALANX_INTERMEDIATE,e.LITTLE_PHALANX_DISTAL,e.LITTLE_PHALANX_TIP],t},e.prototype.updateFromXRFrame=function(e,t,i){var n=this;void 0===i&&(i=2);var r=this.xrController.inputSource.hand;r&&this.trackedMeshes.forEach((function(o,a){var s=r[a];if(s){var c=e.getJointPose(s,t);if(!c||!c.transform)return;var l=c.transform.position,u=c.transform.orientation;o.position.set(l.x,l.y,l.z),o.rotationQuaternion.set(u.x,u.y,u.z,u.w);var h=(c.radius||.008)*i;o.scaling.set(h,h,h),n._handMesh&&n._rigMapping&&n._rigMapping[a]&&(n._transformNodeMapping[a]=n._transformNodeMapping[a]||n._scene.getTransformNodeByName(n._rigMapping[a]),n._transformNodeMapping[a]&&(n._transformNodeMapping[a].position.copyFrom(o.position),n._transformNodeMapping[a].rotationQuaternion.copyFrom(o.rotationQuaternion),o.isVisible=!1)),o.getScene().useRightHandedSystem||(o.position.z*=-1,o.rotationQuaternion.z*=-1,o.rotationQuaternion.w*=-1)}}))},e.prototype.getHandPartMeshes=function(e){var t=this;return this.handPartsDefinition[e].map((function(e){return t.trackedMeshes[e]}))},e.prototype.dispose=function(){this.trackedMeshes.forEach((function(e){return e.dispose()})),this._defaultHandMesh&&this._handMesh&&this._handMesh.dispose()},e.prototype._generateDefaultHandMesh=function(){return Object(h.b)(this,void 0,void 0,(function(){var e,t,i,n,r,o,a,c;return Object(h.e)(this,(function(l){switch(l.label){case 0:return l.trys.push([0,3,,4]),e="right"===this.xrController.inputSource.handedness?"right":"left",t=("right"===e?"r":"l")+"_hand_"+(this._scene.useRightHandedSystem?"r":"l")+"hs.glb",[4,pr.ImportMeshAsync("","https://assets.babylonjs.com/meshes/HandMeshes/",t,this._scene)];case 1:return i=l.sent(),n={base:s.a.FromInts(116,63,203),fresnel:s.a.FromInts(149,102,229),fingerColor:s.a.FromInts(177,130,255),tipFresnel:s.a.FromInts(220,200,255)},[4,(r=new ql("leftHandShader",this._scene,{emitComments:!1})).loadAsync("https://patrickryanms.github.io/BabylonJStextures/Demos/xrHandMesh/handsShader.json")];case 2:if(l.sent(),r.build(!1),r.needDepthPrePass=!0,r.transparencyMode=xo.a.MATERIAL_ALPHABLEND,r.alphaMode=Se.a.ALPHA_COMBINE,(o={base:r.getBlockByName("baseColor"),fresnel:r.getBlockByName("fresnelColor"),fingerColor:r.getBlockByName("fingerColor"),tipFresnel:r.getBlockByName("tipFresnelColor")}).base.value=n.base,o.fresnel.value=n.fresnel,o.fingerColor.value=n.fingerColor,o.tipFresnel.value=n.tipFresnel,i.meshes[1].material=r,this._defaultHandMesh=!0,this._handMesh=i.meshes[0],this._rigMapping=["wrist_","thumb_metacarpal_","thumb_proxPhalanx_","thumb_distPhalanx_","thumb_tip_","index_metacarpal_","index_proxPhalanx_","index_intPhalanx_","index_distPhalanx_","index_tip_","middle_metacarpal_","middle_proxPhalanx_","middle_intPhalanx_","middle_distPhalanx_","middle_tip_","ring_metacarpal_","ring_proxPhalanx_","ring_intPhalanx_","ring_distPhalanx_","ring_tip_","little_metacarpal_","little_proxPhalanx_","little_intPhalanx_","little_distPhalanx_","little_tip_"].map((function(t){return t+("right"===e?"R":"L")})),!(a=this._scene.getTransformNodeByName(this._rigMapping[0])))throw new Error("could not find the wrist node");return a.parent&&a.parent.rotate(J.a.Y,Math.PI),[3,4];case 3:return c=l.sent(),Ce.b.Error("error loading hand mesh"),console.log(c),[3,4];case 4:return[2]}}))}))},e}(),Y_=function(e){function t(i,n){var r=e.call(this,i)||this;return r.options=n,r.onHandAddedObservable=new o.c,r.onHandRemovedObservable=new o.c,r._hands={},r._attachHand=function(e){var i,n,o,s,c,l,u,d,f,p;if(e.inputSource.hand&&!r._hands[e.uniqueId]){var _=e.inputSource.hand,m=[],g=(null===(i=r.options.jointMeshes)||void 0===i?void 0:i.sourceMesh)||xr.a.CreateSphere("jointParent",{diameter:1});g.isVisible=!!(null===(n=r.options.jointMeshes)||void 0===n?void 0:n.keepOriginalVisible);for(var v=0;v<_.length;++v){var b=g.createInstance(e.uniqueId+"-handJoint-"+v);if(null===(o=r.options.jointMeshes)||void 0===o?void 0:o.onHandJointMeshGenerated){var y=r.options.jointMeshes.onHandJointMeshGenerated(b,v,e.uniqueId);y&&y!==b&&(b.dispose(),b=y)}if(b.isPickable=!1,null===(s=r.options.jointMeshes)||void 0===s?void 0:s.enablePhysics){var T=r.options.jointMeshes.physicsProps||{},E=void 0!==T.impostorType?T.impostorType:dc.a.SphereImpostor;b.physicsImpostor=new dc.a(b,E,Object(h.a)({mass:0},T))}b.rotationQuaternion=new a.b,(null===(c=r.options.jointMeshes)||void 0===c?void 0:c.invisible)&&(b.isVisible=!1),m.push(b)}var S="right"===e.inputSource.handedness?"right":"left",A=(null===(l=r.options.jointMeshes)||void 0===l?void 0:l.handMeshes)&&(null===(u=r.options.jointMeshes)||void 0===u?void 0:u.handMeshes[S]),P=(null===(d=r.options.jointMeshes)||void 0===d?void 0:d.rigMapping)&&(null===(f=r.options.jointMeshes)||void 0===f?void 0:f.rigMapping[S]),C=new X_(e,m,A,P,null===(p=r.options.jointMeshes)||void 0===p?void 0:p.disableDefaultHandMesh);r._hands[e.uniqueId]={handObject:C,id:t._idCounter++},r.onHandAddedObservable.notifyObservers(C)}},r.xrNativeFeatureName="hand-tracking",r}return Object(h.d)(t,e),t.prototype.isCompatible=function(){return"undefined"!=typeof XRHand},t.prototype.attach=function(){var t=this;return!!e.prototype.attach.call(this)&&(this.options.xrInput.controllers.forEach(this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerAddedObservable,this._attachHand),this._addNewAttachObserver(this.options.xrInput.onControllerRemovedObservable,(function(e){t._detachHand(e.uniqueId)})),!0)},t.prototype.detach=function(){var t=this;return!!e.prototype.detach.call(this)&&(Object.keys(this._hands).forEach((function(e){t._detachHand(e)})),!0)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onHandAddedObservable.clear()},t.prototype.getHandByControllerId=function(e){var t;return(null===(t=this._hands[e])||void 0===t?void 0:t.handObject)||null},t.prototype.getHandByHandedness=function(e){var t=this,i=Object.keys(this._hands).map((function(e){return t._hands[e].handObject.xrController.inputSource.handedness})).indexOf(e);return-1!==i?this._hands[i].handObject:null},t.prototype._onXRFrame=function(e){var t=this;Object.keys(this._hands).forEach((function(i){var n;t._hands[i].handObject.updateFromXRFrame(e,t._xrSessionManager.referenceSpace,null===(n=t.options.jointMeshes)||void 0===n?void 0:n.scaleFactor)}))},t.prototype._detachHand=function(e){this._hands[e]&&(this.onHandRemovedObservable.notifyObservers(this._hands[e].handObject),this._hands[e].handObject.dispose())},t._idCounter=0,t.Name=Ia.HAND_TRACKING,t.Version=1,t}(ja);Da.AddWebXRFeature(Y_.Name,(function(e,t){return function(){return new Y_(e,t)}}),Y_.Version,!1);var K_=function(e){function t(t,i,n){var r=e.call(this,t,Q_["left-right"],i,n)||this;return r._mapping={defaultButton:{valueNodeName:"VALUE",unpressedNodeName:"UNPRESSED",pressedNodeName:"PRESSED"},defaultAxis:{valueNodeName:"VALUE",minNodeName:"MIN",maxNodeName:"MAX"},buttons:{"xr-standard-trigger":{rootNodeName:"SELECT",componentProperty:"button",states:["default","touched","pressed"]},"xr-standard-squeeze":{rootNodeName:"GRASP",componentProperty:"state",states:["pressed"]},"xr-standard-touchpad":{rootNodeName:"TOUCHPAD_PRESS",labelAnchorNodeName:"squeeze-label",touchPointNodeName:"TOUCH"},"xr-standard-thumbstick":{rootNodeName:"THUMBSTICK_PRESS",componentProperty:"state",states:["pressed"]}},axes:{"xr-standard-touchpad":{"x-axis":{rootNodeName:"TOUCHPAD_TOUCH_X"},"y-axis":{rootNodeName:"TOUCHPAD_TOUCH_Y"}},"xr-standard-thumbstick":{"x-axis":{rootNodeName:"THUMBSTICK_X"},"y-axis":{rootNodeName:"THUMBSTICK_Y"}}}},r.profileId="microsoft-mixed-reality",r}return Object(h.d)(t,e),t.prototype._getFilenameAndPath=function(){return{filename:"left"===this.handedness?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,path:t.MODEL_BASE_URL+"default/"}},t.prototype._getModelLoadingConstraints=function(){var e=pr.IsPluginForExtensionAvailable(".glb");return e||m.a.Warn("glTF / glb loaded was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var t=this;this.rootMesh&&(this.getComponentIds().forEach((function(e,i){if(!t.disableAnimation&&e&&t.rootMesh){var n=t._mapping.buttons[e],r=n.rootNodeName;if(!r)return void m.a.Log("Skipping unknown button at index: "+i+" with mapped name: "+e);var o=t._getChildByName(t.rootMesh,r);if(!o)return void m.a.Warn("Missing button mesh with name: "+r);if(n.valueMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.valueNodeName),n.pressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.pressedNodeName),n.unpressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.unpressedNodeName),n.valueMesh&&n.pressedMesh&&n.unpressedMesh){var a=t.getComponent(e);a&&a.onButtonStateChangedObservable.add((function(e){t._lerpTransform(n,e.value)}),void 0,!0)}else m.a.Warn("Missing button submesh under mesh with name: "+r)}})),this.getComponentIds().forEach((function(e,i){var n=t.getComponent(e);n.isAxes()&&["x-axis","y-axis"].forEach((function(i){if(t.rootMesh){var r=t._mapping.axes[e][i],o=t._getChildByName(t.rootMesh,r.rootNodeName);o?(r.valueMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.valueNodeName),r.minMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.minNodeName),r.maxMesh=t._getImmediateChildByName(o,t._mapping.defaultAxis.maxNodeName),r.valueMesh&&r.minMesh&&r.maxMesh?n&&n.onAxisValueChangedObservable.add((function(e){var n="x-axis"===i?e.x:e.y;t._lerpTransform(r,n,!0)}),void 0,!0):m.a.Warn("Missing axis submesh under mesh with name: "+r.rootNodeName)):m.a.Warn("Missing axis mesh with name: "+r.rootNodeName)}}))})))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new be.a(this.profileId+" "+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var i=0;i<e.length;i++){var n=e[i];n.isPickable=!1,n.parent||(t=n)}t&&t.setParent(this.rootMesh),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",t.MODEL_LEFT_FILENAME="left.glb",t.MODEL_RIGHT_FILENAME="right.glb",t}(wa);Va.RegisterController("windows-mixed-reality",(function(e,t){return new K_(t,e.gamepad,e.handedness)}));var Q_={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{xr_standard_trigger_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_trigger_pressed_value",minNodeName:"xr_standard_trigger_pressed_min",maxNodeName:"xr_standard_trigger_pressed_max"}}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{xr_standard_squeeze_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_squeeze_pressed_value",minNodeName:"xr_standard_squeeze_pressed_min",maxNodeName:"xr_standard_squeeze_pressed_max"}}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{xr_standard_touchpad_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_pressed_value",minNodeName:"xr_standard_touchpad_pressed_min",maxNodeName:"xr_standard_touchpad_pressed_max"},xr_standard_touchpad_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_pressed_value",minNodeName:"xr_standard_touchpad_xaxis_pressed_min",maxNodeName:"xr_standard_touchpad_xaxis_pressed_max"},xr_standard_touchpad_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_pressed_value",minNodeName:"xr_standard_touchpad_yaxis_pressed_min",maxNodeName:"xr_standard_touchpad_yaxis_pressed_max"},xr_standard_touchpad_xaxis_touched:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_touched_value",minNodeName:"xr_standard_touchpad_xaxis_touched_min",maxNodeName:"xr_standard_touchpad_xaxis_touched_max"},xr_standard_touchpad_yaxis_touched:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_touched_value",minNodeName:"xr_standard_touchpad_yaxis_touched_min",maxNodeName:"xr_standard_touchpad_yaxis_touched_max"},xr_standard_touchpad_axes_touched:{componentProperty:"state",states:["touched","pressed"],valueNodeProperty:"visibility",valueNodeName:"xr_standard_touchpad_axes_touched_value"}},touchPointNodeName:"xr_standard_touchpad_axes_touched_value"},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{xr_standard_thumbstick_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_pressed_value",minNodeName:"xr_standard_thumbstick_pressed_min",maxNodeName:"xr_standard_thumbstick_pressed_max"},xr_standard_thumbstick_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_xaxis_pressed_value",minNodeName:"xr_standard_thumbstick_xaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_xaxis_pressed_max"},xr_standard_thumbstick_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_yaxis_pressed_value",minNodeName:"xr_standard_thumbstick_yaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_yaxis_pressed_max"}}}},gamepadMapping:"xr-standard",rootNodeName:"microsoft-mixed-reality-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{xr_standard_trigger_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_trigger_pressed_value",minNodeName:"xr_standard_trigger_pressed_min",maxNodeName:"xr_standard_trigger_pressed_max"}}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{xr_standard_squeeze_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_squeeze_pressed_value",minNodeName:"xr_standard_squeeze_pressed_min",maxNodeName:"xr_standard_squeeze_pressed_max"}}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{xr_standard_touchpad_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_pressed_value",minNodeName:"xr_standard_touchpad_pressed_min",maxNodeName:"xr_standard_touchpad_pressed_max"},xr_standard_touchpad_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_pressed_value",minNodeName:"xr_standard_touchpad_xaxis_pressed_min",maxNodeName:"xr_standard_touchpad_xaxis_pressed_max"},xr_standard_touchpad_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_pressed_value",minNodeName:"xr_standard_touchpad_yaxis_pressed_min",maxNodeName:"xr_standard_touchpad_yaxis_pressed_max"},xr_standard_touchpad_xaxis_touched:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_xaxis_touched_value",minNodeName:"xr_standard_touchpad_xaxis_touched_min",maxNodeName:"xr_standard_touchpad_xaxis_touched_max"},xr_standard_touchpad_yaxis_touched:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_touchpad_yaxis_touched_value",minNodeName:"xr_standard_touchpad_yaxis_touched_min",maxNodeName:"xr_standard_touchpad_yaxis_touched_max"},xr_standard_touchpad_axes_touched:{componentProperty:"state",states:["touched","pressed"],valueNodeProperty:"visibility",valueNodeName:"xr_standard_touchpad_axes_touched_value"}},touchPointNodeName:"xr_standard_touchpad_axes_touched_value"},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{xr_standard_thumbstick_pressed:{componentProperty:"button",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_pressed_value",minNodeName:"xr_standard_thumbstick_pressed_min",maxNodeName:"xr_standard_thumbstick_pressed_max"},xr_standard_thumbstick_xaxis_pressed:{componentProperty:"xAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_xaxis_pressed_value",minNodeName:"xr_standard_thumbstick_xaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_xaxis_pressed_max"},xr_standard_thumbstick_yaxis_pressed:{componentProperty:"yAxis",states:["default","touched","pressed"],valueNodeProperty:"transform",valueNodeName:"xr_standard_thumbstick_yaxis_pressed_value",minNodeName:"xr_standard_thumbstick_yaxis_pressed_min",maxNodeName:"xr_standard_thumbstick_yaxis_pressed_max"}}}},gamepadMapping:"xr-standard",rootNodeName:"microsoft-mixed-reality-right",assetPath:"right.glb"}},q_=function(e){function t(t,i,n,r,o){void 0===r&&(r=!1),void 0===o&&(o=!1);var a=e.call(this,t,Z_[n],i,n)||this;return a._forceLegacyControllers=o,a.profileId="oculus-touch",a}return Object(h.d)(t,e),t.prototype._getFilenameAndPath=function(){return{filename:"left"===this.handedness?t.MODEL_LEFT_FILENAME:t.MODEL_RIGHT_FILENAME,path:this._isQuest()?t.QUEST_MODEL_BASE_URL:t.MODEL_BASE_URL}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var t=this,i=this._isQuest(),n="right"===this.handedness?-1:1;this.getComponentIds().forEach((function(e){var r=e&&t.getComponent(e);r&&r.onButtonStateChangedObservable.add((function(r){if(t.rootMesh&&!t.disableAnimation)switch(e){case"xr-standard-trigger":return void(i||(t._modelRootNode.getChildren()[3].rotation.x=.2*-r.value,t._modelRootNode.getChildren()[3].position.y=.005*-r.value,t._modelRootNode.getChildren()[3].position.z=.005*-r.value));case"xr-standard-squeeze":return void(i||(t._modelRootNode.getChildren()[4].position.x=n*r.value*.0035));case"xr-standard-thumbstick":return;case"a-button":case"x-button":return void(i||(r.pressed?t._modelRootNode.getChildren()[1].position.y=-.001:t._modelRootNode.getChildren()[1].position.y=0));case"b-button":case"y-button":return void(i||(r.pressed?t._modelRootNode.getChildren()[2].position.y=-.001:t._modelRootNode.getChildren()[2].position.y=0))}}),void 0,!0)}))},t.prototype._setRootMesh=function(e){this.rootMesh=new be.a(this.profileId+" "+this.handedness,this.scene),this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0)),e.forEach((function(e){e.isPickable=!1})),this._isQuest()?this._modelRootNode=e[0]:(this._modelRootNode=e[1],this.rootMesh.position.y=.034,this.rootMesh.position.z=.052),this._modelRootNode.parent=this.rootMesh},t.prototype._updateModel=function(){},t.prototype._isQuest=function(){return!!navigator.userAgent.match(/Quest/gi)&&!this._forceLegacyControllers},t.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",t.MODEL_LEFT_FILENAME="left.babylon",t.MODEL_RIGHT_FILENAME="right.babylon",t.QUEST_MODEL_BASE_URL="https://controllers.babylonjs.com/oculusQuest/",t}(wa);Va.RegisterController("oculus-touch",(function(e,t){return new q_(t,e.gamepad,e.handedness)})),Va.RegisterController("oculus-touch-legacy",(function(e,t){return new q_(t,e.gamepad,e.handedness,!0)}));var Z_={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"x-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"x_button",visualResponses:{}},"y-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"y_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-thumbstick":{type:"thumbstick",gamepadIndices:{button:3,xAxis:2,yAxis:3},rootNodeName:"xr_standard_thumbstick",visualResponses:{}},"a-button":{type:"button",gamepadIndices:{button:4},rootNodeName:"a_button",visualResponses:{}},"b-button":{type:"button",gamepadIndices:{button:5},rootNodeName:"b_button",visualResponses:{}},thumbrest:{type:"button",gamepadIndices:{button:6},rootNodeName:"thumbrest",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"oculus-touch-v2-right",assetPath:"right.glb"}},J_=function(e){function t(t,i,n){var r=e.call(this,t,$_[n],i,n)||this;return r.profileId="htc-vive",r}return Object(h.d)(t,e),t.prototype._getFilenameAndPath=function(){return{filename:t.MODEL_FILENAME,path:t.MODEL_BASE_URL}},t.prototype._getModelLoadingConstraints=function(){return!0},t.prototype._processLoadedModel=function(e){var t=this;this.getComponentIds().forEach((function(e){var i=e&&t.getComponent(e);i&&i.onButtonStateChangedObservable.add((function(i){if(t.rootMesh&&!t.disableAnimation)switch(e){case"xr-standard-trigger":return void(t._modelRootNode.getChildren()[6].rotation.x=.15*-i.value);case"xr-standard-touchpad":case"xr-standard-squeeze":return}}),void 0,!0)}))},t.prototype._setRootMesh=function(e){this.rootMesh=new be.a(this.profileId+" "+this.handedness,this.scene),e.forEach((function(e){e.isPickable=!1})),this._modelRootNode=e[1],this._modelRootNode.parent=this.rootMesh,this.scene.useRightHandedSystem||(this.rootMesh.rotationQuaternion=a.b.FromEulerAngles(0,Math.PI,0))},t.prototype._updateModel=function(){},t.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",t.MODEL_FILENAME="wand.babylon",t}(wa);Va.RegisterController("htc-vive",(function(e,t){return new J_(t,e.gamepad,e.handedness)}));var $_={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc_vive_none",assetPath:"none.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr_standard_trigger",visualResponses:{}},"xr-standard-squeeze":{type:"squeeze",gamepadIndices:{button:1},rootNodeName:"xr_standard_squeeze",visualResponses:{}},"xr-standard-touchpad":{type:"touchpad",gamepadIndices:{button:2,xAxis:0,yAxis:1},rootNodeName:"xr_standard_touchpad",visualResponses:{}},menu:{type:"button",gamepadIndices:{button:4},rootNodeName:"menu",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"htc-vive-none",assetPath:"none.glb"}}},function(e,t,i){"use strict";i.d(t,"a",(function(){return g}));var n=i(34),r=function(){function e(){this.children=[]}return e.prototype.isValid=function(e){return!0},e.prototype.process=function(e,t){var i="";if(this.line){var r=this.line,o=t.processor;if(o){if(o.lineProcessor&&(r=o.lineProcessor(r,t.isFragment)),o.attributeProcessor&&n.a.StartsWith(this.line,"attribute"))r=o.attributeProcessor(this.line);else if(o.varyingProcessor&&n.a.StartsWith(this.line,"varying"))r=o.varyingProcessor(this.line,t.isFragment);else if((o.uniformProcessor||o.uniformBufferProcessor)&&n.a.StartsWith(this.line,"uniform")){/uniform (.+) (.+)/.test(this.line)?o.uniformProcessor&&(r=o.uniformProcessor(this.line,t.isFragment)):o.uniformBufferProcessor&&(r=o.uniformBufferProcessor(this.line,t.isFragment),t.lookForClosingBracketForUniformBuffer=!0)}o.endOfUniformBufferProcessor&&t.lookForClosingBracketForUniformBuffer&&-1!==this.line.indexOf("}")&&(t.lookForClosingBracketForUniformBuffer=!1,r=o.endOfUniformBufferProcessor(this.line,t.isFragment))}i+=r+"\r\n"}return this.children.forEach((function(n){i+=n.process(e,t)})),this.additionalDefineKey&&(e[this.additionalDefineKey]=this.additionalDefineValue||"true"),i},e}(),o=function(){function e(){}return Object.defineProperty(e.prototype,"currentLine",{get:function(){return this._lines[this.lineIndex]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canRead",{get:function(){return this.lineIndex<this._lines.length-1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"lines",{set:function(e){this._lines=[];for(var t=0,i=e;t<i.length;t++){var n=i[t];if("#"!==n[0])for(var r=n.split(";"),o=0;o<r.length;o++){var a=r[o];(a=a.trim())&&this._lines.push(a+(o!==r.length-1?";":""))}else this._lines.push(n)}},enumerable:!1,configurable:!0}),e}(),a=i(1),s=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.process=function(e,t){for(var i=0;i<this.children.length;i++){var n=this.children[i];if(n.isValid(e))return n.process(e,t)}return""},t}(r),c=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.isValid=function(e){return this.testExpression.isTrue(e)},t}(r),l=function(){function e(){}return e.prototype.isTrue=function(e){return!0},e.postfixToInfix=function(t){for(var i=[],n=0,r=t;n<r.length;n++){var o=r[n];if(void 0===e._OperatorPriority[o])i.push(o);else{var a=i[i.length-1],s=i[i.length-2];i.length-=2,i.push("("+s+o+a+")")}}return i[i.length-1]},e.infixToPostfix=function(t){for(var i=[],n=-1,r=function(){""!==(l=l.trim())&&(i.push(l),l="")},o=function(t){n<e._Stack.length-1&&(e._Stack[++n]=t)},a=function(){return e._Stack[n]},s=function(){return-1===n?"!!INVALID EXPRESSION!!":e._Stack[n--]},c=0,l="";c<t.length;){var u=t.charAt(c),h=c<t.length-1?t.substr(c,2):"";if("("===u)l="",o(u);else if(")"===u){for(r();-1!==n&&"("!==a();)i.push(s());s()}else if(e._OperatorPriority[h]>1){for(r();-1!==n&&e._OperatorPriority[a()]>=e._OperatorPriority[h];)i.push(s());o(h),c++}else l+=u;c++}for(r();-1!==n;)"("===a()?s():i.push(s());return i},e._OperatorPriority={")":0,"(":1,"||":2,"&&":3},e._Stack=["","","","","","","","","","","","","","","","","","","",""],e}(),u=function(e){function t(t,i){void 0===i&&(i=!1);var n=e.call(this)||this;return n.define=t,n.not=i,n}return Object(a.d)(t,e),t.prototype.isTrue=function(e){var t=void 0!==e[this.define];return this.not&&(t=!t),t},t}(l),h=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)||this.rightOperand.isTrue(e)},t}(l),d=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(a.d)(t,e),t.prototype.isTrue=function(e){return this.leftOperand.isTrue(e)&&this.rightOperand.isTrue(e)},t}(l),f=function(e){function t(t,i,n){var r=e.call(this)||this;return r.define=t,r.operand=i,r.testValue=n,r}return Object(a.d)(t,e),t.prototype.isTrue=function(e){var t=e[this.define];void 0===t&&(t=this.define);var i=!1,n=parseInt(t),r=parseInt(this.testValue);switch(this.operand){case">":i=n>r;break;case"<":i=n<r;break;case"<=":i=n<=r;break;case">=":i=n>=r;break;case"==":i=n===r}return i},t}(l),p=i(21),_=/defined\s*?\((.+?)\)/g,m=/defined\s*?\[(.+?)\]/g,g=function(){function e(){}return e.Process=function(e,t,i,n){var r=this;this._ProcessIncludes(e,t,(function(e){var o=r._ProcessShaderConversion(e,t,n);i(o)}))},e._ProcessPrecision=function(e,t){var i=t.shouldUseHighPrecisionShader;return-1===e.indexOf("precision highp float")?e=i?"precision highp float;\n"+e:"precision mediump float;\n"+e:i||(e=e.replace("precision highp float","precision mediump float")),e},e._ExtractOperation=function(e){var t=/defined\((.+)\)/.exec(e);if(t&&t.length)return new u(t[1].trim(),"!"===e[0]);for(var i="",n=0,r=0,o=["==",">=","<=","<",">"];r<o.length&&(i=o[r],!((n=e.indexOf(i))>-1));r++);if(-1===n)return new u(e);var a=e.substring(0,n).trim(),s=e.substring(n+i.length).trim();return new f(a,i,s)},e._BuildSubExpression=function(e){e=e.replace(_,"defined[$1]");for(var t=[],i=0,n=l.infixToPostfix(e);i<n.length;i++){var r=n[i];if("||"!==r&&"&&"!==r)t.push(r);else if(t.length>=2){var o=t[t.length-1],a=t[t.length-2];t.length-=2;var s="&&"==r?new d:new h;"string"==typeof o&&(o=o.replace(m,"defined($1)")),"string"==typeof a&&(a=a.replace(m,"defined($1)")),s.leftOperand="string"==typeof a?this._ExtractOperation(a):a,s.rightOperand="string"==typeof o?this._ExtractOperation(o):o,t.push(s)}}var c=t[t.length-1];return"string"==typeof c&&(c=c.replace(m,"defined($1)")),"string"==typeof c?this._ExtractOperation(c):c},e._BuildExpression=function(e,t){var i=new c,n=e.substring(0,t),r=e.substring(t);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),i.testExpression="#ifdef"===n?new u(r):"#ifndef"===n?new u(r,!0):this._BuildSubExpression(r),i},e._MoveCursorWithinIf=function(e,t,i){for(var n=e.currentLine;this._MoveCursor(e,i);){var o=(n=e.currentLine).substring(0,5).toLowerCase();if("#else"===o){var a=new r;return t.children.push(a),void this._MoveCursor(e,a)}if("#elif"===o){var s=this._BuildExpression(n,5);t.children.push(s),i=s}}},e._MoveCursor=function(e,t){for(;e.canRead;){e.lineIndex++;var i=e.currentLine,n=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(i);if(n&&n.length){switch(n[0]){case"#ifdef":var o=new s;t.children.push(o);var a=this._BuildExpression(i,6);o.children.push(a),this._MoveCursorWithinIf(e,o,a);break;case"#else":case"#elif":return!0;case"#endif":return!1;case"#ifndef":o=new s;t.children.push(o);a=this._BuildExpression(i,7);o.children.push(a),this._MoveCursorWithinIf(e,o,a);break;case"#if":o=new s,a=this._BuildExpression(i,3);t.children.push(o),o.children.push(a),this._MoveCursorWithinIf(e,o,a)}}else{var c=new r;if(c.line=i,t.children.push(c),"#"===i[0]&&"d"===i[1]){var l=i.replace(";","").split(" ");c.additionalDefineKey=l[1],3===l.length&&(c.additionalDefineValue=l[2])}}}return!1},e._EvaluatePreProcessors=function(e,t,i){var n=new r,a=new o;return a.lineIndex=-1,a.lines=e.split("\n"),this._MoveCursor(a,n),n.process(t,i)},e._PreparePreProcessors=function(e){for(var t={},i=0,n=e.defines;i<n.length;i++){var r=n[i].replace("#define","").replace(";","").trim().split(" ");t[r[0]]=r.length>1?r[1]:""}return t.GL_ES="true",t.__VERSION__=e.version,t[e.platformName]="true",t},e._ProcessShaderConversion=function(e,t,i){var n=this._ProcessPrecision(e,t);if(!t.processor)return n;if(-1!==n.indexOf("#version 3"))return n.replace("#version 300 es","");var r=t.defines,o=this._PreparePreProcessors(t);return t.processor.preProcessor&&(n=t.processor.preProcessor(n,r,t.isFragment)),n=this._EvaluatePreProcessors(n,o,t),t.processor.postProcessor&&(n=t.processor.postProcessor(n,r,t.isFragment,i)),n},e._ProcessIncludes=function(t,i,n){for(var r=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,a=o.exec(t),s=new String(t),c=!1;null!=a;){var l=a[1];if(-1!==l.indexOf("__decl__")&&(l=l.replace(/__decl__/,""),i.supportsUniformBuffers&&(l=(l=l.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),l+="Declaration"),!i.includesShadersStore[l]){var u=i.shadersRepository+"ShadersInclude/"+l+".fx";return void e._FileToolsLoadFile(u,(function(e){i.includesShadersStore[l]=e,r._ProcessIncludes(s,i,n)}))}var h=i.includesShadersStore[l];if(a[2])for(var d=a[3].split(","),f=0;f<d.length;f+=2){var p=new RegExp(d[f],"g"),_=d[f+1];h=h.replace(p,_)}if(a[4]){var m=a[5];if(-1!==m.indexOf("..")){var g=m.split(".."),v=parseInt(g[0]),b=parseInt(g[1]),y=h.slice(0);h="",isNaN(b)&&(b=i.indexParameters[g[1]]);for(var T=v;T<b;T++)i.supportsUniformBuffers||(y=y.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),h+=y.replace(/\{X\}/g,T.toString())+"\n"}else i.supportsUniformBuffers||(h=h.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),h=h.replace(/\{X\}/g,m)}s=s.replace(a[0],h),c=c||h.indexOf("#include<")>=0,a=o.exec(t)}c?this._ProcessIncludes(s.toString(),i,n):n(s)},e._FileToolsLoadFile=function(e,t,i,n,r,o){throw p.a.WarnImport("FileTools")},e}()},function(e,t,i){"use strict";i(26).a.prototype._readTexturePixels=function(e,t,i,n,r,o){void 0===n&&(n=-1),void 0===r&&(r=0),void 0===o&&(o=null);var a=this._gl;if(!a)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var s=a.createFramebuffer();if(!s)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=s}a.bindFramebuffer(a.FRAMEBUFFER,this._dummyFramebuffer),n>-1?a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+n,e._webGLTexture,r):a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e._webGLTexture,r);var c=void 0!==e.type?this._getWebGLTextureType(e.type):a.UNSIGNED_BYTE;switch(c){case a.UNSIGNED_BYTE:o||(o=new Uint8Array(4*t*i)),c=a.UNSIGNED_BYTE;break;default:o||(o=new Float32Array(4*t*i)),c=a.FLOAT}return a.readPixels(0,0,t,i,a.RGBA,c,o),a.bindFramebuffer(a.FRAMEBUFFER,this._currentFramebuffer),o}},function(e,t,i){"use strict";var n="shadowsFragmentFunctions",r="#ifdef SHADOWS\n#ifndef SHADOWFLOAT\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\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.00000012,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\n#define inline\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\nreturn depth>shadow ? darkness : 1.0;\n}\n#define inline\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}\n#define inline\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}\n#define inline\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}\n#ifdef WEBGL2\n#define inline\nfloat computeShadowCSM(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nvec3 uvLayer=vec3(uv.x,uv.y,layer);\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uvLayer));\n#else\nfloat shadow=texture2D(shadowSampler,uvLayer).x;\n#endif\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n#endif\n#define inline\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}\nelse\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\nreturn shadowPixelDepth>shadow ? computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff) : 1.;\n}\n}\n#define inline\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}\nelse\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}\n}\n#define inline\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}\nelse\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}\n}\n#define inline\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}\nelse\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}\n#ifdef WEBGL2\n#define GREATEST_LESS_THAN_ONE 0.99999994\n\n#define inline\nfloat computeShadowWithCSMPCF1(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat shadow=texture(shadowSampler,uvDepthLayer);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\n#define inline\nfloat computeShadowWithCSMPCF3(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\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,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\n#define inline\nfloat computeShadowWithCSMPCF5(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArrayShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\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,vec4(base_uv.xy+vec2(u[0],v[0]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[0]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[0]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[1]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[1]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[1]),layer,uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[0],v[2]),layer,uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[1],v[2]),layer,uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec4(base_uv.xy+vec2(u[2],v[2]),layer,uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n#define inline\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nelse\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\n\n#define inline\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}\nelse\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\n\n#define inline\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}\nelse\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}\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\n#define inline\nfloat computeShadowWithCSMPCSS(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nuvDepth.z=clamp(uvDepth.z,0.,GREATEST_LESS_THAN_ONE);\nvec4 uvDepthLayer=vec4(uvDepth.x,uvDepth.y,layer,uvDepth.z);\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,vec3(uvDepth.xy+(lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse*PoissonSamplers32[i].xy),layer)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nelse\n{\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)*depthCorrection+AAOffset);\nvec4 filterRadius=vec4(penumbraRatio*lightSizeUV*lightSizeUVCorrection*shadowMapSizeInverse,0.,0.);\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++) {\nvec4 offset=vec4(poissonSamplers[i],0.);\n\noffset=vec4(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.,0.);\nshadow+=texture2D(shadowSampler,uvDepthLayer+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,min((depthMetric-avgBlockerDepth)*depthCorrection*penumbraDarkness,1.));\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n}\n\n\n\n\n\n#define inline\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}\nelse\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}\nelse\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}\n}\n}\n#define inline\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}\n#define inline\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}\n#define inline\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#define inline\nfloat computeShadowWithCSMPCSS16(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat computeShadowWithCSMPCSS32(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#define inline\nfloat computeShadowWithCSMPCSS64(float layer,vec4 vPositionFromLight,float depthMetric,highp sampler2DArray depthSampler,highp sampler2DArrayShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,vec2 lightSizeUVCorrection,float depthCorrection,float penumbraDarkness)\n{\nreturn computeShadowWithCSMPCSS(layer,vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64,lightSizeUVCorrection,depthCorrection,penumbraDarkness);\n}\n#endif\n#endif\n";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="reflectionFunction",r="vec3 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}\nvec3 computeFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\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;\nreturn vec3(s,t,0);\n}\nvec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 direction)\n{\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;\nreturn vec3(1.0-s,t,0);\n}\nvec3 computeEquirectangularCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 cameraToVertex=normalize(worldPos.xyz-eyePosition);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nr=vec3(reflectionMatrix*vec4(r,0));\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}\nvec3 computeSphericalCoords(vec4 worldPos,vec3 worldNormal,mat4 view,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr=vec3(reflectionMatrix*vec4(r,0));\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}\nvec3 computePlanarCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=worldPos.xyz-eyePosition;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n}\nvec3 computeCubicCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\n\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeCubicLocalCoords(vec4 worldPos,vec3 worldNormal,vec3 eyePosition,mat4 reflectionMatrix,vec3 reflectionSize,vec3 reflectionPosition)\n{\nvec3 viewDir=normalize(worldPos.xyz-eyePosition);\n\nvec3 coords=reflect(viewDir,worldNormal);\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,reflectionSize,reflectionPosition);\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n}\nvec3 computeProjectionCoords(vec4 worldPos,mat4 view,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*(view*worldPos));\n}\nvec3 computeSkyBoxCoords(vec3 positionW,mat4 reflectionMatrix)\n{\nreturn vec3(reflectionMatrix*vec4(positionW,1.));\n}\n#ifdef REFLECTION\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeMirroredFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED\nvec3 direction=normalize(vDirectionW);\nreturn computeFixedEquirectangularCoords(worldPos,worldNormal,direction);\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nreturn computeEquirectangularCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nreturn computeSphericalCoords(worldPos,worldNormal,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nreturn computePlanarCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_CUBIC\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nreturn computeCubicLocalCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix,vReflectionSize,vReflectionPosition);\n#else\nreturn computeCubicCoords(worldPos,worldNormal,vEyePosition.xyz,reflectionMatrix);\n#endif\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn computeProjectionCoords(worldPos,view,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn computeSkyBoxCoords(vPositionUVW,reflectionMatrix);\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="bumpFragmentMainFunctions",r="#if defined(BUMP) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC) || defined(DETAIL)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\nvec3 perturbNormalBase(mat3 cotangentFrame,vec3 normal,float scale)\n{\n#ifdef NORMALXYSCALE\nnormal=normalize(normal*vec3(scale,scale,1.0));\n#endif\nreturn normalize(cotangentFrame*normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec3 textureSample,float scale)\n{\nreturn perturbNormalBase(cotangentFrame,textureSample*2.0-1.0,scale);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv,vec2 tangentSpaceParams)\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*=tangentSpaceParams.x;\nbitangent*=tangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\n#endif\n";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="bumpFragmentFunctions",r="#if defined(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;\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nreturn perturbNormal(cotangentFrame,texture2D(bumpSampler,uv).xyz,vBumpInfos.y);\n}\n#endif\n#if defined(DETAIL)\n#if DETAILDIRECTUV == 1\n#define vDetailUV vMainUV1\n#elif DETAILDIRECTUV == 2\n#define vDetailUV vMainUV2\n#else\nvarying vec2 vDetailUV;\n#endif\nuniform sampler2D detailSampler;\n#endif\n#if defined(BUMP)\nvec3 perturbNormal(mat3 cotangentFrame,vec3 color)\n{\nreturn perturbNormal(cotangentFrame,color,vBumpInfos.y);\n}\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\nreturn cotangent_frame(normal,p,uv,vTangentSpaceParams);\n}\n#endif\n#if defined(BUMP) && defined(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";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX) || defined(DETAIL)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#elif defined(BUMP)\nfloat normalScale=vBumpInfos.y;\n#else\nfloat normalScale=1.0;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#elif defined(BUMP)\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vDetailUV,vec2(1.,1.));\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW,vPositionW,vMainUV1,vec2(1.,1.));\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 DETAIL\nvec4 detailColor=texture2D(detailSampler,vDetailUV+uvOffset);\nvec2 detailNormalRG=detailColor.wy*2.0-1.0;\nfloat detailNormalB=sqrt(1.-saturate(dot(detailNormalRG,detailNormalRG)));\nvec3 detailNormal=vec3(detailNormalRG,detailNormalB);\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#elif !defined(DETAIL)\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#else\nvec3 bumpNormal=texture2D(bumpSampler,vBumpUV+uvOffset).xyz*2.0-1.0;\n\n#if DETAIL_NORMALBLENDMETHOD == 0\ndetailNormal.xy*=vDetailInfos.z;\nvec3 blendedNormal=normalize(vec3(bumpNormal.xy+detailNormal.xy,bumpNormal.z*detailNormal.z));\n#elif DETAIL_NORMALBLENDMETHOD == 1\ndetailNormal.xy*=vDetailInfos.z;\nbumpNormal+=vec3(0.0,0.0,1.0);\ndetailNormal*=vec3(-1.0,-1.0,1.0);\nvec3 blendedNormal=bumpNormal*dot(bumpNormal,detailNormal)/bumpNormal.z-detailNormal;\n#endif\nnormalW=perturbNormalBase(TBN,blendedNormal,vBumpInfos.y);\n#endif\n#elif defined(DETAIL)\ndetailNormal.xy*=vDetailInfos.z;\nnormalW=perturbNormalBase(TBN,detailNormal,vDetailInfos.z);\n#endif";i(5).a.IncludesShadersStore.bumpFragment=n},function(e,t,i){"use strict";var n="lightFragment",r="#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X})\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#elif defined(SS_TRANSLUCENCY)\ninfo.diffuse=computeDiffuseAndTransmittedLighting(preInfo,light{X}.vLightDiffuse.rgb,subSurfaceOut.transmittance);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,anisotropicOut.anisotropicTangent,anisotropicOut.anisotropicBitangent,anisotropicOut.anisotropy,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#else\ninfo.specular=computeSpecularLighting(preInfo,normalW,clearcoatOut.specularEnvironmentR0,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n#endif\n\n#ifdef SHEEN\n#ifdef SHEEN_LINKWITHALBEDO\n\npreInfo.roughness=sheenOut.sheenIntensity;\n#else\n#ifdef HEMILIGHT{X}\npreInfo.roughness=sheenOut.sheenRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(sheenOut.sheenRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\n#endif\ninfo.sheen=computeSheenLighting(preInfo,normalW,sheenOut.sheenColor,specularEnvironmentR90,AARoughnessFactors.x,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef CLEARCOAT\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=clearcoatOut.clearCoatRoughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(clearcoatOut.clearCoatRoughness,light{X}.vLightSpecular.a,preInfo.lightDistance);\n#endif\ninfo.clearCoat=computeClearCoatLighting(preInfo,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatAARoughnessFactors.x,clearcoatOut.clearCoatIntensity,light{X}.vLightDiffuse.rgb);\n#ifdef CLEARCOAT_TINT\n\nabsorption=computeClearCoatLightingAbsorption(clearcoatOut.clearCoatNdotVRefract,preInfo.L,clearcoatOut.clearCoatNormalW,clearcoatOut.clearCoatColor,clearcoatOut.clearCoatThickness,clearcoatOut.clearCoatIntensity);\ninfo.diffuse*=absorption;\n#ifdef SPECULARTERM\ninfo.specular*=absorption;\n#endif\n#endif\n\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=info.clearCoat.w;\n#endif\n#ifdef SHEEN\ninfo.sheen*=info.clearCoat.w;\n#endif\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.rgb,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular.rgb,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.rgb,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 SHADOWCSM{X}\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++)\n{\n#ifdef SHADOWCSM_RIGHTHANDED{X}\ndiff{X}=viewFrustumZ{X}[i]+vPositionFromCamera{X}.z;\n#else\ndiff{X}=viewFrustumZ{X}[i]-vPositionFromCamera{X}.z;\n#endif\nif (diff{X}>=0.) {\nindex{X}=i;\nbreak;\n}\n}\n#ifdef SHADOWCSMUSESHADOWMAXZ{X}\nif (index{X}>=0)\n#endif\n{\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{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=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#else\nshadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#endif\n#else\nshadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=vec3(shadow)*vCascadeColorsMultiplier{X}[index{X}];\n#endif\n#ifndef SHADOWCSMNOBLEND{X}\nfloat frustumLength=frustumLengths{X}[index{X}];\nfloat diffRatio=clamp(diff{X}/frustumLength,0.,1.)*cascadeBlendFactor{X};\nif (index{X}<(SHADOWCSMNUM_CASCADES{X}-1) && diffRatio<1.)\n{\nindex{X}+=1;\nfloat nextShadow=0.;\n#if defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nnextShadow=computeShadowWithCSMPCF1(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCF3(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nnextShadow=computeShadowWithCSMPCF5(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{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})\nnextShadow=computeShadowWithCSMPCSS16(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#elif defined(SHADOWMEDIUMQUALITY{X})\nnextShadow=computeShadowWithCSMPCSS32(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#else\nnextShadow=computeShadowWithCSMPCSS64(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w,lightSizeUVCorrection{X}[index{X}],depthCorrection{X}[index{X}],penumbraDarkness{X});\n#endif\n#else\nnextShadow=computeShadowCSM(float(index{X}),vPositionFromLight{X}[index{X}],vDepthMetric{X}[index{X}],shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\nshadow=mix(nextShadow,shadow,diffRatio);\n#ifdef SHADOWCSMDEBUG{X}\nshadowDebug{X}=mix(vec3(nextShadow)*vCascadeColorsMultiplier{X}[index{X}],shadowDebug{X},diffRatio);\n#endif\n}\n#endif\n}\n#elif defined(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.rgb*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef CLEARCOAT\n#ifndef LIGHTMAPNOSPECULAR{X}\nclearCoatBase+=info.clearCoat.rgb*shadow*lightmapColor.rgb;\n#endif\n#endif\n#ifdef SHEEN\n#ifndef LIGHTMAPNOSPECULAR{X}\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#else\n#ifdef SHADOWCSMDEBUG{X}\ndiffuseBase+=info.diffuse*shadowDebug{X};\n#else\ndiffuseBase+=info.diffuse*shadow;\n#endif\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#ifdef CLEARCOAT\nclearCoatBase+=info.clearCoat.rgb*shadow;\n#endif\n#ifdef SHEEN\nsheenBase+=info.sheen.rgb*shadow;\n#endif\n#endif\n#endif\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";i(5).a.IncludesShadersStore.fogFragment=n},function(e,t,i){"use strict";var n="fogVertexDeclaration",r="#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="shadowsVertex",r="#ifdef SHADOWS\n#if defined(SHADOWCSM{X})\nvPositionFromCamera{X}=view*worldPos;\nfor (int i=0; i<SHADOWCSMNUM_CASCADES{X}; i++) {\nvPositionFromLight{X}[i]=lightMatrix{X}[i]*worldPos;\nvDepthMetric{X}[i]=((vPositionFromLight{X}[i].z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n}\n#elif 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[n]=r},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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 n;i=i||function(e){return"true"===e};var r=t.split("||");for(var o in r)if(r.hasOwnProperty(o)){var a=e._SimplifyNegation(r[o].trim()),s=a.split("&&");if(s.length>1)for(var c=0;c<s.length;++c){var l=e._SimplifyNegation(s[c].trim());if(!(n="true"!==l&&"false"!==l?"!"===l[0]?!i(l.substring(1)):i(l):"true"===l)){a="false";break}}if(n||"true"===a){n=!0;break}n="true"!==a&&"false"!==a?"!"===a[0]?!i(a.substring(1)):i(a):"true"===a}return n?"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}));var n=function(){function e(){}return e.ExponentialBackoff=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=500),function(i,n,r){return 0!==n.status||r>=e||-1!==i.indexOf("file:")?-1:Math.pow(2,r)*t}},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var 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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r}));var n=i(2),r=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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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:!1,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=n.a.ALWAYS,e.KEEP=n.a.KEEP,e.REPLACE=n.a.REPLACE,e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=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:!1,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:!1,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,i,n){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===n||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=n,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,n){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===n||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=n,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}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){this.vertexCompilationError=null,this.fragmentCompilationError=null,this.programLinkError=null,this.programValidationError=null}return Object.defineProperty(e.prototype,"isAsync",{get:function(){return this.isParallelCompiled},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isReady",{get:function(){return!!this.program&&(!this.isParallelCompiled||this.engine._isRenderingStateCompiled(this))},enumerable:!1,configurable:!0}),e.prototype._handlesSpectorRebuildCallback=function(e){e&&this.program&&e(this.program)},e.prototype._getVertexShaderCode=function(){return this.vertexShader?this.engine._getShaderSource(this.vertexShader):null},e.prototype._getFragmentShaderCode=function(){return this.fragmentShader?this.engine._getShaderSource(this.fragmentShader):null},e}()},function(e,t,i){"use strict";var n;i.d(t,"a",(function(){return a})),function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"}(n||(n={}));var r=function(){this.count=0,this.target=0,this.results=[]},o=function(){function e(e){var t=this;if(this._state=n.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:!1,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,i){var r=this,o=new e;return o._onFulfilled=t,o._onRejected=i,this._children.push(o),o._parent=this,this._state!==n.Pending&&setTimeout((function(){if(r._state===n.Fulfilled||r._rejectWasConsumed){var e=o._resolve(r._result);if(null!=e)if(void 0!==e._state){var t=e;o._children.push(t),t._parent=o,o=t}else o._result=e}else o._reject(r._reason)})),o},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===n.Fulfilled)for(var r=0,o=this._children;r<o.length;r++){o[r]._resolve(this._result)}else if(this._state===n.Rejected)for(var a=0,s=this._children;a<s.length;a++){s[a]._reject(this._reason)}},e.prototype._resolve=function(e){try{this._state=n.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 r=0,o=this._children;r<o.length;r++){o[r]._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=n.Rejected,this._reason=e,this._onRejected&&!t)try{this._onRejected(e),this._rejectWasConsumed=!0}catch(t){e=t}for(var i=0,r=this._children;i<r.length;i++){var o=r[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!==n.Rejected&&t.rootPromise._reject(e)}))},e.all=function(t){var i=new e,n=new r;if(n.target=t.length,n.rootPromise=i,t.length)for(var o=0;o<t.length;o++)e._RegisterForFulfillment(t[o],n,o);else i._resolve([]);return i},e.race=function(t){var i=new e;if(t.length)for(var n=0,r=t;n<r.length;n++){r[n].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=o)},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return r})),i.d(t,"b",(function(){return o}));var n=i(57),r=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=n.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:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFPS",{get:function(){var e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!1,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:!1,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 r}));var n=i(0),r=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new n.e(0,0,0),this._diffPositionForCollisions=new n.e(0,0,0),this._collisionResponse=!0}},function(e,t,i){"use strict";i.d(t,"a",(function(){return a}));var n=i(33),r=i(0),o=i(2),a=function(){function e(e,t,i,r,o){void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=null),this.index=e,this._opaqueSubMeshes=new n.a(256),this._transparentSubMeshes=new n.a(256),this._alphaTestSubMeshes=new n.a(256),this._depthOnlySubMeshes=new n.a(256),this._particleSystems=new n.a(256),this._spriteManagers=new n.a(256),this._edgesRenderers=new n.b(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=o}return Object.defineProperty(e.prototype,"opaqueSortCompareFn",{set:function(t){this._opaqueSortCompareFn=t,this._renderOpaque=t?this.renderOpaqueSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"alphaTestSortCompareFn",{set:function(t){this._alphaTestSortCompareFn=t,this._renderAlphaTest=t?this.renderAlphaTestSorted:e.renderUnsorted},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"transparentSortCompareFn",{set:function(t){this._transparentSortCompareFn=t||e.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!1,configurable:!0}),e.prototype.render=function(e,t,i,n){if(e)e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var r=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(r.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),r.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);var a=r.getStencilBuffer();if(r.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(n),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(r.setStencilBuffer(a),this._renderTransparent(this._transparentSubMeshes),r.setAlphaMode(o.a.ALPHA_DISABLE)),r.setStencilBuffer(!1),this._edgesRenderers.length){for(var s=0;s<this._edgesRenderers.length;s++)this._edgesRenderers.data[s].render();r.setAlphaMode(o.a.ALPHA_DISABLE)}r.setStencilBuffer(a)}},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(t,i,n,a){for(var s,c=0,l=n?n.globalPosition:e._zeroVector;c<t.length;c++)(s=t.data[c])._alphaIndex=s.getMesh().alphaIndex,s._distanceToCamera=r.e.Distance(s.getBoundingInfo().boundingSphere.centerWorld,l);var u=t.data.slice(0,t.length);for(i&&u.sort(i),c=0;c<u.length;c++){if(s=u[c],a){var h=s.getMaterial();if(h&&h.needDepthPrePass){var d=h.getScene().getEngine();d.setColorWrite(!1),d.setAlphaMode(o.a.ALPHA_DISABLE),s.render(!1),d.setColorWrite(!0)}}s.render(a)}},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._renderingGroup=this,t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.pushNoDuplicate(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 n=this._particleSystems.data[i];if(0!==(t&&t.layerMask&n.layerMask)){var r=n.emitter;r.position&&e&&-1===e.indexOf(r)||this._scene._activeParticles.addCount(n.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._zeroVector=r.e.Zero(),e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(e,t){this.distance=e,this.mesh=t}},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return e.GenerateBase64StringFromTexture=function(e,t,i){void 0===t&&(t=0),void 0===i&&(i=0);var n=e.getInternalTexture();if(!n)return null;var r=e.readPixels(t,i);if(!r)return null;var o=e.getSize(),a=o.width,s=o.height;if(r instanceof Float32Array){for(var c=r.byteLength/r.BYTES_PER_ELEMENT,l=new Uint8Array(c);--c>=0;){var u=r[c];u<0?u=0:u>1&&(u=1),l[c]=255*u}r=l}var h=document.createElement("canvas");h.width=a,h.height=s;var d=h.getContext("2d");if(!d)return null;var f=d.createImageData(a,s);if(f.data.set(r),d.putImageData(f,0,0),n.invertY){var p=document.createElement("canvas");p.width=a,p.height=s;var _=p.getContext("2d");return _?(_.translate(0,s),_.scale(1,-1),_.drawImage(h,0,0),p.toDataURL("image/png")):null}return h.toDataURL("image/png")},e}()},function(e,t,i){"use strict";i.d(t,"a",(function(){return f}));var n=i(1),r=i(0),o=i(8),a=i(31),s=i(7),c=i(41),l=i(46),u=i(4),h=i(43),d=i(12);s.a._instancedMeshFactory=function(e,t){var i=new f(e,t);if(t.instancedBuffers)for(var n in i.instancedBuffers={},t.instancedBuffers)i.instancedBuffers[n]=t.instancedBuffers[n];return i};var f=function(e){function t(t,i){var n=e.call(this,t,i.getScene())||this;n._indexInSourceMeshInstanceArray=-1,i.addInstance(n),n._sourceMesh=i,n._unIndexed=i._unIndexed,n.position.copyFrom(i.position),n.rotation.copyFrom(i.rotation),n.scaling.copyFrom(i.scaling),i.rotationQuaternion&&(n.rotationQuaternion=i.rotationQuaternion.clone()),n.animations=d.b.Slice(i.animations);for(var r=0,o=i.getAnimationRanges();r<o.length;r++){var a=o[r];null!=a&&n.createAnimationRange(a.name,a.from,a.to)}return n.infiniteDistance=i.infiniteDistance,n.setPivotMatrix(i.getPivotMatrix()),n.refreshBoundingInfo(),n._syncSubMeshes(),n}return Object(n.d)(t,e),t.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._sourceMesh._lightSources},enumerable:!1,configurable:!0}),t.prototype._resyncLightSources=function(){},t.prototype._resyncLightSource=function(e){},t.prototype._removeLightSource=function(e,t){},Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},set:function(e){this._sourceMesh&&e!==this._sourceMesh.renderingGroupId&&o.a.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")},enumerable:!1,configurable:!0}),t.prototype.getTotalVertices=function(){return this._sourceMesh?this._sourceMesh.getTotalVertices():0},t.prototype.getTotalIndices=function(){return this._sourceMesh.getTotalIndices()},Object.defineProperty(t.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!1,configurable:!0}),t.prototype.createInstance=function(e){return this._sourceMesh.createInstance(e)},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,n){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,n),this.sourceMesh},t.prototype.updateVerticesData=function(e,t,i,n){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,n),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:!1,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,t){if(this._sourceMesh.subMeshes||o.a.Warn("Instances should only be created for meshes with geometry."),this._currentLOD){if(this._currentLOD._getWorldMatrixDeterminant()>0!=this._getWorldMatrixDeterminant()>0)return this._internalAbstractMeshDataInfo._actAsRegularMesh=!0,!0;if(this._internalAbstractMeshDataInfo._actAsRegularMesh=!1,this._currentLOD._registerInstanceForRenderId(this,e),t){if(!this._currentLOD._internalAbstractMeshDataInfo._isActiveIntermediate)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstancesIntermediate=!0,!0}else if(!this._currentLOD._internalAbstractMeshDataInfo._isActive)return this._currentLOD._internalAbstractMeshDataInfo._onlyForInstances=!0,!0}return!1},t.prototype._postActivate=function(){this._sourceMesh.edgesShareWithInstances&&this._sourceMesh._edgesRenderer&&this._sourceMesh._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup?(this._sourceMesh._renderingGroup._edgesRenderers.pushNoDuplicate(this._sourceMesh._edgesRenderer),this._sourceMesh._edgesRenderer.customInstances.push(this.getWorldMatrix())):this._edgesRenderer&&this._edgesRenderer.isEnabled&&this._sourceMesh._renderingGroup&&this._sourceMesh._renderingGroup._edgesRenderers.push(this._edgesRenderer)},t.prototype.getWorldMatrix=function(){if(this._currentLOD&&this._currentLOD.billboardMode!==l.a.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){var t=this._currentLOD._masterMesh;return this._currentLOD._masterMesh=this,r.c.Vector3[7].copyFrom(this._currentLOD.position),this._currentLOD.position.set(0,0,0),r.c.Matrix[0].copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(r.c.Vector3[7]),this._currentLOD._masterMesh=t,r.c.Matrix[0]}return e.prototype.getWorldMatrix.call(this)},Object.defineProperty(t.prototype,"isAnInstance",{get:function(){return!0},enumerable:!1,configurable:!0}),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.sourceMesh:this._currentLOD},t.prototype._preActivateForIntermediateRendering=function(e){return this.sourceMesh._preActivateForIntermediateRendering(e)},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._updateBoundingInfo=function(){return this._boundingInfo?this._boundingInfo.update(this.worldMatrixFromCache):this._boundingInfo=new h.a(this.absolutePosition,this.absolutePosition,this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this},t.prototype.clone=function(e,t,i){void 0===t&&(t=null);var n=this._sourceMesh.createInstance(e);if(c.a.DeepCopy(this,n,["name","subMeshes","uniqueId","parent","lightSources","receiveShadows","material","visibility","skeleton","sourceMesh","isAnInstance","facetNb","isFacetDataEnabled","isBlocked","useBones","hasInstances","collider","edgesRenderer","forward","up","right","absolutePosition","absoluteScaling","absoluteRotationQuaternion","isWorldMatrixFrozen","nonUniformScaling","behaviors","worldMatrixFromCache","hasThinInstances"],[]),this.refreshBoundingInfo(),t&&(n.parent=t),!i)for(var r=0;r<this.getScene().meshes.length;r++){var o=this.getScene().meshes[r];o.parent===this&&o.clone(o.name,n)}return n.computeWorldMatrix(!0),n},t.prototype.dispose=function(t,i){void 0===i&&(i=!1),this._sourceMesh.removeInstance(this),e.prototype.dispose.call(this,t,i)},t}(a.a);s.a.prototype.edgesShareWithInstances=!1,s.a.prototype.registerInstancedBuffer=function(e,t){if(this.removeVerticesData(e),!this.instancedBuffers){this.instancedBuffers={};for(var i=0,n=this.instances;i<n.length;i++){n[i].instancedBuffers={}}this._userInstancedBuffersStorage={data:{},vertexBuffers:{},strides:{},sizes:{}}}this.instancedBuffers[e]=null,this._userInstancedBuffersStorage.strides[e]=t,this._userInstancedBuffersStorage.sizes[e]=32*t,this._userInstancedBuffersStorage.data[e]=new Float32Array(this._userInstancedBuffersStorage.sizes[e]),this._userInstancedBuffersStorage.vertexBuffers[e]=new u.b(this.getEngine(),this._userInstancedBuffersStorage.data[e],e,!0,!1,t,!0),this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[e]);for(var r=0,o=this.instances;r<o.length;r++){o[r].instancedBuffers[e]=null}},s.a.prototype._processInstancedBuffers=function(e,t){var i=e.length;for(var n in this.instancedBuffers){for(var r=this._userInstancedBuffersStorage.sizes[n],o=this._userInstancedBuffersStorage.strides[n],a=(i+1)*o;r<a;)r*=2;this._userInstancedBuffersStorage.data[n].length!=r&&(this._userInstancedBuffersStorage.data[n]=new Float32Array(r),this._userInstancedBuffersStorage.sizes[n]=r,this._userInstancedBuffersStorage.vertexBuffers[n]&&(this._userInstancedBuffersStorage.vertexBuffers[n].dispose(),this._userInstancedBuffersStorage.vertexBuffers[n]=null));var s=this._userInstancedBuffersStorage.data[n],c=0;if(t)(h=this.instancedBuffers[n]).toArray?h.toArray(s,c):h.copyToArray(s,c),c+=o;for(var l=0;l<i;l++){var h;(h=e[l].instancedBuffers[n]).toArray?h.toArray(s,c):h.copyToArray(s,c),c+=o}this._userInstancedBuffersStorage.vertexBuffers[n]?this._userInstancedBuffersStorage.vertexBuffers[n].updateDirectly(s,0):(this._userInstancedBuffersStorage.vertexBuffers[n]=new u.b(this.getEngine(),this._userInstancedBuffersStorage.data[n],n,!0,!1,o,!0),this.setVerticesBuffer(this._userInstancedBuffersStorage.vertexBuffers[n]))}},s.a.prototype._disposeInstanceSpecificData=function(){for(this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(var e in this.instancedBuffers)this._userInstancedBuffersStorage.vertexBuffers[e]&&this._userInstancedBuffersStorage.vertexBuffers[e].dispose();this.instancedBuffers={}}},function(e,t,i){"use strict";i.d(t,"a",(function(){return n}));var n=function(){function e(){}return Object.defineProperty(e,"UniqueId",{get:function(){var e=this._UniqueIdCounter;return this._UniqueIdCounter++,e},enumerable:!1,configurable:!0}),e._UniqueIdCounter=0,e}()},function(e,t,i){"use strict";var n=i(26),r=i(88);n.a.prototype.createUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");var i=new r.a(t);return this.bindUniformBuffer(i),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),i.references=1,i},n.a.prototype.createDynamicUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");var i=new r.a(t);return this.bindUniformBuffer(i),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),i.references=1,i},n.a.prototype.updateUniformBuffer=function(e,t,i,n){this.bindUniformBuffer(e),void 0===i&&(i=0),void 0===n?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+n)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(i,i+n)),this.bindUniformBuffer(null)},n.a.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e?e.underlyingResource:null)},n.a.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e?e.underlyingResource:null)},n.a.prototype.bindUniformBlock=function(e,t,i){var n=e.program,r=this._gl.getUniformBlockIndex(n,t);this._gl.uniformBlockBinding(n,r,i)}},function(e,t,i){"use strict";var n="lightsFragmentFunctions",r="\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\n#define inline\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[n]=r},function(e,t,i){"use strict";var n="logDepthFragment",r="#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\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=n},function(e,t,i){"use strict";var n="#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";i(5).a.IncludesShadersStore.fogVertex=n},function(e,t,i){"use strict";var n="logDepthVertex",r="#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";i(5).a.IncludesShadersStore[n]=r},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},function(e,t,i){"use strict";var n="prePassDeclaration",r="#ifdef PREPASS\n#extension GL_EXT_draw_buffers : require\n#ifdef WEBGL2\nlayout(location=0) out highp vec4 glFragData[{X}];\nhighp vec4 gl_FragColor;\n#endif\n#ifdef PREPASS_DEPTHNORMAL\nvarying highp vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nvarying highp vec4 vCurrentPosition;\nvarying highp vec4 vPreviousPosition;\n#endif\n#endif\n";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="fresnelFunction",r="#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";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";i(5).a.IncludesShadersStore.depthPrePass=n},function(e,t,i){"use strict";var n="prePassVertexDeclaration",r="#ifdef PREPASS\n#ifdef PREPASS_DEPTHNORMAL\nvarying vec3 vViewPos;\n#endif\n#ifdef PREPASS_VELOCITY\nuniform mat4 previousWorld;\nuniform mat4 previousViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="bumpVertexDeclaration",r="#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n="prePassVertex",r="#ifdef PREPASS_DEPTHNORMAL\nvViewPos=(view*worldPos).rgb;\n#endif\n#if defined(PREPASS_VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*worldPos;\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(positionUpdated,1.0);\n#endif\n#endif";i(5).a.IncludesShadersStore[n]=r},function(e,t,i){"use strict";var n=i(5),r=(i(115),i(110),"colorPixelShader"),o="#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\n#include<clipPlaneFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";n.a.ShadersStore[r]=o},function(e,t,i){"use strict";var n=i(5),r=(i(78),i(117),i(79),i(80),i(81),i(111),"colorVertexShader"),o="\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n#include<clipPlaneVertexDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*worldPos;\n} else {\ngl_Position=viewProjectionR*worldPos;\n}\n#else\ngl_Position=viewProjection*worldPos;\n#endif\n#include<clipPlaneVertex>\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";n.a.ShadersStore[r]=o},function(e,t,i){"use strict";(function(e){i.d(t,"b",(function(){return h})),i.d(t,"a",(function(){return d}));var n=i(1),r=i(8),o=i(13),a=i(102),s=i(27),c=i(2),l=i(89),u=i(74),h=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},d=function(t){function i(i){void 0===i&&(i=new h);var n=t.call(this,null)||this;o.a.Instances.push(n),void 0===i.deterministicLockstep&&(i.deterministicLockstep=!1),void 0===i.lockstepMaxSteps&&(i.lockstepMaxSteps=4),n._options=i,u.a.SetMatrixPrecision(!!i.useHighPrecisionMatrix),n._caps={maxTexturesImageUnits:16,maxVertexTextureImageUnits:16,maxCombinedTexturesImageUnits:32,maxTextureSize:512,maxCubemapTextureSize:512,maxRenderTextureSize:512,maxVertexAttribs:16,maxVaryingVectors:16,maxFragmentUniformVectors:16,maxVertexUniformVectors:16,standardDerivatives:!1,astc:null,pvrtc:null,etc1:null,etc2:null,bptc:null,maxAnisotropy:0,uintIndices:!1,fragmentDepthSupported:!1,highPrecisionShaderSupported:!0,colorBufferFloat:!1,textureFloat:!1,textureFloatLinearFiltering:!1,textureFloatRender:!1,textureHalfFloat:!1,textureHalfFloatLinearFiltering:!1,textureHalfFloatRender:!1,textureLOD:!1,drawBuffersExtension:!1,depthTextureExtension:!1,vertexArrayObject:!1,instancedArrays:!1,canUseTimestampForTimerQuery:!1,maxMSAASamples:1,blendMinMax:!1},r.a.Log("Babylon.js v"+o.a.Version+" - Null engine");var a="undefined"!=typeof self?self:void 0!==e?e:window;return"undefined"==typeof URL&&(a.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(a.Blob=function(){}),n}return Object(n.d)(i,t),i.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},i.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},i.prototype.getHardwareScalingLevel=function(){return 1},i.prototype.createVertexBuffer=function(e){var t=new l.a;return t.references=1,t},i.prototype.createIndexBuffer=function(e){var t=new l.a;return t.references=1,t},i.prototype.clear=function(e,t,i,n){void 0===n&&(n=!1)},i.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},i.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},i.prototype.setViewport=function(e,t,i){this._cachedViewport=e},i.prototype.createShaderProgram=function(e,t,i,n,r){return{__SPECTOR_rebuildProgram:null}},i.prototype.getUniforms=function(e,t){return[]},i.prototype.getAttributes=function(e,t){return[]},i.prototype.bindSamplers=function(e){this._currentEffect=null},i.prototype.enableEffect=function(e){this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e)},i.prototype.setState=function(e,t,i,n){void 0===t&&(t=0),void 0===n&&(n=!1)},i.prototype.setIntArray=function(e,t){return!0},i.prototype.setIntArray2=function(e,t){return!0},i.prototype.setIntArray3=function(e,t){return!0},i.prototype.setIntArray4=function(e,t){return!0},i.prototype.setFloatArray=function(e,t){return!0},i.prototype.setFloatArray2=function(e,t){return!0},i.prototype.setFloatArray3=function(e,t){return!0},i.prototype.setFloatArray4=function(e,t){return!0},i.prototype.setArray=function(e,t){return!0},i.prototype.setArray2=function(e,t){return!0},i.prototype.setArray3=function(e,t){return!0},i.prototype.setArray4=function(e,t){return!0},i.prototype.setMatrices=function(e,t){return!0},i.prototype.setMatrix3x3=function(e,t){return!0},i.prototype.setMatrix2x2=function(e,t){return!0},i.prototype.setFloat=function(e,t){return!0},i.prototype.setFloat2=function(e,t,i){return!0},i.prototype.setFloat3=function(e,t,i,n){return!0},i.prototype.setBool=function(e,t){return!0},i.prototype.setFloat4=function(e,t,i,n,r){return!0},i.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(this.alphaState.alphaBlend=e!==c.a.ALPHA_DISABLE,t||this.setDepthWrite(e===c.a.ALPHA_DISABLE),this._alphaMode=e)},i.prototype.bindBuffers=function(e,t,i){},i.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)},i.prototype.draw=function(e,t,i,n){},i.prototype.drawElementsType=function(e,t,i,n){},i.prototype.drawArraysType=function(e,t,i,n){},i.prototype._createTexture=function(){return{}},i.prototype._releaseTexture=function(e){},i.prototype.createTexture=function(e,t,i,n,r,o,a,l,u,h,d,f){void 0===r&&(r=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=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);var p=new s.a(this,s.b.Url),_=String(e);return p.url=_,p.generateMipMaps=!t,p.samplingMode=r,p.invertY=i,p.baseWidth=this._options.textureSize,p.baseHeight=this._options.textureSize,p.width=this._options.textureSize,p.height=this._options.textureSize,h&&(p.format=h),p.isReady=!0,o&&o(),this._internalTexturesCache.push(p),p},i.prototype.createRenderTargetTexture=function(e,t){var i=new a.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?c.a.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?c.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=c.a.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var n=new s.a(this,s.b.RenderTarget),r=e.width||e,o=e.height||e;return n._depthStencilBuffer={},n._framebuffer={},n.baseWidth=r,n.baseHeight=o,n.width=r,n.height=o,n.isReady=!0,n.samples=1,n.generateMipMaps=!!i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(n),n},i.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},i.prototype.bindFramebuffer=function(e,t,i,n,r){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!r&&this.setViewport(this._cachedViewport,i,n)},i.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},i.prototype.createDynamicVertexBuffer=function(e){var t=new l.a;return t.references=1,t.capacity=1,t},i.prototype.updateDynamicTexture=function(e,t,i,n,r){void 0===n&&(n=!1)},i.prototype.areAllEffectsReady=function(){return!0},i.prototype.getError=function(){return 0},i.prototype._getUnpackAlignement=function(){return 1},i.prototype._unpackFlipY=function(e){},i.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},i.prototype.updateDynamicVertexBuffer=function(e,t,i,n){},i.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},i.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},i.prototype._deleteBuffer=function(e){},i.prototype.releaseEffects=function(){},i.prototype.displayLoadingUI=function(){},i.prototype.hideLoadingUI=function(){},i.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,n,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0)},i.prototype._uploadDataToTextureDirectly=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i.prototype._uploadArrayBufferViewToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i.prototype._uploadImageToTexture=function(e,t,i,n){void 0===i&&(i=0),void 0===n&&(n=0)},i}(o.a)}).call(this,i(159))},function(e,t,i){"use strict";i.r(t),function(e){i.d(t,"Debug",(function(){return l}));var n=i(127),r=i(99);i.d(t,"AbstractScene",(function(){return n.AbstractScene})),i.d(t,"AbstractActionManager",(function(){return n.AbstractActionManager})),i.d(t,"Action",(function(){return n.Action})),i.d(t,"ActionEvent",(function(){return n.ActionEvent})),i.d(t,"ActionManager",(function(){return n.ActionManager})),i.d(t,"Condition",(function(){return n.Condition})),i.d(t,"ValueCondition",(function(){return n.ValueCondition})),i.d(t,"PredicateCondition",(function(){return n.PredicateCondition})),i.d(t,"StateCondition",(function(){return n.StateCondition})),i.d(t,"SwitchBooleanAction",(function(){return n.SwitchBooleanAction})),i.d(t,"SetStateAction",(function(){return n.SetStateAction})),i.d(t,"SetValueAction",(function(){return n.SetValueAction})),i.d(t,"IncrementValueAction",(function(){return n.IncrementValueAction})),i.d(t,"PlayAnimationAction",(function(){return n.PlayAnimationAction})),i.d(t,"StopAnimationAction",(function(){return n.StopAnimationAction})),i.d(t,"DoNothingAction",(function(){return n.DoNothingAction})),i.d(t,"CombineAction",(function(){return n.CombineAction})),i.d(t,"ExecuteCodeAction",(function(){return n.ExecuteCodeAction})),i.d(t,"SetParentAction",(function(){return n.SetParentAction})),i.d(t,"PlaySoundAction",(function(){return n.PlaySoundAction})),i.d(t,"StopSoundAction",(function(){return n.StopSoundAction})),i.d(t,"InterpolateValueAction",(function(){return n.InterpolateValueAction})),i.d(t,"Animatable",(function(){return n.Animatable})),i.d(t,"_IAnimationState",(function(){return n._IAnimationState})),i.d(t,"Animation",(function(){return n.Animation})),i.d(t,"TargetedAnimation",(function(){return n.TargetedAnimation})),i.d(t,"AnimationGroup",(function(){return n.AnimationGroup})),i.d(t,"AnimationPropertiesOverride",(function(){return n.AnimationPropertiesOverride})),i.d(t,"EasingFunction",(function(){return n.EasingFunction})),i.d(t,"CircleEase",(function(){return n.CircleEase})),i.d(t,"BackEase",(function(){return n.BackEase})),i.d(t,"BounceEase",(function(){return n.BounceEase})),i.d(t,"CubicEase",(function(){return n.CubicEase})),i.d(t,"ElasticEase",(function(){return n.ElasticEase})),i.d(t,"ExponentialEase",(function(){return n.ExponentialEase})),i.d(t,"PowerEase",(function(){return n.PowerEase})),i.d(t,"QuadraticEase",(function(){return n.QuadraticEase})),i.d(t,"QuarticEase",(function(){return n.QuarticEase})),i.d(t,"QuinticEase",(function(){return n.QuinticEase})),i.d(t,"SineEase",(function(){return n.SineEase})),i.d(t,"BezierCurveEase",(function(){return n.BezierCurveEase})),i.d(t,"RuntimeAnimation",(function(){return n.RuntimeAnimation})),i.d(t,"AnimationEvent",(function(){return n.AnimationEvent})),i.d(t,"AnimationKeyInterpolation",(function(){return n.AnimationKeyInterpolation})),i.d(t,"AnimationRange",(function(){return n.AnimationRange})),i.d(t,"KeepAssets",(function(){return n.KeepAssets})),i.d(t,"InstantiatedEntries",(function(){return n.InstantiatedEntries})),i.d(t,"AssetContainer",(function(){return n.AssetContainer})),i.d(t,"Analyser",(function(){return n.Analyser})),i.d(t,"AudioEngine",(function(){return n.AudioEngine})),i.d(t,"AudioSceneComponent",(function(){return n.AudioSceneComponent})),i.d(t,"Sound",(function(){return n.Sound})),i.d(t,"SoundTrack",(function(){return n.SoundTrack})),i.d(t,"WeightedSound",(function(){return n.WeightedSound})),i.d(t,"AutoRotationBehavior",(function(){return n.AutoRotationBehavior})),i.d(t,"BouncingBehavior",(function(){return n.BouncingBehavior})),i.d(t,"FramingBehavior",(function(){return n.FramingBehavior})),i.d(t,"AttachToBoxBehavior",(function(){return n.AttachToBoxBehavior})),i.d(t,"FadeInOutBehavior",(function(){return n.FadeInOutBehavior})),i.d(t,"MultiPointerScaleBehavior",(function(){return n.MultiPointerScaleBehavior})),i.d(t,"PointerDragBehavior",(function(){return n.PointerDragBehavior})),i.d(t,"SixDofDragBehavior",(function(){return n.SixDofDragBehavior})),i.d(t,"Bone",(function(){return n.Bone})),i.d(t,"BoneIKController",(function(){return n.BoneIKController})),i.d(t,"BoneLookController",(function(){return n.BoneLookController})),i.d(t,"Skeleton",(function(){return n.Skeleton})),i.d(t,"ArcRotateCameraGamepadInput",(function(){return n.ArcRotateCameraGamepadInput})),i.d(t,"ArcRotateCameraKeyboardMoveInput",(function(){return n.ArcRotateCameraKeyboardMoveInput})),i.d(t,"ArcRotateCameraMouseWheelInput",(function(){return n.ArcRotateCameraMouseWheelInput})),i.d(t,"ArcRotateCameraPointersInput",(function(){return n.ArcRotateCameraPointersInput})),i.d(t,"ArcRotateCameraVRDeviceOrientationInput",(function(){return n.ArcRotateCameraVRDeviceOrientationInput})),i.d(t,"FlyCameraKeyboardInput",(function(){return n.FlyCameraKeyboardInput})),i.d(t,"FlyCameraMouseInput",(function(){return n.FlyCameraMouseInput})),i.d(t,"FollowCameraKeyboardMoveInput",(function(){return n.FollowCameraKeyboardMoveInput})),i.d(t,"FollowCameraMouseWheelInput",(function(){return n.FollowCameraMouseWheelInput})),i.d(t,"FollowCameraPointersInput",(function(){return n.FollowCameraPointersInput})),i.d(t,"FreeCameraDeviceOrientationInput",(function(){return n.FreeCameraDeviceOrientationInput})),i.d(t,"FreeCameraGamepadInput",(function(){return n.FreeCameraGamepadInput})),i.d(t,"FreeCameraKeyboardMoveInput",(function(){return n.FreeCameraKeyboardMoveInput})),i.d(t,"FreeCameraMouseInput",(function(){return n.FreeCameraMouseInput})),i.d(t,"FreeCameraMouseWheelInput",(function(){return n.FreeCameraMouseWheelInput})),i.d(t,"FreeCameraTouchInput",(function(){return n.FreeCameraTouchInput})),i.d(t,"FreeCameraVirtualJoystickInput",(function(){return n.FreeCameraVirtualJoystickInput})),i.d(t,"CameraInputTypes",(function(){return n.CameraInputTypes})),i.d(t,"CameraInputsManager",(function(){return n.CameraInputsManager})),i.d(t,"Camera",(function(){return n.Camera})),i.d(t,"TargetCamera",(function(){return n.TargetCamera})),i.d(t,"FreeCamera",(function(){return n.FreeCamera})),i.d(t,"FreeCameraInputsManager",(function(){return n.FreeCameraInputsManager})),i.d(t,"TouchCamera",(function(){return n.TouchCamera})),i.d(t,"ArcRotateCamera",(function(){return n.ArcRotateCamera})),i.d(t,"ArcRotateCameraInputsManager",(function(){return n.ArcRotateCameraInputsManager})),i.d(t,"DeviceOrientationCamera",(function(){return n.DeviceOrientationCamera})),i.d(t,"FlyCamera",(function(){return n.FlyCamera})),i.d(t,"FlyCameraInputsManager",(function(){return n.FlyCameraInputsManager})),i.d(t,"FollowCamera",(function(){return n.FollowCamera})),i.d(t,"ArcFollowCamera",(function(){return n.ArcFollowCamera})),i.d(t,"FollowCameraInputsManager",(function(){return n.FollowCameraInputsManager})),i.d(t,"GamepadCamera",(function(){return n.GamepadCamera})),i.d(t,"AnaglyphArcRotateCamera",(function(){return n.AnaglyphArcRotateCamera})),i.d(t,"AnaglyphFreeCamera",(function(){return n.AnaglyphFreeCamera})),i.d(t,"AnaglyphGamepadCamera",(function(){return n.AnaglyphGamepadCamera})),i.d(t,"AnaglyphUniversalCamera",(function(){return n.AnaglyphUniversalCamera})),i.d(t,"StereoscopicArcRotateCamera",(function(){return n.StereoscopicArcRotateCamera})),i.d(t,"StereoscopicFreeCamera",(function(){return n.StereoscopicFreeCamera})),i.d(t,"StereoscopicGamepadCamera",(function(){return n.StereoscopicGamepadCamera})),i.d(t,"StereoscopicUniversalCamera",(function(){return n.StereoscopicUniversalCamera})),i.d(t,"UniversalCamera",(function(){return n.UniversalCamera})),i.d(t,"VirtualJoysticksCamera",(function(){return n.VirtualJoysticksCamera})),i.d(t,"VRCameraMetrics",(function(){return n.VRCameraMetrics})),i.d(t,"VRDeviceOrientationArcRotateCamera",(function(){return n.VRDeviceOrientationArcRotateCamera})),i.d(t,"VRDeviceOrientationFreeCamera",(function(){return n.VRDeviceOrientationFreeCamera})),i.d(t,"VRDeviceOrientationGamepadCamera",(function(){return n.VRDeviceOrientationGamepadCamera})),i.d(t,"OnAfterEnteringVRObservableEvent",(function(){return n.OnAfterEnteringVRObservableEvent})),i.d(t,"VRExperienceHelper",(function(){return n.VRExperienceHelper})),i.d(t,"WebVRFreeCamera",(function(){return n.WebVRFreeCamera})),i.d(t,"Collider",(function(){return n.Collider})),i.d(t,"DefaultCollisionCoordinator",(function(){return n.DefaultCollisionCoordinator})),i.d(t,"PickingInfo",(function(){return n.PickingInfo})),i.d(t,"IntersectionInfo",(function(){return n.IntersectionInfo})),i.d(t,"_MeshCollisionData",(function(){return n._MeshCollisionData})),i.d(t,"BoundingBox",(function(){return n.BoundingBox})),i.d(t,"BoundingInfo",(function(){return n.BoundingInfo})),i.d(t,"BoundingSphere",(function(){return n.BoundingSphere})),i.d(t,"Octree",(function(){return n.Octree})),i.d(t,"OctreeBlock",(function(){return n.OctreeBlock})),i.d(t,"OctreeSceneComponent",(function(){return n.OctreeSceneComponent})),i.d(t,"Ray",(function(){return n.Ray})),i.d(t,"AxesViewer",(function(){return n.AxesViewer})),i.d(t,"BoneAxesViewer",(function(){return n.BoneAxesViewer})),i.d(t,"DebugLayerTab",(function(){return n.DebugLayerTab})),i.d(t,"DebugLayer",(function(){return n.DebugLayer})),i.d(t,"PhysicsViewer",(function(){return n.PhysicsViewer})),i.d(t,"RayHelper",(function(){return n.RayHelper})),i.d(t,"SkeletonViewer",(function(){return n.SkeletonViewer})),i.d(t,"DeviceInputSystem",(function(){return n.DeviceInputSystem})),i.d(t,"DeviceType",(function(){return n.DeviceType})),i.d(t,"PointerInput",(function(){return n.PointerInput})),i.d(t,"DualShockInput",(function(){return n.DualShockInput})),i.d(t,"XboxInput",(function(){return n.XboxInput})),i.d(t,"SwitchInput",(function(){return n.SwitchInput})),i.d(t,"DeviceSource",(function(){return n.DeviceSource})),i.d(t,"DeviceSourceManager",(function(){return n.DeviceSourceManager})),i.d(t,"Constants",(function(){return n.Constants})),i.d(t,"ThinEngine",(function(){return n.ThinEngine})),i.d(t,"Engine",(function(){return n.Engine})),i.d(t,"EngineStore",(function(){return n.EngineStore})),i.d(t,"NullEngineOptions",(function(){return n.NullEngineOptions})),i.d(t,"NullEngine",(function(){return n.NullEngine})),i.d(t,"_OcclusionDataStorage",(function(){return n._OcclusionDataStorage})),i.d(t,"_forceTransformFeedbackToBundle",(function(){return n._forceTransformFeedbackToBundle})),i.d(t,"EngineView",(function(){return n.EngineView})),i.d(t,"WebGLPipelineContext",(function(){return n.WebGLPipelineContext})),i.d(t,"WebGL2ShaderProcessor",(function(){return n.WebGL2ShaderProcessor})),i.d(t,"NativeEngine",(function(){return n.NativeEngine})),i.d(t,"ShaderCodeInliner",(function(){return n.ShaderCodeInliner})),i.d(t,"PerformanceConfigurator",(function(){return n.PerformanceConfigurator})),i.d(t,"KeyboardEventTypes",(function(){return n.KeyboardEventTypes})),i.d(t,"KeyboardInfo",(function(){return n.KeyboardInfo})),i.d(t,"KeyboardInfoPre",(function(){return n.KeyboardInfoPre})),i.d(t,"PointerEventTypes",(function(){return n.PointerEventTypes})),i.d(t,"PointerInfoBase",(function(){return n.PointerInfoBase})),i.d(t,"PointerInfoPre",(function(){return n.PointerInfoPre})),i.d(t,"PointerInfo",(function(){return n.PointerInfo})),i.d(t,"ClipboardEventTypes",(function(){return n.ClipboardEventTypes})),i.d(t,"ClipboardInfo",(function(){return n.ClipboardInfo})),i.d(t,"DaydreamController",(function(){return n.DaydreamController})),i.d(t,"GearVRController",(function(){return n.GearVRController})),i.d(t,"GenericController",(function(){return n.GenericController})),i.d(t,"OculusTouchController",(function(){return n.OculusTouchController})),i.d(t,"PoseEnabledControllerType",(function(){return n.PoseEnabledControllerType})),i.d(t,"PoseEnabledControllerHelper",(function(){return n.PoseEnabledControllerHelper})),i.d(t,"PoseEnabledController",(function(){return n.PoseEnabledController})),i.d(t,"ViveController",(function(){return n.ViveController})),i.d(t,"WebVRController",(function(){return n.WebVRController})),i.d(t,"WindowsMotionController",(function(){return n.WindowsMotionController})),i.d(t,"XRWindowsMotionController",(function(){return n.XRWindowsMotionController})),i.d(t,"StickValues",(function(){return n.StickValues})),i.d(t,"Gamepad",(function(){return n.Gamepad})),i.d(t,"GenericPad",(function(){return n.GenericPad})),i.d(t,"GamepadManager",(function(){return n.GamepadManager})),i.d(t,"GamepadSystemSceneComponent",(function(){return n.GamepadSystemSceneComponent})),i.d(t,"Xbox360Button",(function(){return n.Xbox360Button})),i.d(t,"Xbox360Dpad",(function(){return n.Xbox360Dpad})),i.d(t,"Xbox360Pad",(function(){return n.Xbox360Pad})),i.d(t,"DualShockButton",(function(){return n.DualShockButton})),i.d(t,"DualShockDpad",(function(){return n.DualShockDpad})),i.d(t,"DualShockPad",(function(){return n.DualShockPad})),i.d(t,"AxisDragGizmo",(function(){return n.AxisDragGizmo})),i.d(t,"AxisScaleGizmo",(function(){return n.AxisScaleGizmo})),i.d(t,"BoundingBoxGizmo",(function(){return n.BoundingBoxGizmo})),i.d(t,"Gizmo",(function(){return n.Gizmo})),i.d(t,"GizmoManager",(function(){return n.GizmoManager})),i.d(t,"PlaneRotationGizmo",(function(){return n.PlaneRotationGizmo})),i.d(t,"PositionGizmo",(function(){return n.PositionGizmo})),i.d(t,"RotationGizmo",(function(){return n.RotationGizmo})),i.d(t,"ScaleGizmo",(function(){return n.ScaleGizmo})),i.d(t,"LightGizmo",(function(){return n.LightGizmo})),i.d(t,"CameraGizmo",(function(){return n.CameraGizmo})),i.d(t,"PlaneDragGizmo",(function(){return n.PlaneDragGizmo})),i.d(t,"EnvironmentHelper",(function(){return n.EnvironmentHelper})),i.d(t,"PhotoDome",(function(){return n.PhotoDome})),i.d(t,"_forceSceneHelpersToBundle",(function(){return n._forceSceneHelpersToBundle})),i.d(t,"VideoDome",(function(){return n.VideoDome})),i.d(t,"EngineInstrumentation",(function(){return n.EngineInstrumentation})),i.d(t,"SceneInstrumentation",(function(){return n.SceneInstrumentation})),i.d(t,"_TimeToken",(function(){return n._TimeToken})),i.d(t,"EffectLayer",(function(){return n.EffectLayer})),i.d(t,"EffectLayerSceneComponent",(function(){return n.EffectLayerSceneComponent})),i.d(t,"GlowLayer",(function(){return n.GlowLayer})),i.d(t,"HighlightLayer",(function(){return n.HighlightLayer})),i.d(t,"Layer",(function(){return n.Layer})),i.d(t,"LayerSceneComponent",(function(){return n.LayerSceneComponent})),i.d(t,"LensFlare",(function(){return n.LensFlare})),i.d(t,"LensFlareSystem",(function(){return n.LensFlareSystem})),i.d(t,"LensFlareSystemSceneComponent",(function(){return n.LensFlareSystemSceneComponent})),i.d(t,"Light",(function(){return n.Light})),i.d(t,"ShadowLight",(function(){return n.ShadowLight})),i.d(t,"ShadowGenerator",(function(){return n.ShadowGenerator})),i.d(t,"CascadedShadowGenerator",(function(){return n.CascadedShadowGenerator})),i.d(t,"ShadowGeneratorSceneComponent",(function(){return n.ShadowGeneratorSceneComponent})),i.d(t,"DirectionalLight",(function(){return n.DirectionalLight})),i.d(t,"HemisphericLight",(function(){return n.HemisphericLight})),i.d(t,"PointLight",(function(){return n.PointLight})),i.d(t,"SpotLight",(function(){return n.SpotLight})),i.d(t,"DefaultLoadingScreen",(function(){return n.DefaultLoadingScreen})),i.d(t,"_BabylonLoaderRegistered",(function(){return n._BabylonLoaderRegistered})),i.d(t,"BabylonFileLoaderConfiguration",(function(){return n.BabylonFileLoaderConfiguration})),i.d(t,"SceneLoaderAnimationGroupLoadingMode",(function(){return n.SceneLoaderAnimationGroupLoadingMode})),i.d(t,"SceneLoader",(function(){return n.SceneLoader})),i.d(t,"SceneLoaderFlags",(function(){return n.SceneLoaderFlags})),i.d(t,"BackgroundMaterial",(function(){return n.BackgroundMaterial})),i.d(t,"ColorCurves",(function(){return n.ColorCurves})),i.d(t,"EffectFallbacks",(function(){return n.EffectFallbacks})),i.d(t,"Effect",(function(){return n.Effect})),i.d(t,"FresnelParameters",(function(){return n.FresnelParameters})),i.d(t,"ImageProcessingConfigurationDefines",(function(){return n.ImageProcessingConfigurationDefines})),i.d(t,"ImageProcessingConfiguration",(function(){return n.ImageProcessingConfiguration})),i.d(t,"Material",(function(){return n.Material})),i.d(t,"MaterialDefines",(function(){return n.MaterialDefines})),i.d(t,"ThinMaterialHelper",(function(){return n.ThinMaterialHelper})),i.d(t,"MaterialHelper",(function(){return n.MaterialHelper})),i.d(t,"MultiMaterial",(function(){return n.MultiMaterial})),i.d(t,"PBRMaterialDefines",(function(){return n.PBRMaterialDefines})),i.d(t,"PBRBaseMaterial",(function(){return n.PBRBaseMaterial})),i.d(t,"PBRBaseSimpleMaterial",(function(){return n.PBRBaseSimpleMaterial})),i.d(t,"PBRMaterial",(function(){return n.PBRMaterial})),i.d(t,"PBRMetallicRoughnessMaterial",(function(){return n.PBRMetallicRoughnessMaterial})),i.d(t,"PBRSpecularGlossinessMaterial",(function(){return n.PBRSpecularGlossinessMaterial})),i.d(t,"PushMaterial",(function(){return n.PushMaterial})),i.d(t,"ShaderMaterial",(function(){return n.ShaderMaterial})),i.d(t,"StandardMaterialDefines",(function(){return n.StandardMaterialDefines})),i.d(t,"StandardMaterial",(function(){return n.StandardMaterial})),i.d(t,"BaseTexture",(function(){return n.BaseTexture})),i.d(t,"ColorGradingTexture",(function(){return n.ColorGradingTexture})),i.d(t,"CubeTexture",(function(){return n.CubeTexture})),i.d(t,"DynamicTexture",(function(){return n.DynamicTexture})),i.d(t,"EquiRectangularCubeTexture",(function(){return n.EquiRectangularCubeTexture})),i.d(t,"HDRFiltering",(function(){return n.HDRFiltering})),i.d(t,"HDRCubeTexture",(function(){return n.HDRCubeTexture})),i.d(t,"HtmlElementTexture",(function(){return n.HtmlElementTexture})),i.d(t,"InternalTextureSource",(function(){return n.InternalTextureSource})),i.d(t,"InternalTexture",(function(){return n.InternalTexture})),i.d(t,"_DDSTextureLoader",(function(){return n._DDSTextureLoader})),i.d(t,"_ENVTextureLoader",(function(){return n._ENVTextureLoader})),i.d(t,"_KTXTextureLoader",(function(){return n._KTXTextureLoader})),i.d(t,"_TGATextureLoader",(function(){return n._TGATextureLoader})),i.d(t,"_BasisTextureLoader",(function(){return n._BasisTextureLoader})),i.d(t,"MirrorTexture",(function(){return n.MirrorTexture})),i.d(t,"MultiRenderTarget",(function(){return n.MultiRenderTarget})),i.d(t,"TexturePacker",(function(){return n.TexturePacker})),i.d(t,"TexturePackerFrame",(function(){return n.TexturePackerFrame})),i.d(t,"CustomProceduralTexture",(function(){return n.CustomProceduralTexture})),i.d(t,"NoiseProceduralTexture",(function(){return n.NoiseProceduralTexture})),i.d(t,"ProceduralTexture",(function(){return n.ProceduralTexture})),i.d(t,"ProceduralTextureSceneComponent",(function(){return n.ProceduralTextureSceneComponent})),i.d(t,"RawCubeTexture",(function(){return n.RawCubeTexture})),i.d(t,"RawTexture",(function(){return n.RawTexture})),i.d(t,"RawTexture2DArray",(function(){return n.RawTexture2DArray})),i.d(t,"RawTexture3D",(function(){return n.RawTexture3D})),i.d(t,"RefractionTexture",(function(){return n.RefractionTexture})),i.d(t,"RenderTargetTexture",(function(){return n.RenderTargetTexture})),i.d(t,"Texture",(function(){return n.Texture})),i.d(t,"VideoTexture",(function(){return n.VideoTexture})),i.d(t,"UniformBuffer",(function(){return n.UniformBuffer})),i.d(t,"MaterialFlags",(function(){return n.MaterialFlags})),i.d(t,"NodeMaterialBlockTargets",(function(){return n.NodeMaterialBlockTargets})),i.d(t,"NodeMaterialBlockConnectionPointTypes",(function(){return n.NodeMaterialBlockConnectionPointTypes})),i.d(t,"NodeMaterialBlockConnectionPointMode",(function(){return n.NodeMaterialBlockConnectionPointMode})),i.d(t,"NodeMaterialSystemValues",(function(){return n.NodeMaterialSystemValues})),i.d(t,"NodeMaterialModes",(function(){return n.NodeMaterialModes})),i.d(t,"NodeMaterialConnectionPointCompatibilityStates",(function(){return n.NodeMaterialConnectionPointCompatibilityStates})),i.d(t,"NodeMaterialConnectionPointDirection",(function(){return n.NodeMaterialConnectionPointDirection})),i.d(t,"NodeMaterialConnectionPoint",(function(){return n.NodeMaterialConnectionPoint})),i.d(t,"NodeMaterialBlock",(function(){return n.NodeMaterialBlock})),i.d(t,"NodeMaterialDefines",(function(){return n.NodeMaterialDefines})),i.d(t,"NodeMaterial",(function(){return n.NodeMaterial})),i.d(t,"VertexOutputBlock",(function(){return n.VertexOutputBlock})),i.d(t,"BonesBlock",(function(){return n.BonesBlock})),i.d(t,"InstancesBlock",(function(){return n.InstancesBlock})),i.d(t,"MorphTargetsBlock",(function(){return n.MorphTargetsBlock})),i.d(t,"LightInformationBlock",(function(){return n.LightInformationBlock})),i.d(t,"FragmentOutputBlock",(function(){return n.FragmentOutputBlock})),i.d(t,"ImageProcessingBlock",(function(){return n.ImageProcessingBlock})),i.d(t,"PerturbNormalBlock",(function(){return n.PerturbNormalBlock})),i.d(t,"DiscardBlock",(function(){return n.DiscardBlock})),i.d(t,"FrontFacingBlock",(function(){return n.FrontFacingBlock})),i.d(t,"DerivativeBlock",(function(){return n.DerivativeBlock})),i.d(t,"FragCoordBlock",(function(){return n.FragCoordBlock})),i.d(t,"ScreenSizeBlock",(function(){return n.ScreenSizeBlock})),i.d(t,"FogBlock",(function(){return n.FogBlock})),i.d(t,"LightBlock",(function(){return n.LightBlock})),i.d(t,"TextureBlock",(function(){return n.TextureBlock})),i.d(t,"ReflectionTextureBlock",(function(){return n.ReflectionTextureBlock})),i.d(t,"CurrentScreenBlock",(function(){return n.CurrentScreenBlock})),i.d(t,"InputBlock",(function(){return n.InputBlock})),i.d(t,"AnimatedInputBlockTypes",(function(){return n.AnimatedInputBlockTypes})),i.d(t,"MultiplyBlock",(function(){return n.MultiplyBlock})),i.d(t,"AddBlock",(function(){return n.AddBlock})),i.d(t,"ScaleBlock",(function(){return n.ScaleBlock})),i.d(t,"ClampBlock",(function(){return n.ClampBlock})),i.d(t,"CrossBlock",(function(){return n.CrossBlock})),i.d(t,"DotBlock",(function(){return n.DotBlock})),i.d(t,"TransformBlock",(function(){return n.TransformBlock})),i.d(t,"RemapBlock",(function(){return n.RemapBlock})),i.d(t,"NormalizeBlock",(function(){return n.NormalizeBlock})),i.d(t,"TrigonometryBlockOperations",(function(){return n.TrigonometryBlockOperations})),i.d(t,"TrigonometryBlock",(function(){return n.TrigonometryBlock})),i.d(t,"ColorMergerBlock",(function(){return n.ColorMergerBlock})),i.d(t,"VectorMergerBlock",(function(){return n.VectorMergerBlock})),i.d(t,"ColorSplitterBlock",(function(){return n.ColorSplitterBlock})),i.d(t,"VectorSplitterBlock",(function(){return n.VectorSplitterBlock})),i.d(t,"LerpBlock",(function(){return n.LerpBlock})),i.d(t,"DivideBlock",(function(){return n.DivideBlock})),i.d(t,"SubtractBlock",(function(){return n.SubtractBlock})),i.d(t,"StepBlock",(function(){return n.StepBlock})),i.d(t,"OneMinusBlock",(function(){return n.OneMinusBlock})),i.d(t,"ViewDirectionBlock",(function(){return n.ViewDirectionBlock})),i.d(t,"FresnelBlock",(function(){return n.FresnelBlock})),i.d(t,"MaxBlock",(function(){return n.MaxBlock})),i.d(t,"MinBlock",(function(){return n.MinBlock})),i.d(t,"DistanceBlock",(function(){return n.DistanceBlock})),i.d(t,"LengthBlock",(function(){return n.LengthBlock})),i.d(t,"NegateBlock",(function(){return n.NegateBlock})),i.d(t,"PowBlock",(function(){return n.PowBlock})),i.d(t,"RandomNumberBlock",(function(){return n.RandomNumberBlock})),i.d(t,"ArcTan2Block",(function(){return n.ArcTan2Block})),i.d(t,"SmoothStepBlock",(function(){return n.SmoothStepBlock})),i.d(t,"ReciprocalBlock",(function(){return n.ReciprocalBlock})),i.d(t,"ReplaceColorBlock",(function(){return n.ReplaceColorBlock})),i.d(t,"PosterizeBlock",(function(){return n.PosterizeBlock})),i.d(t,"WaveBlockKind",(function(){return n.WaveBlockKind})),i.d(t,"WaveBlock",(function(){return n.WaveBlock})),i.d(t,"GradientBlockColorStep",(function(){return n.GradientBlockColorStep})),i.d(t,"GradientBlock",(function(){return n.GradientBlock})),i.d(t,"NLerpBlock",(function(){return n.NLerpBlock})),i.d(t,"WorleyNoise3DBlock",(function(){return n.WorleyNoise3DBlock})),i.d(t,"SimplexPerlin3DBlock",(function(){return n.SimplexPerlin3DBlock})),i.d(t,"NormalBlendBlock",(function(){return n.NormalBlendBlock})),i.d(t,"Rotate2dBlock",(function(){return n.Rotate2dBlock})),i.d(t,"ReflectBlock",(function(){return n.ReflectBlock})),i.d(t,"RefractBlock",(function(){return n.RefractBlock})),i.d(t,"DesaturateBlock",(function(){return n.DesaturateBlock})),i.d(t,"PBRMetallicRoughnessBlock",(function(){return n.PBRMetallicRoughnessBlock})),i.d(t,"SheenBlock",(function(){return n.SheenBlock})),i.d(t,"AnisotropyBlock",(function(){return n.AnisotropyBlock})),i.d(t,"ReflectionBlock",(function(){return n.ReflectionBlock})),i.d(t,"ClearCoatBlock",(function(){return n.ClearCoatBlock})),i.d(t,"RefractionBlock",(function(){return n.RefractionBlock})),i.d(t,"SubSurfaceBlock",(function(){return n.SubSurfaceBlock})),i.d(t,"ParticleTextureBlock",(function(){return n.ParticleTextureBlock})),i.d(t,"ParticleRampGradientBlock",(function(){return n.ParticleRampGradientBlock})),i.d(t,"ParticleBlendMultiplyBlock",(function(){return n.ParticleBlendMultiplyBlock})),i.d(t,"ModBlock",(function(){return n.ModBlock})),i.d(t,"NodeMaterialOptimizer",(function(){return n.NodeMaterialOptimizer})),i.d(t,"PropertyTypeForEdition",(function(){return n.PropertyTypeForEdition})),i.d(t,"editableInPropertyPage",(function(){return n.editableInPropertyPage})),i.d(t,"EffectRenderer",(function(){return n.EffectRenderer})),i.d(t,"EffectWrapper",(function(){return n.EffectWrapper})),i.d(t,"ShadowDepthWrapper",(function(){return n.ShadowDepthWrapper})),i.d(t,"Scalar",(function(){return n.Scalar})),i.d(t,"extractMinAndMaxIndexed",(function(){return n.extractMinAndMaxIndexed})),i.d(t,"extractMinAndMax",(function(){return n.extractMinAndMax})),i.d(t,"Space",(function(){return n.Space})),i.d(t,"Axis",(function(){return n.Axis})),i.d(t,"Coordinate",(function(){return n.Coordinate})),i.d(t,"Color3",(function(){return n.Color3})),i.d(t,"Color4",(function(){return n.Color4})),i.d(t,"TmpColors",(function(){return n.TmpColors})),i.d(t,"ToGammaSpace",(function(){return n.ToGammaSpace})),i.d(t,"ToLinearSpace",(function(){return n.ToLinearSpace})),i.d(t,"Epsilon",(function(){return n.Epsilon})),i.d(t,"Frustum",(function(){return n.Frustum})),i.d(t,"Orientation",(function(){return n.Orientation})),i.d(t,"BezierCurve",(function(){return n.BezierCurve})),i.d(t,"Angle",(function(){return n.Angle})),i.d(t,"Arc2",(function(){return n.Arc2})),i.d(t,"Path2",(function(){return n.Path2})),i.d(t,"Path3D",(function(){return n.Path3D})),i.d(t,"Curve3",(function(){return n.Curve3})),i.d(t,"Plane",(function(){return n.Plane})),i.d(t,"Size",(function(){return n.Size})),i.d(t,"Vector2",(function(){return n.Vector2})),i.d(t,"Vector3",(function(){return n.Vector3})),i.d(t,"Vector4",(function(){return n.Vector4})),i.d(t,"Quaternion",(function(){return n.Quaternion})),i.d(t,"Matrix",(function(){return n.Matrix})),i.d(t,"TmpVectors",(function(){return n.TmpVectors})),i.d(t,"PositionNormalVertex",(function(){return n.PositionNormalVertex})),i.d(t,"PositionNormalTextureVertex",(function(){return n.PositionNormalTextureVertex})),i.d(t,"Viewport",(function(){return n.Viewport})),i.d(t,"SphericalHarmonics",(function(){return n.SphericalHarmonics})),i.d(t,"SphericalPolynomial",(function(){return n.SphericalPolynomial})),i.d(t,"AbstractMesh",(function(){return n.AbstractMesh})),i.d(t,"Buffer",(function(){return n.Buffer})),i.d(t,"VertexBuffer",(function(){return n.VertexBuffer})),i.d(t,"DracoCompression",(function(){return n.DracoCompression})),i.d(t,"CSG",(function(){return n.CSG})),i.d(t,"Geometry",(function(){return n.Geometry})),i.d(t,"GroundMesh",(function(){return n.GroundMesh})),i.d(t,"TrailMesh",(function(){return n.TrailMesh})),i.d(t,"InstancedMesh",(function(){return n.InstancedMesh})),i.d(t,"LinesMesh",(function(){return n.LinesMesh})),i.d(t,"InstancedLinesMesh",(function(){return n.InstancedLinesMesh})),i.d(t,"_CreationDataStorage",(function(){return n._CreationDataStorage})),i.d(t,"_InstancesBatch",(function(){return n._InstancesBatch})),i.d(t,"Mesh",(function(){return n.Mesh})),i.d(t,"VertexData",(function(){return n.VertexData})),i.d(t,"MeshBuilder",(function(){return n.MeshBuilder})),i.d(t,"SimplificationSettings",(function(){return n.SimplificationSettings})),i.d(t,"SimplificationQueue",(function(){return n.SimplificationQueue})),i.d(t,"SimplificationType",(function(){return n.SimplificationType})),i.d(t,"QuadraticErrorSimplification",(function(){return n.QuadraticErrorSimplification})),i.d(t,"SimplicationQueueSceneComponent",(function(){return n.SimplicationQueueSceneComponent})),i.d(t,"Polygon",(function(){return n.Polygon})),i.d(t,"PolygonMeshBuilder",(function(){return n.PolygonMeshBuilder})),i.d(t,"SubMesh",(function(){return n.SubMesh})),i.d(t,"MeshLODLevel",(function(){return n.MeshLODLevel})),i.d(t,"TransformNode",(function(){return n.TransformNode})),i.d(t,"BoxBuilder",(function(){return n.BoxBuilder})),i.d(t,"TiledBoxBuilder",(function(){return n.TiledBoxBuilder})),i.d(t,"DiscBuilder",(function(){return n.DiscBuilder})),i.d(t,"RibbonBuilder",(function(){return n.RibbonBuilder})),i.d(t,"SphereBuilder",(function(){return n.SphereBuilder})),i.d(t,"HemisphereBuilder",(function(){return n.HemisphereBuilder})),i.d(t,"CylinderBuilder",(function(){return n.CylinderBuilder})),i.d(t,"TorusBuilder",(function(){return n.TorusBuilder})),i.d(t,"TorusKnotBuilder",(function(){return n.TorusKnotBuilder})),i.d(t,"LinesBuilder",(function(){return n.LinesBuilder})),i.d(t,"PolygonBuilder",(function(){return n.PolygonBuilder})),i.d(t,"ShapeBuilder",(function(){return n.ShapeBuilder})),i.d(t,"LatheBuilder",(function(){return n.LatheBuilder})),i.d(t,"PlaneBuilder",(function(){return n.PlaneBuilder})),i.d(t,"TiledPlaneBuilder",(function(){return n.TiledPlaneBuilder})),i.d(t,"GroundBuilder",(function(){return n.GroundBuilder})),i.d(t,"TubeBuilder",(function(){return n.TubeBuilder})),i.d(t,"PolyhedronBuilder",(function(){return n.PolyhedronBuilder})),i.d(t,"IcoSphereBuilder",(function(){return n.IcoSphereBuilder})),i.d(t,"DecalBuilder",(function(){return n.DecalBuilder})),i.d(t,"CapsuleBuilder",(function(){return n.CapsuleBuilder})),i.d(t,"DataBuffer",(function(){return n.DataBuffer})),i.d(t,"WebGLDataBuffer",(function(){return n.WebGLDataBuffer})),i.d(t,"MorphTarget",(function(){return n.MorphTarget})),i.d(t,"MorphTargetManager",(function(){return n.MorphTargetManager})),i.d(t,"RecastJSPlugin",(function(){return n.RecastJSPlugin})),i.d(t,"RecastJSCrowd",(function(){return n.RecastJSCrowd})),i.d(t,"Node",(function(){return n.Node})),i.d(t,"Database",(function(){return n.Database})),i.d(t,"BaseParticleSystem",(function(){return n.BaseParticleSystem})),i.d(t,"BoxParticleEmitter",(function(){return n.BoxParticleEmitter})),i.d(t,"ConeParticleEmitter",(function(){return n.ConeParticleEmitter})),i.d(t,"CylinderParticleEmitter",(function(){return n.CylinderParticleEmitter})),i.d(t,"CylinderDirectedParticleEmitter",(function(){return n.CylinderDirectedParticleEmitter})),i.d(t,"HemisphericParticleEmitter",(function(){return n.HemisphericParticleEmitter})),i.d(t,"PointParticleEmitter",(function(){return n.PointParticleEmitter})),i.d(t,"SphereParticleEmitter",(function(){return n.SphereParticleEmitter})),i.d(t,"SphereDirectedParticleEmitter",(function(){return n.SphereDirectedParticleEmitter})),i.d(t,"CustomParticleEmitter",(function(){return n.CustomParticleEmitter})),i.d(t,"MeshParticleEmitter",(function(){return n.MeshParticleEmitter})),i.d(t,"GPUParticleSystem",(function(){return n.GPUParticleSystem})),i.d(t,"Particle",(function(){return n.Particle})),i.d(t,"ParticleHelper",(function(){return n.ParticleHelper})),i.d(t,"ParticleSystem",(function(){return n.ParticleSystem})),i.d(t,"ParticleSystemSet",(function(){return n.ParticleSystemSet})),i.d(t,"SolidParticle",(function(){return n.SolidParticle})),i.d(t,"ModelShape",(function(){return n.ModelShape})),i.d(t,"DepthSortedParticle",(function(){return n.DepthSortedParticle})),i.d(t,"SolidParticleVertex",(function(){return n.SolidParticleVertex})),i.d(t,"SolidParticleSystem",(function(){return n.SolidParticleSystem})),i.d(t,"CloudPoint",(function(){return n.CloudPoint})),i.d(t,"PointsGroup",(function(){return n.PointsGroup})),i.d(t,"PointColor",(function(){return n.PointColor})),i.d(t,"PointsCloudSystem",(function(){return n.PointsCloudSystem})),i.d(t,"SubEmitterType",(function(){return n.SubEmitterType})),i.d(t,"SubEmitter",(function(){return n.SubEmitter})),i.d(t,"PhysicsEngine",(function(){return n.PhysicsEngine})),i.d(t,"PhysicsEngineSceneComponent",(function(){return n.PhysicsEngineSceneComponent})),i.d(t,"PhysicsHelper",(function(){return n.PhysicsHelper})),i.d(t,"PhysicsRadialExplosionEventOptions",(function(){return n.PhysicsRadialExplosionEventOptions})),i.d(t,"PhysicsUpdraftEventOptions",(function(){return n.PhysicsUpdraftEventOptions})),i.d(t,"PhysicsVortexEventOptions",(function(){return n.PhysicsVortexEventOptions})),i.d(t,"PhysicsRadialImpulseFalloff",(function(){return n.PhysicsRadialImpulseFalloff})),i.d(t,"PhysicsUpdraftMode",(function(){return n.PhysicsUpdraftMode})),i.d(t,"PhysicsImpostor",(function(){return n.PhysicsImpostor})),i.d(t,"PhysicsJoint",(function(){return n.PhysicsJoint})),i.d(t,"DistanceJoint",(function(){return n.DistanceJoint})),i.d(t,"MotorEnabledJoint",(function(){return n.MotorEnabledJoint})),i.d(t,"HingeJoint",(function(){return n.HingeJoint})),i.d(t,"Hinge2Joint",(function(){return n.Hinge2Joint})),i.d(t,"CannonJSPlugin",(function(){return n.CannonJSPlugin})),i.d(t,"AmmoJSPlugin",(function(){return n.AmmoJSPlugin})),i.d(t,"OimoJSPlugin",(function(){return n.OimoJSPlugin})),i.d(t,"AnaglyphPostProcess",(function(){return n.AnaglyphPostProcess})),i.d(t,"BlackAndWhitePostProcess",(function(){return n.BlackAndWhitePostProcess})),i.d(t,"BloomEffect",(function(){return n.BloomEffect})),i.d(t,"BloomMergePostProcess",(function(){return n.BloomMergePostProcess})),i.d(t,"BlurPostProcess",(function(){return n.BlurPostProcess})),i.d(t,"ChromaticAberrationPostProcess",(function(){return n.ChromaticAberrationPostProcess})),i.d(t,"CircleOfConfusionPostProcess",(function(){return n.CircleOfConfusionPostProcess})),i.d(t,"ColorCorrectionPostProcess",(function(){return n.ColorCorrectionPostProcess})),i.d(t,"ConvolutionPostProcess",(function(){return n.ConvolutionPostProcess})),i.d(t,"DepthOfFieldBlurPostProcess",(function(){return n.DepthOfFieldBlurPostProcess})),i.d(t,"DepthOfFieldEffectBlurLevel",(function(){return n.DepthOfFieldEffectBlurLevel})),i.d(t,"DepthOfFieldEffect",(function(){return n.DepthOfFieldEffect})),i.d(t,"DepthOfFieldMergePostProcessOptions",(function(){return n.DepthOfFieldMergePostProcessOptions})),i.d(t,"DepthOfFieldMergePostProcess",(function(){return n.DepthOfFieldMergePostProcess})),i.d(t,"DisplayPassPostProcess",(function(){return n.DisplayPassPostProcess})),i.d(t,"ExtractHighlightsPostProcess",(function(){return n.ExtractHighlightsPostProcess})),i.d(t,"FilterPostProcess",(function(){return n.FilterPostProcess})),i.d(t,"FxaaPostProcess",(function(){return n.FxaaPostProcess})),i.d(t,"GrainPostProcess",(function(){return n.GrainPostProcess})),i.d(t,"HighlightsPostProcess",(function(){return n.HighlightsPostProcess})),i.d(t,"ImageProcessingPostProcess",(function(){return n.ImageProcessingPostProcess})),i.d(t,"MotionBlurPostProcess",(function(){return n.MotionBlurPostProcess})),i.d(t,"PassPostProcess",(function(){return n.PassPostProcess})),i.d(t,"PassCubePostProcess",(function(){return n.PassCubePostProcess})),i.d(t,"PostProcess",(function(){return n.PostProcess})),i.d(t,"PostProcessManager",(function(){return n.PostProcessManager})),i.d(t,"RefractionPostProcess",(function(){return n.RefractionPostProcess})),i.d(t,"DefaultRenderingPipeline",(function(){return n.DefaultRenderingPipeline})),i.d(t,"LensRenderingPipeline",(function(){return n.LensRenderingPipeline})),i.d(t,"SSAO2RenderingPipeline",(function(){return n.SSAO2RenderingPipeline})),i.d(t,"SSAORenderingPipeline",(function(){return n.SSAORenderingPipeline})),i.d(t,"StandardRenderingPipeline",(function(){return n.StandardRenderingPipeline})),i.d(t,"PostProcessRenderEffect",(function(){return n.PostProcessRenderEffect})),i.d(t,"PostProcessRenderPipeline",(function(){return n.PostProcessRenderPipeline})),i.d(t,"PostProcessRenderPipelineManager",(function(){return n.PostProcessRenderPipelineManager})),i.d(t,"PostProcessRenderPipelineManagerSceneComponent",(function(){return n.PostProcessRenderPipelineManagerSceneComponent})),i.d(t,"SharpenPostProcess",(function(){return n.SharpenPostProcess})),i.d(t,"StereoscopicInterlacePostProcessI",(function(){return n.StereoscopicInterlacePostProcessI})),i.d(t,"StereoscopicInterlacePostProcess",(function(){return n.StereoscopicInterlacePostProcess})),i.d(t,"TonemappingOperator",(function(){return n.TonemappingOperator})),i.d(t,"TonemapPostProcess",(function(){return n.TonemapPostProcess})),i.d(t,"VolumetricLightScatteringPostProcess",(function(){return n.VolumetricLightScatteringPostProcess})),i.d(t,"VRDistortionCorrectionPostProcess",(function(){return n.VRDistortionCorrectionPostProcess})),i.d(t,"VRMultiviewToSingleviewPostProcess",(function(){return n.VRMultiviewToSingleviewPostProcess})),i.d(t,"ScreenSpaceReflectionPostProcess",(function(){return n.ScreenSpaceReflectionPostProcess})),i.d(t,"ScreenSpaceCurvaturePostProcess",(function(){return n.ScreenSpaceCurvaturePostProcess})),i.d(t,"ReflectionProbe",(function(){return n.ReflectionProbe})),i.d(t,"BoundingBoxRenderer",(function(){return n.BoundingBoxRenderer})),i.d(t,"DepthRenderer",(function(){return n.DepthRenderer})),i.d(t,"DepthRendererSceneComponent",(function(){return n.DepthRendererSceneComponent})),i.d(t,"EdgesRenderer",(function(){return n.EdgesRenderer})),i.d(t,"LineEdgesRenderer",(function(){return n.LineEdgesRenderer})),i.d(t,"GeometryBufferRenderer",(function(){return n.GeometryBufferRenderer})),i.d(t,"GeometryBufferRendererSceneComponent",(function(){return n.GeometryBufferRendererSceneComponent})),i.d(t,"PrePassRenderer",(function(){return n.PrePassRenderer})),i.d(t,"PrePassRendererSceneComponent",(function(){return n.PrePassRendererSceneComponent})),i.d(t,"SubSurfaceSceneComponent",(function(){return n.SubSurfaceSceneComponent})),i.d(t,"OutlineRenderer",(function(){return n.OutlineRenderer})),i.d(t,"RenderingGroup",(function(){return n.RenderingGroup})),i.d(t,"RenderingGroupInfo",(function(){return n.RenderingGroupInfo})),i.d(t,"RenderingManager",(function(){return n.RenderingManager})),i.d(t,"UtilityLayerRenderer",(function(){return n.UtilityLayerRenderer})),i.d(t,"Scene",(function(){return n.Scene})),i.d(t,"SceneComponentConstants",(function(){return n.SceneComponentConstants})),i.d(t,"Stage",(function(){return n.Stage})),i.d(t,"Sprite",(function(){return n.Sprite})),i.d(t,"SpriteManager",(function(){return n.SpriteManager})),i.d(t,"SpriteMap",(function(){return n.SpriteMap})),i.d(t,"SpritePackedManager",(function(){return n.SpritePackedManager})),i.d(t,"SpriteSceneComponent",(function(){return n.SpriteSceneComponent})),i.d(t,"AlphaState",(function(){return n.AlphaState})),i.d(t,"DepthCullingState",(function(){return n.DepthCullingState})),i.d(t,"StencilState",(function(){return n.StencilState})),i.d(t,"AndOrNotEvaluator",(function(){return n.AndOrNotEvaluator})),i.d(t,"AssetTaskState",(function(){return n.AssetTaskState})),i.d(t,"AbstractAssetTask",(function(){return n.AbstractAssetTask})),i.d(t,"AssetsProgressEvent",(function(){return n.AssetsProgressEvent})),i.d(t,"ContainerAssetTask",(function(){return n.ContainerAssetTask})),i.d(t,"MeshAssetTask",(function(){return n.MeshAssetTask})),i.d(t,"TextFileAssetTask",(function(){return n.TextFileAssetTask})),i.d(t,"BinaryFileAssetTask",(function(){return n.BinaryFileAssetTask})),i.d(t,"ImageAssetTask",(function(){return n.ImageAssetTask})),i.d(t,"TextureAssetTask",(function(){return n.TextureAssetTask})),i.d(t,"CubeTextureAssetTask",(function(){return n.CubeTextureAssetTask})),i.d(t,"HDRCubeTextureAssetTask",(function(){return n.HDRCubeTextureAssetTask})),i.d(t,"EquiRectangularCubeTextureAssetTask",(function(){return n.EquiRectangularCubeTextureAssetTask})),i.d(t,"AssetsManager",(function(){return n.AssetsManager})),i.d(t,"BasisTranscodeConfiguration",(function(){return n.BasisTranscodeConfiguration})),i.d(t,"BasisTools",(function(){return n.BasisTools})),i.d(t,"DDSTools",(function(){return n.DDSTools})),i.d(t,"expandToProperty",(function(){return n.expandToProperty})),i.d(t,"serialize",(function(){return n.serialize})),i.d(t,"serializeAsTexture",(function(){return n.serializeAsTexture})),i.d(t,"serializeAsColor3",(function(){return n.serializeAsColor3})),i.d(t,"serializeAsFresnelParameters",(function(){return n.serializeAsFresnelParameters})),i.d(t,"serializeAsVector2",(function(){return n.serializeAsVector2})),i.d(t,"serializeAsVector3",(function(){return n.serializeAsVector3})),i.d(t,"serializeAsMeshReference",(function(){return n.serializeAsMeshReference})),i.d(t,"serializeAsColorCurves",(function(){return n.serializeAsColorCurves})),i.d(t,"serializeAsColor4",(function(){return n.serializeAsColor4})),i.d(t,"serializeAsImageProcessingConfiguration",(function(){return n.serializeAsImageProcessingConfiguration})),i.d(t,"serializeAsQuaternion",(function(){return n.serializeAsQuaternion})),i.d(t,"serializeAsMatrix",(function(){return n.serializeAsMatrix})),i.d(t,"serializeAsCameraReference",(function(){return n.serializeAsCameraReference})),i.d(t,"SerializationHelper",(function(){return n.SerializationHelper})),i.d(t,"Deferred",(function(){return n.Deferred})),i.d(t,"EnvironmentTextureTools",(function(){return n.EnvironmentTextureTools})),i.d(t,"MeshExploder",(function(){return n.MeshExploder})),i.d(t,"FilesInput",(function(){return n.FilesInput})),i.d(t,"CubeMapToSphericalPolynomialTools",(function(){return n.CubeMapToSphericalPolynomialTools})),i.d(t,"HDRTools",(function(){return n.HDRTools})),i.d(t,"PanoramaToCubeMapTools",(function(){return n.PanoramaToCubeMapTools})),i.d(t,"KhronosTextureContainer",(function(){return n.KhronosTextureContainer})),i.d(t,"EventState",(function(){return n.EventState})),i.d(t,"Observer",(function(){return n.Observer})),i.d(t,"MultiObserver",(function(){return n.MultiObserver})),i.d(t,"Observable",(function(){return n.Observable})),i.d(t,"PerformanceMonitor",(function(){return n.PerformanceMonitor})),i.d(t,"RollingAverage",(function(){return n.RollingAverage})),i.d(t,"PromisePolyfill",(function(){return n.PromisePolyfill})),i.d(t,"SceneOptimization",(function(){return n.SceneOptimization})),i.d(t,"TextureOptimization",(function(){return n.TextureOptimization})),i.d(t,"HardwareScalingOptimization",(function(){return n.HardwareScalingOptimization})),i.d(t,"ShadowsOptimization",(function(){return n.ShadowsOptimization})),i.d(t,"PostProcessesOptimization",(function(){return n.PostProcessesOptimization})),i.d(t,"LensFlaresOptimization",(function(){return n.LensFlaresOptimization})),i.d(t,"CustomOptimization",(function(){return n.CustomOptimization})),i.d(t,"ParticlesOptimization",(function(){return n.ParticlesOptimization})),i.d(t,"RenderTargetsOptimization",(function(){return n.RenderTargetsOptimization})),i.d(t,"MergeMeshesOptimization",(function(){return n.MergeMeshesOptimization})),i.d(t,"SceneOptimizerOptions",(function(){return n.SceneOptimizerOptions})),i.d(t,"SceneOptimizer",(function(){return n.SceneOptimizer})),i.d(t,"SceneSerializer",(function(){return n.SceneSerializer})),i.d(t,"SmartArray",(function(){return n.SmartArray})),i.d(t,"SmartArrayNoDuplicate",(function(){return n.SmartArrayNoDuplicate})),i.d(t,"StringDictionary",(function(){return n.StringDictionary})),i.d(t,"Tags",(function(){return n.Tags})),i.d(t,"TextureTools",(function(){return n.TextureTools})),i.d(t,"TGATools",(function(){return n.TGATools})),i.d(t,"Tools",(function(){return n.Tools})),i.d(t,"className",(function(){return n.className})),i.d(t,"AsyncLoop",(function(){return n.AsyncLoop})),i.d(t,"VideoRecorder",(function(){return n.VideoRecorder})),i.d(t,"JoystickAxis",(function(){return n.JoystickAxis})),i.d(t,"VirtualJoystick",(function(){return n.VirtualJoystick})),i.d(t,"WorkerPool",(function(){return n.WorkerPool})),i.d(t,"Logger",(function(){return n.Logger})),i.d(t,"_TypeStore",(function(){return n._TypeStore})),i.d(t,"FilesInputStore",(function(){return n.FilesInputStore})),i.d(t,"DeepCopier",(function(){return n.DeepCopier})),i.d(t,"PivotTools",(function(){return n.PivotTools})),i.d(t,"PrecisionDate",(function(){return n.PrecisionDate})),i.d(t,"ScreenshotTools",(function(){return n.ScreenshotTools})),i.d(t,"WebRequest",(function(){return n.WebRequest})),i.d(t,"InspectableType",(function(){return n.InspectableType})),i.d(t,"BRDFTextureTools",(function(){return n.BRDFTextureTools})),i.d(t,"RGBDTextureTools",(function(){return n.RGBDTextureTools})),i.d(t,"ColorGradient",(function(){return n.ColorGradient})),i.d(t,"Color3Gradient",(function(){return n.Color3Gradient})),i.d(t,"FactorGradient",(function(){return n.FactorGradient})),i.d(t,"GradientHelper",(function(){return n.GradientHelper})),i.d(t,"PerfCounter",(function(){return n.PerfCounter})),i.d(t,"RetryStrategy",(function(){return n.RetryStrategy})),i.d(t,"CanvasGenerator",(function(){return n.CanvasGenerator})),i.d(t,"LoadFileError",(function(){return n.LoadFileError})),i.d(t,"RequestFileError",(function(){return n.RequestFileError})),i.d(t,"ReadFileError",(function(){return n.ReadFileError})),i.d(t,"FileTools",(function(){return n.FileTools})),i.d(t,"StringTools",(function(){return n.StringTools})),i.d(t,"DataReader",(function(){return n.DataReader})),i.d(t,"MinMaxReducer",(function(){return n.MinMaxReducer})),i.d(t,"DepthReducer",(function(){return n.DepthReducer})),i.d(t,"DataStorage",(function(){return n.DataStorage})),i.d(t,"SceneRecorder",(function(){return n.SceneRecorder})),i.d(t,"KhronosTextureContainer2",(function(){return n.KhronosTextureContainer2})),i.d(t,"Trajectory",(function(){return n.Trajectory})),i.d(t,"TrajectoryClassifier",(function(){return n.TrajectoryClassifier})),i.d(t,"TimerState",(function(){return n.TimerState})),i.d(t,"setAndStartTimer",(function(){return n.setAndStartTimer})),i.d(t,"AdvancedTimer",(function(){return n.AdvancedTimer})),i.d(t,"CopyTools",(function(){return n.CopyTools})),i.d(t,"WebXRCamera",(function(){return n.WebXRCamera})),i.d(t,"WebXREnterExitUIButton",(function(){return n.WebXREnterExitUIButton})),i.d(t,"WebXREnterExitUIOptions",(function(){return n.WebXREnterExitUIOptions})),i.d(t,"WebXREnterExitUI",(function(){return n.WebXREnterExitUI})),i.d(t,"WebXRExperienceHelper",(function(){return n.WebXRExperienceHelper})),i.d(t,"WebXRInput",(function(){return n.WebXRInput})),i.d(t,"WebXRInputSource",(function(){return n.WebXRInputSource})),i.d(t,"WebXRManagedOutputCanvasOptions",(function(){return n.WebXRManagedOutputCanvasOptions})),i.d(t,"WebXRManagedOutputCanvas",(function(){return n.WebXRManagedOutputCanvas})),i.d(t,"WebXRState",(function(){return n.WebXRState})),i.d(t,"WebXRTrackingState",(function(){return n.WebXRTrackingState})),i.d(t,"WebXRSessionManager",(function(){return n.WebXRSessionManager})),i.d(t,"WebXRDefaultExperienceOptions",(function(){return n.WebXRDefaultExperienceOptions})),i.d(t,"WebXRDefaultExperience",(function(){return n.WebXRDefaultExperience})),i.d(t,"WebXRFeatureName",(function(){return n.WebXRFeatureName})),i.d(t,"WebXRFeaturesManager",(function(){return n.WebXRFeaturesManager})),i.d(t,"WebXRAbstractFeature",(function(){return n.WebXRAbstractFeature})),i.d(t,"WebXRHitTestLegacy",(function(){return n.WebXRHitTestLegacy})),i.d(t,"WebXRAnchorSystem",(function(){return n.WebXRAnchorSystem})),i.d(t,"WebXRPlaneDetector",(function(){return n.WebXRPlaneDetector})),i.d(t,"WebXRBackgroundRemover",(function(){return n.WebXRBackgroundRemover})),i.d(t,"WebXRMotionControllerTeleportation",(function(){return n.WebXRMotionControllerTeleportation})),i.d(t,"WebXRControllerPointerSelection",(function(){return n.WebXRControllerPointerSelection})),i.d(t,"IWebXRControllerPhysicsOptions",(function(){return n.IWebXRControllerPhysicsOptions})),i.d(t,"WebXRControllerPhysics",(function(){return n.WebXRControllerPhysics})),i.d(t,"WebXRHitTest",(function(){return n.WebXRHitTest})),i.d(t,"WebXRFeaturePointSystem",(function(){return n.WebXRFeaturePointSystem})),i.d(t,"WebXRHand",(function(){return n.WebXRHand})),i.d(t,"WebXRHandTracking",(function(){return n.WebXRHandTracking})),i.d(t,"WebXRAbstractMotionController",(function(){return n.WebXRAbstractMotionController})),i.d(t,"WebXRControllerComponent",(function(){return n.WebXRControllerComponent})),i.d(t,"WebXRGenericTriggerMotionController",(function(){return n.WebXRGenericTriggerMotionController})),i.d(t,"WebXRMicrosoftMixedRealityController",(function(){return n.WebXRMicrosoftMixedRealityController})),i.d(t,"WebXRMotionControllerManager",(function(){return n.WebXRMotionControllerManager})),i.d(t,"WebXROculusTouchMotionController",(function(){return n.WebXROculusTouchMotionController})),i.d(t,"WebXRHTCViveMotionController",(function(){return n.WebXRHTCViveMotionController})),i.d(t,"WebXRProfiledMotionController",(function(){return n.WebXRProfiledMotionController}));var o=void 0!==e?e:"undefined"!=typeof window?window:void 0;if(void 0!==o){o.BABYLON=a,o.BABYLON=o.BABYLON||{};var a=o.BABYLON;a.Debug=a.Debug||{};var s=[];for(var c in r)a.Debug[c]=r[c],s.push(c);for(var c in n)a[c]=n[c]}var l={AxesViewer:r.AxesViewer,BoneAxesViewer:r.BoneAxesViewer,PhysicsViewer:r.PhysicsViewer,SkeletonViewer:r.SkeletonViewer}}.call(this,i(159))}])}));