diff --git "a/libs/babylon.js" "b/libs/babylon.js" new file mode 100644--- /dev/null +++ "b/libs/babylon.js" @@ -0,0 +1,16 @@ +!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 n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=207)}([function(e,t,n){"use strict";n.d(t,"d",(function(){return l})),n.d(t,"e",(function(){return h})),n.d(t,"f",(function(){return d})),n.d(t,"b",(function(){return p})),n.d(t,"a",(function(){return f})),n.d(t,"c",(function(){return m}));var i=n(14),r=n(23),o=n(52),a=n(10),s=n(86),c=n(16),u=function(e){return parseInt(e.toString().replace(/\W/g,""))},l=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: ".concat(this.x," Y: ").concat(this.y,"}")},e.prototype.getClassName=function(){return"Vector2"},e.prototype.getHashCode=function(){var e=u(this.x);return e=397*e^u(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,n){return void 0===n&&(n=0),e.FromArrayToRef(t,n,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,n){return new e(this.x*t,this.y*n)},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 n=new e(0,0);return this.scaleToRef(t,n),n},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&&i.a.WithinEpsilon(this.x,e.x,t)&&i.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.rotateToRef=function(e,t){var n=Math.cos(e),i=Math.sin(e);return t.x=n*this.x-i*this.y,t.y=i*this.x+n*this.y,this},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(){return e.NormalizeToRef(this,this),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,n){return void 0===n&&(n=0),new e(t[n],t[n+1])},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1]},e.CatmullRom=function(t,n,i,r,o){var a=o*o,s=o*a;return new e(.5*(2*n.x+(-t.x+i.x)*o+(2*t.x-5*n.x+4*i.x-r.x)*a+(-t.x+3*n.x-3*i.x+r.x)*s),.5*(2*n.y+(-t.y+i.y)*o+(2*t.y-5*n.y+4*i.y-r.y)*a+(-t.y+3*n.y-3*i.y+r.y)*s))},e.Clamp=function(t,n,i){var r=t.x;r=(r=r>i.x?i.x:r)i.y?i.y:o)n.x?t.x:n.x,t.y>n.y?t.y:n.y)},e.Transform=function(t,n){var i=e.Zero();return e.TransformToRef(t,n,i),i},e.TransformToRef=function(e,t,n){var i=t.m,r=e.x*i[0]+e.y*i[4]+i[12],o=e.x*i[1]+e.y*i[5]+i[13];n.x=r,n.y=o},e.PointInTriangle=function(e,t,n,i){var r=.5*(-n.y*i.x+t.y*(-n.x+i.x)+t.x*(n.y-i.y)+n.x*i.y),o=r<0?-1:1,a=(t.y*i.x-t.x*i.y+(i.y-t.y)*e.x+(t.x-i.x)*e.y)*o,s=(t.x*n.y-t.y*n.x+(t.y-n.y)*e.x+(n.x-t.x)*e.y)*o;return a>0&&s>0&&a+s<2*r*o},e.Distance=function(t,n){return Math.sqrt(e.DistanceSquared(t,n))},e.DistanceSquared=function(e,t){var n=e.x-t.x,i=e.y-t.y;return n*n+i*i},e.Center=function(t,n){return e.CenterToRef(t,n,e.Zero())},e.CenterToRef=function(e,t,n){return n.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2)},e.DistanceOfPointFromSegment=function(t,n,i){var r=e.DistanceSquared(n,i);if(0===r)return e.Distance(t,n);var o=i.subtract(n),a=Math.max(0,Math.min(1,e.Dot(t.subtract(n),o)/r)),s=n.add(o.multiplyByFloats(a,a));return e.Distance(t,s)},e}(),h=function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this._isDirty=!0,this._x=e,this._y=t,this._z=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}),e.prototype.toString=function(){return"{X: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(this._z,"}")},e.prototype.getClassName=function(){return"Vector3"},e.prototype.getHashCode=function(){var e=u(this._x);return e=397*(e=397*e^u(this._y))^u(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,n){return void 0===n&&(n=0),e.FromArrayToRef(t,n,this),this},e.prototype.toQuaternion=function(){return p.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,n){return this.x+=e,this.y+=t,this.z+=n,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,n,i){return new e(this._x-t,this._y-n,this._z-i)},e.prototype.subtractFromFloatsToRef=function(e,t,n,i){return i.copyFromFloats(this._x-e,this._y-t,this._z-n)},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,n){var i=e.Zero();return this.projectOnPlaneToRef(t,n,i),i},e.prototype.projectOnPlaneToRef=function(t,n,i){var r=t.normal,o=t.d,a=_.Vector3[0];this.subtractToRef(n,a),a.normalize();var s=e.Dot(a,r),c=-(e.Dot(n,r)+o)/s,u=a.scaleInPlace(c);n.addToRef(u,i)},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&&i.a.WithinEpsilon(this._x,e._x,t)&&i.a.WithinEpsilon(this._y,e._y,t)&&i.a.WithinEpsilon(this._z,e._z,t)},e.prototype.equalsToFloats=function(e,t,n){return this._x===e&&this._y===t&&this._z===n},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,n,i){return new e(this._x*t,this._y*n,this._z*i)},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,n){return ethis._x&&(this.x=e),t>this._y&&(this.y=t),n>this._z&&(this.z=n),this},e.prototype.isNonUniformWithinEpsilon=function(e){var t=Math.abs(this._x),n=Math.abs(this._y);if(!i.a.WithinEpsilon(t,n,e))return!0;var r=Math.abs(this._z);return!i.a.WithinEpsilon(t,r,e)||!i.a.WithinEpsilon(n,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())||(_.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(n,i){t[n]=_.Vector3[0][e[i]]}))),this},e.prototype.rotateByQuaternionToRef=function(t,n){return t.toRotationMatrix(_.Matrix[0]),e.TransformCoordinatesToRef(this,_.Matrix[0],n),n},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,n){return this.subtractToRef(t,_.Vector3[0]),_.Vector3[0].rotateByQuaternionToRef(e,_.Vector3[0]),t.addToRef(_.Vector3[0],n),n},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,n){return this.x=e,this.y=t,this.z=n,this},e.prototype.set=function(e,t,n){return this.copyFromFloats(e,t,n)},e.prototype.setAll=function(e){return this.x=this.y=this.z=e,this},e.GetClipFactor=function(t,n,i,r){var o=e.Dot(t,i)-r;return o/(o-(e.Dot(n,i)-r))},e.GetAngleBetweenVectors=function(t,n,i){var r=t.normalizeToRef(_.Vector3[1]),o=n.normalizeToRef(_.Vector3[2]),a=e.Dot(r,o),s=Math.acos(a),c=_.Vector3[3];return e.CrossToRef(r,o,c),e.Dot(c,i)>0?isNaN(s)?0:s:isNaN(s)?-Math.PI:-Math.acos(a)},e.GetAngleBetweenVectorsOnPlane=function(t,n,r){_.Vector3[0].copyFrom(t);var o=_.Vector3[0];_.Vector3[1].copyFrom(n);var a=_.Vector3[1];_.Vector3[2].copyFrom(r);var s=_.Vector3[2],c=_.Vector3[3],u=_.Vector3[4];o.normalize(),a.normalize(),s.normalize(),e.CrossToRef(s,o,c),e.CrossToRef(c,s,u);var l=Math.atan2(e.Dot(a,c),e.Dot(a,u));return i.a.NormalizeRadians(l)},e.SlerpToRef=function(t,n,o,a){o=i.a.Clamp(o,0,1);var s,c,u=_.Vector3[0],l=_.Vector3[1];u.copyFrom(t),s=u.length(),u.normalizeFromLength(s),l.copyFrom(n),c=l.length(),l.normalizeFromLength(c);var h,d,p=e.Dot(u,l);if(p<1-r.a){var f=Math.acos(p),m=1/Math.sin(f);h=Math.sin((1-o)*f)*m,d=Math.sin(o*f)*m}else h=1-o,d=o;u.scaleInPlace(h),l.scaleInPlace(d),a.copyFrom(u).addInPlace(l),a.scaleInPlace(i.a.Lerp(s,c,o))},e.SmoothToRef=function(t,n,i,r,o){e.SlerpToRef(t,n,0===r?1:i/r,o)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2])},e.FromFloatArray=function(t,n){return e.FromArray(t,n)},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1],n.z=e[t+2]},e.FromFloatArrayToRef=function(t,n,i){return e.FromArrayToRef(t,n,i)},e.FromFloatsToRef=function(e,t,n,i){i.copyFromFloats(e,t,n)},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,"RightReadOnly",{get:function(){return e._RightReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LeftReadOnly",{get:function(){return e._LeftReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"LeftHandedForwardReadOnly",{get:function(){return e._LeftHandedForwardReadOnly},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RightHandedForwardReadOnly",{get:function(){return e._RightHandedForwardReadOnly},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,n){var i=e.Zero();return e.TransformCoordinatesToRef(t,n,i),i},e.TransformCoordinatesToRef=function(t,n,i){e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,n,i)},e.TransformCoordinatesFromFloatsToRef=function(e,t,n,i,r){var o=i.m,a=e*o[0]+t*o[4]+n*o[8]+o[12],s=e*o[1]+t*o[5]+n*o[9]+o[13],c=e*o[2]+t*o[6]+n*o[10]+o[14],u=1/(e*o[3]+t*o[7]+n*o[11]+o[15]);r.x=a*u,r.y=s*u,r.z=c*u},e.TransformNormal=function(t,n){var i=e.Zero();return e.TransformNormalToRef(t,n,i),i},e.TransformNormalToRef=function(e,t,n){this.TransformNormalFromFloatsToRef(e._x,e._y,e._z,t,n)},e.TransformNormalFromFloatsToRef=function(e,t,n,i,r){var o=i.m;r.x=e*o[0]+t*o[4]+n*o[8],r.y=e*o[1]+t*o[5]+n*o[9],r.z=e*o[2]+t*o[6]+n*o[10]},e.CatmullRom=function(t,n,i,r,o){var a=o*o,s=o*a;return new e(.5*(2*n._x+(-t._x+i._x)*o+(2*t._x-5*n._x+4*i._x-r._x)*a+(-t._x+3*n._x-3*i._x+r._x)*s),.5*(2*n._y+(-t._y+i._y)*o+(2*t._y-5*n._y+4*i._y-r._y)*a+(-t._y+3*n._y-3*i._y+r._y)*s),.5*(2*n._z+(-t._z+i._z)*o+(2*t._z-5*n._z+4*i._z-r._z)*a+(-t._z+3*n._z-3*i._z+r._z)*s))},e.Clamp=function(t,n,i){var r=new e;return e.ClampToRef(t,n,i,r),r},e.ClampToRef=function(e,t,n,i){var r=e._x;r=(r=r>n._x?n._x:r)n._y?n._y:o)n._z?n._z:a)0&&C<0?(D.copyFrom(c),M=n,I=o):C>0&&P<0?(D.copyFrom(l),M=o,I=a):(D.copyFrom(u).scaleInPlace(-1),M=a,I=n);var N=_.Vector3[9],L=_.Vector3[4];if(M.subtractToRef(T,x),I.subtractToRef(T,N),e.CrossToRef(x,N,L),!(e.Dot(L,h)<0))return s.copyFrom(T),Math.abs(v*b);var F=_.Vector3[5];e.CrossToRef(D,L,F),F.normalize();var w=_.Vector3[9];w.copyFrom(M).subtractInPlace(T);var B=w.length();if(Bthis.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 h(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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this},e.prototype.set=function(e,t,n,i){return this.copyFromFloats(e,t,n,i)},e.prototype.setAll=function(e){return this.x=this.y=this.z=this.w=e,this},e.FromArray=function(t,n){return n||(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1],n.z=e[t+2],n.w=e[t+3]},e.FromFloatArrayToRef=function(t,n,i){e.FromArrayToRef(t,n,i)},e.FromFloatsToRef=function(e,t,n,i,r){r.x=e,r.y=t,r.z=n,r.w=i},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 n=e.Zero();return e.NormalizeToRef(t,n),n},e.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},e.Minimize=function(e,t){var n=e.clone();return n.minimizeInPlace(t),n},e.Maximize=function(e,t){var n=e.clone();return n.maximizeInPlace(t),n},e.Distance=function(t,n){return Math.sqrt(e.DistanceSquared(t,n))},e.DistanceSquared=function(e,t){var n=e.x-t.x,i=e.y-t.y,r=e.z-t.z,o=e.w-t.w;return n*n+i*i+r*r+o*o},e.Center=function(t,n){return e.CenterToRef(t,n,e.Zero())},e.CenterToRef=function(e,t,n){return n.copyFromFloats((e.x+t.x)/2,(e.y+t.y)/2,(e.z+t.z)/2,(e.w+t.w)/2)},e.TransformCoordinates=function(t,n){var i=e.Zero();return e.TransformCoordinatesToRef(t,n,i),i},e.TransformCoordinatesToRef=function(t,n,i){e.TransformCoordinatesFromFloatsToRef(t._x,t._y,t._z,n,i)},e.TransformCoordinatesFromFloatsToRef=function(e,t,n,i,r){var o=i.m,a=e*o[0]+t*o[4]+n*o[8]+o[12],s=e*o[1]+t*o[5]+n*o[9]+o[13],c=e*o[2]+t*o[6]+n*o[10]+o[14],u=e*o[3]+t*o[7]+n*o[11]+o[15];r.x=a,r.y=s,r.z=c,r.w=u},e.TransformNormal=function(t,n){var i=e.Zero();return e.TransformNormalToRef(t,n,i),i},e.TransformNormalToRef=function(e,t,n){var i=t.m,r=e.x*i[0]+e.y*i[4]+e.z*i[8],o=e.x*i[1]+e.y*i[5]+e.z*i[9],a=e.x*i[2]+e.y*i[6]+e.z*i[10];n.x=r,n.y=o,n.z=a,n.w=e.w},e.TransformNormalFromFloatsToRef=function(e,t,n,i,r,o){var a=r.m;o.x=e*a[0]+t*a[4]+n*a[8],o.y=e*a[1]+t*a[5]+n*a[9],o.z=e*a[2]+t*a[6]+n*a[10],o.w=i},e.FromVector3=function(t,n){return void 0===n&&(n=0),new e(t._x,t._y,t._z,n)},e}(),p=function(){function e(e,t,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this._isDirty=!0,this._x=e,this._y=t,this._z=n,this._w=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}),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: ".concat(this._x," Y: ").concat(this._y," Z: ").concat(this._z," W: ").concat(this._w,"}")},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=u(this._x);return e=397*(e=397*(e=397*e^u(this._y))^u(this._z))^u(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&&i.a.WithinEpsilon(this._x,e._x,t)&&i.a.WithinEpsilon(this._y,e._y,t)&&i.a.WithinEpsilon(this._z,e._z,t)&&i.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,n,i){return this.x=e,this.y=t,this.z=n,this.w=i,this},e.prototype.set=function(e,t,n,i){return this.copyFromFloats(e,t,n,i)},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 n=new e(0,0,0,1);return this.multiplyToRef(t,n),n},e.prototype.multiplyToRef=function(e,t){var n=this._x*e._w+this._y*e._z-this._z*e._y+this._w*e._x,i=-this._x*e._z+this._y*e._w+this._z*e._x+this._w*e._y,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(n,i,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(){var e=h.Zero();return this.toEulerAnglesToRef(e),e},e.prototype.toEulerAnglesToRef=function(e){var t=this._z,n=this._x,i=this._y,r=this._w,o=r*r,a=t*t,s=n*n,c=i*i,u=i*t-n*r;return u<-.4999999?(e.y=2*Math.atan2(i,r),e.x=Math.PI/2,e.z=0):u>.4999999?(e.y=2*Math.atan2(i,r),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(n*i+t*r),-a-s+c+o),e.x=Math.asin(-2*(t*i-n*r)),e.y=Math.atan2(2*(t*n+i*r),a-s-c+o)),this},e.prototype.toRotationMatrix=function(e){return f.FromQuaternionToRef(this,e),this},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var n=new e;return e.FromRotationMatrixToRef(t,n),n},e.FromRotationMatrixToRef=function(e,t){var n,i=e.m,r=i[0],o=i[4],a=i[8],s=i[1],c=i[5],u=i[9],l=i[2],h=i[6],d=i[10],p=r+c+d;p>0?(n=.5/Math.sqrt(p+1),t.w=.25/n,t.x=(h-u)*n,t.y=(a-l)*n,t.z=(s-o)*n):r>c&&r>d?(n=2*Math.sqrt(1+r-c-d),t.w=(h-u)/n,t.x=.25*n,t.y=(o+s)/n,t.z=(a+l)/n):c>d?(n=2*Math.sqrt(1+c-r-d),t.w=(a-l)/n,t.x=(o+s)/n,t.y=.25*n,t.z=(u+h)/n):(n=2*Math.sqrt(1+d-r-c),t.w=(s-o)/n,t.x=(a+l)/n,t.y=(u+h)/n,t.z=.25*n)},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,n){return e.Dot(t,n)>=0},e.SmoothToRef=function(t,n,r,o,a){var s=0===o?1:r/o;s=i.a.Clamp(s,0,1),e.SlerpToRef(t,n,s,a)},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,n){return e.RotationAxisToRef(t,n,new e)},e.RotationAxisToRef=function(e,t,n){var i=Math.sin(t/2);return e.normalize(),n.w=Math.cos(t/2),n.x=e._x*i,n.y=e._y*i,n.z=e._z*i,n},e.FromArray=function(t,n){return n||(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromArrayToRef=function(e,t,n){n.x=e[t],n.y=e[t+1],n.z=e[t+2],n.w=e[t+3]},e.FromEulerAngles=function(t,n,i){var r=new e;return e.RotationYawPitchRollToRef(n,t,i,r),r},e.FromEulerAnglesToRef=function(t,n,i,r){return e.RotationYawPitchRollToRef(n,t,i,r),r},e.FromEulerVector=function(t){var n=new e;return e.RotationYawPitchRollToRef(t._y,t._x,t._z,n),n},e.FromEulerVectorToRef=function(t,n){return e.RotationYawPitchRollToRef(t._y,t._x,t._z,n),n},e.FromUnitVectorsToRef=function(e,t,n){var i=h.Dot(e,t)+1;return iMath.abs(e.z)?n.set(-e.y,e.x,0,0):n.set(0,-e.z,e.y,0):(h.CrossToRef(e,t,m.Vector3[0]),n.set(m.Vector3[0].x,m.Vector3[0].y,m.Vector3[0].z,i)),n.normalize()},e.RotationYawPitchRoll=function(t,n,i){var r=new e;return e.RotationYawPitchRollToRef(t,n,i,r),r},e.RotationYawPitchRollToRef=function(e,t,n,i){var r=.5*n,o=.5*t,a=.5*e,s=Math.sin(r),c=Math.cos(r),u=Math.sin(o),l=Math.cos(o),h=Math.sin(a),d=Math.cos(a);i.x=d*u*c+h*l*s,i.y=h*l*c-d*u*s,i.z=d*l*s-h*u*c,i.w=d*l*c+h*u*s},e.RotationAlphaBetaGamma=function(t,n,i){var r=new e;return e.RotationAlphaBetaGammaToRef(t,n,i,r),r},e.RotationAlphaBetaGammaToRef=function(e,t,n,i){var r=.5*(n+e),o=.5*(n-e),a=.5*t;i.x=Math.cos(o)*Math.sin(a),i.y=Math.sin(o)*Math.sin(a),i.z=Math.sin(r)*Math.cos(a),i.w=Math.cos(r)*Math.cos(a)},e.RotationQuaternionFromAxis=function(t,n,i){var r=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,n,i,r),r},e.RotationQuaternionFromAxisToRef=function(t,n,i,r){var o=_.Matrix[0];f.FromXYZAxesToRef(t.normalize(),n.normalize(),i.normalize(),o),e.FromRotationMatrixToRef(o,r)},e.FromLookDirectionLH=function(t,n){var i=new e;return e.FromLookDirectionLHToRef(t,n,i),i},e.FromLookDirectionLHToRef=function(t,n,i){var r=_.Matrix[0];f.LookDirectionLHToRef(t,n,r),e.FromRotationMatrixToRef(r,i)},e.FromLookDirectionRH=function(t,n){var i=new e;return e.FromLookDirectionRHToRef(t,n,i),i},e.FromLookDirectionRHToRef=function(t,n,i){var r=_.Matrix[0];return f.LookDirectionRHToRef(t,n,r),e.FromRotationMatrixToRef(r,i)},e.Slerp=function(t,n,i){var r=e.Identity();return e.SlerpToRef(t,n,i,r),r},e.SlerpToRef=function(e,t,n,i){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-n,r=s?-n:n;else{var c=Math.acos(a),u=1/Math.sin(c);o=Math.sin((1-n)*c)*u,r=s?-Math.sin(n*c)*u:Math.sin(n*c)*u}i.x=o*e._x+r*t._x,i.y=o*e._y+r*t._y,i.z=o*e._z+r*t._z,i.w=o*e._w+r*t._w},e.Hermite=function(t,n,i,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,h=s-a;return new e(t._x*c+i._x*u+n._x*l+r._x*h,t._y*c+i._y*u+n._y*l+r._y*h,t._z*c+i._z*u+n._z*l+r._z*h,t._w*c+i._w*u+n._w*l+r._w*h)},e.Hermite1stDerivative=function(t,n,i,r,o){var a=e.Zero();return this.Hermite1stDerivativeToRef(t,n,i,r,o,a),a},e.Hermite1stDerivativeToRef=function(e,t,n,i,r,o){var a=r*r;o.x=6*(a-r)*e.x+(3*a-4*r+1)*t.x+6*(-a+r)*n.x+(3*a-2*r)*i.x,o.y=6*(a-r)*e.y+(3*a-4*r+1)*t.y+6*(-a+r)*n.y+(3*a-2*r)*i.y,o.z=6*(a-r)*e.z+(3*a-4*r+1)*t.z+6*(-a+r)*n.z+(3*a-2*r)*i.z,o.w=6*(a-r)*e.w+(3*a-4*r+1)*t.w+6*(-a+r)*n.w+(3*a-2*r)*i.w},e}(),f=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.markAsUpdated()}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(e,t,n,i){void 0===t&&(t=!1),void 0===n&&(n=!1),void 0===i&&(i=!0),this._isIdentity=e,this._isIdentity3x2=e||n,this._isIdentityDirty=!this._isIdentity&&t,this._isIdentity3x2Dirty=!this._isIdentity3x2&&i},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],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=e[6],c=e[7],u=e[8],l=e[9],h=e[10],d=e[11],p=e[12],f=e[13],_=e[14],m=e[15],g=h*m-_*d,v=l*m-f*d,b=l*_-f*h,y=u*m-p*d,T=u*_-h*p,E=u*f-p*l;return t*+(a*g-s*v+c*b)+n*-(o*g-s*y+c*T)+i*+(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 n=new e;return this.addToRef(t,n),n},e.prototype.addToRef=function(e,t){for(var n=this._m,i=t._m,r=e.m,o=0;o<16;o++)i[o]=n[o]+r[o];return t.markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=this._m,n=e.m,i=0;i<16;i++)t[i]+=n[i];return this.markAsUpdated(),this},e.prototype.invertToRef=function(t){if(!0===this._isIdentity)return e.IdentityToRef(t),this;var n=this._m,i=n[0],r=n[1],o=n[2],a=n[3],s=n[4],c=n[5],u=n[6],l=n[7],h=n[8],d=n[9],p=n[10],f=n[11],_=n[12],m=n[13],g=n[14],v=n[15],b=p*v-g*f,y=d*v-m*f,T=d*g-m*p,E=h*v-_*f,S=h*g-p*_,A=h*m-_*d,x=+(c*b-u*y+l*T),R=-(s*b-u*E+l*S),C=+(s*y-c*E+l*A),P=-(s*T-c*S+u*A),O=i*x+r*R+o*C+a*P;if(0===O)return t.copyFrom(this),this;var M=1/O,I=u*v-g*l,D=c*v-m*l,N=c*g-m*u,L=s*v-_*l,F=s*g-_*u,w=s*m-_*c,B=u*f-p*l,U=c*f-d*l,V=c*p-d*u,k=s*f-h*l,G=s*p-h*u,z=s*d-h*c,j=-(r*b-o*y+a*T),W=+(i*b-o*E+a*S),H=-(i*y-r*E+a*A),X=+(i*T-r*S+o*A),Y=+(r*I-o*D+a*N),K=-(i*I-o*L+a*F),Q=+(i*D-r*L+a*w),q=-(i*N-r*F+o*w),Z=-(r*B-o*U+a*V),J=+(i*B-o*k+a*G),$=-(i*U-r*k+a*z),ee=+(i*V-r*G+o*z);return e.FromValuesToRef(x*M,j*M,Y*M,Z*M,R*M,W*M,K*M,J*M,C*M,H*M,Q*M,$*M,P*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,n){return this._m[12]=e,this._m[13]=t,this._m[14]=n,this.markAsUpdated(),this},e.prototype.addTranslationFromFloats=function(e,t,n){return this._m[12]+=e,this._m[13]+=t,this._m[14]+=n,this.markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.setTranslationFromFloats(e._x,e._y,e._z)},e.prototype.getTranslation=function(){return new h(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 n=new e;return this.multiplyToRef(t,n),n},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this.updateFlag=t.updateFlag,this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);var n=this._m;return e[t]=n[0],e[t+1]=n[1],e[t+2]=n[2],e[t+3]=n[3],e[t+4]=n[4],e[t+5]=n[5],e[t+6]=n[6],e[t+7]=n[7],e[t+8]=n[8],e[t+9]=n[9],e[t+10]=n[10],e[t+11]=n[11],e[t+12]=n[12],e[t+13]=n[13],e[t+14]=n[14],e[t+15]=n[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,n){var i=this._m,r=e.m,o=i[0],a=i[1],s=i[2],c=i[3],u=i[4],l=i[5],h=i[6],d=i[7],p=i[8],f=i[9],_=i[10],m=i[11],g=i[12],v=i[13],b=i[14],y=i[15],T=r[0],E=r[1],S=r[2],A=r[3],x=r[4],R=r[5],C=r[6],P=r[7],O=r[8],M=r[9],I=r[10],D=r[11],N=r[12],L=r[13],F=r[14],w=r[15];return t[n]=o*T+a*x+s*O+c*N,t[n+1]=o*E+a*R+s*M+c*L,t[n+2]=o*S+a*C+s*I+c*F,t[n+3]=o*A+a*P+s*D+c*w,t[n+4]=u*T+l*x+h*O+d*N,t[n+5]=u*E+l*R+h*M+d*L,t[n+6]=u*S+l*C+h*I+d*F,t[n+7]=u*A+l*P+h*D+d*w,t[n+8]=p*T+f*x+_*O+m*N,t[n+9]=p*E+f*R+_*M+m*L,t[n+10]=p*S+f*C+_*I+m*F,t[n+11]=p*A+f*P+_*D+m*w,t[n+12]=g*T+v*x+b*O+y*N,t[n+13]=g*E+v*R+b*M+y*L,t[n+14]=g*S+v*C+b*I+y*F,t[n+15]=g*A+v*P+b*D+y*w,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 n=this.m,i=t.m;return n[0]===i[0]&&n[1]===i[1]&&n[2]===i[2]&&n[3]===i[3]&&n[4]===i[4]&&n[5]===i[5]&&n[6]===i[6]&&n[7]===i[7]&&n[8]===i[8]&&n[9]===i[9]&&n[10]===i[10]&&n[11]===i[11]&&n[12]===i[12]&&n[13]===i[13]&&n[14]===i[14]&&n[15]===i[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=u(this._m[0]),t=1;t<16;t++)e=397*e^u(this._m[t]);return e},e.prototype.decomposeToTransformNode=function(e){return e.rotationQuaternion=e.rotationQuaternion||new p,this.decompose(e.scaling,e.rotationQuaternion,e.position)},e.prototype.decompose=function(t,n,i,r){if(this._isIdentity)return i&&i.setAll(0),t&&t.setAll(1),n&&n.copyFromFloats(0,0,0,1),!0;var o=this._m;if(i&&i.copyFromFloats(o[12],o[13],o[14]),(t=t||_.Vector3[0]).x=Math.sqrt(o[0]*o[0]+o[1]*o[1]+o[2]*o[2]),t.y=Math.sqrt(o[4]*o[4]+o[5]*o[5]+o[6]*o[6]),t.z=Math.sqrt(o[8]*o[8]+o[9]*o[9]+o[10]*o[10]),r){var a=r.scaling.x<0?-1:1,s=r.scaling.y<0?-1:1,c=r.scaling.z<0?-1:1;t.x*=a,t.y*=s,t.z*=c}else this.determinant()<=0&&(t.y*=-1);if(0===t._x||0===t._y||0===t._z)return n&&n.copyFromFloats(0,0,0,1),!1;if(n){var u=1/t._x,l=1/t._y,h=1/t._z;e.FromValuesToRef(o[0]*u,o[1]*u,o[2]*u,0,o[4]*l,o[5]*l,o[6]*l,0,o[8]*h,o[9]*h,o[10]*h,0,0,0,0,1,_.Matrix[0]),p.FromRotationMatrixToRef(_.Matrix[0],n)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new d(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,n,i,r){if(e<0||e>3)return this;var o=4*e;return this._m[o+0]=t,this._m[o+1]=n,this._m[o+2]=i,this._m[o+3]=r,this.markAsUpdated(),this},e.prototype.scale=function(t){var n=new e;return this.scaleToRef(t,n),n},e.prototype.scaleToRef=function(e,t){for(var n=0;n<16;n++)t._m[n]=this._m[n]*e;return t.markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var n=0;n<16;n++)t._m[n]+=this._m[n]*e;return t.markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){var n=_.Matrix[0];this.invertToRef(n),n.transposeToRef(t);var i=t._m;e.FromValuesToRef(i[0],i[1],i[2],0,i[4],i[5],i[6],0,i[8],i[9],i[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 n=_.Vector3[0];if(!this.decompose(n))return e.IdentityToRef(t),this;var i=this._m,r=1/n._x,o=1/n._y,a=1/n._z;return e.FromValuesToRef(i[0]*r,i[1]*r,i[2]*r,0,i[4]*o,i[5]*o,i[6]*o,0,i[8]*a,i[9]*a,i[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,n){void 0===n&&(n=0);var i=new e;return e.FromArrayToRef(t,n,i),i},e.FromArrayToRef=function(e,t,n){for(var i=0;i<16;i++)n._m[i]=e[i+t];n.markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,n,i){for(var r=0;r<16;r++)i._m[r]=e[r+t]*n;i.markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!1,configurable:!0}),e.FromValuesToRef=function(e,t,n,i,r,o,a,s,c,u,l,h,d,p,f,_,m){var g=m._m;g[0]=e,g[1]=t,g[2]=n,g[3]=i,g[4]=r,g[5]=o,g[6]=a,g[7]=s,g[8]=c,g[9]=u,g[10]=l,g[11]=h,g[12]=d,g[13]=p,g[14]=f,g[15]=_,m.markAsUpdated()},e.FromValues=function(t,n,i,r,o,a,s,c,u,l,h,d,p,f,_,m){var g=new e,v=g._m;return v[0]=t,v[1]=n,v[2]=i,v[3]=r,v[4]=o,v[5]=a,v[6]=s,v[7]=c,v[8]=u,v[9]=l,v[10]=h,v[11]=d,v[12]=p,v[13]=f,v[14]=_,v[15]=m,g.markAsUpdated(),g},e.Compose=function(t,n,i){var r=new e;return e.ComposeToRef(t,n,i,r),r},e.ComposeToRef=function(e,t,n,i){var r=i._m,o=t._x,a=t._y,s=t._z,c=t._w,u=o+o,l=a+a,h=s+s,d=o*u,p=o*l,f=o*h,_=a*l,m=a*h,g=s*h,v=c*u,b=c*l,y=c*h,T=e._x,E=e._y,S=e._z;r[0]=(1-(_+g))*T,r[1]=(p+y)*T,r[2]=(f-b)*T,r[3]=0,r[4]=(p-y)*E,r[5]=(1-(d+g))*E,r[6]=(m+v)*E,r[7]=0,r[8]=(f+b)*S,r[9]=(m-v)*S,r[10]=(1-(d+_))*S,r[11]=0,r[12]=n._x,r[13]=n._y,r[14]=n._z,r[15]=1,i.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 n=new e;return e.RotationXToRef(t,n),n},e.Invert=function(t){var n=new e;return t.invertToRef(n),n},e.RotationXToRef=function(t,n){var i=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(1,0,0,0,0,r,i,0,0,-i,r,0,0,0,0,1,n),n._updateIdentityStatus(1===r&&0===i)},e.RotationY=function(t){var n=new e;return e.RotationYToRef(t,n),n},e.RotationYToRef=function(t,n){var i=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,0,-i,0,0,1,0,0,i,0,r,0,0,0,0,1,n),n._updateIdentityStatus(1===r&&0===i)},e.RotationZ=function(t){var n=new e;return e.RotationZToRef(t,n),n},e.RotationZToRef=function(t,n){var i=Math.sin(t),r=Math.cos(t);e.FromValuesToRef(r,i,0,0,-i,r,0,0,0,0,1,0,0,0,0,1,n),n._updateIdentityStatus(1===r&&0===i)},e.RotationAxis=function(t,n){var i=new e;return e.RotationAxisToRef(t,n,i),i},e.RotationAxisToRef=function(e,t,n){var i=Math.sin(-t),r=Math.cos(-t),o=1-r;e.normalize();var a=n._m;a[0]=e._x*e._x*o+r,a[1]=e._x*e._y*o-e._z*i,a[2]=e._x*e._z*o+e._y*i,a[3]=0,a[4]=e._y*e._x*o+e._z*i,a[5]=e._y*e._y*o+r,a[6]=e._y*e._z*o-e._x*i,a[7]=0,a[8]=e._z*e._x*o-e._y*i,a[9]=e._z*e._y*o+e._x*i,a[10]=e._z*e._z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[15]=1,n.markAsUpdated()},e.RotationAlignToRef=function(e,t,n){var i=h.Dot(t,e),o=n._m;if(i<-1+r.a)o[0]=-1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=-1,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0;else{var a=h.Cross(t,e),s=1/(1+i);o[0]=a._x*a._x*s+i,o[1]=a._y*a._x*s-a._z,o[2]=a._z*a._x*s+a._y,o[3]=0,o[4]=a._x*a._y*s+a._z,o[5]=a._y*a._y*s+i,o[6]=a._z*a._y*s-a._x,o[7]=0,o[8]=a._x*a._z*s-a._y,o[9]=a._y*a._z*s+a._x,o[10]=a._z*a._z*s+i,o[11]=0}o[12]=0,o[13]=0,o[14]=0,o[15]=1,n.markAsUpdated()},e.RotationYawPitchRoll=function(t,n,i){var r=new e;return e.RotationYawPitchRollToRef(t,n,i,r),r},e.RotationYawPitchRollToRef=function(e,t,n,i){p.RotationYawPitchRollToRef(e,t,n,_.Quaternion[0]),_.Quaternion[0].toRotationMatrix(i)},e.Scaling=function(t,n,i){var r=new e;return e.ScalingToRef(t,n,i,r),r},e.ScalingToRef=function(t,n,i,r){e.FromValuesToRef(t,0,0,0,0,n,0,0,0,0,i,0,0,0,0,1,r),r._updateIdentityStatus(1===t&&1===n&&1===i)},e.Translation=function(t,n,i){var r=new e;return e.TranslationToRef(t,n,i,r),r},e.TranslationToRef=function(t,n,i,r){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,n,i,1,r),r._updateIdentityStatus(0===t&&0===n&&0===i)},e.Lerp=function(t,n,i){var r=new e;return e.LerpToRef(t,n,i,r),r},e.LerpToRef=function(e,t,n,i){for(var r=i._m,o=e.m,a=t.m,s=0;s<16;s++)r[s]=o[s]*(1-n)+a[s]*n;i.markAsUpdated()},e.DecomposeLerp=function(t,n,i){var r=new e;return e.DecomposeLerpToRef(t,n,i,r),r},e.DecomposeLerpToRef=function(t,n,i,r){var o=_.Vector3[0],a=_.Quaternion[0],s=_.Vector3[1];t.decompose(o,a,s);var c=_.Vector3[2],u=_.Quaternion[1],l=_.Vector3[3];n.decompose(c,u,l);var d=_.Vector3[4];h.LerpToRef(o,c,i,d);var f=_.Quaternion[2];p.SlerpToRef(a,u,i,f);var m=_.Vector3[5];h.LerpToRef(s,l,i,m),e.ComposeToRef(d,f,m,r)},e.LookAtLH=function(t,n,i){var r=new e;return e.LookAtLHToRef(t,n,i,r),r},e.LookAtLHToRef=function(t,n,i,r){var o=_.Vector3[0],a=_.Vector3[1],s=_.Vector3[2];n.subtractToRef(t,s),s.normalize(),h.CrossToRef(i,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),h.CrossToRef(s,o,a),a.normalize();var u=-h.Dot(o,t),l=-h.Dot(a,t),d=-h.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,l,d,1,r)},e.LookAtRH=function(t,n,i){var r=new e;return e.LookAtRHToRef(t,n,i,r),r},e.LookAtRHToRef=function(t,n,i,r){var o=_.Vector3[0],a=_.Vector3[1],s=_.Vector3[2];t.subtractToRef(n,s),s.normalize(),h.CrossToRef(i,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),h.CrossToRef(s,o,a),a.normalize();var u=-h.Dot(o,t),l=-h.Dot(a,t),d=-h.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,l,d,1,r)},e.LookDirectionLH=function(t,n){var i=new e;return e.LookDirectionLHToRef(t,n,i),i},e.LookDirectionLHToRef=function(t,n,i){var r=_.Vector3[0];r.copyFrom(t),r.scaleInPlace(-1);var o=_.Vector3[1];h.CrossToRef(n,r,o),e.FromValuesToRef(o._x,o._y,o._z,0,n._x,n._y,n._z,0,r._x,r._y,r._z,0,0,0,0,1,i)},e.LookDirectionRH=function(t,n){var i=new e;return e.LookDirectionRHToRef(t,n,i),i},e.LookDirectionRHToRef=function(t,n,i){var r=_.Vector3[2];h.CrossToRef(n,t,r),e.FromValuesToRef(r._x,r._y,r._z,0,n._x,n._y,n._z,0,t._x,t._y,t._z,0,0,0,0,1,i)},e.OrthoLH=function(t,n,i,r,o){var a=new e;return e.OrthoLHToRef(t,n,i,r,a,o),a},e.OrthoLHToRef=function(t,n,i,r,o,a){var s=2/t,c=2/n,u=2/(r-i),l=-(r+i)/(r-i);e.FromValuesToRef(s,0,0,0,0,c,0,0,0,0,u,0,0,0,l,1,o),a&&o.multiplyToRef(g,o),o._updateIdentityStatus(1===s&&1===c&&1===u&&0===l)},e.OrthoOffCenterLH=function(t,n,i,r,o,a,s){var c=new e;return e.OrthoOffCenterLHToRef(t,n,i,r,o,a,c,s),c},e.OrthoOffCenterLHToRef=function(t,n,i,r,o,a,s,c){var u=2/(n-t),l=2/(r-i),h=2/(a-o),d=-(a+o)/(a-o),p=(t+n)/(t-n),f=(r+i)/(i-r);e.FromValuesToRef(u,0,0,0,0,l,0,0,0,0,h,0,p,f,d,1,s),c&&s.multiplyToRef(g,s),s.markAsUpdated()},e.OrthoOffCenterRH=function(t,n,i,r,o,a,s){var c=new e;return e.OrthoOffCenterRHToRef(t,n,i,r,o,a,c,s),c},e.OrthoOffCenterRHToRef=function(t,n,i,r,o,a,s,c){e.OrthoOffCenterLHToRef(t,n,i,r,o,a,s,c),s._m[10]*=-1},e.PerspectiveLH=function(t,n,i,r,o,a){void 0===a&&(a=0);var s=new e,c=2*i/t,u=2*i/n,l=(r+i)/(r-i),h=-2*r*i/(r-i),d=Math.tan(a);return e.FromValuesToRef(c,0,0,0,0,u,0,d,0,0,l,1,0,0,h,0,s),o&&s.multiplyToRef(g,s),s._updateIdentityStatus(!1),s},e.PerspectiveFovLH=function(t,n,i,r,o,a,s){void 0===a&&(a=0),void 0===s&&(s=!1);var c=new e;return e.PerspectiveFovLHToRef(t,n,i,r,c,!0,o,a,s),c},e.PerspectiveFovLHToRef=function(t,n,i,r,o,a,s,c,u){void 0===a&&(a=!0),void 0===c&&(c=0),void 0===u&&(u=!1);var l=i,h=r,d=1/Math.tan(.5*t),p=a?d/n:d,f=a?d:d*n,_=u&&0===l?-1:0!==h?(h+l)/(h-l):1,m=u&&0===l?2*h:0!==h?-2*h*l/(h-l):-2*l,v=Math.tan(c);e.FromValuesToRef(p,0,0,0,0,f,0,v,0,0,_,1,0,0,m,0,o),s&&o.multiplyToRef(g,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseLHToRef=function(t,n,i,r,o,a,s,c){void 0===a&&(a=!0),void 0===c&&(c=0);var u=1/Math.tan(.5*t),l=a?u/n:u,h=a?u:u*n,d=Math.tan(c);e.FromValuesToRef(l,0,0,0,0,h,0,d,0,0,-i,1,0,0,1,0,o),s&&o.multiplyToRef(g,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,n,i,r,o,a,s){void 0===a&&(a=0),void 0===s&&(s=!1);var c=new e;return e.PerspectiveFovRHToRef(t,n,i,r,c,!0,o,a,s),c},e.PerspectiveFovRHToRef=function(t,n,i,r,o,a,s,c,u){void 0===a&&(a=!0),void 0===c&&(c=0),void 0===u&&(u=!1);var l=i,h=r,d=1/Math.tan(.5*t),p=a?d/n:d,f=a?d:d*n,_=u&&0===l?1:0!==h?-(h+l)/(h-l):-1,m=u&&0===l?2*h:0!==h?-2*h*l/(h-l):-2*l,v=Math.tan(c);e.FromValuesToRef(p,0,0,0,0,f,0,v,0,0,_,-1,0,0,m,0,o),s&&o.multiplyToRef(g,o),o._updateIdentityStatus(!1)},e.PerspectiveFovReverseRHToRef=function(t,n,i,r,o,a,s,c){void 0===a&&(a=!0),void 0===c&&(c=0);var u=1/Math.tan(.5*t),l=a?u/n:u,h=a?u:u*n,d=Math.tan(c);e.FromValuesToRef(l,0,0,0,0,h,0,d,0,0,-i,-1,0,0,-1,0,o),s&&o.multiplyToRef(g,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,n,i,r,o,a){void 0===r&&(r=!1),void 0===a&&(a=0);var s=r?-1:1,c=Math.tan(e.upDegrees*Math.PI/180),u=Math.tan(e.downDegrees*Math.PI/180),l=Math.tan(e.leftDegrees*Math.PI/180),h=Math.tan(e.rightDegrees*Math.PI/180),d=2/(l+h),p=2/(c+u),f=Math.tan(a),_=i._m;_[0]=d,_[1]=_[2]=_[3]=_[4]=0,_[5]=p,_[6]=0,_[7]=f,_[8]=(l-h)*d*.5,_[9]=-(c-u)*p*.5,_[10]=-n/(t-n),_[11]=1*s,_[12]=_[13]=_[15]=0,_[14]=-2*n*t/(n-t),o&&i.multiplyToRef(g,i),i.markAsUpdated()},e.GetFinalMatrix=function(t,n,i,r,o,a){var s=t.width,c=t.height,u=t.x,l=t.y,h=e.FromValues(s/2,0,0,0,0,-c/2,0,0,0,0,a-o,0,u+s/2,c/2+l,o,1),d=_.Matrix[0];return n.multiplyToRef(i,d),d.multiplyToRef(r,d),d.multiply(h)},e.GetAsMatrix2x2=function(e){var t=e.m,n=[t[0],t[1],t[4],t[5]];return s.a.MatrixUse64Bits?n:new Float32Array(n)},e.GetAsMatrix3x3=function(e){var t=e.m,n=[t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]];return s.a.MatrixUse64Bits?n:new Float32Array(n)},e.Transpose=function(t){var n=new e;return e.TransposeToRef(t,n),n},e.TransposeToRef=function(e,t){var n=t._m,i=e.m;n[0]=i[0],n[1]=i[4],n[2]=i[8],n[3]=i[12],n[4]=i[1],n[5]=i[5],n[6]=i[9],n[7]=i[13],n[8]=i[2],n[9]=i[6],n[10]=i[10],n[11]=i[14],n[12]=i[3],n[13]=i[7],n[14]=i[11],n[15]=i[15],t.markAsUpdated(),t._updateIdentityStatus(e._isIdentity,e._isIdentityDirty)},e.Reflection=function(t){var n=new e;return e.ReflectionToRef(t,n),n},e.ReflectionToRef=function(t,n){t.normalize();var i=t.normal.x,r=t.normal.y,o=t.normal.z,a=-2*i,s=-2*r,c=-2*o;e.FromValuesToRef(a*i+1,s*i,c*i,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,n)},e.FromXYZAxesToRef=function(t,n,i,r){e.FromValuesToRef(t._x,t._y,t._z,0,n._x,n._y,n._z,0,i._x,i._y,i._z,0,0,0,0,1,r)},e.FromQuaternionToRef=function(e,t){var n=e._x*e._x,i=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,u=e._y*e._z,l=e._x*e._w;t._m[0]=1-2*(i+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+n),t._m[6]=2*(u+l),t._m[7]=0,t._m[8]=2*(s+c),t._m[9]=2*(u-l),t._m[10]=1-2*(i+n),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}(),_=function(){function e(){}return e.Vector3=o.a.BuildTuple(11,h.Zero),e.Matrix=o.a.BuildTuple(2,f.Identity),e.Quaternion=o.a.BuildTuple(3,p.Zero),e}(),m=function(){function e(){}return e.Vector2=o.a.BuildTuple(3,l.Zero),e.Vector3=o.a.BuildTuple(13,h.Zero),e.Vector4=o.a.BuildTuple(3,d.Zero),e.Quaternion=o.a.BuildTuple(2,p.Zero),e.Matrix=o.a.BuildTuple(8,f.Identity),e}();Object(a.b)("BABYLON.Vector2",l),Object(a.b)("BABYLON.Vector3",h),Object(a.b)("BABYLON.Vector4",d),Object(a.b)("BABYLON.Matrix",f);var g=f.FromValues(1,0,0,0,0,1,0,0,0,0,.5,0,0,0,.5,1)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=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_LAYER_ACCUMULATE=17,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.ZERO=0,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.TEXTURE_CREATIONFLAG_STORAGE=1,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.TEXTUREFORMAT_BGRA=12,e.TEXTUREFORMAT_DEPTH24_STENCIL8=13,e.TEXTUREFORMAT_DEPTH32_FLOAT=14,e.TEXTUREFORMAT_DEPTH16=15,e.TEXTUREFORMAT_DEPTH24=16,e.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM=36492,e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT=36495,e.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT=36494,e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5=33779,e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3=33778,e.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1=33777,e.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1=33776,e.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4=37808,e.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL=36196,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.TEXTURETYPE_UNDEFINED=16,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_DEPTH_TEXTURE_TYPE=5,e.PREPASS_NORMAL_TEXTURE_TYPE=6,e.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE=7,e.BUFFER_CREATIONFLAG_READ=1,e.BUFFER_CREATIONFLAG_WRITE=2,e.BUFFER_CREATIONFLAG_READWRITE=3,e.BUFFER_CREATIONFLAG_UNIFORM=4,e.BUFFER_CREATIONFLAG_VERTEX=8,e.BUFFER_CREATIONFLAG_INDEX=16,e.BUFFER_CREATIONFLAG_STORAGE=32,e.RENDERPASS_MAIN=0,e.INPUT_ALT_KEY=18,e.INPUT_CTRL_KEY=17,e.INPUT_META_KEY1=91,e.INPUT_META_KEY2=92,e.INPUT_META_KEY3=93,e.INPUT_SHIFT_KEY=16,e.SNAPSHOTRENDERING_STANDARD=0,e.SNAPSHOTRENDERING_FAST=1,e.PERSPECTIVE_CAMERA=0,e.ORTHOGRAPHIC_CAMERA=1,e.FOVMODE_VERTICAL_FIXED=0,e.FOVMODE_HORIZONTAL_FIXED=1,e.RIG_MODE_NONE=0,e.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,e.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,e.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,e.RIG_MODE_STEREOSCOPIC_INTERLACED=14,e.RIG_MODE_VR=20,e.RIG_MODE_WEBVR=21,e.RIG_MODE_CUSTOM=22,e.MAX_SUPPORTED_UV_SETS=6,e.GL_ALPHA_EQUATION_ADD=32774,e.GL_ALPHA_EQUATION_MIN=32775,e.GL_ALPHA_EQUATION_MAX=32776,e.GL_ALPHA_EQUATION_SUBTRACT=32778,e.GL_ALPHA_EQUATION_REVERSE_SUBTRACT=32779,e.GL_ALPHA_FUNCTION_SRC=768,e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR=769,e.GL_ALPHA_FUNCTION_SRC_ALPHA=770,e.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA=771,e.GL_ALPHA_FUNCTION_DST_ALPHA=772,e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA=773,e.GL_ALPHA_FUNCTION_DST_COLOR=774,e.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR=775,e.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED=776,e.GL_ALPHA_FUNCTION_CONSTANT_COLOR=32769,e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR=32770,e.GL_ALPHA_FUNCTION_CONSTANT_ALPHA=32771,e.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA=32772,e}()},function(e,t,n){"use strict";n.d(t,"d",(function(){return r})),n.d(t,"a",(function(){return o})),n.d(t,"c",(function(){return a})),n.d(t,"b",(function(){return s})),n.d(t,"e",(function(){return c})),n.d(t,"f",(function(){return u})); +/*! ***************************************************************************** +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 i=function(e,t){return(i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])})(e,t)};function r(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var o=function(){return(o=Object.assign||function(e){for(var t,n=1,i=arguments.length;n=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}function s(e,t,n,i){return new(n||(n=Promise))((function(r,o){function a(e){try{c(i.next(e))}catch(e){o(e)}}function s(e){try{c(i.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((i=i.apply(e,t||[])).next())}))}function c(e,t){var n,i,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(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,i&&(r=2&o[0]?i.return:o[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,o[1])).done)return r;switch(i=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++,i=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]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,n=this._observers;t
";e._AddLogEntry(r),e._GenerateLimitMessage(t,0)}},e._WarnDisabled=function(e,t){},e._WarnEnabled=function(t,n){if(void 0===n||e._CheckLimit(t,n)){var i=e._FormatMessage(t);console.warn("BJS - "+i);var r="
"+t+"

";e._AddLogEntry(r),e._GenerateLimitMessage(t,1)}},e._ErrorDisabled=function(e,t){},e._ErrorEnabled=function(t,n){if(void 0===n||e._CheckLimit(t,n)){var i=e._FormatMessage(t);e.errorsCount++,console.error("BJS - "+i);var r="
"+i+"

";e._AddLogEntry(r),e._GenerateLimitMessage(t,2)}},Object.defineProperty(e,"LogCache",{get:function(){return e._LogCache},enumerable:!1,configurable:!0}),e.ClearLogCache=function(){e._LogCache="",e._LogLimitOutputs={},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.MessageLimitReached="Too many %TYPE%s (%LIMIT%), no more %TYPE%s will be reported for this message.",e._LogCache="",e._LogLimitOutputs={},e.errorsCount=0,e.Log=e._LogEnabled,e.Warn=e._WarnEnabled,e.Error=e._ErrorEnabled,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return s})),n.d(t,"b",(function(){return c})),n.d(t,"c",(function(){return u}));var i=n(14),r=n(23),o=n(52),a=n(10),s=function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this.r=e,this.g=t,this.b=n}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,n){return void 0===n&&(n=0),e.FromArrayToRef(t,n,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,n){return this.r===e&&this.g===t&&this.b===n},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,n){return void 0===e&&(e=0),void 0===t&&(t=1),n.r=i.a.Clamp(this.r,e,t),n.g=i.a.Clamp(this.g,e,t),n.b=i.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,n){return this.r=e,this.g=t,this.b=n,this},e.prototype.set=function(e,t,n){return this.copyFromFloats(e,t,n)},e.prototype.toHexString=function(){var e=Math.round(255*this.r),t=Math.round(255*this.g),n=Math.round(255*this.b);return"#"+i.a.ToHex(e)+i.a.ToHex(t)+i.a.ToHex(n)},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,n=this.g,i=this.b,r=Math.max(t,n,i),o=Math.min(t,n,i),a=0,s=0,c=r,u=r-o;0!==r&&(s=u/r),r!=o&&(r==t?(a=(n-i)/u,n=0&&o<=1?(s=r,c=a):o>=1&&o<=2?(s=a,c=r):o>=2&&o<=3?(c=r,u=a):o>=3&&o<=4?(c=a,u=r):o>=4&&o<=5?(s=a,u=r):o>=5&&o<=6&&(s=r,u=a);var l=n-r;i.set(s+l,c+l,u+l)},e.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new e(0,0,0);var n=parseInt(t.substring(1,3),16),i=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16);return e.FromInts(n,i,r)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2])},e.FromArrayToRef=function(e,t,n){void 0===t&&(t=0),n.r=e[t],n.g=e[t+1],n.b=e[t+2]},e.FromInts=function(t,n,i){return new e(t/255,n/255,i/255)},e.Lerp=function(t,n,i){var r=new e(0,0,0);return e.LerpToRef(t,n,i,r),r},e.LerpToRef=function(e,t,n,i){i.r=e.r+(t.r-e.r)*n,i.g=e.g+(t.g-e.g)*n,i.b=e.b+(t.b-e.b)*n},e.Hermite=function(t,n,i,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,h=s-a;return new e(t.r*c+i.r*u+n.r*l+r.r*h,t.g*c+i.g*u+n.g*l+r.g*h,t.b*c+i.b*u+n.b*l+r.b*h)},e.Hermite1stDerivative=function(t,n,i,r,o){var a=e.Black();return this.Hermite1stDerivativeToRef(t,n,i,r,o,a),a},e.Hermite1stDerivativeToRef=function(e,t,n,i,r,o){var a=r*r;o.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*n.r+(3*a-2*r)*i.r,o.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*n.g+(3*a-2*r)*i.g,o.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*n.b+(3*a-2*r)*i.b},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,n,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),this.r=e,this.g=t,this.b=n,this.a=i}return e.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},e.prototype.asArray=function(){var e=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,n){return void 0===n&&(n=0),e.FromArrayToRef(t,n,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,n){return void 0===e&&(e=0),void 0===t&&(t=1),n.r=i.a.Clamp(this.r,e,t),n.g=i.a.Clamp(this.g,e,t),n.b=i.a.Clamp(this.b,e,t),n.a=i.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,n,i){return this.r=e,this.g=t,this.b=n,this.a=i,this},e.prototype.set=function(e,t,n,i){return this.copyFromFloats(e,t,n,i)},e.prototype.toHexString=function(e){void 0===e&&(e=!1);var t=Math.round(255*this.r),n=Math.round(255*this.g),r=Math.round(255*this.b);if(e)return"#"+i.a.ToHex(t)+i.a.ToHex(n)+i.a.ToHex(r);var o=Math.round(255*this.a);return"#"+i.a.ToHex(t)+i.a.ToHex(n)+i.a.ToHex(r)+i.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.d),e.g=Math.pow(this.g,r.d),e.b=Math.pow(this.b,r.d),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.c),e.g=Math.pow(this.g,r.c),e.b=Math.pow(this.b,r.c),e.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length&&7!==t.length)return new e(0,0,0,0);var n=parseInt(t.substring(1,3),16),i=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16),o=9===t.length?parseInt(t.substring(7,9),16):255;return e.FromInts(n,i,r,o)},e.Lerp=function(t,n,i){var r=new e(0,0,0,0);return e.LerpToRef(t,n,i,r),r},e.LerpToRef=function(e,t,n,i){i.r=e.r+(t.r-e.r)*n,i.g=e.g+(t.g-e.g)*n,i.b=e.b+(t.b-e.b)*n,i.a=e.a+(t.a-e.a)*n},e.Hermite=function(t,n,i,r,o){var a=o*o,s=o*a,c=2*s-3*a+1,u=-2*s+3*a,l=s-2*a+o,h=s-a;return new e(t.r*c+i.r*u+n.r*l+r.r*h,t.g*c+i.g*u+n.g*l+r.g*h,t.b*c+i.b*u+n.b*l+r.b*h,t.a*c+i.a*u+n.a*l+r.a*h)},e.Hermite1stDerivative=function(t,n,i,r,o){var a=new e;return this.Hermite1stDerivativeToRef(t,n,i,r,o,a),a},e.Hermite1stDerivativeToRef=function(e,t,n,i,r,o){var a=r*r;o.r=6*(a-r)*e.r+(3*a-4*r+1)*t.r+6*(-a+r)*n.r+(3*a-2*r)*i.r,o.g=6*(a-r)*e.g+(3*a-4*r+1)*t.g+6*(-a+r)*n.g+(3*a-2*r)*i.g,o.b=6*(a-r)*e.b+(3*a-4*r+1)*t.b+6*(-a+r)*n.b+(3*a-2*r)*i.b,o.a=6*(a-r)*e.a+(3*a-4*r+1)*t.a+6*(-a+r)*n.a+(3*a-2*r)*i.a},e.FromColor3=function(t,n){return void 0===n&&(n=1),new e(t.r,t.g,t.b,n)},e.FromArray=function(t,n){return void 0===n&&(n=0),new e(t[n],t[n+1],t[n+2],t[n+3])},e.FromArrayToRef=function(e,t,n){void 0===t&&(t=0),n.r=e[t],n.g=e[t+1],n.b=e[t+2],n.a=e[t+3]},e.FromInts=function(t,n,i,r){return new e(t/255,n/255,i/255,r/255)},e.CheckColors4=function(e,t){if(e.length===3*t){for(var n=[],i=0;i0},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,"forcedInstanceCount",{get:function(){return this._internalMeshDataInfo._forcedInstanceCount},set:function(e){this._internalMeshDataInfo._forcedInstanceCount=e},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,"previousWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.instancesPreviousData},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}),Object.defineProperty(t.prototype,"manualUpdateOfPreviousWorldMatrixInstancedBuffer",{get:function(){return this._instanceDataStorage.previousManualUpdate},set:function(e){this._instanceDataStorage.previousManualUpdate=e},enumerable:!1,configurable:!0}),t.prototype.instantiateHierarchy=function(e,t,n){void 0===e&&(e=null);var i=!(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));i.parent=e||this.parent,i.position=this.position.clone(),i.scaling=this.scaling.clone(),this.rotationQuaternion?i.rotationQuaternion=this.rotationQuaternion.clone():i.rotation=this.rotation.clone(),n&&n(this,i);for(var r=0,o=this.getChildTransformNodes(!0);r0},enumerable:!1,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){var e=this._internalMeshDataInfo._useLODScreenCoverage?-1:1;this._internalMeshDataInfo._LODLevels.sort((function(t,n){return t.distanceOrScreenCoveragen.distanceOrScreenCoverage?-e: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 n=new R.a(e,t);return this._internalMeshDataInfo._LODLevels.push(n),t&&(t._masterMesh=this),this._sortLODLevels(),this},t.prototype.getLODLevelAtDistance=function(e){for(var t=this._internalMeshDataInfo,n=0;na*o)return this.onLODLevelSelection&&this.onLODLevelSelection(o,this,this),this;for(var u=0;u0||this.hasThinInstances);this.computeWorldMatrix();var d=this.material||l.defaultMaterial;if(d)if(d._storeEffectOnSubMeshes)for(var p=0,f=this.subMeshes;p0){var n=this.getIndices();if(!n)return null;var i=n.length,r=!1;if(e)r=!0;else for(var o=0,a=this.subMeshes;oi){r=!0;break}if(s.verticesStart+s.verticesCount>t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new m.a(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),n=t/e|0,i=0;n%3!=0;)n++;this.releaseSubMeshes();for(var r=0;r=t);r++)m.a.CreateFromIndices(0,i,r===e-1?t-i:n,this),i+=n;this.synchronizeInstances()}},t.prototype.setVerticesData=function(e,t,n,i){if(void 0===n&&(n=!1),this._geometry)this._geometry.setVerticesData(e,t,n,i);else{var r=new p.a;r.set(t,e);var o=this.getScene();new f.a(f.a.RandomId(),o,r,n,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 n=this.getVertexBuffer(e);n&&n.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},t.prototype.setVerticesBuffer=function(e,t){return void 0===t&&(t=!0),this._geometry||(this._geometry=f.a.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e,null,t),this},t.prototype.updateVerticesData=function(e,t,n,i){return this._geometry?(i?(this.makeGeometryUnique(),this.updateVerticesData(e,t,n,!1)):this._geometry.updateVerticesData(e,t,n),this):this},t.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var n=this.getVerticesData(d.b.PositionKind);if(!n)return this;if(e(n),this.updateVerticesData(d.b.PositionKind,n,!1,!1),t){var i=this.getIndices(),r=this.getVerticesData(d.b.NormalKind);if(!r)return this;p.a.ComputeNormals(n,i,r),this.updateVerticesData(d.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,n){if(void 0===t&&(t=null),void 0===n&&(n=!1),this._geometry)this._geometry.setIndices(e,t,n);else{var i=new p.a;i.indices=e;var r=this.getScene();new f.a(f.a.RandomId(),r,i,n,this)}return this},t.prototype.updateIndices=function(e,t,n){return void 0===n&&(n=!1),this._geometry?(this._geometry.updateIndices(e,t,n),this):this},t.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},t.prototype._bind=function(e,t,n){if(!this._geometry)return this;var i,r=this.getScene().getEngine();if(this.morphTargetManager&&this.morphTargetManager.isUsingTextureForTargets&&this.morphTargetManager._bind(t),this._unIndexed)i=null;else switch(n){case g.a.PointFillMode:i=null;break;case g.a.WireFrameFillMode:i=e._getLinesIndexBuffer(this.getIndices(),r);break;default:case g.a.TriangleFillMode:i=this._geometry.getIndexBuffer()}return!this._userInstancedBuffersStorage||this.hasThinInstances?this._geometry._bind(t,i):this._geometry._bind(t,i,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects),this},t.prototype._draw=function(e,t,n){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._internalMeshDataInfo._onBeforeDrawObservable&&this._internalMeshDataInfo._onBeforeDrawObservable.notifyObservers(this);var i=this.getScene().getEngine();return this._unIndexed||t==g.a.PointFillMode?i.drawArraysType(t,e.verticesStart,e.verticesCount,this.forcedInstanceCount||n):t==g.a.WireFrameFillMode?i.drawElementsType(t,0,e._linesIndexCount,this.forcedInstanceCount||n):i.drawElementsType(t,e.indexStart,e.indexCount,this.forcedInstanceCount||n),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){if(t)return this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.hardwareInstancedRendering[e]=!1,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode.renderSelf[e]=!0,this._instanceDataStorage.batchCacheReplacementModeInFrozenMode;if(this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch}var n=this.getScene(),i=n._isInIntermediateRendering(),r=i?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=n.getRenderId(),c=i?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,n,i,r,o){var a,s=i.visibleInstances[e._id];if(!s)return this;for(var c=this._instanceDataStorage,l=c.instancesBufferSize,h=c.instancesBuffer,p=c.instancesPreviousBuffer,f=16*(s.length+1)*4;c.instancesBufferSizet._distanceToCamera?-1:e._distanceToCameral&&i++,0!==_&&p++,h+=_,l=_}if(c[p]++,p>o&&(o=p),0===h)r++;else{var m=1/h,g=0;for(f=0;f.001&&a++}}var v=this.skeleton.bones.length,b=this.getVerticesData(d.b.MatricesIndicesKind),y=this.getVerticesData(d.b.MatricesIndicesExtraKind),T=0;for(u=0;u=v||E<0)&&T++}return{skinned:!0,valid:0===r&&0===a&&0===T,report:"Number of Weights = "+n/4+"\nMaximum influences = "+o+"\nMissing Weights = "+r+"\nNot Sorted = "+i+"\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 n=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return o.b.LoadFile(this.delayLoadingFile,(function(n){n instanceof ArrayBuffer?t._delayLoadingFunction(n,t):t._delayLoadingFunction(JSON.parse(n),t),t.instances.forEach((function(e){e.refreshBoundingInfo(),e._syncSubMeshes()})),t.delayLoadState=y.a.DELAYLOADSTATE_LOADED,e._removePendingData(t)}),(function(){}),e.offlineProvider,n),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,n=this.getScene().materials;for(t=n.length-1;t>-1;t--)if(n[t].id===e)return this.material=n[t],this;var i=this.getScene().multiMaterials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;return this},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(d.b.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var n,i=this.getVerticesData(d.b.PositionKind),r=new Array;for(n=0;n-1&&(r.morphTargetManager=n.getMorphTargetManagerById(e.morphTargetManagerId)),void 0!==e.skeletonId&&null!==e.skeletonId&&(r.skeleton=n.getLastSkeletonById(e.skeletonId),e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,h=l?this.getVerticesData(d.b.MatricesIndicesExtraKind):null,p=l?this.getVerticesData(d.b.MatricesWeightsExtraKind):null,f=e.getTransformMatrices(this),_=u.e.Zero(),m=new u.a,g=new u.a,v=0,b=0;b0&&(u.a.FromFloat32ArrayToRefScaled(f,Math.floor(16*a[v+c]),y,g),m.addToSelf(g));if(l)for(c=0;c<4;c++)(y=p[v+c])>0&&(u.a.FromFloat32ArrayToRefScaled(f,Math.floor(16*h[v+c]),y,g),m.addToSelf(g));u.e.TransformCoordinatesFromFloatsToRef(n._sourcePositions[b],n._sourcePositions[b+1],n._sourcePositions[b+2],m,_),_.toArray(r,b),t&&(u.e.TransformNormalFromFloatsToRef(n._sourceNormals[b],n._sourceNormals[b+1],n._sourceNormals[b+2],m,_),_.toArray(o,b)),m.reset()}return this.updateVerticesData(d.b.PositionKind,r),t&&this.updateVerticesData(d.b.NormalKind,o),this},t.MinMax=function(e){var t=null,n=null;return e.forEach((function(e){var i=e.getBoundingInfo().boundingBox;t&&n?(t.minimizeInPlace(i.minimumWorld),n.maximizeInPlace(i.maximumWorld)):(t=i.minimumWorld,n=i.maximumWorld)})),t&&n?{min:t,max:n}:{min:u.e.Zero(),max:u.e.Zero()}},t.Center=function(e){var n=e instanceof Array?t.MinMax(e):e;return u.e.Center(n.min,n.max)},t.MergeMeshes=function(e,n,i,r,o,a){return void 0===n&&(n=!0),Object(c.g)(t._MergeMeshesCoroutine(e,n,i,r,o,a,!1))},t.MergeMeshesAsync=function(e,n,i,r,o,a){return void 0===n&&(n=!0),Object(c.f)(t._MergeMeshesCoroutine(e,n,i,r,o,a,!0),Object(c.a)())},t._MergeMeshesCoroutine=function(e,n,r,o,a,s,c){var u,l,h,d,f,_,g,b,y,T,S,A,x,R,C,P,O,M,I,D,N,L,F,w,B;return void 0===n&&(n=!0),Object(i.e)(this,(function(i){switch(i.label){case 0:if(0===(e=e.filter(Boolean)).length)return[2,null];if(!r)for(l=0,u=0;u=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"),[2,null];for(s&&(h=null,a=!1),_=new Array,g=new Array,b=new Array,u=0;u0?e.name:i+e.name,(Object(f.g)(e.url,"data:")||t.UseSerializedUrlIfAny&&e.url)&&(m=e.url),c=new t(m,n,!u,e.invertY,e.samplingMode,a)}return c}),e,n);return s},t.CreateFromBase64String=function(e,n,i,r,o,a,s,u,l,h){return void 0===a&&(a=t.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===u&&(u=null),void 0===l&&(l=c.a.TEXTUREFORMAT_RGBA),new t("data:"+n,i,r,o,a,s,u,e,!1,l,void 0,void 0,h)},t.LoadFromDataString=function(e,n,i,r,o,a,s,u,l,h,d){return void 0===r&&(r=!1),void 0===a&&(a=!0),void 0===s&&(s=t.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null),void 0===l&&(l=null),void 0===h&&(h=c.a.TEXTUREFORMAT_RGBA),"data:"!==e.substr(0,5)&&(e="data:"+e),new t(e,i,o,a,s,u,l,n,r,h,void 0,void 0,d)},t.SerializeBuffers=!0,t.ForceSerializeBuffers=!1,t.OnTextureLoadErrorObservable=new o.c,t._CubeTextureParser=function(e,t,n){throw Object(l.a)("CubeTexture")},t._CreateMirror=function(e,t,n,i){throw Object(l.a)("MirrorTexture")},t._CreateRenderTargetTexture=function(e,t,n,i,r){throw Object(l.a)("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(i.c)([Object(r.d)()],t.prototype,"url",void 0),Object(i.c)([Object(r.d)()],t.prototype,"uOffset",void 0),Object(i.c)([Object(r.d)()],t.prototype,"vOffset",void 0),Object(i.c)([Object(r.d)()],t.prototype,"uScale",void 0),Object(i.c)([Object(r.d)()],t.prototype,"vScale",void 0),Object(i.c)([Object(r.d)()],t.prototype,"uAng",void 0),Object(i.c)([Object(r.d)()],t.prototype,"vAng",void 0),Object(i.c)([Object(r.d)()],t.prototype,"wAng",void 0),Object(i.c)([Object(r.d)()],t.prototype,"uRotationCenter",void 0),Object(i.c)([Object(r.d)()],t.prototype,"vRotationCenter",void 0),Object(i.c)([Object(r.d)()],t.prototype,"wRotationCenter",void 0),Object(i.c)([Object(r.d)()],t.prototype,"homogeneousRotationInUVTransform",void 0),Object(i.c)([Object(r.d)()],t.prototype,"isBlocking",null),t}(s.a);Object(u.b)("BABYLON.Texture",g),r.a._TextureParser=g.Parse},function(e,t,n){"use strict";n.d(t,"b",(function(){return v})),n.d(t,"c",(function(){return b})),n.d(t,"a",(function(){return y}));var i=n(2),r=n(6),o=n(35),a=n(7),s=n(49),c=n(36),u=n(25),l=n(58),h=n(16),d=n(55),p=n(173),f=n(107),_=n(142),m=n(100),g=n(143),v=function(){function e(){}return Object.defineProperty(e,"BaseUrl",{get:function(){return d.c.BaseUrl},set:function(e){d.c.BaseUrl=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"DefaultRetryStrategy",{get:function(){return d.c.DefaultRetryStrategy},set:function(e){d.c.DefaultRetryStrategy=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CorsBehavior",{get:function(){return d.c.CorsBehavior},set:function(e){d.c.CorsBehavior=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"UseFallbackTexture",{get:function(){return h.a.UseFallbackTexture},set:function(e){h.a.UseFallbackTexture=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"RegisteredExternalClasses",{get:function(){return _.a.RegisteredExternalClasses},set:function(e){_.a.RegisteredExternalClasses=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"fallbackTexture",{get:function(){return h.a.FallbackTexture},set:function(e){h.a.FallbackTexture=e},enumerable:!1,configurable:!0}),e.FetchToRef=function(e,t,n,i,r,o){var a=4*((Math.abs(e)*n%n|0)+(Math.abs(t)*i%i|0)*n);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,n){return e*(1-n)+t*n},e.Instantiate=function(e){return _.a.Instantiate(e)},e.Slice=function(e,t,n){return g.a.Slice(e,t,n)},e.SliceToArray=function(e,t,n){return g.a.SliceToArray(e,t,n)},e.SetImmediate=function(e){f.a.SetImmediate(e)},e.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t1?1:Math.round(255*p)}i=h}var f=l.createImageData(t,n);f.data.set(i),l.putImageData(f,0,0);var _=e._ScreenshotCanvas;if(s){var m=document.createElement("canvas");m.width=t,m.height=n;var g=m.getContext("2d");if(!g)return;g.translate(0,n),g.scale(1,-1),g.drawImage(e._ScreenshotCanvas,0,0),_=m}c?e.ToBlob(_,(function(e){var t=new FileReader;t.onload=function(e){var t=e.target.result;r&&r(t)},t.readAsArrayBuffer(e)}),o,u):e.EncodeScreenshotCanvasData(r,o,a,_,u)}},e.DumpDataAsync=function(t,n,i,r,o,a,s,c){return void 0===r&&(r="image/png"),void 0===a&&(a=!1),void 0===s&&(s=!1),new Promise((function(u){e.DumpData(t,n,i,(function(e){return u(e)}),r,o,a,s,c)}))},e.ToBlob=function(e,t,n,i){void 0===n&&(n="image/png"),e.toBlob||(e.toBlob=function(e,t,n){var i=this;setTimeout((function(){for(var r=atob(i.toDataURL(t,n).split(",")[1]),o=r.length,a=new Uint8Array(o),s=0;s=t)break;if(i(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),r)},e}();h.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",p.a.Apply()},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var i=n(2),r=n(6),o=n(35),a=n(16),s=n(25),c=n(27),u=n(1),l=n(176),h=n(61),d=n(103),p=n(7),f=(n(144),n(130),n(145),function(e){function t(n,i,a,s){void 0===s&&(s=!1);var c=e.call(this,n,i,a,s)||this;if(c.enableOfflineSupport=!1,c.disableManifestCheck=!1,c.scenes=new Array,c._virtualScenes=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 l.a,c._compatibilityMode=!0,c.currentRenderPassId=u.a.RENDERPASS_MAIN,c._renderPassNames=["main"],t.Instances.push(c),!n)return c;if(c._features.supportRenderPasses=!0,a=c._creationOptions,n.getContext){var d=n;if(c._sharedInit(d,!!a.doNotHandleTouchAction,a.audioEngine),Object(o.e)()){var p=document;c._onFullscreenChange=function(){void 0!==p.fullscreen?c.isFullscreen=p.fullscreen:void 0!==p.mozFullScreen?c.isFullscreen=p.mozFullScreen:void 0!==p.webkitIsFullScreen?c.isFullscreen=p.webkitIsFullScreen:void 0!==p.msIsFullScreen&&(c.isFullscreen=p.msIsFullScreen),c.isFullscreen&&c._pointerLockRequested&&d&&t._RequestPointerlock(d)},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=p.mozPointerLockElement===d||p.webkitPointerLockElement===d||p.msPointerLockElement===d||p.pointerLockElement===d},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.getAudioContext(),c.getAudioDestination()))}c._connectVREvents(),c.enableOfflineSupport=void 0!==t.OfflineProviderFactory,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(i.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.prototype.createImageBitmapFromSource=function(e,t){var n=this;return new Promise((function(i,r){var o=new Image;o.onload=function(){o.decode().then((function(){n.createImageBitmap(o,t).then((function(e){i(e)}))}))},o.onerror=function(){r("Error loading image ".concat(o.src))},o.src=e}))},t.prototype.createImageBitmap=function(e,t){return createImageBitmap(e,t)},t.prototype.resizeImageBitmap=function(e,t,n){var i=this.createCanvas(t,n).getContext("2d");if(!i)throw new Error("Unable to get 2d context for resizeImageBitmap");return i.drawImage(e,0,0),i.getImageData(0,0,t,n).data},t.MarkAllMaterialsAsDirty=function(e,n){for(var i=0;i0?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(t){void 0===t&&(t=!1),this.isVRPresenting()||e.prototype.resize.call(this,t)},t.prototype.setSize=function(t,n,i){if(void 0===i&&(i=!1),!this._renderingCanvas)return!1;if(!e.prototype.setSize.call(this,t,n,i))return!1;if(this.scenes){for(var r=0;r1&&r){var a=this.createTransformFeedback();this.bindTransformFeedback(a),this.setTranformFeedbackVaryings(o,r),e.transformFeedback=a}return i.linkProgram(o),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),e.context=i,e.vertexShader=t,e.fragmentShader=n,e.isParallelCompiled||this._finalizePipelineContext(e),o},t.prototype._releaseTexture=function(t){e.prototype._releaseTexture.call(this,t)},t.prototype._releaseRenderTargetWrapper=function(t){e.prototype._releaseRenderTargetWrapper.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.getRenderPassNames=function(){return this._renderPassNames},t.prototype.getCurrentRenderPassName=function(){return this._renderPassNames[this.currentRenderPassId]},t.prototype.createRenderPassId=function(e){var n=++t._RenderPassIdCounter;return this._renderPassNames[n]=null!=e?e:"NONAME",n},t.prototype.releaseRenderPassId=function(e){this._renderPassNames[e]=void 0;for(var t=0;t=0&&t.Instances.splice(n,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(Object(o.e)()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},t.prototype.hideLoadingUI=function(){if(Object(o.e)()){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.prototype.createVideoElement=function(e){return document.createElement("video")},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.prototype.getFontOffset=function(e){var t=document.createElement("span");t.innerHTML="Hg",t.setAttribute("style","font: ".concat(e," !important"));var n=document.createElement("div");n.style.display="inline-block",n.style.width="1px",n.style.height="0px",n.style.verticalAlign="bottom";var i=document.createElement("div");i.style.whiteSpace="nowrap",i.appendChild(t),i.appendChild(n),document.body.appendChild(i);var r=0,o=0;try{o=n.getBoundingClientRect().top-t.getBoundingClientRect().top,n.style.verticalAlign="baseline",r=n.getBoundingClientRect().top-t.getBoundingClientRect().top}finally{document.body.removeChild(i)}return{ascent:r,height:o,descent:o-r}},t.ALPHA_DISABLE=u.a.ALPHA_DISABLE,t.ALPHA_ADD=u.a.ALPHA_ADD,t.ALPHA_COMBINE=u.a.ALPHA_COMBINE,t.ALPHA_SUBTRACT=u.a.ALPHA_SUBTRACT,t.ALPHA_MULTIPLY=u.a.ALPHA_MULTIPLY,t.ALPHA_MAXIMIZED=u.a.ALPHA_MAXIMIZED,t.ALPHA_ONEONE=u.a.ALPHA_ONEONE,t.ALPHA_PREMULTIPLIED=u.a.ALPHA_PREMULTIPLIED,t.ALPHA_PREMULTIPLIED_PORTERDUFF=u.a.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHA_INTERPOLATE=u.a.ALPHA_INTERPOLATE,t.ALPHA_SCREENMODE=u.a.ALPHA_SCREENMODE,t.DELAYLOADSTATE_NONE=u.a.DELAYLOADSTATE_NONE,t.DELAYLOADSTATE_LOADED=u.a.DELAYLOADSTATE_LOADED,t.DELAYLOADSTATE_LOADING=u.a.DELAYLOADSTATE_LOADING,t.DELAYLOADSTATE_NOTLOADED=u.a.DELAYLOADSTATE_NOTLOADED,t.NEVER=u.a.NEVER,t.ALWAYS=u.a.ALWAYS,t.LESS=u.a.LESS,t.EQUAL=u.a.EQUAL,t.LEQUAL=u.a.LEQUAL,t.GREATER=u.a.GREATER,t.GEQUAL=u.a.GEQUAL,t.NOTEQUAL=u.a.NOTEQUAL,t.KEEP=u.a.KEEP,t.REPLACE=u.a.REPLACE,t.INCR=u.a.INCR,t.DECR=u.a.DECR,t.INVERT=u.a.INVERT,t.INCR_WRAP=u.a.INCR_WRAP,t.DECR_WRAP=u.a.DECR_WRAP,t.TEXTURE_CLAMP_ADDRESSMODE=u.a.TEXTURE_CLAMP_ADDRESSMODE,t.TEXTURE_WRAP_ADDRESSMODE=u.a.TEXTURE_WRAP_ADDRESSMODE,t.TEXTURE_MIRROR_ADDRESSMODE=u.a.TEXTURE_MIRROR_ADDRESSMODE,t.TEXTUREFORMAT_ALPHA=u.a.TEXTUREFORMAT_ALPHA,t.TEXTUREFORMAT_LUMINANCE=u.a.TEXTUREFORMAT_LUMINANCE,t.TEXTUREFORMAT_LUMINANCE_ALPHA=u.a.TEXTUREFORMAT_LUMINANCE_ALPHA,t.TEXTUREFORMAT_RGB=u.a.TEXTUREFORMAT_RGB,t.TEXTUREFORMAT_RGBA=u.a.TEXTUREFORMAT_RGBA,t.TEXTUREFORMAT_RED=u.a.TEXTUREFORMAT_RED,t.TEXTUREFORMAT_R=u.a.TEXTUREFORMAT_R,t.TEXTUREFORMAT_RG=u.a.TEXTUREFORMAT_RG,t.TEXTUREFORMAT_RED_INTEGER=u.a.TEXTUREFORMAT_RED_INTEGER,t.TEXTUREFORMAT_R_INTEGER=u.a.TEXTUREFORMAT_R_INTEGER,t.TEXTUREFORMAT_RG_INTEGER=u.a.TEXTUREFORMAT_RG_INTEGER,t.TEXTUREFORMAT_RGB_INTEGER=u.a.TEXTUREFORMAT_RGB_INTEGER,t.TEXTUREFORMAT_RGBA_INTEGER=u.a.TEXTUREFORMAT_RGBA_INTEGER,t.TEXTURETYPE_UNSIGNED_BYTE=u.a.TEXTURETYPE_UNSIGNED_BYTE,t.TEXTURETYPE_UNSIGNED_INT=u.a.TEXTURETYPE_UNSIGNED_INT,t.TEXTURETYPE_FLOAT=u.a.TEXTURETYPE_FLOAT,t.TEXTURETYPE_HALF_FLOAT=u.a.TEXTURETYPE_HALF_FLOAT,t.TEXTURETYPE_BYTE=u.a.TEXTURETYPE_BYTE,t.TEXTURETYPE_SHORT=u.a.TEXTURETYPE_SHORT,t.TEXTURETYPE_UNSIGNED_SHORT=u.a.TEXTURETYPE_UNSIGNED_SHORT,t.TEXTURETYPE_INT=u.a.TEXTURETYPE_INT,t.TEXTURETYPE_UNSIGNED_INTEGER=u.a.TEXTURETYPE_UNSIGNED_INTEGER,t.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=u.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,t.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=u.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,t.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=u.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,t.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=u.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,t.TEXTURETYPE_UNSIGNED_INT_24_8=u.a.TEXTURETYPE_UNSIGNED_INT_24_8,t.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=u.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,t.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=u.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,t.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=u.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,t.TEXTURE_NEAREST_SAMPLINGMODE=u.a.TEXTURE_NEAREST_SAMPLINGMODE,t.TEXTURE_BILINEAR_SAMPLINGMODE=u.a.TEXTURE_BILINEAR_SAMPLINGMODE,t.TEXTURE_TRILINEAR_SAMPLINGMODE=u.a.TEXTURE_TRILINEAR_SAMPLINGMODE,t.TEXTURE_NEAREST_NEAREST_MIPLINEAR=u.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR_MIPNEAREST=u.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,t.TEXTURE_LINEAR_LINEAR_MIPLINEAR=u.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_NEAREST_MIPNEAREST=u.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPNEAREST=u.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,t.TEXTURE_NEAREST_LINEAR_MIPLINEAR=u.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,t.TEXTURE_NEAREST_LINEAR=u.a.TEXTURE_NEAREST_LINEAR,t.TEXTURE_NEAREST_NEAREST=u.a.TEXTURE_NEAREST_NEAREST,t.TEXTURE_LINEAR_NEAREST_MIPNEAREST=u.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,t.TEXTURE_LINEAR_NEAREST_MIPLINEAR=u.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,t.TEXTURE_LINEAR_LINEAR=u.a.TEXTURE_LINEAR_LINEAR,t.TEXTURE_LINEAR_NEAREST=u.a.TEXTURE_LINEAR_NEAREST,t.TEXTURE_EXPLICIT_MODE=u.a.TEXTURE_EXPLICIT_MODE,t.TEXTURE_SPHERICAL_MODE=u.a.TEXTURE_SPHERICAL_MODE,t.TEXTURE_PLANAR_MODE=u.a.TEXTURE_PLANAR_MODE,t.TEXTURE_CUBIC_MODE=u.a.TEXTURE_CUBIC_MODE,t.TEXTURE_PROJECTION_MODE=u.a.TEXTURE_PROJECTION_MODE,t.TEXTURE_SKYBOX_MODE=u.a.TEXTURE_SKYBOX_MODE,t.TEXTURE_INVCUBIC_MODE=u.a.TEXTURE_INVCUBIC_MODE,t.TEXTURE_EQUIRECTANGULAR_MODE=u.a.TEXTURE_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=u.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,t.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=u.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,t.SCALEMODE_FLOOR=u.a.SCALEMODE_FLOOR,t.SCALEMODE_NEAREST=u.a.SCALEMODE_NEAREST,t.SCALEMODE_CEILING=u.a.SCALEMODE_CEILING,t._RescalePostProcessFactory=null,t._RenderPassIdCounter=0,t}(c.a))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){}return e.WithinEpsilon=function(e,t,n){return void 0===n&&(n=1401298e-51),Math.abs(e-t)<=n},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,n){return void 0===t&&(t=0),void 0===n&&(n=1),Math.min(n,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.ILog2=function(e){if(Math.log2)return Math.floor(Math.log2(e));if(e<0)return NaN;if(0===e)return-1/0;var t=0;if(e<1){for(;e<1;)t++,e*=2;t=-t}else if(e>1)for(;e>1;)t++,e=Math.floor(e/2);return t},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,n){return(e-t)/(n-t)},e.Denormalize=function(e,t,n){return e*(n-t)+t},e.DeltaAngle=function(t,n){var i=e.Repeat(n-t,360);return i>180&&(i-=360),i},e.PingPong=function(t,n){var i=e.Repeat(t,2*n);return n-Math.abs(i-n)},e.SmoothStep=function(t,n,i){var r=e.Clamp(i);return n*(r=-2*r*r*r+3*r*r)+t*(1-r)},e.MoveTowards=function(t,n,i){return Math.abs(n-t)<=i?n:t+e.Sign(n-t)*i},e.MoveTowardsAngle=function(t,n,i){var r=e.DeltaAngle(t,n),o=0;return-i180&&(r-=360),t+r*e.Clamp(i)},e.InverseLerp=function(t,n,i){return t!=n?e.Clamp((i-t)/(n-t)):0},e.Hermite=function(e,t,n,i,r){var o=r*r,a=r*o;return e*(2*a-3*o+1)+n*(-2*a+3*o)+t*(a-2*o+r)+i*(a-o)},e.Hermite1stDerivative=function(e,t,n,i,r){var o=r*r;return 6*(o-r)*e+(3*o-4*r+1)*t+6*(-o+r)*n+(3*o-2*r)*i},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,n){return(e-t)/(n-t)},e.PercentToRange=function(e,t,n){return(n-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.HCF=function(t,n){var i=t%n;return 0===i?n:e.HCF(n,i)},e.TwoPi=2*Math.PI,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var i=n(7),r=n(28),o=n(22),a=n(16),s=n(4),c=n(53),u=n(1),l=n(8),h=n(138),d=function(){function e(){}return e.BindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},e.PrepareDefinesForMergedUV=function(e,t,n){t._needUVs=!0,t[n]=!0,e.getTextureMatrix().isIdentityAs3x2()?(t[n+"DIRECTUV"]=e.coordinatesIndex+1,t["MAINUV"+(e.coordinatesIndex+1)]=!0):t[n+"DIRECTUV"]=0},e.BindTextureMatrix=function(e,t,n){var i=e.getTextureMatrix();t.updateMatrix(n+"Matrix",i)},e.GetFogState=function(e,t){return t.fogEnabled&&e.applyFog&&t.fogMode!==o.a.FOGMODE_NONE},e.PrepareDefinesForMisc=function(e,t,n,i,r,o,a){a._areMiscDirty&&(a.LOGARITHMICDEPTH=n,a.POINTSIZE=i,a.FOG=r&&this.GetFogState(e,t),a.NONUNIFORMSCALING=e.nonUniformScaling,a.ALPHATEST=o)},e.PrepareDefinesForFrameBoundValues=function(e,t,n,i,r,o){void 0===r&&(r=null),void 0===o&&(o=!1);var a,s,c,u,l,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,u=null==r?void 0!==e.clipPlane4&&null!==e.clipPlane4:r,l=null==r?void 0!==e.clipPlane5&&null!==e.clipPlane5:r,h=null==r?void 0!==e.clipPlane6&&null!==e.clipPlane6:r,n.CLIPPLANE!==a&&(n.CLIPPLANE=a,d=!0),n.CLIPPLANE2!==s&&(n.CLIPPLANE2=s,d=!0),n.CLIPPLANE3!==c&&(n.CLIPPLANE3=c,d=!0),n.CLIPPLANE4!==u&&(n.CLIPPLANE4=u,d=!0),n.CLIPPLANE5!==l&&(n.CLIPPLANE5=l,d=!0),n.CLIPPLANE6!==h&&(n.CLIPPLANE6=h,d=!0),n.DEPTHPREPASS!==!t.getColorWrite()&&(n.DEPTHPREPASS=!n.DEPTHPREPASS,d=!0),n.INSTANCES!==i&&(n.INSTANCES=i,d=!0),n.INSTANCESCOLOR&&!n.INSTANCES&&(n.INSTANCESCOLOR=!1,d=!0),n.THIN_INSTANCES!==o&&(n.THIN_INSTANCES=o,d=!0),d&&n.markAsUnprocessed()},e.PrepareDefinesForBones=function(e,t){if(e.useBones&&e.computeBonesUsingShaders&&e.skeleton){t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers;var n=void 0!==t.BONETEXTURE;if(e.skeleton.isUsingTextureForMatrices&&n)t.BONETEXTURE=!0;else{t.BonesPerMesh=e.skeleton.bones.length+1,t.BONETEXTURE=!n&&void 0;var i=e.getScene().prePassRenderer;if(i&&i.enabled){var r=-1===i.excludedSkinnedMesh.indexOf(e);t.BONES_VELOCITY_ENABLED=r}}}else t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0},e.PrepareDefinesForMorphTargets=function(e,t){var n=e.morphTargetManager;n?(t.MORPHTARGETS_UV=n.supportsUVs&&t.UV1,t.MORPHTARGETS_TANGENT=n.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=n.supportsNormals&&t.NORMAL,t.MORPHTARGETS=n.numInfluencers>0,t.NUM_MORPH_INFLUENCERS=n.numInfluencers,t.MORPHTARGETS_TEXTURE=n.isUsingTextureForTargets):(t.MORPHTARGETS_UV=!1,t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)},e.PrepareDefinesForBakedVertexAnimation=function(e,t){var n=e.bakedVertexAnimationManager;t.BAKED_VERTEX_ANIMATION_TEXTURE=!(!n||!n.isEnabled)},e.PrepareDefinesForAttributes=function(e,t,n,i,r,o,a){if(void 0===r&&(r=!1),void 0===o&&(o=!0),void 0===a&&(a=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(s.b.NormalKind),t._needNormals&&e.isVerticesDataPresent(s.b.TangentKind)&&(t.TANGENT=!0);for(var c=1;c<=u.a.MAX_SUPPORTED_UV_SETS;++c)t["UV"+c]=!!t._needUVs&&e.isVerticesDataPresent("uv".concat(1===c?"":c));if(n){var l=e.useVertexColors&&e.isVerticesDataPresent(s.b.ColorKind);t.VERTEXCOLOR=l,t.VERTEXALPHA=e.hasVertexAlpha&&l&&o}return e.isVerticesDataPresent(s.b.ColorInstanceKind)&&(t.INSTANCESCOLOR=!0),i&&this.PrepareDefinesForBones(e,t),r&&this.PrepareDefinesForMorphTargets(e,t),a&&this.PrepareDefinesForBakedVertexAnimation(e,t),!0},e.PrepareDefinesForMultiview=function(e,t){if(e.activeCamera){var n=t.MULTIVIEW;t.MULTIVIEW=null!==e.activeCamera.outputRenderTarget&&e.activeCamera.outputRenderTarget.getViewCount()>1,t.MULTIVIEW!=n&&t.markAsUnprocessed()}},e.PrepareDefinesForOIT=function(e,t,n){var i=t.ORDER_INDEPENDENT_TRANSPARENCY,r=t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS;t.ORDER_INDEPENDENT_TRANSPARENCY=e.useOrderIndependentTransparency&&n,t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!e.getEngine().getCaps().textureFloatLinearFiltering,i===t.ORDER_INDEPENDENT_TRANSPARENCY&&r===t.ORDER_INDEPENDENT_TRANSPARENCY_16BITS||t.markAsUnprocessed()},e.PrepareDefinesForPrePass=function(e,t,n){var i=t.PREPASS;if(t._arePrePassDirty){var r=[{type:u.a.PREPASS_POSITION_TEXTURE_TYPE,define:"PREPASS_POSITION",index:"PREPASS_POSITION_INDEX"},{type:u.a.PREPASS_VELOCITY_TEXTURE_TYPE,define:"PREPASS_VELOCITY",index:"PREPASS_VELOCITY_INDEX"},{type:u.a.PREPASS_REFLECTIVITY_TEXTURE_TYPE,define:"PREPASS_REFLECTIVITY",index:"PREPASS_REFLECTIVITY_INDEX"},{type:u.a.PREPASS_IRRADIANCE_TEXTURE_TYPE,define:"PREPASS_IRRADIANCE",index:"PREPASS_IRRADIANCE_INDEX"},{type:u.a.PREPASS_ALBEDO_SQRT_TEXTURE_TYPE,define:"PREPASS_ALBEDO_SQRT",index:"PREPASS_ALBEDO_SQRT_INDEX"},{type:u.a.PREPASS_DEPTH_TEXTURE_TYPE,define:"PREPASS_DEPTH",index:"PREPASS_DEPTH_INDEX"},{type:u.a.PREPASS_NORMAL_TEXTURE_TYPE,define:"PREPASS_NORMAL",index:"PREPASS_NORMAL_INDEX"}];if(e.prePassRenderer&&e.prePassRenderer.enabled&&n){t.PREPASS=!0,t.SCENE_MRT_COUNT=e.prePassRenderer.mrtCount;for(var o=0;o0&&(a.shadowEnabled=!0,s.prepareDefines(r,i))}}n.lightmapMode!=c.a.LIGHTMAP_DEFAULT?(a.lightmapMode=!0,r["LIGHTMAPEXCLUDED"+i]=!0,r["LIGHTMAPNOSPECULAR"+i]=n.lightmapMode==c.a.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+i]=!1,r["LIGHTMAPNOSPECULAR"+i]=!1)},e.PrepareDefinesForLights=function(e,t,n,i,r,o){if(void 0===r&&(r=4),void 0===o&&(o=!1),!n._areLightsDirty)return n._needNormals;var a=0,s={needNormals:!1,needRebuild:!1,lightmapMode:!1,shadowEnabled:!1,specularEnabled:!1};if(e.lightsEnabled&&!o)for(var c=0,u=t.lightSources;c0&&(r=i+o,t.addFallback(r,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(i,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(i,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(i,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(i,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(i,"SHADOWESM"+o),e["SHADOWCLOSEESM"+o]&&t.addFallback(i,"SHADOWCLOSEESM"+o));return r++},e.PrepareAttributesForMorphTargetsInfluencers=function(e,t,n){this._TmpMorphInfluencers.NUM_MORPH_INFLUENCERS=n,this.PrepareAttributesForMorphTargets(e,t,this._TmpMorphInfluencers)},e.PrepareAttributesForMorphTargets=function(e,t,n){var r=n.NUM_MORPH_INFLUENCERS;if(r>0&&a.a.LastCreatedEngine){var o=a.a.LastCreatedEngine.getCaps().maxVertexAttribs,c=t.morphTargetManager;if(null==c?void 0:c.isUsingTextureForTargets)return;for(var u=c&&c.supportsNormals&&n.NORMAL,l=c&&c.supportsTangents&&n.TANGENT,h=c&&c.supportsUVs&&n.UV1,d=0;do&&i.a.Error("Cannot add more vertex attributes for mesh "+t.name)}},e.PrepareAttributesForBakedVertexAnimation=function(e,t,n){n.BAKED_VERTEX_ANIMATION_TEXTURE&&n.INSTANCES&&e.push("bakedVertexAnimationSettingsInstanced")},e.PrepareAttributesForBones=function(e,t,n,i){n.NUM_BONE_INFLUENCERS>0&&(i.addCPUSkinningFallback(0,t),e.push(s.b.MatricesIndicesKind),e.push(s.b.MatricesWeightsKind),n.NUM_BONE_INFLUENCERS>4&&(e.push(s.b.MatricesIndicesExtraKind),e.push(s.b.MatricesWeightsExtraKind)))},e.PrepareAttributesForInstances=function(e,t){(t.INSTANCES||t.THIN_INSTANCES)&&this.PushAttributesForInstances(e,!!t.PREPASS_VELOCITY)},e.PushAttributesForInstances=function(e,t){void 0===t&&(t=!1),e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"),t&&(e.push("previousWorld0"),e.push("previousWorld1"),e.push("previousWorld2"),e.push("previousWorld3"))},e.BindLightProperties=function(e,t,n){e.transferToEffect(t,n+"")},e.BindLight=function(e,t,n,i,r,o){void 0===o&&(o=!0),e._bindLight(t,n,i,r,o)},e.BindLights=function(e,t,n,i,r){void 0===r&&(r=4);for(var o=Math.min(t.lightSources.length,r),a=0;a-1){var o=r.getTransformMatrixTexture(t);n.setTexture("boneSampler",o),n.setFloat("boneTextureWidth",4*(r.bones.length+1))}else{var a=r.getTransformMatrices(t);a&&(n.setMatrices("mBones",a),i&&t.getScene().prePassRenderer&&t.getScene().prePassRenderer.getIndex(u.a.PREPASS_VELOCITY_TEXTURE_TYPE)&&(i.previousBones[t.uniqueId]||(i.previousBones[t.uniqueId]=a.slice()),n.setMatrices("mPreviousBones",i.previousBones[t.uniqueId]),e._CopyBonesTransformationMatrices(a,i.previousBones[t.uniqueId])))}}},e._CopyBonesTransformationMatrices=function(e,t){return t.set(e),t},e.BindMorphTargetParameters=function(e,t){var n=e.morphTargetManager;e&&n&&t.setFloatArray("morphTargetInfluences",n.influences)},e.BindLogDepth=function(e,t,n){if(!e||e.LOGARITHMICDEPTH){var o=n.activeCamera;o.mode===r.a.ORTHOGRAPHIC_CAMERA&&i.a.Error("Logarithmic depth is not compatible with orthographic cameras!",20),t.setFloat("logarithmicDepthConstant",2/(Math.log(o.maxZ+1)/Math.LN2))}},e.BindClipPlane=function(e,t){h.a.BindClipPlane(e,t)},e._TmpMorphInfluencers={NUM_MORPH_INFLUENCERS:0},e._tempFogColor=l.a.Black(),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=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,n){"use strict";var i,r,o,a,s,c,u;n.d(t,"a",(function(){return i})),n.d(t,"e",(function(){return r})),n.d(t,"d",(function(){return o})),n.d(t,"c",(function(){return a})),n.d(t,"b",(function(){return s})),n.d(t,"g",(function(){return c})),n.d(t,"f",(function(){return u})),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",e[e.DualSense=7]="DualSense"}(i||(i={})),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",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.Move=12]="Move"}(r||(r={})),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",e[e.MouseWheelX=7]="MouseWheelX",e[e.MouseWheelY=8]="MouseWheelY",e[e.MouseWheelZ=9]="MouseWheelZ",e[e.DeltaHorizontal=10]="DeltaHorizontal",e[e.DeltaVertical=11]="DeltaVertical"}(o||(o={})),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"}(a||(a={})),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.Create=8]="Create",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"}(s||(s={})),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"}(c||(c={})),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"}(u||(u={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o}));var i=n(2),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_DEPTHPEELINGRENDERER="DepthPeelingRenderer",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_PREPASS=0,e.STEP_BEFORECAMERADRAW_EFFECTLAYER=1,e.STEP_BEFORECAMERADRAW_LAYER=2,e.STEP_BEFORERENDERTARGETDRAW_PREPASS=0,e.STEP_BEFORERENDERTARGETDRAW_LAYER=1,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_PREPASS=0,e.STEP_AFTERRENDERTARGETDRAW_LAYER=1,e.STEP_AFTERCAMERADRAW_PREPASS=0,e.STEP_AFTERCAMERADRAW_EFFECTLAYER=1,e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=2,e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=3,e.STEP_AFTERCAMERADRAW_LAYER=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_BEFORERENDERTARGETCLEARSTAGE_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(i.d)(t,e),t.Create=function(){return Object.create(t.prototype)},t.prototype.registerStep=function(e,t,n){var i=0;for(Number.MAX_VALUE;i0))return[3,4];f=null!==(R=null==p?void 0:p.length)&&void 0!==R?R:0,p||(p=new Array(h)),p.length!==h&&(Array.isArray(p)?p.length=h:((_=r||p instanceof Uint32Array?new Uint32Array(h):new Uint16Array(h)).set(p),p=_),t&&t.determinant()<0&&e._FlipFaces(p,0,f)),m=this.positions?this.positions.length/3:0,g=0,v=n,i.label=1;case 1:if(!(gi.bbSize.y?i.bbSize.x:i.bbSize.y;$=$>i.bbSize.z?$:i.bbSize.z,N=i.subDiv.X*M/i.bbSize.x,L=i.subDiv.Y*M/i.bbSize.y,F=i.subDiv.Z*M/i.bbSize.z,w=i.subDiv.max*i.subDiv.max,i.facetPartitioning.length=0}for(o=0;oe.LongPressDelay&&!i._isPointerSwiping()&&(i._startingPointerTime=0,o.processTrigger(b.a.ACTION_OnLongPressTrigger,_.a.CreateNew(t.pickedMesh,n)))}),e.LongPressDelay)}}else for(var a=0,s=r._pointerDownStage;ae.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>e.DragMovementThreshold},e.prototype.simulatePointerUp=function(e,t,n){var i=new PointerEvent("pointerup",t);i.inputIndex=R.e.Move;var r=new P;n?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,i,S.a.POINTERUP)||this._processPointerUp(e,i,r)},e.prototype._processPointerUp=function(e,t,n){var i=this._scene;if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(i.onPointerPick&&i.onPointerPick(t,e),n.singleClick&&!n.ignore&&i.onPointerObservable.hasObservers())){var r=S.a.POINTERPICK,o=new S.b(r,t,e);this._setRayOnPointerInfo(o),i.onPointerObservable.notifyObservers(o,r)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!n.ignore){a.processTrigger(b.a.ACTION_OnPickUpTrigger,_.a.CreateNew(e.pickedMesh,t,e)),!n.hasSwiped&&n.singleClick&&a.processTrigger(b.a.ACTION_OnPickTrigger,_.a.CreateNew(e.pickedMesh,t,e));var s=e.pickedMesh._getActionManagerForTrigger(b.a.ACTION_OnDoublePickTrigger);n.doubleClick&&s&&s.processTrigger(b.a.ACTION_OnDoublePickTrigger,_.a.CreateNew(e.pickedMesh,t,e))}}else if(!n.ignore)for(var c=0,u=i._pointerUpStage;ce.DoubleClickDelay&&!o._doubleClickOccured||t!==o._previousButtonPressed)&&(o._doubleClickOccured=!1,n.singleClick=!0,n.ignore=!1,i(n,o._currentPickResult))},this._initClickEvent=function(t,n,i,r){var a=new P;o._currentPickResult=null;var s=null,c=t.hasSpecificMask(S.a.POINTERPICK)||n.hasSpecificMask(S.a.POINTERPICK)||t.hasSpecificMask(S.a.POINTERTAP)||n.hasSpecificMask(S.a.POINTERTAP)||t.hasSpecificMask(S.a.POINTERDOUBLETAP)||n.hasSpecificMask(S.a.POINTERDOUBLETAP);!c&&A.a&&(s=o._initActionManager(s,a))&&(c=s.hasPickTriggers);var u=!1;if(c){var l=i.button;if(a.hasSwiped=o._isPointerSwiping(),!a.hasSwiped){var h=!e.ExclusiveDoubleClickMode;h||(h=!t.hasSpecificMask(S.a.POINTERDOUBLETAP)&&!n.hasSpecificMask(S.a.POINTERDOUBLETAP))&&!A.a.HasSpecificTrigger(b.a.ACTION_OnDoublePickTrigger)&&(s=o._initActionManager(s,a))&&(h=!s.hasSpecificTrigger(b.a.ACTION_OnDoublePickTrigger)),h?(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay||l!==o._previousButtonPressed)&&(a.singleClick=!0,r(a,o._currentPickResult),u=!0):(o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,o._delayedSimpleClickTimeout=window.setTimeout(o._delayedSimpleClick.bind(o,l,a,r),e.DoubleClickDelay));var d=t.hasSpecificMask(S.a.POINTERDOUBLETAP)||n.hasSpecificMask(S.a.POINTERDOUBLETAP);!d&&A.a.HasSpecificTrigger(b.a.ACTION_OnDoublePickTrigger)&&(s=o._initActionManager(s,a))&&(d=s.hasSpecificTrigger(b.a.ACTION_OnDoublePickTrigger)),d&&(l===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTime0||(o._pointerCaptures[e.pointerId]=!1,(a.cameraToUseForPointers||a.activeCamera)&&(a.pointerUpPredicate||(a.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(!a.cameraToUseForPointers||0!=(a.cameraToUseForPointers.layerMask&e.layerMask))}),!o._meshPickProceed&&(A.a&&A.a.HasTriggers||a.onPointerObservable.hasObservers())&&o._initActionManager(null,t),n||(n=o._currentPickResult),o._processPointerUp(n,e,t),o._previousPickResult=o._currentPickResult))})))},this._onKeyDown=function(e){var t=x.a.KEYDOWN;if(a.onPreKeyboardObservable.hasObservers()){var n=new x.c(t,e);if(a.onPreKeyboardObservable.notifyObservers(n,t),n.skipOnKeyboardObservable)return}if(a.onKeyboardObservable.hasObservers()){n=new x.b(t,e);a.onKeyboardObservable.notifyObservers(n,t)}a.actionManager&&a.actionManager.processTrigger(b.a.ACTION_OnKeyDownTrigger,_.a.CreateNewFromScene(a,e))},this._onKeyUp=function(e){var t=x.a.KEYUP;if(a.onPreKeyboardObservable.hasObservers()){var n=new x.c(t,e);if(a.onPreKeyboardObservable.notifyObservers(n,t),n.skipOnKeyboardObservable)return}if(a.onKeyboardObservable.hasObservers()){n=new x.b(t,e);a.onKeyboardObservable.notifyObservers(n,t)}a.actionManager&&a.actionManager.processTrigger(b.a.ACTION_OnKeyUpTrigger,_.a.CreateNewFromScene(a,e))},this._deviceSourceManager.onDeviceConnectedObservable.add((function(e){e.deviceType===R.a.Mouse?e.onInputChangedObservable.add((function(r){if(r.inputIndex===R.e.LeftClick||r.inputIndex===R.e.MiddleClick||r.inputIndex===R.e.RightClick){var a=r;n&&1===e.getInput(a.inputIndex)?o._onPointerDown(a):t&&0===e.getInput(a.inputIndex)&&o._onPointerUp(a)}else i&&(r.inputIndex===R.e.Move?o._onPointerMove(r):r.inputIndex!==R.e.MouseWheelX&&r.inputIndex!==R.e.MouseWheelY&&r.inputIndex!==R.e.MouseWheelZ||o._onPointerMove(r))})):e.deviceType===R.a.Touch?e.onInputChangedObservable.add((function(r){var a=r;r.inputIndex===R.e.LeftClick&&(n&&1===e.getInput(a.inputIndex)?o._onPointerDown(r):t&&0===e.getInput(a.inputIndex)&&o._onPointerUp(r)),i&&r.inputIndex===R.e.Move&&o._onPointerMove(r)})):e.deviceType===R.a.Keyboard&&e.onInputChangedObservable.add((function(e){var t=e;"keydown"===t.type?o._onKeyDown(t):"keyup"===t.type&&o._onKeyUp(t)}))})),this._alreadyAttached=!0},e.prototype.detachControl=function(){this._alreadyAttached&&(this._deviceSourceManager.dispose(),this._deviceSourceManager=null,this._alreadyAttachedTo&&!this._scene.doNotHandleCursors&&(this._alreadyAttachedTo.style.cursor=this._scene.defaultCursor),this._alreadyAttached=!1,this._alreadyAttachedTo=null)},e.prototype.setPointerOverMesh=function(e,t,n){if(void 0===t&&(t=0),this._meshUnderPointerId[t]!==e){var i,r=this._meshUnderPointerId[t];r&&(i=r._getActionManagerForTrigger(b.a.ACTION_OnPointerOutTrigger))&&i.processTrigger(b.a.ACTION_OnPointerOutTrigger,_.a.CreateNew(r,void 0,{pointerId:t})),e?(this._meshUnderPointerId[t]=e,this._pointerOverMesh=e,(i=e._getActionManagerForTrigger(b.a.ACTION_OnPointerOverTrigger))&&i.processTrigger(b.a.ACTION_OnPointerOverTrigger,_.a.CreateNew(e,void 0,{pointerId:t,pickResult:n}))):(delete this._meshUnderPointerId[t],this._pointerOverMesh=null)}},e.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},e.prototype._invalidateMesh=function(e){for(var t in this._pointerOverMesh===e&&(this._pointerOverMesh=null),this._pickedDownMesh===e&&(this._pickedDownMesh=null),this._pickedUpMesh===e&&(this._pickedUpMesh=null),this._meshUnderPointerId)this._meshUnderPointerId[t]===e&&delete this._meshUnderPointerId[t]},e.DragMovementThreshold=10,e.LongPressDelay=500,e.DoubleClickDelay=300,e.ExclusiveDoubleClickMode=!1,e}(),M=n(61),I=n(8),D=n(104),N=n(141),L=n(55),F=n(70),w=n(150),B=n(175),U=function(e){function t(n,r){var o=e.call(this)||this;o._inputManager=new O(o),o.cameraToUseForPointers=null,o._isScene=!0,o._blockEntityCollection=!1,o.autoClear=!0,o.autoClearDepthAndStencil=!0,o.clearColor=new I.b(.2,.2,.3,1),o.ambientColor=new I.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.skipPointerMovePicking=!1,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 I.a(.2,.2,.3),o.fogDensity=.1,o.fogStart=0,o.fogEnd=1e3,o.needsPreviousWorldMatrices=!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 l.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 M.a,o._activeIndices=new M.a,o._activeParticles=new M.a,o._activeBones=new M.a,o._animationTime=0,o.animationTimeScale=1,o._renderId=0,o._frameId=0,o._executeWhenReadyTimeoutId=null,o._intermediateRendering=!1,o._defaultFrameBufferCleared=!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=l.a.Zero(),o.requireLightSorting=!1,o._components=[],o._serializableComponents=[],o._transientComponents=[],o._beforeCameraUpdateStage=v.b.Create(),o._beforeClearStage=v.b.Create(),o._beforeRenderTargetClearStage=v.b.Create(),o._gatherRenderTargetsStage=v.b.Create(),o._gatherActiveCameraRenderTargetsStage=v.b.Create(),o._isReadyForMeshStage=v.b.Create(),o._beforeEvaluateActiveMeshStage=v.b.Create(),o._evaluateSubMeshStage=v.b.Create(),o._preActiveMeshStage=v.b.Create(),o._cameraDrawRenderTargetStage=v.b.Create(),o._beforeCameraDrawStage=v.b.Create(),o._beforeRenderTargetDrawStage=v.b.Create(),o._beforeRenderingGroupDrawStage=v.b.Create(),o._beforeRenderingMeshStage=v.b.Create(),o._afterRenderingMeshStage=v.b.Create(),o._afterRenderingGroupDrawStage=v.b.Create(),o._afterCameraDrawStage=v.b.Create(),o._afterRenderTargetDrawStage=v.b.Create(),o._afterRenderStage=v.b.Create(),o._pointerMoveStage=v.b.Create(),o._pointerDownStage=v.b.Create(),o._pointerUpStage=v.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,o._perfCollector=null,o.onComputePressureChanged=new a.c;var c=Object(i.a)({useGeometryUniqueIdsMap:!0,useMaterialMeshMap:!0,useClonedMeshMap:!0,virtual:!1},r);return o._engine=n||T.a.LastCreatedEngine,c.virtual?o._engine._virtualScenes.push(o):(T.a._LastCreatedScene=o,o._engine.scenes.push(o)),o._uid=null,o._renderingManager=new g.b(o),m.a&&(o.postProcessManager=new m.a(o)),Object(y.e)()&&o.attachControl(),o._createUbo(),d.a&&(o._imageProcessingConfiguration=new d.a),o.setDefaultCandidateProviders(),c.useGeometryUniqueIdsMap&&(o.geometriesByUniqueId={}),o.useMaterialMeshMap=c.useMaterialMeshMap,o.useClonedMeshMap=c.useClonedMeshMap,r&&r.virtual||o._engine.onNewSceneAddedObservable.notifyObservers(o),w.a.IsAvailable&&(o._computePressureObserver=new w.a((function(e){o.onComputePressureChanged.notifyObservers(e)}),{cpuUtilizationThresholds:[.25,.5,.75,.9],cpuSpeedThresholds:[.5]}),o._computePressureObserver.observe()),o}return Object(i.d)(t,e),t.DefaultMaterialFactory=function(e){throw Object(E.a)("StandardMaterial")},t.CollisionCoordinatorFactory=function(){throw Object(E.a)("DefaultCollisionCoordinator")},Object.defineProperty(t.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(b.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(b.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(b.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 O.DragMovementThreshold},set:function(e){O.DragMovementThreshold=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LongPressDelay",{get:function(){return O.LongPressDelay},set:function(e){O.LongPressDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DoubleClickDelay",{get:function(){return O.DoubleClickDelay},set:function(e){O.DoubleClickDelay=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ExclusiveDoubleClickMode",{get:function(){return O.ExclusiveDoubleClickMode},set:function(e){O.ExclusiveDoubleClickMode=e},enumerable:!1,configurable:!0}),t.prototype.bindEyePosition=function(e,t,n){var i;void 0===t&&(t="vEyePosition"),void 0===n&&(n=!1);var r=this._forcedViewPosition?this._forcedViewPosition:this._mirroredCameraPosition?this._mirroredCameraPosition:null!==(i=this.activeCamera.globalPosition)&&void 0!==i?i:this.activeCamera.devicePosition,o=this.useRightHandedSystem===(null!=this._mirroredCameraPosition);return l.c.Vector4[0].set(r.x,r.y,r.z,o?-1:1),e&&(n?e.setFloat3(t,l.c.Vector4[0].x,l.c.Vector4[0].y,l.c.Vector4[0].z):e.setVector4(t,l.c.Vector4[0])),l.c.Vector4[0]},t.prototype.finalizeSceneUbo=function(){var e=this.getSceneUniformBuffer(),t=this.bindEyePosition(null);return e.updateFloat4("vEyePosition",t.x,t.y,t.z,t.w),e.update(),e},Object.defineProperty(t.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(b.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(b.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(b.a.MATERIAL_MiscDirtyFlag))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"prePass",{get:function(){return!!this.prePassRenderer&&this.prePassRenderer.defaultRT.enabled},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(b.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(b.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(b.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(b.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;e0)return!1;for(e&&(this._processedMaterials.reset(),this._renderTargets.reset()),t=0;t0,o=0,a=this._isReadyForMeshStage;o0)for(var h=0,d=this.activeCameras;h0},enumerable:!1,configurable:!0}),t.prototype.executeWhenReady=function(e,t){var n=this;void 0===t&&(t=!1),this.onReadyObservable.add(e),null===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){n._checkIsReady(t)}),150))},t.prototype.whenReadyAsync=function(e){var t=this;return void 0===e&&(e=!1),new Promise((function(n){t.executeWhenReady((function(){n()}),e)}))},t.prototype._checkIsReady=function(e){var t=this;return void 0===e&&(e=!1),this._registerTransientComponents(),this.isReady(e)?(this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):this._isDisposed?(this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=null)):void(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady(e)}),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,n,i){n||i||!this._multiviewSceneUbo||(this._multiviewSceneUbo.dispose(),this._multiviewSceneUbo=null),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?D.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=D.a.GetPlanes(this._transformMatrix),this._multiviewSceneUbo&&this._multiviewSceneUbo.useUbo?this._updateMultiviewUbo(n,i):this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.updateMatrix("projection",this._projectionMatrix)))},t.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},t.prototype.createSceneUniformBuffer=function(e){var t=new p.a(this._engine,void 0,!1,null!=e?e:"scene");return t.addUniform("viewProjection",16),t.addUniform("view",16),t.addUniform("projection",16),t.addUniform("vEyePosition",4),t},t.prototype.setSceneUniformBuffer=function(e){this._sceneUbo=e,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1},t.prototype.getUniqueId=function(){return N.a.UniqueId},t.prototype.addMesh=function(e,t){var n=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){n.addMesh(e)})))},t.prototype.removeMesh=function(e,t){var n=this;void 0===t&&(t=!1);var i=this.meshes.indexOf(e);return-1!==i&&(this.meshes[i]=this.meshes[this.meshes.length-1],this.meshes.pop(),e.parent||e._removeFromSceneRootNodes()),this._inputManager._invalidateMesh(e),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){n.removeMesh(e)})),i},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 n=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=n,n._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),this._executeActiveContainerCleanup(this._activeSkeletons)),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 n=0,i=this.meshes;n0?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),this._executeActiveContainerCleanup(this._activeParticleSystems)),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,n){},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=0;n--)if(this.materials[n].id===e)return this.materials[n];if(t)for(n=this.multiMaterials.length-1;n>=0;n--)if(this.multiMaterials[n].id===e)return this.multiMaterials[n];return null},t.prototype.getMaterialByName=function(e){for(var t=0;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 n=this.getTransformNodeById(e);if(n)return n;var i=this.getLightById(e);if(i)return i;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 n=this.getTransformNodeByName(e);if(n)return n;var i=this.getLightByName(e);if(i)return i;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=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},t.prototype.getSkeletonByUniqueId=function(e){for(var t=0;t0&&(null===(e=this.activeCamera)||void 0===e||e._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset());else if(this._activeMeshesFrozen&&this._activeMeshes.length){if(!this._skipEvaluateActiveMeshesCompletely)for(var t=this._activeMeshes.length,n=0;n0&&0!=(c.layerMask&this.activeCamera.layerMask)&&(this._skipFrustumClipping||c.alwaysSelectAsActiveMesh||c.isInFrustum(this._frustumPlanes)))){this._activeMeshes.push(c),this.activeCamera._activeMeshes.push(c),u!==c&&u._activate(this._renderId,!1);for(var l=0,h=this._preActiveMeshStage;l0)for(var n=this.getActiveSubMeshCandidates(t),i=n.length,r=0;r0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),this.environmentTexture&&this.environmentTexture.isRenderTarget&&this._renderTargets.pushNoDuplicate(this.environmentTexture);for(var h=0,d=this._gatherActiveCameraRenderTargetsStage;h0){r.b.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var f=0;f0),this._renderId++}for(var g=0,v=this._cameraDrawRenderTargetStage;g-1&&(i.trigger===b.a.ACTION_OnIntersectionExitTrigger&&i._executeCurrent(_.a.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(b.a.ACTION_OnIntersectionExitTrigger,(function(e){var t=e.mesh?e.mesh:e;return o===t}))&&i.trigger!==b.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,n=this._engine.getTimeStep(),i=1e3/n/1e3,r=0,o=this._engine.getLockstepMaxSteps(),a=Math.floor(e/n);for(a=Math.min(a,o);e>0&&r0)for(var c=0;c0),this._intermediateRendering=!0;for(var p=0;p0),this._intermediateRendering=!1,this._renderId++}this._engine.currentRenderPassId=null!==(o=null==d?void 0:d.renderPassId)&&void 0!==o?o:b.a.RENDERPASS_MAIN,this.activeCamera=d,this._activeCamera&&this._activeCamera.cameraRigMode!==b.a.RIG_MODE_CUSTOM&&!this.prePass&&this._bindFrameBuffer(this._activeCamera,!1),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var _=0,m=this._beforeClearStage;_0)for(c=0;c0);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera,!!this.activeCamera.outputRenderTarget)}this._checkIntersections();for(var y=0,T=this._afterRenderStage;y-1&&this._engine.scenes.splice(i,1),T.a._LastCreatedScene===this&&(this._engine.scenes.length>0?T.a._LastCreatedScene=this._engine.scenes[this._engine.scenes.length-1]:T.a._LastCreatedScene=null),(i=this._engine._virtualScenes.indexOf(this))>-1&&this._engine._virtualScenes.splice(i,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;e0)if(parseInt(C[C.length-1])>=R)continue}for(var P=0,O=E;P1?new g.a:new m,this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent);var L="Babylon.js v".concat(e.Version);console.log(L+" - ".concat(this.description)),this._renderingCanvas&&this._renderingCanvas.setAttribute&&this._renderingCanvas.setAttribute("data-engine",L)}}return Object.defineProperty(e,"NpmPackage",{get:function(){return"babylonjs@5.0.0-rc.3"},enumerable:!1,configurable:!0}),Object.defineProperty(e,"Version",{get:function(){return"5.0.0-rc.3"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"description",{get:function(){var e=this.name+this.webGLVersion;return this._caps.parallelShaderCompile&&(e+=" - Parallel shader compilation"),e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"version",{get:function(){return this._webGLVersion},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShadersRepository",{get:function(){return o.a.ShadersRepository},set:function(e){o.a.ShadersRepository=e},enumerable:!1,configurable:!0}),e.prototype._getShaderProcessor=function(e){return this._shaderProcessor},Object.defineProperty(e.prototype,"useReverseDepthBuffer",{get:function(){return this._useReverseDepthBuffer},set:function(e){e!==this._useReverseDepthBuffer&&(this._useReverseDepthBuffer=e,this._depthCullingState.depthFunc=e?h.a.GEQUAL:h.a.LEQUAL)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"frameId",{get:function(){return this._frameId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!1,configurable:!0}),e.prototype.getCreationOptions=function(){return this._creationOptions},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,"activeRenderLoops",{get:function(){return this._activeRenderLoops},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,h.a.TEXTUREFORMAT_RGBA,!1,!1,h.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,h.a.TEXTUREFORMAT_RGBA,!1,!1,h.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,h.a.TEXTUREFORMAT_RGBA,!1,!1,h.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,h.a.TEXTUREFORMAT_RGBA,h.a.TEXTURETYPE_UNSIGNED_INT,!1,!1,h.a.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isWebGPU",{get:function(){return this._isWebGPU},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shaderPlatformName",{get:function(){return this._shaderPlatformName},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"snapshotRendering",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"snapshotRenderingMode",{get:function(){return this._snapshotRenderingMode},set:function(e){this._snapshotRenderingMode=e},enumerable:!1,configurable:!0}),e.prototype.snapshotRenderingReset=function(){this.snapshotRendering=!1},e._createCanvas=function(e,t){if("undefined"==typeof document)return new OffscreenCanvas(e,t);var n=document.createElement("canvas");return n.width=e,n.height=t,n},e.prototype.createCanvas=function(t,n){return e._createCanvas(t,n)},e.prototype.createCanvasImage=function(){return document.createElement("img")},e.prototype._restoreEngineAfterContextLost=function(e){var t=this;setTimeout((function(){return Object(i.b)(t,void 0,void 0,(function(){var t,n,r,o,a;return Object(i.e)(this,(function(i){switch(i.label){case 0:return this._dummyFramebuffer=null,t=this._depthCullingState.depthTest,n=this._depthCullingState.depthFunc,r=this._depthCullingState.depthMask,o=this._stencilState.stencilTest,[4,e()];case 1:return i.sent(),this._rebuildEffects(),null===(a=this._rebuildComputeEffects)||void 0===a||a.call(this),this._rebuildInternalTextures(),this._rebuildRenderTargetWrappers(),this._rebuildBuffers(),this.wipeCaches(!0),this._depthCullingState.depthTest=t,this._depthCullingState.depthFunc=n,this._depthCullingState.depthMask=r,this._stencilState.stencilTest=o,p.a.Warn(this.name+" context successfully restored."),this.onContextRestoredObservable.notifyObservers(this),this._contextWasLost=!1,[2]}}))}))}),0)},e.prototype._sharedInit=function(e,t,n){this._renderingCanvas=e},e.prototype._getShaderProcessingContext=function(e){return null},e.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e1?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")||void 0,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"),s3tc_srgb:this._gl.getExtension("WEBGL_compressed_texture_s3tc_srgb")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc_srgb"),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"),supportOcclusionQuery:this._webGLVersion>1,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,canUseGLInstanceID:this._webGLVersion>1,canUseGLVertexID:this._webGLVersion>1,supportComputeShaders:!1,supportSRGBBuffers:!1,supportTransformFeedbacks:this._webGLVersion>1,textureMaxLevel:this._webGLVersion>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=this._gl.getParameter(this._gl.VENDOR)||"Unknown vendor"),this._glRenderer||(this._glRenderer=this._gl.getParameter(this._gl.RENDERER)||"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._caps.astc&&(this._gl.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR=this._caps.astc.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR),this._caps.bptc&&(this._gl.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT=this._caps.bptc.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT),this._caps.s3tc_srgb&&(this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT,this._gl.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT=this._caps.s3tc_srgb.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT),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 n=0;n<16;n++)this._gl["COLOR_ATTACHMENT"+n+"_WEBGL"]=t["COLOR_ATTACHMENT"+n+"_WEBGL"]}}if(this._webGLVersion>1)this._caps.depthTextureExtension=!0;else{var i=this._gl.getExtension("WEBGL_depth_texture");null!=i&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=i.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)}if(!this._caps.supportSRGBBuffers){if(this._webGLVersion>1)this._caps.supportSRGBBuffers=!0;else{var u=this._gl.getExtension("EXT_sRGB");null!=u&&(this._caps.supportSRGBBuffers=!0,this._gl.SRGB=u.SRGB_EXT,this._gl.SRGB8=u.SRGB_ALPHA_EXT,this._gl.SRGB8_ALPHA8=u.SRGB_ALPHA_EXT)}this._caps.supportSRGBBuffers=this._caps.supportSRGBBuffers&&!(!this._creationOptions||!this._creationOptions.forceSRGBBufferSupportState)}this._depthCullingState.depthTest=!0,this._depthCullingState.depthFunc=this._gl.LEQUAL,this._depthCullingState.depthMask=!0,this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var l=0;l=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;t0?this._frameHandler=this._queueNewFrame(this._boundRenderFunction,this.getHostWindow()):this._renderingQueueLaunched=!1},e.prototype.getRenderingCanvas=function(){return this._renderingCanvas},e.prototype.getAudioContext=function(){return this._audioContext},e.prototype.getAudioDestination=function(){return this._audioDestination},e.prototype.getHostWindow=function(){return Object(f.e)()?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,n){return e.QueueNewFrame(t,n)},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,n,i){void 0===i&&(i=!1);var r=this.stencilStateComposer.useStencilGlobalOnly;this.stencilStateComposer.useStencilGlobalOnly=!0,this.applyStates(),this.stencilStateComposer.useStencilGlobalOnly=r;var o=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),o|=this._gl.COLOR_BUFFER_BIT),n&&(this.useReverseDepthBuffer?(this._depthCullingState.depthFunc=this._gl.GEQUAL,this._gl.clearDepth(0)):this._gl.clearDepth(1),o|=this._gl.DEPTH_BUFFER_BIT),i&&(this._gl.clearStencil(0),o|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(o)},e.prototype._viewport=function(e,t,n,i){e===this._viewportCached.x&&t===this._viewportCached.y&&n===this._viewportCached.z&&i===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=n,this._viewportCached.w=i,this._gl.viewport(e,t,n,i))},e.prototype.setViewport=function(e,t,n){var i=t||this.getRenderWidth(),r=n||this.getRenderHeight(),o=e.x||0,a=e.y||0;this._cachedViewport=e,this._viewport(o*i,a*r,i*e.width,r*e.height)},e.prototype.beginFrame=function(){},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._frameId++},e.prototype.resize=function(e){var t,n;if(void 0===e&&(e=!1),this._adaptToDeviceRatio){var i=Object(f.e)()&&window.devicePixelRatio||1,r=this._creationOptions.limitDeviceRatio||i;this._hardwareScalingLevel=this._adaptToDeviceRatio?1/Math.min(r,i):1}Object(f.e)()?(t=this._renderingCanvas?this._renderingCanvas.clientWidth||this._renderingCanvas.width:window.innerWidth,n=this._renderingCanvas?this._renderingCanvas.clientHeight||this._renderingCanvas.height:window.innerHeight):(t=this._renderingCanvas?this._renderingCanvas.width:100,n=this._renderingCanvas?this._renderingCanvas.height:100),this.setSize(t/this._hardwareScalingLevel,n/this._hardwareScalingLevel,e)},e.prototype.setSize=function(e,t,n){return void 0===n&&(n=!1),!!this._renderingCanvas&&(e|=0,t|=0,!(!n&&this._renderingCanvas.width===e&&this._renderingCanvas.height===t)&&(this._renderingCanvas.width=e,this._renderingCanvas.height=t,!0))},e.prototype.bindFramebuffer=function(e,t,n,i,r,o,a){var s,c,u,l,h;void 0===t&&(t=0),void 0===o&&(o=0),void 0===a&&(a=0);var d=e;this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._bindUnboundFramebuffer(d._MSAAFramebuffer?d._MSAAFramebuffer:d._framebuffer);var p=this._gl;e.is2DArray?p.framebufferTextureLayer(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,null===(s=e.texture._hardwareTexture)||void 0===s?void 0:s.underlyingResource,o,a):e.isCube&&p.framebufferTexture2D(p.FRAMEBUFFER,p.COLOR_ATTACHMENT0,p.TEXTURE_CUBE_MAP_POSITIVE_X+t,null===(c=e.texture._hardwareTexture)||void 0===c?void 0:c.underlyingResource,o);var f=e._depthStencilTexture;if(f){var _=e._depthStencilTextureWithStencil?p.DEPTH_STENCIL_ATTACHMENT:p.DEPTH_ATTACHMENT;e.is2DArray?p.framebufferTextureLayer(p.FRAMEBUFFER,_,null===(u=f._hardwareTexture)||void 0===u?void 0:u.underlyingResource,o,a):e.isCube?p.framebufferTexture2D(p.FRAMEBUFFER,_,p.TEXTURE_CUBE_MAP_POSITIVE_X+t,null===(l=f._hardwareTexture)||void 0===l?void 0:l.underlyingResource,o):p.framebufferTexture2D(p.FRAMEBUFFER,_,p.TEXTURE_2D,null===(h=f._hardwareTexture)||void 0===h?void 0:h.underlyingResource,o)}this._cachedViewport&&!r?this.setViewport(this._cachedViewport,n,i):(n||(n=e.width,o&&(n/=Math.pow(2,o))),i||(i=e.height,o&&(i/=Math.pow(2,o))),this._viewport(0,0,n,i)),this.wipeCaches()},e.prototype.setState=function(e,t,n,i,r,o,a){var s,c;void 0===t&&(t=0),void 0===i&&(i=!1),void 0===a&&(a=0),(this._depthCullingState.cull!==e||n)&&(this._depthCullingState.cull=e);var u=null===(c=null!==(s=this.cullBackFaces)&&void 0!==s?s:r)||void 0===c||c?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==u||n)&&(this._depthCullingState.cullFace=u),this.setZOffset(t),this.setZOffsetUnits(a);var l=i?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==l||n)&&(this._depthCullingState.frontFace=l),this._stencilStateComposer.stencilMaterial=o},e.prototype.setZOffset=function(e){this._depthCullingState.zOffset=this.useReverseDepthBuffer?-e:e},e.prototype.getZOffset=function(){var e=this._depthCullingState.zOffset;return this.useReverseDepthBuffer?-e:e},e.prototype.setZOffsetUnits=function(e){this._depthCullingState.zOffsetUnits=this.useReverseDepthBuffer?-e:e},e.prototype.getZOffsetUnits=function(){var e=this._depthCullingState.zOffsetUnits;return this.useReverseDepthBuffer?-e:e},e.prototype._bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},e.prototype._currentFrameBufferIsDefaultFrameBuffer=function(){return null===this._currentFramebuffer},e.prototype.generateMipmaps=function(e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)},e.prototype.unBindFramebuffer=function(e,t,n){var i;void 0===t&&(t=!1);var r=e;this._currentRenderTarget=null;var o=this._gl;if(r._MSAAFramebuffer){if(e.isMulti)return void this.unBindMultiColorAttachmentFramebuffer(e,t,n);o.bindFramebuffer(o.READ_FRAMEBUFFER,r._MSAAFramebuffer),o.bindFramebuffer(o.DRAW_FRAMEBUFFER,r._framebuffer),o.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,o.COLOR_BUFFER_BIT,o.NEAREST)}!(null===(i=e.texture)||void 0===i?void 0:i.generateMipMaps)||t||e.isCube||this.generateMipmaps(e.texture),n&&(r._MSAAFramebuffer&&this._bindUnboundFramebuffer(r._framebuffer),n()),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 n=this._gl.createBuffer();if(!n)throw new Error("Unable to create vertex buffer");var i=new v.a(n);return this.bindArrayBuffer(i),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),t):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,t),this._resetVertexBufferBinding(),i.references=1,i},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 n=this._gl.createBuffer(),i=new v.a(n);if(!n)throw new Error("Unable to create index buffer");this.bindIndexBuffer(i);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(),i.references=1,i.is32Bits=4===r.BYTES_PER_ELEMENT,i},e.prototype._normalizeIndexData=function(e){if(2===e.BYTES_PER_ELEMENT)return e;if(this._caps.uintIndices){if(e instanceof Uint32Array)return e;for(var t=0;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,n){var i=e.program,r=this._gl.getUniformBlockIndex(i,t);this._gl.uniformBlockBinding(i,r,n)},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,n,i,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!==n&&(s.size=n,c=!0),s.type!==i&&(s.type=i,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=n,s.type=i,s.normalized=r,s.stride=o,s.offset=a,s.buffer=e),(c||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,n,i,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,n){var i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var r=0;r=0){var a=i[r],s=null;if(n&&(s=n[a]),s||(s=e[a]),!s)continue;this._gl.enableVertexAttribArray(o),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[o]=!0);var c=s.getBuffer();c&&(this._vertexAttribPointer(c,o,s.getSize(),s.type,s.normalized,s.byteStride,s.byteOffset),s.getIsInstanced()&&(this._gl.vertexAttribDivisor(o,s.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(o),this._currentInstanceBuffers.push(c))))}}},e.prototype.recordVertexArrayObject=function(e,t,n,i){var r=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,n,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r},e.prototype.bindVertexArrayObject=function(e,t){this._cachedVertexArrayObject!==e&&(this._cachedVertexArrayObject=e,this._gl.bindVertexArray(e),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._uintIndicesCurrentlySet=null!=t&&t.is32Bits,this._mustWipeVertexAttributes=!0)},e.prototype.bindBuffersDirectly=function(e,t,n,i,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=0&&(this._gl.enableVertexAttribArray(c),this._vertexAttribArraysEnabled[c]=!0,this._vertexAttribPointer(e,c,n[s],this._gl.FLOAT,!1,i,a)),a+=4*n[s]}}this._bindIndexBufferWithCache(t)},e.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},e.prototype.bindBuffers=function(e,t,n,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===n||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n,this._bindVertexBuffersAttributes(e,n,i)),this._bindIndexBufferWithCache(t)},e.prototype.unbindInstanceAttributes=function(){for(var e,t=0,n=this._currentInstanceLocations.length;t1?"#version 300 es\n#define WEBGL2 \n":"",s=this._compileShader(t,"vertex",i,a),c=this._compileShader(n,"fragment",i,a);return this._createShaderProgram(e,s,c,r,o)},e.prototype.inlineShaderCode=function(e){return e},e.prototype.createPipelineContext=function(e){var t=new b.a;return t.engine=this,this._caps.parallelShaderCompile&&(t.isParallelCompiled=!0),t},e.prototype.createMaterialContext=function(){},e.prototype.createDrawContext=function(){},e.prototype._createShaderProgram=function(e,t,n,i,r){void 0===r&&(r=null);var o=i.createProgram();if(e.program=o,!o)throw new Error("Unable to create program");return i.attachShader(o,t),i.attachShader(o,n),i.linkProgram(o),e.context=i,e.vertexShader=t,e.fragmentShader=n,e.isParallelCompiled||this._finalizePipelineContext(e),o},e.prototype._finalizePipelineContext=function(e){var t=e.context,n=e.vertexShader,i=e.fragmentShader,r=e.program;if(!t.getProgramParameter(r,t.LINK_STATUS)){var o,a;if(!this._gl.getShaderParameter(n,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(n))throw e.vertexCompilationError=o,new Error("VERTEX SHADER "+o);if(!this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(i))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(n),t.deleteShader(i),e.vertexShader=void 0,e.fragmentShader=void 0,e.onCompiled&&(e.onCompiled(),e.onCompiled=void 0)},e.prototype._preparePipelineContext=function(e,t,n,i,r,o,a,s,c,u){var l=e;l.program=i?this.createRawShaderProgram(l,t,n,void 0,c):this.createShaderProgram(l,t,n,s,void 0,c),l.program.__SPECTOR_rebuildProgram=a},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 n=e;if(n.isParallelCompiled){var i=n.onCompiled;n.onCompiled=i?function(){i(),t()}:t}else t()},e.prototype.getUniforms=function(e,t){for(var n=new Array,i=e,r=0;r1||this.isWebGPU||t)},e.prototype._createTextureBase=function(t,n,i,o,a,s,c,u,l,f,_,m,g,v,b,y){var T=this;void 0===a&&(a=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===c&&(c=null),void 0===f&&(f=null),void 0===_&&(_=null),void 0===m&&(m=null),void 0===g&&(g=null);var E="data:"===(t=t||"").substr(0,5),S="blob:"===t.substr(0,5),A=E&&-1!==t.indexOf(";base64,"),x=_||new d.a(this,d.b.Url),R=t;!this._transformTextureUrl||A||_||f||(t=this._transformTextureUrl(t)),R!==t&&(x._originalUrl=R);var C=t.lastIndexOf("."),P=g||(C>-1?t.substring(C).toLowerCase():""),O=null;P.indexOf("?")>-1&&(P=P.split("?")[0]);for(var M=0,I=e._TextureLoaders;Mp||n.height>p||!g._supportsHardwareTextureRescaling)return g._prepareWorkingCanvas(),!(!g._workingCanvas||!g._workingContext)&&(g._workingCanvas.width=e,g._workingCanvas.height=t,g._workingContext.drawImage(n,0,0,n.width,n.height,0,0,e,t),s.texImage2D(s.TEXTURE_2D,0,l,h,s.UNSIGNED_BYTE,g._workingCanvas),o.width=e,o.height=t,!1);var f=new d.a(g,d.b.Temp);return g._bindTextureDirectly(s.TEXTURE_2D,f,!0),s.texImage2D(s.TEXTURE_2D,0,l,h,s.UNSIGNED_BYTE,n),g._rescaleTexture(f,o,i,l,(function(){g._releaseTexture(f),g._bindTextureDirectly(s.TEXTURE_2D,o,!0),a()})),!0}),s,c,u,l,p,f,m)},e._FileToolsLoadImage=function(e,t,n,i,r,o){throw Object(a.a)("FileTools")},e.prototype._rescaleTexture=function(e,t,n,i,r){},e.prototype.createRawTexture=function(e,t,n,i,r,o,s,c,u){throw void 0===c&&(c=null),void 0===u&&(u=h.a.TEXTURETYPE_UNSIGNED_INT),Object(a.a)("Engine.RawTexture")},e.prototype.createRawCubeTexture=function(e,t,n,i,r,o,s,c){throw void 0===c&&(c=null),Object(a.a)("Engine.RawTexture")},e.prototype.createRawTexture3D=function(e,t,n,i,r,o,s,c,u,l){throw void 0===u&&(u=null),void 0===l&&(l=h.a.TEXTURETYPE_UNSIGNED_INT),Object(a.a)("Engine.RawTexture")},e.prototype.createRawTexture2DArray=function(e,t,n,i,r,o,s,c,u,l){throw void 0===u&&(u=null),void 0===l&&(l=h.a.TEXTURETYPE_UNSIGNED_INT),Object(a.a)("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,n){void 0===n&&(n=!1);var i=this._getTextureTarget(t),r=this._getSamplingParameters(e,t.generateMipMaps||n);this._setTextureParameterInteger(i,this._gl.TEXTURE_MAG_FILTER,r.mag,t),this._setTextureParameterInteger(i,this._gl.TEXTURE_MIN_FILTER,r.min),n&&(t.generateMipMaps=!0,this._gl.generateMipmap(i)),this._bindTextureDirectly(i,null),t.samplingMode=e},e.prototype.updateTextureDimensions=function(e,t,n,i){void 0===i&&(i=1)},e.prototype.updateTextureWrappingMode=function(e,t,n,i){void 0===n&&(n=null),void 0===i&&(i=null);var r=this._getTextureTarget(e);null!==t&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t),e),e._cachedWrapU=t),null!==n&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(n),e),e._cachedWrapV=n),(e.is2DArray||e.is3D)&&null!==i&&(this._setTextureParameterInteger(r,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(i),e),e._cachedWrapR=i),this._bindTextureDirectly(r,null)},e.prototype._setupDepthStencilTexture=function(e,t,n,i,r,o){void 0===o&&(o=1);var a=t.width||t,s=t.height||t,c=t.layers||0;e.baseWidth=a,e.baseHeight=s,e.width=a,e.height=s,e.is2DArray=c>0,e.depth=c,e.isReady=!0,e.samples=o,e.generateMipMaps=!1,e.samplingMode=i?h.a.TEXTURE_BILINEAR_SAMPLINGMODE:h.a.TEXTURE_NEAREST_SAMPLINGMODE,e.type=h.a.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=r;var u=this._gl,l=this._getTextureTarget(e),d=this._getSamplingParameters(e.samplingMode,!1);u.texParameteri(l,u.TEXTURE_MAG_FILTER,d.mag),u.texParameteri(l,u.TEXTURE_MIN_FILTER,d.min),u.texParameteri(l,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(l,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),0===r?(u.texParameteri(l,u.TEXTURE_COMPARE_FUNC,h.a.LEQUAL),u.texParameteri(l,u.TEXTURE_COMPARE_MODE,u.NONE)):(u.texParameteri(l,u.TEXTURE_COMPARE_FUNC,r),u.texParameteri(l,u.TEXTURE_COMPARE_MODE,u.COMPARE_REF_TO_TEXTURE))},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,n,i,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0);var s=this._gl,c=s.TEXTURE_2D;if(e.isCube&&(c=s.TEXTURE_CUBE_MAP_POSITIVE_X+o),e._useSRGBBuffer)switch(t){case h.a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:t=s.COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT;break;case h.a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:t=s.COMPRESSED_SRGB8_ALPHA8_ASTC_4x4_KHR;break;case h.a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:this._caps.s3tc_srgb?t=s.COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:e._useSRGBBuffer=!1;break;case h.a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:this._caps.s3tc_srgb?t=s.COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:e._useSRGBBuffer=!1;break;default:e._useSRGBBuffer=!1}this._gl.compressedTexImage2D(c,a,t,n,i,0,r)},e.prototype._uploadDataToTextureDirectly=function(e,t,n,i,r,o){void 0===n&&(n=0),void 0===i&&(i=0),void 0===o&&(o=!1);var a=this._gl,s=this._getWebGLTextureType(e.type),c=this._getInternalFormat(e.format),u=void 0===r?this._getRGBABufferInternalSizedFormat(e.type,e.format,e._useSRGBBuffer):this._getInternalFormat(r,e._useSRGBBuffer);this._unpackFlipY(e.invertY);var l=a.TEXTURE_2D;e.isCube&&(l=a.TEXTURE_CUBE_MAP_POSITIVE_X+n);var h=Math.round(Math.log(e.width)*Math.LOG2E),d=Math.round(Math.log(e.height)*Math.LOG2E),p=o?e.width:Math.pow(2,Math.max(h-i,0)),f=o?e.height:Math.pow(2,Math.max(d-i,0));a.texImage2D(l,i,u,p,f,0,c,s,t)},e.prototype.updateTextureData=function(e,t,n,i,r,o,a,s){void 0===a&&(a=0),void 0===s&&(s=0);var c=this._gl,u=this._getWebGLTextureType(e.type),l=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,n,i,r,o,l,u,t)},e.prototype._uploadArrayBufferViewToTexture=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0);var r=this._gl,o=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,n,i),this._bindTextureDirectly(o,null,!0)},e.prototype._prepareWebGLTextureContinuation=function(e,t,n,i,r){var o=this._gl;if(o){var a=this._getSamplingParameters(r,!n);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,a.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,a.min),n||i||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,n,i,r,o,a,s,c,u){var l=this;void 0===u&&(u=h.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,p=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(r.width,d):r.width),f=Math.min(d,this.needPOTTextures?e.GetExponentOfTwo(r.height,d):r.height),_=this._gl;_&&(t._hardwareTexture?(this._bindTextureDirectly(_.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=r.width,t.baseHeight=r.height,t.width=p,t.height=f,t.isReady=!0,c(p,f,r,n,t,(function(){l._prepareWebGLTextureContinuation(t,i,a,s,u)}))||this._prepareWebGLTextureContinuation(t,i,a,s,u)):i&&i._removePendingData(t))},e.prototype._setupFramebufferDepthAttachments=function(e,t,n,i,r){void 0===r&&(r=1);var o=this._gl;if(e&&t)return this._createRenderBuffer(n,i,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._createRenderBuffer(n,i,r,a,a,o.DEPTH_ATTACHMENT)}return e?this._createRenderBuffer(n,i,r,o.STENCIL_INDEX8,o.STENCIL_INDEX8,o.STENCIL_ATTACHMENT):null},e.prototype._createRenderBuffer=function(e,t,n,i,r,o,a){void 0===a&&(a=!0);var s=this._gl,c=s.createRenderbuffer();return s.bindRenderbuffer(s.RENDERBUFFER,c),n>1&&s.renderbufferStorageMultisample?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,r,e,t):s.renderbufferStorage(s.RENDERBUFFER,i,e,t),s.framebufferRenderbuffer(s.FRAMEBUFFER,o,s.RENDERBUFFER,c),a&&s.bindRenderbuffer(s.RENDERBUFFER,null),c},e.prototype._releaseTexture=function(e){var t;this._deleteTexture(null===(t=e._hardwareTexture)||void 0===t?void 0:t.underlyingResource),this.unbindAllTextures();var n=this._internalTexturesCache.indexOf(e);-1!==n&&this._internalTexturesCache.splice(n,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),e._irradianceTexture&&e._irradianceTexture.dispose()},e.prototype._releaseRenderTargetWrapper=function(e){var t=this._renderTargetWrapperCache.indexOf(e);-1!==t&&this._renderTargetWrapperCache.splice(t,1)},e.prototype._deleteTexture=function(e){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 n=e.getSamplers(),i=0;i-1;if(n&&s&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||i){if(this._activateCurrentTexture(),t&&t.isMultiview)throw console.error(e,t),"_bindTextureDirectly called with a multiview texture!";this._gl.bindTexture(e,null!==(o=null===(r=null==t?void 0:t._hardwareTexture)||void 0===r?void 0:r.underlyingResource)&&void 0!==o?o:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)}else n&&(a=!0,this._activateCurrentTexture());return s&&!n&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),a},e.prototype._bindTexture=function(e,t,n){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;e1&&(this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,null))},e.prototype.setTexture=function(e,t,n,i){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,n))},e.prototype._bindSamplerUniformToChannel=function(e,t){var n=this._boundUniforms[e];n&&n._currentState!==t&&(this._gl.uniform1i(n,t),n._currentState=t)},e.prototype._getTextureWrapMode=function(e){switch(e){case h.a.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case h.a.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case h.a.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.prototype._setTexture=function(e,t,n,i,r){if(void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===r&&(r=""),!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===h.a.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var o;o=i?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:t.is2DArray?this.emptyTexture2DArray:this.emptyTexture,!n&&o&&(o._associatedChannel=e);var a=!0;this._boundTexturesCache[e]===o&&(n||this._bindSamplerUniformToChannel(o._associatedChannel,e),a=!1),this._activeChannel=e;var s=this._getTextureTarget(o);if(a&&this._bindTextureDirectly(s,o,n),o&&!o.isMultiview){if(o.isCube&&o._cachedCoordinatesMode!==t.coordinatesMode){o._cachedCoordinatesMode=t.coordinatesMode;var c=t.coordinatesMode!==h.a.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==h.a.TEXTURE_SKYBOX_MODE?h.a.TEXTURE_WRAP_ADDRESSMODE:h.a.TEXTURE_CLAMP_ADDRESSMODE;t.wrapU=c,t.wrapV=c}o._cachedWrapU!==t.wrapU&&(o._cachedWrapU=t.wrapU,this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),o)),o._cachedWrapV!==t.wrapV&&(o._cachedWrapV=t.wrapV,this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),o)),o.is3D&&o._cachedWrapR!==t.wrapR&&(o._cachedWrapR=t.wrapR,this._setTextureParameterInteger(s,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),o)),this._setAnisotropicLevel(s,o,t.anisotropicFilteringLevel)}return!0},e.prototype.setTextureArray=function(e,t,n,i){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===n.length||(this._textureUnits=new Int32Array(n.length));for(var r=0;r=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(){var e;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(),null===(e=this.releaseComputeEffects)||void 0===e||e.call(this),this.unbindAllAttributes(),this._boundUniforms=[],Object(f.e)()&&this._renderingCanvas&&(this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored)),window.removeEventListener("resize",this._checkForMobile)),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._boundRenderFunction=null,o.a.ResetCache();for(var t=0,n=this._activeRequests;t1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(h.a.TEXTURETYPE_FLOAT)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(h.a.TEXTURETYPE_HALF_FLOAT)},e.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var n=!0,i=t.createTexture();t.bindTexture(t.TEXTURE_2D,i),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var r=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,r),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,i,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((n=(n=n&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),n=n&&t.getError()===t.NO_ERROR),n){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),n=n&&t.getError()===t.NO_ERROR}for(t.deleteTexture(i),t.deleteFramebuffer(r),t.bindFramebuffer(t.FRAMEBUFFER,null);!n&&t.getError()!==t.NO_ERROR;);return n},e.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case h.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case h.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case h.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case h.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case h.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case h.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5}return this._gl.UNSIGNED_BYTE}switch(e){case h.a.TEXTURETYPE_BYTE:return this._gl.BYTE;case h.a.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case h.a.TEXTURETYPE_SHORT:return this._gl.SHORT;case h.a.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case h.a.TEXTURETYPE_INT:return this._gl.INT;case h.a.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case h.a.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case h.a.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case h.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case h.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case h.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case h.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case h.a.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case h.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case h.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case h.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,t){void 0===t&&(t=!1);var n=t?this._gl.SRGB8_ALPHA8:this._gl.RGBA;switch(e){case h.a.TEXTUREFORMAT_ALPHA:n=this._gl.ALPHA;break;case h.a.TEXTUREFORMAT_LUMINANCE:n=this._gl.LUMINANCE;break;case h.a.TEXTUREFORMAT_LUMINANCE_ALPHA:n=this._gl.LUMINANCE_ALPHA;break;case h.a.TEXTUREFORMAT_RED:n=this._gl.RED;break;case h.a.TEXTUREFORMAT_RG:n=this._gl.RG;break;case h.a.TEXTUREFORMAT_RGB:n=t?this._gl.SRGB:this._gl.RGB;break;case h.a.TEXTUREFORMAT_RGBA:n=t?this._gl.SRGB8_ALPHA8:this._gl.RGBA}if(this._webGLVersion>1)switch(e){case h.a.TEXTUREFORMAT_RED_INTEGER:n=this._gl.RED_INTEGER;break;case h.a.TEXTUREFORMAT_RG_INTEGER:n=this._gl.RG_INTEGER;break;case h.a.TEXTUREFORMAT_RGB_INTEGER:n=this._gl.RGB_INTEGER;break;case h.a.TEXTUREFORMAT_RGBA_INTEGER:n=this._gl.RGBA_INTEGER}return n},e.prototype._getRGBABufferInternalSizedFormat=function(e,t,n){if(void 0===n&&(n=!1),1===this._webGLVersion){if(void 0!==t)switch(t){case h.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case h.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case h.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;case h.a.TEXTUREFORMAT_RGB:return n?this._gl.SRGB:this._gl.RGB}return this._gl.RGBA}switch(e){case h.a.TEXTURETYPE_BYTE:switch(t){case h.a.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case h.a.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case h.a.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case h.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case h.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case h.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case h.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case h.a.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case h.a.TEXTUREFORMAT_RED:return this._gl.R8;case h.a.TEXTUREFORMAT_RG:return this._gl.RG8;case h.a.TEXTUREFORMAT_RGB:return n?this._gl.SRGB8:this._gl.RGB8;case h.a.TEXTUREFORMAT_RGBA:return n?this._gl.SRGB8_ALPHA8:this._gl.RGBA8;case h.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case h.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case h.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case h.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case h.a.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case h.a.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case h.a.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case h.a.TEXTURETYPE_SHORT:switch(t){case h.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case h.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case h.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case h.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case h.a.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case h.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case h.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case h.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case h.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case h.a.TEXTURETYPE_INT:switch(t){case h.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case h.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case h.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case h.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case h.a.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case h.a.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case h.a.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case h.a.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case h.a.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case h.a.TEXTURETYPE_FLOAT:switch(t){case h.a.TEXTUREFORMAT_RED:return this._gl.R32F;case h.a.TEXTUREFORMAT_RG:return this._gl.RG32F;case h.a.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case h.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case h.a.TEXTURETYPE_HALF_FLOAT:switch(t){case h.a.TEXTUREFORMAT_RED:return this._gl.R16F;case h.a.TEXTUREFORMAT_RG:return this._gl.RG16F;case h.a.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case h.a.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case h.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case h.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case h.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case h.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case h.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case h.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case h.a.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case h.a.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return n?this._gl.SRGB8_ALPHA8:this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(e){return e===h.a.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===h.a.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},e.prototype._loadFile=function(t,n,i,r,o,a){var s=this,c=e._FileToolsLoadFile(t,n,i,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,n,i,r,o){throw Object(a.a)("FileTools")},e.prototype.readPixels=function(e,t,n,i,r,o){void 0===r&&(r=!0),void 0===o&&(o=!0);var a=r?4:3,s=r?this._gl.RGBA:this._gl.RGB,c=new Uint8Array(i*n*a);return o&&this.flushFramebuffer(),this._gl.readPixels(e,t,n,i,s,this._gl.UNSIGNED_BYTE,c),Promise.resolve(c)},Object.defineProperty(e,"IsSupportedAsync",{get:function(){return Promise.resolve(this.isSupported())},enumerable:!1,configurable:!0}),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=this._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=this._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 n=e.CeilingPOT(t),i=e.FloorPOT(t);return n-t>t-i?i:n},e.GetExponentOfTwo=function(t,n,i){var r;switch(void 0===i&&(i=h.a.SCALEMODE_NEAREST),i){case h.a.SCALEMODE_FLOOR:r=e.FloorPOT(t);break;case h.a.SCALEMODE_NEAREST:r=e.NearestPOT(t);break;case h.a.SCALEMODE_CEILING:default:r=e.CeilingPOT(t)}return Math.min(r,n)},e.QueueNewFrame=function(e,t){return Object(f.e)()?(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,n){"use strict";n.d(t,"a",(function(){return m}));var i=n(2),r=n(3),o=n(43),a=n(12),s=n(6),c=n(0),u=n(30),l=n(7),h=n(10),d=n(25),p=n(62),f=n(104),_=n(1),m=function(e){function t(n,i,r,a){void 0===a&&(a=!0);var u=e.call(this,n,r)||this;return u._position=c.e.Zero(),u._upVector=c.e.Up(),u.orthoLeft=null,u.orthoRight=null,u.orthoBottom=null,u.orthoTop=null,u.fov=.8,u.projectionPlaneTilt=0,u.minZ=1,u.maxZ=1e4,u.inertia=.9,u.mode=t.PERSPECTIVE_CAMERA,u.isIntermediate=!1,u.viewport=new p.a(0,0,1,1),u.layerMask=268435455,u.fovMode=t.FOVMODE_VERTICAL_FIXED,u.cameraRigMode=t.RIG_MODE_NONE,u.customRenderTargets=new Array,u.outputRenderTarget=null,u.onViewMatrixChangedObservable=new s.c,u.onProjectionMatrixChangedObservable=new s.c,u.onAfterCheckInputsObservable=new s.c,u.onRestoreStateObservable=new s.c,u.isRigCamera=!1,u._rigCameras=new Array,u._webvrViewMatrix=c.a.Identity(),u._skipRendering=!1,u._projectionMatrix=new c.a,u._postProcesses=new Array,u._activeMeshes=new o.a(256),u._globalPosition=c.e.Zero(),u._computedViewMatrix=c.a.Identity(),u._doNotComputeProjectionMatrix=!1,u._transformMatrix=c.a.Zero(),u._refreshFrustumPlanes=!0,u._absoluteRotation=c.b.Identity(),u._isCamera=!0,u._isLeftCamera=!1,u._isRightCamera=!1,u.getScene().addCamera(u),a&&!u.getScene().activeCamera&&(u.getScene().activeCamera=u),u.position=i,u.renderPassId=u.getScene().getEngine().createRenderPassId("Camera ".concat(n)),u}return Object(i.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}),Object.defineProperty(t.prototype,"screenArea",{get:function(){var e,n,i,r,o=0,a=0;if(this.mode===t.PERSPECTIVE_CAMERA)this.fovMode===t.FOVMODE_VERTICAL_FIXED?(a=2*this.minZ*Math.tan(this.fov/2),o=this.getEngine().getAspectRatio(this)*a):a=(o=2*this.minZ*Math.tan(this.fov/2))/this.getEngine().getAspectRatio(this);else{var s=this.getEngine().getRenderWidth()/2,c=this.getEngine().getRenderHeight()/2;o=(null!==(e=this.orthoRight)&&void 0!==e?e:s)-(null!==(n=this.orthoLeft)&&void 0!==n?n:-s),a=(null!==(i=this.orthoTop)&&void 0!==i?i:c)-(null!==(r=this.orthoBottom)&&void 0!==r?r:-c)}return o*a},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 n=0;n-1?(l.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 n,i,r,o,a,s,u,l;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._cache.projectionPlaneTilt=this.projectionPlaneTilt,this.minZ<=0&&(this.minZ=.1);var p=h.useReverseDepthBuffer;(d.useRightHandedSystem?c.a.PerspectiveFovRHToRef:c.a.PerspectiveFovLHToRef)(this.fov,h.getAspectRatio(this),p?this.maxZ:this.minZ,p?this.minZ:this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED,h.isNDCHalfZRange,this.projectionPlaneTilt,h.useReverseDepthBuffer)}else{var f=h.getRenderWidth()/2,_=h.getRenderHeight()/2;d.useRightHandedSystem?c.a.OrthoOffCenterRHToRef(null!==(n=this.orthoLeft)&&void 0!==n?n:-f,null!==(i=this.orthoRight)&&void 0!==i?i:f,null!==(r=this.orthoBottom)&&void 0!==r?r:-_,null!==(o=this.orthoTop)&&void 0!==o?o:_,this.minZ,this.maxZ,this._projectionMatrix,h.isNDCHalfZRange):c.a.OrthoOffCenterLHToRef(null!==(a=this.orthoLeft)&&void 0!==a?a:-f,null!==(s=this.orthoRight)&&void 0!==s?s:f,null!==(u=this.orthoBottom)&&void 0!==u?u:-_,null!==(l=this.orthoTop)&&void 0!==l?l:_,this.minZ,this.maxZ,this._projectionMatrix,h.isNDCHalfZRange),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?f.a.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=f.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 n=!1;return this.rigCameras.forEach((function(t){t._updateFrustumPlanes(),n=n||e.isInFrustum(t._frustumPlanes)})),n}return e.isInFrustum(this._frustumPlanes)},t.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},t.prototype.getForwardRay=function(e,t,n){throw void 0===e&&(e=100),Object(d.a)("Ray")},t.prototype.getForwardRayToRef=function(e,t,n,i){throw void 0===t&&(t=100),Object(d.a)("Ray")},t.prototype.dispose=function(n,i){for(void 0===i&&(i=!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._parentContainer){var o=this._parentContainer.cameras.indexOf(this);o>-1&&this._parentContainer.cameras.splice(o,1),this._parentContainer=null}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 a=this._postProcesses.length;--a>=0;){var s=this._postProcesses[a];s&&s.dispose(this)}for(a=this.customRenderTargets.length;--a>=0;)this.customRenderTargets[a].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),this.getScene().getEngine().releaseRenderPassId(this.renderPassId),e.prototype.dispose.call(this,n,i)},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,n){if(this.cameraRigMode!==e){for(;this._rigCameras.length>0;){var i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=n.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))}this._setRigMode(n),this._cascadePostProcessesToRigCams(),this.update()}},t.prototype._setRigMode=function(e){},t.prototype._getVRProjectionMatrix=function(){return c.a.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix,!0,this.getEngine().isNDCHalfZRange),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=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-1&&this._parentContainer.materials.splice(r,1),this._parentContainer=null}if(!0!==n)if(this.meshMap)for(var o in this.meshMap){(c=this.meshMap[o])&&(c.material=null,this.releaseVertexArrayObject(c,e))}else for(var a=0,s=i.meshes;a100&&(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===n.mass?0:n.mass,this._options.friction=void 0===n.friction?.2:n.friction,this._options.restitution=void 0===n.restitution?.2:n.restitution,this.soft&&(this._options.mass=this._options.mass>0?this._options.mass:1,this._options.pressure=void 0===n.pressure?200:n.pressure,this._options.stiffness=void 0===n.stiffness?1:n.stiffness,this._options.velocityIterations=void 0===n.velocityIterations?20:n.velocityIterations,this._options.positionIterations=void 0===n.positionIterations?20:n.positionIterations,this._options.fixedPoints=void 0===n.fixedPoints?0:n.fixedPoints,this._options.margin=void 0===n.margin?0:n.margin,this._options.damping=void 0===n.damping?0:n.damping,this._options.path=void 0===n.path?null:n.path,this._options.shape=void 0===n.shape?null:n.shape),this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&i.a.Warn("You must affect impostors to children before affecting impostor to parent.")):i.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):i.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,n=this.object.scaling.clone();this.object.rotationQuaternion=e.IDENTITY_QUATERNION;var i=this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);i&&i.decompose(n,void 0,void 0);var r=this.object.getBoundingInfo().boundingBox.extendSize.scale(2).multiplyInPlace(n);return r.x=Math.abs(r.x),r.y=Math.abs(r.y),r.z=Math.abs(r.z),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):i.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):i.a.Warn("Function to remove was not found")},e.prototype.registerOnPhysicsCollide=function(e,t){var n=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:n})},e.prototype.unregisterOnPhysicsCollide=function(e,t){var n=e instanceof Array?e:[e],r=-1;this._onPhysicsCollideCallbacks.some((function(e,i){if(e.callback===t&&e.otherImpostors.length===n.length){var o=e.otherImpostors.every((function(e){return n.indexOf(e)>-1}));return o&&(r=i),o}return!1}))?this._onPhysicsCollideCallbacks.splice(r,1):i.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,n){var i=new c.e(t,n);return this.addJoint(e,i),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,n,i,r){if(!this._physicsEngine)return this;var o=this._physicsEngine.getPhysicsPlugin();return o.appendAnchor?(this._physicsEngine&&o.appendAnchor(this,e,t,n,i,r),this):this},e.prototype.addHook=function(e,t,n,i){if(!this._physicsEngine)return this;var r=this._physicsEngine.getPhysicsPlugin();return r.appendAnchor?(this._physicsEngine&&r.appendHook(this,e,t,n,i),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,n,i,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,u.c.WORLD,n)}else t.setRotationQuaternion(s.rotationQuaternion,u.c.WORLD,n);a.x=0,a.y=0,a.z=0,i&&(a.x=i.x,a.y=i.y,a.z=i.z,t.getDirectionToRef(a,n,a),null==r&&(r=i.length()),a.x*=r,a.y*=r,a.z*=r),t.getParent()?(a.addInPlace(s.getAbsolutePosition()),t.setAbsolutePosition(a,n)):(n.setAbsolutePosition(s.getAbsolutePosition()),n.position.x-=a.x,n.position.y-=a.y,n.position.z-=a.z)},e.prototype.syncImpostorWithBone=function(t,n,i,r,o,a){var s=this.object;if(s.rotationQuaternion)if(o){var c=e._tmpQuat;t.getRotationQuaternionToRef(u.c.WORLD,n,c),c.multiplyToRef(o,s.rotationQuaternion)}else t.getRotationQuaternionToRef(u.c.WORLD,n,s.rotationQuaternion);var l=e._tmpVecs[0],h=e._tmpVecs[1];a||((a=e._tmpVecs[2]).x=0,a.y=1,a.z=0),t.getDirectionToRef(a,n,h),t.getAbsolutePositionToRef(n,l),null==r&&i&&(r=i.length()),null!=r&&(l.x+=h.x*r,l.y+=h.y*r,l.z+=h.z*r),s.setAbsolutePosition(l)},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,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){}return e.UseOpenGLOrientationForUV=!1,e}()},function(e,t,n){"use strict";n.d(t,"b",(function(){return I})),n.d(t,"a",(function(){return D}));var i=n(2),r=n(3),o=n(43),a=n(22),s=n(0),c=n(8),u=n(4),l=n(127),h=n(51),d=n(29),p=n(68),f=n(64),_=n(88),m=n(15),g=n(11),v=n(10),b=n(21),y=n(5),T="uniform vec4 vEyePosition;\nuniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\nuniform vec3 vAmbientColor;\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#ifdef ALPHATEST\nuniform float alphaCutOff;\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#if defined(USE_LOCAL_REFRACTIONMAP_CUBIC) && defined(REFRACTIONMAP_3D)\nuniform vec3 vRefractionPosition;\nuniform vec3 vRefractionSize;\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\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n";y.a.IncludesShadersStore.defaultFragmentDeclaration=T;n(146),n(185);var E="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;\nfloat alphaCutOff;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec3 vRefractionPosition;\nvec3 vRefractionSize;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nvec3 vAmbientColor;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n";y.a.IncludesShadersStore.defaultUboDeclaration=E;n(193),n(194),n(153),n(69),n(154),n(155),n(186),n(156),n(187),n(195),n(157),n(128),n(129),n(158),n(159),n(118),n(133),n(147),n(196),n(108),n(160),n(197),n(161),n(188),n(162);var S="#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#include[SCENE_MRT_COUNT]\n#include\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include[1..7]\n\n#include\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include\n\n#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_SAMPLERNAME_,diffuse)\n#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULARTERM)\n#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_SAMPLERNAME_,specular)\n#endif\n\n#include\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\n#endif\n#include\n#include\n#include\n#include\n#include\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#include\nvec3 viewDirectionW=normalize(vEyePosition.xyz-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\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\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\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[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\n#ifdef USE_LOCAL_REFRACTIONMAP_CUBIC\nrefractionVector=parallaxCorrectNormal(vPositionW,refractionVector,vRefractionSize,vRefractionPosition);\n#endif\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_OPPOSITEZ\nvReflectionUVW.z*=-1.0;\n#endif\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\n#include\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\nfloat writeGeometryInfo=color.a>0.4 ? 1.0 : 0.0;\ngl_FragData[0]=color;\n#ifdef PREPASS_POSITION\ngl_FragData[PREPASS_POSITION_INDEX]=vec4(vPositionW,writeGeometryInfo);\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,writeGeometryInfo);\n#endif\n#ifdef PREPASS_IRRADIANCE\ngl_FragData[PREPASS_IRRADIANCE_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_DEPTH\ngl_FragData[PREPASS_DEPTH_INDEX]=vec4(vViewPos.z,0.0,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[PREPASS_NORMAL_INDEX]=vec4((view*vec4(normalW,0.0)).rgb,writeGeometryInfo);\n#endif\n#ifdef PREPASS_ALBEDO_SQRT\ngl_FragData[PREPASS_ALBEDO_SQRT_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);\n#endif\n#ifdef PREPASS_REFLECTIVITY\n#if defined(SPECULAR)\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(specularMapColor.rgb,specularMapColor.a*writeGeometryInfo);\n#else\ngl_FragData[PREPASS_REFLECTIVITY_INDEX]=vec4(0.0,0.0,0.0,writeGeometryInfo);\n#endif\n#endif\n#endif\n#if !defined(PREPASS) || defined(WEBGL2)\ngl_FragColor=color;\n#endif\n#if ORDER_INDEPENDENT_TRANSPARENCY\nif (fragDepth == nearestDepth) {\nfrontColor.rgb+=color.rgb*color.a*alphaMultiplier;\nfrontColor.a=1.0-alphaMultiplier*(1.0-color.a);\n} else {\nbackColor+=color;\n}\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}\n";y.a.ShadersStore.defaultPixelShader=S;var A="\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#ifdef DETAIL\nuniform vec4 vDetailInfos;\nuniform mat4 detailMatrix;\n#endif\n#define ADDITIONAL_VERTEX_DECLARATION\n";y.a.IncludesShadersStore.defaultVertexDeclaration=A;n(198),n(92),n(97),n(98),n(199),n(200),n(201),n(119),n(163),n(164),n(165),n(109),n(110),n(120),n(121),n(93),n(94),n(99),n(202),n(203),n(204),n(189),n(111),n(190),n(166);var x="#if defined(POINTSIZE) && !defined(WEBGPU)\ngl_PointSize=pointSize;\n#endif";y.a.IncludesShadersStore.pointCloudVertex=x;n(191);var R="#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#include[2..7]\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n#include\n\n#include\n#include\n#include[1..7]\n#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse)\n#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail)\n#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient)\n#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity)\n#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive)\n#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap)\n#if defined(SPECULARTERM)\n#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular)\n#endif\n#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump)\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#include\n#include\n#include\n#include<__decl__lightVxFragment>[0..maxSimultaneousLights]\n#include\n#include[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\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\n#include[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvPositionUVW=positionUpdated;\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include\n#if defined(PREPASS) && defined(PREPASS_VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include\n#include\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\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#ifdef MAINUV1\nvMainUV1=uvUpdated;\n#endif\n#include[2..7]\n#include(_DEFINENAME_,DIFFUSE,_VARYINGNAME_,Diffuse,_MATRIXNAME_,diffuse,_INFONAME_,DiffuseInfos.x)\n#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_MATRIXNAME_,detail,_INFONAME_,DetailInfos.x)\n#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_MATRIXNAME_,ambient,_INFONAME_,AmbientInfos.x)\n#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_MATRIXNAME_,opacity,_INFONAME_,OpacityInfos.x)\n#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_MATRIXNAME_,emissive,_INFONAME_,EmissiveInfos.x)\n#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_MATRIXNAME_,lightmap,_INFONAME_,LightmapInfos.x)\n#if defined(SPECULARTERM)\n#include(_DEFINENAME_,SPECULAR,_VARYINGNAME_,Specular,_MATRIXNAME_,specular,_INFONAME_,SpecularInfos.x)\n#endif\n#include(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_MATRIXNAME_,bump,_INFONAME_,BumpInfos.x)\n#include\n#include\n#include\n#include[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#include\n#include\n#define CUSTOM_VERTEX_MAIN_END\n}\n";y.a.ShadersStore.defaultVertexShader=R;var C=n(1),P=n(79),O=n(125),M={effect:null,subMesh:null},I=function(e){function t(t){var n=e.call(this,t)||this;return n.MAINUV1=!1,n.MAINUV2=!1,n.MAINUV3=!1,n.MAINUV4=!1,n.MAINUV5=!1,n.MAINUV6=!1,n.DIFFUSE=!1,n.DIFFUSEDIRECTUV=0,n.BAKED_VERTEX_ANIMATION_TEXTURE=!1,n.AMBIENT=!1,n.AMBIENTDIRECTUV=0,n.OPACITY=!1,n.OPACITYDIRECTUV=0,n.OPACITYRGB=!1,n.REFLECTION=!1,n.EMISSIVE=!1,n.EMISSIVEDIRECTUV=0,n.SPECULAR=!1,n.SPECULARDIRECTUV=0,n.BUMP=!1,n.BUMPDIRECTUV=0,n.PARALLAX=!1,n.PARALLAXOCCLUSION=!1,n.SPECULAROVERALPHA=!1,n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.ALPHATEST=!1,n.DEPTHPREPASS=!1,n.ALPHAFROMDIFFUSE=!1,n.POINTSIZE=!1,n.FOG=!1,n.SPECULARTERM=!1,n.DIFFUSEFRESNEL=!1,n.OPACITYFRESNEL=!1,n.REFLECTIONFRESNEL=!1,n.REFRACTIONFRESNEL=!1,n.EMISSIVEFRESNEL=!1,n.FRESNEL=!1,n.NORMAL=!1,n.TANGENT=!1,n.UV1=!1,n.UV2=!1,n.UV3=!1,n.UV4=!1,n.UV5=!1,n.UV6=!1,n.VERTEXCOLOR=!1,n.VERTEXALPHA=!1,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.BONETEXTURE=!1,n.BONES_VELOCITY_ENABLED=!1,n.INSTANCES=!1,n.THIN_INSTANCES=!1,n.INSTANCESCOLOR=!1,n.GLOSSINESS=!1,n.ROUGHNESS=!1,n.EMISSIVEASILLUMINATION=!1,n.LINKEMISSIVEWITHDIFFUSE=!1,n.REFLECTIONFRESNELFROMSPECULAR=!1,n.LIGHTMAP=!1,n.LIGHTMAPDIRECTUV=0,n.OBJECTSPACE_NORMALMAP=!1,n.USELIGHTMAPASSHADOWMAP=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFRACTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.INVERTCUBICMAP=!1,n.LOGARITHMICDEPTH=!1,n.REFRACTION=!1,n.REFRACTIONMAP_3D=!1,n.REFLECTIONOVERALPHA=!1,n.TWOSIDEDLIGHTING=!1,n.SHADOWFLOAT=!1,n.MORPHTARGETS=!1,n.MORPHTARGETS_NORMAL=!1,n.MORPHTARGETS_TANGENT=!1,n.MORPHTARGETS_UV=!1,n.NUM_MORPH_INFLUENCERS=0,n.MORPHTARGETS_TEXTURE=!1,n.NONUNIFORMSCALING=!1,n.PREMULTIPLYALPHA=!1,n.ALPHATEST_AFTERALLALPHACOMPUTATIONS=!1,n.ALPHABLEND=!0,n.PREPASS=!1,n.PREPASS_IRRADIANCE=!1,n.PREPASS_IRRADIANCE_INDEX=-1,n.PREPASS_ALBEDO_SQRT=!1,n.PREPASS_ALBEDO_SQRT_INDEX=-1,n.PREPASS_DEPTH=!1,n.PREPASS_DEPTH_INDEX=-1,n.PREPASS_NORMAL=!1,n.PREPASS_NORMAL_INDEX=-1,n.PREPASS_POSITION=!1,n.PREPASS_POSITION_INDEX=-1,n.PREPASS_VELOCITY=!1,n.PREPASS_VELOCITY_INDEX=-1,n.PREPASS_REFLECTIVITY=!1,n.PREPASS_REFLECTIVITY_INDEX=-1,n.SCENE_MRT_COUNT=0,n.RGBDLIGHTMAP=!1,n.RGBDREFLECTION=!1,n.RGBDREFRACTION=!1,n.IMAGEPROCESSING=!1,n.VIGNETTE=!1,n.VIGNETTEBLENDMODEMULTIPLY=!1,n.VIGNETTEBLENDMODEOPAQUE=!1,n.TONEMAPPING=!1,n.TONEMAPPING_ACES=!1,n.CONTRAST=!1,n.COLORCURVES=!1,n.COLORGRADING=!1,n.COLORGRADING3D=!1,n.SAMPLER3DGREENDEPTH=!1,n.SAMPLER3DBGRMAP=!1,n.IMAGEPROCESSINGPOSTPROCESS=!1,n.SKIPFINALCOLORCLAMP=!1,n.MULTIVIEW=!1,n.ORDER_INDEPENDENT_TRANSPARENCY=!1,n.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,n.IS_REFLECTION_LINEAR=!1,n.IS_REFRACTION_LINEAR=!1,n.EXPOSURE=!1,n.rebuild(),n}return Object(i.d)(t,e),t.prototype.setReflectionMode=function(e){for(var t=0,n=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];t0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===g.a.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,o.RGBDREFLECTION=this._reflectionTexture.isRGBD,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!this._reflectionTexture.invertZ:this._reflectionTexture.invertZ,this._reflectionTexture.coordinatesMode){case g.a.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case g.a.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case g.a.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case g.a.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case g.a.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case g.a.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case g.a.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case g.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case g.a.CUBIC_MODE:case g.a.INVCUBIC_MODE:default:o.setReflectionMode("REFLECTIONMAP_CUBIC")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1,o.REFLECTIONMAP_OPPOSITEZ=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;m.a.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;m.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;m.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;m.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,o.USE_LOCAL_REFRACTIONMAP_CUBIC=!!this._refractionTexture.boundingBoxSize}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===C.a.ALPHA_PREMULTIPLIED||this.alphaMode===C.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.ALPHATEST_AFTERALLALPHACOMPUTATIONS=null!==this.transparencyMode,o.ALPHABLEND=null===this.transparencyMode||this.needAlphaBlendingForMesh(e)}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=o,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)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),m.a.PrepareDefinesForMisc(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,o),m.a.PrepareDefinesForAttributes(e,o,!0,!0,!0),m.a.PrepareDefinesForFrameBoundValues(r,a,o,i,null,n.getRenderingMesh().hasThinInstances),this._eventInfo.defines=o,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefines(this._eventInfo),o.isDirty){var d=o._areLightsDisposed;o.markAsProcessed();var f=new P.a;o.REFLECTION&&f.addFallback(0,"REFLECTION"),o.SPECULAR&&f.addFallback(0,"SPECULAR"),o.BUMP&&f.addFallback(0,"BUMP"),o.PARALLAX&&f.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&f.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&f.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&f.addFallback(1,"FOG"),o.POINTSIZE&&f.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&f.addFallback(0,"LOGARITHMICDEPTH"),m.a.HandleFallbacksForShadows(o,f,this._maxSimultaneousLights),o.SPECULARTERM&&f.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&f.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&f.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&f.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&f.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&f.addFallback(4,"FRESNEL"),o.MULTIVIEW&&f.addFallback(0,"MULTIVIEW");var _=[u.b.PositionKind];o.NORMAL&&_.push(u.b.NormalKind),o.TANGENT&&_.push(u.b.TangentKind);for(c=1;c<=C.a.MAX_SUPPORTED_UV_SETS;++c)o["UV"+c]&&_.push("uv".concat(1===c?"":c));o.VERTEXCOLOR&&_.push(u.b.ColorKind),o.INSTANCESCOLOR&&_.push(u.b.ColorInstanceKind),m.a.PrepareAttributesForBones(_,e,o,f),m.a.PrepareAttributesForInstances(_,o),m.a.PrepareAttributesForMorphTargets(_,e,o),m.a.PrepareAttributesForBakedVertexAnimation(_,e,o);var v="default",b=["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","vRefractionPosition","vRefractionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth","morphTargetTextureInfo","morphTargetTextureIndices"],y=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],T=["Material","Scene","Mesh"];this._eventInfo.fallbacks=f,this._eventInfo.fallbackRank=0,this._eventInfo.defines=o,this._eventInfo.uniforms=b,this._eventInfo.samplers=y,this._eventInfo.uniformBuffersNames=T,this._eventInfo.customCode=void 0,this._callbackPluginEventGeneric(p.a.PrepareEffect,this._eventInfo),l.a.AddUniforms(b),l.a.AddSamplers(y),h.a&&(h.a.PrepareUniforms(b,o),h.a.PrepareSamplers(y,o)),m.a.PrepareUniformsAndSamplersList({uniformsNames:b,uniformBuffersNames:T,samplers:y,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var E={};this.customShaderNameResolve&&(v=this.customShaderNameResolve(v,b,T,y,o,_,E));var S=o.toString(),A=n.effect,x=r.getEngine().createEffect(v,{attributes:_,uniformsNames:b,uniformBuffersNames:T,samplers:y,defines:S,fallbacks:f,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS},processFinalCode:E.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:o.PREPASS},a);if(x)if(this._onEffectCreatedObservable&&(M.effect=x,M.subMesh=n,this._onEffectCreatedObservable.notifyObservers(M)),this.allowShaderHotSwapping&&A&&!x.isReady()){if(x=A,o.markAsUnprocessed(),d)return o._areLightsDisposed=!0,!1}else r.resetCachedMaterial(),n.setEffect(x,o,this._materialContext)}return!(!n.effect||!n.effect.isReady())&&(o._renderId=r.getRenderId(),n.effect._wasPreviouslyReady=!0,!0)},t.prototype.buildUniformLayout=function(){var t=this._uniformBuffer;t.addUniform("diffuseLeftColor",4),t.addUniform("diffuseRightColor",4),t.addUniform("opacityParts",4),t.addUniform("reflectionLeftColor",4),t.addUniform("reflectionRightColor",4),t.addUniform("refractionLeftColor",4),t.addUniform("refractionRightColor",4),t.addUniform("emissiveLeftColor",4),t.addUniform("emissiveRightColor",4),t.addUniform("vDiffuseInfos",2),t.addUniform("vAmbientInfos",2),t.addUniform("vOpacityInfos",2),t.addUniform("vReflectionInfos",2),t.addUniform("vReflectionPosition",3),t.addUniform("vReflectionSize",3),t.addUniform("vEmissiveInfos",2),t.addUniform("vLightmapInfos",2),t.addUniform("vSpecularInfos",2),t.addUniform("vBumpInfos",3),t.addUniform("diffuseMatrix",16),t.addUniform("ambientMatrix",16),t.addUniform("opacityMatrix",16),t.addUniform("reflectionMatrix",16),t.addUniform("emissiveMatrix",16),t.addUniform("lightmapMatrix",16),t.addUniform("specularMatrix",16),t.addUniform("bumpMatrix",16),t.addUniform("vTangentSpaceParams",2),t.addUniform("pointSize",1),t.addUniform("alphaCutOff",1),t.addUniform("refractionMatrix",16),t.addUniform("vRefractionInfos",4),t.addUniform("vRefractionPosition",3),t.addUniform("vRefractionSize",3),t.addUniform("vSpecularColor",4),t.addUniform("vEmissiveColor",3),t.addUniform("vDiffuseColor",4),t.addUniform("vAmbientColor",3),e.prototype.buildUniformLayout.call(this)},t.prototype.bindForSubMesh=function(e,n,i){var r,o=this.getScene(),s=i.materialDefines;if(s){var u=i.effect;if(u){this._activeEffect=u,n.getMeshUniformBuffer().bindToEffect(u,"Mesh"),n.transferToEffect(e),this._uniformBuffer.bindToEffect(u,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,o,n,e,this.isFrozen),this._eventInfo.subMesh=i,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),s.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(o,u,n.visibility);m.a.BindBonesParameters(n,u);var h=this._uniformBuffer;if(l){if(this.bindViewProjection(u),!h.useUbo||!this.isFrozen||!h.isSync){if(t.FresnelEnabled&&s.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(h.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),h.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&h.updateColor4("opacityParts",new c.a(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(h.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),h.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(h.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),h.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(h.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),h.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),o.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(h.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),m.a.BindTextureMatrix(this._diffuseTexture,h,"diffuse")),this._ambientTexture&&t.AmbientTextureEnabled&&(h.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),m.a.BindTextureMatrix(this._ambientTexture,h,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(h.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),m.a.BindTextureMatrix(this._opacityTexture,h,"opacity")),this._hasAlphaChannel()&&h.updateFloat("alphaCutOff",this.alphaCutOff),this._reflectionTexture&&t.ReflectionTextureEnabled&&(h.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),h.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var d=this._reflectionTexture;h.updateVector3("vReflectionPosition",d.boundingBoxPosition),h.updateVector3("vReflectionSize",d.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(h.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),m.a.BindTextureMatrix(this._emissiveTexture,h,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(h.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),m.a.BindTextureMatrix(this._lightmapTexture,h,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(h.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),m.a.BindTextureMatrix(this._specularTexture,h,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(h.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),m.a.BindTextureMatrix(this._bumpTexture,h,"bump"),o._mirroredCameraPosition?h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):h.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var p=1;if(this._refractionTexture.isCube||(h.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(p=this._refractionTexture.depth)),h.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,p,this.invertRefractionY?-1:1),this._refractionTexture.boundingBoxSize){d=this._refractionTexture;h.updateVector3("vRefractionPosition",d.boundingBoxPosition),h.updateVector3("vRefractionSize",d.boundingBoxSize)}}}this.pointsCloud&&h.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&h.updateColor4("vSpecularColor",this.specularColor,this.specularPower),h.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:c.a.BlackReadOnly),h.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),h.updateColor3("vAmbientColor",this._globalAmbientColor)}if(o.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&u.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&u.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&u.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?u.setTexture("reflectionCubeSampler",this._reflectionTexture):u.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&u.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&u.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&u.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&u.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){p=1;this._refractionTexture.isCube?u.setTexture("refractionCubeSampler",this._refractionTexture):u.setTexture("refraction2DSampler",this._refractionTexture)}this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(n)&&this.getScene().depthPeelingRenderer.bind(u),this._eventInfo.subMesh=i,this._callbackPluginEventBindForSubMesh(this._eventInfo),m.a.BindClipPlane(u,o),this.bindEyePosition(u)}else o.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!l&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&m.a.BindLights(o,n,u,s,this._maxSimultaneousLights),(o.fogEnabled&&n.applyFog&&o.fogMode!==a.a.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture||n.receiveShadows)&&this.bindView(u),m.a.BindFogParameters(o,n,u),s.NUM_MORPH_INFLUENCERS&&m.a.BindMorphTargetParameters(n,u),s.BAKED_VERTEX_ANIMATION_TEXTURE&&(null===(r=n.bakedVertexAnimationManager)||void 0===r||r.bind(u,s.INSTANCES)),this.useLogarithmicDepth&&m.a.BindLogDepth(s,u,o),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(n,this._activeEffect),h.update()}}},t.prototype.getAnimatables=function(){var t=e.prototype.getAnimatables.call(this);return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&t.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&t.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&t.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&t.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&t.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&t.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&t.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&t.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&t.push(this._refractionTexture),t},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._emissiveTexture===t||(this._specularTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||this._refractionTexture===t))))))))},t.prototype.dispose=function(t,n){var i,r,o,a,s,c,u,l,h;n&&(null===(i=this._diffuseTexture)||void 0===i||i.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===(u=this._bumpTexture)||void 0===u||u.dispose(),null===(l=this._lightmapTexture)||void 0===l||l.dispose(),null===(h=this._refractionTexture)||void 0===h||h.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,n)},t.prototype.clone=function(e){var n=this,i=r.a.Clone((function(){return new t(e,n.getScene())}),this);return i.name=e,i.id=e,this.stencil.copyTo(i.stencil),i},t.Parse=function(e,n,i){var o=r.a.Parse((function(){return new t(e.name,n)}),e,n,i);return e.stencil&&o.stencil.parse(e.stencil,n,i),o},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return b.a.DiffuseTextureEnabled},set:function(e){b.a.DiffuseTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"DetailTextureEnabled",{get:function(){return b.a.DetailTextureEnabled},set:function(e){b.a.DetailTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return b.a.AmbientTextureEnabled},set:function(e){b.a.AmbientTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return b.a.OpacityTextureEnabled},set:function(e){b.a.OpacityTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return b.a.ReflectionTextureEnabled},set:function(e){b.a.ReflectionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return b.a.EmissiveTextureEnabled},set:function(e){b.a.EmissiveTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return b.a.SpecularTextureEnabled},set:function(e){b.a.SpecularTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return b.a.BumpTextureEnabled},set:function(e){b.a.BumpTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return b.a.LightmapTextureEnabled},set:function(e){b.a.LightmapTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return b.a.RefractionTextureEnabled},set:function(e){b.a.RefractionTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return b.a.ColorGradingTextureEnabled},set:function(e){b.a.ColorGradingTextureEnabled=e},enumerable:!1,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return b.a.FresnelEnabled},set:function(e){b.a.FresnelEnabled=e},enumerable:!1,configurable:!0}),Object(i.c)([Object(r.n)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),Object(i.c)([Object(r.n)("ambientTexture")],t.prototype,"_ambientTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(i.c)([Object(r.n)("opacityTexture")],t.prototype,"_opacityTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(i.c)([Object(r.n)("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(i.c)([Object(r.n)("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(i.c)([Object(r.n)("specularTexture")],t.prototype,"_specularTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),Object(i.c)([Object(r.n)("bumpTexture")],t.prototype,"_bumpTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(i.c)([Object(r.n)("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),Object(i.c)([Object(r.n)("refractionTexture")],t.prototype,"_refractionTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),Object(i.c)([Object(r.f)("ambient")],t.prototype,"ambientColor",void 0),Object(i.c)([Object(r.f)("diffuse")],t.prototype,"diffuseColor",void 0),Object(i.c)([Object(r.f)("specular")],t.prototype,"specularColor",void 0),Object(i.c)([Object(r.f)("emissive")],t.prototype,"emissiveColor",void 0),Object(i.c)([Object(r.d)()],t.prototype,"specularPower",void 0),Object(i.c)([Object(r.d)("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),Object(i.c)([Object(r.d)("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),Object(i.c)([Object(r.d)("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),Object(i.c)([Object(r.d)("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(i.c)([Object(r.d)("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),Object(i.c)([Object(r.d)("disableLighting")],t.prototype,"_disableLighting",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(i.c)([Object(r.d)("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(i.c)([Object(r.d)("useParallax")],t.prototype,"_useParallax",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(i.c)([Object(r.d)("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(i.c)([Object(r.d)()],t.prototype,"parallaxScaleBias",void 0),Object(i.c)([Object(r.d)("roughness")],t.prototype,"_roughness",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(i.c)([Object(r.d)()],t.prototype,"indexOfRefraction",void 0),Object(i.c)([Object(r.d)()],t.prototype,"invertRefractionY",void 0),Object(i.c)([Object(r.d)()],t.prototype,"alphaCutOff",void 0),Object(i.c)([Object(r.d)("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(i.c)([Object(r.i)("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),Object(i.c)([Object(r.i)("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),Object(i.c)([Object(r.i)("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),Object(i.c)([Object(r.i)("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),Object(i.c)([Object(r.i)("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),Object(i.c)([Object(r.d)("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),Object(i.c)([Object(r.d)("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),Object(i.c)([Object(r.d)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(i.c)([Object(r.d)("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(i.c)([Object(r.d)("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(i.c)([Object(r.d)("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),Object(i.c)([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(i.c)([Object(r.d)()],t.prototype,"useLogarithmicDepth",null),t}(_.a);Object(v.b)("BABYLON.StandardMaterial",D),a.a.DefaultMaterialFactory=function(e){return new D("default material",e)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return A}));var i=n(2),r=n(12),o=n(6),a=n(0),s=n(13),c=n(4),u=n(19),l=n(47),h=n(48),d=n(75),p=n(1),f=n(67),_=n(177),m=n(25),g=n(124),v=n(8),b=n(23),y=n(26),T=n(10),E=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},S=function(){this._hasVertexAlpha=!1,this._useVertexColors=!0,this._numBoneInfluencers=4,this._applyFog=!0,this._receiveShadows=!1,this._facetData=new E,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,this._collisionRetryCount=3,this._morphTargetManager=null,this._renderingGroupId=0,this._bakedVertexAnimationManager=null,this._material=null,this._positions=null,this._meshCollisionData=new _.a,this._enableDistantPicking=!1},A=function(e){function t(n,i){void 0===i&&(i=null);var r=e.call(this,n,i,!1)||this;return r._internalAbstractMeshDataInfo=new S,r._waitingMaterialId=null,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.isNearPickable=!1,r.isNearGrabbable=!1,r.showSubMeshesBoundingBox=!1,r.isBlocker=!1,r.enablePointerMoveEvents=!1,r.outlineColor=v.a.Red(),r.outlineWidth=.02,r.overlayColor=v.a.Red(),r.overlayAlpha=.5,r.useOctreeForRenderingSelection=!0,r.useOctreeForPicking=!0,r.useOctreeForCollisions=!0,r.alwaysSelectAsActiveMesh=!1,r.doNotSyncBoundingInfo=!1,r.actionManager=null,r.ellipsoid=new a.e(.5,1,.5),r.ellipsoidOffset=new a.e(0,0,0),r.edgesWidth=1,r.edgesColor=new v.b(1,0,0,1),r._edgesRenderer=null,r._masterMesh=null,r._boundingInfo=null,r._boundingInfoIsDirty=!0,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,n){void 0===n&&(n=null),t.subtractToRef(r._internalAbstractMeshDataInfo._meshCollisionData._oldPositionForCollisions,r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions.length()>s.a.CollisionsEpsilon&&r.position.addInPlace(r._internalAbstractMeshDataInfo._meshCollisionData._diffPositionForCollisions),n&&r.onCollideObservable.notifyObservers(n),r.onCollisionPositionChangeObservable.notifyObservers(r.position)},r.getScene().addMesh(r),r._resyncLightSources(),r._uniformBuffer=new f.a(r.getScene().getEngine(),void 0,void 0,n),r._buildUniformLayout(),r}return Object(i.d)(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return l.a.BILLBOARDMODE_NONE},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return l.a.BILLBOARDMODE_X},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return l.a.BILLBOARDMODE_Y},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return l.a.BILLBOARDMODE_Z},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return l.a.BILLBOARDMODE_ALL},enumerable:!1,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_USE_POSITION",{get:function(){return l.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,"collisionRetryCount",{get:function(){return this._internalAbstractMeshDataInfo._collisionRetryCount},set:function(e){this._internalAbstractMeshDataInfo._collisionRetryCount=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"morphTargetManager",{get:function(){return this._internalAbstractMeshDataInfo._morphTargetManager},set:function(e){this._internalAbstractMeshDataInfo._morphTargetManager!==e&&(this._internalAbstractMeshDataInfo._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"bakedVertexAnimationManager",{get:function(){return this._internalAbstractMeshDataInfo._bakedVertexAnimationManager},set:function(e){this._internalAbstractMeshDataInfo._bakedVertexAnimationManager!==e&&(this._internalAbstractMeshDataInfo._bakedVertexAnimationManager=e,this._markSubMeshesAsAttributesDirty())},enumerable:!1,configurable:!0}),t.prototype._syncGeometryWithMorphTargetManager=function(){},t.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,"onCollide",{set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver),this._internalAbstractMeshDataInfo._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){if(this._internalAbstractMeshDataInfo._visibility!==e){var t=this._internalAbstractMeshDataInfo._visibility;this._internalAbstractMeshDataInfo._visibility=e,(1===t&&1!==e||1!==t&&1===e)&&this._markSubMeshesAsMiscDirty()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"renderingGroupId",{get:function(){return this._internalAbstractMeshDataInfo._renderingGroupId},set:function(e){this._internalAbstractMeshDataInfo._renderingGroupId=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._internalAbstractMeshDataInfo._material},set:function(e){this._internalAbstractMeshDataInfo._material!==e&&(this._internalAbstractMeshDataInfo._material&&this._internalAbstractMeshDataInfo._material.meshMap&&(this._internalAbstractMeshDataInfo._material.meshMap[this.uniqueId]=void 0),this._internalAbstractMeshDataInfo._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers()&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&(this.resetDrawCache(),this._unBindEffect()))},enumerable:!1,configurable:!0}),t.prototype.getMaterialForRenderPass=function(e){var t;return null===(t=this._internalAbstractMeshDataInfo._materialForRenderPass)||void 0===t?void 0:t[e]},t.prototype.setMaterialForRenderPass=function(e,t){this._internalAbstractMeshDataInfo._materialForRenderPass||(this._internalAbstractMeshDataInfo._materialForRenderPass=[]),this._internalAbstractMeshDataInfo._materialForRenderPass[e]=t},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,"enableDistantPicking",{get:function(){return this._internalAbstractMeshDataInfo._enableDistantPicking},set:function(e){this._internalAbstractMeshDataInfo._enableDistantPicking=e},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._internalAbstractMeshDataInfo._meshCollisionData._collisionMask},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionResponse",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionResponse=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup},set:function(e){this._internalAbstractMeshDataInfo._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"surroundingMeshes",{get:function(){return this._internalAbstractMeshDataInfo._meshCollisionData._surroundingMeshes},set:function(e){this._internalAbstractMeshDataInfo._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._buildUniformLayout=function(){this._uniformBuffer.addUniform("world",16),this._uniformBuffer.addUniform("visibility",1),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e){var t=this._uniformBuffer;t.updateMatrix("world",e),t.updateFloat("visibility",this._internalAbstractMeshDataInfo._visibility),t.update()},t.prototype.getMeshUniformBuffer=function(){return this._uniformBuffer},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 n=this._internalAbstractMeshDataInfo._skeleton;return n&&(t+=", skeleton: "+n.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!==l.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(e){if(void 0===e&&(e=!1),this.onRebuildObservable.notifyObservers(this),null!==this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var t=0,n=this.subMeshes;t0){var h=u.getPositions();h&&(n[o]+=(h[o]-n[o])*l)}}if(i++,this._positions&&3===i){i=0;var d=3*r;this._positions[r++].copyFromFloats(n[d],n[d+1],n[d+2])}}if(n&&e&&this.skeleton){var p=this.getVerticesData(c.b.MatricesIndicesKind),f=this.getVerticesData(c.b.MatricesWeightsKind);if(f&&p)for(var _=this.numBoneInfluencers>4,m=_?this.getVerticesData(c.b.MatricesIndicesExtraKind):null,g=_?this.getVerticesData(c.b.MatricesWeightsExtraKind):null,v=this.skeleton.getTransformMatrices(this),b=a.c.Vector3[0],y=a.c.Matrix[0],T=a.c.Matrix[1],E=0,S=0;S0&&(a.a.FromFloat32ArrayToRefScaled(v,Math.floor(16*p[E+A]),x,T),y.addToSelf(T));if(_)for(A=0;A<4;A++)(x=g[E+A])>0&&(a.a.FromFloat32ArrayToRefScaled(v,Math.floor(16*m[E+A]),x,T),y.addToSelf(T));a.e.TransformCoordinatesFromFloatsToRef(n[S],n[S+1],n[S+2],y,b),b.toArray(n,S),this._positions&&this._positions[S/3].copyFrom(b)}}return n},t.prototype._getPositionData=function(e,t){var n,i=this.getVerticesData(c.b.PositionKind);if(this._internalAbstractMeshDataInfo._positions&&(this._internalAbstractMeshDataInfo._positions=null),i&&(e&&this.skeleton||t&&this.morphTargetManager)&&(i=r.b.Slice(i),this._generatePointsArray(),this._positions)){var o=this._positions;this._internalAbstractMeshDataInfo._positions=new Array(o.length);for(var s=0;s1||!i.IsGlobal)&&i.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||(this._boundingInfoIsDirty=!0)},t.prototype.isInFrustum=function(e){return this.getBoundingInfo().isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return this.getBoundingInfo().isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,t,n){void 0===t&&(t=!1);var i=this.getBoundingInfo(),r=e.getBoundingInfo();if(i.intersects(r,t))return!0;if(n)for(var o=0,a=this.getChildMeshes();o1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},t.prototype._shouldConvertRHS=function(){return!1},t.prototype._checkCollision=function(e){if(!this.getBoundingInfo()._checkCollision(e))return this;var t=a.c.Matrix[0],n=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,n),this._processCollisionsForSubMeshes(e,n),this},t.prototype._generatePointsArray=function(){return!1},t.prototype.intersects=function(e,t,n,i,r,o){void 0===i&&(i=!1),void 0===o&&(o=!1);var s=new h.a,c="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,u=this.getBoundingInfo();if(!this.subMeshes)return s;if(!(o||e.intersectsSphere(u.boundingSphere,c)&&e.intersectsBox(u.boundingBox,c)))return s;if(i)return s.hit=!o,s.pickedMesh=o?null:this,s.distance=o?0:a.e.Distance(e.origin,u.boundingSphere.center),s.subMeshId=0,s;if(!this._generatePointsArray())return s;for(var l=null,d=this._scene.getIntersectingSubMeshCandidates(this,e),f=d.length,_=!1,m=0;m1)||v.canIntersects(e)){var b=v.intersects(e,this._positions,this.getIndices(),t,n);if(b&&(t||!l||b.distance-1&&this._parentContainer.meshes.splice(c,1),this._parentContainer=null}if(n&&this.material&&("MultiMaterial"===this.material.getClassName()?this.material.dispose(!1,!0,!0):this.material.dispose(!1,!0)),!t)for(i=0;i65535){o=!0;break}e.depthSortedIndices=o?new Uint32Array(n):new Uint16Array(n)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var l=this.getScene().activeCamera;e.facetDepthSortFrom=l?l.position:a.e.Zero()}e.depthSortedFacets=[];for(var h=0;hb.a?r.maximum.x-r.minimum.x:b.a,e.bbSize.y=r.maximum.y-r.minimum.y>b.a?r.maximum.y-r.minimum.y:b.a,e.bbSize.z=r.maximum.z-r.minimum.z>b.a?r.maximum.z-r.minimum.z:b.a;var p=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(p=p>e.bbSize.z?p:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/p),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/p),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/p),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,i&&u.a.ComputeNormals(t,n,i,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var f=e.depthSortedIndices.length/3|0;for(h=0;hr.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,n,i,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 u=a.c.Vector3[8];a.e.TransformCoordinatesFromFloatsToRef(e,t,n,c,u);var l=this.getClosestFacetAtLocalCoordinates(u.x,u.y,u.z,i,r,o);return i&&a.e.TransformCoordinatesFromFloatsToRef(i.x,i.y,i.z,s,i),l},t.prototype.getClosestFacetAtLocalCoordinates=function(e,t,n,i,r,o){void 0===r&&(r=!1),void 0===o&&(o=!0);var a=null,s=0,c=0,u=0,l=0,h=0,d=0,p=0,f=0,_=this.getFacetLocalPositions(),m=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,n);if(!g)return null;for(var v,b,y,T=Number.MAX_VALUE,E=T,S=0;S=0||r&&!o&&l<=0)&&(l=b.x*y.x+b.y*y.y+b.z*y.z,h=-(b.x*e+b.y*t+b.z*n-l)/(b.x*b.x+b.y*b.y+b.z*b.z),(E=(s=(d=e+b.x*h)-e)*s+(c=(p=t+b.y*h)-t)*c+(u=(f=n+b.z*h)-n)*u)-1?e:c.a.GetShadersRepository(this._shaderLanguage)+e,this._engine._loadFile(r+"."+t.toLowerCase()+".fx",i)}else{i(window.atob(e.substr(7)))}else i(e.substr(7))},Object.defineProperty(e.prototype,"vertexSourceCode",{get:function(){var e,t;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._vertexSourceCodeOverride:null!==(t=null===(e=this._pipelineContext)||void 0===e?void 0:e._getVertexShaderCode())&&void 0!==t?t:this._vertexSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fragmentSourceCode",{get:function(){var e,t;return this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._fragmentSourceCodeOverride:null!==(t=null===(e=this._pipelineContext)||void 0===e?void 0:e._getFragmentShaderCode())&&void 0!==t?t: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,n,i){var o=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){i&&i(t)},this.onCompiled=function(){var e=o.getEngine().scenes;if(e)for(var t=0;t=a&&(r="Offending line [".concat(a,"] in ").concat(n?"fragment":"vertex"," code: ").concat(s[a-1]))}}return[e,r]},e.prototype._processCompilationErrors=function(t,n){var i,r,o,s,c;void 0===n&&(n=null),this._compilationError=t.message;var u=this._attributesNames,l=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: "+u.map((function(e){return" "+e}))),a.a.Error("Defines:\r\n"+this.defines),e.LogShaderCodeOnCompilationError){var h=null,d=null,p=null;(null===(o=this._pipelineContext)||void 0===o?void 0:o._getVertexShaderCode())&&(p=(i=this._getShaderCodeAndErrorLine(this._pipelineContext._getVertexShaderCode(),this._compilationError,!1))[0],h=i[1],p&&(a.a.Error("Vertex code:"),a.a.Error(p))),(null===(s=this._pipelineContext)||void 0===s?void 0:s._getFragmentShaderCode())&&(p=(r=this._getShaderCodeAndErrorLine(null===(c=this._pipelineContext)||void 0===c?void 0:c._getFragmentShaderCode(),this._compilationError,!0))[0],d=r[1],p&&(a.a.Error("Fragment code:"),a.a.Error(p))),h&&a.a.Error(h),d&&a.a.Error(d)}a.a.Error("Error: "+this._compilationError),n&&(this._pipelineContext=n,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),l?(this._pipelineContext=null,l.hasMoreFallbacks?(this._allFallbacksProcessed=!1,a.a.Error("Trying next fallback."),this.defines=l.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)},e.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers[e],this._uniforms[e],t,e)},e.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers[e],this._uniforms[e],t,e)},e.prototype.setTextureArray=function(e,t){var n=e+"Ex";if(-1===this._samplerList.indexOf(n+"0")){for(var i=this._samplerList.indexOf(e),r=1;r>2,o=(3&t)<<4|(n=l>4,a=(15&n)<<2|(i=l>6,s=63&i,isNaN(n)?a=s=64:isNaN(i)&&(s=64),u+=c.charAt(r)+c.charAt(o)+c.charAt(a)+c.charAt(s);return u},s=function(e){return atob(e)},c=function(e){for(var t=s(e),n=t.length,i=new Uint8Array(new ArrayBuffer(n)),r=0;r0&&(t.push(s-1),t.push(s)),s++}var d=new o.a;return d.indices=t,d.positions=n,r&&(d.colors=a),d}function u(e){var t,n,r=e.dashSize||3,a=e.gapSize||1,s=e.dashNb||200,c=e.points,u=new Array,l=new Array,h=i.e.Zero(),d=0,p=0,f=0,_=0,m=0;for(m=0;m0)):!n._pointerCaptures[l.pointerId]&&c.distance>u.distance&&(n.mainSceneTrackerPredicate&&n.mainSceneTrackerPredicate(u.pickedMesh)?(n._notifyObservers(t,u,l),t.skipOnPointerObservable=!0):t.type!==o.a.POINTERMOVE&&t.type!==o.a.POINTERUP||(n._lastPointerEvents[l.pointerId]&&(n.onPointerOutObservable.notifyObservers(l.pointerId),delete n._lastPointerEvents[l.pointerId]),n._notifyObservers(t,c,l))),t.type===o.a.POINTERUP&&n._pointerCaptures[l.pointerId]&&(n._pointerCaptures[l.pointerId]=!1))}}}})),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterCameraRenderObservable.add((function(e){n.shouldRender&&e==n.getRenderCamera()&&(e.outputRenderTarget&&e.isRigCamera&&n.originalScene.getEngine().clear(null,!1,!0,!1),n.render())})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){n.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 c.a("shared gizmo light",new u.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._CreateDefaultUtilityLayerFromScene(s.a.LastCreatedScene):e._DefaultUtilityLayer},enumerable:!1,configurable:!0}),e._CreateDefaultUtilityLayerFromScene=function(t){return e._DefaultUtilityLayer=new e(t),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null})),e._DefaultUtilityLayer},Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(s.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!1,configurable:!0}),e.prototype._notifyObservers=function(e,t,n){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(e.type,e.event,t),e.type),this._lastPointerEvents[n.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,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(167),r=function(){function e(){}return e.EnableFor=function(t){t._tags=t._tags||{},t.hasTags=function(){return e.HasTags(t)},t.addTags=function(n){return e.AddTagsTo(t,n)},t.removeTags=function(n){return e.RemoveTagsFrom(t,n)},t.matchesTagsQuery=function(n){return e.MatchesQuery(t,n)}},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 n in t)if(t.hasOwnProperty(n))return!0;return!1},e.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var n=[];for(var i in e._tags)e._tags.hasOwnProperty(i)&&!0===e._tags[i]&&n.push(i);return n.join(" ")}return e._tags},e.AddTagsTo=function(t,n){n&&("string"==typeof n&&n.split(" ").forEach((function(n,i,r){e._AddTagTo(t,n)})))},e._AddTagTo=function(t,n){""!==(n=n.trim())&&"true"!==n&&"false"!==n&&(n.match(/[\s]/)||n.match(/^([!]|([|]|[&]){2})/)||(e.EnableFor(t),t._tags[n]=!0))},e.RemoveTagsFrom=function(t,n){if(e.HasTags(t)){var i=n.split(" ");for(var r in i)e._RemoveTagFrom(t,i[r])}},e._RemoveTagFrom=function(e,t){delete e._tags[t]},e.MatchesQuery=function(t,n){return void 0===n||(""===n?e.HasTags(t):i.a.Eval(n,(function(n){return e.HasTags(t)&&t._tags[n]})))},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o}));var i=n(2),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;tthis.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;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(i.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;tu.x)return!1}else if(r=1/this.direction.x,o=(c.x-this.origin.x)*r,(a=(u.x-this.origin.x)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(l=Math.max(o,l))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yu.y)return!1}else if(r=1/this.direction.y,o=(c.y-this.origin.y)*r,(a=(u.y-this.origin.y)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(l=Math.max(o,l))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zu.z)return!1}else if(r=1/this.direction.z,o=(c.z-this.origin.z)*r,(a=(u.z-this.origin.z)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(l=Math.max(o,l))>(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 n=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,o=n*n+i*i+r*r,a=e.radius+t,s=a*a;if(o<=s)return!0;var c=n*this.direction.x+i*this.direction.y+r*this.direction.z;return!(c<0)&&o-c*c<=s},e.prototype.intersectsTriangle=function(t,n,i){var o=e._TmpVector3[0],s=e._TmpVector3[1],c=e._TmpVector3[2],u=e._TmpVector3[3],l=e._TmpVector3[4];n.subtractToRef(t,o),i.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,u);var p=r.e.Dot(u,c)*d;if(p<0||p>1)return null;r.e.CrossToRef(u,o,l);var f=r.e.Dot(this.direction,l)*d;if(f<0||p+f>1)return null;var _=r.e.Dot(s,l)*d;return _>this.length?null:new a.a(1-p-f,p,_)},e.prototype.intersectsPlane=function(e){var t,n=r.e.Dot(e.normal,this.direction);if(Math.abs(n)<9.99999997475243e-7)return null;var i=r.e.Dot(e.normal,this.origin);return(t=(-e.d-i)/n)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsAxis=function(e,t){switch(void 0===t&&(t=0),e){case"y":return(n=(this.origin.y-t)/this.direction.y)>0?null:new r.e(this.origin.x+this.direction.x*-n,t,this.origin.z+this.direction.z*-n);case"x":return(n=(this.origin.x-t)/this.direction.x)>0?null:new r.e(t,this.origin.y+this.direction.y*-n,this.origin.z+this.direction.z*-n);case"z":var n;return(n=(this.origin.z-t)/this.direction.z)>0?null:new r.e(this.origin.x+this.direction.x*-n,this.origin.y+this.direction.y*-n,t);default:return null}},e.prototype.intersectsMesh=function(t,n){var i=r.c.Matrix[0];return t.getWorldMatrix().invertToRef(i),this._tmpRay?e.TransformToRef(this,i,this._tmpRay):this._tmpRay=e.Transform(this,i),t.intersects(this._tmpRay,n)},e.prototype.intersectsMeshes=function(e,t,n){n?n.length=0:n=[];for(var i=0;it.distance?1:0},e.prototype.intersectionSegment=function(t,n,i){var o=this.origin,a=r.c.Vector3[0],s=r.c.Vector3[1],c=r.c.Vector3[2],u=r.c.Vector3[3];n.subtractToRef(t,a),this.direction.scaleToRef(e.rayl,c),o.addToRef(c,s),t.subtractToRef(o,u);var l,h,d,p,f=r.e.Dot(a,a),_=r.e.Dot(a,c),m=r.e.Dot(c,c),g=r.e.Dot(a,u),v=r.e.Dot(c,u),b=f*m-_*_,y=b,T=b;by&&(h=y,p=v+_,T=m)),p<0?(p=0,-g<0?h=0:-g>f?h=y:(h=-g,y=f)):p>T&&(p=T,-g+_<0?h=0:-g+_>f?h=y:(h=-g+_,y=f)),l=Math.abs(h)0&&d<=this.length&&A.lengthSquared()=e.distance?null:u:null},s.a.prototype._internalPick=function(e,t,n,i,a){if(!o.a)return null;for(var s=null,c=0;c-1&&this._parentContainer.transformNodes.splice(i,1),this._parentContainer=null}if(this.onAfterWorldMatrixUpdateObservable.clear(),t)for(var r=0,o=this.getChildTransformNodes(!0);r0)if("object"==typeof l[0])for(var d=0;d1)?1:e.arc||1,u=e.slice&&e.slice<=0?1:e.slice||1,l=0===e.sideOrientation?0:e.sideOrientation||o.a.DEFAULTSIDE,h=!!e.dedupTopBottomIndices,d=new i.e(n/2,r/2,s/2),p=2+t,f=2*p,_=[],m=[],g=[],v=[],b=0;b<=p;b++){for(var y=b/p,T=y*Math.PI*u,E=0;E<=f;E++){var S=E/f,A=S*Math.PI*2*c,x=i.a.RotationZ(-T),R=i.a.RotationY(A),C=i.e.TransformCoordinates(i.e.Up(),x),P=i.e.TransformCoordinates(C,R),O=P.multiply(d),M=P.divide(d).normalize();m.push(O.x,O.y,O.z),g.push(M.x,M.y,M.z),v.push(S,a.a.UseOpenGLOrientationForUV?1-y:y)}if(b>0)for(var I=m.length/3,D=I-2*(f+1);D+f+21&&(_.push(D),_.push(D+1),_.push(D+f+1)),(b0&&-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.prototype.dispose=function(t,n){if(void 0===n&&(n=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this),this._parentContainer){var i=this._parentContainer.lights.indexOf(this);i>-1&&this._parentContainer.lights.splice(i,1),this._parentContainer=null}for(var r=0,o=this.getScene().meshes;r0&&(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.isEnabled=this.isEnabled(),e},t.GetConstructorFromName=function(e,t,n){var i=s.a.Construct("Light_Type_"+e,t,n);return i||null},t.Parse=function(e,n){var i=t.GetConstructorFromName(e.type,e.name,n);if(!i)return null;var o=r.a.Parse(i,e,n);if(e.excludedMeshesIds&&(o._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=e.includedOnlyMeshesIds),void 0!==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=0&&this._scene.textures.splice(t,1),this._scene.onTextureRemovedObservable.notifyObservers(this),this._scene=null,this._parentContainer){var n=this._parentContainer.textures.indexOf(this);n>-1&&this._parentContainer.textures.splice(n,1),this._parentContainer=null}}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.metadata=null,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 n=e.length;if(0!==n)for(var i=0;i=200&&i.status<300||0===i.status&&(!Object(o.e)()||P())){try{t(s?i.response:i.responseText,i)}catch(e){_(e)}return}var n=T.DefaultRetryStrategy;if(n){var u=n(l,i,d);if(-1!==u)return i.removeEventListener("loadend",p),i=new r.a,void(a=setTimeout((function(){return m(d+1)}),u))}var f=new b("Error status: "+i.status+" "+i.statusText+" - Unable to load "+l,i);c&&c(f)}},i.addEventListener("readystatechange",e),i.send()}};m(0)};if(i&&i.enableSceneOffline){var _=function(e){e&&e.status>400?c&&c(e):p()};i.open((function(){i&&i.loadFile(T.BaseUrl+e,(function(e){h||t(e),d.onCompleteObservable.notifyObservers(d)}),n?function(e){h||n(e)}:void 0,_,s)}),_)}else p();return d},P=function(){return"undefined"!=typeof location&&"file:"===location.protocol},O=function(e){return g.test(e)};function M(e){return Object(l.b)(e.split(",")[1])}var I=function(e){return Object(l.c)(e.split(",")[1])};d.a._FileToolsLoadImage=A,d.a._FileToolsLoadFile=R,h.a._FileToolsLoadFile=R,Object(m.b)(M,I,T,O,P,R,A,x,C,S)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(e,t,n,i,r,o){this.source=e,this.pointerX=t,this.pointerY=n,this.meshUnderPointer=i,this.sourceEvent=r,this.additionalData=o}return e.CreateNew=function(t,n,i){var r=t.getScene();return new e(t,r.pointerX,r.pointerY,r.meshUnderPointer||t,n,i)},e.CreateNewFromSprite=function(t,n,i,r){return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer,i,r)},e.CreateNewFromScene=function(t,n){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,n)},e.CreateNewFromPrimitive=function(t,n,i,r){return new e(t,n.x,n.y,null,i,r)},e}()},function(e,t,n){"use strict";n.d(t,"b",(function(){return l})),n.d(t,"a",(function(){return h})),n.d(t,"c",(function(){return d}));var i=n(0),r=n(8),o=n(9),a=n(19),s=n(22),c=n(26),u=n(32);function l(e){var t=e.height||2,n=0===e.diameterTop?0:e.diameterTop||e.diameter||1,s=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1;n=n||1e-5,s=s||1e-5;var l,h=e.tessellation||24,d=e.subdivisions||1,p=!!e.hasRings,f=!!e.enclose,_=0===e.cap?0:e.cap||o.a.CAP_ALL,m=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,g=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,v=e.faceUV||new Array(3),b=e.faceColors,y=2+(1+(1!==m&&f?2:0))*(p?d:1);for(l=0;l1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(e,t,n,i){this.x=e,this.y=t,this.width=n,this.height=i}return e.prototype.toGlobal=function(t,n){return new e(this.x*t,this.y*n,this.width*t,this.height*n)},e.prototype.toGlobalToRef=function(e,t,n){return n.x=this.x*e,n.y=this.y*t,n.width=this.width*e,n.height=this.height*t,this},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return a}));var i=n(2),r=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(i.d)(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t}(Error),o={MeshInvalidPositionsError:0,UnsupportedTextureError:1e3,GLTFLoaderUnexpectedMagicError:2e3,SceneLoaderError:3e3,LoadFileError:4e3,RequestFileError:4001,ReadFileError:4002},a=function(e){function t(n,i,o){var a=e.call(this,n)||this;return a.errorCode=i,a.innerError=o,a.name="RuntimeError",r._setPrototypeOf(a,t.prototype),a}return Object(i.d)(t,e),t}(r)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(e){if(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,this._externalProperties=e,e)for(var t in e)e.hasOwnProperty(t)&&this._setDefaultValue(t)}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);ec&&(c=h)}return new e(t,s,c-s+1,n,i,r,o,a)},e}()},function(e,t,n){"use strict";n.d(t,"c",(function(){return c})),n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return l}));var i=n(0),r=n(8),o=n(9),a=n(19),s=n(32);function c(e){var t,n=[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],c=[],u=e.width||e.size||1,l=e.height||e.size||1,h=e.depth||e.size||1,d=e.wrap||!1,p=void 0===e.topBaseAt?1:e.topBaseAt,f=void 0===e.bottomBaseAt?0:e.bottomBaseAt,_=[2,0,3,1][p=(p+4)%4],m=[2,0,1,3][f=(f+4)%4],g=[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(d){n=[2,3,0,2,0,1,4,5,6,4,6,7,9,10,11,9,11,8,12,14,15,12,13,14],g=[-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 v=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],b=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],y=[17,18,19,16],T=[22,23,20,21];_>0;)v.unshift(v.pop()),y.unshift(y.pop()),_--;for(;m>0;)b.unshift(b.pop()),T.unshift(T.pop()),m--;v=v.flat(),b=b.flat(),g=g.concat(v).concat(b),n.push(y[0],y[2],y[3],y[0],y[1],y[2]),n.push(T[0],T[2],T[3],T[0],T[1],T[2])}var E=[u/2,l/2,h/2];t=g.reduce((function(e,t,n){return e.concat(t*E[n%3])}),[]);for(var S=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,A=e.faceUV||new Array(6),x=e.faceColors,R=[],C=0;C<6;C++)void 0===A[C]&&(A[C]=new i.f(0,0,1,1)),x&&void 0===x[C]&&(x[C]=new r.b(1,1,1,1));for(var P=0;P<6;P++)if(c.push(A[P].z,s.a.UseOpenGLOrientationForUV?1-A[P].w:A[P].w),c.push(A[P].x,s.a.UseOpenGLOrientationForUV?1-A[P].w:A[P].w),c.push(A[P].x,s.a.UseOpenGLOrientationForUV?1-A[P].y:A[P].y),c.push(A[P].z,s.a.UseOpenGLOrientationForUV?1-A[P].y:A[P].y),x)for(var O=0;O<4;O++)R.push(x[P].r,x[P].g,x[P].b,x[P].a);a.a._ComputeSides(S,t,n,o,c,e.frontUVs,e.backUVs);var M=new a.a;if(M.indices=n,M.positions=t,M.normals=o,M.uvs=c,x){var I=S===a.a.DOUBLESIDE?R.concat(R):R;M.colors=I}return M}function u(e,t,n){void 0===t&&(t={}),void 0===n&&(n=null);var i=new o.a(e,n);return t.sideOrientation=o.a._GetDefaultSideOrientation(t.sideOrientation),i._originalBuilderSideOrientation=t.sideOrientation,c(t).applyToMesh(i,t.updatable),i}var l={CreateBox:u};a.a.CreateBox=c,o.a.CreateBox=function(e,t,n,i,r){return void 0===n&&(n=null),u(e,{size:t,sideOrientation:r,updatable:i},n)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(7),r=n(12),o=(n(184),function(){function e(e,t,n,i){this._valueCache={},this._engine=e,this._noUBO=!e.supportsUniformBuffers,this._dynamic=n,this._name=null!=i?i:"no-name",this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformArraySizes={},this._uniformLocationPointer=0,this._needSync=!1,this._engine._features.trackUbosInFrame&&(this._buffers=[],this._bufferIndex=-1,this._createBufferOnWrite=!1,this._currentFrameId=0),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.updateFloatArray=this._updateFloatArrayForEffect,this.updateArray=this._updateArrayForEffect,this.updateIntArray=this._updateIntArrayForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateMatrices=this._updateMatricesForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect,this.updateDirectColor4=this._updateDirectColor4ForEffect,this.updateInt=this._updateIntForEffect,this.updateInt2=this._updateInt2ForEffect,this.updateInt3=this._updateInt3ForEffect,this.updateInt4=this._updateInt4ForEffect):(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.updateFloatArray=this._updateFloatArrayForUniform,this.updateArray=this._updateArrayForUniform,this.updateIntArray=this._updateIntArrayForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateMatrices=this._updateMatricesForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform,this.updateDirectColor4=this._updateDirectColor4ForUniform,this.updateInt=this._updateIntForUniform,this.updateInt2=this._updateInt2ForUniform,this.updateInt3=this._updateInt3ForUniform,this.updateInt4=this._updateInt4ForUniform)}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 n=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;for(var i=this._uniformLocationPointer-n,r=0;r0){if(t instanceof Array)throw"addUniform should not be use with Array in UBO: "+e;if(this._fillAlignment(4),this._uniformArraySizes[e]={strideSize:t,arraySize:n},16==t)t*=n;else t=t*n+(4-t)*n;i=[];for(var r=0;r1&&this._buffers[this._bufferIndex][1]){if(this._buffersEqual(this._bufferData,this._buffers[this._bufferIndex][1]))return this._needSync=!1,void(this._createBufferOnWrite=this._engine._features.trackUbosInFrame);this._copyBuffer(this._bufferData,this._buffers[this._bufferIndex][1])}this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._engine._features._collectUbosUpdatedInFrame&&(e._updatedUbosInFrame[this._name]||(e._updatedUbosInFrame[this._name]=0),e._updatedUbosInFrame[this._name]++),this._needSync=!1,this._createBufferOnWrite=this._engine._features.trackUbosInFrame}else this._createBufferOnWrite=this._engine._features.trackUbosInFrame;else this.create()},e.prototype._createNewBuffer=function(){this._bufferIndex+10?(this._needSync=0!==this._bufferIndex,this._bufferIndex=0,this._buffer=this._buffers[this._bufferIndex][0]):this._bufferIndex=-1)},e.prototype.updateUniform=function(e,t,n){this._checkNewFrame();var o=this._uniformLocations[e];if(void 0===o){if(this._buffer)return void i.a.Error("Cannot add an uniform after UBO has been created.");this.addUniform(e,n),o=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(s=0;s1&&(this._multiview=!0,f.push("#define MULTIVIEW"),-1!==this._options.uniforms.indexOf("viewProjection")&&-1===this._options.uniforms.indexOf("viewProjectionR")&&this._options.uniforms.push("viewProjectionR"));for(var E=0;E4&&(m.push(a.b.MatricesIndicesExtraKind),m.push(a.b.MatricesWeightsExtraKind));var A=e.skeleton;f.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),g.addCPUSkinningFallback(0,e),A.isUsingTextureForMatrices?(f.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")):(f.push("#define BonesPerMesh "+(A.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else f.push("#define NUM_BONE_INFLUENCERS 0");var x=0,R=e?e.morphTargetManager:null;if(R){var C=R.supportsUVs&&-1!==f.indexOf("#define UV1"),P=R.supportsTangents&&-1!==f.indexOf("#define TANGENT"),O=R.supportsNormals&&-1!==f.indexOf("#define NORMAL");x=R.numInfluencers,C&&f.push("#define MORPHTARGETS_UV"),P&&f.push("#define MORPHTARGETS_TANGENT"),O&&f.push("#define MORPHTARGETS_NORMAL"),x>0&&f.push("#define MORPHTARGETS"),R.isUsingTextureForTargets&&(f.push("#define MORPHTARGETS_TEXTURE"),-1===this._options.uniforms.indexOf("morphTargetTextureIndices")&&this._options.uniforms.push("morphTargetTextureIndices"),-1===this._options.samplers.indexOf("morphTargets")&&this._options.samplers.push("morphTargets")),f.push("#define NUM_MORPH_INFLUENCERS "+x);for(E=0;E0&&((b=b.slice()).push("morphTargetInfluences"),b.push("morphTargetTextureInfo"),b.push("morphTargetTextureIndices"))}else f.push("#define NUM_MORPH_INFLUENCERS 0");if(e){var M=e.bakedVertexAnimationManager;M&&M.isEnabled&&(f.push("#define BAKED_VERTEX_ANIMATION_TEXTURE"),-1===this._options.uniforms.indexOf("bakedVertexAnimationSettings")&&this._options.uniforms.push("bakedVertexAnimationSettings"),-1===this._options.uniforms.indexOf("bakedVertexAnimationTextureSizeInverted")&&this._options.uniforms.push("bakedVertexAnimationTextureSizeInverted"),-1===this._options.uniforms.indexOf("bakedVertexAnimationTime")&&this._options.uniforms.push("bakedVertexAnimationTime"),-1===this._options.samplers.indexOf("bakedVertexAnimationTexture")&&this._options.samplers.push("bakedVertexAnimationTexture")),c.a.PrepareAttributesForBakedVertexAnimation(m,e,f)}for(var I in this._textures)if(!this._textures[I].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&f.push("#define ALPHATEST"),(null===this._options.useClipPlane&&d.clipPlane||this._options.useClipPlane)&&(f.push("#define CLIPPLANE"),-1===b.indexOf("vClipPlane")&&b.push("vClipPlane")),(null===this._options.useClipPlane&&d.clipPlane2||this._options.useClipPlane)&&(f.push("#define CLIPPLANE2"),-1===b.indexOf("vClipPlane2")&&b.push("vClipPlane2")),(null===this._options.useClipPlane&&d.clipPlane3||this._options.useClipPlane)&&(f.push("#define CLIPPLANE3"),-1===b.indexOf("vClipPlane3")&&b.push("vClipPlane3")),(null===this._options.useClipPlane&&d.clipPlane4||this._options.useClipPlane)&&(f.push("#define CLIPPLANE4"),-1===b.indexOf("vClipPlane4")&&b.push("vClipPlane4")),(null===this._options.useClipPlane&&d.clipPlane5||this._options.useClipPlane)&&(f.push("#define CLIPPLANE5"),-1===b.indexOf("vClipPlane5")&&b.push("vClipPlane5")),(null===this._options.useClipPlane&&d.clipPlane6||this._options.useClipPlane)&&(f.push("#define CLIPPLANE6"),-1===b.indexOf("vClipPlane6")&&b.push("vClipPlane6")),this.customShaderNameResolve&&(b=b.slice(),y=y.slice(),T=T.slice(),v=this.customShaderNameResolve(v,b,y,T,f,m));var D=u?n._getDrawWrapper():this._drawWrapper,N=null!==(i=null==D?void 0:D.effect)&&void 0!==i?i:null,L=null!==(r=null==D?void 0:D.defines)&&void 0!==r?r:null,F=f.join("\n"),w=N;return L!==F&&(w=p.createEffect(v,{attributes:m,uniformsNames:b,uniformBuffersNames:y,samplers:T,defines:F,fallbacks:g,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousMorphTargets:x},shaderLanguage:this._options.shaderLanguage},p),u?n.setEffect(w,F,this._materialContext):D&&D.setEffect(w,F),this._onEffectCreatedObservable&&(_.effect=w,_.subMesh=null!==(o=null!=n?n:null==e?void 0:e.subMeshes[0])&&void 0!==o?o:null,this._onEffectCreatedObservable.notifyObservers(_))),this._effectUsesInstances=!!t,null!==(s=!(null==w?void 0:w.isReady()))&&void 0!==s&&!s&&(N!==w&&d.resetCachedMaterial(),w._wasPreviouslyReady=!0,!0)},t.prototype.bindOnlyWorldMatrix=function(e,t){var n=this.getScene(),i=null!=t?t:this.getEffect();i&&(-1!==this._options.uniforms.indexOf("world")&&i.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(n.getViewMatrix(),this._cachedWorldViewMatrix),i.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&(e.multiplyToRef(n.getTransformMatrix(),this._cachedWorldViewProjectionMatrix),i.setMatrix("worldViewProjection",this._cachedWorldViewProjectionMatrix)))},t.prototype.bindForSubMesh=function(e,t,n){var i;this.bind(e,t,null===(i=n._drawWrapperOverride)||void 0===i?void 0:i.effect,n)},t.prototype.bind=function(e,t,n,i){var r,o=i&&this._storeEffectOnSubMeshes,a=null!=n?n:o?i.effect:this.getEffect();if(a){this._activeEffect=a,this.bindOnlyWorldMatrix(e,n);var s=this._options.uniformBuffers,u=!1;if(a&&s&&s.length>0&&this.getScene().getEngine().supportsUniformBuffers)for(var l=0;l0&&c.a.BindMorphTargetParameters(t,a);var m=t.bakedVertexAnimationManager;m&&m.isEnabled&&(null===(r=t.bakedVertexAnimationManager)||void 0===r||r.bind(a,this._effectUsesInstances))}this._afterBind(t,a)}},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);for(var n in this._textures)t.push(this._textures[n]);for(var n in this._textureArrays)for(var i=this._textureArrays[n],r=0;ru.max||u.min>c.max)},d=function(){function e(e,t,n){this._isLocked=!1,this.boundingBox=new a.a(e,t,n),this.boundingSphere=new s.a(e,t,n)}return e.prototype.reConstruct=function(e,t,n){this.boundingBox.reConstruct(e,t,n),this.boundingSphere.reConstruct(e,t,n)},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,n){var i=e.TmpVector3[0].copyFrom(t).subtractInPlace(n),r=e.TmpVector3[1].copyFrom(t).addInPlace(n);return this.boundingBox.reConstruct(i,r,this.boundingBox.getWorldMatrix()),this.boundingSphere.reConstruct(i,r,this.boundingBox.getWorldMatrix()),this},e.prototype.encapsulate=function(e){var t=r.e.Minimize(this.minimum,e),n=r.e.Maximize(this.maximum,e);return this.reConstruct(t,n,this.boundingBox.getWorldMatrix()),this},e.prototype.encapsulateBoundingInfo=function(e){return this.encapsulate(e.boundingBox.centerWorld.subtract(e.boundingBox.extendSizeWorld)),this.encapsulate(e.boundingBox.centerWorld.add(e.boundingBox.extendSizeWorld)),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 n=this.boundingBox,i=e.boundingBox;return!!h(n.directions[0],n,i)&&(!!h(n.directions[1],n,i)&&(!!h(n.directions[2],n,i)&&(!!h(i.directions[0],n,i)&&(!!h(i.directions[1],n,i)&&(!!h(i.directions[2],n,i)&&(!!h(r.e.Cross(n.directions[0],i.directions[0]),n,i)&&(!!h(r.e.Cross(n.directions[0],i.directions[1]),n,i)&&(!!h(r.e.Cross(n.directions[0],i.directions[2]),n,i)&&(!!h(r.e.Cross(n.directions[1],i.directions[0]),n,i)&&(!!h(r.e.Cross(n.directions[1],i.directions[1]),n,i)&&(!!h(r.e.Cross(n.directions[1],i.directions[2]),n,i)&&(!!h(r.e.Cross(n.directions[2],i.directions[0]),n,i)&&(!!h(r.e.Cross(n.directions[2],i.directions[1]),n,i)&&!!h(r.e.Cross(n.directions[2],i.directions[2]),n,i))))))))))))))},e.TmpVector3=i.a.BuildArray(2,r.e.Zero),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(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(i.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 i.e,e._PivotTranslation=new i.e,e._PivotTmpVector=new i.e,e._PivotPostMultiplyPivotMatrix=!1,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var i=n(9),r=n(22),o=n(6),a=n(0),s=n(20),c=n(45),u=n(76),l=n(71),h=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.onEnabledObservable=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,"currentDraggingPointerID",{get:function(){return this.currentDraggingPointerId},set:function(e){this.currentDraggingPointerId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){e!=this._enabled&&this.onEnabledObservable.notifyObservers(e),this._enabled=e},enumerable:!1,configurable:!0}),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,n){var o=this;this._scene=t.getScene(),t.isNearGrabbable=!0,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=Object(l.a)("pointerDragPlane",{size:this._debugMode?1:1e4,updatable:!1,sideOrientation:i.a.DOUBLESIDE},e._planeScene),this.lastDragPosition=new a.e(0,0,0);var h=n||function(e){return o.attachedNode==e||e.isDescendantOf(o.attachedNode)};this._pointerObserver=this._scene.onPointerObservable.add((function(t,n){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&&h(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 i=t.event.pointerId;if(o.currentDraggingPointerId===e._AnyMouseId&&i!==e._AnyMouseId){var r=t.event;("mouse"===r.pointerType||!o._scene.getEngine().hostInformation.isMobile&&r instanceof MouseEvent)&&(o._lastPointerRay[o.currentDraggingPointerId]&&(o._lastPointerRay[i]=o._lastPointerRay[o.currentDraggingPointerId],delete o._lastPointerRay[o.currentDraggingPointerId]),o.currentDraggingPointerId=i)}o._lastPointerRay[i]||(o._lastPointerRay[i]=new c.a(new a.e,new a.e)),t.pickInfo&&t.pickInfo.ray&&(o._lastPointerRay[i].origin.copyFrom(t.pickInfo.ray.origin),o._lastPointerRay[i].direction.copyFrom(t.pickInfo.ray.direction),o.currentDraggingPointerId==i&&o.dragging&&o._moveDrag(t.pickInfo.ray))}}else o._attachedToElement&&o.releaseDrag()})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){if(o._moving&&o.moveAttached){var e=!1;u.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),e=!0),u.a._RestorePivotPoint(o.attachedNode),e&&o.attachedNode.computeWorldMatrix()}}))},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,n,i){void 0===t&&(t=e._AnyMouseId),this._startDrag(t,n,i);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,n){if(this._scene.activeCamera&&!this.dragging&&this.attachedNode){u.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,n||this._tmpVector);var i=this._pickWithRayOnDragPlane(this._startDragRay);i&&(this.dragging=!0,this.currentDraggingPointerId=e,this.lastDragPosition.copyFrom(i),this.onDragStartObservable.notifyObservers({dragPlanePoint:i,pointerId:this.currentDraggingPointerId}),this._targetPosition.copyFrom(this.attachedNode.getAbsolutePosition()),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)),u.a._RestorePivotPoint(this.attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){u.a._RemoveAndStorePivotPoint(this.attachedNode),this.updateDragPlane&&this._updateDragPlanePosition(e,t);var n=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),n=a.e.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(n,this._dragDelta)):(n=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:n,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerId}),this.lastDragPosition.copyFrom(t),u.a._RestorePivotPoint(this.attachedNode)}},e.prototype._pickWithRayOnDragPlane=function(t){var n=this;if(!t)return null;var i=Math.acos(a.e.Dot(this._dragPlane.forward,t.direction));if(i>Math.PI/2&&(i=Math.PI-i),this.maxDragAngle>0&&i>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==n._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.getAbsolutePosition()),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this.attachedNode.isNearGrabbable=!1,this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this._dragPlane.dispose(),this.releaseDrag()},e._AnyMouseId=-2,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o})),n.d(t,"c",(function(){return a}));var i=n(2),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,n){var i=e.call(this,t,n)||this;return i.type=t,i.event=n,i.skipOnKeyboardObservable=!1,i}return Object(i.d)(t,e),Object.defineProperty(t.prototype,"skipOnPointerObservable",{get:function(){return this.skipOnKeyboardObservable},set:function(e){this.skipOnKeyboardObservable=e},enumerable:!1,configurable:!0}),t}(o)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=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]||(ethis._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,ethis._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 n=this._mesh.getScene(),i=0;i0&&(r.computeBonesUsingShaders=!1)}}else{var s=this._defines[this._currentRank];if(s)for(i=0;i=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 n;if(e.prototype.hasTexture.call(this,t))return!0;for(var i=0;i=0&&r.multiMaterials.splice(o,1),e.prototype.dispose.call(this,t,n)}},t.ParseMultiMaterial=function(e,n){var i=new t(e.name,n);return i.id=e.id,i._loadedUniqueId=e.uniqueId,o.a&&o.a.AddTagsTo(i,e.tags),e.materialsUniqueIds?i._waitingSubMaterialsUniqueIds=e.materialsUniqueIds:e.materials.forEach((function(e){return i.subMaterials.push(n.getLastMaterialById(e))})),i},t}(r.a);Object(a.b)("BABYLON.MultiMaterial",s)},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(1),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=i.a.SCENELOADER_NO_LOGGING,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(2),r=n(3),o=n(180),a=n(1),s=function(){function e(e,t,n,i,r,s){void 0===r&&(r=!0),void 0===s&&(s=!1),this.priority=500,this.registerForExtraEvents=!1,this._material=e,this.name=t,this.priority=n,e.pluginManager||(e.pluginManager=new o.a(e)),this._pluginDefineNames=i,this._pluginManager=e.pluginManager,r&&this._pluginManager._addPlugin(this),s&&this._enable(!0),this.markAllDefinesAsDirty=e._dirtyCallbacks[a.a.MATERIAL_AllDirtyFlag]}return e.prototype._enable=function(e){e&&this._pluginManager._activatePlugin(this)},e.prototype.getClassName=function(){return"MaterialPluginBase"},e.prototype.isReadyForSubMesh=function(e,t,n,i){return!0},e.prototype.hardBindForSubMesh=function(e,t,n,i){},e.prototype.bindForSubMesh=function(e,t,n,i){},e.prototype.dispose=function(e){},e.prototype.getCustomCode=function(e){return null},e.prototype.collectDefines=function(e){if(this._pluginDefineNames)for(var t=0,n=Object.keys(this._pluginDefineNames);t0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,this._updatable)),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e),this._vertexArrayObjects&&this._disposeVertexArrayObjects();for(var t=0,n=this._meshes;t0){for(var t=0;t0){for(t=0;t0){for(t=0;t-1&&this._parentContainer.geometries.splice(r,1),this._parentContainer=null}this._isDisposed=!0},e.prototype.copy=function(t){var n=new o.a;n.indices=[];var i=this.getIndices();if(i)for(var r=0;r0){var h=new Float32Array(t,l.positionsAttrDesc.offset,l.positionsAttrDesc.count);n.setVerticesData(a.b.PositionKind,h,!1)}if(l.normalsAttrDesc&&l.normalsAttrDesc.count>0){var d=new Float32Array(t,l.normalsAttrDesc.offset,l.normalsAttrDesc.count);n.setVerticesData(a.b.NormalKind,d,!1)}if(l.tangetsAttrDesc&&l.tangetsAttrDesc.count>0){var p=new Float32Array(t,l.tangetsAttrDesc.offset,l.tangetsAttrDesc.count);n.setVerticesData(a.b.TangentKind,p,!1)}if(l.uvsAttrDesc&&l.uvsAttrDesc.count>0){var f=new Float32Array(t,l.uvsAttrDesc.offset,l.uvsAttrDesc.count);if(_.a.UseOpenGLOrientationForUV)for(var m=1;m0){var g=new Float32Array(t,l.uvs2AttrDesc.offset,l.uvs2AttrDesc.count);if(_.a.UseOpenGLOrientationForUV)for(m=1;m0){var v=new Float32Array(t,l.uvs3AttrDesc.offset,l.uvs3AttrDesc.count);if(_.a.UseOpenGLOrientationForUV)for(m=1;m0){var b=new Float32Array(t,l.uvs4AttrDesc.offset,l.uvs4AttrDesc.count);if(_.a.UseOpenGLOrientationForUV)for(m=1;m0){var y=new Float32Array(t,l.uvs5AttrDesc.offset,l.uvs5AttrDesc.count);if(_.a.UseOpenGLOrientationForUV)for(m=1;m0){var T=new Float32Array(t,l.uvs6AttrDesc.offset,l.uvs6AttrDesc.count);if(_.a.UseOpenGLOrientationForUV)for(m=1;m0){var E=new Float32Array(t,l.colorsAttrDesc.offset,l.colorsAttrDesc.count);n.setVerticesData(a.b.ColorKind,E,!1,l.colorsAttrDesc.stride)}if(l.matricesIndicesAttrDesc&&l.matricesIndicesAttrDesc.count>0){for(var S=new Int32Array(t,l.matricesIndicesAttrDesc.offset,l.matricesIndicesAttrDesc.count),A=[],x=0;x>8),A.push((16711680&m)>>16),A.push(m>>24&255)}n.setVerticesData(a.b.MatricesIndicesKind,A,!1)}if(l.matricesIndicesExtraAttrDesc&&l.matricesIndicesExtraAttrDesc.count>0){for(S=new Int32Array(t,l.matricesIndicesExtraAttrDesc.offset,l.matricesIndicesExtraAttrDesc.count),A=[],x=0;x>8),A.push((16711680&m)>>16),A.push(m>>24&255)}n.setVerticesData(a.b.MatricesIndicesExtraKind,A,!1)}if(l.matricesWeightsAttrDesc&&l.matricesWeightsAttrDesc.count>0){var R=new Float32Array(t,l.matricesWeightsAttrDesc.offset,l.matricesWeightsAttrDesc.count);n.setVerticesData(a.b.MatricesWeightsKind,R,!1)}if(l.indicesAttrDesc&&l.indicesAttrDesc.count>0){var C=new Int32Array(t,l.indicesAttrDesc.offset,l.indicesAttrDesc.count);n.setIndices(C,null)}if(l.subMeshesAttrDesc&&l.subMeshesAttrDesc.count>0){var P=new Int32Array(t,l.subMeshesAttrDesc.offset,5*l.subMeshesAttrDesc.count);n.subMeshes=[];for(x=0;x>8),A.push((16711680&L)>>16),A.push(L>>24&255)}n.setVerticesData(a.b.MatricesIndicesKind,A,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,n.setVerticesData(a.b.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(A=[],x=0;x>8),A.push((16711680&L)>>16),A.push(L>>24&255)}n.setVerticesData(a.b.MatricesIndicesExtraKind,A,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,n),n.setVerticesData(a.b.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&n.setVerticesData(a.b.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),n.setIndices(t.indices,null)}if(t.subMeshes){n.subMeshes=[];for(var F=0;F-1){var i=t.getScene().getLastSkeletonById(e.skeletonId);if(i){n=i.bones.length;for(var r=t.getVerticesData(a.b.MatricesIndicesKind),o=t.getVerticesData(a.b.MatricesIndicesExtraKind),s=e.matricesWeights,u=e.matricesWeightsExtra,l=e.numBoneInfluencer,h=s.length,d=0;dl-1)&&(f=l-1),p>.001){var g=1/p;for(_=0;_<4;_++)s[d+_]*=g;if(u)for(_=0;_<4;_++)u[d+_]*=g}else f>=4?(u[d+f-4]=1-p,o[d+f-4]=n):(s[d+f]=1-p,r[d+f]=n)}t.setVerticesData(a.b.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(a.b.MatricesIndicesExtraKind,o)}}}},e.Parse=function(t,n,r){var s=new e(t.id,n,void 0,t.updatable);return s._loadedUniqueId=t.uniqueId,d.a&&d.a.AddTagsTo(s,t.tags),t.delayLoadingFile?(s.delayLoadState=l.a.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=r+t.delayLoadingFile,s._boundingInfo=new u.a(i.e.FromArray(t.boundingBoxMinimum),i.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),n.pushGeometry(s,!0),s},e}()},function(e,t,n){"use strict";n.d(t,"e",(function(){return i})),n.d(t,"c",(function(){return s})),n.d(t,"a",(function(){return c})),n.d(t,"b",(function(){return u})),n.d(t,"f",(function(){return l})),n.d(t,"g",(function(){return h})),n.d(t,"d",(function(){return d}));var i,r=n(14),o=n(0),a=n(23);!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(i||(i={}));var s=function(){function e(){}return e.Interpolate=function(e,t,n,i,r){for(var o=1-3*i+3*t,a=3*i-6*t,s=3*t,c=e,u=0;u<5;u++){var l=c*c;c-=(o*(l*c)+a*l+s*c-e)*(1/(3*o*l+2*a*c+s)),c=Math.min(1,Math.max(0,c))}return 3*Math.pow(1-c,2)*c*n+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,n){var i=n.subtract(t);return new e(Math.atan2(i.y,i.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e}(),u=function(e,t,n){this.startPoint=e,this.midPoint=t,this.endPoint=n;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(n.x,2)-Math.pow(n.y,2))/2,u=(e.x-t.x)*(t.y-n.y)-(t.x-n.x)*(e.y-t.y);this.centerPoint=new o.d((a*(t.y-n.y)-s*(e.y-t.y))/u,((e.x-t.x)*s-(t.x-n.x)*a)/u),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=c.BetweenTwoPoints(this.centerPoint,this.startPoint);var l=this.startAngle.degrees(),h=c.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),d=c.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-l>180&&(h-=360),h-l<-180&&(h+=360),d-h>180&&(d-=360),d-h<-180&&(d+=360),this.orientation=h-l<0?i.CW:i.CCW,this.angle=c.FromDegrees(this.orientation===i.CW?l-d:d-l)},l=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 n=new o.d(e,t),i=this._points[this._points.length-1];return this._points.push(n),this._length+=n.subtract(i).length(),this},e.prototype.addArcTo=function(e,t,n,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),l=new o.d(n,r),h=new u(s,c,l),d=h.angle.radians()/a;h.orientation===i.CW&&(d*=-1);for(var p=h.startAngle.radians()+d,f=0;f1)return o.d.Zero();for(var t=e*this.length(),n=0,i=0;i=n&&t<=c){var u=s.normalize(),l=t-n;return new o.d(a.x+u.x*l,a.y+u.y*l)}n=c}return o.d.Zero()},e.StartingAt=function(t,n){return new e(t,n)},e}(),h=function(){function e(e,t,n,i){void 0===t&&(t=null),void 0===i&&(i=!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;rn){var i=t;t=n,n=i}var r=this.getCurve(),o=this.getPointAt(t),a=this.getPreviousPointIndexAt(t),s=this.getPointAt(n),c=this.getPreviousPointIndexAt(n)+1,u=[];return 0!==t&&(a++,u.push(o)),u.push.apply(u,r.slice(a,c)),1===n&&1!==t||u.push(s),new e(u,this.getNormalAt(t),this._raw,this._alignTangentsWithPath)},e.prototype.update=function(e,t,n){void 0===t&&(t=null),void 0===n&&(n=!1);for(var i=0;it+1;)t++,n=this._curve[e].subtract(this._curve[e-t]);return n},e.prototype._normalVector=function(e,t){var n,i,s=e.length();(0===s&&(s=1),null==t)?(i=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),n=o.e.Cross(e,i)):(n=o.e.Cross(e,t),o.e.CrossToRef(n,e,n));return n.normalize(),n},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 n=this.getPoints();if(e<=0)return this._setPointAtData(0,0,n[0],0,t);if(e>=1)return this._setPointAtData(1,1,n[n.length-1],n.length-1,t);for(var i,r=n[0],a=0,s=e*this.length(),c=1;cs){var l=(a-s)/u,h=r.subtract(i),d=i.add(h.scaleInPlace(l));return this._setPointAtData(e,1-l,d,c-1,t)}r=i}return this._pointAtData},e.prototype._setPointAtData=function(e,t,n,i,r){return this._pointAtData.point=n,this._pointAtData.position=e,this._pointAtData.subPosition=t,this._pointAtData.previousPointArrayIndex=i,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,n=this._tangents[e].clone(),i=this._normals[e].clone(),r=this._binormals[e].clone(),a=this._tangents[t].clone(),s=this._normals[t].clone(),c=this._binormals[t].clone(),u=o.b.RotationQuaternionFromAxis(i,r,n),l=o.b.RotationQuaternionFromAxis(s,c,a);o.b.Slerp(u,l,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,n,i,r){r=r>2?r:3;for(var a=new Array,s=function(e,t,n,i){return(1-e)*(1-e)*t+2*e*(1-e)*n+e*e*i},c=0;c<=r;c++)a.push(new o.e(s(c/r,t.x,n.x,i.x),s(c/r,t.y,n.y,i.y),s(c/r,t.z,n.z,i.z)));return new e(a)},e.CreateCubicBezier=function(t,n,i,r,a){a=a>3?a:4;for(var s=new Array,c=function(e,t,n,i,r){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*n+3*e*e*(1-e)*i+e*e*e*r},u=0;u<=a;u++)s.push(new o.e(c(u/a,t.x,n.x,i.x,r.x),c(u/a,t.y,n.y,i.y,r.y),c(u/a,t.z,n.z,i.z,r.z)));return new e(s)},e.CreateHermiteSpline=function(t,n,i,r,a){for(var s=new Array,c=1/a,u=0;u<=a;u++)s.push(o.e.Hermite(t,n,i,r,u*c));return new e(s)},e.CreateCatmullRomSpline=function(t,n,i){var r=new Array,a=1/n,s=0;if(i){for(var c=t.length,u=0;u_.snapDistance){var n=Math.floor(Math.abs(v)/_.snapDistance);v%=_.snapDistance,e.delta.normalizeToRef(b),b.scaleInPlace(_.snapDistance*n),_.attachedNode.getWorldMatrix().getTranslationToRef(y),y.addInPlace(b),_.dragBehavior.validateDrag(y)&&(_.attachedNode.getWorldMatrix().addTranslationFromFloats(b.x,b.y,b.z),_.attachedNode.updateCache(),T.snapDistance=_.snapDistance*n,_.onSnapObservable.notifyObservers(T),t=!0)}t&&_._matrixChanged()}})),_.dragBehavior.onDragStartObservable.add((function(){_._dragging=!0})),_.dragBehavior.onDragEndObservable.add((function(){_._dragging=!1}));var E=a._getSharedGizmoLight();E.includedOnlyMeshes=E.includedOnlyMeshes.concat(_._rootMesh.getChildMeshes(!1));var S={gizmoMeshes:m.getChildMeshes(),colliderMeshes:g.getChildMeshes(),material:_._coloredMaterial,hoverMaterial:_._hoverMaterial,disableMaterial:_._disableMaterial,active:!1,dragBehavior:_.dragBehavior};return null===(f=_._parent)||void 0===f||f.addToAxisCache(g,S),_._pointerObserver=a.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!_._customMeshSet&&(_._isHovered=!(-1==S.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!_._parent)){var n=_.dragBehavior.enabled?_._isHovered||_._dragging?_._hoverMaterial:_._coloredMaterial:_._disableMaterial;_._setGizmoMeshMaterial(S.gizmoMeshes,n)}})),_.dragBehavior.onEnabledObservable.add((function(e){_._setGizmoMeshMaterial(S.gizmoMeshes,e?S.material:S.disableMaterial)})),_}return Object(i.d)(t,e),t._CreateArrow=function(e,t,n,i){void 0===n&&(n=1),void 0===i&&(i=!1);var r=new a.a("arrow",e),o=Object(c.a)("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375*(1+(n-1)/4),tessellation:96},e),s=Object(c.a)("cylinder",{diameterTop:.005*n,height:.275,diameterBottom:.005*n,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,i&&(s.visibility=0,o.visibility=0),r},t._CreateArrowInstance=function(e,t){for(var n=new a.a("arrow",e),i=0,r=t.getChildMeshes();ic?c:Math.floor(u);var l,h,d,p,f=0===e.sideOrientation?0:e.sideOrientation||a.a.DEFAULTSIDE,_=e.uvs,m=e.colors,g=[],v=[],b=[],y=[],T=[],E=[],S=[],A=[],x=[],R=[];if(t.length<2){var C=[],P=[];for(d=0;d0&&(I=O[p].subtract(O[p-1]).length()+S[h],T[h].push(I),S[h]=I),p++;i&&(p--,g.push(O[0].x,O[0].y,O[0].z),I=O[p].subtract(O[0]).length()+S[h],T[h].push(I),S[h]=I),x[h]=M+F,R[h]=L,L+=M+F}var w,B,U=null,V=null;for(d=0;de?(t=a,setTimeout((function(){i(n,r,o)}),0)):i(n,r,o)}}function o(e,t,n,i,r){var o=function(){var a,s=function(e){e.done?n(e.value):void 0===a?a=!0:o()};do{a=void 0,r&&r.aborted?i(new Error("Aborted")):t(e,s,i),void 0===a&&(a=!1)}while(a)};o()}function a(e,t){var n;return o(e,i,(function(e){return n=e}),(function(e){throw e}),t),n}function s(e,t,n){return new Promise((function(i,r){o(e,t,i,r,n)}))}function c(e,t){return function(){for(var n=[],i=0;i1){for(r();-1!==i&&e._OperatorPriority[a()]>=e._OperatorPriority[h];)n.push(s());o(h),c++}else u+=l;c++}for(r();-1!==i;)"("===a()?s():n.push(s());return n},e._OperatorPriority={")":0,"(":1,"||":2,"&&":3},e._Stack=["","","","","","","","","","","","","","","","","","","",""],e}(),l=function(e){function t(t,n){void 0===n&&(n=!1);var i=e.call(this)||this;return i.define=t,i.not=n,i}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}(u),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}(u),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}(u),p=function(e){function t(t,n,i){var r=e.call(this)||this;return r.define=t,r.operand=n,r.testValue=i,r}return Object(a.d)(t,e),t.prototype.isTrue=function(e){var t=e[this.define];void 0===t&&(t=this.define);var n=!1,i=parseInt(t),r=parseInt(this.testValue);switch(this.operand){case">":n=i>r;break;case"<":n=i=":n=i>=r;break;case"==":n=i===r}return n},t}(u),f=n(25),_=n(44),m=/defined\s*?\((.+?)\)/g,g=/defined\s*?\[(.+?)\]/g,v=function(){function e(){}return e.Initialize=function(e){e.processor&&e.processor.initializeShaders&&e.processor.initializeShaders(e.processingContext)},e.Process=function(e,t,n,i){var r,o=this;(null===(r=t.processor)||void 0===r?void 0:r.preProcessShaderCode)&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),this._ProcessIncludes(e,t,(function(e){t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e));var r=o._ProcessShaderConversion(e,t,i);n(r)}))},e.PreProcess=function(e,t,n,i){var r,o=this;(null===(r=t.processor)||void 0===r?void 0:r.preProcessShaderCode)&&(e=t.processor.preProcessShaderCode(e,t.isFragment)),this._ProcessIncludes(e,t,(function(e){t.processCodeAfterIncludes&&(e=t.processCodeAfterIncludes(t.isFragment?"fragment":"vertex",e));var r=o._ApplyPreProcessing(e,t,i);n(r)}))},e.Finalize=function(e,t,n){return n.processor&&n.processor.finalizeShaders?n.processor.finalizeShaders(e,t,n.processingContext):{vertexCode:e,fragmentCode:t}},e._ProcessPrecision=function(e,t){var n;if(null===(n=t.processor)||void 0===n?void 0:n.noPrecision)return e;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 l(t[1].trim(),"!"===e[0]);for(var n="",i=0,r=0,o=["==",">=","<=","<",">"];r-1));r++);if(-1===i)return new l(e);var a=e.substring(0,i).trim(),s=e.substring(i+n.length).trim();return new p(a,n,s)},e._BuildSubExpression=function(e){e=e.replace(m,"defined[$1]");for(var t=[],n=0,i=u.infixToPostfix(e);n=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(g,"defined($1)")),"string"==typeof a&&(a=a.replace(g,"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(g,"defined($1)")),"string"==typeof c?this._ExtractOperation(c):c},e._BuildExpression=function(e,t){var n=new c,i=e.substring(0,t),r=e.substring(t);return r=r.substring(0,(r.indexOf("//")+1||r.length+1)-1).trim(),n.testExpression="#ifdef"===i?new l(r):"#ifndef"===i?new l(r,!0):this._BuildSubExpression(r),n},e._MoveCursorWithinIf=function(e,t,n){for(var i=e.currentLine;this._MoveCursor(e,n);){var o=(i=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(i,5);t.children.push(s),n=s}}},e._MoveCursor=function(e,t){for(;e.canRead;){e.lineIndex++;var n=e.currentLine,i=/(#ifdef)|(#else)|(#elif)|(#endif)|(#ifndef)|(#if)/.exec(n);if(i&&i.length){switch(i[0]){case"#ifdef":var o=new s;t.children.push(o);var a=this._BuildExpression(n,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(n,7);o.children.push(a),this._MoveCursorWithinIf(e,o,a);break;case"#if":o=new s,a=this._BuildExpression(n,3);t.children.push(o),o.children.push(a),this._MoveCursorWithinIf(e,o,a)}}else{var c=new r;if(c.line=n,t.children.push(c),"#"===n[0]&&"d"===n[1]){var u=n.replace(";","").split(" ");c.additionalDefineKey=u[1],3===u.length&&(c.additionalDefineValue=u[2])}}}return!1},e._EvaluatePreProcessors=function(e,t,n){var i=new r,a=new o;return a.lineIndex=-1,a.lines=e.split("\n"),this._MoveCursor(a,i),i.process(t,n)},e._PreparePreProcessors=function(e,t){for(var n,i={},r=0,o=e.defines;r1?a[1]:""}return(null===(n=e.processor)||void 0===n?void 0:n.shaderLanguage)===_.a.GLSL&&(i.GL_ES="true"),i.__VERSION__=e.version,i[e.platformName]="true",t._getGlobalDefines(i),i},e._ProcessShaderConversion=function(e,t,n){var i=this._ProcessPrecision(e,t);if(!t.processor)return i;if(t.processor.shaderLanguage===_.a.GLSL&&-1!==i.indexOf("#version 3"))return i.replace("#version 300 es","");var r=t.defines,o=this._PreparePreProcessors(t,n);return t.processor.preProcessor&&(i=t.processor.preProcessor(i,r,t.isFragment,t.processingContext)),i=this._EvaluatePreProcessors(i,o,t),t.processor.postProcessor&&(i=t.processor.postProcessor(i,r,t.isFragment,t.processingContext,n)),n._features.needShaderCodeInlining&&(i=n.inlineShaderCode(i)),i},e._ApplyPreProcessing=function(e,t,n){var i,r,o=e,a=t.defines,s=this._PreparePreProcessors(t,n);return(null===(i=t.processor)||void 0===i?void 0:i.preProcessor)&&(o=t.processor.preProcessor(o,a,t.isFragment,t.processingContext)),o=this._EvaluatePreProcessors(o,s,t),(null===(r=t.processor)||void 0===r?void 0:r.postProcessor)&&(o=t.processor.postProcessor(o,a,t.isFragment,t.processingContext,n)),n._features.needShaderCodeInlining&&(o=n.inlineShaderCode(o)),o},e._ProcessIncludes=function(t,n,i){for(var r=this,o=/#include\s?<(.+)>(\((.*)\))*(\[(.*)\])*/g,a=o.exec(t),s=new String(t),c=!1;null!=a;){var u=a[1];if(-1!==u.indexOf("__decl__")&&(u=u.replace(/__decl__/,""),n.supportsUniformBuffers&&(u=(u=u.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),u+="Declaration"),!n.includesShadersStore[u]){var l=n.shadersRepository+"ShadersInclude/"+u+".fx";return void e._FileToolsLoadFile(l,(function(e){n.includesShadersStore[u]=e,r._ProcessIncludes(s,n,i)}))}var h=n.includesShadersStore[u];if(a[2])for(var d=a[3].split(","),p=0;p=0||h.indexOf("#include <")>=0,a=o.exec(t)}c?this._ProcessIncludes(s.toString(),n,i):i(s)},e._FileToolsLoadFile=function(e,t,n,i,r,o){throw Object(f.a)("FileTools")},e}()},function(e,t,n){"use strict";var i="bakedVertexAnimationDeclaration",r="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform float bakedVertexAnimationTime;\nuniform vec2 bakedVertexAnimationTextureSizeInverted;\nuniform vec4 bakedVertexAnimationSettings;\nuniform sampler2D bakedVertexAnimationTexture;\n#ifdef INSTANCES\nattribute vec4 bakedVertexAnimationSettingsInstanced;\n#endif\n#define inline\nmat4 readMatrixFromRawSamplerVAT(sampler2D smp,float index,float frame)\n{\nfloat offset=index*4.0;\nfloat frameUV=(frame+0.5)*bakedVertexAnimationTextureSizeInverted.y;\nfloat dx=bakedVertexAnimationTextureSizeInverted.x;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),frameUV));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),frameUV));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),frameUV));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),frameUV));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="instancesDeclaration",r="#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#ifdef INSTANCESCOLOR\nattribute vec4 instanceColor;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nattribute vec4 previousWorld0;\nattribute vec4 previousWorld1;\nattribute vec4 previousWorld2;\nattribute vec4 previousWorld3;\n#ifdef THIN_INSTANCES\nuniform mat4 previousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform mat4 world;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nuniform mat4 previousWorld;\n#endif\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="bakedVertexAnimation",r="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n#ifdef INSTANCES\n#define BVASNAME bakedVertexAnimationSettingsInstanced\n#else\n#define BVASNAME bakedVertexAnimationSettings\n#endif\n\nfloat VATStartFrame=BVASNAME.x;\nfloat VATEndFrame=BVASNAME.y;\nfloat VATOffsetFrame=BVASNAME.z;\nfloat VATSpeed=BVASNAME.w;\nfloat totalFrames=VATEndFrame-VATStartFrame+1.0;\nfloat time=bakedVertexAnimationTime*VATSpeed/totalFrames;\n\nfloat frameCorrection=time<1.0 ? 0.0 : 1.0;\nfloat numOfFrames=totalFrames-frameCorrection;\nfloat VATFrameNum=fract(time)*numOfFrames;\nVATFrameNum=mod(VATFrameNum+VATOffsetFrame,numOfFrames);\nVATFrameNum=floor(VATFrameNum);\nVATFrameNum+=VATStartFrame+frameCorrection;\nmat4 VATInfluence;\nVATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence+=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;\n}\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";function i(){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)}))}n.d(t,"b",(function(){return i})),n.d(t,"a",(function(){return r}));var r={RandomId:i}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(24),r=n(1),o=function(){function e(e,t,n,i){this._textures=null,this._attachments=null,this._generateStencilBuffer=!1,this._generateDepthBuffer=!1,this._depthStencilTextureWithStencil=!1,this._isMulti=e,this._isCube=t,this._size=n,this._engine=i,this._depthStencilTexture=null}return Object.defineProperty(e.prototype,"depthStencilTexture",{get:function(){return this._depthStencilTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"depthStencilTextureWithStencil",{get:function(){return this._depthStencilTextureWithStencil},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCube",{get:function(){return this._isCube},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isMulti",{get:function(){return this._isMulti},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"is2DArray",{get:function(){return this.layers>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"size",{get:function(){return this.width},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._size.width||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._size.height||this._size},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"layers",{get:function(){return this._size.layers||0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){var e,t;return null!==(t=null===(e=this._textures)||void 0===e?void 0:e[0])&&void 0!==t?t:null},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textures",{get:function(){return this._textures},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"samples",{get:function(){var e,t;return null!==(t=null===(e=this.texture)||void 0===e?void 0:e.samples)&&void 0!==t?t:1},enumerable:!1,configurable:!0}),e.prototype.setSamples=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n=!1),this.samples!==e||n?this._isMulti?this._engine.updateMultipleRenderTargetTextureSampleCount(this,e,t):this._engine.updateRenderTargetTextureSampleCount(this,e):e},e.prototype.setTextures=function(e){Array.isArray(e)?this._textures=e:this._textures=e?[e]:null},e.prototype.setTexture=function(e,t,n){void 0===t&&(t=0),void 0===n&&(n=!0),this._textures||(this._textures=[]),this._textures[t]&&n&&this._textures[t].dispose(),this._textures[t]=e},e.prototype.createDepthStencilTexture=function(e,t,n,i,o){var a;return void 0===e&&(e=0),void 0===t&&(t=!0),void 0===n&&(n=!1),void 0===i&&(i=1),void 0===o&&(o=r.a.TEXTUREFORMAT_DEPTH32_FLOAT),null===(a=this._depthStencilTexture)||void 0===a||a.dispose(),this._depthStencilTextureWithStencil=n,this._depthStencilTexture=this._engine.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:n,isCube:this._isCube,samples:i,depthTextureFormat:o},this),this._depthStencilTexture},e.prototype._shareDepth=function(e){this._depthStencilTexture&&(e._depthStencilTexture&&e._depthStencilTexture.dispose(),e._depthStencilTexture=this._depthStencilTexture,this._depthStencilTexture.incrementReferences())},e.prototype._swapAndDie=function(e){this.texture&&this.texture._swapAndDie(e),this._textures=null,this.dispose(!0)},e.prototype._cloneRenderTargetWrapper=function(){var e,t,n,r,o,a,s=null;if(this._isMulti){var c=this.textures;if(c&&c.length>0){var u=!1,l=c.length,h=c[c.length-1]._source;h!==i.b.Depth&&h!==i.b.DepthStencil||(u=!0,l--);for(var d=[],p=[],f=0;f1&&e.setSamples(this.samples),e._swapRenderTargetWrapper(this),e.dispose()}},e.prototype.releaseTextures=function(){var e,t;if(this._textures)for(var n=0;null!==(t=n<(null===(e=this._textures)||void 0===e?void 0:e.length))&&void 0!==t&&t;++n)this._textures[n].dispose();this._textures=null},e.prototype.dispose=function(e){var t;void 0===e&&(e=!1),e||(null===(t=this._depthStencilTexture)||void 0===t||t.dispose(),this._depthStencilTexture=null,this.releaseTextures()),this._engine._releaseRenderTargetWrapper(this)},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var i=n(2),r=n(3),o=n(0),a=n(8),s=n(30),c=n(53);s.a.AddNodeConstructor("Light_Type_3",(function(e,t){return function(){return new u(e,o.e.Zero(),t)}}));var u=function(e){function t(t,n,i){var r=e.call(this,t,i)||this;return r.groundColor=new a.a(0,0,0),r.direction=n||o.e.Up(),r}return Object(i.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 n=o.e.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",n.x,n.y,n.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this},t.prototype.transferToNodeMaterialEffect=function(e,t){var n=o.e.Normalize(this.direction);return e.setFloat3(t,n.x,n.y,n.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(i.c)([Object(r.f)()],t.prototype,"groundColor",void 0),Object(i.c)([Object(r.p)()],t.prototype,"direction",void 0),t}(c.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(2),r=function(e){function t(t){var n=e.call(this)||this;return n._buffer=t,n}return Object(i.d)(t,e),Object.defineProperty(t.prototype,"underlyingResource",{get:function(){return this._buffer},enumerable:!1,configurable:!0}),t}(n(83).a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(72),r=function(){function e(){}return e.GetPlanes=function(t){for(var n=[],r=0;r<6;r++)n.push(new i.a(0,0,0,0));return e.GetPlanesToRef(t,n),n},e.GetNearPlaneToRef=function(e,t){var n=e.m;t.normal.x=n[3]+n[2],t.normal.y=n[7]+n[6],t.normal.z=n[11]+n[10],t.d=n[15]+n[14],t.normalize()},e.GetFarPlaneToRef=function(e,t){var n=e.m;t.normal.x=n[3]-n[2],t.normal.y=n[7]-n[6],t.normal.z=n[11]-n[10],t.d=n[15]-n[14],t.normalize()},e.GetLeftPlaneToRef=function(e,t){var n=e.m;t.normal.x=n[3]+n[0],t.normal.y=n[7]+n[4],t.normal.z=n[11]+n[8],t.d=n[15]+n[12],t.normalize()},e.GetRightPlaneToRef=function(e,t){var n=e.m;t.normal.x=n[3]-n[0],t.normal.y=n[7]-n[4],t.normal.z=n[11]-n[8],t.d=n[15]-n[12],t.normalize()},e.GetTopPlaneToRef=function(e,t){var n=e.m;t.normal.x=n[3]-n[1],t.normal.y=n[7]-n[5],t.normal.z=n[11]-n[9],t.d=n[15]-n[13],t.normalize()},e.GetBottomPlaneToRef=function(e,t){var n=e.m;t.normal.x=n[3]+n[1],t.normal.y=n[7]+n[5],t.normal.z=n[11]+n[9],t.d=n[15]+n[13],t.normalize()},e.GetPlanesToRef=function(t,n){e.GetNearPlaneToRef(t,n[0]),e.GetFarPlaneToRef(t,n[1]),e.GetLeftPlaneToRef(t,n[2]),e.GetRightPlaneToRef(t,n[3]),e.GetTopPlaneToRef(t,n[4]),e.GetBottomPlaneToRef(t,n[5])},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(52),r=n(0),o=function(){function e(e,t,n){this.center=r.e.Zero(),this.centerWorld=r.e.Zero(),this.minimum=r.e.Zero(),this.maximum=r.e.Zero(),this.reConstruct(e,t,n)}return e.prototype.reConstruct=function(e,t,n){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var i=r.e.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*i,this._update(n||r.a.IdentityReadOnly)},e.prototype.scale=function(t){var n=this.radius*t,i=e.TmpVector3,r=i[0].setAll(n),o=this.center.subtractToRef(r,i[1]),a=this.center.addToRef(r,i[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 n=e.TmpVector3[0];r.e.TransformNormalFromFloatsToRef(1,1,1,t,n),this.radiusWorld=Math.max(Math.abs(n.x),Math.abs(n.y),Math.abs(n.z))*this.radius}},e.prototype.isInFrustum=function(e){for(var t=this.centerWorld,n=this.radiusWorld,i=0;i<6;i++)if(e[i].dotCoordinate(t)<=-n)return!1;return!0},e.prototype.isCenterInFrustum=function(e){for(var t=this.centerWorld,n=0;n<6;n++)if(e[n].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=i.a.ACTION_OnPickTrigger&&n<=i.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!1,configurable:!0}),e.HasSpecificTrigger=function(t){for(var n in e.Triggers){if(e.Triggers.hasOwnProperty(n))if(parseInt(n)===t)return!0}return!1},e.Triggers={},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(35),r=function(){function e(){}return e.SetImmediate=function(e){Object(i.e)()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},e}()},function(e,t,n){"use strict";var i="clipPlaneFragment",r="#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\n\n\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelse if (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nelse if (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nelse if (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nelse if (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nelse if (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nelse if (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="morphTargetsVertexGlobalDeclaration",r="#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#ifdef MORPHTARGETS_TEXTURE\nprecision mediump sampler2DArray;\nuniform float morphTargetTextureIndices[NUM_MORPH_INFLUENCERS];\nuniform vec3 morphTargetTextureInfo;\nuniform sampler2DArray morphTargets;\nvec3 readVector3FromRawSampler(int targetIndex,float vertexIndex)\n{\nfloat y=floor(vertexIndex/morphTargetTextureInfo.y);\nfloat x=vertexIndex-y*morphTargetTextureInfo.y;\nvec3 textureUV=vec3((x+0.5)/morphTargetTextureInfo.y,(y+0.5)/morphTargetTextureInfo.z,morphTargetTextureIndices[targetIndex]);\nreturn texture(morphTargets,textureUV).xyz;\n}\n#endif\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="morphTargetsVertexDeclaration",r="#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\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\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="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";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(4),r=n(1),o=function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[i.b.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[i.b.PositionKind]=new i.b(this._scene.getEngine(),e,i.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[i.b.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())},e.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var n=this._scene.activeCamera;return!!n&&(!(!(t=t||n._postProcesses.filter((function(e){return null!=e})))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(n,e,null!=t),!0))},e.prototype.directRender=function(e,t,n,i,o,a){var s;void 0===t&&(t=null),void 0===n&&(n=!1),void 0===i&&(i=0),void 0===o&&(o=0),void 0===a&&(a=!1);for(var c=this._scene.getEngine(),u=0;u3?0:p,f);var R=Object(o.a)(e,{pathArray:S,closeArray:h,closePath:d,updatable:m,sideOrientation:g,invertUV:b,frontUVs:y||void 0,backUVs:T||void 0},_);return R._creationDataStorage.pathArray=S,R._creationDataStorage.path3D=E,R._creationDataStorage.cap=p,R}var l={ExtrudeShape:s,ExtrudeShapeCustom:c};r.a.ExtrudeShape=function(e,t,n,i,o,a,c,u,l,h){return void 0===c&&(c=null),s(e,{shape:t,path:n,scale:i,rotation:o,cap:0===a?0:a||r.a.NO_CAP,sideOrientation:l,instance:h,updatable:u},c)},r.a.ExtrudeShapeCustom=function(e,t,n,i,o,a,s,u,l,h,d,p){return c(e,{shape:t,path:n,scaleFunction:i,rotationFunction:o,ribbonCloseArray:a,ribbonClosePath:s,cap:0===u?0:u||r.a.NO_CAP,sideOrientation:d,instance:p,updatable:h},l)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){}return e.FilesToLoad={},e}()},function(e,t,n){"use strict";n.d(t,"b",(function(){return l})),n.d(t,"a",(function(){return h}));var i=n(2),r=n(8),o=n(4),a=n(9),s=n(181),c=n(29),u=n(74);n(205),n(206);a.a._LinesMeshParser=function(e,t){return l.Parse(e,t)};var l=function(e){function t(t,n,i,a,s,c,l,h){void 0===n&&(n=null),void 0===i&&(i=null),void 0===a&&(a=null);var d=e.call(this,t,n,i,a,s)||this;d.useVertexColor=c,d.useVertexAlpha=l,d.color=new r.a(1,1,1),d.alpha=1,a&&(d.color=a.color.clone(),d.alpha=a.alpha,d.useVertexColor=a.useVertexColor,d.useVertexAlpha=a.useVertexAlpha),d.intersectionThreshold=.1;var p={attributes:[o.b.PositionKind],uniforms:["vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","world","viewProjection"],needAlphaBlending:!0,defines:[],useClipPlane:null};return!1===l&&(p.needAlphaBlending=!1),c?(p.defines.push("#define VERTEXCOLOR"),p.attributes.push(o.b.ColorKind)):(p.uniforms.push("color"),d.color4=new r.b),d.material=h||new u.a("colorShader",d.getScene(),"color",p,!1),d}return Object(i.d)(t,e),t.prototype._isShaderMaterial=function(e){return"ShaderMaterial"===e.getClassName()},t.prototype.isReady=function(){return!!this._lineMaterial.isReady(this,!!this._userInstancedBuffersStorage)&&e.prototype.isReady.call(this)},t.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(t.prototype,"material",{get:function(){return this._lineMaterial},set:function(e){this._lineMaterial=e,this._lineMaterial.fillMode=c.a.LineListDrawMode},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"checkCollisions",{get:function(){return!1},set:function(e){},enumerable:!1,configurable:!0}),t.prototype._bind=function(e,t,n){if(!this._geometry)return this;var i=this._lineMaterial.getEffect(),r=this.isUnIndexed?null:this._geometry.getIndexBuffer();if(this._userInstancedBuffersStorage?this._geometry._bind(i,r,this._userInstancedBuffersStorage.vertexBuffers,this._userInstancedBuffersStorage.vertexArrayObjects):this._geometry._bind(i,r),!this.useVertexColor&&this._isShaderMaterial(this._lineMaterial)){var o=this.color,a=o.r,s=o.g,c=o.b;this.color4.set(a,s,c,this.alpha),this._lineMaterial.setColor4("color",this.color4)}return this},t.prototype._draw=function(e,t,n){if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;var i=this.getScene().getEngine();return this._unIndexed?i.drawArraysType(c.a.LineListDrawMode,e.verticesStart,e.verticesCount,n):i.drawElementsType(c.a.LineListDrawMode,e.indexStart,e.indexCount,n),this},t.prototype.dispose=function(t){this._lineMaterial.dispose(!1,!1,!0),e.prototype.dispose.call(this,t)},t.prototype.clone=function(e,n,i){return void 0===n&&(n=null),new t(e,this.getScene(),n,this,i)},t.prototype.createInstance=function(e){var t=new h(e,this);if(this.instancedBuffers)for(var n in t.instancedBuffers={},this.instancedBuffers)t.instancedBuffers[n]=this.instancedBuffers[n];return t},t.prototype.serialize=function(t){e.prototype.serialize.call(this,t),t.color=this.color.asArray(),t.alpha=this.alpha},t.Parse=function(e,n){var i=new t(e.name,n);return i.color=r.a.FromArray(e.color),i.alpha=e.alpha,i},t}(a.a),h=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.intersectionThreshold=n.intersectionThreshold,i}return Object(i.d)(t,e),t.prototype.getClassName=function(){return"InstancedLinesMesh"},t}(s.a)},function(e,t,n){"use strict";n.r(t),n.d(t,"AxesViewer",(function(){return u})),n.d(t,"BoneAxesViewer",(function(){return d})),n.d(t,"DebugLayerTab",(function(){return i})),n.d(t,"DebugLayer",(function(){return g})),n.d(t,"PhysicsViewer",(function(){return x})),n.d(t,"RayHelper",(function(){return C})),n.d(t,"SkeletonViewer",(function(){return L})),n.d(t,"DirectionalLightFrustumViewer",(function(){return B}));var i,r=n(0),o=n(33),a=n(87),s=n(8),c=n(16),u=function(){function e(t,n,i,u,l,h){if(void 0===n&&(n=1),void 0===i&&(i=2),this._scaleLinesFactor=4,this._instanced=!1,this.scene=null,this.scaleLines=1,t=t||c.a.LastCreatedScene){if(this.scaleLines=n,!u){var d=new o.a("",t);d.disableLighting=!0,d.emissiveColor=s.a.Red().scale(.5),u=a.a._CreateArrow(t,d)}if(!l){var p=new o.a("",t);p.disableLighting=!0,p.emissiveColor=s.a.Green().scale(.5),l=a.a._CreateArrow(t,p)}if(!h){var f=new o.a("",t);f.disableLighting=!0,f.emissiveColor=s.a.Blue().scale(.5),h=a.a._CreateArrow(t,f)}this._xAxis=u,this._xAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._yAxis=l,this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis=h,this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),null!=i&&(e._SetRenderingGroupId(this._xAxis,i),e._SetRenderingGroupId(this._yAxis,i),e._SetRenderingGroupId(this._zAxis,i)),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,n,i){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(n),this._yAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor),this._zAxis.position.copyFrom(e),this._zAxis.setDirection(i),this._zAxis.scaling.setAll(this.scaleLines*this._scaleLinesFactor)},e.prototype.createInstance=function(){var t=a.a._CreateArrowInstance(this.scene,this._xAxis),n=a.a._CreateArrowInstance(this.scene,this._yAxis),i=a.a._CreateArrowInstance(this.scene,this._zAxis),r=new e(this.scene,this.scaleLines,null,t,n,i);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=n(2),h=n(26),d=function(e){function t(t,n,i,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=i,a.bone=n,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(h.a.X,this.mesh,this.xaxis),t.getDirectionToRef(h.a.Y,this.mesh,this.yaxis),t.getDirectionToRef(h.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}(u),p=n(12),f=n(6),_=n(22),m=n(13);Object.defineProperty(_.a.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new g(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"}(i||(i={}));var g=function(){function e(e){var t=this;this.BJSINSPECTOR=this._getGlobalInspector(),this._scene=e||c.a.LastCreatedScene,this._scene&&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,n=this._onPropertyChangedObservable.observers;t-1&&this._debugMeshMeshes.splice(o,1),this._numMeshes--,this._numMeshes>0?(this._meshes[i]=this._meshes[this._numMeshes],this._impostors[i]=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=Object(b.b)("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=Object(y.a)("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=r.b.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodySphereViewInstance")},e.prototype._getDebugCapsuleMesh=function(e){return this._debugCapsuleMesh||(this._debugCapsuleMesh=Object(A.b)("physicsBodyCapsuleViewMesh",{height:1},e),this._debugCapsuleMesh.rotationQuaternion=r.b.Identity(),this._debugCapsuleMesh.material=this._getDebugMaterial(e),this._debugCapsuleMesh.setEnabled(!1)),this._debugCapsuleMesh.createInstance("physicsBodyCapsuleViewInstance")},e.prototype._getDebugCylinderMesh=function(e){return this._debugCylinderMesh||(this._debugCylinderMesh=Object(S.a)("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("physicsBodyCylinderViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var n=new v.a(e.name,t,null,e);return n.setParent(e),n.position=r.e.Zero(),n.material=this._getDebugMaterial(t),this._debugMeshMeshes.push(n),n},e.prototype._getDebugMesh=function(e,t){var n=this;if(!this._utilityLayer)return null;if(t&&t.parent&&t.parent.physicsImpostor)return null;var i=null,r=this._utilityLayer.utilityLayerScene;switch(e.type){case T.a.BoxImpostor:i=this._getDebugBoxMesh(r),e.getBoxSizeToRef(i.scaling);break;case T.a.SphereImpostor:i=this._getDebugSphereMesh(r);var o=e.getRadius();i.scaling.x=2*o,i.scaling.y=2*o,i.scaling.z=2*o;break;case T.a.CapsuleImpostor:i=this._getDebugCapsuleMesh(r);var a=e.object.getBoundingInfo();i.scaling.x=2*(a.boundingBox.maximum.x-a.boundingBox.minimum.x)*e.object.scaling.x,i.scaling.y=(a.boundingBox.maximum.y-a.boundingBox.minimum.y)*e.object.scaling.y,i.scaling.z=2*(a.boundingBox.maximum.z-a.boundingBox.minimum.z)*e.object.scaling.z;break;case T.a.MeshImpostor:t&&(i=this._getDebugMeshMesh(t,r));break;case T.a.NoImpostor:if(t)t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){if(e.physicsImpostor&&"Mesh"===e.getClassName()){var t=e.getBoundingInfo(),o=t.boundingBox.minimum,a=t.boundingBox.maximum;switch(e.physicsImpostor.type){case T.a.BoxImpostor:(i=n._getDebugBoxMesh(r)).position.copyFrom(o),i.position.addInPlace(a),i.position.scaleInPlace(.5);break;case T.a.SphereImpostor:i=n._getDebugSphereMesh(r);break;case T.a.CylinderImpostor:i=n._getDebugCylinderMesh(r);break;default:i=null}i&&(i.scaling.x=a.x-o.x,i.scaling.y=a.y-o.y,i.scaling.z=a.z-o.z,i.parent=e)}}));i=null;break;case T.a.CylinderImpostor:i=this._getDebugCylinderMesh(r);a=e.object.getBoundingInfo();i.scaling.x=(a.boundingBox.maximum.x-a.boundingBox.minimum.x)*e.object.scaling.x,i.scaling.y=(a.boundingBox.maximum.y-a.boundingBox.minimum.y)*e.object.scaling.y,i.scaling.z=(a.boundingBox.maximum.z-a.boundingBox.minimum.z)*e.object.scaling.z}return i},e.prototype.dispose=function(){for(var e=this._numMeshes,t=0;te.DISPLAY_SPHERE_AND_SPURS&&(C=e.DISPLAY_LINES),this.displayMode=C,this.update(),this._bindObs()}return e.CreateBoneWeightShader=function(e,t){var n,i,r,o,a,c,u=e.skeleton,l=null!==(n=e.colorBase)&&void 0!==n?n:s.a.Black(),h=null!==(i=e.colorZero)&&void 0!==i?i:s.a.Blue(),d=null!==(r=e.colorQuarter)&&void 0!==r?r:s.a.Green(),p=null!==(o=e.colorHalf)&&void 0!==o?o:s.a.Yellow(),f=null!==(a=e.colorFull)&&void 0!==a?a:s.a.Red(),_=null!==(c=e.targetBoneIndex)&&void 0!==c?c:0;D.a.ShadersStore["boneWeights:"+u.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\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include\n\n #include\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\n #include\n #include\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 }",D.a.ShadersStore["boneWeights:"+u.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 O.a("boneWeight:"+u.name,t,{vertex:"boneWeights:"+u.name,fragment:"boneWeights:"+u.name},{attributes:["position","normal","matricesIndices","matricesWeights"],uniforms:["world","worldView","worldViewProjection","view","projection","viewProjection","colorBase","colorZero","colorQuarter","colorHalf","colorFull","targetBoneIndex"]});return m.setColor3("colorBase",l),m.setColor3("colorZero",h),m.setColor3("colorQuarter",d),m.setColor3("colorHalf",p),m.setColor3("colorFull",f),m.setFloat("targetBoneIndex",_),m.getClassName=function(){return"BoneWeightShader"},m.transparencyMode=P.a.MATERIAL_OPAQUE,m},e.CreateSkeletonMapShader=function(t,n){var i,r=t.skeleton,o=null!==(i=t.colorMap)&&void 0!==i?i:[{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,n),u=new O.a("boneWeights:"+r.name,n,{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\n #if NUM_BONE_INFLUENCERS == 0\n attribute vec4 matricesIndices;\n attribute vec4 matricesWeights;\n #endif\n #include\n #include\n\n varying vec3 vColor;\n\n void main() {\n vec3 positionUpdated = position;\n\n #include\n #include\n #include\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 u.setFloats("colorMap",c),u.getClassName=function(){return"SkeletonMapShader"},u.transparencyMode=P.a.MATERIAL_OPAQUE,u},e._CreateBoneMapColorBuffer=function(e,t,n){var i=new M.a("temp",{width:e,height:1},n,!1),r=i.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),i.update();for(var a=[],s=r.getImageData(0,0,e,1).data,c=0;ce.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,n,i,o,a){void 0===i&&(i=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!==i||0!==o||0!==a){var u=r.c.Matrix[1];r.a.IdentityToRef(u),u.setTranslationFromFloats(i,o,a),u.multiplyToRef(s,s)}c&&s.multiplyToRef(c.getAbsoluteTransform(),s),s.multiplyToRef(n,s),e.x=s.m[12],e.y=s.m[13],e.z=s.m[14]},e.prototype._getLinesForBonesWithLength=function(e,t){for(var n=e.length,i=this.mesh.position,o=0,a=0;a=0;a--){var s=e[a],c=s.getParent();if(c&&(this._boneIndices.has(s.getIndex())||this.options.useAllBones)){var u=this._debugLines[n];u||(u=[r.e.Zero(),r.e.Zero()],this._debugLines[n]=u),s.getAbsolutePositionToRef(i,u[0]),c.getAbsolutePositionToRef(i,u[1]),u[0].subtractInPlace(o),u[1].subtractInPlace(o),n++}}},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.getBaseMatrix().multiplyToRef(t,t)):t.copyFrom(r.a.Identity())},e.prototype._buildSpheresAndSpurs=function(e){var t,n;void 0===e&&(e=!0),this._debugMesh&&(this._debugMesh.dispose(),this._debugMesh=null,this.ready=!1),this._ready=!1;var i=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,i.animationsEnabled=!1),this.options.returnToRest&&this.skeleton.returnToRest(),this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();for(var u=Number.NEGATIVE_INFINITY,l=this.options.displayOptions||{},h=function(t){var n=o[t];if(-1===n._index||!d._boneIndices.has(n.getIndex())&&!d.options.useAllBones)return"continue";var c=new r.a;d._getAbsoluteBindPoseToRef(n,c);var h=new r.e;c.decompose(void 0,void 0,h),n.children.forEach((function(t,o){var a=new r.a;t.getBaseMatrix().multiplyToRef(c,a);var d=new r.e;a.decompose(void 0,void 0,d);var p=r.e.Distance(h,d);if(p>u&&(u=p),!e){for(var f=d.clone().subtract(h.clone()),_=f.length(),m=f.normalize().scale(_),g=l.midStep||.165,b=l.midStepFactor||.215,y=m.scale(g),T=Object(N.b)("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:v.a.DEFAULTSIDE,updatable:!1},i),E=T.getTotalVertices(),S=[],A=[],x=0;x9?A.push(t.getIndex(),0,0,0):A.push(n.getIndex(),0,0,0);T.position=h.clone(),T.setVerticesData(I.b.MatricesWeightsKind,S,!1),T.setVerticesData(I.b.MatricesIndicesKind,A,!1),T.convertToFlatShadedMesh(),s.push(T)}}));for(var p=l.sphereBaseSize||.2,f=Object(y.a)("skeletonViewer",{segments:6,diameter:p,updatable:!0},i),_=f.getTotalVertices(),m=[],g=[],b=0;b<_;b++)m.push(1,0,0,0),g.push(n.getIndex(),0,0,0);f.setVerticesData(I.b.MatricesWeightsKind,m,!1),f.setVerticesData(I.b.MatricesIndicesKind,g,!1),f.position=h.clone(),a.push([f,n])},d=this,p=0;p=6&&e._showPlanes)})),this._oldPosition.set(Number.NaN,Number.NaN,Number.NaN),this._visible=!0},e.prototype.hide=function(){this._lightHelperFrustumMeshes.forEach((function(e){e.setEnabled(!1)})),this._visible=!1},e.prototype.update=function(){var e,t,n,i,o,a;if(this._visible&&(!this._oldPosition.equals(this._light.position)||!this._oldDirection.equals(this._light.direction)||this._oldAutoCalc!==this._light.autoCalcShadowZBounds||this._oldMinZ!==this._light.shadowMinZ||this._oldMaxZ!==this._light.shadowMaxZ)){this._oldPosition.copyFrom(this._light.position),this._oldDirection.copyFrom(this._light.direction),this._oldAutoCalc=this._light.autoCalcShadowZBounds,this._oldMinZ=this._light.shadowMinZ,this._oldMaxZ=this._light.shadowMaxZ,r.c.Vector3[0].set(this._light.orthoLeft,this._light.orthoBottom,void 0!==this._light.shadowMinZ?this._light.shadowMinZ:this._camera.minZ),r.c.Vector3[1].set(this._light.orthoRight,this._light.orthoTop,void 0!==this._light.shadowMaxZ?this._light.shadowMaxZ:this._camera.maxZ);var s=this._getInvertViewMatrix();r.c.Vector3[2].copyFromFloats(r.c.Vector3[1].x,r.c.Vector3[1].y,r.c.Vector3[0].z),r.c.Vector3[3].copyFromFloats(r.c.Vector3[1].x,r.c.Vector3[0].y,r.c.Vector3[0].z),r.c.Vector3[4].copyFromFloats(r.c.Vector3[0].x,r.c.Vector3[0].y,r.c.Vector3[0].z),r.c.Vector3[5].copyFromFloats(r.c.Vector3[0].x,r.c.Vector3[1].y,r.c.Vector3[0].z),r.e.TransformCoordinatesToRef(r.c.Vector3[2],s,r.c.Vector3[2]),r.e.TransformCoordinatesToRef(r.c.Vector3[3],s,r.c.Vector3[3]),r.e.TransformCoordinatesToRef(r.c.Vector3[4],s,r.c.Vector3[4]),r.e.TransformCoordinatesToRef(r.c.Vector3[5],s,r.c.Vector3[5]),r.c.Vector3[6].copyFromFloats(r.c.Vector3[1].x,r.c.Vector3[1].y,r.c.Vector3[1].z),r.c.Vector3[7].copyFromFloats(r.c.Vector3[1].x,r.c.Vector3[0].y,r.c.Vector3[1].z),r.c.Vector3[8].copyFromFloats(r.c.Vector3[0].x,r.c.Vector3[0].y,r.c.Vector3[1].z),r.c.Vector3[9].copyFromFloats(r.c.Vector3[0].x,r.c.Vector3[1].y,r.c.Vector3[1].z),r.e.TransformCoordinatesToRef(r.c.Vector3[6],s,r.c.Vector3[6]),r.e.TransformCoordinatesToRef(r.c.Vector3[7],s,r.c.Vector3[7]),r.e.TransformCoordinatesToRef(r.c.Vector3[8],s,r.c.Vector3[8]),r.e.TransformCoordinatesToRef(r.c.Vector3[9],s,r.c.Vector3[9]),Object(R.e)("nearlines",{updatable:!0,points:this._nearLinesPoints,instance:this._lightHelperFrustumMeshes[0]},this._scene),Object(R.e)("farlines",{updatable:!0,points:this._farLinesPoints,instance:this._lightHelperFrustumMeshes[1]},this._scene),Object(R.e)("trlines",{updatable:!0,points:this._trLinesPoints,instance:this._lightHelperFrustumMeshes[2]},this._scene),Object(R.e)("brlines",{updatable:!0,points:this._brLinesPoints,instance:this._lightHelperFrustumMeshes[3]},this._scene),Object(R.e)("tllines",{updatable:!0,points:this._tlLinesPoints,instance:this._lightHelperFrustumMeshes[4]},this._scene),Object(R.e)("bllines",{updatable:!0,points:this._blLinesPoints,instance:this._lightHelperFrustumMeshes[5]},this._scene),r.c.Vector3[2].toArray(this._nearPlaneVertices,0),r.c.Vector3[3].toArray(this._nearPlaneVertices,3),r.c.Vector3[4].toArray(this._nearPlaneVertices,6),r.c.Vector3[5].toArray(this._nearPlaneVertices,9),null===(e=this._lightHelperFrustumMeshes[6].geometry)||void 0===e||e.updateVerticesDataDirectly("position",this._nearPlaneVertices,0),r.c.Vector3[6].toArray(this._farPlaneVertices,0),r.c.Vector3[7].toArray(this._farPlaneVertices,3),r.c.Vector3[8].toArray(this._farPlaneVertices,6),r.c.Vector3[9].toArray(this._farPlaneVertices,9),null===(t=this._lightHelperFrustumMeshes[7].geometry)||void 0===t||t.updateVerticesDataDirectly("position",this._farPlaneVertices,0),r.c.Vector3[2].toArray(this._rightPlaneVertices,0),r.c.Vector3[6].toArray(this._rightPlaneVertices,3),r.c.Vector3[7].toArray(this._rightPlaneVertices,6),r.c.Vector3[3].toArray(this._rightPlaneVertices,9),null===(n=this._lightHelperFrustumMeshes[8].geometry)||void 0===n||n.updateVerticesDataDirectly("position",this._rightPlaneVertices,0),r.c.Vector3[5].toArray(this._leftPlaneVertices,0),r.c.Vector3[9].toArray(this._leftPlaneVertices,3),r.c.Vector3[8].toArray(this._leftPlaneVertices,6),r.c.Vector3[4].toArray(this._leftPlaneVertices,9),null===(i=this._lightHelperFrustumMeshes[9].geometry)||void 0===i||i.updateVerticesDataDirectly("position",this._leftPlaneVertices,0),r.c.Vector3[2].toArray(this._topPlaneVertices,0),r.c.Vector3[6].toArray(this._topPlaneVertices,3),r.c.Vector3[9].toArray(this._topPlaneVertices,6),r.c.Vector3[5].toArray(this._topPlaneVertices,9),null===(o=this._lightHelperFrustumMeshes[10].geometry)||void 0===o||o.updateVerticesDataDirectly("position",this._topPlaneVertices,0),r.c.Vector3[3].toArray(this._bottomPlaneVertices,0),r.c.Vector3[7].toArray(this._bottomPlaneVertices,3),r.c.Vector3[8].toArray(this._bottomPlaneVertices,6),r.c.Vector3[4].toArray(this._bottomPlaneVertices,9),null===(a=this._lightHelperFrustumMeshes[11].geometry)||void 0===a||a.updateVerticesDataDirectly("position",this._bottomPlaneVertices,0)}},e.prototype.dispose=function(){this._lightHelperFrustumMeshes.forEach((function(e){var t;null===(t=e.material)||void 0===t||t.dispose(),e.dispose()})),this._rootNode.dispose()},e.prototype._createGeometry=function(){var e=this;this._rootNode=new w.a("directionalLightHelperRoot_"+this._light.name,this._scene),this._rootNode.parent=this._light.parent,this._nearLinesPoints=[r.e.ZeroReadOnly,r.e.ZeroReadOnly,r.e.ZeroReadOnly,r.e.ZeroReadOnly,r.e.ZeroReadOnly];var t=Object(R.e)("nearlines",{updatable:!0,points:this._nearLinesPoints},this._scene);t.parent=this._rootNode,t.alwaysSelectAsActiveMesh=!0,this._farLinesPoints=[r.e.ZeroReadOnly,r.e.ZeroReadOnly,r.e.ZeroReadOnly,r.e.ZeroReadOnly,r.e.ZeroReadOnly];var n=Object(R.e)("farlines",{updatable:!0,points:this._farLinesPoints},this._scene);n.parent=this._rootNode,n.alwaysSelectAsActiveMesh=!0,this._trLinesPoints=[r.e.ZeroReadOnly,r.e.ZeroReadOnly];var i=Object(R.e)("trlines",{updatable:!0,points:this._trLinesPoints},this._scene);i.parent=this._rootNode,i.alwaysSelectAsActiveMesh=!0,this._brLinesPoints=[r.e.ZeroReadOnly,r.e.ZeroReadOnly];var a=Object(R.e)("brlines",{updatable:!0,points:this._brLinesPoints},this._scene);a.parent=this._rootNode,a.alwaysSelectAsActiveMesh=!0,this._tlLinesPoints=[r.e.ZeroReadOnly,r.e.ZeroReadOnly];var c=Object(R.e)("tllines",{updatable:!0,points:this._tlLinesPoints},this._scene);c.parent=this._rootNode,c.alwaysSelectAsActiveMesh=!0,this._blLinesPoints=[r.e.ZeroReadOnly,r.e.ZeroReadOnly];var u=Object(R.e)("bllines",{updatable:!0,points:this._blLinesPoints},this._scene);u.parent=this._rootNode,u.alwaysSelectAsActiveMesh=!0,this._lightHelperFrustumMeshes.push(t,n,i,a,c,u);var l=function(t,n,i){var r=new v.a(t+"plane",e._scene),a=new o.a(t+"PlaneMat",e._scene);r.material=a,r.parent=e._rootNode,r.alwaysSelectAsActiveMesh=!0,a.emissiveColor=n,a.alpha=e.transparency,a.backFaceCulling=!1,a.disableLighting=!0;var s=new F.a;s.positions=i,s.indices=[0,1,2,0,2,3],s.applyToMesh(r,!0),e._lightHelperFrustumMeshes.push(r)};this._nearPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._farPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._rightPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._leftPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._topPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],this._bottomPlaneVertices=[0,0,0,0,0,0,0,0,0,0,0,0],l("near",new s.a(1,0,0),this._nearPlaneVertices),l("far",new s.a(.3,0,0),this._farPlaneVertices),l("right",new s.a(0,1,0),this._rightPlaneVertices),l("left",new s.a(0,.3,0),this._leftPlaneVertices),l("top",new s.a(0,0,1),this._topPlaneVertices),l("bottom",new s.a(0,0,.3),this._bottomPlaneVertices),this._nearLinesPoints[0]=r.c.Vector3[2],this._nearLinesPoints[1]=r.c.Vector3[3],this._nearLinesPoints[2]=r.c.Vector3[4],this._nearLinesPoints[3]=r.c.Vector3[5],this._nearLinesPoints[4]=r.c.Vector3[2],this._farLinesPoints[0]=r.c.Vector3[6],this._farLinesPoints[1]=r.c.Vector3[7],this._farLinesPoints[2]=r.c.Vector3[8],this._farLinesPoints[3]=r.c.Vector3[9],this._farLinesPoints[4]=r.c.Vector3[6],this._trLinesPoints[0]=r.c.Vector3[2],this._trLinesPoints[1]=r.c.Vector3[6],this._brLinesPoints[0]=r.c.Vector3[3],this._brLinesPoints[1]=r.c.Vector3[7],this._tlLinesPoints[0]=r.c.Vector3[4],this._tlLinesPoints[1]=r.c.Vector3[8],this._blLinesPoints[0]=r.c.Vector3[5],this._blLinesPoints[1]=r.c.Vector3[9]},e.prototype._getInvertViewMatrix=function(){return r.a.LookAtLHToRef(this._light.position,this._light.position.add(this._light.direction),r.e.UpReadOnly,this._inverseViewMatrix),this._inverseViewMatrix.invertToRef(this._inverseViewMatrix),this._inverseViewMatrix},e}()},function(e,t,n){"use strict";var i="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";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="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";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="morphTargetsVertexGlobal",r="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nfloat vertexID;\n#endif\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="morphTargetsVertex",r="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvertexID=float(gl_VertexID)*morphTargetTextureInfo.x;\npositionUpdated+=(readVector3FromRawSampler({X},vertexID)-position)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(readVector3FromRawSampler({X},vertexID)-normal)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated+=(readVector3FromRawSampler({X},vertexID).xy-uv)*morphTargetInfluences[{X}];\nvertexID+=1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(readVector3FromRawSampler({X},vertexID)-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#else\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\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(e,t){if(void 0===e&&(e=null),this._MSAARenderBuffer=null,this._context=t,!e&&!(e=t.createTexture()))throw new Error("Unable to create webGL texture");this.set(e)}return Object.defineProperty(e.prototype,"underlyingResource",{get:function(){return this._webGLTexture},enumerable:!1,configurable:!0}),e.prototype.setUsage=function(e,t,n,i,r){},e.prototype.set=function(e){this._webGLTexture=e},e.prototype.reset=function(){this._webGLTexture=null,this._MSAARenderBuffer=null},e.prototype.release=function(){this._MSAARenderBuffer&&(this._context.deleteRenderbuffer(this._MSAARenderBuffer),this._MSAARenderBuffer=null),this._webGLTexture&&this._context.deleteTexture(this._webGLTexture),this.reset()},e}()},function(e,t,n){"use strict";var i;n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return r})),function(e){e[e.PointerMove=0]="PointerMove",e[e.PointerDown=1]="PointerDown",e[e.PointerUp=2]="PointerUp"}(i||(i={}));var r=function(){function e(){}return e.DOM_DELTA_PIXEL=0,e.DOM_DELTA_LINE=1,e.DOM_DELTA_PAGE=2,e}()},function(e,t,n){"use strict";n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return c}));var i=n(2),r=n(0),o=n(3),a=function(){function e(){}return e.extractMinAndMaxIndexed=function(e,t,n,i,r,o){for(var a=n;a0&&e.push(this._texture)},t.prototype.dispose=function(e){var t;e&&(null===(t=this._texture)||void 0===t||t.dispose())},t.prototype.getClassName=function(){return"DetailMapConfiguration"},t.prototype.getSamplers=function(e){e.push("detailSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vDetailInfos",size:4,type:"vec4"},{name:"detailMatrix",size:16,type:"mat4"}]}},Object(i.c)([Object(o.n)("detailTexture"),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),Object(i.c)([Object(o.d)()],t.prototype,"diffuseBlendLevel",void 0),Object(i.c)([Object(o.d)()],t.prototype,"roughnessBlendLevel",void 0),Object(i.c)([Object(o.d)()],t.prototype,"bumpLevel",void 0),Object(i.c)([Object(o.d)(),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"normalBlendMethod",void 0),Object(i.c)([Object(o.d)(),Object(o.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),t}(u.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(52),r=n(0),o=n(23),a=function(){function e(e,t,n){this.vectors=i.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=i.a.BuildArray(3,r.e.Zero),this.vectorsWorld=i.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._drawWrapperFront=null,this._drawWrapperBack=null,this.reConstruct(e,t,n)}return e.prototype.reConstruct=function(e,t,n){var i=e.x,o=e.y,a=e.z,s=t.x,c=t.y,u=t.z,l=this.vectors;this.minimum.copyFromFloats(i,o,a),this.maximum.copyFromFloats(s,c,u),l[0].copyFromFloats(i,o,a),l[1].copyFromFloats(s,c,u),l[2].copyFromFloats(s,o,a),l[3].copyFromFloats(i,c,a),l[4].copyFromFloats(i,o,u),l[5].copyFromFloats(s,c,a),l[6].copyFromFloats(i,c,u),l[7].copyFromFloats(s,o,u),t.addToRef(e,this.center).scaleInPlace(.5),t.subtractToRef(e,this.extendSize).scaleInPlace(.5),this._worldMatrix=n||r.a.IdentityReadOnly,this._update(this._worldMatrix)},e.prototype.scale=function(t){var n=e.TmpVector3,i=this.maximum.subtractToRef(this.minimum,n[0]),r=i.length();i.normalizeFromLength(r);var o=r*t,a=i.scaleInPlace(.5*o),s=this.center.subtractToRef(a,n[1]),c=this.center.addToRef(a,n[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,n=this.maximumWorld,i=this.directions,o=this.vectorsWorld,a=this.vectors;if(e.isIdentity()){t.copyFrom(this.minimum),n.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),n.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),n.maximizeInPlace(c)}n.subtractToRef(t,this.extendSizeWorld).scaleInPlace(.5),n.addToRef(t,this.centerWorld).scaleInPlace(.5)}r.e.FromArrayToRef(e.m,0,i[0]),r.e.FromArrayToRef(e.m,4,i[1]),r.e.FromArrayToRef(e.m,8,i[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,n=this.maximumWorld,i=t.x,r=t.y,a=t.z,s=n.x,c=n.y,u=n.z,l=e.x,h=e.y,d=e.z,p=-o.a;return!(s-ll-i)&&(!(c-hh-r)&&!(u-dd-a))},e.prototype.intersectsSphere=function(t){return e.IntersectsSphere(this.minimumWorld,this.maximumWorld,t.centerWorld,t.radiusWorld)},e.prototype.intersectsMinMax=function(e,t){var n=this.minimumWorld,i=this.maximumWorld,r=n.x,o=n.y,a=n.z,s=i.x,c=i.y,u=i.z,l=e.x,h=e.y,d=e.z,p=t.x,f=t.y,_=t.z;return!(sp)&&(!(cf)&&!(u_))},e.prototype.dispose=function(){var e,t;null===(e=this._drawWrapperFront)||void 0===e||e.dispose(),null===(t=this._drawWrapperBack)||void 0===t||t.dispose()},e.Intersects=function(e,t){return e.intersectsMinMax(t.minimumWorld,t.maximumWorld)},e.IntersectsSphere=function(t,n,i,o){var a=e.TmpVector3[0];return r.e.ClampToRef(i,t,n,a),r.e.DistanceSquared(i,a)<=o*o},e.IsCompletelyInFrustum=function(e,t){for(var n=0;n<6;++n)for(var i=t[n],r=0;r<8;++r)if(i.dotCoordinate(e[r])<0)return!1;return!0},e.IsInFrustum=function(e,t){for(var n=0;n<6;++n){for(var i=!0,r=t[n],o=0;o<8;++o)if(r.dotCoordinate(e[o])>=0){i=!1;break}if(i)return!1}return!0},e.TmpVector3=i.a.BuildArray(3,r.e.Zero),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(1),r=function(){function e(){this.previousWorldMatrices={},this.previousBones={}}return e.AddUniforms=function(e){e.push("previousWorld","previousViewProjection","mPreviousBones")},e.AddSamplers=function(e){},e.prototype.bindForSubMesh=function(e,t,n,r,o){if(t.prePassRenderer&&t.prePassRenderer.enabled&&t.prePassRenderer.currentRTisSceneRT&&-1!==t.prePassRenderer.getIndex(i.a.PREPASS_VELOCITY_TEXTURE_TYPE)){this.previousWorldMatrices[n.uniqueId]||(this.previousWorldMatrices[n.uniqueId]=r.clone()),this.previousViewProjection||(this.previousViewProjection=t.getTransformMatrix().clone(),this.currentViewProjection=t.getTransformMatrix().clone());var a=t.getEngine();this.currentViewProjection.updateFlag!==t.getTransformMatrix().updateFlag?(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection),this.currentViewProjection.copyFrom(t.getTransformMatrix())):this._lastUpdateFrameId!==a.frameId&&(this._lastUpdateFrameId=a.frameId,this.previousViewProjection.copyFrom(this.currentViewProjection)),e.setMatrix("previousWorld",this.previousWorldMatrices[n.uniqueId]),e.setMatrix("previousViewProjection",this.previousViewProjection),this.previousWorldMatrices[n.uniqueId]=r.clone()}},e}()},function(e,t,n){"use strict";var i="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";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="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}";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(27),r=n(1);function o(e,t,n,i){switch(void 0===n&&(n=!1),e){case r.a.TEXTURETYPE_BYTE:var o=(ArrayBuffer,new Int8Array(t));return i&&o.set(new Int8Array(i)),o;case r.a.TEXTURETYPE_UNSIGNED_BYTE:var a=(ArrayBuffer,new Uint8Array(t));return i&&a.set(new Uint8Array(i)),a;case r.a.TEXTURETYPE_SHORT:var s=t instanceof ArrayBuffer?new Int16Array(t):new Int16Array(n?t/2:t);return i&&s.set(new Int16Array(i)),s;case r.a.TEXTURETYPE_UNSIGNED_SHORT:case r.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:case r.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:case r.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:case r.a.TEXTURETYPE_HALF_FLOAT:var c=t instanceof ArrayBuffer?new Uint16Array(t):new Uint16Array(n?t/2:t);return i&&c.set(new Uint16Array(i)),c;case r.a.TEXTURETYPE_INT:var u=t instanceof ArrayBuffer?new Int32Array(t):new Int32Array(n?t/4:t);return i&&u.set(new Int32Array(i)),u;case r.a.TEXTURETYPE_UNSIGNED_INTEGER:case r.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:case r.a.TEXTURETYPE_UNSIGNED_INT_24_8:case r.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:case r.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:case r.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:var l=t instanceof ArrayBuffer?new Uint32Array(t):new Uint32Array(n?t/4:t);return i&&l.set(new Uint32Array(i)),l;case r.a.TEXTURETYPE_FLOAT:var h=t instanceof ArrayBuffer?new Float32Array(t):new Float32Array(n?t/4:t);return i&&h.set(new Float32Array(i)),h}var d=(ArrayBuffer,new Uint8Array(t));return i&&d.set(new Uint8Array(i)),d}i.a.prototype._readTexturePixelsSync=function(e,t,n,i,r,a,s,c){var u,l;void 0===i&&(i=-1),void 0===r&&(r=0),void 0===a&&(a=null),void 0===s&&(s=!0),void 0===c&&(c=!1);var h=this._gl;if(!h)throw new Error("Engine does not have gl rendering context.");if(!this._dummyFramebuffer){var d=h.createFramebuffer();if(!d)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=d}h.bindFramebuffer(h.FRAMEBUFFER,this._dummyFramebuffer),i>-1?h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_CUBE_MAP_POSITIVE_X+i,null===(u=e._hardwareTexture)||void 0===u?void 0:u.underlyingResource,r):h.framebufferTexture2D(h.FRAMEBUFFER,h.COLOR_ATTACHMENT0,h.TEXTURE_2D,null===(l=e._hardwareTexture)||void 0===l?void 0:l.underlyingResource,r);var p=void 0!==e.type?this._getWebGLTextureType(e.type):h.UNSIGNED_BYTE;if(c)a||(a=o(e.type,4*t*n));else switch(p){case h.UNSIGNED_BYTE:a||(a=new Uint8Array(4*t*n)),p=h.UNSIGNED_BYTE;break;default:a||(a=new Float32Array(4*t*n)),p=h.FLOAT}return s&&this.flushFramebuffer(),h.readPixels(0,0,t,n,h.RGBA,p,a),h.bindFramebuffer(h.FRAMEBUFFER,this._currentFramebuffer),a},i.a.prototype._readTexturePixels=function(e,t,n,i,r,o,a,s){return void 0===i&&(i=-1),void 0===r&&(r=0),void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1),Promise.resolve(this._readTexturePixelsSync(e,t,n,i,r,o,a,s))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var t=this;this.clear(),e.forEach((function(e,n){return t.add(e,n)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var n=this.get(e);return void 0!==n||(n=t(e))&&this.add(e,n),n},e.prototype.getOrAdd=function(e,t){var n=this.get(e);return void 0!==n?n:(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 n=e(t,this._data[t]);if(n)return n}return null},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(e,t,n){this.bu=e,this.bv=t,this.distance=n,this.faceId=0,this.subMeshId=0}},function(e,t,n){"use strict";var i="logDepthDeclaration",r="#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(e){void 0===e&&(e=!0),this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,e&&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,"zOffsetUnits",{get:function(){return this._zOffsetUnits},set:function(e){this._zOffsetUnits!==e&&(this._zOffsetUnits=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._zOffsetUnits=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!0,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||this.zOffsetUnits?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,this.zOffsetUnits)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(1),r=function(){function e(){this.samplingMode=-1,this._useMipMaps=!0,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedWrapR=null,this._cachedAnisotropicFilteringLevel=null,this._comparisonFunction=0}return Object.defineProperty(e.prototype,"wrapU",{get:function(){return this._cachedWrapU},set:function(e){this._cachedWrapU=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wrapV",{get:function(){return this._cachedWrapV},set:function(e){this._cachedWrapV=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"wrapR",{get:function(){return this._cachedWrapR},set:function(e){this._cachedWrapR=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"anisotropicFilteringLevel",{get:function(){return this._cachedAnisotropicFilteringLevel},set:function(e){this._cachedAnisotropicFilteringLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"comparisonFunction",{get:function(){return this._comparisonFunction},set:function(e){this._comparisonFunction=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useMipMaps",{get:function(){return this._useMipMaps},set:function(e){this._useMipMaps=e},enumerable:!1,configurable:!0}),e.prototype.setParameters=function(e,t,n,r,o,a){return void 0===e&&(e=i.a.TEXTURE_WRAP_ADDRESSMODE),void 0===t&&(t=i.a.TEXTURE_WRAP_ADDRESSMODE),void 0===n&&(n=i.a.TEXTURE_WRAP_ADDRESSMODE),void 0===r&&(r=1),void 0===o&&(o=i.a.TEXTURE_BILINEAR_SAMPLINGMODE),void 0===a&&(a=0),this._cachedWrapU=e,this._cachedWrapV=t,this._cachedWrapR=n,this._cachedAnisotropicFilteringLevel=r,this.samplingMode=o,this._comparisonFunction=a,this},e.prototype.compareSampler=function(e){return this._cachedWrapU===e._cachedWrapU&&this._cachedWrapV===e._cachedWrapV&&this._cachedWrapR===e._cachedWrapR&&this._cachedAnisotropicFilteringLevel===e._cachedAnisotropicFilteringLevel&&this.samplingMode===e.samplingMode&&this._comparisonFunction===e._comparisonFunction&&this._useMipMaps===e._useMipMaps},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(44),r=function(){function e(){this.shaderLanguage=i.a.GLSL}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,n,i,r){var o=-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("),n)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,(o?"":"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,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(e){void 0===e&&(e=!0),this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.useStencilGlobalOnly=!1,e&&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,"func",{get:function(){return this._func},set:function(e){this._func!==e&&(this._func=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"funcRef",{get:function(){return this._funcRef},set:function(e){this._funcRef!==e&&(this._funcRef=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"funcMask",{get:function(){return this._funcMask},set:function(e){this._funcMask!==e&&(this._funcMask=e,this._isStencilFuncDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"opStencilFail",{get:function(){return this._opStencilFail},set:function(e){this._opStencilFail!==e&&(this._opStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"opDepthFail",{get:function(){return this._opDepthFail},set:function(e){this._opDepthFail!==e&&(this._opDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"opStencilDepthPass",{get:function(){return this._opStencilDepthPass},set:function(e){this._opStencilDepthPass!==e&&(this._opStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"mask",{get:function(){return this._mask},set:function(e){this._mask!==e&&(this._mask=e,this._isStencilMaskDirty=!0)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enabled",{get:function(){return this._enabled},set:function(e){this._enabled!==e&&(this._enabled=e,this._isStencilTestDirty=!0)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){var e;this.stencilMaterial=void 0,null===(e=this.stencilGlobal)||void 0===e||e.reset(),this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},e.prototype.apply=function(e){var t;if(e){var n=!this.useStencilGlobalOnly&&!!(null===(t=this.stencilMaterial)||void 0===t?void 0:t.enabled);this.enabled=n?this.stencilMaterial.enabled:this.stencilGlobal.enabled,this.func=n?this.stencilMaterial.func:this.stencilGlobal.func,this.funcRef=n?this.stencilMaterial.funcRef:this.stencilGlobal.funcRef,this.funcMask=n?this.stencilMaterial.funcMask:this.stencilGlobal.funcMask,this.opStencilFail=n?this.stencilMaterial.opStencilFail:this.stencilGlobal.opStencilFail,this.opDepthFail=n?this.stencilMaterial.opDepthFail:this.stencilGlobal.opDepthFail,this.opStencilDepthPass=n?this.stencilMaterial.opStencilDepthPass:this.stencilGlobal.opStencilDepthPass,this.mask=n?this.stencilMaterial.mask:this.stencilGlobal.mask,this.isDirty&&(this._isStencilTestDirty&&(this.enabled?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.mask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.func,this.funcRef,this.funcMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.opStencilFail,this.opDepthFail,this.opStencilDepthPass),this._isStencilOpDirty=!1))}},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){}return e.BindClipPlane=function(e,t){if(t.clipPlane){var n=t.clipPlane;e.setFloat4("vClipPlane",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane2){n=t.clipPlane2;e.setFloat4("vClipPlane2",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane3){n=t.clipPlane3;e.setFloat4("vClipPlane3",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane4){n=t.clipPlane4;e.setFloat4("vClipPlane4",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane5){n=t.clipPlane5;e.setFloat4("vClipPlane5",n.normal.x,n.normal.y,n.normal.z,n.d)}if(t.clipPlane6){n=t.clipPlane6;e.setFloat4("vClipPlane6",n.normal.x,n.normal.y,n.normal.z,n.d)}},e}()},function(e,t,n){"use strict";n.d(t,"c",(function(){return s})),n.d(t,"b",(function(){return c})),n.d(t,"a",(function(){return u}));var i=n(19),r=n(0),o=n(9),a=n(32);function s(e){void 0===e&&(e={subdivisions:2,tessellation:16,height:1,radius:.25,capSubdivisions:6});var t,n,o=Math.max(e.subdivisions?e.subdivisions:2,1),s=Math.max(e.tessellation?e.tessellation:16,3),c=Math.max(e.height?e.height:1,0),u=Math.max(e.radius?e.radius:.25,0),l=Math.max(e.capSubdivisions?e.capSubdivisions:6,1),h=s,d=o,p=Math.max(e.radiusTop?e.radiusTop:u,0),f=Math.max(e.radiusBottom?e.radiusBottom:u,0),_=c-(p+f),m=2*Math.PI,g=Math.max(e.topCapSubdivisions?e.topCapSubdivisions:l,1),v=Math.max(e.bottomCapSubdivisions?e.bottomCapSubdivisions:l,1),b=Math.acos((f-p)/c),y=[],T=[],E=[],S=[],A=0,x=[],R=.5*_,C=.5*Math.PI,P=r.e.Zero(),O=r.e.Zero(),M=Math.cos(b),I=Math.sin(b),D=new r.d(p*I,R+p*M).subtract(new r.d(f*I,f*M-R)).length(),N=p*b+D+f*(C-b),L=0;for(n=0;n<=g;n++){var F=[],w=C-b*(n/g);L+=p*b/g;var B=Math.cos(w),U=Math.sin(w),V=B*p;for(t=0;t<=h;t++){var k=(H=t/h)*m+0,G=Math.sin(k),z=Math.cos(k);O.x=V*G,O.y=R+U*p,O.z=V*z,T.push(O.x,O.y,O.z),P.set(B*G,U,B*z),E.push(P.x,P.y,P.z),S.push(H,a.a.UseOpenGLOrientationForUV?L/N:1-L/N),F.push(A),A++}x.push(F)}var j=c-p-f+M*p-M*f,W=I*(f-p)/j;for(n=1;n<=d;n++){F=[];L+=D/d;V=I*(n*(f-p)/d+p);for(t=0;t<=h;t++){k=(H=t/h)*m+0,G=Math.sin(k),z=Math.cos(k);O.x=V*G,O.y=R+M*p-n*j/d,O.z=V*z,T.push(O.x,O.y,O.z),P.set(G,W,z).normalize(),E.push(P.x,P.y,P.z),S.push(H,a.a.UseOpenGLOrientationForUV?L/N:1-L/N),F.push(A),A++}x.push(F)}for(n=1;n<=v;n++){F=[],w=C-b-(Math.PI-b)*(n/v);L+=f*b/v;B=Math.cos(w),U=Math.sin(w),V=B*f;for(t=0;t<=h;t++){var H;k=(H=t/h)*m+0,G=Math.sin(k),z=Math.cos(k);O.x=V*G,O.y=U*f-R,O.z=V*z,T.push(O.x,O.y,O.z),P.set(B*G,U,B*z),E.push(P.x,P.y,P.z),S.push(H,a.a.UseOpenGLOrientationForUV?L/N:1-L/N),F.push(A),A++}x.push(F)}for(t=0;t=r&&0===n?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,n,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,n,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(n,n+i)):(t=t instanceof ArrayBuffer?new Uint8Array(t,n,i):new Uint8Array(t.buffer,t.byteOffset+n,i),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()}},function(e,t,n){"use strict";var i="sceneUboDeclaration",r="layout(std140,column_major) uniform;\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\nmat4 projection;\nvec4 vEyePosition;\n};\n";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="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";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i=n(27),r=n(24);i.a.prototype.createDynamicTexture=function(e,t,n,o){var a=new r.a(this,r.b.Dynamic);return a.baseWidth=e,a.baseHeight=t,n&&(e=this.needPOTTextures?i.a.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?i.a.GetExponentOfTwo(t,this._caps.maxTextureSize):t),a.width=e,a.height=t,a.isReady=!1,a.generateMipMaps=n,a.samplingMode=o,this.updateTextureSamplingMode(o,a),this._internalTexturesCache.push(a),a},i.a.prototype.updateDynamicTexture=function(e,t,n,i,r,o,a){if(void 0===i&&(i=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),e){var s=this._gl,c=s.TEXTURE_2D,u=this._bindTextureDirectly(c,e,!0,o);this._unpackFlipY(void 0===n?e.invertY:n),i&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var l=this._getWebGLTextureType(e.type),h=this._getInternalFormat(r||e.format),d=this._getRGBABufferInternalSizedFormat(e.type,h);s.texImage2D(c,0,d,h,l,t),e.generateMipMaps&&s.generateMipmap(c),u||this._bindTextureDirectly(c,null),i&&s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(6),r=function(){function e(e,t,n){void 0===n&&(n=0),this.deviceType=t,this.deviceSlot=n,this.onInputChangedObservable=new i.c,this._deviceInputSystem=e}return e.prototype.getInput=function(e){return this._deviceInputSystem.pollInput(this.deviceType,this.deviceSlot,e)},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(35),r=function(){function e(t,n){e.IsAvailable&&(this._observer=new window.ComputePressureObserver(t,n))}return Object.defineProperty(e,"IsAvailable",{get:function(){return Object(i.e)()&&"ComputePressureObserver"in window},enumerable:!1,configurable:!0}),e.prototype.observe=function(){var e,t;(null===(e=this._observer)||void 0===e?void 0:e.observe)&&(null===(t=this._observer)||void 0===t||t.observe())},e.prototype.unobserve=function(){var e,t;(null===(e=this._observer)||void 0===e?void 0:e.unobserve)&&(null===(t=this._observer)||void 0===t||t.unobserve())},e}()},function(e,t,n){"use strict";n.d(t,"b",(function(){return r})),n.d(t,"c",(function(){return o})),n.d(t,"d",(function(){return a})),n.d(t,"a",(function(){return s}));var i=n(2);function r(e,t,n){void 0===n&&(n=!1);var i=t.width,r=t.height;if(e instanceof Float32Array){for(var o=e.byteLength/e.BYTES_PER_ELEMENT,a=new Uint8Array(o);--o>=0;){var s=e[o];s<0?s=0:s>1&&(s=1),a[o]=255*s}e=a}var c=document.createElement("canvas");c.width=i,c.height=r;var u=c.getContext("2d");if(!u)return null;var l=u.createImageData(i,r);if(l.data.set(e),u.putImageData(l,0,0),n){var h=document.createElement("canvas");h.width=i,h.height=r;var d=h.getContext("2d");return d?(d.translate(0,r),d.scale(1,-1),d.drawImage(c,0,0),h.toDataURL("image/png")):null}return c.toDataURL("image/png")}function o(e,t,n){void 0===t&&(t=0),void 0===n&&(n=0);var i=e.getInternalTexture();if(!i)return null;var o=e._readPixelsSync(t,n);return o?r(o,e.getSize(),i.invertY):null}function a(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=0),Object(i.b)(this,void 0,void 0,(function(){var o,a;return Object(i.e)(this,(function(i){switch(i.label){case 0:return(o=e.getInternalTexture())?[4,e.readPixels(t,n)]:[2,null];case 1:return(a=i.sent())?[2,r(a,e.getSize(),o.invertY)]:[2,null]}}))}))}var s={GenerateBase64StringFromPixelData:r,GenerateBase64StringFromTexture:o,GenerateBase64StringFromTextureAsync:a}},function(e,t,n){"use strict";n.r(t),n.d(t,"AbstractScene",(function(){return i.a})),n.d(t,"AbstractActionManager",(function(){return r.a})),n.d(t,"Action",(function(){return u})),n.d(t,"ActionEvent",(function(){return l.a})),n.d(t,"ActionManager",(function(){return M})),n.d(t,"Condition",(function(){return d})),n.d(t,"ValueCondition",(function(){return p})),n.d(t,"PredicateCondition",(function(){return f})),n.d(t,"StateCondition",(function(){return _})),n.d(t,"SwitchBooleanAction",(function(){return v})),n.d(t,"SetStateAction",(function(){return b})),n.d(t,"SetValueAction",(function(){return y})),n.d(t,"IncrementValueAction",(function(){return T})),n.d(t,"PlayAnimationAction",(function(){return E})),n.d(t,"StopAnimationAction",(function(){return S})),n.d(t,"DoNothingAction",(function(){return A})),n.d(t,"CombineAction",(function(){return x})),n.d(t,"ExecuteCodeAction",(function(){return R})),n.d(t,"SetParentAction",(function(){return C})),n.d(t,"PlaySoundAction",(function(){return I})),n.d(t,"StopSoundAction",(function(){return D})),n.d(t,"InterpolateValueAction",(function(){return z})),n.d(t,"Animatable",(function(){return ee})),n.d(t,"_IAnimationState",(function(){return k})),n.d(t,"Animation",(function(){return G})),n.d(t,"TargetedAnimation",(function(){return ne})),n.d(t,"AnimationGroup",(function(){return ie})),n.d(t,"AnimationPropertiesOverride",(function(){return re})),n.d(t,"EasingFunction",(function(){return ae})),n.d(t,"CircleEase",(function(){return se})),n.d(t,"BackEase",(function(){return ce})),n.d(t,"BounceEase",(function(){return ue})),n.d(t,"CubicEase",(function(){return le})),n.d(t,"ElasticEase",(function(){return he})),n.d(t,"ExponentialEase",(function(){return de})),n.d(t,"PowerEase",(function(){return pe})),n.d(t,"QuadraticEase",(function(){return fe})),n.d(t,"QuarticEase",(function(){return _e})),n.d(t,"QuinticEase",(function(){return me})),n.d(t,"SineEase",(function(){return ge})),n.d(t,"BezierCurveEase",(function(){return ve})),n.d(t,"RuntimeAnimation",(function(){return K})),n.d(t,"AnimationEvent",(function(){return be})),n.d(t,"AnimationKeyInterpolation",(function(){return N})),n.d(t,"AnimationRange",(function(){return w})),n.d(t,"PathCursor",(function(){return ye})),n.d(t,"KeepAssets",(function(){return Ee})),n.d(t,"InstantiatedEntries",(function(){return Se})),n.d(t,"AssetContainer",(function(){return Ae})),n.d(t,"Analyser",(function(){return Ce})),n.d(t,"AudioEngine",(function(){return Oe})),n.d(t,"AudioSceneComponent",(function(){return Le})),n.d(t,"Sound",(function(){return Ie})),n.d(t,"SoundTrack",(function(){return De})),n.d(t,"WeightedSound",(function(){return Fe})),n.d(t,"BakedVertexAnimationManager",(function(){return we})),n.d(t,"VertexAnimationBaker",(function(){return Qe})),n.d(t,"AutoRotationBehavior",(function(){return Ze})),n.d(t,"BouncingBehavior",(function(){return Je})),n.d(t,"FramingBehavior",(function(){return $e})),n.d(t,"AttachToBoxBehavior",(function(){return tt})),n.d(t,"FadeInOutBehavior",(function(){return nt})),n.d(t,"MultiPointerScaleBehavior",(function(){return rt})),n.d(t,"PointerDragBehavior",(function(){return it.a})),n.d(t,"SixDofDragBehavior",(function(){return ut})),n.d(t,"SurfaceMagnetismBehavior",(function(){return lt})),n.d(t,"BaseSixDofDragBehavior",(function(){return st})),n.d(t,"FollowBehavior",(function(){return dt})),n.d(t,"HandConstraintZone",(function(){return We})),n.d(t,"HandConstraintOrientation",(function(){return He})),n.d(t,"HandConstraintVisibility",(function(){return Xe})),n.d(t,"HandConstraintBehavior",(function(){return _t})),n.d(t,"Bone",(function(){return $})),n.d(t,"BoneIKController",(function(){return mt})),n.d(t,"BoneLookController",(function(){return gt})),n.d(t,"Skeleton",(function(){return vt})),n.d(t,"Buffer",(function(){return bt.a})),n.d(t,"VertexBuffer",(function(){return bt.b})),n.d(t,"DataBuffer",(function(){return yt.a})),n.d(t,"StorageBuffer",(function(){return Tt})),n.d(t,"BaseCameraMouseWheelInput",(function(){return St})),n.d(t,"BaseCameraPointersInput",(function(){return At})),n.d(t,"ArcRotateCameraGamepadInput",(function(){return Mt})),n.d(t,"ArcRotateCameraKeyboardMoveInput",(function(){return Dt})),n.d(t,"ArcRotateCameraMouseWheelInput",(function(){return Lt})),n.d(t,"ArcRotateCameraPointersInput",(function(){return Ft})),n.d(t,"ArcRotateCameraVRDeviceOrientationInput",(function(){return Bt})),n.d(t,"FlyCameraKeyboardInput",(function(){return Ut})),n.d(t,"FlyCameraMouseInput",(function(){return Vt})),n.d(t,"FollowCameraKeyboardMoveInput",(function(){return kt})),n.d(t,"FollowCameraMouseWheelInput",(function(){return Gt})),n.d(t,"FollowCameraPointersInput",(function(){return zt})),n.d(t,"FreeCameraDeviceOrientationInput",(function(){return Qt})),n.d(t,"FreeCameraGamepadInput",(function(){return qt})),n.d(t,"FreeCameraKeyboardMoveInput",(function(){return jt})),n.d(t,"FreeCameraMouseInput",(function(){return Ht})),n.d(t,"FreeCameraMouseWheelInput",(function(){return Xt})),n.d(t,"FreeCameraTouchInput",(function(){return Yt})),n.d(t,"FreeCameraVirtualJoystickInput",(function(){return en})),n.d(t,"CameraInputTypes",(function(){return xt})),n.d(t,"CameraInputsManager",(function(){return Rt})),n.d(t,"Camera",(function(){return at.a})),n.d(t,"TargetCamera",(function(){return tn})),n.d(t,"FreeCamera",(function(){return nn})),n.d(t,"FreeCameraInputsManager",(function(){return Kt})),n.d(t,"TouchCamera",(function(){return rn})),n.d(t,"ArcRotateCamera",(function(){return on})),n.d(t,"ArcRotateCameraInputsManager",(function(){return wt})),n.d(t,"DeviceOrientationCamera",(function(){return an})),n.d(t,"FlyCamera",(function(){return cn})),n.d(t,"FlyCameraInputsManager",(function(){return sn})),n.d(t,"FollowCamera",(function(){return hn})),n.d(t,"ArcFollowCamera",(function(){return dn})),n.d(t,"FollowCameraInputsManager",(function(){return un})),n.d(t,"GamepadCamera",(function(){return xn})),n.d(t,"AnaglyphArcRotateCamera",(function(){return kn})),n.d(t,"AnaglyphFreeCamera",(function(){return Gn})),n.d(t,"AnaglyphGamepadCamera",(function(){return zn})),n.d(t,"AnaglyphUniversalCamera",(function(){return jn})),n.d(t,"StereoscopicArcRotateCamera",(function(){return Qn})),n.d(t,"StereoscopicFreeCamera",(function(){return qn})),n.d(t,"StereoscopicGamepadCamera",(function(){return Zn})),n.d(t,"StereoscopicUniversalCamera",(function(){return Jn})),n.d(t,"StereoscopicScreenUniversalCamera",(function(){return $n})),n.d(t,"UniversalCamera",(function(){return An})),n.d(t,"VirtualJoysticksCamera",(function(){return ei})),n.d(t,"VRCameraMetrics",(function(){return ti})),n.d(t,"VRDeviceOrientationArcRotateCamera",(function(){return _i})),n.d(t,"VRDeviceOrientationFreeCamera",(function(){return mi})),n.d(t,"VRDeviceOrientationGamepadCamera",(function(){return gi})),n.d(t,"OnAfterEnteringVRObservableEvent",(function(){return rr})),n.d(t,"VRExperienceHelper",(function(){return or})),n.d(t,"WebVRFreeCamera",(function(){return yi})),n.d(t,"setStereoscopicAnaglyphRigMode",(function(){return Vn})),n.d(t,"setStereoscopicRigMode",(function(){return Kn})),n.d(t,"setVRRigMode",(function(){return fi})),n.d(t,"setWebVRRigMode",(function(){return bi})),n.d(t,"Collider",(function(){return sr})),n.d(t,"DefaultCollisionCoordinator",(function(){return cr})),n.d(t,"PickingInfo",(function(){return lr.a})),n.d(t,"IntersectionInfo",(function(){return hr.a})),n.d(t,"_MeshCollisionData",(function(){return dr.a})),n.d(t,"ComputeEffect",(function(){return _r})),n.d(t,"ComputeShader",(function(){return vr})),n.d(t,"BoundingBox",(function(){return br.a})),n.d(t,"BoundingInfo",(function(){return yr.a})),n.d(t,"BoundingSphere",(function(){return Tr.a})),n.d(t,"Octree",(function(){return Sr})),n.d(t,"OctreeBlock",(function(){return Er})),n.d(t,"OctreeSceneComponent",(function(){return Ar})),n.d(t,"Ray",(function(){return pn.a})),n.d(t,"AxesViewer",(function(){return xr.AxesViewer})),n.d(t,"BoneAxesViewer",(function(){return xr.BoneAxesViewer})),n.d(t,"DebugLayerTab",(function(){return xr.DebugLayerTab})),n.d(t,"DebugLayer",(function(){return xr.DebugLayer})),n.d(t,"PhysicsViewer",(function(){return xr.PhysicsViewer})),n.d(t,"RayHelper",(function(){return xr.RayHelper})),n.d(t,"SkeletonViewer",(function(){return xr.SkeletonViewer})),n.d(t,"DirectionalLightFrustumViewer",(function(){return xr.DirectionalLightFrustumViewer})),n.d(t,"DeviceType",(function(){return Rr.a})),n.d(t,"PointerInput",(function(){return Rr.e})),n.d(t,"NativePointerInput",(function(){return Rr.d})),n.d(t,"DualShockInput",(function(){return Rr.c})),n.d(t,"DualSenseInput",(function(){return Rr.b})),n.d(t,"XboxInput",(function(){return Rr.g})),n.d(t,"SwitchInput",(function(){return Rr.f})),n.d(t,"DeviceSource",(function(){return Cr.a})),n.d(t,"DeviceSourceManager",(function(){return Pr.a})),n.d(t,"Constants",(function(){return g.a})),n.d(t,"ThinEngine",(function(){return Ve.a})),n.d(t,"Engine",(function(){return xe.a})),n.d(t,"EngineStore",(function(){return P.a})),n.d(t,"NullEngineOptions",(function(){return Or.b})),n.d(t,"NullEngine",(function(){return Or.a})),n.d(t,"_OcclusionDataStorage",(function(){return Dr})),n.d(t,"_forceTransformFeedbackToBundle",(function(){return Nr})),n.d(t,"EngineView",(function(){return wr})),n.d(t,"allocateAndCopyTypedBuffer",(function(){return Br.a})),n.d(t,"ComputeBindingType",(function(){return ur})),n.d(t,"NativeDataStream",(function(){return Vr})),n.d(t,"WebGLPipelineContext",(function(){return ks.a})),n.d(t,"WebGLHardwareTexture",(function(){return Mi.a})),n.d(t,"PowerPreference",(function(){return Bo})),n.d(t,"FeatureName",(function(){return Uo})),n.d(t,"BufferUsage",(function(){return Vo})),n.d(t,"MapMode",(function(){return ko})),n.d(t,"TextureDimension",(function(){return Go})),n.d(t,"TextureUsage",(function(){return zo})),n.d(t,"TextureViewDimension",(function(){return jo})),n.d(t,"TextureAspect",(function(){return Wo})),n.d(t,"TextureFormat",(function(){return Ho})),n.d(t,"AddressMode",(function(){return Xo})),n.d(t,"FilterMode",(function(){return Yo})),n.d(t,"CompareFunction",(function(){return Ko})),n.d(t,"ShaderStage",(function(){return Qo})),n.d(t,"BufferBindingType",(function(){return qo})),n.d(t,"SamplerBindingType",(function(){return Zo})),n.d(t,"TextureSampleType",(function(){return Jo})),n.d(t,"StorageTextureAccess",(function(){return $o})),n.d(t,"CompilationMessageType",(function(){return ea})),n.d(t,"PrimitiveTopology",(function(){return ta})),n.d(t,"FrontFace",(function(){return na})),n.d(t,"CullMode",(function(){return ia})),n.d(t,"ColorWrite",(function(){return ra})),n.d(t,"BlendFactor",(function(){return oa})),n.d(t,"BlendOperation",(function(){return aa})),n.d(t,"StencilOperation",(function(){return sa})),n.d(t,"IndexFormat",(function(){return ca})),n.d(t,"VertexFormat",(function(){return ua})),n.d(t,"InputStepMode",(function(){return la})),n.d(t,"ComputePassTimestampLocation",(function(){return ha})),n.d(t,"RenderPassTimestampLocation",(function(){return da})),n.d(t,"LoadOp",(function(){return pa})),n.d(t,"StoreOp",(function(){return fa})),n.d(t,"QueryType",(function(){return _a})),n.d(t,"CanvasCompositingAlphaMode",(function(){return ma})),n.d(t,"DeviceLostReason",(function(){return ga})),n.d(t,"ErrorFilter",(function(){return va})),n.d(t,"WebGPUEngine",(function(){return Ns})),n.d(t,"WebGPUCacheRenderPipeline",(function(){return os})),n.d(t,"WebGPUCacheRenderPipelineTree",(function(){return ss})),n.d(t,"WebGPUCacheBindGroups",(function(){return ms})),n.d(t,"WebGPUCacheSampler",(function(){return ns})),n.d(t,"WebGPUDrawContext",(function(){return fs})),n.d(t,"WebGPUTintWASM",(function(){return Is})),n.d(t,"WebGL2ShaderProcessor",(function(){return Co.a})),n.d(t,"AcquireNativeObjectAsync",(function(){return Mo})),n.d(t,"RegisterNativeTypeAsync",(function(){return Io})),n.d(t,"NativeEngine",(function(){return wo})),n.d(t,"ShaderCodeInliner",(function(){return Ro})),n.d(t,"PerformanceConfigurator",(function(){return Gs.a})),n.d(t,"EngineFactory",(function(){return zs})),n.d(t,"ShaderStore",(function(){return Cn.a})),n.d(t,"RenderTargetWrapper",(function(){return On.a})),n.d(t,"KeyboardEventTypes",(function(){return It.a})),n.d(t,"KeyboardInfo",(function(){return It.b})),n.d(t,"KeyboardInfoPre",(function(){return It.c})),n.d(t,"PointerEventTypes",(function(){return qe.a})),n.d(t,"PointerInfoBase",(function(){return qe.c})),n.d(t,"PointerInfoPre",(function(){return qe.d})),n.d(t,"PointerInfo",(function(){return qe.b})),n.d(t,"ClipboardEventTypes",(function(){return js})),n.d(t,"ClipboardInfo",(function(){return Ws})),n.d(t,"DeviceInputEventType",(function(){return Et.a})),n.d(t,"EventConstants",(function(){return Et.b})),n.d(t,"DaydreamController",(function(){return Ys})),n.d(t,"GearVRController",(function(){return Ks})),n.d(t,"GenericController",(function(){return Qs})),n.d(t,"OculusTouchController",(function(){return qs})),n.d(t,"PoseEnabledControllerType",(function(){return ln})),n.d(t,"PoseEnabledControllerHelper",(function(){return mn})),n.d(t,"PoseEnabledController",(function(){return gn})),n.d(t,"ViveController",(function(){return Zs})),n.d(t,"WebVRController",(function(){return Ti})),n.d(t,"WindowsMotionController",(function(){return $s})),n.d(t,"XRWindowsMotionController",(function(){return ec})),n.d(t,"StickValues",(function(){return Ct})),n.d(t,"Gamepad",(function(){return Pt})),n.d(t,"GenericPad",(function(){return Ot})),n.d(t,"GamepadManager",(function(){return En})),n.d(t,"GamepadSystemSceneComponent",(function(){return Sn})),n.d(t,"Xbox360Button",(function(){return fn})),n.d(t,"Xbox360Dpad",(function(){return _n})),n.d(t,"Xbox360Pad",(function(){return yn})),n.d(t,"DualShockButton",(function(){return vn})),n.d(t,"DualShockDpad",(function(){return bn})),n.d(t,"DualShockPad",(function(){return Tn})),n.d(t,"AxisDragGizmo",(function(){return tc.a})),n.d(t,"AxisScaleGizmo",(function(){return oc})),n.d(t,"BoundingBoxGizmo",(function(){return uc})),n.d(t,"Gizmo",(function(){return ic.a})),n.d(t,"GizmoManager",(function(){return yc})),n.d(t,"PlaneRotationGizmo",(function(){return dc})),n.d(t,"PositionGizmo",(function(){return _c})),n.d(t,"RotationGizmo",(function(){return pc})),n.d(t,"ScaleGizmo",(function(){return bc})),n.d(t,"LightGizmo",(function(){return Mc})),n.d(t,"CameraGizmo",(function(){return Ic})),n.d(t,"PlaneDragGizmo",(function(){return fc})),n.d(t,"EnvironmentHelper",(function(){return Jc})),n.d(t,"PhotoDome",(function(){return eu})),n.d(t,"_forceSceneHelpersToBundle",(function(){return jh})),n.d(t,"VideoDome",(function(){return Hh})),n.d(t,"EngineInstrumentation",(function(){return Xh})),n.d(t,"SceneInstrumentation",(function(){return Yh})),n.d(t,"_TimeToken",(function(){return Mr})),n.d(t,"EffectLayer",(function(){return qh})),n.d(t,"EffectLayerSceneComponent",(function(){return Zh})),n.d(t,"GlowLayer",(function(){return ed})),n.d(t,"HighlightLayer",(function(){return id})),n.d(t,"Layer",(function(){return sd})),n.d(t,"LayerSceneComponent",(function(){return rd})),n.d(t,"LensFlare",(function(){return cd})),n.d(t,"LensFlareSystem",(function(){return hd})),n.d(t,"LensFlareSystemSceneComponent",(function(){return dd})),n.d(t,"Light",(function(){return Tc.a})),n.d(t,"ShadowLight",(function(){return Ec})),n.d(t,"ShadowGenerator",(function(){return xd})),n.d(t,"CascadedShadowGenerator",(function(){return Bd})),n.d(t,"ShadowGeneratorSceneComponent",(function(){return Ud})),n.d(t,"DirectionalLight",(function(){return Sc})),n.d(t,"HemisphericLight",(function(){return vi.a})),n.d(t,"PointLight",(function(){return Vd})),n.d(t,"SpotLight",(function(){return Oc})),n.d(t,"DefaultLoadingScreen",(function(){return kd})),n.d(t,"_BabylonLoaderRegistered",(function(){return up})),n.d(t,"BabylonFileLoaderConfiguration",(function(){return lp})),n.d(t,"SceneLoaderAnimationGroupLoadingMode",(function(){return Vs})),n.d(t,"SceneLoader",(function(){return Xs})),n.d(t,"SceneLoaderFlags",(function(){return Hs.a})),n.d(t,"BackgroundMaterial",(function(){return Zc})),n.d(t,"ColorCurves",(function(){return bp.a})),n.d(t,"EffectFallbacks",(function(){return Qc.a})),n.d(t,"Effect",(function(){return ya.a})),n.d(t,"FresnelParameters",(function(){return yp})),n.d(t,"ImageProcessingConfigurationDefines",(function(){return Ei.b})),n.d(t,"ImageProcessingConfiguration",(function(){return Ei.a})),n.d(t,"Material",(function(){return cu.a})),n.d(t,"MaterialDefines",(function(){return Gc.a})),n.d(t,"ThinMaterialHelper",(function(){return Tp.a})),n.d(t,"MaterialHelper",(function(){return kc.a})),n.d(t,"MultiMaterial",(function(){return zd.a})),n.d(t,"OcclusionMaterial",(function(){return Ep})),n.d(t,"MaterialAnisotropicDefines",(function(){return qu})),n.d(t,"PBRAnisotropicConfiguration",(function(){return Zu})),n.d(t,"PBRMaterialDefines",(function(){return rl})),n.d(t,"PBRBaseMaterial",(function(){return ol})),n.d(t,"PBRBaseSimpleMaterial",(function(){return Sp})),n.d(t,"MaterialClearCoatDefines",(function(){return Ku})),n.d(t,"PBRClearCoatConfiguration",(function(){return Qu})),n.d(t,"PBRMaterial",(function(){return al})),n.d(t,"PBRMetallicRoughnessMaterial",(function(){return Ap})),n.d(t,"PBRSpecularGlossinessMaterial",(function(){return xp})),n.d(t,"MaterialSheenDefines",(function(){return Ju})),n.d(t,"PBRSheenConfiguration",(function(){return $u})),n.d(t,"MaterialSubSurfaceDefines",(function(){return el})),n.d(t,"PBRSubSurfaceConfiguration",(function(){return tl})),n.d(t,"PushMaterial",(function(){return zc.a})),n.d(t,"ShaderLanguage",(function(){return fr.a})),n.d(t,"ShaderMaterial",(function(){return lc.a})),n.d(t,"StandardMaterialDefines",(function(){return Si.b})),n.d(t,"StandardMaterial",(function(){return Si.a})),n.d(t,"BaseTexture",(function(){return Kr.a})),n.d(t,"ColorGradingTexture",(function(){return Rp})),n.d(t,"CubeTexture",(function(){return Vc})),n.d(t,"DynamicTexture",(function(){return Ai.a})),n.d(t,"EquiRectangularCubeTexture",(function(){return Cp})),n.d(t,"ExternalTexture",(function(){return ds})),n.d(t,"HDRFiltering",(function(){return Qd})),n.d(t,"HDRCubeTexture",(function(){return qd})),n.d(t,"HtmlElementTexture",(function(){return Pp})),n.d(t,"InternalTextureSource",(function(){return Ue.b})),n.d(t,"InternalTexture",(function(){return Ue.a})),n.d(t,"_DDSTextureLoader",(function(){return pl})),n.d(t,"_ENVTextureLoader",(function(){return fl})),n.d(t,"_KTXTextureLoader",(function(){return yl})),n.d(t,"_TGATextureLoader",(function(){return Dp})),n.d(t,"_HDRTextureLoader",(function(){return Np})),n.d(t,"_BasisTextureLoader",(function(){return Hp})),n.d(t,"MirrorTexture",(function(){return Uc})),n.d(t,"MultiRenderTarget",(function(){return Xp})),n.d(t,"TexturePacker",(function(){return Kp})),n.d(t,"TexturePackerFrame",(function(){return Yp})),n.d(t,"CustomProceduralTexture",(function(){return Qp})),n.d(t,"NoiseProceduralTexture",(function(){return Zp})),n.d(t,"ProceduralTexture",(function(){return xh})),n.d(t,"ProceduralTextureSceneComponent",(function(){return Eh})),n.d(t,"RawCubeTexture",(function(){return Jp})),n.d(t,"RawTexture",(function(){return Ye})),n.d(t,"RawTexture2DArray",(function(){return Jd})),n.d(t,"RawTexture3D",(function(){return $p})),n.d(t,"RefractionTexture",(function(){return ef})),n.d(t,"RenderTargetTexture",(function(){return ci})),n.d(t,"TextureSampler",(function(){return gr.a})),n.d(t,"Texture",(function(){return Be.a})),n.d(t,"ThinTexture",(function(){return tf.a})),n.d(t,"ThinRenderTargetTexture",(function(){return nf})),n.d(t,"VideoTexture",(function(){return Wh})),n.d(t,"UniformBuffer",(function(){return oi.a})),n.d(t,"MaterialFlags",(function(){return jc.a})),n.d(t,"NodeMaterialBlockTargets",(function(){return Il})),n.d(t,"NodeMaterialBlockConnectionPointTypes",(function(){return Ml})),n.d(t,"NodeMaterialBlockConnectionPointMode",(function(){return Yl})),n.d(t,"NodeMaterialSystemValues",(function(){return Kl})),n.d(t,"NodeMaterialModes",(function(){return sh})),n.d(t,"NodeMaterialConnectionPointCompatibilityStates",(function(){return Bl})),n.d(t,"NodeMaterialConnectionPointDirection",(function(){return Ul})),n.d(t,"NodeMaterialConnectionPoint",(function(){return Gl})),n.d(t,"NodeMaterialBlock",(function(){return zl})),n.d(t,"NodeMaterialDefines",(function(){return Ph})),n.d(t,"NodeMaterial",(function(){return Oh})),n.d(t,"VertexOutputBlock",(function(){return Hl})),n.d(t,"BonesBlock",(function(){return rf})),n.d(t,"InstancesBlock",(function(){return of})),n.d(t,"MorphTargetsBlock",(function(){return af})),n.d(t,"LightInformationBlock",(function(){return sf})),n.d(t,"FragmentOutputBlock",(function(){return ql})),n.d(t,"ImageProcessingBlock",(function(){return cf})),n.d(t,"PerturbNormalBlock",(function(){return uf})),n.d(t,"DiscardBlock",(function(){return lf})),n.d(t,"FrontFacingBlock",(function(){return hf})),n.d(t,"DerivativeBlock",(function(){return df})),n.d(t,"FragCoordBlock",(function(){return pf})),n.d(t,"ScreenSizeBlock",(function(){return ff})),n.d(t,"ScreenSpaceBlock",(function(){return _f})),n.d(t,"TwirlBlock",(function(){return mf})),n.d(t,"FogBlock",(function(){return gf})),n.d(t,"LightBlock",(function(){return vf})),n.d(t,"TextureBlock",(function(){return Tf})),n.d(t,"ReflectionTextureBlock",(function(){return Sf})),n.d(t,"CurrentScreenBlock",(function(){return th})),n.d(t,"SceneDepthBlock",(function(){return Af})),n.d(t,"ImageSourceBlock",(function(){return yf})),n.d(t,"ClipPlanesBlock",(function(){return xf})),n.d(t,"InputBlock",(function(){return eh})),n.d(t,"AnimatedInputBlockTypes",(function(){return Ql})),n.d(t,"MultiplyBlock",(function(){return ch})),n.d(t,"AddBlock",(function(){return Rf})),n.d(t,"ScaleBlock",(function(){return Cf})),n.d(t,"ClampBlock",(function(){return Pf})),n.d(t,"CrossBlock",(function(){return Of})),n.d(t,"CustomBlock",(function(){return Mf})),n.d(t,"DotBlock",(function(){return If})),n.d(t,"TransformBlock",(function(){return jl})),n.d(t,"RemapBlock",(function(){return ah})),n.d(t,"NormalizeBlock",(function(){return Df})),n.d(t,"TrigonometryBlockOperations",(function(){return Ah})),n.d(t,"TrigonometryBlock",(function(){return Rh})),n.d(t,"ColorMergerBlock",(function(){return Nf})),n.d(t,"VectorMergerBlock",(function(){return oh})),n.d(t,"ColorSplitterBlock",(function(){return yh})),n.d(t,"VectorSplitterBlock",(function(){return Lf})),n.d(t,"LerpBlock",(function(){return Ff})),n.d(t,"DivideBlock",(function(){return wf})),n.d(t,"SubtractBlock",(function(){return Bf})),n.d(t,"StepBlock",(function(){return Uf})),n.d(t,"OneMinusBlock",(function(){return Vf})),n.d(t,"ViewDirectionBlock",(function(){return kf})),n.d(t,"FresnelBlock",(function(){return Gf})),n.d(t,"MaxBlock",(function(){return zf})),n.d(t,"MinBlock",(function(){return jf})),n.d(t,"DistanceBlock",(function(){return Wf})),n.d(t,"LengthBlock",(function(){return Hf})),n.d(t,"NegateBlock",(function(){return Xf})),n.d(t,"PowBlock",(function(){return Yf})),n.d(t,"RandomNumberBlock",(function(){return Kf})),n.d(t,"ArcTan2Block",(function(){return Qf})),n.d(t,"SmoothStepBlock",(function(){return qf})),n.d(t,"ReciprocalBlock",(function(){return Zf})),n.d(t,"ReplaceColorBlock",(function(){return Jf})),n.d(t,"PosterizeBlock",(function(){return e_})),n.d(t,"WaveBlockKind",(function(){return $f})),n.d(t,"WaveBlock",(function(){return t_})),n.d(t,"GradientBlockColorStep",(function(){return n_})),n.d(t,"GradientBlock",(function(){return i_})),n.d(t,"NLerpBlock",(function(){return r_})),n.d(t,"WorleyNoise3DBlock",(function(){return o_})),n.d(t,"SimplexPerlin3DBlock",(function(){return a_})),n.d(t,"NormalBlendBlock",(function(){return s_})),n.d(t,"Rotate2dBlock",(function(){return c_})),n.d(t,"ReflectBlock",(function(){return u_})),n.d(t,"RefractBlock",(function(){return l_})),n.d(t,"DesaturateBlock",(function(){return h_})),n.d(t,"PBRMetallicRoughnessBlock",(function(){return b_})),n.d(t,"SheenBlock",(function(){return d_})),n.d(t,"AnisotropyBlock",(function(){return p_})),n.d(t,"ReflectionBlock",(function(){return f_})),n.d(t,"ClearCoatBlock",(function(){return __})),n.d(t,"RefractionBlock",(function(){return m_})),n.d(t,"SubSurfaceBlock",(function(){return g_})),n.d(t,"ParticleTextureBlock",(function(){return nh})),n.d(t,"ParticleRampGradientBlock",(function(){return ih})),n.d(t,"ParticleBlendMultiplyBlock",(function(){return rh})),n.d(t,"ModBlock",(function(){return y_})),n.d(t,"MatrixBuilderBlock",(function(){return E_})),n.d(t,"ConditionalBlockConditions",(function(){return T_})),n.d(t,"ConditionalBlock",(function(){return S_})),n.d(t,"CloudBlock",(function(){return A_})),n.d(t,"VoronoiNoiseBlock",(function(){return x_})),n.d(t,"ElbowBlock",(function(){return R_})),n.d(t,"NodeMaterialOptimizer",(function(){return C_})),n.d(t,"PropertyTypeForEdition",(function(){return Wl})),n.d(t,"editableInPropertyPage",(function(){return Xl})),n.d(t,"EffectRenderer",(function(){return Hd})),n.d(t,"EffectWrapper",(function(){return Xd})),n.d(t,"ShadowDepthWrapper",(function(){return O_})),n.d(t,"DrawWrapper",(function(){return In.a})),n.d(t,"MaterialPluginBase",(function(){return ru.a})),n.d(t,"MaterialPluginManager",(function(){return M_.a})),n.d(t,"RegisterMaterialPlugin",(function(){return M_.b})),n.d(t,"UnregisterMaterialPlugin",(function(){return M_.d})),n.d(t,"UnregisterAllMaterialPlugins",(function(){return M_.c})),n.d(t,"MaterialDetailMapDefines",(function(){return nl.b})),n.d(t,"DetailMapConfiguration",(function(){return nl.a})),n.d(t,"createPBRAnisotropicPlugin",(function(){return I_})),n.d(t,"createPBRBRDFPlugin",(function(){return D_})),n.d(t,"createPBRClearCoatPlugin",(function(){return N_})),n.d(t,"createPBRSheenPlugin",(function(){return L_})),n.d(t,"createPBRSubSurfacePlugin",(function(){return F_})),n.d(t,"createDetailMapPlugin",(function(){return w_})),n.d(t,"Scalar",(function(){return L.a})),n.d(t,"extractMinAndMaxIndexed",(function(){return B_.b})),n.d(t,"extractMinAndMax",(function(){return B_.a})),n.d(t,"Space",(function(){return J.c})),n.d(t,"Axis",(function(){return J.a})),n.d(t,"Coordinate",(function(){return J.b})),n.d(t,"Color3",(function(){return s.a})),n.d(t,"Color4",(function(){return s.b})),n.d(t,"TmpColors",(function(){return s.c})),n.d(t,"ToGammaSpace",(function(){return ht.c})),n.d(t,"ToLinearSpace",(function(){return ht.d})),n.d(t,"PHI",(function(){return ht.b})),n.d(t,"Epsilon",(function(){return ht.a})),n.d(t,"Frustum",(function(){return li.a})),n.d(t,"Orientation",(function(){return oe.e})),n.d(t,"BezierCurve",(function(){return oe.c})),n.d(t,"Angle",(function(){return oe.a})),n.d(t,"Arc2",(function(){return oe.b})),n.d(t,"Path2",(function(){return oe.f})),n.d(t,"Path3D",(function(){return oe.g})),n.d(t,"Curve3",(function(){return oe.d})),n.d(t,"Plane",(function(){return Nt.a})),n.d(t,"Size",(function(){return U.a})),n.d(t,"Vector2",(function(){return a.d})),n.d(t,"Vector3",(function(){return a.e})),n.d(t,"Vector4",(function(){return a.f})),n.d(t,"Quaternion",(function(){return a.b})),n.d(t,"Matrix",(function(){return a.a})),n.d(t,"TmpVectors",(function(){return a.c})),n.d(t,"PositionNormalVertex",(function(){return kr})),n.d(t,"PositionNormalTextureVertex",(function(){return Gr})),n.d(t,"Viewport",(function(){return Wn.a})),n.d(t,"SphericalHarmonics",(function(){return Xr})),n.d(t,"SphericalPolynomial",(function(){return Yr})),n.d(t,"AbstractMesh",(function(){return ot.a})),n.d(t,"DracoCompression",(function(){return k_})),n.d(t,"MeshoptCompression",(function(){return G_})),n.d(t,"CSG",(function(){return Y_})),n.d(t,"Geometry",(function(){return Gd.a})),n.d(t,"GroundMesh",(function(){return Xi})),n.d(t,"GoldbergMesh",(function(){return K_})),n.d(t,"TrailMesh",(function(){return Q_})),n.d(t,"InstancedMesh",(function(){return q_.a})),n.d(t,"LinesMesh",(function(){return Z_.b})),n.d(t,"InstancedLinesMesh",(function(){return Z_.a})),n.d(t,"_CreationDataStorage",(function(){return Te.b})),n.d(t,"_InstancesBatch",(function(){return Te.c})),n.d(t,"Mesh",(function(){return Te.a})),n.d(t,"_injectLTSMesh",(function(){return J_.a})),n.d(t,"VertexData",(function(){return Gi.a})),n.d(t,"MeshBuilder",(function(){return Fm})),n.d(t,"SimplificationSettings",(function(){return wm})),n.d(t,"SimplificationQueue",(function(){return Bm})),n.d(t,"SimplificationType",(function(){return Lm})),n.d(t,"QuadraticErrorSimplification",(function(){return zm})),n.d(t,"SimplicationQueueSceneComponent",(function(){return jm})),n.d(t,"Polygon",(function(){return hm})),n.d(t,"PolygonMeshBuilder",(function(){return dm})),n.d(t,"_PrimaryIsoTriangle",(function(){return Pm})),n.d(t,"PolyhedronData",(function(){return Om})),n.d(t,"GeodesicData",(function(){return Mm})),n.d(t,"SubMesh",(function(){return Dh.a})),n.d(t,"MeshLODLevel",(function(){return Wm.a})),n.d(t,"TransformNode",(function(){return ct.a})),n.d(t,"CreateBoxVertexData",(function(){return nc.c})),n.d(t,"CreateBox",(function(){return nc.b})),n.d(t,"BoxBuilder",(function(){return nc.a})),n.d(t,"CreateTiledBoxVertexData",(function(){return im})),n.d(t,"CreateTiledBox",(function(){return rm})),n.d(t,"TiledBoxBuilder",(function(){return om})),n.d(t,"CreateDisc",(function(){return xc})),n.d(t,"DiscBuilder",(function(){return Rc})),n.d(t,"CreateRibbonVertexData",(function(){return $_.b})),n.d(t,"CreateRibbon",(function(){return $_.a})),n.d(t,"RibbonBuilder",(function(){return $_.c})),n.d(t,"CreateSphereVertexData",(function(){return ac.b})),n.d(t,"CreateSphere",(function(){return ac.a})),n.d(t,"SphereBuilder",(function(){return ac.c})),n.d(t,"CreateHemisphere",(function(){return Cc})),n.d(t,"HemisphereBuilder",(function(){return Pc})),n.d(t,"CreateCylinderVertexData",(function(){return ki.b})),n.d(t,"CreateCylinder",(function(){return ki.a})),n.d(t,"CylinderBuilder",(function(){return ki.c})),n.d(t,"CreateTorusVertexData",(function(){return ji})),n.d(t,"CreateTorus",(function(){return Wi})),n.d(t,"TorusBuilder",(function(){return Hi})),n.d(t,"CreateTorusKnotVertexData",(function(){return am})),n.d(t,"CreateTorusKnot",(function(){return sm})),n.d(t,"TorusKnotBuilder",(function(){return cm})),n.d(t,"CreateLineSystemVertexData",(function(){return sc.d})),n.d(t,"CreateDashedLinesVertexData",(function(){return sc.b})),n.d(t,"CreateLineSystem",(function(){return sc.c})),n.d(t,"CreateLines",(function(){return sc.e})),n.d(t,"CreateDashedLines",(function(){return sc.a})),n.d(t,"LinesBuilder",(function(){return sc.f})),n.d(t,"CreatePolygonVertexData",(function(){return pm})),n.d(t,"CreatePolygon",(function(){return fm})),n.d(t,"ExtrudePolygon",(function(){return _m})),n.d(t,"PolygonBuilder",(function(){return mm})),n.d(t,"ExtrudeShape",(function(){return ap.a})),n.d(t,"ExtrudeShapeCustom",(function(){return ap.b})),n.d(t,"ShapeBuilder",(function(){return ap.c})),n.d(t,"CreateLathe",(function(){return gm})),n.d(t,"LatheBuilder",(function(){return vm})),n.d(t,"CreatePlaneVertexData",(function(){return hc.b})),n.d(t,"CreatePlane",(function(){return hc.a})),n.d(t,"PlaneBuilder",(function(){return hc.c})),n.d(t,"CreateTiledPlaneVertexData",(function(){return em})),n.d(t,"CreateTiledPlane",(function(){return tm})),n.d(t,"TiledPlaneBuilder",(function(){return nm})),n.d(t,"CreateGroundVertexData",(function(){return Yi})),n.d(t,"CreateTiledGroundVertexData",(function(){return Ki})),n.d(t,"CreateGroundFromHeightMapVertexData",(function(){return Qi})),n.d(t,"CreateGround",(function(){return qi})),n.d(t,"CreateTiledGround",(function(){return Zi})),n.d(t,"CreateGroundFromHeightMap",(function(){return Ji})),n.d(t,"GroundBuilder",(function(){return $i})),n.d(t,"CreateTube",(function(){return bm})),n.d(t,"TubeBuilder",(function(){return ym})),n.d(t,"CreatePolyhedronVertexData",(function(){return mc})),n.d(t,"CreatePolyhedron",(function(){return gc})),n.d(t,"PolyhedronBuilder",(function(){return vc})),n.d(t,"CreateIcoSphereVertexData",(function(){return Tm})),n.d(t,"CreateIcoSphere",(function(){return Em})),n.d(t,"IcoSphereBuilder",(function(){return Sm})),n.d(t,"CreateGeodesic",(function(){return Im})),n.d(t,"CreateGoldbergVertexData",(function(){return Dm})),n.d(t,"CreateGoldberg",(function(){return Nm})),n.d(t,"CreateDecal",(function(){return Am})),n.d(t,"DecalBuilder",(function(){return xm})),n.d(t,"CreateCapsuleVertexData",(function(){return Rm.c})),n.d(t,"CreateCapsule",(function(){return Rm.b})),n.d(t,"CapsuleBuilder",(function(){return Rm.a})),n.d(t,"WebGLDataBuffer",(function(){return Hm.a})),n.d(t,"WebGPUDataBuffer",(function(){return qa})),n.d(t,"MorphTarget",(function(){return Zd})),n.d(t,"MorphTargetManager",(function(){return $d})),n.d(t,"RecastJSPlugin",(function(){return Xm})),n.d(t,"RecastJSCrowd",(function(){return Ym})),n.d(t,"Node",(function(){return B.a})),n.d(t,"Database",(function(){return Km})),n.d(t,"BaseParticleSystem",(function(){return bh})),n.d(t,"BoxParticleEmitter",(function(){return uh})),n.d(t,"ConeParticleEmitter",(function(){return lh})),n.d(t,"CylinderParticleEmitter",(function(){return hh})),n.d(t,"CylinderDirectedParticleEmitter",(function(){return dh})),n.d(t,"HemisphericParticleEmitter",(function(){return ph})),n.d(t,"PointParticleEmitter",(function(){return fh})),n.d(t,"SphereParticleEmitter",(function(){return _h})),n.d(t,"SphereDirectedParticleEmitter",(function(){return mh})),n.d(t,"CustomParticleEmitter",(function(){return gh})),n.d(t,"MeshParticleEmitter",(function(){return vh})),n.d(t,"WebGL2ParticleSystem",(function(){return Zm})),n.d(t,"ComputeShaderParticleSystem",(function(){return $m})),n.d(t,"GPUParticleSystem",(function(){return fg})),n.d(t,"Particle",(function(){return og})),n.d(t,"ParticleHelper",(function(){return mg})),n.d(t,"ParticleSystem",(function(){return ug})),n.d(t,"ParticleSystemSet",(function(){return _g})),n.d(t,"SolidParticle",(function(){return vg})),n.d(t,"ModelShape",(function(){return bg})),n.d(t,"DepthSortedParticle",(function(){return yg})),n.d(t,"SolidParticleVertex",(function(){return Tg})),n.d(t,"SolidParticleSystem",(function(){return Eg})),n.d(t,"CloudPoint",(function(){return Sg})),n.d(t,"PointsGroup",(function(){return Ag})),n.d(t,"PointColor",(function(){return gg})),n.d(t,"PointsCloudSystem",(function(){return xg})),n.d(t,"SubEmitterType",(function(){return eg})),n.d(t,"SubEmitter",(function(){return ag})),n.d(t,"PhysicsEngine",(function(){return np})),n.d(t,"PhysicsEngineSceneComponent",(function(){return Pg})),n.d(t,"PhysicsHelper",(function(){return Og})),n.d(t,"PhysicsRadialExplosionEventOptions",(function(){return Lg})),n.d(t,"PhysicsUpdraftEventOptions",(function(){return Fg})),n.d(t,"PhysicsVortexEventOptions",(function(){return wg})),n.d(t,"PhysicsRadialImpulseFalloff",(function(){return Rg})),n.d(t,"PhysicsUpdraftMode",(function(){return Cg})),n.d(t,"PhysicsImpostor",(function(){return ep.a})),n.d(t,"PhysicsJoint",(function(){return tp.e})),n.d(t,"DistanceJoint",(function(){return tp.a})),n.d(t,"MotorEnabledJoint",(function(){return tp.d})),n.d(t,"HingeJoint",(function(){return tp.c})),n.d(t,"Hinge2Joint",(function(){return tp.b})),n.d(t,"CannonJSPlugin",(function(){return rp})),n.d(t,"AmmoJSPlugin",(function(){return sp})),n.d(t,"OimoJSPlugin",(function(){return op})),n.d(t,"AnaglyphPostProcess",(function(){return Un})),n.d(t,"BlackAndWhitePostProcess",(function(){return Ug})),n.d(t,"BloomEffect",(function(){return Wg})),n.d(t,"BloomMergePostProcess",(function(){return jg})),n.d(t,"BlurPostProcess",(function(){return Bc})),n.d(t,"ChromaticAberrationPostProcess",(function(){return Xg})),n.d(t,"CircleOfConfusionPostProcess",(function(){return Kg})),n.d(t,"ColorCorrectionPostProcess",(function(){return qg})),n.d(t,"ConvolutionPostProcess",(function(){return Jg})),n.d(t,"DepthOfFieldBlurPostProcess",(function(){return $g})),n.d(t,"DepthOfFieldEffectBlurLevel",(function(){return tv})),n.d(t,"DepthOfFieldEffect",(function(){return rv})),n.d(t,"DepthOfFieldMergePostProcessOptions",(function(){return nv})),n.d(t,"DepthOfFieldMergePostProcess",(function(){return iv})),n.d(t,"DisplayPassPostProcess",(function(){return av})),n.d(t,"ExtractHighlightsPostProcess",(function(){return Gg})),n.d(t,"FilterPostProcess",(function(){return cv})),n.d(t,"FxaaPostProcess",(function(){return hv})),n.d(t,"GrainPostProcess",(function(){return pv})),n.d(t,"HighlightsPostProcess",(function(){return _v})),n.d(t,"ImageProcessingPostProcess",(function(){return Pi})),n.d(t,"MotionBlurPostProcess",(function(){return Sv})),n.d(t,"PassPostProcess",(function(){return Fn})),n.d(t,"PassCubePostProcess",(function(){return wn})),n.d(t,"PostProcess",(function(){return Dn})),n.d(t,"PostProcessManager",(function(){return ai.a})),n.d(t,"RefractionPostProcess",(function(){return xv})),n.d(t,"DefaultRenderingPipeline",(function(){return Iv})),n.d(t,"LensRenderingPipeline",(function(){return Lv})),n.d(t,"SSAO2RenderingPipeline",(function(){return Uv})),n.d(t,"SSAORenderingPipeline",(function(){return kv})),n.d(t,"StandardRenderingPipeline",(function(){return Hv})),n.d(t,"PostProcessRenderEffect",(function(){return Vg})),n.d(t,"PostProcessRenderPipeline",(function(){return Pv})),n.d(t,"PostProcessRenderPipelineManager",(function(){return Ov})),n.d(t,"PostProcessRenderPipelineManagerSceneComponent",(function(){return Mv})),n.d(t,"SharpenPostProcess",(function(){return Cv})),n.d(t,"StereoscopicInterlacePostProcessI",(function(){return Xn})),n.d(t,"StereoscopicInterlacePostProcess",(function(){return Yn})),n.d(t,"TonemappingOperator",(function(){return Yv})),n.d(t,"TonemapPostProcess",(function(){return Kv})),n.d(t,"VolumetricLightScatteringPostProcess",(function(){return Jv})),n.d(t,"VRDistortionCorrectionPostProcess",(function(){return ii})),n.d(t,"VRMultiviewToSingleviewPostProcess",(function(){return pi})),n.d(t,"ScreenSpaceReflectionPostProcess",(function(){return jv})),n.d(t,"ScreenSpaceCurvaturePostProcess",(function(){return eb})),n.d(t,"ReflectionProbe",(function(){return cp})),n.d(t,"BoundingBoxRenderer",(function(){return rb})),n.d(t,"DepthRenderer",(function(){return Pd})),n.d(t,"DepthRendererSceneComponent",(function(){return ob})),n.d(t,"DepthPeelingRenderer",(function(){return ub})),n.d(t,"DepthPeelingSceneComponent",(function(){return lb})),n.d(t,"EdgesRenderer",(function(){return fb})),n.d(t,"LineEdgesRenderer",(function(){return _b})),n.d(t,"GeometryBufferRenderer",(function(){return bv})),n.d(t,"GeometryBufferRendererSceneComponent",(function(){return Tv})),n.d(t,"PrePassRenderer",(function(){return gb})),n.d(t,"PrePassRendererSceneComponent",(function(){return vb})),n.d(t,"SubSurfaceSceneComponent",(function(){return Ab})),n.d(t,"OutlineRenderer",(function(){return Cb})),n.d(t,"RenderingGroup",(function(){return Pb.a})),n.d(t,"RenderingGroupInfo",(function(){return si.a})),n.d(t,"RenderingManager",(function(){return si.b})),n.d(t,"UtilityLayerRenderer",(function(){return rc.a})),n.d(t,"Scene",(function(){return Q.a})),n.d(t,"_injectLTSScene",(function(){return Ob.a})),n.d(t,"SceneComponentConstants",(function(){return Ne.a})),n.d(t,"Stage",(function(){return Ne.b})),n.d(t,"Sprite",(function(){return Mb})),n.d(t,"SpriteManager",(function(){return Fb})),n.d(t,"SpriteMap",(function(){return Vb})),n.d(t,"SpritePackedManager",(function(){return kb})),n.d(t,"SpriteSceneComponent",(function(){return Ib})),n.d(t,"AlphaState",(function(){return Gb.a})),n.d(t,"DepthCullingState",(function(){return ls.a})),n.d(t,"StencilState",(function(){return zb.a})),n.d(t,"StencilStateComposer",(function(){return cs.a})),n.d(t,"AndOrNotEvaluator",(function(){return jb.a})),n.d(t,"AssetTaskState",(function(){return Ub})),n.d(t,"AbstractAssetTask",(function(){return Wb})),n.d(t,"AssetsProgressEvent",(function(){return Hb})),n.d(t,"ContainerAssetTask",(function(){return Xb})),n.d(t,"MeshAssetTask",(function(){return Yb})),n.d(t,"TextFileAssetTask",(function(){return Kb})),n.d(t,"BinaryFileAssetTask",(function(){return Qb})),n.d(t,"ImageAssetTask",(function(){return qb})),n.d(t,"TextureAssetTask",(function(){return Zb})),n.d(t,"CubeTextureAssetTask",(function(){return Jb})),n.d(t,"HDRCubeTextureAssetTask",(function(){return $b})),n.d(t,"EquiRectangularCubeTextureAssetTask",(function(){return ey})),n.d(t,"AssetsManager",(function(){return ty})),n.d(t,"BasisTranscodeConfiguration",(function(){return Fp})),n.d(t,"BasisToolsOptions",(function(){return wp})),n.d(t,"GetInternalFormatFromBasisFormat",(function(){return Bp})),n.d(t,"TranscodeAsync",(function(){return Gp})),n.d(t,"LoadTextureFromTranscodeResult",(function(){return zp})),n.d(t,"BasisTools",(function(){return jp})),n.d(t,"DDSTools",(function(){return dl})),n.d(t,"expandToProperty",(function(){return F.b})),n.d(t,"serialize",(function(){return F.d})),n.d(t,"serializeAsTexture",(function(){return F.n})),n.d(t,"serializeAsColor3",(function(){return F.f})),n.d(t,"serializeAsFresnelParameters",(function(){return F.i})),n.d(t,"serializeAsVector2",(function(){return F.o})),n.d(t,"serializeAsVector3",(function(){return F.p})),n.d(t,"serializeAsMeshReference",(function(){return F.l})),n.d(t,"serializeAsColorCurves",(function(){return F.h})),n.d(t,"serializeAsColor4",(function(){return F.g})),n.d(t,"serializeAsImageProcessingConfiguration",(function(){return F.j})),n.d(t,"serializeAsQuaternion",(function(){return F.m})),n.d(t,"serializeAsMatrix",(function(){return F.k})),n.d(t,"serializeAsCameraReference",(function(){return F.e}));n.d(t,"SerializationHelper",(function(){return F.a})),n.d(t,"nativeOverride",(function(){return F.c})),n.d(t,"Deferred",(function(){return ny})),n.d(t,"GetEnvInfo",(function(){return co})),n.d(t,"normalizeEnvInfo",(function(){return uo})),n.d(t,"CreateEnvTextureAsync",(function(){return lo})),n.d(t,"CreateImageDataArrayBufferViews",(function(){return po})),n.d(t,"UploadEnvLevelsAsync",(function(){return fo})),n.d(t,"UploadLevelsAsync",(function(){return mo})),n.d(t,"UploadEnvSpherical",(function(){return go})),n.d(t,"_UpdateRGBDAsync",(function(){return vo})),n.d(t,"EnvironmentTextureTools",(function(){return bo})),n.d(t,"MeshExploder",(function(){return iy})),n.d(t,"FilesInput",(function(){return oy})),n.d(t,"CubeMapToSphericalPolynomialTools",(function(){return oo})),n.d(t,"HDRTools",(function(){return Wd})),n.d(t,"PanoramaToCubeMapTools",(function(){return jd})),n.d(t,"KhronosTextureContainer",(function(){return _l})),n.d(t,"EventState",(function(){return o.a})),n.d(t,"Observer",(function(){return o.d})),n.d(t,"MultiObserver",(function(){return o.b})),n.d(t,"Observable",(function(){return o.c})),n.d(t,"PerformanceMonitor",(function(){return sy.a})),n.d(t,"RollingAverage",(function(){return sy.b})),n.d(t,"PromisePolyfill",(function(){return cy.a})),n.d(t,"SceneOptimization",(function(){return uy})),n.d(t,"TextureOptimization",(function(){return ly})),n.d(t,"HardwareScalingOptimization",(function(){return hy})),n.d(t,"ShadowsOptimization",(function(){return dy})),n.d(t,"PostProcessesOptimization",(function(){return py})),n.d(t,"LensFlaresOptimization",(function(){return fy})),n.d(t,"CustomOptimization",(function(){return _y})),n.d(t,"ParticlesOptimization",(function(){return my})),n.d(t,"RenderTargetsOptimization",(function(){return gy})),n.d(t,"MergeMeshesOptimization",(function(){return vy})),n.d(t,"SceneOptimizerOptions",(function(){return by})),n.d(t,"SceneOptimizer",(function(){return yy})),n.d(t,"SceneSerializer",(function(){return Ay})),n.d(t,"SmartArray",(function(){return Rn.a})),n.d(t,"SmartArrayNoDuplicate",(function(){return Rn.b})),n.d(t,"StringDictionary",(function(){return Jt.a})),n.d(t,"Tags",(function(){return te.a})),n.d(t,"CreateResizedCopy",(function(){return Jr})),n.d(t,"ApplyPostProcess",(function(){return $r})),n.d(t,"ToHalfFloat",(function(){return eo})),n.d(t,"FromHalfFloat",(function(){return to})),n.d(t,"TextureTools",(function(){return no})),n.d(t,"GetTGAHeader",(function(){return Op})),n.d(t,"UploadContent",(function(){return Mp})),n.d(t,"TGATools",(function(){return Ip})),n.d(t,"Tools",(function(){return Re.b})),n.d(t,"className",(function(){return Re.c})),n.d(t,"AsyncLoop",(function(){return Re.a})),n.d(t,"VideoRecorder",(function(){return xy})),n.d(t,"JoystickAxis",(function(){return Zt})),n.d(t,"VirtualJoystick",(function(){return $t})),n.d(t,"WorkerPool",(function(){return ml})),n.d(t,"AutoReleaseWorkerPool",(function(){return gl})),n.d(t,"Logger",(function(){return m.a})),n.d(t,"RegisterClass",(function(){return c.b})),n.d(t,"GetClass",(function(){return c.a})),n.d(t,"FilesInputStore",(function(){return ry.a})),n.d(t,"DeepCopier",(function(){return O.a})),n.d(t,"PivotTools",(function(){return cc.a})),n.d(t,"PrecisionDate",(function(){return q.a})),n.d(t,"CreateScreenshot",(function(){return Ry})),n.d(t,"CreateScreenshotAsync",(function(){return Cy})),n.d(t,"CreateScreenshotWithResizeAsync",(function(){return Py})),n.d(t,"CreateScreenshotUsingRenderTarget",(function(){return Oy})),n.d(t,"CreateScreenshotUsingRenderTargetAsync",(function(){return My})),n.d(t,"ScreenshotTools",(function(){return Ny})),n.d(t,"WebRequest",(function(){return V.a})),n.d(t,"InspectableType",(function(){return Dy})),n.d(t,"GetEnvironmentBRDFTexture",(function(){return nu})),n.d(t,"BRDFTextureTools",(function(){return iu})),n.d(t,"RGBDTextureTools",(function(){return io})),n.d(t,"ColorGradient",(function(){return tg})),n.d(t,"Color3Gradient",(function(){return ng})),n.d(t,"FactorGradient",(function(){return ig})),n.d(t,"GradientHelper",(function(){return rg})),n.d(t,"PerfCounter",(function(){return Ir.a})),n.d(t,"RetryStrategy",(function(){return Fy.a})),n.d(t,"LoadFileError",(function(){return Lr.g})),n.d(t,"RequestFileError",(function(){return Lr.l})),n.d(t,"ReadFileError",(function(){return Lr.j})),n.d(t,"FileToolsOptions",(function(){return Lr.c})),n.d(t,"SetCorsBehavior",(function(){return Lr.m})),n.d(t,"LoadImage",(function(){return Lr.h})),n.d(t,"ReadFile",(function(){return Lr.i})),n.d(t,"LoadFile",(function(){return Lr.f})),n.d(t,"RequestFile",(function(){return Lr.k})),n.d(t,"IsFileURL",(function(){return Lr.e})),n.d(t,"IsBase64DataUrl",(function(){return Lr.d})),n.d(t,"DecodeBase64UrlToBinary",(function(){return Lr.a})),n.d(t,"DecodeBase64UrlToString",(function(){return Lr.b})),n.d(t,"FileTools",(function(){return wy.a})),n.d(t,"_injectLTSFileTools",(function(){return wy.b})),n.d(t,"EndsWith",(function(){return Ke.e})),n.d(t,"StartsWith",(function(){return Ke.g})),n.d(t,"Decode",(function(){return Ke.a})),n.d(t,"EncodeArrayBufferToBase64",(function(){return Ke.d})),n.d(t,"DecodeBase64ToString",(function(){return Ke.c})),n.d(t,"DecodeBase64ToBinary",(function(){return Ke.b})),n.d(t,"PadNumber",(function(){return Ke.f})),n.d(t,"StringTools",(function(){return Ke.h})),n.d(t,"DataReader",(function(){return By})),n.d(t,"MinMaxReducer",(function(){return Md})),n.d(t,"DepthReducer",(function(){return Id})),n.d(t,"DataStorage",(function(){return Uy})),n.d(t,"SceneRecorder",(function(){return Vy})),n.d(t,"KhronosTextureContainer2",(function(){return vl})),n.d(t,"Trajectory",(function(){return ky})),n.d(t,"TrajectoryClassifier",(function(){return Wy})),n.d(t,"TimerState",(function(){return Lh})),n.d(t,"setAndStartTimer",(function(){return Uh})),n.d(t,"AdvancedTimer",(function(){return Vh})),n.d(t,"GenerateBase64StringFromPixelData",(function(){return Hy.b})),n.d(t,"GenerateBase64StringFromTexture",(function(){return Hy.c})),n.d(t,"GenerateBase64StringFromTextureAsync",(function(){return Hy.d})),n.d(t,"CopyTools",(function(){return Hy.a})),n.d(t,"Reflector",(function(){return Xy})),n.d(t,"IsWindowObjectExist",(function(){return Pe.e})),n.d(t,"IsNavigatorAvailable",(function(){return Pe.d})),n.d(t,"IsDocumentAvailable",(function(){return Pe.c})),n.d(t,"GetDOMTextContent",(function(){return Pe.b})),n.d(t,"DomManagement",(function(){return Pe.a})),n.d(t,"ComputePressureObserverWrapper",(function(){return Yy.a})),n.d(t,"PerformanceViewerCollector",(function(){return qy})),n.d(t,"PerfCollectionStrategy",(function(){return Jy})),n.d(t,"DynamicFloat32Array",(function(){return Ky})),n.d(t,"inlineScheduler",(function(){return ay.b})),n.d(t,"createYieldingScheduler",(function(){return ay.a})),n.d(t,"runCoroutine",(function(){return ay.e})),n.d(t,"runCoroutineSync",(function(){return ay.g})),n.d(t,"runCoroutineAsync",(function(){return ay.f})),n.d(t,"makeSyncFunction",(function(){return ay.d})),n.d(t,"makeAsyncFunction",(function(){return ay.c})),n.d(t,"RandomGUID",(function(){return Fr.b})),n.d(t,"GUID",(function(){return Fr.a})),n.d(t,"BaseError",(function(){return Po.a})),n.d(t,"ErrorCodes",(function(){return Po.b})),n.d(t,"RuntimeError",(function(){return Po.c})),n.d(t,"WebXRCamera",(function(){return Tl})),n.d(t,"WebXREnterExitUIButton",(function(){return Fh})),n.d(t,"WebXREnterExitUIOptions",(function(){return wh})),n.d(t,"WebXREnterExitUI",(function(){return Bh})),n.d(t,"WebXRExperienceHelper",(function(){return El})),n.d(t,"WebXRInput",(function(){return Ll})),n.d(t,"WebXRInputSource",(function(){return Nl})),n.d(t,"WebXRManagedOutputCanvasOptions",(function(){return Li})),n.d(t,"WebXRManagedOutputCanvas",(function(){return Fi})),n.d(t,"WebXRState",(function(){return Ri})),n.d(t,"WebXRTrackingState",(function(){return Ci})),n.d(t,"WebXRSessionManager",(function(){return Vi})),n.d(t,"WebXRDefaultExperienceOptions",(function(){return Gh})),n.d(t,"WebXRDefaultExperience",(function(){return zh})),n.d(t,"WebXRFeatureName",(function(){return pt})),n.d(t,"WebXRFeaturesManager",(function(){return ft})),n.d(t,"WebXRAbstractFeature",(function(){return Fl})),n.d(t,"WebXRHitTestLegacy",(function(){return $y})),n.d(t,"WebXRAnchorSystem",(function(){return tT})),n.d(t,"WebXRPlaneDetector",(function(){return iT})),n.d(t,"WebXRBackgroundRemover",(function(){return rT})),n.d(t,"WebXRMotionControllerTeleportation",(function(){return kh})),n.d(t,"WebXRControllerPointerSelection",(function(){return wl})),n.d(t,"IWebXRControllerPhysicsOptions",(function(){return oT})),n.d(t,"WebXRControllerPhysics",(function(){return aT})),n.d(t,"WebXRHitTest",(function(){return sT})),n.d(t,"WebXRFeaturePointSystem",(function(){return uT})),n.d(t,"WebXRHand",(function(){return dT})),n.d(t,"WebXRHandTracking",(function(){return pT})),n.d(t,"WebXRMeshDetector",(function(){return _T})),n.d(t,"WebXRImageTracking",(function(){return mT})),n.d(t,"WebXRNearControllerMode",(function(){return Ih})),n.d(t,"WebXRNearInteraction",(function(){return Nh})),n.d(t,"WebXRDomOverlay",(function(){return gT})),n.d(t,"WebXRControllerMovement",(function(){return vT})),n.d(t,"WebXRLightEstimation",(function(){return yT})),n.d(t,"WebXREyeTracking",(function(){return TT})),n.d(t,"WebXRWalkingLocomotion",(function(){return RT})),n.d(t,"WebXRCompositionLayerWrapper",(function(){return CT})),n.d(t,"WebXRProjectionLayerWrapper",(function(){return OT})),n.d(t,"WebXRLayers",(function(){return NT})),n.d(t,"WebXRAbstractMotionController",(function(){return Al})),n.d(t,"WebXRControllerComponent",(function(){return Sl})),n.d(t,"WebXRGenericHandController",(function(){return LT})),n.d(t,"WebXRGenericTriggerMotionController",(function(){return xl})),n.d(t,"WebXRMicrosoftMixedRealityController",(function(){return wT})),n.d(t,"WebXRMotionControllerManager",(function(){return Ol})),n.d(t,"WebXROculusTouchMotionController",(function(){return UT})),n.d(t,"WebXRHTCViveMotionController",(function(){return kT})),n.d(t,"WebXRProfiledMotionController",(function(){return Cl})),n.d(t,"NativeXRLayerWrapper",(function(){return wi})),n.d(t,"NativeXRLayerRenderTargetTextureProvider",(function(){return Bi})),n.d(t,"NativeXRRenderTarget",(function(){return Ui})),n.d(t,"NativeXRFrame",(function(){return zT})),n.d(t,"CompatibilityOptions",(function(){return zi.a}));var i=n(46),r=n(106),o=n(6),a=n(0),s=n(8),c=n(10),u=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.setTriggerParameter=function(e){this._triggerParameter=e},e.prototype._evaluateConditionForCurrentFrame=function(){var e=this._condition;if(!e)return!0;var t=this._actionManager.getScene().getRenderId();return e._evaluationId!==t&&(e._evaluationId=t,e._currentResult=e.isValid()),e._currentResult},e.prototype._executeCurrent=function(e){this._evaluateConditionForCurrentFrame()&&(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 n={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(n),this._condition){var i=this._condition.serialize();return i.children.push(n),t&&t.children.push(i),i}return t&&t.children.push(n),n},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}();Object(c.b)("BABYLON.Action",u);var l=n(56),h=n(2),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}(),p=function(e){function t(n,i,r,o,a){void 0===a&&(a=t.IsEqual);var s=e.call(this,n)||this;return s.propertyPath=r,s.value=o,s.operator=a,s._target=i,s._effectiveTarget=s._getEffectiveTarget(i,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]-1&&this._scene.actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t-1)return!0}return!1},t.prototype.hasSpecificTriggers2=function(e,t){for(var n=0;n=t.OnPickTrigger&&n.trigger<=t.OnPointerOutTrigger)return!0}return!1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e=t.OnPickTrigger&&n.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 n=this.actions.indexOf(e);return-1!==n&&(this.actions.splice(n,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,n){for(var i=0;i0;if(2===e.type?h.push(r):h.push(n),m){for(var g=new Array,v=0;v0){var _=f.properties[0].value,m=null===f.properties[0].targetType?_:i.getMeshByName(_);m._meshId&&(m.mesh=i.getMeshById(m._meshId)),h={trigger:t[f.name],parameter:m}}else h=t[f.name];for(var g=0;g=0?n:0;var c=0,u=s._keys[0],l=s._keys.length-1,h=s._keys[l],d={referenceValue:u.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]},p=!1,f=u.frame,_=h.frame;if(i){var m=s.getRange(i);m&&(f=m.from,_=m.to)}var g=u.frame===f,v=h.frame===_;if(1===s._keys.length){var b=s._getKeyValue(s._keys[0]);d.referenceValue=b.clone?b.clone():b,p=!0}else if(n<=u.frame){b=s._getKeyValue(u.value);d.referenceValue=b.clone?b.clone():b,p=!0}else if(n>=h.frame){b=s._getKeyValue(h.value);d.referenceValue=b.clone?b.clone():b,p=!0}for(var y=0;!p||!g||!v&&y=T.frame&&n<=E.frame){b=void 0;if(n===T.frame)b=s._getKeyValue(T.value);else if(n===E.frame)b=s._getKeyValue(E.value);else{var S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};b=s._interpolate(n,S)}d.referenceValue=b.clone?b.clone():b,p=!0}if(!g&&f>=T.frame&&f<=E.frame){if(f===T.frame)c=y;else if(f===E.frame)c=y+1;else{S={key:y,repeatCount:0,loopMode:this.ANIMATIONLOOPMODE_CONSTANT};var A={frame:f,value:(b=s._interpolate(f,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)l=y;else if(_===E.frame)l=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),l=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<=l;y++){A=s._keys[y];if(!y||s.dataType===e.ANIMATIONTYPE_FLOAT||A.value!==u.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,n,i,r,o,a,s){if(void 0===s&&(s=null),a<=0)return n[e]=t,s&&s(),null;var c=r*(a/1e3);o.setKeys([{frame:0,value:n[e].clone?n[e].clone():n[e]},{frame:c,value:t}]),n.animations||(n.animations=[]),n.animations.push(o);var u=i.beginAnimation(n,0,c,!1);return u.onAnimationEnd=s,u},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=0;o--)this._keys[o].frame>=i&&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,n=this._keys.length;t0)return n.highLimitValue.clone?n.highLimitValue.clone():n.highLimitValue;var i=this._keys;if(1===i.length)return this._getKeyValue(i[0].value);var r=n.key;if(i[r].frame>=t)for(;r-1>=0&&i[r].frame>=t;)r--;for(var o=r;o=t){n.key=o;var s=i[o],c=this._getKeyValue(s.value),u=this._getKeyValue(a.value);if(s.interpolation===N.STEP)return a.frame>t?c:u;var l=void 0!==s.outTangent&&void 0!==a.inTangent,h=a.frame-s.frame,d=(t-s.frame)/h,p=this.getEasingFunction();switch(null!==p&&(d=p.ease(d)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var f=l?this.floatInterpolateFunctionWithTangents(c,s.outTangent*h,u,a.inTangent*h,d):this.floatInterpolateFunction(c,u,d);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return f;case e.ANIMATIONLOOPMODE_RELATIVE:return n.offsetValue*n.repeatCount+f}break;case e.ANIMATIONTYPE_QUATERNION:var _=l?this.quaternionInterpolateFunctionWithTangents(c,s.outTangent.scale(h),u,a.inTangent.scale(h),d):this.quaternionInterpolateFunction(c,u,d);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return _;case e.ANIMATIONLOOPMODE_RELATIVE:return _.addInPlace(n.offsetValue.scale(n.repeatCount))}return _;case e.ANIMATIONTYPE_VECTOR3:var m=l?this.vector3InterpolateFunctionWithTangents(c,s.outTangent.scale(h),u,a.inTangent.scale(h),d):this.vector3InterpolateFunction(c,u,d);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return m.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var g=l?this.vector2InterpolateFunctionWithTangents(c,s.outTangent.scale(h),u,a.inTangent.scale(h),d):this.vector2InterpolateFunction(c,u,d);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_SIZE:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(c,u,d);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(c,u,d).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_COLOR3:var v=l?this.color3InterpolateFunctionWithTangents(c,s.outTangent.scale(h),u,a.inTangent.scale(h),d):this.color3InterpolateFunction(c,u,d);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return v;case e.ANIMATIONLOOPMODE_RELATIVE:return v.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_COLOR4:var b=l?this.color4InterpolateFunctionWithTangents(c,s.outTangent.scale(h),u,a.inTangent.scale(h),d):this.color4InterpolateFunction(c,u,d);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return b;case e.ANIMATIONLOOPMODE_RELATIVE:return b.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_MATRIX:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:if(e.AllowMatricesInterpolation)return this.matrixInterpolateFunction(c,u,d,n.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return c}}break}}return this._getKeyValue(i[i.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,n,i,r){return e.AllowMatrixDecomposeForInterpolation?r?(a.a.DecomposeLerpToRef(t,n,i,r),r):a.a.DecomposeLerp(t,n,i):r?(a.a.LerpToRef(t,n,i,r),r):a.a.Lerp(t,n,i)},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 n in t._ranges={},this._ranges){var i=this._ranges[n];i&&(t._ranges[n]=i.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 n=this.dataType;t.keys=[];for(var i=this.getKeys(),r=0;r=2&&(l=u.values[1]),u.values.length>=3&&(h=u.values[2]),u.values.length>=4&&(d=u.values[3]);break;case e.ANIMATIONTYPE_QUATERNION:if(n=a.b.FromArray(u.values),u.values.length>=8){var p=a.b.FromArray(u.values.slice(4,8));p.equals(a.b.Zero())||(l=p)}if(u.values.length>=12){var f=a.b.FromArray(u.values.slice(8,12));f.equals(a.b.Zero())||(h=f)}u.values.length>=13&&(d=u.values[12]);break;case e.ANIMATIONTYPE_MATRIX:n=a.a.FromArray(u.values),u.values.length>=17&&(d=u.values[16]);break;case e.ANIMATIONTYPE_COLOR3:n=s.a.FromArray(u.values),u.values[3]&&(l=s.a.FromArray(u.values[3])),u.values[4]&&(h=s.a.FromArray(u.values[4])),u.values[5]&&(d=u.values[5]);break;case e.ANIMATIONTYPE_COLOR4:n=s.b.FromArray(u.values),u.values[4]&&(l=s.b.FromArray(u.values[4])),u.values[5]&&(h=s.b.FromArray(u.values[5])),u.values[6]&&(d=s.b.FromArray(u.values[6]));break;case e.ANIMATIONTYPE_VECTOR3:default:n=a.e.FromArray(u.values),u.values[3]&&(l=a.e.FromArray(u.values[3])),u.values[4]&&(h=a.e.FromArray(u.values[4])),u.values[5]&&(d=u.values[5])}var _={};_.frame=u.frame,_.value=n,null!=l&&(_.inTangent=l),null!=h&&(_.outTangent=h),null!=d&&(_.interpolation=d),c.push(_)}if(r.setKeys(c),t.ranges)for(i=0;i0&&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 n=this._animation.targetPropertyPath;if(n.length>1){for(var i=e[n[0]],r=1;r-1&&this._animation.runtimeAnimations.splice(e,1)},e.prototype.setValue=function(e,t){if(this._targetIsArray)for(var n=0;nt[t.length-1].frame&&(e=t[t.length-1].frame);var n=this._events;if(n.length)for(var i=0;ithis._maxFrame)&&(t=this._minFrame),(nthis._maxFrame)&&(n=this._maxFrame);var u,l,h=n-t,d=e*(a.framePerSecond*r)/1e3+this._ratioOffset,p=0;if(this._previousDelay=e,this._previousRatio=d,!i&&n>=t&&d>=h)c=!1,p=a._getKeyValue(this._maxValue);else if(!i&&t>=n&&d<=h)c=!1,p=a._getKeyValue(this._minValue);else if(this._animationState.loopMode!==G.ANIMATIONLOOPMODE_CYCLE){var f=n.toString()+t.toString();if(!this._offsetsCache[f]){this._animationState.repeatCount=0,this._animationState.loopMode=G.ANIMATIONLOOPMODE_CYCLE;var _=a._interpolate(t,this._animationState),m=a._interpolate(n,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),a.dataType){case G.ANIMATIONTYPE_FLOAT:this._offsetsCache[f]=m-_;break;case G.ANIMATIONTYPE_QUATERNION:case G.ANIMATIONTYPE_VECTOR3:case G.ANIMATIONTYPE_VECTOR2:case G.ANIMATIONTYPE_SIZE:case G.ANIMATIONTYPE_COLOR3:this._offsetsCache[f]=m.subtract(_)}this._highLimitsCache[f]=m}p=this._highLimitsCache[f],u=this._offsetsCache[f]}if(void 0===u)switch(a.dataType){case G.ANIMATIONTYPE_FLOAT:u=0;break;case G.ANIMATIONTYPE_QUATERNION:u=j;break;case G.ANIMATIONTYPE_VECTOR3:u=W;break;case G.ANIMATIONTYPE_VECTOR2:u=H;break;case G.ANIMATIONTYPE_SIZE:u=X;break;case G.ANIMATIONTYPE_COLOR3:u=Y}if(this._host&&this._host.syncRoot){var g=this._host.syncRoot;l=t+(n-t)*((g.masterFrame-g.fromFrame)/(g.toFrame-g.fromFrame))}else l=d>0&&t>n||d<0&&t0&&this.currentFrame>l||r<0&&this.currentFrame>0,this._animationState.highLimitValue=p,this._animationState.offsetValue=u;var y=a._interpolate(l,this._animationState);if(this.setValue(y,o),v.length)for(b=0;b0&&l>=v[b].frame&&v[b].frame>=t||h<0&&l<=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(l))}return c||(this._stopped=!0),c},e}(),Q=n(22),q=n(36),Z=n(52),J=n(26),$=function(e){function t(t,n,i,r,o,s,c){void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=null);var u=e.call(this,t,n.getScene())||this;return u.name=t,u.children=new Array,u.animations=new Array,u._index=null,u._absoluteTransform=new a.a,u._invertedAbsoluteTransform=new a.a,u._scalingDeterminant=1,u._worldTransform=new a.a,u._needToDecompose=!0,u._needToCompose=!1,u._linkedTransformNode=null,u._waitingTransformNodeId=null,u._skeleton=n,u._localMatrix=r?r.clone():a.a.Identity(),u._restPose=o||u._localMatrix.clone(),u._baseMatrix=s||u._localMatrix.clone(),u._index=c,n.bones.push(u),u.setParent(i,!1),(s||r)&&u._updateDifferenceMatrix(),u}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"_matrix",{get:function(){return this._compose(),this._localMatrix},set:function(e){this._needToCompose=!1,e.updateFlag!==this._localMatrix.updateFlag&&(this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose())},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"Bone"},t.prototype.getSkeleton=function(){return this._skeleton},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){this.setParent(e)},enumerable:!1,configurable:!0}),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 n=this.parent.children.indexOf(this);-1!==n&&this.parent.children.splice(n,1)}this._parentNode=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._baseMatrix},t.prototype.setBindPose=function(e){this.updateMatrix(e)},t.prototype.getWorldMatrix=function(){return this._worldTransform},t.prototype.returnToRest=function(){var e;if(this._linkedTransformNode){var t=a.c.Vector3[0],n=a.c.Quaternion[0],i=a.c.Vector3[1];this.getRestPose().decompose(t,n,i),this._linkedTransformNode.position.copyFrom(i),this._linkedTransformNode.rotationQuaternion=null!==(e=this._linkedTransformNode.rotationQuaternion)&&void 0!==e?e:a.b.Identity(),this._linkedTransformNode.rotationQuaternion.copyFrom(n),this._linkedTransformNode.scaling.copyFrom(t)}else this._matrix=this._restPose},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,n){void 0===t&&(t=!0),void 0===n&&(n=!0),this._baseMatrix.copyFrom(e),t&&this._updateDifferenceMatrix(),n?this._matrix=e: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 n=0;n-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 n=this,i=0;i-1){for(var i=(o=this._runtimeAnimations).length-1;i>=0;i--){var r=o[i];e&&r.animation.name!=e||(t&&!t(r.target)||(r.dispose(),o.splice(i,1)))}0==o.length&&(this._scene._activeAnimatables.splice(n,1),this._raiseOnAnimationEnd())}}else{if((i=this._scene._activeAnimatables.indexOf(this))>-1){this._scene._activeAnimatables.splice(i,1);var o=this._runtimeAnimations;for(i=0;i0)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 n=this._animationTime,i=0;in&&r>0&&(r*=-1),s&&this.stopAnimation(e,void 0,c),a||(a=new ee(this,e,t,n,i,r,o,void 0,u,l));var h=!c||c(e);if(e.animations&&h&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),p=0;pi&&o>0)o*=-1;else if(i>n&&o<0){var u=i;i=n,n=u}return new ee(this,e,n,i,r,o,a,t,s,c)},Q.a.prototype.beginDirectHierarchyAnimation=function(e,t,n,i,r,o,a,s,c,u){void 0===u&&(u=!1);var l=e.getDescendants(t),h=[];h.push(this.beginDirectAnimation(e,n,i,r,o,a,s,c,u));for(var d=0,p=l;d0)r.copyFrom(i);else if(1===e.animations.length){if(a.b.SlerpToRef(i,n.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 u=1-e.totalWeight;c=[],(s=[]).push(i),c.push(u)}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 l=0;l=u&&a.frame<=l&&(i?(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+n,value:c}));return this.animations[0].createRange(t,u+n,l+n),!0};var te=n(42),ne=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._parentContainer=null,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.metadata=null,this._scene=t||P.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;ti[0].frame&&(this._from=i[0].frame),this._toe){var a={frame:e,value:r.value,inTangent:r.inTangent,outTangent:r.outTangent,interpolation:r.interpolation};i.splice(0,0,a)}if(o.frame-1&&this._scene.animationGroups.splice(e,1),this._parentContainer){var t=this._parentContainer.animationGroups.indexOf(this);t>-1&&this._parentContainer.animationGroups.splice(t,1),this._parentContainer=null}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,n,i){void 0===i&&(i=!1);for(var r=new e(t||this.name,this._scene),o=0,a=this._targetedAnimations;o=.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}(),se=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}(ae),ce=function(e){function t(t){void 0===t&&(t=1);var n=e.call(this)||this;return n.amplitude=t,n}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}(ae),ue=function(e){function t(t,n){void 0===t&&(t=3),void 0===n&&(n=2);var i=e.call(this)||this;return i.bounces=t,i.bounciness=n,i}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),n=this.bounciness;n<=1&&(n=1.001);var i=Math.pow(n,t),r=1-n,o=(1-i)/r+.5*i,a=e*o,s=Math.log(-a*(1-n)+1)/Math.log(n),c=Math.floor(s),u=c+1,l=(1-Math.pow(n,c))/(r*o),h=.5*(l+(1-Math.pow(n,u))/(r*o)),d=e-h,p=h-l;return-Math.pow(1/n,t-c)/(p*p)*(d-p)*(d+p)},t}(ae),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}(ae),he=function(e){function t(t,n){void 0===t&&(t=3),void 0===n&&(n=3);var i=e.call(this)||this;return i.oscillations=t,i.springiness=n,i}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),n=Math.max(0,this.springiness);return(0==n?e:(Math.exp(n*e)-1)/(Math.exp(n)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t}(ae),de=function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.exponent=t,n}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}(ae),pe=function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.power=t,n}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(ae),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}(ae),_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},t}(ae),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 e*e*e*e*e},t}(ae),ge=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}(ae),ve=function(e){function t(t,n,i,r){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=1),void 0===r&&(r=1);var o=e.call(this)||this;return o.x1=t,o.y1=n,o.x2=i,o.y2=r,o}return Object(h.d)(t,e),t.prototype.easeInCore=function(e){return oe.c.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(ae),be=function(){function e(e,t,n){this.frame=e,this.action=t,this.onlyOnce=n,this.isDone=!1}return e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)},e}(),ye=function(){function e(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return e.prototype.getPoint=function(){var e=this.path.getPointAtLengthPosition(this.value);return new a.e(e.x,0,e.y)},e.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},e.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},e.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},e.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},e.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},e.prototype.onchange=function(e){return this._onchange.push(e),this},e}(),Te=n(9),Ee=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t}(i.a),Se=function(){this.rootNodes=[],this.skeletons=[],this.animationGroups=[]},Ae=function(e){function t(t){var n=e.call(this)||this;return n._wasAddedToScene=!1,(t=t||P.a.LastCreatedScene)?(n.scene=t,n.sounds=[],n.effectLayers=[],n.layers=[],n.lensFlareSystems=[],n.proceduralTextures=[],n.reflectionProbes=[],t.onDisposeObservable.add((function(){n._wasAddedToScene||n.dispose()})),n._onContextRestoredObserver=t.getEngine().onContextRestoredObservable.add((function(){for(var e=0,t=n.geometries;e-1&&t.animations.splice(o,1)}},r=0,o=e.animations;r0&&(g=!0,this._soundLoaded(n));break;case"String":_.push(n);case"Array":0===_.length&&(_=n);for(var v=0;v<_.length;v++){var b=_[v];if(g=s&&s.skipCodecCheck||-1!==b.indexOf(".mp3",b.length-4)&&xe.a.audioEngine.isMP3supported||-1!==b.indexOf(".ogg",b.length-4)&&xe.a.audioEngine.isOGGsupported||-1!==b.indexOf(".wav",b.length-4)||-1!==b.indexOf(".m4a",b.length-4)||-1!==b.indexOf(".mp4",b.length-4)||-1!==b.indexOf("blob:")){this._streaming?(this._htmlAudioElement=new Audio(b),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,Re.b.SetCorsBehavior(b,this._htmlAudioElement),this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",(function(){p._isReadyToPlay=!0,p.autoplay&&p.play(0,p._offset,p._length),p._readyToPlayCallback&&p._readyToPlayCallback()})),document.body.appendChild(this._htmlAudioElement),this._htmlAudioElement.load()):this._scene._loadFile(b,(function(e){p._soundLoaded(e)}),void 0,!0,!0,(function(e){e&&m.a.Error("XHR "+e.status+" error on: "+b+"."),m.a.Error("Sound creation aborted."),p._scene.mainSoundTrack.removeSound(p)}));break}}break;default:f=!1}f?g||(this._isReadyToPlay=!0,this._readyToPlayCallback&&window.setTimeout((function(){p._readyToPlayCallback&&p._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),xe.a.audioEngine&&!xe.a.audioEngine.WarnedWebAudioUnsupported&&(m.a.Error("Web Audio is not supported by your browser."),xe.a.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout((function(){p._readyToPlayCallback&&p._readyToPlayCallback()}),1e3)}return Object.defineProperty(e.prototype,"loop",{get:function(){return this._loop},set:function(e){e!==this._loop&&(this._loop=e,this.updateOptions({loop:e}))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentTime",{get:function(){var e;if(this._htmlAudioElement)return this._htmlAudioElement.currentTime;var t=this._startOffset;return this.isPlaying&&(null===(e=xe.a.audioEngine)||void 0===e?void 0:e.audioContext)&&(t+=xe.a.audioEngine.audioContext.currentTime-this._startTime),t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"spatialSound",{get:function(){return this._spatialSound},set:function(e){var t;this._spatialSound=e,this._spatialSound&&(null===(t=xe.a.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&xe.a.audioEngine.audioContext&&this._createSpatialParameters()},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){var e;(null===(e=xe.a.audioEngine)||void 0===e?void 0:e.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.getClassName=function(){return"Sound"},e.prototype._soundLoaded=function(e){var t,n=this;(null===(t=xe.a.audioEngine)||void 0===t?void 0:t.audioContext)&&xe.a.audioEngine.audioContext.decodeAudioData(e,(function(e){n._audioBuffer=e,n._isReadyToPlay=!0,n.autoplay&&n.play(0,n._offset,n._length),n._readyToPlayCallback&&n._readyToPlayCallback()}),(function(e){m.a.Error("Error while decoding audio data for: "+n.name+" / Error: "+e)}))},e.prototype.setAudioBuffer=function(e){var t;(null===(t=xe.a.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&(this._audioBuffer=e,this._isReadyToPlay=!0)},e.prototype.updateOptions=function(e){var t,n,i,r,o,a,s,c,u,l;e&&(this.loop=null!==(t=e.loop)&&void 0!==t?t:this.loop,this.maxDistance=null!==(n=e.maxDistance)&&void 0!==n?n:this.maxDistance,this.useCustomAttenuation=null!==(i=e.useCustomAttenuation)&&void 0!==i?i: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!==(u=e.offset)&&void 0!==u?u:void 0,this.setVolume(null!==(l=e.volume)&&void 0!==l?l:this._volume),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(){var e,t;(null===(e=xe.a.audioEngine)||void 0===e?void 0:e.canUseWebAudio)&&xe.a.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=null!==(t=this._soundPanner)&&void 0!==t?t:xe.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(){var e;(null===(e=xe.a.audioEngine)||void 0===e?void 0:e.canUseWebAudio)&&this._spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)},e.prototype.connectToSoundTrackAudioNode=function(e){var t;(null===(t=xe.a.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._outputAudioNode&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(e),this._isOutputConnected=!0)},e.prototype.setDirectionalCone=function(e,t,n){t0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if((null===(t=xe.a.audioEngine)||void 0===t?void 0:t.audioContext)&&this._soundSource){var i=e?xe.a.audioEngine.audioContext.currentTime+e:void 0;this._soundSource.stop(i),void 0===i?(this.isPlaying=!1,this._soundSource.onended=function(){}):this._soundSource.onended=function(){n.isPlaying=!1},this.isPaused||(this._startOffset=0)}},e.prototype.pause=function(){var e;this.isPlaying&&(this.isPaused=!0,this._streaming?(this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect(),this.isPlaying=!1):(null===(e=xe.a.audioEngine)||void 0===e?void 0:e.audioContext)&&(this.stop(0),this._startOffset+=xe.a.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){var n;(null===(n=xe.a.audioEngine)||void 0===n?void 0:n.canUseWebAudio)&&this._soundGain&&(t&&xe.a.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(xe.a.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,xe.a.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,xe.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){var t;if(e.getBoundingInfo){var n=e.getBoundingInfo();this.setPosition(n.boundingSphere.centerWorld)}else this.setPosition(e.absolutePosition);(null===(t=xe.a.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._isDirectional&&this.isPlaying&&this._updateDirection()},e.prototype.clone=function(){var t=this;if(this._streaming)return null;var n=function(){t._isReadyToPlay?(r._audioBuffer=t.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play(0,t._offset,t._length)):window.setTimeout(n,300)},i={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,i);return this.useCustomAttenuation&&r.setAttenuationFunction(this._customAttenuationFunction),r.setPosition(this._position),r.setPlaybackRate(this._playbackRate),n(),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,n,i,r){var o,s=t.name;o=t.url?i+t.url:i+s;var c,u={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 l=function(){r._isReadyToPlay?(c._audioBuffer=r.getAudioBuffer(),c._isReadyToPlay=!0,c.autoplay&&c.play(0,c._offset,c._length)):window.setTimeout(l,300)};c=new e(s,new ArrayBuffer(0),n,null,u),l()}else c=new e(s,o,n,(function(){n._removePendingData(c)}),u),n._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 p=n.getMeshById(t.connectedMeshId);p&&c.attachToMesh(p)}return t.metadata&&(c.metadata=t.metadata),c},e._SceneComponentInitialization=function(e){throw Object(Me.a)("AudioSceneComponent")},e}(),De=function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isInitialized=!1,(e=e||P.a.LastCreatedScene)&&(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(){var e;(null===(e=xe.a.audioEngine)||void 0===e?void 0:e.canUseWebAudio)&&xe.a.audioEngine.audioContext&&(this._outputAudioNode=xe.a.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(xe.a.audioEngine.masterGain),this._options&&this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._isInitialized=!0)},e.prototype.dispose=function(){if(xe.a.audioEngine&&xe.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){var t;this._isInitialized||this._initializeSoundTrackAudioGraph(),(null===(t=xe.a.audioEngine)||void 0===t?void 0:t.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){var t;(null===(t=xe.a.audioEngine)||void 0===t?void 0:t.canUseWebAudio)&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){var e;if(null===(e=xe.a.audioEngine)||void 0===e?void 0:e.canUseWebAudio)for(var t=0;t0?n.activeCameras[0]:n.activeCamera){this._cachedCameraPosition.equals(o.globalPosition)||(this._cachedCameraPosition.copyFrom(o.globalPosition),i.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(e._CameraDirection,s);c.normalize(),isNaN(c.x)||isNaN(c.y)||isNaN(c.z)||this._cachedCameraDirection.equals(c)||(this._cachedCameraDirection.copyFrom(c),i.audioContext.listener.setOrientation(c.x,c.y,c.z,0,1,0))}else i.audioContext.listener.setPosition(0,0,0)}var u;for(u=0;u0?1/r:0,c=0;c>v,y=0;y<6;y++){var T=g[v][y];m&&(T=ke(T,b,b,r)),p.texImage2D(y,v,_,b,b,0,l,u,T)}d._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else d.updateRawCubeTexture(f,o,i,r,h);f.isReady=!0,null==t||t._removePendingData(f),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,n){null==t||t._removePendingData(f),u&&e&&u(e.status+" "+e.statusText,n)})),f},Ve.a.prototype.createRawTexture2DArray=Ge(!1),Ve.a.prototype.createRawTexture3D=Ge(!0),Ve.a.prototype.updateRawTexture2DArray=ze(!1),Ve.a.prototype.updateRawTexture3D=ze(!0);var je,We,He,Xe,Ye=function(e){function t(t,n,i,r,o,a,s,c,u,l){void 0===a&&(a=!0),void 0===s&&(s=!1),void 0===c&&(c=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT);var h=e.call(this,null,o,!a,s,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,l)||this;return h.format=r,h._engine?(h._engine._caps.textureFloatLinearFiltering||u!==g.a.TEXTURETYPE_FLOAT||(c=g.a.TEXTURE_NEAREST_SAMPLINGMODE),h._engine._caps.textureHalfFloatLinearFiltering||u!==g.a.TEXTURETYPE_HALF_FLOAT||(c=g.a.TEXTURE_NEAREST_SAMPLINGMODE),h._texture=h._engine.createRawTexture(t,n,i,r,a,s,c,null,u,null!=l?l:0),h.wrapU=Be.a.CLAMP_ADDRESSMODE,h.wrapV=Be.a.CLAMP_ADDRESSMODE,h):h}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,n,i,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,n,i,g.a.TEXTUREFORMAT_LUMINANCE,r,o,a,s)},t.CreateLuminanceAlphaTexture=function(e,n,i,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,n,i,g.a.TEXTUREFORMAT_LUMINANCE_ALPHA,r,o,a,s)},t.CreateAlphaTexture=function(e,n,i,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,n,i,g.a.TEXTUREFORMAT_ALPHA,r,o,a,s)},t.CreateRGBTexture=function(e,n,i,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,n,i,g.a.TEXTUREFORMAT_RGB,r,o,a,s,c)},t.CreateRGBATexture=function(e,n,i,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,n,i,g.a.TEXTUREFORMAT_RGBA,r,o,a,s,c)},t.CreateRGBAStorageTexture=function(e,n,i,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,n,i,g.a.TEXTUREFORMAT_RGBA,r,o,a,s,c,g.a.TEXTURE_CREATIONFLAG_STORAGE)},t.CreateRTexture=function(e,n,i,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Be.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_FLOAT),new t(e,n,i,g.a.TEXTUREFORMAT_R,r,o,a,s,c)},t.CreateRStorageTexture=function(e,n,i,r,o,a,s,c){return void 0===o&&(o=!0),void 0===a&&(a=!1),void 0===s&&(s=Be.a.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=g.a.TEXTURETYPE_FLOAT),new t(e,n,i,g.a.TEXTUREFORMAT_R,r,o,a,s,c,g.a.TEXTURE_CREATIONFLAG_STORAGE)},t}(Be.a),Ke=n(39),Qe=function(){function e(e,t){this._scene=e,this._mesh=t}return e.prototype.bakeVertexData=function(e){return Object(h.b)(this,void 0,void 0,(function(){var t,n,i,r,o,a,s,c;return Object(h.e)(this,(function(u){switch(u.label){case 0:if(!this._mesh.skeleton)throw new Error("No skeleton in this mesh.");if(t=this._mesh.skeleton.bones.length,n=e.reduce((function(e,t){return e+t.to-t.from+1}),0),isNaN(n))throw new Error("Invalid animation ranges.");i=0,r=new Float32Array(4*(t+1)*4*n),this._scene.stopAnimation(this._mesh),this._mesh.skeleton.returnToRest(),o=0,a=e,u.label=1;case 1:if(!(o0},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e;var n=this._attachedCamera.getScene();this._onPrePointerObservableObserver=n.onPrePointerObservable.add((function(e){e.type!==qe.a.POINTERDOWN?e.type===qe.a.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=q.a.Now,n=0;null!=t._lastFrameTime&&(n=e-t._lastFrameTime),t._lastFrameTime=e,t._applyUserInteraction();var i=e-t._lastInteractionTime-t._idleRotationWaitTime,r=Math.max(Math.min(i/t._idleRotationSpinupTime,1),0);t._cameraRotationSpeed=t._idleRotationSpeed*r,t._attachedCamera&&(t._attachedCamera.alpha-=t._cameraRotationSpeed*(n/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.resetLastInteractionTime=function(e){this._lastInteractionTime=null!=e?e:q.a.Now},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}(),Je=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 n=this._attachedCamera;n&&(e?this._onMeshTargetChangedObserver=n.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var n=e.getBoundingInfo().diagonalLength;t.lowerRadiusTransitionRange=.05*n,t.upperRadiusTransitionRange=.05*n}})):this._onMeshTargetChangedObserver&&n.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 n=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=G.CreateAnimation("radius",G.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 i=G.TransitionTo("radius",this._attachedCamera.radius+t,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return n._clearAnimationLocks()}));i&&this._animatables.push(i)}},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 ce(.3),e.EasingMode=ae.EASINGMODE_EASEOUT,e}(),$e=function(){function e(){this.onTargetFramingAnimationEndObservable=new o.c,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 n=this;this._attachedCamera=t;var i=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==qe.a.POINTERDOWN?e.type===qe.a.POINTERUP&&(n._isPointerDown=!1):n._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&n.zoomOnMesh(e,void 0,(function(){n.onTargetFramingAnimationEndObservable.notifyObservers()}))})),this._onAfterCheckInputsObserver=t.onAfterCheckInputsObservable.add((function(){n._applyUserInteraction(),n._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,n){void 0===t&&(t=!1),void 0===n&&(n=null),e.computeWorldMatrix(!0);var i=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(i.minimumWorld,i.maximumWorld,t,n)},e.prototype.zoomOnMeshHierarchy=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null),e.computeWorldMatrix(!0);var i=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(i.min,i.max,t,n)},e.prototype.zoomOnMeshesHierarchy=function(e,t,n){void 0===t&&(t=!1),void 0===n&&(n=null);for(var i=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;ou.upperRadiusLimit?u.upperRadiusLimit:c),c):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var n=q.a.Now-this._lastInteractionTime,i=.5*Math.PI-this._defaultElevation,r=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>r&&n>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=G.CreateAnimation("beta",G.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=G.TransitionTo("beta",i,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),n=Math.tan(e.fov/2),i=n*t;return new a.d(i,n)},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 de,e.EasingMode=ae.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),et=function(e,t,n,i){void 0===t&&(t=new a.e),void 0===n&&(n=0),void 0===i&&(i=!1),this.direction=e,this.rotatedDirection=t,this.diff=n,this.ignore=i},tt=function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new et(a.e.Up()),new et(a.e.Down()),new et(a.e.Left()),new et(a.e.Right()),new et(a.e.Forward()),new et(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(n){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(n.direction,t._tmpMatrix,n.rotatedDirection),n.diff=a.e.GetAngleBetweenVectors(n.rotatedDirection,e,a.e.Cross(n.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore||e.diff1)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 n=this;e.visibility=t,e.getChildMeshes().forEach((function(e){n._setAllVisibility(e,t)}))},e}(),it=n(77),rt=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 it.a({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new it.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(n){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(n){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 n=t._targetScale.subtract(e.scaling).scaleInPlace(.1);n.length()>.01&&e.scaling.addInPlace(n)}}))},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}(),ot=n(34),at=n(28),st=function(){function e(){this._attachedToElement=!1,this._virtualMeshesInfo={},this._tmpVector=new a.e,this._tmpQuaternion=new a.b,this._dragType={NONE:0,DRAG:1,DRAG_WITH_CONTROLLER:2,NEAR_DRAG:3},this._moving=!1,this._dragging=this._dragType.NONE,this.draggableMeshes=null,this.zDragFactor=3,this.currentDraggingPointerIds=[],this.detachCameraControls=!0,this.onDragStartObservable=new o.c,this.onDragObservable=new o.c,this.onDragEndObservable=new o.c,this.allowMultiPointer=!0}return Object.defineProperty(e.prototype,"currentDraggingPointerId",{get:function(){return void 0!==this.currentDraggingPointerIds[0]?this.currentDraggingPointerIds[0]:-1},set:function(e){this.currentDraggingPointerIds[0]=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentDraggingPointerID",{get:function(){return this.currentDraggingPointerId},set:function(e){this.currentDraggingPointerId=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return"BaseSixDofDrag"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isMoving",{get:function(){return this._moving},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._createVirtualMeshInfo=function(){var t=new ot.a("",e._virtualScene);t.rotationQuaternion=new a.b;var n=new ot.a("",e._virtualScene);n.rotationQuaternion=new a.b;var i=new ot.a("",e._virtualScene);return i.rotationQuaternion=new a.b,{dragging:!1,moving:!1,dragMesh:t,originMesh:n,pivotMesh:i,startingPivotPosition:new a.e,startingPivotOrientation:new a.b,startingPosition:new a.e,startingOrientation:new a.b,lastOriginPosition:new a.e,lastDragPosition:new a.e}},e.prototype._resetVirtualMeshesPosition=function(){for(var e=0;ed&&(d=Math.min(.01-h,0)),l.scaleInPlace(d),l.addToRef(r.pivotMesh.absolutePosition,this._tmpVector),r.pivotMesh.setAbsolutePosition(this._tmpVector),l.addToRef(r.dragMesh.absolutePosition,this._tmpVector),r.dragMesh.setAbsolutePosition(this._tmpVector)}},e.prototype.attach=function(t){var n=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._pointerObserver=this._scene.onPointerObservable.add((function(e,t){var i=e.event.pointerId;n._virtualMeshesInfo[i]||(n._virtualMeshesInfo[i]=n._createVirtualMeshInfo());var r,o=n._virtualMeshesInfo[i],a="xr"===e.event.pointerType;if(e.type==qe.a.POINTERDOWN){if(!o.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.pickedPoint&&e.pickInfo.ray&&(!a||e.pickInfo.aimTransform)&&(r=e.pickInfo.pickedMesh,n._ownerNode===r||r.isDescendantOf(n._ownerNode)&&(!n.draggableMeshes||-1!==n.draggableMeshes.indexOf(r)))){if(!n.allowMultiPointer&&n.currentDraggingPointerIds.length>0)return;!n._pointerCamera||n._pointerCamera.cameraRigMode!==at.a.RIG_MODE_NONE||n._pointerCamera._isLeftCamera||n._pointerCamera._isRightCamera||e.pickInfo.ray.origin.copyFrom(n._pointerCamera.globalPosition),n._ownerNode.computeWorldMatrix(!0);var s=n._virtualMeshesInfo[i];a?(n._dragging=e.pickInfo.originMesh?n._dragType.NEAR_DRAG:n._dragType.DRAG_WITH_CONTROLLER,s.originMesh.position.copyFrom(e.pickInfo.aimTransform.position),n._dragging===n._dragType.NEAR_DRAG&&e.pickInfo.gripTransform?s.originMesh.rotationQuaternion.copyFrom(e.pickInfo.gripTransform.rotationQuaternion):s.originMesh.rotationQuaternion.copyFrom(e.pickInfo.aimTransform.rotationQuaternion)):(n._dragging=n._dragType.DRAG,s.originMesh.position.copyFrom(e.pickInfo.ray.origin)),s.lastOriginPosition.copyFrom(s.originMesh.position),s.dragMesh.position.copyFrom(e.pickInfo.pickedPoint),s.lastDragPosition.copyFrom(e.pickInfo.pickedPoint),s.pivotMesh.position.copyFrom(n._ownerNode.getAbsolutePivotPoint()),s.pivotMesh.rotationQuaternion.copyFrom(n._ownerNode.absoluteRotationQuaternion),s.startingPosition.copyFrom(s.dragMesh.position),s.startingPivotPosition.copyFrom(s.pivotMesh.position),s.startingOrientation.copyFrom(s.dragMesh.rotationQuaternion),s.startingPivotOrientation.copyFrom(s.pivotMesh.rotationQuaternion),a?(s.originMesh.addChild(s.dragMesh),s.originMesh.addChild(s.pivotMesh)):s.originMesh.lookAt(s.dragMesh.position),s.dragging=!0,-1===n.currentDraggingPointerIds.indexOf(i)&&n.currentDraggingPointerIds.push(i),n.detachCameraControls&&n._pointerCamera&&!n._pointerCamera.leftCamera&&(n._pointerCamera.inputs&&n._pointerCamera.inputs.attachedToElement?(n._pointerCamera.detachControl(),n._attachedToElement=!0):n._attachedToElement=!1),n._targetDragStart(s.pivotMesh.position,s.pivotMesh.rotationQuaternion,i),n.onDragStartObservable.notifyObservers({position:s.pivotMesh.position})}}else if(e.type==qe.a.POINTERUP||e.type==qe.a.POINTERDOUBLETAP){var c=n.currentDraggingPointerIds.indexOf(i);o.dragging=!1,-1!==c&&(n.currentDraggingPointerIds.splice(c,1),0===n.currentDraggingPointerIds.length&&(n._moving=!1,n._dragging=n._dragType.NONE,n.detachCameraControls&&n._attachedToElement&&n._pointerCamera&&!n._pointerCamera.leftCamera&&(n._pointerCamera.attachControl(!0),n._attachedToElement=!1)),o.originMesh.removeChild(o.dragMesh),o.originMesh.removeChild(o.pivotMesh),n._targetDragEnd(i),n.onDragEndObservable.notifyObservers({}))}else if(e.type==qe.a.POINTERMOVE){if(-1!==(c=n.currentDraggingPointerIds.indexOf(i))&&o.dragging&&e.pickInfo&&(e.pickInfo.ray||e.pickInfo.aimTransform)){var u=n.zDragFactor;(n.currentDraggingPointerIds.length>1||e.pickInfo.originMesh)&&(u=0),n._ownerNode.computeWorldMatrix(!0),a?n._pointerUpdateXR(e.pickInfo.aimTransform,e.pickInfo.gripTransform,i,u):n._pointerUpdate2D(e.pickInfo.ray,i,u),n._tmpQuaternion.copyFrom(o.startingPivotOrientation),n._tmpQuaternion.x=-n._tmpQuaternion.x,n._tmpQuaternion.y=-n._tmpQuaternion.y,n._tmpQuaternion.z=-n._tmpQuaternion.z,o.pivotMesh.absoluteRotationQuaternion.multiplyToRef(n._tmpQuaternion,n._tmpQuaternion),o.pivotMesh.absolutePosition.subtractToRef(o.startingPivotPosition,n._tmpVector),n.onDragObservable.notifyObservers({delta:n._tmpVector,position:o.pivotMesh.position,pickInfo:e.pickInfo}),n._targetDrag(n._tmpVector,n._tmpQuaternion,i),o.lastDragPosition.copyFrom(o.dragMesh.absolutePosition),n._moving=!0}}}))},e.prototype._applyZOffset=function(e,t,n){e.position.z-=e.position.z<1?t*n:t*n*e.position.z,e.position.z<0&&(e.position.z=0)},e.prototype._targetDragStart=function(e,t,n){},e.prototype._targetDrag=function(e,t,n){},e.prototype._targetDragEnd=function(e){},e.prototype.detach=function(){for(var e in 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._virtualMeshesInfo)this._virtualMeshesInfo[e].originMesh.dispose(),this._virtualMeshesInfo[e].dragMesh.dispose();this.onDragEndObservable.clear(),this.onDragObservable.clear(),this.onDragStartObservable.clear()},e}(),ct=n(47),ut=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._sceneRenderObserver=null,t._targetPosition=new a.e(0,0,0),t._targetOrientation=new a.b,t._targetScaling=new a.e(1,1,1),t._startingPosition=new a.e(0,0,0),t._startingOrientation=new a.b,t._startingScaling=new a.e(1,1,1),t.onPositionChangedObservable=new o.c,t.dragDeltaRatio=.2,t.rotateDraggedObject=!0,t.rotateAroundYOnly=!1,t.rotateWithMotionController=!0,t.disableMovement=!1,t.faceCameraOnDragStart=!1,t}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!1,configurable:!0}),t.prototype.attach=function(t){var n=this;e.prototype.attach.call(this,t),t.isNearGrabbable=!0,this._virtualTransformNode=new ct.a("virtual_sixDof",st._virtualScene),this._virtualTransformNode.rotationQuaternion=a.b.Identity(),this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(1===n.currentDraggingPointerIds.length&&n._moving&&!n.disableMovement){var e=t.parent;t.setParent(null),t.position.addInPlace(n._targetPosition.subtract(t.position).scale(n.dragDeltaRatio)),n.onPositionChangedObservable.notifyObservers({position:t.absolutePosition}),(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&a.b.SlerpToRef(t.rotationQuaternion,n._targetOrientation,n.dragDeltaRatio,t.rotationQuaternion),t.setParent(e)}}))},t.prototype._getPositionOffsetAround=function(e,t,n){var i=a.c.Matrix[0],r=a.c.Matrix[1],o=a.c.Matrix[2],s=a.c.Matrix[3],c=a.c.Matrix[4];return a.a.TranslationToRef(e.x,e.y,e.z,i),a.a.TranslationToRef(-e.x,-e.y,-e.z,r),a.a.FromQuaternionToRef(n,o),a.a.ScalingToRef(t,t,t,s),r.multiplyToRef(o,c),c.multiplyToRef(s,c),c.multiplyToRef(i,c),c.getTranslation()},t.prototype._onePointerPositionUpdated=function(e,t){a.c.Vector3[0].setAll(0),this._dragging===this._dragType.DRAG?this.rotateDraggedObject&&(this.rotateAroundYOnly?a.b.RotationYawPitchRollToRef(t.toEulerAngles().y,0,0,a.c.Quaternion[0]):a.c.Quaternion[0].copyFrom(t),a.c.Quaternion[0].multiplyToRef(this._startingOrientation,this._targetOrientation)):(this._dragging===this._dragType.NEAR_DRAG||this._dragging===this._dragType.DRAG_WITH_CONTROLLER&&this.rotateWithMotionController)&&t.multiplyToRef(this._startingOrientation,this._targetOrientation),this._targetPosition.copyFrom(this._startingPosition).addInPlace(e)},t.prototype._twoPointersPositionUpdated=function(){var e=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].startingPosition,t=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].startingPosition,n=a.c.Vector3[0];e.addToRef(t,n),n.scaleInPlace(.5);var i=a.c.Vector3[1];t.subtractToRef(e,i);var r=this._virtualMeshesInfo[this.currentDraggingPointerIds[0]].dragMesh.absolutePosition,o=this._virtualMeshesInfo[this.currentDraggingPointerIds[1]].dragMesh.absolutePosition,s=a.c.Vector3[2];r.addToRef(o,s),s.scaleInPlace(.5);var c=a.c.Vector3[3];o.subtractToRef(r,c);var u=c.length()/i.length(),l=s.subtract(n),h=a.b.FromEulerAngles(0,a.e.GetAngleBetweenVectorsOnPlane(i.normalize(),c.normalize(),a.e.UpReadOnly),0),d=this._ownerNode.parent;this._ownerNode.setParent(null);var p=this._getPositionOffsetAround(n.subtract(this._virtualTransformNode.getAbsolutePivotPoint()),u,h);this._virtualTransformNode.rotationQuaternion.multiplyToRef(h,this._ownerNode.rotationQuaternion),this._virtualTransformNode.scaling.scaleToRef(u,this._ownerNode.scaling),this._virtualTransformNode.position.addToRef(l.addInPlace(p),this._ownerNode.position),this.onPositionChangedObservable.notifyObservers({position:this._ownerNode.position}),this._ownerNode.setParent(d)},t.prototype._targetDragStart=function(){var e=this.currentDraggingPointerIds.length,t=this._ownerNode.parent;this._ownerNode.rotationQuaternion||(this._ownerNode.rotationQuaternion=a.b.RotationYawPitchRoll(this._ownerNode.rotation.y,this._ownerNode.rotation.x,this._ownerNode.rotation.z));var n=this._ownerNode.getAbsolutePivotPoint();if(this._ownerNode.setParent(null),1===e){if(this._targetPosition.copyFrom(this._ownerNode.position),this._targetOrientation.copyFrom(this._ownerNode.rotationQuaternion),this._targetScaling.copyFrom(this._ownerNode.scaling),this.faceCameraOnDragStart&&this._scene.activeCamera){var i=a.c.Vector3[0];this._scene.activeCamera.position.subtractToRef(n,i),i.normalize();var r=a.c.Quaternion[0];this._scene.useRightHandedSystem?a.b.FromLookDirectionRHToRef(i,new a.e(0,1,0),r):a.b.FromLookDirectionLHToRef(i,new a.e(0,1,0),r),r.normalize(),a.b.RotationYawPitchRollToRef(r.toEulerAngles().y,0,0,a.c.Quaternion[0]),this._targetOrientation.copyFrom(a.c.Quaternion[0])}this._startingPosition.copyFrom(this._targetPosition),this._startingOrientation.copyFrom(this._targetOrientation),this._startingScaling.copyFrom(this._targetScaling)}else 2===e&&(this._virtualTransformNode.setPivotPoint(new a.e(0,0,0),J.c.LOCAL),this._virtualTransformNode.position.copyFrom(this._ownerNode.position),this._virtualTransformNode.scaling.copyFrom(this._ownerNode.scaling),this._virtualTransformNode.rotationQuaternion.copyFrom(this._ownerNode.rotationQuaternion),this._virtualTransformNode.setPivotPoint(n,J.c.WORLD),this._resetVirtualMeshesPosition());this._ownerNode.setParent(t)},t.prototype._targetDrag=function(e,t,n){1===this.currentDraggingPointerIds.length?this._onePointerPositionUpdated(e,t):2===this.currentDraggingPointerIds.length&&this._twoPointersPositionUpdated()},t.prototype._targetDragEnd=function(){if(1===this.currentDraggingPointerIds.length){this._resetVirtualMeshesPosition();var e=this.faceCameraOnDragStart;this.faceCameraOnDragStart=!1,this._targetDragStart(),this.faceCameraOnDragStart=e}},t.prototype.detach=function(){e.prototype.detach.call(this),this._ownerNode&&(this._ownerNode.isNearGrabbable=!1,this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver)),this._virtualTransformNode&&this._virtualTransformNode.dispose()},t}(st),lt=function(){function e(){this._attachPointLocalOffset=new a.e,this._workingPosition=new a.e,this._workingQuaternion=new a.b,this._lastTick=-1,this._hit=!1,this.hitNormalOffset=.05,this.meshes=[],this.interpolatePose=!0,this.lerpTime=250,this.keepOrientationVertical=!0,this.enabled=!0,this.maxStickingDistance=.8}return Object.defineProperty(e.prototype,"name",{get:function(){return"SurfaceMagnetism"},enumerable:!1,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e,t){this._attachedMesh=e,this._scene=t||e.getScene(),this._attachedMesh.rotationQuaternion||(this._attachedMesh.rotationQuaternion=a.b.RotationYawPitchRoll(this._attachedMesh.rotation.y,this._attachedMesh.rotation.x,this._attachedMesh.rotation.z)),this.updateAttachPoint(),this._workingPosition.copyFrom(this._attachedMesh.position),this._workingQuaternion.copyFrom(this._attachedMesh.rotationQuaternion),this._addObservables()},e.prototype.detach=function(){this._attachedMesh=null,this._removeObservables()},e.prototype._getTargetPose=function(e){if(!this._attachedMesh)return null;if(e&&e.hit){var t=e.getNormal(!0,!0),n=e.pickedPoint;if(!t||!n)return null;t.normalize();var i=a.c.Vector3[0];return i.copyFrom(t),i.scaleInPlace(this.hitNormalOffset),i.addInPlace(n),this._attachedMesh.parent&&(a.c.Matrix[0].copyFrom(this._attachedMesh.parent.getWorldMatrix()).invert(),a.e.TransformNormalToRef(i,a.c.Matrix[0],i)),{position:i,quaternion:a.b.RotationYawPitchRoll(-Math.atan2(t.x,-t.z),this.keepOrientationVertical?0:Math.atan2(t.y,Math.sqrt(t.z*t.z+t.x*t.x)),0)}}return null},e.prototype.updateAttachPoint=function(){this._getAttachPointOffsetToRef(this._attachPointLocalOffset)},e.prototype.findAndUpdateTarget=function(e){if(this._hit=!1,!e.ray)return!1;var t=e.ray.intersectsMeshes(this.meshes)[0];if(this._attachedMesh&&t&&t.hit&&t.pickedMesh){var n=this._getTargetPose(t);n&&a.e.Distance(this._attachedMesh.position,n.position)l&&(a.b.RotationAxisToRef(i,-u+l,s),t.rotateByQuaternionToRef(s,t),o=!0)}var h=this._angleBetweenVectorAndPlane(t,i)*(this._scene.useRightHandedSystem?-1:1),d=this.maxViewHorizontalDegrees*Math.PI/180*.5;return h<-d?(a.b.RotationAxisToRef(r,-h-d,s),t.rotateByQuaternionToRef(s,t),o=!0):h>d&&(a.b.RotationAxisToRef(r,-h+d,s),t.rotateByQuaternionToRef(s,t),o=!0),o},e.prototype._orientationClamp=function(e,t){var n,i=this._tmpVectors[0];i.copyFrom(e).scaleInPlace(-1).normalize();var r=this._tmpVectors[1],o=this._tmpVectors[2];r.copyFromFloats(0,1,0),a.e.CrossToRef(i,r,o);var s=o.length();sthis.orientToCameraDeadzoneDegrees},e.prototype._updateLeashing=function(e){if(this.attachedNode&&this._enabled){var t=this.attachedNode.parent;this.attachedNode.setParent(null);var n=this.attachedNode.getWorldMatrix(),i=this._workingPosition,r=this._workingQuaternion,o=this.attachedNode.getPivotPoint(),s=this._tmpInvertView;s.copyFrom(e.getViewMatrix()),s.invert(),a.e.TransformCoordinatesToRef(o,n,i);var c=this._tmpPosition;c.copyFromFloats(0,0,0),a.e.TransformCoordinatesToRef(c,n,c),c.scaleInPlace(-1).subtractInPlace(o),i.subtractInPlace(e.globalPosition),this.ignoreCameraPitchAndRoll&&this._applyPitchOffset(s);var u=!1,l=this._tmpForward;l.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),a.e.TransformNormalToRef(l,s,l);var h=this._tmpNodeForward;if(h.copyFromFloats(0,0,this._scene.useRightHandedSystem?-1:1),a.e.TransformNormalToRef(h,n,h),this._recenterNextUpdate)i.copyFrom(l).scaleInPlace(this.defaultDistance);else if(this.ignoreAngleClamp){var d=i.length();i.copyFrom(l).scaleInPlace(d)}else u=this._angularClamp(s,i);var p=!1;this.ignoreDistanceClamp||(p=this._distanceClamp(i,u),this._applyVerticalClamp(i)),this.useFixedVerticalOffset&&(i.y=c.y-e.globalPosition.y+this.fixedVerticalOffset),(u||p||this._passedOrientationDeadzone(i,h)||this._recenterNextUpdate)&&this._orientationClamp(i,r),this._workingPosition.subtractInPlace(o),this._recenterNextUpdate=!1,this.attachedNode.setParent(t)}},e.prototype._updateTransformToGoal=function(e){if(this.attachedNode&&this.followedCamera&&this._enabled){this.attachedNode.rotationQuaternion||(this.attachedNode.rotationQuaternion=a.b.Identity());var t=this.attachedNode.parent;if(this.attachedNode.setParent(null),!this.interpolatePose)return this.attachedNode.position.copyFrom(this.followedCamera.globalPosition).addInPlace(this._workingPosition),void this.attachedNode.rotationQuaternion.copyFrom(this._workingQuaternion);var n=new a.e;n.copyFrom(this.attachedNode.position).subtractInPlace(this.followedCamera.globalPosition),a.e.SmoothToRef(n,this._workingPosition,e,this.lerpTime,n),n.addInPlace(this.followedCamera.globalPosition),this.attachedNode.position.copyFrom(n);var i=new a.b;i.copyFrom(this.attachedNode.rotationQuaternion),a.b.SmoothToRef(i,this._workingQuaternion,e,this.lerpTime,this.attachedNode.rotationQuaternion),this.attachedNode.setParent(t)}},e.prototype._addObservables=function(){var e=this;this._lastTick=Date.now(),this._onBeforeRender=this._scene.onBeforeRenderObservable.add((function(){if(e.followedCamera){var t=Date.now();e._updateLeashing(e.followedCamera),e._updateTransformToGoal(t-e._lastTick),e._lastTick=t}}))},e.prototype._removeObservables=function(){this._onBeforeRender&&this._scene.onBeforeRenderObservable.remove(this._onBeforeRender)},e}(),pt=function(){function e(){}return e.ANCHOR_SYSTEM="xr-anchor-system",e.BACKGROUND_REMOVER="xr-background-remover",e.HIT_TEST="xr-hit-test",e.MESH_DETECTION="xr-mesh-detection",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.IMAGE_TRACKING="xr-image-tracking",e.NEAR_INTERACTION="xr-near-interaction",e.DOM_OVERLAY="xr-dom-overlay",e.MOVEMENT="xr-controller-movement",e.LIGHT_ESTIMATION="xr-light-estimation",e.EYE_TRACKING="xr-eye-tracking",e.WALKING_LOCOMOTION="xr-walking-locomotion",e.LAYERS="xr-layers",e}(),ft=function(){function e(e){var t=this;this._xrSessionManager=e,this._features={},this._xrSessionManager.onXRSessionInit.add((function(){t.getEnabledFeatures().forEach((function(e){var n=t._features[e];!n.enabled||n.featureImplementation.attached||n.featureImplementation.disableAutoAttach||t.attachFeature(e)}))})),this._xrSessionManager.onXRSessionEnded.add((function(){t.getEnabledFeatures().forEach((function(e){var n=t._features[e];n.enabled&&n.featureImplementation.attached&&t.detachFeature(e)}))}))}return e.AddWebXRFeature=function(e,t,n,i){void 0===n&&(n=1),void 0===i&&(i=!1),this._AvailableFeatures[e]=this._AvailableFeatures[e]||{latest:n},n>this._AvailableFeatures[e].latest&&(this._AvailableFeatures[e].latest=n),i&&(this._AvailableFeatures[e].stable=n),this._AvailableFeatures[e][n]=t},e.ConstructFeature=function(e,t,n,i){void 0===t&&(t=1);var r=this._AvailableFeatures[e][t];if(!r)throw new Error("feature not found");return r(n,i)},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,n=this._features[t];return!(!n||!n.enabled)&&(n.enabled=!1,this.detachFeature(t),n.featureImplementation.dispose(),delete this._features[t],!0)},e.prototype.dispose=function(){var e=this;this.getEnabledFeatures().forEach((function(t){e.disableFeature(t)}))},e.prototype.enableFeature=function(t,n,i,r,o){var a=this;void 0===n&&(n="latest"),void 0===i&&(i={}),void 0===r&&(r=!0),void 0===o&&(o=!0);var s="string"==typeof t?t:t.Name,c=0;if("string"==typeof n){if(!n)throw new Error("Error in provided version - ".concat(s," (").concat(n,")"));if(-1===(c="stable"===n?e.GetStableVersionOfFeature(s):"latest"===n?e.GetLatestVersionOfFeature(s):+n)||isNaN(c))throw new Error("feature not found - ".concat(s," (").concat(n,")"))}else c=n;var u=e._ConflictingFeatures[s];if(void 0!==u&&-1!==this.getEnabledFeatures().indexOf(u))throw new Error("Feature ".concat(s," cannot be enabled while ").concat(u," is enabled."));var l=this._features[s],h=e.ConstructFeature(s,c,this._xrSessionManager,i);if(!h)throw new Error("feature not found - ".concat(s));l&&this.disableFeature(s);var d=h();if(d.dependsOn&&!d.dependsOn.every((function(e){return!!a._features[e]})))throw new Error("Dependant features missing. Make sure the following features are enabled - ".concat(d.dependsOn.join(", ")));if(d.isCompatible())return this._features[s]={featureImplementation:d,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 Re.b.Warn("Feature ".concat(s," not compatible with the current environment/browser and was not enabled.")),d},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){return Object(h.b)(this,void 0,void 0,(function(){var t,n,i,r,o,a,s;return Object(h.e)(this,(function(c){switch(c.label){case 0:t=this.getEnabledFeatures(),n=0,i=t,c.label=1;case 1:return n0)s.lengthSquared()-u2*this.palmUpStrictness-1&&(t=!0)}}this._node.setEnabled(t&&n)},e.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._sceneRenderObserver)},e.prototype.linkToXRExperience=function(e){try{this._eyeTracking=e.featuresManager.getEnabledFeature(pt.EYE_TRACKING)}catch(e){}try{this._handTracking=e.featuresManager.getEnabledFeature(pt.HAND_TRACKING)}catch(e){alert("Hand tracking must be enabled for the Hand Menu to work")}},e}(),mt=function(){function e(e,t,n){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 i=t.getPosition();if(t.getAbsoluteTransform().determinant()>0&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,i.x>i.y&&i.x>i.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),u=this._bone1.getAbsolutePosition(e);this._bone1Length=a.e.Distance(s,c),this._bone2Length=a.e.Distance(c,u)}this._bone1.getRotationMatrixToRef(J.c.WORLD,e,this._bone1Mat),this.maxAngle=Math.PI,n&&(n.targetMesh&&(this.targetMesh=n.targetMesh,this.targetMesh.computeWorldMatrix(!0)),n.poleTargetMesh?(this.poleTargetMesh=n.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):n.poleTargetBone?this.poleTargetBone=n.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),n.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(n.poleTargetLocalOffset),n.poleAngle&&(this.poleAngle=n.poleAngle),n.bendAxis&&this._bendAxis.copyFrom(n.bendAxis),n.maxAngle&&(this.maxAngle=n.maxAngle),n.slerpAmount&&(this.slerpAmount=n.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,n=this._bone2Length;this._maxReach=Math.sqrt(t*t+n*n-2*t*n*Math.cos(e))},e.prototype.update=function(){var t=this._bone1;if(t){var n=this.targetPosition,i=this.poleTargetPosition,r=e._tmpMats[0],o=e._tmpMats[1];this.targetMesh&&n.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,i):this.poleTargetMesh&&a.e.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),i);var s=e._tmpVecs[0],c=e._tmpVecs[1],u=e._tmpVecs[2],l=e._tmpVecs[3],h=e._tmpVecs[4],d=e._tmpQuat;t.getAbsolutePositionToRef(this.mesh,s),i.subtractToRef(s,h),0==h.x&&0==h.y&&0==h.z?h.y=1:h.normalize(),n.subtractToRef(s,l),l.normalize(),a.e.CrossToRef(l,h,c),c.normalize(),a.e.CrossToRef(l,c,u),u.normalize(),a.a.FromXYZAxesToRef(u,l,c,r);var p=this._bone1Length,f=this._bone2Length,_=a.e.Distance(s,n);this._maxReach>0&&(_=Math.min(this._maxReach,_));var m=(f*f+_*_-p*p)/(2*f*_),g=(_*_+p*p-f*f)/(2*_*p);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(l,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._updateLinkedTransformRotation(this._bone1)),this._bone2.setAxisAngle(this._bendAxis,y,J.c.LOCAL),this._updateLinkedTransformRotation(this._bone2),this._bone2Ang=y}},e.prototype._updateLinkedTransformRotation=function(e){e._linkedTransformNode&&(e._linkedTransformNode.rotationQuaternion||(e._linkedTransformNode.rotationQuaternion=new a.b),e.getRotationQuaternionToRef(J.c.LOCAL,null,e._linkedTransformNode.rotationQuaternion))},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}(),gt=function(){function e(e,t,n,i){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=n,i&&(i.adjustYaw&&(this.adjustYaw=i.adjustYaw),i.adjustPitch&&(this.adjustPitch=i.adjustPitch),i.adjustRoll&&(this.adjustRoll=i.adjustRoll),null!=i.maxYaw?this.maxYaw=i.maxYaw:this.maxYaw=Math.PI,null!=i.minYaw?this.minYaw=i.minYaw:this.minYaw=-Math.PI,null!=i.maxPitch?this.maxPitch=i.maxPitch:this.maxPitch=Math.PI,null!=i.minPitch?this.minPitch=i.minPitch:this.minPitch=-Math.PI,null!=i.slerpAmount&&(this.slerpAmount=i.slerpAmount),null!=i.upAxis&&(this.upAxis=i.upAxis),null!=i.upAxisSpace&&(this.upAxisSpace=i.upAxisSpace),null!=i.yawAxis||null!=i.pitchAxis)){var r=J.a.Y,o=J.a.X;null!=i.yawAxis&&(r=i.yawAxis.clone()).normalize(),null!=i.pitchAxis&&(o=i.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,n=e._tmpVecs[0];t.getAbsolutePositionToRef(this.mesh,n);var i=this.target,r=e._tmpMats[0],o=e._tmpMats[1],s=this.mesh,c=t.getParent(),u=e._tmpVecs[1];u.copyFrom(this.upAxis),this.upAxisSpace==J.c.BONE&&c?(this._transformYawPitch&&a.e.TransformCoordinatesToRef(u,this._transformYawPitchInv,u),c.getDirectionToRef(u,this.mesh,u)):this.upAxisSpace==J.c.LOCAL&&(s.getDirectionToRef(u,u),1==s.scaling.x&&1==s.scaling.y&&1==s.scaling.z||u.normalize());var l=!1,h=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(l=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(h=!0),l||h){var d=e._tmpMats[2],p=e._tmpMats[3];if(this.upAxisSpace==J.c.BONE&&1==u.y&&c)c.getRotationMatrixToRef(J.c.WORLD,this.mesh,d);else if(this.upAxisSpace!=J.c.LOCAL||1!=u.y||c){(_=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&a.e.TransformCoordinatesToRef(_,this._transformYawPitchInv,_),c?c.getDirectionToRef(_,this.mesh,_):s.getDirectionToRef(_,_);var f=a.e.Cross(u,_);f.normalize();var _=a.e.Cross(f,u);a.a.FromXYZAxesToRef(f,u,_,d)}else d.copyFrom(s.getWorldMatrix());d.invertToRef(p);var m=null;if(h){var g=e._tmpVecs[3];i.subtractToRef(n,g),a.e.TransformCoordinatesToRef(g,p,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):vthis._maxYaw||yMath.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):yMath.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,p,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 x=this._getAngleBetween(A,this._maxYaw);this._getAngleBetween(A,this._minYaw)Math.PI?n-=2*Math.PI:n<-Math.PI&&(n+=2*Math.PI),n},e.prototype._getAngleBetween=function(e,t){var n=0;return(n=(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&&(n=2*Math.PI-n),n},e.prototype._isAngleBetween=function(e,t,n){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(n=(n%=2*Math.PI)<0?n+2*Math.PI:n)){if(e>t&&en&&e0}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||this.prepare(),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: ".concat(this.name,", nBones: ").concat(this.bones.length);if(t+=", nAnimationRanges: ".concat(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var n=!0;for(var i in this._ranges)n&&(t+=", ",n=!1),t+=i;t+="}"}return t},e.prototype.getBoneIndexByName=function(e){for(var t=0,n=this.bones.length;t-1&&this._meshesWithPoseMatrix.splice(t,1)},e.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var n=0;n0)for(var e=0,t=this.bones;e-1&&this._parentContainer.skeletons.splice(e,1),this._parentContainer=null}this._transformMatrixTexture&&(this._transformMatrixTexture.dispose(),this._transformMatrixTexture=null)},e.prototype.serialize=function(){var e,t={};t.name=this.name,t.id=this.id,this.dimensionsAtRest&&(t.dimensionsAtRest=this.dimensionsAtRest.asArray()),t.bones=[],t.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var n=0;n0&&(o.animation=i.animations[0].serialize()),t.ranges=[],this._ranges){var s=this._ranges[a];if(s){var c={};c.name=a,c.from=s.from,c.to=s.to,t.ranges.push(c)}}}return t},e.Parse=function(t,n){var i,r=new e(t.name,t.id,n);for(t.dimensionsAtRest&&(r.dimensionsAtRest=a.e.FromArray(t.dimensionsAtRest)),r.needInitialSkinMatrix=t.needInitialSkinMatrix,i=0;i-1&&(c=r.bones[o.parentBoneIndex]);var u=o.rest?a.a.FromArray(o.rest):null,l=new $(o.name,r,c,a.a.FromArray(o.matrix),u,null,s);void 0!==o.id&&null!==o.id&&(l.id=o.id),o.length&&(l.length=o.length),o.metadata&&(l.metadata=o.metadata),o.animation&&l.animations.push(G.Parse(o.animation)),void 0!==o.linkedTransformNodeId&&null!==o.linkedTransformNodeId&&(r._hasWaitingData=!0,l._waitingTransformNodeId=o.linkedTransformNodeId)}if(t.ranges)for(i=0;i0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),n=0;n=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}(),Ot=function(e){function t(t,n,i){var r=e.call(this,t,n,i)||this;return r.onButtonDownObservable=new o.c,r.onButtonUpObservable=new o.c,r.type=Pt.GENERIC,r._buttons=new Array(i.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,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t.005&&(e.inertialAlphaOffset+=n)}if(0!=t.y){var i=t.y/this.gamepadRotationSensibility*this._yAxisScale;0!=i&&Math.abs(i)>.005&&(e.inertialBetaOffset+=i)}}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(F.d)()],e.prototype,"gamepadRotationSensibility",void 0),Object(h.c)([Object(F.d)()],e.prototype,"gamepadMoveSensibility",void 0),e}();xt.ArcRotateCameraGamepadInput=Mt;var It=n(78),Dt=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=Re.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(n){var i,r=n.event;r.metaKey||(n.type===It.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===(i=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)||((i=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(i,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;t0?n/(1+this.wheelDeltaPercentage):n*(1+this.wheelDeltaPercentage)},e.prototype.attachControl=function(e){var t=this;e=Re.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n,i){if(n.type===qe.a.POINTERWHEEL){var r=n.event,o=0,a=r,s=0,c=r.deltaMode===Et.b.DOM_DELTA_LINE?40:1;if(s=void 0!==r.deltaY?-r.deltaY*c:void 0!==r.wheelDeltaY?-r.wheelDeltaY*c:a.wheelDelta,t.customComputeDeltaFromMouseWheel)o=t.customComputeDeltaFromMouseWheel(s,t,r);else if(t.wheelDeltaPercentage){if((o=t.computeDeltaFromMouseWheelLegacyEvent(s,t.camera.radius))>0){for(var u=t.camera.radius,l=t.camera.inertialRadiusOffset+o,h=0;h<20&&Math.abs(l)>.001;h++)u-=l,l*=t.camera.inertia;u=L.a.Clamp(u,0,Number.MAX_VALUE),o=t.computeDeltaFromMouseWheelLegacyEvent(s,u)}}else o=s/(40*t.wheelPrecision);o&&(t.zoomToMouseLocation&&t._hitPlane?t._zoomToMouse(o):t.camera.inertialRadiusOffset+=o),r.preventDefault&&(e||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,qe.a.POINTERWHEEL),this.zoomToMouseLocation&&this._inertialPanning.setAll(0)},e.prototype.detachControl=function(e){this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.checkInputs=function(){if(this.zoomToMouseLocation){var e=this.camera;0+e.inertialAlphaOffset+e.inertialBetaOffset+e.inertialRadiusOffset&&(this._updateHitPlane(),e.target.addInPlace(this._inertialPanning),this._inertialPanning.scaleInPlace(e.inertia),this._zeroIfClose(this._inertialPanning))}},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},e.prototype._updateHitPlane=function(){var e=this.camera,t=e.target.subtract(e.position);this._hitPlane=Nt.a.FromPositionAndNormal(e.target,t)},e.prototype._getPosition=function(){var e,t=this.camera,n=t.getScene(),i=n.createPickingRay(n.pointerX,n.pointerY,a.a.Identity(),t,!1),r=0;return this._hitPlane&&(r=null!==(e=i.intersectsPlane(this._hitPlane))&&void 0!==e?e:0),i.origin.addInPlace(i.direction.scaleInPlace(r))},e.prototype._zoomToMouse=function(e){var t,n,i=this.camera,r=1-i.inertia;if(i.lowerRadiusLimit){var o=null!==(t=i.lowerRadiusLimit)&&void 0!==t?t:0;i.radius-(i.inertialRadiusOffset+e)/rs&&(e=(i.radius-s)*r-i.inertialRadiusOffset)}var c=e/r/i.radius,u=this._getPosition(),l=a.c.Vector3[6];u.subtractToRef(i.target,l),l.scaleInPlace(c),l.scaleInPlace(r),this._inertialPanning.addInPlace(l),i.inertialRadiusOffset+=e},e.prototype._zeroIfClose=function(e){Math.abs(e.x)this.camera.pinchToPanMaxDistance?(this._computePinchZoom(n,i),this._isPinching=!0):this._computeMultiTouchPanning(r,o)):this.multiTouchPanning?this._computeMultiTouchPanning(r,o):this.pinchZoom&&this._computePinchZoom(n,i))},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},t.MinimumRadiusForPinch=.001,Object(h.c)([Object(F.d)()],t.prototype,"buttons",void 0),Object(h.c)([Object(F.d)()],t.prototype,"angularSensibilityX",void 0),Object(h.c)([Object(F.d)()],t.prototype,"angularSensibilityY",void 0),Object(h.c)([Object(F.d)()],t.prototype,"pinchPrecision",void 0),Object(h.c)([Object(F.d)()],t.prototype,"pinchDeltaPercentage",void 0),Object(h.c)([Object(F.d)()],t.prototype,"useNaturalPinchZoom",void 0),Object(h.c)([Object(F.d)()],t.prototype,"pinchZoom",void 0),Object(h.c)([Object(F.d)()],t.prototype,"panningSensibility",void 0),Object(h.c)([Object(F.d)()],t.prototype,"multiTouchPanning",void 0),Object(h.c)([Object(F.d)()],t.prototype,"multiTouchPanAndZoom",void 0),t}(At);xt.ArcRotateCameraPointersInput=Ft;var wt=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 Lt),this},t.prototype.addPointers=function(){return this.add(new Ft),this},t.prototype.addKeyboard=function(){return this.add(new Dt),this},t}(Rt);wt.prototype.addVRDeviceOrientation=function(){return this.add(new Bt),this};var Bt=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=Re.b.BackCompatCameraNoPreventDefault(arguments),this.camera.attachControl(e);var n=this.camera.getScene().getEngine().getHostWindow();n&&("undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"===e?n.addEventListener("deviceorientation",t._deviceOrientationHandler):Re.b.Warn("Permission not granted.")})).catch((function(e){Re.b.Error(e)})):n.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}();xt.ArcRotateCameraVRDeviceOrientationInput=Bt;var Ut=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=Re.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(n){var i,r=n.event;n.type===It.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===(i=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)||((i=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(i,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=0&&t._keys.splice(i,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(F.d)()],e.prototype,"keysHeightOffsetIncr",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysHeightOffsetDecr",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysHeightOffsetModifierAlt",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysHeightOffsetModifierShift",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRotationOffsetIncr",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRotationOffsetDecr",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRotationOffsetModifierAlt",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRotationOffsetModifierShift",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRadiusIncr",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRadiusDecr",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRadiusModifierAlt",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRadiusModifierCtrl",void 0),Object(h.c)([Object(F.d)()],e.prototype,"keysRadiusModifierShift",void 0),Object(h.c)([Object(F.d)()],e.prototype,"heightSensibility",void 0),Object(h.c)([Object(F.d)()],e.prototype,"rotationSensibility",void 0),Object(h.c)([Object(F.d)()],e.prototype,"radiusSensibility",void 0),e}();xt.FollowCameraKeyboardMoveInput=kt;var Gt=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=Re.b.BackCompatCameraNoPreventDefault(arguments),this._wheel=function(n,i){if(n.type===qe.a.POINTERWHEEL){var r=n.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 controls 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,qe.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(F.d)()],e.prototype,"axisControlRadius",void 0),Object(h.c)([Object(F.d)()],e.prototype,"axisControlHeight",void 0),Object(h.c)([Object(F.d)()],e.prototype,"axisControlRotation",void 0),Object(h.c)([Object(F.d)()],e.prototype,"wheelPrecision",void 0),Object(h.c)([Object(F.d)()],e.prototype,"wheelDeltaPercentage",void 0),e}();xt.FollowCameraMouseWheelInput=Gt;var zt=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,n){this._warning(),this.axisXControlRotation?this.camera.rotationOffset+=t/this.angularSensibilityX:this.axisYControlRotation&&(this.camera.rotationOffset+=n/this.angularSensibilityX),this.axisXControlHeight?this.camera.heightOffset+=t/this.angularSensibilityY:this.axisYControlHeight&&(this.camera.heightOffset+=n/this.angularSensibilityY),this.axisXControlRadius?this.camera.radius-=t/this.angularSensibilityY:this.axisYControlRadius&&(this.camera.radius-=n/this.angularSensibilityY)},t.prototype.onMultiTouch=function(e,t,n,i,r,o){if(!(0===n&&null===r||0===i&&null===o)){var a=(i-n)/(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(F.d)()],t.prototype,"angularSensibilityX",void 0),Object(h.c)([Object(F.d)()],t.prototype,"angularSensibilityY",void 0),Object(h.c)([Object(F.d)()],t.prototype,"pinchPrecision",void 0),Object(h.c)([Object(F.d)()],t.prototype,"pinchDeltaPercentage",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisXControlRadius",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisXControlHeight",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisXControlRotation",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisYControlRadius",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisYControlHeight",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisYControlRotation",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisPinchControlRadius",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisPinchControlHeight",void 0),Object(h.c)([Object(F.d)()],t.prototype,"axisPinchControlRotation",void 0),t}(At);xt.FollowCameraPointersInput=zt;var jt=function(){function e(){this.keysUp=[38],this.keysUpward=[33],this.keysDown=[40],this.keysDownward=[34],this.keysLeft=[37],this.keysRight=[39],this.rotationSpeed=.5,this.keysRotateLeft=[],this.keysRotateRight=[],this._keys=new Array}return e.prototype.attachControl=function(e){var t=this;e=Re.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(n){var i,r=n.event;r.metaKey||(n.type===It.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===t.keysRotateLeft.indexOf(r.keyCode)&&-1===t.keysRotateRight.indexOf(r.keyCode)||(-1===(i=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)&&-1===t.keysRotateLeft.indexOf(r.keyCode)&&-1===t.keysRotateRight.indexOf(r.keyCode)||((i=t._keys.indexOf(r.keyCode))>=0&&t._keys.splice(i,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;t1)e.cameraRotation.x=-this._offsetY/this.touchAngularSensibility;else{var t=e._computeLocalCameraSpeed(),n=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(n,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},Object(h.c)([Object(F.d)()],e.prototype,"touchAngularSensibility",void 0),Object(h.c)([Object(F.d)()],e.prototype,"touchMoveSensibility",void 0),e}();xt.FreeCameraTouchInput=Yt;var Kt=function(e){function t(t){var n=e.call(this,t)||this;return n._mouseInput=null,n._mouseWheelInput=null,n}return Object(h.d)(t,e),t.prototype.addKeyboard=function(){return this.add(new jt),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this._mouseInput||(this._mouseInput=new Ht(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 Xt,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 Yt),this},t.prototype.clear=function(){e.prototype.clear.call(this),this._mouseInput=null},t}(Rt);Kt.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new Qt,this.add(this._deviceOrientationInput)),this};var Qt=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=-Re.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,n){var i=!1,r=function(){window.removeEventListener("deviceorientation",r),i=!0,t()};e&&setTimeout((function(){i||(window.removeEventListener("deviceorientation",r),n("WaitForOrientationChangeAsync timed out"))}),e),"undefined"!=typeof DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(e){"granted"==e?window.addEventListener("deviceorientation",r):Re.b.Warn("Permission not granted.")})).catch((function(e){Re.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 n=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?n():Re.b.Warn("Permission not granted.")})).catch((function(e){Re.b.Error(e)})):n()}},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(Re.b.ToRadians(this._alpha),Re.b.ToRadians(this._beta),-Re.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}();xt.FreeCameraDeviceOrientationInput=Qt;var qt=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this.deadzoneDelta=.1,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!==Pt.POSE_ENABLED&&(e.gamepad&&t.type!==Pt.XBOX||(e.gamepad=t))})),this._onGamepadDisconnectedObserver=t.onGamepadDisconnectedObservable.add((function(t){e.gamepad===t&&(e.gamepad=null)})),this.gamepad=t.getGamepadByType(Pt.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;0!==this.gamepadMoveSensibility&&(t.x=Math.abs(t.x)>this.deadzoneDelta?t.x/this.gamepadMoveSensibility:0,t.y=Math.abs(t.y)>this.deadzoneDelta?t.y/this.gamepadMoveSensibility:0);var n=this.gamepad.rightStick;n&&0!==this.gamepadAngularSensibility?(n.x=Math.abs(n.x)>this.deadzoneDelta?n.x/this.gamepadAngularSensibility:0,n.y=(Math.abs(n.y)>this.deadzoneDelta?n.y/this.gamepadAngularSensibility:0)*this._yAxisScale):n={x:0,y:0},e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):a.a.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var i=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*i,0,-t.y*i),a.e.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(n.y,n.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},Object(h.c)([Object(F.d)()],e.prototype,"gamepadAngularSensibility",void 0),Object(h.c)([Object(F.d)()],e.prototype,"gamepadMoveSensibility",void 0),e}();xt.FreeCameraGamepadInput=qt;var Zt,Jt=n(131);!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(Zt||(Zt={}));var $t=function(){function e(t,n){var i=this,r=Object(h.a)(Object(h.a)({},e._GetDefaultOptions()),n);if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=Zt.X,this._axisTargetedByUpAndDown=Zt.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new Jt.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){i._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){i._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){i._onPointerUp(e)},e.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){i._drawVirtualJoystick()}))}return e._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.clientXe.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 n=new a.d(t.clientX-this._joystickPointerStartPos.x,t.clientY-this._joystickPointerStartPos.y),i=n.length();i>this.containerSize&&n.scaleInPlace(this.containerSize/i),this._joystickPointerPos.x=this._joystickPointerStartPos.x+n.x,this._joystickPointerPos.y=this._joystickPointerStartPos.y+n.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=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,n=this._decideIfNeedsToMove(),i=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(n&&this._updatePosition(),i){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)}n&&(Math.abs(this.cameraDirection.x)xe.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&n&&o.onCollide(n))},o.inputs=new Kt(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}),Object.defineProperty(t.prototype,"keysRotateLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRotateLeft=e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"keysRotateRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRotateRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRotateRight=e)},enumerable:!1,configurable:!0}),t.prototype.attachControl=function(e,t){t=Re.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 n=e;this.applyGravity&&(n=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,n,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(F.p)()],t.prototype,"ellipsoid",void 0),Object(h.c)([Object(F.p)()],t.prototype,"ellipsoidOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"checkCollisions",void 0),Object(h.c)([Object(F.d)()],t.prototype,"applyGravity",void 0),t}(tn);B.a.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new rn(e,a.e.Zero(),t)}}));var rn=function(e){function t(t,n,i){var r=e.call(this,t,n,i)||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}(nn);B.a.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new on(e,0,0,1,a.e.Zero(),t)}}));var on=function(e){function t(t,n,i,r,s,c,u){void 0===u&&(u=!0);var l=e.call(this,t,a.e.Zero(),c,u)||this;return l.inertialAlphaOffset=0,l.inertialBetaOffset=0,l.inertialRadiusOffset=0,l.lowerAlphaLimit=null,l.upperAlphaLimit=null,l.lowerBetaLimit=.01,l.upperBetaLimit=Math.PI-.01,l.lowerRadiusLimit=null,l.upperRadiusLimit=null,l.inertialPanningX=0,l.inertialPanningY=0,l.pinchToPanMaxDistance=20,l.panningDistanceLimit=null,l.panningOriginTarget=a.e.Zero(),l.panningInertia=.9,l.zoomOnFactor=1,l.targetScreenOffset=a.d.Zero(),l.allowUpsideDown=!0,l.useInputToRestoreState=!0,l._viewMatrix=new a.a,l.panningAxis=new a.e(1,1,0),l._transformedDirection=new a.e,l.mapPanning=!1,l.onMeshTargetChangedObservable=new o.c,l.checkCollisions=!1,l.collisionRadius=new a.e(.5,.5,.5),l._previousPosition=a.e.Zero(),l._collisionVelocity=a.e.Zero(),l._newPosition=a.e.Zero(),l._computationVector=a.e.Zero(),l._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null),n?(l.setPosition(t),l.onCollide&&l.onCollide(n)):l._previousPosition.copyFrom(l._position);var i=Math.cos(l.alpha),r=Math.sin(l.alpha),o=Math.cos(l.beta),a=Math.sin(l.beta);0===a&&(a=1e-4);var s=l._getTargetPosition();l._computationVector.copyFromFloats(l.radius*i*a,l.radius*o,l.radius*r*a),s.addToRef(l._computationVector,l._newPosition),l._position.copyFrom(l._newPosition);var c=l.upVector;l.allowUpsideDown&&l.beta<0&&(c=(c=c.clone()).negate()),l._computeViewMatrix(l._position,s,c),l._viewMatrix.addAtIndex(12,l.targetScreenOffset.x),l._viewMatrix.addAtIndex(13,l.targetScreenOffset.y),l._collisionTriggered=!1},l._target=a.e.Zero(),s&&l.setTarget(s),l.alpha=n,l.beta=i,l.radius=r,l.getViewMatrix(),l.inputs=new wt(l),l.inputs.addKeyboard().addMouseWheel().addPointers(),l}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,"targetHost",{get:function(){return this._targetHost},set:function(e){e&&this.setTarget(e)},enumerable:!1,configurable:!0}),t.prototype.getTarget=function(){return this.target},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,"zoomToMouseLocation",{get:function(){var e=this.inputs.attached.mousewheel;return!!e&&e.zoomToMouseLocation},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.zoomToMouseLocation=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 Je,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 $e,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 Ze,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.getAbsolutePosition();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,n,i){var r=this;void 0===n&&(n=!0),void 0===i&&(i=2),t=Re.b.BackCompatCameraNoPreventDefault(arguments),this._useCtrlForPanning=n,this._panningMouseButton=i,"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)Math.PI&&(this.beta=this.beta-2*Math.PI):this.betathis.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alphathis.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radiusthis.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,n,i){if(void 0===t&&(t=!1),void 0===n&&(n=!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 r=e,o=this._getTargetPosition();if(o&&!n&&o.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}i||this.rebuildAnglesAndRadius()},t.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),n=Math.cos(this.beta),i=Math.sin(this.beta);0===i&&(i=1e-4),0===this.radius&&(this.radius=1e-4);var r=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*i,this.radius*n,this.radius*t*i),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&&i<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 n=Te.a.MinMax(e),i=a.e.Distance(n.min,n.max);this.radius=i*this.zoomOnFactor,this.focusOn({min:n.min,max:n.max,distance:i},t)},t.prototype.focusOn=function(e,t){var n,i;if(void 0===t&&(t=!1),void 0===e.min){var r=e||this.getScene().meshes;n=Te.a.MinMax(r),i=a.e.Distance(n.min,n.max)}else{n=e,i=e.distance}this._target=Te.a.Center(n),t||(this.maxZ=2*i)},t.prototype.createRigCamera=function(e,n){var i=0;switch(this.cameraRigMode){case at.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case at.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case at.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case at.a.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(0===n?1:-1);break;case at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(0===n?-1:1)}var r=new t(e,this.alpha+i,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],n=this._rigCameras[1];switch(t.beta=n.beta=this.beta,this.cameraRigMode){case at.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case at.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case at.a.RIG_MODE_STEREOSCOPIC_INTERLACED:case at.a.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,n.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(F.d)()],t.prototype,"alpha",void 0),Object(h.c)([Object(F.d)()],t.prototype,"beta",void 0),Object(h.c)([Object(F.d)()],t.prototype,"radius",void 0),Object(h.c)([Object(F.p)("target")],t.prototype,"_target",void 0),Object(h.c)([Object(F.l)("targetHost")],t.prototype,"_targetHost",void 0),Object(h.c)([Object(F.d)()],t.prototype,"inertialAlphaOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"inertialBetaOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"inertialRadiusOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"lowerAlphaLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"upperAlphaLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"lowerBetaLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"upperBetaLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"lowerRadiusLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"upperRadiusLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"inertialPanningX",void 0),Object(h.c)([Object(F.d)()],t.prototype,"inertialPanningY",void 0),Object(h.c)([Object(F.d)()],t.prototype,"pinchToPanMaxDistance",void 0),Object(h.c)([Object(F.d)()],t.prototype,"panningDistanceLimit",void 0),Object(h.c)([Object(F.p)()],t.prototype,"panningOriginTarget",void 0),Object(h.c)([Object(F.d)()],t.prototype,"panningInertia",void 0),Object(h.c)([Object(F.d)()],t.prototype,"zoomToMouseLocation",null),Object(h.c)([Object(F.d)()],t.prototype,"zoomOnFactor",void 0),Object(h.c)([Object(F.o)()],t.prototype,"targetScreenOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"allowUpsideDown",void 0),Object(h.c)([Object(F.d)()],t.prototype,"useInputToRestoreState",void 0),t}(tn);B.a.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new an(e,a.e.Zero(),t)}}));var an=function(e){function t(t,n,i){var r=e.call(this,t,n,i)||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(n){e[n]?t._initialQuaternion[n]*=-1:t._initialQuaternion[n]=0})),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},t}(nn),sn=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 Ut),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new Vt(e)),this},t}(Rt),cn=function(e){function t(t,n,i,r){void 0===r&&(r=!0);var o=e.call(this,t,n,i,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,n){void 0===n&&(n=null);var i;i=t,o._newPosition.copyFrom(i),o._newPosition.subtractToRef(o._oldPosition,o._diffPosition),o._diffPosition.length()>xe.a.CollisionsEpsilon&&(o.position.addInPlace(o._diffPosition),o.onCollide&&n&&o.onCollide(n))},o.inputs=new sn(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=Re.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 n=e;this.applyGravity&&(n=e.add(this.getScene().gravity)),t.getNewPosition(this._oldPosition,n,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,n=t-this.rotation.z;Math.abs(n)>=.001&&(this.rotation.z+=n/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(F.p)()],t.prototype,"ellipsoid",void 0),Object(h.c)([Object(F.p)()],t.prototype,"ellipsoidOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"checkCollisions",void 0),Object(h.c)([Object(F.d)()],t.prototype,"applyGravity",void 0),t}(tn),un=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 kt),this},t.prototype.addMouseWheel=function(){return this.add(new Gt),this},t.prototype.addPointers=function(){return this.add(new zt),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(Rt);B.a.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new hn(e,a.e.Zero(),t)}})),B.a.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new dn(e,0,0,1,null,t)}}));var ln,hn=function(e){function t(t,n,i,r){void 0===r&&(r=null);var o=e.call(this,t,n,i)||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 un(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return Object(h.d)(t,e),t.prototype._follow=function(e){if(e){var t=a.c.Matrix[0];e.absoluteRotationQuaternion.toRotationMatrix(t);var n=Math.atan2(t.m[8],t.m[10]),i=Re.b.ToRadians(this.rotationOffset)+n,r=e.getAbsolutePosition(),o=r.x+Math.sin(i)*this.radius,s=r.z+Math.cos(i)*this.radius,c=o-this.position.x,u=r.y+this.heightOffset-this.position.y,l=s-this.position.z,h=c*this.cameraAcceleration*2,d=u*this.cameraAcceleration,p=l*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),(p>this.maxCameraSpeed||p<-this.maxCameraSpeed)&&(p=p<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new a.e(this.position.x+h,this.position.y+d,this.position.z+p),this.setTarget(r)}},t.prototype.attachControl=function(e,t){t=Re.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.radiusthis.upperRadiusLimit&&(this.radius=this.upperRadiusLimit),null!==this.lowerHeightOffsetLimit&&this.heightOffsetthis.upperHeightOffsetLimit&&(this.heightOffset=this.upperHeightOffsetLimit),null!==this.lowerRotationOffsetLimit&&this.rotationOffsetthis.upperRotationOffsetLimit&&(this.rotationOffset=this.upperRotationOffsetLimit)},t.prototype.getClassName=function(){return"FollowCamera"},Object(h.c)([Object(F.d)()],t.prototype,"radius",void 0),Object(h.c)([Object(F.d)()],t.prototype,"lowerRadiusLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"upperRadiusLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"rotationOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"lowerRotationOffsetLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"upperRotationOffsetLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"heightOffset",void 0),Object(h.c)([Object(F.d)()],t.prototype,"lowerHeightOffsetLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"upperHeightOffsetLimit",void 0),Object(h.c)([Object(F.d)()],t.prototype,"cameraAcceleration",void 0),Object(h.c)([Object(F.d)()],t.prototype,"maxCameraSpeed",void 0),Object(h.c)([Object(F.l)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(tn),dn=function(e){function t(t,n,i,r,o,s){var c=e.call(this,t,a.e.Zero(),s)||this;return c.alpha=n,c.beta=i,c.radius=r,c._cartesianCoordinates=a.e.Zero(),c.setMeshTarget(o),c}return Object(h.d)(t,e),t.prototype.setMeshTarget=function(e){this._meshTarget=e,this._follow()},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}(tn),pn=n(45);!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"}(ln||(ln={}));var fn,_n,mn=function(){function e(){}return e.InitiateController=function(e){for(var t=0,n=this._ControllerFactories;tthis._maxRotationDistFromHeadset){var i=n-(n<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=i;var r=Math.sin(-i),o=Math.cos(-i);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=[],n=this._pointingPoseNode;n.parent;)t.push(n.parent),n=n.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 pn.a(a.e.Zero(),new a.e(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),n=t.getTranslation(),i=new a.e(0,0,-1),r=a.e.TransformNormal(i,t),o=a.e.Normalize(r);return new pn.a(n,o,e)},t.POINTING_POSE="POINTING_POSE",t}(Pt);!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"}(fn||(fn={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(_n||(_n={}));var vn,bn,yn=function(e){function t(t,n,i,r){void 0===r&&(r=!1);var a=e.call(this,t,n,i,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=Pt.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,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype._setDPadValue=function(e,t,n){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(n),this.onPadDownObservable.notifyObservers(n)),0===e&&(this._ondpadup&&this._ondpadup(n),this.onPadUpObservable.notifyObservers(n))),e},Object.defineProperty(t.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,fn.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,fn.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,fn.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,fn.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,fn.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,fn.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,fn.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,fn.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,fn.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,fn.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,_n.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,_n.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,_n.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,_n.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}(Pt);!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"}(vn||(vn={})),function(e){e[e.Up=12]="Up",e[e.Down=13]="Down",e[e.Left=14]="Left",e[e.Right=15]="Right"}(bn||(bn={}));var Tn=function(e){function t(t,n,i){var r=e.call(this,t.replace("STANDARD GAMEPAD","SONY PLAYSTATION DUALSHOCK"),n,i,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=Pt.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,n){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(n),this.onButtonDownObservable.notifyObservers(n)),0===e&&(this._onbuttonup&&this._onbuttonup(n),this.onButtonUpObservable.notifyObservers(n))),e},t.prototype._setDPadValue=function(e,t,n){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(n),this.onPadDownObservable.notifyObservers(n)),0===e&&(this._ondpadup&&this._ondpadup(n),this.onPadUpObservable.notifyObservers(n))),e},Object.defineProperty(t.prototype,"buttonCross",{get:function(){return this._buttonCross},set:function(e){this._buttonCross=this._setButtonValue(e,this._buttonCross,vn.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,vn.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,vn.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,vn.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,vn.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,vn.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,vn.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,vn.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,vn.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,vn.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,bn.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,bn.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,bn.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,bn.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}(Pt),En=function(){function e(e){var t=this;if(this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new o.c,Object(Pe.e)()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator&&(navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads)):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new o.c((function(e){for(var n in t._babylonGamepads){var i=t._babylonGamepads[n];i&&i._isConnected&&t.onGamepadConnectedObservable.notifyObserver(e,i)}})),this._onGamepadConnectedEvent=function(e){var n,i=e.gamepad;i.index in t._babylonGamepads&&t._babylonGamepads[i.index].isConnected||(t._babylonGamepads[i.index]?((n=t._babylonGamepads[i.index]).browserGamepad=i,n._isConnected=!0):n=t._addNewGamepad(i),t.onGamepadConnectedObservable.notifyObservers(n),t._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var n=e.gamepad;for(var i in t._babylonGamepads)if(t._babylonGamepads[i].index===n.index){var r=t._babylonGamepads[i];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 n=this._scene?this._scene.getEngine().getHostWindow():window;n&&(n.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),n.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=Pt.XBOX);for(var t=0,n=this._babylonGamepads;t1?"COLOR_ATTACHMENT"+t:"COLOR_ATTACHMENT"+t+"_WEBGL"],c=-1!==n?r.TEXTURE_CUBE_MAP_POSITIVE_X+n:r.TEXTURE_2D;r.framebufferTexture2D(r.FRAMEBUFFER,s,c,e._hardwareTexture.underlyingResource,i),this._engine._bindUnboundFramebuffer(a)}},t.prototype.setTexture=function(t,n,i){void 0===n&&(n=0),void 0===i&&(i=!0),e.prototype.setTexture.call(this,t,n,i),this._bindTextureRenderTarget(t,n)},t.prototype.dispose=function(t){void 0===t&&(t=!1);var n=this._context;t||(this._colorTextureArray&&(this._context.deleteTexture(this._colorTextureArray),this._colorTextureArray=null),this._depthStencilTextureArray&&(this._context.deleteTexture(this._depthStencilTextureArray),this._depthStencilTextureArray=null)),this._framebuffer&&(n.deleteFramebuffer(this._framebuffer),this._framebuffer=null),this._depthStencilBuffer&&(n.deleteRenderbuffer(this._depthStencilBuffer),this._depthStencilBuffer=null),this._MSAAFramebuffer&&(n.deleteFramebuffer(this._MSAAFramebuffer),this._MSAAFramebuffer=null),e.prototype.dispose.call(this,t)},t}(On.a);Ve.a.prototype._createHardwareRenderTargetWrapper=function(e,t,n){var i=new Mn(e,t,n,this,this._gl);return this._renderTargetWrapperCache.push(i),i},Ve.a.prototype.createRenderTargetTexture=function(e,t){var n=this._createHardwareRenderTargetWrapper(!1,!1,e),i={};void 0!==t&&"object"==typeof t?(i.generateDepthBuffer=!!t.generateDepthBuffer,i.generateStencilBuffer=!!t.generateStencilBuffer):(i.generateDepthBuffer=!0,i.generateStencilBuffer=!1);var r=this._createInternalTexture(e,t,!0,Ue.b.RenderTarget),o=e.width||e,a=e.height||e,s=this._currentFramebuffer,c=this._gl,u=c.createFramebuffer();return this._bindUnboundFramebuffer(u),n._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!i.generateStencilBuffer,i.generateDepthBuffer,o,a),r.is2DArray||c.framebufferTexture2D(c.FRAMEBUFFER,c.COLOR_ATTACHMENT0,c.TEXTURE_2D,r._hardwareTexture.underlyingResource,0),this._bindUnboundFramebuffer(s),n._framebuffer=u,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,n.setTextures(r),n},Ve.a.prototype.createDepthStencilTexture=function(e,t,n){if(t.isCube){var i=e.width||e;return this._createDepthStencilCubeTexture(i,t,n)}return this._createDepthStencilTexture(e,t,n)},Ve.a.prototype._createDepthStencilTexture=function(e,t,n){var i=this._gl,r=e.layers||0,o=0!==r?i.TEXTURE_2D_ARRAY:i.TEXTURE_2D,a=new Ue.a(this,Ue.b.DepthStencil);if(!this._caps.depthTextureExtension)return m.a.Error("Depth texture is not supported by your browser or hardware."),a;var s=Object(h.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t);this._bindTextureDirectly(o,a,!0),this._setupDepthStencilTexture(a,e,s.generateStencil,0!==s.comparisonFunction&&s.bilinearFiltering,s.comparisonFunction),a.format=s.generateStencil?g.a.TEXTUREFORMAT_DEPTH24_STENCIL8:g.a.TEXTUREFORMAT_DEPTH24,n._depthStencilTexture=a,n._depthStencilTextureWithStencil=s.generateStencil;var c=s.generateStencil?i.UNSIGNED_INT_24_8:i.UNSIGNED_INT,u=s.generateStencil?i.DEPTH_STENCIL:i.DEPTH_COMPONENT,l=u;return this.webGLVersion>1&&(l=s.generateStencil?i.DEPTH24_STENCIL8:i.DEPTH_COMPONENT24),a.is2DArray?i.texImage3D(o,0,l,a.width,a.height,r,0,u,c,null):i.texImage2D(o,0,l,a.width,a.height,0,u,c,null),this._bindTextureDirectly(o,null),this._internalTexturesCache.push(a),a},Ve.a.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||!e.texture)return 1;if(e.samples===t)return t;var n=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(n.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(n.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null);var i=e.texture._hardwareTexture;if(i._MSAARenderBuffer&&(n.deleteRenderbuffer(i._MSAARenderBuffer),i._MSAARenderBuffer=null),t>1&&n.renderbufferStorageMultisample){var r=n.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var o=this._createRenderBuffer(e.texture.width,e.texture.height,t,-1,this._getRGBAMultiSampleBufferFormat(e.texture.type),n.COLOR_ATTACHMENT0,!1);if(!o)throw new Error("Unable to create multi sampled framebuffer");i._MSAARenderBuffer=o}else this._bindUnboundFramebuffer(e._framebuffer);return e.texture.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.texture.width,e.texture.height,t),this._bindUnboundFramebuffer(null),t};var In=n(37),Dn=function(){function e(e,t,n,i,r,s,c,u,l,h,d,p,f,_,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===p&&(p="postprocess"),void 0===_&&(_=!1),void 0===m&&(m=g.a.TEXTUREFORMAT_RGBA),this._parentContainer=null,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._renderId=0,this.externalTextureSamplerBinding=!1,this._textures=new Rn.a(2),this._textureCache=[],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()):u&&(this._engine=u,this._engine.postProcesses.push(this)),this._options=r,this.renderTargetSamplingMode=c||g.a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=l||!1,this._textureType=d,this._textureFormat=m,this._samplers=i||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=p,this._parameters=n||[],this._parameters.push("scale"),this._indexParameters=f,this._drawWrapper=new In.a(this._engine),_||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&&(this._forcedOutputTexture=null,this.markTextureDirty())},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._drawWrapper.effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new Rn.a(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,n,i,r,o,a,s){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),this._postProcessDefines=e,this._drawWrapper.effect=this._engine.createEffect({vertex:null!=a?a:this._vertexUrl,fragment:null!=s?s:this._fragmentUrl},["position"],t||this._parameters,n||this._samplers,null!==e?e:"",void 0,r,o,i||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype._createRenderTargetTexture=function(e,t,n){void 0===n&&(n=0);for(var i=0;i=0;t--)if(e-this._textureCache[t].lastUsedRenderId>100){for(var n=!1,i=0;i0&&this._textures.reset(),this.width=e,this.height=t;for(var o=null,a=0;a=0;e--)this._textureCache[e].texture.dispose();this._textureCache.length=0},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),this._parentContainer){var n=this._parentContainer.postProcesses.indexOf(this);n>-1&&this._parentContainer.postProcesses.splice(n,1),this._parentContainer=null}if(-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=F.a.Serialize(this),t=this.getCamera()||this._scene&&this._scene.activeCamera;return e.customType="BABYLON."+this.getClassName(),e.cameraId=t?t.id:null,e.reusable=this._reusable,e.textureType=this._textureType,e.fragmentUrl=this._fragmentUrl,e.parameters=this._parameters,e.samplers=this._samplers,e.options=this._options,e.defines=this._postProcessDefines,e.textureFormat=this._textureFormat,e.vertexUrl=this._vertexUrl,e.indexParameters=this._indexParameters,e},e.prototype.clone=function(){var t=this.serialize();t._engine=this._engine,t.cameraId=null;var n=e.Parse(t,this._scene,"");return n?(n.onActivateObservable=this.onActivateObservable.clone(),n.onSizeChangedObservable=this.onSizeChangedObservable.clone(),n.onApplyObservable=this.onApplyObservable.clone(),n.onBeforeRenderObservable=this.onBeforeRenderObservable.clone(),n.onAfterRenderObservable=this.onAfterRenderObservable.clone(),n._prePassEffectConfiguration=this._prePassEffectConfiguration,n):null},e.Parse=function(e,t,n){var i=Object(c.a)(e.customType);if(!i||!i._Parse)return null;var r=t?t.getCameraById(e.cameraId):null;return i._Parse(e,r,t,n)},e._Parse=function(t,n,i,r){return F.a.Parse((function(){return new e(t.name,t.fragmentUrl,t.parameters,t.samplers,t.options,n,t.renderTargetSamplingMode,t._engine,t.reusable,t.defines,t.textureType,t.vertexUrl,t.indexParameters,!1,t.textureFormat)}),t,i,r)},Object(h.c)([Object(F.d)()],e.prototype,"uniqueId",void 0),Object(h.c)([Object(F.d)()],e.prototype,"name",void 0),Object(h.c)([Object(F.d)()],e.prototype,"width",void 0),Object(h.c)([Object(F.d)()],e.prototype,"height",void 0),Object(h.c)([Object(F.d)()],e.prototype,"renderTargetSamplingMode",void 0),Object(h.c)([Object(F.g)()],e.prototype,"clearColor",void 0),Object(h.c)([Object(F.d)()],e.prototype,"autoClear",void 0),Object(h.c)([Object(F.d)()],e.prototype,"alphaMode",void 0),Object(h.c)([Object(F.d)()],e.prototype,"alphaConstants",void 0),Object(h.c)([Object(F.d)()],e.prototype,"enablePixelPerfectMode",void 0),Object(h.c)([Object(F.d)()],e.prototype,"forceFullscreenViewport",void 0),Object(h.c)([Object(F.d)()],e.prototype,"scaleMode",void 0),Object(h.c)([Object(F.d)()],e.prototype,"alwaysForcePOT",void 0),Object(h.c)([Object(F.d)("samples")],e.prototype,"_samples",void 0),Object(h.c)([Object(F.d)()],e.prototype,"adaptScaleToCurrentViewport",void 0),e}();Object(c.b)("BABYLON.PostProcess",Dn);var Nn="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";Cn.a.ShadersStore.passPixelShader=Nn;var Ln="\nvarying vec2 vUV;\nuniform samplerCube textureSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\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}";Cn.a.ShadersStore.passCubePixelShader=Ln;var Fn=function(e){function t(t,n,i,r,o,a,s,c){return void 0===i&&(i=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1),e.call(this,t,"pass",null,null,n,i,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,n,i,r){return F.a.Parse((function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,e._engine,e.reusable)}),e,i,r)},t}(Dn);Object(c.b)("BABYLON.PassPostProcess",Fn);var wn=function(e){function t(t,n,i,r,o,a,s,c){void 0===i&&(i=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var u=e.call(this,t,"passCube",null,null,n,i,r,o,a,"#define POSITIVEX",s,void 0,null,c)||this;return u._face=0,u}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,n,i,r){return F.a.Parse((function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,e._engine,e.reusable)}),e,i,r)},t}(Dn);xe.a._RescalePostProcessFactory=function(e){return new Fn("rescale",1,null,g.a.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,g.a.TEXTURETYPE_UNSIGNED_INT)};var Bn="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\n#define CUSTOM_FRAGMENT_DEFINITIONS\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}";Cn.a.ShadersStore.anaglyphPixelShader=Bn;var Un=function(e){function t(t,n,i,r,o,a){var s=e.call(this,t,"anaglyph",null,["leftSampler"],n,i[1],r,o,a)||this;return s._passedProcess=i[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}(Dn);function Vn(e){e._rigCameras[0]._rigPostProcess=new Fn(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new Un(e.name+"_anaglyph",1,e._rigCameras)}Object(c.b)("BABYLON.AnaglyphPostProcess",Un),B.a.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,n){return function(){return new kn(e,0,0,1,a.e.Zero(),n.interaxial_distance,t)}}));var kn=function(e){function t(t,n,i,r,o,a,s){var c=e.call(this,t,n,i,r,o,s)||this;return c._setRigMode=Vn.bind(null,c),c.interaxialDistance=a,c.setCameraRigMode(at.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:a}),c}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},t}(on);B.a.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,n){return function(){return new Gn(e,a.e.Zero(),n.interaxial_distance,t)}}));var Gn=function(e){function t(t,n,i,r){var o=e.call(this,t,n,r)||this;return o._setRigMode=Vn.bind(null,o),o.interaxialDistance=i,o.setCameraRigMode(at.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphFreeCamera"},t}(nn);B.a.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,n){return function(){return new zn(e,a.e.Zero(),n.interaxial_distance,t)}}));var zn=function(e){function t(t,n,i,r){var o=e.call(this,t,n,r)||this;return o._setRigMode=Vn.bind(null,o),o.interaxialDistance=i,o.setCameraRigMode(at.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},t}(xn);B.a.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,n){return function(){return new jn(e,a.e.Zero(),n.interaxial_distance,t)}}));var jn=function(e){function t(t,n,i,r){var o=e.call(this,t,n,r)||this;return o._setRigMode=Vn.bind(null,o),o.interaxialDistance=i,o.setCameraRigMode(at.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),o}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},t}(An),Wn=n(62),Hn="const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\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";Cn.a.ShadersStore.stereoscopicInterlacePixelShader=Hn;var Xn=function(e){function t(t,n,i,r,o,s,c){var u=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],o,s,c,r?"#define IS_STEREOSCOPIC_INTERLACED 1":i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return u._passedProcess=n[0]._rigPostProcess,u._stepSize=new a.d(1/u.width,1/u.height),u.onSizeChangedObservable.add((function(){u._stepSize=new a.d(1/u.width,1/u.height)})),u.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",u._passedProcess),e.setFloat2("stepSize",u._stepSize.x,u._stepSize.y)})),u}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicInterlacePostProcessI"},t}(Dn),Yn=function(e){function t(t,n,i,r,o,s){var c=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],r,o,s,i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return c._passedProcess=n[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}(Dn);function Kn(e){var t=e.cameraRigMode===at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED,n=e.cameraRigMode===at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e.cameraRigMode===at.a.RIG_MODE_STEREOSCOPIC_INTERLACED?(e._rigCameras[0]._rigPostProcess=new Fn(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new Xn(e.name+"_stereoInterlace",e._rigCameras,!1,!0)):(e._rigCameras[n?1:0].viewport=new Wn.a(0,0,t?.5:1,t?1:.5),e._rigCameras[n?0:1].viewport=new Wn.a(t?.5:0,t?0:.5,t?.5:1,t?1:.5))}B.a.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,n){return function(){return new Qn(e,0,0,1,a.e.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var Qn=function(e){function t(t,n,i,r,o,a,s,c){var u=e.call(this,t,n,i,r,o,c)||this;return u._setRigMode=Kn.bind(null,u),u.interaxialDistance=a,u.isStereoscopicSideBySide=s,u.setCameraRigMode(s?at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:at.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),u}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(on);B.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new qn(e,a.e.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var qn=function(e){function t(t,n,i,r,o){var a=e.call(this,t,n,o)||this;return a._setRigMode=Kn.bind(null,a),a.interaxialDistance=i,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:at.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(nn);B.a.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,n){return function(){return new Zn(e,a.e.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var Zn=function(e){function t(t,n,i,r,o){var a=e.call(this,t,n,o)||this;return a._setRigMode=Kn.bind(null,a),a.interaxialDistance=i,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:at.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(xn);B.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new Jn(e,a.e.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var Jn=function(e){function t(t,n,i,r,o){var a=e.call(this,t,n,o)||this;return a._setRigMode=Kn.bind(null,a),a.interaxialDistance=i,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:at.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),a}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(An),$n=function(e){function t(t,n,i,r,o){void 0===r&&(r=1),void 0===o&&(o=.065);var a=e.call(this,t,n,i)||this;return a._distanceBetweenEyes=o,a._distanceToProjectionPlane=r,a.setCameraRigMode(at.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL,{stereoHalfAngle:0}),a._cameraRigParams.stereoHalfAngle=0,a._cameraRigParams.interaxialDistance=o,a}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"distanceBetweenEyes",{get:function(){return this._distanceBetweenEyes},set:function(e){this._distanceBetweenEyes=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"distanceToProjectionPlane",{get:function(){return this._distanceToProjectionPlane},set:function(e){this._distanceToProjectionPlane=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t.prototype.createRigCamera=function(e,t){var n=new tn(e,a.e.Zero(),this.getScene()),i=new ct.a("tm_"+e,this.getScene());return n.parent=i,i.setPivotMatrix(a.a.Identity(),!1),n.isRigCamera=!0,n.rigParent=this,n},t.prototype._updateRigCameras=function(){for(var e=0;e1.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}";Cn.a.ShadersStore.vrDistortionCorrectionPixelShader=ni;var ii=function(e){function t(t,n,i,r){var o=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,r.postProcessScaleFactor,n,Be.a.BILINEAR_SAMPLINGMODE)||this;return o._isRightEye=i,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}(Dn),ri="precision mediump sampler2DArray;\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=texture2D(multiviewSampler,vec3(vUV,imageIndex));\n}";Cn.a.ShadersStore.vrMultiviewToSingleviewPixelShader=ri;var oi=n(67),ai=n(112),si=n(113);Ve.a.prototype.createRenderTargetCubeTexture=function(e,t){var n=this._createHardwareRenderTargetWrapper(!1,!0,e),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 r=this._gl,o=new Ue.a(this,Ue.b.RenderTarget);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,o,!0);var a=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")),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,a.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,a.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var s=0;s<6;s++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),e,e,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);var c=r.createFramebuffer();return this._bindUnboundFramebuffer(c),n._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,e,e),i.generateMipMaps&&r.generateMipmap(r.TEXTURE_CUBE_MAP),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),this._bindUnboundFramebuffer(null),n._framebuffer=c,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=i.generateStencilBuffer,o.width=e,o.height=e,o.isReady=!0,o.isCube=!0,o.samples=1,o.generateMipMaps=i.generateMipMaps,o.samplingMode=i.samplingMode,o.type=i.type,o.format=i.format,this._internalTexturesCache.push(o),n.setTextures(o),n};var ci=function(e){function t(t,n,i,r,s,c,u,l,h,d,p,f,_,m,v){var b;void 0===s&&(s=!0),void 0===c&&(c=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=!1),void 0===l&&(l=Be.a.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=!0),void 0===d&&(d=!1),void 0===p&&(p=!1),void 0===f&&(f=g.a.TEXTUREFORMAT_RGBA),void 0===_&&(_=!1);var y=e.call(this,null,i,!r,void 0,l,void 0,void 0,void 0,void 0,f)||this;if(y.renderParticles=!0,y.renderSprites=!1,y.ignoreCameraViewport=!1,y.onBeforeBindObservable=new o.c,y.onAfterUnbindObservable=new o.c,y.onBeforeRenderObservable=new o.c,y.onAfterRenderObservable=new o.c,y.onClearObservable=new o.c,y.onResizeObservable=new o.c,y._cleared=!1,y.skipInitialClear=!1,y._currentRefreshId=-1,y._refreshRate=1,y._samples=1,y._canRescale=!0,y._renderTarget=null,y.boundingBoxPosition=a.e.Zero(),!(i=y.getScene()))return y;var T=y.getScene().getEngine();return y._coordinatesMode=Be.a.PROJECTION_MODE,y.renderList=new Array,y.name=t,y.isRenderTarget=!0,y._initialSizeParameter=n,y._renderPassIds=[],y.__isCube=u,y._processSizeParameter(n),y.renderPassId=y._renderPassIds[0],y._resizeObserver=T.onResizeObservable.add((function(){})),y._generateMipMaps=!!r,y._doNotChangeAspectRatio=s,y._renderingManager=new si.b(i),y._renderingManager._useSceneAutoClearSetup=!0,p||(y._renderTargetOptions={generateMipMaps:r,type:c,format:null!==(b=y._format)&&void 0!==b?b:void 0,samplingMode:y.samplingMode,generateDepthBuffer:h,generateStencilBuffer:d,samples:m,creationFlags:v},y.samplingMode===Be.a.NEAREST_SAMPLINGMODE&&(y.wrapU=Be.a.CLAMP_ADDRESSMODE,y.wrapV=Be.a.CLAMP_ADDRESSMODE),_||(u?(y._renderTarget=i.getEngine().createRenderTargetCubeTexture(y.getRenderSize(),y._renderTargetOptions),y.coordinatesMode=Be.a.INVCUBIC_MODE,y._textureMatrix=a.a.Identity()):y._renderTarget=i.getEngine().createRenderTargetTexture(y._size,y._renderTargetOptions),y._texture=y._renderTarget.texture,void 0!==m&&(y.samples=m))),y}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,n=e.push;e.push=function(){for(var i,r=[],o=0;o0&&(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},t.prototype.disableRescaling=function(){this._canRescale=!1},Object.defineProperty(t.prototype,"canRescale",{get:function(){return this._canRescale},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,n=this.isCube;null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null;var i=this.getScene();i&&(this._processSizeParameter(e),this._renderTarget=n?i.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):i.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions),this._texture=this._renderTarget.texture,void 0!==this._renderTargetOptions.samples&&(this.samples=this._renderTargetOptions.samples),this.onResizeObservable.hasObservers()&&this.onResizeObservable.notifyObservers(this))},t.prototype.render=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1),this._render(e,t)},t.prototype.isReadyForRendering=function(){return this._render(!1,!1,!0)},t.prototype._render=function(e,t,n){var i;if(void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===n&&(n=!1),!(c=this.getScene()))return n;var r=c.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var o=0;o1||this.activeCamera&&this.activeCamera!==c.activeCamera)&&c.setTransformMatrix(c.activeCamera.getViewMatrix(),c.activeCamera.getProjectionMatrix(!0)),r.setViewport(c.activeCamera.viewport)),c.resetCachedMaterial(),p},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var n=e*t,i=xe.a.NearestPOT(n+16384/(128+n));return Math.min(xe.a.FloorPOT(e),i)},t.prototype._prepareRenderingManager=function(e,t,n,i){var r=this.getScene();if(r){this._renderingManager.reset();for(var o=r.getRenderId(),a=0;a=0&&this._renderingManager.dispatchParticles(p))}}},t.prototype._bindFrameBuffer=function(e,t){void 0===e&&(e=0),void 0===t&&(t=0);var n=this.getScene();if(n){var i=n.getEngine();this._renderTarget&&i.bindFramebuffer(this._renderTarget,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,0,t)}},t.prototype.unbindFrameBuffer=function(e,t){var n=this;this._renderTarget&&e.unBindFramebuffer(this._renderTarget,this.isCube,(function(){n.onAfterRenderObservable.notifyObservers(t)}))},t.prototype._prepareFrame=function(e,t,n,i){this._postProcessManager?this._prePassEnabled||this._postProcessManager._prepareFrame(this._texture,this._postProcesses):i&&e.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(t,n)},t.prototype.renderToTarget=function(e,t,n,i,r){var o,a,s,c;void 0===i&&(i=0),void 0===r&&(r=null);var u=this.getScene();if(u){var l=u.getEngine();if(this._texture){if(null===(o=l._debugPushGroup)||void 0===o||o.call(l,"render to face #".concat(e," layer #").concat(i),1),this._prepareFrame(u,e,i,t),this.is2DArray?(l.currentRenderPassId=this._renderPassIds[i],this.onBeforeRenderObservable.notifyObservers(i)):(l.currentRenderPassId=this._renderPassIds[e],this.onBeforeRenderObservable.notifyObservers(e)),l.snapshotRendering&&l.snapshotRenderingMode===g.a.SNAPSHOTRENDERING_FAST)this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(l):this.skipInitialClear||l.clear(this.clearColor||u.clearColor,!0,!0,!0);else{var h=null,d=this.renderList?this.renderList:u.getActiveMeshes().data,p=this.renderList?this.renderList.length:u.getActiveMeshes().length;this.getCustomRenderList&&(h=this.getCustomRenderList(this.is2DArray?i:e,d,p)),h?this._prepareRenderingManager(h,h.length,r,!1):(this._defaultRenderListPrepared||(this._prepareRenderingManager(d,p,r,!this.renderList),this._defaultRenderListPrepared=!0),h=d);for(var f=0,_=u._beforeRenderTargetClearStage;f<_.length;f++){_[f].action(this,e,i)}this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(l):this.skipInitialClear||l.clear(this.clearColor||u.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||u.updateTransformMatrix(!0);for(var m=0,v=u._beforeRenderTargetDrawStage;m=0&&n.customRenderTargets.splice(i,1);for(var r=0,o=n.cameras;r=0&&a.customRenderTargets.splice(i,1)}null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null,this._texture=null,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}(Be.a);Be.a._CreateRenderTargetTexture=function(e,t,n,i,r){return new ci(e,t,n,i)};var ui=function(e){function t(t,n){void 0===n&&(n=512);var i=e.call(this,"multiview rtt",n,t,!1,!0,g.a.TEXTURETYPE_UNSIGNED_INT,!1,void 0,!1,!1,!0,void 0,!0)||this;return i._renderTarget=i.getScene().getEngine().createMultiviewRenderTargetTexture(i.getRenderWidth(),i.getRenderHeight()),i._texture=i._renderTarget.texture,i._texture.isMultiview=!0,i._texture.format=g.a.TEXTUREFORMAT_RGBA,i.samples=i._getEngine().getCaps().maxSamples||i.samples,i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"samples",{set:function(e){this._samples=e},enumerable:!1,configurable:!0}),t.prototype._bindFrameBuffer=function(e){void 0===e&&(e=0),this._renderTarget&&this.getScene().getEngine().bindMultiviewFramebuffer(this._renderTarget)},t.prototype.getViewCount=function(){return 2},t}(ci),li=n(104);function hi(e,t){var n=new oi.a(e,void 0,!0,t);return n.addUniform("viewProjection",16),n.addUniform("viewProjectionR",16),n.addUniform("view",16),n.addUniform("projection",16),n.addUniform("vEyePosition",4),n}xe.a.prototype.createMultiviewRenderTargetTexture=function(e,t){var n=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var i=this._createHardwareRenderTargetWrapper(!1,!1,{width:e,height:t});i._framebuffer=n.createFramebuffer();var r=new Ue.a(this,Ue.b.Unknown,!0);return r.width=e,r.height=t,r.isMultiview=!0,i._colorTextureArray=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,i._colorTextureArray),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.RGBA8,e,t,2),i._depthStencilTextureArray=n.createTexture(),n.bindTexture(n.TEXTURE_2D_ARRAY,i._depthStencilTextureArray),n.texStorage3D(n.TEXTURE_2D_ARRAY,1,n.DEPTH24_STENCIL8,e,t,2),r.isReady=!0,i.setTextures(r),i._depthStencilTexture=r,i},xe.a.prototype.bindMultiviewFramebuffer=function(e){var t=e,n=this._gl,i=this.getCaps().oculusMultiview||this.getCaps().multiview;if(this.bindFramebuffer(t,void 0,void 0,void 0,!0),n.bindFramebuffer(n.DRAW_FRAMEBUFFER,t._framebuffer),!t._colorTextureArray||!t._depthStencilTextureArray)throw"Invalid multiview frame buffer";this.getCaps().oculusMultiview?(i.framebufferTextureMultisampleMultiviewOVR(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,t._colorTextureArray,0,t.samples,0,2),i.framebufferTextureMultisampleMultiviewOVR(n.DRAW_FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,t._depthStencilTextureArray,0,t.samples,0,2)):(i.framebufferTextureMultiviewOVR(n.DRAW_FRAMEBUFFER,n.COLOR_ATTACHMENT0,t._colorTextureArray,0,0,2),i.framebufferTextureMultiviewOVR(n.DRAW_FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,t._depthStencilTextureArray,0,0,2))},at.a.prototype._useMultiviewToSingleView=!1,at.a.prototype._multiviewTexture=null,at.a.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new ui(this.getScene(),{width:e,height:t})):this._multiviewTexture=new ui(this.getScene(),{width:e,height:t})};var di=Q.a.prototype.createSceneUniformBuffer;Q.a.prototype._transformMatrixR=a.a.Zero(),Q.a.prototype._multiviewSceneUbo=null,Q.a.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=hi(this.getEngine(),"scene_multiview")},Q.a.prototype.createSceneUniformBuffer=function(e){return this._multiviewSceneUbo?hi(this.getEngine(),e):di.bind(this)(e)},Q.a.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,a.c.Matrix[0]),li.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.updateMatrix("projection",this._projectionMatrix))},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=2&&e.onControllersAttachedObservable.notifyObservers(e.controllers)}}}))},t}(nn),Ti=function(e){function t(t){var n=e.call(this,t)||this;return n.onTriggerStateChangedObservable=new o.c,n.onMainButtonStateChangedObservable=new o.c,n.onSecondaryButtonStateChangedObservable=new o.c,n.onPadStateChangedObservable=new o.c,n.onPadValuesChangedObservable=new o.c,n.pad={x:0,y:0},n._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},n._buttons=new Array(t.buttons.length),n.hand=t.hand,n}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\n#include\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\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}");Cn.a.ShadersStore.imageProcessingPixelShader=xi;var Ri,Ci,Pi=function(e){function t(t,n,i,r,o,a,s,c){void 0===i&&(i=null),void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT);var u=e.call(this,t,"imageProcessing",[],[],n,i,r,o,a,null,s,"postprocess",null,!0)||this;return u._fromLinearSpace=!0,u._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,SKIPFINALCOLORCLAMP:!1},c?(c.applyByPostProcess=!0,u._attachImageProcessingConfiguration(c,!0),u.fromLinearSpace=!1):(u._attachImageProcessingConfiguration(null,!0),u.imageProcessingConfiguration.applyByPostProcess=!0),u.onApply=function(e){u.imageProcessingConfiguration.bind(e,u.aspectRatio)},u}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 n=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 i=null,r=this.getEngine(),o=this.getCamera();if(o)i=o.getScene();else if(r&&r.scenes){var a=r.scenes;i=a[a.length-1]}else i=P.a.LastCreatedScene;this._imageProcessingConfiguration=i?i.imageProcessingConfiguration:new Ei.a}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){n._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 ".concat(t,";\r\n"));var n=["textureSampler"],i=["scale"];Ei.a&&(Ei.a.PrepareSamplers(n,this._defines),Ei.a.PrepareUniforms(i,this._defines)),this.updateEffect(e,i,n)},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(F.d)()],t.prototype,"_fromLinearSpace",void 0),t}(Dn),Oi=function(){function e(e,t,n,i,r){this.getWidth=e,this.getHeight=t,this.layer=n,this.layerType=i,this.createRenderTargetTextureProvider=r}return Object.defineProperty(e.prototype,"isFixedFoveationSupported",{get:function(){return"XRWebGLLayer"==this.layerType&&"number"==typeof this.layer.fixedFoveation},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fixedFoveation",{get:function(){return this.isFixedFoveationSupported?this.layer.fixedFoveation:null},set:function(e){if(this.isFixedFoveationSupported){var t=Math.max(0,Math.min(1,e||0));this.layer.fixedFoveation=t}},enumerable:!1,configurable:!0}),e}(),Mi=n(122),Ii=function(){function e(e,t){this._scene=e,this.layerWrapper=t,this._renderTargetTextures=new Array,this._engine=e.getEngine()}return e.prototype._createInternalTexture=function(e,t){var n=new Ue.a(this._engine,Ue.b.Unknown,!0);return n.width=e.width,n.height=e.height,n._hardwareTexture=new Mi.a(t,this._engine._gl),n.isReady=!0,n},e.prototype._createRenderTargetTexture=function(e,t,n,i,r,o){if(!this._engine)throw new Error("Engine is disposed");var a={width:e,height:t},s=o?new ui(this._scene,a):new ci("XR renderTargetTexture",a,this._scene),c=s.renderTarget;if(!n&&i||(c._framebuffer=n),i)if(o)c._colorTextureArray=i;else{var u=this._createInternalTexture(a,i);c.setTexture(u,0),s._texture=u}return r&&(o?c._depthStencilTextureArray=r:c._depthStencilTexture=this._createInternalTexture(a,r)),s.disableRescaling(),"undefined"!=typeof XRWebGLBinding&&(s.skipInitialClear=!0),this._renderTargetTextures.push(s),s},e.prototype._destroyRenderTargetTexture=function(e){this._renderTargetTextures.splice(this._renderTargetTextures.indexOf(e),1),e.dispose()},e.prototype.getFramebufferDimensions=function(){return this._framebufferDimensions},e.prototype.dispose=function(){this._renderTargetTextures.forEach((function(e){return e.dispose()})),this._renderTargetTextures.length=0},e}(),Di=function(e){function t(t){var n=e.call(this,(function(){return t.framebufferWidth}),(function(){return t.framebufferHeight}),t,"XRWebGLLayer",(function(e){return new Ni(e.scene,n)}))||this;return n.layer=t,n}return Object(h.d)(t,e),t}(Oi),Ni=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.layerWrapper=n,i._layer=n.layer,i._framebufferDimensions={framebufferWidth:i._layer.framebufferWidth,framebufferHeight:i._layer.framebufferHeight},i}return Object(h.d)(t,e),t.prototype.trySetViewportForView=function(e,t){var n=this._layer.getViewport(t),i=this._framebufferDimensions.framebufferWidth,r=this._framebufferDimensions.framebufferHeight;return e.x=n.x/i,e.y=n.y/r,e.width=n.width/i,e.height=n.height/r,!0},t.prototype.getRenderTargetTextureForEye=function(e){var t=this._layer.framebufferWidth,n=this._layer.framebufferHeight,i=this._layer.framebuffer;return this._rtt&&t===this._framebufferDimensions.framebufferWidth&&n===this._framebufferDimensions.framebufferHeight&&i===this._framebuffer||(this._rtt=this._createRenderTargetTexture(t,n,i),this._framebufferDimensions.framebufferWidth=t,this._framebufferDimensions.framebufferHeight=n,this._framebuffer=i),this._rtt},t.prototype.getRenderTargetTextureForView=function(e){return this.getRenderTargetTextureForEye(e.eye)},t}(Ii),Li=function(){function e(){}return e.GetDefaults=function(t){var n=new e;return n.canvasOptions={antialias:!0,depth:!0,stencil:!t||t.isStencilEnable,alpha:!0,multiview:!1,framebufferScaleFactor:1},n.newCanvasCssStyle="position:absolute; bottom:0px;right:0px;z-index:10;width:90%;height:100%;background-color: #000000;",n},e}(),Fi=function(){function e(e,t){var n=this;if(void 0===t&&(t=Li.GetDefaults()),this._options=t,this._canvas=null,this._engine=null,this.xrLayer=null,this._xrLayerWrapper=null,this.onXRLayerInitObservable=new o.c,this._engine=e.scene.getEngine(),this._engine.onDisposeObservable.addOnce((function(){n._engine=null})),t.canvasElement)this._setManagedOutputCanvas(t.canvasElement);else{var i=document.createElement("canvas");i.style.cssText=this._options.newCanvasCssStyle||"position:absolute; bottom:0px;right:0px;",this._setManagedOutputCanvas(i)}e.onXRSessionInit.add((function(){n._addCanvas()})),e.onXRSessionEnded.add((function(){n._removeCanvas()}))}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype.initializeXRLayerAsync=function(e){return Object(h.b)(this,void 0,void 0,(function(){var t,n=this;return Object(h.e)(this,(function(i){return t=function(){return n.xrLayer=new XRWebGLLayer(e,n.canvasContext,n._options.canvasOptions),n._xrLayerWrapper=new Di(n.xrLayer),n.onXRLayerInitObservable.notifyObservers(n.xrLayer),n.xrLayer},this.canvasContext.makeXRCompatible?[2,this.canvasContext.makeXRCompatible().then((function(){}),(function(){Re.b.Warn("Error executing makeXRCompatible. This does not mean that the session will work incorrectly.")})).then((function(){return t()}))]:[2,Promise.resolve(t())]}))}))},e.prototype._addCanvas=function(){var e=this;this._canvas&&this._engine&&this._canvas!==this._engine.getRenderingCanvas()&&document.body.appendChild(this._canvas),this.xrLayer?this._setCanvasSize(!0):this.onXRLayerInitObservable.addOnce((function(){e._setCanvasSize(!0)}))},e.prototype._removeCanvas=function(){this._canvas&&this._engine&&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._xrLayerWrapper),this._canvas&&this._engine&&(e?t&&(this._canvas!==this._engine.getRenderingCanvas()?(this._canvas.style.width=t.getWidth()+"px",this._canvas.style.height=t.getHeight()+"px"):this._engine.setSize(t.getWidth(),t.getHeight())):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}(),wi=function(e){function t(t){var n=e.call(this,(function(){return t.framebufferWidth}),(function(){return t.framebufferHeight}),t,"XRWebGLLayer",(function(e){return new Bi(e,n)}))||this;return n.layer=t,n}return Object(h.d)(t,e),t}(Oi),Bi=function(e){function t(t,n){var i=e.call(this,t.scene,n)||this;return i.layerWrapper=n,i._nativeRTTProvider=navigator.xr.getNativeRenderTargetProvider(t.session,i._createRenderTargetTexture.bind(i),i._destroyRenderTargetTexture.bind(i)),i._nativeLayer=n.layer,i}return Object(h.d)(t,e),t.prototype.trySetViewportForView=function(e){return e.x=0,e.y=0,e.width=1,e.height=1,!0},t.prototype.getRenderTargetTextureForEye=function(e){return this._nativeRTTProvider.getRenderTargetForEye(e)},t.prototype.getRenderTargetTextureForView=function(e){return this._nativeRTTProvider.getRenderTargetForEye(e.eye)},t.prototype.getFramebufferDimensions=function(){return{framebufferWidth:this._nativeLayer.framebufferWidth,framebufferHeight:this._nativeLayer.framebufferHeight}},t}(Ii),Ui=function(){function e(e){this._nativeRenderTarget=navigator.xr.getWebXRRenderTarget(e.scene.getEngine())}return e.prototype.initializeXRLayerAsync=function(e){return Object(h.b)(this,void 0,void 0,(function(){return Object(h.e)(this,(function(t){switch(t.label){case 0:return[4,this._nativeRenderTarget.initializeXRLayerAsync(e)];case 1:return t.sent(),this.xrLayer=this._nativeRenderTarget.xrLayer,[2,this.xrLayer]}}))}))},e.prototype.dispose=function(){},e}(),Vi=function(){function e(e){var t=this;this.scene=e,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,this.inXRFrameLoop=!1,this.inXRSession=!1,this._engine=e.getEngine(),this._onEngineDisposedObserver=this._engine.onDisposeObservable.addOnce((function(){t._engine=null})),e.onDisposeObservable.addOnce((function(){t.dispose()}))}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}),Object.defineProperty(e.prototype,"sessionMode",{get:function(){return this._sessionMode},enumerable:!1,configurable:!0}),e.prototype.dispose=function(){var e;this.inXRSession&&this.exitXRAsync(),this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear(),this.onXRReferenceSpaceChanged.clear(),this.onXRSessionInit.clear(),null===(e=this._engine)||void 0===e||e.onDisposeObservable.remove(this._onEngineDisposedObserver),this._engine=null},e.prototype.exitXRAsync=function(){return this.session&&this.inXRSession?(this.inXRSession=!1,this.session.end().catch((function(e){m.a.Warn("Could not end XR session.")}))):Promise.resolve()},e.prototype.trySetViewportForView=function(e,t){var n;return(null===(n=this._baseLayerRTTProvider)||void 0===n?void 0:n.trySetViewportForView(e,t))||!1},e.prototype.getRenderTargetTextureForEye=function(e){var t;return(null===(t=this._baseLayerRTTProvider)||void 0===t?void 0:t.getRenderTargetTextureForEye(e))||null},e.prototype.getRenderTargetTextureForView=function(e){var t;return(null===(t=this._baseLayerRTTProvider)||void 0===t?void 0:t.getRenderTargetTextureForView(e))||null},e.prototype.getWebXRRenderTarget=function(e){var t=this.scene.getEngine();return this._xrNavigator.xr.native?new Ui(this):((e=e||Li.GetDefaults(t)).canvasElement=e.canvasElement||t.getRenderingCanvas()||void 0,new Fi(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 n=this;return void 0===e&&(e="immersive-vr"),void 0===t&&(t={}),this._xrNavigator.xr.requestSession(e,t).then((function(t){return n.session=t,n._sessionMode=e,n.onXRSessionInit.notifyObservers(t),n.inXRSession=!0,n.session.addEventListener("end",(function(){var e;n.inXRSession=!1,n.onXRSessionEnded.notifyObservers(null),n._engine&&(n._engine.framebufferDimensionsObject=null,n._engine.restoreDefaultFramebuffer(),n._engine.customAnimationFrameRequester=null,n._engine._renderLoop()),n.isNative&&(null===(e=n._baseLayerRTTProvider)||void 0===e||e.dispose()),n._baseLayerRTTProvider=null,n._baseLayerWrapper=null}),{once:!0}),n.session}))},e.prototype.isSessionSupportedAsync=function(t){return e.IsSessionSupportedAsync(t)},e.prototype.resetReferenceSpace=function(){this.referenceSpace=this.baseReferenceSpace},e.prototype.runXRRenderLoop=function(){var e,t=this;this.inXRSession&&this._engine&&(this._engine.customAnimationFrameRequester={requestAnimationFrame:this.session.requestAnimationFrame.bind(this.session),renderFunction:function(e,n){var i;t.inXRSession&&t._engine&&(t.currentFrame=n,t.currentTimestamp=e,n&&(t.inXRFrameLoop=!0,t._engine.framebufferDimensionsObject=(null===(i=t._baseLayerRTTProvider)||void 0===i?void 0:i.getFramebufferDimensions())||null,t.onXRFrameObservable.notifyObservers(n),t._engine._renderLoop(),t._engine.framebufferDimensionsObject=null,t.inXRFrameLoop=!1))}},this._engine.framebufferDimensionsObject=(null===(e=this._baseLayerRTTProvider)||void 0===e?void 0:e.getFramebufferDimensions())||null,"undefined"!=typeof window&&window.cancelAnimationFrame&&window.cancelAnimationFrame(this._engine._frameHandler),this._engine._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 n=new XRRigidTransform({x:0,y:-t.defaultHeightCompensation,z:0});return e.getOffsetReferenceSpace(n)}),(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(n){return t.viewerReferenceSpace=n,e}))})).then((function(e){return t.referenceSpace=t.baseReferenceSpace=e,t.referenceSpace}))},e.prototype.updateRenderStateAsync=function(e){return Promise.resolve(this.session.updateRenderState(e))},e.prototype._setBaseLayerWrapper=function(e){var t,n;this.isNative&&(null===(t=this._baseLayerRTTProvider)||void 0===t||t.dispose()),this._baseLayerWrapper=e,this._baseLayerRTTProvider=(null===(n=this._baseLayerWrapper)||void 0===n?void 0:n.createRenderTargetTextureProvider(this))||null},e.prototype.updateRenderState=function(e){e.baseLayer&&this._setBaseLayerWrapper(this.isNative?new wi(e.baseLayer):new Di(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)},Object.defineProperty(e.prototype,"isNative",{get:function(){var e;return null!==(e=this._xrNavigator.xr.native)&&void 0!==e&&e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"currentFrameRate",{get:function(){var e;return null===(e=this.session)||void 0===e?void 0:e.frameRate},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"supportedFrameRates",{get:function(){var e;return null===(e=this.session)||void 0===e?void 0:e.supportedFrameRates},enumerable:!1,configurable:!0}),e.prototype.updateTargetFrameRate=function(e){return this.session.updateTargetFrameRate(e)},e.prototype.runInXRFrame=function(e,t){void 0===t&&(t=!0),this.inXRFrameLoop?e():!this.inXRSession&&t||this.onXRFrameObservable.addOnce(e)},Object.defineProperty(e.prototype,"isFixedFoveationSupported",{get:function(){var e;return(null===(e=this._baseLayerWrapper)||void 0===e?void 0:e.isFixedFoveationSupported)||!1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fixedFoveation",{get:function(){var e;return(null===(e=this._baseLayerWrapper)||void 0===e?void 0:e.fixedFoveation)||null},set:function(e){var t=Math.max(0,Math.min(1,e||0));this._baseLayerWrapper&&(this._baseLayerWrapper.fixedFoveation=t)},enumerable:!1,configurable:!0}),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"}(Ri||(Ri={})),function(e){e[e.NOT_TRACKING=0]="NOT_TRACKING",e[e.TRACKING_LOST=1]="TRACKING_LOST",e[e.TRACKING=2]="TRACKING"}(Ci||(Ci={}));var ki=n(57),Gi=n(19),zi=n(32);function ji(e){for(var t=[],n=[],i=[],r=[],o=e.diameter||1,s=e.thickness||.5,c=e.tessellation||16,u=0===e.sideOrientation?0:e.sideOrientation||Gi.a.DEFAULTSIDE,l=c+1,h=0;h<=c;h++)for(var d=h/c,p=h*Math.PI*2/c-Math.PI/2,f=a.a.Translation(o/2,0,0).multiply(a.a.RotationY(p)),_=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,f),y=a.e.TransformNormal(y,f),n.push(T.x,T.y,T.z),i.push(y.x,y.y,y.z),r.push(E.x,zi.a.UseOpenGLOrientationForUV?1-E.y:E.y);var S=(h+1)%l,A=(_+1)%l;t.push(h*l+_),t.push(h*l+A),t.push(S*l+_),t.push(h*l+A),t.push(S*l+A),t.push(S*l+_)}Gi.a._ComputeSides(u,n,t,i,r,e.frontUVs,e.backUVs);var x=new Gi.a;return x.indices=t,x.positions=n,x.normals=i,x.uvs=r,x}function Wi(e,t,n){void 0===t&&(t={});var i=new Te.a(e,n);return t.sideOrientation=Te.a._GetDefaultSideOrientation(t.sideOrientation),i._originalBuilderSideOrientation=t.sideOrientation,ji(t).applyToMesh(i,t.updatable),i}var Hi={CreateTorus:Wi};Gi.a.CreateTorus=ji,Te.a.CreateTorus=function(e,t,n,i,r,o,a){return Wi(e,{diameter:t,thickness:n,tessellation:i,sideOrientation:a,updatable:o},r)},Te.a._GroundMeshParser=function(e,t){return Xi.Parse(e,t)};var Xi=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.generateOctree=!1,i}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 n=this.getWorldMatrix(),i=a.c.Matrix[5];n.invertToRef(i);var r=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,i,r),e=r.x,t=r.z,ethis._maxX||tthis._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,n,r),r.y},t.prototype.getNormalAtCoordinates=function(e,t){var n=new a.e(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,n),n},t.prototype.getNormalAtCoordinatesToRef=function(e,t,n){var i=this.getWorldMatrix(),r=a.c.Matrix[5];i.invertToRef(r);var o=a.c.Vector3[8];if(a.e.TransformCoordinatesFromFloatsToRef(e,0,t,r,o),e=o.x,t=o.z,ethis._maxX||tthis._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,i,n),this},t.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},t.prototype._getFacetAt=function(e,t){var n=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),i=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),r=this._heightQuads[i*this._subdivisionsX+n];return te.maxHeight){h=!0;var d=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=d}for(t=0;t<=e.subdivisions;t++)for(n=0;n<=e.subdivisions;n++){var p=new a.e(n*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),f=4*(((p.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(p.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),_=e.buffer[f]/255,m=e.buffer[f+1]/255,g=e.buffer[f+2]/255,v=e.buffer[f+3]/255;h&&(_=1-_,m=1-m,g=1-g);var b=_*u.r+m*u.g+g*u.b;p.y=v>=l?e.minHeight+(e.maxHeight-e.minHeight)*b:e.minHeight-ht.a,r.push(p.x,p.y,p.z),o.push(0,0,0),c.push(n/e.subdivisions,1-t/e.subdivisions)}for(t=0;t=e.minHeight,x=r[3*T+1]>=e.minHeight,R=r[3*E+1]>=e.minHeight;A&&x&&R&&(i.push(y),i.push(T),i.push(E)),r[3*S+1]>=e.minHeight&&A&&R&&(i.push(S),i.push(y),i.push(E))}Gi.a.ComputeNormals(r,i,o);var C=new Gi.a;return C.indices=i,C.positions=r,C.normals=o,C.uvs=c,C}function qi(e,t,n){void 0===t&&(t={});var i=new Xi(e,n);return i._setReady(!1),i._subdivisionsX=t.subdivisionsX||t.subdivisions||1,i._subdivisionsY=t.subdivisionsY||t.subdivisions||1,i._width=t.width||1,i._height=t.height||1,i._maxX=i._width/2,i._maxZ=i._height/2,i._minX=-i._maxX,i._minZ=-i._maxZ,Yi(t).applyToMesh(i,t.updatable),i._setReady(!0),i}function Zi(e,t,n){void 0===n&&(n=null);var i=new Te.a(e,n);return Ki(t).applyToMesh(i,t.updatable),i}function Ji(e,t,n,i){void 0===n&&(n={}),void 0===i&&(i=null);var r=n.width||10,o=n.height||10,a=n.subdivisions||1,c=n.minHeight||0,u=n.maxHeight||1,l=n.colorFilter||new s.a(.3,.59,.11),h=n.alphaFilter||0,d=n.updatable,p=n.onReady;i=i||P.a.LastCreatedScene;var f=new Xi(e,i);f._subdivisionsX=a,f._subdivisionsY=a,f._width=r,f._height=o,f._maxX=f._width/2,f._maxZ=f._height/2,f._minX=-f._maxX,f._minZ=-f._maxZ,f._setReady(!1);return Re.b.LoadImage(t,(function(e){var t=e.width,n=e.height;if(!i.isDisposed){var s=null==i?void 0:i.getEngine().resizeImageBitmap(e,t,n);Qi({width:r,height:o,subdivisions:a,minHeight:c,maxHeight:u,colorFilter:l,buffer:s,bufferWidth:t,bufferHeight:n,alphaFilter:h}).applyToMesh(f,d),p&&p(f),f._setReady(!0)}}),(function(){}),i.offlineProvider),f}var $i={CreateGround:qi,CreateGroundFromHeightMap:Ji,CreateTiledGround:Zi};Gi.a.CreateGround=Yi,Gi.a.CreateTiledGround=Ki,Gi.a.CreateGroundFromHeightMap=Qi,Te.a.CreateGround=function(e,t,n,i,r,o){return qi(e,{width:t,height:n,subdivisions:i,updatable:o},r)},Te.a.CreateTiledGround=function(e,t,n,i,r,o,a,s,c){return Zi(e,{xmin:t,zmin:n,xmax:i,zmax:r,subdivisions:o,precision:a,updatable:c},s)},Te.a.CreateGroundFromHeightMap=function(e,t,n,i,r,o,a,s,c,u,l){return Ji(e,t,{width:n,height:i,subdivisions:r,minHeight:o,maxHeight:a,updatable:c,onReady:u,alphaFilter:l},s)};var er,tr=function(){function e(t,n){if(void 0===n&&(n=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++,n)this._gazeTracker=n.clone("gazeTracker");else{this._gazeTracker=Wi("gazeTracker",{diameter:.0035,thickness:.0025,tessellation:20,updatable:!1},t),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var i=new Si.a("targetMat",t);i.specularColor=s.a.Black(),i.emissiveColor=new s.a(.7,.7,.7),i.backFaceCulling=!1,this._gazeTracker.material=i}}return e.prototype._getForwardRay=function(e){return new pn.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}(),nr=function(e){function t(t,n,i){var r=e.call(this,n,i)||this;r.webVRController=t,r._laserPointer=Object(ki.a)("laserPointer",{updatable:!1,height:1,diameterTop:.004,diameterBottom:2e-4,tessellation:20,subdivisions:1},n);var o=new Si.a("laserPointerMat",n);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 Te.a("preloadControllerMesh",n),c=new Te.a(gn.POINTING_POSE,n);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 n=e.getChildren(void 0,!1),i=e;this.webVRController._pointingPoseNode=null;for(var r=0;r=0){i=n[r],this.webVRController._pointingPoseNode=i;break}this._laserPointer.parent=i},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}(tr),ir=function(e){function t(t,n){var i=e.call(this,n)||this;return i.getCamera=t,i}return Object(h.d)(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new pn.a(a.e.Zero(),a.e.Forward())},t}(tr),rr=function(){},or=function(){function e(t,n){var i=this;if(void 0===n&&(n={}),this.webVROptions=n,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(){i.moveButtonToBottomRight(),i._fullscreenVRpresenting&&i._webVRready&&i.exitVR()},this._onFullscreenChange=function(){var e=document;void 0!==e.fullscreen?i._fullscreenVRpresenting=document.fullscreen:void 0!==e.mozFullScreen?i._fullscreenVRpresenting=e.mozFullScreen:void 0!==e.webkitIsFullScreen?i._fullscreenVRpresenting=e.webkitIsFullScreen:void 0!==e.msIsFullScreen?i._fullscreenVRpresenting=e.msIsFullScreen:void 0!==document.msFullscreenElement&&(i._fullscreenVRpresenting=document.msFullscreenElement),!i._fullscreenVRpresenting&&i._inputElement&&(i.exitVR(),!i._useCustomVRButton&&i._btnVR&&(i._btnVR.style.top=i._inputElement.offsetTop+i._inputElement.offsetHeight-70+"px",i._btnVR.style.left=i._inputElement.offsetLeft+i._inputElement.offsetWidth-100+"px",i.updateButtonVisibility()))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){i._leftController&&i._leftController._activePointer&&i._castRayAndSelectObject(i._leftController),i._rightController&&i._rightController._activePointer&&i._castRayAndSelectObject(i._rightController),i._noControllerIsActive&&(i._scene.getEngine().isPointerLock||i.enableGazeEvenWhenNoPointerLock)?i._castRayAndSelectObject(i._cameraGazer):i._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==Pt.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){i._teleportationInitialized&&i.teleportationEnabled&&(!i._leftController&&!i._rightController||i._leftController&&!i._leftController._activePointer&&i._rightController&&!i._rightController._activePointer)&&(i._checkTeleportWithRay(e,i._cameraGazer),i._checkTeleportBackwards(e,i._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){i._teleportationInitialized&&i._checkRotate(e,i._cameraGazer)})),e.type===Pt.XBOX&&(e.onbuttondown((function(e){i._interactionsEnabled&&e===fn.A&&i._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){i._interactionsEnabled&&e===fn.A&&i._cameraGazer._selectionPointerUp()})));else{var t=e,n=new nr(t,i._scene,i._cameraGazer._gazeTracker);"right"===t.hand||i._leftController&&i._leftController.webVRController!=t?i._rightController=n:i._leftController=n,i._tryEnableInteractionOnController(n)}},this._tryEnableInteractionOnController=function(e){i._interactionsRequested&&!e._interactionsEnabled&&i._enableInteractionOnController(e),i._teleportationRequested&&!e._teleportationEnabled&&i._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof Ti&&("left"===e.hand&&null!=i._leftController&&(i._leftController.dispose(),i._leftController=null),"right"===e.hand&&null!=i._rightController&&(i._rightController.dispose(),i._rightController=null))},this._workingVector=a.e.Zero(),this._workingQuaternion=a.b.Identity(),this._workingMatrix=a.a.Identity(),m.a.Warn("WebVR is deprecated. Please avoid using this experience helper and use the WebXR experience helper instead"),this._scene=t,this._inputElement=t.getEngine().getInputElement(),"getVRDisplays"in navigator||void 0!==n.useXR||(n.useXR=!0),void 0===n.createFallbackVRDeviceOrientationFreeCamera&&(n.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===n.createDeviceOrientationCamera&&(n.createDeviceOrientationCamera=!0),void 0===n.laserToggle&&(n.laserToggle=!0),void 0===n.defaultHeight&&(n.defaultHeight=1.7),n.useCustomVRButton&&(this._useCustomVRButton=!0,n.customVRButton&&(this._btnVR=n.customVRButton)),n.rayLength&&(this._rayLength=n.rayLength),this._defaultHeight=n.defaultHeight,n.positionScale&&(this._rayLength*=n.positionScale,this._defaultHeight*=n.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new a.e(0,this._defaultHeight,0),n.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new an("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 tn&&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?Vi.IsSessionSupportedAsync("immersive-vr").then((function(e){e?(m.a.Log("Using WebXR. It is recommended to use the WebXRDefaultExperience directly"),t.createDefaultXRExperienceAsync({floorMeshes:n.floorMeshes||[]}).then((function(e){i.xr=e,i.xrTestDone=!0,i._cameraGazer=new ir((function(){return i.xr.baseExperience.camera}),t),i.xr.baseExperience.onStateChangedObservable.add((function(e){switch(e){case Ri.ENTERING_XR:i.onEnteringVRObservable.notifyObservers(i),i._interactionsEnabled||i.xr.pointerSelection.detach(),i.xr.pointerSelection.displayLaserPointer=i._displayLaserPointer;break;case Ri.EXITING_XR:i.onExitingVRObservable.notifyObservers(i),i._scene.getEngine().resize();break;case Ri.IN_XR:i._hasEnteredVR=!0;break;case Ri.NOT_IN_XR:i._hasEnteredVR=!1}}))}))):i.completeVRInit(t,n)})):this.completeVRInit(t,n)}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 n=this;if(this.xrTestDone=!0,t.createFallbackVRDeviceOrientationFreeCamera&&(t.useMultiview&&(t.vrDeviceOrientationCameraMetrics||(t.vrDeviceOrientationCameraMetrics=ti.GetDefault()),t.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new mi("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new yi("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new ir((function(){return n.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 i=".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) }";i+=".babylonVRicon.vrdisplaypresenting { display: none; }";var r=document.createElement("style");r.appendChild(document.createTextNode(i)),document.getElementsByTagName("head")[0].appendChild(r),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){n.isInVRMode?n._scene.getEngine().disableVR():n.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&&n.displayVRButton()})),this._onKeyDown=function(e){27===e.keyCode&&n.isInVRMode&&n.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add((function(){n._hasEnteredVR&&n.exitVROnDoubleTap&&(n.exitVR(),n._fullscreenVRpresenting&&n._scene.getEngine().exitFullscreen())}),qe.a.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return n.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return n.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){n._webVRrequesting=!0,n.updateButtonVisibility()},this._onVRRequestPresentComplete=function(){n._webVRrequesting=!1,n.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(){n.dispose()})),this._webVRCamera.onControllerMeshLoadedObservable.add((function(e){return n._onDefaultMeshLoaded(e)})),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new se,this._circleEase.setEasingMode(ae.EASINGMODE_EASEINOUT),this._teleportationEasing=this._circleEase,e.onPointerObservable.add((function(t){n._interactionsEnabled&&e.activeCamera===n.vrDeviceOrientationCamera&&"mouse"===t.event.pointerType&&(t.type===qe.a.POINTERDOWN?n._cameraGazer._selectionPointerDown():t.type===qe.a.POINTERUP&&n._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===Ri.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,n=a.b.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-t,i=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=a.b.FromEulerAngles(0,i+n,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===Ri.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-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 n=e.floorMeshes||[];if(!n.length){var i=this._scene.getMeshByName(e.floorMeshName);i&&n.push(i)}if(this.xr)return n.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 Ei.a;o.vignetteColor=new s.b(0,0,0,0),o.vignetteEnabled=!0,this._postProcessMove=new Pi("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(n){t._displayLaserPointer&&1===n.value&&(e._activePointer?e._deactivatePointer():e._activatePointer(),t.displayGaze&&(e._gazeTracker.isVisible=e._activePointer))})),e.webVRController.onTriggerStateChangedObservable.add((function(n){var i=e;t._noControllerIsActive&&(i=t._cameraGazer),i._pointerDownOnMeshAsked?n.valuet._padSensibilityUp&&i._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&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.xthis._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 n=a.b.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),i=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(n=this.currentVRCamera.deviceRotationQuaternion,i=this.currentVRCamera.devicePosition),n.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 pn.a(i,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===ln.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(n){t.teleportationEnabled&&(t._checkTeleportBackwards(n,e),t._checkTeleportWithRay(n,e)),t._checkRotate(n,e)})))},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=qi("teleportationTarget",{width:2,height:2,subdivisions:2},this._scene),this._teleportationTarget.isPickable=!1;var e=new Ai.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 n=new Si.a("TextPlaneMaterial",this._scene);n.diffuseTexture=e,this._teleportationTarget.material=n;var i=Wi("torusTeleportation",{diameter:.75,thickness:.1,tessellation:25,updatable:!1},this._scene);i.isPickable=!1,i.parent=this._teleportationTarget;var r=new G("animationInnerCircle","position.y",30,G.ANIMATIONTYPE_FLOAT,G.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 ge;a.setEasingMode(ae.EASINGMODE_EASEINOUT),r.setEasingFunction(a),i.animations=[],i.animations.push(r),this._scene.beginAnimation(i,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 nn){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var n=a.b.FromRotationMatrix(a.a.RotationY(Math.PI/4*this._rotationAngle)),i=new G("animationRotation","rotationQuaternion",90,G.ANIMATIONTYPE_QUATERNION,G.ANIMATIONLOOPMODE_CONSTANT),r=[];r.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),r.push({frame:6,value:n}),i.setKeys(r),i.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(i),this._postProcessMove.animations=[];var o=new G("animationPP","vignetteWeight",90,G.ANIMATIONTYPE_FLOAT,G.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 G("animationPP2","vignetteStretch",90,G.ANIMATIONTYPE_FLOAT,G.ANIMATIONLOOPMODE_CONSTANT),u=[];u.push({frame:0,value:0}),u.push({frame:3,value:10}),u.push({frame:6,value:0}),c.setKeys(u),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,n){if(e.pickedPoint){t._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(e.pickedPoint),this._teleportationTarget.position.copyFrom(e.pickedPoint));var i=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),n);if(i){var r=a.e.Cross(J.a.Y,i),o=a.e.Cross(i,r);a.e.RotationFromAxisToRef(o,i,r,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(t){var n=this;if(this.currentVRCamera instanceof nn){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 i,r;if(this._teleportationMode==e.TELEPORTATIONMODE_CONSTANTSPEED){r=90;var o=a.e.Distance(this.currentVRCamera.position,this._workingVector);i=this._teleportationSpeed/o}else r=Math.round(90*this._teleportationTime/1e3),i=1;this.currentVRCamera.animations=[];var s=new G("animationCameraTeleportation","position",90,G.ANIMATIONTYPE_VECTOR3,G.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 u=Math.round(r/2),l=new G("animationPP","vignetteWeight",90,G.ANIMATIONTYPE_FLOAT,G.ANIMATIONLOOPMODE_CONSTANT),h=[];h.push({frame:0,value:0}),h.push({frame:u,value:8}),h.push({frame:r,value:0}),l.setKeys(h),this._postProcessMove.animations.push(l);var d=new G("animationPP2","vignetteStretch",90,G.ANIMATIONTYPE_FLOAT,G.ANIMATIONLOOPMODE_CONSTANT),p=[];p.push({frame:0,value:0}),p.push({frame:u,value:10}),p.push({frame:r,value:0}),d.setKeys(p),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,i,(function(){n._webVRCamera.detachPostProcess(n._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,r,!1,i,(function(){n.onAfterCameraTeleport.notifyObservers(n._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))s){var c=s;s=a,a=c}return a>0&&a0&&s=0))},e.prototype._canDoCollision=function(e,t,n,i){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,n,i){return!(e.x>n.x+i)&&(!(n.x-i>t.x)&&(!(e.y>n.y+i)&&(!(n.y-i>t.y)&&(!(e.z>n.z+i)&&!(n.z-i>t.z)))))}(n,i,this._basePointWorld,this._velocityWorldLength+o)},e.prototype._testTriangle=function(e,t,n,i,r,o,s){var c,u=!1;t||(t=[]),t[e]||(t[e]=new Nt.a(0,0,0,0),t[e].copyFromPoints(n,i,r));var l=t[e];if(o||l.isFrontFacingTo(this._normalizedVelocity,0)){var h=l.signedDistanceTo(this._basePoint),d=a.e.Dot(l.normal,this._velocity);if(0==d){if(Math.abs(h)>=1)return;u=!0,c=0}else{var p=(1-h)/d;if((c=(-1-h)/d)>p){var f=p;p=c,c=f}if(c>1||p<0)return;c<0&&(c=0),c>1&&(c=1)}this._collisionPoint.copyFromFloats(0,0,0);var _=!1,m=1;if(u||(this._basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(c,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,i,r,l.normal)&&(_=!0,m=c,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!_){var g=this._velocitySquaredLength;this._basePoint.subtractToRef(n,this._tempVector);var v=2*a.e.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=ar(g,v,b,m);y.found&&(m=y.root,_=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(i,this._tempVector),v=2*a.e.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,(y=ar(g,v,b,m)).found&&(m=y.root,_=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(r,this._tempVector),v=2*a.e.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,(y=ar(g,v,b,m)).found&&(m=y.root,_=!0,this._collisionPoint.copyFrom(r)),i.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex);var T=this._edge.lengthSquared(),E=a.e.Dot(this._edge,this._velocity),S=a.e.Dot(this._edge,this._baseToVertex);if(g=T*-this._velocitySquaredLength+E*E,v=2*(T*a.e.Dot(this._velocity,this._baseToVertex)-E*S),b=T*(1-this._baseToVertex.lengthSquared())+S*S,(y=ar(g,v,b,m)).found){var A=(E*y.root-S)/T;A>=0&&A<=1&&(m=y.root,_=!0,this._edge.scaleInPlace(A),n.addToRef(this._edge,this._collisionPoint))}r.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex),T=this._edge.lengthSquared(),E=a.e.Dot(this._edge,this._velocity),S=a.e.Dot(this._edge,this._baseToVertex),g=T*-this._velocitySquaredLength+E*E,v=2*(T*a.e.Dot(this._velocity,this._baseToVertex)-E*S),b=T*(1-this._baseToVertex.lengthSquared())+S*S,(y=ar(g,v,b,m)).found&&(A=(E*y.root-S)/T)>=0&&A<=1&&(m=y.root,_=!0,this._edge.scaleInPlace(A),i.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),T=this._edge.lengthSquared(),E=a.e.Dot(this._edge,this._velocity),S=a.e.Dot(this._edge,this._baseToVertex),g=T*-this._velocitySquaredLength+E*E,v=2*(T*a.e.Dot(this._velocity,this._baseToVertex)-E*S),b=T*(1-this._baseToVertex.lengthSquared())+S*S,(y=ar(g,v,b,m)).found&&(A=(E*y.root-S)/T)>=0&&A<=1&&(m=y.root,_=!0,this._edge.scaleInPlace(A),r.addToRef(this._edge,this._collisionPoint))}if(_){var x=m*m*this._velocitySquaredLength;(!this.collisionFound||x=i)r.copyFrom(e);else{var s=o?o.collisionMask:n.collisionMask;n._initialize(e,t,a);for(var c=o&&o.surroundingMeshes||this._scene.meshes,u=0;u-1?e:this._shaderRepository+e,this._engine._loadFile(r+"."+t.toLowerCase()+".fx",i)):i(window.atob(e.substr(7))):i(e.substr(7))},Object.defineProperty(e.prototype,"computeSourceCode",{get:function(){var e,t;return this._computeSourceCodeOverride?this._computeSourceCodeOverride:null!==(t=null===(e=this._pipelineContext)||void 0===e?void 0:e._getComputeShaderCode())&&void 0!==t?t:this._computeSourceCode},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"rawComputeSourceCode",{get:function(){return this._rawComputeSourceCode},enumerable:!1,configurable:!0}),e.prototype._prepareEffect=function(){var e=this,t=this.defines,n=this._pipelineContext;this._isReady=!1;try{var i=this._engine;this._pipelineContext=i.createComputePipelineContext(),this._pipelineContext._name=this._key,i._prepareComputePipelineContext(this._pipelineContext,this._computeSourceCodeOverride?this._computeSourceCodeOverride:this._computeSourceCode,this._rawComputeSourceCode,this._computeSourceCodeOverride?null:t,this._entryPoint),i._executeWhenComputeStateIsCompiled(this._pipelineContext,(function(){e._compilationError="",e._isReady=!0,e.onCompiled&&e.onCompiled(e),e.onCompileObservable.notifyObservers(e),e.onCompileObservable.clear(),n&&e.getEngine()._deleteComputePipelineContext(n)})),this._pipelineContext.isAsync&&this._checkIsReady(n)}catch(e){this._processCompilationErrors(e,n)}},e.prototype._getShaderCodeAndErrorLine=function(e,t){var n=null;if(t&&e){var i=t.match(/COMPUTE SHADER ERROR: 0:(\d+?):/);if(i&&2===i.length){var r=parseInt(i[1]),o=e.split("\n",-1);o.length>=r&&(n="Offending line [".concat(r,"] in compute code: ").concat(o[r-1]))}}return[e,n]},e.prototype._processCompilationErrors=function(t,n){var i,r;if(void 0===n&&(n=null),this._compilationError=t.message,m.a.Error("Unable to compile compute effect:"),m.a.Error("Defines:\r\n"+this.defines),e.LogShaderCodeOnCompilationError){var o=null,a=null;(null===(r=this._pipelineContext)||void 0===r?void 0:r._getComputeShaderCode())&&(a=(i=this._getShaderCodeAndErrorLine(this._pipelineContext._getComputeShaderCode(),this._compilationError))[0],o=i[1],a&&(m.a.Error("Compute code:"),m.a.Error(a))),o&&m.a.Error(o)}m.a.Error("Error: "+this._compilationError),n&&(this._pipelineContext=n,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this))},e.prototype.dispose=function(){this._pipelineContext&&this._pipelineContext.dispose(),this._engine._releaseComputeEffect(this)},e.RegisterShader=function(e,t){Cn.a.GetShadersStore(fr.a.WGSL)["".concat(e,"ComputeShader")]=t},e._uniqueIdSeed=0,e.LogShaderCodeOnCompilationError=!0,e}();!function(e){e[e.Texture=0]="Texture",e[e.StorageTexture=1]="StorageTexture",e[e.UniformBuffer=2]="UniformBuffer",e[e.StorageBuffer=3]="StorageBuffer",e[e.TextureWithoutSampler=4]="TextureWithoutSampler",e[e.Sampler=5]="Sampler"}(ur||(ur={})),Ve.a.prototype.createComputeEffect=function(e,t){throw new Error("createComputeEffect: This engine does not support compute shaders!")},Ve.a.prototype.createComputePipelineContext=function(){throw new Error("createComputePipelineContext: This engine does not support compute shaders!")},Ve.a.prototype.createComputeContext=function(){},Ve.a.prototype.computeDispatch=function(e,t,n,i,r,o,a){throw new Error("computeDispatch: This engine does not support compute shaders!")},Ve.a.prototype.areAllComputeEffectsReady=function(){return!0},Ve.a.prototype.releaseComputeEffects=function(){},Ve.a.prototype._prepareComputePipelineContext=function(e,t,n,i,r){},Ve.a.prototype._rebuildComputeEffects=function(){},Ve.a.prototype._executeWhenComputeStateIsCompiled=function(e,t){t()},Ve.a.prototype._releaseComputeEffect=function(e){},Ve.a.prototype._deleteComputePipelineContext=function(e){};var mr=n(141),gr=n(135),vr=function(){function e(e,t,n,i){void 0===i&&(i={}),this._bindings={},this._samplers={},this._contextIsDirty=!1,this.onCompiled=null,this.onError=null,this.name=e,this._engine=t,this.uniqueId=mr.a.UniqueId,this._engine.getCaps().supportComputeShaders?i.bindingsMapping?(this._context=t.createComputeContext(),this._shaderPath=n,this._options=Object(h.a)({bindingsMapping:{},defines:[]},i)):m.a.Error("You must provide the binding mappings as browsers don't support reflection for wgsl shaders yet!"):m.a.Error("This engine does not support compute shaders!")}return Object.defineProperty(e.prototype,"options",{get:function(){return this._options},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"shaderPath",{get:function(){return this._shaderPath},enumerable:!1,configurable:!0}),e.prototype.getClassName=function(){return"ComputeShader"},e.prototype.setTexture=function(e,t,n){void 0===n&&(n=!0);var i=this._bindings[e];this._bindings[e]={type:n?ur.Texture:ur.TextureWithoutSampler,object:t,indexInGroupEntries:null==i?void 0:i.indexInGroupEntries},this._contextIsDirty||(this._contextIsDirty=!i||i.object!==t||i.type!==this._bindings[e].type)},e.prototype.setStorageTexture=function(e,t){var n=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!n||n.object!==t),this._bindings[e]={type:ur.StorageTexture,object:t,indexInGroupEntries:null==n?void 0:n.indexInGroupEntries}},e.prototype.setUniformBuffer=function(e,t){var n=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!n||n.object!==t),this._bindings[e]={type:ur.UniformBuffer,object:t,indexInGroupEntries:null==n?void 0:n.indexInGroupEntries}},e.prototype.setStorageBuffer=function(e,t){var n=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!n||n.object!==t),this._bindings[e]={type:ur.StorageBuffer,object:t,indexInGroupEntries:null==n?void 0:n.indexInGroupEntries}},e.prototype.setTextureSampler=function(e,t){var n=this._bindings[e];this._contextIsDirty||(this._contextIsDirty=!n||!t.compareSampler(n.object)),this._bindings[e]={type:ur.Sampler,object:t,indexInGroupEntries:null==n?void 0:n.indexInGroupEntries}},e.prototype.isReady=function(){var e=this._effect;for(var t in this._bindings){var n=this._bindings[t],i=n.type,r=n.object;switch(i){case ur.Texture:case ur.TextureWithoutSampler:case ur.StorageTexture:if(!r.isReady())return!1}}var o=[],a=this._shaderPath;if(this._options.defines)for(var s=0;sthis.capacity&&this._depth-1&&this.entries.splice(n,1)}},e.prototype.addEntries=function(e){for(var t=0;t-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}}))):(this.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},xe.a.prototype._getGlAlgorithmType=function(e){return e===ot.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(ot.a.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},set:function(e){this._occlusionDataStorage.isOcclusionQueryInProgress=e},enumerable:!1,configurable:!0}),Object.defineProperty(ot.a.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new Dr),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(ot.a.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(ot.a.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(ot.a.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(ot.a.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),Object.defineProperty(ot.a.prototype,"forceRenderingWhenOccluded",{get:function(){return this._occlusionDataStorage.forceRenderingWhenOccluded},set:function(e){this._occlusionDataStorage.forceRenderingWhenOccluded=e},enumerable:!0,configurable:!0}),ot.a.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===ot.a.OCCLUSION_TYPE_NONE)return e.isOccluded=!1,!1;var t=this.getEngine();if(!t.getCaps().supportOcclusionQuery)return e.isOccluded=!1,!1;if(!t.isQueryResultAvailable)return e.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var n=t.getQueryResult(this._occlusionQuery);e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=!(n>0)}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return e.occlusionType!==ot.a.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==ot.a.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var i=this.getScene();if(i.getBoundingBoxRenderer){var r=i.getBoundingBoxRenderer();null===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 Nr=!0;xe.a.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},xe.a.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},xe.a.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},xe.a.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},xe.a.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},xe.a.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},xe.a.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)};n(148);Ve.a.prototype.createExternalTexture=function(e){return null},Ve.a.prototype.setExternalTexture=function(e,t){throw new Error("setExternalTexture: This engine does not support external textures!")},Ve.a.prototype.updateVideoTexture=function(e,t,n){if(e&&!e._isDisabled){var i=this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0);this._unpackFlipY(!n);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=this.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),i||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},Ve.a.prototype.restoreSingleAttachment=function(){var e=this._gl;this.bindAttachments([e.BACK])},Ve.a.prototype.restoreSingleAttachmentForRenderTarget=function(){var e=this._gl;this.bindAttachments([e.COLOR_ATTACHMENT0])},Ve.a.prototype.buildTextureLayout=function(e){for(var t=this._gl,n=[],i=0;i1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"],i.readBuffer(r[a]),i.drawBuffers(r),i.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,i.COLOR_BUFFER_BIT,i.NEAREST)}for(a=0;a1?"COLOR_ATTACHMENT"+a:"COLOR_ATTACHMENT"+a+"_WEBGL"];i.drawBuffers(r)}for(a=0;a1&&(t.depthTextureFormat===g.a.TEXTUREFORMAT_DEPTH24_STENCIL8||t.depthTextureFormat===g.a.TEXTUREFORMAT_DEPTH24||t.depthTextureFormat===g.a.TEXTUREFORMAT_DEPTH32_FLOAT)&&(s=t.depthTextureFormat));var f=this._gl,_=f.createFramebuffer();this._bindUnboundFramebuffer(_);var v=e.width||e,b=e.height||e,y=[],T=[],E=this.webGLVersion>1&&a&&t.depthTextureFormat===g.a.TEXTUREFORMAT_DEPTH24_STENCIL8,S=this._setupFramebufferDepthAttachments(!E&&o,!a&&r,v,b);p._framebuffer=_,p._depthStencilBuffer=S,p._generateDepthBuffer=!a&&r,p._generateStencilBuffer=!E&&o,p._attachments=T;for(var A=0;A1?"COLOR_ATTACHMENT"+A:"COLOR_ATTACHMENT"+A+"_WEBGL"];y.push(P),T.push(O),f.activeTexture(f["TEXTURE"+A]),f.bindTexture(f.TEXTURE_2D,P._hardwareTexture.underlyingResource),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,C.mag),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,C.min),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texImage2D(f.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(R),v,b,0,f.RGBA,this._getWebGLTextureType(R),null),f.framebufferTexture2D(f.DRAW_FRAMEBUFFER,O,f.TEXTURE_2D,P._hardwareTexture.underlyingResource,0),i&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(f.TEXTURE_2D,null),P.baseWidth=v,P.baseHeight=b,P.width=v,P.height=b,P.isReady=!0,P.samples=1,P.generateMipMaps=i,P.samplingMode=x,P.type=R,this._internalTexturesCache.push(P)}if(a&&this._caps.depthTextureExtension){var M=new Ue.a(this,Ue.b.Depth),I=g.a.TEXTURETYPE_UNSIGNED_SHORT,D=f.DEPTH_COMPONENT16,N=f.DEPTH_COMPONENT,L=f.UNSIGNED_SHORT,F=f.DEPTH_ATTACHMENT;this.webGLVersion<2?D=f.DEPTH_COMPONENT:s===g.a.TEXTUREFORMAT_DEPTH32_FLOAT?(I=g.a.TEXTURETYPE_FLOAT,L=f.FLOAT,D=f.DEPTH_COMPONENT32F):s===g.a.TEXTUREFORMAT_DEPTH24?(I=g.a.TEXTURETYPE_UNSIGNED_INT,L=f.UNSIGNED_INT,D=f.DEPTH_COMPONENT24,F=f.DEPTH_ATTACHMENT):s===g.a.TEXTUREFORMAT_DEPTH24_STENCIL8&&(I=g.a.TEXTURETYPE_UNSIGNED_INT_24_8,L=f.UNSIGNED_INT_24_8,D=f.DEPTH24_STENCIL8,N=f.DEPTH_STENCIL,F=f.DEPTH_STENCIL_ATTACHMENT),f.activeTexture(f.TEXTURE0),f.bindTexture(f.TEXTURE_2D,M._hardwareTexture.underlyingResource),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MAG_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_MIN_FILTER,f.NEAREST),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_S,f.CLAMP_TO_EDGE),f.texParameteri(f.TEXTURE_2D,f.TEXTURE_WRAP_T,f.CLAMP_TO_EDGE),f.texImage2D(f.TEXTURE_2D,0,D,v,b,0,N,L,null),f.framebufferTexture2D(f.FRAMEBUFFER,F,f.TEXTURE_2D,M._hardwareTexture.underlyingResource,0),M.baseWidth=v,M.baseHeight=b,M.width=v,M.height=b,M.isReady=!0,M.samples=1,M.generateMipMaps=i,M.samplingMode=g.a.TEXTURE_NEAREST_SAMPLINGMODE,M.format=s,M.type=I,y.push(M),this._internalTexturesCache.push(M)}return p.setTextures(y),n&&f.drawBuffers(T),this._bindUnboundFramebuffer(null),this.resetTextureCache(),p},Ve.a.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t,n){if(void 0===n&&(n=!0),this.webGLVersion<2||!e||!e.texture)return 1;if(e.samples===t)return t;var i=e._attachments.length;if(0===i)return 1;var r=this._gl;t=Math.min(t,this.getCaps().maxMSAASamples),e._depthStencilBuffer&&(r.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(r.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null);for(var o=0;o1&&r.renderbufferStorageMultisample){var a=r.createFramebuffer();if(!a)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=a,this._bindUnboundFramebuffer(a);var s=[];for(o=0;o1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],h=this._createRenderBuffer(c.width,c.height,t,-1,this._getRGBAMultiSampleBufferFormat(c.type),l);if(!h)throw new Error("Unable to create multi sampled framebuffer");u._MSAARenderBuffer=h,c.samples=t,s.push(l)}n&&r.drawBuffers(s)}else this._bindUnboundFramebuffer(e._framebuffer);return e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.texture.width,e.texture.height,t),this._bindUnboundFramebuffer(null),t};var Lr=n(55),Fr=n(100);Ve.a.prototype._createDepthStencilCubeTexture=function(e,t,n){var i=new Ue.a(this,Ue.b.DepthStencil);if(i.isCube=!0,1===this.webGLVersion)return m.a.Error("Depth cube texture is not supported by WebGL 1."),i;var r=Object(h.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),o=this._gl;this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,i,!0),this._setupDepthStencilTexture(i,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction),n._depthStencilTexture=i,n._depthStencilTextureWithStencil=r.generateStencil;for(var a=0;a<6;a++)r.generateStencil?o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,o.DEPTH24_STENCIL8,e,e,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,o.DEPTH_COMPONENT24,e,e,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null);return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null),this._internalTexturesCache.push(i),i},Ve.a.prototype._partialLoadFile=function(e,t,n,i,r){void 0===r&&(r=null);this._loadFile(e,(function(e){n[t]=e,n._internalCount++,6===n._internalCount&&i(n)}),void 0,void 0,!0,(function(e,t){r&&e&&r(e.status+" "+e.statusText,t)}))},Ve.a.prototype._cascadeLoadFiles=function(e,t,n,i){void 0===i&&(i=null);var r=[];r._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(n[o],o,r,t,i)},Ve.a.prototype._cascadeLoadImgs=function(e,t,n,i,r,o){void 0===r&&(r=null);var a=[];a._internalCount=0;for(var s=0;s<6;s++)this._partialLoadImg(i[s],s,a,e,t,n,r,o)},Ve.a.prototype._partialLoadImg=function(e,t,n,i,r,o,a,s){void 0===a&&(a=null);var c=Object(Fr.b)();Object(Lr.h)(e,(function(e){n[t]=e,n._internalCount++,i&&i._removePendingData(c),6===n._internalCount&&o&&o(r,n)}),(function(e,t){i&&i._removePendingData(c),a&&a(e,t)}),i?i.offlineProvider:null,s),i&&i._addPendingData(c)},Ve.a.prototype._setCubeMapTextureParams=function(e,t,n){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,t&&this.getCaps().textureMaxLevel&&void 0!==n&&n>0&&(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAX_LEVEL,n),e._maxLodLevel=n),this._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null)},Ve.a.prototype.createCubeTextureBase=function(e,t,n,i,r,o,a,s,c,u,l,h,d,p,f){var _=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!1),void 0===u&&(u=0),void 0===l&&(l=0),void 0===h&&(h=null),void 0===d&&(d=null),void 0===p&&(p=null),void 0===f&&(f=!1);var g=h||new Ue.a(this,Ue.b.Cube);g.isCube=!0,g.url=e,g.generateMipMaps=!i,g._lodGenerationScale=u,g._lodGenerationOffset=l,g._useSRGBBuffer=!!f&&this._caps.supportSRGBBuffers&&(this.webGLVersion>1||this.isWebGPU||!!i),this._doNotHandleContextLost||(g._extension=s,g._files=n);var v=e;this._transformTextureUrl&&!h&&(e=this._transformTextureUrl(e));for(var b=e.lastIndexOf("."),y=s||(b>-1?e.substring(b).toLowerCase():""),T=null,E=0,S=Ve.a._TextureLoaders;E-1?e.substring(n,e.length):"";return(t>-1?e.substring(0,t):e)+this._textureFormatInUse+i}Ve.a.prototype.createStorageBuffer=function(e,t){throw new Error("createStorageBuffer: Unsupported method in this engine!")},Ve.a.prototype.updateStorageBuffer=function(e,t,n,i){},Ve.a.prototype.readFromStorageBuffer=function(e,t,n,i){throw new Error("readFromStorageBuffer: Unsupported method in this engine!")},Ve.a.prototype.setStorageBuffer=function(e,t){throw new Error("setStorageBuffer: Unsupported method in this engine!")},Object.defineProperty(xe.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(xe.a.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse||null},enumerable:!0,configurable:!0}),xe.a.prototype.setCompressedTextureExclusions=function(e){this._excludedCompressedTextures=e},xe.a.prototype.setTextureFormatToUse=function(e){for(var t=this.texturesSupported,n=0,i=t.length;nthis._length&&this._flush()},e.prototype._flush=function(){this._nativeDataStream.writeBuffer(this._uint32s.buffer,this._position),this._position=0},e.DEFAULT_BUFFER_SIZE=65536,e}(),kr=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}(),Gr=function(){function e(e,t,n){void 0===e&&(e=a.e.Zero()),void 0===t&&(t=a.e.Up()),void 0===n&&(n=a.d.Zero()),this.position=e,this.normal=t,this.uv=n}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e}(),zr=[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))],jr=[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}],Wr=function(e,t){return zr[e]*jr[e](t)},Hr=[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],Xr=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,n){a.c.Vector3[0].set(t.r,t.g,t.b);var i=a.c.Vector3[0],r=a.c.Vector3[1];i.scaleToRef(n,r),r.scaleToRef(Wr(0,e),a.c.Vector3[2]),this.l00.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(1,e),a.c.Vector3[2]),this.l1_1.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(2,e),a.c.Vector3[2]),this.l10.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(3,e),a.c.Vector3[2]),this.l11.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(4,e),a.c.Vector3[2]),this.l2_2.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(5,e),a.c.Vector3[2]),this.l2_1.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(6,e),a.c.Vector3[2]),this.l20.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(7,e),a.c.Vector3[2]),this.l21.addInPlace(a.c.Vector3[2]),r.scaleToRef(Wr(8,e),a.c.Vector3[2]),this.l22.addInPlace(a.c.Vector3[2])},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(Hr[0]),this.l1_1.scaleInPlace(Hr[1]),this.l10.scaleInPlace(Hr[2]),this.l11.scaleInPlace(Hr[3]),this.l2_2.scaleInPlace(Hr[4]),this.l2_1.scaleInPlace(Hr[5]),this.l20.scaleInPlace(Hr[6]),this.l21.scaleInPlace(Hr[7]),this.l22.scaleInPlace(Hr[8])},e.prototype.convertIrradianceToLambertianRadiance=function(){this.scaleInPlace(1/Math.PI)},e.prototype.preScaleForRendering=function(){this.preScaled=!0,this.l00.scaleInPlace(zr[0]),this.l1_1.scaleInPlace(zr[1]),this.l10.scaleInPlace(zr[2]),this.l11.scaleInPlace(zr[3]),this.l2_2.scaleInPlace(zr[4]),this.l2_1.scaleInPlace(zr[5]),this.l20.scaleInPlace(zr[6]),this.l21.scaleInPlace(zr[7]),this.l22.scaleInPlace(zr[8])},e.prototype.updateFromArray=function(e){return a.e.FromArrayToRef(e[0],0,this.l00),a.e.FromArrayToRef(e[1],0,this.l1_1),a.e.FromArrayToRef(e[2],0,this.l10),a.e.FromArrayToRef(e[3],0,this.l11),a.e.FromArrayToRef(e[4],0,this.l2_2),a.e.FromArrayToRef(e[5],0,this.l2_1),a.e.FromArrayToRef(e[6],0,this.l20),a.e.FromArrayToRef(e[7],0,this.l21),a.e.FromArrayToRef(e[8],0,this.l22),this},e.prototype.updateFromFloatsArray=function(e){return a.e.FromFloatsToRef(e[0],e[1],e[2],this.l00),a.e.FromFloatsToRef(e[3],e[4],e[5],this.l1_1),a.e.FromFloatsToRef(e[6],e[7],e[8],this.l10),a.e.FromFloatsToRef(e[9],e[10],e[11],this.l11),a.e.FromFloatsToRef(e[12],e[13],e[14],this.l2_2),a.e.FromFloatsToRef(e[15],e[16],e[17],this.l2_1),a.e.FromFloatsToRef(e[18],e[19],e[20],this.l20),a.e.FromFloatsToRef(e[21],e[22],e[23],this.l21),a.e.FromFloatsToRef(e[24],e[25],e[26],this.l22),this},e.FromArray=function(t){return(new e).updateFromArray(t)},e.FromPolynomial=function(t){var n=new e;return n.l00=t.xx.scale(.376127).add(t.yy.scale(.376127)).add(t.zz.scale(.376126)),n.l1_1=t.y.scale(.977204),n.l10=t.z.scale(.977204),n.l11=t.x.scale(.977204),n.l2_2=t.xy.scale(1.16538),n.l2_1=t.yz.scale(1.16538),n.l20=t.zz.scale(1.34567).subtract(t.xx.scale(.672834)).subtract(t.yy.scale(.672834)),n.l21=t.zx.scale(1.16538),n.l22=t.xx.scale(1.16538).subtract(t.yy.scale(1.16538)),n.l1_1.scaleInPlace(-1),n.l11.scaleInPlace(-1),n.l2_1.scaleInPlace(-1),n.l21.scaleInPlace(-1),n.scaleInPlace(Math.PI),n},e}(),Yr=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=Xr.FromPolynomial(this)),this._harmonics.preScaled||this._harmonics.preScaleForRendering(),this._harmonics},enumerable:!1,configurable:!0}),e.prototype.addAmbient=function(e){a.c.Vector3[0].copyFromFloats(e.r,e.g,e.b);var t=a.c.Vector3[0];this.xx.addInPlace(t),this.yy.addInPlace(t),this.zz.addInPlace(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.prototype.updateFromHarmonics=function(e){return this._harmonics=e,this.x.copyFrom(e.l11),this.x.scaleInPlace(1.02333).scaleInPlace(-1),this.y.copyFrom(e.l1_1),this.y.scaleInPlace(1.02333).scaleInPlace(-1),this.z.copyFrom(e.l10),this.z.scaleInPlace(1.02333),this.xx.copyFrom(e.l00),a.c.Vector3[0].copyFrom(e.l20).scaleInPlace(.247708),a.c.Vector3[1].copyFrom(e.l22).scaleInPlace(.429043),this.xx.scaleInPlace(.886277).subtractInPlace(a.c.Vector3[0]).addInPlace(a.c.Vector3[1]),this.yy.copyFrom(e.l00),this.yy.scaleInPlace(.886277).subtractInPlace(a.c.Vector3[0]).subtractInPlace(a.c.Vector3[1]),this.zz.copyFrom(e.l00),a.c.Vector3[0].copyFrom(e.l20).scaleInPlace(.495417),this.zz.scaleInPlace(.886277).addInPlace(a.c.Vector3[0]),this.yz.copyFrom(e.l2_1),this.yz.scaleInPlace(.858086).scaleInPlace(-1),this.zx.copyFrom(e.l21),this.zx.scaleInPlace(.858086).scaleInPlace(-1),this.xy.copyFrom(e.l2_2),this.xy.scaleInPlace(.858086),this.scaleInPlace(1/Math.PI),this},e.FromHarmonics=function(t){return(new e).updateFromHarmonics(t)},e.FromArray=function(t){var n=new e;return a.e.FromArrayToRef(t[0],0,n.x),a.e.FromArrayToRef(t[1],0,n.y),a.e.FromArrayToRef(t[2],0,n.z),a.e.FromArrayToRef(t[3],0,n.xx),a.e.FromArrayToRef(t[4],0,n.yy),a.e.FromArrayToRef(t[5],0,n.zz),a.e.FromArrayToRef(t[6],0,n.yz),a.e.FromArrayToRef(t[7],0,n.zx),a.e.FromArrayToRef(t[8],0,n.xy),n},e}(),Kr=n(54),Qr="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";Cn.a.ShadersStore.rgbdDecodePixelShader=Qr;var qr,Zr;function Jr(e,t,n,i){void 0===i&&(i=!0);var r=e.getScene(),o=r.getEngine(),a=new ci("resized"+e.name,{width:t,height:n},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=Be.a.CLAMP_ADDRESSMODE,e.wrapV=Be.a.CLAMP_ADDRESSMODE;var s=new Fn("pass",1,null,i?Be.a.BILINEAR_SAMPLINGMODE:Be.a.NEAREST_SAMPLINGMODE,o,!1,g.a.TEXTURETYPE_UNSIGNED_INT);return s.externalTextureSamplerBinding=!0,s.getEffect().executeWhenCompiled((function(){s.onApply=function(t){t.setTexture("textureSampler",e)};var t=a.renderTarget;t&&(r.postProcessManager.directRender([s],t),o.unBindFramebuffer(t),a.disposeFramebufferObjects(),s.dispose(),a.getInternalTexture().isReady=!0)})),a}function $r(e,t,n,i,r,o){var a=t.getEngine();return t.isReady=!1,r=null!=r?r:t.samplingMode,i=null!=i?i:t.type,o=null!=o?o:t.format,-1===i&&(i=g.a.TEXTURETYPE_UNSIGNED_BYTE),new Promise((function(s){var c=new Dn("postprocess",e,null,null,1,null,r,a,!1,void 0,i,void 0,null,!1,o);c.externalTextureSamplerBinding=!0;var u=a.createRenderTargetTexture({width:t.width,height:t.height},{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:r,type:i,format:o});c.getEffect().executeWhenCompiled((function(){c.onApply=function(e){e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},n.postProcessManager.directRender([c],u,!0),a.restoreDefaultFramebuffer(),a._releaseTexture(t),c&&c.dispose(),u._swapAndDie(t),t.type=i,t.format=g.a.TEXTUREFORMAT_RGBA,t.isReady=!0,s(t)}))}))}function eo(e){qr||(qr=new Float32Array(1),Zr=new Int32Array(qr.buffer)),qr[0]=e;var t=Zr[0],n=t>>16&32768,i=t>>12&2047,r=t>>23&255;return r<103?n:r>142?(n|=31744,n|=(255==r?0:1)&&8388607&t):r<113?n|=((i|=2048)>>114-r)+(i>>113-r&1):(n|=r-112<<10|i>>1,n+=1&i)}function to(e){var t=(32768&e)>>15,n=(31744&e)>>10,i=1023&e;return 0===n?(t?-1:1)*Math.pow(2,-14)*(i/Math.pow(2,10)):31==n?i?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,n-15)*(1+i/Math.pow(2,10))}var no={CreateResizedCopy:Jr,ApplyPostProcess:$r,ToHalfFloat:eo,FromHalfFloat:to},io=function(){function e(){}return e.ExpandRGBDTexture=function(e){var t=e._texture;if(t&&e.isRGBD){var n=t.getEngine(),i=n.getCaps(),r=t.isReady,o=!1;i.textureHalfFloatRender&&i.textureHalfFloatLinearFiltering?(o=!0,t.type=g.a.TEXTURETYPE_HALF_FLOAT):i.textureFloatRender&&i.textureFloatLinearFiltering&&(o=!0,t.type=g.a.TEXTURETYPE_FLOAT),o&&(t.isReady=!1,t._isRGBD=!1,t.invertY=!1);var a=function(){if(o){var i=new Dn("rgbdDecode","rgbdDecode",null,null,1,null,g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,n,!1,void 0,t.type,void 0,null,!1);i.externalTextureSamplerBinding=!0;var r=n.createRenderTargetTexture(t.width,{generateDepthBuffer:!1,generateMipMaps:!1,generateStencilBuffer:!1,samplingMode:t.samplingMode,type:t.type,format:g.a.TEXTUREFORMAT_RGBA});i.getEffect().executeWhenCompiled((function(){i.onApply=function(e){e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},e.getScene().postProcessManager.directRender([i],r,!0),n.restoreDefaultFramebuffer(),n._releaseTexture(t),i&&i.dispose(),r._swapAndDie(t),t.isReady=!0}))}};r?a():e.onLoadObservable.addOnce(a)}},e.EncodeTextureToRGBD=function(e,t,n){return void 0===n&&(n=g.a.TEXTURETYPE_UNSIGNED_BYTE),$r("rgbdEncode",e,t,n,g.a.TEXTURE_NEAREST_SAMPLINGMODE,g.a.TEXTUREFORMAT_RGBA)},e}(),ro=function(e,t,n,i){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=n,this.worldAxisForFileY=i},oo=function(){function e(){}return e.ConvertCubeMapTextureToSphericalPolynomial=function(e){var t,n=this;if(!e.isCube)return null;null===(t=e.getScene())||void 0===t||t.getEngine().flushFramebuffer();var i,r,o=e.getSize().width,a=e.readPixels(0,void 0,void 0,!1),s=e.readPixels(1,void 0,void 0,!1);e.isRenderTarget?(i=e.readPixels(3,void 0,void 0,!1),r=e.readPixels(2,void 0,void 0,!1)):(i=e.readPixels(2,void 0,void 0,!1),r=e.readPixels(3,void 0,void 0,!1));var c=e.readPixels(4,void 0,void 0,!1),u=e.readPixels(5,void 0,void 0,!1),l=e.gammaSpace,h=g.a.TEXTUREFORMAT_RGBA,d=g.a.TEXTURETYPE_UNSIGNED_INT;return e.textureType!=g.a.TEXTURETYPE_FLOAT&&e.textureType!=g.a.TEXTURETYPE_HALF_FLOAT||(d=g.a.TEXTURETYPE_FLOAT),new Promise((function(e,t){Promise.all([s,a,i,r,c,u]).then((function(t){var i=t[0],r=t[1],a=t[2],s=t[3],c=t[4],u=t[5],p={size:o,right:r,left:i,up:a,down:s,front:c,back:u,format:h,type:d,gammaSpace:l};e(n.ConvertCubeMapToSphericalPolynomial(p))}))}))},e._AreaElement=function(e,t){return Math.atan2(e*t,Math.sqrt(e*e+t*t+1))},e.ConvertCubeMapToSphericalPolynomial=function(e){for(var t=new Xr,n=0,i=2/e.size,r=i,o=.5*i,a=o-1,c=0;c<6;c++)for(var u=this.FileFaces[c],l=e[u.name],h=a,d=e.format===g.a.TEXTUREFORMAT_RGBA?4:3,p=0;p2)throw new Error('Unsupported babylon environment map version "'.concat(e.version,'". Latest supported version is "').concat(2,'".'));return 2===e.version?e:e=Object(h.a)(Object(h.a)({},e),{version:2,imageType:"image/png"})}function lo(e,t){var n;return void 0===t&&(t={}),Object(h.b)(this,void 0,void 0,(function(){var i,r,o,a,s,c,u,l,d,p,f,_,m,v,b,y,T,E,S,A,x,R,C,P,O,M,I,D,N,F;return Object(h.e)(this,(function(h){switch(h.label){case 0:if(!(i=e.getInternalTexture()))return[2,Promise.reject("The cube texture is invalid.")];if(r=null!==(n=t.imageType)&&void 0!==n?n:"image/png",o=i.getEngine(),e.textureType!==g.a.TEXTURETYPE_HALF_FLOAT&&e.textureType!==g.a.TEXTURETYPE_FLOAT&&e.textureType!==g.a.TEXTURETYPE_UNSIGNED_BYTE&&e.textureType!==g.a.TEXTURETYPE_UNSIGNED_INT&&e.textureType!==g.a.TEXTURETYPE_UNSIGNED_INTEGER&&-1!==e.textureType)return[2,Promise.reject("The cube texture should allow HDR (Full Float or Half Float).")];if(a=g.a.TEXTURETYPE_FLOAT,!o.getCaps().textureFloatRender&&(a=g.a.TEXTURETYPE_HALF_FLOAT,!o.getCaps().textureHalfFloatRender))return[2,Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.")];s=i.width,c=new Q.a(o),u={},o.flushFramebuffer(),l=L.a.ILog2(i.width),D=0,h.label=1;case 1:if(!(D<=l))return[3,9];d=Math.pow(2,l-D),N=0,h.label=2;case 2:return N<6?[4,e.readPixels(N,D,void 0,!1)]:[3,8];case 3:if((p=h.sent())&&p.byteLength===p.length){for(f=new Float32Array(4*p.byteLength),_=0;_=48&&t<=57||t>=65&&t<=90||t>=97&&t<=122||95==t}function So(e){for(var t=0,n="",i=!1,r=[];t=0&&e.charAt(t)!==n;)t--;return t}var xo,Ro=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=".concat(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=0&&f.push(m.substring(g+1))}"void"!==a&&f.push("return"),this._functionDescr.push({name:s,type:a,parameters:f,body:d,callIndex:0}),t=h+1;var v=n>0?this._sourceCode.substring(0,n):"",b=h+1=0},e.prototype._replaceFunctionCallsByCode=function(){for(var e=!1,t=0,n=this._functionDescr;t0?this._sourceCode.substring(0,u):"",y=h+1=0){var s=t[r[o]];if(s){var c=s.getBuffer();c&&this._engine.recordVertexBuffer(e,c.nativeVertexBuffer,a,s.byteOffset,s.byteStride,s.getSize(),this._getNativeAttribType(s.type),s.normalized,s.getInstanceDivisor())}}}},t.prototype.bindBuffers=function(e,t,n){this._boundBuffersVertexArray&&this._deleteVertexArray(this._boundBuffersVertexArray),this._boundBuffersVertexArray=this._engine.createVertexArray(),this._recordVertexArrayObject(this._boundBuffersVertexArray,e,t,n),this.bindVertexArrayObject(this._boundBuffersVertexArray)},t.prototype.recordVertexArrayObject=function(e,t,n){var i=this._engine.createVertexArray();return this._recordVertexArrayObject(i,e,t,n),i},t.prototype._deleteVertexArray=function(e){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.bindVertexArrayObject=function(e){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_BINDVERTEXARRAY),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.releaseVertexArrayObject=function(e){this._deleteVertexArray(e)},t.prototype.getAttributes=function(e,t){var n=e;return this._engine.getAttributes(n.nativeProgram,t)},t.prototype.drawElementsType=function(e,t,n,i){this._drawCalls.addCount(1,!1),this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAWINDEXED),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.drawArraysType=function(e,t,n,i){this._drawCalls.addCount(1,!1),this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DRAW),this._commandBufferEncoder.encodeCommandArgAsUInt32(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.finishEncodingCommand()},t.prototype.createPipelineContext=function(){return new Do(this)},t.prototype.createMaterialContext=function(){},t.prototype.createDrawContext=function(){},t.prototype._preparePipelineContext=function(e,t,n,i,r,o,a,s,c){var u=e;u.nativeProgram=i?this.createRawShaderProgram(e,t,n,void 0,c):this.createShaderProgram(e,t,n,s,void 0,c)},t.prototype._isRenderingStateCompiled=function(e){return!0},t.prototype._executeWhenRenderingStateIsCompiled=function(e,t){t()},t.prototype.createRawShaderProgram=function(e,t,n,i,r){throw void 0===r&&(r=null),new Error("Not Supported")},t.prototype.createShaderProgram=function(e,t,n,i,r,o){void 0===o&&(o=null),this.onBeforeShaderCompilationObservable.notifyObservers(this);var a=new Ro(t);a.processCode(),t=a.code;var s=new Ro(n);s.processCode(),n=s.code,t=Ve.a._ConcatenateShader(t,i),n=Ve.a._ConcatenateShader(n,i);var c=this._engine.createProgram(t,n);return this.onAfterShaderCompilationObservable.notifyObservers(this),c},t.prototype.inlineShaderCode=function(e){var t=new Ro(e);return t.debug=!1,t.processCode(),t.code},t.prototype._setProgram=function(e){this._currentProgram!==e&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETPROGRAM),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.finishEncodingCommand(),this._currentProgram=e)},t.prototype._deletePipelineContext=function(e){var t=e;t&&t.nativeProgram&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEPROGRAM),this._commandBufferEncoder.encodeCommandArgAsNativeData(t.nativeProgram),this._commandBufferEncoder.finishEncodingCommand())},t.prototype.getUniforms=function(e,t){var n=e;return this._engine.getUniforms(n.nativeProgram,t)},t.prototype.bindUniformBlock=function(e,t,n){throw new Error("Not Implemented")},t.prototype.bindSamplers=function(e){var t=e.getPipelineContext();this._setProgram(t.nativeProgram);for(var n=e.getSamplers(),i=0;i-1?e.substring(E).toLowerCase():""),A=null,x=0,R=xe.a._TextureLoaders;x-1?e.substring(m).toLowerCase():""))){if(n&&6===n.length)throw new Error("Multi-file loading not allowed on env files.");this._loadFile(e,(function(e){return function(e){var t=co(e);_.width=t.width,_.height=t.width,go(_,t);var n=t.specular;if(!n)throw new Error("Nothing else parsed so far");_._lodGenerationScale=n.lodGenerationScale;var i=po(e,t);_.format=g.a.TEXTUREFORMAT_RGBA,_.type=g.a.TEXTURETYPE_UNSIGNED_INT,_.generateMipMaps=!0,_.getEngine().updateTextureSamplingMode(Be.a.TRILINEAR_SAMPLINGMODE,_),_._isRGBD=!0,_.invertY=!0,f._engine.loadCubeTextureWithMips(_._hardwareTexture.underlyingResource,i,!1,p,(function(){_.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(!n||6!==n.length)throw new Error("Cannot load cubemap because 6 files were not defined");var v=[n[0],n[3],n[1],n[4],n[2],n[5]];Promise.all(v.map((function(e){return Re.b.LoadFileAsync(e).then((function(e){return new Uint8Array(e)}))}))).then((function(e){return new Promise((function(t,n){f._engine.loadCubeTexture(_._hardwareTexture.underlyingResource,e,!i,!0,p,t,n)}))})).then((function(){_.isReady=!0,r&&r()}),(function(e){o&&o("Failed to load cubemap: ".concat(e.message),e)}))}return this._internalTexturesCache.push(_),_},t.prototype._createHardwareRenderTargetWrapper=function(e,t,n){var i=new No(e,t,n,this);return this._renderTargetWrapperCache.push(i),i},t.prototype.createRenderTargetTexture=function(e,t){var n=this._createHardwareRenderTargetWrapper(!1,!1,e),i={};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 r=new Ue.a(this,Ue.b.RenderTarget),o=e.width||e,a=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 s=this._engine.createFrameBuffer(r._hardwareTexture.underlyingResource,o,a,this._getNativeTextureFormat(i.format,i.type),!!i.generateStencilBuffer,i.generateDepthBuffer,!!i.generateMipMaps);return n._framebuffer=s,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,r.baseWidth=o,r.baseHeight=a,r.width=o,r.height=a,r.isReady=!0,r.samples=1,r.generateMipMaps=!!i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,this._internalTexturesCache.push(r),n.setTextures(r),n},t.prototype.updateTextureSamplingMode=function(e,t){if(t._hardwareTexture){var n=this._getNativeSamplingMode(e);this._setTextureSampling(t._hardwareTexture.underlyingResource,n)}t.samplingMode=e},t.prototype.bindFramebuffer=function(e,t,n,i,r){var o=e;if(t)throw new Error("Cuboid frame buffers are not yet supported in NativeEngine.");if(n||i)throw new Error("Required width/height for frame buffers not yet supported in NativeEngine.");o._framebufferDepthStencil?this._bindUnboundFramebuffer(o._framebufferDepthStencil):this._bindUnboundFramebuffer(o._framebuffer)},t.prototype.unBindFramebuffer=function(e,t,n){void 0===t&&(t=!1),n&&n(),this._bindUnboundFramebuffer(null)},t.prototype.createDynamicVertexBuffer=function(e){return this.createVertexBuffer(e,!0)},t.prototype.updateDynamicIndexBuffer=function(e,t,n){void 0===n&&(n=0);var i=e,r=this._normalizeIndexData(t);i.is32Bits=4===r.BYTES_PER_ELEMENT,this._engine.updateDynamicIndexBuffer(i.nativeIndexBuffer,r.buffer,r.byteOffset,r.byteLength,n)},t.prototype.updateDynamicVertexBuffer=function(e,t,n,i){var r=e,o=ArrayBuffer.isView(t)?t:new Float32Array(t);this._engine.updateDynamicVertexBuffer(r.nativeVertexBuffer,o.buffer,o.byteOffset+(null!=n?n:0),null!=i?i:o.byteLength)},t.prototype._setTexture=function(e,t,n,i){void 0===n&&(n=!1),void 0===i&&(i=!1);var r,o=this._boundUniforms[e];if(!o)return!1;if(!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._setTextureCore(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=i?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._hardwareTexture)&&(this._setTextureWrapMode(r._hardwareTexture.underlyingResource,this._getAddressMode(t.wrapU),this._getAddressMode(t.wrapV),this._getAddressMode(t.wrapR)),this._updateAnisotropicLevel(t),this._setTextureCore(o,r._hardwareTexture.underlyingResource),!0)},t.prototype._setTextureSampling=function(e,t){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURESAMPLING),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._setTextureWrapMode=function(e,t,n,i){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREWRAPMODE),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsUInt32(t),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.encodeCommandArgAsUInt32(i),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._setTextureCore=function(e,t){this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTURE),this._commandBufferEncoder.encodeCommandArgAsNativeData(e),this._commandBufferEncoder.encodeCommandArgAsNativeData(t),this._commandBufferEncoder.finishEncodingCommand()},t.prototype._updateAnisotropicLevel=function(e){var t=e.getInternalTexture(),n=e.anisotropicFilteringLevel;t&&t._hardwareTexture&&t._cachedAnisotropicFilteringLevel!==n&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_SETTEXTUREANISOTROPICLEVEL),this._commandBufferEncoder.encodeCommandArgAsNativeData(t._hardwareTexture.underlyingResource),this._commandBufferEncoder.encodeCommandArgAsUInt32(n),this._commandBufferEncoder.finishEncodingCommand(),t._cachedAnisotropicFilteringLevel=n)},t.prototype._getAddressMode=function(e){switch(e){case g.a.TEXTURE_WRAP_ADDRESSMODE:return _native.Engine.ADDRESS_MODE_WRAP;case g.a.TEXTURE_CLAMP_ADDRESSMODE:return _native.Engine.ADDRESS_MODE_CLAMP;case g.a.TEXTURE_MIRROR_ADDRESSMODE:return _native.Engine.ADDRESS_MODE_MIRROR;default:throw new Error("Unexpected wrap mode: "+e+".")}},t.prototype._bindTexture=function(e,t){var n=this._boundUniforms[e];if(n&&t&&t._hardwareTexture){var i=t._hardwareTexture.underlyingResource;this._setTextureCore(n,i)}},t.prototype._deleteBuffer=function(e){e.nativeIndexBuffer&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEINDEXBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeIndexBuffer),this._commandBufferEncoder.finishEncodingCommand(),delete e.nativeIndexBuffer),e.nativeVertexBuffer&&(this._commandBufferEncoder.startEncodingCommand(_native.Engine.COMMAND_DELETEVERTEXBUFFER),this._commandBufferEncoder.encodeCommandArgAsNativeData(e.nativeVertexBuffer),this._commandBufferEncoder.finishEncodingCommand(),delete e.nativeVertexBuffer)},t.prototype.createCanvas=function(e,t){if(!_native.Canvas)throw new Error("Native Canvas plugin not available.");var n=new _native.Canvas;return n.width=e,n.height=t,n},t.prototype.createCanvasImage=function(){if(!_native.Canvas)throw new Error("Native Canvas plugin not available.");return new _native.Image},t.prototype._uploadCompressedDataToTextureDirectly=function(e,t,n,i,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,n,i){throw void 0===n&&(n=0),void 0===i&&(i=0),new Error("_uploadDataToTextureDirectly not implemented.")},t.prototype._uploadArrayBufferViewToTexture=function(e,t,n,i){throw void 0===n&&(n=0),void 0===i&&(i=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._uploadImageToTexture=function(e,t,n,i){throw void 0===n&&(n=0),void 0===i&&(i=0),new Error("_uploadArrayBufferViewToTexture not implemented.")},t.prototype._getNativeSamplingMode=function(e){switch(e){case g.a.TEXTURE_NEAREST_NEAREST:return _native.Engine.TEXTURE_NEAREST_NEAREST;case g.a.TEXTURE_LINEAR_LINEAR:return _native.Engine.TEXTURE_LINEAR_LINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST;case g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:return _native.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR;case g.a.TEXTURE_NEAREST_LINEAR:return _native.Engine.TEXTURE_NEAREST_LINEAR;case g.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:return _native.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:return _native.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR;case g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:return _native.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST;case g.a.TEXTURE_LINEAR_NEAREST:return _native.Engine.TEXTURE_LINEAR_NEAREST;default:throw new Error("Unsupported sampling mode: ".concat(e,"."))}},t.prototype._getStencilFunc=function(e){switch(e){case g.a.LESS:return _native.Engine.STENCIL_TEST_LESS;case g.a.LEQUAL:return _native.Engine.STENCIL_TEST_LEQUAL;case g.a.EQUAL:return _native.Engine.STENCIL_TEST_EQUAL;case g.a.GEQUAL:return _native.Engine.STENCIL_TEST_GEQUAL;case g.a.GREATER:return _native.Engine.STENCIL_TEST_GREATER;case g.a.NOTEQUAL:return _native.Engine.STENCIL_TEST_NOTEQUAL;case g.a.NEVER:return _native.Engine.STENCIL_TEST_NEVER;case g.a.ALWAYS:return _native.Engine.STENCIL_TEST_ALWAYS;default:throw new Error("Unsupported stencil func mode: ".concat(e,"."))}},t.prototype._getStencilOpFail=function(e){switch(e){case g.a.KEEP:return _native.Engine.STENCIL_OP_FAIL_S_KEEP;case g.a.ZERO:return _native.Engine.STENCIL_OP_FAIL_S_ZERO;case g.a.REPLACE:return _native.Engine.STENCIL_OP_FAIL_S_REPLACE;case g.a.INCR:return _native.Engine.STENCIL_OP_FAIL_S_INCR;case g.a.DECR:return _native.Engine.STENCIL_OP_FAIL_S_DECR;case g.a.INVERT:return _native.Engine.STENCIL_OP_FAIL_S_INVERT;case g.a.INCR_WRAP:return _native.Engine.STENCIL_OP_FAIL_S_INCRSAT;case g.a.DECR_WRAP:return _native.Engine.STENCIL_OP_FAIL_S_DECRSAT;default:throw new Error("Unsupported stencil OpFail mode: ".concat(e,"."))}},t.prototype._getStencilDepthFail=function(e){switch(e){case g.a.KEEP:return _native.Engine.STENCIL_OP_FAIL_Z_KEEP;case g.a.ZERO:return _native.Engine.STENCIL_OP_FAIL_Z_ZERO;case g.a.REPLACE:return _native.Engine.STENCIL_OP_FAIL_Z_REPLACE;case g.a.INCR:return _native.Engine.STENCIL_OP_FAIL_Z_INCR;case g.a.DECR:return _native.Engine.STENCIL_OP_FAIL_Z_DECR;case g.a.INVERT:return _native.Engine.STENCIL_OP_FAIL_Z_INVERT;case g.a.INCR_WRAP:return _native.Engine.STENCIL_OP_FAIL_Z_INCRSAT;case g.a.DECR_WRAP:return _native.Engine.STENCIL_OP_FAIL_Z_DECRSAT;default:throw new Error("Unsupported stencil depthFail mode: ".concat(e,"."))}},t.prototype._getStencilDepthPass=function(e){switch(e){case g.a.KEEP:return _native.Engine.STENCIL_OP_PASS_Z_KEEP;case g.a.ZERO:return _native.Engine.STENCIL_OP_PASS_Z_ZERO;case g.a.REPLACE:return _native.Engine.STENCIL_OP_PASS_Z_REPLACE;case g.a.INCR:return _native.Engine.STENCIL_OP_PASS_Z_INCR;case g.a.DECR:return _native.Engine.STENCIL_OP_PASS_Z_DECR;case g.a.INVERT:return _native.Engine.STENCIL_OP_PASS_Z_INVERT;case g.a.INCR_WRAP:return _native.Engine.STENCIL_OP_PASS_Z_INCRSAT;case g.a.DECR_WRAP:return _native.Engine.STENCIL_OP_PASS_Z_DECRSAT;default:throw new Error("Unsupported stencil opPass mode: ".concat(e,"."))}},t.prototype._getNativeTextureFormat=function(e,t){if(e==g.a.TEXTUREFORMAT_RGB&&t==g.a.TEXTURETYPE_UNSIGNED_INT)return _native.Engine.TEXTURE_FORMAT_RGB8;if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_UNSIGNED_INT)return _native.Engine.TEXTURE_FORMAT_RGBA8;if(e==g.a.TEXTUREFORMAT_RGBA&&t==g.a.TEXTURETYPE_FLOAT)return _native.Engine.TEXTURE_FORMAT_RGBA32F;throw new Po.c("Unsupported texture format or type: format ".concat(e,", type ").concat(t,"."),Po.b.UnsupportedTextureError)},t.prototype._getNativeAlphaMode=function(e){switch(e){case g.a.ALPHA_DISABLE:return _native.Engine.ALPHA_DISABLE;case g.a.ALPHA_ADD:return _native.Engine.ALPHA_ADD;case g.a.ALPHA_COMBINE:return _native.Engine.ALPHA_COMBINE;case g.a.ALPHA_SUBTRACT:return _native.Engine.ALPHA_SUBTRACT;case g.a.ALPHA_MULTIPLY:return _native.Engine.ALPHA_MULTIPLY;case g.a.ALPHA_MAXIMIZED:return _native.Engine.ALPHA_MAXIMIZED;case g.a.ALPHA_ONEONE:return _native.Engine.ALPHA_ONEONE;case g.a.ALPHA_PREMULTIPLIED:return _native.Engine.ALPHA_PREMULTIPLIED;case g.a.ALPHA_PREMULTIPLIED_PORTERDUFF:return _native.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF;case g.a.ALPHA_INTERPOLATE:return _native.Engine.ALPHA_INTERPOLATE;case g.a.ALPHA_SCREENMODE:return _native.Engine.ALPHA_SCREENMODE;default:throw new Error("Unsupported alpha mode: ".concat(e,"."))}},t.prototype._getNativeAttribType=function(e){switch(e){case bt.b.BYTE:return _native.Engine.ATTRIB_TYPE_INT8;case bt.b.UNSIGNED_BYTE:return _native.Engine.ATTRIB_TYPE_UINT8;case bt.b.SHORT:return _native.Engine.ATTRIB_TYPE_INT16;case bt.b.UNSIGNED_SHORT:return _native.Engine.ATTRIB_TYPE_UINT16;case bt.b.FLOAT:return _native.Engine.ATTRIB_TYPE_FLOAT;default:throw new Error("Unsupported attribute type: ".concat(e,"."))}},t.prototype.getFontOffset=function(e){return{ascent:0,height:0,descent:0}},t.PROTOCOL_VERSION=4,t}(xe.a);wo._createNativeDataStream=function(){return _native.NativeDataStream.VALIDATION_ENABLED?new ba:new Vr};var Bo,Uo,Vo,ko,Go,zo,jo,Wo,Ho,Xo,Yo,Ko,Qo,qo,Zo,Jo,$o,ea,ta,na,ia,ra,oa,aa,sa,ca,ua,la,ha,da,pa,fa,_a,ma,ga,va,ba=function(e){function t(){return e.call(this)||this}return Object(h.d)(t,e),t.prototype.writeUint32=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_UINT_32),e.prototype.writeUint32.call(this,t)},t.prototype.writeInt32=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_INT_32),e.prototype.writeInt32.call(this,t)},t.prototype.writeFloat32=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_FLOAT_32),e.prototype.writeFloat32.call(this,t)},t.prototype.writeUint32Array=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_UINT_32_ARRAY),e.prototype.writeUint32Array.call(this,t)},t.prototype.writeInt32Array=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_INT_32_ARRAY),e.prototype.writeInt32Array.call(this,t)},t.prototype.writeFloat32Array=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_FLOAT_32_ARRAY),e.prototype.writeFloat32Array.call(this,t)},t.prototype.writeNativeData=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_NATIVE_DATA),e.prototype.writeNativeData.call(this,t)},t.prototype.writeBoolean=function(t){e.prototype.writeUint32.call(this,_native.NativeDataStream.VALIDATION_BOOLEAN),e.prototype.writeBoolean.call(this,t)},t}(Vr),ya=n(38);!function(e){e.SRGB="srgb"}(Bo||(Bo={})),function(e){e.LowPower="low-power",e.HighPerformance="high-performance"}(Bo||(Bo={})),function(e){e.DepthClipControl="depth-clip-control",e.Depth24UnormStencil8="depth24unorm-stencil8",e.Depth32FloatStencil8="depth32float-stencil8",e.TextureCompressionBC="texture-compression-bc",e.TextureCompressionETC2="texture-compression-etc2",e.TextureCompressionASTC="texture-compression-astc",e.TimestampQuery="timestamp-query",e.IndirectFirstInstance="indirect-first-instance"}(Uo||(Uo={})),function(e){e[e.MapRead=1]="MapRead",e[e.MapWrite=2]="MapWrite",e[e.CopySrc=4]="CopySrc",e[e.CopyDst=8]="CopyDst",e[e.Index=16]="Index",e[e.Vertex=32]="Vertex",e[e.Uniform=64]="Uniform",e[e.Storage=128]="Storage",e[e.Indirect=256]="Indirect",e[e.QueryResolve=512]="QueryResolve"}(Vo||(Vo={})),function(e){e[e.Read=1]="Read",e[e.Write=2]="Write"}(ko||(ko={})),function(e){e.E1d="1d",e.E2d="2d",e.E3d="3d"}(Go||(Go={})),function(e){e[e.CopySrc=1]="CopySrc",e[e.CopyDst=2]="CopyDst",e[e.TextureBinding=4]="TextureBinding",e[e.StorageBinding=8]="StorageBinding",e[e.RenderAttachment=16]="RenderAttachment"}(zo||(zo={})),function(e){e.E1d="1d",e.E2d="2d",e.E2dArray="2d-array",e.Cube="cube",e.CubeArray="cube-array",e.E3d="3d"}(jo||(jo={})),function(e){e.All="all",e.StencilOnly="stencil-only",e.DepthOnly="depth-only"}(Wo||(Wo={})),function(e){e.R8Unorm="r8unorm",e.R8Snorm="r8snorm",e.R8Uint="r8uint",e.R8Sint="r8sint",e.R16Uint="r16uint",e.R16Sint="r16sint",e.R16Float="r16float",e.RG8Unorm="rg8unorm",e.RG8Snorm="rg8snorm",e.RG8Uint="rg8uint",e.RG8Sint="rg8sint",e.R32Uint="r32uint",e.R32Sint="r32sint",e.R32Float="r32float",e.RG16Uint="rg16uint",e.RG16Sint="rg16sint",e.RG16Float="rg16float",e.RGBA8Unorm="rgba8unorm",e.RGBA8UnormSRGB="rgba8unorm-srgb",e.RGBA8Snorm="rgba8snorm",e.RGBA8Uint="rgba8uint",e.RGBA8Sint="rgba8sint",e.BGRA8Unorm="bgra8unorm",e.BGRA8UnormSRGB="bgra8unorm-srgb",e.RGB9E5UFloat="rgb9e5ufloat",e.RGB10A2Unorm="rgb10a2unorm",e.RG11B10UFloat="rg11b10ufloat",e.RG32Uint="rg32uint",e.RG32Sint="rg32sint",e.RG32Float="rg32float",e.RGBA16Uint="rgba16uint",e.RGBA16Sint="rgba16sint",e.RGBA16Float="rgba16float",e.RGBA32Uint="rgba32uint",e.RGBA32Sint="rgba32sint",e.RGBA32Float="rgba32float",e.Stencil8="stencil8",e.Depth16Unorm="depth16unorm",e.Depth24Plus="depth24plus",e.Depth24PlusStencil8="depth24plus-stencil8",e.Depth32Float="depth32float",e.BC1RGBAUnorm="bc1-rgba-unorm",e.BC1RGBAUnormSRGB="bc1-rgba-unorm-srgb",e.BC2RGBAUnorm="bc2-rgba-unorm",e.BC2RGBAUnormSRGB="bc2-rgba-unorm-srgb",e.BC3RGBAUnorm="bc3-rgba-unorm",e.BC3RGBAUnormSRGB="bc3-rgba-unorm-srgb",e.BC4RUnorm="bc4-r-unorm",e.BC4RSnorm="bc4-r-snorm",e.BC5RGUnorm="bc5-rg-unorm",e.BC5RGSnorm="bc5-rg-snorm",e.BC6HRGBUFloat="bc6h-rgb-ufloat",e.BC6HRGBFloat="bc6h-rgb-float",e.BC7RGBAUnorm="bc7-rgba-unorm",e.BC7RGBAUnormSRGB="bc7-rgba-unorm-srgb",e.ETC2RGB8Unorm="etc2-rgb8unorm",e.ETC2RGB8UnormSRGB="etc2-rgb8unorm-srgb",e.ETC2RGB8A1Unorm="etc2-rgb8a1unorm",e.ETC2RGB8A1UnormSRGB="etc2-rgb8a1unorm-srgb",e.ETC2RGBA8Unorm="etc2-rgba8unorm",e.ETC2RGBA8UnormSRGB="etc2-rgba8unorm-srgb",e.EACR11Unorm="eac-r11unorm",e.EACR11Snorm="eac-r11snorm",e.EACRG11Unorm="eac-rg11unorm",e.EACRG11Snorm="eac-rg11snorm",e.ASTC4x4Unorm="astc-4x4-unorm",e.ASTC4x4UnormSRGB="astc-4x4-unorm-srgb",e.ASTC5x4Unorm="astc-5x4-unorm",e.ASTC5x4UnormSRGB="astc-5x4-unorm-srgb",e.ASTC5x5Unorm="astc-5x5-unorm",e.ASTC5x5UnormSRGB="astc-5x5-unorm-srgb",e.ASTC6x5Unorm="astc-6x5-unorm",e.ASTC6x5UnormSRGB="astc-6x5-unorm-srgb",e.ASTC6x6Unorm="astc-6x6-unorm",e.ASTC6x6UnormSRGB="astc-6x6-unorm-srgb",e.ASTC8x5Unorm="astc-8x5-unorm",e.ASTC8x5UnormSRGB="astc-8x5-unorm-srgb",e.ASTC8x6Unorm="astc-8x6-unorm",e.ASTC8x6UnormSRGB="astc-8x6-unorm-srgb",e.ASTC8x8Unorm="astc-8x8-unorm",e.ASTC8x8UnormSRGB="astc-8x8-unorm-srgb",e.ASTC10x5Unorm="astc-10x5-unorm",e.ASTC10x5UnormSRGB="astc-10x5-unorm-srgb",e.ASTC10x6Unorm="astc-10x6-unorm",e.ASTC10x6UnormSRGB="astc-10x6-unorm-srgb",e.ASTC10x8Unorm="astc-10x8-unorm",e.ASTC10x8UnormSRGB="astc-10x8-unorm-srgb",e.ASTC10x10Unorm="astc-10x10-unorm",e.ASTC10x10UnormSRGB="astc-10x10-unorm-srgb",e.ASTC12x10Unorm="astc-12x10-unorm",e.ASTC12x10UnormSRGB="astc-12x10-unorm-srgb",e.ASTC12x12Unorm="astc-12x12-unorm",e.ASTC12x12UnormSRGB="astc-12x12-unorm-srgb",e.Depth24UnormStencil8="depth24unorm-stencil8",e.Depth32FloatStencil8="depth32float-stencil8"}(Ho||(Ho={})),function(e){e.ClampToEdge="clamp-to-edge",e.Repeat="repeat",e.MirrorRepeat="mirror-repeat"}(Xo||(Xo={})),function(e){e.Nearest="nearest",e.Linear="linear"}(Yo||(Yo={})),function(e){e.Never="never",e.Less="less",e.Equal="equal",e.LessEqual="less-equal",e.Greater="greater",e.NotEqual="not-equal",e.GreaterEqual="greater-equal",e.Always="always"}(Ko||(Ko={})),function(e){e[e.Vertex=1]="Vertex",e[e.Fragment=2]="Fragment",e[e.Compute=4]="Compute"}(Qo||(Qo={})),function(e){e.Uniform="uniform",e.Storage="storage",e.ReadOnlyStorage="read-only-storage"}(qo||(qo={})),function(e){e.Filtering="filtering",e.NonFiltering="non-filtering",e.Comparison="comparison"}(Zo||(Zo={})),function(e){e.Float="float",e.UnfilterableFloat="unfilterable-float",e.Depth="depth",e.Sint="sint",e.Uint="uint"}(Jo||(Jo={})),function(e){e.WriteOnly="write-only"}($o||($o={})),function(e){e.Error="error",e.Warning="warning",e.Info="info"}(ea||(ea={})),function(e){e.PointList="point-list",e.LineList="line-list",e.LineStrip="line-strip",e.TriangleList="triangle-list",e.TriangleStrip="triangle-strip"}(ta||(ta={})),function(e){e.CCW="ccw",e.CW="cw"}(na||(na={})),function(e){e.None="none",e.Front="front",e.Back="back"}(ia||(ia={})),function(e){e[e.Red=1]="Red",e[e.Green=2]="Green",e[e.Blue=4]="Blue",e[e.Alpha=8]="Alpha",e[e.All=15]="All"}(ra||(ra={})),function(e){e.Zero="zero",e.One="one",e.Src="src",e.OneMinusSrc="one-minus-src",e.SrcAlpha="src-alpha",e.OneMinusSrcAlpha="one-minus-src-alpha",e.Dst="dst",e.OneMinusDst="one-minus-dst",e.DstAlpha="dst-alpha",e.OneMinusDstAlpha="one-minus-dst-alpha",e.SrcAlphaSaturated="src-alpha-saturated",e.Constant="constant",e.OneMinusConstant="one-minus-constant"}(oa||(oa={})),function(e){e.Add="add",e.Subtract="subtract",e.ReverseSubtract="reverse-subtract",e.Min="min",e.Max="max"}(aa||(aa={})),function(e){e.Keep="keep",e.Zero="zero",e.Replace="replace",e.Invert="invert",e.IncrementClamp="increment-clamp",e.DecrementClamp="decrement-clamp",e.IncrementWrap="increment-wrap",e.DecrementWrap="decrement-wrap"}(sa||(sa={})),function(e){e.Uint16="uint16",e.Uint32="uint32"}(ca||(ca={})),function(e){e.Uint8x2="uint8x2",e.Uint8x4="uint8x4",e.Sint8x2="sint8x2",e.Sint8x4="sint8x4",e.Unorm8x2="unorm8x2",e.Unorm8x4="unorm8x4",e.Snorm8x2="snorm8x2",e.Snorm8x4="snorm8x4",e.Uint16x2="uint16x2",e.Uint16x4="uint16x4",e.Sint16x2="sint16x2",e.Sint16x4="sint16x4",e.Unorm16x2="unorm16x2",e.Unorm16x4="unorm16x4",e.Snorm16x2="snorm16x2",e.Snorm16x4="snorm16x4",e.Float16x2="float16x2",e.Float16x4="float16x4",e.Float32="float32",e.Float32x2="float32x2",e.Float32x3="float32x3",e.Float32x4="float32x4",e.Uint32="uint32",e.Uint32x2="uint32x2",e.Uint32x3="uint32x3",e.Uint32x4="uint32x4",e.Sint32="sint32",e.Sint32x2="sint32x2",e.Sint32x3="sint32x3",e.Sint32x4="sint32x4"}(ua||(ua={})),function(e){e.Vertex="vertex",e.Instance="instance"}(la||(la={})),function(e){e.Beginning="beginning",e.End="end"}(ha||(ha={})),function(e){e.Beginning="beginning",e.End="end"}(da||(da={})),function(e){e.Load="load",e.Clear="clear"}(pa||(pa={})),function(e){e.Store="store",e.Discard="discard"}(fa||(fa={})),function(e){e.Occlusion="occlusion",e.Timestamp="timestamp"}(_a||(_a={})),function(e){e.Opaque="opaque",e.Premultiplied="premultiplied"}(ma||(ma={})),function(e){e.Destroyed="destroyed"}(ga||(ga={})),function(e){e.OutOfMemory="out-of-memory",e.Validation="validation"}(va||(va={}));var Ta=function(){function e(){this.shaderLanguage=fr.a.GLSL}return e.prototype._addUniformToLeftOverUBO=function(e,t,n){var i,r;e=(i=this._getArraySize(e,t,n))[0],t=i[1],r=i[2];for(var o=0;o=0){for(;r++=0&&(m.push(a[u]),g.push(v))}this.shaderProcessingContext.attributeNamesFromEffect=m,this.shaderProcessingContext.attributeLocationsFromEffect=g},e.prototype.buildUniformLayout=function(){if(this.shaderProcessingContext.leftOverUniforms.length){this.uniformBuffer=new oi.a(this.engine,void 0,void 0,"leftOver-"+this._name);for(var e=0,t=this.shaderProcessingContext.leftOverUniforms;e)?$/,"$1"),r=Ta.UniformSizes[i];this.uniformBuffer.addUniform(n.name,r,n.length),this._leftOverUniformsByName[n.name]=n.type}this.uniformBuffer.create()}},e.prototype.dispose=function(){this.uniformBuffer&&this.uniformBuffer.dispose()},e.prototype.setInt=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt(e,t)},e.prototype.setInt2=function(e,t,n){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt2(e,t,n)},e.prototype.setInt3=function(e,t,n,i){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt3(e,t,n,i)},e.prototype.setInt4=function(e,t,n,i,r){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateInt4(e,t,n,i,r)},e.prototype.setIntArray=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateIntArray(e,t)},e.prototype.setIntArray2=function(e,t){this.setIntArray(e,t)},e.prototype.setIntArray3=function(e,t){this.setIntArray(e,t)},e.prototype.setIntArray4=function(e,t){this.setIntArray(e,t)},e.prototype.setArray=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateArray(e,t)},e.prototype.setArray2=function(e,t){this.setArray(e,t)},e.prototype.setArray3=function(e,t){this.setArray(e,t)},e.prototype.setArray4=function(e,t){this.setArray(e,t)},e.prototype.setMatrices=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrices(e,t)},e.prototype.setMatrix=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrix(e,t)},e.prototype.setMatrix3x3=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrix3x3(e,t)},e.prototype.setMatrix2x2=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateMatrix2x2(e,t)},e.prototype.setFloat=function(e,t){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat(e,t)},e.prototype.setVector2=function(e,t){this.setFloat2(e,t.x,t.y)},e.prototype.setFloat2=function(e,t,n){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat2(e,t,n)},e.prototype.setVector3=function(e,t){this.setFloat3(e,t.x,t.y,t.z)},e.prototype.setFloat3=function(e,t,n,i){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat3(e,t,n,i)},e.prototype.setVector4=function(e,t){this.setFloat4(e,t.x,t.y,t.z,t.w)},e.prototype.setFloat4=function(e,t,n,i,r){this.uniformBuffer&&this._leftOverUniformsByName[e]&&this.uniformBuffer.updateFloat4(e,t,n,i,r)},e.prototype.setColor3=function(e,t){this.setFloat3(e,t.r,t.g,t.b)},e.prototype.setColor4=function(e,t,n){this.setFloat4(e,t.r,t.g,t.b,n)},e.prototype.setDirectColor4=function(e,t){this.setFloat4(e,t.r,t.g,t.b,t.a)},e.prototype._getVertexShaderCode=function(){var e;return null===(e=this.sources)||void 0===e?void 0:e.vertex},e.prototype._getFragmentShaderCode=function(){var e;return null===(e=this.sources)||void 0===e?void 0:e.fragment},e}(),Sa={mat2:2,mat3:3,mat4:4,mat2x2:2,mat3x3:3,mat4x4:4},Aa=function(){function e(e){this.shaderLanguage=e,this._attributeNextLocation=0,this._varyingNextLocation=0,this.freeGroupIndex=0,this.freeBindingIndex=0,this.availableVaryings={},this.availableAttributes={},this.availableBuffers={},this.availableTextures={},this.availableSamplers={},this.orderedAttributes=[],this.bindGroupLayoutEntries=[],this.bindGroupLayoutEntryInfo=[],this.bindGroupEntries=[],this.bufferNames=[],this.textureNames=[],this.samplerNames=[],this.leftOverUniforms=[],this._findStartingGroupBinding()}return Object.defineProperty(e,"KnownUBOs",{get:function(){return e._SimplifiedKnownBindings?e._SimplifiedKnownUBOs:e._KnownUBOs},enumerable:!1,configurable:!0}),e.prototype._findStartingGroupBinding=function(){var t=e.KnownUBOs,n=[];for(var i in t){var r=t[i].binding;-1!==r.groupIndex&&(void 0===n[r.groupIndex]?n[r.groupIndex]=r.bindingIndex:n[r.groupIndex]=Math.max(n[r.groupIndex],r.bindingIndex))}this.freeGroupIndex=n.length-1,0===this.freeGroupIndex?(this.freeGroupIndex++,this.freeBindingIndex=0):this.freeBindingIndex=n[n.length-1]+1},e.prototype.getAttributeNextLocation=function(e,t){var n;void 0===t&&(t=0);var i=this._attributeNextLocation;return this._attributeNextLocation+=(null!==(n=Sa[e])&&void 0!==n?n:1)*(t||1),i},e.prototype.getVaryingNextLocation=function(e,t){var n;void 0===t&&(t=0);var i=this._varyingNextLocation;return this._varyingNextLocation+=(null!==(n=Sa[e])&&void 0!==n?n:1)*(t||1),i},e.prototype.getNextFreeUBOBinding=function(){return this._getNextFreeBinding(1)},e.prototype._getNextFreeBinding=function(e){if(this.freeBindingIndex>65536-e&&(this.freeGroupIndex++,this.freeBindingIndex=0),4===this.freeGroupIndex)throw"Too many textures or UBOs have been declared and it is not supported in WebGPU.";var t={groupIndex:this.freeGroupIndex,bindingIndex:this.freeBindingIndex};return this.freeBindingIndex+=e,t},e._SimplifiedKnownBindings=!0,e._SimplifiedKnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:-1,bindingIndex:-1}},Light1:{binding:{groupIndex:-1,bindingIndex:-1}},Light2:{binding:{groupIndex:-1,bindingIndex:-1}},Light3:{binding:{groupIndex:-1,bindingIndex:-1}},Light4:{binding:{groupIndex:-1,bindingIndex:-1}},Light5:{binding:{groupIndex:-1,bindingIndex:-1}},Light6:{binding:{groupIndex:-1,bindingIndex:-1}},Light7:{binding:{groupIndex:-1,bindingIndex:-1}},Light8:{binding:{groupIndex:-1,bindingIndex:-1}},Light9:{binding:{groupIndex:-1,bindingIndex:-1}},Light10:{binding:{groupIndex:-1,bindingIndex:-1}},Light11:{binding:{groupIndex:-1,bindingIndex:-1}},Light12:{binding:{groupIndex:-1,bindingIndex:-1}},Light13:{binding:{groupIndex:-1,bindingIndex:-1}},Light14:{binding:{groupIndex:-1,bindingIndex:-1}},Light15:{binding:{groupIndex:-1,bindingIndex:-1}},Light16:{binding:{groupIndex:-1,bindingIndex:-1}},Light17:{binding:{groupIndex:-1,bindingIndex:-1}},Light18:{binding:{groupIndex:-1,bindingIndex:-1}},Light19:{binding:{groupIndex:-1,bindingIndex:-1}},Light20:{binding:{groupIndex:-1,bindingIndex:-1}},Light21:{binding:{groupIndex:-1,bindingIndex:-1}},Light22:{binding:{groupIndex:-1,bindingIndex:-1}},Light23:{binding:{groupIndex:-1,bindingIndex:-1}},Light24:{binding:{groupIndex:-1,bindingIndex:-1}},Light25:{binding:{groupIndex:-1,bindingIndex:-1}},Light26:{binding:{groupIndex:-1,bindingIndex:-1}},Light27:{binding:{groupIndex:-1,bindingIndex:-1}},Light28:{binding:{groupIndex:-1,bindingIndex:-1}},Light29:{binding:{groupIndex:-1,bindingIndex:-1}},Light30:{binding:{groupIndex:-1,bindingIndex:-1}},Light31:{binding:{groupIndex:-1,bindingIndex:-1}},Material:{binding:{groupIndex:-1,bindingIndex:-1}},Mesh:{binding:{groupIndex:-1,bindingIndex:-1}},Internals:{binding:{groupIndex:-1,bindingIndex:-1}}},e._KnownUBOs={Scene:{binding:{groupIndex:0,bindingIndex:0}},Light0:{binding:{groupIndex:1,bindingIndex:0}},Light1:{binding:{groupIndex:1,bindingIndex:1}},Light2:{binding:{groupIndex:1,bindingIndex:2}},Light3:{binding:{groupIndex:1,bindingIndex:3}},Light4:{binding:{groupIndex:1,bindingIndex:4}},Light5:{binding:{groupIndex:1,bindingIndex:5}},Light6:{binding:{groupIndex:1,bindingIndex:6}},Light7:{binding:{groupIndex:1,bindingIndex:7}},Light8:{binding:{groupIndex:1,bindingIndex:8}},Light9:{binding:{groupIndex:1,bindingIndex:9}},Light10:{binding:{groupIndex:1,bindingIndex:10}},Light11:{binding:{groupIndex:1,bindingIndex:11}},Light12:{binding:{groupIndex:1,bindingIndex:12}},Light13:{binding:{groupIndex:1,bindingIndex:13}},Light14:{binding:{groupIndex:1,bindingIndex:14}},Light15:{binding:{groupIndex:1,bindingIndex:15}},Light16:{binding:{groupIndex:1,bindingIndex:16}},Light17:{binding:{groupIndex:1,bindingIndex:17}},Light18:{binding:{groupIndex:1,bindingIndex:18}},Light19:{binding:{groupIndex:1,bindingIndex:19}},Light20:{binding:{groupIndex:1,bindingIndex:20}},Light21:{binding:{groupIndex:1,bindingIndex:21}},Light22:{binding:{groupIndex:1,bindingIndex:22}},Light23:{binding:{groupIndex:1,bindingIndex:23}},Light24:{binding:{groupIndex:1,bindingIndex:24}},Light25:{binding:{groupIndex:1,bindingIndex:25}},Light26:{binding:{groupIndex:1,bindingIndex:26}},Light27:{binding:{groupIndex:1,bindingIndex:27}},Light28:{binding:{groupIndex:1,bindingIndex:28}},Light29:{binding:{groupIndex:1,bindingIndex:29}},Light30:{binding:{groupIndex:1,bindingIndex:30}},Light31:{binding:{groupIndex:1,bindingIndex:31}},Material:{binding:{groupIndex:2,bindingIndex:0}},Mesh:{binding:{groupIndex:2,bindingIndex:1}},Internals:{binding:{groupIndex:2,bindingIndex:2}}},e}(),xa=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._missingVaryings=[],t._textureArrayProcessing=[],t.shaderLanguage=fr.a.GLSL,t}return Object(h.d)(t,e),t.prototype._getArraySize=function(e,t,n){var i=0,r=e.indexOf("["),o=e.indexOf("]");if(r>0&&o>0){var a=e.substring(r+1,o);i=+a,isNaN(i)&&(i=+n[a.trim()]),e=e.substr(0,r)}return[e,t,i]},t.prototype.initializeShaders=function(e){this.webgpuProcessingContext=e,this._missingVaryings.length=0,this._textureArrayProcessing.length=0},t.prototype.preProcessShaderCode=function(e,t){var n="uniform ".concat(Ta.InternalsUBOName," {\nfloat yFactor__;\nfloat textureOutputHeight__;\n};\n");return t?n+"##INJECTCODE##\n"+e:n+e},t.prototype.varyingProcessor=function(e,t,n,i){this._preProcessors=n;var r=/\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);if(null!=r){var o,a=r[1],s=r[2];t?(o=this.webgpuProcessingContext.availableVaryings[s],this._missingVaryings[o]="",void 0===o&&m.a.Warn('Invalid fragment shader: The varying named "'.concat(s,'" is not declared in the vertex shader! This declaration will be ignored.'))):(o=this.webgpuProcessingContext.getVaryingNextLocation(a,this._getArraySize(s,a,n)[2]),this.webgpuProcessingContext.availableVaryings[s]=o,this._missingVaryings[o]="layout(location = ".concat(o,") in ").concat(a," ").concat(s,";")),e=e.replace(r[0],void 0===o?"":"layout(location = ".concat(o,") ").concat(t?"in":"out"," ").concat(a," ").concat(s,";"))}return e},t.prototype.attributeProcessor=function(e,t,n){this._preProcessors=t;var i=/\s*attribute\s+(\S+)\s+(\S+)\s*;/gm.exec(e);if(null!=i){var r=i[1],o=i[2],a=this.webgpuProcessingContext.getAttributeNextLocation(r,this._getArraySize(o,r,t)[2]);this.webgpuProcessingContext.availableAttributes[o]=a,this.webgpuProcessingContext.orderedAttributes[a]=o,e=e.replace(i[0],"layout(location = ".concat(a,") in ").concat(r," ").concat(o,";"))}return e},t.prototype.uniformProcessor=function(e,t,n,i){var r,o;this._preProcessors=n;var a=/\s*uniform\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s+(\S+)\s*;/gm.exec(e);if(null!=a){var s=a[1],c=a[2];if(0===s.indexOf("sampler")||1===s.indexOf("sampler")){var u=0;c=(r=this._getArraySize(c,s,n))[0],s=r[1],u=r[2];var l=this.webgpuProcessingContext.availableTextures[c];if(!l){l={autoBindSampler:!0,isTextureArray:u>0,isStorageTexture:!1,textures:[],sampleType:Jo.Float};for(var h=0;h<(u||1);++h)l.textures.push(this.webgpuProcessingContext.getNextFreeUBOBinding())}var d=null!==(o=Ta._SamplerTypeByWebGLSamplerType[s])&&void 0!==o?o:"sampler",p=!!Ta._IsComparisonSamplerByWebGPUSamplerType[d],f=p?Zo.Comparison:Zo.Filtering,_=c+Ta.AutoSamplerSuffix,m=this.webgpuProcessingContext.availableSamplers[_];m||(m={binding:this.webgpuProcessingContext.getNextFreeUBOBinding(),type:f});var g="u"===s.charAt(0)?"u":"i"===s.charAt(0)?"i":"";g&&(s=s.substr(1));var v=p?Jo.Depth:"u"===g?Jo.Uint:"i"===g?Jo.Sint:Jo.Float;l.sampleType=v;var b=u>0,y=m.binding.groupIndex,T=m.binding.bindingIndex,E=Ta._SamplerFunctionByWebGLSamplerType[s],S=Ta._TextureTypeByWebGLSamplerType[s],A=Ta._GpuTextureViewDimensionByWebGPUTextureType[S];if(b){var x=[];x.push("layout(set = ".concat(y,", binding = ").concat(T,") uniform ").concat(g).concat(d," ").concat(_,";")),e="\r\n";for(h=0;h0?"\r\n":"","#define ").concat(c).concat(h," ").concat(g).concat(E,"(").concat(c,"Texture").concat(h,", ").concat(_,")")}e=x.join("\r\n")+e,this._textureArrayProcessing.push(c)}else u=1,e="layout(set = ".concat(y,", binding = ").concat(T,") uniform ").concat(g).concat(d," ").concat(_,";\n layout(set = ").concat(l.textures[0].groupIndex,", binding = ").concat(l.textures[0].bindingIndex,") uniform ").concat(S," ").concat(c,"Texture;\n #define ").concat(c," ").concat(g).concat(E,"(").concat(c,"Texture, ").concat(_,")");this.webgpuProcessingContext.availableTextures[c]=l,this.webgpuProcessingContext.availableSamplers[_]=m,this._addSamplerBindingDescription(_,m,!t);for(h=0;h=0,s=a?"vec4 glFragCoord__;\n":"";e=(e=(e=(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(/gl_FragCoord/g,"glFragCoord__")).replace(/void\s+?main\s*\(/g,(o?"":"layout(location = 0) out vec4 glFragColor;\n")+"void main(")).replace(/dFdy/g,"(-yFactor__)*dFdy")).replace("##INJECTCODE##",s),a&&(e=this._injectStartingAndEndingCode(e,"void main","\n glFragCoord__ = gl_FragCoord;\n if (yFactor__ == 1.) {\n glFragCoord__.y = textureOutputHeight__ - glFragCoord__.y;\n }\n "))}else{if(e=(e=e.replace(/gl_InstanceID/g,"gl_InstanceIndex")).replace(/gl_VertexID/g,"gl_VertexIndex"),-1!==t.indexOf("#define MULTIVIEW"))return"#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+e}if(!n){var c=e.lastIndexOf("}");e=e.substring(0,c),e+="gl_Position.y *= yFactor__;\n",r.isNDCHalfZRange||(e+="gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0;\n"),e+="}"}return e},t.prototype._applyTextureArrayProcessing=function(e,t){for(var n=new RegExp(t+"\\s*\\[(.+)?\\]","gm"),i=n.exec(e);null!=i;){var r=i[1],o=+r;this._preProcessors&&isNaN(o)&&(o=+this._preProcessors[r.trim()]),e=e.replace(i[0],t+o),i=n.exec(e)}return e},t.prototype._generateLeftOverUBOCode=function(e,t){for(var n="layout(set = ".concat(t.binding.groupIndex,", binding = ").concat(t.binding.bindingIndex,") uniform ").concat(e," {\n "),i=0,r=this.webgpuProcessingContext.leftOverUniforms;i0?n+=" ".concat(o.type," ").concat(o.name,"[").concat(o.length,"];\n"):n+=" ".concat(o.type," ").concat(o.name,";\n")}return n+="};\n\n"},t.prototype.finalizeShaders=function(e,t,n){for(var i=0;i0&&(t=o+"\n"+t)}var a=this._buildLeftOverUBO();return e=a+e,t=a+t,this._collectBindingNames(),this._preCreateBindGroupEntries(),this._preProcessors=null,{vertexCode:e,fragmentCode:t}},t}(Ta),Ra="#if NUM_BONE_INFLUENCERS>0\nattribute matricesIndices : vec4;\nattribute matricesWeights : vec4;\n#if NUM_BONE_INFLUENCERS>4\nattribute matricesIndicesExtra : vec4;\nattribute matricesWeightsExtra : vec4;\n#endif\n#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#ifdef BONETEXTURE\nvar boneSampler : texture_2d;\nuniform boneTextureWidth : f32;\n#else\nuniform mBones : array;\n#ifdef BONES_VELOCITY_ENABLED\nuniform mPreviousBones : array;\n#endif\n#endif\n#ifdef BONETEXTURE\nfn readMatrixFromRawSampler(smp : texture_2d,index : f32) -> mat4x4\n{\nlet offset=i32(index)*4;\nlet m0=textureLoad(smp,vec2(offset+0,0),0);\nlet m1=textureLoad(smp,vec2(offset+1,0),0);\nlet m2=textureLoad(smp,vec2(offset+2,0),0);\nlet m3=textureLoad(smp,vec2(offset+3,0),0);\nreturn mat4x4(m0,m1,m2,m3);\n}\n#endif\n#endif\n#endif";Cn.a.IncludesShadersStoreWGSL.bonesDeclaration=Ra;var Ca="#ifndef BAKED_VERTEX_ANIMATION_TEXTURE\n#if NUM_BONE_INFLUENCERS>0\nvar influence : mat4x4;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\ninfluence=uniforms.mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence=influence+uniforms.mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence=influence+uniforms.mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence=influence+uniforms.mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence=influence+uniforms.mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\n#endif\nfinalWorld=finalWorld*influence;\n#endif\n#endif";Cn.a.IncludesShadersStoreWGSL.bonesVertex=Ca;var Pa="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\nuniform bakedVertexAnimationTime: f32;\nuniform bakedVertexAnimationTextureSizeInverted: vec2;\nuniform bakedVertexAnimationSettings: vec4;\nvar bakedVertexAnimationTexture : texture_2d;\n#ifdef INSTANCES\nattribute bakedVertexAnimationSettingsInstanced : vec4;\n#endif\nfn readMatrixFromRawSamplerVAT(smp : texture_2d,index : f32,frame : f32) -> mat4x4\n{\nlet offset=i32(index)*4;\nlet frameUV=i32(frame);\nlet m0=textureLoad(smp,vec2(offset+0,frameUV),0);\nlet m1=textureLoad(smp,vec2(offset+1,frameUV),0);\nlet m2=textureLoad(smp,vec2(offset+2,frameUV),0);\nlet m3=textureLoad(smp,vec2(offset+3,frameUV),0);\nreturn mat4x4(m0,m1,m2,m3);\n}\n#endif";Cn.a.IncludesShadersStoreWGSL.bakedVertexAnimationDeclaration=Pa;var Oa="#ifdef BAKED_VERTEX_ANIMATION_TEXTURE\n{\n\n#ifdef INSTANCES\nlet VATStartFrame: f32=bakedVertexAnimationSettingsInstanced.x;\nlet VATEndFrame: f32=bakedVertexAnimationSettingsInstanced.y;\nlet VATOffsetFrame: f32=bakedVertexAnimationSettingsInstanced.z;\nlet VATSpeed: f32=bakedVertexAnimationSettingsInstanced.w;\n#else\nlet VATStartFrame: f32=uniforms.bakedVertexAnimationSettings.x;\nlet VATEndFrame: f32=uniforms.bakedVertexAnimationSettings.y;\nlet VATOffsetFrame: f32=uniforms.bakedVertexAnimationSettings.z;\nlet VATSpeed: f32=uniforms.bakedVertexAnimationSettings.w;\n#endif\nlet totalFrames: f32=VATEndFrame-VATStartFrame+1.0;\nlet time: f32=uniforms.bakedVertexAnimationTime*VATSpeed/totalFrames;\n\nlet frameCorrection: f32=select(1.0,0.0,time<1.0);\nlet numOfFrames: f32=totalFrames-frameCorrection;\nvar VATFrameNum: f32=fract(time)*numOfFrames;\nVATFrameNum=(VATFrameNum+VATOffsetFrame) % numOfFrames;\nVATFrameNum=floor(VATFrameNum);\nVATFrameNum=VATFrameNum+VATStartFrame+frameCorrection;\nvar VATInfluence : mat4x4;\nVATInfluence=readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[0],VATFrameNum)*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[1],VATFrameNum)*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[2],VATFrameNum)*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndices[3],VATFrameNum)*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[0],VATFrameNum)*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[1],VATFrameNum)*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[2],VATFrameNum)*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\nVATInfluence=VATInfluence+readMatrixFromRawSamplerVAT(bakedVertexAnimationTexture,matricesIndicesExtra[3],VATFrameNum)*matricesWeightsExtra[3];\n#endif\nfinalWorld=finalWorld*VATInfluence;\n}\n#endif";Cn.a.IncludesShadersStoreWGSL.bakedVertexAnimation=Oa;var Ma="#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\n\n\nif (false) {}\n#endif\n#ifdef CLIPPLANE\nelseif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nelseif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nelseif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nelseif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE5\nelseif (fClipDistance5>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE6\nelseif (fClipDistance6>0.0)\n{\ndiscard;\n}\n#endif";Cn.a.IncludesShadersStoreWGSL.clipPlaneFragment=Ma;var Ia="#ifdef CLIPPLANE\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nvarying fClipDistance6: f32;\n#endif";Cn.a.IncludesShadersStoreWGSL.clipPlaneFragmentDeclaration=Ia;var Da="#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,uniforms.vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,uniforms.vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,uniforms.vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,uniforms.vClipPlane4);\n#endif\n#ifdef CLIPPLANE5\nfClipDistance5=dot(worldPos,uniforms.vClipPlane5);\n#endif\n#ifdef CLIPPLANE6\nfClipDistance6=dot(worldPos,uniforms.vClipPlane6);\n#endif";Cn.a.IncludesShadersStoreWGSL.clipPlaneVertex=Da;var Na="#ifdef CLIPPLANE\nuniform vClipPlane: vec4;\nvarying fClipDistance: f32;\n#endif\n#ifdef CLIPPLANE2\nuniform vClipPlane2: vec4;\nvarying fClipDistance2: f32;\n#endif\n#ifdef CLIPPLANE3\nuniform vClipPlane3: vec4;\nvarying fClipDistance3: f32;\n#endif\n#ifdef CLIPPLANE4\nuniform vClipPlane4: vec4;\nvarying fClipDistance4: f32;\n#endif\n#ifdef CLIPPLANE5\nuniform vClipPlane5: vec4;\nvarying fClipDistance5: f32;\n#endif\n#ifdef CLIPPLANE6\nuniform vClipPlane6: vec4;\nvarying fClipDistance6: f32;\n#endif";Cn.a.IncludesShadersStoreWGSL.clipPlaneVertexDeclaration=Na;var La="#ifdef INSTANCES\nattribute world0 : vec4;\nattribute world1 : vec4;\nattribute world2 : vec4;\nattribute world3 : vec4;\n#ifdef INSTANCESCOLOR\nattribute instanceColor : vec4;\n#endif\n#if defined(THIN_INSTANCES) && !defined(WORLD_UBO)\nuniform world : mat4x4;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nattribute previousWorld0 : vec4;\nattribute previousWorld1 : vec4;\nattribute previousWorld2 : vec4;\nattribute previousWorld3 : vec4;\n#ifdef THIN_INSTANCES\nuniform previousWorld : mat4x4;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nuniform world : mat4x4;\n#endif\n#if defined(VELOCITY) || defined(PREPASS_VELOCITY)\nuniform previousWorld : mat4x4;\n#endif\n#endif";Cn.a.IncludesShadersStoreWGSL.instancesDeclaration=La;var Fa="#ifdef INSTANCES\nvar finalWorld=mat4x4(world0,world1,world2,world3);\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=mat4x4(previousWorld0,previousWorld1,previousWorld2,previousWorld3);\n#endif\n#ifdef THIN_INSTANCES\n#if !defined(WORLD_UBO)\nfinalWorld=uniforms.world*finalWorld;\n#else\nfinalWorld=mesh.world*finalWorld;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nfinalPreviousWorld=previousWorld*finalPreviousWorld;\n#endif\n#endif\n#else\n#if !defined(WORLD_UBO)\nvar finalWorld=uniforms.world;\n#else\nvar finalWorld=mesh.world;\n#endif\n#if defined(PREPASS_VELOCITY) || defined(VELOCITY)\nvar finalPreviousWorld=previousWorld;\n#endif\n#endif";Cn.a.IncludesShadersStoreWGSL.instancesVertex=Fa;var wa="struct Mesh {\nworld : mat4x4;\nvisibility : f32;\n};\nvar mesh : Mesh;\n#define WORLD_UBO\n";Cn.a.IncludesShadersStoreWGSL.meshUboDeclaration=wa;var Ba="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvertexID=f32(gl_VertexID)*uniforms.morphTargetTextureInfo.x;\npositionUpdated=positionUpdated+(readVector3FromRawSampler({X},vertexID)-position)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated=normalUpdated+(readVector3FromRawSampler({X},vertexID)-normal)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(readVector3FromRawSampler({X},vertexID).xy-uv)*uniforms.morphTargetInfluences[{X}];\nvertexID=vertexID+1.0;\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(readVector3FromRawSampler({X},vertexID)-tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#else\npositionUpdated=positionUpdated+(position{X}-position)*uniforms.morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz=tangentUpdated.xyz+(tangent{X}-tangent.xyz)*uniforms.morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_UV\nuvUpdated=uvUpdated+(uv_{X}-uv)*uniforms.morphTargetInfluences[{X}];\n#endif\n#endif\n#endif";Cn.a.IncludesShadersStoreWGSL.morphTargetsVertex=Ba;var Ua="#ifdef MORPHTARGETS\n#ifndef MORPHTARGETS_TEXTURE\nattribute position{X} : vec3;\n#ifdef MORPHTARGETS_NORMAL\nattribute normal{X} : vec3;\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute tangent{X} : vec3;\n#endif\n#ifdef MORPHTARGETS_UV\nattribute uv_{X} : vec2;\n#endif\n#endif\n#endif";Cn.a.IncludesShadersStoreWGSL.morphTargetsVertexDeclaration=Ua;Cn.a.IncludesShadersStoreWGSL.morphTargetsVertexGlobal="#ifdef MORPHTARGETS\n#ifdef MORPHTARGETS_TEXTURE\nvar vertexID : f32;\n#endif\n#endif";var Va="#ifdef MORPHTARGETS\nuniform morphTargetInfluences : array;\n#ifdef MORPHTARGETS_TEXTURE\nuniform morphTargetTextureIndices : array;\nuniform morphTargetTextureInfo : vec3;\nvar morphTargets : texture_2d_array;\nvar morphTargetsSampler : sampler;\nfn readVector3FromRawSampler(targetIndex : i32,vertexIndex : f32) -> vec3\n{\nlet y=floor(vertexIndex/uniforms.morphTargetTextureInfo.y);\nlet x=vertexIndex-y*uniforms.morphTargetTextureInfo.y;\nlet textureUV=vec2((x+0.5)/uniforms.morphTargetTextureInfo.y,(y+0.5)/uniforms.morphTargetTextureInfo.z);\nreturn textureSampleLevel(morphTargets,morphTargetsSampler,textureUV,i32(uniforms.morphTargetTextureIndices[targetIndex]),0.0).xyz;\n}\n#endif\n#endif";Cn.a.IncludesShadersStoreWGSL.morphTargetsVertexGlobalDeclaration=Va;var ka="struct Scene {\nviewProjection : mat4x4;\n#ifdef MULTIVIEW\nviewProjectionR : mat4x4;\n#endif\nview : mat4x4;\nprojection : mat4x4;\nvEyePosition : vec4;\n};\nvar scene : Scene;\n";Cn.a.IncludesShadersStoreWGSL.sceneUboDeclaration=ka;var Ga,za={texture_1d:jo.E1d,texture_2d:jo.E2d,texture_2d_array:jo.E2dArray,texture_3d:jo.E3d,texture_cube:jo.Cube,texture_cube_array:jo.CubeArray,texture_multisampled_2d:jo.E2d,texture_depth_2d:jo.E2d,texture_depth_2d_array:jo.E2dArray,texture_depth_cube:jo.Cube,texture_depth_cube_array:jo.CubeArray,texture_depth_multisampled_2d:jo.E2d,texture_storage_1d:jo.E1d,texture_storage_2d:jo.E2d,texture_storage_2d_array:jo.E2dArray,texture_storage_3d:jo.E3d,texture_external:null},ja=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.shaderLanguage=fr.a.WGSL,t.uniformRegexp=/uniform\s+(\w+)\s*:\s*(.+)\s*;/,t.textureRegexp=/var\s+(\w+)\s*:\s*((array<\s*)?(texture_\w+)\s*(<\s*(.+)\s*>)?\s*(,\s*\w+\s*>\s*)?);/,t.noPrecision=!0,t}return Object(h.d)(t,e),t.prototype._getArraySize=function(e,t,n){var i=0,r=t.lastIndexOf(">");if(t.indexOf("array")>=0&&r>0){for(var o=r;o>0&&" "!==t.charAt(o)&&","!==t.charAt(o);)o--;var a=t.substring(o+1,r);for(i=+a,isNaN(i)&&(i=+n[a.trim()]);o>0&&(" "===t.charAt(o)||","===t.charAt(o));)o--;t=t.substring(t.indexOf("<")+1,o+1)}return[e,t,i]},t.prototype.initializeShaders=function(e){this.webgpuProcessingContext=e,this._attributesWGSL=[],this._attributesDeclWGSL=[],this._attributeNamesWGSL=[],this._varyingsWGSL=[],this._varyingsDeclWGSL=[],this._varyingNamesWGSL=[]},t.prototype.preProcessShaderCode=function(e,t){return"struct ".concat(Ta.InternalsUBOName," {\nyFactor__: f32;\ntextureOutputHeight__: f32;\n};\nvar ").concat("internals"," : ").concat(Ta.InternalsUBOName,";\n")+So(e)},t.prototype.varyingProcessor=function(e,t,n,i){var r=/\s*varying\s+(?:(?:highp)?|(?:lowp)?)\s*(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(null!==r){var o,a=r[2],s=r[1];t?void 0===(o=this.webgpuProcessingContext.availableVaryings[s])&&m.a.Warn('Invalid fragment shader: The varying named "'.concat(s,'" is not declared in the vertex shader! This declaration will be ignored.')):(o=this.webgpuProcessingContext.getVaryingNextLocation(a,this._getArraySize(s,a,n)[2]),this.webgpuProcessingContext.availableVaryings[s]=o,this._varyingsWGSL.push("@location(".concat(o,") ").concat(s," : ").concat(a,";")),this._varyingsDeclWGSL.push("var ".concat(s," : ").concat(a,";")),this._varyingNamesWGSL.push(s)),e=""}return e},t.prototype.attributeProcessor=function(e,t,n){var i=/\s*attribute\s+(\S+)\s*:\s*(.+)\s*;/gm.exec(e);if(null!==i){var r=i[2],o=i[1],a=this.webgpuProcessingContext.getAttributeNextLocation(r,this._getArraySize(o,r,t)[2]);this.webgpuProcessingContext.availableAttributes[o]=a,this.webgpuProcessingContext.orderedAttributes[a]=o,this._attributesWGSL.push("@location(".concat(a,") ").concat(o," : ").concat(r,";")),this._attributesDeclWGSL.push("var ".concat(o," : ").concat(r,";")),this._attributeNamesWGSL.push(o),e=""}return e},t.prototype.uniformProcessor=function(e,t,n,i){var r=this.uniformRegexp.exec(e);if(null!==r){var o=r[2],a=r[1];this._addUniformToLeftOverUBO(a,o,n),e=""}return e},t.prototype.textureProcessor=function(e,t,n,i){var r=this.textureRegexp.exec(e);if(null!==r){var o=r[1],a=r[2],s=!!r[3],c=r[4],u=c.indexOf("storage")>0,l=r[6],h=u?l.substring(0,l.indexOf(",")).trim():null,d=s?this._getArraySize(o,a,n)[2]:0,p=this.webgpuProcessingContext.availableTextures[o];if(p)d=p.textures.length;else{p={isTextureArray:d>0,isStorageTexture:u,textures:[],sampleType:Jo.Float},d=d||1;for(var f=0;f0,m=za[c],g=_?Jo.Depth:"u32"===l?Jo.Uint:"i32"===l?Jo.Sint:Jo.Float;if(p.sampleType=g,void 0===m)throw"Can't get the texture dimension corresponding to the texture function \"".concat(c,'"!');for(f=0;f=0?"\n if (internals.yFactor__ == 1.) {\n gl_FragCoord.y = internals.textureOutputHeight__ - gl_FragCoord.y;\n }\n ":"";e=this._processSamplers(e,!0),t=this._processSamplers(t,!1),e=this._processCustomBuffers(e,!0),t=this._processCustomBuffers(t,!1);var r=this._buildLeftOverUBO();t=r+t,e=(e=r+e).replace(/#define /g,"//#define ");var o=this._varyingsDeclWGSL.join("\n")+"\n",a="var ".concat("gl_VertexID"," : u32;\nvar ").concat("gl_InstanceID"," : u32;\nvar ").concat("gl_Position"," : vec4;\n"),s=this._attributesDeclWGSL.join("\n")+"\n",c="struct VertexInputs {\n @builtin(vertex_index) vertexIndex : u32;\n @builtin(instance_index) instanceIndex : u32;\n";this._attributesWGSL.length>0&&(c+=this._attributesWGSL.join("\n")),c+="\n};\n";var u="struct FragmentInputs {\n @builtin(position) position : vec4;\n";this._varyingsWGSL.length>0&&(u+=this._varyingsWGSL.join("\n")),e=a+c+s+(u+="\n};\n")+o+e;for(var l=" var output : FragmentInputs;\n ".concat("gl_VertexID"," = input.vertexIndex;\n ").concat("gl_InstanceID"," = input.instanceIndex;\n"),h=0;h;\nvar ").concat("gl_FrontFacing"," : bool;\nvar ").concat("gl_FragColor"," : vec4;\nvar ").concat("gl_FragDepth"," : f32;\n"),m="struct FragmentInputs {\n @builtin(position) position : vec4;\n @builtin(front_facing) frontFacing : bool;\n";this._varyingsWGSL.length>0&&(m+=this._varyingsWGSL.join("\n")),m+="\n};\n";for(var g="struct FragmentOutputs {\n @location(0) color : vec4;\n",v=!1,b=0;!(v||(b=t.indexOf("gl_FragDepth",b))<0);){var y=b;for(v=!0;b>1&&"\n"!==t.charAt(b);){if("/"===t.charAt(b)&&"/"===t.charAt(b-1)){v=!1;break}b--}b=y+"gl_FragDepth".length}v&&(g+=" @builtin(frag_depth) fragDepth: f32;\n"),t=_+m+o+(g+="};\n")+t;var T=" var output : FragmentOutputs;\n ".concat("gl_FragCoord"," = input.position;\n ").concat("gl_FrontFacing"," = input.frontFacing;\n")+i;for(h=0;h)?$/,"$1"),s=Ta.UniformSizes[a];o.length>0?n+=s<=2?" @align(16) ".concat(o.name," : @stride(16) array<").concat(o.type,", ").concat(o.length,">;\n"):" ".concat(o.name," : array<").concat(o.type,", ").concat(o.length,">;\n"):n+=" ".concat(o.name," : ").concat(o.type,";\n")}return n+="};\n",n+="@group(".concat(t.binding.groupIndex,") @binding(").concat(t.binding.bindingIndex,") var ").concat("uniforms"," : ").concat(e,";\n")},t.prototype._processSamplers=function(e,t){for(var n=/var\s+(\w+Sampler)\s*:\s*(sampler|sampler_comparison)\s*;/gm;;){var i=n.exec(e);if(null===i)break;var r=i[1],o=i[2],a=r.indexOf(Ta.AutoSamplerSuffix)===r.length-Ta.AutoSamplerSuffix.length?r.substring(0,r.indexOf(Ta.AutoSamplerSuffix)):null,s="sampler_comparison"===o?Zo.Comparison:Zo.Filtering;if(a){var c=this.webgpuProcessingContext.availableTextures[a];c&&(c.autoBindSampler=!0)}var u=this.webgpuProcessingContext.availableSamplers[r];u||(u={binding:this.webgpuProcessingContext.getNextFreeUBOBinding(),type:s},this.webgpuProcessingContext.availableSamplers[r]=u),this._addSamplerBindingDescription(r,u,t);var l=e.substring(0,i.index),h="@group(".concat(u.binding.groupIndex,") @binding(").concat(u.binding.bindingIndex,") "),d=e.substring(i.index);e=l+h+d,n.lastIndex+=h.length}return e},t.prototype._processCustomBuffers=function(e,t){for(var n=/var<\s*(uniform|storage)\s*(,\s*(read|read_write)\s*)?>\s+(\S+)\s*:\s*(\S+)\s*;/gm;;){var i=n.exec(e);if(null===i)break;var r=i[1],o=i[3],a=i[4],s=i[5],c=this.webgpuProcessingContext.availableBuffers[a];if(!c){var u="uniform"===r?Aa.KnownUBOs[s]:null,l=void 0;u?(a=s,-1===(l=u.binding).groupIndex&&(l=this.webgpuProcessingContext.getNextFreeUBOBinding())):l=this.webgpuProcessingContext.getNextFreeUBOBinding(),c={binding:l},this.webgpuProcessingContext.availableBuffers[a]=c}this._addBufferBindingDescription(a,this.webgpuProcessingContext.availableBuffers[a],"read_write"===o?qo.Storage:"storage"===r?qo.ReadOnlyStorage:qo.Uniform,t);var h=c.binding.groupIndex,d=c.binding.bindingIndex,p=e.substring(0,i.index),f="@group(".concat(h,") @binding(").concat(d,") "),_=e.substring(i.index);e=p+f+_,n.lastIndex+=f.length}return e},t}(Ta),Wa=function(){function e(e){void 0===e&&(e=null),this.format=Ho.RGBA8Unorm,this.textureUsages=0,this.textureAdditionalUsages=0,this._webgpuTexture=e,this._webgpuMSAATexture=null,this.view=null,this.viewForWriting=null}return Object.defineProperty(e.prototype,"underlyingResource",{get:function(){return this._webgpuTexture},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"msaaTexture",{get:function(){return this._webgpuMSAATexture},set:function(e){this._webgpuMSAATexture=e},enumerable:!1,configurable:!0}),e.prototype.set=function(e){this._webgpuTexture=e},e.prototype.setUsage=function(e,t,n,i,r){t=e!==Ue.b.RenderTarget&&t,this.createView({format:this.format,dimension:n?jo.Cube:jo.E2d,mipLevelCount:t?L.a.ILog2(Math.max(i,r))+1:1,baseArrayLayer:0,baseMipLevel:0,arrayLayerCount:n?6:1,aspect:Wo.All})},e.prototype.createView=function(e,t){if(void 0===t&&(t=!1),this.view=this._webgpuTexture.createView(e),t&&e){var n=e.mipLevelCount;e.mipLevelCount=1,this.viewForWriting=this._webgpuTexture.createView(e),e.mipLevelCount=n}},e.prototype.reset=function(){this._webgpuTexture=null,this._webgpuMSAATexture=null,this.view=null,this.viewForWriting=null},e.prototype.release=function(){var e,t,n;null===(e=this._webgpuTexture)||void 0===e||e.destroy(),null===(t=this._webgpuMSAATexture)||void 0===t||t.destroy(),null===(n=this._copyInvertYTempTexture)||void 0===n||n.destroy(),this.reset()},e}(),Ha="\n #extension GL_EXT_samplerless_texture_functions : enable\n\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) out flat ivec2 vTextureSize;\n #endif\n\n void main() {\n #ifdef INVERTY\n vTextureSize = textureSize(img, 0);\n #endif\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ";!function(e){e[e.MipMap=0]="MipMap",e[e.InvertYPremultiplyAlpha=1]="InvertYPremultiplyAlpha",e[e.Clear=2]="Clear",e[e.InvertYPremultiplyAlphaWithOfst=3]="InvertYPremultiplyAlphaWithOfst"}(Ga||(Ga={}));var Xa,Ya=[{vertex:"\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(location = 0) out vec2 vTex;\n\n void main() {\n vTex = tex[gl_VertexIndex];\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",fragment:"\n layout(set = 0, binding = 0) uniform sampler imgSampler;\n layout(set = 0, binding = 1) uniform texture2D img;\n\n layout(location = 0) in vec2 vTex;\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = texture(sampler2D(img, imgSampler), vTex);\n }\n "},{vertex:Ha,fragment:"\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, vTextureSize.y - gl_FragCoord.y), 0);\n #else\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color.rgb *= color.a;\n #endif\n outColor = color;\n }\n "},{vertex:"\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n\n void main() {\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",fragment:"\n layout(set = 0, binding = 0) uniform Uniforms {\n uniform vec4 color;\n };\n\n layout(location = 0) out vec4 outColor;\n\n void main() {\n outColor = color;\n }\n "},{vertex:"\n #extension GL_EXT_samplerless_texture_functions : enable\n\n const vec2 pos[4] = vec2[4](vec2(-1.0f, 1.0f), vec2(1.0f, 1.0f), vec2(-1.0f, -1.0f), vec2(1.0f, -1.0f));\n const vec2 tex[4] = vec2[4](vec2(0.0f, 0.0f), vec2(1.0f, 0.0f), vec2(0.0f, 1.0f), vec2(1.0f, 1.0f));\n\n layout(set = 0, binding = 0) uniform texture2D img;\n\n #ifdef INVERTY\n layout(location = 0) out flat ivec2 vTextureSize;\n #endif\n\n void main() {\n #ifdef INVERTY\n vTextureSize = textureSize(img, 0);\n #endif\n gl_Position = vec4(pos[gl_VertexIndex], 0.0, 1.0);\n }\n ",fragment:"\n #extension GL_EXT_samplerless_texture_functions : enable\n\n layout(set = 0, binding = 0) uniform texture2D img;\n layout(set = 0, binding = 1) uniform Params {\n float ofstX;\n float ofstY;\n float width;\n float height;\n };\n\n #ifdef INVERTY\n layout(location = 0) in flat ivec2 vTextureSize;\n #endif\n layout(location = 0) out vec4 outColor;\n\n void main() {\n if (gl_FragCoord.x < ofstX || gl_FragCoord.x >= ofstX + width) {\n discard;\n }\n if (gl_FragCoord.y < ofstY || gl_FragCoord.y >= ofstY + height) {\n discard;\n }\n #ifdef INVERTY\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.x, ofstY + height - (gl_FragCoord.y - ofstY)), 0);\n #else\n vec4 color = texelFetch(img, ivec2(gl_FragCoord.xy), 0);\n #endif\n #ifdef PREMULTIPLYALPHA\n color.rgb *= color.a;\n #endif\n outColor = color;\n }\n "}],Ka={"":0,r8unorm:1,r8uint:2,r8sint:3,r16uint:4,r16sint:5,r16float:6,rg8unorm:7,rg8uint:8,rg8sint:9,r32uint:10,r32sint:11,r32float:12,rg16uint:13,rg16sint:14,rg16float:15,rgba8unorm:16,"rgba8unorm-srgb":17,rgba8uint:18,rgba8sint:19,bgra8unorm:20,"bgra8unorm-srgb":21,rgb10a2unorm:22,rg32uint:23,rg32sint:24,rg32float:25,rgba16uint:26,rgba16sint:27,rgba16float:28,rgba32uint:29,rgba32sint:30,rgba32float:31,stencil8:32,depth16unorm:33,depth24plus:34,"depth24plus-stencil8":35,depth32float:36,"depth24unorm-stencil8":37,"depth32float-stencil8":38},Qa=function(){function e(e,t,n,i){this._pipelines={},this._compiledShaders=[],this._deferredReleaseTextures=[],this._device=e,this._glslang=t,this._tintWASM=n,this._bufferManager=i,this._mipmapSampler=e.createSampler({minFilter:Yo.Linear}),this._ubCopyWithOfst=this._bufferManager.createBuffer(16,Vo.Uniform|Vo.CopyDst).underlyingResource,this._getPipeline(Ho.RGBA8Unorm)}return e.ComputeNumMipmapLevels=function(e,t){return L.a.ILog2(Math.max(e,t))+1},e.prototype._getPipeline=function(e,t,n){void 0===t&&(t=Ga.MipMap);var i=t===Ga.MipMap?1:t===Ga.InvertYPremultiplyAlpha?((n.invertY?1:0)<<1)+((n.premultiplyAlpha?1:0)<<2):t===Ga.Clear?8:t===Ga.InvertYPremultiplyAlphaWithOfst?((n.invertY?1:0)<<4)+((n.premultiplyAlpha?1:0)<<5):0;this._pipelines[e]||(this._pipelines[e]=[]);var r=this._pipelines[e][i];if(!r){var o="#version 450\r\n";t!==Ga.InvertYPremultiplyAlpha&&t!==Ga.InvertYPremultiplyAlphaWithOfst||(n.invertY&&(o+="#define INVERTY\r\n"),n.premultiplyAlpha&&(o+="#define PREMULTIPLYALPHA\r\n"));var a=this._compiledShaders[i];if(!a){var s=this._glslang.compileGLSL(o+Ya[t].vertex,"vertex"),c=this._glslang.compileGLSL(o+Ya[t].fragment,"fragment");this._tintWASM&&(s=this._tintWASM.convertSpirV2WGSL(s),c=this._tintWASM.convertSpirV2WGSL(c));var u=this._device.createShaderModule({code:s}),l=this._device.createShaderModule({code:c});a=this._compiledShaders[i]=[u,l]}var h=this._device.createRenderPipeline({vertex:{module:a[0],entryPoint:"main"},fragment:{module:a[1],entryPoint:"main",targets:[{format:e}]},primitive:{topology:ta.TriangleStrip,stripIndexFormat:ca.Uint16}});r=this._pipelines[e][i]=[h,h.getBindGroupLayout(0)]}return r},e._GetTextureTypeFromFormat=function(e){switch(e){case Ho.R8Unorm:case Ho.R8Snorm:case Ho.R8Uint:case Ho.R8Sint:case Ho.RG8Unorm:case Ho.RG8Snorm:case Ho.RG8Uint:case Ho.RG8Sint:case Ho.RGBA8Unorm:case Ho.RGBA8UnormSRGB:case Ho.RGBA8Snorm:case Ho.RGBA8Uint:case Ho.RGBA8Sint:case Ho.BGRA8Unorm:case Ho.BGRA8UnormSRGB:case Ho.RGB10A2Unorm:case Ho.RGB9E5UFloat:case Ho.RG11B10UFloat:case Ho.Depth24UnormStencil8:case Ho.Depth32FloatStencil8:case Ho.BC7RGBAUnorm:case Ho.BC7RGBAUnormSRGB:case Ho.BC6HRGBUFloat:case Ho.BC6HRGBFloat:case Ho.BC5RGUnorm:case Ho.BC5RGSnorm:case Ho.BC3RGBAUnorm:case Ho.BC3RGBAUnormSRGB:case Ho.BC2RGBAUnorm:case Ho.BC2RGBAUnormSRGB:case Ho.BC4RUnorm:case Ho.BC4RSnorm:case Ho.BC1RGBAUnorm:case Ho.BC1RGBAUnormSRGB:case Ho.ETC2RGB8Unorm:case Ho.ETC2RGB8UnormSRGB:case Ho.ETC2RGB8A1Unorm:case Ho.ETC2RGB8A1UnormSRGB:case Ho.ETC2RGBA8Unorm:case Ho.ETC2RGBA8UnormSRGB:case Ho.EACR11Unorm:case Ho.EACR11Snorm:case Ho.EACRG11Unorm:case Ho.EACRG11Snorm:case Ho.ASTC4x4Unorm:case Ho.ASTC4x4UnormSRGB:case Ho.ASTC5x4Unorm:case Ho.ASTC5x4UnormSRGB:case Ho.ASTC5x5Unorm:case Ho.ASTC5x5UnormSRGB:case Ho.ASTC6x5Unorm:case Ho.ASTC6x5UnormSRGB:case Ho.ASTC6x6Unorm:case Ho.ASTC6x6UnormSRGB:case Ho.ASTC8x5Unorm:case Ho.ASTC8x5UnormSRGB:case Ho.ASTC8x6Unorm:case Ho.ASTC8x6UnormSRGB:case Ho.ASTC8x8Unorm:case Ho.ASTC8x8UnormSRGB:case Ho.ASTC10x5Unorm:case Ho.ASTC10x5UnormSRGB:case Ho.ASTC10x6Unorm:case Ho.ASTC10x6UnormSRGB:case Ho.ASTC10x8Unorm:case Ho.ASTC10x8UnormSRGB:case Ho.ASTC10x10Unorm:case Ho.ASTC10x10UnormSRGB:case Ho.ASTC12x10Unorm:case Ho.ASTC12x10UnormSRGB:case Ho.ASTC12x12Unorm:case Ho.ASTC12x12UnormSRGB:return g.a.TEXTURETYPE_UNSIGNED_BYTE;case Ho.R16Uint:case Ho.R16Sint:case Ho.RG16Uint:case Ho.RG16Sint:case Ho.RGBA16Uint:case Ho.RGBA16Sint:case Ho.Depth16Unorm:return g.a.TEXTURETYPE_UNSIGNED_SHORT;case Ho.R16Float:case Ho.RG16Float:case Ho.RGBA16Float:return g.a.TEXTURETYPE_HALF_FLOAT;case Ho.R32Uint:case Ho.R32Sint:case Ho.RG32Uint:case Ho.RG32Sint:case Ho.RGBA32Uint:case Ho.RGBA32Sint:return g.a.TEXTURETYPE_UNSIGNED_INTEGER;case Ho.R32Float:case Ho.RG32Float:case Ho.RGBA32Float:case Ho.Depth32Float:return g.a.TEXTURETYPE_FLOAT;case Ho.Stencil8:throw"No fixed size for Stencil8 format!";case Ho.Depth24Plus:throw"No fixed size for Depth24Plus format!";case Ho.Depth24PlusStencil8:throw"No fixed size for Depth24PlusStencil8 format!"}return g.a.TEXTURETYPE_UNSIGNED_BYTE},e._GetBlockInformationFromFormat=function(e){switch(e){case Ho.R8Unorm:case Ho.R8Snorm:case Ho.R8Uint:case Ho.R8Sint:return{width:1,height:1,length:1};case Ho.R16Uint:case Ho.R16Sint:case Ho.R16Float:case Ho.RG8Unorm:case Ho.RG8Snorm:case Ho.RG8Uint:case Ho.RG8Sint:return{width:1,height:1,length:2};case Ho.R32Uint:case Ho.R32Sint:case Ho.R32Float:case Ho.RG16Uint:case Ho.RG16Sint:case Ho.RG16Float:case Ho.RGBA8Unorm:case Ho.RGBA8UnormSRGB:case Ho.RGBA8Snorm:case Ho.RGBA8Uint:case Ho.RGBA8Sint:case Ho.BGRA8Unorm:case Ho.BGRA8UnormSRGB:case Ho.RGB9E5UFloat:case Ho.RGB10A2Unorm:case Ho.RG11B10UFloat:return{width:1,height:1,length:4};case Ho.RG32Uint:case Ho.RG32Sint:case Ho.RG32Float:case Ho.RGBA16Uint:case Ho.RGBA16Sint:case Ho.RGBA16Float:return{width:1,height:1,length:8};case Ho.RGBA32Uint:case Ho.RGBA32Sint:case Ho.RGBA32Float:return{width:1,height:1,length:16};case Ho.Stencil8:throw"No fixed size for Stencil8 format!";case Ho.Depth16Unorm:return{width:1,height:1,length:2};case Ho.Depth24Plus:throw"No fixed size for Depth24Plus format!";case Ho.Depth24PlusStencil8:throw"No fixed size for Depth24PlusStencil8 format!";case Ho.Depth32Float:case Ho.Depth24UnormStencil8:return{width:1,height:1,length:4};case Ho.Depth32FloatStencil8:return{width:1,height:1,length:5};case Ho.BC7RGBAUnorm:case Ho.BC7RGBAUnormSRGB:case Ho.BC6HRGBUFloat:case Ho.BC6HRGBFloat:case Ho.BC5RGUnorm:case Ho.BC5RGSnorm:case Ho.BC3RGBAUnorm:case Ho.BC3RGBAUnormSRGB:case Ho.BC2RGBAUnorm:case Ho.BC2RGBAUnormSRGB:return{width:4,height:4,length:16};case Ho.BC4RUnorm:case Ho.BC4RSnorm:case Ho.BC1RGBAUnorm:case Ho.BC1RGBAUnormSRGB:return{width:4,height:4,length:8};case Ho.ETC2RGB8Unorm:case Ho.ETC2RGB8UnormSRGB:case Ho.ETC2RGB8A1Unorm:case Ho.ETC2RGB8A1UnormSRGB:case Ho.EACR11Unorm:case Ho.EACR11Snorm:return{width:4,height:4,length:8};case Ho.ETC2RGBA8Unorm:case Ho.ETC2RGBA8UnormSRGB:case Ho.EACRG11Unorm:case Ho.EACRG11Snorm:return{width:4,height:4,length:16};case Ho.ASTC4x4Unorm:case Ho.ASTC4x4UnormSRGB:return{width:4,height:4,length:16};case Ho.ASTC5x4Unorm:case Ho.ASTC5x4UnormSRGB:return{width:5,height:4,length:16};case Ho.ASTC5x5Unorm:case Ho.ASTC5x5UnormSRGB:return{width:5,height:5,length:16};case Ho.ASTC6x5Unorm:case Ho.ASTC6x5UnormSRGB:return{width:6,height:5,length:16};case Ho.ASTC6x6Unorm:case Ho.ASTC6x6UnormSRGB:return{width:6,height:6,length:16};case Ho.ASTC8x5Unorm:case Ho.ASTC8x5UnormSRGB:return{width:8,height:5,length:16};case Ho.ASTC8x6Unorm:case Ho.ASTC8x6UnormSRGB:return{width:8,height:6,length:16};case Ho.ASTC8x8Unorm:case Ho.ASTC8x8UnormSRGB:return{width:8,height:8,length:16};case Ho.ASTC10x5Unorm:case Ho.ASTC10x5UnormSRGB:return{width:10,height:5,length:16};case Ho.ASTC10x6Unorm:case Ho.ASTC10x6UnormSRGB:return{width:10,height:6,length:16};case Ho.ASTC10x8Unorm:case Ho.ASTC10x8UnormSRGB:return{width:10,height:8,length:16};case Ho.ASTC10x10Unorm:case Ho.ASTC10x10UnormSRGB:return{width:10,height:10,length:16};case Ho.ASTC12x10Unorm:case Ho.ASTC12x10UnormSRGB:return{width:12,height:10,length:16};case Ho.ASTC12x12Unorm:case Ho.ASTC12x12UnormSRGB:return{width:12,height:12,length:16}}return{width:1,height:1,length:4}},e._IsHardwareTexture=function(e){return!!e.release},e._IsInternalTexture=function(e){return!!e.dispose},e.IsImageBitmap=function(e){return void 0!==e.close},e.IsImageBitmapArray=function(e){return Array.isArray(e)&&void 0!==e[0].close},e.prototype.setCommandEncoder=function(e){this._commandEncoderForCreation=e},e.IsCompressedFormat=function(e){switch(e){case Ho.BC7RGBAUnormSRGB:case Ho.BC7RGBAUnorm:case Ho.BC6HRGBFloat:case Ho.BC6HRGBUFloat:case Ho.BC5RGSnorm:case Ho.BC5RGUnorm:case Ho.BC4RSnorm:case Ho.BC4RUnorm:case Ho.BC3RGBAUnormSRGB:case Ho.BC3RGBAUnorm:case Ho.BC2RGBAUnormSRGB:case Ho.BC2RGBAUnorm:case Ho.BC1RGBAUnormSRGB:case Ho.BC1RGBAUnorm:case Ho.ETC2RGB8Unorm:case Ho.ETC2RGB8UnormSRGB:case Ho.ETC2RGB8A1Unorm:case Ho.ETC2RGB8A1UnormSRGB:case Ho.ETC2RGBA8Unorm:case Ho.ETC2RGBA8UnormSRGB:case Ho.EACR11Unorm:case Ho.EACR11Snorm:case Ho.EACRG11Unorm:case Ho.EACRG11Snorm:case Ho.ASTC4x4Unorm:case Ho.ASTC4x4UnormSRGB:case Ho.ASTC5x4Unorm:case Ho.ASTC5x4UnormSRGB:case Ho.ASTC5x5Unorm:case Ho.ASTC5x5UnormSRGB:case Ho.ASTC6x5Unorm:case Ho.ASTC6x5UnormSRGB:case Ho.ASTC6x6Unorm:case Ho.ASTC6x6UnormSRGB:case Ho.ASTC8x5Unorm:case Ho.ASTC8x5UnormSRGB:case Ho.ASTC8x6Unorm:case Ho.ASTC8x6UnormSRGB:case Ho.ASTC8x8Unorm:case Ho.ASTC8x8UnormSRGB:case Ho.ASTC10x5Unorm:case Ho.ASTC10x5UnormSRGB:case Ho.ASTC10x6Unorm:case Ho.ASTC10x6UnormSRGB:case Ho.ASTC10x8Unorm:case Ho.ASTC10x8UnormSRGB:case Ho.ASTC10x10Unorm:case Ho.ASTC10x10UnormSRGB:case Ho.ASTC12x10Unorm:case Ho.ASTC12x10UnormSRGB:case Ho.ASTC12x12Unorm:case Ho.ASTC12x12UnormSRGB:return!0}return!1},e.GetWebGPUTextureFormat=function(e,t,n){switch(void 0===n&&(n=!1),t){case g.a.TEXTUREFORMAT_DEPTH16:return Ho.Depth16Unorm;case g.a.TEXTUREFORMAT_DEPTH24:return Ho.Depth24Plus;case g.a.TEXTUREFORMAT_DEPTH24_STENCIL8:return Ho.Depth24PlusStencil8;case g.a.TEXTUREFORMAT_DEPTH32_FLOAT:return Ho.Depth32Float;case g.a.TEXTUREFORMAT_COMPRESSED_RGBA_BPTC_UNORM:return n?Ho.BC7RGBAUnormSRGB:Ho.BC7RGBAUnorm;case g.a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT:return Ho.BC6HRGBUFloat;case g.a.TEXTUREFORMAT_COMPRESSED_RGB_BPTC_SIGNED_FLOAT:return Ho.BC6HRGBFloat;case g.a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT5:return n?Ho.BC3RGBAUnormSRGB:Ho.BC3RGBAUnorm;case g.a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT3:return n?Ho.BC2RGBAUnormSRGB:Ho.BC2RGBAUnorm;case g.a.TEXTUREFORMAT_COMPRESSED_RGBA_S3TC_DXT1:case g.a.TEXTUREFORMAT_COMPRESSED_RGB_S3TC_DXT1:return n?Ho.BC1RGBAUnormSRGB:Ho.BC1RGBAUnorm;case g.a.TEXTUREFORMAT_COMPRESSED_RGBA_ASTC_4x4:return n?Ho.ASTC4x4UnormSRGB:Ho.ASTC4x4Unorm;case g.a.TEXTUREFORMAT_COMPRESSED_RGB_ETC1_WEBGL:return n?Ho.ETC2RGB8UnormSRGB:Ho.ETC2RGB8Unorm}switch(e){case g.a.TEXTURETYPE_BYTE:switch(t){case g.a.TEXTUREFORMAT_RED:return Ho.R8Snorm;case g.a.TEXTUREFORMAT_RG:return Ho.RG8Snorm;case g.a.TEXTUREFORMAT_RGB:throw"RGB format not supported in WebGPU";case g.a.TEXTUREFORMAT_RED_INTEGER:return Ho.R8Sint;case g.a.TEXTUREFORMAT_RG_INTEGER:return Ho.RG8Sint;case g.a.TEXTUREFORMAT_RGB_INTEGER:throw"RGB_INTEGER format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA_INTEGER:return Ho.RGBA8Sint;default:return Ho.RGBA8Snorm}case g.a.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case g.a.TEXTUREFORMAT_RED:return Ho.R8Unorm;case g.a.TEXTUREFORMAT_RG:return Ho.RG8Unorm;case g.a.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA:return n?Ho.RGBA8UnormSRGB:Ho.RGBA8Unorm;case g.a.TEXTUREFORMAT_BGRA:return n?Ho.BGRA8UnormSRGB:Ho.BGRA8Unorm;case g.a.TEXTUREFORMAT_RED_INTEGER:return Ho.R8Uint;case g.a.TEXTUREFORMAT_RG_INTEGER:return Ho.RG8Uint;case g.a.TEXTUREFORMAT_RGB_INTEGER:throw"RGB_INTEGER format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA_INTEGER:return Ho.RGBA8Uint;case g.a.TEXTUREFORMAT_ALPHA:throw"TEXTUREFORMAT_ALPHA format not supported in WebGPU";case g.a.TEXTUREFORMAT_LUMINANCE:throw"TEXTUREFORMAT_LUMINANCE format not supported in WebGPU";case g.a.TEXTUREFORMAT_LUMINANCE_ALPHA:throw"TEXTUREFORMAT_LUMINANCE_ALPHA format not supported in WebGPU";default:return Ho.RGBA8Unorm}case g.a.TEXTURETYPE_SHORT:switch(t){case g.a.TEXTUREFORMAT_RED_INTEGER:return Ho.R16Sint;case g.a.TEXTUREFORMAT_RG_INTEGER:return Ho.RG16Sint;case g.a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA_INTEGER:default:return Ho.RGBA16Sint}case g.a.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case g.a.TEXTUREFORMAT_RED_INTEGER:return Ho.R16Uint;case g.a.TEXTUREFORMAT_RG_INTEGER:return Ho.RG16Uint;case g.a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA_INTEGER:default:return Ho.RGBA16Uint}case g.a.TEXTURETYPE_INT:switch(t){case g.a.TEXTUREFORMAT_RED_INTEGER:return Ho.R32Sint;case g.a.TEXTUREFORMAT_RG_INTEGER:return Ho.RG32Sint;case g.a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA_INTEGER:default:return Ho.RGBA32Sint}case g.a.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case g.a.TEXTUREFORMAT_RED_INTEGER:return Ho.R32Uint;case g.a.TEXTUREFORMAT_RG_INTEGER:return Ho.RG32Uint;case g.a.TEXTUREFORMAT_RGB_INTEGER:throw"TEXTUREFORMAT_RGB_INTEGER format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA_INTEGER:default:return Ho.RGBA32Uint}case g.a.TEXTURETYPE_FLOAT:switch(t){case g.a.TEXTUREFORMAT_RED:return Ho.R32Float;case g.a.TEXTUREFORMAT_RG:return Ho.RG32Float;case g.a.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA:default:return Ho.RGBA32Float}case g.a.TEXTURETYPE_HALF_FLOAT:switch(t){case g.a.TEXTUREFORMAT_RED:return Ho.R16Float;case g.a.TEXTUREFORMAT_RG:return Ho.RG16Float;case g.a.TEXTUREFORMAT_RGB:throw"TEXTUREFORMAT_RGB format not supported in WebGPU";case g.a.TEXTUREFORMAT_RGBA:default:return Ho.RGBA16Float}case g.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:throw"TEXTURETYPE_UNSIGNED_SHORT_5_6_5 format not supported in WebGPU";case g.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:throw"TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV format not supported in WebGPU";case g.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:throw"TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV format not supported in WebGPU";case g.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:throw"TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 format not supported in WebGPU";case g.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:throw"TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 format not supported in WebGPU";case g.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case g.a.TEXTUREFORMAT_RGBA:return Ho.RGB10A2Unorm;case g.a.TEXTUREFORMAT_RGBA_INTEGER:throw"TEXTUREFORMAT_RGBA_INTEGER format not supported in WebGPU when type is TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV";default:return Ho.RGB10A2Unorm}}return n?Ho.RGBA8UnormSRGB:Ho.RGBA8Unorm},e.GetNumChannelsFromWebGPUTextureFormat=function(e){switch(e){case Ho.R8Unorm:case Ho.R8Snorm:case Ho.R8Uint:case Ho.R8Sint:case Ho.BC4RUnorm:case Ho.BC4RSnorm:case Ho.R16Uint:case Ho.R16Sint:case Ho.Depth16Unorm:case Ho.R16Float:case Ho.R32Uint:case Ho.R32Sint:case Ho.R32Float:case Ho.Depth32Float:case Ho.Stencil8:case Ho.Depth24Plus:case Ho.EACR11Unorm:case Ho.EACR11Snorm:return 1;case Ho.RG8Unorm:case Ho.RG8Snorm:case Ho.RG8Uint:case Ho.RG8Sint:case Ho.Depth24UnormStencil8:case Ho.Depth32FloatStencil8:case Ho.BC5RGUnorm:case Ho.BC5RGSnorm:case Ho.RG16Uint:case Ho.RG16Sint:case Ho.RG16Float:case Ho.RG32Uint:case Ho.RG32Sint:case Ho.RG32Float:case Ho.Depth24PlusStencil8:case Ho.EACRG11Unorm:case Ho.EACRG11Snorm:return 2;case Ho.RGB9E5UFloat:case Ho.RG11B10UFloat:case Ho.BC6HRGBUFloat:case Ho.BC6HRGBFloat:case Ho.ETC2RGB8Unorm:case Ho.ETC2RGB8UnormSRGB:return 3;case Ho.RGBA8Unorm:case Ho.RGBA8UnormSRGB:case Ho.RGBA8Snorm:case Ho.RGBA8Uint:case Ho.RGBA8Sint:case Ho.BGRA8Unorm:case Ho.BGRA8UnormSRGB:case Ho.RGB10A2Unorm:case Ho.BC7RGBAUnorm:case Ho.BC7RGBAUnormSRGB:case Ho.BC3RGBAUnorm:case Ho.BC3RGBAUnormSRGB:case Ho.BC2RGBAUnorm:case Ho.BC2RGBAUnormSRGB:case Ho.BC1RGBAUnorm:case Ho.BC1RGBAUnormSRGB:case Ho.RGBA16Uint:case Ho.RGBA16Sint:case Ho.RGBA16Float:case Ho.RGBA32Uint:case Ho.RGBA32Sint:case Ho.RGBA32Float:case Ho.ETC2RGB8A1Unorm:case Ho.ETC2RGB8A1UnormSRGB:case Ho.ETC2RGBA8Unorm:case Ho.ETC2RGBA8UnormSRGB:case Ho.ASTC4x4Unorm:case Ho.ASTC4x4UnormSRGB:case Ho.ASTC5x4Unorm:case Ho.ASTC5x4UnormSRGB:case Ho.ASTC5x5Unorm:case Ho.ASTC5x5UnormSRGB:case Ho.ASTC6x5Unorm:case Ho.ASTC6x5UnormSRGB:case Ho.ASTC6x6Unorm:case Ho.ASTC6x6UnormSRGB:case Ho.ASTC8x5Unorm:case Ho.ASTC8x5UnormSRGB:case Ho.ASTC8x6Unorm:case Ho.ASTC8x6UnormSRGB:case Ho.ASTC8x8Unorm:case Ho.ASTC8x8UnormSRGB:case Ho.ASTC10x5Unorm:case Ho.ASTC10x5UnormSRGB:case Ho.ASTC10x6Unorm:case Ho.ASTC10x6UnormSRGB:case Ho.ASTC10x8Unorm:case Ho.ASTC10x8UnormSRGB:case Ho.ASTC10x10Unorm:case Ho.ASTC10x10UnormSRGB:case Ho.ASTC12x10Unorm:case Ho.ASTC12x10UnormSRGB:case Ho.ASTC12x12Unorm:case Ho.ASTC12x12UnormSRGB:return 4}throw"Unknown format ".concat(e,"!")},e.HasStencilAspect=function(e){switch(e){case Ho.Stencil8:case Ho.Depth24UnormStencil8:case Ho.Depth32FloatStencil8:case Ho.Depth24PlusStencil8:return!0}return!1},e.prototype.invertYPreMultiplyAlpha=function(t,n,i,r,o,a,s,c,u,l,h,d,p,f,_){var m,g,v,b,y,T;void 0===o&&(o=!1),void 0===a&&(a=!1),void 0===s&&(s=0),void 0===c&&(c=0),void 0===u&&(u=1),void 0===l&&(l=0),void 0===h&&(h=0),void 0===d&&(d=0),void 0===p&&(p=0);var E,S=0!==d,A=void 0===f,x=this._getPipeline(r,S?Ga.InvertYPremultiplyAlphaWithOfst:Ga.InvertYPremultiplyAlpha,{invertY:o,premultiplyAlpha:a}),R=x[0],C=x[1];if(s=Math.max(s,0),A&&(f=this._device.createCommandEncoder({})),null===(g=(m=f).pushDebugGroup)||void 0===g||g.call(m,"internal process texture - invertY=".concat(o," premultiplyAlpha=").concat(a)),e._IsHardwareTexture(t)?(E=t.underlyingResource,o&&!a&&1===u&&0===s||(t=void 0)):(E=t,t=void 0),E){S&&this._bufferManager.setRawData(this._ubCopyWithOfst,0,new Float32Array([l,h,d,p]),0,16);var P=t,O=null!==(v=null==P?void 0:P._copyInvertYTempTexture)&&void 0!==v?v:this.createTexture({width:n,height:i,layers:1},!1,!1,!1,!1,!1,r,1,f,zo.CopySrc|zo.RenderAttachment|zo.TextureBinding),M=null!==(b=null==P?void 0:P._copyInvertYRenderPassDescr)&&void 0!==b?b:{colorAttachments:[{view:O.createView({format:r,dimension:jo.E2d,baseMipLevel:0,mipLevelCount:1,arrayLayerCount:1,baseArrayLayer:0}),loadOp:pa.Load,storeOp:fa.Store}]},I=f.beginRenderPass(M),D=S?null==P?void 0:P._copyInvertYBindGroupWithOfst:null==P?void 0:P._copyInvertYBindGroup;if(!D){var N={layout:C,entries:[{binding:0,resource:E.createView({format:r,dimension:jo.E2d,baseMipLevel:c,mipLevelCount:1,arrayLayerCount:u,baseArrayLayer:s})}]};S&&N.entries.push({binding:1,resource:{buffer:this._ubCopyWithOfst}}),D=this._device.createBindGroup(N)}I.setPipeline(R),I.setBindGroup(0,D),I.draw(4,1,0,0),I.end(),f.copyTextureToTexture({texture:O},{texture:E,mipLevel:c,origin:{x:0,y:0,z:s}},{width:n,height:i,depthOrArrayLayers:1}),P?(P._copyInvertYTempTexture=O,P._copyInvertYRenderPassDescr=M,S?P._copyInvertYBindGroupWithOfst=D:P._copyInvertYBindGroup=D):this._deferredReleaseTextures.push([O,null]),null===(T=(y=f).popDebugGroup)||void 0===T||T.call(y),A&&(this._device.queue.submit([f.finish()]),f=null)}},e.prototype.copyWithInvertY=function(e,t,n,i){var r,o,a,s,c=void 0===i,u=this._getPipeline(t,Ga.InvertYPremultiplyAlpha,{invertY:!0,premultiplyAlpha:!1}),l=u[0],h=u[1];c&&(i=this._device.createCommandEncoder({})),null===(o=(r=i).pushDebugGroup)||void 0===o||o.call(r,"internal copy texture with invertY");var d=i.beginRenderPass(n),p=this._device.createBindGroup({layout:h,entries:[{binding:0,resource:e}]});d.setPipeline(l),d.setBindGroup(0,p),d.draw(4,1,0,0),d.end(),null===(s=(a=i).popDebugGroup)||void 0===s||s.call(a),c&&(this._device.queue.submit([i.finish()]),i=null)},e.prototype.createTexture=function(t,n,i,r,o,a,s,c,u,l,h){void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=!1),void 0===s&&(s=Ho.RGBA8Unorm),void 0===c&&(c=1),void 0===l&&(l=-1),void 0===h&&(h=0),c>1&&(c=4);var d=t.layers||1,p={width:t.width,height:t.height,depthOrArrayLayers:d},f=e.IsCompressedFormat(s),_=n?e.ComputeNumMipmapLevels(t.width,t.height):1,m=l>=0?l:zo.CopySrc|zo.CopyDst|zo.TextureBinding;h|=n&&!f?zo.CopySrc|zo.RenderAttachment:0,f||(h|=zo.RenderAttachment|zo.CopyDst);var g=this._device.createTexture({size:p,dimension:a?Go.E3d:Go.E2d,format:s,usage:m|h,sampleCount:c,mipLevelCount:_});return e.IsImageBitmap(t)&&(this.updateTexture(t,g,t.width,t.height,d,s,0,0,r,o,0,0),n&&i&&this.generateMipmaps(g,s,_,0,u)),g},e.prototype.createCubeTexture=function(t,n,i,r,o,a,s,c,u,l){void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===a&&(a=Ho.RGBA8Unorm),void 0===s&&(s=1),void 0===u&&(u=-1),void 0===l&&(l=0),s>1&&(s=4);var h=e.IsImageBitmapArray(t)?t[0].width:t.width,d=e.IsImageBitmapArray(t)?t[0].height:t.height,p=e.IsCompressedFormat(a),f=n?e.ComputeNumMipmapLevels(h,d):1,_=u>=0?u:zo.CopySrc|zo.CopyDst|zo.TextureBinding;l|=n&&!p?zo.CopySrc|zo.RenderAttachment:0,p||(l|=zo.RenderAttachment|zo.CopyDst);var m=this._device.createTexture({size:{width:h,height:d,depthOrArrayLayers:6},dimension:Go.E2d,format:a,usage:_|l,sampleCount:s,mipLevelCount:f});return e.IsImageBitmapArray(t)&&(this.updateCubeTextures(t,m,h,d,a,r,o,0,0),n&&i&&this.generateCubeMipmaps(m,a,f,c)),m},e.prototype.generateCubeMipmaps=function(e,t,n,i){var r,o,a,s,c=void 0===i;c&&(i=this._device.createCommandEncoder({})),null===(o=(r=i).pushDebugGroup)||void 0===o||o.call(r,"create cube mipmaps - ".concat(n," levels"));for(var u=0;u<6;++u)this.generateMipmaps(e,t,n,u,i);null===(s=(a=i).popDebugGroup)||void 0===s||s.call(a),c&&(this._device.queue.submit([i.finish()]),i=null)},e.prototype.generateMipmaps=function(t,n,i,r,o){var a,s,c,u,l,h,d,p;void 0===r&&(r=0);var f,_=void 0===o,m=this._getPipeline(n),g=m[0],v=m[1];if(r=Math.max(r,0),_&&(o=this._device.createCommandEncoder({})),null===(s=(a=o).pushDebugGroup)||void 0===s||s.call(a,"create mipmaps for face #".concat(r," - ").concat(i," levels")),e._IsHardwareTexture(t)?(f=t.underlyingResource,t._mipmapGenRenderPassDescr=t._mipmapGenRenderPassDescr||[],t._mipmapGenBindGroup=t._mipmapGenBindGroup||[]):(f=t,t=void 0),f){for(var b=t,y=1;y15728640;)this._device.queue.writeBuffer(o,t+l,n.buffer,a+l,15728640),l+=15728640;this._device.queue.writeBuffer(o,t+l,n.buffer,a+l,r-l)},e.prototype._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,t,n){n||(n=new Float32Array(e));for(var i=new Uint16Array(t);e--;)n[e]=to(i[e]);return n},e.prototype.readDataFromBuffer=function(e,t,n,i,r,o,a,s,c,u,l){var h=this;void 0===a&&(a=g.a.TEXTURETYPE_UNSIGNED_BYTE),void 0===s&&(s=0),void 0===c&&(c=null),void 0===u&&(u=!0),void 0===l&&(l=!1);var d=a===g.a.TEXTURETYPE_FLOAT?2:a===g.a.TEXTURETYPE_HALF_FLOAT?1:0;return new Promise((function(n,p){e.mapAsync(ko.Read,s,t).then((function(){var p=e.getMappedRange(s,t),f=c;if(l)f=null===f?Object(Br.a)(a,t,!0,p):Object(Br.a)(a,f.buffer,void 0,p);else if(null===f)switch(d){case 0:(f=new Uint8Array(t)).set(new Uint8Array(p));break;case 1:f=h._GetHalfFloatAsFloatRGBAArrayBuffer(t/2,p);break;case 2:(f=new Float32Array(t/4)).set(new Float32Array(p))}else switch(d){case 0:(f=new Uint8Array(f.buffer)).set(new Uint8Array(p));break;case 1:f=h._GetHalfFloatAsFloatRGBAArrayBuffer(t/2,p,c);break;case 2:(f=new Float32Array(f.buffer)).set(new Float32Array(p))}if(r!==o){1!==d||l||(r*=2,o*=2);for(var _=new Uint8Array(f.buffer),m=r,g=0,v=1;v1?4:1;return $a[e.samplingMode]+es[(e._comparisonFunction||514)-512+1]+ts[e.samplingMode]+((null!==(t=e._cachedWrapU)&&void 0!==t?t:1)<<8)+((null!==(n=e._cachedWrapV)&&void 0!==n?n:1)<<10)+((null!==(i=e._cachedWrapR)&&void 0!==i?i:1)<<12)+((e.useMipMaps?1:0)<<14)+(r<<15)},e._GetSamplerFilterDescriptor=function(e,t){var n,i,r,o,a,s=e.useMipMaps;switch(e.samplingMode){case g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST:n=Yo.Linear,i=Yo.Linear,r=Yo.Nearest,s||(o=a=0);break;case g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR:case g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:n=Yo.Linear,i=Yo.Linear,s?r=Yo.Linear:(r=Yo.Nearest,o=a=0);break;case g.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR:n=Yo.Nearest,i=Yo.Nearest,s?r=Yo.Linear:(r=Yo.Nearest,o=a=0);break;case g.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST:n=Yo.Nearest,i=Yo.Nearest,r=Yo.Nearest,s||(o=a=0);break;case g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST:n=Yo.Nearest,i=Yo.Linear,r=Yo.Nearest,s||(o=a=0);break;case g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR:n=Yo.Nearest,i=Yo.Linear,s?r=Yo.Linear:(r=Yo.Nearest,o=a=0);break;case g.a.TEXTURE_NEAREST_LINEAR:n=Yo.Nearest,i=Yo.Linear,r=Yo.Nearest,o=a=0;break;case g.a.TEXTURE_NEAREST_NEAREST:case g.a.TEXTURE_NEAREST_SAMPLINGMODE:n=Yo.Nearest,i=Yo.Nearest,r=Yo.Nearest,o=a=0;break;case g.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST:n=Yo.Linear,i=Yo.Nearest,r=Yo.Nearest,s||(o=a=0);break;case g.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR:n=Yo.Linear,i=Yo.Nearest,s?r=Yo.Linear:(r=Yo.Nearest,o=a=0);break;case g.a.TEXTURE_LINEAR_LINEAR:case g.a.TEXTURE_BILINEAR_SAMPLINGMODE:n=Yo.Linear,i=Yo.Linear,r=Yo.Nearest,o=a=0;break;case g.a.TEXTURE_LINEAR_NEAREST:n=Yo.Linear,i=Yo.Nearest,r=Yo.Nearest,o=a=0;break;default:n=Yo.Nearest,i=Yo.Nearest,r=Yo.Nearest,o=a=0}return t>1&&(0!==o||0!==a)?{magFilter:Yo.Linear,minFilter:Yo.Linear,mipmapFilter:Yo.Linear,anisotropyEnabled:!0}:{magFilter:n,minFilter:i,mipmapFilter:r,lodMinClamp:o,lodMaxClamp:a}},e._GetWrappingMode=function(e){switch(e){case g.a.TEXTURE_WRAP_ADDRESSMODE:return Xo.Repeat;case g.a.TEXTURE_CLAMP_ADDRESSMODE:return Xo.ClampToEdge;case g.a.TEXTURE_MIRROR_ADDRESSMODE:return Xo.MirrorRepeat}return Xo.Repeat},e._GetSamplerWrappingDescriptor=function(e){return{addressModeU:this._GetWrappingMode(e._cachedWrapU),addressModeV:this._GetWrappingMode(e._cachedWrapV),addressModeW:this._GetWrappingMode(e._cachedWrapR)}},e._GetSamplerDescriptor=function(t){var n=t.useMipMaps&&t._cachedAnisotropicFilteringLevel&&t._cachedAnisotropicFilteringLevel>1?4:1,i=this._GetSamplerFilterDescriptor(t,n);return Object(h.a)(Object(h.a)(Object(h.a)({},i),this._GetSamplerWrappingDescriptor(t)),{compare:t._comparisonFunction?e.GetCompareFunction(t._comparisonFunction):void 0,maxAnisotropy:i.anisotropyEnabled?n:1})},e.GetCompareFunction=function(e){switch(e){case g.a.ALWAYS:return Ko.Always;case g.a.EQUAL:return Ko.Equal;case g.a.GREATER:return Ko.Greater;case g.a.GEQUAL:return Ko.GreaterEqual;case g.a.LESS:return Ko.Less;case g.a.LEQUAL:return Ko.LessEqual;case g.a.NEVER:return Ko.Never;case g.a.NOTEQUAL:return Ko.NotEqual;default:return Ko.Less}},e.prototype.getSampler=function(t,n,i){if(void 0===n&&(n=!1),void 0===i&&(i=0),this.disabled)return this._device.createSampler(e._GetSamplerDescriptor(t));n?i=0:0===i&&(i=e.GetSamplerHashCode(t));var r=n?void 0:this._samplers[i];return r||(r=this._device.createSampler(e._GetSamplerDescriptor(t)),n||(this._samplers[i]=r)),r},e}();!function(e){e[e.StencilReadMask=0]="StencilReadMask",e[e.StencilWriteMask=1]="StencilWriteMask",e[e.DepthBias=2]="DepthBias",e[e.DepthBiasSlopeScale=3]="DepthBiasSlopeScale",e[e.DepthStencilState=4]="DepthStencilState",e[e.MRTAttachments1=5]="MRTAttachments1",e[e.MRTAttachments2=6]="MRTAttachments2",e[e.RasterizationState=7]="RasterizationState",e[e.ColorStates=8]="ColorStates",e[e.ShaderStage=9]="ShaderStage",e[e.TextureStage=10]="TextureStage",e[e.VertexState=11]="VertexState",e[e.NumStates=12]="NumStates"}(Xa||(Xa={}));var is={0:1,1:2,768:3,769:4,770:5,771:6,772:7,773:8,774:9,775:10,776:11,32769:12,32770:13,32771:12,32772:13},rs={0:0,7680:1,7681:2,7682:3,7683:4,5386:5,34055:6,34056:7},os=function(){function e(e,t,n){this.mrtTextureCount=0,this._device=e,this._useTextureStage=n,this._states=new Array(30),this._statesLength=0,this._stateDirtyLowestIndex=0,this._emptyVertexBuffer=t,this._mrtFormats=[],this._parameter={token:void 0,pipeline:null},this.disabled=!1,this.vertexBuffers=[],this._kMaxVertexBufferStride=e.limits.maxVertexBufferArrayStride||2048,this.reset()}return e.prototype.reset=function(){this._isDirty=!0,this.vertexBuffers.length=0,this.setAlphaToCoverage(!1),this.resetDepthCullingState(),this.setClampDepth(!1),this.setDepthBias(0),this._webgpuColorFormat=[Ho.BGRA8Unorm],this.setColorFormat(Ho.BGRA8Unorm),this.setMRT([]),this.setAlphaBlendEnabled(!1),this.setAlphaBlendFactors([null,null,null,null],[null,null]),this.setWriteMask(15),this.setDepthStencilFormat(Ho.Depth24PlusStencil8),this.setStencilEnabled(!1),this.resetStencilState(),this.setBuffers(null,null,null),this._setTextureState(0)},Object.defineProperty(e.prototype,"colorFormats",{get:function(){return this._mrtAttachments1>0?this._mrtFormats:this._webgpuColorFormat},enumerable:!1,configurable:!0}),e.prototype.getRenderPipeline=function(t,n,i,r){if(void 0===r&&(r=0),i>1&&(i=4),this.disabled){var o=e._GetTopology(t);return this._setVertexState(n),this._parameter.pipeline=this._createRenderPipeline(n,o,i),e.NumCacheMiss++,e._NumPipelineCreationCurrentFrame++,this._parameter.pipeline}if(this._setShaderStage(n.uniqueId),this._setRasterizationState(t,i),this._setColorStates(),this._setDepthStencilState(),this._setVertexState(n),this._setTextureState(r),this.lastStateDirtyLowestIndex=this._stateDirtyLowestIndex,!this._isDirty&&this._parameter.pipeline)return this._stateDirtyLowestIndex=this._statesLength,e.NumCacheHitWithoutHash++,this._parameter.pipeline;if(this._getRenderPipeline(this._parameter),this._isDirty=!1,this._stateDirtyLowestIndex=this._statesLength,this._parameter.pipeline)return e.NumCacheHitWithHash++,this._parameter.pipeline;var a=e._GetTopology(t);return this._parameter.pipeline=this._createRenderPipeline(n,a,i),this._setRenderPipeline(this._parameter),e.NumCacheMiss++,e._NumPipelineCreationCurrentFrame++,this._parameter.pipeline},e.prototype.endFrame=function(){e.NumPipelineCreationLastFrame=e._NumPipelineCreationCurrentFrame,e._NumPipelineCreationCurrentFrame=0},e.prototype.setAlphaToCoverage=function(e){this._alphaToCoverageEnabled=e},e.prototype.setFrontFace=function(e){this._frontFace=e},e.prototype.setCullEnabled=function(e){this._cullEnabled=e},e.prototype.setCullFace=function(e){this._cullFace=e},e.prototype.setClampDepth=function(e){this._clampDepth=e},e.prototype.resetDepthCullingState=function(){this.setDepthCullingState(!1,2,1,0,0,!0,!0,g.a.ALWAYS)},e.prototype.setDepthCullingState=function(e,t,n,i,r,o,a,s){this._depthWriteEnabled=a,this._depthTestEnabled=o,this._depthCompare=(null!=s?s:g.a.ALWAYS)-512,this._cullFace=n,this._cullEnabled=e,this._frontFace=t,this.setDepthBiasSlopeScale(i),this.setDepthBias(r)},e.prototype.setDepthBias=function(e){this._depthBias!==e&&(this._depthBias=e,this._states[Xa.DepthBias]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.DepthBias))},e.prototype.setDepthBiasSlopeScale=function(e){this._depthBiasSlopeScale!==e&&(this._depthBiasSlopeScale=e,this._states[Xa.DepthBiasSlopeScale]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.DepthBiasSlopeScale))},e.prototype.setColorFormat=function(e){this._webgpuColorFormat[0]=e,this._colorFormat=Ka[e]},e.prototype.setMRTAttachments=function(e){this.mrtAttachments=e;for(var t=0,n=0;n10)throw"Can't handle more than 10 attachments for a MRT in cache render pipeline!";this.mrtTextureArray=e,this.mrtTextureCount=t,this._mrtEnabledMask=65535;for(var i=[0,0],r=0,o=0,a=0,s=0;s=32&&(o=0,r++)}this._mrtFormats.length=a,this._mrtAttachments1===i[0]&&this._mrtAttachments2===i[1]||(this._mrtAttachments1=i[0],this._mrtAttachments2=i[1],this._states[Xa.MRTAttachments1]=i[0],this._states[Xa.MRTAttachments2]=i[1],this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.MRTAttachments1))},e.prototype.setAlphaBlendEnabled=function(e){this._alphaBlendEnabled=e},e.prototype.setAlphaBlendFactors=function(e,t){this._alphaBlendFuncParams=e,this._alphaBlendEqParams=t},e.prototype.setWriteMask=function(e){this._writeMask=e},e.prototype.setDepthStencilFormat=function(e){this._webgpuDepthStencilFormat=e,this._depthStencilFormat=void 0===e?0:Ka[e]},e.prototype.setDepthTestEnabled=function(e){this._depthTestEnabled=e},e.prototype.setDepthWriteEnabled=function(e){this._depthWriteEnabled=e},e.prototype.setDepthCompare=function(e){this._depthCompare=(null!=e?e:g.a.ALWAYS)-512},e.prototype.setStencilEnabled=function(e){this._stencilEnabled=e},e.prototype.setStencilCompare=function(e){this._stencilFrontCompare=(null!=e?e:g.a.ALWAYS)-512},e.prototype.setStencilDepthFailOp=function(e){this._stencilFrontDepthFailOp=null===e?1:rs[e]},e.prototype.setStencilPassOp=function(e){this._stencilFrontPassOp=null===e?2:rs[e]},e.prototype.setStencilFailOp=function(e){this._stencilFrontFailOp=null===e?1:rs[e]},e.prototype.setStencilReadMask=function(e){this._stencilReadMask!==e&&(this._stencilReadMask=e,this._states[Xa.StencilReadMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.StencilReadMask))},e.prototype.setStencilWriteMask=function(e){this._stencilWriteMask!==e&&(this._stencilWriteMask=e,this._states[Xa.StencilWriteMask]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.StencilWriteMask))},e.prototype.resetStencilState=function(){this.setStencilState(!1,g.a.ALWAYS,g.a.KEEP,g.a.REPLACE,g.a.KEEP,255,255)},e.prototype.setStencilState=function(e,t,n,i,r,o,a){this._stencilEnabled=e,this._stencilFrontCompare=(null!=t?t:g.a.ALWAYS)-512,this._stencilFrontDepthFailOp=null===n?1:rs[n],this._stencilFrontPassOp=null===i?2:rs[i],this._stencilFrontFailOp=null===r?1:rs[r],this.setStencilReadMask(o),this.setStencilWriteMask(a)},e.prototype.setBuffers=function(e,t,n){this._vertexBuffers=e,this._overrideVertexBuffers=n,this._indexBuffer=t},e._GetTopology=function(e){switch(e){case g.a.MATERIAL_TriangleFillMode:return ta.TriangleList;case g.a.MATERIAL_PointFillMode:return ta.PointList;case g.a.MATERIAL_WireFrameFillMode:return ta.LineList;case g.a.MATERIAL_PointListDrawMode:return ta.PointList;case g.a.MATERIAL_LineListDrawMode:return ta.LineList;case g.a.MATERIAL_LineLoopDrawMode:throw"LineLoop is an unsupported fillmode in WebGPU";case g.a.MATERIAL_LineStripDrawMode:return ta.LineStrip;case g.a.MATERIAL_TriangleStripDrawMode:return ta.TriangleStrip;case g.a.MATERIAL_TriangleFanDrawMode:throw"TriangleFan is an unsupported fillmode in WebGPU";default:return ta.TriangleList}},e._GetAphaBlendOperation=function(e){switch(e){case g.a.GL_ALPHA_EQUATION_ADD:return aa.Add;case g.a.GL_ALPHA_EQUATION_SUBTRACT:return aa.Subtract;case g.a.GL_ALPHA_EQUATION_REVERSE_SUBTRACT:return aa.ReverseSubtract;case g.a.GL_ALPHA_EQUATION_MIN:return aa.Min;case g.a.GL_ALPHA_EQUATION_MAX:return aa.Max;default:return aa.Add}},e._GetAphaBlendFactor=function(e){switch(e){case 0:return oa.Zero;case 1:return oa.One;case g.a.GL_ALPHA_FUNCTION_SRC:return oa.Src;case g.a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_COLOR:return oa.OneMinusSrc;case g.a.GL_ALPHA_FUNCTION_SRC_ALPHA:return oa.SrcAlpha;case g.a.GL_ALPHA_FUNCTION_ONE_MINUS_SRC_ALPHA:return oa.OneMinusSrcAlpha;case g.a.GL_ALPHA_FUNCTION_DST_ALPHA:return oa.DstAlpha;case g.a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_ALPHA:return oa.OneMinusDstAlpha;case g.a.GL_ALPHA_FUNCTION_DST_COLOR:return oa.Dst;case g.a.GL_ALPHA_FUNCTION_ONE_MINUS_DST_COLOR:return oa.OneMinusDst;case g.a.GL_ALPHA_FUNCTION_SRC_ALPHA_SATURATED:return oa.SrcAlphaSaturated;case g.a.GL_ALPHA_FUNCTION_CONSTANT_COLOR:return oa.Constant;case g.a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_COLOR:return oa.OneMinusConstant;case g.a.GL_ALPHA_FUNCTION_CONSTANT_ALPHA:return oa.Constant;case g.a.GL_ALPHA_FUNCTION_ONE_MINUS_CONSTANT_ALPHA:return oa.OneMinusConstant;default:return oa.One}},e._GetCompareFunction=function(e){switch(e){case 0:return Ko.Never;case 1:return Ko.Less;case 2:return Ko.Equal;case 3:return Ko.LessEqual;case 4:return Ko.Greater;case 5:return Ko.NotEqual;case 6:return Ko.GreaterEqual;case 7:return Ko.Always}return Ko.Never},e._GetStencilOpFunction=function(e){switch(e){case 0:return sa.Zero;case 1:return sa.Keep;case 2:return sa.Replace;case 3:return sa.IncrementClamp;case 4:return sa.DecrementClamp;case 5:return sa.Invert;case 6:return sa.IncrementWrap;case 7:return sa.DecrementWrap}return sa.Keep},e._GetVertexInputDescriptorFormat=function(e){var t=e.type,n=e.normalized,i=e.getSize();switch(t){case bt.b.BYTE:switch(i){case 1:case 2:return n?ua.Snorm8x2:ua.Sint8x2;case 3:case 4:return n?ua.Snorm8x4:ua.Sint8x4}break;case bt.b.UNSIGNED_BYTE:switch(i){case 1:case 2:return n?ua.Unorm8x2:ua.Uint8x2;case 3:case 4:return n?ua.Unorm8x4:ua.Uint8x4}break;case bt.b.SHORT:switch(i){case 1:case 2:return n?ua.Snorm16x2:ua.Sint16x2;case 3:case 4:return n?ua.Snorm16x4:ua.Sint16x4}break;case bt.b.UNSIGNED_SHORT:switch(i){case 1:case 2:return n?ua.Unorm16x2:ua.Uint16x2;case 3:case 4:return n?ua.Unorm16x4:ua.Uint16x4}break;case bt.b.INT:switch(i){case 1:return ua.Sint32;case 2:return ua.Sint32x2;case 3:return ua.Sint32x3;case 4:return ua.Sint32x4}break;case bt.b.UNSIGNED_INT:switch(i){case 1:return ua.Uint32;case 2:return ua.Uint32x2;case 3:return ua.Uint32x3;case 4:return ua.Uint32x4}break;case bt.b.FLOAT:switch(i){case 1:return ua.Float32;case 2:return ua.Float32x2;case 3:return ua.Float32x3;case 4:return ua.Float32x4}}throw new Error("Invalid Format '".concat(e.getKind(),"' - type=").concat(t,", normalized=").concat(n,", size=").concat(i))},e.prototype._getAphaBlendState=function(){return this._alphaBlendEnabled?{srcFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[2]),dstFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[3]),operation:e._GetAphaBlendOperation(this._alphaBlendEqParams[1])}:null},e.prototype._getColorBlendState=function(){return this._alphaBlendEnabled?{srcFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[0]),dstFactor:e._GetAphaBlendFactor(this._alphaBlendFuncParams[1]),operation:e._GetAphaBlendOperation(this._alphaBlendEqParams[0])}:null},e.prototype._setShaderStage=function(e){this._shaderId!==e&&(this._shaderId=e,this._states[Xa.ShaderStage]=e,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.ShaderStage))},e.prototype._setRasterizationState=function(e,t){var n=this._frontFace-1+((this._cullEnabled?this._cullFace:0)<<1)+((this._clampDepth?1:0)<<3)+((this._alphaToCoverageEnabled?1:0)<<4)+(e<<5)+(t<<8);this._rasterizationState!==n&&(this._rasterizationState=n,this._states[Xa.RasterizationState]=this._rasterizationState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.RasterizationState))},e.prototype._setColorStates=function(){var e=((this._writeMask?1:0)<<22)+(this._colorFormat<<23)+((this._depthWriteEnabled?1:0)<<29);this._alphaBlendEnabled&&(e+=((null===this._alphaBlendFuncParams[0]?2:is[this._alphaBlendFuncParams[0]])<<0)+((null===this._alphaBlendFuncParams[1]?2:is[this._alphaBlendFuncParams[1]])<<4)+((null===this._alphaBlendFuncParams[2]?2:is[this._alphaBlendFuncParams[2]])<<8)+((null===this._alphaBlendFuncParams[3]?2:is[this._alphaBlendFuncParams[3]])<<12)+((null===this._alphaBlendEqParams[0]?1:this._alphaBlendEqParams[0]-32773)<<16)+((null===this._alphaBlendEqParams[1]?1:this._alphaBlendEqParams[1]-32773)<<19)),e!==this._colorStates&&(this._colorStates=e,this._states[Xa.ColorStates]=this._colorStates,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.ColorStates))},e.prototype._setDepthStencilState=function(){var e=this._stencilEnabled?this._stencilFrontCompare+(this._stencilFrontDepthFailOp<<3)+(this._stencilFrontPassOp<<6)+(this._stencilFrontFailOp<<9):591,t=this._depthStencilFormat+((this._depthTestEnabled?this._depthCompare:7)<<6)+(e<<10);this._depthStencilState!==t&&(this._depthStencilState=t,this._states[Xa.DepthStencilState]=this._depthStencilState,this._isDirty=!0,this._stateDirtyLowestIndex=Math.min(this._stateDirtyLowestIndex,Xa.DepthStencilState))},e.prototype._setVertexState=function(e){for(var t,n,i,r=this._statesLength,o=Xa.VertexState,a=e._pipelineContext,s=a.shaderProcessingContext.attributeNamesFromEffect,c=a.shaderProcessingContext.attributeLocationsFromEffect,u=0,l=0;l0)for(var l=0;l=this._video.HAVE_CURRENT_DATA},e.prototype.dispose=function(){},e}(),ps=function(){function e(){this.uniqueId=e._Counter++,this.updateId=0,this.reset()}return Object.defineProperty(e.prototype,"forceBindGroupCreation",{get:function(){return this._numExternalTextures>0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasFloatTextures",{get:function(){return this._numFloatTextures>0},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this.samplers={},this.textures={},this.isDirty=!0,this._numFloatTextures=0,this._numExternalTextures=0},e.prototype.setSampler=function(e,t){var n=this.samplers[e],i=-1;n?i=n.hashCode:this.samplers[e]=n={sampler:t,hashCode:0},n.sampler=t,n.hashCode=t?ns.GetSamplerHashCode(t):0;var r=i!==n.hashCode;r&&this.updateId++,this.isDirty||(this.isDirty=r)},e.prototype.setTexture=function(e,t){var n,i,r,o=this.textures[e],a=-1;o?a=null!==(i=null===(n=o.texture)||void 0===n?void 0:n.uniqueId)&&void 0!==i?i:-1:this.textures[e]=o={texture:t,isFloatTexture:!1,isExternalTexture:!1},o.isExternalTexture&&this._numExternalTextures--,o.isFloatTexture&&this._numFloatTextures--,t?(o.isFloatTexture=t.type===g.a.TEXTURETYPE_FLOAT,o.isExternalTexture=ds.IsExternalTexture(t),o.isFloatTexture&&this._numFloatTextures++,o.isExternalTexture&&this._numExternalTextures++):(o.isFloatTexture=!1,o.isExternalTexture=!1),o.texture=t;var s=a!==(null!==(r=null==t?void 0:t.uniqueId)&&void 0!==r?r:-1);s&&this.updateId++,this.isDirty||(this.isDirty=s)},e._Counter=0,e}(),fs=function(){function e(t){this._bufferManager=t,this.uniqueId=e._Counter++,this._useInstancing=!1,this._currentInstanceCount=0,this.reset()}return e.prototype.isDirty=function(e){return this._isDirty||this._materialContextUpdateId!==e},e.prototype.resetIsDirty=function(e){this._isDirty=!1,this._materialContextUpdateId=e},Object.defineProperty(e.prototype,"useInstancing",{get:function(){return this._useInstancing},set:function(e){this._useInstancing!==e&&(e?(this.indirectDrawBuffer=this._bufferManager.createRawBuffer(40,Vo.CopyDst|Vo.Indirect),this._indirectDrawData=new Uint32Array(5),this._indirectDrawData[3]=0,this._indirectDrawData[4]=0):(this.indirectDrawBuffer&&this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this._useInstancing=e,this._currentInstanceCount=-1)},enumerable:!1,configurable:!0}),e.prototype.reset=function(){this.buffers={},this._isDirty=!0,this._materialContextUpdateId=0,this.fastBundle=void 0,this.bindGroups=void 0},e.prototype.setBuffer=function(e,t){var n;this._isDirty||(this._isDirty=(null==t?void 0:t.uniqueId)!==(null===(n=this.buffers[e])||void 0===n?void 0:n.uniqueId)),this.buffers[e]=t},e.prototype.setIndirectData=function(e,t,n){t!==this._currentInstanceCount&&this.indirectDrawBuffer&&this._indirectDrawData&&(this._currentInstanceCount=t,this._indirectDrawData[0]=e,this._indirectDrawData[1]=t,this._indirectDrawData[2]=n,this._bufferManager.setRawData(this.indirectDrawBuffer,0,this._indirectDrawData,0,20))},e.prototype.dispose=function(){this.indirectDrawBuffer&&(this._bufferManager.releaseBuffer(this.indirectDrawBuffer),this.indirectDrawBuffer=void 0,this._indirectDrawData=void 0),this.fastBundle=void 0,this.bindGroups=void 0,this.buffers=void 0},e._Counter=0,e}(),_s=function(){this.values={}},ms=function(){function e(e,t,n){this.disabled=!1,this._device=e,this._cacheSampler=t,this._engine=n}return Object.defineProperty(e,"Statistics",{get:function(){return{totalCreated:e.NumBindGroupsCreatedTotal,lastFrameCreated:e.NumBindGroupsCreatedLastFrame,lookupLastFrame:e.NumBindGroupsLookupLastFrame,noLookupLastFrame:e.NumBindGroupsNoLookupLastFrame}},enumerable:!1,configurable:!0}),e.prototype.endFrame=function(){e.NumBindGroupsCreatedLastFrame=e._NumBindGroupsCreatedCurrentFrame,e.NumBindGroupsLookupLastFrame=e._NumBindGroupsLookupCurrentFrame,e.NumBindGroupsNoLookupLastFrame=e._NumBindGroupsNoLookupCurrentFrame,e._NumBindGroupsCreatedCurrentFrame=0,e._NumBindGroupsLookupCurrentFrame=0,e._NumBindGroupsNoLookupCurrentFrame=0},e.prototype.getBindGroups=function(t,n,i){var r,o,a,s,c,u,l,h,d,p,f=void 0,_=e._Cache,g=this.disabled||i.forceBindGroupCreation;if(!g){if(!n.isDirty(i.updateId)&&!i.isDirty)return e._NumBindGroupsNoLookupCurrentFrame++,n.bindGroups;for(var v=0,b=t.shaderProcessingContext.bufferNames;v":t})),", materialContext.uniqueId=").concat(i.uniqueId),50);continue}L[F].resource=this._cacheSampler.getSampler(V,!1,G.hashCode)}else m.a.Error('Sampler "'.concat(U,'" could not be bound. entry=').concat(JSON.stringify(w),", materialContext=").concat(JSON.stringify(i,(function(e,t){return"texture"===e||"sampler"===e?"":t}))),50);else if(w.texture||w.storageTexture){if(G=i.textures[U]){if(this._engine.dbgSanityChecks&&null===G.texture){m.a.Error("Trying to bind a null texture! entry=".concat(JSON.stringify(w),", bindingInfo=").concat(JSON.stringify(G,(function(e,t){return"texture"===e?"":t})),", materialContext.uniqueId=").concat(i.uniqueId),50);continue}var k=G.texture._hardwareTexture;if(this._engine.dbgSanityChecks&&(!k||w.texture&&!k.view||w.storageTexture&&!k.viewForWriting)){m.a.Error("Trying to bind a null gpu texture or view! entry=".concat(JSON.stringify(w),", name=").concat(U,", bindingInfo=").concat(JSON.stringify(G,(function(e,t){return"texture"===e?"":t})),", isReady=").concat(null===(d=G.texture)||void 0===d?void 0:d.isReady,", materialContext.uniqueId=").concat(i.uniqueId),50);continue}L[F].resource=w.storageTexture?k.viewForWriting:k.view}else m.a.Error('Texture "'.concat(U,'" could not be bound. entry=').concat(JSON.stringify(w),", materialContext=").concat(JSON.stringify(i,(function(e,t){return"texture"===e||"sampler"===e?"":t}))),50)}else if(w.externalTexture){var G;if(G=i.textures[U]){if(this._engine.dbgSanityChecks&&null===G.texture){m.a.Error("Trying to bind a null external texture! entry=".concat(JSON.stringify(w),", name=").concat(U,", bindingInfo=").concat(JSON.stringify(G,(function(e,t){return"texture"===e?"":t})),", materialContext.uniqueId=").concat(i.uniqueId),50);continue}var z=G.texture.underlyingResource;if(this._engine.dbgSanityChecks&&!z){m.a.Error("Trying to bind a null gpu external texture! entry=".concat(JSON.stringify(w),", name=").concat(U,", bindingInfo=").concat(JSON.stringify(G,(function(e,t){return"texture"===e?"":t})),", isReady=").concat(null===(p=G.texture)||void 0===p?void 0:p.isReady,", materialContext.uniqueId=").concat(i.uniqueId),50);continue}L[F].resource=this._device.importExternalTexture({source:z})}else m.a.Error('Texture "'.concat(U,'" could not be bound. entry=').concat(JSON.stringify(w),", materialContext=").concat(JSON.stringify(i,(function(e,t){return"texture"===e||"sampler"===e?"":t}))),50)}else if(w.buffer){var j=n.buffers[U];if(j){var W=j.underlyingResource;L[F].resource.buffer=W,L[F].resource.size=j.capacity}else m.a.Error("Can't find buffer \"".concat(U,'". entry=').concat(JSON.stringify(w),", buffers=").concat(JSON.stringify(n.buffers),", drawContext.uniqueId=").concat(n.uniqueId),50)}}var H=I[D];f[D]=this._device.createBindGroup({layout:H,entries:L})}return f},e.NumBindGroupsCreatedTotal=0,e.NumBindGroupsCreatedLastFrame=0,e.NumBindGroupsLookupLastFrame=0,e.NumBindGroupsNoLookupLastFrame=0,e._Cache=new _s,e._NumBindGroupsCreatedCurrentFrame=0,e._NumBindGroupsLookupCurrentFrame=0,e._NumBindGroupsNoLookupCurrentFrame=0,e}(),gs="uniform float depthValue;\nconst vec2 pos[4]={\nvec2(-1.0,1.0),\nvec2(1.0,1.0),\nvec2(-1.0,-1.0),\nvec2(1.0,-1.0)\n};\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\ngl_Position=vec4(pos[gl_VertexID],depthValue,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}\n";Cn.a.ShadersStore.clearQuadVertexShader=gs;Cn.a.ShadersStore.clearQuadPixelShader="uniform vec4 color;\nvoid main() {\ngl_FragColor=color;\n}\n";var vs=function(){function e(e,t,n){this._bindGroups={},this._bundleCache={},this._keyTemp=[],this._device=e,this._engine=t,this._cacheRenderPipeline=new ss(this._device,n,!t._caps.textureFloatLinearFiltering),this._cacheRenderPipeline.setDepthTestEnabled(!1),this._cacheRenderPipeline.setStencilReadMask(255),this._effect=t.createEffect("clearQuad",[],["color","depthValue"])}return e.prototype.setDepthStencilFormat=function(e){this._depthTextureFormat=e,this._cacheRenderPipeline.setDepthStencilFormat(e)},e.prototype.setColorFormat=function(e){this._cacheRenderPipeline.setColorFormat(e)},e.prototype.setMRTAttachments=function(e,t,n){this._cacheRenderPipeline.setMRT(t,n),this._cacheRenderPipeline.setMRTAttachments(e)},e.prototype.clear=function(e,t,n,i,r){var o,a;void 0===r&&(r=1);var s,c=null,u=!!this._engine._currentRenderTarget;if(e)a=e;else{var l=0;this._keyTemp.length=0;for(var h=0;h1?Math.pow(2,36):0)+d*Math.pow(2,37),s=this._keyTemp.join("_"),c=this._bundleCache[s])return c;a=this._device.createRenderBundleEncoder({colorFormats:this._cacheRenderPipeline.colorFormats,depthStencilFormat:this._depthTextureFormat,sampleCount:r})}this._cacheRenderPipeline.setDepthWriteEnabled(!!n),this._cacheRenderPipeline.setStencilEnabled(!!i&&!!this._depthTextureFormat&&Qa.HasStencilAspect(this._depthTextureFormat)),this._cacheRenderPipeline.setStencilWriteMask(i?255:0),this._cacheRenderPipeline.setStencilCompare(i?g.a.ALWAYS:g.a.NEVER),this._cacheRenderPipeline.setStencilPassOp(i?g.a.REPLACE:g.a.KEEP),this._cacheRenderPipeline.setWriteMask(t?15:0);var p=this._cacheRenderPipeline.getRenderPipeline(g.a.MATERIAL_TriangleStripDrawMode,this._effect,r),f=this._effect._pipelineContext;t&&this._effect.setDirectColor4("color",t),this._effect.setFloat("depthValue",this._engine.useReverseDepthBuffer?this._engine._clearReverseDepthValue:this._engine._clearDepthValue),f.uniformBuffer.update();var _=u?this._engine._ubInvertY:this._engine._ubDontInvertY,m=f.uniformBuffer.getBuffer(),v=m.uniqueId+"-"+_.uniqueId,b=this._bindGroups[v];if(!b){var y=f.bindGroupLayouts;(b=this._bindGroups[v]=[]).push(this._device.createBindGroup({layout:y[0],entries:[]})),Aa._SimplifiedKnownBindings||b.push(this._device.createBindGroup({layout:y[1],entries:[]})),b.push(this._device.createBindGroup({layout:y[Aa._SimplifiedKnownBindings?1:2],entries:[{binding:0,resource:{buffer:_.underlyingResource,size:_.capacity}},{binding:1,resource:{buffer:m.underlyingResource,size:m.capacity}}]}))}a.setPipeline(p);for(h=0;h=0&&(t._gpuFrameTimeCounter.fetchNewFrame(),t._gpuFrameTimeCounter.addCount(e,!0)),t._measureDurationState=0})))},e}(),Os=function(){function e(e,t){this._querySet=new Cs(2,_a.Timestamp,e,t)}return e.prototype.start=function(e){e.writeTimestamp(this._querySet.querySet,0)},e.prototype.stop=function(e){return Object(h.b)(this,void 0,void 0,(function(){return Object(h.e)(this,(function(t){return e.writeTimestamp(this._querySet.querySet,1),[2,this._querySet.readTwoValuesAndSubtract(0)]}))}))},e.prototype.dispose=function(){this._querySet.dispose()},e}(),Ms=function(){function e(e,t,n,i,r){void 0===i&&(i=50),void 0===r&&(r=100),this._availableIndices=[],this._engine=e,this._device=t,this._bufferManager=n,this._frameLastBuffer=-1,this._currentTotalIndices=0,this._countIncrement=r,this._allocateNewIndices(i)}return Object.defineProperty(e.prototype,"querySet",{get:function(){return this._querySet.querySet},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"hasQueries",{get:function(){return this._currentTotalIndices!==this._availableIndices.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"canBeginQuery",{get:function(){switch(this._engine._getCurrentRenderPassIndex()){case 0:return void 0!==this._engine._mainRenderPassWrapper.renderPassDescriptor.occlusionQuerySet;case 1:return void 0!==this._engine._rttRenderPassWrapper.renderPassDescriptor.occlusionQuerySet}return!1},enumerable:!1,configurable:!0}),e.prototype.createQuery=function(){0===this._availableIndices.length&&this._allocateNewIndices();var e=this._availableIndices[this._availableIndices.length-1];return this._availableIndices.length--,e},e.prototype.deleteQuery=function(e){this._availableIndices[this._availableIndices.length-1]=e},e.prototype.isQueryResultAvailable=function(e){return this._retrieveQueryBuffer(),!!this._lastBuffer&&e=0||void 0,s3tc:this._deviceEnabledExtensions.indexOf(Uo.TextureCompressionBC)>=0||void 0,pvrtc:null,etc1:null,etc2:this._deviceEnabledExtensions.indexOf(Uo.TextureCompressionETC2)>=0||void 0,bptc:this._deviceEnabledExtensions.indexOf(Uo.TextureCompressionBC)>=0||void 0,maxAnisotropy:4,uintIndices:!0,fragmentDepthSupported:!0,highPrecisionShaderSupported:!0,colorBufferFloat:!0,textureFloat:!0,textureFloatLinearFiltering:!1,textureFloatRender:!0,textureHalfFloat:!0,textureHalfFloatLinearFiltering:!0,textureHalfFloatRender:!0,textureLOD:!0,drawBuffersExtension:!0,depthTextureExtension:!0,vertexArrayObject:!1,instancedArrays:!0,timerQuery:"undefined"!=typeof BigUint64Array&&-1!==this.enabledExtensions.indexOf(Uo.TimestampQuery)||void 0,supportOcclusionQuery:"undefined"!=typeof BigUint64Array,canUseTimestampForTimerQuery:!0,multiview:!1,oculusMultiview:!1,parallelShaderCompile:void 0,blendMinMax:!0,maxMSAASamples:4,canUseGLInstanceID:!0,canUseGLVertexID:!0,supportComputeShaders:!0,supportSRGBBuffers:!0,supportTransformFeedbacks:!1,textureMaxLevel:!0},this._caps.parallelShaderCompile=null,this._features={forceBitmapOverHTMLImageElement:!0,supportRenderAndCopyToLodForFloatTextures:!0,supportDepthStencilTexture:!0,supportShadowSamplers:!0,uniformBufferHardCheckMatrix:!1,allowTexturePrefiltering:!0,trackUbosInFrame:!0,checkUbosContentBeforeUpload:!0,supportCSM:!0,basisNeedsPOT:!1,support3DTextures:!0,needTypeSuffixInShaderConstants:!0,supportMSAA:!0,supportSSAO2:!0,supportExtendedTextureFormats:!0,supportSwitchCaseInShader:!0,supportSyncTextureRead:!1,needsInvertingBitmap:!1,useUBOBindingCache:!1,needShaderCodeInlining:!0,needToAlwaysBindUniformBuffers:!0,supportRenderPasses:!0,_collectUbosUpdatedInFrame:!1}},t.prototype._initializeContextAndSwapChain=function(){this._context=this._canvas.getContext("webgpu"),this._configureContext(this._canvas.width,this._canvas.height),this._colorFormat=this._options.swapChainFormat,this._mainRenderPassWrapper.colorAttachmentGPUTextures=[new Wa],this._mainRenderPassWrapper.colorAttachmentGPUTextures[0].format=this._colorFormat},t.prototype._initializeMainAttachments=function(){var e;this._mainTextureExtends={width:this.getRenderWidth(),height:this.getRenderHeight(),depthOrArrayLayers:1};var t,n=new Float32Array([this.getRenderHeight()]);if(this._bufferManager.setSubData(this._ubInvertY,4,n),this._bufferManager.setSubData(this._ubDontInvertY,4,n),this._options.antialiasing){var i={size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:Go.E2d,format:this._options.swapChainFormat,usage:zo.RenderAttachment};null===(e=this._mainTexture)||void 0===e||e.destroy(),this._mainTexture=this._device.createTexture(i),t=[{view:this._mainTexture.createView(),clearValue:new s.b(0,0,0,1),loadOp:pa.Clear,storeOp:fa.Store}]}else t=[{view:void 0,clearValue:new s.b(0,0,0,1),loadOp:pa.Clear,storeOp:fa.Store}];this._mainRenderPassWrapper.depthTextureFormat=this.isStencilEnable?Ho.Depth24PlusStencil8:Ho.Depth32Float,this._setDepthTextureFormat(this._mainRenderPassWrapper);var r={size:this._mainTextureExtends,mipLevelCount:1,sampleCount:this._mainPassSampleCount,dimension:Go.E2d,format:this._mainRenderPassWrapper.depthTextureFormat,usage:zo.RenderAttachment};this._depthTexture&&this._depthTexture.destroy(),this._depthTexture=this._device.createTexture(r);var o={view:this._depthTexture.createView(),depthClearValue:this._clearDepthValue,depthLoadOp:pa.Clear,depthStoreOp:fa.Store,stencilClearValue:this._clearStencilValue,stencilLoadOp:pa.Clear,stencilStoreOp:fa.Store};this._mainRenderPassWrapper.renderPassDescriptor={colorAttachments:t,depthStencilAttachment:o},null!==this._mainRenderPassWrapper.renderPass&&this._endMainRenderPass()},t.prototype._configureContext=function(e,t){this._context.configure({device:this._device,format:this._options.swapChainFormat,usage:zo.RenderAttachment|zo.CopySrc,compositingAlphaMode:this.premultipliedAlpha?ma.Premultiplied:ma.Opaque,size:{width:e,height:t,depthOrArrayLayers:1}})},t.prototype.setSize=function(t,n,i){return void 0===i&&(i=!1),!!e.prototype.setSize.call(this,t,n,i)&&(this.dbgVerboseLogsForFirstFrames&&(void 0===this._count&&(this._count=0),(!this._count||this._count0,s._cachedWrapU=g.a.TEXTURE_CLAMP_ADDRESSMODE,s._cachedWrapV=g.a.TEXTURE_CLAMP_ADDRESSMODE,this._internalTexturesCache.push(s),n||this._textureHelper.createGPUTextureForInternalTexture(s,c,u,l||1,a.creationFlags),s},t.prototype.createTexture=function(e,t,n,i,r,o,a,s,c,u,l,h,d,p,f){var _=this;return 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===u&&(u=null),void 0===l&&(l=null),this._createTextureBase(e,t,n,i,r,o,a,(function(e,t,n,i,r,o,a,s,c){var l,h=i;if(e.baseWidth=h.width,e.baseHeight=h.height,e.width=h.width,e.height=h.height,e.format=null!=u?u:-1,s(e.width,e.height,h,t,e,(function(){})),null===(l=e._hardwareTexture)||void 0===l?void 0:l.underlyingResource)o||a||_._generateMipmaps(e,_._uploadEncoder);else{var d=_._textureHelper.createGPUTextureForInternalTexture(e,h.width,h.height,void 0,p);Qa.IsImageBitmap(h)&&(_._textureHelper.updateTexture(h,e,h.width,h.height,e.depth,d.format,0,0,r,!1,0,0),o||a||_._generateMipmaps(e,_._uploadEncoder))}n&&n._removePendingData(e),e.isReady=!0,e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}),(function(){return!1}),s,c,u,l,h,d,f)},t.prototype.generateMipMapsForCubemap=function(e,t){var n;(void 0===t&&(t=!0),e.generateMipMaps)&&((null===(n=e._hardwareTexture)||void 0===n?void 0:n.underlyingResource)||this._textureHelper.createGPUTextureForInternalTexture(e),this._generateMipmaps(e,e.source===Ue.b.RenderTarget||e.source===Ue.b.MultiRenderTarget?this._renderTargetEncoder:void 0))},t.prototype.updateTextureSamplingMode=function(e,t,n){void 0===n&&(n=!1),n&&(t.generateMipMaps=!0,this._generateMipmaps(t)),t.samplingMode=e},t.prototype.updateTextureWrappingMode=function(e,t,n,i){void 0===n&&(n=null),void 0===i&&(i=null),null!==t&&(e._cachedWrapU=t),null!==n&&(e._cachedWrapV=n),(e.is2DArray||e.is3D)&&null!==i&&(e._cachedWrapR=i)},t.prototype.updateTextureDimensions=function(e,t,n,i){if(void 0===i&&(i=1),e._hardwareTexture&&(e.width!==t||e.height!==n||e.depth!==i)){var r=e._hardwareTexture.textureAdditionalUsages;e._hardwareTexture.release(),this._textureHelper.createGPUTextureForInternalTexture(e,t,n,i,r)}},t.prototype._setInternalTexture=function(e,t,n,i){if(void 0===i&&(i=0),n=null!=n?n:e,this._currentEffect){var r=this._currentEffect._pipelineContext.shaderProcessingContext.availableTextures[n];if(this._currentMaterialContext.setTexture(e,t),r&&r.autoBindSampler){var o=n+Ta.AutoSamplerSuffix;this._currentMaterialContext.setSampler(o,t)}}},t.prototype.setTexture=function(e,t,n,i){this._setTexture(e,n,!1,!1,i,i)},t.prototype.setTextureArray=function(e,t,n,i){for(var r=0;r0;for(var r in e){var o=e[r],a=n[r],s=a.group,c=a.binding,u=o.type,l=o.object,h=o.indexInGroupEntries;switch((b=this._bindGroupEntries[s])||(b=this._bindGroupEntries[s]=[]),u){case ur.Sampler:var d=l;void 0!==h&&i?b[h].resource=this._cacheSampler.getSampler(d):(o.indexInGroupEntries=b.length,b.push({binding:c,resource:this._cacheSampler.getSampler(d)}));break;case ur.Texture:case ur.TextureWithoutSampler:var p=(f=l)._texture._hardwareTexture;void 0!==h&&i?(u===ur.Texture&&(b[h++].resource=this._cacheSampler.getSampler(f._texture)),b[h].resource=p.view):(o.indexInGroupEntries=b.length,u===ur.Texture&&b.push({binding:c-1,resource:this._cacheSampler.getSampler(f._texture)}),b.push({binding:c,resource:p.view}));break;case ur.StorageTexture:var f;0==((p=(f=l)._texture._hardwareTexture).textureAdditionalUsages&zo.StorageBinding)&&m.a.Error("computeDispatch: The texture (name=".concat(f.name,", uniqueId=").concat(f.uniqueId,") is not a storage texture!"),50),void 0!==h&&i?b[h].resource=p.viewForWriting:(o.indexInGroupEntries=b.length,b.push({binding:c,resource:p.viewForWriting}));break;case ur.UniformBuffer:case ur.StorageBuffer:var _=(ur.UniformBuffer,l).getBuffer(),g=_.underlyingResource;void 0!==h&&i?(b[h].resource.buffer=g,b[h].resource.size=_.capacity):(o.indexInGroupEntries=b.length,b.push({binding:c,resource:{buffer:g,offset:0,size:_.capacity}}))}}for(var v=0;v>v,y=[],T=0;T<6;T++){var E=f[v][m[T]];l&&(E=Bs(E,b,b,r)),y.push(new Uint8Array(E.buffer,E.byteOffset,E.byteLength))}d._textureHelper.updateCubeTextures(y,_.underlyingResource,b,b,_.format,h,!1,0,0)}else{for(y=[],T=0;T<6;T++)y.push(o[u[T]]);d.updateRawCubeTexture(p,y,i,r,h)}p.isReady=!0,null==t||t._removePendingData(p),c&&c()}}(e)}),void 0,null==t?void 0:t.offlineProvider,!0,(function(e,n){null==t||t._removePendingData(p),u&&e&&u(e.status+" "+e.statusText,n)})),p},Ns.prototype.createRawTexture3D=function(e,t,n,i,r,o,a,s,c,u,l){void 0===c&&(c=null),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=0);var h=Ue.b.Raw3D,d=new Ue.a(this,h);return d.baseWidth=t,d.baseHeight=n,d.baseDepth=i,d.width=t,d.height=n,d.depth=i,d.format=r,d.type=u,d.generateMipMaps=o,d.samplingMode=s,d.is3D=!0,this._doNotHandleContextLost||(d._bufferView=e),this._textureHelper.createGPUTextureForInternalTexture(d,t,n,void 0,l),this.updateRawTexture3D(d,e,r,a,c,u),this._internalTexturesCache.push(d),d},Ns.prototype.updateRawTexture3D=function(e,t,n,i,r,o){if(void 0===r&&(r=null),void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(e._bufferView=t,e.format=n,e.invertY=i,e._compression=r),t){var a=e._hardwareTexture;n===g.a.TEXTUREFORMAT_RGB&&(t=Bs(t,e.width,e.height,o));var s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(s,e,e.width,e.height,e.depth,a.format,0,0,i,!1,0,0),e.generateMipMaps&&this._generateMipmaps(e,this._uploadEncoder)}e.isReady=!0},Ns.prototype.createRawTexture2DArray=function(e,t,n,i,r,o,a,s,c,u,l){void 0===c&&(c=null),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=0);var h=Ue.b.Raw2DArray,d=new Ue.a(this,h);return d.baseWidth=t,d.baseHeight=n,d.baseDepth=i,d.width=t,d.height=n,d.depth=i,d.format=r,d.type=u,d.generateMipMaps=o,d.samplingMode=s,d.is2DArray=!0,this._doNotHandleContextLost||(d._bufferView=e),this._textureHelper.createGPUTextureForInternalTexture(d,t,n,i,l),this.updateRawTexture2DArray(d,e,r,a,c,u),this._internalTexturesCache.push(d),d},Ns.prototype.updateRawTexture2DArray=function(e,t,n,i,r,o){if(void 0===r&&(r=null),void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),this._doNotHandleContextLost||(e._bufferView=t,e.format=n,e.invertY=i,e._compression=r),t){var a=e._hardwareTexture;n===g.a.TEXTUREFORMAT_RGB&&(t=Bs(t,e.width,e.height,o));var s=new Uint8Array(t.buffer,t.byteOffset,t.byteLength);this._textureHelper.updateTexture(s,e,e.width,e.height,e.depth,a.format,0,0,i,!1,0,0),e.generateMipMaps&&this._generateMipmaps(e,this._uploadEncoder)}e.isReady=!0},Ns.prototype._readTexturePixels=function(e,t,n,i,r,o,a,s){void 0===i&&(i=-1),void 0===r&&(r=0),void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1);var c=e._hardwareTexture;return a&&this.flushFramebuffer(),this._textureHelper.readPixels(c.underlyingResource,0,0,t,n,c.format,i,r,o,s)},Ns.prototype._readTexturePixelsSync=function(e,t,n,i,r,o,a,s){throw void 0===i&&(i=-1),void 0===r&&(r=0),void 0===o&&(o=null),void 0===a&&(a=!0),void 0===s&&(s=!1),"_readTexturePixelsSync is unsupported in WebGPU!"};var Us=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return Object(h.d)(t,e),t}(On.a);Ns.prototype._createHardwareRenderTargetWrapper=function(e,t,n){var i=new Us(e,t,n,this);return this._renderTargetWrapperCache.push(i),i},Ns.prototype.createRenderTargetTexture=function(e,t){var n,i=this._createHardwareRenderTargetWrapper(!1,!1,e),r={};void 0!==t&&"object"==typeof t?(r.generateMipMaps=t.generateMipMaps,r.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,r.generateStencilBuffer=r.generateDepthBuffer&&t.generateStencilBuffer,r.samplingMode=void 0===t.samplingMode?g.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,r.creationFlags=null!==(n=t.creationFlags)&&void 0!==n?n:0):(r.generateMipMaps=t,r.generateDepthBuffer=!0,r.generateStencilBuffer=!1,r.samplingMode=g.a.TEXTURE_TRILINEAR_SAMPLINGMODE,r.creationFlags=0);var o=this._createInternalTexture(e,t,!0,Ue.b.RenderTarget);return i._generateDepthBuffer=r.generateDepthBuffer,i._generateStencilBuffer=!!r.generateStencilBuffer,i.setTextures(o),(i._generateDepthBuffer||i._generateStencilBuffer)&&i.createDepthStencilTexture(0,void 0===r.samplingMode||r.samplingMode===g.a.TEXTURE_BILINEAR_SAMPLINGMODE||r.samplingMode===g.a.TEXTURE_LINEAR_LINEAR||r.samplingMode===g.a.TEXTURE_TRILINEAR_SAMPLINGMODE||r.samplingMode===g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR||r.samplingMode===g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST||r.samplingMode===g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR||r.samplingMode===g.a.TEXTURE_NEAREST_LINEAR||r.samplingMode===g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,i._generateStencilBuffer,i.samples),void 0!==t&&"object"==typeof t&&t.createMipMaps&&!r.generateMipMaps&&(o.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(o,void 0,void 0,void 0,r.creationFlags),void 0!==t&&"object"==typeof t&&t.createMipMaps&&!r.generateMipMaps&&(o.generateMipMaps=!1),i},Ns.prototype._createDepthStencilTexture=function(e,t,n){var i=new Ue.a(this,Ue.b.DepthStencil),r=Object(h.a)({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1,samples:1,depthTextureFormat:g.a.TEXTUREFORMAT_DEPTH32_FLOAT},t);return i.format=r.generateStencil?g.a.TEXTUREFORMAT_DEPTH24_STENCIL8:r.depthTextureFormat,this._setupDepthStencilTexture(i,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction,r.samples),this._textureHelper.createGPUTextureForInternalTexture(i),this._internalTexturesCache.push(i),i},Ns.prototype._setupDepthStencilTexture=function(e,t,n,i,r,o){void 0===o&&(o=1);var a=t.width||t,s=t.height||t,c=t.layers||0;e.baseWidth=a,e.baseHeight=s,e.width=a,e.height=s,e.is2DArray=c>0,e.depth=c,e.isReady=!0,e.samples=o,e.generateMipMaps=!1,e.samplingMode=i?g.a.TEXTURE_BILINEAR_SAMPLINGMODE:g.a.TEXTURE_NEAREST_SAMPLINGMODE,e.type=g.a.TEXTURETYPE_FLOAT,e._comparisonFunction=r,e._cachedWrapU=g.a.TEXTURE_CLAMP_ADDRESSMODE,e._cachedWrapV=g.a.TEXTURE_CLAMP_ADDRESSMODE},Ns.prototype.updateRenderTargetTextureSampleCount=function(e,t){return e&&e.texture&&e.samples!==t?(t=Math.min(t,this.getCaps().maxMSAASamples),this._textureHelper.createMSAATexture(e.texture,t),e._depthStencilTexture&&(this._textureHelper.createMSAATexture(e._depthStencilTexture,t),e._depthStencilTexture.samples=t),e.texture.samples=t,t):t},Ns.prototype.createRenderTargetCubeTexture=function(e,t){var n=this._createHardwareRenderTargetWrapper(!1,!0,e),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,samples:1},t);i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=i.generateStencilBuffer;var r=new Ue.a(this,Ue.b.RenderTarget);return r.width=e,r.height=e,r.depth=0,r.isReady=!0,r.isCube=!0,r.samples=i.samples,r.generateMipMaps=i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r.format=i.format,this._internalTexturesCache.push(r),n.setTextures(r),(n._generateDepthBuffer||n._generateStencilBuffer)&&n.createDepthStencilTexture(0,void 0===i.samplingMode||i.samplingMode===g.a.TEXTURE_BILINEAR_SAMPLINGMODE||i.samplingMode===g.a.TEXTURE_LINEAR_LINEAR||i.samplingMode===g.a.TEXTURE_TRILINEAR_SAMPLINGMODE||i.samplingMode===g.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR||i.samplingMode===g.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST||i.samplingMode===g.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR||i.samplingMode===g.a.TEXTURE_NEAREST_LINEAR||i.samplingMode===g.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,n._generateStencilBuffer,n.samples),t&&t.createMipMaps&&!i.generateMipMaps&&(r.generateMipMaps=!0),this._textureHelper.createGPUTextureForInternalTexture(r),t&&t.createMipMaps&&!i.generateMipMaps&&(r.generateMipMaps=!1),n},ya.a.prototype.setTextureSampler=function(e,t){this._engine.setTextureSampler(e,t)},Ns.prototype.setTextureSampler=function(e,t){var n;null===(n=this._currentMaterialContext)||void 0===n||n.setSampler(e,t)},ya.a.prototype.setStorageBuffer=function(e,t){this._engine.setStorageBuffer(e,t)},Ns.prototype.createStorageBuffer=function(e,t){return this._createBuffer(e,t|g.a.BUFFER_CREATIONFLAG_STORAGE)},Ns.prototype.updateStorageBuffer=function(e,t,n,i){var r,o=e;void 0===n&&(n=0),void 0===i?i=(r=t instanceof Array?new Float32Array(t):t instanceof ArrayBuffer?new Uint8Array(t):t).byteLength:r=t instanceof Array?new Float32Array(t):t instanceof ArrayBuffer?new Uint8Array(t):t,this._bufferManager.setSubData(o,n,r,0,i)},Ns.prototype.readFromStorageBuffer=function(e,t,n,i){var r=this;n=n||e.capacity;var o=this._bufferManager.createRawBuffer(n,Vo.MapRead|Vo.CopyDst);return this._renderTargetEncoder.copyBufferToBuffer(e.underlyingResource,null!=t?t:0,o,0,n),new Promise((function(e,t){r.onEndFrameObservable.addOnce((function(){o.mapAsync(ko.Read,0,n).then((function(){var t=o.getMappedRange(0,n),a=i;if(void 0===a)(a=new Uint8Array(n)).set(new Uint8Array(t));else{var s=a.constructor;(a=new s(a.buffer)).set(new s(t))}o.unmap(),r._bufferManager.releaseBuffer(o),e(a)}),(function(e){return t(e)}))}))}))},Ns.prototype.setStorageBuffer=function(e,t){var n,i;null===(n=this._currentDrawContext)||void 0===n||n.setBuffer(e,null!==(i=null==t?void 0:t.getBuffer())&&void 0!==i?i:null)},Ns.prototype.createUniformBuffer=function(e){var t;return t=e instanceof Array?new Float32Array(e):e,this._bufferManager.createBuffer(t,Vo.Uniform|Vo.CopyDst)},Ns.prototype.createDynamicUniformBuffer=function(e){return this.createUniformBuffer(e)},Ns.prototype.updateUniformBuffer=function(e,t,n,i){void 0===n&&(n=0);var r,o=e;void 0===i?i=(r=t instanceof Float32Array?t:new Float32Array(t)).byteLength:r=t instanceof Float32Array?t:new Float32Array(t),this._bufferManager.setSubData(o,n,r,0,i)},Ns.prototype.bindUniformBufferBase=function(e,t,n){this._currentDrawContext.setBuffer(n,e)},Ns.prototype.bindUniformBlock=function(e,t,n){},Ns.prototype.updateVideoTexture=function(e,t,n){var i,r=this;if(e&&!e._isDisabled){void 0===this._videoTextureSupported&&(this._videoTextureSupported=!0);var o=e._hardwareTexture;(null===(i=e._hardwareTexture)||void 0===i?void 0:i.underlyingResource)||(o=this._textureHelper.createGPUTextureForInternalTexture(e)),this.createImageBitmap(t).then((function(t){r._textureHelper.updateTexture(t,e,e.width,e.height,e.depth,o.format,0,0,!n,!1,0,0),e.generateMipMaps&&r._generateMipmaps(e,r._uploadEncoder),e.isReady=!0})).catch((function(t){e.isReady=!0}))}};var Vs,ks=n(171),Gs=n(86),zs=function(){function e(){}return e.CreateAsync=function(e,t){return Ns.IsSupportedAsync.then((function(n){return n?Ns.CreateAsync(e,t):xe.a.IsSupported?new Promise((function(n){n(new xe.a(e,void 0,t))})):new Promise((function(e){e(new Or.a(t))}))}))},e}(),js=function(){function e(){}return e.COPY=1,e.CUT=2,e.PASTE=3,e}(),Ws=function(){function e(e,t){this.type=e,this.event=t}return e.GetTypeFromCharacter=function(e){switch(e){case 67:return js.COPY;case 86:return js.PASTE;case 88:return js.CUT;default:return-1}},e}(),Hs=n(81);!function(e){e[e.Clean=0]="Clean",e[e.Stop=1]="Stop",e[e.Sync=2]="Sync",e[e.NoSync=3]="NoSync"}(Vs||(Vs={}));var Xs=function(){function e(){}return Object.defineProperty(e,"ForceFullSceneLoadingForIncremental",{get:function(){return Hs.a.ForceFullSceneLoadingForIncremental},set:function(e){Hs.a.ForceFullSceneLoadingForIncremental=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"ShowLoadingScreen",{get:function(){return Hs.a.ShowLoadingScreen},set:function(e){Hs.a.ShowLoadingScreen=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"loggingLevel",{get:function(){return Hs.a.loggingLevel},set:function(e){Hs.a.loggingLevel=e},enumerable:!1,configurable:!0}),Object.defineProperty(e,"CleanBoneMatrixWeights",{get:function(){return Hs.a.CleanBoneMatrixWeights},set:function(e){Hs.a.CleanBoneMatrixWeights=e},enumerable:!1,configurable:!0}),e.GetDefaultPlugin=function(){return e._registeredPlugins[".babylon"]},e._GetPluginForExtension=function(t){var n=e._registeredPlugins[t];return n||(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 n in e._registeredPlugins){var i=e._registeredPlugins[n].plugin;if(i.canDirectLoad&&i.canDirectLoad(t))return e._registeredPlugins[n]}return e.GetDefaultPlugin()},e._GetPluginForFilename=function(t){var n=t.indexOf("?");-1!==n&&(t=t.substring(0,n));var i=t.lastIndexOf("."),r=t.substring(i,t.length).toLowerCase();return e._GetPluginForExtension(r)},e._GetDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},e._FormatErrorMessage=function(e,t,n){var i="Unable to load from "+e.url;return t?i+=": ".concat(t):n&&(i+=": ".concat(n)),i},e._LoadData=function(t,n,i,r,o,a,s){var c,u=e._GetDirectLoad(t.url),l=s?e._GetPluginForExtension(s):u?e._GetPluginForDirectLoad(t.url):e._GetPluginForFilename(t.url);if(!(c=void 0!==l.plugin.createPlugin?l.plugin.createPlugin():l.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),u&&(c.canDirectLoad&&c.canDirectLoad(t.url)||!Object(Lr.d)(t.url))){if(c.directLoad){var h=c.directLoad(n,u);h.then?h.then((function(e){i(c,e)})).catch((function(e){o("Error in directLoad of _loadData: "+e,e)})):i(c,h)}else i(c,u);return c}var d=l.isBinary,p=function(e,t){n.isDisposed?o("Scene has been disposed"):i(c,e,t)},f=null,_=!1,m=c.onDisposeObservable;m&&m.add((function(){_=!0,f&&(f.abort(),f=null),a()}));var g=function(){if(!_){var e=function(e,t){o(null==e?void 0:e.statusText,t)},i=t.file||t.url;f=c.loadFile?c.loadFile(n,i,p,r,d,e):n._loadFile(i,p,r,!0,d,e)}},v=n.getEngine(),b=v.enableOfflineSupport;if(b){for(var y=!1,T=0,E=n.disableOfflineSupportExceptionRules;Tm.snapDistance?(r=Math.floor(Math.abs(R)/m.snapDistance),R<0&&(r*=-1),R%=m.snapDistance,C.scaleToRef(m.snapDistance*r,C),i=!0):C.scaleInPlace(0)),a.a.ScalingToRef(1+C.x,1+C.y,1+C.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),i&&(P.snapDistance=m.snapDistance*r,m.onSnapObservable.notifyObservers(P)),m._matrixChanged()}})),m.dragBehavior.onDragStartObservable.add((function(){m._dragging=!0})),m.dragBehavior.onDragObservable.add((function(e){return A(e.dragDistance)})),m.dragBehavior.onDragEndObservable.add(x),null===(h=null===(l=null===(u=null==r?void 0:r.uniformScaleGizmo)||void 0===u?void 0:u.dragBehavior)||void 0===l?void 0:l.onDragObservable)||void 0===h||h.add((function(e){return A(e.delta.y)})),null===(f=null===(p=null===(d=null==r?void 0:r.uniformScaleGizmo)||void 0===d?void 0:d.dragBehavior)||void 0===p?void 0:p.onDragEndObservable)||void 0===f||f.add(x);var O={gizmoMeshes:[v,b],colliderMeshes:[y.arrowMesh,y.arrowTail],material:m._coloredMaterial,hoverMaterial:m._hoverMaterial,disableMaterial:m._disableMaterial,active:!1,dragBehavior:m.dragBehavior};null===(_=m._parent)||void 0===_||_.addToAxisCache(m._gizmoMesh,O),m._pointerObserver=i.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 n=m.dragBehavior.enabled?m._isHovered||m._dragging?m._hoverMaterial:m._coloredMaterial:m._disableMaterial;m._setGizmoMeshMaterial(O.gizmoMeshes,n)}})),m.dragBehavior.onEnabledObservable.add((function(e){m._setGizmoMeshMaterial(O.gizmoMeshes,e?m._coloredMaterial:m._disableMaterial)}));var M=i._getSharedGizmoLight();return M.includedOnlyMeshes=M.includedOnlyMeshes.concat(m._rootMesh.getChildMeshes()),m}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,n){void 0===n&&(n=!1);var i=Object(nc.b)("yPosMesh",{size:.4*(1+(t-1)/4)},this.gizmoLayer.utilityLayerScene),r=Object(ki.a)("cylinder",{diameterTop:.005*t,height:.275,diameterBottom:.005*t,tessellation:96},this.gizmoLayer.utilityLayerScene);return i.scaling.scaleInPlace(.1),i.material=this._coloredMaterial,i.rotation.x=Math.PI/2,i.position.z+=.3,r.material=this._coloredMaterial,r.position.z+=.1375,r.rotation.x=Math.PI/2,n&&(i.visibility=0,r.visibility=0),e.addChild(i),e.addChild(r),{arrowMesh:i,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,n){var i=this;void 0===n&&(n=!1),e.prototype.setCustomMesh.call(this,t),n&&(this._rootMesh.getChildMeshes().forEach((function(e){e.material=i._coloredMaterial,e.color&&(e.color=i._coloredMaterial.diffuseColor)})),this._customMeshSet=!1)},t}(ic.a),ac=n(50),sc=n(40),cc=n(76),uc=function(e){function t(t,n){void 0===t&&(t=s.a.Gray()),void 0===n&&(n=rc.a.DefaultKeepDepthUtilityLayer);var i=e.call(this,n)||this;i._boundingDimensions=new a.e(1,1,1),i._renderObserver=null,i._pointerObserver=null,i._scaleDragSpeed=.2,i._tmpQuaternion=new a.b,i._tmpVector=new a.e(0,0,0),i._tmpRotationMatrix=new a.a,i.ignoreChildren=!1,i.includeChildPredicate=null,i.rotationSphereSize=.1,i.scaleBoxSize=.1,i.fixedDragMeshScreenSize=!1,i.fixedDragMeshBoundsSize=!1,i.fixedDragMeshScreenSizeDistanceFactor=10,i.onDragStartObservable=new o.c,i.onScaleBoxDragObservable=new o.c,i.onScaleBoxDragEndObservable=new o.c,i.onRotationSphereDragObservable=new o.c,i.onRotationSphereDragEndObservable=new o.c,i.scalePivot=null,i._axisFactor=new a.e(1,1,1),i._existingMeshScale=new a.e,i._dragMesh=null,i.pointerDragBehavior=new it.a,i.updateScale=!1,i._anchorMesh=new ot.a("anchor",n.utilityLayerScene),i.coloredMaterial=new Si.a("",n.utilityLayerScene),i.coloredMaterial.disableLighting=!0,i.hoverColoredMaterial=new Si.a("",n.utilityLayerScene),i.hoverColoredMaterial.disableLighting=!0,i._lineBoundingBox=new ot.a("",n.utilityLayerScene),i._lineBoundingBox.rotationQuaternion=new a.b;var r=[];r.push(Object(sc.e)("lines",{points:[new a.e(0,0,0),new a.e(i._boundingDimensions.x,0,0)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(0,0,0),new a.e(0,i._boundingDimensions.y,0)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(0,0,0),new a.e(0,0,i._boundingDimensions.z)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(i._boundingDimensions.x,0,0),new a.e(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(i._boundingDimensions.x,0,0),new a.e(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(0,i._boundingDimensions.y,0),new a.e(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(0,i._boundingDimensions.y,0),new a.e(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(0,0,i._boundingDimensions.z),new a.e(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(0,0,i._boundingDimensions.z),new a.e(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new a.e(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new a.e(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),r.push(Object(sc.e)("lines",{points:[new a.e(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new a.e(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),r.forEach((function(e){e.color=t,e.position.addInPlace(new a.e(-i._boundingDimensions.x/2,-i._boundingDimensions.y/2,-i._boundingDimensions.z/2)),e.isPickable=!1,i._lineBoundingBox.addChild(e)})),i._rootMesh.addChild(i._lineBoundingBox),i.setColor(t),i._rotateSpheresParent=new ot.a("",n.utilityLayerScene),i._rotateSpheresParent.rotationQuaternion=new a.b;for(var c=function(e){var t=Object(ac.a)("",{diameter:1},n.utilityLayerScene);t.rotationQuaternion=new a.b,t.material=u.coloredMaterial,t.isNearGrabbable=!0,(p=new it.a({})).moveAttached=!1,p.updateDragPlane=!1,t.addBehavior(p);var r=new a.e(1,0,0),o=0;p.onDragStartObservable.add((function(){r.copyFrom(t.forward),o=0})),p.onDragObservable.add((function(t){if(i.onRotationSphereDragObservable.notifyObservers({}),i.attachedMesh){var n=i.attachedMesh.parent;if(n&&n.scaling&&n.scaling.isNonUniformWithinEpsilon(.001))return void m.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");cc.a._RemoveAndStorePivotPoint(i.attachedMesh);var s=r,c=t.dragPlaneNormal.scale(a.e.Dot(t.dragPlaneNormal,s)),u=s.subtract(c).normalizeToNew(),l=a.e.Dot(u,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());l=l/i._boundingDimensions.length()*i._anchorMesh.scaling.length(),i.attachedMesh.rotationQuaternion||(i.attachedMesh.rotationQuaternion=a.b.RotationYawPitchRoll(i.attachedMesh.rotation.y,i.attachedMesh.rotation.x,i.attachedMesh.rotation.z)),i._anchorMesh.rotationQuaternion||(i._anchorMesh.rotationQuaternion=a.b.RotationYawPitchRoll(i._anchorMesh.rotation.y,i._anchorMesh.rotation.x,i._anchorMesh.rotation.z)),o+=l,Math.abs(o)<=2*Math.PI&&(e>=8?a.b.RotationYawPitchRollToRef(0,0,l,i._tmpQuaternion):e>=4?a.b.RotationYawPitchRollToRef(l,0,0,i._tmpQuaternion):a.b.RotationYawPitchRollToRef(0,l,0,i._tmpQuaternion),i._anchorMesh.addChild(i.attachedMesh),i._anchorMesh.rotationQuaternion.multiplyToRef(i._tmpQuaternion,i._anchorMesh.rotationQuaternion),i._anchorMesh.removeChild(i.attachedMesh),i.attachedMesh.setParent(n)),i.updateBoundingBox(),cc.a._RestorePivotPoint(i.attachedMesh)}i._updateDummy()})),p.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({}),i._selectNode(t)})),p.onDragEndObservable.add((function(){i.onRotationSphereDragEndObservable.notifyObservers({}),i._selectNode(null),i._updateDummy()})),u._rotateSpheresParent.addChild(t)},u=this,l=0;l<12;l++)c(l);i._rootMesh.addChild(i._rotateSpheresParent),i._scaleBoxesParent=new ot.a("",n.utilityLayerScene),i._scaleBoxesParent.rotationQuaternion=new a.b;for(var h=0;h<3;h++)for(var d=0;d<3;d++)for(var p,f=function(){var e=(1===h?1:0)+(1===d?1:0)+(1===g?1:0);if(1===e||3===e)return"continue";var t=Object(nc.b)("",{size:1},n.utilityLayerScene);t.material=_.coloredMaterial,t.metadata=2===e,t.isNearGrabbable=!0;var r=new a.e(h-1,d-1,g-1).normalize();(p=new it.a({dragAxis:r})).updateDragPlane=!1,p.moveAttached=!1,t.addBehavior(p),p.onDragObservable.add((function(n){if(i.onScaleBoxDragObservable.notifyObservers({}),i.attachedMesh){var o=i.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");cc.a._RemoveAndStorePivotPoint(i.attachedMesh);var s=n.dragDistance/i._boundingDimensions.length()*i._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(i._scaleDragSpeed),c.multiplyInPlace(i._axisFactor),i.updateBoundingBox(),i.scalePivot?(i.attachedMesh.getWorldMatrix().getRotationMatrixToRef(i._tmpRotationMatrix),i._boundingDimensions.scaleToRef(.5,i._tmpVector),a.e.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector),i._boundingDimensions.multiplyToRef(i.scalePivot,i._tmpVector),a.e.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.addInPlace(i._tmpVector)):(t.absolutePosition.subtractToRef(i._anchorMesh.position,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector)),i._anchorMesh.addChild(i.attachedMesh),i._anchorMesh.scaling.addInPlace(c),(i._anchorMesh.scaling.x<0||i._anchorMesh.scaling.y<0||i._anchorMesh.scaling.z<0)&&i._anchorMesh.scaling.subtractInPlace(c),i._anchorMesh.removeChild(i.attachedMesh),i.attachedMesh.setParent(o),cc.a._RestorePivotPoint(i.attachedMesh)}i._updateDummy()})),p.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({}),i._selectNode(t)})),p.onDragEndObservable.add((function(){i.onScaleBoxDragEndObservable.notifyObservers({}),i._selectNode(null),i._updateDummy()})),_._scaleBoxesParent.addChild(t)},_=this,g=0;g<3;g++)f();i._rootMesh.addChild(i._scaleBoxesParent);var v=new Array;return i._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){v[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=v[e.event.pointerId]&&(v[e.event.pointerId].material=i.coloredMaterial,delete v[e.event.pointerId]):i._rotateSpheresParent.getChildMeshes().concat(i._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(v[e.event.pointerId]=t,t.material=i.hoverColoredMaterial)}))})),i._renderObserver=i.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){i.attachedMesh&&!i._existingMeshScale.equals(i.attachedMesh.scaling)?i.updateBoundingBox():(i.fixedDragMeshScreenSize||i.fixedDragMeshBoundsSize)&&(i._updateRotationSpheres(),i._updateScaleBoxes()),i._dragMesh&&i.attachedMesh&&i.pointerDragBehavior.dragging&&(i._lineBoundingBox.position.rotateByQuaternionToRef(i._rootMesh.rotationQuaternion,i._tmpVector),i.attachedMesh.setAbsolutePosition(i._dragMesh.position.add(i._tmpVector.scale(-1))))})),i.updateBoundingBox(),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"axisFactor",{get:function(){return this._axisFactor},set:function(e){this._axisFactor=e;for(var t=this._scaleBoxesParent.getChildMeshes(),n=0,i=0;i<3;i++)for(var r=0;r<3;r++)for(var o=0;o<3;o++){var s=(1===i?1:0)+(1===r?1:0)+(1===o?1:0);if(1!==s&&3!==s){if(t[n]){var c=new a.e(i-1,r-1,o-1);c.multiplyInPlace(this._axisFactor),t[n].setEnabled(c.lengthSquared()>ht.a)}n++}}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"scaleDragSpeed",{get:function(){return this._scaleDragSpeed},set:function(e){this._scaleDragSpeed=e},enumerable:!1,configurable:!0}),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){this._anchorMesh.scaling.setAll(1),cc.a._RemoveAndStorePivotPoint(e);var n=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(n),cc.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){cc.a._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(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 t=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);t.max.subtractToRef(t.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((t.max.x+t.min.x)/2,(t.max.y+t.min.y)/2,(t.max.z+t.min.z)/2),this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),this.attachedMesh.setParent(e)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),cc.a._RestorePivotPoint(this.attachedMesh))},t.prototype._updateRotationSpheres=function(){for(var e=this._rotateSpheresParent.getChildMeshes(),t=0;t<3;t++)for(var n=0;n<2;n++)for(var i=0;i<2;i++){var r=4*t+2*n+i;if(0==t&&(e[r].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*n,this._boundingDimensions.z*i),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*n,this._boundingDimensions.y/2,this._boundingDimensions.z*i),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*n,this._boundingDimensions.y*i,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,n=0;n<3;n++)for(var i=0;i<3;i++)for(var r=0;r<3;r++){var o=(1===n?1:0)+(1===i?1:0)+(1===r?1:0);if(1!==o&&3!==o){if(e[t])if(e[t].position.set(this._boundingDimensions.x*(n/2),this._boundingDimensions.y*(i/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,n){n<4?t.setEnabled(-1!=e.indexOf("x")):n<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(n,i){var r=e;t&&!0===n.metadata&&(r=!1),n.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=Object(nc.b)("dummy",{size: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 n=e.position.clone(),i=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var r=Object(nc.b)("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,r.scaling),0===r.scaling.y&&(r.scaling.y=ht.a),0===r.scaling.x&&(r.scaling.x=ht.a),0===r.scaling.z&&(r.scaling.z=ht.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(i),e.position.copyFrom(n),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}(ic.a),lc=n(74),hc=n(71),dc=function(e){function t(n,i,r,c,u,l,h){var d;void 0===i&&(i=s.a.Gray()),void 0===r&&(r=rc.a.DefaultUtilityLayer),void 0===c&&(c=32),void 0===u&&(u=null),void 0===l&&(l=!1),void 0===h&&(h=1);var p=e.call(this,r)||this;p._pointerObserver=null,p.snapDistance=0,p.onSnapObservable=new o.c,p.angle=0,p._isEnabled=!0,p._parent=null,p._dragging=!1,p._angles=new a.e,p._parent=u,p._coloredMaterial=new Si.a("",r.utilityLayerScene),p._coloredMaterial.diffuseColor=i,p._coloredMaterial.specularColor=i.subtract(new s.a(.1,.1,.1)),p._hoverMaterial=new Si.a("",r.utilityLayerScene),p._hoverMaterial.diffuseColor=s.a.Yellow(),p._disableMaterial=new Si.a("",r.utilityLayerScene),p._disableMaterial.diffuseColor=s.a.Gray(),p._disableMaterial.alpha=.4,p._gizmoMesh=new Te.a("",r.utilityLayerScene);var f=p._createGizmoMesh(p._gizmoMesh,h,c),_=f.rotationMesh,m=f.collider;p._rotationDisplayPlane=Object(hc.a)("rotationDisplay",{size:.6,updatable:!1},p.gizmoLayer.utilityLayerScene),p._rotationDisplayPlane.rotation.z=.5*Math.PI,p._rotationDisplayPlane.parent=p._gizmoMesh,p._rotationDisplayPlane.setEnabled(!1),ya.a.ShadersStore.rotationGizmoVertexShader=t._rotationGizmoVertexShader,ya.a.ShadersStore.rotationGizmoFragmentShader=t._rotationGizmoFragmentShader,p._rotationShaderMaterial=new lc.a("shader",p.gizmoLayer.utilityLayerScene,{vertex:"rotationGizmo",fragment:"rotationGizmo"},{attributes:["position","uv"],uniforms:["worldViewProjection","angles"]}),p._rotationShaderMaterial.backFaceCulling=!1,p._rotationDisplayPlane.material=p._rotationShaderMaterial,p._rotationDisplayPlane.visibility=.999,p._gizmoMesh.lookAt(p._rootMesh.position.add(n)),p._rootMesh.addChild(p._gizmoMesh),p._gizmoMesh.scaling.scaleInPlace(1/3),p.dragBehavior=new it.a({dragPlaneNormal:n}),p.dragBehavior.moveAttached=!1,p.dragBehavior.maxDragAngle=t.MaxDragAngle,p.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,p._rootMesh.addBehavior(p.dragBehavior);var g=new a.e,v=new a.a,b=new a.e,y=new a.e;p.dragBehavior.onDragStartObservable.add((function(e){p.attachedNode&&(g.copyFrom(e.dragPlanePoint),p._rotationDisplayPlane.setEnabled(!0),p._rotationDisplayPlane.getWorldMatrix().invertToRef(v),a.e.TransformCoordinatesToRef(e.dragPlanePoint,v,g),p._angles.x=Math.atan2(g.y,g.x)+Math.PI,p._angles.y=0,p._angles.z=p.updateGizmoRotationToMatchAttachedMesh?1:0,p._dragging=!0,g.copyFrom(e.dragPlanePoint),p._rotationShaderMaterial.setVector3("angles",p._angles),p.angle=0)})),p.dragBehavior.onDragEndObservable.add((function(){p._dragging=!1,p._rotationDisplayPlane.setEnabled(!1)}));var T={snapDistance:0},E=0,S=new a.a,A=new a.b;p.dragBehavior.onDragObservable.add((function(e){if(p.attachedNode){var t=new a.e(1,1,1),i=new a.b(0,0,0,1),o=new a.e(0,0,0);p._handlePivot(),p.attachedNode.getWorldMatrix().decompose(t,i,o);var s=e.dragPlanePoint.subtract(o).normalize(),c=g.subtract(o).normalize(),u=a.e.Cross(s,c),l=a.e.Dot(s,c),h=Math.atan2(u.length(),l);b.copyFrom(n),y.copyFrom(n),p.updateGizmoRotationToMatchAttachedMesh&&(i.toRotationMatrix(v),y=a.e.TransformCoordinates(b,v));var d=!1;if(r.utilityLayerScene.activeCamera){var f=r.utilityLayerScene.activeCamera.position.subtract(o).normalize();a.e.Dot(f,y)>0&&(b.scaleInPlace(-1),y.scaleInPlace(-1),d=!0)}a.e.Dot(y,u)>0&&(h=-h);var _=!1;if(0!=p.snapDistance)if(E+=h,Math.abs(E)>p.snapDistance){var m=Math.floor(Math.abs(E)/p.snapDistance);E<0&&(m*=-1),E%=p.snapDistance,h=p.snapDistance*m,_=!0}else h=0;var x=Math.sin(h/2);if(A.set(b.x*x,b.y*x,b.z*x,Math.cos(h/2)),S.determinant()>0){var R=new a.e;A.toEulerAnglesToRef(R),a.b.RotationYawPitchRollToRef(R.y,-R.x,-R.z,A)}p.updateGizmoRotationToMatchAttachedMesh?i.multiplyToRef(A,i):A.multiplyToRef(i,i),p.attachedNode.getWorldMatrix().copyFrom(a.a.Compose(t,i,o)),g.copyFrom(e.dragPlanePoint),_&&(T.snapDistance=h,p.onSnapObservable.notifyObservers(T)),p._angles.y+=h,p.angle+=d?-h:h,p._rotationShaderMaterial.setVector3("angles",p._angles),p._matrixChanged()}}));var x=r._getSharedGizmoLight();x.includedOnlyMeshes=x.includedOnlyMeshes.concat(p._rootMesh.getChildMeshes(!1));var R={colliderMeshes:[m],gizmoMeshes:[_],material:p._coloredMaterial,hoverMaterial:p._hoverMaterial,disableMaterial:p._disableMaterial,active:!1,dragBehavior:p.dragBehavior};return null===(d=p._parent)||void 0===d||d.addToAxisCache(p._gizmoMesh,R),p._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){var n;if(!p._customMeshSet&&(p.dragBehavior.maxDragAngle=t.MaxDragAngle,p._isHovered=!(-1==R.colliderMeshes.indexOf(null===(n=null==e?void 0:e.pickInfo)||void 0===n?void 0:n.pickedMesh)),!p._parent)){var i=R.dragBehavior.enabled?p._isHovered||p._dragging?p._hoverMaterial:p._coloredMaterial:p._disableMaterial;p._setGizmoMeshMaterial(R.gizmoMeshes,i)}})),p.dragBehavior.onEnabledObservable.add((function(e){p._setGizmoMeshMaterial(R.gizmoMeshes,e?p._coloredMaterial:p._disableMaterial)})),p}return Object(h.d)(t,e),t.prototype._createGizmoMesh=function(e,t,n){var i=Wi("ignore",{diameter:.6,thickness:.03*t,tessellation:n},this.gizmoLayer.utilityLayerScene);i.visibility=0;var r=Wi("",{diameter:.6,thickness:.005*t,tessellation:n},this.gizmoLayer.utilityLayerScene);return r.material=this._coloredMaterial,r.rotation.x=Math.PI/2,i.rotation.x=Math.PI/2,e.addChild(r),e.addChild(i),{rotationMesh:r,collider: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.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._rotationDisplayPlane&&this._rotationDisplayPlane.dispose(),this._rotationShaderMaterial&&this._rotationShaderMaterial.dispose(),[this._coloredMaterial,this._hoverMaterial,this._disableMaterial].forEach((function(e){e&&e.dispose()})),e.prototype.dispose.call(this)},t.MaxDragAngle=9*Math.PI/20,t._rotationGizmoVertexShader="\n precision highp float;\n attribute vec3 position;\n attribute vec2 uv;\n uniform mat4 worldViewProjection;\n varying vec3 vPosition;\n varying vec2 vUV;\n void main(void) {\n gl_Position = worldViewProjection * vec4(position, 1.0);\n vUV = uv;\n }",t._rotationGizmoFragmentShader="\n precision highp float;\n varying vec2 vUV;\n varying vec3 vPosition;\n uniform vec3 angles;\n #define twopi 6.283185307\n void main(void) {\n vec2 uv = vUV - vec2(0.5);\n float angle = atan(uv.y, uv.x) + 3.141592;\n float delta = gl_FrontFacing ? angles.y : -angles.y;\n float begin = angles.x - delta * angles.z;\n float start = (begin < (begin + delta)) ? begin : (begin + delta);\n float end = (begin > (begin + delta)) ? begin : (begin + delta);\n float len = sqrt(dot(uv,uv));\n float opacity = 1. - step(0.5, len);\n\n float base = abs(floor(start / twopi)) * twopi;\n start += base;\n end += base;\n\n float intensity = 0.;\n for (int i = 0; i < 5; i++)\n {\n intensity += max(step(start, angle) - step(end, angle), 0.);\n angle += twopi;\n }\n gl_FragColor = vec4(1.,1.,0., min(intensity * 0.25, 0.8)) * opacity;\n }",t}(ic.a),pc=function(e){function t(t,n,i,r,c,u){void 0===t&&(t=rc.a.DefaultUtilityLayer),void 0===n&&(n=32),void 0===i&&(i=!1),void 0===r&&(r=1);var l=e.call(this,t)||this;l.onDragStartObservable=new o.c,l.onDragEndObservable=new o.c,l._observables=[],l._gizmoAxisCache=new Map;var h=u&&u.xOptions&&u.xOptions.color?u.xOptions.color:s.a.Red().scale(.5),d=u&&u.yOptions&&u.yOptions.color?u.yOptions.color:s.a.Green().scale(.5),p=u&&u.zOptions&&u.zOptions.color?u.zOptions.color:s.a.Blue().scale(.5);return l.xGizmo=new dc(new a.e(1,0,0),h,t,n,l,i,r),l.yGizmo=new dc(new a.e(0,1,0),d,t,n,l,i,r),l.zGizmo=new dc(new a.e(0,0,1),p,t,n,l,i,r),[l.xGizmo,l.yGizmo,l.zGizmo].forEach((function(e){u&&null!=u.updateScale&&(e.updateScale=u.updateScale),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):ic.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}(ic.a),fc=function(e){function t(n,i,r,c){var u;void 0===i&&(i=s.a.Gray()),void 0===r&&(r=rc.a.DefaultUtilityLayer),void 0===c&&(c=null);var l=e.call(this,r)||this;l._pointerObserver=null,l.snapDistance=0,l.onSnapObservable=new o.c,l._isEnabled=!1,l._parent=null,l._dragging=!1,l._parent=c,l._coloredMaterial=new Si.a("",r.utilityLayerScene),l._coloredMaterial.diffuseColor=i,l._coloredMaterial.specularColor=i.subtract(new s.a(.1,.1,.1)),l._hoverMaterial=new Si.a("",r.utilityLayerScene),l._hoverMaterial.diffuseColor=s.a.Yellow(),l._disableMaterial=new Si.a("",r.utilityLayerScene),l._disableMaterial.diffuseColor=s.a.Gray(),l._disableMaterial.alpha=.4,l._gizmoMesh=t._CreatePlane(r.utilityLayerScene,l._coloredMaterial),l._gizmoMesh.lookAt(l._rootMesh.position.add(n)),l._gizmoMesh.scaling.scaleInPlace(1/3),l._gizmoMesh.parent=l._rootMesh;var h=0,d=new a.e,p={snapDistance:0};l.dragBehavior=new it.a({dragPlaneNormal:n}),l.dragBehavior.moveAttached=!1,l._rootMesh.addBehavior(l.dragBehavior),l.dragBehavior.onDragObservable.add((function(e){if(l.attachedNode){if(l._handlePivot(),0==l.snapDistance)l.attachedNode.getWorldMatrix().addTranslationFromFloats(e.delta.x,e.delta.y,e.delta.z);else if(h+=e.dragDistance,Math.abs(h)>l.snapDistance){var t=Math.floor(Math.abs(h)/l.snapDistance);h%=l.snapDistance,e.delta.normalizeToRef(d),d.scaleInPlace(l.snapDistance*t),l.attachedNode.getWorldMatrix().addTranslationFromFloats(d.x,d.y,d.z),p.snapDistance=l.snapDistance*t,l.onSnapObservable.notifyObservers(p)}l._matrixChanged()}})),l.dragBehavior.onDragStartObservable.add((function(){l._dragging=!0})),l.dragBehavior.onDragEndObservable.add((function(){l._dragging=!1}));var f=r._getSharedGizmoLight();f.includedOnlyMeshes=f.includedOnlyMeshes.concat(l._rootMesh.getChildMeshes(!1));var _={gizmoMeshes:l._gizmoMesh.getChildMeshes(),colliderMeshes:l._gizmoMesh.getChildMeshes(),material:l._coloredMaterial,hoverMaterial:l._hoverMaterial,disableMaterial:l._disableMaterial,active:!1,dragBehavior:l.dragBehavior};return null===(u=l._parent)||void 0===u||u.addToAxisCache(l._gizmoMesh,_),l._pointerObserver=r.utilityLayerScene.onPointerObservable.add((function(e){var t;if(!l._customMeshSet&&(l._isHovered=!(-1==_.colliderMeshes.indexOf(null===(t=null==e?void 0:e.pickInfo)||void 0===t?void 0:t.pickedMesh)),!l._parent)){var n=_.dragBehavior.enabled?l._isHovered||l._dragging?l._hoverMaterial:l._coloredMaterial:l._disableMaterial;l._setGizmoMeshMaterial(_.gizmoMeshes,n)}})),l.dragBehavior.onEnabledObservable.add((function(e){l._setGizmoMeshMaterial(_.gizmoMeshes,e?l._coloredMaterial:l._disableMaterial)})),l}return Object(h.d)(t,e),t._CreatePlane=function(e,t){var n=new ct.a("plane",e),i=Object(hc.a)("dragPlane",{width:.1375,height:.1375,sideOrientation:2},e);return i.material=t,i.parent=n,n},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}(ic.a),_c=function(e){function t(t,n,i){void 0===t&&(t=rc.a.DefaultUtilityLayer),void 0===n&&(n=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 tc.a(new a.e(1,0,0),s.a.Red().scale(.5),t,r,n),r.yGizmo=new tc.a(new a.e(0,1,0),s.a.Green().scale(.5),t,r,n),r.zGizmo=new tc.a(new a.e(0,0,1),s.a.Blue().scale(.5),t,r,n),r.xPlaneGizmo=new fc(new a.e(1,0,0),s.a.Red().scale(.5),r.gizmoLayer,r),r.yPlaneGizmo=new fc(new a.e(0,1,0),s.a.Green().scale(.5),r.gizmoLayer,r),r.zPlaneGizmo=new fc(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,i?i.addToAxisCache(r._gizmoAxisCache):ic.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=e,[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(n){n&&(n.isEnabled=e,e&&(n.attachedMesh?n.attachedMesh=t.attachedMesh:n.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}(ic.a);function mc(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 n,i,r,o,c,u,l=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,h=e.size,d=e.sizeX||h||1,p=e.sizeY||h||1,f=e.sizeZ||h||1,_=e.custom||t[l],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||Gi.a.DEFAULTSIDE,T=new Array,E=new Array,S=new Array,A=new Array,x=new Array,R=0,C=0,P=new Array,O=0,M=0;if(b)for(M=0;M0&&e.forEach((function(e,n){t._gizmoAxisCache.set(n,e)}))},e.prototype.dispose=function(){var e,t,n=this;for(var i in this._pointerObservers.forEach((function(e){n.scene.onPointerObservable.remove(e)})),this.gizmos){var r=this.gizmos[i];r&&r.dispose()}this._defaultKeepDepthUtilityLayer!==rc.a._DefaultKeepDepthUtilityLayer&&(null===(e=this._defaultKeepDepthUtilityLayer)||void 0===e||e.dispose()),this._defaultUtilityLayer!==rc.a._DefaultUtilityLayer&&(null===(t=this._defaultUtilityLayer)||void 0===t||t.dispose()),this.boundingBoxDragBehavior.detach(),this.onAttachedToMeshObservable.clear()},e}(),Tc=n(53),Ec=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,n){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,n,e):this._setDefaultShadowProjectionMatrix(e,t,n),this},Object(h.c)([Object(F.p)()],t.prototype,"position",null),Object(h.c)([Object(F.p)()],t.prototype,"direction",null),Object(h.c)([Object(F.d)()],t.prototype,"shadowMinZ",null),Object(h.c)([Object(F.d)()],t.prototype,"shadowMaxZ",null),t}(Tc.a);B.a.AddNodeConstructor("Light_Type_1",(function(e,t){return function(){return new Sc(e,a.e.Zero(),t)}}));var Sc=function(e){function t(t,n,i){var r=e.call(this,t,i)||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=n.scale(-1),r.direction=n,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}),Object.defineProperty(t.prototype,"orthoLeft",{get:function(){return this._orthoLeft},set:function(e){this._orthoLeft=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoRight",{get:function(){return this._orthoRight},set:function(e){this._orthoRight=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoTop",{get:function(){return this._orthoTop},set:function(e){this._orthoTop=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"orthoBottom",{get:function(){return this._orthoBottom},set:function(e){this._orthoBottom=e},enumerable:!1,configurable:!0}),t.prototype.getClassName=function(){return"DirectionalLight"},t.prototype.getTypeID=function(){return Tc.a.LIGHTTYPEID_DIRECTIONALLIGHT},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,n){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,n)},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,this.getScene().getEngine().isNDCHalfZRange)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,n){var i=this.getScene().activeCamera;if(i){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;cthis._orthoRight&&(this._orthoRight=r.x),r.y>this._orthoTop&&(this._orthoTop=r.y),this.autoCalcShadowZBounds&&(r.zs&&(s=r.z))}this.autoCalcShadowZBounds&&(this._shadowMinZ=o,this._shadowMaxZ=s)}var d=this._orthoRight-this._orthoLeft,p=this._orthoTop-this._orthoBottom,f=void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,_=void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,m=this.getScene().getEngine().useReverseDepthBuffer;a.a.OrthoOffCenterLHToRef(this._orthoLeft-d*this.shadowOrthoScale,this._orthoRight+d*this.shadowOrthoScale,this._orthoBottom-p*this.shadowOrthoScale,this._orthoTop+p*this.shadowOrthoScale,m?_:f,m?f:_,e,this.getScene().getEngine().isNDCHalfZRange)}},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){var t=this._scene.getEngine();return!t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1},t.prototype.getDepthMaxZ=function(e){var t=this._scene.getEngine();return t.useReverseDepthBuffer&&t.isNDCHalfZRange?0:1},t.prototype.prepareLightSpecificDefines=function(e,t){e["DIRLIGHT"+t]=!0},Object(h.c)([Object(F.d)()],t.prototype,"shadowFrustumSize",null),Object(h.c)([Object(F.d)()],t.prototype,"shadowOrthoScale",null),Object(h.c)([Object(F.d)()],t.prototype,"autoUpdateExtends",void 0),Object(h.c)([Object(F.d)()],t.prototype,"autoCalcShadowZBounds",void 0),Object(h.c)([Object(F.d)("orthoLeft")],t.prototype,"_orthoLeft",void 0),Object(h.c)([Object(F.d)("orthoRight")],t.prototype,"_orthoRight",void 0),Object(h.c)([Object(F.d)("orthoTop")],t.prototype,"_orthoTop",void 0),Object(h.c)([Object(F.d)("orthoBottom")],t.prototype,"_orthoBottom",void 0),t}(Ec);function Ac(e){var t=new Array,n=new Array,i=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||Gi.a.DEFAULTSIDE;t.push(0,0,0),r.push(.5,.5);for(var u=2*Math.PI*s,l=1===s?u/a:u/(a-1),h=0,d=0;d1e-4){var n=this.attachedMesh.forward;this._light.direction=new a.e(n.x,n.y,n.z),this._cachedForward.copyFrom(this.attachedMesh.forward)}else 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 n=new Te.a("hemisphereLight",e),i=Cc(n.name,{segments:10,diameter:1},e);return i.position.z=-.15,i.rotation.x=Math.PI/2,i.parent=n,this._CreateLightLines(3,e).parent=n,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreatePointLightMesh=function(e){var n=new Te.a("pointLight",e),i=Object(ac.a)(n.name,{segments:10,diameter:1},e);return i.rotation.x=Math.PI/2,i.parent=n,this._CreateLightLines(5,e).parent=n,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreateSpotLightMesh=function(e){var n=new Te.a("spotLight",e);Object(ac.a)(n.name,{segments:10,diameter:1},e).parent=n;var i=Cc(n.name,{segments:10,diameter:2},e);return i.parent=n,i.rotation.x=-Math.PI/2,this._CreateLightLines(2,e).parent=n,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreateDirectionalLightMesh=function(e){var n=new Te.a("directionalLight",e),i=new Te.a(n.name,e);i.parent=n,Object(ac.a)(n.name,{diameter:1.2,segments:10},e).parent=i;var r=Object(ki.a)(n.name,{updatable:!1,height:6,diameterTop:.3,diameterBottom:.3,tessellation:6,subdivisions:1},e);r.parent=i,(o=r.clone(n.name)).scaling.y=.5,o.position.x+=1.25,(a=r.clone(n.name)).scaling.y=.5,a.position.x+=-1.25;var o,a,s=Object(ki.a)(n.name,{updatable:!1,height:1,diameterTop:0,diameterBottom:.6,tessellation:6,subdivisions:1},e);return s.position.y+=3,s.parent=i,(o=s.clone(n.name)).position.y=1.5,o.position.x+=1.25,(a=s.clone(n.name)).position.y=1.5,a.position.x+=-1.25,i.scaling.scaleInPlace(t._Scale),i.rotation.z=Math.PI/2,i.rotation.y=Math.PI/2,n},t._Scale=.007,t._CreateLightLines=function(e,t){var n=new Te.a("root",t);n.rotation.x=Math.PI/2;var i=new Te.a("linePivot",t);i.parent=n;var r=Object(ki.a)("line",{updatable:!1,height:2,diameterTop:.2,diameterBottom:.3,tessellation:6,subdivisions:1},t);if(r.position.y=r.scaling.y/2+1.2,r.parent=i,e<2)return i;for(var o=0;o<4;o++){(a=i.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 n;for(o=0;o<4;o++){(a=i.clone("linePivotClone")).rotation.z=Math.PI/2,a.rotation.y=Math.PI/2*o}if(e<4)return n;for(o=0;o<4;o++){var a;(a=i.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=i.clone("linePivotClone")).rotation.z=Math.PI),n},t}(ic.a),Ic=function(e){function t(t){void 0===t&&(t=rc.a.DefaultUtilityLayer);var n=e.call(this,t)||this;return n._pointerObserver=null,n.onClickedObservable=new o.c,n._camera=null,n._invProjection=new a.a,n._material=new Si.a("cameraGizmoMaterial",n.gizmoLayer.utilityLayerScene),n._material.diffuseColor=new s.a(.5,.5,.5),n._material.specularColor=new s.a(.1,.1,.1),n._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e){n._camera&&(n._isHovered=!(!e.pickInfo||-1==n._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)),n._isHovered&&0===e.event.button&&n.onClickedObservable.notifyObservers(n._camera))}),qe.a.POINTERDOWN),n}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 n=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=n._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 i=this.gizmoLayer._getSharedGizmoLight();i.includedOnlyMeshes=i.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 n=new Te.a("rootCameraGizmo",e),i=new Te.a(n.name,e);i.parent=n,Object(nc.b)(n.name,{width:1,height:.8,depth:.5},e).parent=i;var r=Object(ki.a)(n.name,{height:.5,diameterTop:.8,diameterBottom:.8},e);r.parent=i,r.position.y=.3,r.position.x=-.6,r.rotation.x=.5*Math.PI;var o=Object(ki.a)(n.name,{height:.5,diameterTop:.6,diameterBottom:.6},e);o.parent=i,o.position.y=.5,o.position.x=.4,o.rotation.x=.5*Math.PI;var a=Object(ki.a)(n.name,{height:.5,diameterTop:.5,diameterBottom:.5},e);return a.parent=i,a.position.y=0,a.position.x=.6,a.rotation.z=.5*Math.PI,n.scaling.scaleInPlace(t._Scale),i.position.x=-.9,n},t._CreateCameraFrustum=function(e){var t=new Te.a("rootCameraGizmo",e),n=new Te.a(t.name,e);n.parent=t;for(var i=0;i<4;i+=2)for(var r=0;r<4;r+=2){var o;(o=Object(sc.e)("lines",{points:[new a.e(-1+r,-1+i,-1),new a.e(-1+r,-1+i,1)]},e)).parent=n,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Object(sc.e)("lines",{points:[new a.e(-1,-1+r,-1+i),new a.e(1,-1+r,-1+i)]},e)).parent=n,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1,(o=Object(sc.e)("lines",{points:[new a.e(-1+r,-1,-1+i),new a.e(-1+r,1,-1+i)]},e)).parent=n,o.alwaysSelectAsActiveMesh=!0,o.isPickable=!1}return t},t._Scale=.05,t}(ic.a);Cn.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Dc="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}";Cn.a.IncludesShadersStore.packingFunctions=Dc;var Nc="#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";Cn.a.IncludesShadersStore.kernelBlurFragment=Nc;var Lc="#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";Cn.a.IncludesShadersStore.kernelBlurFragment2=Lc;var Fc="\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\n}\nfloat sampleCoC(in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\nreturn coc;\n}\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\n#include\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\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[0..varyingCount]\n#include[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}";Cn.a.ShadersStore.kernelBlurPixelShader=Fc;Cn.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var wc="\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";Cn.a.ShadersStore.kernelBlurVertexShader=wc;var Bc=function(e){function t(t,n,i,r,o,a,s,c,u,l,h){void 0===a&&(a=Be.a.BILINEAR_SAMPLINGMODE),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=""),void 0===h&&(h=!1);var d=e.call(this,t,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],r,o,a,s,c,null,u,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return d.blockCompilation=h,d._packedFloat=!1,d._staticDefines="",d._staticDefines=l,d.direction=n,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=i,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,n,i,r,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===n&&(n=null),this._updateParameters(r,o)},t.prototype._updateParameters=function(t,n){for(var i=this._kernel,r=(i-1)/2,o=[],a=[],s=0,c=0;c0)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,n,i,r){return F.a.Parse((function(){return new t(e.name,e.direction,e.kernel,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable,e.textureType,void 0,!1)}),e,i,r)},Object(h.c)([Object(F.d)("kernel")],t.prototype,"_kernel",void 0),Object(h.c)([Object(F.d)("packedFloat")],t.prototype,"_packedFloat",void 0),Object(h.c)([Object(F.o)()],t.prototype,"direction",void 0),t}(Dn);Object(c.b)("BABYLON.BlurPostProcess",Bc);var Uc=function(e){function t(t,n,i,r,o,s,c){void 0===o&&(o=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=Be.a.BILINEAR_SAMPLINGMODE),void 0===c&&(c=!0);var u=e.call(this,t,n,i,r,!0,o,!1,s,c)||this;if(u.scene=i,u.mirrorPlane=new Nt.a(0,1,0,1),u._transformMatrix=a.a.Zero(),u._mirrorMatrix=a.a.Zero(),u._adaptiveBlurKernel=0,u._blurKernelX=0,u._blurKernelY=0,u._blurRatio=1,u.scene=u.getScene(),!i)return u;u.ignoreCameraViewport=!0,u._updateGammaSpace(),u._imageProcessingConfigChangeObserver=i.imageProcessingConfiguration.onUpdateParameters.add((function(){u._updateGammaSpace()}));var l,h=i.getEngine();return h.supportsUniformBuffers&&(u._sceneUBO=i.createSceneUniformBuffer('Scene for Mirror Texture (name "'.concat(t,'")'))),u.onBeforeBindObservable.add((function(){var e;null===(e=h._debugPushGroup)||void 0===e||e.call(h,"mirror generation for ".concat(t),1)})),u.onAfterUnbindObservable.add((function(){var e;null===(e=h._debugPopGroup)||void 0===e||e.call(h,1)})),u.onBeforeRenderObservable.add((function(){u._sceneUBO&&(u._currentSceneUBO=i.getSceneUniformBuffer(),i.setSceneUniformBuffer(u._sceneUBO),i.getSceneUniformBuffer().unbindEffect()),a.a.ReflectionToRef(u.mirrorPlane,u._mirrorMatrix),u._mirrorMatrix.multiplyToRef(i.getViewMatrix(),u._transformMatrix),i.setTransformMatrix(u._transformMatrix,i.getProjectionMatrix()),l=i.clipPlane,i.clipPlane=u.mirrorPlane,i.getEngine().cullBackFaces=!1,i._mirroredCameraPosition=a.e.TransformCoordinates(i.activeCamera.globalPosition,u._mirrorMatrix)})),u.onAfterRenderObservable.add((function(){u._sceneUBO&&i.setSceneUniformBuffer(u._currentSceneUBO),i.updateTransformMatrix(),i.getEngine().cullBackFaces=null,i._mirroredCameraPosition=null,i.clipPlane=l})),u}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(),n=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*n},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&&e.getCaps().textureFloatLinearFiltering?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT;this._blurX=new Bc("horizontal blur",new a.d(1,0),this._blurKernelX,this._blurRatio,null,Be.a.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._renderTarget:this._blurX.alwaysForcePOT=!0,this._blurY=new Bc("vertical blur",new a.d(0,1),this._blurKernelY,this._blurRatio,null,Be.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 n=this.getSize(),i=new t(this.name,n.width,e,this._renderTargetOptions.generateMipMaps,this._renderTargetOptions.type,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.mirrorPlane=this.mirrorPlane.clone(),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);return t.mirrorPlane=this.mirrorPlane.asArray(),t},t.prototype.dispose=function(){var t;e.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver),null===(t=this._sceneUBO)||void 0===t||t.dispose()},t}(ci);Be.a._CreateMirror=function(e,t,n,i){return new Uc(e,t,n,i)};var Vc=function(e){function t(t,n,i,r,s,c,u,l,h,d,p,f,_,m,v){var b;void 0===i&&(i=null),void 0===r&&(r=!1),void 0===s&&(s=null),void 0===c&&(c=null),void 0===u&&(u=null),void 0===l&&(l=g.a.TEXTUREFORMAT_RGBA),void 0===h&&(h=!1),void 0===d&&(d=null),void 0===p&&(p=!1),void 0===f&&(f=.8),void 0===_&&(_=0);var y=e.call(this,n)||this;return y._lodScale=.8,y._lodOffset=0,y.onLoadObservable=new o.c,y.boundingBoxPosition=a.e.Zero(),y._rotationY=0,y._files=null,y._forcedExtension=null,y._extensions=null,y.name=t,y.url=t,y._noMipmap=r,y.hasAlpha=!1,y._format=l,y.isCube=!0,y._textureMatrix=a.a.Identity(),y._createPolynomials=p,y.coordinatesMode=Be.a.CUBIC_MODE,y._extensions=i,y._files=s,y._forcedExtension=d,y._loaderOptions=m,y._useSRGBBuffer=v,y._lodScale=f,y._lodOffset=_,t||s?(y.updateURL(t,d,c,h,u,i,null===(b=y.getScene())||void 0===b?void 0:b.useDelayedTextureLoading,s),y):y}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}),Object.defineProperty(t.prototype,"forcedExtension",{get:function(){return this._forcedExtension},enumerable:!1,configurable:!0}),t.CreateFromImages=function(e,n,i){var r="";return e.forEach((function(e){return r+=e})),new t(r,n,null,i,e)},t.CreateFromPrefilteredData=function(e,n,i,r){void 0===i&&(i=null),void 0===r&&(r=!0);var o=n.useDelayedTextureLoading;n.useDelayedTextureLoading=!1;var a=new t(e,n,null,!1,null,null,null,void 0,!0,i,r);return n.useDelayedTextureLoading=o,a},t.prototype.getClassName=function(){return"CubeTexture"},t.prototype.updateURL=function(e,t,n,i,r,o,a,s){void 0===n&&(n=null),void 0===i&&(i=!1),void 0===r&&(r=null),void 0===o&&(o=null),void 0===a&&(a=!1),void 0===s&&(s=null),this.name&&!Object(Ke.g)(this.name,"data:")||(this.name=e),this.url=e;var c=e.lastIndexOf("."),u=t||(c>-1?e.substring(c).toLowerCase():""),l=0===u.indexOf(".dds"),h=0===u.indexOf(".env");if(h?(this.gammaSpace=!1,this._prefiltered=!1,this.anisotropicFilteringLevel=1):(this._prefiltered=i,i&&(this.gammaSpace=!1,this.anisotropicFilteringLevel=1)),s)this._files=s;else if(h||l||o||(o=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),this._files=this._files||[],this._files.length=0,o){for(var d=0;d0,r.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!a.invertZ:a.invertZ,r.LODINREFLECTIONALPHA=a.lodLevelInAlpha,r.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,r.REFLECTIONBGR=this.switchToBGR,a.coordinatesMode===Be.a.INVCUBIC_MODE&&(r.INVERTCUBICMAP=!0),r.REFLECTIONMAP_3D=a.isCube,a.coordinatesMode){case Be.a.EXPLICIT_MODE:r.REFLECTIONMAP_EXPLICIT=!0;break;case Be.a.PLANAR_MODE:r.REFLECTIONMAP_PLANAR=!0;break;case Be.a.PROJECTION_MODE:r.REFLECTIONMAP_PROJECTION=!0;break;case Be.a.SKYBOX_MODE:r.REFLECTIONMAP_SKYBOX=!0;break;case Be.a.SPHERICAL_MODE:r.REFLECTIONMAP_SPHERICAL=!0;break;case Be.a.EQUIRECTANGULAR_MODE:r.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Be.a.FIXED_EQUIRECTANGULAR_MODE:r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Be.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Be.a.CUBIC_MODE:case Be.a.INVCUBIC_MODE:default:r.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(r.REFLECTIONFRESNEL=!0,r.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):(r.REFLECTIONFRESNEL=!1,r.REFLECTIONFALLOFF=!1)}else r.REFLECTION=!1,r.REFLECTIONFRESNEL=!1,r.REFLECTIONFALLOFF=!1,r.REFLECTIONBLUR=!1,r.REFLECTIONMAP_3D=!1,r.REFLECTIONMAP_SPHERICAL=!1,r.REFLECTIONMAP_PLANAR=!1,r.REFLECTIONMAP_CUBIC=!1,r.REFLECTIONMAP_PROJECTION=!1,r.REFLECTIONMAP_SKYBOX=!1,r.REFLECTIONMAP_EXPLICIT=!1,r.REFLECTIONMAP_EQUIRECTANGULAR=!1,r.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,r.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,r.INVERTCUBICMAP=!1,r.REFLECTIONMAP_OPPOSITEZ=!1,r.LODINREFLECTIONALPHA=!1,r.GAMMAREFLECTION=!1,r.RGBDREFLECTION=!1}r.PREMULTIPLYALPHA=this.alphaMode===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,r.USERGBCOLOR=this._useRGBColor,r.NOISE=this._enableNoise}if(r._areLightsDirty&&(r.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel),r.BACKMAT_SHADOWONLY=this._shadowOnly),r._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(r)}if(kc.a.PrepareDefinesForMisc(e,i,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),r),kc.a.PrepareDefinesForFrameBoundValues(i,o,r,n,null,t.getRenderingMesh().hasThinInstances),kc.a.PrepareDefinesForAttributes(e,r,!1,!0,!1)&&e&&(i.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(bt.b.NormalKind)||(e.createNormals(!0),m.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),r.isDirty){r.markAsProcessed(),i.resetCachedMaterial();var s=new Qc.a;r.FOG&&s.addFallback(0,"FOG"),r.POINTSIZE&&s.addFallback(1,"POINTSIZE"),r.MULTIVIEW&&s.addFallback(0,"MULTIVIEW"),kc.a.HandleFallbacksForShadows(r,s,this._maxSimultaneousLights);var c=[bt.b.PositionKind];r.NORMAL&&c.push(bt.b.NormalKind),r.UV1&&c.push(bt.b.UVKind),r.UV2&&c.push(bt.b.UV2Kind),kc.a.PrepareAttributesForBones(c,e,r,s),kc.a.PrepareAttributesForInstances(c,r);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"],l=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],h=["Material","Scene"];Ei.a&&(Ei.a.PrepareUniforms(u,r),Ei.a.PrepareSamplers(l,r)),kc.a.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:h,samplers:l,defines:r,maxSimultaneousLights:this._maxSimultaneousLights});var d=r.toString(),p=i.getEngine().createEffect("background",{attributes:c,uniformsNames:u,uniformBuffersNames:h,samplers:l,defines:d,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},o);t.setEffect(p,r,this._materialContext),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(r._renderId=i.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,n){var i=this.getScene(),r=n.materialDefines;if(r){var o=n.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),kc.a.BindBonesParameters(t,this._activeEffect);var a=this._mustRebind(i,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||(i.texturesEnabled&&(this._diffuseTexture&&jc.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),kc.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&jc.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),i.texturesEnabled&&(this._diffuseTexture&&jc.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&jc.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)))),kc.a.BindClipPlane(this._activeEffect,i),i.bindEyePosition(o)}else i.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._uniformBuffer.bindToEffect(o,"Material"),this._needToBindSceneUbo=!0);!a&&this.isFrozen||(i.lightsEnabled&&kc.a.BindLights(i,t,this._activeEffect,r,this._maxSimultaneousLights),this.bindView(o),kc.a.BindFogParameters(i,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._afterBind(t,this._activeEffect),this._uniformBuffer.update()}}},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._reflectionTexture===t||this._diffuseTexture===t)},t.prototype.dispose=function(t,n){void 0===t&&(t=!1),void 0===n&&(n=!1),n&&(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 n=this;return F.a.Clone((function(){return new t(e,n.getScene())}),this)},t.prototype.serialize=function(){var e=F.a.Serialize(this);return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,n,i){return F.a.Parse((function(){return new t(e.name,n)}),e,n,i)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,Object(h.c)([Object(F.f)()],t.prototype,"_primaryColor",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),Object(h.c)([Object(F.f)()],t.prototype,"__perceptualColor",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_primaryColorShadowLevel",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_primaryColorHighlightLevel",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),Object(h.c)([Object(F.n)()],t.prototype,"_reflectionTexture",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_reflectionBlur",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),Object(h.c)([Object(F.n)()],t.prototype,"_diffuseTexture",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_shadowLevel",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),Object(h.c)([Object(F.p)()],t.prototype,"_sceneCenter",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_opacityFresnel",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_reflectionFresnel",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_reflectionFalloffDistance",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_reflectionAmount",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_reflectionReflectance0",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_reflectionReflectance90",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_useRGBColor",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_enableNoise",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_maxSimultaneousLights",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_shadowOnly",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"shadowOnly",void 0),Object(h.c)([Object(F.j)()],t.prototype,"_imageProcessingConfiguration",void 0),t}(zc.a);Object(c.b)("BABYLON.BackgroundMaterial",Zc);var Jc=function(){function e(t,n){var i=this;this._errorHandler=function(e,t){i.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=Object(h.a)(Object(h.a)({},e._getDefaultOptions()),t),this._scene=n,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 Kr.a)this._scene.environmentTexture=this._options.environmentTexture;else{var e=Vc.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new Te.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,n=this._options.skyboxSize,i=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:t,skyboxSize:n,rootPosition:i};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 on&&this._scene.activeCamera.upperRadiusLimit&&(n=t=2*this._scene.activeCamera.upperRadiusLimit);var a=o.length();a>t&&(n=t=2*a),t*=1.1,n*=1.5,(i=r.min.add(o.scale(.5))).y=r.min.y-this._options.groundYBias}return{groundSize:t,skyboxSize:n,rootPosition:i}},e.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=Object(hc.a)("BackgroundPlane",{size: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 Zc("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 Kr.a?this._groundMaterial.diffuseTexture=this._options.groundTexture:(this._groundTexture=new Be.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=Be.a.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new Uc("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Be.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new Nt.a(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.renderList))for(var n=0;n0\nuniform vec2 vDebugMode;\n#endif\n#ifdef DETAIL\nuniform vec4 vDetailInfos;\n#endif\n#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#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#endif\n#endif\n#define ADDITIONAL_FRAGMENT_DECLARATION\n");Cn.a.IncludesShadersStore.pbrFragmentDeclaration=lu;n(185);var hu="layout(std140,column_major) uniform;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nuniform Material {\nvec2 vAlbedoInfos;\nvec4 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec3 vReflectivityInfos;\nvec2 vMicroSurfaceSamplerInfos;\nvec2 vReflectionInfos;\nvec2 vReflectionFilteringInfo;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec3 vBumpInfos;\nmat4 albedoMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 reflectivityMatrix;\nmat4 microSurfaceSamplerMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nmat4 reflectionMatrix;\nvec3 vReflectionColor;\nvec4 vAlbedoColor;\nvec4 vLightingIntensity;\nvec3 vReflectionMicrosurfaceInfos;\nfloat pointSize;\nvec4 vReflectivityColor;\nvec3 vEmissiveColor;\nvec3 vAmbientColor;\nvec2 vDebugMode;\nvec4 vMetallicReflectanceFactors;\nvec2 vMetallicReflectanceInfos;\nmat4 metallicReflectanceMatrix;\nvec2 vReflectanceInfos;\nmat4 reflectanceMatrix;\nvec3 vSphericalL00;\nvec3 vSphericalL1_1;\nvec3 vSphericalL10;\nvec3 vSphericalL11;\nvec3 vSphericalL2_2;\nvec3 vSphericalL2_1;\nvec3 vSphericalL20;\nvec3 vSphericalL21;\nvec3 vSphericalL22;\nvec3 vSphericalX;\nvec3 vSphericalY;\nvec3 vSphericalZ;\nvec3 vSphericalXX_ZZ;\nvec3 vSphericalYY_ZZ;\nvec3 vSphericalZZ;\nvec3 vSphericalXY;\nvec3 vSphericalYZ;\nvec3 vSphericalZX;\n#define ADDITIONAL_UBO_DECLARATION\n};\n#include\n#include\n";Cn.a.IncludesShadersStore.pbrUboDeclaration=hu;n(153);var du="\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nvarying vec4 vClipSpacePosition;\n#endif\n#include[1..7]\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif";Cn.a.IncludesShadersStore.pbrFragmentExtraDeclaration=du;n(187);var pu="#ifdef _DEFINENAME_\n#if _DEFINENAME_DIRECTUV == 1\n#define v_VARYINGNAME_UV vMainUV1\n#elif _DEFINENAME_DIRECTUV == 2\n#define v_VARYINGNAME_UV vMainUV2\n#elif _DEFINENAME_DIRECTUV == 3\n#define v_VARYINGNAME_UV vMainUV3\n#elif _DEFINENAME_DIRECTUV == 4\n#define v_VARYINGNAME_UV vMainUV4\n#elif _DEFINENAME_DIRECTUV == 5\n#define v_VARYINGNAME_UV vMainUV5\n#elif _DEFINENAME_DIRECTUV == 6\n#define v_VARYINGNAME_UV vMainUV6\n#else\nvarying vec2 v_VARYINGNAME_UV;\n#endif\n#endif\n";Cn.a.IncludesShadersStore.samplerFragmentAlternateDeclaration=pu;var fu="#include(_DEFINENAME_,ALBEDO,_VARYINGNAME_,Albedo,_SAMPLERNAME_,albedo)\n#include(_DEFINENAME_,AMBIENT,_VARYINGNAME_,Ambient,_SAMPLERNAME_,ambient)\n#include(_DEFINENAME_,OPACITY,_VARYINGNAME_,Opacity,_SAMPLERNAME_,opacity)\n#include(_DEFINENAME_,EMISSIVE,_VARYINGNAME_,Emissive,_SAMPLERNAME_,emissive)\n#include(_DEFINENAME_,LIGHTMAP,_VARYINGNAME_,Lightmap,_SAMPLERNAME_,lightmap)\n#include(_DEFINENAME_,REFLECTIVITY,_VARYINGNAME_,Reflectivity,_SAMPLERNAME_,reflectivity)\n#include(_DEFINENAME_,MICROSURFACEMAP,_VARYINGNAME_,MicroSurfaceSampler,_SAMPLERNAME_,microSurface)\n#include(_DEFINENAME_,METALLIC_REFLECTANCE,_VARYINGNAME_,MetallicReflectance,_SAMPLERNAME_,metallicReflectance)\n#include(_DEFINENAME_,REFLECTANCE,_VARYINGNAME_,Reflectance,_SAMPLERNAME_,reflectance)\n#ifdef CLEARCOAT\n#include(_DEFINENAME_,CLEARCOAT_TEXTURE,_VARYINGNAME_,ClearCoat,_SAMPLERNAME_,clearCoat)\n#include(_DEFINENAME_,CLEARCOAT_TEXTURE_ROUGHNESS,_VARYINGNAME_,ClearCoatRoughness)\n#if defined(CLEARCOAT_TEXTURE_ROUGHNESS) && !defined(CLEARCOAT_TEXTURE_ROUGHNESS_IDENTICAL)\nuniform sampler2D clearCoatRoughnessSampler;\n#endif\n#include(_DEFINENAME_,CLEARCOAT_BUMP,_VARYINGNAME_,ClearCoatBump,_SAMPLERNAME_,clearCoatBump)\n#include(_DEFINENAME_,CLEARCOAT_TINT_TEXTURE,_VARYINGNAME_,ClearCoatTint,_SAMPLERNAME_,clearCoatTint)\n#endif\n#ifdef SHEEN\n#include(_DEFINENAME_,SHEEN_TEXTURE,_VARYINGNAME_,Sheen,_SAMPLERNAME_,sheen)\n#include(_DEFINENAME_,SHEEN_TEXTURE_ROUGHNESS,_VARYINGNAME_,SheenRoughness)\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#include(_DEFINENAME_,ANISOTROPIC_TEXTURE,_VARYINGNAME_,Anisotropy,_SAMPLERNAME_,anisotropy)\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#include(_DEFINENAME_,SS_THICKNESSANDMASK_TEXTURE,_VARYINGNAME_,Thickness,_SAMPLERNAME_,thickness)\n#include(_DEFINENAME_,SS_REFRACTIONINTENSITY_TEXTURE,_VARYINGNAME_,RefractionIntensity,_SAMPLERNAME_,refractionIntensity)\n#include(_DEFINENAME_,SS_TRANSLUCENCYINTENSITY_TEXTURE,_VARYINGNAME_,TranslucencyIntensity,_SAMPLERNAME_,translucencyIntensity)\n#endif";Cn.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=fu;n(133);Cn.a.IncludesShadersStore.subSurfaceScatteringFunctions="bool testLightingForSSS(float diffusionProfile)\n{\nreturn diffusionProfile<1.;\n}";var _u="\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}";Cn.a.IncludesShadersStore.importanceSampling=_u;var mu="\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";Cn.a.IncludesShadersStore.pbrHelperFunctions=mu;var gu="#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\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\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";Cn.a.IncludesShadersStore.harmonicsFunctions=gu;var vu="\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}";Cn.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=vu;var bu="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}";Cn.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=bu;var yu="\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";Cn.a.IncludesShadersStore.pbrBRDFFunctions=yu;var Tu="#ifdef NUM_SAMPLES\n#if NUM_SAMPLES>0\n#if defined(WEBGL2) || defined(WEBGPU)\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#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i0.) {\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} else {\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#if defined(WEBGL2) || defined(WEBGPU)\nfor(uint i=0u; i0.) {\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}\n#endif\n#endif";Cn.a.IncludesShadersStore.hdrFilteringFunctions=Tu;var Eu="#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";Cn.a.IncludesShadersStore.pbrDirectLightingFunctions=Eu;var Su="#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";Cn.a.IncludesShadersStore.pbrIBLFunctions=Su;n(158),n(159);var Au="struct albedoOpacityOutParams\n{\nvec3 surfaceAlbedo;\nfloat alpha;\n};\n#define pbr_inline\nvoid albedoOpacityBlock(\nin vec4 vAlbedoColor,\n#ifdef ALBEDO\nin vec4 albedoTexture,\nin vec2 albedoInfos,\n#endif\n#ifdef OPACITY\nin vec4 opacityMap,\nin vec2 vOpacityInfos,\n#endif\n#ifdef DETAIL\nin vec4 detailColor,\nin 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#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\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 (alpha0&&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)},t.prototype.dispose=function(e){var t,n,i,r;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(n=this._textureRoughness)||void 0===n||n.dispose(),null===(i=this._bumpTexture)||void 0===i||i.dispose(),null===(r=this._tintTexture)||void 0===r||r.dispose())},t.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},t.prototype.addFallbacks=function(e,t,n){return e.CLEARCOAT_BUMP&&t.addFallback(n++,"CLEARCOAT_BUMP"),e.CLEARCOAT_TINT&&t.addFallback(n++,"CLEARCOAT_TINT"),e.CLEARCOAT&&t.addFallback(n++,"CLEARCOAT"),n},t.prototype.getSamplers=function(e){e.push("clearCoatSampler","clearCoatRoughnessSampler","clearCoatBumpSampler","clearCoatTintSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vClearCoatParams",size:2,type:"vec2"},{name:"vClearCoatRefractionParams",size:4,type:"vec4"},{name:"vClearCoatInfos",size:4,type:"vec4"},{name:"clearCoatMatrix",size:16,type:"mat4"},{name:"clearCoatRoughnessMatrix",size:16,type:"mat4"},{name:"vClearCoatBumpInfos",size:2,type:"vec2"},{name:"vClearCoatTangentSpaceParams",size:2,type:"vec2"},{name:"clearCoatBumpMatrix",size:16,type:"mat4"},{name:"vClearCoatTintParams",size:4,type:"vec4"},{name:"clearCoatColorAtDistance",size:1,type:"float"},{name:"vClearCoatTintInfos",size:2,type:"vec2"},{name:"clearCoatTintMatrix",size:16,type:"mat4"}]}},t._DefaultIndexOfRefraction=1.5,Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),Object(h.c)([Object(F.d)()],t.prototype,"intensity",void 0),Object(h.c)([Object(F.d)()],t.prototype,"roughness",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"remapF0OnInterfaceChange",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTintEnabled",void 0),Object(h.c)([Object(F.f)()],t.prototype,"tintColor",void 0),Object(h.c)([Object(F.d)()],t.prototype,"tintColorAtDistance",void 0),Object(h.c)([Object(F.d)()],t.prototype,"tintThickness",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"tintTexture",void 0),t}(ru.a),qu=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.ANISOTROPIC=!1,t.ANISOTROPIC_TEXTURE=!1,t.ANISOTROPIC_TEXTUREDIRECTUV=0,t.MAINUV1=!1,t}return Object(h.d)(t,e),t}(Gc.a),Zu=function(e){function t(t,n){void 0===n&&(n=!0);var i=e.call(this,t,"PBRAnisotropic",110,new qu,n)||this;return i._isEnabled=!1,i.isEnabled=!1,i.intensity=1,i.direction=new a.d(1,0),i._texture=null,i.texture=null,i._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[g.a.MATERIAL_TextureDirtyFlag],i}return Object(h.d)(t,e),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isReadyForSubMesh=function(e,t,n){return!this._isEnabled||!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&jc.a.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},t.prototype.prepareDefines=function(e,t,n){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!n.isVerticesDataPresent(bt.b.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&jc.a.AnisotropicTextureEnabled?kc.a.PrepareDefinesForMergedUV(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1)},t.prototype.bindForSubMesh=function(e,t,n,i){if(this._isEnabled){var r=this._material.isFrozen;e.useUbo&&r&&e.isSync||(this._texture&&jc.a.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),kc.a.BindTextureMatrix(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&jc.a.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)}},t.prototype.hasTexture=function(e){return this._texture===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},t.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},t.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},t.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},t.prototype.addFallbacks=function(e,t,n){return e.ANISOTROPIC&&t.addFallback(n++,"ANISOTROPIC"),n},t.prototype.getSamplers=function(e){e.push("anisotropySampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vAnisotropy",size:3,type:"vec3"},{name:"vAnisotropyInfos",size:2,type:"vec2"},{name:"anisotropyMatrix",size:16,type:"mat4"}]}},Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),Object(h.c)([Object(F.d)()],t.prototype,"intensity",void 0),Object(h.c)([Object(F.o)()],t.prototype,"direction",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),t}(ru.a),Ju=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.SHEEN=!1,t.SHEEN_TEXTURE=!1,t.SHEEN_GAMMATEXTURE=!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}return Object(h.d)(t,e),t}(Gc.a),$u=function(e){function t(t,n){void 0===n&&(n=!0);var i=e.call(this,t,"Sheen",120,new Ju,n)||this;return i._isEnabled=!1,i.isEnabled=!1,i._linkSheenWithAlbedo=!1,i.linkSheenWithAlbedo=!1,i.intensity=1,i.color=s.a.White(),i._texture=null,i.texture=null,i._useRoughnessFromMainTexture=!0,i.useRoughnessFromMainTexture=!0,i._roughness=null,i.roughness=null,i._textureRoughness=null,i.textureRoughness=null,i._albedoScaling=!1,i.albedoScaling=!1,i._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[g.a.MATERIAL_TextureDirtyFlag],i}return Object(h.d)(t,e),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype.isReadyForSubMesh=function(e,t,n){if(!this._isEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&jc.a.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(this._textureRoughness&&jc.a.SheenTextureEnabled&&!this._textureRoughness.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefines=function(e,t,n){var i;this._isEnabled?(e.SHEEN=!0,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&&jc.a.SheenTextureEnabled?(kc.a.PrepareDefinesForMergedUV(this._texture,e,"SHEEN_TEXTURE"),e.SHEEN_GAMMATEXTURE=this._texture.gammaSpace):e.SHEEN_TEXTURE=!1,this._textureRoughness&&jc.a.SheenTextureEnabled?kc.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)},t.prototype.bindForSubMesh=function(e,t,n,i){var r,o,a,s,c,u,l,h;if(this._isEnabled){var d=i.materialDefines,p=this._material.isFrozen,f=d.SHEEN_TEXTURE_ROUGHNESS_IDENTICAL;e.useUbo&&p&&e.isSync||(f&&jc.a.SheenTextureEnabled?(e.updateFloat4("vSheenInfos",this._texture.coordinatesIndex,this._texture.level,-1,-1),kc.a.BindTextureMatrix(this._texture,e,"sheen")):(this._texture||this._textureRoughness)&&jc.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!==(u=null===(c=this._textureRoughness)||void 0===c?void 0:c.coordinatesIndex)&&void 0!==u?u:0,null!==(h=null===(l=this._textureRoughness)||void 0===l?void 0:l.level)&&void 0!==h?h:0),this._texture&&kc.a.BindTextureMatrix(this._texture,e,"sheen"),!this._textureRoughness||f||d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE||kc.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&&jc.a.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture),this._textureRoughness&&!f&&!d.SHEEN_USE_ROUGHNESS_FROM_MAINTEXTURE&&jc.a.SheenTextureEnabled&&e.setTexture("sheenRoughnessSampler",this._textureRoughness))}},t.prototype.hasTexture=function(e){return this._texture===e||this._textureRoughness===e},t.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._textureRoughness&&e.push(this._textureRoughness)},t.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)},t.prototype.dispose=function(e){var t,n;e&&(null===(t=this._texture)||void 0===t||t.dispose(),null===(n=this._textureRoughness)||void 0===n||n.dispose())},t.prototype.getClassName=function(){return"PBRSheenConfiguration"},t.prototype.addFallbacks=function(e,t,n){return e.SHEEN&&t.addFallback(n++,"SHEEN"),n},t.prototype.getSamplers=function(e){e.push("sheenSampler","sheenRoughnessSampler")},t.prototype.getUniforms=function(){return{ubo:[{name:"vSheenColor",size:4,type:"vec4"},{name:"vSheenRoughness",size:1,type:"float"},{name:"vSheenInfos",size:4,type:"vec4"},{name:"sheenMatrix",size:16,type:"mat4"},{name:"sheenRoughnessMatrix",size:16,type:"mat4"}]}},Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isEnabled",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkSheenWithAlbedo",void 0),Object(h.c)([Object(F.d)()],t.prototype,"intensity",void 0),Object(h.c)([Object(F.f)()],t.prototype,"color",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"texture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMainTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"textureRoughness",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoScaling",void 0),t}(ru.a),el=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.SUBSURFACE=!1,t.SS_REFRACTION=!1,t.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE=!1,t.SS_TRANSLUCENCY=!1,t.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE=!1,t.SS_SCATTERING=!1,t.SS_THICKNESSANDMASK_TEXTURE=!1,t.SS_THICKNESSANDMASK_TEXTUREDIRECTUV=0,t.SS_HAS_THICKNESS=!1,t.SS_REFRACTIONINTENSITY_TEXTURE=!1,t.SS_REFRACTIONINTENSITY_TEXTUREDIRECTUV=0,t.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,t.SS_TRANSLUCENCYINTENSITY_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_ALBEDOFORTRANSLUCENCYTINT=!1,t.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,t.SS_USE_THICKNESS_AS_DEPTH=!1,t.SS_MASK_FROM_THICKNESS_TEXTURE=!1,t.SS_USE_GLTF_TEXTURES=!1,t}return Object(h.d)(t,e),t}(Gc.a),tl=function(e){function t(t,n){void 0===n&&(n=!0);var i=e.call(this,t,"PBRSubSurface",130,new el,n)||this;return i._isRefractionEnabled=!1,i.isRefractionEnabled=!1,i._isTranslucencyEnabled=!1,i.isTranslucencyEnabled=!1,i._isScatteringEnabled=!1,i.isScatteringEnabled=!1,i._scatteringDiffusionProfileIndex=0,i.refractionIntensity=1,i.translucencyIntensity=1,i.useAlbedoToTintRefraction=!1,i.useAlbedoToTintTranslucency=!1,i._thicknessTexture=null,i.thicknessTexture=null,i._refractionTexture=null,i.refractionTexture=null,i._indexOfRefraction=1.5,i.indexOfRefraction=1.5,i._volumeIndexOfRefraction=-1,i._invertRefractionY=!1,i.invertRefractionY=!1,i._linkRefractionWithTransparency=!1,i.linkRefractionWithTransparency=!1,i.minimumThickness=0,i.maximumThickness=1,i.useThicknessAsDepth=!1,i.tintColor=s.a.White(),i.tintColorAtDistance=1,i.diffusionDistance=s.a.White(),i._useMaskFromThicknessTexture=!1,i.useMaskFromThicknessTexture=!1,i._refractionIntensityTexture=null,i.refractionIntensityTexture=null,i._translucencyIntensityTexture=null,i.translucencyIntensityTexture=null,i._useGltfStyleTextures=!1,i.useGltfStyleTextures=!1,i._scene=t.getScene(),i.registerForExtraEvents=!0,i._internalMarkAllSubMeshesAsTexturesDirty=t._dirtyCallbacks[g.a.MATERIAL_TextureDirtyFlag],i._internalMarkScenePrePassDirty=t._dirtyCallbacks[g.a.MATERIAL_PrePassDirtyFlag],i}return Object(h.d)(t,e),Object.defineProperty(t.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(t.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}),t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._enable(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled),this._internalMarkAllSubMeshesAsTexturesDirty()},t.prototype._markScenePrePassDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty(),this._internalMarkScenePrePassDirty()},t.prototype.isReadyForSubMesh=function(e,t,n){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return!0;if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&jc.a.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var i=this._getRefractionTexture(t);if(i&&jc.a.RefractionTextureEnabled&&!i.isReadyOrNotBlocking())return!1}return!0},t.prototype.prepareDefines=function(e,t,n){if(!this._isRefractionEnabled&&!this._isTranslucencyEnabled&&!this._isScatteringEnabled)return e.SUBSURFACE=!1,e.SS_TRANSLUCENCY=!1,e.SS_SCATTERING=!1,void(e.SS_REFRACTION=!1);if(e._areTexturesDirty){e.SUBSURFACE=!0,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE=!1,e.SS_SCATTERING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_REFRACTIONINTENSITY_TEXTURE=!1,e.SS_TRANSLUCENCYINTENSITY_TEXTURE=!1,e.SS_HAS_THICKNESS=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_USE_GLTF_TEXTURES=!1,e.SS_REFRACTION=!1,e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE=!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,e.SS_ALBEDOFORTRANSLUCENCYTINT=!1,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=!1,e.SS_USE_THICKNESS_AS_DEPTH=!1;var i=!!this._thicknessTexture&&!!this._refractionIntensityTexture&&this._refractionIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture)&&this._refractionIntensityTexture._texture===this._thicknessTexture._texture,r=!!this._thicknessTexture&&!!this._translucencyIntensityTexture&&this._translucencyIntensityTexture.checkTransformsAreIdentical(this._thicknessTexture)&&this._translucencyIntensityTexture._texture===this._thicknessTexture._texture,o=(i||!this._refractionIntensityTexture)&&(r||!this._translucencyIntensityTexture);if(e._areTexturesDirty&&t.texturesEnabled&&(this._thicknessTexture&&jc.a.ThicknessTextureEnabled&&kc.a.PrepareDefinesForMergedUV(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),this._refractionIntensityTexture&&jc.a.RefractionIntensityTextureEnabled&&!o&&kc.a.PrepareDefinesForMergedUV(this._refractionIntensityTexture,e,"SS_REFRACTIONINTENSITY_TEXTURE"),this._translucencyIntensityTexture&&jc.a.TranslucencyIntensityTextureEnabled&&!o&&kc.a.PrepareDefinesForMergedUV(this._translucencyIntensityTexture,e,"SS_TRANSLUCENCYINTENSITY_TEXTURE")),e.SS_HAS_THICKNESS=this.maximumThickness-this.minimumThickness!=0,e.SS_MASK_FROM_THICKNESS_TEXTURE=(this._useMaskFromThicknessTexture||!!this._refractionIntensityTexture||!!this._translucencyIntensityTexture)&&o,e.SS_USE_GLTF_TEXTURES=this._useGltfStyleTextures,e.SS_REFRACTION_USE_INTENSITY_FROM_TEXTURE=(this._useMaskFromThicknessTexture||!!this._refractionIntensityTexture)&&o,e.SS_TRANSLUCENCY_USE_INTENSITY_FROM_TEXTURE=(this._useMaskFromThicknessTexture||!!this._translucencyIntensityTexture)&&o,this._isRefractionEnabled&&t.texturesEnabled){var a=this._getRefractionTexture(t);a&&jc.a.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=a.isCube,e.SS_GAMMAREFRACTION=a.gammaSpace,e.SS_RGBDREFRACTION=a.isRGBD,e.SS_LINEARSPECULARREFRACTION=a.linearSpecularLOD,e.SS_REFRACTIONMAP_OPPOSITEZ=a.invertZ,e.SS_LODINREFRACTIONALPHA=a.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency,e.SS_ALBEDOFORREFRACTIONTINT=this.useAlbedoToTintRefraction,e.SS_USE_LOCAL_REFRACTIONMAP_CUBIC=a.isCube&&a.boundingBoxSize,e.SS_USE_THICKNESS_AS_DEPTH=this.useThicknessAsDepth)}this._isTranslucencyEnabled&&(e.SS_ALBEDOFORTRANSLUCENCYTINT=this.useAlbedoToTintTranslucency)}},t.prototype.hardBindForSubMesh=function(e,t,n,i){if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled){i.getRenderingMesh().getWorldMatrix().decompose(a.c.Vector3[0]);var r=Math.max(Math.abs(a.c.Vector3[0].x),Math.abs(a.c.Vector3[0].y),Math.abs(a.c.Vector3[0].z));e.updateFloat2("vThicknessParam",this.minimumThickness*r,(this.maximumThickness-this.minimumThickness)*r)}},t.prototype.bindForSubMesh=function(e,t,n,i){if(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled){var r=i.materialDefines,o=this._material.isFrozen,a=this._material.realTimeFiltering,s=r.LODBASEDMICROSFURACE,c=this._getRefractionTexture(t);if(!e.useUbo||!o||!e.isSync){if(this._thicknessTexture&&jc.a.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),kc.a.BindTextureMatrix(this._thicknessTexture,e,"thickness")),this._refractionIntensityTexture&&jc.a.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&(e.updateFloat2("vRefractionIntensityInfos",this._refractionIntensityTexture.coordinatesIndex,this._refractionIntensityTexture.level),kc.a.BindTextureMatrix(this._refractionIntensityTexture,e,"refractionIntensity")),this._translucencyIntensityTexture&&jc.a.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&(e.updateFloat2("vTranslucencyIntensityInfos",this._translucencyIntensityTexture.coordinatesIndex,this._translucencyIntensityTexture.level),kc.a.BindTextureMatrix(this._translucencyIntensityTexture,e,"translucencyIntensity")),c&&jc.a.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",c.getReflectionTextureMatrix());var u=1;c.isCube||c.depth&&(u=c.depth);var l=c.getSize().width,h=this.volumeIndexOfRefraction;if(e.updateFloat4("vRefractionInfos",c.level,1/h,u,this._invertRefractionY?-1:1),e.updateFloat4("vRefractionMicrosurfaceInfos",l,c.lodGenerationScale,c.lodGenerationOffset,1/this.indexOfRefraction),a&&e.updateFloat2("vRefractionFilteringInfo",l,L.a.Log2(l)),c.boundingBoxSize){var d=c;e.updateVector3("vRefractionPosition",d.boundingBoxPosition),e.updateVector3("vRefractionSize",d.boundingBoxSize)}}this._isScatteringEnabled&&e.updateFloat("scatteringDiffusionProfile",this._scatteringDiffusionProfileIndex),e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintColorAtDistance)),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,0)}t.texturesEnabled&&(this._thicknessTexture&&jc.a.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),this._refractionIntensityTexture&&jc.a.RefractionIntensityTextureEnabled&&r.SS_REFRACTIONINTENSITY_TEXTURE&&e.setTexture("refractionIntensitySampler",this._refractionIntensityTexture),this._translucencyIntensityTexture&&jc.a.TranslucencyIntensityTextureEnabled&&r.SS_TRANSLUCENCYINTENSITY_TEXTURE&&e.setTexture("translucencyIntensitySampler",this._translucencyIntensityTexture),c&&jc.a.RefractionTextureEnabled&&(s?e.setTexture("refractionSampler",c):(e.setTexture("refractionSampler",c._lodTextureMid||c),e.setTexture("refractionSamplerLow",c._lodTextureLow||c),e.setTexture("refractionSamplerHigh",c._lodTextureHigh||c))))}},t.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(t.prototype,"disableAlphaBlending",{get:function(){return this._isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!1,configurable:!0}),t.prototype.fillRenderTargetTextures=function(e){jc.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},t.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e},t.prototype.hasRenderTargetTextures=function(){return!!(jc.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},t.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture)},t.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)},t.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose())},t.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},t.prototype.addFallbacks=function(e,t,n){return e.SS_SCATTERING&&t.addFallback(n++,"SS_SCATTERING"),e.SS_TRANSLUCENCY&&t.addFallback(n++,"SS_TRANSLUCENCY"),n},t.prototype.getSamplers=function(e){e.push("thicknessSampler","refractionIntensitySampler","translucencyIntensitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh")},t.prototype.getUniforms=function(){return{ubo:[{name:"vRefractionMicrosurfaceInfos",size:4,type:"vec4"},{name:"vRefractionFilteringInfo",size:2,type:"vec2"},{name:"vTranslucencyIntensityInfos",size:2,type:"vec2"},{name:"vRefractionInfos",size:4,type:"vec4"},{name:"refractionMatrix",size:16,type:"mat4"},{name:"vThicknessInfos",size:2,type:"vec2"},{name:"vRefractionIntensityInfos",size:2,type:"vec2"},{name:"thicknessMatrix",size:16,type:"mat4"},{name:"refractionIntensityMatrix",size:16,type:"mat4"},{name:"translucencyIntensityMatrix",size:16,type:"mat4"},{name:"vThicknessParam",size:2,type:"vec2"},{name:"vDiffusionDistance",size:3,type:"vec3"},{name:"vTintColor",size:4,type:"vec4"},{name:"vSubSurfaceIntensity",size:3,type:"vec3"},{name:"vRefractionPosition",size:3,type:"vec3"},{name:"vRefractionSize",size:3,type:"vec3"},{name:"scatteringDiffusionProfile",size:1,type:"float"}]}},Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isRefractionEnabled",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"isTranslucencyEnabled",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markScenePrePassDirty")],t.prototype,"isScatteringEnabled",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_scatteringDiffusionProfileIndex",void 0),Object(h.c)([Object(F.d)()],t.prototype,"refractionIntensity",void 0),Object(h.c)([Object(F.d)()],t.prototype,"translucencyIntensity",void 0),Object(h.c)([Object(F.d)()],t.prototype,"useAlbedoToTintRefraction",void 0),Object(h.c)([Object(F.d)()],t.prototype,"useAlbedoToTintTranslucency",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"thicknessTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"indexOfRefraction",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_volumeIndexOfRefraction",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"volumeIndexOfRefraction",null),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertRefractionY",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkRefractionWithTransparency",void 0),Object(h.c)([Object(F.d)()],t.prototype,"minimumThickness",void 0),Object(h.c)([Object(F.d)()],t.prototype,"maximumThickness",void 0),Object(h.c)([Object(F.d)()],t.prototype,"useThicknessAsDepth",void 0),Object(h.c)([Object(F.f)()],t.prototype,"tintColor",void 0),Object(h.c)([Object(F.d)()],t.prototype,"tintColorAtDistance",void 0),Object(h.c)([Object(F.f)()],t.prototype,"diffusionDistance",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMaskFromThicknessTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionIntensityTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"translucencyIntensityTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGltfStyleTextures",void 0),t}(ru.a),nl=n(125),il={effect:null,subMesh:null},rl=function(e){function t(t){var n=e.call(this,t)||this;return n.PBR=!0,n.NUM_SAMPLES="0",n.REALTIME_FILTERING=!1,n.MAINUV1=!1,n.MAINUV2=!1,n.MAINUV3=!1,n.MAINUV4=!1,n.MAINUV5=!1,n.MAINUV6=!1,n.UV1=!1,n.UV2=!1,n.UV3=!1,n.UV4=!1,n.UV5=!1,n.UV6=!1,n.ALBEDO=!1,n.GAMMAALBEDO=!1,n.ALBEDODIRECTUV=0,n.VERTEXCOLOR=!1,n.BAKED_VERTEX_ANIMATION_TEXTURE=!1,n.AMBIENT=!1,n.AMBIENTDIRECTUV=0,n.AMBIENTINGRAYSCALE=!1,n.OPACITY=!1,n.VERTEXALPHA=!1,n.OPACITYDIRECTUV=0,n.OPACITYRGB=!1,n.ALPHATEST=!1,n.DEPTHPREPASS=!1,n.ALPHABLEND=!1,n.ALPHAFROMALBEDO=!1,n.ALPHATESTVALUE="0.5",n.SPECULAROVERALPHA=!1,n.RADIANCEOVERALPHA=!1,n.ALPHAFRESNEL=!1,n.LINEARALPHAFRESNEL=!1,n.PREMULTIPLYALPHA=!1,n.EMISSIVE=!1,n.EMISSIVEDIRECTUV=0,n.GAMMAEMISSIVE=!1,n.REFLECTIVITY=!1,n.REFLECTIVITY_GAMMA=!1,n.REFLECTIVITYDIRECTUV=0,n.SPECULARTERM=!1,n.MICROSURFACEFROMREFLECTIVITYMAP=!1,n.MICROSURFACEAUTOMATIC=!1,n.LODBASEDMICROSFURACE=!1,n.MICROSURFACEMAP=!1,n.MICROSURFACEMAPDIRECTUV=0,n.METALLICWORKFLOW=!1,n.ROUGHNESSSTOREINMETALMAPALPHA=!1,n.ROUGHNESSSTOREINMETALMAPGREEN=!1,n.METALLNESSSTOREINMETALMAPBLUE=!1,n.AOSTOREINMETALMAPRED=!1,n.METALLIC_REFLECTANCE=!1,n.METALLIC_REFLECTANCE_GAMMA=!1,n.METALLIC_REFLECTANCEDIRECTUV=0,n.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=!1,n.REFLECTANCE=!1,n.REFLECTANCE_GAMMA=!1,n.REFLECTANCEDIRECTUV=0,n.ENVIRONMENTBRDF=!1,n.ENVIRONMENTBRDF_RGBD=!1,n.NORMAL=!1,n.TANGENT=!1,n.BUMP=!1,n.BUMPDIRECTUV=0,n.OBJECTSPACE_NORMALMAP=!1,n.PARALLAX=!1,n.PARALLAXOCCLUSION=!1,n.NORMALXYSCALE=!0,n.LIGHTMAP=!1,n.LIGHTMAPDIRECTUV=0,n.USELIGHTMAPASSHADOWMAP=!1,n.GAMMALIGHTMAP=!1,n.RGBDLIGHTMAP=!1,n.REFLECTION=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.INVERTCUBICMAP=!1,n.USESPHERICALFROMREFLECTIONMAP=!1,n.USEIRRADIANCEMAP=!1,n.USESPHERICALINVERTEX=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.LODINREFLECTIONALPHA=!1,n.GAMMAREFLECTION=!1,n.RGBDREFLECTION=!1,n.LINEARSPECULARREFLECTION=!1,n.RADIANCEOCCLUSION=!1,n.HORIZONOCCLUSION=!1,n.INSTANCES=!1,n.THIN_INSTANCES=!1,n.INSTANCESCOLOR=!1,n.PREPASS=!1,n.PREPASS_IRRADIANCE=!1,n.PREPASS_IRRADIANCE_INDEX=-1,n.PREPASS_ALBEDO_SQRT=!1,n.PREPASS_ALBEDO_SQRT_INDEX=-1,n.PREPASS_DEPTH=!1,n.PREPASS_DEPTH_INDEX=-1,n.PREPASS_NORMAL=!1,n.PREPASS_NORMAL_INDEX=-1,n.PREPASS_POSITION=!1,n.PREPASS_POSITION_INDEX=-1,n.PREPASS_VELOCITY=!1,n.PREPASS_VELOCITY_INDEX=-1,n.PREPASS_REFLECTIVITY=!1,n.PREPASS_REFLECTIVITY_INDEX=-1,n.SCENE_MRT_COUNT=0,n.NUM_BONE_INFLUENCERS=0,n.BonesPerMesh=0,n.BONETEXTURE=!1,n.BONES_VELOCITY_ENABLED=!1,n.NONUNIFORMSCALING=!1,n.MORPHTARGETS=!1,n.MORPHTARGETS_NORMAL=!1,n.MORPHTARGETS_TANGENT=!1,n.MORPHTARGETS_UV=!1,n.NUM_MORPH_INFLUENCERS=0,n.MORPHTARGETS_TEXTURE=!1,n.IMAGEPROCESSING=!1,n.VIGNETTE=!1,n.VIGNETTEBLENDMODEMULTIPLY=!1,n.VIGNETTEBLENDMODEOPAQUE=!1,n.TONEMAPPING=!1,n.TONEMAPPING_ACES=!1,n.CONTRAST=!1,n.COLORCURVES=!1,n.COLORGRADING=!1,n.COLORGRADING3D=!1,n.SAMPLER3DGREENDEPTH=!1,n.SAMPLER3DBGRMAP=!1,n.IMAGEPROCESSINGPOSTPROCESS=!1,n.SKIPFINALCOLORCLAMP=!1,n.EXPOSURE=!1,n.MULTIVIEW=!1,n.ORDER_INDEPENDENT_TRANSPARENCY=!1,n.ORDER_INDEPENDENT_TRANSPARENCY_16BITS=!1,n.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!1,n.TWOSIDEDLIGHTING=!1,n.SHADOWFLOAT=!1,n.CLIPPLANE=!1,n.CLIPPLANE2=!1,n.CLIPPLANE3=!1,n.CLIPPLANE4=!1,n.CLIPPLANE5=!1,n.CLIPPLANE6=!1,n.POINTSIZE=!1,n.FOG=!1,n.LOGARITHMICDEPTH=!1,n.FORCENORMALFORWARD=!1,n.SPECULARAA=!1,n.UNLIT=!1,n.DEBUGMODE=0,n.rebuild(),n}return Object(h.d)(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0,this.NORMALXYSCALE=!0},t}(Gc.a),ol=function(e){function t(n,i){var r=e.call(this,n,i)||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._useOnlyMetallicFromMetallicReflectanceTexture=!1,r._metallicReflectanceTexture=null,r._reflectanceTexture=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 Rn.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._cacheHasRenderTargetTextures=!1,r.brdf=new au(r),r.clearCoat=new Qu(r),r.anisotropy=new Zu(r),r.sheen=new $u(r),r.subSurface=new tl(r),r.detailMap=new nl.a(r),r._attachImageProcessingConfiguration(null),r.getRenderTargetTextures=function(){return r._renderTargets.reset(),jc.a.ReflectionTextureEnabled&&r._reflectionTexture&&r._reflectionTexture.isRenderTarget&&r._renderTargets.push(r._reflectionTexture),r._eventInfo.renderTargets=r._renderTargets,r._callbackPluginEventFillRenderTargetTextures(r._eventInfo),r._renderTargets},r._environmentBRDFTexture=nu(r.getScene()),r.prePassConfiguration=new su.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!!(jc.a.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||this._cacheHasRenderTargetTextures},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isPrePassCapable",{get:function(){return!this.disableDepthWrite},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(){var e;return this._transparencyMode===t.PBRMATERIAL_OPAQUE||this._transparencyMode===t.PBRMATERIAL_ALPHATEST||(null===(e=this.subSurface)||void 0===e?void 0:e.disableAlphaBlending)},enumerable:!1,configurable:!0}),t.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},t.prototype.needAlphaTesting=function(){var e;return!!this._forceAlphaTest||!(null===(e=this.subSurface)||void 0===e?void 0:e.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,n){if(this._uniformBufferLayoutBuilt||this.buildUniformLayout(),t.effect&&this.isFrozen&&t.effect._wasPreviouslyReady)return!0;t.materialDefines||(this._callbackPluginEventGeneric(uu.a.GetDefineNames,this._eventInfo),t.materialDefines=new rl(this._eventInfo.defineNames));var i=t.materialDefines;if(this._isReadyForSubMesh(t))return!0;var r=this.getScene(),o=r.getEngine();if(i._areTexturesDirty&&(this._eventInfo.hasRenderTargetTextures=!1,this._callbackPluginEventHasRenderTargetTextures(this._eventInfo),this._cacheHasRenderTargetTextures=this._eventInfo.hasRenderTargetTextures,r.texturesEnabled)){if(this._albedoTexture&&jc.a.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&jc.a.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&jc.a.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var a=this._getReflectionTexture();if(a&&jc.a.ReflectionTextureEnabled){if(!a.isReadyOrNotBlocking())return!1;if(a.irradianceTexture&&!a.irradianceTexture.isReadyOrNotBlocking())return!1}if(this._lightmapTexture&&jc.a.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&jc.a.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(jc.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._reflectanceTexture&&!this._reflectanceTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&jc.a.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&jc.a.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(this._eventInfo.isReadyForSubMesh=!0,this._eventInfo.defines=i,this._callbackPluginEventIsReadyForSubMesh(this._eventInfo),!this._eventInfo.isReadyForSubMesh)return!1;if(i._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;o.getCaps().standardDerivatives||e.isVerticesDataPresent(bt.b.NormalKind)||(e.createNormals(!0),m.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var s=t.effect,c=i._areLightsDisposed,u=this._prepareEffect(e,i,this.onCompiled,this.onError,n,null,t.getRenderingMesh().hasThinInstances);if(u)if(this._onEffectCreatedObservable&&(il.effect=u,il.subMesh=t,this._onEffectCreatedObservable.notifyObservers(il)),this.allowShaderHotSwapping&&s&&!u.isReady()){if(u=s,i.markAsUnprocessed(),c)return i._areLightsDisposed=!0,!1}else r.resetCachedMaterial(),t.setEffect(u,i,this._materialContext);return!(!t.effect||!t.effect.isReady())&&(i._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,n,i,r,o,a){if(void 0===n&&(n=null),void 0===i&&(i=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 Qc.a,u=0;t.USESPHERICALINVERTEX&&c.addFallback(u++,"USESPHERICALINVERTEX"),t.FOG&&c.addFallback(u,"FOG"),t.SPECULARAA&&c.addFallback(u,"SPECULARAA"),t.POINTSIZE&&c.addFallback(u,"POINTSIZE"),t.LOGARITHMICDEPTH&&c.addFallback(u,"LOGARITHMICDEPTH"),t.PARALLAX&&c.addFallback(u,"PARALLAX"),t.PARALLAXOCCLUSION&&c.addFallback(u++,"PARALLAXOCCLUSION"),t.ENVIRONMENTBRDF&&c.addFallback(u++,"ENVIRONMENTBRDF"),t.TANGENT&&c.addFallback(u++,"TANGENT"),t.BUMP&&c.addFallback(u++,"BUMP"),u=kc.a.HandleFallbacksForShadows(t,c,this._maxSimultaneousLights,u++),t.SPECULARTERM&&c.addFallback(u++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&c.addFallback(u++,"USESPHERICALFROMREFLECTIONMAP"),t.USEIRRADIANCEMAP&&c.addFallback(u++,"USEIRRADIANCEMAP"),t.LIGHTMAP&&c.addFallback(u++,"LIGHTMAP"),t.NORMAL&&c.addFallback(u++,"NORMAL"),t.AMBIENT&&c.addFallback(u++,"AMBIENT"),t.EMISSIVE&&c.addFallback(u++,"EMISSIVE"),t.VERTEXCOLOR&&c.addFallback(u++,"VERTEXCOLOR"),t.MORPHTARGETS&&c.addFallback(u++,"MORPHTARGETS"),t.MULTIVIEW&&c.addFallback(0,"MULTIVIEW");var l=[bt.b.PositionKind];t.NORMAL&&l.push(bt.b.NormalKind),t.TANGENT&&l.push(bt.b.TangentKind);for(var h=1;h<=g.a.MAX_SUPPORTED_UV_SETS;++h)t["UV"+h]&&l.push("uv".concat(1===h?"":h));t.VERTEXCOLOR&&l.push(bt.b.ColorKind),kc.a.PrepareAttributesForBones(l,e,t,c),kc.a.PrepareAttributesForInstances(l,t),kc.a.PrepareAttributesForMorphTargets(l,e,t),kc.a.PrepareAttributesForBakedVertexAnimation(l,e,t);var d="pbr",p=["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","vReflectanceInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","metallicReflectanceMatrix","reflectanceMatrix","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","morphTargetTextureInfo","morphTargetTextureIndices"],f=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","irradianceSampler","microSurfaceSampler","environmentBrdfSampler","boneSampler","metallicReflectanceSampler","reflectanceSampler","morphTargets","oitDepthSampler","oitFrontColorSampler"],_=["Material","Scene","Mesh"];this._eventInfo.fallbacks=c,this._eventInfo.fallbackRank=u,this._eventInfo.defines=t,this._eventInfo.uniforms=p,this._eventInfo.samplers=f,this._eventInfo.uniformBuffersNames=_,this._eventInfo.customCode=void 0,this._callbackPluginEventGeneric(uu.a.PrepareEffect,this._eventInfo),su.a.AddUniforms(p),su.a.AddSamplers(f),Ei.a&&(Ei.a.PrepareUniforms(p,t),Ei.a.PrepareSamplers(f,t)),kc.a.PrepareUniformsAndSamplersList({uniformsNames:p,uniformBuffersNames:_,samplers:f,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});var m={};this.customShaderNameResolve&&(d=this.customShaderNameResolve(d,p,_,f,t,l,m));var v=t.toString();return s.createEffect(d,{attributes:l,uniformsNames:p,uniformBuffersNames:_,samplers:f,defines:v,fallbacks:c,onCompiled:n,onError:i,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS},processFinalCode:m.processFinalCode,processCodeAfterIncludes:this._eventInfo.customCode,multiTarget:t.PREPASS},s)},t.prototype._prepareDefines=function(e,n,i,r,o){var a;void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=!1);var s=this.getScene(),c=s.getEngine();kc.a.PrepareDefinesForLights(s,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._needNormals=!0,kc.a.PrepareDefinesForMultiview(s,n);var u=this.needAlphaBlendingForMesh(e)&&this.getScene().useOrderIndependentTransparency;if(kc.a.PrepareDefinesForPrePass(s,n,this.canRenderToMRT&&!u),kc.a.PrepareDefinesForOIT(s,n,u),n.METALLICWORKFLOW=this.isMetallicWorkflow(),n._areTexturesDirty){if(n._needUVs=!1,s.texturesEnabled){s.getEngine().getCaps().textureLOD&&(n.LODBASEDMICROSFURACE=!0),this._albedoTexture&&jc.a.DiffuseTextureEnabled?(kc.a.PrepareDefinesForMergedUV(this._albedoTexture,n,"ALBEDO"),n.GAMMAALBEDO=this._albedoTexture.gammaSpace):n.ALBEDO=!1,this._ambientTexture&&jc.a.AmbientTextureEnabled?(kc.a.PrepareDefinesForMergedUV(this._ambientTexture,n,"AMBIENT"),n.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):n.AMBIENT=!1,this._opacityTexture&&jc.a.OpacityTextureEnabled?(kc.a.PrepareDefinesForMergedUV(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):n.OPACITY=!1;var l=this._getReflectionTexture();if(l&&jc.a.ReflectionTextureEnabled){switch(n.REFLECTION=!0,n.GAMMAREFLECTION=l.gammaSpace,n.RGBDREFLECTION=l.isRGBD,n.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!l.invertZ:l.invertZ,n.LODINREFLECTIONALPHA=l.lodLevelInAlpha,n.LINEARSPECULARREFLECTION=l.linearSpecularLOD,this.realTimeFiltering&&this.realTimeFilteringQuality>0?(n.NUM_SAMPLES=""+this.realTimeFilteringQuality,c._features.needTypeSuffixInShaderConstants&&(n.NUM_SAMPLES=n.NUM_SAMPLES+"u"),n.REALTIME_FILTERING=!0):n.REALTIME_FILTERING=!1,l.coordinatesMode===Be.a.INVCUBIC_MODE&&(n.INVERTCUBICMAP=!0),n.REFLECTIONMAP_3D=l.isCube,n.REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,l.coordinatesMode){case Be.a.EXPLICIT_MODE:n.REFLECTIONMAP_EXPLICIT=!0;break;case Be.a.PLANAR_MODE:n.REFLECTIONMAP_PLANAR=!0;break;case Be.a.PROJECTION_MODE:n.REFLECTIONMAP_PROJECTION=!0;break;case Be.a.SKYBOX_MODE:n.REFLECTIONMAP_SKYBOX=!0;break;case Be.a.SPHERICAL_MODE:n.REFLECTIONMAP_SPHERICAL=!0;break;case Be.a.EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Be.a.FIXED_EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Be.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Be.a.CUBIC_MODE:case Be.a.INVCUBIC_MODE:default:n.REFLECTIONMAP_CUBIC=!0,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!!l.boundingBoxSize}l.coordinatesMode!==Be.a.SKYBOX_MODE&&(l.irradianceTexture?(n.USEIRRADIANCEMAP=!0,n.USESPHERICALFROMREFLECTIONMAP=!1):l.isCube&&(n.USESPHERICALFROMREFLECTIONMAP=!0,n.USEIRRADIANCEMAP=!1,this._forceIrradianceInFragment||this.realTimeFiltering||s.getEngine().getCaps().maxVaryingVectors<=8?n.USESPHERICALINVERTEX=!1:n.USESPHERICALINVERTEX=!0))}else n.REFLECTION=!1,n.REFLECTIONMAP_3D=!1,n.REFLECTIONMAP_SPHERICAL=!1,n.REFLECTIONMAP_PLANAR=!1,n.REFLECTIONMAP_CUBIC=!1,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,n.REFLECTIONMAP_PROJECTION=!1,n.REFLECTIONMAP_SKYBOX=!1,n.REFLECTIONMAP_EXPLICIT=!1,n.REFLECTIONMAP_EQUIRECTANGULAR=!1,n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,n.INVERTCUBICMAP=!1,n.USESPHERICALFROMREFLECTIONMAP=!1,n.USEIRRADIANCEMAP=!1,n.USESPHERICALINVERTEX=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.LODINREFLECTIONALPHA=!1,n.GAMMAREFLECTION=!1,n.RGBDREFLECTION=!1,n.LINEARSPECULARREFLECTION=!1;if(this._lightmapTexture&&jc.a.LightmapTextureEnabled?(kc.a.PrepareDefinesForMergedUV(this._lightmapTexture,n,"LIGHTMAP"),n.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,n.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace,n.RGBDLIGHTMAP=this._lightmapTexture.isRGBD):n.LIGHTMAP=!1,this._emissiveTexture&&jc.a.EmissiveTextureEnabled?(kc.a.PrepareDefinesForMergedUV(this._emissiveTexture,n,"EMISSIVE"),n.GAMMAEMISSIVE=this._emissiveTexture.gammaSpace):n.EMISSIVE=!1,jc.a.SpecularTextureEnabled){if(this._metallicTexture?(kc.a.PrepareDefinesForMergedUV(this._metallicTexture,n,"REFLECTIVITY"),n.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,n.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,n.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,n.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed,n.REFLECTIVITY_GAMMA=!1):this._reflectivityTexture?(kc.a.PrepareDefinesForMergedUV(this._reflectivityTexture,n,"REFLECTIVITY"),n.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,n.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap,n.REFLECTIVITY_GAMMA=this._reflectivityTexture.gammaSpace):n.REFLECTIVITY=!1,this._metallicReflectanceTexture||this._reflectanceTexture){var h=null!==this._metallicReflectanceTexture&&this._metallicReflectanceTexture._texture===(null===(a=this._reflectanceTexture)||void 0===a?void 0:a._texture)&&this._metallicReflectanceTexture.checkTransformsAreIdentical(this._reflectanceTexture);n.METALLIC_REFLECTANCE_USE_ALPHA_ONLY=this._useOnlyMetallicFromMetallicReflectanceTexture&&!h,this._metallicReflectanceTexture?(kc.a.PrepareDefinesForMergedUV(this._metallicReflectanceTexture,n,"METALLIC_REFLECTANCE"),n.METALLIC_REFLECTANCE_GAMMA=this._metallicReflectanceTexture.gammaSpace):n.METALLIC_REFLECTANCE=!1,this._reflectanceTexture&&!h&&(!this._metallicReflectanceTexture||this._metallicReflectanceTexture&&this._useOnlyMetallicFromMetallicReflectanceTexture)?(kc.a.PrepareDefinesForMergedUV(this._reflectanceTexture,n,"REFLECTANCE"),n.REFLECTANCE_GAMMA=this._reflectanceTexture.gammaSpace):n.REFLECTANCE=!1}else n.METALLIC_REFLECTANCE=!1,n.REFLECTANCE=!1;this._microSurfaceTexture?kc.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,n,"MICROSURFACEMAP"):n.MICROSURFACEMAP=!1}else n.REFLECTIVITY=!1,n.MICROSURFACEMAP=!1;s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&jc.a.BumpTextureEnabled&&!this._disableBumpMap?(kc.a.PrepareDefinesForMergedUV(this._bumpTexture,n,"BUMP"),this._useParallax&&this._albedoTexture&&jc.a.DiffuseTextureEnabled?(n.PARALLAX=!0,n.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):n.PARALLAX=!1,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):n.BUMP=!1,this._environmentBRDFTexture&&jc.a.ReflectionTextureEnabled?(n.ENVIRONMENTBRDF=!0,n.ENVIRONMENTBRDF_RGBD=this._environmentBRDFTexture.isRGBD):(n.ENVIRONMENTBRDF=!1,n.ENVIRONMENTBRDF_RGBD=!1),this._shouldUseAlphaFromAlbedoTexture()?n.ALPHAFROMALBEDO=!0:n.ALPHAFROMALBEDO=!1}n.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===t.LIGHTFALLOFF_STANDARD?(n.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===t.LIGHTFALLOFF_GLTF?(n.USEPHYSICALLIGHTFALLOFF=!1,n.USEGLTFLIGHTFALLOFF=!0):(n.USEPHYSICALLIGHTFALLOFF=!0,n.USEGLTFLIGHTFALLOFF=!1),n.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?n.TWOSIDEDLIGHTING=!0:n.TWOSIDEDLIGHTING=!1,n.SPECULARAA=s.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}(n._areTexturesDirty||n._areMiscDirty)&&(n.ALPHATESTVALUE="".concat(this._alphaCutOff).concat(this._alphaCutOff%1==0?".":""),n.PREMULTIPLYALPHA=this.alphaMode===g.a.ALPHA_PREMULTIPLIED||this.alphaMode===g.a.ALPHA_PREMULTIPLIED_PORTERDUFF,n.ALPHABLEND=this.needAlphaBlendingForMesh(e),n.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,n.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel),n._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(n),n.FORCENORMALFORWARD=this._forceNormalForward,n.RADIANCEOCCLUSION=this._useRadianceOcclusion,n.HORIZONOCCLUSION=this._useHorizonOcclusion,n._areMiscDirty&&(kc.a.PrepareDefinesForMisc(e,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,n),n.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(bt.b.NormalKind),n.DEBUGMODE=this._debugMode),this._eventInfo.defines=n,this._eventInfo.mesh=e,this._callbackPluginEventPrepareDefines(this._eventInfo),kc.a.PrepareDefinesForFrameBoundValues(s,c,n,!!i,r,o),kc.a.PrepareDefinesForAttributes(e,n,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,n){var i=this,r=Object(h.a)({clipPlane:!1,useInstances:!1},n);this._uniformBufferLayoutBuilt||this.buildUniformLayout(),this._callbackPluginEventGeneric(uu.a.GetDefineNames,this._eventInfo);var o=new rl(this._eventInfo.defineNames),a=this._prepareEffect(e,o,void 0,void 0,r.useInstances,r.clipPlane,e.hasThinInstances);this._onEffectCreatedObservable&&(il.effect=a,il.subMesh=null,this._onEffectCreatedObservable.notifyObservers(il)),a.isReady()?t&&t(this):a.onCompileObservable.add((function(){t&&t(i)}))},t.prototype.buildUniformLayout=function(){var t=this._uniformBuffer;t.addUniform("vAlbedoInfos",2),t.addUniform("vAmbientInfos",4),t.addUniform("vOpacityInfos",2),t.addUniform("vEmissiveInfos",2),t.addUniform("vLightmapInfos",2),t.addUniform("vReflectivityInfos",3),t.addUniform("vMicroSurfaceSamplerInfos",2),t.addUniform("vReflectionInfos",2),t.addUniform("vReflectionFilteringInfo",2),t.addUniform("vReflectionPosition",3),t.addUniform("vReflectionSize",3),t.addUniform("vBumpInfos",3),t.addUniform("albedoMatrix",16),t.addUniform("ambientMatrix",16),t.addUniform("opacityMatrix",16),t.addUniform("emissiveMatrix",16),t.addUniform("lightmapMatrix",16),t.addUniform("reflectivityMatrix",16),t.addUniform("microSurfaceSamplerMatrix",16),t.addUniform("bumpMatrix",16),t.addUniform("vTangentSpaceParams",2),t.addUniform("reflectionMatrix",16),t.addUniform("vReflectionColor",3),t.addUniform("vAlbedoColor",4),t.addUniform("vLightingIntensity",4),t.addUniform("vReflectionMicrosurfaceInfos",3),t.addUniform("pointSize",1),t.addUniform("vReflectivityColor",4),t.addUniform("vEmissiveColor",3),t.addUniform("vAmbientColor",3),t.addUniform("vDebugMode",2),t.addUniform("vMetallicReflectanceFactors",4),t.addUniform("vMetallicReflectanceInfos",2),t.addUniform("metallicReflectanceMatrix",16),t.addUniform("vReflectanceInfos",2),t.addUniform("reflectanceMatrix",16),t.addUniform("vSphericalL00",3),t.addUniform("vSphericalL1_1",3),t.addUniform("vSphericalL10",3),t.addUniform("vSphericalL11",3),t.addUniform("vSphericalL2_2",3),t.addUniform("vSphericalL2_1",3),t.addUniform("vSphericalL20",3),t.addUniform("vSphericalL21",3),t.addUniform("vSphericalL22",3),t.addUniform("vSphericalX",3),t.addUniform("vSphericalY",3),t.addUniform("vSphericalZ",3),t.addUniform("vSphericalXX_ZZ",3),t.addUniform("vSphericalYY_ZZ",3),t.addUniform("vSphericalZZ",3),t.addUniform("vSphericalXY",3),t.addUniform("vSphericalYZ",3),t.addUniform("vSphericalZX",3),e.prototype.buildUniformLayout.call(this)},t.prototype.bindForSubMesh=function(e,t,n){var i,r,o,a,c=this.getScene(),u=n.materialDefines;if(u){var l=n.effect;if(l){this._activeEffect=l,t.getMeshUniformBuffer().bindToEffect(l,"Mesh"),t.transferToEffect(e);var h=c.getEngine();this._uniformBuffer.bindToEffect(l,"Material"),this.prePassConfiguration.bindForSubMesh(this._activeEffect,c,t,e,this.isFrozen),this._eventInfo.subMesh=n,this._callbackPluginEventHardBindForSubMesh(this._eventInfo),u.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var d=this._mustRebind(c,l,t.visibility);kc.a.BindBonesParameters(t,this._activeEffect,this.prePassConfiguration);var p=null,f=this._uniformBuffer;if(d){if(this.bindViewProjection(l),p=this._getReflectionTexture(),!f.useUbo||!this.isFrozen||!f.isSync){if(c.texturesEnabled){if(this._albedoTexture&&jc.a.DiffuseTextureEnabled&&(f.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),kc.a.BindTextureMatrix(this._albedoTexture,f,"albedo")),this._ambientTexture&&jc.a.AmbientTextureEnabled&&(f.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),kc.a.BindTextureMatrix(this._ambientTexture,f,"ambient")),this._opacityTexture&&jc.a.OpacityTextureEnabled&&(f.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),kc.a.BindTextureMatrix(this._opacityTexture,f,"opacity")),p&&jc.a.ReflectionTextureEnabled){if(f.updateMatrix("reflectionMatrix",p.getReflectionTextureMatrix()),f.updateFloat2("vReflectionInfos",p.level,0),p.boundingBoxSize){var _=p;f.updateVector3("vReflectionPosition",_.boundingBoxPosition),f.updateVector3("vReflectionSize",_.boundingBoxSize)}if(this.realTimeFiltering){var m=p.getSize().width;f.updateFloat2("vReflectionFilteringInfo",m,L.a.Log2(m))}if(!u.USEIRRADIANCEMAP){var g=p.sphericalPolynomial;if(u.USESPHERICALFROMREFLECTIONMAP&&g)if(u.SPHERICAL_HARMONICS){var v=g.preScaledHarmonics;f.updateVector3("vSphericalL00",v.l00),f.updateVector3("vSphericalL1_1",v.l1_1),f.updateVector3("vSphericalL10",v.l10),f.updateVector3("vSphericalL11",v.l11),f.updateVector3("vSphericalL2_2",v.l2_2),f.updateVector3("vSphericalL2_1",v.l2_1),f.updateVector3("vSphericalL20",v.l20),f.updateVector3("vSphericalL21",v.l21),f.updateVector3("vSphericalL22",v.l22)}else f.updateFloat3("vSphericalX",g.x.x,g.x.y,g.x.z),f.updateFloat3("vSphericalY",g.y.x,g.y.y,g.y.z),f.updateFloat3("vSphericalZ",g.z.x,g.z.y,g.z.z),f.updateFloat3("vSphericalXX_ZZ",g.xx.x-g.zz.x,g.xx.y-g.zz.y,g.xx.z-g.zz.z),f.updateFloat3("vSphericalYY_ZZ",g.yy.x-g.zz.x,g.yy.y-g.zz.y,g.yy.z-g.zz.z),f.updateFloat3("vSphericalZZ",g.zz.x,g.zz.y,g.zz.z),f.updateFloat3("vSphericalXY",g.xy.x,g.xy.y,g.xy.z),f.updateFloat3("vSphericalYZ",g.yz.x,g.yz.y,g.yz.z),f.updateFloat3("vSphericalZX",g.zx.x,g.zx.y,g.zx.z)}f.updateFloat3("vReflectionMicrosurfaceInfos",p.getSize().width,p.lodGenerationScale,p.lodGenerationOffset)}this._emissiveTexture&&jc.a.EmissiveTextureEnabled&&(f.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),kc.a.BindTextureMatrix(this._emissiveTexture,f,"emissive")),this._lightmapTexture&&jc.a.LightmapTextureEnabled&&(f.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),kc.a.BindTextureMatrix(this._lightmapTexture,f,"lightmap")),jc.a.SpecularTextureEnabled&&(this._metallicTexture?(f.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),kc.a.BindTextureMatrix(this._metallicTexture,f,"reflectivity")):this._reflectivityTexture&&(f.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),kc.a.BindTextureMatrix(this._reflectivityTexture,f,"reflectivity")),this._metallicReflectanceTexture&&(f.updateFloat2("vMetallicReflectanceInfos",this._metallicReflectanceTexture.coordinatesIndex,this._metallicReflectanceTexture.level),kc.a.BindTextureMatrix(this._metallicReflectanceTexture,f,"metallicReflectance")),this._reflectanceTexture&&u.REFLECTANCE&&(f.updateFloat2("vReflectanceInfos",this._reflectanceTexture.coordinatesIndex,this._reflectanceTexture.level),kc.a.BindTextureMatrix(this._reflectanceTexture,f,"reflectance")),this._microSurfaceTexture&&(f.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),kc.a.BindTextureMatrix(this._microSurfaceTexture,f,"microSurfaceSampler"))),this._bumpTexture&&h.getCaps().standardDerivatives&&jc.a.BumpTextureEnabled&&!this._disableBumpMap&&(f.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),kc.a.BindTextureMatrix(this._bumpTexture,f,"bump"),c._mirroredCameraPosition?f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}if(this.pointsCloud&&f.updateFloat("pointSize",this.pointSize),u.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,f.updateColor4("vReflectivityColor",s.c.Color3[0],1);var b=null!==(r=null===(i=this.subSurface)||void 0===i?void 0:i._indexOfRefraction)&&void 0!==r?r:1.5,y=Math.pow((b-1)/(b+1),2);this._metallicReflectanceColor.scaleToRef(y*this._metallicF0Factor,s.c.Color3[0]);var T=this._metallicF0Factor;f.updateColor4("vMetallicReflectanceFactors",s.c.Color3[0],T)}else f.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface);f.updateColor3("vEmissiveColor",jc.a.EmissiveTextureEnabled?this._emissiveColor:s.a.BlackReadOnly),f.updateColor3("vReflectionColor",this._reflectionColor),!u.SS_REFRACTION&&(null===(o=this.subSurface)||void 0===o?void 0:o._linkRefractionWithTransparency)?f.updateColor4("vAlbedoColor",this._albedoColor,1):f.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity*c.environmentIntensity,this._lightingInfos.w=this._specularIntensity,f.updateVector4("vLightingIntensity",this._lightingInfos),c.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor),f.updateColor3("vAmbientColor",this._globalAmbientColor),f.updateFloat2("vDebugMode",this.debugLimit,this.debugFactor)}c.texturesEnabled&&(this._albedoTexture&&jc.a.DiffuseTextureEnabled&&f.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&jc.a.AmbientTextureEnabled&&f.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&jc.a.OpacityTextureEnabled&&f.setTexture("opacitySampler",this._opacityTexture),p&&jc.a.ReflectionTextureEnabled&&(u.LODBASEDMICROSFURACE?f.setTexture("reflectionSampler",p):(f.setTexture("reflectionSampler",p._lodTextureMid||p),f.setTexture("reflectionSamplerLow",p._lodTextureLow||p),f.setTexture("reflectionSamplerHigh",p._lodTextureHigh||p)),u.USEIRRADIANCEMAP&&f.setTexture("irradianceSampler",p.irradianceTexture)),u.ENVIRONMENTBRDF&&f.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&jc.a.EmissiveTextureEnabled&&f.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&jc.a.LightmapTextureEnabled&&f.setTexture("lightmapSampler",this._lightmapTexture),jc.a.SpecularTextureEnabled&&(this._metallicTexture?f.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&f.setTexture("reflectivitySampler",this._reflectivityTexture),this._metallicReflectanceTexture&&f.setTexture("metallicReflectanceSampler",this._metallicReflectanceTexture),this._reflectanceTexture&&u.REFLECTANCE&&f.setTexture("reflectanceSampler",this._reflectanceTexture),this._microSurfaceTexture&&f.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&h.getCaps().standardDerivatives&&jc.a.BumpTextureEnabled&&!this._disableBumpMap&&f.setTexture("bumpSampler",this._bumpTexture)),this.getScene().useOrderIndependentTransparency&&this.needAlphaBlendingForMesh(t)&&this.getScene().depthPeelingRenderer.bind(l),this._eventInfo.subMesh=n,this._callbackPluginEventBindForSubMesh(this._eventInfo),kc.a.BindClipPlane(this._activeEffect,c),this.bindEyePosition(l)}else c.getEngine()._features.needToAlwaysBindUniformBuffers&&(this._needToBindSceneUbo=!0);!d&&this.isFrozen||(c.lightsEnabled&&!this._disableLighting&&kc.a.BindLights(c,t,this._activeEffect,u,this._maxSimultaneousLights),(c.fogEnabled&&t.applyFog&&c.fogMode!==Q.a.FOGMODE_NONE||p||t.receiveShadows)&&this.bindView(l),kc.a.BindFogParameters(c,t,this._activeEffect,!0),u.NUM_MORPH_INFLUENCERS&&kc.a.BindMorphTargetParameters(t,this._activeEffect),u.BAKED_VERTEX_ANIMATION_TEXTURE&&(null===(a=t.bakedVertexAnimationManager)||void 0===a||a.bind(l,u.INSTANCES)),this._imageProcessingConfiguration.bind(this._activeEffect),kc.a.BindLogDepth(u,this._activeEffect,c)),this._afterBind(t,this._activeEffect),f.update()}}},t.prototype.getAnimatables=function(){var t=e.prototype.getAnimatables.call(this);return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&t.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&t.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&t.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&t.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&t.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?t.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&t.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&t.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&t.push(this._lightmapTexture),t},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._reflectanceTexture&&t.push(this._reflectanceTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),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._reflectanceTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||this._lightmapTexture===t))))))))))},t.prototype.setPrePassRenderer=function(e){var t;if(null===(t=this.subSurface)||void 0===t?void 0:t.isScatteringEnabled){var n=this.getScene().enableSubSurfaceForPrePass();return n&&(n.enabled=!0),!0}return!1},t.prototype.dispose=function(t,n){var i,r,o,a,s,c,u,l,h,d,p,f;n&&(this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),null===(i=this._albedoTexture)||void 0===i||i.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===(u=this._reflectivityTexture)||void 0===u||u.dispose(),null===(l=this._bumpTexture)||void 0===l||l.dispose(),null===(h=this._lightmapTexture)||void 0===h||h.dispose(),null===(d=this._metallicReflectanceTexture)||void 0===d||d.dispose(),null===(p=this._reflectanceTexture)||void 0===p||p.dispose(),null===(f=this._microSurfaceTexture)||void 0===f||f.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,n)},t.PBRMATERIAL_OPAQUE=cu.a.MATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=cu.a.MATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=cu.a.MATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=cu.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(F.j)()],t.prototype,"_imageProcessingConfiguration",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),Object(h.c)([Object(F.d)()],t.prototype,"useLogarithmicDepth",null),t}(zc.a),al=function(e){function t(n,i){var r=e.call(this,n,i)||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.useOnlyMetallicFromMetallicReflectanceTexture=!1,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=nu(r.getScene()),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===ol.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?ol.LIGHTFALLOFF_PHYSICAL:ol.LIGHTFALLOFF_STANDARD)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===ol.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?ol.LIGHTFALLOFF_GLTF:ol.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 n=this,i=F.a.Clone((function(){return new t(e,n.getScene())}),this);return i.id=e,i.name=e,this.stencil.copyTo(i.stencil),this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),this.subSurface.copyTo(i.subSurface),i},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.customType="BABYLON.PBRMaterial",t.clearCoat=this.clearCoat.serialize(),t.anisotropy=this.anisotropy.serialize(),t.brdf=this.brdf.serialize(),t.sheen=this.sheen.serialize(),t.subSurface=this.subSurface.serialize(),t},t.Parse=function(e,n,i){var r=F.a.Parse((function(){return new t(e.name,n)}),e,n,i);return e.stencil&&r.stencil.parse(e.stencil,n,i),e.clearCoat&&r.clearCoat.parse(e.clearCoat,n,i),e.anisotropy&&r.anisotropy.parse(e.anisotropy,n,i),e.brdf&&r.brdf.parse(e.brdf,n,i),e.sheen&&r.sheen.parse(e.sheen,n,i),e.subSurface&&r.subSurface.parse(e.subSurface,n,i),r},t.PBRMATERIAL_OPAQUE=ol.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=ol.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=ol.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=ol.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=ol.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicF0Factor",void 0),Object(h.c)([Object(F.f)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceColor",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useOnlyMetallicFromMetallicReflectanceTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicReflectanceTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectanceTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),Object(h.c)([Object(F.n)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),Object(h.c)([Object(F.f)("ambient"),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),Object(h.c)([Object(F.f)("albedo"),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),Object(h.c)([Object(F.f)("reflectivity"),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),Object(h.c)([Object(F.f)("reflection"),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),Object(h.c)([Object(F.f)("emissive"),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),Object(h.c)([Object(F.d)()],t.prototype,"usePhysicalLightFalloff",null),Object(h.c)([Object(F.d)()],t.prototype,"useGLTFLightFalloff",null),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),Object(h.c)([Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),Object(h.c)([Object(F.d)(),Object(F.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(ol);Object(c.b)("BABYLON.PBRMaterial",al);function sl(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var cl=sl("DXT1"),ul=sl("DXT3"),ll=sl("DXT5"),hl=sl("DX10"),dl=function(){function e(){}return e.GetDDSInfo=function(e){var t=new Int32Array(e.buffer,e.byteOffset,31),n=new Int32Array(e.buffer,e.byteOffset,35),i=1;131072&t[2]&&(i=Math.max(1,t[7]));var r=t[21],o=r===hl?n[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 hl: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:i,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:r===cl||r===ul||r===ll,dxgiFormat:o,textureType:a}},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,n,i,r,o,a){for(var s=new Float32Array(r),c=new Uint16Array(o,i),u=0,l=0;l>8)},e._GetRGBArrayBuffer=function(e,t,n,i,r,o,a,s){for(var c=new Uint8Array(i),u=new Uint8Array(r,n),l=0,h=0;h>8&255,R>>16&255,R>>24&255)))}var O=e._ExtractLongWordOrder(T[23]),M=e._ExtractLongWordOrder(T[24]),I=e._ExtractLongWordOrder(T[25]),D=e._ExtractLongWordOrder(T[26]);C&&(S=t._getRGBABufferInternalSizedFormat(r.textureType)),b=1,131072&T[2]&&!1!==o&&(b=Math.max(1,T[7]));for(var N=c||0,L=t.getCaps(),F=N;F0?r.sphericalPolynomial=oo.ConvertCubeMapToSphericalPolynomial({size:T[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}();Ve.a.prototype.createPrefilteredCubeTexture=function(e,t,n,i,r,o,a,s,c){var u=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 Yr,o._source=Ue.b.CubePrefiltered,u.getCaps().textureLOD)r&&r(o);else{var a=u._gl,s=e.width;if(s){for(var l=[],h=0;h<3;h++){var d=1-h/2,p=i,f=L.a.Log2(s)*n+i,_=p+(f-p)*d,v=Math.round(Math.min(Math.max(_,0),f)),b=new Ue.a(u,Ue.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,b._cachedWrapU=g.a.TEXTURE_CLAMP_ADDRESSMODE,b._cachedWrapV=g.a.TEXTURE_CLAMP_ADDRESSMODE,u._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;u._unpackFlipY(y.isCompressed),dl.UploadDDSLevels(u,b,T,y,!0,6,v)}else m.a.Warn("DDS is the only prefiltered cube map supported so far.");u._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var E=new Kr.a(t);E.isCube=!0,E._texture=b,b.isReady=!0,l.push(E)}o._lodTextureHigh=l[2],o._lodTextureMid=l[1],o._lodTextureLow=l[0],r&&r(o)}}}else r&&r(null)}),o,a,s,c,n,i)};var pl=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e){return Object(Ke.e)(e,".dds")},e.prototype.loadCubeData=function(e,t,n,i,r){var o,a=t.getEngine(),s=!1,c=1e3;if(Array.isArray(e))for(var u=0;u1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),dl.UploadDDSLevels(a,t,l,o,s,6,-1,u),o.isFourCC||1!==o.mipmapCount?c=o.mipmapCount-1:a.generateMipMapsForCubemap(t)}else{var h=e;o=dl.GetDDSInfo(h),t.width=o.width,t.height=o.height,n&&(o.sphericalPolynomial=new Yr),s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),dl.UploadDDSLevels(a,t,h,o,s,6),o.isFourCC||1!==o.mipmapCount?c=o.mipmapCount-1:a.generateMipMapsForCubemap(t,!1)}a._setCubeMapTextureParams(t,s,c),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),i&&i({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,n){var i=dl.GetDDSInfo(e),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&t.generateMipMaps&&i.width>>i.mipmapCount-1==1;n(i.width,i.height,r,i.isFourCC,(function(){dl.UploadDDSLevels(t.getEngine(),t,e,i,r,1)}))},e}();xe.a._TextureLoaders.push(new pl);var fl=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Object(Ke.e)(e,".env")},e.prototype.loadCubeData=function(e,t,n,i,r){if(!Array.isArray(e)){var o=co(e);if(o){t.width=o.width,t.height=o.width;try{go(t,o),fo(t,e,o).then((function(){t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),i&&i()}),(function(e){null==r||r("Can not upload environment levels",e)}))}catch(e){null==r||r("Can not upload environment file",e)}}else r&&r("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,n){throw".env not supported in 2d."},e}();xe.a._TextureLoaders.push(new fl);var _l=function(){function e(t,n,i,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===n?this.loadType=e.COMPRESSED_2D:m.a.Error("number of faces expected"+n+", 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,n){switch(this.loadType){case e.COMPRESSED_2D:this._upload2DCompressedLevels(t,n);break;case e.TEX_2D:case e.COMPRESSED_3D:case e.TEX_3D:}},e.prototype._upload2DCompressedLevels=function(t,n){for(var i=e.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,o=this.pixelHeight,a=n?this.numberOfMipmapLevels:1,s=0;s=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}(),ml=function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{workerPromise:Promise.resolve(e),idle:!0}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;e1,e.errors)throw new Error("KTX2 container - could not transcode the data. "+e.errors);for(var i=0;i=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,wasmZSTDDecoder:null},e.DefaultNumWorkers=e.GetDefaultNumWorkers(),e}();function bl(){var e;onmessage=function(t){if(t.data)switch(t.data.action){case"init":var n=t.data.urls;importScripts(n.jsDecoderModule),null!==n.wasmUASTCToASTC&&(KTX2DECODER.LiteTranscoder_UASTC_ASTC.WasmModuleURL=n.wasmUASTCToASTC),null!==n.wasmUASTCToBC7&&(KTX2DECODER.LiteTranscoder_UASTC_BC7.WasmModuleURL=n.wasmUASTCToBC7),null!==n.wasmUASTCToRGBA_UNORM&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_UNORM.WasmModuleURL=n.wasmUASTCToRGBA_UNORM),null!==n.wasmUASTCToRGBA_SRGB&&(KTX2DECODER.LiteTranscoder_UASTC_RGBA_SRGB.WasmModuleURL=n.wasmUASTCToRGBA_SRGB),null!==n.jsMSCTranscoder&&(KTX2DECODER.MSCTranscoder.JSModuleURL=n.jsMSCTranscoder),null!==n.wasmMSCTranscoder&&(KTX2DECODER.MSCTranscoder.WasmModuleURL=n.wasmMSCTranscoder),null!==n.wasmZSTDDecoder&&(KTX2DECODER.ZSTDDecoder.WasmModuleURL=n.wasmZSTDDecoder),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=[],n=0;n1&&t.generateMipMaps;o._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,o._setCubeMapTextureParams(t,s,a.numberOfMipmapLevels-1),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),i&&i()}},e.prototype.loadData=function(e,t,n,i){if(_l.IsValid(e)){t._invertVScale=!t.invertY;var r=new _l(e,1);n(r.pixelWidth,r.pixelHeight,t.generateMipMaps,!0,(function(){r.uploadLevels(t,t.generateMipMaps)}),r.isInvalid)}else if(vl.IsValid(e)){new vl(t.getEngine()).uploadAsync(e,t,i).then((function(){n(t.width,t.height,t.generateMipMaps,!0,(function(){}),!1)}),(function(e){m.a.Warn("Failed to load KTX2 texture data: ".concat(e.message)),n(0,0,!1,!1,(function(){}),!0)}))}else m.a.Error("texture missing KTX identifier"),n(0,0,!1,!1,(function(){}),!0)},e}();xe.a._TextureLoaders.unshift(new yl);var Tl=function(e){function t(t,n,i){var r=e.call(this,t,a.e.Zero(),n)||this;return r._xrSessionManager=i,r._firstFrame=!1,r._referenceQuaternion=a.b.Identity(),r._referencedPosition=new a.e,r._trackingState=Ci.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=at.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 Wn.a(0,0,.5,1),this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new Wn.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.dispose=function(){e.prototype.dispose.call(this),this._lastXRViewerPose=void 0},t.prototype._updateFromXRSession=function(){var e=this,t=this._xrSessionManager.currentFrame&&this._xrSessionManager.currentFrame.getViewerPose(this._xrSessionManager.referenceSpace);if(this._lastXRViewerPose=t||void 0,t){var n=t.emulatedPosition?Ci.TRACKING_LOST:Ci.TRACKING;if(this._setTrackingState(n),t.transform){var i=t.transform.orientation;if(void 0===t.transform.orientation.x)return;var r=t.transform.position;this._referencedPosition.set(r.x,r.y,r.z),this._referenceQuaternion.set(i.x,i.y,i.z,i.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,n){var i,r=e.rigCameras[n];r.isLeftCamera||r.isRightCamera||("right"===t.eye?r._isRightCamera=!0:"left"===t.eye&&(r._isLeftCamera=!0));var o=t.transform.position,s=t.transform.orientation;r.parent=e.parent,r.position.set(o.x,o.y,o.z),r.rotationQuaternion.set(s.x,s.y,s.z,s.w),e._scene.useRightHandedSystem?r.rotationQuaternion.multiplyInPlace(e._rotate180):(r.position.z*=-1,r.rotationQuaternion.z*=-1,r.rotationQuaternion.w*=-1),a.a.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,r._projectionMatrix),e._scene.useRightHandedSystem||r._projectionMatrix.toggleProjectionMatrixHandInPlace(),0===n&&e._projectionMatrix.copyFrom(r._projectionMatrix);var c=e._xrSessionManager.getRenderTargetTextureForView(t);e._renderingMultiview=(null===(i=null==c?void 0:c._texture)||void 0===i?void 0:i.isMultiview)||!1,e._renderingMultiview?0==n&&(e._xrSessionManager.trySetViewportForView(e.viewport,t),e.outputRenderTarget=c):(e._xrSessionManager.trySetViewportForView(r.viewport,t),r.outputRenderTarget=c||e._xrSessionManager.getRenderTargetTextureForView(t))}))}else this._setTrackingState(Ci.NOT_TRACKING)},t.prototype._updateNumberOfRigCameras=function(e){for(void 0===e&&(e=1);this.rigCameras.lengthe;){var n=this.rigCameras.pop();n&&n.dispose()}},t.prototype._updateReferenceSpace=function(){if(!this.position.equals(this._referencedPosition)||!this.rotationQuaternion.equals(this._referenceQuaternion)){var e=a.c.Matrix[0],n=a.c.Matrix[1],i=a.c.Matrix[2];a.a.ComposeToRef(t._ScaleReadOnly,this._referenceQuaternion,this._referencedPosition,e),a.a.ComposeToRef(t._ScaleReadOnly,this.rotationQuaternion,this.position,n),e.invert().multiplyToRef(n,i),i.invert(),this._scene.useRightHandedSystem||i.toggleModelMatrixHandInPlace(),i.decompose(void 0,this._referenceQuaternion,this._referencedPosition);var r=new XRRigidTransform({x:this._referencedPosition.x,y:this._referencedPosition.y,z:this._referencedPosition.z},{x:this._referenceQuaternion.x,y:this._referenceQuaternion.y,z:this._referenceQuaternion.z,w:this._referenceQuaternion.w});this._xrSessionManager.referenceSpace=this._xrSessionManager.referenceSpace.getOffsetReferenceSpace(r)}},t._ScaleReadOnly=a.e.One(),t}(nn),El=function(){function e(e){var t=this;this.scene=e,this._nonVRCamera=null,this._attachedToElement=!1,this._spectatorCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this._spectatorMode=!1,this.onInitialXRPoseSetObservable=new o.c,this.onStateChangedObservable=new o.c,this.state=Ri.NOT_IN_XR,this.sessionManager=new Vi(e),this.camera=new Tl("webxr",e,this.sessionManager),this.featuresManager=new ft(this.sessionManager),e.onDisposeObservable.addOnce((function(){t.dispose()}))}return e.CreateAsync=function(t){var n=new e(t);return n.sessionManager.initializeAsync().then((function(){return n._supported=!0,n})).catch((function(e){throw n._setState(Ri.NOT_IN_XR),n.dispose(),e}))},e.prototype.dispose=function(){var e;this.exitXRAsync(),this.camera.dispose(),this.onStateChangedObservable.clear(),this.onInitialXRPoseSetObservable.clear(),this.sessionManager.dispose(),null===(e=this._spectatorCamera)||void 0===e||e.dispose(),this._nonVRCamera&&(this.scene.activeCamera=this._nonVRCamera)},e.prototype.enterXRAsync=function(e,t,n,i){var r,o;return void 0===n&&(n=this.sessionManager.getWebXRRenderTarget()),void 0===i&&(i={}),Object(h.b)(this,void 0,void 0,(function(){var a,s,c,u=this;return Object(h.e)(this,(function(l){switch(l.label){case 0:if(!this._supported)throw"WebXR not supported in this browser or environment";return this._setState(Ri.ENTERING_XR),"viewer"!==t&&"local"!==t&&(i.optionalFeatures=i.optionalFeatures||[],i.optionalFeatures.push(t)),[4,this.featuresManager._extendXRSessionInitObject(i)];case 1:i=l.sent(),"immersive-ar"===e&&"unbounded"!==t&&m.a.Warn("We recommend using 'unbounded' reference space type when using 'immersive-ar' session mode"),l.label=2;case 2:return l.trys.push([2,6,,7]),[4,this.sessionManager.initializeSessionAsync(e,i)];case 3:return l.sent(),[4,this.sessionManager.setReferenceSpaceTypeAsync(t)];case 4:return l.sent(),[4,n.initializeXRLayerAsync(this.sessionManager.session)];case 5:return a=l.sent(),s={depthFar:this.camera.maxZ,depthNear:this.camera.minZ},this.featuresManager.getEnabledFeature(pt.LAYERS)||(s.baseLayer=a),this.sessionManager.updateRenderState(s),this.sessionManager.runXRRenderLoop(),this._originalSceneAutoClear=this.scene.autoClear,this._nonVRCamera=this.scene.activeCamera,this._attachedToElement=!!(null===(r=this._nonVRCamera)||void 0===r?void 0:r.inputs.attachedToElement),null===(o=this._nonVRCamera)||void 0===o||o.detachControl(),this.scene.activeCamera=this.camera,"immersive-ar"!==e?this._nonXRToXRCamera():(this.scene.autoClear=!1,this.camera.compensateOnFirstFrame=!1,this.camera.position.set(0,0,0),this.camera.rotationQuaternion.set(0,0,0,1)),this.sessionManager.onXRSessionEnded.addOnce((function(){u.state!==Ri.EXITING_XR&&u._setState(Ri.EXITING_XR),u.camera.rigCameras.forEach((function(e){e.outputRenderTarget=null})),u.scene.autoClear=u._originalSceneAutoClear,u.scene.activeCamera=u._nonVRCamera,u._attachedToElement&&u._nonVRCamera&&u._nonVRCamera.attachControl(!!u._nonVRCamera.inputs.noPreventDefault),"immersive-ar"!==e&&u.camera.compensateOnFirstFrame&&(u._nonVRCamera.setPosition?u._nonVRCamera.setPosition(u.camera.position):u._nonVRCamera.position.copyFrom(u.camera.position)),u._setState(Ri.NOT_IN_XR)})),this.sessionManager.onXRFrameObservable.addOnce((function(){u._setState(Ri.IN_XR)})),[2,this.sessionManager];case 6:throw c=l.sent(),console.log(c),console.log(c.message),this._setState(Ri.NOT_IN_XR),c;case 7:return[2]}}))}))},e.prototype.exitXRAsync=function(){return this.state!==Ri.IN_XR?Promise.resolve():(this._setState(Ri.EXITING_XR),this.sessionManager.exitXRAsync())},e.prototype.enableSpectatorMode=function(){var e=this;if(!this._spectatorMode){var t=function(){e._spectatorCamera&&(e._spectatorCamera.position.copyFrom(e.camera.rigCameras[0].globalPosition),e._spectatorCamera.rotationQuaternion.copyFrom(e.camera.rigCameras[0].absoluteRotation))},n=function(){e.state===Ri.IN_XR?(e._spectatorCamera=new An("webxr-spectator",a.e.Zero(),e.scene),e._spectatorCamera.rotationQuaternion=new a.b,e.scene.activeCameras=[e.camera,e._spectatorCamera],e.sessionManager.onXRFrameObservable.add(t),e.scene.onAfterRenderCameraObservable.add((function(t){t===e.camera&&(e.scene.getEngine().framebufferDimensionsObject=null)}))):e.state===Ri.EXITING_XR&&(e.sessionManager.onXRFrameObservable.removeCallback(t),e.scene.activeCameras=null)};this._spectatorMode=!0,this.onStateChangedObservable.add(n),n()}},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}(),Sl=function(){function e(e,t,n,i){void 0===n&&(n=-1),void 0===i&&(i=[]),this.id=e,this.type=t,this._buttonIndex=n,this._axesIndices=i,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,n=!1;if(this._hasChanges=!1,this._changes={},this.isButton()){var i=e.buttons[this._buttonIndex];if(!i)return;this._currentValue!==i.value&&(this.changes.value={current:i.value,previous:this._currentValue},t=!0,this._currentValue=i.value),this._touched!==i.touched&&(this.changes.touched={current:i.touched,previous:this._touched},t=!0,this._touched=i.touched),this._pressed!==i.pressed&&(this.changes.pressed={current:i.pressed,previous:this._pressed},t=!0,this._pressed=i.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]],n=!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]],n=!0)),t&&(this._hasChanges=!0,this.onButtonStateChangedObservable.notifyObservers(this)),n&&(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}(),Al=function(){function e(e,t,n,i,r,a){var s=this;void 0===r&&(r=!1),this.scene=e,this.layout=t,this.gamepadObject=n,this.handedness=i,this._doNotLoadControllerMesh=r,this._controllerCache=a,this._initComponent=function(e){if(e){var t=s.layout.components[e],n=t.type,i=t.gamepadIndices.button,r=[];void 0!==t.gamepadIndices.xAxis&&void 0!==t.gamepadIndices.yAxis&&r.push(t.gamepadIndices.xAxis,t.gamepadIndices.yAxis),s.components[e]=new Sl(e,n,i,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.getChildren(void 0,!0).forEach((function(e){e.setEnabled(!1)})),this.rootMesh.dispose(!!this._controllerCache,!this._controllerCache))},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,n=this;return Object(h.e)(this,(function(i){return e=!this._getModelLoadingConstraints(),t=this._getGenericFilenameAndPath(),e?m.a.Warn("Falling back to generic models"):t=this._getFilenameAndPath(),[2,new Promise((function(i,r){var o=function(t){e?n._getGenericParentMesh(t):n._setRootMesh(t),n._processLoadedModel(t),n._modelReady=!0,n.onModelLoadedObservable.notifyObservers(n),i(!0)};if(n._controllerCache){var a=n._controllerCache.filter((function(e){return e.filename===t.filename&&e.path===t.path}));if(a[0])return a[0].meshes.forEach((function(e){return e.setEnabled(!0)})),void o(a[0].meshes)}Xs.ImportMesh("",t.path,t.filename,n.scene,(function(e){n._controllerCache&&n._controllerCache.push(Object(h.a)(Object(h.a)({},t),{meshes:e})),o(e)}),null,(function(e,i){m.a.Log(i),m.a.Warn("Failed to retrieve controller model of type ".concat(n.profileId," from the remote server: ").concat(t.path).concat(t.filename)),r(i)}))}))]}))}))},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,n){return void 0===n&&(n=0),this.gamepadObject.hapticActuators&&this.gamepadObject.hapticActuators[n]?this.gamepadObject.hapticActuators[n].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,n){if(e.minMesh&&e.maxMesh&&e.valueMesh&&e.minMesh.rotationQuaternion&&e.maxMesh.rotationQuaternion&&e.valueMesh.rotationQuaternion){var i=n?.5*t+.5:t;a.b.SlerpToRef(e.minMesh.rotationQuaternion,e.maxMesh.rotationQuaternion,i,e.valueMesh.rotationQuaternion),a.e.LerpToRef(e.minMesh.position,e.maxMesh.position,i,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 Te.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}(),xl=function(e){function t(n,i,r){var o=e.call(this,n,Rl[r],i,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 Te.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}(Al),Rl={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"}},Cl=function(e){function t(t,n,i,r,o){var a=e.call(this,t,i.layouts[n.handedness||"none"],n.gamepad,n.handedness,void 0,o)||this;return a._repositoryUrl=r,a.controllerCache=o,a._buttonMeshMapping={},a._touchDots={},a.profileId=i.profileId,a}return Object(h.d)(t,e),t.prototype.dispose=function(){var t=this;e.prototype.dispose.call(this),this.controllerCache||Object.keys(this._touchDots).forEach((function(e){t._touchDots[e].dispose()}))},t.prototype._getFilenameAndPath=function(){return{filename:this.layout.assetPath,path:"".concat(this._repositoryUrl,"/profiles/").concat(this.profileId,"/")}},t.prototype._getModelLoadingConstraints=function(){var e=Xs.IsPluginForExtensionAvailable(".glb");return e||m.a.Warn("glTF / glb loader was not registered, using generic controller instead"),e},t.prototype._processLoadedModel=function(e){var t=this;this.getComponentIds().forEach((function(e){var n=t.layout.components[e];t._buttonMeshMapping[e]={mainMesh:t._getChildByName(t.rootMesh,n.rootNodeName),states:{}},Object.keys(n.visualResponses).forEach((function(i){var r=n.visualResponses[i];if("transform"===r.valueNodeProperty)t._buttonMeshMapping[e].states[i]={valueMesh:t._getChildByName(t.rootMesh,r.valueNodeName),minMesh:t._getChildByName(t.rootMesh,r.minNodeName),maxMesh:t._getChildByName(t.rootMesh,r.maxNodeName)};else{var o=n.type===Sl.TOUCHPAD_TYPE&&n.touchPointNodeName?n.touchPointNodeName:r.valueNodeName;if(t._buttonMeshMapping[e].states[i]={valueMesh:t._getChildByName(t.rootMesh,o)},n.type===Sl.TOUCHPAD_TYPE&&!t._touchDots[i]){var a=Object(ac.a)(i+"dot",{diameter:.0015,segments:8},t.scene);a.material=new Si.a(i+"mat",t.scene),a.material.diffuseColor=s.a.Red(),a.parent=t._buttonMeshMapping[e].states[i].valueMesh||null,a.isVisible=!1,t._touchDots[i]=a}}}))}))},t.prototype._setRootMesh=function(e){var t;this.rootMesh=new Te.a(this.profileId+"-"+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var n=0;ni/10&&(a.isVisible=!0),(s+=t._scene.getEngine().getDeltaTime())>=i)t._scene.simulatePointerDown(n.pick,u),c=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,u),a.isVisible=!1;else{var e=1-s/i;a.scaling.set(e,e,e)}else c=!1,s=0;t._scene.simulatePointerMove(n.pick,u),o=n.pick}})),void 0!==this._options.renderingGroupId&&(a.renderingGroupId=this._options.renderingGroupId),e&&e.onDisposeObservable.addOnce((function(){n.pick&&!t._options.disablePointerUpOnTouchOut&&c&&(t._scene.simulatePointerUp(n.pick,u),n.finalPointerUpTriggered=!0),a.dispose()}))},t.prototype._attachScreenRayMode=function(e){var t=this,n=this._controllers[e.uniqueId],i=!1,r={pointerId:n.id,pointerType:"xr"};n.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){t._augmentPointerInit(r,n.id,n.screenCoordinates),!n.pick||t._options.disablePointerUpOnTouchOut&&i||(i?t._scene.simulatePointerMove(n.pick,r):(t._scene.simulatePointerDown(n.pick,r),n.pointerDownTriggered=!0,i=!0,t._options.disablePointerUpOnTouchOut&&t._scene.simulatePointerUp(n.pick,r)))})),e.onDisposeObservable.addOnce((function(){t._augmentPointerInit(r,n.id,n.screenCoordinates),t._xrSessionManager.runInXRFrame((function(){n.pick&&!n.finalPointerUpTriggered&&i&&!t._options.disablePointerUpOnTouchOut&&(t._scene.simulatePointerUp(n.pick,r),n.finalPointerUpTriggered=!0)}))}))},t.prototype._attachTrackedPointerRayMode=function(e){var t=this,n=this._controllers[e.uniqueId];if(this._options.forceGazeMode)return this._attachGazeMode(e);var i={pointerId:n.id,pointerType:"xr"};if(n.onFrameObserver=this._xrSessionManager.onXRFrameObservable.add((function(){n.laserPointer.material.disableLighting=t.disablePointerLighting,n.selectionMesh.material.disableLighting=t.disableSelectionMeshLighting,n.pick&&(t._augmentPointerInit(i,n.id,n.screenCoordinates),t._scene.simulatePointerMove(n.pick,i))})),e.inputSource.gamepad){var r=function(r){t._options.overrideButtonId&&(n.selectionComponent=r.getComponent(t._options.overrideButtonId)),n.selectionComponent||(n.selectionComponent=r.getMainComponent()),n.onButtonChangedObserver=n.selectionComponent.onButtonStateChangedObservable.add((function(r){if(r.changes.pressed){var o=r.changes.pressed.current;n.pick?(t._options.enablePointerSelectionOnAllControllers||e.uniqueId===t._attachedController)&&(t._augmentPointerInit(i,n.id,n.screenCoordinates),o?(t._scene.simulatePointerDown(n.pick,i),n.pointerDownTriggered=!0,n.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,n.laserPointer.material.emissiveColor=t.laserPointerPickedColor):(t._scene.simulatePointerUp(n.pick,i),n.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,n.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)):!o||t._options.enablePointerSelectionOnAllControllers||t._options.disableSwitchOnClick||(t._attachedController=e.uniqueId)}}))};e.motionController?r(e.motionController):e.onMotionControllerInitObservable.add(r)}else{var o=function(e){t._augmentPointerInit(i,n.id,n.screenCoordinates),n.xrController&&e.inputSource===n.xrController.inputSource&&n.pick&&(t._scene.simulatePointerDown(n.pick,i),n.pointerDownTriggered=!0,n.selectionMesh.material.emissiveColor=t.selectionMeshPickedColor,n.laserPointer.material.emissiveColor=t.laserPointerPickedColor)},a=function(e){t._augmentPointerInit(i,n.id,n.screenCoordinates),n.xrController&&e.inputSource===n.xrController.inputSource&&n.pick&&(t._scene.simulatePointerUp(n.pick,i),n.selectionMesh.material.emissiveColor=t.selectionMeshDefaultColor,n.laserPointer.material.emissiveColor=t.laserPointerDefaultColor)};n.eventListeners={selectend:a,selectstart:o},this._xrSessionManager.session.addEventListener("selectstart",o),this._xrSessionManager.session.addEventListener("selectend",a)}},t.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(a.e.Dot(e,t.direction))i},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},t.prototype._augmentPointerInit=function(e,t,n){e.pointerId=t,e.pointerType="xr",n&&(e.screenX=n.x,e.screenY=n.y)},Object.defineProperty(t.prototype,"lasterPointerDefaultColor",{get:function(){return this.laserPointerDefaultColor},enumerable:!1,configurable:!0}),t._idCounter=200,t.Name=pt.POINTER_SELECTION,t.Version=1,t}(Fl);ft.AddWebXRFeature(wl.Name,(function(e,t){return function(){return new wl(e,t)}}),wl.Version,!0),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"}(Ml||(Ml={})),function(e){e[e.Vertex=1]="Vertex",e[e.Fragment=2]="Fragment",e[e.Neutral=4]="Neutral",e[e.VertexAndFragment=3]="VertexAndFragment"}(Il||(Il={}));var Bl,Ul,Vl=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,n=this.target===Il.Fragment;this.compilationString="\r\n".concat(t?"//Entry point\r\n":"","void main(void) {\r\n").concat(this.compilationString),this._constantDeclaration&&(this.compilationString="\r\n".concat(t?"//Constants\r\n":"").concat(this._constantDeclaration,"\r\n").concat(this.compilationString));var i="";for(var r in this.functions)i+=this.functions[r]+"\r\n";for(var o in this.compilationString="\r\n".concat(i,"\r\n").concat(this.compilationString),!n&&this._varyingTransfer&&(this.compilationString="".concat(this.compilationString,"\r\n").concat(this._varyingTransfer)),this._injectAtEnd&&(this.compilationString="".concat(this.compilationString,"\r\n").concat(this._injectAtEnd)),this.compilationString="".concat(this.compilationString,"\r\n}"),this.sharedData.varyingDeclaration&&(this.compilationString="\r\n".concat(t?"//Varyings\r\n":"").concat(this.sharedData.varyingDeclaration,"\r\n").concat(this.compilationString)),this._samplerDeclaration&&(this.compilationString="\r\n".concat(t?"//Samplers\r\n":"").concat(this._samplerDeclaration,"\r\n").concat(this.compilationString)),this._uniformDeclaration&&(this.compilationString="\r\n".concat(t?"//Uniforms\r\n":"").concat(this._uniformDeclaration,"\r\n").concat(this.compilationString)),this._attributeDeclaration&&!n&&(this.compilationString="\r\n".concat(t?"//Attributes\r\n":"").concat(this._attributeDeclaration,"\r\n").concat(this.compilationString)),this.compilationString="precision highp float;\r\n"+this.compilationString,this.extensions){var a=this.extensions[o];this.compilationString="\r\n".concat(a,"\r\n").concat(this.compilationString)}this._builtCompilationString=this.compilationString},Object.defineProperty(e.prototype,"_repeatableContentAnchor",{get:function(){return"###___ANCHOR".concat(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 ".concat(e,";\r\n"),this.samplers.push(e))},e.prototype._getGLType=function(e){switch(e){case Ml.Float:return"float";case Ml.Int:return"int";case Ml.Vector2:return"vec2";case Ml.Color3:case Ml.Vector3:return"vec3";case Ml.Color4:case Ml.Vector4:return"vec4";case Ml.Matrix:return"mat4"}return""},e.prototype._emitExtension=function(e,t,n){void 0===n&&(n=""),this.extensions[e]||(n&&(t="#if ".concat(n,"\r\n").concat(t,"\r\n#endif")),this.extensions[e]=t)},e.prototype._emitFunction=function(e,t,n){this.functions[e]||(this.sharedData.emitComments&&(t=n+"\r\n"+t),this.functions[e]=t)},e.prototype._emitCodeFromInclude=function(e,t,n){if(n&&n.repeatKey)return"#include<".concat(e,">[0..").concat(n.repeatKey,"]\r\n");var i=ya.a.IncludesShadersStore[e]+"\r\n";if(this.sharedData.emitComments&&(i=t+"\r\n"+i),!n)return i;if(n.replaceStrings)for(var r=0;r[0..").concat(n.repeatKey,"]\r\n"):this.functions[r]="#include<".concat(e,">\r\n"),void(this.sharedData.emitComments&&(this.functions[r]=t+"\r\n"+this.functions[r]));if(this.functions[r]=ya.a.IncludesShadersStore[e],this.sharedData.emitComments&&(this.functions[r]=t+"\r\n"+this.functions[r]),n.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,"")),n.removeAttributes&&(this.functions[r]=this.functions[r].replace(/^\s*?attribute.+$/gm,"")),n.removeUniforms&&(this.functions[r]=this.functions[r].replace(/^\s*?uniform.+$/gm,"")),n.removeVaryings&&(this.functions[r]=this.functions[r].replace(/^\s*?varying.+$/gm,"")),n.replaceStrings)for(var o=0;o0},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isDirectlyConnectedToVertexOutput",{get:function(){if(!this.hasEndpoints)return!1;for(var e=0,t=this._endpoints;e=0)&&(t.isExposedOnFrame=!0,t.exposedPortPosition=this.exposedPortPosition),t},e.prototype.dispose=function(){this.onConnectionObservable.clear()},e}(),zl=function(){function e(e,t,n,i){void 0===t&&(t=Il.Vertex),void 0===n&&(n=!1),void 0===i&&(i=!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.visibleOnFrame=!1,this._target=t,this._originalTargetIsNeutral=t===Il.Neutral,this._isFinalMerger=n,this._isInput=i,this._name=e,this.uniqueId=mr.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,n,i){},e.prototype._declareOutput=function(e,t){return"".concat(t._getGLType(e.type)," ").concat(e.associatedVariableName)},e.prototype._writeVariable=function(e){return e.connectedPoint?"".concat(e.associatedVariableName):"0."},e.prototype._writeFloat=function(e){var t=e.toString();return-1===t.indexOf(".")&&(t+=".0"),"".concat(t)},e.prototype.getClassName=function(){return"NodeMaterialBlock"},e.prototype.registerInput=function(e,t,n,i,r){return void 0===n&&(n=!1),(r=null!=r?r:new Gl(e,this,Ul.Input)).type=t,r.isOptional=n,i&&(r.target=i),this._inputs.push(r),this},e.prototype.registerOutput=function(e,t,n,i){return(i=null!=i?i:new Gl(e,this,Ul.Output)).type=t,n&&(i.target=n),this._outputs.push(i),this},e.prototype.getFirstAvailableInput=function(e){void 0===e&&(e=null);for(var t=0,n=this._inputs;t=this._outputs.length?null:this._outputs[t+1]},e.prototype.isAnAncestorOf=function(e){for(var t=0,n=this._outputs;t0||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,"billboardMode",{get:function(){return this._billboardMode},set:function(e){this._billboardMode!==e&&(this._billboardMode=e,this._reset())},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,n){if(!t)return this;for(var i=0,r=0,o=t;r0);for(var e=0;e0)}},e}(),Sh="\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";Cn.a.ShadersStore.proceduralVertexShader=Sh;var Ah,xh=function(e){function t(t,n,i,r,a,s,c,u){void 0===a&&(a=null),void 0===s&&(s=!0),void 0===c&&(c=!1),void 0===u&&(u=g.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,null,r,!s)||this;l.isEnabled=!0,l.autoClear=!0,l.onGeneratedObservable=new o.c,l.onBeforeGenerationObservable=new o.c,l.nodeMaterialSource=null,l._textures={},l._currentRefreshId=-1,l._frameId=-1,l._refreshRate=1,l._vertexBuffers={},l._uniforms=new Array,l._samplers=new Array,l._floats={},l._ints={},l._floatsArrays={},l._colors3={},l._colors4={},l._vectors2={},l._vectors3={},l._matrices={},l._fallbackTextureUsed=!1,l._cachedDefines=null,l._contentUpdateId=-1,l._rtWrapper=null;var h=(r=l.getScene()||P.a.LastCreatedScene)._getComponent(Ne.a.NAME_PROCEDURALTEXTURE);h||(h=new Eh(r),r._addComponent(h)),r.proceduralTextures.push(l),l._fullEngine=r.getEngine(),l.name=t,l.isRenderTarget=!0,l._size=n,l._textureType=u,l._generateMipMaps=s,l._drawWrapper=new In.a(l._fullEngine),l.setFragment(i),l._fallbackTexture=a;var d=l._createRtWrapper(c,n,s,u);l._texture=d.texture;var p=[];return p.push(1,1),p.push(-1,1),p.push(-1,-1),p.push(1,-1),l._vertexBuffers[bt.b.PositionKind]=new bt.b(l._fullEngine,p,bt.b.PositionKind,!1,!1,2),l._createIndexBuffer(),l}return Object(h.d)(t,e),t.prototype._createRtWrapper=function(e,t,n,i){return e?(this._rtWrapper=this._fullEngine.createRenderTargetCubeTexture(t,{generateMipMaps:n,generateDepthBuffer:!1,generateStencilBuffer:!1,type:i}),this.setFloat("face",0)):this._rtWrapper=this._fullEngine.createRenderTargetTexture(t,{generateMipMaps:n,generateDepthBuffer:!1,generateStencilBuffer:!1,type:i}),this._rtWrapper},t.prototype.getEffect=function(){return this._drawWrapper.effect},t.prototype._setEffect=function(e){this._drawWrapper.effect=e},t.prototype.getContent=function(){var e=this;return this._contentData&&this._frameId===this._contentUpdateId||(this._contentData?this._contentData.then((function(t){e._contentData=e.readPixels(0,0,t),e._contentUpdateId=e._frameId})):(this._contentData=this.readPixels(0,0),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[bt.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===ci.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=ci.REFRESHRATE_RENDER_ONCE)},t.prototype.reset=function(){var e;null===(e=this._drawWrapper.effect)||void 0===e||e.dispose()},t.prototype._getDefines=function(){return""},t.prototype.isReady=function(){var e,t=this,n=this._fullEngine;if(this.nodeMaterialSource)return this._drawWrapper.effect.isReady();if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;if(!this._texture)return!1;var i=this._getDefines();return!(!this._drawWrapper.effect||i!==this._cachedDefines||!this._drawWrapper.effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines!==i&&(this._cachedDefines=i,this._drawWrapper.effect=n.createEffect(e,[bt.b.PositionKind],this._uniforms,this._samplers,i,void 0,void 0,(function(){var e;null===(e=t._rtWrapper)||void 0===e||e.dispose(),t._rtWrapper=t._texture=null,t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture&&t._texture.incrementReferences()),t._fallbackTextureUsed=!0}))),this._drawWrapper.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){if(!this._fallbackTextureUsed&&this._rtWrapper&&this._texture){var n=this._texture.isCube;this._rtWrapper.dispose();var i=this._createRtWrapper(n,e,t,this._textureType);this._texture=i.texture,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,n,i=this.getScene();if(i){var r=this._fullEngine;if(r.enableEffect(this._drawWrapper),this.onBeforeGenerationObservable.notifyObservers(this),r.setState(!1),!this.nodeMaterialSource){for(var o in this._textures)this._drawWrapper.effect.setTexture(o,this._textures[o]);for(o in this._ints)this._drawWrapper.effect.setInt(o,this._ints[o]);for(o in this._floats)this._drawWrapper.effect.setFloat(o,this._floats[o]);for(o in this._floatsArrays)this._drawWrapper.effect.setArray(o,this._floatsArrays[o]);for(o in this._colors3)this._drawWrapper.effect.setColor3(o,this._colors3[o]);for(o in this._colors4){var a=this._colors4[o];this._drawWrapper.effect.setFloat4(o,a.r,a.g,a.b,a.a)}for(o in this._vectors2)this._drawWrapper.effect.setVector2(o,this._vectors2[o]);for(o in this._vectors3)this._drawWrapper.effect.setVector3(o,this._vectors3[o]);for(o in this._matrices)this._drawWrapper.effect.setMatrix(o,this._matrices[o])}if(this._texture&&this._rtWrapper){if(null===(t=r._debugPushGroup)||void 0===t||t.call(r,"procedural texture generation for ".concat(this.name),1),this.isCube)for(var s=0;s<6;s++)r.bindFramebuffer(this._rtWrapper,s,void 0,void 0,!0),r.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this._drawWrapper.effect.setFloat("face",s),this.autoClear&&r.clear(i.clearColor,!0,!1,!1),r.drawElementsType(cu.a.TriangleFillMode,0,6);else r.bindFramebuffer(this._rtWrapper,0,void 0,void 0,!0),r.bindBuffers(this._vertexBuffers,this._indexBuffer,this._drawWrapper.effect),this.autoClear&&r.clear(i.clearColor,!0,!1,!1),r.drawElementsType(cu.a.TriangleFillMode,0,6);r.unBindFramebuffer(this._rtWrapper,this.isCube),this.isCube&&r.generateMipMapsForCubemap(this._texture),null===(n=r._debugPopGroup)||void 0===n||n.call(r,1),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},t.prototype.clone=function(){var e=this.getSize(),n=new t(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return n.hasAlpha=this.hasAlpha,n.level=this.level,n.coordinatesMode=this.coordinatesMode,n},t.prototype.dispose=function(){var t=this.getScene();if(t){var n=t.proceduralTextures.indexOf(this);n>=0&&t.proceduralTextures.splice(n,1);var i=this._vertexBuffers[bt.b.PositionKind];i&&(i.dispose(),this._vertexBuffers[bt.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(F.d)()],t.prototype,"isEnabled",void 0),Object(h.c)([Object(F.d)()],t.prototype,"autoClear",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_generateMipMaps",void 0),Object(h.c)([Object(F.d)()],t.prototype,"_size",void 0),Object(h.c)([Object(F.d)()],t.prototype,"refreshRate",null),t}(Be.a);Object(c.b)("BABYLON.ProceduralTexture",xh),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"}(Ah||(Ah={}));var Rh=function(e){function t(t){var n=e.call(this,t,Il.Neutral)||this;return n.operation=Ah.Cos,n.registerInput("input",Ml.AutoDetect),n.registerOutput("output",Ml.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}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 n=this._outputs[0],i="";switch(this.operation){case Ah.Cos:i="cos";break;case Ah.Sin:i="sin";break;case Ah.Abs:i="abs";break;case Ah.Exp:i="exp";break;case Ah.Exp2:i="exp2";break;case Ah.Round:i="round";break;case Ah.Floor:i="floor";break;case Ah.Ceiling:i="ceil";break;case Ah.Sqrt:i="sqrt";break;case Ah.Log:i="log";break;case Ah.Tan:i="tan";break;case Ah.ArcTan:i="atan";break;case Ah.ArcCos:i="acos";break;case Ah.ArcSin:i="asin";break;case Ah.Fract:i="fract";break;case Ah.Sign:i="sign";break;case Ah.Radians:i="radians";break;case Ah.Degrees:i="degrees"}return t.compilationString+=this._declareOutput(n,t)+" = ".concat(i,"(").concat(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,n,i){e.prototype._deserialize.call(this,t,n,i),this.operation=t.operation},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".operation = BABYLON.TrigonometryBlockOperations.").concat(Ah[this.operation],";\r\n")},t}(zl);Object(c.b)("BABYLON.TrigonometryBlock",Rh);var Ch={effect:null,subMesh:null},Ph=function(e){function t(){var t=e.call(this)||this;return t.NORMAL=!1,t.TANGENT=!1,t.UV1=!1,t.UV2=!1,t.UV3=!1,t.UV4=!1,t.UV5=!1,t.UV6=!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.MORPHTARGETS_TEXTURE=!1,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.SKIPFINALCOLORCLAMP=!1,t.BUMPDIRECTUV=0,t.rebuild(),t}return Object(h.d)(t,e),t.prototype.setValue=function(e,t,n){void 0===n&&(n=!1),void 0===this[e]&&this._keys.push(e),n&&this[e]!==t&&this.markAsUnprocessed(),this[e]=t},t}(Gc.a),Oh=function(e){function t(n,i,r){void 0===r&&(r={});var s=e.call(this,n,i||P.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=sh.Material,s.forceAlphaBlending=!1,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},set:function(e){this._mode=e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"buildId",{get:function(){return this._buildId},set:function(e){this._buildId=e},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,n=0,i=this.attachedBlocks;n-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&Il.Vertex)&&this._addVertexOutputNode(e),0!=(e.target&Il.Fragment)&&this._addFragmentOutputNode(e),this},t.prototype.removeOutputNode=function(e){return null===e.target||(0!=(e.target&Il.Vertex)&&this._removeVertexOutputNode(e),0!=(e.target&Il.Fragment)&&this._removeFragmentOutputNode(e)),this},t.prototype._addVertexOutputNode=function(e){if(-1===this._vertexOutputNodes.indexOf(e))return e.target=Il.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=Il.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.forceAlphaBlending||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,n,i){if(void 0===i&&(i=!0),e.initialize(t),i&&e.autoConfigure(this),e._preparationId=this._buildId,-1===this.attachedBlocks.indexOf(e)){if(e.isUnique)for(var r=e.getClassName(),o=0,a=this.attachedBlocks;o-1&&this.attachedBlocks.splice(t,1),e.isFinalMerger&&this.removeOutputNode(e)},t.prototype.build=function(e,n,i){void 0===e&&(e=!1),void 0===n&&(n=!0),void 0===i&&(i=!0),this._buildWasSuccessful=!1;var r=this.getScene().getEngine(),o=this._mode===sh.Particle;if(0===this._vertexOutputNodes.length&&!o)throw"You must define at least one vertexOutputNode";if(0===this._fragmentOutputNodes.length)throw"You must define at least one fragmentOutputNode";this._vertexCompilationState=new Vl,this._vertexCompilationState.supportUniformBuffers=r.supportsUniformBuffers,this._vertexCompilationState.target=Il.Vertex,this._fragmentCompilationState=new Vl,this._fragmentCompilationState.supportUniformBuffers=r.supportsUniformBuffers,this._fragmentCompilationState.target=Il.Fragment,this._sharedData=new kl,this._sharedData.fragmentOutputNodes=this._fragmentOutputNodes,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=o;for(var a=[],s=[],c=0,u=this._vertexOutputNodes;ce.currentAnimationState)switch(e.currentAnimationState){case Mh.DEHYDRATED:if(e.hydrateCollisionMeshFunction(!0),t===Mh.HOVER)break;case Mh.HOVER:if(e.touchCollisionMeshFunction(!0),t===Mh.TOUCH)break}else switch(e.currentAnimationState){case Mh.TOUCH:if(e.touchCollisionMeshFunction(!1),t===Mh.HOVER)break;case Mh.HOVER:if(e.hydrateCollisionMeshFunction(!1),t===Mh.DEHYDRATED)break}e.currentAnimationState=t}},t.prototype._processTouchPoint=function(e,t,n){var i,r=this._controllers[e];r.grabRay.origin.copyFrom(t),n.toEulerAnglesToRef(a.c.Vector3[0]),r.grabRay.direction.copyFrom(a.c.Vector3[0]),this._options.nearInteractionControllerMode!==Ih.CENTERED_IN_FRONT||(null===(i=r.xrController)||void 0===i?void 0:i.inputSource.hand)||(r.xrController.getWorldPointerRayToRef(this._tmpRay),r.grabRay.origin.addInPlace(this._tmpRay.direction.scale(.05))),r.grabRay.length=this._nearGrabLengthScale*this._hoverRadius,r.touchCollisionMesh.position.copyFrom(r.grabRay.origin)},t.prototype._onXRFrame=function(e){var t=this;Object.keys(this._controllers).forEach((function(n){var i=t._controllers[n];if((t._options.enableNearInteractionOnAllControllers||n===t._attachedController)&&i.xrController&&(i.xrController.inputSource.hand||t._options.nearInteractionControllerMode&&i.xrController.inputSource.gamepad)){if(i.hoverInteraction=!1,i.nearInteraction=!1,i.xrController){var r=i.xrController.inputSource.hand;if(r){var o=r.get("index-finger-tip");if(o){var s=e.getJointPose(o,t._xrSessionManager.referenceSpace);if(s&&s.transform){var c=t._scene.useRightHandedSystem?1:-1;a.c.Vector3[0].set(s.transform.position.x,s.transform.position.y,s.transform.position.z*c),a.c.Quaternion[0].set(s.transform.orientation.x,s.transform.orientation.y,s.transform.orientation.z*c,s.transform.orientation.w*c),t._processTouchPoint(n,a.c.Vector3[0],a.c.Quaternion[0])}}}else if(i.xrController.inputSource.gamepad&&t._options.nearInteractionControllerMode!==Ih.DISABLED){var u=i.xrController.pointer;i.xrController.grip&&t._options.nearInteractionControllerMode===Ih.CENTERED_ON_CONTROLLER&&(u=i.xrController.grip),t._processTouchPoint(n,u.position,u.rotationQuaternion)}var l=function(e,t){return t&&t.hit?e&&e.hit?t.distancec&&(s=0,h.copyFrom(t.center)),-1!==s&&s=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"}(Lh||(Lh={}));var Vh=function(){function e(e){var t,n,i=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();i._timer=t-i._startTime;var n={startTime:i._startTime,currentTime:t,deltaTime:i._timer,completeRate:i._timer/i._timeToEnd,payload:e},r=i._breakOnNextTick||i._breakCondition(n);r||i._timer>=i._timeToEnd?i._stop(n,r):i.onEachCountObservable.notifyObservers(n)},this._setState(Lh.INIT),this._contextObservable=e.contextObservable,this._observableParameters=null!==(t=e.observableParameters)&&void 0!==t?t:{},this._breakCondition=null!==(n=e.breakCondition)&&void 0!==n?n:function(){return!1},this._timeToEnd=e.timeout,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===Lh.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(Lh.STARTED)},e.prototype.stop=function(){this._state===Lh.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(Lh.ENDED),t?this.onTimerAbortedObservable.notifyObservers(e):this.onTimerEndedObservable.notifyObservers(e)},e}(),kh=function(e){function t(t,n){var i=e.call(this,t)||this;return i._options=n,i._controllers={},i._snappedToPoint=!1,i._tmpRay=new pn.a(new a.e,new a.e),i._tmpVector=new a.e,i._tmpQuaternion=new a.b,i.skipNextTeleportation=!1,i.backwardsMovementEnabled=!0,i.backwardsTeleportationDistance=.7,i.parabolicCheckRadius=5,i.parabolicRayEnabled=!0,i.straightRayEnabled=!0,i.rotationAngle=Math.PI/8,i.onTargetMeshPositionUpdatedObservable=new o.c,i.teleportationEnabled=!0,i._rotationEnabled=!0,i._attachController=function(e){if(!(i._controllers[e.uniqueId]||i._options.forceHandedness&&e.inputSource.handedness!==i._options.forceHandedness)){i._controllers[e.uniqueId]={xrController:e,teleportationState:{forward:!1,backwards:!1,rotating:!1,currentRotation:0,baseRotation:0}};var t=i._controllers[e.uniqueId];if("tracked-pointer"===t.xrController.inputSource.targetRayMode&&t.xrController.inputSource.gamepad){var n=function(){if(e.motionController){var n=e.motionController.getComponentOfType(Sl.THUMBSTICK_TYPE)||e.motionController.getComponentOfType(Sl.TOUCHPAD_TYPE);if(!n||i._options.useMainComponentOnly){var r=e.motionController.getMainComponent();if(!r)return;t.teleportationComponent=r,t.onButtonChangedObserver=r.onButtonStateChangedObservable.add((function(){i.teleportationEnabled&&(r.changes.pressed&&(r.changes.pressed.current?(t.teleportationState.forward=!0,i._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Uh({timeout:i._options.timeToTeleport||3e3,contextObservable:i._xrSessionManager.onXRFrameObservable,breakCondition:function(){return!r.pressed},onEnded:function(){i._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&i._teleportForward(e.uniqueId)}})):(t.teleportationState.forward=!1,i._currentTeleportationControllerId="")))}))}else t.teleportationComponent=n,t.onAxisChangedObserver=n.onAxisValueChangedObservable.add((function(n){if(n.y<=.7&&t.teleportationState.backwards&&(t.teleportationState.backwards=!1),n.y>.7&&!t.teleportationState.forward&&i.backwardsMovementEnabled&&!i.snapPointsOnly&&!t.teleportationState.backwards){t.teleportationState.backwards=!0,i._tmpQuaternion.copyFrom(i._options.xrInput.xrCamera.rotationQuaternion),i._tmpQuaternion.toEulerAnglesToRef(i._tmpVector),i._tmpVector.x=0,i._tmpVector.z=0,a.b.FromEulerVectorToRef(i._tmpVector,i._tmpQuaternion),i._tmpVector.set(0,0,i.backwardsTeleportationDistance*(i._xrSessionManager.scene.useRightHandedSystem?1:-1)),i._tmpVector.rotateByQuaternionToRef(i._tmpQuaternion,i._tmpVector),i._tmpVector.addInPlace(i._options.xrInput.xrCamera.position),i._tmpRay.origin.copyFrom(i._tmpVector),i._tmpRay.length=i._options.xrInput.xrCamera.realWorldHeight+.1,i._tmpRay.direction.set(0,-1,0);var r=i._xrSessionManager.scene.pickWithRay(i._tmpRay,(function(e){return-1!==i._floorMeshes.indexOf(e)}));r&&r.pickedPoint&&(i._options.xrInput.xrCamera.position.x=r.pickedPoint.x,i._options.xrInput.xrCamera.position.z=r.pickedPoint.z)}if(n.y<-.7&&!i._currentTeleportationControllerId&&!t.teleportationState.rotating&&i.teleportationEnabled&&(t.teleportationState.forward=!0,i._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y),n.x){if(t.teleportationState.forward)i._currentTeleportationControllerId===t.xrController.uniqueId&&(i.rotationEnabled?setTimeout((function(){t.teleportationState.currentRotation=Math.atan2(n.x,n.y*(i._xrSessionManager.scene.useRightHandedSystem?1:-1))})):t.teleportationState.currentRotation=0);else if(!t.teleportationState.rotating&&Math.abs(n.x)>.7){t.teleportationState.rotating=!0;var o=i.rotationAngle*(n.x>0?1:-1)*(i._xrSessionManager.scene.useRightHandedSystem?-1:1);a.b.FromEulerAngles(0,o,0).multiplyToRef(i._options.xrInput.xrCamera.rotationQuaternion,i._options.xrInput.xrCamera.rotationQuaternion)}}else t.teleportationState.rotating=!1;0===n.x&&0===n.y&&t.teleportationState.forward&&i._teleportForward(e.uniqueId)}))}};e.motionController?n():e.onMotionControllerInitObservable.addOnce((function(){n()}))}else i._xrSessionManager.scene.onPointerObservable.add((function(n){n.type===qe.a.POINTERDOWN?(t.teleportationState.forward=!0,i._currentTeleportationControllerId=t.xrController.uniqueId,t.teleportationState.baseRotation=i._options.xrInput.xrCamera.rotationQuaternion.toEulerAngles().y,t.teleportationState.currentRotation=0,Uh({timeout:i._options.timeToTeleport||3e3,contextObservable:i._xrSessionManager.onXRFrameObservable,onEnded:function(){i._currentTeleportationControllerId===t.xrController.uniqueId&&t.teleportationState.forward&&i._teleportForward(e.uniqueId)}})):n.type===qe.a.POINTERUP&&(t.teleportationState.forward=!1,i._currentTeleportationControllerId="")}))}},i._options.teleportationTargetMesh||i._createDefaultTargetMesh(),i._floorMeshes=i._options.floorMeshes||[],i._snapToPositions=i._options.snapPositions||[],i._setTargetMeshVisibility(!1),i}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.addBlockerMesh=function(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[],this._options.pickBlockerMeshes.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.removeBlockerMesh=function(e){this._options.pickBlockerMeshes=this._options.pickBlockerMeshes||[];var t=this._options.pickBlockerMeshes.indexOf(e);-1!==t&&this._options.pickBlockerMeshes.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 n=0;n=u.video.HAVE_CURRENT_DATA;return!s.poster||s.autoPlay&&l?l&&u._createInternalTexture():(u._texture=u._getEngine().createTexture(s.poster,!1,!u.invertY,i),u._displayingPosterTexture=!0),u}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._processError=function(e){this._errorFound=!0,this._onError?this._onError(null==e?void 0:e.message):m.a.Error(null==e?void 0:e.message)},t.prototype._handlePlay=function(){var e=this;this._errorFound=!1,this.video.play().catch((function(t){if("NotAllowedError"===(null==t?void 0:t.name)){if(e._onUserActionRequestedObservable&&e._onUserActionRequestedObservable.hasObservers())return void e._onUserActionRequestedObservable.notifyObservers(e);if(!e.video.muted)return m.a.Warn("Unable to autoplay a video with sound. Trying again with muted turned true"),e.video.muted=!0,e._errorFound=!1,void e.video.play().catch((function(t){e._processError(t)}))}e._processError(t)}))},t.prototype.getClassName=function(){return"VideoTexture"},t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},t.prototype._getVideo=function(e){if(e.isNative)return e;if(e instanceof HTMLVideoElement)return Re.b.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(Re.b.SetCorsBehavior(e,t),t.src=e):(Re.b.SetCorsBehavior(e[0],t),e.forEach((function(e){var n=document.createElement("source");n.src=e,t.appendChild(n)}))),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,n,i,r){void 0===r&&(r=!0);var o=e.getEngine().createVideoElement(i);return e.getEngine()._badOS&&(document.body.appendChild(o),o.style.transform="scale(0.0001, 0.0001)",o.style.opacity="0",o.style.position="fixed",o.style.bottom="0px",o.style.right="0px"),o.setAttribute("autoplay",""),o.setAttribute("muted","true"),o.setAttribute("playsinline",""),o.muted=!0,void 0!==o.mozSrcObject?o.mozSrcObject=n:"object"==typeof o.srcObject?o.srcObject=n:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,o.src=window.URL&&window.URL.createObjectURL(n)),new Promise((function(n){var i=function(){n(new t("video",o,e,!0,r)),o.removeEventListener("playing",i)};o.addEventListener("playing",i),o.play()}))},t.CreateFromWebCamAsync=function(e,t,n,i){var r,o=this;if(void 0===n&&(n=!1),void 0===i&&(i=!0),t&&t.deviceId&&(r={exact:t.deviceId}),navigator.mediaDevices)return navigator.mediaDevices.getUserMedia({video:t,audio:n}).then((function(n){return o.CreateFromStreamAsync(e,n,t,i)}));var a=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia;return a&&a({video:{deviceId:r,width:{min:t&&t.minWidth||256,max:t&&t.maxWidth||640},height:{min:t&&t.minHeight||256,max:t&&t.maxHeight||480}},audio:n},(function(n){return o.CreateFromStreamAsync(e,n,t,i)}),(function(e){m.a.Error(e.name)})),Promise.reject("No support for userMedia on this device")},t.CreateFromWebCam=function(e,t,n,i,r){void 0===i&&(i=!1),void 0===r&&(r=!0),this.CreateFromWebCamAsync(e,n,i,r).then((function(e){t&&t(e)})).catch((function(e){m.a.Error(e.name)}))},t}(Be.a),Hh=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,n){var i=this,r={loop:n.loop,autoPlay:n.autoPlay,autoUpdateTexture:!0,poster:n.poster},o=new Wh((this.name||"videoDome")+"_texture",e,t,n.generateMipMaps,this._useDirectMapping,Be.a.TRILINEAR_SAMPLINGMODE,r);return n.clickToPlay&&(this._pointerObserver=t.onPointerObservable.add((function(e){e.type!==qe.a.POINTERUP&&i._texture.video.play()}))),this._textureObserver=o.onLoadObservable.add((function(){i.onLoadObservable.notifyObservers()})),o},t.prototype.dispose=function(t,n){void 0===n&&(n=!1),this._texture.onLoadObservable.remove(this._textureObserver),this._scene.onPointerObservable.remove(this._pointerObserver),e.prototype.dispose.call(this,t,n)},t.MODE_MONOSCOPIC=$c.MODE_MONOSCOPIC,t.MODE_TOPBOTTOM=$c.MODE_TOPBOTTOM,t.MODE_SIDEBYSIDE=$c.MODE_SIDEBYSIDE,t}($c),Xh=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new Ir.a,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this.engine.getGPUFrameTimeCounter()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,this.engine.captureGPUFrameTime(e))},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}(),Yh=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new Ir.a,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new Ir.a,this._captureFrameTime=!1,this._frameTime=new Ir.a,this._captureRenderTime=!1,this._renderTime=new Ir.a,this._captureInterFrameTime=!1,this._interFrameTime=new Ir.a,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new Ir.a,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new Ir.a,this._capturePhysicsTime=!1,this._physicsTime=new Ir.a,this._captureAnimationsTime=!1,this._animationsTime=new Ir.a,this._captureCameraRenderTime=!1,this._cameraRenderTime=new Ir.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&&(Re.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&&(Re.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(){Re.b.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Re.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(){Re.b.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Re.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(){Re.b.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Re.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(){Re.b.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Re.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(){Re.b.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Re.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(),Re.b.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Re.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(),Re.b.StartPerformanceCounter("Rendering camera ".concat(e.name))})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Re.b.EndPerformanceCounter("Rendering camera ".concat(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}(),Kh="#if defined(DIFFUSE_ISLINEAR) || defined(EMISSIVE_ISLINEAR)\n#include\n#endif\n#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;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\nvec4 finalColor=glowColor;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\n#ifdef DIFFUSE_ISLINEAR\nalbedoTexture=toGammaSpace(albedoTexture);\n#endif\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.a4&&(u.push(bt.b.MatricesIndicesExtraKind),u.push(bt.b.MatricesWeightsExtraKind)),c.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers);var g=o.skeleton;g&&g.isUsingTextureForMatrices?c.push("#define BONETEXTURE"):c.push("#define BonesPerMesh "+(g?g.bones.length+1:0)),o.numBoneInfluencers>0&&m.addCPUSkinningFallback(0,o)}else c.push("#define NUM_BONE_INFLUENCERS 0");var v=o.morphTargetManager,b=0;v&&v.numInfluencers>0&&(c.push("#define MORPHTARGETS"),b=v.numInfluencers,c.push("#define NUM_MORPH_INFLUENCERS "+b),v.isUsingTextureForTargets&&c.push("#define MORPHTARGETS_TEXTURE"),kc.a.PrepareAttributesForMorphTargetsInfluencers(u,o,b)),t&&(c.push("#define INSTANCES"),kc.a.PushAttributesForInstances(u),e.getRenderingMesh().hasThinInstances&&c.push("#define THIN_INSTANCES")),this._addCustomEffectDefines(c);var y=e._getDrawWrapper(void 0,!0),T=y.defines,E=c.join("\n");return T!==E&&y.setEffect(this._engine.createEffect("glowMapGeneration",u,["world","mBones","viewProjection","glowColor","morphTargetInfluences","boneTextureWidth","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity","morphTargetTextureInfo","morphTargetTextureIndices"],["diffuseSampler","emissiveSampler","opacitySampler","boneSampler","morphTargets"],E,m,void 0,void 0,{maxSimultaneousMorphTargets:b}),E),y.effect.isReady()},e.prototype.render=function(){for(var e=0;e-1&&this._scene.effectLayers.splice(i,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,n){return Re.b.Instantiate(e.customType).Parse(e,t,n)},e._SceneComponentInitialization=function(e){throw Object(Me.a)("EffectLayerSceneComponent")},Object(h.c)([Object(F.d)()],e.prototype,"name",void 0),Object(h.c)([Object(F.g)()],e.prototype,"neutralColor",void 0),Object(h.c)([Object(F.d)()],e.prototype,"isEnabled",void 0),Object(h.c)([Object(F.e)()],e.prototype,"camera",null),Object(h.c)([Object(F.d)()],e.prototype,"renderingGroupId",null),Object(h.c)([Object(F.d)()],e.prototype,"disableBoundingBoxesFromEffectLayer",void 0),e}();i.a.AddParser(Ne.a.NAME_EFFECTLAYER,(function(e,t,n,i){if(e.effectLayers){n.effectLayers||(n.effectLayers=new Array);for(var r=0;r0){this._previousStencilState=this._engine.getStencilBuffer();for(var i=0,r=n;i-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,n=0;n-1},t.prototype.referenceMeshToUseItsOwnMaterial=function(e){var t=this;e.resetDrawCache(this._mainTexture.renderPassId),this._meshesUsingTheirOwnMaterials.push(e.uniqueId),e.onDisposeObservable.add((function(){t._disposeMesh(e)}))},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);e.resetDrawCache(this._mainTexture.renderPassId)},t.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},t.prototype.getClassName=function(){return"GlowLayer"},t.prototype.serialize=function(){var e,t=F.a.Serialize(this);if(t.customType="BABYLON.GlowLayer",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e0&&e.isBackground===t&&e.renderTargetTextures.indexOf(i)>-1&&0!=(e.layerMask&n)},e.prototype._drawRenderTargetBackground=function(e){var t=this;this._draw((function(n){return t._drawRenderTargetPredicate(n,!0,t.scene.activeCamera.layerMask,e)}))},e.prototype._drawRenderTargetForeground=function(e){var t=this;this._draw((function(n){return t._drawRenderTargetPredicate(n,!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 n=this;void 0===t&&(t=!1),e.layers&&e.layers.forEach((function(e){var i=n.scene.layers.indexOf(e);-1!==i&&n.scene.layers.splice(i,1),t&&e.dispose()}))},e}(),od="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\n\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\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#define CUSTOM_FRAGMENT_MAIN_END\n}";Cn.a.ShadersStore.layerPixelShader=od;var ad="\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);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\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#define CUSTOM_VERTEX_MAIN_END\n}";Cn.a.ShadersStore.layerVertexShader=ad;var sd=function(){function e(e,t,n,i,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.isEnabled=!0,this._vertexBuffers={},this.onDisposeObservable=new o.c,this.onBeforeRenderObservable=new o.c,this.onAfterRenderObservable=new o.c,this.texture=t?new Be.a(t,n,!0):null,this.isBackground=void 0===i||i,this.color=void 0===r?new s.b(1,1,1,1):r,this._scene=n||P.a.LastCreatedScene;var c=this._scene._getComponent(Ne.a.NAME_LAYER);c||(c=new rd(this._scene),this._scene._addComponent(c)),this._scene.layers.push(this);var u=this._scene.getEngine();this._drawWrapper=new In.a(u);var l=[];l.push(1,1),l.push(-1,1),l.push(-1,-1),l.push(1,-1);var h=new bt.b(u,l,bt.b.PositionKind,!1,!1,2);this._vertexBuffers[bt.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[bt.b.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){if(this.isEnabled){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._drawWrapper.effect=e.createEffect("layer",[bt.b.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],t));var n=this._drawWrapper.effect;if(n&&n.isReady()&&this.texture&&this.texture.isReady()){e=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),e.enableEffect(this._drawWrapper),e.setState(!1),n.setTexture("textureSampler",this.texture),n.setMatrix("textureMatrix",this.texture.getTextureMatrix()),n.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),n.setVector2("offset",this.offset),n.setVector2("scale",this.scale),e.bindBuffers(this._vertexBuffers,this._indexBuffer,n),this.alphaTest?e.drawElementsType(cu.a.TriangleFillMode,0,6):(e.setAlphaMode(this.alphaBlendingMode),e.drawElementsType(cu.a.TriangleFillMode,0,6),e.setAlphaMode(g.a.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}}},e.prototype.dispose=function(){var e=this._vertexBuffers[bt.b.PositionKind];e&&(e.dispose(),this._vertexBuffers[bt.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}(),cd=function(){function e(e,t,n,i,r){this.size=e,this.position=t,this.alphaMode=g.a.ALPHA_ONEONE,this.color=n||new s.a(1,1,1),this.texture=i?new Be.a(i,r.getScene(),!0):null,this._system=r;var o=r.scene.getEngine();this._drawWrapper=new In.a(o),this._drawWrapper.effect=o.createEffect("lensFlare",[bt.b.PositionKind],["color","viewportMatrix"],["textureSampler"],""),r.lensFlares.push(this)}return e.AddFlare=function(t,n,i,r,o){return new e(t,n,i,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}(),ud="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";Cn.a.ShadersStore.lensFlarePixelShader=ud;var ld="\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n#define CUSTOM_VERTEX_MAIN_END\n}";Cn.a.ShadersStore.lensFlareVertexShader=ld;var hd=function(){function e(t,n,i){this.name=t,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=i||P.a.LastCreatedScene,e._SceneComponentInitialization(this._scene),this._emitter=n,this.id=t,i.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return i.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&i.activeCamera.layerMask)};var r=i.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[bt.b.PositionKind]=new bt.b(r,o,bt.b.PositionKind,!1,!1,2),this._createIndexBuffer()}return Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!1,configurable:!0}),e.prototype._createIndexBuffer=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)},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();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);var n=this._scene.useRightHandedSystem;return!!(t.z>0&&!n||t.z<0&&n)&&(this._positionX>e.x&&this._positionXe.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 n=new pn.a(this._scene.activeCamera.globalPosition,e),i=this._scene.pickWithRay(n,this.meshesSelectionPredicate,!0);return!i||!i.hit||i.distance>t},e.prototype.render=function(){if(!this._scene.activeCamera)return!1;var e,t,n=this._scene.getEngine(),i=this._scene.activeCamera.viewport.toGlobal(n.getRenderWidth(!0),n.getRenderHeight(!0));if(!this.computeEffectivePosition(i))return!1;if(!this._isVisible())return!1;var r=(e=this._positionXi.x+i.width-this.borderLimit?this._positionX-i.x-i.width+this.borderLimit:0)>(t=this._positionYi.y+i.height-this.borderLimit?this._positionY-i.y-i.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&&(i.x+=this.viewportBorder,i.y+=this.viewportBorder,i.width-=2*this.viewportBorder,i.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var s=i.x+i.width/2,c=i.y+i.height/2,u=s-this._positionX,l=c-this._positionY;n.setState(!1),n.setDepthBuffer(!1);for(var h=0;h0);for(var n=0,i=t;n0)}},e}();hd._SceneComponentInitialization=function(e){var t=e._getComponent(Ne.a.NAME_LENSFLARESYSTEM);t||(t=new dd(e),e._addComponent(t))};var pd="\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";Cn.a.IncludesShadersStore.bayerDitherFunctions=pd;var fd="#if SM_FLOAT == 0\n#include\n#endif\n#if SM_SOFTTRANSPARENTSHADOW == 1\n#include\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";Cn.a.IncludesShadersStore.shadowMapFragmentExtraDeclaration=fd;var _d=" float depthSM=vDepthMetricSM;\n#if defined(SM_DEPTHCLAMP) && SM_DEPTHCLAMP == 1\n#if SM_USEDISTANCE == 1\ndepthSM=(length(vPositionWSM-lightDataSM)+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\n#ifdef USE_REVERSE_DEPTHBUFFER\ndepthSM=(-zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\ndepthSM=(zSM+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_FragDepth=clamp(1.0-depthSM,0.0,1.0);\n#else\ngl_FragDepth=clamp(depthSM,0.0,1.0);\n#endif\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;";Cn.a.IncludesShadersStore.shadowMapFragment=_d;var md="#include\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void)\n{\n#include\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\n}";Cn.a.ShadersStore.shadowMapPixelShader=md;var gd="uniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec4 vEyePosition;\n";Cn.a.IncludesShadersStore.sceneVertexDeclaration=gd;Cn.a.IncludesShadersStore.meshVertexDeclaration="uniform mat4 world;\nuniform float visibility;\n";Cn.a.IncludesShadersStore.shadowMapVertexDeclaration="#include\n#include\n";var vd="layout(std140,column_major) uniform;\n#include\n#include\n";Cn.a.IncludesShadersStore.shadowMapUboDeclaration=vd;var bd="#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";Cn.a.IncludesShadersStore.shadowMapVertexExtraDeclaration=bd;var yd="\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";Cn.a.IncludesShadersStore.shadowMapVertexNormalBias=yd;var Td="#if SM_USEDISTANCE == 1\nvPositionWSM=worldPos.xyz;\n#endif\n#if SM_DEPTHTEXTURE == 1\n#ifdef IS_NDC_HALF_ZRANGE\n#define BIASFACTOR 0.5\n#else\n#define BIASFACTOR 1.0\n#endif\n\n#ifdef USE_REVERSE_DEPTHBUFFER\ngl_Position.z-=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#else\ngl_Position.z+=biasAndScaleSM.x*gl_Position.w*BIASFACTOR;\n#endif\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\n#ifdef USE_REVERSE_DEPTHBUFFER\nvDepthMetricSM=(-gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#else\nvDepthMetricSM=(gl_Position.z+depthValuesSM.x)/depthValuesSM.y+biasAndScaleSM.x;\n#endif\n#endif\n";Cn.a.IncludesShadersStore.shadowMapVertexMetric=Td;var Ed="\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n\n\n#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#endif\n#include\n#include<__decl__shadowMapVertex>\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\n#include\n#define CUSTOM_VERTEX_DEFINITIONS\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\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\n#include\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\n\ngl_Position=viewProjection*worldPos;\n#include\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\n}";Cn.a.ShadersStore.shadowMapVertexShader=Ed;var Sd="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\n#define CUSTOM_FRAGMENT_DEFINITIONS\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}";Cn.a.ShadersStore.depthBoxBlurPixelShader=Sd;var Ad="#if SM_SOFTTRANSPARENTSHADOW == 1\nif ((bayerDither8(floor(mod(gl_FragCoord.xy,8.0))))/64.0>=softTransparentShadowSM*alpha) discard;\n#endif\n";Cn.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow=Ad;var xd=function(){function e(t,n,i){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=n,this._scene=n.getScene(),n._shadowGenerator=this,this.id=n.id,this._useUBO=this._scene.getEngine().supportsUniformBuffers,this._useUBO&&(this._sceneUBOs=[],this._sceneUBOs.push(this._scene.createSceneUniformBuffer('Scene for Shadow Generator (light "'.concat(this._light.name,'")')))),e._SceneComponentInitialization(this._scene);var r=this._scene.getEngine().getCaps();i?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||this._scene.getEngine()._features.supportShadowSamplers?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 n=this._validateFilter(e.FILTER_POISSONSAMPLING);(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_EXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_BLUREXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_CLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){var n=this._validateFilter(e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP);(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?n:e.FILTER_NONE)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){var n=this._validateFilter(e.FILTER_PCF);(t||this.filter===e.FILTER_PCF)&&(this.filter=t?n: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 n=this._validateFilter(e.FILTER_PCSS);(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?n: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){if(void 0===t&&(t=!0),!this._shadowMap)return this;if(this._shadowMap.renderList||(this._shadowMap.renderList=[]),-1===this._shadowMap.renderList.indexOf(e)&&this._shadowMap.renderList.push(e),t)for(var n=0,i=e.getChildMeshes();n=a.length)return void(e&&e(n));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(n){t.forceCompilation((function(){n()}),e)}))},e.prototype._isReadyCustomDefines=function(e,t,n){},e.prototype._prepareShadowDefines=function(e,t,n,i){n.push("#define SM_FLOAT "+(this._textureType!==g.a.TEXTURETYPE_UNSIGNED_INT?"1":"0")),n.push("#define SM_ESM "+(this.useExponentialShadowMap||this.useBlurExponentialShadowMap?"1":"0")),n.push("#define SM_DEPTHTEXTURE "+(this.usePercentageCloserFiltering||this.useContactHardeningShadow?"1":"0"));var r=e.getMesh();return n.push("#define SM_NORMALBIAS "+(this.normalBias&&r.isVerticesDataPresent(bt.b.NormalKind)?"1":"0")),n.push("#define SM_DIRECTIONINLIGHTDATA "+(this.getLight().getTypeID()===Tc.a.LIGHTTYPEID_DIRECTIONALLIGHT?"1":"0")),n.push("#define SM_USEDISTANCE "+(this._light.needCube()?"1":"0")),n.push("#define SM_SOFTTRANSPARENTSHADOW "+(this.enableSoftTransparentShadow&&i?"1":"0")),this._isReadyCustomDefines(n,e,t),n},e.prototype.isReady=function(e,t,n){var i=e.getMaterial(),r=null==i?void 0:i.shadowDepthWrapper,o=[];if(this._prepareShadowDefines(e,t,o,n),r){if(!r.isReadyForSubMesh(e,o,this,t,this._scene.getEngine().currentRenderPassId))return!1}else{var a=e._getDrawWrapper(void 0,!0),s=a.effect,c=a.defines,u=[bt.b.PositionKind],l=e.getMesh();if(this.normalBias&&l.isVerticesDataPresent(bt.b.NormalKind)&&(u.push(bt.b.NormalKind),o.push("#define NORMAL"),l.nonUniformScaling&&o.push("#define NONUNIFORMSCALING")),i&&i.needAlphaTesting()){var h=i.getAlphaTestTexture();if(h){if(!h.isReady())return!1;o.push("#define ALPHATEST"),l.isVerticesDataPresent(bt.b.UVKind)&&(u.push(bt.b.UVKind),o.push("#define UV1")),l.isVerticesDataPresent(bt.b.UV2Kind)&&1===h.coordinatesIndex&&(u.push(bt.b.UV2Kind),o.push("#define UV2"))}}var d=new Qc.a;if(l.useBones&&l.computeBonesUsingShaders&&l.skeleton){u.push(bt.b.MatricesIndicesKind),u.push(bt.b.MatricesWeightsKind),l.numBoneInfluencers>4&&(u.push(bt.b.MatricesIndicesExtraKind),u.push(bt.b.MatricesWeightsExtraKind));var p=l.skeleton;o.push("#define NUM_BONE_INFLUENCERS "+l.numBoneInfluencers),l.numBoneInfluencers>0&&d.addCPUSkinningFallback(0,l),p.isUsingTextureForMatrices?o.push("#define BONETEXTURE"):o.push("#define BonesPerMesh "+(p.bones.length+1))}else o.push("#define NUM_BONE_INFLUENCERS 0");var f=l.morphTargetManager,_=0;f&&f.numInfluencers>0&&(o.push("#define MORPHTARGETS"),_=f.numInfluencers,o.push("#define NUM_MORPH_INFLUENCERS "+_),f.isUsingTextureForTargets&&o.push("#define MORPHTARGETS_TEXTURE"),kc.a.PrepareAttributesForMorphTargetsInfluencers(u,l,_));var m=this._scene;if(m.clipPlane&&o.push("#define CLIPPLANE"),m.clipPlane2&&o.push("#define CLIPPLANE2"),m.clipPlane3&&o.push("#define CLIPPLANE3"),m.clipPlane4&&o.push("#define CLIPPLANE4"),m.clipPlane5&&o.push("#define CLIPPLANE5"),m.clipPlane6&&o.push("#define CLIPPLANE6"),t&&(o.push("#define INSTANCES"),kc.a.PushAttributesForInstances(u),e.getRenderingMesh().hasThinInstances&&o.push("#define THIN_INSTANCES")),this.customShaderOptions&&this.customShaderOptions.defines)for(var g=0,v=this.customShaderOptions.defines;g4&&(c.push(bt.b.MatricesIndicesExtraKind),c.push(bt.b.MatricesWeightsExtraKind)),s.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),s.push("#define BonesPerMesh "+(r.skeleton?r.skeleton.bones.length+1:0));var u=e.getRenderingMesh().skeleton;(null==u?void 0:u.isUsingTextureForMatrices)&&s.push("#define BONETEXTURE")}else s.push("#define NUM_BONE_INFLUENCERS 0");var l=r.morphTargetManager,h=0;l&&l.numInfluencers>0&&(h=l.numInfluencers,s.push("#define MORPHTARGETS"),s.push("#define NUM_MORPH_INFLUENCERS "+h),l.isUsingTextureForTargets&&s.push("#define MORPHTARGETS_TEXTURE"),kc.a.PrepareAttributesForMorphTargetsInfluencers(c,r,h)),t&&(s.push("#define INSTANCES"),kc.a.PushAttributesForInstances(c),e.getRenderingMesh().hasThinInstances&&s.push("#define THIN_INSTANCES")),this._storeNonLinearDepth&&s.push("#define NONLINEARDEPTH"),this.isPacked&&s.push("#define PACKED");var d=e._getDrawWrapper(void 0,!0),p=d.defines,f=s.join("\n");return p!==f&&d.setEffect(i.createEffect("depth",c,["world","mBones","boneTextureWidth","viewProjection","diffuseMatrix","depthValues","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"],["diffuseSampler","morphTargets","boneSampler"],f,void 0,void 0,void 0,{maxSimultaneousMorphTargets:h}),f),d.effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){var e=[];for(var t in this._scene._depthRenderer){this._scene._depthRenderer[t]===this&&e.push(t)}if(e.length>0){this._depthMap.dispose();for(var n=0,i=e;n1||c>1;){s=Math.max(Math.round(s/2),1),c=Math.max(Math.round(c/2),1);var l=new Dn("Reduction phase "+u,"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"),n,void 0,void 0,void 0,g.a.TEXTUREFORMAT_RG);if(l.autoClear=!1,l.forceFullscreenViewport=i,l.onApply=function(e,t){return function(n){1==e||1==t?n.setInt2("texSize",e,t):n.setFloat2("texSize",e,t)}}(s,c),this._reductionSteps.push(l),u++,1==s&&1==c){l.onAfterRenderObservable.add(function(e,t,n){var i=new Float32Array(4*e*t),a={min:0,max:0};return function(){o.getEngine()._readTexturePixels(n.inputTexture.texture,e,t,-1,0,i,!1),a.min=i[0],a.max=i[1],r.onAfterReductionPerformed.notifyObservers(a)}}(s,c,l))}}}},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(){var t,n,i=e._camera.getScene().getEngine();null===(t=i._debugPushGroup)||void 0===t||t.call(i,"min max reduction",1),e._reductionSteps[0].activate(e._camera),e._postProcessManager.directRender(e._reductionSteps,e._reductionSteps[0].inputTexture,e._forceFullscreenViewport),i.unBindFramebuffer(e._reductionSteps[0].inputTexture,!1),null===(n=i._debugPopGroup)||void 0===n||n.call(i,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._onContextRestoredObserver&&(this._camera.getEngine().onContextRestoredObservable.remove(this._onContextRestoredObserver),this._onContextRestoredObserver=null)),this.deactivate(),this._reductionSteps){for(var t=0;tt&&(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=0&&ethis._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=0&&e=0&&e=i&&(n=0,i=1),n==t._minDistance&&i==t._maxDistance||t.setMinMaxDistance(n,i)})),this._depthReducer.setDepthRenderer(this._depthRenderer)),this._depthReducer.activate()}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"autoCalcDepthBoundsRefreshRate",{get:function(){var e,t,n;return null!==(n=null===(t=null===(e=this._depthReducer)||void 0===e?void 0:e.depthRenderer)||void 0===t?void 0:t.getDepthMap().refreshRate)&&void 0!==n?n:-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,n=e.maxZ,i=n-t,r=this._minDistance,o=t+r*i,a=t+(this._shadowMaxZ=t?Math.min((this._shadowMaxZ-t)/(n-t),this._maxDistance):this._maxDistance)*i,s=a-o,c=a/o,u=0;uMath.PI;)r-=2*Math.PI;var a=r/Math.PI,s=o/Math.PI;a=.5*a+.5;var c=Math.round(a*n);c<0?c=0:c>=n&&(c=n-1);var u=Math.round(s*i);u<0?u=0:u>=i&&(u=i-1);var l=i-u-1;return{r:t[l*n*3+3*c+0],g:t[l*n*3+3*c+1],b:t[l*n*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}(),Wd=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,n,i,r,o){r>0?(r=this.Ldexp(1,r-136),e[o+0]=t*r,e[o+1]=n*r,e[o+2]=i*r):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var n="",i="",r=t;r32767)throw"HDR Bad header format, unsupported size";return{height:t,width:n,dataPosition:a+=i.length+1}},e.GetCubeMapTextureData=function(e,t){var n=new Uint8Array(e),i=this.RGBE_ReadHeader(n),r=this.RGBE_ReadPixels(n,i);return jd.ConvertPanoramaToCubemap(r,i.width,i.height,t)},e.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},e.RGBE_ReadPixels_RLE=function(e,t){for(var n,i,r,o,a,s=t.height,c=t.width,u=t.dataPosition,l=0,h=0,d=0,p=new ArrayBuffer(4*c),f=new Uint8Array(p),_=new ArrayBuffer(t.width*t.height*4*3),m=new Float32Array(_);s>0;){if(n=e[u++],i=e[u++],r=e[u++],o=e[u++],2!=n||2!=i||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(l=0,d=0;d<4;d++)for(h=(d+1)*c;l128){if(0==(a=n-128)||a>h-l)throw"HDR Bad Format, bad scanline data (run)";for(;a-- >0;)f[l++]=i}else{if(0==(a=n)||a>h-l)throw"HDR Bad Format, bad scanline data (non-run)";if(f[l++]=i,--a>0)for(var g=0;g0;){for(a=0;a255){var m=255/_;d*=m,p*=m,f*=m}s[3*h+0]=d,s[3*h+1]=p,s[3*h+2]=f}c?a.push(c):s?a.push(s):a.push(l)}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,n=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(n)})))},t.prototype.dispose=function(){this.onLoadObservable.clear(),e.prototype.dispose.call(this)},t.Parse=function(e,n,i){var r=null;return e.name&&!e.isRenderTarget&&((r=new t(i+e.name,n,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}(Kr.a);Object(c.b)("BABYLON.HDRCubeTexture",qd);var Zd=function(){function e(e,t,n){void 0===t&&(t=0),void 0===n&&(n=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=n||P.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,n=F.a.Clone((function(){return new e(t.name,t.influence,t._scene)}),this);return n._positions=this._positions,n._normals=this._normals,n._tangents=this._tangents,n._uvs=this._uvs,n},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())),F.a.AppendSerializedAnimations(this,e),e},e.prototype.getClassName=function(){return"MorphTarget"},e.Parse=function(t,n){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 r=0;r0}}return Object.defineProperty(e.prototype,"areUpdatesFrozen",{get:function(){return this._blockCounter>0},set:function(e){e?this._blockCounter++:(this._blockCounter--,this._blockCounter<=0&&(this._blockCounter=0,this._syncActiveTargets(!0)))},enumerable:!1,configurable:!0}),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}),Object.defineProperty(e.prototype,"useTextureToStoreTargets",{get:function(){return this._useTextureToStoreTargets},set:function(e){this._useTextureToStoreTargets=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForTargets",{get:function(){return e.EnableTextureStorage&&this.useTextureToStoreTargets&&this._canUseTextureForTargets},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._bind=function(e){e.setFloat3("morphTargetTextureInfo",this._textureVertexStride,this._textureWidth,this._textureHeight),e.setFloatArray("morphTargetTextureIndices",this._morphTargetTextureIndices),e.setTexture("morphTargets",this._targetStoreTexture)},e.prototype.clone=function(){for(var t=new e(this._scene),n=0,i=this._targets;ne&&(this._textureHeight=Math.ceil(this._textureWidth/e),this._textureWidth=e);var t=!0;if(this._targetStoreTexture){var n=this._targetStoreTexture.getSize();n.width===this._textureWidth&&n.height===this._textureHeight&&this._targetStoreTexture.depth===this._targets.length&&(t=!1)}if(t){this._targetStoreTexture&&this._targetStoreTexture.dispose();for(var i=this._targets.length,r=new Float32Array(i*this._textureWidth*this._textureHeight*4),o=0,a=0;a-1&&this._parentContainer.morphTargetManagers.splice(e,1),this._parentContainer=null}},e.Parse=function(t,n){var i=new e(n);i._uniqueId=t.id;for(var r=0,o=t.targets;r-1&&(this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e))},e.prototype.addJoint=function(e,t,n){var i={mainImpostor:e,connectedImpostor:t,joint:n};n.physicsPlugin=this._physicsPlugin,this._joints.push(i),this._physicsPlugin.generateJoint(i)},e.prototype.removeJoint=function(e,t,n){var i=this._joints.filter((function(i){return i.connectedImpostor===t&&i.joint===n&&i.mainImpostor===e}));i.length&&this._physicsPlugin.removeJoint(i[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;t0&&(this._physicsBodysToRemoveAfterStep.forEach((function(t){"function"==typeof e.world.removeBody?e.world.removeBody(t):e.world.remove(t)})),this._physicsBodysToRemoveAfterStep=[])},e.prototype.applyImpulse=function(e,t,n){var i=new this.BJSCANNON.Vec3(n.x,n.y,n.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(r,i)},e.prototype.applyForce=function(e,t,n){var i=new this.BJSCANNON.Vec3(n.x,n.y,n.z),r=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(r,i)},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),n=e.physicsBody;n&&this.removePhysicsBody(e);var i=this._addMaterial("mat-"+e.uniqueId,e.getParam("friction"),e.getParam("restitution")),r={mass:e.getParam("mass"),material:i},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),"function"==typeof this.world.addBody?this.world.addBody(e.physicsBody):this.world.add(e.physicsBody),n&&["force","torque","velocity","angularVelocity"].forEach((function(t){var i=n[t];e.physicsBody[t].set(i.x,i.y,i.z)})),this._processChildMeshes(e)}this._updatePhysicsBodyTransformation(e)}},e.prototype._processChildMeshes=function(e){var t=this,n=e.object.getChildMeshes?e.object.getChildMeshes(!0):[],i=e.object.rotationQuaternion;if(i?i.conjugateToRef(this._tmpQuaternion):this._tmpQuaternion.set(0,0,0,1),n.length){var r=function(n){if(n.rotationQuaternion){var i=n.getPhysicsImpostor();if(i)if(i.parent!==e&&n.parent){var o=n.getAbsolutePosition().subtract(n.parent.getAbsolutePosition()),a=n.rotationQuaternion.multiply(t._tmpQuaternion);i.physicsBody&&(t.removePhysicsBody(i),i.physicsBody=null),i.parent=e,i.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(i),new t.BJSCANNON.Vec3(o.x,o.y,o.z),new t.BJSCANNON.Quaternion(a.x,a.y,a.z,a.w)),e.physicsBody.mass+=i.getParam("mass")}n.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(r)}};n.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,n=e.connectedImpostor.physicsBody;if(t&&n){var i,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 tp.e.HingeJoint:case tp.e.Hinge2Joint:i=new this.BJSCANNON.HingeConstraint(t,n,o);break;case tp.e.DistanceJoint:i=new this.BJSCANNON.DistanceConstraint(t,n,r.maxDistance||2);break;case tp.e.SpringJoint:var a=r;i=new this.BJSCANNON.Spring(t,n,{restLength:a.length,stiffness:a.stiffness,damping:a.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case tp.e.LockJoint:i=new this.BJSCANNON.LockConstraint(t,n,o);break;case tp.e.PointToPointJoint:case tp.e.BallAndSocketJoint:default:i=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,n,o.pivotB,o.maxForce)}i.collideConnected=!!r.collision,e.joint.physicsJoint=i,e.joint.type!==tp.e.SpringJoint?this.world.addConstraint(i):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){i.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==tp.e.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,n){var i,r;for(i=0;i1e3*n));s++);this.time+=i;for(var c=this.time%n/n,u=e,l=this.bodies,h=0;h!==l.length;h++){var d=l[h];d.type!==t.Body.STATIC&&d.sleepState!==t.Body.SLEEPING?(d.position.vsub(d.previousPosition,u),u.scale(c,u),d.position.vadd(u,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}();np.DefaultPluginFactory=function(){return new rp};var op=function(){function e(e,t,n){void 0===e&&(e=!0),void 0===n&&(n=OIMO),this._useDeltaForWorldStep=e,this.name="OimoJSPlugin",this._fixedTimeStep=1/60,this._tmpImpostorsArray=[],this._tmpPositionVector=a.e.Zero(),this.BJSOIMO=n,this.world=new this.BJSOIMO.World({iterations:t}),this.world.clear(),this._raycastResult=new ip}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 n=this;t.forEach((function(e){e.beforeStep()})),this.world.timeStep=this._useDeltaForWorldStep?e:this._fixedTimeStep,this.world.step(),t.forEach((function(e){e.afterStep(),n._tmpImpostorsArray[e.uniqueId]=e}));for(var i=this.world.contacts;null!==i;)if(!i.touching||i.body1.sleeping||i.body2.sleeping){var r=this._tmpImpostorsArray[+i.body1.name],o=this._tmpImpostorsArray[+i.body2.name];r&&o?(r.onCollide({body:o.physicsBody,point:null}),o.onCollide({body:r.physicsBody,point:null}),i=i.next):i=i.next}else i=i.next},e.prototype.applyImpulse=function(e,t,n){var i=e.physicsBody.mass;e.physicsBody.applyImpulse(n.scale(this.world.invScale),t.scale(this.world.invScale*i))},e.prototype.applyForce=function(e,t,n){m.a.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(e,t,n)},e.prototype.generatePhysicsBody=function(e){var t=this;if(e.parent)e.physicsBody&&(this.removePhysicsBody(e),e.forceUpdate());else{if(e.isBodyInitRequired()){var n={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},i=[e];(s=e.object).getChildMeshes&&s.getChildMeshes().forEach((function(e){e.physicsImpostor&&i.push(e.physicsImpostor)}));var r=function(e){return Math.max(e,np.Epsilon)},o=new a.b;i.forEach((function(i){if(i.object.rotationQuaternion){var a=i.object.rotationQuaternion;o.copyFrom(a),i.object.rotationQuaternion.set(0,0,0,1),i.object.computeWorldMatrix(!0);var s=o.toEulerAngles(),c=i.getObjectExtendSize();if(i===e){var u=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(u,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),n.pos.push(u.x),n.pos.push(u.y),n.pos.push(u.z),n.posShape.push(0,0,0),n.rotShape.push(0,0,0)}else{var l=i.object.position.clone();n.posShape.push(l.x),n.posShape.push(l.y),n.posShape.push(l.z),n.rotShape.push(57.29577951308232*s.x,57.29577951308232*s.y,57.29577951308232*s.z)}switch(i.object.rotationQuaternion.copyFrom(o),i.type){case ep.a.ParticleImpostor:m.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case ep.a.SphereImpostor:var h=c.x,d=c.y,p=c.z,f=Math.max(r(h),r(d),r(p))/2;n.type.push("sphere"),n.size.push(f),n.size.push(f),n.size.push(f);break;case ep.a.CylinderImpostor:var _=r(c.x)/2,g=r(c.y);n.type.push("cylinder"),n.size.push(_),n.size.push(g),n.size.push(g);break;case ep.a.PlaneImpostor:case ep.a.BoxImpostor:default:_=r(c.x),g=r(c.y);var v=r(c.z);n.type.push("box"),n.size.push(_),n.size.push(g),n.size.push(v)}i.object.rotationQuaternion=a}})),e.physicsBody=this.world.add(n),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,n=e.connectedImpostor.physicsBody;if(t&&n){var i,r=e.joint.jointData,o=r.nativeParams||{},a={body1:t,body2:n,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 tp.e.BallAndSocketJoint:i="jointBall";break;case tp.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 tp.e.DistanceJoint:i="jointDistance",a.max=r.maxDistance;break;case tp.e.PrismaticJoint:i="jointPrisme";break;case tp.e.SliderJoint:i="jointSlide";break;case tp.e.WheelJoint:i="jointWheel";break;case tp.e.HingeJoint:default:i="jointHinge"}a.type=i,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 n=e.physicsBody.getPosition();e.object.position.set(n.x,n.y,n.z)}if(e.object.rotationQuaternion){var i=e.physicsBody.getQuaternion();e.object.rotationQuaternion.set(i.x,i.y,i.z,i.w)}}},e.prototype.setPhysicsBodyTransformation=function(e,t,n){var i=e.physicsBody;e.physicsBody.shapes.next||(i.position.set(t.x,t.y,t.z),i.orientation.set(n.x,n.y,n.z,n.w),i.syncShapes(),i.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 n=0===t;e.physicsBody.shapes.density=n?1:t,e.physicsBody.setupMass(n?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,n){e.physicsJoint.limitMotor.upperLimit=t,void 0!==n&&(e.physicsJoint.limitMotor.lowerLimit=n)},e.prototype.setMotor=function(e,t,n,i){void 0!==n?m.a.Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter"):n=1e6,t*=-1;var r=i?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setMotor(t,n)},e.prototype.setLimit=function(e,t,n,i){var r=i?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;r&&r.setLimit(t,void 0===n?-t:n)},e.prototype.syncMeshWithImpostor=function(e,t){var n=t.physicsBody;e.position.x=n.position.x,e.position.y=n.position.y,e.position.z=n.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=n.orientation.x,e.rotationQuaternion.y=n.orientation.y,e.rotationQuaternion.z=n.orientation.z,e.rotationQuaternion.w=n.orientation.s)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var n=e.physicsBody.shapes;t.x=2*n.halfWidth,t.y=2*n.halfHeight,t.z=2*n.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}(),ap=n(114),sp=function(){function e(e,t,n){var i=this;void 0===e&&(e=!0),void 0===t&&(t=Ammo),void 0===n&&(n=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._tmpVec3=new a.e,this._tmpMatrix=new a.a,"function"!=typeof t?(this.bjsAMMO=t,this.isSupported()?(this._collisionConfiguration=new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,this._dispatcher=new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),this._overlappingPairCache=n||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,n,r){var o=(e=i.bjsAMMO.wrapPointer(e,i.bjsAMMO.btManifoldPoint)).getPositionWorldOnA();i._tmpContactPoint.x=o.x(),i._tmpContactPoint.y=o.y(),i._tmpContactPoint.z=o.z(),i._tmpContactCallbackResult=!0},this._raycastResult=new ip,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.")):m.a.Error("AmmoJS is not ready. Please make sure you await Ammo() before using the plugin.")}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,n){if(void 0===e&&(e=1/60),void 0===t&&(t=10),void 0===n&&(n=1/60),0==t)this.world.stepSimulation(e,0);else for(;t>0&&e>0;)e-n0&&this._isImpostorInContact(s))for(var c=0,u=s._onPhysicsCollideCallbacks;c3?3:s;var c=(new this.bjsAMMO.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,n-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,n){var i=this,r=0;if(n&&n.getIndices&&n.getWorldMatrix&&n.getChildMeshes){var o=n.getIndices();o||(o=[]);var s=n.getVerticesData(bt.b.PositionKind);s||(s=[]),n.computeWorldMatrix(!1);for(var c=o.length/3,u=0;u0){if(e.type!=ep.a.NoImpostor){var u=this._createShape(e,!0);u&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),i.addChildShape(this._tmpAmmoTransform,u))}return i}this.bjsAMMO.destroy(i),i=null}switch(e.type){case ep.a.SphereImpostor:if(L.a.WithinEpsilon(o.x,o.y,1e-4)&&L.a.WithinEpsilon(o.x,o.z,1e-4))i=new this.bjsAMMO.btSphereShape(o.x/2);else{var l=[new this.bjsAMMO.btVector3(0,0,0)];(i=new this.bjsAMMO.btMultiSphereShape(l,[1],1)).setLocalScaling(new this.bjsAMMO.btVector3(o.x/2,o.y/2,o.z/2))}break;case ep.a.CapsuleImpostor:var h=o.x/2;i=new this.bjsAMMO.btCapsuleShape(h,o.y-2*h);break;case ep.a.CylinderImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),i=new this.bjsAMMO.btCylinderShape(this._tmpAmmoVectorA);break;case ep.a.PlaneImpostor:case ep.a.BoxImpostor:this._tmpAmmoVectorA.setValue(o.x/2,o.y/2,o.z/2),i=new this.bjsAMMO.btBoxShape(this._tmpAmmoVectorA);break;case ep.a.MeshImpostor:if(0==e.getParam("mass")){if(this.onCreateCustomMeshImpostor)i=this.onCreateCustomMeshImpostor(e);else{var d=new this.bjsAMMO.btTriangleMesh;e._pluginData.toDispose.push(d);var p=this._addMeshVerts(d,r,r);i=0==p?new this.bjsAMMO.btCompoundShape:new this.bjsAMMO.btBvhTriangleMeshShape(d)}break}case ep.a.ConvexHullImpostor:if(this.onCreateCustomConvexHullImpostor)i=this.onCreateCustomConvexHullImpostor(e);else{var f=new this.bjsAMMO.btConvexHullShape;0==(p=this._addHullVerts(f,r,r))?(e._pluginData.toDispose.push(f),i=new this.bjsAMMO.btCompoundShape):i=f}break;case ep.a.NoImpostor:i=new this.bjsAMMO.btSphereShape(o.x/2);break;case ep.a.CustomImpostor:i=this._createCustom(e);break;case ep.a.SoftbodyImpostor:i=this._createSoftbody(e);break;case ep.a.ClothImpostor:i=this._createCloth(e);break;case ep.a.RopeImpostor:i=this._createRope(e);break;default:m.a.Warn("The impostor type is not currently supported by the ammo plugin.")}return i},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,n){var i=e.physicsBody.getWorldTransform();if(Math.abs(i.getOrigin().x()-t.x)>ht.a||Math.abs(i.getOrigin().y()-t.y)>ht.a||Math.abs(i.getOrigin().z()-t.z)>ht.a||Math.abs(i.getRotation().x()-n.x)>ht.a||Math.abs(i.getRotation().y()-n.y)>ht.a||Math.abs(i.getRotation().z()-n.z)>ht.a||Math.abs(i.getRotation().w()-n.w)>ht.a)if(this._tmpAmmoVectorA.setValue(t.x,t.y,t.z),i.setOrigin(this._tmpAmmoVectorA),this._tmpAmmoQuaternion.setValue(n.x,n.y,n.z,n.w),i.setRotation(this._tmpAmmoQuaternion),e.physicsBody.setWorldTransform(i),0==e.mass){var r=e.physicsBody.getMotionState();r&&r.setWorldTransform(i)}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 n=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),n},e.prototype.getAngularVelocity=function(e){if(e.soft)var t=e.physicsBody.angularVelocity();else t=e.physicsBody.getAngularVelocity();if(!t)return null;var n=new a.e(t.x(),t.y(),t.z());return this.bjsAMMO.destroy(t),n},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===ep.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,n,i,r,o){void 0===r&&(r=1),void 0===o&&(o=!1);var a=e.segments,s=Math.round((a-1)*n)+a*(a-1-Math.round((a-1)*i));e.physicsBody.appendAnchor(s,t.physicsBody,o,r)},e.prototype.appendHook=function(e,t,n,i,r){void 0===i&&(i=1),void 0===r&&(r=!1);var o=Math.round(e.segments*n);e.physicsBody.appendAnchor(o,t.physicsBody,r,i)},e.prototype.sleepBody=function(e){e.physicsBody.forceActivationState(0)},e.prototype.wakeUpBody=function(e){e.physicsBody.activate()},e.prototype.updateDistanceJoint=function(e,t,n){m.a.Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin")},e.prototype.setMotor=function(e,t,n,i){e.physicsJoint.enableAngularMotor(!0,t,n)},e.prototype.setLimit=function(e,t,n){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 n=e.getObjectExtendSize();t.x=n.x,t.y=n.y,t.z=n.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 n=new this.bjsAMMO.ClosestRayResultCallback(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB);return this.world.rayTest(this._tmpAmmoVectorRCA,this._tmpAmmoVectorRCB,n),this._raycastResult.reset(e,t),n.hasHit()&&(this._raycastResult.setHitData({x:n.get_m_hitNormalWorld().x(),y:n.get_m_hitNormalWorld().y(),z:n.get_m_hitNormalWorld().z()},{x:n.get_m_hitPointWorld().x(),y:n.get_m_hitPointWorld().y(),z:n.get_m_hitPointWorld().z()}),this._raycastResult.calculateHitDistance()),this.bjsAMMO.destroy(n),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}();i.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},i.a.prototype.addReflectionProbe=function(e){this.reflectionProbes||(this.reflectionProbes=[]),this.reflectionProbes.push(e)};var cp=function(){function e(e,t,n,i,r,o){var s=this;if(void 0===i&&(i=!0),void 0===r&&(r=!1),void 0===o&&(o=!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._parentContainer=null,this._scene=n,n.getEngine().supportsUniformBuffers){this._sceneUBOs=[];for(var c=0;c<6;++c)this._sceneUBOs.push(n.createSceneUniformBuffer('Scene for Reflection Probe (name "'.concat(e,'") face #').concat(c)))}this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this);var u=g.a.TEXTURETYPE_UNSIGNED_BYTE;if(r){var l=this._scene.getEngine().getCaps();l.textureHalfFloatRender?u=g.a.TEXTURETYPE_HALF_FLOAT:l.textureFloatRender&&(u=g.a.TEXTURETYPE_FLOAT)}this._renderTargetTexture=new ci(e,t,n,i,!0,u,!0),this._renderTargetTexture.gammaSpace=!o;var h,d=n.getEngine().useReverseDepthBuffer;this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(s._sceneUBOs&&(n.setSceneUniformBuffer(s._sceneUBOs[e]),n.getSceneUniformBuffer().unbindEffect()),e){case 0:s._add.copyFromFloats(1,0,0);break;case 1:s._add.copyFromFloats(-1,0,0);break;case 2:s._add.copyFromFloats(0,s._invertYAxis?1:-1,0);break;case 3:s._add.copyFromFloats(0,s._invertYAxis?-1:1,0);break;case 4:s._add.copyFromFloats(0,0,n.useRightHandedSystem?-1:1);break;case 5:s._add.copyFromFloats(0,0,n.useRightHandedSystem?1:-1)}s._attachedMesh&&s.position.copyFrom(s._attachedMesh.getAbsolutePosition()),s.position.addToRef(s._add,s._target);var t=n.useRightHandedSystem?a.a.LookAtRHToRef:a.a.LookAtLHToRef,i=n.useRightHandedSystem?a.a.PerspectiveFovRH:a.a.PerspectiveFovLH;t(s.position,s._target,a.e.Up(),s._viewMatrix),n.activeCamera&&(s._projectionMatrix=i(Math.PI/2,1,d?n.activeCamera.maxZ:n.activeCamera.minZ,d?n.activeCamera.minZ:n.activeCamera.maxZ,s._scene.getEngine().isNDCHalfZRange),n.setTransformMatrix(s._viewMatrix,s._projectionMatrix),n.activeCamera.isRigCamera&&!s._renderTargetTexture.activeCamera&&(s._renderTargetTexture.activeCamera=n.activeCamera.rigParent||null)),n._forcedViewPosition=s.position})),this._renderTargetTexture.onBeforeBindObservable.add((function(){var t,i;s._currentSceneUBO=n.getSceneUniformBuffer(),null===(i=(t=n.getEngine())._debugPushGroup)||void 0===i||i.call(t,"reflection probe generation for ".concat(e),1),h=s._scene.imageProcessingConfiguration.applyByPostProcess,o&&(n.imageProcessingConfiguration.applyByPostProcess=!0)})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){var e,t;n.imageProcessingConfiguration.applyByPostProcess=h,n._forcedViewPosition=null,s._sceneUBOs&&n.setSceneUniformBuffer(s._currentSceneUBO),n.updateTransformMatrix(!0),null===(t=(e=n.getEngine())._debugPopGroup)||void 0===t||t.call(e,1)}))}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);if(-1!==e&&this._scene.reflectionProbes.splice(e,1),this._parentContainer){var t=this._parentContainer.reflectionProbes.indexOf(this);t>-1&&this._parentContainer.reflectionProbes.splice(t,1),this._parentContainer=null}if(this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null),this._sceneUBOs){for(var n=0,i=this._sceneUBOs;n0){var i=t._waitingData.lods.ids,r=n.isEnabled(!1);if(t._waitingData.lods.distances){var o=t._waitingData.lods.distances;if(o.length>=i.length){var a=o.length>i.length?o[o.length-1]:0;n.setEnabled(!1);for(var s=0;s0&&n.addLODLevel(a,null),!0===r&&n.setEnabled(!0)}else Re.b.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},mp=function(e,t){return"number"!=typeof e?t.getLastEntryById(e):hp[e]},gp=function(e,t){return"number"!=typeof e?t.getLastMaterialById(e,!0):dp[e]},vp=function(e,t,n,r,o){void 0===o&&(o=!1);var a=new Ae(e),s="importScene has failed JSON parse";try{var u=JSON.parse(t);s="";var l,h,d=Xs.loggingLevel===Xs.DETAILED_LOGGING;if(void 0!==u.environmentTexture&&null!==u.environmentTexture){var p=void 0===u.isPBR||u.isPBR;if(u.environmentTextureType&&"BABYLON.HDRCubeTexture"===u.environmentTextureType){var f=u.environmentTextureSize?u.environmentTextureSize:128,_=new qd((u.environmentTexture.match(/https?:\/\//g)?"":n)+u.environmentTexture,e,f,!0,!p);u.environmentTextureRotationY&&(_.rotationY=u.environmentTextureRotationY),e.environmentTexture=_}else if(Object(Ke.e)(u.environmentTexture,".env")){var g=new Vc((u.environmentTexture.match(/https?:\/\//g)?"":n)+u.environmentTexture,e);u.environmentTextureRotationY&&(g.rotationY=u.environmentTextureRotationY),e.environmentTexture=g}else{var v=Vc.CreateFromPrefilteredData((u.environmentTexture.match(/https?:\/\//g)?"":n)+u.environmentTexture,e);u.environmentTextureRotationY&&(v.rotationY=u.environmentTextureRotationY),e.environmentTexture=v}if(!0===u.createDefaultSkybox){var b=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,y=u.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,p,b,y)}a.environmentTexture=e.environmentTexture}if(void 0!==u.environmentIntensity&&null!==u.environmentIntensity&&(e.environmentIntensity=u.environmentIntensity),void 0!==u.lights&&null!==u.lights)for(l=0,h=u.lights.length;l0){for(var se=0;se0){for(var ue=0;ue-1&&void 0!==h.skeletons&&null!==h.skeletons&&!(O.indexOf(b.skeletonId)>-1))for(var f=0,_=h.skeletons.length;f<_;f++)(A=h.skeletons[f]).id===b.skeletonId&&(U=vt.Parse(A,t),s.push(U),O.push(A.id),l+="\n\tSkeleton "+U.toString(d));if(b.morphTargetManagerId>-1&&void 0!==h.morphTargetManagers&&null!==h.morphTargetManagers&&!(D.indexOf(b.morphTargetManagerId)>-1))for(var v=0,P=h.morphTargetManagers.length;v-1&&f.splice(F,1)}P._waitingParentId=null}P._waitingData.lods&&_p(t,P)}for(var w=0,B=f;w0&&(f+1)%4==0)a[f]=255;else{var T=s[f];a[f]=T/p*255}e.is3D?(e.updateSize(u,u,u),i.updateRawTexture3D(e,a,g.a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(u*u,u),i.updateRawTexture(e,a,g.a.TEXTUREFORMAT_RGBA,!1)),e.isReady=!0,n._triggerOnLoad()}},o=this.getScene();return o?o._loadFile(this.url,r):i._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,n){var i=null;return e.name&&!e.isRenderTarget&&((i=new t(e.name,n)).name=e.name,i.level=e.level),i},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}(Kr.a);Object(c.b)("BABYLON.ColorGradingTexture",Rp);var Cp=function(e){function t(t,n,i,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,n)||this;if(c._onLoad=null,c._onError=null,!t)throw new Error("Image url is not set");return c._coordinatesMode=Be.a.CUBIC_MODE,c.name=t,c.url=t,c._size=i,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?Re.b.SetImmediate((function(){return a()})):c._texture.onLoadedObservable.add(a)):n.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 n=this,i=document.createElement("canvas");Object(Lr.h)(this.url,(function(t){n._width=t.width,n._height=t.height,i.width=n._width,i.height=n._height;var r=i.getContext("2d");r.drawImage(t,0,0);var o=r.getImageData(0,0,t.width,t.height);n._buffer=o.data.buffer,i.remove(),e()}),(function(e,i){t&&t("".concat(n.getClassName()," could not be loaded"),i)}),null)},t.prototype.loadTexture=function(){var e=this,n=this.getScene();n&&(this._texture=n.getEngine().createRawCubeTextureFromUrl(this.url,n,this._size,g.a.TEXTUREFORMAT_RGB,n.getEngine().getCaps().textureFloat?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_UNSIGNED_INTEGER,this._noMipmap,(function(){for(var n=e.getFloat32ArrayFromArrayBuffer(e._buffer),i=jd.ConvertPanoramaToCubemap(n,e._width,e._height,e._size),r=[],o=0;o<6;o++){var a=i[t._FacesMapping[o]];r.push(a)}return r}),null,this._onLoad,this._onError))},t.prototype.getFloat32ArrayFromArrayBuffer=function(e){for(var t=new DataView(e),n=new Float32Array(3*e.byteLength/4),i=0,r=0;rt.length)m.a.Error("Unable to load TGA file - Not enough data");else{n+=i.id_length;var r,o=!1,a=!1,s=!1;switch(i.image_type){case 9:o=!0;case 1:a=!0;break;case 10:o=!0;case 2:break;case 11:o=!0;case 3:s=!0}var c,u,l,h,d,p,f,_=i.pixel_size>>3,g=i.width*i.height*_;if(a&&(c=t.subarray(n,n+=i.colormap_length*(i.colormap_size>>3))),o){var v,b,y;r=new Uint8Array(g);for(var T=0,E=new Uint8Array(_);n>4){default:case 2:u=0,h=1,f=i.width,l=0,d=1,p=i.height;break;case 0:u=0,h=1,f=i.width,l=i.height-1,d=-1,p=-1;break;case 3:u=i.width-1,h=-1,f=-1,l=0,d=1,p=i.height;break;case 1:u=i.width-1,h=-1,f=-1,l=i.height-1,d=-1,p=-1}var S="_getImageData"+(s?"Grey":"")+i.pixel_size+"bits",A=Ip[S](i,c,r,l,d,p,u,h,f);e.getEngine()._uploadDataToTextureDirectly(e,A)}}}var Ip={GetTGAHeader:Op,UploadContent:Mp,_getImageData8bits:function(e,t,n,i,r,o,a,s,c){var u,l,h,d=n,p=t,f=e.width,_=e.height,m=0,g=new Uint8Array(f*_*4);for(h=i;h!==o;h+=r)for(l=a;l!==c;l+=s,m++)u=d[m],g[4*(l+f*h)+3]=255,g[4*(l+f*h)+2]=p[3*u+0],g[4*(l+f*h)+1]=p[3*u+1],g[4*(l+f*h)+0]=p[3*u+2];return g},_getImageData16bits:function(e,t,n,i,r,o,a,s,c){var u,l,h,d=n,p=e.width,f=e.height,_=0,m=new Uint8Array(p*f*4);for(h=i;h!==o;h+=r)for(l=a;l!==c;l+=s,_+=2){var g=255*((31744&(u=d[_+0]+(d[_+1]<<8)))>>10)/31|0,v=255*((992&u)>>5)/31|0,b=255*(31&u)/31|0;m[4*(l+p*h)+0]=g,m[4*(l+p*h)+1]=v,m[4*(l+p*h)+2]=b,m[4*(l+p*h)+3]=32768&u?0:255}return m},_getImageData24bits:function(e,t,n,i,r,o,a,s,c){var u,l,h=n,d=e.width,p=e.height,f=0,_=new Uint8Array(d*p*4);for(l=i;l!==o;l+=r)for(u=a;u!==c;u+=s,f+=3)_[4*(u+d*l)+3]=255,_[4*(u+d*l)+2]=h[f+0],_[4*(u+d*l)+1]=h[f+1],_[4*(u+d*l)+0]=h[f+2];return _},_getImageData32bits:function(e,t,n,i,r,o,a,s,c){var u,l,h=n,d=e.width,p=e.height,f=0,_=new Uint8Array(d*p*4);for(l=i;l!==o;l+=r)for(u=a;u!==c;u+=s,f+=4)_[4*(u+d*l)+2]=h[f+0],_[4*(u+d*l)+1]=h[f+1],_[4*(u+d*l)+0]=h[f+2],_[4*(u+d*l)+3]=h[f+3];return _},_getImageDataGrey8bits:function(e,t,n,i,r,o,a,s,c){var u,l,h,d=n,p=e.width,f=e.height,_=0,m=new Uint8Array(p*f*4);for(h=i;h!==o;h+=r)for(l=a;l!==c;l+=s,_++)u=d[_],m[4*(l+p*h)+0]=u,m[4*(l+p*h)+1]=u,m[4*(l+p*h)+2]=u,m[4*(l+p*h)+3]=255;return m},_getImageDataGrey16bits:function(e,t,n,i,r,o,a,s,c){var u,l,h=n,d=e.width,p=e.height,f=0,_=new Uint8Array(d*p*4);for(l=i;l!==o;l+=r)for(u=a;u!==c;u+=s,f+=2)_[4*(u+d*l)+0]=h[f+0],_[4*(u+d*l)+1]=h[f+0],_[4*(u+d*l)+2]=h[f+0],_[4*(u+d*l)+3]=h[f+1];return _}},Dp=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Object(Ke.e)(e,".tga")},e.prototype.loadCubeData=function(e,t,n,i,r){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,n){var i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=Op(i);n(r.width,r.height,t.generateMipMaps,!1,(function(){Mp(t,i)}))},e}();xe.a._TextureLoaders.push(new Dp);var Np=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e){return Object(Ke.e)(e,".hdr")},e.prototype.loadCubeData=function(e,t,n,i,r){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,n){for(var i=new Uint8Array(e.buffer,e.byteOffset,e.byteLength),r=Wd.RGBE_ReadHeader(i),o=Wd.RGBE_ReadPixels(i,r),a=r.width*r.height,s=new Float32Array(4*a),c=0;c1,t.fileInfo.images[o].levels.forEach((function(n,r){i._uploadCompressedDataToTextureDirectly(e,jp.GetInternalFormatFromBasisFormat(t.format,i),n.width,n.height,n.transcodedPixels,o,r)})),!i._features.basisNeedsPOT||L.a.Log2(e.width)%1==0&&L.a.Log2(e.height)%1==0||(Re.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."),e._cachedWrapU=Be.a.CLAMP_ADDRESSMODE,e._cachedWrapV=Be.a.CLAMP_ADDRESSMODE)},o=0;o>2&3],o[p++]=r[d>>4&3],o[p++]=r[d>>6&3]}}return o}(a,0,e.getImageWidth(t,n)+3&-4,e.getImageHeight(t,n)+3&-4));return a}onmessage=function(a){if("init"===a.data.action){if(!r){Module={wasmBinary:a.data.wasmBinary};try{importScripts(a.data.url)}catch(e){postMessage({action:"error",error:e})}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,u=new Module.BasisFile(c),l=function(e){for(var t=e.getHasAlpha(),n=e.getNumImages(),i=[],r=0;r1&&t.generateMipMaps;zp(t,e),t.getEngine()._setCubeMapTextureParams(t,n),t.isReady=!0,t.onLoadedObservable.notifyObservers(t),t.onLoadedObservable.clear(),i&&i()})).catch((function(e){Re.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),t.isReady=!0,r&&r(e)}))}},e.prototype.loadData=function(e,t,n){var i=t.getEngine().getCaps(),r={supportedCompressionFormats:{etc1:!!i.etc1,s3tc:!!i.s3tc,pvrtc:!!i.pvrtc,etc2:!!i.etc2}};Gp(e,r).then((function(e){var i=e.fileInfo.images[0].levels[0],r=e.fileInfo.images[0].levels.length>1&&t.generateMipMaps;n(i.width,i.height,r,-1!==e.format,(function(){zp(t,e)}))})).catch((function(e){Re.b.Warn("Failed to transcode Basis file, transcoding may not be supported on this device"),n(0,0,!1,!1,(function(){}),!0)}))},e}();xe.a._TextureLoaders.push(new Hp);var Xp=function(e){function t(t,n,i,r,o,a){var s=this,c=!(!o||!o.generateMipMaps)&&o.generateMipMaps,u=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,l=o&&o.depthTextureFormat?o.depthTextureFormat:g.a.TEXTUREFORMAT_DEPTH16,h=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio,d=!(!o||!o.drawOnlyOnFirstAttachmentByDefault)&&o.drawOnlyOnFirstAttachmentByDefault;if((s=e.call(this,t,n,r,c,h,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0)||this).isSupported){var p=[],f=[];s._initTypes(i,p,f,o);var _=!o||void 0===o.generateDepthBuffer||o.generateDepthBuffer,m=!(!o||void 0===o.generateStencilBuffer)&&o.generateStencilBuffer;return s._size=n,s._multiRenderTargetOptions={samplingModes:f,generateMipMaps:c,generateDepthBuffer:_,generateStencilBuffer:m,generateDepthTexture:u,depthTextureFormat:l,types:p,textureCount:i},s._count=i,s._drawOnlyOnFirstAttachmentByDefault=d,i>0&&(s._createInternalTextures(),s._createTextures(a)),s}s.dispose()}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"isSupported",{get:function(){var e,t;return null!==(t=null===(e=this._engine)||void 0===e?void 0:e.getCaps().drawBuffersExtension)&&void 0!==t&&t},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=0;i--)this._textures[i]._texture=null;null===(t=this._renderTarget)||void 0===t||t.dispose(),this._renderTarget=null}},t}(ci),Yp=function(e,t,n){this.id=e,this.scale=t,this.offset=n},Kp=function(){function e(t,n,i,r){var o,a,c,u,l,h,d,p,f,_,m,g,v;return this.name=t,this.meshes=n,this.scene=r,this.options=i,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:bt.b.UVKind,this.options.uvsOut=null!==(c=this.options.uvsOut)&&void 0!==c?c:bt.b.UVKind,this.options.layout=null!==(u=this.options.layout)&&void 0!==u?u:e.LAYOUT_STRIP,this.options.layout===e.LAYOUT_COLNUM&&(this.options.colnum=null!==(l=this.options.colnum)&&void 0!==l?l: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===(p=this.options.fillBlanks)||void 0===p||p,!0===this.options.fillBlanks&&(this.options.customFillColor=null!==(f=this.options.customFillColor)&&void 0!==f?f:"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,n=this._calculateSize(),i=new a.d(1,1).divide(n),r=0,o=this._expecting,c=this.meshes.length,u=Object.keys(this.sets),l=0;l0)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){n()}else n()}),!1),r.addEventListener("error",(function(){n()}),!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 n=this.getScene();this._animate&&n&&(this._time+=.03*n.getAnimationRatio(),this.updateShaderUniforms()),e.prototype.render.call(this,t)},t.prototype.updateTextures=function(){for(var e=0;e0&&(kc.a.BindMorphTargetParameters(n,e),n.morphTargetManager.isUsingTextureForTargets&&n.morphTargetManager._bind(e))},t.prototype.replaceRepeatableContent=function(e,t,n,i){var r=this.position,o=this.normal,a=this.tangent,s=this.uv,c=this.positionOutput,u=this.normalOutput,l=this.tangentOutput,h=this.uvOutput,d=e,p=i.NUM_MORPH_INFLUENCERS,f=n.morphTargetManager,_=f&&f.supportsNormals&&i.NORMAL,m=f&&f.supportsTangents&&i.TANGENT,g=f&&f.supportsUVs&&i.UV1,v="";(null==f?void 0:f.isUsingTextureForTargets)&&p>0&&(v+="float vertexID;\r\n");for(var b=0;b0)for(b=0;b\(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump\)/g,replace:""},{search:/uniform sampler2D bumpSampler;/g,replace:""},{search:/vec2 parallaxOcclusion\(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale\)/g,replace:"#define inline\r\nvec2 parallaxOcclusion(vec3 vViewDirCoT, vec3 vNormalCoT, vec2 texCoord, float parallaxScale, sampler2D bumpSampler)"},{search:/vec2 parallaxOffset\(vec3 viewDir,float heightScale\)/g,replace:"vec2 parallaxOffset(vec3 viewDir, float heightScale, float height_)"},{search:/texture2D\(bumpSampler,vBumpUV\)\.w/g,replace:"height_"}]});var d=c&&s?"texture2D(".concat(s,", ").concat(i.associatedVariableName," + uvOffset).xyz"):this.normalMapColor.associatedVariableName;return t.compilationString+=this._declareOutput(this.output,t)+" = vec4(0.);\r\n",t.compilationString+=t._emitCodeFromInclude("bumpFragment",n,{replaceStrings:[{search:/perturbNormal\(TBN,texture2D\(bumpSampler,vBumpUV\+uvOffset\).xyz,vBumpInfos.y\)/g,replace:"perturbNormal(TBN, ".concat(d,", vBumpInfos.y)")},{search:/parallaxOcclusion\(invTBN\*-viewDirectionW,invTBN\*normalW,vBumpUV,vBumpInfos.z\)/g,replace:"parallaxOcclusion((invTBN * -viewDirectionW), (invTBN * normalW), vBumpUV, vBumpInfos.z, ".concat(c&&this.useParallaxOcclusion?s:"bumpSampler",")")},{search:/parallaxOffset\(invTBN\*viewDirectionW,vBumpInfos\.z\)/g,replace:"parallaxOffset(invTBN * viewDirectionW, vBumpInfos.z, ".concat(c?this.parallaxHeight.associatedVariableName:"0.",")")},{search:/vTangentSpaceParams/g,replace:this._tangentSpaceParameterName},{search:/vBumpInfos.y/g,replace:l},{search:/vBumpInfos.z/g,replace:u},{search:/vBumpUV/g,replace:i.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"},{search:/viewDirectionW/g,replace:c?this.viewDirection.associatedVariableName:"vec3(0.)"},h]}),this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".invertX = ").concat(this.invertX,";\r\n");return t+="".concat(this._codeVariableName,".invertY = ").concat(this.invertY,";\r\n"),t+="".concat(this._codeVariableName,".useParallaxOcclusion = ").concat(this.useParallaxOcclusion,";\r\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.invertX=this.invertX,t.invertY=this.invertY,t.useParallaxOcclusion=this.useParallaxOcclusion,t},t.prototype._deserialize=function(t,n,i){e.prototype._deserialize.call(this,t,n,i),this.invertX=t.invertX,this.invertY=t.invertY,this.useParallaxOcclusion=!!t.useParallaxOcclusion},Object(h.c)([Xl("Invert X axis",Wl.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertX",void 0),Object(h.c)([Xl("Invert Y axis",Wl.Boolean,"PROPERTIES",{notifiers:{update:!1}})],t.prototype,"invertY",void 0),Object(h.c)([Xl("Use parallax occlusion",Wl.Boolean)],t.prototype,"useParallaxOcclusion",void 0),t}(zl);Object(c.b)("BABYLON.PerturbNormalBlock",uf);var lf=function(e){function t(t){var n=e.call(this,t,Il.Fragment,!0)||this;return n.registerInput("value",Ml.Float,!0),n.registerInput("cutoff",Ml.Float,!0),n}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 (".concat(this.value.associatedVariableName," < ").concat(this.cutoff.associatedVariableName,") discard;\r\n"),this},t}(zl);Object(c.b)("BABYLON.DiscardBlock",lf);var hf=function(e){function t(t){var n=e.call(this,t,Il.Fragment)||this;return n.registerOutput("output",Ml.Float,Il.Fragment),n}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===Il.Vertex)throw"FrontFacingBlock must only be used in a fragment shader";var n=this._outputs[0];return t.compilationString+=this._declareOutput(n,t)+" = gl_FrontFacing ? 1.0 : 0.0;\r\n",this},t}(zl);Object(c.b)("BABYLON.FrontFacingBlock",hf);var df=function(e){function t(t){var n=e.call(this,t,Il.Fragment)||this;return n.registerInput("input",Ml.AutoDetect,!1),n.registerOutput("dx",Ml.BasedOnInput),n.registerOutput("dy",Ml.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n._outputs[1]._typeConnectionSource=n._inputs[0],n}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 n=this._outputs[0],i=this._outputs[1];return t._emitExtension("derivatives","#extension GL_OES_standard_derivatives : enable"),n.hasEndpoints&&(t.compilationString+=this._declareOutput(n,t)+" = dFdx(".concat(this.input.associatedVariableName,");\r\n")),i.hasEndpoints&&(t.compilationString+=this._declareOutput(i,t)+" = dFdy(".concat(this.input.associatedVariableName,");\r\n")),this},t}(zl);Object(c.b)("BABYLON.DerivativeBlock",df);var pf=function(e){function t(t){var n=e.call(this,t,Il.Fragment)||this;return n.registerOutput("xy",Ml.Vector2,Il.Fragment),n.registerOutput("xyz",Ml.Vector3,Il.Fragment),n.registerOutput("xyzw",Ml.Vector4,Il.Fragment),n.registerOutput("x",Ml.Float,Il.Fragment),n.registerOutput("y",Ml.Float,Il.Fragment),n.registerOutput("z",Ml.Float,Il.Fragment),n.registerOutput("w",Ml.Float,Il.Fragment),n}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="",n=0,i=this._outputs;n=0;kc.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,n["PROJECTEDLIGHTTEXTURE"+r],i,o)}},t.prototype.bind=function(e,t,n){if(n){var i=n.getScene();this.light?kc.a.BindLight(this.light,this._lightId,i,e,!0):kc.a.BindLights(i,n,e,!0,t.maxSimultaneousLights)}},t.prototype._injectVertexCode=function(e){var t=this.worldPosition,n="//".concat(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?"lightVxUboDeclaration":"lightVxFragmentDeclaration",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",n,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var i="v_"+t.associatedVariableName;e._emitVaryingFromString(i,"vec4")&&(e.compilationString+="".concat(i," = ").concat(t.associatedVariableName,";\r\n")),this.light?e.compilationString+=e._emitCodeFromInclude("shadowsVertex",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()},{search:/worldPos/g,replace:t.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = ".concat(t.associatedVariableName,";\r\n"),this.view.isConnected&&(e.compilationString+="mat4 view = ".concat(this.view.associatedVariableName,";\r\n")),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",n,{repeatKey:"maxSimultaneousLights"}))},t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),t.target===Il.Fragment){t.sharedData.forcedBindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this);var n="//".concat(this.name),i=this.worldPosition;t._emitFunctionFromInclude("helperFunctions",n),t._emitFunctionFromInclude("lightsFragmentFunctions",n,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+i.associatedVariableName+".xyz"}]}),t._emitFunctionFromInclude("shadowsFragmentFunctions",n,{replaceStrings:[{search:/vPositionW/g,replace:"v_"+i.associatedVariableName+".xyz"}]}),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",n,{repeatKey:"maxSimultaneousLights"}),0===this._lightId&&(t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName," - ").concat("v_"+i.associatedVariableName,".xyz);\r\n")),t.compilationString+="lightingInfo info;\r\n",t.compilationString+="float shadow = 1.;\r\n",t.compilationString+="float glossiness = ".concat(this.glossiness.isConnected?this.glossiness.associatedVariableName:"1.0"," * ").concat(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 = ".concat(this.worldNormal.associatedVariableName,".xyz;\r\n")),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",n,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",n,{repeatKey:"maxSimultaneousLights"});var r=this.diffuseOutput,o=this.specularOutput;return t.compilationString+=this._declareOutput(r,t)+" = diffuseBase".concat(this.diffuseColor.isConnected?" * "+this.diffuseColor.associatedVariableName:"",";\r\n"),o.hasEndpoints&&(t.compilationString+=this._declareOutput(o,t)+" = specularBase".concat(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,n,i){e.prototype._deserialize.call(this,t,n,i),t.lightId&&(this.light=n.getLightById(t.lightId))},t}(zl);Object(c.b)("BABYLON.LightBlock",vf);var bf=function(e){function t(t,n,i,r,o,a){var s=e.call(this,t,n,i)||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?Bl.Compatible:Bl.TypeIncompatible},t.prototype.createCustomInputBlock=function(){return[new this._blockType(this._blockName),this.name]},t}(Gl),yf=function(e){function t(n){var i=e.call(this,n,Il.VertexAndFragment)||this;return i.registerOutput("source",Ml.Object,Il.VertexAndFragment,new bf("source",i,Ul.Output,t,"ImageSourceBlock")),i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"texture",{get:function(){return this._texture},set:function(e){var t,n=this;if(this._texture!==e){var i=null!==(t=null==e?void 0:e.getScene())&&void 0!==t?t:P.a.LastCreatedScene;!e&&i&&i.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(n._texture)})),this._texture=e,e&&i&&i.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(t){return t.hasTexture(e)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerName",{get:function(){return this._samplerName},enumerable:!1,configurable:!0}),t.prototype.bind=function(e,t,n){this.texture&&e.setTexture(this._samplerName,this.texture)},t.prototype.isReady=function(){return!(this.texture&&!this.texture.isReadyOrNotBlocking())},t.prototype.getClassName=function(){return"ImageSourceBlock"},Object.defineProperty(t.prototype,"source",{get:function(){return this._outputs[0]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){return e.prototype._buildBlock.call(this,t),t.target===Il.Vertex&&(this._samplerName=t._getFreeVariableName(this.name+"Sampler"),t.sharedData.blockingBlocks.push(this),t.sharedData.textureBlocks.push(this),t.sharedData.bindableBlocks.push(this)),t._emit2DSampler(this._samplerName),this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return this.texture?(t+="".concat(this._codeVariableName,'.texture = new BABYLON.Texture("').concat(this.texture.name,'", null, ').concat(this.texture.noMipmap,", ").concat(this.texture.invertY,", ").concat(this.texture.samplingMode,");\r\n"),t+="".concat(this._codeVariableName,".texture.wrapU = ").concat(this.texture.wrapU,";\r\n"),t+="".concat(this._codeVariableName,".texture.wrapV = ").concat(this.texture.wrapV,";\r\n"),t+="".concat(this._codeVariableName,".texture.uAng = ").concat(this.texture.uAng,";\r\n"),t+="".concat(this._codeVariableName,".texture.vAng = ").concat(this.texture.vAng,";\r\n"),t+="".concat(this._codeVariableName,".texture.wAng = ").concat(this.texture.wAng,";\r\n"),t+="".concat(this._codeVariableName,".texture.uOffset = ").concat(this.texture.uOffset,";\r\n"),t+="".concat(this._codeVariableName,".texture.vOffset = ").concat(this.texture.vOffset,";\r\n"),t+="".concat(this._codeVariableName,".texture.uScale = ").concat(this.texture.uScale,";\r\n"),t+="".concat(this._codeVariableName,".texture.vScale = ").concat(this.texture.vScale,";\r\n"),t+="".concat(this._codeVariableName,".texture.coordinatesMode = ").concat(this.texture.coordinatesMode,";\r\n")):t},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return this.texture&&!this.texture.isRenderTarget&&"VideoTexture"!==this.texture.getClassName()&&(t.texture=this.texture.serialize()),t},t.prototype._deserialize=function(t,n,i){e.prototype._deserialize.call(this,t,n,i),t.texture&&!Oh.IgnoreTexturesAtLoadTime&&void 0!==t.texture.url&&(i=0===t.texture.url.indexOf("data:")?"":i,this.texture=Be.a.Parse(t.texture,n,i))},t}(zl);Object(c.b)("BABYLON.ImageSourceBlock",yf);var Tf=function(e){function t(t,n){void 0===n&&(n=!1);var i=e.call(this,t,n?Il.Fragment:Il.VertexAndFragment)||this;return i._convertToGammaSpace=!1,i._convertToLinearSpace=!1,i.disableLevelMultiplication=!1,i._fragmentOnly=n,i.registerInput("uv",Ml.Vector2,!1,Il.VertexAndFragment),i.registerInput("source",Ml.Object,!0,Il.VertexAndFragment,new bf("source",i,Ul.Input,yf,"ImageSourceBlock")),i.registerOutput("rgba",Ml.Color4,Il.Neutral),i.registerOutput("rgb",Ml.Color3,Il.Neutral),i.registerOutput("r",Ml.Float,Il.Neutral),i.registerOutput("g",Ml.Float,Il.Neutral),i.registerOutput("b",Ml.Float,Il.Neutral),i.registerOutput("a",Ml.Float,Il.Neutral),i.registerOutput("level",Ml.Float,Il.Neutral),i._inputs[0].acceptedConnectionPointTypes.push(Ml.Vector3),i._inputs[0].acceptedConnectionPointTypes.push(Ml.Vector4),i._inputs[0]._prioritizeVertex=!n,i}return Object(h.d)(t,e),Object.defineProperty(t.prototype,"texture",{get:function(){var e;return this.source.isConnected?(null===(e=this.source.connectedPoint)||void 0===e?void 0:e.ownerBlock).texture:this._texture},set:function(e){var t,n=this;if(this._texture!==e){var i=null!==(t=null==e?void 0:e.getScene())&&void 0!==t?t:P.a.LastCreatedScene;!e&&i&&i.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(n._texture)})),this._texture=e,e&&i&&i.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(t){return t.hasTexture(e)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"samplerName",{get:function(){return this._imageSource?this._imageSource.samplerName:this._samplerName},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hasImageSource",{get:function(){return!!this._imageSource},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToGammaSpace",{get:function(){return this._convertToGammaSpace},set:function(e){var t,n=this;if(e!==this._convertToGammaSpace&&(this._convertToGammaSpace=e,this.texture)){var i=null!==(t=this.texture.getScene())&&void 0!==t?t:P.a.LastCreatedScene;null==i||i.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(n.texture)}))}},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"convertToLinearSpace",{get:function(){return this._convertToLinearSpace},set:function(e){var t,n=this;if(e!==this._convertToLinearSpace&&(this._convertToLinearSpace=e,this.texture)){var i=null!==(t=this.texture.getScene())&&void 0!==t?t:P.a.LastCreatedScene;null==i||i.markAllMaterialsAsDirty(g.a.MATERIAL_TextureDirtyFlag,(function(e){return e.hasTexture(n.texture)}))}},enumerable:!1,configurable:!0}),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,"source",{get:function(){return this._inputs[1]},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,"level",{get:function(){return this._outputs[6]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){if(this._fragmentOnly)return Il.Fragment;if(!this.uv.isConnected)return Il.VertexAndFragment;if(this.uv.sourceBlock.isInput)return Il.VertexAndFragment;for(var e=this.uv.connectedPoint;e;){if(e.target===Il.Fragment)return Il.Fragment;if(e.target===Il.Vertex)return Il.VertexAndFragment;if(e.target===Il.Neutral||e.target===Il.VertexAndFragment){var t=e.ownerBlock;if(t.target===Il.Fragment)return Il.Fragment;e=null;for(var n=0,i=t.inputs;n0&&(t.compilationString+=", "),t.compilationString+=e.associatedVariableName,o=!0})),this._outputs.forEach((function(e,n){(n>0||o)&&(t.compilationString+=", "),t.compilationString+=e.associatedVariableName})),t.compilationString+=");\r\n",this},t.prototype._dumpPropertiesCode=function(){var t=e.prototype._dumpPropertiesCode.call(this);return t+="".concat(this._codeVariableName,".options = ").concat(JSON.stringify(this._options),";\r\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.options=this._options,t},t.prototype._deserialize=function(t,n,i){this._deserializeOptions(t.options),e.prototype._deserialize.call(this,t,n,i)},t.prototype._deserializeOptions=function(e){var t,n,i,r=this;this._options=e,this._code=e.code.join("\r\n")+"\r\n",this.name=this.name||e.name,this.target=Il[e.target],null===(t=e.inParameters)||void 0===t||t.forEach((function(e,t){var n=Ml[e.type];r.registerInput(e.name,n),Object.defineProperty(r,e.name,{get:function(){return this._inputs[t]},enumerable:!0,configurable:!0})})),null===(n=e.outParameters)||void 0===n||n.forEach((function(e,t){r.registerOutput(e.name,Ml[e.type]),Object.defineProperty(r,e.name,{get:function(){return this._outputs[t]},enumerable:!0,configurable:!0}),"BasedOnInput"===e.type&&(r._outputs[t]._typeConnectionSource=r._findInputByName(e.typeFromInput)[0])})),null===(i=e.inLinkedConnectionTypes)||void 0===i||i.forEach((function(e){r._linkConnectionTypes(r._findInputByName(e.input1)[1],r._findInputByName(e.input2)[1])}))},t.prototype._findInputByName=function(e){if(!e)return null;for(var t=0;t=0;kc.a.PrepareUniformsAndSamplersForLight(r,e.uniforms,e.samplers,n["PROJECTEDLIGHTTEXTURE"+r],i,o)}},t.prototype.isReady=function(e,t,n){return!(this._environmentBRDFTexture&&!this._environmentBRDFTexture.isReady())&&!(n._areImageProcessingDirty&&t.imageProcessingConfiguration&&!t.imageProcessingConfiguration.isReady())},t.prototype.bind=function(e,t,n){var i,r;if(n){var o=n.getScene();this.light?kc.a.BindLight(this.light,this._lightId,o,e,!0):kc.a.BindLights(o,n,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 u=null!==(r=null===(i=this.indexOfRefraction.connectInputBlock)||void 0===i?void 0:i.value)&&void 0!==r?r:1.5,l=Math.pow((u-1)/(u+1),2);this._metallicReflectanceColor.scaleToRef(l*this._metallicF0Factor,s.c.Color3[0]);var h=this._metallicF0Factor;e.setColor4(this._vMetallicReflectanceFactorsName,s.c.Color3[0],h),t.imageProcessingConfiguration&&t.imageProcessingConfiguration.bind(e)}},t.prototype._injectVertexCode=function(e){var t,n,i=this.worldPosition,r="//".concat(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?"lightVxUboDeclaration":"lightVxFragmentDeclaration",r,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString())):(e._emitFunctionFromInclude(e.supportUniformBuffers?"lightVxUboDeclaration":"lightVxFragmentDeclaration",r,{repeatKey:"maxSimultaneousLights"}),this._lightId=0,e.sharedData.dynamicUniformBlocks.push(this));var o="v_"+i.associatedVariableName;e._emitVaryingFromString(o,"vec4")&&(e.compilationString+="".concat(o," = ").concat(i.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!==(n=null==a?void 0:a.handleVertexSide(e))&&void 0!==n?n:"",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:i.associatedVariableName}]}):(e.compilationString+="vec4 worldPos = ".concat(i.associatedVariableName,";\r\n"),this.view.isConnected&&(e.compilationString+="mat4 view = ".concat(this.view.associatedVariableName,";\r\n")),e.compilationString+=e._emitCodeFromInclude("shadowsVertex",r,{repeatKey:"maxSimultaneousLights"}))},t.prototype._getAlbedoOpacityCode=function(){var e="albedoOpacityOutParams albedoOpacityOut;\r\n",t=this.baseColor.isConnected?this.baseColor.associatedVariableName:"vec3(1.)",n=this.opacity.isConnected?this.opacity.associatedVariableName:"1.";return e+="albedoOpacityBlock(\n vec4(".concat(t,", 1.),\n #ifdef ALBEDO\n vec4(1.),\n vec2(1., 1.),\n #endif\n #ifdef OPACITY\n vec4(").concat(n,"),\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",t=this.ambientOcc.isConnected?this.ambientOcc.associatedVariableName:"1.";return e+="ambientOcclusionBlock(\n #ifdef AMBIENT\n vec3(".concat(t,"),\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(".concat(this.metallic.associatedVariableName,", ").concat(this.roughness.associatedVariableName,", 0., 0.),\n #ifdef METALLICWORKFLOW\n surfaceAlbedo,\n ").concat(this._vMetallicReflectanceFactorsName,",\n #endif\n #ifdef REFLECTIVITY\n vec3(0., 0., ").concat("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 n,i,r,o,a,s,c,u,l,h,d,p,f,_,m,g,v,b,y,T,E,S,A,x,R,C,P,O,M,I,D,N,L,F,w,B,U,V,k,G;e.prototype._buildBlock.call(this,t),this._scene=t.sharedData.scene,this._environmentBRDFTexture||(this._environmentBRDFTexture=nu(this._scene));var z=this.reflection.isConnected?null===(n=this.reflection.connectedPoint)||void 0===n?void 0:n.ownerBlock:null;if(z&&(z.worldPositionConnectionPoint=this.worldPosition,z.cameraPositionConnectionPoint=this.cameraPosition,z.worldNormalConnectionPoint=this.worldNormal),t.target!==Il.Fragment)return this._injectVertexCode(t),this;t.sharedData.forcedBindableBlocks.push(this),t.sharedData.blocksWithDefines.push(this),t.sharedData.blockingBlocks.push(this);var j="//".concat(this.name),W="v_"+this.worldPosition.associatedVariableName,H=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"),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"),this.light?t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",j,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]},this._lightId.toString()):t._emitFunctionFromInclude(t.supportUniformBuffers?"lightUboDeclaration":"lightFragmentDeclaration",j,{repeatKey:"maxSimultaneousLights"}),t._emitFunctionFromInclude("helperFunctions",j),t._emitFunctionFromInclude("importanceSampling",j),t._emitFunctionFromInclude("pbrHelperFunctions",j),t._emitFunctionFromInclude("imageProcessingDeclaration",j),t._emitFunctionFromInclude("imageProcessingFunctions",j),t._emitFunctionFromInclude("shadowsFragmentFunctions",j,{replaceStrings:[{search:/vPositionW/g,replace:W+".xyz"}]}),t._emitFunctionFromInclude("pbrDirectLightingSetupFunctions",j,{replaceStrings:[{search:/vPositionW/g,replace:W+".xyz"}]}),t._emitFunctionFromInclude("pbrDirectLightingFalloffFunctions",j),t._emitFunctionFromInclude("pbrBRDFFunctions",j,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(i=null==z?void 0:z._defineSkyboxName)&&void 0!==i?i:"REFLECTIONMAP_SKYBOX"}]}),t._emitFunctionFromInclude("hdrFilteringFunctions",j),t._emitFunctionFromInclude("pbrDirectLightingFunctions",j,{replaceStrings:[{search:/vPositionW/g,replace:W+".xyz"}]}),t._emitFunctionFromInclude("pbrIBLFunctions",j),t._emitFunctionFromInclude("pbrBlockAlbedoOpacity",j),t._emitFunctionFromInclude("pbrBlockReflectivity",j),t._emitFunctionFromInclude("pbrBlockAmbientOcclusion",j),t._emitFunctionFromInclude("pbrBlockAlphaFresnel",j),t._emitFunctionFromInclude("pbrBlockAnisotropic",j),t._emitUniformFromString("vLightingIntensity","vec4"),this._vNormalWName=t._getFreeVariableName("vNormalW"),t.compilationString+="vec4 ".concat(this._vNormalWName," = normalize(").concat(this.worldNormal.associatedVariableName,");\r\n"),t._registerTempVariable("viewDirectionW")&&(t.compilationString+="vec3 viewDirectionW = normalize(".concat(this.cameraPosition.associatedVariableName," - ").concat(W,".xyz);\r\n")),t.compilationString+="vec3 geometricNormalW = ".concat(this._vNormalWName,".xyz;\r\n"),t.compilationString+="vec3 normalW = ".concat(H.isConnected?"normalize("+H.associatedVariableName+".xyz)":"geometricNormalW",";\r\n"),this._invertNormalName=t._getFreeVariableName("invertNormal"),t._emitUniformFromString(this._invertNormalName,"float"),t.compilationString+=t._emitCodeFromInclude("pbrBlockNormalFinal",j,{replaceStrings:[{search:/vPositionW/g,replace:W+".xyz"},{search:/vEyePosition.w/g,replace:this._invertNormalName}]}),t.compilationString+=this._getAlbedoOpacityCode(),t.compilationString+=t._emitCodeFromInclude("depthPrePass",j),t.compilationString+=this._getAmbientOcclusionCode(),t.compilationString+=t._emitCodeFromInclude("pbrBlockLightmapInit",j),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",j,{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 X=this.anisotropy.isConnected?null===(a=this.anisotropy.connectedPoint)||void 0===a?void 0:a.ownerBlock:null;X&&(X.worldPositionConnectionPoint=this.worldPosition,X.worldNormalConnectionPoint=this.worldNormal,t.compilationString+=X.getCode(t,!this.perturbedNormal.isConnected)),z&&z.hasTexture&&(t.compilationString+=z.getCode(t,X?"anisotropicOut.anisotropicNormal":"normalW")),t._emitFunctionFromInclude("pbrBlockReflection",j,{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!==(u=null==z?void 0:z._defineProjectionName)&&void 0!==u?u:"REFLECTIONMAP_PROJECTION"},{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(l=null==z?void 0:z._defineSkyboxName)&&void 0!==l?l:"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!==(p=null==z?void 0:z._vReflectionFilteringInfoName)&&void 0!==p?p:"vReflectionFilteringInfo"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance0",j,{replaceStrings:[{search:/metallicReflectanceFactors/g,replace:this._vMetallicReflectanceFactorsName}]});var Y=this.sheen.isConnected?null===(f=this.sheen.connectedPoint)||void 0===f?void 0:f.ownerBlock:null;Y&&(t.compilationString+=Y.getCode(z)),t._emitFunctionFromInclude("pbrBlockSheen",j,{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 K=this.clearcoat.isConnected?null===(b=this.clearcoat.connectedPoint)||void 0===b?void 0:b.ownerBlock:null,Q=!this.perturbedNormal.isConnected&&!this.anisotropy.isConnected,q=this.perturbedNormal.isConnected&&(null===(T=(null===(y=this.perturbedNormal.connectedPoint)||void 0===y?void 0:y.ownerBlock).worldTangent)||void 0===T?void 0:T.isConnected),Z=this.anisotropy.isConnected&&(null===(E=this.anisotropy.connectedPoint)||void 0===E?void 0:E.ownerBlock).worldTangent.isConnected,J=q||!this.perturbedNormal.isConnected&&Z;t.compilationString+=__.GetCode(t,K,z,W,Q,J,this.worldNormal.associatedVariableName),Q&&(J=null!==(S=null==K?void 0:K.worldTangent.isConnected)&&void 0!==S&&S),t._emitFunctionFromInclude("pbrBlockClearcoat",j,{replaceStrings:[{search:/computeReflectionCoords/g,replace:"computeReflectionCoordsPBR"},{search:/REFLECTIONMAP_3D/g,replace:null!==(A=null==z?void 0:z._define3DName)&&void 0!==A?A:"REFLECTIONMAP_3D"},{search:/REFLECTIONMAP_OPPOSITEZ/g,replace:null!==(x=null==z?void 0:z._defineOppositeZ)&&void 0!==x?x:"REFLECTIONMAP_OPPOSITEZ"},{search:/REFLECTIONMAP_PROJECTION/g,replace:null!==(R=null==z?void 0:z._defineProjectionName)&&void 0!==R?R:"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!==(P=null==z?void 0:z._defineLODReflectionAlpha)&&void 0!==P?P:"LODINREFLECTIONALPHA"},{search:/LINEARSPECULARREFLECTION/g,replace:null!==(O=null==z?void 0:z._defineLinearSpecularReflection)&&void 0!==O?O:"LINEARSPECULARREFLECTION"},{search:/defined\(TANGENT\)/g,replace:J?"defined(TANGENT)":"defined(IGNORE)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockReflectance",j,{replaceStrings:[{search:/REFLECTIONMAP_SKYBOX/g,replace:null!==(M=null==z?void 0:z._defineSkyboxName)&&void 0!==M?M:"REFLECTIONMAP_SKYBOX"},{search:/REFLECTIONMAP_3D/g,replace:null!==(I=null==z?void 0:z._define3DName)&&void 0!==I?I:"REFLECTIONMAP_3D"}]});var $=this.subsurface.isConnected?null===(D=this.subsurface.connectedPoint)||void 0===D?void 0:D.ownerBlock:null,ee=this.subsurface.isConnected?null===(L=(null===(N=this.subsurface.connectedPoint)||void 0===N?void 0:N.ownerBlock).refraction.connectedPoint)||void 0===L?void 0:L.ownerBlock:null;ee&&(ee.viewConnectionPoint=this.view,ee.indexOfRefractionConnectionPoint=this.indexOfRefraction),t.compilationString+=g_.GetCode(t,$,z,W),t._emitFunctionFromInclude("pbrBlockSubSurface",j,{replaceStrings:[{search:/REFLECTIONMAP_3D/g,replace:null!==(F=null==z?void 0:z._define3DName)&&void 0!==F?F:"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!==(B=null==z?void 0:z._defineProjectionName)&&void 0!==B?B:"REFLECTIONMAP_PROJECTION"},{search:/SS_REFRACTIONMAP_3D/g,replace:null!==(U=null==ee?void 0:ee._define3DName)&&void 0!==U?U:"SS_REFRACTIONMAP_3D"},{search:/SS_LODINREFRACTIONALPHA/g,replace:null!==(V=null==ee?void 0:ee._defineLODRefractionAlpha)&&void 0!==V?V:"SS_LODINREFRACTIONALPHA"},{search:/SS_LINEARSPECULARREFRACTION/g,replace:null!==(k=null==ee?void 0:ee._defineLinearSpecularRefraction)&&void 0!==k?k:"SS_LINEARSPECULARREFRACTION"},{search:/SS_REFRACTIONMAP_OPPOSITEZ/g,replace:null!==(G=null==ee?void 0:ee._defineOppositeZ)&&void 0!==G?G:"SS_REFRACTIONMAP_OPPOSITEZ"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockDirectLighting",j),this.light?t.compilationString+=t._emitCodeFromInclude("lightFragment",j,{replaceStrings:[{search:/{X}/g,replace:this._lightId.toString()}]}):t.compilationString+=t._emitCodeFromInclude("lightFragment",j,{repeatKey:"maxSimultaneousLights"}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalLitComponents",j),t.compilationString+="#endif\r\n";var te=this.ambientColor.isConnected?this.ambientColor.associatedVariableName:"vec3(0., 0., 0.)",ne=ol.DEFAULT_AO_ON_ANALYTICAL_LIGHTS.toString();-1===ne.indexOf(".")&&(ne+="."),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalUnlitComponents",j,{replaceStrings:[{search:/vec3 finalEmissive[\s\S]*?finalEmissive\*=vLightingIntensity\.y;/g,replace:""},{search:/vAmbientColor/g,replace:te+" * ambientFromScene"},{search:/vAmbientInfos\.w/g,replace:ne}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockFinalColorComposition",j,{replaceStrings:[{search:/finalEmissive/g,replace:"vec3(0.)"}]}),t.compilationString+=t._emitCodeFromInclude("pbrBlockImageProcessing",j,{replaceStrings:[{search:/visibility/g,replace:"1."}]}),t.compilationString+=t._emitCodeFromInclude("pbrDebug",j,{replaceStrings:[{search:/vNormalW/g,replace:this._vNormalWName},{search:/vPositionW/g,replace:W},{search:/albedoTexture\.rgb;/g,replace:"vec3(1.);\r\ngl_FragColor.rgb = toGammaSpace(gl_FragColor.rgb);\r\n"}]});for(var ie=0,re=this._outputs;ie ").concat(this.b.associatedVariableName," ? ").concat(i," : ").concat(r,";\r\n");break;case T_.GreaterOrEqual:t.compilationString+=this._declareOutput(n,t)+" = ".concat(this.a.associatedVariableName," >= ").concat(this.b.associatedVariableName," ? ").concat(i," : ").concat(r,";\r\n");break;case T_.Xor:t.compilationString+=this._declareOutput(n,t)+" = (mod(".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,", 2.0) > 0.0) ? ").concat(i," : ").concat(r,";\r\n");break;case T_.Or:t.compilationString+=this._declareOutput(n,t)+" = (min(".concat(this.a.associatedVariableName," + ").concat(this.b.associatedVariableName,", 1.0) > 0.0) ? ").concat(i," : ").concat(r,";\r\n");break;case T_.And:t.compilationString+=this._declareOutput(n,t)+" = (".concat(this.a.associatedVariableName," * ").concat(this.b.associatedVariableName," > 0.0) ? ").concat(i," : ").concat(r,";\r\n")}return this},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.condition=this.condition,t},t.prototype._deserialize=function(t,n,i){e.prototype._deserialize.call(this,t,n,i),this.condition=t.condition},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".condition = BABYLON.ConditionalBlockConditions.").concat(T_[this.condition],";\r\n")},t}(zl);Object(c.b)("BABYLON.ConditionalBlock",S_);var A_=function(e){function t(t){var n=e.call(this,t,Il.Neutral)||this;return n.octaves=6,n.registerInput("seed",Ml.AutoDetect),n.registerInput("chaos",Ml.AutoDetect,!0),n.registerInput("offsetX",Ml.Float,!0),n.registerInput("offsetY",Ml.Float,!0),n.registerInput("offsetZ",Ml.Float,!0),n.registerOutput("output",Ml.Float),n._inputs[0].acceptedConnectionPointTypes.push(Ml.Vector2),n._inputs[0].acceptedConnectionPointTypes.push(Ml.Vector3),n._linkConnectionTypes(0,1),n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"CloudBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"chaos",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetX",{get:function(){return this._inputs[2]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetY",{get:function(){return this._inputs[3]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offsetZ",{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){var n,i;if(e.prototype._buildBlock.call(this,t),this.seed.isConnected&&this._outputs[0].hasEndpoints){var r="fbm".concat(this.octaves);t._emitFunction("CloudBlockCode","\n\n float cloudRandom(in float p) { p = fract(p * 0.011); p *= p + 7.5; p *= p + p; return fract(p); }\n\n // Based on Morgan McGuire @morgan3d\n // https://www.shadertoy.com/view/4dS3Wd\n float cloudNoise(in vec2 x, in vec2 chaos) {\n vec2 step = chaos * vec2(75., 120.) + vec2(75., 120.);\n\n vec2 i = floor(x);\n vec2 f = fract(x);\n\n float n = dot(i, step);\n\n vec2 u = f * f * (3.0 - 2.0 * f);\n return mix(\n mix(cloudRandom(n + dot(step, vec2(0, 0))), cloudRandom(n + dot(step, vec2(1, 0))), u.x),\n mix(cloudRandom(n + dot(step, vec2(0, 1))), cloudRandom(n + dot(step, vec2(1, 1))), u.x),\n u.y\n );\n }\n\n float cloudNoise(in vec3 x, in vec3 chaos) {\n vec3 step = chaos * vec3(60., 120., 75.) + vec3(60., 120., 75.);\n\n vec3 i = floor(x);\n vec3 f = fract(x);\n\n float n = dot(i, step);\n\n vec3 u = f * f * (3.0 - 2.0 * f);\n return mix(mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 0))), cloudRandom(n + dot(step, vec3(1, 0, 0))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 0))), cloudRandom(n + dot(step, vec3(1, 1, 0))), u.x), u.y),\n mix(mix( cloudRandom(n + dot(step, vec3(0, 0, 1))), cloudRandom(n + dot(step, vec3(1, 0, 1))), u.x),\n mix( cloudRandom(n + dot(step, vec3(0, 1, 1))), cloudRandom(n + dot(step, vec3(1, 1, 1))), u.x), u.y), u.z);\n }","// CloudBlockCode"),t._emitFunction("CloudBlockCodeFBM"+this.octaves,"\n float fbm(in vec2 st, in vec2 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = .5;\n float frequency = 0.;\n\n // Loop of octaves\n for (int i = 0; i < OCTAVES; i++) {\n value += amplitude * cloudNoise(st, chaos);\n st *= 2.0;\n amplitude *= 0.5;\n }\n return value;\n }\n\n float fbm(in vec3 x, in vec3 chaos) {\n // Initial values\n float value = 0.0;\n float amplitude = 0.5;\n for (int i = 0; i < OCTAVES; ++i) {\n value += amplitude * cloudNoise(x, chaos);\n x = x * 2.0;\n amplitude *= 0.5;\n }\n return value;\n }".replace(/fbm/gi,r).replace(/OCTAVES/gi,(0|this.octaves).toString()),"// CloudBlockCode FBM");var o=t._getFreeVariableName("st"),a=(null===(n=this.seed.connectedPoint)||void 0===n?void 0:n.type)===Ml.Vector2?"vec2":"vec3";t.compilationString+="".concat(a," ").concat(o," = ").concat(this.seed.associatedVariableName,";\r\n"),this.offsetX.isConnected&&(t.compilationString+="".concat(o,".x += 0.1 * ").concat(this.offsetX.associatedVariableName,";\r\n")),this.offsetY.isConnected&&(t.compilationString+="".concat(o,".y += 0.1 * ").concat(this.offsetY.associatedVariableName,";\r\n")),this.offsetZ.isConnected&&"vec3"===a&&(t.compilationString+="".concat(o,".z += 0.1 * ").concat(this.offsetZ.associatedVariableName,";\r\n"));var s="";return s=this.chaos.isConnected?this.chaos.associatedVariableName:(null===(i=this.seed.connectedPoint)||void 0===i?void 0:i.type)===Ml.Vector2?"vec2(0., 0.)":"vec3(0., 0., 0.)",t.compilationString+=this._declareOutput(this._outputs[0],t)+" = ".concat(r,"(").concat(o,", ").concat(s,");\r\n"),this}},t.prototype._dumpPropertiesCode=function(){return e.prototype._dumpPropertiesCode.call(this)+"".concat(this._codeVariableName,".octaves = ").concat(this.octaves,";\r\n")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.octaves=this.octaves,t},t.prototype._deserialize=function(t,n,i){e.prototype._deserialize.call(this,t,n,i),this.octaves=t.octaves},Object(h.c)([Xl("Octaves",Wl.Int)],t.prototype,"octaves",void 0),t}(zl);Object(c.b)("BABYLON.CloudBlock",A_);var x_=function(e){function t(t){var n=e.call(this,t,Il.Neutral)||this;return n.registerInput("seed",Ml.Vector2),n.registerInput("offset",Ml.Float),n.registerInput("density",Ml.Float),n.registerOutput("output",Ml.Float),n.registerOutput("cells",Ml.Float),n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"VoronoiNoiseBlock"},Object.defineProperty(t.prototype,"seed",{get:function(){return this._inputs[0]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"offset",{get:function(){return this._inputs[1]},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"density",{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}),Object.defineProperty(t.prototype,"cells",{get:function(){return this._outputs[1]},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){if(e.prototype._buildBlock.call(this,t),this.seed.isConnected){var n="vec2 voronoiRandom(vec2 seed, float offset){\n mat2 m = mat2(15.27, 47.63, 99.41, 89.98);\n vec2 uv = fract(sin(m * seed) * 46839.32);\n return vec2(sin(uv.y * offset) * 0.5 + 0.5, cos(uv.x * offset) * 0.5 + 0.5);\n }\n ";t._emitFunction("voronoiRandom",n,"// Voronoi random generator"),n="void voronoi(vec2 seed, float offset, float density, out float outValue, out float cells){\n vec2 g = floor(seed * density);\n vec2 f = fract(seed * density);\n float t = 8.0;\n vec3 res = vec3(8.0, 0.0, 0.0);\n\n for(int y=-1; y<=1; y++)\n {\n for(int x=-1; x<=1; x++)\n {\n vec2 lattice = vec2(x,y);\n vec2 randomOffset = voronoiRandom(lattice + g, offset);\n float d = distance(lattice + randomOffset, f);\n if(d < res.x)\n {\n res = vec3(d, randomOffset.x, randomOffset.y);\n outValue = res.x;\n cells = res.y;\n }\n }\n }\n }\n ",t._emitFunction("voronoi",n,"// Voronoi");var i=t._getFreeVariableName("tempOutput"),r=t._getFreeVariableName("tempCells");return t.compilationString+="float ".concat(i," = 0.0;\r\n"),t.compilationString+="float ".concat(r," = 0.0;\r\n"),t.compilationString+="voronoi(".concat(this.seed.associatedVariableName,", ").concat(this.offset.associatedVariableName,", ").concat(this.density.associatedVariableName,", ").concat(i,", ").concat(r,");\r\n"),this.output.hasEndpoints&&(t.compilationString+=this._declareOutput(this.output,t)+" = ".concat(i,";\r\n")),this.cells.hasEndpoints&&(t.compilationString+=this._declareOutput(this.cells,t)+" = ".concat(r,";\r\n")),this}},t}(zl);Object(c.b)("BABYLON.VoronoiNoiseBlock",x_);var R_=function(e){function t(t){var n=e.call(this,t,Il.Neutral)||this;return n.registerInput("input",Ml.AutoDetect),n.registerOutput("output",Ml.BasedOnInput),n._outputs[0]._typeConnectionSource=n._inputs[0],n}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"ElbowBlock"},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}),Object.defineProperty(t.prototype,"target",{get:function(){var e=this._inputs[0];if(e.isConnected){var t=e.connectedPoint.ownerBlock;return t.isInput?Il.Vertex:t.target}return this._target},set:function(e){0==(this._target&e)&&(this._target=e)},enumerable:!1,configurable:!0}),t.prototype._buildBlock=function(t){e.prototype._buildBlock.call(this,t);var n=this._outputs[0],i=this._inputs[0];return t.compilationString+=this._declareOutput(n,t)+" = ".concat(i.associatedVariableName,";\r\n"),this},t}(zl);Object(c.b)("BABYLON.ElbowBlock",R_);var C_=function(){function e(){}return e.prototype.optimize=function(e,t){},e}(),P_=function(){function e(){this.mm=new Map}return e.prototype.get=function(e,t){var n=this.mm.get(e);if(void 0!==n)return n.get(t)},e.prototype.set=function(e,t,n){var i=this.mm.get(e);void 0===i&&this.mm.set(e,i=new Map),i.set(t,n)},e}(),O_=function(){function e(e,t,n){var i=this;this._baseMaterial=e,this._scene=null!=t?t:P.a.LastCreatedScene,this._options=n,this._subMeshToEffect=new Map,this._subMeshToDepthWrapper=new P_,this._meshes=new Map,this._onEffectCreatedObserver=this._baseMaterial.onEffectCreatedObservable.add((function(e){var t,n=null===(t=e.subMesh)||void 0===t?void 0:t.getMesh();n&&!i._meshes.has(n)&&i._meshes.set(n,n.onDisposeObservable.add((function(e){for(var t=i._subMeshToEffect.keys(),n=t.next();!0!==n.done;n=t.next()){var r=n.value;(null==r?void 0:r.getMesh())===e&&(i._subMeshToEffect.delete(r),i._subMeshToDepthWrapper.mm.delete(r))}}))),i._subMeshToEffect.set(e.subMesh,[e.effect,i._scene.getEngine().currentRenderPassId]),i._subMeshToDepthWrapper.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,n){var i,r=null===(i=this._subMeshToDepthWrapper.mm.get(e))||void 0===i?void 0:i.get(t);if(!r)return null;var o=r.drawWrapper[n];return o||(o=r.drawWrapper[n]=new In.a(this._scene.getEngine())).setEffect(r.mainDrawWrapper.effect,r.mainDrawWrapper.defines),o},e.prototype.isReadyForSubMesh=function(e,t,n,i,r){var o,a;return!(this.standalone&&!this._baseMaterial.isReadyForSubMesh(e.getMesh(),e,i))&&(null!==(a=null===(o=this._makeEffect(e,t,n,r))||void 0===o?void 0:o.isReady())&&void 0!==a&&a)},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 n=t.value,i=n[0],r=n[1];i.onDisposeObservable.remove(r)}},e.prototype._makeEffect=function(e,t,n,i){var r,o,a,s=this._scene.getEngine(),c=this._subMeshToEffect.get(e);if(!c)return null;var u=c[0],l=c[1],h=this._subMeshToDepthWrapper.get(e,n);if(!h){var d=new In.a(s);d.defines=null!==(o=null===(r=e._getDrawWrapper(l))||void 0===r?void 0:r.defines)&&void 0!==o?o:null,(h={drawWrapper:[],mainDrawWrapper:d,depthDefines:"",token:Object(Fr.b)()}).drawWrapper[i]=d,this._subMeshToDepthWrapper.set(e,n,h)}var p=t.join("\n");if(h.mainDrawWrapper.effect&&p===h.depthDefines)return h.mainDrawWrapper.effect;h.depthDefines=p;var f=u.rawVertexSourceCode,_=u.rawFragmentSourceCode,m=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):ya.a.IncludesShadersStore.shadowMapVertexNormalBias,g=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):ya.a.IncludesShadersStore.shadowMapVertexMetric,v=this._options&&this._options.remappedVariables?"#include(".concat(this._options.remappedVariables.join(","),")"):ya.a.IncludesShadersStore.shadowMapFragmentSoftTransparentShadow,b=ya.a.IncludesShadersStore.shadowMapFragment;f=(f=-1!==(f=(f=f.replace(/void\s+?main/g,ya.a.IncludesShadersStore.shadowMapVertexExtraDeclaration+"\r\nvoid main")).replace(/#define SHADOWDEPTH_NORMALBIAS|#define CUSTOM_VERTEX_UPDATE_WORLDPOS/g,m)).indexOf("#define SHADOWDEPTH_METRIC")?f.replace(/#define SHADOWDEPTH_METRIC/g,g):f.replace(/}\s*$/g,g+"\r\n}")).replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var y=_.indexOf("#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW")>=0||_.indexOf("#define CUSTOM_FRAGMENT_BEFORE_FOG")>=0,T=-1!==_.indexOf("#define SHADOWDEPTH_FRAGMENT"),E="";y?_=_.replace(/#define SHADOWDEPTH_SOFTTRANSPARENTSHADOW|#define CUSTOM_FRAGMENT_BEFORE_FOG/g,v):E=v+"\r\n",_=_.replace(/void\s+?main/g,ya.a.IncludesShadersStore.shadowMapFragmentExtraDeclaration+"\r\nvoid main"),T?_=_.replace(/#define SHADOWDEPTH_FRAGMENT/g,b):E+=b+"\r\n",E&&(_=_.replace(/}\s*$/g,E+"}")),_=_.replace(/#define SHADER_NAME.*?\n|out vec4 glFragColor;\n/g,"");var S=u.getUniformNames().slice();S.push("biasAndScaleSM","depthValuesSM","lightDataSM","softTransparentShadowSM"),h.mainDrawWrapper.effect=s.createEffect({vertexSource:f,fragmentSource:_,vertexToken:h.token,fragmentToken:h.token},{attributes:u.getAttributesNames(),uniformsNames:S,uniformBuffersNames:u.getUniformBuffersNames(),samplers:u.getSamplers(),defines:p+"\n"+u.defines.replace("#define SHADOWS","").replace(/#define SHADOW\d/g,""),indexParameters:u.getIndexParameters()},s);for(var A=0;Ae.EPSILON?1:0;u|=h,l.push(h)}switch(u){case 0:(a.e.Dot(this.normal,t.plane.normal)>0?n:i).push(t);break;case 1:r.push(t);break;case 2:o.push(t);break;case 3:var d,p=[],f=[];for(s=0;s=3&&(d=new H_(p,t.shared)).plane&&r.push(d),f.length>=3&&(d=new H_(f,t.shared)).plane&&o.push(d)}},e.EPSILON=1e-5,e}(),H_=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=W_.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}(),X_=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;ethis.goldbergData.nbUnsharedFaces-1&&(m.a.Warn("Maximum number of unshared faces used"),e=this.goldbergData.nbUnsharedFaces-1),this.goldbergData.nbUnsharedFaces+e):(e>11&&(m.a.Warn("Last pole used"),e=11),t>this.goldbergData.nbFacesAtPole-1&&(m.a.Warn("Maximum number of faces at a pole used"),t=this.goldbergData.nbFacesAtPole-1),12+e*this.goldbergData.nbFacesAtPole+t)},t.prototype._changeGoldbergFaceColors=function(e){for(var t=0;t1&&(l=1),c.push(l,h);for(d=0;d<6;d++)l=o.x+a*Math.cos(s+d*Math.PI/3),h=o.y+a*Math.sin(s+d*Math.PI/3),l<0&&(l=0),l>1&&(l=1),u.push(l,h);for(var p=i;p0||h>0){m=-d,g=-p;v=d,b=p;switch(r){case Te.a.CENTER:m-=c/=2,v+=c;break;case Te.a.LEFT:v+=c,f=-c/2;break;case Te.a.RIGHT:m-=c,f=c/2}switch(o){case Te.a.CENTER:g-=h/=2,b+=h;break;case Te.a.BOTTOM:b+=h,_=-h/2;break;case Te.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!==Te.a.ROTATE_TILE&&t!==Te.a.ROTATE_ROW||(E[1]=[1,1,0,1,0,0,1,0]),t!==Te.a.FLIP_TILE&&t!==Te.a.FLIP_ROW||(E[1]=[1,0,0,0,0,1,1,1]),t!==Te.a.FLIP_N_ROTATE_TILE&&t!==Te.a.FLIP_N_ROTATE_ROW||(E[1]=[0,1,1,1,1,0,0,0]);for(var S=[],A=[],x=[],R=0,C=0;C0||h>0){var O,M,I,D,N=h>0&&(o===Te.a.CENTER||o===Te.a.TOP),L=h>0&&(o===Te.a.CENTER||o===Te.a.BOTTOM),F=c>0&&(r===Te.a.CENTER||r===Te.a.RIGHT),w=c>0&&(r===Te.a.CENTER||r===Te.a.LEFT),B=[];if(N&&F&&(y.push(m+f,g+_,0),y.push(-d+f,g+_,0),y.push(-d+f,g+h+_,0),y.push(m+f,g+h+_,0),x.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=[O=1-c/n,M=1-h/i,I=1,M,I,D=1,O,D],t===Te.a.ROTATE_ROW&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t===Te.a.FLIP_ROW&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),t===Te.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&&w&&(y.push(d+f,g+_,0),y.push(v+f,g+_,0),y.push(v+f,g+h+_,0),y.push(d+f,g+h+_,0),x.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=[O=0,M=1-h/i,I=c/n,M,I,D=1,O,D],(t===Te.a.ROTATE_ROW||t===Te.a.ROTATE_TILE&&s%2==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===Te.a.FLIP_ROW||t===Te.a.FLIP_TILE&&s%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===Te.a.FLIP_N_ROTATE_ROW||t===Te.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&&F&&(y.push(m+f,p+_,0),y.push(-d+f,p+_,0),y.push(-d+f,b+_,0),y.push(m+f,b+_,0),x.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=[O=1-c/n,M=0,I=1,M,I,D=h/i,O,D],(t===Te.a.ROTATE_ROW&&l%2==1||t===Te.a.ROTATE_TILE&&l%1==0)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===Te.a.FLIP_ROW&&l%2==1||t===Te.a.FLIP_TILE&&l%2==0)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===Te.a.FLIP_N_ROTATE_ROW&&l%2==1||t===Te.a.FLIP_N_ROTATE_TILE&&l%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(d+f,p+_,0),y.push(v+f,p+_,0),y.push(v+f,b+_,0),y.push(d+f,b+_,0),x.push(R,R+1,R+3,R+1,R+2,R+3),R+=4,B=[O=0,M=0,I=c/n,M,I,D=h/i,O,D],(t===Te.a.ROTATE_ROW&&l%2==1||t===Te.a.ROTATE_TILE&&(l+s)%2==1)&&(B=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),(t===Te.a.FLIP_ROW&&l%2==1||t===Te.a.FLIP_TILE&&(l+s)%2==1)&&(B=[1-O,M,1-I,M,1-I,D,1-O,D]),(t===Te.a.FLIP_N_ROTATE_ROW&&l%2==1||t===Te.a.FLIP_N_ROTATE_TILE&&(l+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/i,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!==Te.a.ROTATE_TILE&&t!==Te.a.ROTATE_ROW||(U[1]=[1-O,1-M,1-I,1-M,1-I,1-D,1-O,1-D]),t!==Te.a.FLIP_TILE&&t!==Te.a.FLIP_ROW||(U[1]=[1-O,M,1-I,M,1-I,D,1-O,D]),t!==Te.a.FLIP_N_ROTATE_TILE&&t!==Te.a.FLIP_N_ROTATE_ROW||(U[1]=[O,1-M,I,1-M,I,1-D,O,1-D]);for(P=0;Pt.x&&(t.x=n.x),n.yt.y&&(t.y=n.y)})),{min:e,max:t,width:t.x-e.x,height:t.y-e.y}},e}(),hm=function(){function e(){}return e.Rectangle=function(e,t,n,i){return[new a.d(e,t),new a.d(n,t),new a.d(n,i),new a.d(e,i)]},e.Circle=function(e,t,n,i){void 0===t&&(t=0),void 0===n&&(n=0),void 0===i&&(i=32);for(var r=new Array,o=0,s=2*Math.PI/i,c=0;c0){var h=o.length/3;this._points.elements.forEach((function(t){r.push(0,-1,0),o.push(t.x,-e,t.y),a.push(1-(t.x-s.min.x)/s.width,1-(t.y-s.min.y)/s.height)}));var d=c.length;for(l=0;lu?Su?A1?1:t.arc:1,o=void 0===t.closed||t.closed,s=t.shape,c=t.radius||1,u=t.tessellation||64,l=t.clip||0,h=t.updatable,d=Te.a._GetDefaultSideOrientation(t.sideOrientation),p=t.cap||Te.a.NO_CAP,f=2*Math.PI,_=new Array,m=t.invertUV||!1,g=0,v=0,b=f/u*r,y=new Array;for(g=0;g<=u-l;g++){y=[];for(p!=Te.a.CAP_START&&p!=Te.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;v1)?1:t.arc||1;var p,f,_=function(e,t,n,i,r,o,s,c){for(var u,l,h,d,p=t.getTangents(),f=t.getNormals(),_=t.getDistances(),m=2*Math.PI/r*c,g=o||function(){return i},v=a.c.Matrix[0],b=s===Te.a.NO_CAP||s===Te.a.CAP_END?0:2,y=0;y3?0:u,t.arc);var v=Object($_.a)(e,{pathArray:f,closePath:!0,closeArray:!1,updatable:h,sideOrientation:d,invertUV:l,frontUVs:t.frontUVs,backUVs:t.backUVs},n);return v._creationDataStorage.pathArray=f,v._creationDataStorage.path3D=p,v._creationDataStorage.tessellation=s,v._creationDataStorage.cap=u,v._creationDataStorage.arc=t.arc,v._creationDataStorage.radius=o,v}Te.a.CreateLathe=function(e,t,n,i,r,o,a){return gm(e,{shape:t,radius:n,tessellation:i,sideOrientation:a,updatable:o},r)};var ym={CreateTube:bm};function Tm(e){var t,n=e.sideOrientation||Gi.a.DEFAULTSIDE,i=e.radius||1,r=void 0===e.flat||e.flat,o=e.subdivisions||4,s=e.radiusX||i,c=e.radiusY||i,u=e.radiusZ||i,l=(1+Math.sqrt(5))/2,h=[-1,l,-0,1,l,0,-1,-l,0,1,-l,0,0,-1,-l,0,1,-l,0,-1,l,0,1,l,l,0,1,l,0,-1,-l,0,1,-l,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],p=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],f=[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*p[A]],h[3*p[A]+1],h[3*p[A]+2]),T[t].normalize().scaleInPlace(i),E[t].copyFromFloats(f[2*A]*(138/1024)+60/1024+_[S]*(-40/1024),f[2*A+1]*(239/1024)+26/1024+_[S]*(20/1024))}for(var x=function(e,t,n,i){var l,h=a.e.Lerp(T[0],T[2],t/o),d=a.e.Lerp(T[1],T[2],t/o),p=o===t?T[2]:a.e.Lerp(h,d,e/(o-t));if(p.normalize(),r){var f=a.e.Lerp(T[0],T[2],i/o),_=a.e.Lerp(T[1],T[2],i/o);l=a.e.Lerp(f,_,n/(o-i))}else l=new a.e(p.x,p.y,p.z);l.x/=s,l.y/=c,l.z/=u,l.normalize();var S=a.d.Lerp(E[0],E[2],t/o),A=a.d.Lerp(E[1],E[2],t/o),x=o===t?E[2]:a.d.Lerp(S,A,e/(o-t));g.push(p.x*s,p.y*c,p.z*u),v.push(l.x,l.y,l.z),b.push(x.x,zi.a.UseOpenGLOrientationForUV?1-x.y:x.y),m.push(y),y++},R=0;R0)?1:0)+((c=a.e.Dot(e[o+1].position,t)-n>0)?1:0)+((u=a.e.Dot(e[o+2].position,t)-n>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],p=i(e[o],h),f=i(e[o],d)),c){h=e[o],d=e[o+2],p=i(e[o+1],h),f=i(e[o+1],d),r.push(p),r.push(d.clone()),r.push(h.clone()),r.push(d.clone()),r.push(p.clone()),r.push(f);break}u&&(h=e[o],d=e[o+1],p=i(e[o+2],h),f=i(e[o+2],d)),h&&d&&p&&f&&(r.push(h.clone()),r.push(d.clone()),r.push(p),r.push(f),r.push(p.clone()),r.push(d.clone()));break;case 2:s||(d=i(h=e[o].clone(),e[o+1]),p=i(h,e[o+2]),r.push(h),r.push(d),r.push(p)),c||(d=i(h=e[o+1].clone(),e[o+2]),p=i(h,e[o]),r.push(h),r.push(d),r.push(p)),u||(d=i(h=e[o+2].clone(),e[o]),p=i(h,e[o+1]),r.push(h),r.push(d),r.push(p))}}return r},x=0;x2?E[c[d]]=[-S[f][0],S[f][1],c[d]]:E[c[d]]=[T[S[f][0]],S[f][1],c[d]])}function R(e,t,n,i){p=t+"|"+i,(d=e+"|"+n)in c||p in c?d in c&&!(p in c)?c[p]=c[d]:p in c&&!(d in c)&&(c[d]=c[p]):(c[d]=s,c[p]=s,s++),S[n][0]>2?E[c[d]]=[-S[n][0],S[n][1],c[d]]:E[c[d]]=[T[S[n][0]],S[n][1],c[d]]}this.closestTo=E,this.vecToIdx=c},e.prototype.calcCoeffs=function(){var e=this.m,t=this.n,n=Math.sqrt(3)/3,i=e*e+t*t+e*t;this.coau=(e+t)/i,this.cobu=-t/i,this.coav=-n*(e-t)/i,this.cobv=n*(2*e+t)/i},e.prototype.createInnerFacets=function(){for(var e=this.m,t=this.n,n=0;n0&&i0){for(var c=L.a.HCF(e,t),u=e/c,l=t/c,h=1;h-1?i[n][1]>0&&t[i[n][0]].push([n,i[n][1]]):t[12].push([n,i[n][0]]);var r=[];for(n=0;n<12;n++)r[n]=n;var o=12;for(n=0;n<12;n++){t[n].sort((function(e,t){return e[1]-t[1]}));for(var a=0;a0;)r=t[s],this.face[r].indexOf(a)>-1?(o=(this.face[r].indexOf(a)+1)%3,a=this.face[r][o],n.push(a),i.push(r),t.splice(s,1),s=0):s++;return this.adjacentFaces.push(n),i},t.prototype.toGoldbergPolyhedronData=function(){var e=this,t=new Om("GeoDual","Goldberg",[],[]);t.name="GD dual";for(var n=this.vertex.length,i=new Array(n),r=0;ri){var o=r;r=i,i=o,m.a.Warn("n > m therefore m and n swapped")}var a=new Pm;return a.build(i,r),gc(e,{custom:Mm.BuildGeodesicData(a),size:t.size,sizeX:t.sizeX,sizeY:t.sizeY,sizeZ:t.sizeZ,faceUV:t.faceUV,faceColors:t.faceColors,flat:t.flat,updatable:t.updatable,sideOrientation:t.sideOrientation,frontUVs:t.frontUVs,backUVs:t.backUVs},n)}function Dm(e,t){for(var n=e.size,i=e.sizeX||n||1,r=e.sizeY||n||1,o=e.sizeZ||n||1,s=0===e.sideOrientation?0:e.sideOrientation||Gi.a.DEFAULTSIDE,c=new Array,u=new Array,l=new Array,h=new Array,d=1/0,p=-1/0,f=1/0,_=-1/0,m=0;mu){var h=l;l=u,u=h,m.a.Warn("n > m therefore m and n swapped")}var d=new Pm;d.build(u,l);var p=Mm.BuildGeodesicData(d),f=p.toGoldbergPolyhedronData(),_=new K_(e,n);t.sideOrientation=Te.a._GetDefaultSideOrientation(t.sideOrientation),_._originalBuilderSideOrientation=t.sideOrientation,Dm(t,f).applyToMesh(_,t.updatable),_.goldbergData.nbSharedFaces=p.sharedNodes,_.goldbergData.nbUnsharedFaces=p.poleNodes,_.goldbergData.adjacentFaces=p.adjacentFaces,_.goldbergData.nbFaces=_.goldbergData.nbSharedFaces+_.goldbergData.nbUnsharedFaces,_.goldbergData.nbFacesAtPole=(_.goldbergData.nbUnsharedFaces-12)/12;for(var g=0;gc||n.deleted||n.isDirty))for(var r=0;r<3;++r)if(n.error[r]>0,(function(e){if(r){var t=e+s.verticesStart,o=a.e.FromArray(r,3*t),u=function(e){if(n)for(var t=0;t0&&this._reconstructedMesh.setVerticesData(bt.b.NormalKind,a),s.length>0&&this._reconstructedMesh.setVerticesData(bt.b.UVKind,s),c.length>0&&this._reconstructedMesh.setVerticesData(bt.b.ColorKind,c);var b=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],m.forEach((function(e){Dh.a.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),Dh.a.AddToMesh(b.materialIndex,_,d,f,3*r.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new Te.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,n,i,r){for(var o=0;o.999)return!0;var p=a.e.Cross(h,d).normalize();if(i[o]=!1,a.e.Dot(p,s.normal)<.2)return!0}else i[o]=!0,r.push(s)}}return!1},e.prototype.updateTriangles=function(e,t,n,i){for(var r=i,o=0;o=this._thinInstanceDataStorage.instancesCount)return!1;var i=this._thinInstanceDataStorage.matrixData;return t.copyToArray(i,16*e),this._thinInstanceDataStorage.worldMatrices&&(this._thinInstanceDataStorage.worldMatrices[e]=t),n&&(this.thinInstanceBufferUpdated("matrix"),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)),!0},Te.a.prototype.thinInstanceSetAttributeAt=function(e,t,n,i){return void 0===i&&(i=!0),!(!this._userThinInstanceBuffersStorage||!this._userThinInstanceBuffersStorage.data[e]||t>=this._thinInstanceDataStorage.instancesCount)&&(this._thinInstanceUpdateBufferSize(e,0),this._userThinInstanceBuffersStorage.data[e].set(n,t*this._userThinInstanceBuffersStorage.strides[e]),i&&this.thinInstanceBufferUpdated(e),!0)},Object.defineProperty(Te.a.prototype,"thinInstanceCount",{get:function(){return this._thinInstanceDataStorage.instancesCount},set:function(e){var t,n;e<=(null!==(n=null===(t=this._thinInstanceDataStorage.matrixData)||void 0===t?void 0:t.length)&&void 0!==n?n:0)/16&&(this._thinInstanceDataStorage.instancesCount=e)},enumerable:!0,configurable:!0}),Te.a.prototype._thinInstanceCreateMatrixBuffer=function(e,t,n){void 0===n&&(n=!1);for(var i=new bt.a(this.getEngine(),t,!n,16,!1,!0),r=0;r<4;r++)this.setVerticesBuffer(i.createVertexBuffer(e+r,4*r,4));return i},Te.a.prototype.thinInstanceSetBuffer=function(e,t,n,i){var r,o,a;void 0===n&&(n=0),void 0===i&&(i=!1),n=n||16,"matrix"===e?(null===(r=this._thinInstanceDataStorage.matrixBuffer)||void 0===r||r.dispose(),this._thinInstanceDataStorage.matrixBuffer=null,this._thinInstanceDataStorage.matrixBufferSize=t?t.length:32*n,this._thinInstanceDataStorage.matrixData=t,this._thinInstanceDataStorage.worldMatrices=null,null!==t?(this._thinInstanceDataStorage.instancesCount=t.length/n,this._thinInstanceDataStorage.matrixBuffer=this._thinInstanceCreateMatrixBuffer("world",t,i),this.doNotSyncBoundingInfo||this.thinInstanceRefreshBoundingInfo(!1)):(this._thinInstanceDataStorage.instancesCount=0,this.doNotSyncBoundingInfo||this.refreshBoundingInfo())):"previousMatrix"===e?(null===(o=this._thinInstanceDataStorage.previousMatrixBuffer)||void 0===o||o.dispose(),this._thinInstanceDataStorage.previousMatrixBuffer=null,this._thinInstanceDataStorage.previousMatrixData=t,null!==t&&(this._thinInstanceDataStorage.previousMatrixBuffer=this._thinInstanceCreateMatrixBuffer("previousWorld",t,i))):(e===bt.b.ColorKind&&(e=bt.b.ColorInstanceKind),null===t?(null===(a=this._userThinInstanceBuffersStorage)||void 0===a?void 0:a.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]=n,this._userThinInstanceBuffersStorage.sizes[e]=t.length,this._userThinInstanceBuffersStorage.vertexBuffers[e]=new bt.b(this.getEngine(),t,e,!i,!1,n,!0),this.setVerticesBuffer(this._userThinInstanceBuffersStorage.vertexBuffers[e])))},Te.a.prototype.thinInstanceBufferUpdated=function(e){var t,n,i;"matrix"===e?null===(t=this._thinInstanceDataStorage.matrixBuffer)||void 0===t||t.updateDirectly(this._thinInstanceDataStorage.matrixData,0,this._thinInstanceDataStorage.instancesCount):"previousMatrix"===e?null===(n=this._thinInstanceDataStorage.previousMatrixBuffer)||void 0===n||n.updateDirectly(this._thinInstanceDataStorage.previousMatrixData,0,this._thinInstanceDataStorage.instancesCount):(null===(i=this._userThinInstanceBuffersStorage)||void 0===i?void 0:i.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(this._userThinInstanceBuffersStorage.data[e],0)},Te.a.prototype.thinInstancePartialBufferUpdate=function(e,t,n){var i;"matrix"===e?this._thinInstanceDataStorage.matrixBuffer&&this._thinInstanceDataStorage.matrixBuffer.updateDirectly(t,n):(null===(i=this._userThinInstanceBuffersStorage)||void 0===i?void 0:i.vertexBuffers[e])&&this._userThinInstanceBuffersStorage.vertexBuffers[e].updateDirectly(t,n)},Te.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-1&&(this.agentDestinationArmed[n]=!0,this.agentDestination[n].set(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 n=this.recastCrowd.getAgentParameters(e);void 0!==t.radius&&(n.radius=t.radius),void 0!==t.height&&(n.height=t.height),void 0!==t.maxAcceleration&&(n.maxAcceleration=t.maxAcceleration),void 0!==t.maxSpeed&&(n.maxSpeed=t.maxSpeed),void 0!==t.collisionQueryRange&&(n.collisionQueryRange=t.collisionQueryRange),void 0!==t.pathOptimizationRange&&(n.pathOptimizationRange=t.pathOptimizationRange),void 0!==t.separationWeight&&(n.separationWeight=t.separationWeight),this.recastCrowd.setAgentParameters(e,n)},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),this.reachRadii.splice(t,1),this.agentDestinationArmed.splice(t,1),this.agentDestination.splice(t,1))},e.prototype.getAgents=function(){return this.agents},e.prototype.update=function(e){this.bjsRECASTPlugin.navMesh.update();var t=this.bjsRECASTPlugin.getTimeStep(),n=this.bjsRECASTPlugin.getMaximumSubStepCount();if(t<=ht.a)this.recastCrowd.update(e);else{var i=Math.floor(e/t);n&&i>n&&(i=n),i<1&&(i=1);for(var r=e/i,o=0;od&&c.y=400&&o?o(u):n()}),!1),u.addEventListener("error",(function(){m.a.Error("error on XHR request."),n()}),!1),u.send()}else m.a.Error("Error: IndexedDB not supported by your browser or Babylon.js database is not open."),n()},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 n=Op(e.response);if(n.width&&n.height&&n.width>0&&n.height>0)return!0;if(2===t)return!1}if(4&t){var i=new Uint8Array(e.response,0,3);return 68===i[0]&&68===i[1]&&83===i[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("#")),n=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(n,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}(),Qm=function(){function e(e){this._isUbo(e)?(this.setMatrix3x3=e.updateMatrix3x3.bind(e),this.setMatrix2x2=e.updateMatrix2x2.bind(e),this.setFloat=e.updateFloat.bind(e),this.setFloat2=e.updateFloat2.bind(e),this.setFloat3=e.updateFloat3.bind(e),this.setFloat4=e.updateFloat4.bind(e),this.setFloatArray=e.updateFloatArray.bind(e),this.setArray=e.updateArray.bind(e),this.setIntArray=e.updateIntArray.bind(e),this.setMatrix=e.updateMatrix.bind(e),this.setMatrices=e.updateMatrices.bind(e),this.setVector3=e.updateVector3.bind(e),this.setVector4=e.updateVector4.bind(e),this.setColor3=e.updateColor3.bind(e),this.setColor4=e.updateColor4.bind(e),this.setDirectColor4=e.updateDirectColor4.bind(e),this.setInt=e.updateInt.bind(e),this.setInt2=e.updateInt2.bind(e),this.setInt3=e.updateInt3.bind(e),this.setInt4=e.updateInt4.bind(e)):(this.setMatrix3x3=e.setMatrix3x3.bind(e),this.setMatrix2x2=e.setMatrix2x2.bind(e),this.setFloat=e.setFloat.bind(e),this.setFloat2=e.setFloat2.bind(e),this.setFloat3=e.setFloat3.bind(e),this.setFloat4=e.setFloat4.bind(e),this.setFloatArray=e.setFloatArray.bind(e),this.setArray=e.setArray.bind(e),this.setIntArray=e.setIntArray.bind(e),this.setMatrix=e.setMatrix.bind(e),this.setMatrices=e.setMatrices.bind(e),this.setVector3=e.setVector3.bind(e),this.setVector4=e.setVector4.bind(e),this.setColor3=e.setColor3.bind(e),this.setColor4=e.setColor4.bind(e),this.setDirectColor4=e.setDirectColor4.bind(e),this.setInt=e.setInt.bind(e),this.setInt2=e.setInt2.bind(e),this.setInt3=e.setInt3.bind(e),this.setInt4=e.setInt4.bind(e))}return e.prototype._isUbo=function(e){return void 0!==e.addUniform},e}();Cn.a.ShadersStore.gpuUpdateParticlesPixelShader="#version 300 es\nvoid main() {\ndiscard;\n}\n";var qm="#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 vec4 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=normalize(direction1+(direction2-direction1)*randoms3);\n#else\n\nnewDirection=normalize(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)*directionRandomizer;\nnewDirection=vec3(cos(angle),(randoms3.y-0.5)*directionRandomizer,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=0.;\nif (cellInfos.w == 1.0) {\nratio=clamp(mod(cellStartOffset+cellInfos.z*offsetAge,life)/life,0.,1.0);\n}\nelse {\nratio=clamp(cellStartOffset+cellInfos.z*offsetAge/life,0.,1.0);\n}\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}";Cn.a.ShadersStore.gpuUpdateParticlesVertexShader=qm;var Zm=function(){function e(e,t){this._renderVAO=[],this._updateVAO=[],this.alignDataInBuffer=!1,this._parent=e,this._engine=t,this._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:[]}}return e.prototype.isUpdateBufferCreated=function(){return!!this._updateEffect},e.prototype.isUpdateBufferReady=function(){var e,t;return null!==(t=null===(e=this._updateEffect)||void 0===e?void 0:e.isReady())&&void 0!==t&&t},e.prototype.createUpdateBuffer=function(e){return this._updateEffectOptions.transformFeedbackVaryings=["outPosition"],this._updateEffectOptions.transformFeedbackVaryings.push("outAge"),this._updateEffectOptions.transformFeedbackVaryings.push("outSize"),this._updateEffectOptions.transformFeedbackVaryings.push("outLife"),this._updateEffectOptions.transformFeedbackVaryings.push("outSeed"),this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),this._parent.particleEmitterType instanceof gh&&this._updateEffectOptions.transformFeedbackVaryings.push("outInitialPosition"),this._parent._colorGradientsTexture||this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),this._parent._isBillboardBased||this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),this._parent.noiseTexture&&(this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),this._parent.isAnimationSheetEnabled&&(this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),this._parent.spriteRandomStartCell&&this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),this._updateEffectOptions.defines=e,this._updateEffect=new ya.a("gpuUpdateParticles",this._updateEffectOptions,this._engine),new Qm(this._updateEffect)},e.prototype.createVertexBuffers=function(e,t){this._updateVAO.push(this._createUpdateVAO(e)),this._renderVAO.push(this._engine.recordVertexArrayObject(t,null,this._parent._getWrapper(this._parent.blendMode).effect)),this._engine.bindArrayBuffer(null)},e.prototype.createParticleBuffer=function(e){return e},e.prototype.bindDrawBuffers=function(e,t){this._engine.bindVertexArrayObject(this._renderVAO[e],null)},e.prototype.preUpdateParticleBuffer=function(){var e=this._engine;if(this._engine.enableEffect(this._updateEffect),!e.setState)throw new Error("GPU particles cannot work without a full Engine. ThinEngine is not supported")},e.prototype.updateParticleBuffer=function(e,t,n){this._updateEffect.setTexture("randomSampler",this._parent._randomTexture),this._updateEffect.setTexture("randomSampler2",this._parent._randomTexture2),this._parent._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._parent._sizeGradientsTexture),this._parent._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._parent._angularSpeedGradientsTexture),this._parent._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._parent._velocityGradientsTexture),this._parent._limitVelocityGradientsTexture&&this._updateEffect.setTexture("limitVelocityGradientSampler",this._parent._limitVelocityGradientsTexture),this._parent._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._parent._dragGradientsTexture),this._parent.noiseTexture&&this._updateEffect.setTexture("noiseSampler",this._parent.noiseTexture),this._engine.bindVertexArrayObject(this._updateVAO[e],null);var i=this._engine;i.bindTransformFeedbackBuffer(t.getBuffer()),i.setRasterizerState(!1),i.beginTransformFeedback(!0),i.drawArraysType(g.a.MATERIAL_PointListDrawMode,0,n),i.endTransformFeedback(),i.setRasterizerState(!0),i.bindTransformFeedbackBuffer(null)},e.prototype.releaseBuffers=function(){},e.prototype.releaseVertexBuffers=function(){for(var e=0;ee)n(t[0],t[0],1);else{for(var i=0;i=r.gradient&&e<=o.gradient)return void n(r,o,(e-r.gradient)/(o.gradient-r.gradient))}var a=t.length-1;n(t[a],t[a],1)}},e}(),og=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 n,i=this._initialEndSpriteCellID-this._initialStartSpriteCellID;n=this._initialSpriteCellLoop?L.a.Clamp(e*t%this.lifeTime/this.lifeTime):L.a.Clamp(e*t/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 n=a.c.Vector3[0];this.direction.normalizeToRef(n),t.setDirection(n,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,e._initialSpriteCellLoop=this._initialSpriteCellLoop),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"}(eg||(eg={}));var ag=function(){function e(e){if(this.particleSystem=e,this.type=eg.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,!e.emitter||!e.emitter.dispose){var t=Object(c.a)("BABYLON.AbstractMesh");e.emitter=new t("SubemitterSystemEmitter",e.getScene()),e._disposeEmitterOnDispose=!0}}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(Object(c.a)("BABYLON.Mesh"))("",t.getScene())).isVisible=!1}}else t=new a.e;var n=new e(this.particleSystem.clone(this.particleSystem.name,t));return n.particleSystem.name+="Clone",n.type=this.type,n.inheritDirection=this.inheritDirection,n.inheritedVelocityAmount=this.inheritedVelocityAmount,n.particleSystem._disposeEmitterOnDispose=!0,n.particleSystem.disposeOnStop=!0,n},e.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};return t.type=this.type,t.inheritDirection=this.inheritDirection,t.inheritedVelocityAmount=this.inheritedVelocityAmount,t.particleSystem=this.particleSystem.serialize(e),t},e._ParseParticleSystem=function(e,t,n,i){throw void 0===i&&(i=!1),Object(Me.a)("ParseParticle")},e.Parse=function(t,n,i){var r=t.particleSystem,o=new e(e._ParseParticleSystem(r,n,i,!0));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}(),sg="\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include\n#include\n#include\n#include\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\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#define CUSTOM_FRAGMENT_MAIN_END\n}";Cn.a.ShadersStore.particlesPixelShader=sg;var cg="\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\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\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\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\n#define CUSTOM_VERTEX_MAIN_END\n}";Cn.a.ShadersStore.particlesVertexShader=cg;var ug=function(e){function t(t,n,i,r,c,u){void 0===r&&(r=null),void 0===c&&(c=!1),void 0===u&&(u=.01);var l=e.call(this,t)||this;l._emitterInverseWorldMatrix=a.a.Identity(),l._inheritedVelocityOffset=new a.e,l.onDisposeObservable=new o.c,l.onStoppedObservable=new o.c,l._particles=new Array,l._stockParticles=new Array,l._newPartsExcess=0,l._vertexBuffers={},l._scaledColorStep=new s.b(0,0,0,0),l._colorDiff=new s.b(0,0,0,0),l._scaledDirection=a.e.Zero(),l._scaledGravity=a.e.Zero(),l._currentRenderId=-1,l._useInstancing=!1,l._started=!1,l._stopped=!1,l._actualFrame=0,l._currentEmitRate1=0,l._currentEmitRate2=0,l._currentStartSize1=0,l._currentStartSize2=0,l._rawTextureWidth=256,l._useRampGradients=!1,l._disposeEmitterOnDispose=!1,l.isLocal=!1,l._onBeforeDrawParticlesObservable=null,l.recycleParticle=function(e){var t=l._particles.pop();t!==e&&t.copyTo(e),l._stockParticles.push(t)},l._createParticle=function(){var e;if(0!==l._stockParticles.length?(e=l._stockParticles.pop())._reset():e=new og(l),l._subEmitters&&l._subEmitters.length>0){var t=l._subEmitters[Math.floor(Math.random()*l._subEmitters.length)];e._attachedSubEmitters=[],t.forEach((function(t){if(t.type===eg.ATTACHED){var n=t.clone();e._attachedSubEmitters.push(n),n.particleSystem.start()}}))}return e},l._emitFromParticle=function(e){if(l._subEmitters&&0!==l._subEmitters.length){var t=Math.floor(Math.random()*l._subEmitters.length);l._subEmitters[t].forEach((function(t){if(t.type===eg.END){var n=t.clone();e._inheritParticleInfoToSubEmitter(n),n.particleSystem._rootParticleSystem=l,l.activeSubSystems.push(n.particleSystem),n.particleSystem.start()}}))}},l._capacity=n,l._epsilon=u,l._isAnimationSheetEnabled=c,i&&"Scene"!==i.getClassName()?(l._engine=i,l.defaultProjectionMatrix=a.a.PerspectiveFovLH(.8,1,.1,100,l._engine.isNDCHalfZRange)):(l._scene=i||P.a.LastCreatedScene,l._engine=l._scene.getEngine(),l.uniqueId=l._scene.getUniqueId(),l._scene.particleSystems.push(l)),l._engine.getCaps().vertexArrayObject&&(l._vertexArrayObject=null),l._attachImageProcessingConfiguration(null),l._customWrappers={0:new In.a(l._engine)},l._customWrappers[0].effect=r,l._drawWrappers=[],l._useInstancing=l._engine.getCaps().instancedArrays,l._createIndexBuffer(),l._createVertexBuffers(),l.particleEmitterType=new uh;var h=null;return l.updateFunction=function(e){var t,n=null;l.noiseTexture&&(n=l.noiseTexture.getSize(),null===(t=l.noiseTexture.getContent())||void 0===t||t.then((function(e){h=e})));for(var i,r=function(){i=e[o];var t=l._scaledUpdateSpeed,r=i.age;if(i.age+=t,i.age>i.lifeTime){var c=i.age-r;t=(i.lifeTime-r)*t/c,i.age=i.lifeTime}var u=i.age/i.lifeTime;l._colorGradients&&l._colorGradients.length>0?rg.GetCurrentGradient(u,l._colorGradients,(function(e,t,n){e!==i._currentColorGradient&&(i._currentColor1.copyFrom(i._currentColor2),t.getColorToRef(i._currentColor2),i._currentColorGradient=e),s.b.LerpToRef(i._currentColor1,i._currentColor2,n,i.color)})):(i.colorStep.scaleToRef(t,l._scaledColorStep),i.color.addInPlace(l._scaledColorStep),i.color.a<0&&(i.color.a=0)),l._angularSpeedGradients&&l._angularSpeedGradients.length>0&&rg.GetCurrentGradient(u,l._angularSpeedGradients,(function(e,t,n){e!==i._currentAngularSpeedGradient&&(i._currentAngularSpeed1=i._currentAngularSpeed2,i._currentAngularSpeed2=t.getFactor(),i._currentAngularSpeedGradient=e),i.angularSpeed=L.a.Lerp(i._currentAngularSpeed1,i._currentAngularSpeed2,n)})),i.angle+=i.angularSpeed*t;var d=t;if(l._velocityGradients&&l._velocityGradients.length>0&&rg.GetCurrentGradient(u,l._velocityGradients,(function(e,t,n){e!==i._currentVelocityGradient&&(i._currentVelocity1=i._currentVelocity2,i._currentVelocity2=t.getFactor(),i._currentVelocityGradient=e),d*=L.a.Lerp(i._currentVelocity1,i._currentVelocity2,n)})),i.direction.scaleToRef(d,l._scaledDirection),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&rg.GetCurrentGradient(u,l._limitVelocityGradients,(function(e,t,n){e!==i._currentLimitVelocityGradient&&(i._currentLimitVelocity1=i._currentLimitVelocity2,i._currentLimitVelocity2=t.getFactor(),i._currentLimitVelocityGradient=e);var r=L.a.Lerp(i._currentLimitVelocity1,i._currentLimitVelocity2,n);i.direction.length()>r&&i.direction.scaleInPlace(l.limitVelocityDamping)})),l._dragGradients&&l._dragGradients.length>0&&rg.GetCurrentGradient(u,l._dragGradients,(function(e,t,n){e!==i._currentDragGradient&&(i._currentDrag1=i._currentDrag2,i._currentDrag2=t.getFactor(),i._currentDragGradient=e);var r=L.a.Lerp(i._currentDrag1,i._currentDrag2,n);l._scaledDirection.scaleInPlace(1-r)})),l.isLocal&&i._localPosition?(i._localPosition.addInPlace(l._scaledDirection),a.e.TransformCoordinatesToRef(i._localPosition,l._emitterWorldMatrix,i.position)):i.position.addInPlace(l._scaledDirection),h&&n&&i._randomNoiseCoordinates1){var p=l._fetchR(i._randomNoiseCoordinates1.x,i._randomNoiseCoordinates1.y,n.width,n.height,h),f=l._fetchR(i._randomNoiseCoordinates1.z,i._randomNoiseCoordinates2.x,n.width,n.height,h),_=l._fetchR(i._randomNoiseCoordinates2.y,i._randomNoiseCoordinates2.z,n.width,n.height,h),m=a.c.Vector3[0],g=a.c.Vector3[1];m.copyFromFloats((2*p-1)*l.noiseStrength.x,(2*f-1)*l.noiseStrength.y,(2*_-1)*l.noiseStrength.z),m.scaleToRef(t,g),i.direction.addInPlace(g)}if(l.gravity.scaleToRef(t,l._scaledGravity),i.direction.addInPlace(l._scaledGravity),l._sizeGradients&&l._sizeGradients.length>0&&rg.GetCurrentGradient(u,l._sizeGradients,(function(e,t,n){e!==i._currentSizeGradient&&(i._currentSize1=i._currentSize2,i._currentSize2=t.getFactor(),i._currentSizeGradient=e),i.size=L.a.Lerp(i._currentSize1,i._currentSize2,n)})),l._useRampGradients&&(l._colorRemapGradients&&l._colorRemapGradients.length>0&&rg.GetCurrentGradient(u,l._colorRemapGradients,(function(e,t,n){var r=L.a.Lerp(e.factor1,t.factor1,n),o=L.a.Lerp(e.factor2,t.factor2,n);i.remapData.x=r,i.remapData.y=o-r})),l._alphaRemapGradients&&l._alphaRemapGradients.length>0&&rg.GetCurrentGradient(u,l._alphaRemapGradients,(function(e,t,n){var r=L.a.Lerp(e.factor1,t.factor1,n),o=L.a.Lerp(e.factor2,t.factor2,n);i.remapData.z=r,i.remapData.w=o-r}))),l._isAnimationSheetEnabled&&i.updateCellIndex(),i._inheritParticleInfoToSubEmitters(),i.age>=i.lifeTime)return l._emitFromParticle(i),i._attachedSubEmitters&&(i._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),i._attachedSubEmitters=null),l.recycleParticle(i),o--,"continue"},o=0;ot.gradient?1:0}))},t.prototype._removeFactorGradient=function(e,t){if(e)for(var n=0,i=0,r=e;it.gradient?1:0})),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture())},t.prototype.addRampGradient=function(e,t){this._rampGradients||(this._rampGradients=[]);var n=new ng(e,t);return this._rampGradients.push(n),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,n){this._colorGradients||(this._colorGradients=[]);var i=new tg(e,t,n);return this._colorGradients.push(i),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this},t.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,n=0,i=this._colorGradients;n0&&(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 i=this.noiseTexture;if(i&&i.onGeneratedObservable)i.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e0&&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,n,i,r){var o=e*this._vertexBufferSize;if(this._vertexData[o++]=n.position.x+this.worldOffset.x,this._vertexData[o++]=n.position.y+this.worldOffset.y,this._vertexData[o++]=n.position.z+this.worldOffset.z,this._vertexData[o++]=n.color.r,this._vertexData[o++]=n.color.g,this._vertexData[o++]=n.color.b,this._vertexData[o++]=n.color.a,this._vertexData[o++]=n.angle,this._vertexData[o++]=n.scale.x*n.size,this._vertexData[o++]=n.scale.y*n.size,this._isAnimationSheetEnabled&&(this._vertexData[o++]=n.cellIndex),this._isBillboardBased)this.billboardMode===t.BILLBOARDMODE_STRETCHED&&(this._vertexData[o++]=n.direction.x,this._vertexData[o++]=n.direction.y,this._vertexData[o++]=n.direction.z);else if(n._initialDirection){var s=n._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=n.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&&n.remapData&&(this._vertexData[o++]=n.remapData.x,this._vertexData[o++]=n.remapData.y,this._vertexData[o++]=n.remapData.z,this._vertexData[o++]=n.remapData.w),this._useInstancing||(this._isAnimationSheetEnabled&&(0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon)),this._vertexData[o++]=i,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,n=this;if(this._alive=this._particles.length>0,this.emitter.position){var i=this.emitter;this._emitterWorldMatrix=i.getWorldMatrix()}else{var r=this.emitter;this._emitterWorldMatrix=a.a.Translation(r.x,r.y,r.z)}this._emitterWorldMatrix.invertToRef(this._emitterInverseWorldMatrix),this.updateFunction(this._particles);for(var o,c=function(){if(u._particles.length===u._capacity)return"break";if(t=u._createParticle(),u._particles.push(t),u.targetStopDuration&&u._lifeTimeGradients&&u._lifeTimeGradients.length>0){var e=L.a.Clamp(u._actualFrame/u.targetStopDuration);rg.GetCurrentGradient(e,u._lifeTimeGradients,(function(n,i){var r=n,o=i,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(u.minLifeTime,u.maxLifeTime);var i=L.a.RandomRange(u.minEmitPower,u.maxEmitPower);if(u.startPositionFunction?u.startPositionFunction(u._emitterWorldMatrix,t.position,t,u.isLocal):u.particleEmitterType.startPositionFunction(u._emitterWorldMatrix,t.position,t,u.isLocal),u.isLocal&&(t._localPosition?t._localPosition.copyFrom(t.position):t._localPosition=t.position.clone(),a.e.TransformCoordinatesToRef(t._localPosition,u._emitterWorldMatrix,t.position)),u.startDirectionFunction?u.startDirectionFunction(u._emitterWorldMatrix,t.direction,t,u.isLocal):u.particleEmitterType.startDirectionFunction(u._emitterWorldMatrix,t.direction,t,u.isLocal,u._emitterInverseWorldMatrix),0===i?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(i),u._sizeGradients&&0!==u._sizeGradients.length?(t._currentSizeGradient=u._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,u._sizeGradients.length>1?t._currentSize2=u._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=L.a.RandomRange(u.minSize,u.maxSize),t.scale.copyFromFloats(L.a.RandomRange(u.minScaleX,u.maxScaleX),L.a.RandomRange(u.minScaleY,u.maxScaleY)),u._startSizeGradients&&u._startSizeGradients[0]&&u.targetStopDuration){var r=u._actualFrame/u.targetStopDuration;rg.GetCurrentGradient(r,u._startSizeGradients,(function(e,i,r){e!==n._currentStartSizeGradient&&(n._currentStartSize1=n._currentStartSize2,n._currentStartSize2=i.getFactor(),n._currentStartSizeGradient=e);var o=L.a.Lerp(n._currentStartSize1,n._currentStartSize2,r);t.scale.scaleInPlace(o)}))}u._angularSpeedGradients&&0!==u._angularSpeedGradients.length?(t._currentAngularSpeedGradient=u._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,u._angularSpeedGradients.length>1?t._currentAngularSpeed2=u._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=L.a.RandomRange(u.minAngularSpeed,u.maxAngularSpeed),t.angle=L.a.RandomRange(u.minInitialRotation,u.maxInitialRotation),u._velocityGradients&&u._velocityGradients.length>0&&(t._currentVelocityGradient=u._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),u._velocityGradients.length>1?t._currentVelocity2=u._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),u._limitVelocityGradients&&u._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=u._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),u._limitVelocityGradients.length>1?t._currentLimitVelocity2=u._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),u._dragGradients&&u._dragGradients.length>0&&(t._currentDragGradient=u._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),u._dragGradients.length>1?t._currentDrag2=u._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),u._colorGradients&&0!==u._colorGradients.length?(t._currentColorGradient=u._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),u._colorGradients.length>1?u._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(o=L.a.RandomRange(0,1),s.b.LerpToRef(u.color1,u.color2,o,t.color),u.colorDead.subtractToRef(t.color,u._colorDiff),u._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),u._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=u.startSpriteCellID,t._initialEndSpriteCellID=u.endSpriteCellID,t._initialSpriteCellLoop=u.spriteCellLoop),t.direction.addInPlace(u._inheritedVelocityOffset),u._useRampGradients&&(t.remapData=new a.f(0,1,0,1)),u.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()},u=this,l=0;l-1)i=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var r=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var o=this._actualFrame/this.targetStopDuration;rg.GetCurrentGradient(o,this._emitRateGradients,(function(e,t,i){e!==n._currentEmitRateGradient&&(n._currentEmitRate1=n._currentEmitRate2,n._currentEmitRate2=t.getFactor(),n._currentEmitRateGradient=e),r=L.a.Lerp(n._currentEmitRate1,n._currentEmitRate2,i)}))}i=r*this._scaledUpdateSpeed>>0,this._newPartsExcess+=r*this._scaledUpdateSpeed-i}if(this._newPartsExcess>1&&(i+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?i=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(i),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene&&this._scene._toBeDisposed.push(this))),!e){for(var a=0,s=0;s=0&&(c.invertToRef(a.c.Matrix[0]),o.setMatrix("invView",a.c.Matrix[0])),void 0!==this._vertexArrayObject?(this._vertexArrayObject||(this._vertexArrayObject=this._engine.recordVertexArrayObject(this._vertexBuffers,this._indexBuffer,o)),this._engine.bindVertexArrayObject(this._vertexArrayObject,this._indexBuffer)):s.bindBuffers(this._vertexBuffers,this._indexBuffer,o),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(o),e){case t.BLENDMODE_ADD:s.setAlphaMode(g.a.ALPHA_ADD);break;case t.BLENDMODE_ONEONE:s.setAlphaMode(g.a.ALPHA_ONEONE);break;case t.BLENDMODE_STANDARD:s.setAlphaMode(g.a.ALPHA_COMBINE);break;case t.BLENDMODE_MULTIPLY:s.setAlphaMode(g.a.ALPHA_MULTIPLY)}return this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(o),this._useInstancing?s.drawArraysType(g.a.MATERIAL_TriangleStripDrawMode,0,4,this._particles.length):s.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 n=0;return n=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),n},t.prototype.dispose=function(e){if(void 0===e&&(e=!0),this.resetDrawCache(),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&&this._prepareSubEmitterInternalArray(),this._subEmitters&&this._subEmitters.length){for(var t=0;t-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,n){var i=Object(h.a)({},this._customWrappers),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"):"",s=o.createEffectForParticles(r.shaderPath.fragmentElement,r.shaderOptions.uniforms,r.shaderOptions.samplers,a);i[0]?i[0].effect=s:this.setCustomEffect(s,0)}var c=this.serialize(),u=t.Parse(c,this._scene||this._engine,this._rootUrl);return u.name=e,u.customShader=r,u._customWrappers=i,void 0===n&&(n=this.emitter),this.noiseTexture&&(u.noiseTexture=this.noiseTexture.clone()),u.emitter=n,this.preventAutoStart||u.start(),u},t.prototype.serialize=function(e){void 0===e&&(e=!1);var n={};if(t._Serialize(n,this,e),n.textureMask=this.textureMask.asArray(),n.customShader=this.customShader,n.preventAutoStart=this.preventAutoStart,this.subEmitters){n.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var i=0,r=this._subEmitters;i0?l.shaderOptions.defines.join("\n"):"";u=a.createEffectForParticles(l.shaderPath.fragmentElement,l.shaderOptions.uniforms,l.shaderOptions.samplers,h)}var d=new t(c,o||e.capacity,n,u,e.isAnimationSheetEnabled);if(d.customShader=l,d._rootUrl=i,e.id&&(d.id=e.id),e.subEmitters){d.subEmitters=[];for(var p=0,f=e.subEmitters;p0&&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._platform.releaseVertexBuffers(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype.getCustomEffect=function(e){var t,n;return void 0===e&&(e=0),null!==(n=null===(t=this._customWrappers[e])||void 0===t?void 0:t.effect)&&void 0!==n?n:this._customWrappers[0].effect},t.prototype._getCustomDrawWrapper=function(e){var t;return void 0===e&&(e=0),null!==(t=this._customWrappers[e])&&void 0!==t?t:this._customWrappers[0]},t.prototype.setCustomEffect=function(e,t){void 0===t&&(t=0),this._customWrappers[t]=new In.a(this._engine),this._customWrappers[t].effect=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,n,i){return e.prototype._removeGradientAndTexture.call(this,t,n,i),this._releaseBuffers(),this},t.prototype.addColorGradient=function(e,t,n){this._colorGradients||(this._colorGradients=[]);var i=new tg(e,t);return this._colorGradients.push(i),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.gradientt.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.resetDrawCache=function(){var e;for(var t in this._drawWrappers){null===(e=this._drawWrappers[t].drawContext)||void 0===e||e.reset()}},t.prototype._addFactorGradient=function(e,t,n){var i=new ig(t,n);e.push(i),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,n){if(void 0===n&&(n=!1),e){n&&e.sort((function(e,t){return e.gradientt.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,n){return this},t.prototype.removeEmitRateGradient=function(e){return this},t.prototype.addStartSizeGradient=function(e,t,n){return this},t.prototype.removeStartSizeGradient=function(e){return this},t.prototype.addColorRemapGradient=function(e,t,n){return this},t.prototype.removeColorRemapGradient=function(){return this},t.prototype.addAlphaRemapGradient=function(e,t,n){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,n){return this},t.prototype.removeLifeTimeGradient=function(e){return this},t.prototype._reset=function(){this._releaseBuffers()},t.prototype._createVertexBuffers=function(e,t,n){var i={};i.position=t.createVertexBuffer("position",0,3,this._attributesStrideSize,!0);var r=3;i.age=t.createVertexBuffer("age",r,1,this._attributesStrideSize,!0),r+=1,i.size=t.createVertexBuffer("size",r,3,this._attributesStrideSize,!0),r+=3,i.life=t.createVertexBuffer("life",r,1,this._attributesStrideSize,!0),r+=1,r+=4,this.billboardMode===ug.BILLBOARDMODE_STRETCHED&&(i.direction=t.createVertexBuffer("direction",r,3,this._attributesStrideSize,!0)),r+=3,this._platform.alignDataInBuffer&&(r+=1),this.particleEmitterType instanceof gh&&(r+=3,this._platform.alignDataInBuffer&&(r+=1)),this._colorGradientsTexture||(i.color=t.createVertexBuffer("color",r,4,this._attributesStrideSize,!0),r+=4),this._isBillboardBased||(i.initialDirection=t.createVertexBuffer("initialDirection",r,3,this._attributesStrideSize,!0),r+=3,this._platform.alignDataInBuffer&&(r+=1)),this.noiseTexture&&(i.noiseCoordinates1=t.createVertexBuffer("noiseCoordinates1",r,3,this._attributesStrideSize,!0),r+=3,this._platform.alignDataInBuffer&&(r+=1),i.noiseCoordinates2=t.createVertexBuffer("noiseCoordinates2",r,3,this._attributesStrideSize,!0),r+=3,this._platform.alignDataInBuffer&&(r+=1)),i.angle=t.createVertexBuffer("angle",r,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?r++:r+=2,this._isAnimationSheetEnabled&&(i.cellIndex=t.createVertexBuffer("cellIndex",r,1,this._attributesStrideSize,!0),r+=1,this.spriteRandomStartCell&&(i.cellStartOffset=t.createVertexBuffer("cellStartOffset",r,1,this._attributesStrideSize,!0),r+=1)),i.offset=n.createVertexBuffer("offset",0,2),i.uv=n.createVertexBuffer("uv",2,2),this._platform.createVertexBuffers(e,i),this.resetDrawCache()},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._engine,n=new Array;this._attributesStrideSize=21,this._targetIndex=0,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1),this.particleEmitterType instanceof gh&&(this._attributesStrideSize+=3,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1)),this.isBillboardBased||(this._attributesStrideSize+=3,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=1)),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,this._platform.alignDataInBuffer&&(this._attributesStrideSize+=2)),this._platform.alignDataInBuffer&&(this._attributesStrideSize+=3-(this._attributesStrideSize+3&3));for(var i=this.particleEmitterType instanceof gh,r=a.c.Vector3[0],o=0,s=0;s0;)n.push(0)}var u=new Float32Array([.5,.5,1,1,-.5,.5,0,1,.5,-.5,1,0,-.5,-.5,0,0]),l=this._platform.createParticleBuffer(n),h=this._platform.createParticleBuffer(n);this._buffer0=new bt.a(t,l,!1,this._attributesStrideSize),this._buffer1=new bt.a(t,h,!1,this._attributesStrideSize),this._spriteBuffer=new bt.a(t,u,!1,4),this._createVertexBuffers(this._buffer0,this._buffer1,this._spriteBuffer),this._createVertexBuffers(this._buffer1,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._platform.isUpdateBufferCreated()&&this._cachedUpdateDefines===e||(this._cachedUpdateDefines=e,this._updateBuffer=this._platform.createUpdateBuffer(e))},t.prototype._getWrapper=function(e){var t=this._getCustomDrawWrapper(e);if(null==t?void 0:t.effect)return t;var n=[];this.fillDefines(n,e);var i=this._drawWrappers[e];i||((i=new In.a(this._engine)).drawContext&&(i.drawContext.useInstancing=!0),this._drawWrappers[e]=i);var r=n.join("\n");if(i.defines!==r){var o=[],a=[],s=[];this.fillUniformsAttributesAndSamplerNames(a,o,s),i.setEffect(this._engine.createEffect("gpuRenderParticles",o,a,s,r),r)}return i},t._GetAttributeNamesOrOptions=function(e,t,n,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===n&&(n=!1),void 0===i&&(i=!1);var r=[bt.b.PositionKind,"age","life","size","angle"];return e||r.push(bt.b.ColorKind),t&&r.push("cellIndex"),n||r.push("initialDirection"),i||r.push("direction"),r.push("offset",bt.b.UVKind),r},t._GetEffectCreationOptions=function(e){void 0===e&&(e=!1);var t=["emitterWM","worldOffset","view","projection","colorDead","invView","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6","translationPivot","eyePosition"];return e&&t.push("sheetInfos"),t},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")),t===ug.BLENDMODE_MULTIPLY&&e.push("#define BLENDMULTIPLYMODE"),this.isLocal&&e.push("#define LOCAL"),this._isBillboardBased)switch(e.push("#define BILLBOARD"),this.billboardMode){case ug.BILLBOARDMODE_Y:e.push("#define BILLBOARDY");break;case ug.BILLBOARDMODE_STRETCHED:e.push("#define BILLBOARDSTRETCHED");break;case ug.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,n,i){n.push.apply(n,t._GetAttributeNamesOrOptions(!!this._colorGradientsTexture,this._isAnimationSheetEnabled,this._isBillboardBased,this._isBillboardBased&&this.billboardMode===ug.BILLBOARDMODE_STRETCHED)),e.push.apply(e,t._GetEffectCreationOptions(this._isAnimationSheetEnabled)),i.push("diffuseSampler","colorGradientSampler"),this._imageProcessingConfiguration&&(Ei.a.PrepareUniforms(e,this._imageProcessingConfigurationDefines),Ei.a.PrepareSamplers(i,this._imageProcessingConfigurationDefines))},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 n=this[t];if(e&&e.length&&!n){for(var i=new Float32Array(this._rawTextureWidth),r=0;r=0){var h=s.clone();h.invert(),o.setMatrix("invView",h)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(o),e){case ug.BLENDMODE_ADD:this._engine.setAlphaMode(g.a.ALPHA_ADD);break;case ug.BLENDMODE_ONEONE:this._engine.setAlphaMode(g.a.ALPHA_ONEONE);break;case ug.BLENDMODE_STANDARD:this._engine.setAlphaMode(g.a.ALPHA_COMBINE);break;case ug.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(g.a.ALPHA_MULTIPLY)}return this._platform.bindDrawBuffers(this._targetIndex,o),this._onBeforeDrawParticlesObservable&&this._onBeforeDrawParticlesObservable.notifyObservers(o),this._engine.drawArraysType(g.a.MATERIAL_TriangleStripDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(g.a.ALPHA_DISABLE),this._currentActiveCount},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),!this._started)return 0;if(this._createColorGradientTexture(),this._createSizeGradientTexture(),this._createAngularSpeedGradientTexture(),this._createVelocityGradientTexture(),this._createLimitVelocityGradientTexture(),this._createDragGradientTexture(),this._recreateUpdateEffect(),!this.isReady())return 0;if(!e&&this._scene){if(!this._preWarmDone&&this.preWarmCycles){for(var n=0;n1){var i=0|this._accumulatedCount;this._accumulatedCount-=i,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+i)}if(!this._currentActiveCount)return 0;var r;if(this.emitter.position){r=this.emitter.getWorldMatrix()}else{var o=this.emitter;r=a.a.Translation(o.x,o.y,o.z)}var s=this._engine;this._platform.preUpdateParticleBuffer(),this._updateBuffer.setFloat("currentCount",this._currentActiveCount),this._updateBuffer.setFloat("timeDelta",this._timeDelta),this._updateBuffer.setFloat("stopFactor",this._stopped?0:1),this._updateBuffer.setInt("randomTextureSize",this._randomTextureSize),this._updateBuffer.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateBuffer.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateBuffer.setDirectColor4("color1",this.color1),this._updateBuffer.setDirectColor4("color2",this.color2)),this._updateBuffer.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateBuffer.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateBuffer.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateBuffer.setVector3("gravity",this.gravity),this._limitVelocityGradientsTexture&&this._updateBuffer.setFloat("limitVelocityDamping",this.limitVelocityDamping),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateBuffer),this._isAnimationSheetEnabled&&this._updateBuffer.setFloat4("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed,this.spriteCellLoop?1:0),this.noiseTexture&&this._updateBuffer.setVector3("noiseStrength",this.noiseStrength),this.isLocal||this._updateBuffer.setMatrix("emitterWM",r),this._platform.updateParticleBuffer(this._targetIndex,this._targetBuffer,this._currentActiveCount);var c=0;e||t||(s.setState(!1),this.forceDepthWrite&&s.setDepthWrite(!0),c=this.blendMode===ug.BLENDMODE_MULTIPLYADD?this._render(ug.BLENDMODE_MULTIPLY,r)+this._render(ug.BLENDMODE_ADD,r):this._render(this.blendMode,r),this._engine.setAlphaMode(g.a.ALPHA_DISABLE)),this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var u=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=u,c},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),this._platform.releaseBuffers()},t.prototype.dispose=function(e){for(var t in void 0===e&&(e=!0),this._drawWrappers){this._drawWrappers[t].dispose()}if(this._drawWrappers={},this._scene){var n=this._scene.particleSystems.indexOf(this);n>-1&&this._scene.particleSystems.splice(n,1)}this._releaseBuffers(),this._platform.releaseVertexBuffers(),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,n){var i=Object(h.a)({},this._customWrappers),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"):"";i[0]=o.createEffectForParticles(r.shaderPath.fragmentElement,r.shaderOptions.uniforms,r.shaderOptions.samplers,a,void 0,void 0,void 0,this)}var s=this.serialize(),c=t.Parse(s,this._scene||this._engine,this._rootUrl);return c.name=e,c.customShader=r,c._customWrappers=i,void 0===n&&(n=this.emitter),this.noiseTexture&&(c.noiseTexture=this.noiseTexture.clone()),c.emitter=n,c},t.prototype.serialize=function(e){void 0===e&&(e=!1);var t={};return ug._Serialize(t,this,e),t.activeParticleCount=this.activeParticleCount,t.randomTextureSize=this._randomTextureSize,t.customShader=this.customShader,t},t.Parse=function(e,n,i,r,o){void 0===r&&(r=!1);var a,s=e.name;a=n instanceof Ve.a?n:n.getEngine();var c=new t(s,{capacity:o||e.capacity,randomTextureSize:e.randomTextureSize},n,null,e.isAnimationSheetEnabled);if(c._rootUrl=i,e.customShader&&a.createEffectForParticles){var u=e.customShader,l=u.shaderOptions.defines.length>0?u.shaderOptions.defines.join("\n"):"",h=a.createEffectForParticles(u.shaderPath.fragmentElement,u.shaderOptions.uniforms,u.shaderOptions.samplers,l,void 0,void 0,void 0,c);c.setCustomEffect(h,0),c.customShader=u}return e.id&&(c.id=e.id),e.activeParticleCount&&(c.activeParticleCount=e.activeParticleCount),ug._Parse(e,c,n,i),e.preventAutoStart&&(c.preventAutoStart=e.preventAutoStart),r||c.preventAutoStart||c.start(),c},t}(bh),_g=function(){function e(){this._emitterNodeIsOwned=!0,this.systems=new Array}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},set:function(e){this._emitterNodeIsOwned&&this._emitterNode&&(this._emitterNode.dispose&&this._emitterNode.dispose(),this._emitterNodeIsOwned=!1);for(var t=0,n=this.systems;t0&&n.set(this._uvs32,bt.b.UVKind),this._colors32.length>0&&n.set(this._colors32,bt.b.ColorKind),n.applyToMesh(this.mesh,this._updatable),this.mesh.isPickable=this._pickable,this._pickable)for(var i=0,r=0;rp?p:i,n=Math.round(p/i),r=0):n=n>p?p:n;for(var f=[],_=[],m=[],g=[],v=[],b=a.e.Zero(),y=n;dp-(n=y+Math.floor((1+r)*Math.random()))&&(n=p-d),f.length=0,_.length=0,m.length=0,g.length=0,v.length=0;for(var T=0,E=3*d;E<3*(d+n);E++){m.push(T);var S=s[E],A=3*S;if(f.push(o[A],o[A+1],o[A+2]),_.push(l[A],l[A+1],l[A+2]),c){var x=2*S;g.push(c[x],c[x+1])}if(u){var R=4*S;v.push(u[R],u[R+1],u[R+2],u[R+3])}T++}var C,P=this.nbParticles,O=this._posToShape(f),M=this._uvsToShapeUV(g),I=Re.b.Slice(m),D=Re.b.Slice(v),N=Re.b.Slice(_);for(b.copyFromFloats(0,0,0),C=0;C65535&&(this._needs32Bits=!0)}if(this._depthSort||this._multimaterialEnabled){var U=null!==T.materialIndex?T.materialIndex:0;this.depthSortedParticles.push(new yg(p,t,r.length,U))}return T},e.prototype._posToShape=function(e){for(var t=[],n=0;n=this.nbParticles||!this._updatable)return[];var i=this.particles,r=this.nbParticles;if(t=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var L=this.mesh.getBoundingInfo();L&&(v.copyFrom(L.minimum),b.copyFrom(L.maximum))}var F=(P=this.particles[e]._pos)/3|0;M=4*F,D=2*F;for(var w=e;w<=t;w++){var B=this.particles[w];this.updateParticle(B);var U=B._model._shape,V=B._model._shapeUV,k=B._rotationMatrix,G=B.position,z=B.rotation,j=B.scaling,W=B._globalPosition;if(this._depthSort&&this._depthSortParticles){var H=this.depthSortedParticles[w];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)P+=3*(N=U.length),M+=4*N,D+=2*N;else{if(B.isVisible){B._stillInvisible=!1;var X=f[12];if(B.pivot.multiplyToRef(j,X),this.billboard&&(z.x=0,z.y=0),(this._computeParticleRotation||this.billboard)&&B.getRotationMatrix(i),null!==B.parentId){var Y=this.getParticleById(B.parentId);if(Y){var K=Y._rotationMatrix,Q=Y._globalPosition,q=G.x*K[1]+G.y*K[4]+G.z*K[7],Z=G.x*K[0]+G.y*K[3]+G.z*K[6],$=G.x*K[2]+G.y*K[5]+G.z*K[8];if(W.x=Q.x+Z,W.y=Q.y+q,W.z=Q.z+$,this._computeParticleRotation||this.billboard){var ee=i.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=G.x,W.y=G.y,W.z=G.z,this._computeParticleRotation||this.billboard){ee=i.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=f[11];for(B.translateFromPivot?te.setAll(0):te.copyFrom(X),N=0;N0)for(var t=0;t0&&t.set(this._uvs32,bt.b.UVKind);var n=0;this._colors32.length>0&&(n=1,t.set(this._colors32,bt.b.ColorKind));var i=new Te.a(this.name,this._scene);t.applyToMesh(i,this._updatable),this.mesh=i,this._positions=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0);var r=e;return r||((r=new Si.a("point cloud material",this._scene)).emissiveColor=new s.a(n,n,n),r.disableLighting=!0,r.pointsCloud=!0,r.pointSize=this._size),i.material=r,new Promise((function(e){return e(i)}))},e.prototype._addParticle=function(e,t,n,i){var r=new Sg(e,t,n,i,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,n,i){var r=e._groupImageData,o=n*(4*i)+4*t,a=[o,o+1,o+2,o+3],c=a[1],u=a[2],l=a[3],h=r[a[0]],d=r[c],p=r[u],f=r[l];return new s.b(h/255,d/255,p/255,f)},e.prototype._setPointsColorOrUV=function(e,t,n,i,r,o,c){n&&e.updateFacetData();var u=2*e.getBoundingInfo().boundingSphere.radius,l=e.getVerticesData(bt.b.PositionKind),h=e.getIndices(),d=e.getVerticesData(bt.b.UVKind),p=e.getVerticesData(bt.b.ColorKind),f=a.e.Zero();e.computeWorldMatrix();var _=e.getWorldMatrix();if(!_.isIdentity()){l=l.slice(0);for(var m=0;m1&&(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),Fe.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,n){var i=this;if(null===e.material)return m.a.Warn(e.name+"has no material."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,n,!0,!1);var r=e.material.getActiveTextures();if(0===r.length)return m.a.Warn(e.name+"has no usable texture."),t._groupImageData=null,void this._setPointsColorOrUV(e,t,n,!0,!1);var o=e.clone();o.setEnabled(!1),this._promises.push(new Promise((function(e){Kr.a.WhenAllReady(r,(function(){var a=t._textureNb;a<0&&(a=0),a>r.length-1&&(a=r.length-1);var s=function(){t._groupImgWidth=r[a].getSize().width,t._groupImgHeight=r[a].getSize().height,i._setPointsColorOrUV(o,t,n,!0,!0),o.dispose(),e()};t._groupImageData=null;var c=r[a].readPixels();c?c.then((function(e){t._groupImageData=e,s()})):s()}))})))},e.prototype._calculateDensity=function(e,t,n){for(var i,r,o,s,c,u,l,h,d,p,f,_,m,g,v,b,y,T=new Array,E=a.e.Zero(),S=a.e.Zero(),A=a.e.Zero(),x=a.e.Zero(),R=a.e.Zero(),C=a.e.Zero(),P=new Array,O=0,M=n.length/3,I=0;I0&&(T=T.map((function(e){return e+L})));for(I=0;I3)&&(o=gg.Random);var a=e.getVerticesData(bt.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var u=new Ag(this._groupCounter,null);switch(u._groupDensity=this._calculateDensity(t,a,c),o===gg.Color?u._textureNb=i||0:i=i||new s.b(1,1,1,1),o){case gg.Color:this._colorFromTexture(e,u,!1);break;case gg.UV:this._setPointsColorOrUV(e,u,!1,!1,!1);break;case gg.Random:this._setPointsColorOrUV(e,u,!1);break;case gg.Stated:this._setPointsColorOrUV(e,u,!1,void 0,void 0,i,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.addVolumePoints=function(e,t,n,i,r){var o=n||gg.Random;(isNaN(o)||o<0||o>3)&&(o=gg.Random);var a=e.getVerticesData(bt.b.PositionKind),c=e.getIndices();this._groups.push(this._groupCounter);var u=new Ag(this._groupCounter,null);switch(u._groupDensity=this._calculateDensity(t,a,c),o===gg.Color?u._textureNb=i||0:i=i||new s.b(1,1,1,1),o){case gg.Color:this._colorFromTexture(e,u,!0);break;case gg.UV:this._setPointsColorOrUV(e,u,!0,!1,!1);break;case gg.Random:this._setPointsColorOrUV(e,u,!0);break;case gg.Stated:this._setPointsColorOrUV(e,u,!0,void 0,void 0,i,r)}return this.nbParticles+=t,this._groupCounter++,this._groupCounter-1},e.prototype.setParticles=function(e,t,n){if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===n&&(n=!0),!this._updatable||!this._isReady)return this;this.beforeUpdateParticles(e,t,n);var i=a.c.Matrix[0],r=this.mesh,o=this._colors32,s=this._positions32,c=this._uvs32,u=a.c.Vector3,l=u[5].copyFromFloats(1,0,0),h=u[6].copyFromFloats(0,1,0),d=u[7].copyFromFloats(0,0,1),p=u[8].setAll(Number.MAX_VALUE),f=u[9].setAll(-Number.MAX_VALUE);a.a.IdentityToRef(i);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.getBoundingInfo();m&&(p.copyFrom(m.minimum),f.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(i),null!==T.parentId){var x=this.particles[T.parentId],R=x._rotationMatrix,C=x._globalPosition,P=S.x*R[1]+S.y*R[4]+S.z*R[7],O=S.x*R[0]+S.y*R[3]+S.z*R[6],M=S.x*R[2]+S.y*R[5]+S.z*R[8];if(A.x=C.x+O,A.y=C.y+P,A.z=C.z+M,this._computeParticleRotation){var I=i.m;E[0]=I[0]*R[0]+I[1]*R[3]+I[2]*R[6],E[1]=I[0]*R[1]+I[1]*R[4]+I[2]*R[7],E[2]=I[0]*R[2]+I[1]*R[5]+I[2]*R[8],E[3]=I[4]*R[0]+I[5]*R[3]+I[6]*R[6],E[4]=I[4]*R[1]+I[5]*R[4]+I[6]*R[7],E[5]=I[4]*R[2]+I[5]*R[5]+I[6]*R[8],E[6]=I[8]*R[0]+I[9]*R[3]+I[10]*R[6],E[7]=I[8]*R[1]+I[9]*R[4]+I[10]*R[7],E[8]=I[8]*R[2]+I[9]*R[5]+I[10]*R[8]}}else if(A.x=0,A.y=0,A.z=0,this._computeParticleRotation){I=i.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=u[11];T.translateFromPivot?D.setAll(0):D.copyFrom(T.pivot);var N=u[0];N.copyFrom(T.position);var L=N.x-T.pivot.x,F=N.y-T.pivot.y,w=N.z-T.pivot.z,B=L*E[0]+F*E[3]+w*E[6],U=L*E[1]+F*E[4]+w*E[7],V=L*E[2]+F*E[5]+w*E[8];B+=D.x,U+=D.y,V+=D.z;var k=s[g]=A.x+l.x*B+h.x*U+d.x*V,G=s[g+1]=A.y+l.y*B+h.y*U+d.y*V,z=s[g+2]=A.z+l.z*B+h.z*U+d.z*V;if(this._computeBoundingBox&&(p.minimizeInPlaceFromFloats(k,G,z),f.maximizeInPlaceFromFloats(k,G,z)),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 n&&(this._computeParticleColor&&r.updateVerticesData(bt.b.ColorKind,o,!1,!1),this._computeParticleTexture&&r.updateVerticesData(bt.b.UVKind,c,!1,!1),r.updateVerticesData(bt.b.PositionKind,s,!1,!1)),this._computeBoundingBox&&(r.hasBoundingInfo?r.getBoundingInfo().reConstruct(p,f,r._worldMatrix):r.buildBoundingInfo(p,f,r._worldMatrix)),this.afterUpdateParticles(e,t,n),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.buildBoundingInfo(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,n){},e.prototype.afterUpdateParticles=function(e,t,n){},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 n=this._getComponent(Ne.a.NAME_PHYSICSENGINE);n||(n=new Pg(this),this._addComponent(n));try{return this._physicsEngine=new np(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(ot.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}),ot.a.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},ot.a.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},ot.a.prototype.setPhysicsLinkWith=function(e,t,n,i){return this.physicsImpostor&&e.physicsImpostor?(this.physicsImpostor.createJoint(e.physicsImpostor,tp.e.HingeJoint,{mainPivot:t,connectedPivot:n,nativeParams:i}),this):this};var Rg,Cg,Pg=function(){function e(e){var t=this;this.name=Ne.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}(),Og=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,n,i){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 Lg).radius=t,t.strength=n||t.strength,t.falloff=i||t.falloff);var o=new Mg(this._scene,t),a=Array();return r.forEach((function(t){var n=o.getImpostorHitData(t,e);n&&(t.applyImpulse(n.force,n.contactPoint),a.push({impostor:t,hitData:n}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.applyRadialExplosionForce=function(e,t,n,i){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 Lg).radius=t,t.strength=n||t.strength,t.falloff=i||t.falloff);var o=new Mg(this._scene,t),a=Array();return r.forEach((function(t){var n=o.getImpostorHitData(t,e);n&&(t.applyForce(n.force,n.contactPoint),a.push({impostor:t,hitData:n}))})),o.triggerAffectedImpostorsCallback(a),o.dispose(!1),o},e.prototype.gravitationalField=function(e,t,n,i){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 Lg).radius=t,t.strength=n||t.strength,t.falloff=i||t.falloff);var r=new Ig(this,this._scene,e,t);return r.dispose(!1),r},e.prototype.updraft=function(e,t,n,i,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 Fg).radius=t,t.strength=n||t.strength,t.height=i||t.height,t.updraftMode=r||t.updraftMode);var o=new Dg(this._scene,e,t);return o.dispose(!1),o},e.prototype.vortex=function(e,t,n,i){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 wg).radius=t,t.strength=n||t.strength,t.height=i||t.height);var r=new Ng(this._scene,e,t);return r.dispose(!1),r},e}(),Mg=function(){function e(e,t){this._scene=e,this._options=t,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Lg),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 n=e.getObjectCenter().subtract(t),i=new pn.a(t,n,this._options.radius).intersectsMesh(e.object).pickedPoint;if(!i)return null;var r=a.e.Distance(t,i);if(r>this._options.radius)return null;var o=this._options.falloff===Rg.Constant?this._options.strength:this._options.strength*(1-r/this._options.radius);return{force:n.multiplyByFloats(o,o,o),contactPoint:i,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=Object(ac.a)("radialExplosionEventSphere",this._options.sphere,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,n){var i=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new a.e(2*n,2*n,2*n),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(i,!0)},e}(),Ig=function(){function e(e,t,n,i){this._physicsHelper=e,this._scene=t,this._origin=n,this._options=i,this._dataFetched=!1,this._options=Object(h.a)(Object(h.a)({},new Lg),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}(),Dg=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,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 Fg),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===Cg.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===Cg.Perpendicular)var n=this._originDirection;else n=t.subtract(this._originTop);var i=a.e.Distance(this._origin,t),r=-1*this._options.strength;return{force:n.multiplyByFloats(r,r,r),contactPoint:t,distanceFromOrigin:i}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var n=e.getImpostorHitData(t);n&&t.applyForce(n.force,n.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=Object(ki.a)("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}(),Ng=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,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 wg),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(),n=new a.e(this._origin.x,t.y,this._origin.z),i=t.subtract(n),r=new pn.a(n,i,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 u=c.x*this._options.centripetalForceMultiplier,l=c.y*this._options.updraftForceMultiplier,h=c.z*this._options.centripetalForceMultiplier;else{var d=a.e.Cross(n,t).normalize();u=(d.x+c.x)*this._options.centrifugalForceMultiplier,l=this._originTop.y*this._options.updraftForceMultiplier,h=(d.z+c.z)*this._options.centrifugalForceMultiplier}var p=new a.e(u,l,h);return{force:p=p.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 n=e.getImpostorHitData(t);n&&t.applyForce(n.force,n.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=Object(ki.a)("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}(),Lg=function(){this.radius=5,this.strength=10,this.falloff=Rg.Constant,this.sphere={segments:32,diameter:1}},Fg=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=Cg.Center},wg=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"}(Rg||(Rg={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(Cg||(Cg={}));var Bg="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\n#define CUSTOM_FRAGMENT_DEFINITIONS\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}";Cn.a.ShadersStore.blackAndWhitePixelShader=Bg;var Ug=function(e){function t(t,n,i,r,o,a){var s=e.call(this,t,"blackAndWhite",["degree"],null,n,i,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,n,i,r){return F.a.Parse((function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)}),e,i,r)},Object(h.c)([Object(F.d)()],t.prototype,"degree",void 0),t}(Dn);Object(c.b)("BABYLON.BlackAndWhitePostProcess",Ug);var Vg=function(){function e(e,t,n,i){this._name=t,this._singleInstance=i||!0,this._getPostProcesses=n,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],n=0;n-1?"#define MALI 1\n":null},t._Parse=function(e,n,i,r){return F.a.Parse((function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)}),e,i,r)},t}(Dn);Object(c.b)("BABYLON.FxaaPostProcess",hv);var dv="#include\n\nuniform sampler2D textureSampler;\n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\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}";Cn.a.ShadersStore.grainPixelShader=dv;var pv=function(e){function t(t,n,i,r,o,a,s,c){void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var u=e.call(this,t,"grain",["intensity","animatedSeed"],[],n,i,r,o,a,null,s,void 0,null,c)||this;return u.intensity=30,u.animated=!1,u.onApplyObservable.add((function(e){e.setFloat("intensity",u.intensity),e.setFloat("animatedSeed",u.animated?Math.random()+1:1)})),u}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"GrainPostProcess"},t._Parse=function(e,n,i,r){return F.a.Parse((function(){return new t(e.name,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.reusable)}),e,i,r)},Object(h.c)([Object(F.d)()],t.prototype,"intensity",void 0),Object(h.c)([Object(F.d)()],t.prototype,"animated",void 0),t}(Dn);Object(c.b)("BABYLON.GrainPostProcess",pv);var fv="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\n#define CUSTOM_FRAGMENT_DEFINITIONS\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}";Cn.a.ShadersStore.highlightsPixelShader=fv;var _v=function(e){function t(t,n,i,r,o,a,s){return void 0===s&&(s=g.a.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,"highlights",null,null,n,i,r,o,a,null,s)||this}return Object(h.d)(t,e),t.prototype.getClassName=function(){return"HighlightsPostProcess"},t}(Dn),mv="#if defined(WEBGL2) || defined(WEBGPU)\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";Cn.a.IncludesShadersStore.mrtFragmentDeclaration=mv;var gv="#extension GL_EXT_draw_buffers : require\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\nprecision highp float;\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#if defined(REFLECTIVITY) && (defined(HAS_SPECULAR) || defined(HAS_REFLECTIVITY))\nvarying vec2 vReflectivityUV;\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef ALPHATEST\nuniform sampler2D diffuseSampler;\n#endif\n#include[RENDER_TARGET_COUNT]\n#include\n#include\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\nnormalOutput=normalize(vec3(vWorldView*vec4(normalW,0.0)));\n#else\nnormalOutput=normalize(vNormalV);\n#endif\n#ifdef PREPASS\n#ifdef PREPASS_DEPTH\ngl_FragData[DEPTH_INDEX]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n#endif\n#ifdef PREPASS_NORMAL\ngl_FragData[NORMAL_INDEX]=vec4(normalOutput,1.0);\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}\n";Cn.a.ShadersStore.geometryPixelShader=gv;Cn.a.IncludesShadersStore.geometryVertexDeclaration="\nuniform mat4 viewProjection;\nuniform mat4 view;";Cn.a.IncludesShadersStore.geometryUboDeclaration="#include";var vv="precision highp float;\n#include\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include<__decl__geometryVertex>\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#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 previousViewProjection;\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void)\n{\nvec3 positionUpdated=position;\nvec3 normalUpdated=normal;\n#ifdef UV1\nvec2 uvUpdated=uv;\n#endif\n#include\n#include[0..maxSimultaneousMorphTargets]\n#include\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvPreviousPosition=previousViewProjection*finalPreviousWorld*vec4(positionUpdated,1.0);\n#endif\n#include\n#include\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*finalPreviousWorld*previousInfluence*vec4(positionUpdated,1.0);\n#else\nvPreviousPosition=previousViewProjection*finalPreviousWorld*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#if defined(ALPHATEST) && defined(ALPHATEST_UV1)\nvUV=vec2(diffuseMatrix*vec4(uvUpdated,1.0,0.0));\n#else\nvUV=uv;\n#endif\n#ifdef BUMP_UV1\nvBumpUV=vec2(bumpMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV1\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uvUpdated,1.0,0.0));\n#endif\n#endif\n#ifdef UV2\n#if defined(ALPHATEST) && defined(ALPHATEST_UV2)\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#else\nvUV=uv2;\n#endif\n#ifdef BUMP_UV2\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n#endif\n#ifdef REFLECTIVITY_UV2\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#endif\n#include\n}\n";Cn.a.ShadersStore.geometryVertexShader=vv;var bv=function(){function e(t,n){void 0===n&&(n=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._depthIndex=-1,this._normalIndex=-1,this._linkedWithPrePass=!1,this._scene=t,this._ratio=n,this._useUbo=t.getEngine().supportsUniformBuffers,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,n){t===e.POSITION_TEXTURE_TYPE?(this._positionIndex=n,this._enablePosition=!0):t===e.VELOCITY_TEXTURE_TYPE?(this._velocityIndex=n,this._enableVelocity=!0):t===e.REFLECTIVITY_TEXTURE_TYPE?(this._reflectivityIndex=n,this._enableReflectivity=!0):t===e.DEPTH_TEXTURE_TYPE?this._depthIndex=n:t===e.NORMAL_TEXTURE_TYPE&&(this._normalIndex=n)},e.prototype._setAttachments=function(e){this._attachments=e},e.prototype._linkInternalTexture=function(e){this._multiRenderTarget.setInternalTexture(e,0,!1)},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()),this._scene.needsPreviousWorldMatrices=e},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 n=e.getMaterial();if(n&&n.disableDepthWrite)return!1;var i=[],r=[bt.b.PositionKind,bt.b.NormalKind],o=e.getMesh();if(n){var a=!1;n.needAlphaTesting()&&n.getAlphaTestTexture()&&(i.push("#define ALPHATEST"),i.push("#define ALPHATEST_UV".concat(n.getAlphaTestTexture().coordinatesIndex+1)),a=!0),n.bumpTexture&&jc.a.BumpTextureEnabled&&(i.push("#define BUMP"),i.push("#define BUMP_UV".concat(n.bumpTexture.coordinatesIndex+1)),a=!0),this._enableReflectivity&&(n.specularTexture?(i.push("#define HAS_SPECULAR"),i.push("#define REFLECTIVITY_UV".concat(n.specularTexture.coordinatesIndex+1)),a=!0):n.reflectivityTexture&&(i.push("#define HAS_REFLECTIVITY"),i.push("#define REFLECTIVITY_UV".concat(n.reflectivityTexture.coordinatesIndex+1)),a=!0)),a&&(i.push("#define NEED_UV"),o.isVerticesDataPresent(bt.b.UVKind)&&(r.push(bt.b.UVKind),i.push("#define UV1")),o.isVerticesDataPresent(bt.b.UV2Kind)&&(r.push(bt.b.UV2Kind),i.push("#define UV2")))}this._linkedWithPrePass&&(i.push("#define PREPASS"),-1!==this._depthIndex&&(i.push("#define DEPTH_INDEX "+this._depthIndex),i.push("#define PREPASS_DEPTH")),-1!==this._normalIndex&&(i.push("#define NORMAL_INDEX "+this._normalIndex),i.push("#define PREPASS_NORMAL"))),this._enablePosition&&(i.push("#define POSITION"),i.push("#define POSITION_INDEX "+this._positionIndex)),this._enableVelocity&&(i.push("#define VELOCITY"),i.push("#define VELOCITY_INDEX "+this._velocityIndex),-1===this.excludedSkinnedMeshesFromVelocity.indexOf(o)&&i.push("#define BONES_VELOCITY_ENABLED")),this._enableReflectivity&&(i.push("#define REFLECTIVITY"),i.push("#define REFLECTIVITY_INDEX "+this._reflectivityIndex)),o.useBones&&o.computeBonesUsingShaders?(r.push(bt.b.MatricesIndicesKind),r.push(bt.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(r.push(bt.b.MatricesIndicesExtraKind),r.push(bt.b.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),i.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0");var s=o.morphTargetManager,c=0;s&&s.numInfluencers>0&&(c=s.numInfluencers,i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+c),s.isUsingTextureForTargets&&i.push("#define MORPHTARGETS_TEXTURE"),kc.a.PrepareAttributesForMorphTargetsInfluencers(r,o,c)),t&&(i.push("#define INSTANCES"),kc.a.PushAttributesForInstances(r,this._enableVelocity),e.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES")),this._linkedWithPrePass?i.push("#define RENDER_TARGET_COUNT "+this._attachments.length):i.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var u=e._getDrawWrapper(void 0,!0),l=u.defines,h=i.join("\n");return l!==h&&u.setEffect(this._scene.getEngine().createEffect("geometry",{attributes:r,uniformsNames:["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones","bumpMatrix","reflectivityMatrix","vTangentSpaceParams","vBumpInfos","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices"],samplers:["diffuseSampler","bumpSampler","reflectivitySampler","morphTargets"],defines:h,onCompiled:null,fallbacks:null,onError:null,uniformBuffersNames:["Scene"],indexParameters:{buffersCount:this._multiRenderTarget.textures.length-1,maxSimultaneousMorphTargets:c}},this._scene.getEngine()),h),u.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=[],t=2;return e.push("gBuffer_Depth","gBuffer_Normal"),this._enablePosition&&(this._positionIndex=t,t++,e.push("gBuffer_Position")),this._enableVelocity&&(this._velocityIndex=t,t++,e.push("gBuffer_Velocity")),this._enableReflectivity&&(this._reflectivityIndex=t,t++,e.push("gBuffer_Reflectivity")),[t,e]},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),n=this._assignRenderTargetIndices(),i=n[0],r=n[1],o=g.a.TEXTURETYPE_UNSIGNED_BYTE;if(t._caps.textureFloat&&t._caps.textureFloatLinearFiltering?o=g.a.TEXTURETYPE_FLOAT:t._caps.textureHalfFloat&&t._caps.textureHalfFloatLinearFiltering&&(o=g.a.TEXTURETYPE_HALF_FLOAT),this._multiRenderTarget=new Xp("gBuffer",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},i,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:o},r.concat("gBuffer_DepthBuffer")),this.isSupported){this._multiRenderTarget.wrapU=Be.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Be.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,0),!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 c=function(t){var n=t.getRenderingMesh(),i=t.getEffectiveMesh(),r=e._scene,o=r.getEngine(),s=t.getMaterial();if(s){if(i._internalAbstractMeshDataInfo._isActiveIntermediate=!1,e._enableVelocity&&!e._previousTransformationMatrices[i.uniqueId]&&(e._previousTransformationMatrices[i.uniqueId]={world:a.a.Identity(),viewProjection:r.getTransformMatrix()},n.skeleton)){var c=n.skeleton.getTransformMatrices(n);e._previousBonesTransformationMatrices[n.uniqueId]=e._copyBonesTransformationMatrices(c,new Float32Array(c.length))}var u=n._getInstancesRenderList(t._id,!!t.getReplacementMesh());if(!u.mustReturn){var l=o.getCaps().instancedArrays&&(null!==u.visibleInstances[t._id]||n.hasThinInstances),h=i.getWorldMatrix();if(e.isReady(t,l)){var d=t._getDrawWrapper();if(!d)return;var p=d.effect;if(o.enableEffect(d),l||n._bind(t,p,s.fillMode),e._useUbo?(kc.a.BindSceneUniformBuffer(p,e._scene.getSceneUniformBuffer()),e._scene.finalizeSceneUbo()):(p.setMatrix("viewProjection",r.getTransformMatrix()),p.setMatrix("view",r.getViewMatrix())),s){var f=void 0,_=n._instanceDataStorage;if(_.isFrozen||!s.backFaceCulling&&null===n.overrideMaterialSideOrientation)f=_.sideOrientation;else{var m=i._getWorldMatrixDeterminant();null===(f=n.overrideMaterialSideOrientation)&&(f=s.sideOrientation),m<0&&(f=f===cu.a.ClockWiseSideOrientation?cu.a.CounterClockWiseSideOrientation:cu.a.ClockWiseSideOrientation)}if(s._preBind(d,f),s.needAlphaTesting()){var g=s.getAlphaTestTexture();g&&(p.setTexture("diffuseSampler",g),p.setMatrix("diffuseMatrix",g.getTextureMatrix()))}s.bumpTexture&&r.getEngine().getCaps().standardDerivatives&&jc.a.BumpTextureEnabled&&(p.setFloat3("vBumpInfos",s.bumpTexture.coordinatesIndex,1/s.bumpTexture.level,s.parallaxScaleBias),p.setMatrix("bumpMatrix",s.bumpTexture.getTextureMatrix()),p.setTexture("bumpSampler",s.bumpTexture),p.setFloat2("vTangentSpaceParams",s.invertNormalMapX?-1:1,s.invertNormalMapY?-1:1)),e._enableReflectivity&&(s.specularTexture?(p.setMatrix("reflectivityMatrix",s.specularTexture.getTextureMatrix()),p.setTexture("reflectivitySampler",s.specularTexture)):s.reflectivityTexture&&(p.setMatrix("reflectivityMatrix",s.reflectivityTexture.getTextureMatrix()),p.setTexture("reflectivitySampler",s.reflectivityTexture)))}n.useBones&&n.computeBonesUsingShaders&&n.skeleton&&(p.setMatrices("mBones",n.skeleton.getTransformMatrices(n)),e._enableVelocity&&p.setMatrices("mPreviousBones",e._previousBonesTransformationMatrices[n.uniqueId])),kc.a.BindMorphTargetParameters(n,p),n.morphTargetManager&&n.morphTargetManager.isUsingTextureForTargets&&n.morphTargetManager._bind(p),e._enableVelocity&&(p.setMatrix("previousWorld",e._previousTransformationMatrices[i.uniqueId].world),p.setMatrix("previousViewProjection",e._previousTransformationMatrices[i.uniqueId].viewProjection)),l&&n.hasThinInstances&&p.setMatrix("world",h),n._processRendering(i,t,p,s.fillMode,u,l,(function(e,t){e||p.setMatrix("world",t)}))}e._enableVelocity&&(e._previousTransformationMatrices[i.uniqueId].world=h.clone(),e._previousTransformationMatrices[i.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),n.skeleton&&e._copyBonesTransformationMatrices(n.skeleton.getTransformMatrices(n),e._previousBonesTransformationMatrices[i.uniqueId]))}}};this._multiRenderTarget.customIsReadyFunction=function(n,i){if(!n.isReady(!1))return!1;if(0===i&&n.subMeshes)for(var r=0;r0){var n=this._renderEffects[t[0]].getPostProcesses();n&&(n[0].samples=e)}return!0},e.prototype.setPrePassRenderer=function(e){return!1},e.prototype.dispose=function(){},Object(h.c)([Object(F.d)()],e.prototype,"_name",void 0),e}(),Ov=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 n=this._renderPipelines[t];n.isSupported&&e.push(n)}return e},enumerable:!1,configurable:!0}),e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,n){void 0===n&&(n=!1);var i=this._renderPipelines[e];i&&i._attachCameras(t,n)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var n=this._renderPipelines[e];n&&n._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,n){var i=this._renderPipelines[e];i&&i._enableEffect(t,n)},e.prototype.disableEffectInPipeline=function(e,t,n){var i=this._renderPipelines[e];i&&i._disableEffect(t,n)},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(Ne.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new Mv(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new Ov}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var Mv=function(){function e(e){this.name=Ne.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(Ne.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}(),Iv=function(e){function t(t,n,i,r,a){void 0===t&&(t=""),void 0===n&&(n=!0),void 0===i&&(i=P.a.LastCreatedScene),void 0===a&&(a=!0);var s=e.call(this,i.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=tv.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||i.cameras,s._cameras=s._cameras.slice(),s._camerasToBeAttached=s._cameras.slice(),s._buildAllowed=a,s._scene=i;var c=s._scene.getEngine().getCaps();s._hdr=n&&(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,i.postProcessRenderPipelineManager.addPipeline(s);var u=s._scene.getEngine();return s.sharpen=new Cv("sharpen",1,null,Be.a.BILINEAR_SAMPLINGMODE,u,!1,s._defaultPipelineTextureType,!0),s._sharpenEffect=new Vg(u,s.SharpenPostProcessId,(function(){return s.sharpen}),!0),s.depthOfField=new rv(s._scene,null,s._depthOfFieldBlurLevel,s._defaultPipelineTextureType,!0),s.bloom=new Wg(s._scene,s._bloomScale,s._bloomWeight,s.bloomKernel,s._defaultPipelineTextureType,!0),s.chromaticAberration=new Xg("ChromaticAberration",u.getRenderWidth(),u.getRenderHeight(),1,null,Be.a.BILINEAR_SAMPLINGMODE,u,!1,s._defaultPipelineTextureType,!0),s._chromaticAberrationEffect=new Vg(u,s.ChromaticAberrationPostProcessId,(function(){return s.chromaticAberration}),!0),s.grain=new pv("Grain",1,null,Be.a.BILINEAR_SAMPLINGMODE,u,!1,s._defaultPipelineTextureType,!0),s._grainEffect=new Vg(u,s.GrainPostProcessId,(function(){return s.grain}),!0),s._resizeObserver=u.onResizeObservable.add((function(){s._hardwareScaleLevel=u.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 Wg(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var t=0;t1){for(var n=0,i=this._cameras;n-1&&(e.depthOfField.depthTexture=t.enableDepthRenderer(t.activeCamera).getDepthMap())}))}else{this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);var o=this._scene.enableDepthRenderer(this._cameras[0]);this.depthOfField.depthTexture=o.getDepthMap()}this.depthOfField._isReady()||this.depthOfField._updateEffects(),this.addEffect(this.depthOfField),this._setAutoClearAndTextureSharing(this.depthOfField._effects[0],!0)}else this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);this.bloomEnabled&&(this.bloom._isReady()||this.bloom._updateEffects(),this.addEffect(this.bloom),this._setAutoClearAndTextureSharing(this.bloom._effects[0],!0)),this._imageProcessingEnabled&&(this.imageProcessing=new Pi("imageProcessing",1,null,Be.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new Vg(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 hv("fxaa",1,null,Be.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new Vg(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;t1e-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; i1.0 || offset.y>1.0) {\ncontinue;\n}\n\nfloat sampleDepth=abs(texture2D(depthSampler,offset.xy).r);\n\ndifference=depthSign*samplePosition.z-sampleDepth;\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\n}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i0?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._geometryBufferRenderer?e.setTexture("depthSampler",i._geometryBufferRenderer.getGBuffer().textures[0]):i._prePassRenderer&&e.setTexture("depthSampler",i._prePassRenderer.getRenderTarget().textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTH_TEXTURE_TYPE)]),e.setArray("samplerOffsets",i._samplerOffsets))},this._blurVPostProcess=new Dn("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],t,null,Be.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(r?"1":"0")+"\n",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._geometryBufferRenderer?e.setTexture("depthSampler",i._geometryBufferRenderer.getGBuffer().textures[0]):i._prePassRenderer&&e.setTexture("depthSampler",i._prePassRenderer.getRenderTarget().textures[i._prePassRenderer.getIndex(g.a.PREPASS_DEPTH_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 n=2*t*Math.PI,i=1-(.85*e+.15),r=Math.sqrt(1-i*i);return new a.e(Math.cos(n)*r,Math.sin(n)*r,i)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,n=[],i=0;i0.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*=stepSize;\nfor(int i=0; i>0)),e.push("#define SMOOTH_STEPS "+(this._smoothSteps>>0)),this.updateEffect(e.join("\n"))},t._Parse=function(e,n,i,r){return F.a.Parse((function(){return new t(e.name,i,e.options,n,e.renderTargetSamplingMode,i.getEngine(),e.textureType,e.reusable)}),e,i,r)},Object(h.c)([Object(F.d)()],t.prototype,"threshold",void 0),Object(h.c)([Object(F.d)()],t.prototype,"strength",void 0),Object(h.c)([Object(F.d)()],t.prototype,"reflectionSpecularFalloffExponent",void 0),Object(h.c)([Object(F.d)()],t.prototype,"step",void 0),Object(h.c)([Object(F.d)()],t.prototype,"roughnessFactor",void 0),Object(h.c)([Object(F.d)()],t.prototype,"enableSmoothReflections",null),Object(h.c)([Object(F.d)()],t.prototype,"reflectionSamples",null),Object(h.c)([Object(F.d)()],t.prototype,"smoothSteps",null),t}(Dn);Object(c.b)("BABYLON.ScreenSpaceReflectionPostProcess",jv);var Wv="uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#define CUSTOM_FRAGMENT_DEFINITIONS\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 (luminanceshadowPixelDepth)\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\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=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";Cn.a.ShadersStore.standardPixelShader=Wv;var Hv=function(e){function t(t,n,i,r,o){void 0===r&&(r=null);var a=e.call(this,n.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||n.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._scene=n,a._basePostProcess=r,a._ratio=i,a._floatTextureType=n.getEngine().getCaps().textureFloatRender?g.a.TEXTURETYPE_FLOAT:g.a.TEXTURETYPE_HALF_FLOAT,n.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,n=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 jv("HDRPass",n,t,null,Be.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,this._floatTextureType),this.screenSpaceReflectionPostProcess.onApplyObservable.add((function(){e._currentDepthOfFieldSource=e.screenSpaceReflectionPostProcess})),this.addEffect(new Vg(n.getEngine(),"HDRScreenSpaceReflections",(function(){return e.screenSpaceReflectionPostProcess}),!0))),this._basePostProcess?this.originalPostProcess=this._basePostProcess:this.originalPostProcess=new Dn("HDRPass","standard",[],[],t,null,Be.a.BILINEAR_SAMPLINGMODE,n.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 Vg(n.getEngine(),"HDRPassPostProcess",(function(){return e.originalPostProcess}),!0)),this._bloomEnabled&&(this._createDownSampleX4PostProcess(n,t/4),this._createBrightPassPostProcess(n,t/4),this._createBlurPostProcesses(n,t/4,1),this._createTextureAdderPostProcess(n,t),this.textureAdderFinalPostProcess=new Dn("HDRDepthOfFieldSource","standard",[],[],t,null,Be.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Vg(n.getEngine(),"HDRBaseDepthOfFieldSource",(function(){return e.textureAdderFinalPostProcess}),!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(n,t),this.volumetricLightFinalPostProcess=new Dn("HDRVLSFinal","standard",[],[],t,null,Be.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Vg(n.getEngine(),"HDRVLSFinal",(function(){return e.volumetricLightFinalPostProcess}),!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(n,t),this.lensFlareFinalPostProcess=new Dn("HDRPostLensFlareDepthOfFieldSource","standard",[],[],t,null,Be.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Vg(n.getEngine(),"HDRPostLensFlareDepthOfFieldSource",(function(){return e.lensFlareFinalPostProcess}),!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(n,this._floatTextureType),this._createHdrPostProcess(n,t),this.hdrFinalPostProcess=new Dn("HDRPostHDReDepthOfFieldSource","standard",[],[],t,null,Be.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,"#define PASS_POST_PROCESS",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Vg(n.getEngine(),"HDRPostHDReDepthOfFieldSource",(function(){return e.hdrFinalPostProcess}),!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(n,t/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(n,t)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(n,t),this._fxaaEnabled&&(this.fxaaPostProcess=new hv("fxaa",1,null,Be.a.BILINEAR_SAMPLINGMODE,n.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Vg(n.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 n=this,i=new Array(32);this.downSampleX4PostProcess=new Dn("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",this._floatTextureType),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,r=n.downSampleX4PostProcess.width,o=n.downSampleX4PostProcess.height,a=-2;a<2;a++)for(var s=-2;s<2;s++)i[t]=(a+.5)*(1/r),i[t+1]=(s+.5)*(1/o),t+=2;e.setArray2("dsOffsets",i)},this.addEffect(new Vg(e.getEngine(),"HDRDownSampleX4",(function(){return n.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var n=this,i=new Array(8);this.brightPassPostProcess=new Dn("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",this._floatTextureType),this.brightPassPostProcess.onApply=function(e){var t=1/n.brightPassPostProcess.width,r=1/n.brightPassPostProcess.height;i[0]=-.5*t,i[1]=.5*r,i[2]=.5*t,i[3]=.5*r,i[4]=-.5*t,i[5]=-.5*r,i[6]=.5*t,i[7]=-.5*r,e.setArray2("dsOffsets",i),e.setFloat("brightThreshold",n.brightThreshold)},this.addEffect(new Vg(e.getEngine(),"HDRBrightPass",(function(){return n.brightPassPostProcess}),!0))},t.prototype._createBlurPostProcesses=function(e,t,n,i){var r=this;void 0===i&&(i="blurWidth");var o=e.getEngine(),s=new Bc("HDRBlurH_"+n,new a.d(1,0),this[i],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType),c=new Bc("HDRBlurV_"+n,new a.d(0,1),this[i],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,this._floatTextureType);s.onActivateObservable.add((function(){var e=s.width/o.getRenderWidth();s.kernel=r[i]*e})),c.onActivateObservable.add((function(){var e=c.height/o.getRenderHeight();c.kernel=r.horizontalBlur?64*e:r[i]*e})),this.addEffect(new Vg(e.getEngine(),"HDRBlurH"+n,(function(){return s}),!0)),this.addEffect(new Vg(e.getEngine(),"HDRBlurV"+n,(function(){return c}),!0)),this.blurHPostProcesses.push(s),this.blurVPostProcesses.push(c)},t.prototype._createTextureAdderPostProcess=function(e,t){var n=this;this.textureAdderPostProcess=new Dn("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",this._floatTextureType),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",n._vlsEnabled?n._currentDepthOfFieldSource:n.originalPostProcess),e.setTexture("lensSampler",n.lensTexture),e.setFloat("exposure",n._currentExposure),n._currentDepthOfFieldSource=n.textureAdderFinalPostProcess},this.addEffect(new Vg(e.getEngine(),"HDRTextureAdder",(function(){return n.textureAdderPostProcess}),!0))},t.prototype._createVolumetricLightPostProcess=function(e,t){var n=this,i=e.enableGeometryBufferRenderer();i.enablePosition=!0;var r=i.getGBuffer();this.volumetricLightPostProcess=new Dn("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Be.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(n.sourceLight&&n.sourceLight.getShadowGenerator()&&n._scene.activeCamera){var t=n.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",r.textures[2]),e.setColor3("sunColor",n.sourceLight.diffuse),e.setVector3("sunDirection",n.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",n._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",n.volumetricLightCoefficient),e.setFloat("scatteringPower",n.volumetricLightPower),o.x=n.sourceLight.getDepthMinZ(n._scene.activeCamera),o.y=n.sourceLight.getDepthMaxZ(n._scene.activeCamera),e.setVector2("depthValues",o)}},this.addEffect(new Vg(e.getEngine(),"HDRVLS",(function(){return n.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new Dn("HDRVLSMerge","standard",[],["originalSampler"],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",n._bloomEnabled?n.textureAdderFinalPostProcess:n.originalPostProcess),n._currentDepthOfFieldSource=n.volumetricLightFinalPostProcess},this.addEffect(new Vg(e.getEngine(),"HDRVLSMerge",(function(){return n.volumetricLightMergePostProces}),!0))},t.prototype._createLuminancePostProcesses=function(e,n){var i=this,r=Math.pow(3,t.LuminanceSteps);this.luminancePostProcess=new Dn("HDRLuminance","standard",["lumOffsets"],[],{width:r,height:r},null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",n);var o=[];this.luminancePostProcess.onApply=function(e){var t=1/i.luminancePostProcess.width,n=1/i.luminancePostProcess.height;o[0]=-.5*t,o[1]=.5*n,o[2]=.5*t,o[3]=.5*n,o[4]=-.5*t,o[5]=-.5*n,o[6]=.5*t,o[7]=-.5*n,e.setArray2("lumOffsets",o)},this.addEffect(new Vg(e.getEngine(),"HDRLuminance",(function(){return i.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 u=new Dn("HDRLuminanceDownSample"+s,"standard",["dsOffsets","halfDestPixelSize"],[],{width:r,height:r},null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,c,n);this.luminanceDownSamplePostProcesses.push(u)}var l=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,n){var r=new Array(18);t.onApply=function(e){if(l){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)r[o]=a/l.width,r[o+1]=s/l.height,o+=2;e.setArray2("dsOffsets",r),e.setFloat("halfDestPixelSize",.5/l.width),l=n===i.luminanceDownSamplePostProcesses.length-1?i.luminancePostProcess:t}},n===i.luminanceDownSamplePostProcesses.length-1&&(t.onAfterRender=function(){var t=e.getEngine().readPixels(0,0,1,1),n=new a.f(1/16581375,1/65025,1/255,1);t.then((function(e){var t=new Uint8Array(e.buffer);i._hdrCurrentLuminance=(t[0]*n.x+t[1]*n.y+t[2]*n.z+t[3]*n.w)/100}))}),i.addEffect(new Vg(e.getEngine(),"HDRLuminanceDownSample"+n,(function(){return t}),!0))}))},t.prototype._createHdrPostProcess=function(e,t){var n=this,i=["#define HDR"];this._hdrAutoExposure&&i.push("#define AUTO_EXPOSURE"),this.hdrPostProcess=new Dn("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,i.join("\n"),g.a.TEXTURETYPE_UNSIGNED_INT);var r=1,o=0,a=0;this.hdrPostProcess.onApply=function(t){if(t.setTextureFromPostProcess("textureAdderSampler",n._currentDepthOfFieldSource),o+=e.getEngine().getDeltaTime(),r<0)r=n._hdrCurrentLuminance;else{var i=(a-o)/1e3;n._hdrCurrentLuminancer-n.hdrIncreaseRate*i?r-=n.hdrIncreaseRate*i:r=n._hdrCurrentLuminance}n.hdrAutoExposure?n._currentExposure=n._fixedExposure/r:(r=L.a.Clamp(r,n.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",r)),a=o,n._currentDepthOfFieldSource=n.hdrFinalPostProcess},this.addEffect(new Vg(e.getEngine(),"HDR",(function(){return n.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var n=this;this.lensFlarePostProcess=new Dn("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Vg(e.getEngine(),"HDRLensFlare",(function(){return n.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2,"lensFlareBlurWidth"),this.lensFlareComposePostProcess=new Dn("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",g.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new Vg(e.getEngine(),"HDRLensFlareCompose",(function(){return n.lensFlareComposePostProcess}),!0));var i=new a.d(0,0);this.lensFlarePostProcess.externalTextureSamplerBinding=!0,this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",n._bloomEnabled?n.blurHPostProcesses[0]:n.originalPostProcess),e.setTexture("lensColorSampler",n.lensColorTexture),e.setFloat("strength",n.lensFlareStrength),e.setFloat("ghostDispersal",n.lensFlareGhostDispersal),e.setFloat("haloWidth",n.lensFlareHaloWidth),i.x=n.lensFlarePostProcess.width,i.y=n.lensFlarePostProcess.height,e.setVector2("resolution",i),e.setFloat("distortionStrength",n.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(n._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",n.lensFlarePostProcess),e.setTexture("lensDirtSampler",n.lensFlareDirtTexture),e.setTexture("lensStarSampler",n.lensStarTexture);var t=n._scene.activeCamera.getViewMatrix().getRow(0),i=n._scene.activeCamera.getViewMatrix().getRow(2),s=a.e.Dot(t.toVector3(),new a.e(1,0,0))+a.e.Dot(i.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),u=o.multiply(c).multiply(r);e.setMatrix("lensStarMatrix",u),n._currentDepthOfFieldSource=n.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var n=this;this.depthOfFieldPostProcess=new Dn("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",g.a.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",n._currentDepthOfFieldSource),e.setTexture("depthSampler",n._getDepthTexture()),e.setFloat("distance",n.depthOfFieldDistance)},this.addEffect(new Vg(e.getEngine(),"HDRDepthOfField",(function(){return n.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var n=this;if(this._isObjectBasedMotionBlur){var i=new Sv("HDRMotionBlur",e,t,null,Be.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,g.a.TEXTURETYPE_UNSIGNED_INT);i.motionStrength=this.motionStrength,i.motionBlurSamples=this.motionBlurSamples,this.motionBlurPostProcess=i}else{this.motionBlurPostProcess=new Dn("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Be.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(),u=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,u.x=n.motionBlurPostProcess.width,u.y=n.motionBlurPostProcess.height,t.setVector2("screenSize",u),r=e.getEngine().getFps()/60,t.setFloat("motionScale",r),t.setFloat("motionStrength",n.motionStrength),t.setTexture("depthSampler",n._getDepthTexture())}}this.addEffect(new Vg(e.getEngine(),"HDRMotionBlur",(function(){return n.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;e0&&-1!==this.excludedMeshes.indexOf(e)},t.prototype._createPass=function(e,t){var n=this,i=e.getEngine();this._volumetricLightScatteringRTT=new ci("volumetricLightScatteringMap",{width:i.getRenderWidth()*t,height:i.getRenderHeight()*t},e,!1,!0,g.a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Be.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Be.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(),i=e.getEffectiveMesh();if(!n._meshExcluded(t)){i._internalAbstractMeshDataInfo._isActiveIntermediate=!1;var r=e.getMaterial();if(r){var o=t.getScene(),a=o.getEngine();a.setState(r.backFaceCulling,void 0,void 0,void 0,r.cullBackFaces);var s=t._getInstancesRenderList(e._id,!!e.getReplacementMesh());if(!s.mustReturn){var c=a.getCaps().instancedArrays&&(null!==s.visibleInstances[e._id]||t.hasThinInstances);if(n._isReady(e,c)){var u=n._volumetricLightScatteringPass;t===n.mesh&&(u=e.effect?e._drawWrapper:r._getDrawWrapper());var l=u.effect;if(a.enableEffect(u),c||t._bind(e,l,r.fillMode),t===n.mesh)r.bind(i.getWorldMatrix(),t);else{if(l.setMatrix("viewProjection",o.getTransformMatrix()),r&&r.needAlphaTesting()){var h=r.getAlphaTestTexture();l.setTexture("diffuseSampler",h),h&&l.setMatrix("diffuseMatrix",h.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&l.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(i,e,l,cu.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.customIsReadyFunction=function(e,t){if(!e.isReady(!1))return!1;if(0===t&&e.subMeshes)for(var r=0;rt._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),s.setAlphaMode(g.a.ALPHA_COMBINE),o=0;o\nuniform vec4 color;\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\ngl_FragColor=color;\n#define CUSTOM_FRAGMENT_MAIN_END\n}";Cn.a.ShadersStore.linePixelShader=hb;var db="#include\n#include\n\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 viewProjection;\nuniform float width;\nuniform float aspectRatio;\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include\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#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)\nvec4 worldPos=finalWorld*vec4(position,1.0);\n#include\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}";Cn.a.ShadersStore.lineVertexShader=db;ot.a.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},ot.a.prototype.enableEdgesRendering=function(e,t,n){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new fb(this,e,t,!0,n),this},Object.defineProperty(ot.a.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),Z_.b.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new _b(this,e,t),this},Z_.a.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),Z_.b.prototype.enableEdgesRendering.apply(this,arguments),this};var pb=function(){this.edges=new Array,this.edgesConnectedCount=0},fb=function(){function e(e,t,n,i,r){var o,a=this;void 0===t&&(t=.95),void 0===n&&(n=!1),void 0===i&&(i=!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 Rn.a(32),this._source=e,this._checkVerticesInsteadOfIndices=n,this._options=null!=r?r:null,this._epsilon=t,this._source.getScene().getEngine().isWebGPU&&(this._drawWrapper=new In.a(e.getEngine())),this._prepareRessources(),i&&(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}),Object.defineProperty(e.prototype,"lineShader",{get:function(){return this._lineShader},set:function(e){this._lineShader=e},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"]},!1);t.disableDepthWrite=!0,t.backFaceCulling=!1,t.checkReadyOnEveryCall=e.getEngine().isWebGPU,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[bt.b.PositionKind];e&&e._rebuild(),(e=this._buffers[bt.b.NormalKind])&&e._rebuild();var t=this._source.getScene().getEngine();this._ib=t.createIndexBuffer(this._linesIndices)},e.prototype.dispose=function(){var e;this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var t=this._buffers[bt.b.PositionKind];t&&(t.dispose(),this._buffers[bt.b.PositionKind]=null),(t=this._buffers[bt.b.NormalKind])&&(t.dispose(),this._buffers[bt.b.NormalKind]=null),this._ib&&this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose(),null===(e=this._drawWrapper)||void 0===e||e.dispose()},e.prototype._processEdgeForAdjacencies=function(e,t,n,i,r){return e===n&&t===i||e===i&&t===n?0:e===i&&t===r||e===r&&t===i?1:e===r&&t===n||e===n&&t===r?2:-1},e.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,n,i,r){var o=1e-10;return e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(i,o)||e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(n,o)?0:e.equalsWithEpsilon(i,o)&&t.equalsWithEpsilon(r,o)||e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(i,o)?1:e.equalsWithEpsilon(r,o)&&t.equalsWithEpsilon(n,o)||e.equalsWithEpsilon(n,o)&&t.equalsWithEpsilon(r,o)?2:-1},e.prototype._checkEdge=function(e,t,n,i,r){var o;void 0===t?o=!0:o=a.e.Dot(n[e],n[t])=0&&t.push(n);for(var i=0;i=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:0})):e[a].sort((function(e,t){return e[1]>t[1]?-1:e[1]=o+1;--l)r(e[l%3],c,l!==o+2?i[n[t+(l+1)%3]]:-1);var h=c.length;n.push(i[n[t+o]],s[0],c[0]),n.push(i[n[t+(o+1)%3]],c[h-1],s[u-1]);for(var d=u<=h,p=d?u:h,f=d?h:u,_=d?u-1:h-1,m=d?0:1,g=u+h-2,v=0,b=0,y=d?s:c,T=d?c:s,E=0;g-- >0;){m?n.push(y[v],T[b]):n.push(T[b],y[v]);var S=void 0;(E+=p)>=f&&v<_?(S=y[++v],E-=f):S=T[++b],n.push(S)}n[t+0]=n[n.length-3],n[t+1]=n[n.length-2],n[t+2]=n[n.length-1],n.length=n.length-3},e.prototype._generateEdgesLinesAlternate=function(){var e,t,n,i,r,o,s,c,u,l,h=this._source.getVerticesData(bt.b.PositionKind),d=this._source.getIndices();if(d&&h){Array.isArray(d)||(d=Re.b.SliceToArray(d));var p=null===(t=null===(e=this._options)||void 0===e?void 0:e.useFastVertexMerger)||void 0===t||t,f=p?Math.round(-Math.log(null!==(i=null===(n=this._options)||void 0===n?void 0:n.epsilonVertexMerge)&&void 0!==i?i:1e-6)/Math.log(10)):null!==(o=null===(r=this._options)||void 0===r?void 0:r.epsilonVertexMerge)&&void 0!==o?o:1e-6,_=[],m=[];if(p)for(var g={},v=0;vL){var ee=N;N=L,L=ee}if(ne=J[te=N+"_"+L]){if(!ne.done)a.e.Dot($,ne.normal)0||this._source.hasThinInstances)},e.prototype.render=function(){var e=this._source.getScene(),t=this._lineShader._getDrawWrapper();if(this._drawWrapper&&this._lineShader._setDrawWrapper(this._drawWrapper),this.isReady()&&e.activeCamera){var n=this._source.hasInstances&&this.customInstances.length>0,i=n||this._source.hasThinInstances,r=0;if(i)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"),n){var o=this._source._instanceDataStorage;if(r=this.customInstances.length,!o.instancesData)return void(this._source.getScene()._activeMeshesFrozen||this.customInstances.reset());if(!o.isFrozen){for(var a=0,s=0;s0&&(t.push(!0),n.push(!1));this._multiRenderAttachments=this._engine.buildTextureLayout(e),this._clearAttachments=this._engine.buildTextureLayout(t),this._defaultAttachments=this._engine.buildTextureLayout(n)},e.prototype._resetLayout=function(){for(var t=0;t=0;e--)this.renderTargets[e].dispose();for(e=0;e=5)return m.a.Error("You already reached the maximum number of diffusion profiles."),0;for(var t=0;t4&&(r.push(bt.b.MatricesIndicesExtraKind),r.push(bt.b.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),i.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0");var c=o.morphTargetManager,u=0;c&&c.numInfluencers>0&&(u=c.numInfluencers,i.push("#define MORPHTARGETS"),i.push("#define NUM_MORPH_INFLUENCERS "+u),c.isUsingTextureForTargets&&i.push("#define MORPHTARGETS_TEXTURE"),kc.a.PrepareAttributesForMorphTargetsInfluencers(r,o,u)),t&&(i.push("#define INSTANCES"),kc.a.PushAttributesForInstances(r),e.getRenderingMesh().hasThinInstances&&i.push("#define THIN_INSTANCES")),s.clipPlane&&i.push("#define CLIPPLANE"),s.clipPlane2&&i.push("#define CLIPPLANE2"),s.clipPlane3&&i.push("#define CLIPPLANE3"),s.clipPlane4&&i.push("#define CLIPPLANE4"),s.clipPlane5&&i.push("#define CLIPPLANE5"),s.clipPlane6&&i.push("#define CLIPPLANE6");var l=e._getDrawWrapper(n,!0),h=l.defines,d=i.join("\n");return h!==d&&l.setEffect(this.scene.getEngine().createEffect("outline",r,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant","morphTargetInfluences","morphTargetTextureInfo","morphTargetTextureIndices","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","vClipPlane5","vClipPlane6"],["diffuseSampler","morphTargets"],d,void 0,void 0,void 0,{maxSimultaneousMorphTargets:u}),d),l.effect.isReady()},e.prototype._beforeRenderingMesh=function(t,n,i){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var r=n.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._engine.stencilStateComposer.useStencilGlobalOnly=!0,this.render(n,i,!0,this._passIdForDrawWrapper[1]),this._engine.setColorWrite(!0),this._engine.setStencilFunction(g.a.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(n,i,!1,this._passIdForDrawWrapper[0]),this._engine.setDepthWrite(this._savedDepthWrite),r&&r.needAlphaBlendingForMesh(t)&&(this._engine.stencilStateComposer.useStencilGlobalOnly=!1,this._engine.restoreStencilState())}},e.prototype._afterRenderingMesh=function(e,t,n){if(e.renderOverlay){var i=this._engine.getAlphaMode(),r=this._engine.alphaState.alphaBlend;this._engine.setAlphaMode(g.a.ALPHA_COMBINE),this.render(t,n,!0,this._passIdForDrawWrapper[3]),this._engine.setAlphaMode(i),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,n,!1,this._passIdForDrawWrapper[2]),this._engine.setColorWrite(!0))},e._StencilReference=4,e}(),Pb=n(174),Ob=n(175),Mb=function(e){function t(t,n){var i=e.call(this)||this;return i.name=t,i.animations=new Array,i.isPickable=!1,i.useAlphaForPicking=!1,i.onDisposeObservable=new o.c,i._onAnimationEnd=null,i._endAnimation=function(){i._onAnimationEnd&&i._onAnimationEnd(),i.disposeWhenFinishedAnimating&&i.dispose()},i.color=new s.b(1,1,1,1),i.position=a.e.Zero(),i._manager=n,i._manager.sprites.push(i),i.uniqueId=i._manager.scene.getUniqueId(),i}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,n,i,r,o){void 0===o&&(o=null),this._onAnimationEnd=o,e.prototype.playAnimation.call(this,t,n,i,r,this._endAnimation)},t.prototype.dispose=function(){for(var e=0;ethis._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,(this._direction>0&&this.cellIndex>this._toIndex||this._direction<0&&this.cellIndex0?this._fromIndex:this._toIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onBaseAnimationEnd&&this._onBaseAnimationEnd()))))},e}());Q.a.prototype._internalPickSprites=function(e,t,n,i){if(!lr.a)return null;var r=null;if(!i){if(!this.activeCamera)return null;i=this.activeCamera}if(this.spriteManagers.length>0)for(var o=0;o=r.distance))&&(r=s,n))break}}return r||new lr.a},Q.a.prototype._internalMultiPickSprites=function(e,t,n){if(!lr.a)return null;var i=new Array;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var r=0;r0&&(n=r.pickSprite(e,t,this._spritePredicate,!1,r.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(r._pickedDownSprite=n.pickedSprite,i.button){case 0:n.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnLeftPickTrigger,l.a.CreateNewFromSprite(n.pickedSprite,r,i));break;case 1:n.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnCenterPickTrigger,l.a.CreateNewFromSprite(n.pickedSprite,r,i));break;case 2:n.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnRightPickTrigger,l.a.CreateNewFromSprite(n.pickedSprite,r,i))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickDownTrigger,l.a.CreateNewFromSprite(n.pickedSprite,r,i))}return n},e.prototype._pointerUp=function(e,t,n,i){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,l.a.CreateNewFromSprite(o.pickedSprite,r,i)),o.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(g.a.ACTION_OnPickTrigger,l.a.CreateNewFromSprite(o.pickedSprite,r,i)))),r._pickedDownSprite&&r._pickedDownSprite.actionManager&&r._pickedDownSprite!==o.pickedSprite&&r._pickedDownSprite.actionManager.processTrigger(g.a.ACTION_OnPickOutTrigger,l.a.CreateNewFromSprite(r._pickedDownSprite,r,i)))}return n},e}();Cn.a.IncludesShadersStore.imageProcessingCompatibility="#ifdef IMAGEPROCESSINGPOSTPROCESS\ngl_FragColor.rgb=pow(gl_FragColor.rgb,vec3(2.2));\n#endif";var Db="uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest)\n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\ngl_FragColor=color;\n#include\n#define CUSTOM_FRAGMENT_MAIN_END\n}";Cn.a.ShadersStore.spritesPixelShader=Db;var Nb="\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\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\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#define CUSTOM_VERTEX_MAIN_END\n}";Cn.a.ShadersStore.spritesVertexShader=Nb;var Lb=function(){function e(e,t,n,i){void 0===n&&(n=.01),void 0===i&&(i=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=n,this._engine=e,this._useInstancing=e.getCaps().instancedArrays,this._useVAO=e.getCaps().vertexArrayObject&&!e.disableVertexArrayObjects,this._scene=i,this._drawWrapperBase=new In.a(e),this._drawWrapperFog=new In.a(e),this._drawWrapperDepth=new In.a(e,!1),this._drawWrapperFogDepth=new In.a(e,!1),this._useInstancing||this._buildIndexBuffer(),this._drawWrapperBase.drawContext&&(this._drawWrapperBase.drawContext.useInstancing=this._useInstancing),this._drawWrapperFog.drawContext&&(this._drawWrapperFog.drawContext.useInstancing=this._useInstancing),this._drawWrapperDepth.drawContext&&(this._drawWrapperDepth.drawContext.useInstancing=this._useInstancing),this._drawWrapperFogDepth.drawContext&&(this._drawWrapperFogDepth.drawContext.useInstancing=this._useInstancing),this._vertexBufferSize=this._useInstancing?16:18,this._vertexData=new Float32Array(t*this._vertexBufferSize*(this._useInstancing?1:4)),this._buffer=new bt.a(e,this._vertexData,!0,this._vertexBufferSize);var r,o=this._buffer.createVertexBuffer(bt.b.PositionKind,0,4,this._vertexBufferSize,this._useInstancing),a=this._buffer.createVertexBuffer("options",4,2,this._vertexBufferSize,this._useInstancing),s=6;if(this._useInstancing){var c=new Float32Array([0,0,1,0,0,1,1,1]);this._spriteBuffer=new bt.a(e,c,!1,2),r=this._spriteBuffer.createVertexBuffer("offsets",0,2)}else r=this._buffer.createVertexBuffer("offsets",s,2,this._vertexBufferSize,this._useInstancing),s+=2;var u=this._buffer.createVertexBuffer("inverts",s,2,this._vertexBufferSize,this._useInstancing),l=this._buffer.createVertexBuffer("cellInfo",s+2,4,this._vertexBufferSize,this._useInstancing),h=this._buffer.createVertexBuffer(bt.b.ColorKind,s+6,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[bt.b.PositionKind]=o,this._vertexBuffers.options=a,this._vertexBuffers.offsets=r,this._vertexBuffers.inverts=u,this._vertexBuffers.cellInfo=l,this._vertexBuffers[bt.b.ColorKind]=h,this._drawWrapperBase.effect=this._engine.createEffect("sprites",[bt.b.PositionKind,"options","offsets","inverts","cellInfo",bt.b.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._drawWrapperDepth.effect=this._drawWrapperBase.effect,this._drawWrapperDepth.materialContext=this._drawWrapperBase.materialContext,this._scene&&(this._drawWrapperFog.effect=this._scene.getEngine().createEffect("sprites",[bt.b.PositionKind,"options","offsets","inverts","cellInfo",bt.b.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG"),this._drawWrapperFogDepth.effect=this._drawWrapperFog.effect,this._drawWrapperFogDepth.materialContext=this._drawWrapperFog.materialContext)}return Object.defineProperty(e.prototype,"capacity",{get:function(){return this._capacity},enumerable:!1,configurable:!0}),e.prototype.render=function(e,t,n,i,r){if(void 0===r&&(r=null),this.texture&&this.texture.isReady()&&e.length){var o=this._drawWrapperBase,a=this._drawWrapperDepth,s=!1;this.fogEnabled&&this._scene&&this._scene.fogEnabled&&0!==this._scene.fogMode&&(o=this._drawWrapperFog,a=this._drawWrapperFogDepth,s=!0);var c=o.effect;if(c.isReady()){for(var u=this._engine,l=!(!this._scene||!this._scene.useRightHandedSystem),h=this.texture.getBaseSize(),d=Math.min(this._capacity,e.length),p=0,f=!0,_=0;_>0;t._xOffset=(t.cellIndex-u*c)*this.cellWidth/r.width,t._yOffset=u*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]=n,this._vertexData[s+7]=i),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._buildIndexBuffer=function(){for(var e=[],t=0,n=0;n0);var l=e.substring(0,u-1)+".json";Re.b.LoadFile(l,(function(e){try{var t=JSON.parse(e),i=Reflect.ownKeys(t.frames);n._spriteMap=i,n._packedAndReady=!0,n._cellData=t.frames}catch(e){throw n._fromPacked=!1,n._packedAndReady=!1,new Error("Invalid JSON format. Please check documentation for format specifications.")}}),void 0,void 0,!1,(function(){m.a.Error("JSON ERROR: Unable to load JSON file."),n._fromPacked=!1,n._packedAndReady=!1}))}},e.prototype._checkTextureAlpha=function(e,t,n,i,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(n),s.addInPlace(t.origin);var c=(s.x-i.x)/(r.x-i.x)-.5,u=1-(s.y-i.y)/(r.y-i.y)-.5,l=e.angle,h=c*Math.cos(l)-u*Math.sin(l)+.5,d=c*Math.sin(l)+u*Math.cos(l)+.5,p=e._xOffset*o.width+h*e._xSize|0,f=e._yOffset*o.height+d*e._ySize|0;return this._textureContent[4*(p+f*o.width)+3]>.5},e.prototype.intersects=function(e,t,n,i){for(var r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=Number.MAX_VALUE,u=null,l=a.c.Vector3[0],h=a.c.Vector3[1],d=t.getViewMatrix(),p=e,f=e,_=0;_g){if(!this._checkTextureAlpha(m,p,g,o,s))continue;if(f=p,c=g,u=m,i)break}}}}if(u){var v=new lr.a;d.invertToRef(a.c.Matrix[0]),v.hit=!0,v.pickedSprite=u,v.distance=c;var b=a.c.Vector3[2];return b.copyFrom(f.direction),b.normalize(),b.scaleInPlace(c),f.origin.addToRef(b,l),v.pickedPoint=a.e.TransformCoordinates(l,a.c.Matrix[0]),v}return null},e.prototype.multiIntersects=function(e,t,n){for(var i,r=Math.min(this.capacity,this.sprites.length),o=a.e.Zero(),s=a.e.Zero(),c=[],u=a.c.Vector3[0].copyFromFloats(0,0,0),l=a.c.Vector3[1].copyFromFloats(0,0,0),h=t.getViewMatrix(),d=0;d0&&(e+="\n\r"),e+=this._tileMaps[t]._texture._bufferView.toString();var n=document.createElement("a");n.href="data:octet/stream;charset=utf-8,"+encodeURI(e),n.target="_blank",n.download=this.name+".tilemaps",n.click(),n.remove()},e.prototype.loadTileMaps=function(e){var t=this,n=new XMLHttpRequest;n.open("GET",e);var i=this.options.layerCount||0;n.onload=function(){for(var e=n.response.split("\n\r"),r=0;r-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 Hb(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 n=0,i=t;n-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,n=function(n,i){e._setErrorObject(n,i),t.onTaskError?t.onTaskError(e):e.onError||m.a.Error(t._formatTaskErrorMessage(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){n("Error executing task success callbacks",e)}}),n)},e.prototype._formatTaskErrorMessage=function(e){var t="Unable to complete task "+e.name;return e.errorObject.message&&(t+=": ".concat(e.errorObject.message)),e.errorObject.exception&&(t+=": ".concat(e.errorObject.exception)),t},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=0&&this._meshes.splice(n,1),this._centerPosition=this._centerMesh.getAbsolutePosition().clone();for(var i=0;i0&&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,n,i){var r=this,o=e.createReader(),a=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");o.readEntries((function(e){n.count+=e.length;for(var o=0,s=e;o0)){for(var n=new Array,i=[],r=e.dataTransfer?e.dataTransfer.items:null,o=0;o0&&m.a.ClearLogCache(),this._engine.stopRenderLoop()),Xs.ShowLoadingScreen=!1,this._engine.displayLoadingUI(),this.loadAsync(this._sceneFileToLoad,this._progressCallback).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}(),ay=n(91);o.c.prototype.runCoroutineAsync=function(e){if(!this._coroutineScheduler){var t=(n=this,i=new Array,r=new Array,o=new Array,a=n.add((function(){for(var e=i.length,t=0;tthis.maximumSize&&(r.scale(this.step),n=!1)}}return n},t}(uy),hy=function(e){function t(t,n,i){void 0===t&&(t=0),void 0===n&&(n=2),void 0===i&&(i=.25);var r=e.call(this,t)||this;return r.priority=t,r.maximumScale=n,r.step=i,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}(uy),dy=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}(uy),py=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}(uy),fy=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}(uy),_y=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}(uy),my=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}(uy),gy=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}(uy),vy=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof Te.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,n,i){for(var r=e.meshes.slice(0),o=r.length,a=0;a=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var i=!0,r=!0,o=0;o0){a.animationGroups=[];for(var d=0;d0)for(a.reflectionProbes=[],i=0;i0&&setTimeout((function(){n.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){n._resolve=e,n._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&&Re.b.Download(e,this._fileName)},e._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},e}();function Ry(e,t,n,i,r,o){void 0===r&&(r="image/png"),void 0===o&&(o=!1);var a=Iy(e,t,n),s=a.height,c=a.width;if(s&&c){Re.b._ScreenshotCanvas||(Re.b._ScreenshotCanvas=document.createElement("canvas")),Re.b._ScreenshotCanvas.width=c,Re.b._ScreenshotCanvas.height=s;var u=Re.b._ScreenshotCanvas.getContext("2d"),l=e.getRenderWidth()/e.getRenderHeight(),h=c,d=h/l;d>s&&(h=(d=s)*l);var p=Math.max(0,c-h)/2,f=Math.max(0,s-d)/2;e.onEndFrameObservable.addOnce((function(){var t=e.getRenderingCanvas();u&&t&&u.drawImage(t,p,f,h,d),o?(Re.b.EncodeScreenshotCanvasData(void 0,r),i&&i("")):Re.b.EncodeScreenshotCanvasData(i,r)}))}else m.a.Error("Invalid 'size' parameter !")}function Cy(e,t,n,i){return void 0===i&&(i="image/png"),new Promise((function(r,o){Ry(e,t,n,(function(e){void 0!==e?r(e):o(new Error("Data is undefined"))}),i)}))}function Py(e,t,n,i,r){return void 0===r&&(r="image/png"),new Promise((function(o,a){Ry(e,t,{width:n,height:i},(function(){o()}),r,!0)}))}function Oy(e,t,n,i,r,o,a,s,c,u){void 0===r&&(r="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),void 0===c&&(c=!1),void 0===u&&(u=!1);var l=Iy(e,t,n),h=l.height,d=l.width,p={width:d,height:h};if(h&&d){var f=t.getScene(),_=null,v=f.activeCameras;f.activeCameras=null,f.activeCamera!==t&&(_=f.activeCamera,f.activeCamera=t),f.render();var b=new ci("screenShot",p,f,!1,!1,g.a.TEXTURETYPE_UNSIGNED_INT,!1,Be.a.NEAREST_SAMPLINGMODE,void 0,u,void 0,void 0,void 0,o);b.renderList=null,b.samples=o,b.renderSprites=c,e.onEndFrameObservable.addOnce((function(){b.readPixels(void 0,void 0,void 0,!1).then((function(e){Re.b.DumpData(d,h,e,i,r,s,!0),b.dispose()}))}));var y=function(){f.incrementRenderId(),f.resetCachedMaterial(),b.render(!0),f.incrementRenderId(),f.resetCachedMaterial(),_&&(f.activeCamera=_),f.activeCameras=v,t.getProjectionMatrix(!0),f.render()};if(a){var T=new hv("antialiasing",1,f.activeCamera);b.addPostProcess(T),T.getEffect().isReady()?y():T.getEffect().onCompiled=function(){y()}}else y()}else m.a.Error("Invalid 'size' parameter !")}function My(e,t,n,i,r,o,a,s){return void 0===i&&(i="image/png"),void 0===r&&(r=1),void 0===o&&(o=!1),void 0===s&&(s=!1),new Promise((function(c,u){Oy(e,t,n,(function(e){void 0!==e?c(e):u(new Error("Data is undefined"))}),i,r,o,a,s)}))}function Iy(e,t,n){var i=0,r=0;if("object"==typeof n){var o=n.precision?Math.abs(n.precision):1;n.width&&n.height?(i=n.height*o,r=n.width*o):n.width&&!n.height?(r=n.width*o,i=Math.round(r/e.getAspectRatio(t))):n.height&&!n.width?(i=n.height*o,r=Math.round(i*e.getAspectRatio(t))):(r=Math.round(e.getRenderWidth()*o),i=Math.round(r/e.getAspectRatio(t)))}else isNaN(n)||(i=n,r=n);return r&&(r=Math.floor(r)),i&&(i=Math.floor(i)),{height:0|i,width:0|r}}var Dy,Ny={CreateScreenshot:Ry,CreateScreenshotAsync:Cy,CreateScreenshotWithResizeAsync:Py,CreateScreenshotUsingRenderTarget:Oy,CreateScreenshotUsingRenderTargetAsync:My};Re.b.CreateScreenshot=Ry,Re.b.CreateScreenshotAsync=Cy,Re.b.CreateScreenshotUsingRenderTarget=Oy,Re.b.CreateScreenshotUsingRenderTargetAsync=My,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",e[e.Button=6]="Button",e[e.Options=7]="Options",e[e.Tab=8]="Tab"}(Dy||(Dy={}));var Ly,Fy=n(168),wy=n(172),By=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 Object(Ke.a)(this.readUint8Array(e))},e.prototype.skipBytes=function(e){this._dataByteOffset+=e,this.byteOffset+=e},e}(),Uy=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 n=e[t];return void 0===n?null:n},setItem:function(t,n){e[t]=n}}}},e.ReadString=function(e,t){var n=this._Storage.getItem(e);return null!==n?n:t},e.WriteString=function(e,t){this._Storage.setItem(e,t)},e.ReadBoolean=function(e,t){var n=this._Storage.getItem(e);return null!==n?"true"===n:t},e.WriteBoolean=function(e,t){this._Storage.setItem(e,t?"true":"false")},e.ReadNumber=function(e,t){var n=this._Storage.getItem(e);return null!==n?parseFloat(n):t},e.WriteNumber=function(e,t){this._Storage.setItem(e,t.toString())},e._Storage=e._GetStorage(),e}(),Vy=function(){function e(){this._trackedScene=null}return e.prototype.track=function(e){this._trackedScene=e,F.a.AllowLoadingUniqueId=!0,this._savedJSON=Ay.Serialize(e),F.a.AllowLoadingUniqueId=!1},e.prototype.getDelta=function(){if(!this._trackedScene)return null;var e=Be.a.ForceSerializeBuffers;Be.a.ForceSerializeBuffers=!1,F.a.AllowLoadingUniqueId=!0;var t=Ay.Serialize(this._trackedScene);F.a.AllowLoadingUniqueId=!1;var n={};for(var i in t)this._compareCollections(i,this._savedJSON[i],t[i],n);return Be.a.ForceSerializeBuffers=e,n},e.prototype._compareArray=function(e,t,n,i){if(0===t.length&&0===n.length)return!0;if(t.length&&!isNaN(t[0])||n.length&&!isNaN(n[0])){if(t.length!==n.length)return!1;if(0===t.length)return!0;for(var r=0;re.MAX_SEQUENCE_LENGTH)throw new Error("Sequences longer than "+e.MAX_SEQUENCE_LENGTH+" not supported.");this._alphabet=n,this._characters=t.map((function(e){return i._alphabet.getCharacterIdx(e)}))}return e.prototype.serialize=function(){return JSON.stringify(this._characters)},e.Deserialize=function(t,n){var i=new e([],n);return i._characters=JSON.parse(t),i},e.prototype.distance=function(t){return e._distance(this,t)},e._distance=function(t,n){var i=t._alphabet;if(i!==n._alphabet)throw new Error("Cannot Levenshtein compare Sequences built from different alphabets.");var r=t._characters,o=n._characters,a=r.length,s=o.length,c=e._costMatrix;c[0][0]=0;for(var u=0;u.98)&&(a.e.CrossToRef(e._forwardDir,e._inverseFromVec,e._upDir),e._upDir.normalize(),a.a.LookAtLHToRef(t,n,e._upDir,e._lookMatrix),i.subtractToRef(n,e._fromToVec),e._fromToVec.normalize(),a.e.TransformNormalToRef(e._fromToVec,e._lookMatrix,r),!0)},e._tokenizeSegment=function(t,n){e._bestMatch=0,e._score=a.e.Dot(t,n[0]),e._bestScore=e._score;for(var i=1;ie._bestScore&&(e._bestMatch=i,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}(),Gy=function(){function e(e){this.chars=new Array(e)}return e.Generate=function(t,n,i,r,o){void 0===t&&(t=64),void 0===n&&(n=256),void 0===i&&(i=.1),void 0===r&&(r=.001),void 0===o&&(o=[]);for(var s,c,u=new e(t),l=0;l1e-6&&p.scaleAndAddToRef(1/(p.lengthSquared()*c),d)})),d.scaleInPlace(s),u.chars[e].addInPlace(d),u.chars[e].normalize()};for(l=o.length;l4;o=Math.floor(o/2))r.push(t.resampleAtTargetResolution(o).tokenize(n.chars));return r},e.prototype.distance=function(e){for(var t=0,n=0;n0&&(this._averageDistance=Math.max(this._averageDistance/this._descriptors.length,e.MIN_AVERAGE_DISTANCE))},e.MIN_AVERAGE_DISTANCE=1,e}(),Wy=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,n){e.nameToDescribedTrajectory.push(n),e.nameToDescribedTrajectory.push(t.serialize())})),JSON.stringify(e)},e.Deserialize=function(t){var n=JSON.parse(t),i=new e;i._maximumAllowableMatchCost=n.maximumAllowableMatchCost,i._vector3Alphabet=Gy.Deserialize(n.vector3Alphabet),i._levenshteinAlphabet=Ly.Alphabet.Deserialize(n.levenshteinAlphabet);for(var r=0;r=this._itemLength?NaN:this._view[e]},e.prototype.subarray=function(e,t){return e>=t||e<0?new Float32Array(0):(t>this._itemLength&&(t=this._itemLength),this._view.subarray(e,t))},e.prototype.push=function(e){this._view[this._itemLength]=e,this._itemLength++,this._itemLength>=this._view.length&&this._growArray()},e.prototype._growArray=function(){var e=Math.floor(1.5*this._view.length),t=new Float32Array(e);t.set(this._view),this._view=t},e}(),Qy=/\r/g,qy=function(){function e(t,n){var i=this;this._scene=t,this._collectDataAtFrame=function(){var t=q.a.Now-i._startingTimestamp,n=i.datasets.ids.length,r=i.datasets.startingIndices.itemLength,o=0;if(r>0){var a=i.datasets.startingIndices.at(r-1);o=a+i.datasets.data.at(a+e.NumberOfPointsOffset)+e.SliceDataOffset}if(i.datasets.startingIndices.push(o),i.datasets.data.push(t),i.datasets.data.push(n),i.datasets.ids.forEach((function(e){var t=i._strategies.get(e);t&&i.datasets.data.push(t.getData())})),i.datasetObservable.hasObservers()){for(var s=[t,n],c=0;c>n&255).toString(16)).substr(-2)}return i},e.prototype.getCurrentSlice=function(){var e=this,t=[q.a.Now-this._startingTimestamp,this.datasets.ids.length];this.datasets.ids.forEach((function(n){var i=e._strategies.get(n);i&&e.datasetObservable.hasObservers()&&t.push(i.getData())})),this.datasetObservable.hasObservers()&&this.datasetObservable.notifyObservers(t)},e.prototype.updateMetadata=function(e,t,n){var i=this._datasetMeta.get(e);i&&(i[t]=n,this.metadataObservable.notifyObservers(this._datasetMeta))},e.prototype.clear=function(e){this.datasets.data=new Ky(1800),this.datasets.ids.length=0,this.datasets.startingIndices=new Ky(1800),this._datasetMeta.clear(),this._strategies.forEach((function(e){return e.dispose()})),this._strategies.clear(),e||this._eventRestoreSet.clear(),this._hasLoadedData=!1},Object.defineProperty(e.prototype,"hasLoadedData",{get:function(){return this._hasLoadedData},enumerable:!1,configurable:!0}),e.prototype.loadFromFileData=function(t,n){var i=t.replace(Qy,"").split("\n").map((function(e){return e.split(",").filter((function(e){return e.length>0}))})).filter((function(e){return e.length>0})),r=e.NumberOfPointsOffset;if(i.length<2)return!1;var o={ids:[],data:new Ky(1800),startingIndices:new Ky(1800)},a=i[0],s=i.slice(1);if(a.length<2||"timestamp"!==a[0]||"numPoints"!==a[r])return!1;for(var c=new Map,u=e.SliceDataOffset;u0&&this.onFeaturePointsAddedObservable.notifyObservers(r),i.length>0&&this.onFeaturePointsUpdatedObservable.notifyObservers(i)}}},t.prototype._init=function(){this._xrSessionManager.session.trySetFeaturePointCloudEnabled&&this._xrSessionManager.session.trySetFeaturePointCloudEnabled(!0)&&(this._enabled=!0)},t.Name=pt.FEATURE_POINTS,t.Version=1,t}(Fl);ft.AddWebXRFeature(uT.Name,(function(e){return function(){return new uT(e)}}),uT.Version);var lT=["wrist","thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip","index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip","middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip","ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip","pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"],hT=((cT={}).wrist=["wrist"],cT.thumb=["thumb-metacarpal","thumb-phalanx-proximal","thumb-phalanx-distal","thumb-tip"],cT.index=["index-finger-metacarpal","index-finger-phalanx-proximal","index-finger-phalanx-intermediate","index-finger-phalanx-distal","index-finger-tip"],cT.middle=["middle-finger-metacarpal","middle-finger-phalanx-proximal","middle-finger-phalanx-intermediate","middle-finger-phalanx-distal","middle-finger-tip"],cT.ring=["ring-finger-metacarpal","ring-finger-phalanx-proximal","ring-finger-phalanx-intermediate","ring-finger-phalanx-distal","ring-finger-tip"],cT.little=["pinky-finger-metacarpal","pinky-finger-phalanx-proximal","pinky-finger-phalanx-intermediate","pinky-finger-phalanx-distal","pinky-finger-tip"],cT),dT=function(){function e(e,t,n,i,r,o,s){void 0===r&&(r=!1),void 0===o&&(o=!1),void 0===s&&(s=1),this.xrController=e,this._jointMeshes=t,this._handMesh=n,this.rigMapping=i,this._leftHandedMeshes=r,this._jointsInvisible=o,this._jointScaleFactor=s,this._jointTransforms=new Array(lT.length),this._jointTransformMatrices=new Float32Array(16*lT.length),this._tempJointMatrix=new a.a,this._jointRadii=new Float32Array(lT.length),this._scene=t[0].getScene();for(var c=0;c0)}},t.Name=pt.IMAGE_TRACKING,t.Version=1,t}(Fl);ft.AddWebXRFeature(mT.Name,(function(e,t){return function(){return new mT(e,t)}}),mT.Version,!1);var gT=function(e){function t(t,n){var i=e.call(this,t)||this;return i.options=n,i._domOverlayType=null,i._beforeXRSelectListener=null,i._element=null,i.xrNativeFeatureName="dom-overlay",Re.b.Warn("dom-overlay is an experimental and unstable feature."),i}return Object(h.d)(t,e),t.prototype.attach=function(){return!!e.prototype.attach.call(this)&&(!(!this._xrSessionManager.session.domOverlayState||null===this._xrSessionManager.session.domOverlayState.type)&&(this._domOverlayType=this._xrSessionManager.session.domOverlayState.type,null!==this._element&&!0===this.options.supressXRSelectEvents&&(this._beforeXRSelectListener=function(e){e.preventDefault()},this._element.addEventListener("beforexrselect",this._beforeXRSelectListener)),!0))},Object.defineProperty(t.prototype,"domOverlayType",{get:function(){return this._domOverlayType},enumerable:!1,configurable:!0}),t.prototype.dispose=function(){e.prototype.dispose.call(this),null!==this._element&&this._beforeXRSelectListener&&this._element.removeEventListener("beforexrselect",this._beforeXRSelectListener)},t.prototype._onXRFrame=function(e){},t.prototype.getXRSessionInitExtension=function(){return Object(h.b)(this,void 0,void 0,(function(){var e;return Object(h.e)(this,(function(t){if(void 0===this.options.element)return Re.b.Warn('"element" option must be provided to attach xr-dom-overlay feature.'),[2,{}];if("string"==typeof this.options.element){if(null===(e=document.querySelector(this.options.element)))return Re.b.Warn("element not found '".concat(this.options.element,"' (not requesting xr-dom-overlay)")),[2,{}];this._element=e}else this._element=this.options.element;return[2,{domOverlay:{root:this._element}}]}))}))},t.Name=pt.DOM_OVERLAY,t.Version=1,t}(Fl);ft.AddWebXRFeature(gT.Name,(function(e,t){return function(){return new gT(e,t)}}),gT.Version,!1);var vT=function(e){function t(n,i){var r,o,s,c,u,l,h=e.call(this,n)||this;return h._controllers={},h._currentRegistrationConfigurations=[],h._movementDirection=null,h._tmpRotationMatrix=a.a.Identity(),h._tmpTranslationDirection=new a.e,h._tmpMovementTranslation=new a.e,h._attachController=function(e){if(!h._controllers[e.uniqueId]){h._controllers[e.uniqueId]={xrController:e,registeredComponents:[]};var t=h._controllers[e.uniqueId];if("tracked-pointer"===t.xrController.inputSource.targetRayMode&&t.xrController.inputSource.gamepad){var n=function(){if(e.motionController)for(var n=function(n){var i=null;if(n.allowedComponentTypes)for(var r=0,o=n.allowedComponentTypes;rn.rotationThreshold?e.x:0,t.rotateY=Math.abs(e.y)>n.rotationThreshold?e.y:0}},{allowedComponentTypes:[Sl.THUMBSTICK_TYPE,Sl.TOUCHPAD_TYPE],forceHandedness:"right",axisChangedHandler:function(e,t,n,i){t.moveX=Math.abs(e.x)>n.movementThreshold?e.x:0,t.moveY=Math.abs(e.y)>n.movementThreshold?e.y:0}}]},t.Version=1,t}(Fl);ft.AddWebXRFeature(vT.Name,(function(e,t){return function(){return new vT(e,t)}}),vT.Version,!0);var bT=n(70),yT=function(e){function t(t,n){var i=e.call(this,t)||this;return i.options=n,i._canvasContext=null,i._reflectionCubeMap=null,i._xrLightEstimate=null,i._xrLightProbe=null,i._xrWebGLBinding=null,i._lightDirection=a.e.Up().negateInPlace(),i._lightColor=s.a.White(),i._intensity=1,i._sphericalHarmonics=new Xr,i._cubeMapPollTime=Date.now(),i._lightEstimationPollTime=Date.now(),i._ReflectionCubeMapTextureSize=16,i.directionalLight=null,i.onReflectionCubeMapUpdatedObservable=new o.c,i._updateReflectionCubeMap=function(){var e;if(i._xrLightProbe){if(i.options.cubeMapPollInterval){var t=Date.now();if(t-i._cubeMapPollTime=this._samples.length)throw new Error("Index out of bounds");return this._samples[(this._idx+e)%this._samples.length]},e}(),ST=function(){function e(){this._samples=new ET(20),this._entropy=0,this.onFirstStepDetected=new o.c}return e.prototype.update=function(e,t,n,i){this._samples.push(e,t);var r=this._samples.at(0);if(this._entropy*=this._entropyDecayFactor,this._entropy+=a.d.Distance(r,this._samples.at(1)),!(this._entropy>this._entropyThreshold)){var o;for(o=this._samePointCheckStartIdx;os&&(c=l,s=u);if(!(so*this._squaredProjectionDistanceThreshold)){var m=a.c.Vector3[0];m.set(n,i,0);var g=a.c.Vector3[1];g.set(d.x,d.y,0);var v=a.e.Cross(m,g).z>0,b=r.clone(),y=r.clone();h.subtractToRef(r,d),v?(d.scaleAndAddToRef(this._axisToApexShrinkFactor,b),d.scaleAndAddToRef(this._axisToApexExtendFactor,y)):(d.scaleAndAddToRef(this._axisToApexExtendFactor,b),d.scaleAndAddToRef(this._axisToApexShrinkFactor,y)),this.onFirstStepDetected.notifyObservers({leftApex:b,rightApex:y,currentPosition:r,currentStepDirection:v?"right":"left"})}}}}},e.prototype.reset=function(){for(var e=0;ethis._maxT&&(this._maxT=this._t,this._maxTPosition.copyFromFloats(e,t)),!(this._vitalityn&&(this.onMovement.notifyObservers({deltaT:this._t-n}),n<.5&&this._t>=.5&&this.onFootfall.notifyObservers({foot:this._steppingLeft?"left":"right"})),this._t<.95*this._maxT&&(this._currentPosition.copyFromFloats(e,t),this._steppingLeft?this._leftApex.copyFrom(this._maxTPosition):this._rightApex.copyFrom(this._maxTPosition),this._reset(this._leftApex,this._rightApex,this._currentPosition,!this._steppingLeft)),!(this._axisLength<.03))},Object.defineProperty(e.prototype,"_vitalityThreshold",{get:function(){return.1},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"forward",{get:function(){return this._forward},enumerable:!1,configurable:!0}),e}(),xT=function(){function e(t){var n=this;this._detector=new ST,this._walker=null,this._movement=new a.d,this._millisecondsSinceLastUpdate=e._MillisecondsPerUpdate,this.movementThisFrame=a.e.Zero(),this._engine=t,this._detector.onFirstStepDetected.add((function(e){n._walker||(n._walker=new AT(e.leftApex,e.rightApex,e.currentPosition,e.currentStepDirection),n._walker.onFootfall.add((function(){console.log("Footfall!")})),n._walker.onMovement.add((function(e){n._walker.forward.scaleAndAddToRef(.024*e.deltaT,n._movement)})))}))}return Object.defineProperty(e,"_MillisecondsPerUpdate",{get:function(){return 1e3/15},enumerable:!1,configurable:!0}),e.prototype.update=function(t,n){if(n.y=0,n.normalize(),this._millisecondsSinceLastUpdate+=this._engine.getDeltaTime(),this._millisecondsSinceLastUpdate>=e._MillisecondsPerUpdate){if(this._millisecondsSinceLastUpdate-=e._MillisecondsPerUpdate,this._detector.update(t.x,t.z,n.x,n.z),this._walker)this._walker.update(t.x,t.z)||(this._walker=null);this._movement.scaleInPlace(.85)}this.movementThisFrame.set(this._movement.x,0,this._movement.y)},e}(),RT=function(e){function t(t,n){var i=e.call(this,t)||this;return i._up=new a.e,i._forward=new a.e,i._position=new a.e,i._movement=new a.e,i._sessionManager=t,i.locomotionTarget=n.locomotionTarget,i._isLocomotionTargetWebXRCamera&&m.a.Warn("Using walking locomotion directly on a WebXRCamera may have unintended interactions with other XR techniques. Using an XR space parent is highly recommended"),i}return Object(h.d)(t,e),Object.defineProperty(t,"Name",{get:function(){return pt.WALKING_LOCOMOTION},enumerable:!1,configurable:!0}),Object.defineProperty(t,"Version",{get:function(){return 1},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"locomotionTarget",{get:function(){return this._locomotionTarget},set:function(e){this._locomotionTarget=e,this._isLocomotionTargetWebXRCamera="WebXRCamera"===this._locomotionTarget.getClassName()},enumerable:!1,configurable:!0}),t.prototype.isCompatible=function(){return void 0===this._sessionManager.sessionMode||"immersive-vr"===this._sessionManager.sessionMode},t.prototype.attach=function(){return!(!this.isCompatible||!e.prototype.attach.call(this))&&(this._walker=new xT(this._sessionManager.scene.getEngine()),!0)},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._walker=null,!0)},t.prototype._onXRFrame=function(e){var t=e.getViewerPose(this._sessionManager.baseReferenceSpace);if(t){var n=this.locomotionTarget.getScene().useRightHandedSystem?1:-1,i=t.transform.matrix;this._up.copyFromFloats(i[4],i[5],n*i[6]),this._forward.copyFromFloats(i[8],i[9],n*i[10]),this._position.copyFromFloats(i[12],i[13],n*i[14]),this._forward.scaleAndAddToRef(.05,this._position),this._up.scaleAndAddToRef(-.05,this._position),this._walker.update(this._position,this._forward),this._movement.copyFrom(this._walker.movementThisFrame),this._isLocomotionTargetWebXRCamera||a.e.TransformNormalToRef(this._movement,this.locomotionTarget.getWorldMatrix(),this._movement),this.locomotionTarget.position.addInPlace(this._movement)}},t}(Fl);ft.AddWebXRFeature(RT.Name,(function(e,t){return function(){return new RT(e,t)}}),RT.Version,!1);var CT=function(e){function t(t,n,i,r,o,a){var s=e.call(this,t,n,i,r,a)||this;return s.getWidth=t,s.getHeight=n,s.layer=i,s.layerType=r,s.isMultiview=o,s.createRTTProvider=a,s}return Object(h.d)(t,e),t}(Oi),PT=function(e){function t(t,n,i){var r=e.call(this,t.scene,i)||this;return r._xrSessionManager=t,r._xrWebGLBinding=n,r.layerWrapper=i,r._lastSubImages=new Map,r._compositionLayer=i.layer,r}return Object(h.d)(t,e),t.prototype._getRenderTargetForSubImage=function(e,t){var n=this._lastSubImages.get(t),i="left"==t?0:1;return this._renderTargetTextures[i]&&(null==n?void 0:n.textureWidth)===e.textureWidth&&(null==n?void 0:n.textureHeight)==e.textureHeight||(this._renderTargetTextures[i]=this._createRenderTargetTexture(e.textureWidth,e.textureHeight,null,e.colorTexture,e.depthStencilTexture,this.layerWrapper.isMultiview),this._framebufferDimensions={framebufferWidth:e.textureWidth,framebufferHeight:e.textureHeight}),this._lastSubImages.set(t,e),this._renderTargetTextures[i]},t.prototype._getSubImageForEye=function(e){var t=this._xrSessionManager.currentFrame;return t?this._xrWebGLBinding.getSubImage(this._compositionLayer,t,e):null},t.prototype.getRenderTargetTextureForEye=function(e){var t=this._getSubImageForEye(e);return t?this._getRenderTargetForSubImage(t,e):null},t.prototype.getRenderTargetTextureForView=function(e){return this.getRenderTargetTextureForEye(e.eye)},t.prototype._setViewportForSubImage=function(e,t){var n=t.textureWidth,i=t.textureHeight,r=t.viewport;e.x=r.x/n,e.y=r.y/i,e.width=r.width/n,e.height=r.height/i},t.prototype.trySetViewportForView=function(e,t){var n=this._lastSubImages.get(t.eye)||this._getSubImageForEye(t.eye);return!!n&&(this._setViewportForSubImage(e,n),!0)},t}(Ii),OT=function(e){function t(t,n,i){var r=e.call(this,(function(){return t.textureWidth}),(function(){return t.textureHeight}),t,"XRProjectionLayer",n,(function(e){return new MT(e,i,r)}))||this;return r.layer=t,r}return Object(h.d)(t,e),t}(CT),MT=function(e){function t(t,n,i){var r=e.call(this,t,n,i)||this;return r.layerWrapper=i,r._projectionLayer=i.layer,r}return Object(h.d)(t,e),t.prototype._getSubImageForView=function(e){return this._xrWebGLBinding.getViewSubImage(this._projectionLayer,e)},t.prototype.getRenderTargetTextureForView=function(e){return this._getRenderTargetForSubImage(this._getSubImageForView(e),e.eye)},t.prototype.getRenderTargetTextureForEye=function(e){var t=this._lastSubImages.get(e);return t?this._getRenderTargetForSubImage(t,e):null},t.prototype.trySetViewportForView=function(e,t){var n=this._lastSubImages.get(t.eye)||this._getSubImageForView(t);return!!n&&(this._setViewportForSubImage(e,n),!0)},t}(PT),IT={},DT={textureType:"texture",colorFormat:6408,depthFormat:35056,scaleFactor:1},NT=function(e){function t(t,n){void 0===n&&(n={});var i=e.call(this,t)||this;return i._options=n,i._existingLayers=[],i.xrNativeFeatureName="layers",i}return Object(h.d)(t,e),t.prototype.attach=function(){if(!e.prototype.attach.call(this))return!1;var t=this._xrSessionManager.scene.getEngine();this._glContext=t._gl,this._xrWebGLBinding=new XRWebGLBinding(this._xrSessionManager.session,this._glContext),this._existingLayers=[];var n=Object(h.a)({},DT),i=this._options.preferMultiviewOnInit&&t.getCaps().multiview;return i&&(n.textureType="texture-array"),this.addXRSessionLayer(this.createProjectionLayer(n,i)),!0},t.prototype.detach=function(){return!!e.prototype.detach.call(this)&&(this._existingLayers.length=0,!0)},t.prototype.createXRWebGLLayer=function(e){void 0===e&&(e=IT);var t=new XRWebGLLayer(this._xrSessionManager.session,this._glContext,e);return new Di(t)},t.prototype.createProjectionLayer=function(e,t){if(void 0===e&&(e=DT),void 0===t&&(t=!1),t&&"texture-array"!==e.textureType)throw new Error("Projection layers can only be made multiview if they use texture arrays. Set the textureType parameter to 'texture-array'.");if(!t&&"texture-array"===e.textureType)throw new Error("We currently only support multiview rendering when the textureType parameter is set to 'texture-array'.");var n=this._xrWebGLBinding.createProjectionLayer(e);return new OT(n,t,this._xrWebGLBinding)},t.prototype.addXRSessionLayer=function(e){this.setXRSessionLayers(Object(h.f)(Object(h.f)([],this._existingLayers,!0),[e],!1))},t.prototype.setXRSessionLayers=function(e){this._existingLayers=e;var t=Object(h.a)({},this._xrSessionManager.session.renderState);t.baseLayer=void 0,t.layers=e.map((function(e){return e.layer})),this._xrSessionManager.updateRenderState(t),this._xrSessionManager._setBaseLayerWrapper(e.length>0?e[0]:null)},t.prototype.isCompatible=function(){return!this._xrSessionManager.isNative&&"undefined"!=typeof XRWebGLBinding&&!!XRWebGLBinding.prototype.createProjectionLayer},t.prototype.dispose=function(){e.prototype.dispose.call(this)},t.prototype._onXRFrame=function(e){},t.Name=pt.LAYERS,t.Version=1,t}(Fl);ft.AddWebXRFeature(NT.Name,(function(e,t){return function(){return new NT(e,t)}}),NT.Version,!1);var LT=function(e){function t(t,n,i){var r=e.call(this,t,FT[i],n,i,!0)||this;return r.profileId="generic-hand-select-grasp",r}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){},t.prototype._updateModel=function(){},t}(Al);Ol.RegisterController("generic-hand-select-grasp",(function(e,t){return new LT(t,e.gamepad,e.handedness)}));var FT={left:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr-standard-trigger",visualResponses:{}},grasp:{type:"trigger",gamepadIndices:{button:4},rootNodeName:"grasp",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-hand-select-grasp-left",assetPath:"left.glb"},right:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr-standard-trigger",visualResponses:{}},grasp:{type:"trigger",gamepadIndices:{button:4},rootNodeName:"grasp",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-hand-select-grasp-right",assetPath:"right.glb"},none:{selectComponentId:"xr-standard-trigger",components:{"xr-standard-trigger":{type:"trigger",gamepadIndices:{button:0},rootNodeName:"xr-standard-trigger",visualResponses:{}},grasp:{type:"trigger",gamepadIndices:{button:4},rootNodeName:"grasp",visualResponses:{}}},gamepadMapping:"xr-standard",rootNodeName:"generic-hand-select-grasp-none",assetPath:"none.glb"}},wT=function(e){function t(t,n,i){var r=e.call(this,t,BT["left-right"],n,i)||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=Xs.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,n){if(!t.disableAnimation&&e&&t.rootMesh){var i=t._mapping.buttons[e],r=i.rootNodeName;if(!r)return void m.a.Log("Skipping unknown button at index: "+n+" 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(i.valueMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.valueNodeName),i.pressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.pressedNodeName),i.unpressedMesh=t._getImmediateChildByName(o,t._mapping.defaultButton.unpressedNodeName),i.valueMesh&&i.pressedMesh&&i.unpressedMesh){var a=t.getComponent(e);a&&a.onButtonStateChangedObservable.add((function(e){t._lerpTransform(i,e.value)}),void 0,!0)}else m.a.Warn("Missing button submesh under mesh with name: "+r)}})),this.getComponentIds().forEach((function(e,n){var i=t.getComponent(e);i.isAxes()&&["x-axis","y-axis"].forEach((function(n){if(t.rootMesh){var r=t._mapping.axes[e][n],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?i&&i.onAxisValueChangedObservable.add((function(e){var i="x-axis"===n?e.x:e.y;t._lerpTransform(r,i,!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 Te.a(this.profileId+" "+this.handedness,this.scene),this.rootMesh.isPickable=!1;for(var n=0;n(_DEFINENAME_,BUMP,_VARYINGNAME_,Bump,_SAMPLERNAME_,bump)\n#endif\n#if defined(DETAIL)\n#include(_DEFINENAME_,DETAIL,_VARYINGNAME_,Detail,_SAMPLERNAME_,detail)\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; icurrRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n";i.a.IncludesShadersStore[r]=o},function(e,t,n){"use strict";var i="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)\n\nvec2 TBNUV=gl_FrontFacing ? vBumpUV : -vBumpUV;\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vTangentSpaceParams);\n#else\n\nvec2 TBNUV=gl_FrontFacing ? vDetailUV : -vDetailUV;\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,TBNUV,vec2(1.,1.));\n#endif\n#elif defined(ANISOTROPIC)\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\n\nvec2 TBNUV=gl_FrontFacing ? vMainUV1 : -vMainUV1;\nmat3 TBN=cotangent_frame(normalW,vPositionW,TBNUV,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,texture2D(bumpSampler,vBumpUV+uvOffset).xyz,vBumpInfos.y);\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\n";n(5).a.IncludesShadersStore.bumpFragment=i},function(e,t,n){"use strict";var i="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=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";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="#ifdef FOG\nfloat fog=CalcFogFactor();\n#ifdef PBR\nfog=toLinearSpace(fog);\n#endif\ncolor.rgb=mix(vFogColor,color.rgb,fog);\n#endif";n(5).a.IncludesShadersStore.fogFragment=i},function(e,t,n){"use strict";var i="fogVertexDeclaration",r="#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="lightVxFragmentDeclaration",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}];\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\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#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="lightVxUboDeclaration",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 SHADOW{X}\n#ifdef SHADOWCSM{X}\nuniform mat4 lightMatrix{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromLight{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying float vDepthMetric{X}[SHADOWCSMNUM_CASCADES{X}];\nvarying vec4 vPositionFromCamera{X};\n#elif defined(SHADOWCUBE{X})\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif";n(5).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="shadowsVertex",r="#ifdef SHADOWS\n#if defined(SHADOWCSM{X})\nvPositionFromCamera{X}=view*worldPos;\nfor (int i=0; i1)for(var c=0;c=e||-1!==n.indexOf("file:")?-1:Math.pow(2,r)*t}},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(1),r=function(){function e(){this.reset()}return e.prototype.reset=function(){this.enabled=!1,this.mask=255,this.func=e.ALWAYS,this.funcRef=1,this.funcMask=255,this.opStencilFail=e.KEEP,this.opDepthFail=e.KEEP,this.opStencilDepthPass=e.REPLACE},Object.defineProperty(e.prototype,"stencilFunc",{get:function(){return this.func},set:function(e){this.func=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncRef",{get:function(){return this.funcRef},set:function(e){this.funcRef=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncMask",{get:function(){return this.funcMask},set:function(e){this.funcMask=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilFail",{get:function(){return this.opStencilFail},set:function(e){this.opStencilFail=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpDepthFail",{get:function(){return this.opDepthFail},set:function(e){this.opDepthFail=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilDepthPass",{get:function(){return this.opStencilDepthPass},set:function(e){this.opStencilDepthPass=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilMask",{get:function(){return this.mask},set:function(e){this.mask=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"stencilTest",{get:function(){return this.enabled},set:function(e){this.enabled=e},enumerable:!1,configurable:!0}),e.ALWAYS=i.a.ALWAYS,e.KEEP=i.a.KEEP,e.REPLACE=i.a.REPLACE,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty||this._isBlendEquationParametersDirty},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,n,i){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===n&&this._blendConstants[3]===i||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=n,this._blendConstants[3]=i,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,n,i){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===n&&this._blendFunctionParameters[3]===i||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=n,this._blendFunctionParameters[3]=i,this._isBlendFunctionParametersDirty=!0)},e.prototype.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._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,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){this._valueCache={},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._fillEffectInformation=function(e,t,n,i,r,o,a,s){var c,u=this.engine;if(u.supportsUniformBuffers)for(var l in t)e.bindUniformBlock(l,t[l]);for(this.engine.getUniforms(this,n).forEach((function(e,t){i[n[t]]=e})),this._uniforms=i,c=0;cn._alphaIndex?1:t._alphaIndext._distanceToCamera?-1:0},e.frontToBackSortCompare=function(e,t){return e._distanceToCamerat._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,n){void 0===t&&(t=e.getMesh()),void 0===n&&(n=e.getMaterial()),null!=n&&(n.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):n.needAlphaTesting()?(n.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(n.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 n=0;n=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,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(0),r=function(){this._checkCollisions=!1,this._collisionMask=-1,this._collisionGroup=-1,this._surroundingMeshes=null,this._collider=null,this._oldPositionForCollisions=new i.e(0,0,0),this._diffPositionForCollisions=new i.e(0,0,0),this._collisionResponse=!0}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(e,t){this.distanceOrScreenCoverage=e,this.mesh=t}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(25),r=function(e){e.prototype.setMaterialByID=function(e){return this.setMaterialById(e)},e.CreateDisc=e.CreateDisc||function(){throw Object(i.a)("MeshBuilder")},e.CreateBox=e.CreateBox||function(){throw Object(i.a)("MeshBuilder")},e.CreateSphere=e.CreateSphere||function(){throw Object(i.a)("MeshBuilder")},e.CreateCylinder=e.CreateCylinder||function(){throw Object(i.a)("MeshBuilder")},e.CreateTorusKnot=e.CreateTorusKnot||function(){throw Object(i.a)("MeshBuilder")},e.CreateTorus=e.CreateTorus||function(){throw Object(i.a)("MeshBuilder")},e.CreatePlane=e.CreatePlane||function(){throw Object(i.a)("MeshBuilder")},e.CreateGround=e.CreateGround||function(){throw Object(i.a)("MeshBuilder")},e.CreateTiledGround=e.CreateTiledGround||function(){throw Object(i.a)("MeshBuilder")},e.CreateGroundFromHeightMap=e.CreateGroundFromHeightMap||function(){throw Object(i.a)("MeshBuilder")},e.CreateTube=e.CreateTube||function(){throw Object(i.a)("MeshBuilder")},e.CreatePolyhedron=e.CreatePolyhedron||function(){throw Object(i.a)("MeshBuilder")},e.CreateIcoSphere=e.CreateIcoSphere||function(){throw Object(i.a)("MeshBuilder")},e.CreateDecal=e.CreateDecal||function(){throw Object(i.a)("MeshBuilder")},e.CreateCapsule=e.CreateCapsule||function(){throw Object(i.a)("MeshBuilder")},e.CreateGoldberg=e.CreateGoldberg||function(){throw Object(i.a)("MeshBuilder")}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o})),n.d(t,"b",(function(){return c})),n.d(t,"d",(function(){return u})),n.d(t,"c",(function(){return l}));var i=n(29),r=n(68),o=function(){function e(e){this._plugins=[],this._activePlugins=[],this._activePluginsForExtraEvents=[],this._material=e,this._scene=e.getScene(),this._engine=this._scene.getEngine()}return e.prototype._addPlugin=function(e){for(var t=0;t0?this._defineNamesFromPlugins=n:delete this._defineNamesFromPlugins},e.prototype._activatePlugin=function(e){-1===this._activePlugins.indexOf(e)&&(this._activePlugins.push(e),this._activePlugins.sort((function(e,t){return e.priority-t.priority})),this._material._callbackPluginEventIsReadyForSubMesh=this._handlePluginEventIsReadyForSubMesh.bind(this),this._material._callbackPluginEventPrepareDefines=this._handlePluginEventPrepareDefines.bind(this),this._material._callbackPluginEventBindForSubMesh=this._handlePluginEventBindForSubMesh.bind(this),e.registerForExtraEvents&&(this._activePluginsForExtraEvents.push(e),this._activePluginsForExtraEvents.sort((function(e,t){return e.priority-t.priority})),this._material._callbackPluginEventHasRenderTargetTextures=this._handlePluginEventHasRenderTargetTextures.bind(this),this._material._callbackPluginEventFillRenderTargetTextures=this._handlePluginEventFillRenderTargetTextures.bind(this),this._material._callbackPluginEventHardBindForSubMesh=this._handlePluginEventHardBindForSubMesh.bind(this)))},e.prototype.getPlugin=function(e){for(var t=0;t0&&(n=a.uniforms).push.apply(n,this._uniformList),this._samplerList.length>0&&(i=a.samplers).push.apply(i,this._samplerList),this._uboList.length>0&&(o=a.uniformBuffersNames).push.apply(o,this._uboList),a.customCode=this._injectCustomCode(a.customCode);break;case r.a.PrepareUniformBuffer:a=t;this._uboDeclaration="",this._vertexDeclaration="",this._fragmentDeclaration="",this._uniformList=[],this._samplerList=[],this._uboList=[];for(var b=0,y=this._plugins;b0)if("!"===a.charAt(0))for(var h=new RegExp(a.substring(1),"g"),d=h.exec(i);null!==d;)i=i.replace(d[0],s),d=h.exec(i);else{var p="#define "+a;i=i.replace(p,"\r\n"+s+"\r\n"+p)}}return i}},e}(),a=[],s=!1;function c(e,t){s||(i.a.OnEventObservable.add((function(e,t){for(var n=0,i=a;n0?n[0][1]=t:a.push([e,t])}function u(e){for(var t=0;t=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!==u.a.BILLBOARDMODE_NONE&&this._currentLOD._masterMesh!==this){this._billboardWorldMatrix||(this._billboardWorldMatrix=new r.a);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),this._billboardWorldMatrix.copyFrom(this._currentLOD.computeWorldMatrix(!0)),this._currentLOD.position.copyFrom(r.c.Vector3[7]),this._currentLOD._masterMesh=t,this._billboardWorldMatrix}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.sourceMesh.getLODLevels();if(t&&0!==t.length){var n=this.getBoundingInfo();this._currentLOD=this.sourceMesh.getLOD(e,n.boundingSphere)}else this._currentLOD=this.sourceMesh;return 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=i.e.LeftClick&&n<=i.e.RightClick&&(s.type=1===r?"pointerdown":"pointerup",s.button=n-2),s},e._createWheelEvent=function(e,t,n,r,o,s){var c=this._createMouseEvent(e,t,n,r,o,s);return c.type="wheel",c.deltaMode=a.b.DOM_DELTA_PIXEL,c.deltaX=n===i.e.MouseWheelX?r:o.pollInput(e,t,i.e.MouseWheelX),c.deltaY=n===i.e.MouseWheelY?r:o.pollInput(e,t,i.e.MouseWheelY),c.deltaZ=n===i.e.MouseWheelZ?r:o.pollInput(e,t,i.e.MouseWheelZ),c},e._createMouseEvent=function(e,t,n,r,o,a){var s=this._createEvent(a),c=o.pollInput(e,t,i.e.Horizontal),u=o.pollInput(e,t,i.e.Vertical);return a?(s.movementX=0,s.movementY=0,s.offsetX=s.movementX-a.getBoundingClientRect().x,s.offsetY=s.movementY-a.getBoundingClientRect().y):(s.movementX=o.pollInput(e,t,i.d.DeltaHorizontal),s.movementY=o.pollInput(e,t,i.d.DeltaVertical),s.offsetX=0,s.offsetY=0),this._checkNonCharacterKeys(s,o),s.clientX=c,s.clientY=u,s.x=c,s.y=u,s.deviceType=e,s.deviceSlot=t,s.inputIndex=n,s},e._createKeyboardEvent=function(e,t,n,r){var o=this._createEvent(r);return this._checkNonCharacterKeys(o,n),o.deviceType=i.a.Keyboard,o.deviceSlot=0,o.inputIndex=e,o.type=1===t?"keydown":"keyup",o.key=String.fromCharCode(e),o.keyCode=e,o},e._checkNonCharacterKeys=function(e,t){var n=t.isDeviceAvailable(i.a.Keyboard),r=n&&1===t.pollInput(i.a.Keyboard,0,o.a.INPUT_ALT_KEY),a=n&&1===t.pollInput(i.a.Keyboard,0,o.a.INPUT_CTRL_KEY),s=n&&(1===t.pollInput(i.a.Keyboard,0,o.a.INPUT_META_KEY1)||1===t.pollInput(i.a.Keyboard,0,o.a.INPUT_META_KEY2)||1===t.pollInput(i.a.Keyboard,0,o.a.INPUT_META_KEY3)),c=n&&1===t.pollInput(i.a.Keyboard,0,o.a.INPUT_SHIFT_KEY);e.altKey=r,e.ctrlKey=a,e.metaKey=s,e.shiftKey=c},e._createEvent=function(e){var t={preventDefault:function(){}};return t.target=e,t},e}(),c=function(){function e(e){var t=this;this.onDeviceConnected=function(e,t){},this.onDeviceDisconnected=function(e,t){},this.onInputChanged=function(e,t,n){},this._nativeInput=e||this._createDummyNativeInput(),this._nativeInput.onDeviceConnected=function(e,n){t.onDeviceConnected(e,n)},this._nativeInput.onDeviceDisconnected=function(e,n){t.onDeviceDisconnected(e,n)},this._nativeInput.onInputChanged=function(e,n,r,o){var a=r===i.d.Horizontal||r===i.d.Vertical||r===i.d.DeltaHorizontal||r===i.d.DeltaVertical?i.e.Move:r,c=s.CreateDeviceEvent(e,n,a,o,t);t.onInputChanged(e,n,c)}}return e.prototype.pollInput=function(e,t,n){return this._nativeInput.pollInput(e,t,n)},e.prototype.isDeviceAvailable=function(e){return e===i.a.Mouse||e===i.a.Touch},e.prototype.dispose=function(){this.onDeviceConnected=function(){},this.onDeviceDisconnected=function(){},this.onInputChanged=function(){}},e.prototype._createDummyNativeInput=function(){return{onDeviceConnected:function(e,t){},onDeviceDisconnected:function(e,t){},onInputChanged:function(e,t,n,i){},pollInput:function(){return 0},isDeviceAvailable:function(){return!1},dispose:function(){}}},e}(),u=n(35),l=n(12),h=Object.keys(i.e).length/2,d=function(){function e(e){var t=this;this._inputs=[],this._keyboardActive=!1,this._pointerActive=!1,this._usingSafari=l.b.IsSafari(),this._keyboardDownEvent=function(e){},this._keyboardUpEvent=function(e){},this._keyboardBlurEvent=function(e){},this._pointerMoveEvent=function(e){},this._pointerDownEvent=function(e){},this._pointerUpEvent=function(e){},this._pointerCancelEvent=function(e){},this._pointerWheelEvent=function(e){},this._pointerBlurEvent=function(e){},this._eventsAttached=!1,this._mouseId=-1,this._isUsingFirefox=u.a.IsNavigatorAvailable()&&navigator.userAgent&&-1!==navigator.userAgent.indexOf("Firefox"),this._maxTouchPoints=0,this._pointerInputClearObserver=null,this._gamepadConnectedEvent=function(e){},this._gamepadDisconnectedEvent=function(e){},this._eventPrefix=l.b.GetPointerPrefix(e),this._engine=e,this.onDeviceConnected=function(e,t){},this.onDeviceDisconnected=function(e,t){},this.onInputChanged=function(e,t,n){},this._enableEvents(),this._engine._onEngineViewChanged||(this._engine._onEngineViewChanged=function(){t._enableEvents()})}return Object.defineProperty(e.prototype,"onDeviceConnected",{get:function(){return this._onDeviceConnected},set:function(e){this._onDeviceConnected=e;for(var t=0;t=i.a.DualShock&&e<=i.a.DualSense&&navigator.getGamepads&&this._updateDevice(e,t,n);var o=r[n];if(void 0===o)throw"Unable to find input ".concat(n," for device ").concat(i.a[e]," in slot ").concat(t);return n===i.e.Move&&l.b.Warn("Unable to provide information for PointerInput.Move. Try using PointerInput.Horizontal or PointerInput.Vertical for move data."),o},e.prototype.isDeviceAvailable=function(e){return void 0!==this._inputs[e]},e.prototype.dispose=function(){this.onDeviceConnected=function(){},this.onDeviceDisconnected=function(){},this.onInputChanged=function(){},delete this._engine._onEngineViewChanged,this._elementToAttachTo&&this._disableEvents()},e.prototype._enableEvents=function(){var e=null==this?void 0:this._engine.getInputElement();if(e&&(!this._eventsAttached||this._elementToAttachTo!==e)){if(this._disableEvents(),this._inputs)for(var t=0,n=this._inputs;t=0))return void l.b.Warn("Max number of touches exceeded. Ignoring touches in excess of ".concat(e._maxTouchPoints));r=o,e._activeTouchIds[o]=t.pointerId}e._inputs[n]||(e._inputs[n]={}),e._inputs[n][r]?n===i.a.Touch&&e.onDeviceConnected(n,r):e._addPointerDevice(n,r,t.clientX,t.clientY);var a=e._inputs[n][r];if(a){var s=a[i.e.Horizontal],c=a[i.e.Vertical];if(n===i.a.Mouse){if(-1===e._mouseId&&(void 0===t.pointerId?e._mouseId=e._isUsingFirefox?0:1:e._mouseId=t.pointerId),!document.pointerLockElement&&e._elementToAttachTo.hasPointerCapture)try{e._elementToAttachTo.setPointerCapture(e._mouseId)}catch(e){}}else if(t.pointerId&&!document.pointerLockElement&&e._elementToAttachTo.hasPointerCapture)try{e._elementToAttachTo.setPointerCapture(t.pointerId)}catch(e){}a[i.e.Horizontal]=t.clientX,a[i.e.Vertical]=t.clientY,a[t.button+2]=1;var u=t;u.inputIndex=t.button+2,e.onInputChanged(n,r,u),s===t.clientX&&c===t.clientY||(u.inputIndex=i.e.Move,e.onInputChanged(n,r,u))}},this._pointerUpEvent=function(t){var n,r,o,a,s,c=e._getPointerType(t),u=c===i.a.Mouse?0:e._activeTouchIds.indexOf(t.pointerId);if(c===i.a.Touch){if(-1===u)return;e._activeTouchIds[u]=-1}var l=null===(n=e._inputs[c])||void 0===n?void 0:n[u];if(l&&0!==l[t.button+2]){var h=l[i.e.Horizontal],d=l[i.e.Vertical];l[i.e.Horizontal]=t.clientX,l[i.e.Vertical]=t.clientY,l[t.button+2]=0;var p=t;h===t.clientX&&d===t.clientY||(p.inputIndex=i.e.Move,e.onInputChanged(c,u,p)),p.inputIndex=t.button+2,c===i.a.Mouse&&e._mouseId>=0&&(null===(o=(r=e._elementToAttachTo).hasPointerCapture)||void 0===o?void 0:o.call(r,e._mouseId))?e._elementToAttachTo.releasePointerCapture(e._mouseId):t.pointerId&&(null===(s=(a=e._elementToAttachTo).hasPointerCapture)||void 0===s?void 0:s.call(a,t.pointerId))&&e._elementToAttachTo.releasePointerCapture(t.pointerId),e.onInputChanged(c,u,p),c===i.a.Touch&&e.onDeviceDisconnected(c,u)}},this._pointerCancelEvent=function(t){var n,r,o,a;if("mouse"===t.pointerType){var c=e._inputs[i.a.Mouse][0];e._mouseId>=0&&(null===(r=(n=e._elementToAttachTo).hasPointerCapture)||void 0===r?void 0:r.call(n,e._mouseId))&&e._elementToAttachTo.releasePointerCapture(e._mouseId);for(var u=i.e.LeftClick;u<=i.e.BrowserForward;u++)if(1===c[u]){c[u]=0;var l=s.CreateDeviceEvent(i.a.Mouse,0,u,0,e,e._elementToAttachTo);e.onInputChanged(i.a.Mouse,0,l)}}else{var h=e._activeTouchIds.indexOf(t.pointerId);(null===(a=(o=e._elementToAttachTo).hasPointerCapture)||void 0===a?void 0:a.call(o,t.pointerId))&&e._elementToAttachTo.releasePointerCapture(t.pointerId),e._inputs[i.a.Touch][h][i.e.LeftClick]=0;l=s.CreateDeviceEvent(i.a.Touch,h,i.e.LeftClick,0,e,e._elementToAttachTo);e.onInputChanged(i.a.Touch,h,l),e._activeTouchIds[h]=-1,e.onDeviceDisconnected(i.a.Touch,h)}},this._wheelEventName="onwheel"in document.createElement("div")?"wheel":void 0!==document.onmousewheel?"mousewheel":"DOMMouseScroll";var n=!1,r=function(){};try{var o={passive:{get:function(){n=!0}}};this._elementToAttachTo.addEventListener("test",r,o),this._elementToAttachTo.removeEventListener("test",r,o)}catch(e){}this._pointerBlurEvent=function(t){var n,r,o,a,c;if(e.isDeviceAvailable(i.a.Mouse)){var u=e._inputs[i.a.Mouse][0];e._mouseId>=0&&(null===(r=(n=e._elementToAttachTo).hasPointerCapture)||void 0===r?void 0:r.call(n,e._mouseId))&&e._elementToAttachTo.releasePointerCapture(e._mouseId);for(var l=i.e.LeftClick;l<=i.e.BrowserForward;l++)if(1===u[l]){u[l]=0;var h=s.CreateDeviceEvent(i.a.Mouse,0,l,0,e,e._elementToAttachTo);e.onInputChanged(i.a.Mouse,0,h)}}if(e.isDeviceAvailable(i.a.Touch)){u=e._inputs[i.a.Touch];for(var d=0;d=i.buttons.length?r[n]=i.axes[n-i.buttons.length].valueOf():r[n]=i.buttons[n].value}},e.prototype._getGamepadDeviceType=function(e){return-1!==e.indexOf("054c")?-1!==e.indexOf("0ce6")?i.a.DualSense:i.a.DualShock:-1!==e.indexOf("Xbox One")||-1!==e.search("Xbox 360")||-1!==e.search("xinput")?i.a.Xbox:-1!==e.indexOf("057e")?i.a.Switch:i.a.Generic},e.prototype._getPointerType=function(e){var t=i.a.Mouse;return("touch"===e.pointerType||"pen"===e.pointerType||e.touches)&&(t=i.a.Touch),t},e}(),p=n(149),f=function(){function e(e){var t=this;this._registeredManagers=new Array,this._refCount=0,this.registerManager=function(e){for(var n=0;n-1&&t._registeredManagers.splice(n,1)};var n=Object.keys(i.a).length/2;this._devices=new Array(n),"undefined"!=typeof _native?this._deviceInputSystem=_native.DeviceInputSystem?new c(new _native.DeviceInputSystem):new c:this._deviceInputSystem=new d(e),this._deviceInputSystem.onDeviceConnected=function(e,n){t._devices[e]||(t._devices[e]=new Array),t._devices[e][n]||(t._devices[e][n]=n);for(var i=0,r=t._registeredManagers;i\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n#define CUSTOM_FRAGMENT_MAIN_END\n}";i.a.ShadersStore[r]=o},function(e,t,n){"use strict";var i=n(5),r=(n(92),n(97),n(119),n(98),n(93),n(94),n(99),n(111),"colorVertexShader"),o="\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n#include\n\n#include\nuniform mat4 viewProjection;\n#ifdef MULTIVIEW\nuniform mat4 viewProjectionR;\n#endif\n\n#if defined(VERTEXCOLOR) || defined(INSTANCESCOLOR)\nvarying vec4 vColor;\n#endif\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\n#include\n#include\n#include\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\n#ifdef VERTEXCOLOR\nvColor=color;\n#elif INSTANCESCOLOR\nvColor=instanceColor;\n#endif\n#define CUSTOM_VERTEX_MAIN_END\n}";i.a.ShadersStore[r]=o},function(e,t,n){"use strict";n.r(t),function(e){n.d(t,"Debug",(function(){return u}));var i=n(152),r=n(117);n.d(t,"AbstractScene",(function(){return i.AbstractScene})),n.d(t,"AbstractActionManager",(function(){return i.AbstractActionManager})),n.d(t,"Action",(function(){return i.Action})),n.d(t,"ActionEvent",(function(){return i.ActionEvent})),n.d(t,"ActionManager",(function(){return i.ActionManager})),n.d(t,"Condition",(function(){return i.Condition})),n.d(t,"ValueCondition",(function(){return i.ValueCondition})),n.d(t,"PredicateCondition",(function(){return i.PredicateCondition})),n.d(t,"StateCondition",(function(){return i.StateCondition})),n.d(t,"SwitchBooleanAction",(function(){return i.SwitchBooleanAction})),n.d(t,"SetStateAction",(function(){return i.SetStateAction})),n.d(t,"SetValueAction",(function(){return i.SetValueAction})),n.d(t,"IncrementValueAction",(function(){return i.IncrementValueAction})),n.d(t,"PlayAnimationAction",(function(){return i.PlayAnimationAction})),n.d(t,"StopAnimationAction",(function(){return i.StopAnimationAction})),n.d(t,"DoNothingAction",(function(){return i.DoNothingAction})),n.d(t,"CombineAction",(function(){return i.CombineAction})),n.d(t,"ExecuteCodeAction",(function(){return i.ExecuteCodeAction})),n.d(t,"SetParentAction",(function(){return i.SetParentAction})),n.d(t,"PlaySoundAction",(function(){return i.PlaySoundAction})),n.d(t,"StopSoundAction",(function(){return i.StopSoundAction})),n.d(t,"InterpolateValueAction",(function(){return i.InterpolateValueAction})),n.d(t,"Animatable",(function(){return i.Animatable})),n.d(t,"_IAnimationState",(function(){return i._IAnimationState})),n.d(t,"Animation",(function(){return i.Animation})),n.d(t,"TargetedAnimation",(function(){return i.TargetedAnimation})),n.d(t,"AnimationGroup",(function(){return i.AnimationGroup})),n.d(t,"AnimationPropertiesOverride",(function(){return i.AnimationPropertiesOverride})),n.d(t,"EasingFunction",(function(){return i.EasingFunction})),n.d(t,"CircleEase",(function(){return i.CircleEase})),n.d(t,"BackEase",(function(){return i.BackEase})),n.d(t,"BounceEase",(function(){return i.BounceEase})),n.d(t,"CubicEase",(function(){return i.CubicEase})),n.d(t,"ElasticEase",(function(){return i.ElasticEase})),n.d(t,"ExponentialEase",(function(){return i.ExponentialEase})),n.d(t,"PowerEase",(function(){return i.PowerEase})),n.d(t,"QuadraticEase",(function(){return i.QuadraticEase})),n.d(t,"QuarticEase",(function(){return i.QuarticEase})),n.d(t,"QuinticEase",(function(){return i.QuinticEase})),n.d(t,"SineEase",(function(){return i.SineEase})),n.d(t,"BezierCurveEase",(function(){return i.BezierCurveEase})),n.d(t,"RuntimeAnimation",(function(){return i.RuntimeAnimation})),n.d(t,"AnimationEvent",(function(){return i.AnimationEvent})),n.d(t,"AnimationKeyInterpolation",(function(){return i.AnimationKeyInterpolation})),n.d(t,"AnimationRange",(function(){return i.AnimationRange})),n.d(t,"PathCursor",(function(){return i.PathCursor})),n.d(t,"KeepAssets",(function(){return i.KeepAssets})),n.d(t,"InstantiatedEntries",(function(){return i.InstantiatedEntries})),n.d(t,"AssetContainer",(function(){return i.AssetContainer})),n.d(t,"Analyser",(function(){return i.Analyser})),n.d(t,"AudioEngine",(function(){return i.AudioEngine})),n.d(t,"AudioSceneComponent",(function(){return i.AudioSceneComponent})),n.d(t,"Sound",(function(){return i.Sound})),n.d(t,"SoundTrack",(function(){return i.SoundTrack})),n.d(t,"WeightedSound",(function(){return i.WeightedSound})),n.d(t,"BakedVertexAnimationManager",(function(){return i.BakedVertexAnimationManager})),n.d(t,"VertexAnimationBaker",(function(){return i.VertexAnimationBaker})),n.d(t,"AutoRotationBehavior",(function(){return i.AutoRotationBehavior})),n.d(t,"BouncingBehavior",(function(){return i.BouncingBehavior})),n.d(t,"FramingBehavior",(function(){return i.FramingBehavior})),n.d(t,"AttachToBoxBehavior",(function(){return i.AttachToBoxBehavior})),n.d(t,"FadeInOutBehavior",(function(){return i.FadeInOutBehavior})),n.d(t,"MultiPointerScaleBehavior",(function(){return i.MultiPointerScaleBehavior})),n.d(t,"PointerDragBehavior",(function(){return i.PointerDragBehavior})),n.d(t,"SixDofDragBehavior",(function(){return i.SixDofDragBehavior})),n.d(t,"SurfaceMagnetismBehavior",(function(){return i.SurfaceMagnetismBehavior})),n.d(t,"BaseSixDofDragBehavior",(function(){return i.BaseSixDofDragBehavior})),n.d(t,"FollowBehavior",(function(){return i.FollowBehavior})),n.d(t,"HandConstraintZone",(function(){return i.HandConstraintZone})),n.d(t,"HandConstraintOrientation",(function(){return i.HandConstraintOrientation})),n.d(t,"HandConstraintVisibility",(function(){return i.HandConstraintVisibility})),n.d(t,"HandConstraintBehavior",(function(){return i.HandConstraintBehavior})),n.d(t,"Bone",(function(){return i.Bone})),n.d(t,"BoneIKController",(function(){return i.BoneIKController})),n.d(t,"BoneLookController",(function(){return i.BoneLookController})),n.d(t,"Skeleton",(function(){return i.Skeleton})),n.d(t,"Buffer",(function(){return i.Buffer})),n.d(t,"VertexBuffer",(function(){return i.VertexBuffer})),n.d(t,"DataBuffer",(function(){return i.DataBuffer})),n.d(t,"StorageBuffer",(function(){return i.StorageBuffer})),n.d(t,"BaseCameraMouseWheelInput",(function(){return i.BaseCameraMouseWheelInput})),n.d(t,"BaseCameraPointersInput",(function(){return i.BaseCameraPointersInput})),n.d(t,"ArcRotateCameraGamepadInput",(function(){return i.ArcRotateCameraGamepadInput})),n.d(t,"ArcRotateCameraKeyboardMoveInput",(function(){return i.ArcRotateCameraKeyboardMoveInput})),n.d(t,"ArcRotateCameraMouseWheelInput",(function(){return i.ArcRotateCameraMouseWheelInput})),n.d(t,"ArcRotateCameraPointersInput",(function(){return i.ArcRotateCameraPointersInput})),n.d(t,"ArcRotateCameraVRDeviceOrientationInput",(function(){return i.ArcRotateCameraVRDeviceOrientationInput})),n.d(t,"FlyCameraKeyboardInput",(function(){return i.FlyCameraKeyboardInput})),n.d(t,"FlyCameraMouseInput",(function(){return i.FlyCameraMouseInput})),n.d(t,"FollowCameraKeyboardMoveInput",(function(){return i.FollowCameraKeyboardMoveInput})),n.d(t,"FollowCameraMouseWheelInput",(function(){return i.FollowCameraMouseWheelInput})),n.d(t,"FollowCameraPointersInput",(function(){return i.FollowCameraPointersInput})),n.d(t,"FreeCameraDeviceOrientationInput",(function(){return i.FreeCameraDeviceOrientationInput})),n.d(t,"FreeCameraGamepadInput",(function(){return i.FreeCameraGamepadInput})),n.d(t,"FreeCameraKeyboardMoveInput",(function(){return i.FreeCameraKeyboardMoveInput})),n.d(t,"FreeCameraMouseInput",(function(){return i.FreeCameraMouseInput})),n.d(t,"FreeCameraMouseWheelInput",(function(){return i.FreeCameraMouseWheelInput})),n.d(t,"FreeCameraTouchInput",(function(){return i.FreeCameraTouchInput})),n.d(t,"FreeCameraVirtualJoystickInput",(function(){return i.FreeCameraVirtualJoystickInput})),n.d(t,"CameraInputTypes",(function(){return i.CameraInputTypes})),n.d(t,"CameraInputsManager",(function(){return i.CameraInputsManager})),n.d(t,"Camera",(function(){return i.Camera})),n.d(t,"TargetCamera",(function(){return i.TargetCamera})),n.d(t,"FreeCamera",(function(){return i.FreeCamera})),n.d(t,"FreeCameraInputsManager",(function(){return i.FreeCameraInputsManager})),n.d(t,"TouchCamera",(function(){return i.TouchCamera})),n.d(t,"ArcRotateCamera",(function(){return i.ArcRotateCamera})),n.d(t,"ArcRotateCameraInputsManager",(function(){return i.ArcRotateCameraInputsManager})),n.d(t,"DeviceOrientationCamera",(function(){return i.DeviceOrientationCamera})),n.d(t,"FlyCamera",(function(){return i.FlyCamera})),n.d(t,"FlyCameraInputsManager",(function(){return i.FlyCameraInputsManager})),n.d(t,"FollowCamera",(function(){return i.FollowCamera})),n.d(t,"ArcFollowCamera",(function(){return i.ArcFollowCamera})),n.d(t,"FollowCameraInputsManager",(function(){return i.FollowCameraInputsManager})),n.d(t,"GamepadCamera",(function(){return i.GamepadCamera})),n.d(t,"AnaglyphArcRotateCamera",(function(){return i.AnaglyphArcRotateCamera})),n.d(t,"AnaglyphFreeCamera",(function(){return i.AnaglyphFreeCamera})),n.d(t,"AnaglyphGamepadCamera",(function(){return i.AnaglyphGamepadCamera})),n.d(t,"AnaglyphUniversalCamera",(function(){return i.AnaglyphUniversalCamera})),n.d(t,"StereoscopicArcRotateCamera",(function(){return i.StereoscopicArcRotateCamera})),n.d(t,"StereoscopicFreeCamera",(function(){return i.StereoscopicFreeCamera})),n.d(t,"StereoscopicGamepadCamera",(function(){return i.StereoscopicGamepadCamera})),n.d(t,"StereoscopicUniversalCamera",(function(){return i.StereoscopicUniversalCamera})),n.d(t,"StereoscopicScreenUniversalCamera",(function(){return i.StereoscopicScreenUniversalCamera})),n.d(t,"UniversalCamera",(function(){return i.UniversalCamera})),n.d(t,"VirtualJoysticksCamera",(function(){return i.VirtualJoysticksCamera})),n.d(t,"VRCameraMetrics",(function(){return i.VRCameraMetrics})),n.d(t,"VRDeviceOrientationArcRotateCamera",(function(){return i.VRDeviceOrientationArcRotateCamera})),n.d(t,"VRDeviceOrientationFreeCamera",(function(){return i.VRDeviceOrientationFreeCamera})),n.d(t,"VRDeviceOrientationGamepadCamera",(function(){return i.VRDeviceOrientationGamepadCamera})),n.d(t,"OnAfterEnteringVRObservableEvent",(function(){return i.OnAfterEnteringVRObservableEvent})),n.d(t,"VRExperienceHelper",(function(){return i.VRExperienceHelper})),n.d(t,"WebVRFreeCamera",(function(){return i.WebVRFreeCamera})),n.d(t,"setStereoscopicAnaglyphRigMode",(function(){return i.setStereoscopicAnaglyphRigMode})),n.d(t,"setStereoscopicRigMode",(function(){return i.setStereoscopicRigMode})),n.d(t,"setVRRigMode",(function(){return i.setVRRigMode})),n.d(t,"setWebVRRigMode",(function(){return i.setWebVRRigMode})),n.d(t,"Collider",(function(){return i.Collider})),n.d(t,"DefaultCollisionCoordinator",(function(){return i.DefaultCollisionCoordinator})),n.d(t,"PickingInfo",(function(){return i.PickingInfo})),n.d(t,"IntersectionInfo",(function(){return i.IntersectionInfo})),n.d(t,"_MeshCollisionData",(function(){return i._MeshCollisionData})),n.d(t,"ComputeEffect",(function(){return i.ComputeEffect})),n.d(t,"ComputeShader",(function(){return i.ComputeShader})),n.d(t,"BoundingBox",(function(){return i.BoundingBox})),n.d(t,"BoundingInfo",(function(){return i.BoundingInfo})),n.d(t,"BoundingSphere",(function(){return i.BoundingSphere})),n.d(t,"Octree",(function(){return i.Octree})),n.d(t,"OctreeBlock",(function(){return i.OctreeBlock})),n.d(t,"OctreeSceneComponent",(function(){return i.OctreeSceneComponent})),n.d(t,"Ray",(function(){return i.Ray})),n.d(t,"AxesViewer",(function(){return i.AxesViewer})),n.d(t,"BoneAxesViewer",(function(){return i.BoneAxesViewer})),n.d(t,"DebugLayerTab",(function(){return i.DebugLayerTab})),n.d(t,"DebugLayer",(function(){return i.DebugLayer})),n.d(t,"PhysicsViewer",(function(){return i.PhysicsViewer})),n.d(t,"RayHelper",(function(){return i.RayHelper})),n.d(t,"SkeletonViewer",(function(){return i.SkeletonViewer})),n.d(t,"DirectionalLightFrustumViewer",(function(){return i.DirectionalLightFrustumViewer})),n.d(t,"DeviceType",(function(){return i.DeviceType})),n.d(t,"PointerInput",(function(){return i.PointerInput})),n.d(t,"NativePointerInput",(function(){return i.NativePointerInput})),n.d(t,"DualShockInput",(function(){return i.DualShockInput})),n.d(t,"DualSenseInput",(function(){return i.DualSenseInput})),n.d(t,"XboxInput",(function(){return i.XboxInput})),n.d(t,"SwitchInput",(function(){return i.SwitchInput})),n.d(t,"DeviceSource",(function(){return i.DeviceSource})),n.d(t,"DeviceSourceManager",(function(){return i.DeviceSourceManager})),n.d(t,"Constants",(function(){return i.Constants})),n.d(t,"ThinEngine",(function(){return i.ThinEngine})),n.d(t,"Engine",(function(){return i.Engine})),n.d(t,"EngineStore",(function(){return i.EngineStore})),n.d(t,"NullEngineOptions",(function(){return i.NullEngineOptions})),n.d(t,"NullEngine",(function(){return i.NullEngine})),n.d(t,"_OcclusionDataStorage",(function(){return i._OcclusionDataStorage})),n.d(t,"_forceTransformFeedbackToBundle",(function(){return i._forceTransformFeedbackToBundle})),n.d(t,"EngineView",(function(){return i.EngineView})),n.d(t,"allocateAndCopyTypedBuffer",(function(){return i.allocateAndCopyTypedBuffer})),n.d(t,"ComputeBindingType",(function(){return i.ComputeBindingType})),n.d(t,"NativeDataStream",(function(){return i.NativeDataStream})),n.d(t,"WebGLPipelineContext",(function(){return i.WebGLPipelineContext})),n.d(t,"WebGLHardwareTexture",(function(){return i.WebGLHardwareTexture})),n.d(t,"PowerPreference",(function(){return i.PowerPreference})),n.d(t,"FeatureName",(function(){return i.FeatureName})),n.d(t,"BufferUsage",(function(){return i.BufferUsage})),n.d(t,"MapMode",(function(){return i.MapMode})),n.d(t,"TextureDimension",(function(){return i.TextureDimension})),n.d(t,"TextureUsage",(function(){return i.TextureUsage})),n.d(t,"TextureViewDimension",(function(){return i.TextureViewDimension})),n.d(t,"TextureAspect",(function(){return i.TextureAspect})),n.d(t,"TextureFormat",(function(){return i.TextureFormat})),n.d(t,"AddressMode",(function(){return i.AddressMode})),n.d(t,"FilterMode",(function(){return i.FilterMode})),n.d(t,"CompareFunction",(function(){return i.CompareFunction})),n.d(t,"ShaderStage",(function(){return i.ShaderStage})),n.d(t,"BufferBindingType",(function(){return i.BufferBindingType})),n.d(t,"SamplerBindingType",(function(){return i.SamplerBindingType})),n.d(t,"TextureSampleType",(function(){return i.TextureSampleType})),n.d(t,"StorageTextureAccess",(function(){return i.StorageTextureAccess})),n.d(t,"CompilationMessageType",(function(){return i.CompilationMessageType})),n.d(t,"PrimitiveTopology",(function(){return i.PrimitiveTopology})),n.d(t,"FrontFace",(function(){return i.FrontFace})),n.d(t,"CullMode",(function(){return i.CullMode})),n.d(t,"ColorWrite",(function(){return i.ColorWrite})),n.d(t,"BlendFactor",(function(){return i.BlendFactor})),n.d(t,"BlendOperation",(function(){return i.BlendOperation})),n.d(t,"StencilOperation",(function(){return i.StencilOperation})),n.d(t,"IndexFormat",(function(){return i.IndexFormat})),n.d(t,"VertexFormat",(function(){return i.VertexFormat})),n.d(t,"InputStepMode",(function(){return i.InputStepMode})),n.d(t,"ComputePassTimestampLocation",(function(){return i.ComputePassTimestampLocation})),n.d(t,"RenderPassTimestampLocation",(function(){return i.RenderPassTimestampLocation})),n.d(t,"LoadOp",(function(){return i.LoadOp})),n.d(t,"StoreOp",(function(){return i.StoreOp})),n.d(t,"QueryType",(function(){return i.QueryType})),n.d(t,"CanvasCompositingAlphaMode",(function(){return i.CanvasCompositingAlphaMode})),n.d(t,"DeviceLostReason",(function(){return i.DeviceLostReason})),n.d(t,"ErrorFilter",(function(){return i.ErrorFilter})),n.d(t,"WebGPUEngine",(function(){return i.WebGPUEngine})),n.d(t,"WebGPUCacheRenderPipeline",(function(){return i.WebGPUCacheRenderPipeline})),n.d(t,"WebGPUCacheRenderPipelineTree",(function(){return i.WebGPUCacheRenderPipelineTree})),n.d(t,"WebGPUCacheBindGroups",(function(){return i.WebGPUCacheBindGroups})),n.d(t,"WebGPUCacheSampler",(function(){return i.WebGPUCacheSampler})),n.d(t,"WebGPUDrawContext",(function(){return i.WebGPUDrawContext})),n.d(t,"WebGPUTintWASM",(function(){return i.WebGPUTintWASM})),n.d(t,"WebGL2ShaderProcessor",(function(){return i.WebGL2ShaderProcessor})),n.d(t,"AcquireNativeObjectAsync",(function(){return i.AcquireNativeObjectAsync})),n.d(t,"RegisterNativeTypeAsync",(function(){return i.RegisterNativeTypeAsync})),n.d(t,"NativeEngine",(function(){return i.NativeEngine})),n.d(t,"ShaderCodeInliner",(function(){return i.ShaderCodeInliner})),n.d(t,"PerformanceConfigurator",(function(){return i.PerformanceConfigurator})),n.d(t,"EngineFactory",(function(){return i.EngineFactory})),n.d(t,"ShaderStore",(function(){return i.ShaderStore})),n.d(t,"RenderTargetWrapper",(function(){return i.RenderTargetWrapper})),n.d(t,"KeyboardEventTypes",(function(){return i.KeyboardEventTypes})),n.d(t,"KeyboardInfo",(function(){return i.KeyboardInfo})),n.d(t,"KeyboardInfoPre",(function(){return i.KeyboardInfoPre})),n.d(t,"PointerEventTypes",(function(){return i.PointerEventTypes})),n.d(t,"PointerInfoBase",(function(){return i.PointerInfoBase})),n.d(t,"PointerInfoPre",(function(){return i.PointerInfoPre})),n.d(t,"PointerInfo",(function(){return i.PointerInfo})),n.d(t,"ClipboardEventTypes",(function(){return i.ClipboardEventTypes})),n.d(t,"ClipboardInfo",(function(){return i.ClipboardInfo})),n.d(t,"DeviceInputEventType",(function(){return i.DeviceInputEventType})),n.d(t,"EventConstants",(function(){return i.EventConstants})),n.d(t,"DaydreamController",(function(){return i.DaydreamController})),n.d(t,"GearVRController",(function(){return i.GearVRController})),n.d(t,"GenericController",(function(){return i.GenericController})),n.d(t,"OculusTouchController",(function(){return i.OculusTouchController})),n.d(t,"PoseEnabledControllerType",(function(){return i.PoseEnabledControllerType})),n.d(t,"PoseEnabledControllerHelper",(function(){return i.PoseEnabledControllerHelper})),n.d(t,"PoseEnabledController",(function(){return i.PoseEnabledController})),n.d(t,"ViveController",(function(){return i.ViveController})),n.d(t,"WebVRController",(function(){return i.WebVRController})),n.d(t,"WindowsMotionController",(function(){return i.WindowsMotionController})),n.d(t,"XRWindowsMotionController",(function(){return i.XRWindowsMotionController})),n.d(t,"StickValues",(function(){return i.StickValues})),n.d(t,"Gamepad",(function(){return i.Gamepad})),n.d(t,"GenericPad",(function(){return i.GenericPad})),n.d(t,"GamepadManager",(function(){return i.GamepadManager})),n.d(t,"GamepadSystemSceneComponent",(function(){return i.GamepadSystemSceneComponent})),n.d(t,"Xbox360Button",(function(){return i.Xbox360Button})),n.d(t,"Xbox360Dpad",(function(){return i.Xbox360Dpad})),n.d(t,"Xbox360Pad",(function(){return i.Xbox360Pad})),n.d(t,"DualShockButton",(function(){return i.DualShockButton})),n.d(t,"DualShockDpad",(function(){return i.DualShockDpad})),n.d(t,"DualShockPad",(function(){return i.DualShockPad})),n.d(t,"AxisDragGizmo",(function(){return i.AxisDragGizmo})),n.d(t,"AxisScaleGizmo",(function(){return i.AxisScaleGizmo})),n.d(t,"BoundingBoxGizmo",(function(){return i.BoundingBoxGizmo})),n.d(t,"Gizmo",(function(){return i.Gizmo})),n.d(t,"GizmoManager",(function(){return i.GizmoManager})),n.d(t,"PlaneRotationGizmo",(function(){return i.PlaneRotationGizmo})),n.d(t,"PositionGizmo",(function(){return i.PositionGizmo})),n.d(t,"RotationGizmo",(function(){return i.RotationGizmo})),n.d(t,"ScaleGizmo",(function(){return i.ScaleGizmo})),n.d(t,"LightGizmo",(function(){return i.LightGizmo})),n.d(t,"CameraGizmo",(function(){return i.CameraGizmo})),n.d(t,"PlaneDragGizmo",(function(){return i.PlaneDragGizmo})),n.d(t,"EnvironmentHelper",(function(){return i.EnvironmentHelper})),n.d(t,"PhotoDome",(function(){return i.PhotoDome})),n.d(t,"_forceSceneHelpersToBundle",(function(){return i._forceSceneHelpersToBundle})),n.d(t,"VideoDome",(function(){return i.VideoDome})),n.d(t,"EngineInstrumentation",(function(){return i.EngineInstrumentation})),n.d(t,"SceneInstrumentation",(function(){return i.SceneInstrumentation})),n.d(t,"_TimeToken",(function(){return i._TimeToken})),n.d(t,"EffectLayer",(function(){return i.EffectLayer})),n.d(t,"EffectLayerSceneComponent",(function(){return i.EffectLayerSceneComponent})),n.d(t,"GlowLayer",(function(){return i.GlowLayer})),n.d(t,"HighlightLayer",(function(){return i.HighlightLayer})),n.d(t,"Layer",(function(){return i.Layer})),n.d(t,"LayerSceneComponent",(function(){return i.LayerSceneComponent})),n.d(t,"LensFlare",(function(){return i.LensFlare})),n.d(t,"LensFlareSystem",(function(){return i.LensFlareSystem})),n.d(t,"LensFlareSystemSceneComponent",(function(){return i.LensFlareSystemSceneComponent})),n.d(t,"Light",(function(){return i.Light})),n.d(t,"ShadowLight",(function(){return i.ShadowLight})),n.d(t,"ShadowGenerator",(function(){return i.ShadowGenerator})),n.d(t,"CascadedShadowGenerator",(function(){return i.CascadedShadowGenerator})),n.d(t,"ShadowGeneratorSceneComponent",(function(){return i.ShadowGeneratorSceneComponent})),n.d(t,"DirectionalLight",(function(){return i.DirectionalLight})),n.d(t,"HemisphericLight",(function(){return i.HemisphericLight})),n.d(t,"PointLight",(function(){return i.PointLight})),n.d(t,"SpotLight",(function(){return i.SpotLight})),n.d(t,"DefaultLoadingScreen",(function(){return i.DefaultLoadingScreen})),n.d(t,"_BabylonLoaderRegistered",(function(){return i._BabylonLoaderRegistered})),n.d(t,"BabylonFileLoaderConfiguration",(function(){return i.BabylonFileLoaderConfiguration})),n.d(t,"SceneLoaderAnimationGroupLoadingMode",(function(){return i.SceneLoaderAnimationGroupLoadingMode})),n.d(t,"SceneLoader",(function(){return i.SceneLoader})),n.d(t,"SceneLoaderFlags",(function(){return i.SceneLoaderFlags})),n.d(t,"BackgroundMaterial",(function(){return i.BackgroundMaterial})),n.d(t,"ColorCurves",(function(){return i.ColorCurves})),n.d(t,"EffectFallbacks",(function(){return i.EffectFallbacks})),n.d(t,"Effect",(function(){return i.Effect})),n.d(t,"FresnelParameters",(function(){return i.FresnelParameters})),n.d(t,"ImageProcessingConfigurationDefines",(function(){return i.ImageProcessingConfigurationDefines})),n.d(t,"ImageProcessingConfiguration",(function(){return i.ImageProcessingConfiguration})),n.d(t,"Material",(function(){return i.Material})),n.d(t,"MaterialDefines",(function(){return i.MaterialDefines})),n.d(t,"ThinMaterialHelper",(function(){return i.ThinMaterialHelper})),n.d(t,"MaterialHelper",(function(){return i.MaterialHelper})),n.d(t,"MultiMaterial",(function(){return i.MultiMaterial})),n.d(t,"OcclusionMaterial",(function(){return i.OcclusionMaterial})),n.d(t,"MaterialAnisotropicDefines",(function(){return i.MaterialAnisotropicDefines})),n.d(t,"PBRAnisotropicConfiguration",(function(){return i.PBRAnisotropicConfiguration})),n.d(t,"PBRMaterialDefines",(function(){return i.PBRMaterialDefines})),n.d(t,"PBRBaseMaterial",(function(){return i.PBRBaseMaterial})),n.d(t,"PBRBaseSimpleMaterial",(function(){return i.PBRBaseSimpleMaterial})),n.d(t,"MaterialClearCoatDefines",(function(){return i.MaterialClearCoatDefines})),n.d(t,"PBRClearCoatConfiguration",(function(){return i.PBRClearCoatConfiguration})),n.d(t,"PBRMaterial",(function(){return i.PBRMaterial})),n.d(t,"PBRMetallicRoughnessMaterial",(function(){return i.PBRMetallicRoughnessMaterial})),n.d(t,"PBRSpecularGlossinessMaterial",(function(){return i.PBRSpecularGlossinessMaterial})),n.d(t,"MaterialSheenDefines",(function(){return i.MaterialSheenDefines})),n.d(t,"PBRSheenConfiguration",(function(){return i.PBRSheenConfiguration})),n.d(t,"MaterialSubSurfaceDefines",(function(){return i.MaterialSubSurfaceDefines})),n.d(t,"PBRSubSurfaceConfiguration",(function(){return i.PBRSubSurfaceConfiguration})),n.d(t,"PushMaterial",(function(){return i.PushMaterial})),n.d(t,"ShaderLanguage",(function(){return i.ShaderLanguage})),n.d(t,"ShaderMaterial",(function(){return i.ShaderMaterial})),n.d(t,"StandardMaterialDefines",(function(){return i.StandardMaterialDefines})),n.d(t,"StandardMaterial",(function(){return i.StandardMaterial})),n.d(t,"BaseTexture",(function(){return i.BaseTexture})),n.d(t,"ColorGradingTexture",(function(){return i.ColorGradingTexture})),n.d(t,"CubeTexture",(function(){return i.CubeTexture})),n.d(t,"DynamicTexture",(function(){return i.DynamicTexture})),n.d(t,"EquiRectangularCubeTexture",(function(){return i.EquiRectangularCubeTexture})),n.d(t,"ExternalTexture",(function(){return i.ExternalTexture})),n.d(t,"HDRFiltering",(function(){return i.HDRFiltering})),n.d(t,"HDRCubeTexture",(function(){return i.HDRCubeTexture})),n.d(t,"HtmlElementTexture",(function(){return i.HtmlElementTexture})),n.d(t,"InternalTextureSource",(function(){return i.InternalTextureSource})),n.d(t,"InternalTexture",(function(){return i.InternalTexture})),n.d(t,"_DDSTextureLoader",(function(){return i._DDSTextureLoader})),n.d(t,"_ENVTextureLoader",(function(){return i._ENVTextureLoader})),n.d(t,"_KTXTextureLoader",(function(){return i._KTXTextureLoader})),n.d(t,"_TGATextureLoader",(function(){return i._TGATextureLoader})),n.d(t,"_HDRTextureLoader",(function(){return i._HDRTextureLoader})),n.d(t,"_BasisTextureLoader",(function(){return i._BasisTextureLoader})),n.d(t,"MirrorTexture",(function(){return i.MirrorTexture})),n.d(t,"MultiRenderTarget",(function(){return i.MultiRenderTarget})),n.d(t,"TexturePacker",(function(){return i.TexturePacker})),n.d(t,"TexturePackerFrame",(function(){return i.TexturePackerFrame})),n.d(t,"CustomProceduralTexture",(function(){return i.CustomProceduralTexture})),n.d(t,"NoiseProceduralTexture",(function(){return i.NoiseProceduralTexture})),n.d(t,"ProceduralTexture",(function(){return i.ProceduralTexture})),n.d(t,"ProceduralTextureSceneComponent",(function(){return i.ProceduralTextureSceneComponent})),n.d(t,"RawCubeTexture",(function(){return i.RawCubeTexture})),n.d(t,"RawTexture",(function(){return i.RawTexture})),n.d(t,"RawTexture2DArray",(function(){return i.RawTexture2DArray})),n.d(t,"RawTexture3D",(function(){return i.RawTexture3D})),n.d(t,"RefractionTexture",(function(){return i.RefractionTexture})),n.d(t,"RenderTargetTexture",(function(){return i.RenderTargetTexture})),n.d(t,"TextureSampler",(function(){return i.TextureSampler})),n.d(t,"Texture",(function(){return i.Texture})),n.d(t,"ThinTexture",(function(){return i.ThinTexture})),n.d(t,"ThinRenderTargetTexture",(function(){return i.ThinRenderTargetTexture})),n.d(t,"VideoTexture",(function(){return i.VideoTexture})),n.d(t,"UniformBuffer",(function(){return i.UniformBuffer})),n.d(t,"MaterialFlags",(function(){return i.MaterialFlags})),n.d(t,"NodeMaterialBlockTargets",(function(){return i.NodeMaterialBlockTargets})),n.d(t,"NodeMaterialBlockConnectionPointTypes",(function(){return i.NodeMaterialBlockConnectionPointTypes})),n.d(t,"NodeMaterialBlockConnectionPointMode",(function(){return i.NodeMaterialBlockConnectionPointMode})),n.d(t,"NodeMaterialSystemValues",(function(){return i.NodeMaterialSystemValues})),n.d(t,"NodeMaterialModes",(function(){return i.NodeMaterialModes})),n.d(t,"NodeMaterialConnectionPointCompatibilityStates",(function(){return i.NodeMaterialConnectionPointCompatibilityStates})),n.d(t,"NodeMaterialConnectionPointDirection",(function(){return i.NodeMaterialConnectionPointDirection})),n.d(t,"NodeMaterialConnectionPoint",(function(){return i.NodeMaterialConnectionPoint})),n.d(t,"NodeMaterialBlock",(function(){return i.NodeMaterialBlock})),n.d(t,"NodeMaterialDefines",(function(){return i.NodeMaterialDefines})),n.d(t,"NodeMaterial",(function(){return i.NodeMaterial})),n.d(t,"VertexOutputBlock",(function(){return i.VertexOutputBlock})),n.d(t,"BonesBlock",(function(){return i.BonesBlock})),n.d(t,"InstancesBlock",(function(){return i.InstancesBlock})),n.d(t,"MorphTargetsBlock",(function(){return i.MorphTargetsBlock})),n.d(t,"LightInformationBlock",(function(){return i.LightInformationBlock})),n.d(t,"FragmentOutputBlock",(function(){return i.FragmentOutputBlock})),n.d(t,"ImageProcessingBlock",(function(){return i.ImageProcessingBlock})),n.d(t,"PerturbNormalBlock",(function(){return i.PerturbNormalBlock})),n.d(t,"DiscardBlock",(function(){return i.DiscardBlock})),n.d(t,"FrontFacingBlock",(function(){return i.FrontFacingBlock})),n.d(t,"DerivativeBlock",(function(){return i.DerivativeBlock})),n.d(t,"FragCoordBlock",(function(){return i.FragCoordBlock})),n.d(t,"ScreenSizeBlock",(function(){return i.ScreenSizeBlock})),n.d(t,"ScreenSpaceBlock",(function(){return i.ScreenSpaceBlock})),n.d(t,"TwirlBlock",(function(){return i.TwirlBlock})),n.d(t,"FogBlock",(function(){return i.FogBlock})),n.d(t,"LightBlock",(function(){return i.LightBlock})),n.d(t,"TextureBlock",(function(){return i.TextureBlock})),n.d(t,"ReflectionTextureBlock",(function(){return i.ReflectionTextureBlock})),n.d(t,"CurrentScreenBlock",(function(){return i.CurrentScreenBlock})),n.d(t,"SceneDepthBlock",(function(){return i.SceneDepthBlock})),n.d(t,"ImageSourceBlock",(function(){return i.ImageSourceBlock})),n.d(t,"ClipPlanesBlock",(function(){return i.ClipPlanesBlock})),n.d(t,"InputBlock",(function(){return i.InputBlock})),n.d(t,"AnimatedInputBlockTypes",(function(){return i.AnimatedInputBlockTypes})),n.d(t,"MultiplyBlock",(function(){return i.MultiplyBlock})),n.d(t,"AddBlock",(function(){return i.AddBlock})),n.d(t,"ScaleBlock",(function(){return i.ScaleBlock})),n.d(t,"ClampBlock",(function(){return i.ClampBlock})),n.d(t,"CrossBlock",(function(){return i.CrossBlock})),n.d(t,"CustomBlock",(function(){return i.CustomBlock})),n.d(t,"DotBlock",(function(){return i.DotBlock})),n.d(t,"TransformBlock",(function(){return i.TransformBlock})),n.d(t,"RemapBlock",(function(){return i.RemapBlock})),n.d(t,"NormalizeBlock",(function(){return i.NormalizeBlock})),n.d(t,"TrigonometryBlockOperations",(function(){return i.TrigonometryBlockOperations})),n.d(t,"TrigonometryBlock",(function(){return i.TrigonometryBlock})),n.d(t,"ColorMergerBlock",(function(){return i.ColorMergerBlock})),n.d(t,"VectorMergerBlock",(function(){return i.VectorMergerBlock})),n.d(t,"ColorSplitterBlock",(function(){return i.ColorSplitterBlock})),n.d(t,"VectorSplitterBlock",(function(){return i.VectorSplitterBlock})),n.d(t,"LerpBlock",(function(){return i.LerpBlock})),n.d(t,"DivideBlock",(function(){return i.DivideBlock})),n.d(t,"SubtractBlock",(function(){return i.SubtractBlock})),n.d(t,"StepBlock",(function(){return i.StepBlock})),n.d(t,"OneMinusBlock",(function(){return i.OneMinusBlock})),n.d(t,"ViewDirectionBlock",(function(){return i.ViewDirectionBlock})),n.d(t,"FresnelBlock",(function(){return i.FresnelBlock})),n.d(t,"MaxBlock",(function(){return i.MaxBlock})),n.d(t,"MinBlock",(function(){return i.MinBlock})),n.d(t,"DistanceBlock",(function(){return i.DistanceBlock})),n.d(t,"LengthBlock",(function(){return i.LengthBlock})),n.d(t,"NegateBlock",(function(){return i.NegateBlock})),n.d(t,"PowBlock",(function(){return i.PowBlock})),n.d(t,"RandomNumberBlock",(function(){return i.RandomNumberBlock})),n.d(t,"ArcTan2Block",(function(){return i.ArcTan2Block})),n.d(t,"SmoothStepBlock",(function(){return i.SmoothStepBlock})),n.d(t,"ReciprocalBlock",(function(){return i.ReciprocalBlock})),n.d(t,"ReplaceColorBlock",(function(){return i.ReplaceColorBlock})),n.d(t,"PosterizeBlock",(function(){return i.PosterizeBlock})),n.d(t,"WaveBlockKind",(function(){return i.WaveBlockKind})),n.d(t,"WaveBlock",(function(){return i.WaveBlock})),n.d(t,"GradientBlockColorStep",(function(){return i.GradientBlockColorStep})),n.d(t,"GradientBlock",(function(){return i.GradientBlock})),n.d(t,"NLerpBlock",(function(){return i.NLerpBlock})),n.d(t,"WorleyNoise3DBlock",(function(){return i.WorleyNoise3DBlock})),n.d(t,"SimplexPerlin3DBlock",(function(){return i.SimplexPerlin3DBlock})),n.d(t,"NormalBlendBlock",(function(){return i.NormalBlendBlock})),n.d(t,"Rotate2dBlock",(function(){return i.Rotate2dBlock})),n.d(t,"ReflectBlock",(function(){return i.ReflectBlock})),n.d(t,"RefractBlock",(function(){return i.RefractBlock})),n.d(t,"DesaturateBlock",(function(){return i.DesaturateBlock})),n.d(t,"PBRMetallicRoughnessBlock",(function(){return i.PBRMetallicRoughnessBlock})),n.d(t,"SheenBlock",(function(){return i.SheenBlock})),n.d(t,"AnisotropyBlock",(function(){return i.AnisotropyBlock})),n.d(t,"ReflectionBlock",(function(){return i.ReflectionBlock})),n.d(t,"ClearCoatBlock",(function(){return i.ClearCoatBlock})),n.d(t,"RefractionBlock",(function(){return i.RefractionBlock})),n.d(t,"SubSurfaceBlock",(function(){return i.SubSurfaceBlock})),n.d(t,"ParticleTextureBlock",(function(){return i.ParticleTextureBlock})),n.d(t,"ParticleRampGradientBlock",(function(){return i.ParticleRampGradientBlock})),n.d(t,"ParticleBlendMultiplyBlock",(function(){return i.ParticleBlendMultiplyBlock})),n.d(t,"ModBlock",(function(){return i.ModBlock})),n.d(t,"MatrixBuilderBlock",(function(){return i.MatrixBuilderBlock})),n.d(t,"ConditionalBlockConditions",(function(){return i.ConditionalBlockConditions})),n.d(t,"ConditionalBlock",(function(){return i.ConditionalBlock})),n.d(t,"CloudBlock",(function(){return i.CloudBlock})),n.d(t,"VoronoiNoiseBlock",(function(){return i.VoronoiNoiseBlock})),n.d(t,"ElbowBlock",(function(){return i.ElbowBlock})),n.d(t,"NodeMaterialOptimizer",(function(){return i.NodeMaterialOptimizer})),n.d(t,"PropertyTypeForEdition",(function(){return i.PropertyTypeForEdition})),n.d(t,"editableInPropertyPage",(function(){return i.editableInPropertyPage})),n.d(t,"EffectRenderer",(function(){return i.EffectRenderer})),n.d(t,"EffectWrapper",(function(){return i.EffectWrapper})),n.d(t,"ShadowDepthWrapper",(function(){return i.ShadowDepthWrapper})),n.d(t,"DrawWrapper",(function(){return i.DrawWrapper})),n.d(t,"MaterialPluginBase",(function(){return i.MaterialPluginBase})),n.d(t,"MaterialPluginManager",(function(){return i.MaterialPluginManager})),n.d(t,"RegisterMaterialPlugin",(function(){return i.RegisterMaterialPlugin})),n.d(t,"UnregisterMaterialPlugin",(function(){return i.UnregisterMaterialPlugin})),n.d(t,"UnregisterAllMaterialPlugins",(function(){return i.UnregisterAllMaterialPlugins})),n.d(t,"MaterialDetailMapDefines",(function(){return i.MaterialDetailMapDefines})),n.d(t,"DetailMapConfiguration",(function(){return i.DetailMapConfiguration})),n.d(t,"createPBRAnisotropicPlugin",(function(){return i.createPBRAnisotropicPlugin})),n.d(t,"createPBRBRDFPlugin",(function(){return i.createPBRBRDFPlugin})),n.d(t,"createPBRClearCoatPlugin",(function(){return i.createPBRClearCoatPlugin})),n.d(t,"createPBRSheenPlugin",(function(){return i.createPBRSheenPlugin})),n.d(t,"createPBRSubSurfacePlugin",(function(){return i.createPBRSubSurfacePlugin})),n.d(t,"createDetailMapPlugin",(function(){return i.createDetailMapPlugin})),n.d(t,"Scalar",(function(){return i.Scalar})),n.d(t,"extractMinAndMaxIndexed",(function(){return i.extractMinAndMaxIndexed})),n.d(t,"extractMinAndMax",(function(){return i.extractMinAndMax})),n.d(t,"Space",(function(){return i.Space})),n.d(t,"Axis",(function(){return i.Axis})),n.d(t,"Coordinate",(function(){return i.Coordinate})),n.d(t,"Color3",(function(){return i.Color3})),n.d(t,"Color4",(function(){return i.Color4})),n.d(t,"TmpColors",(function(){return i.TmpColors})),n.d(t,"ToGammaSpace",(function(){return i.ToGammaSpace})),n.d(t,"ToLinearSpace",(function(){return i.ToLinearSpace})),n.d(t,"PHI",(function(){return i.PHI})),n.d(t,"Epsilon",(function(){return i.Epsilon})),n.d(t,"Frustum",(function(){return i.Frustum})),n.d(t,"Orientation",(function(){return i.Orientation})),n.d(t,"BezierCurve",(function(){return i.BezierCurve})),n.d(t,"Angle",(function(){return i.Angle})),n.d(t,"Arc2",(function(){return i.Arc2})),n.d(t,"Path2",(function(){return i.Path2})),n.d(t,"Path3D",(function(){return i.Path3D})),n.d(t,"Curve3",(function(){return i.Curve3})),n.d(t,"Plane",(function(){return i.Plane})),n.d(t,"Size",(function(){return i.Size})),n.d(t,"Vector2",(function(){return i.Vector2})),n.d(t,"Vector3",(function(){return i.Vector3})),n.d(t,"Vector4",(function(){return i.Vector4})),n.d(t,"Quaternion",(function(){return i.Quaternion})),n.d(t,"Matrix",(function(){return i.Matrix})),n.d(t,"TmpVectors",(function(){return i.TmpVectors})),n.d(t,"PositionNormalVertex",(function(){return i.PositionNormalVertex})),n.d(t,"PositionNormalTextureVertex",(function(){return i.PositionNormalTextureVertex})),n.d(t,"Viewport",(function(){return i.Viewport})),n.d(t,"SphericalHarmonics",(function(){return i.SphericalHarmonics})),n.d(t,"SphericalPolynomial",(function(){return i.SphericalPolynomial})),n.d(t,"AbstractMesh",(function(){return i.AbstractMesh})),n.d(t,"DracoCompression",(function(){return i.DracoCompression})),n.d(t,"MeshoptCompression",(function(){return i.MeshoptCompression})),n.d(t,"CSG",(function(){return i.CSG})),n.d(t,"Geometry",(function(){return i.Geometry})),n.d(t,"GroundMesh",(function(){return i.GroundMesh})),n.d(t,"GoldbergMesh",(function(){return i.GoldbergMesh})),n.d(t,"TrailMesh",(function(){return i.TrailMesh})),n.d(t,"InstancedMesh",(function(){return i.InstancedMesh})),n.d(t,"LinesMesh",(function(){return i.LinesMesh})),n.d(t,"InstancedLinesMesh",(function(){return i.InstancedLinesMesh})),n.d(t,"_CreationDataStorage",(function(){return i._CreationDataStorage})),n.d(t,"_InstancesBatch",(function(){return i._InstancesBatch})),n.d(t,"Mesh",(function(){return i.Mesh})),n.d(t,"_injectLTSMesh",(function(){return i._injectLTSMesh})),n.d(t,"VertexData",(function(){return i.VertexData})),n.d(t,"MeshBuilder",(function(){return i.MeshBuilder})),n.d(t,"SimplificationSettings",(function(){return i.SimplificationSettings})),n.d(t,"SimplificationQueue",(function(){return i.SimplificationQueue})),n.d(t,"SimplificationType",(function(){return i.SimplificationType})),n.d(t,"QuadraticErrorSimplification",(function(){return i.QuadraticErrorSimplification})),n.d(t,"SimplicationQueueSceneComponent",(function(){return i.SimplicationQueueSceneComponent})),n.d(t,"Polygon",(function(){return i.Polygon})),n.d(t,"PolygonMeshBuilder",(function(){return i.PolygonMeshBuilder})),n.d(t,"_PrimaryIsoTriangle",(function(){return i._PrimaryIsoTriangle})),n.d(t,"PolyhedronData",(function(){return i.PolyhedronData})),n.d(t,"GeodesicData",(function(){return i.GeodesicData})),n.d(t,"SubMesh",(function(){return i.SubMesh})),n.d(t,"MeshLODLevel",(function(){return i.MeshLODLevel})),n.d(t,"TransformNode",(function(){return i.TransformNode})),n.d(t,"CreateBoxVertexData",(function(){return i.CreateBoxVertexData})),n.d(t,"CreateBox",(function(){return i.CreateBox})),n.d(t,"BoxBuilder",(function(){return i.BoxBuilder})),n.d(t,"CreateTiledBoxVertexData",(function(){return i.CreateTiledBoxVertexData})),n.d(t,"CreateTiledBox",(function(){return i.CreateTiledBox})),n.d(t,"TiledBoxBuilder",(function(){return i.TiledBoxBuilder})),n.d(t,"CreateDisc",(function(){return i.CreateDisc})),n.d(t,"DiscBuilder",(function(){return i.DiscBuilder})),n.d(t,"CreateRibbonVertexData",(function(){return i.CreateRibbonVertexData})),n.d(t,"CreateRibbon",(function(){return i.CreateRibbon})),n.d(t,"RibbonBuilder",(function(){return i.RibbonBuilder})),n.d(t,"CreateSphereVertexData",(function(){return i.CreateSphereVertexData})),n.d(t,"CreateSphere",(function(){return i.CreateSphere})),n.d(t,"SphereBuilder",(function(){return i.SphereBuilder})),n.d(t,"CreateHemisphere",(function(){return i.CreateHemisphere})),n.d(t,"HemisphereBuilder",(function(){return i.HemisphereBuilder})),n.d(t,"CreateCylinderVertexData",(function(){return i.CreateCylinderVertexData})),n.d(t,"CreateCylinder",(function(){return i.CreateCylinder})),n.d(t,"CylinderBuilder",(function(){return i.CylinderBuilder})),n.d(t,"CreateTorusVertexData",(function(){return i.CreateTorusVertexData})),n.d(t,"CreateTorus",(function(){return i.CreateTorus})),n.d(t,"TorusBuilder",(function(){return i.TorusBuilder})),n.d(t,"CreateTorusKnotVertexData",(function(){return i.CreateTorusKnotVertexData})),n.d(t,"CreateTorusKnot",(function(){return i.CreateTorusKnot})),n.d(t,"TorusKnotBuilder",(function(){return i.TorusKnotBuilder})),n.d(t,"CreateLineSystemVertexData",(function(){return i.CreateLineSystemVertexData})),n.d(t,"CreateDashedLinesVertexData",(function(){return i.CreateDashedLinesVertexData})),n.d(t,"CreateLineSystem",(function(){return i.CreateLineSystem})),n.d(t,"CreateLines",(function(){return i.CreateLines})),n.d(t,"CreateDashedLines",(function(){return i.CreateDashedLines})),n.d(t,"LinesBuilder",(function(){return i.LinesBuilder})),n.d(t,"CreatePolygonVertexData",(function(){return i.CreatePolygonVertexData})),n.d(t,"CreatePolygon",(function(){return i.CreatePolygon})),n.d(t,"ExtrudePolygon",(function(){return i.ExtrudePolygon})),n.d(t,"PolygonBuilder",(function(){return i.PolygonBuilder})),n.d(t,"ExtrudeShape",(function(){return i.ExtrudeShape})),n.d(t,"ExtrudeShapeCustom",(function(){return i.ExtrudeShapeCustom})),n.d(t,"ShapeBuilder",(function(){return i.ShapeBuilder})),n.d(t,"CreateLathe",(function(){return i.CreateLathe})),n.d(t,"LatheBuilder",(function(){return i.LatheBuilder})),n.d(t,"CreatePlaneVertexData",(function(){return i.CreatePlaneVertexData})),n.d(t,"CreatePlane",(function(){return i.CreatePlane})),n.d(t,"PlaneBuilder",(function(){return i.PlaneBuilder})),n.d(t,"CreateTiledPlaneVertexData",(function(){return i.CreateTiledPlaneVertexData})),n.d(t,"CreateTiledPlane",(function(){return i.CreateTiledPlane})),n.d(t,"TiledPlaneBuilder",(function(){return i.TiledPlaneBuilder})),n.d(t,"CreateGroundVertexData",(function(){return i.CreateGroundVertexData})),n.d(t,"CreateTiledGroundVertexData",(function(){return i.CreateTiledGroundVertexData})),n.d(t,"CreateGroundFromHeightMapVertexData",(function(){return i.CreateGroundFromHeightMapVertexData})),n.d(t,"CreateGround",(function(){return i.CreateGround})),n.d(t,"CreateTiledGround",(function(){return i.CreateTiledGround})),n.d(t,"CreateGroundFromHeightMap",(function(){return i.CreateGroundFromHeightMap})),n.d(t,"GroundBuilder",(function(){return i.GroundBuilder})),n.d(t,"CreateTube",(function(){return i.CreateTube})),n.d(t,"TubeBuilder",(function(){return i.TubeBuilder})),n.d(t,"CreatePolyhedronVertexData",(function(){return i.CreatePolyhedronVertexData})),n.d(t,"CreatePolyhedron",(function(){return i.CreatePolyhedron})),n.d(t,"PolyhedronBuilder",(function(){return i.PolyhedronBuilder})),n.d(t,"CreateIcoSphereVertexData",(function(){return i.CreateIcoSphereVertexData})),n.d(t,"CreateIcoSphere",(function(){return i.CreateIcoSphere})),n.d(t,"IcoSphereBuilder",(function(){return i.IcoSphereBuilder})),n.d(t,"CreateGeodesic",(function(){return i.CreateGeodesic})),n.d(t,"CreateGoldbergVertexData",(function(){return i.CreateGoldbergVertexData})),n.d(t,"CreateGoldberg",(function(){return i.CreateGoldberg})),n.d(t,"CreateDecal",(function(){return i.CreateDecal})),n.d(t,"DecalBuilder",(function(){return i.DecalBuilder})),n.d(t,"CreateCapsuleVertexData",(function(){return i.CreateCapsuleVertexData})),n.d(t,"CreateCapsule",(function(){return i.CreateCapsule})),n.d(t,"CapsuleBuilder",(function(){return i.CapsuleBuilder})),n.d(t,"WebGLDataBuffer",(function(){return i.WebGLDataBuffer})),n.d(t,"WebGPUDataBuffer",(function(){return i.WebGPUDataBuffer})),n.d(t,"MorphTarget",(function(){return i.MorphTarget})),n.d(t,"MorphTargetManager",(function(){return i.MorphTargetManager})),n.d(t,"RecastJSPlugin",(function(){return i.RecastJSPlugin})),n.d(t,"RecastJSCrowd",(function(){return i.RecastJSCrowd})),n.d(t,"Node",(function(){return i.Node})),n.d(t,"Database",(function(){return i.Database})),n.d(t,"BaseParticleSystem",(function(){return i.BaseParticleSystem})),n.d(t,"BoxParticleEmitter",(function(){return i.BoxParticleEmitter})),n.d(t,"ConeParticleEmitter",(function(){return i.ConeParticleEmitter})),n.d(t,"CylinderParticleEmitter",(function(){return i.CylinderParticleEmitter})),n.d(t,"CylinderDirectedParticleEmitter",(function(){return i.CylinderDirectedParticleEmitter})),n.d(t,"HemisphericParticleEmitter",(function(){return i.HemisphericParticleEmitter})),n.d(t,"PointParticleEmitter",(function(){return i.PointParticleEmitter})),n.d(t,"SphereParticleEmitter",(function(){return i.SphereParticleEmitter})),n.d(t,"SphereDirectedParticleEmitter",(function(){return i.SphereDirectedParticleEmitter})),n.d(t,"CustomParticleEmitter",(function(){return i.CustomParticleEmitter})),n.d(t,"MeshParticleEmitter",(function(){return i.MeshParticleEmitter})),n.d(t,"WebGL2ParticleSystem",(function(){return i.WebGL2ParticleSystem})),n.d(t,"ComputeShaderParticleSystem",(function(){return i.ComputeShaderParticleSystem})),n.d(t,"GPUParticleSystem",(function(){return i.GPUParticleSystem})),n.d(t,"Particle",(function(){return i.Particle})),n.d(t,"ParticleHelper",(function(){return i.ParticleHelper})),n.d(t,"ParticleSystem",(function(){return i.ParticleSystem})),n.d(t,"ParticleSystemSet",(function(){return i.ParticleSystemSet})),n.d(t,"SolidParticle",(function(){return i.SolidParticle})),n.d(t,"ModelShape",(function(){return i.ModelShape})),n.d(t,"DepthSortedParticle",(function(){return i.DepthSortedParticle})),n.d(t,"SolidParticleVertex",(function(){return i.SolidParticleVertex})),n.d(t,"SolidParticleSystem",(function(){return i.SolidParticleSystem})),n.d(t,"CloudPoint",(function(){return i.CloudPoint})),n.d(t,"PointsGroup",(function(){return i.PointsGroup})),n.d(t,"PointColor",(function(){return i.PointColor})),n.d(t,"PointsCloudSystem",(function(){return i.PointsCloudSystem})),n.d(t,"SubEmitterType",(function(){return i.SubEmitterType})),n.d(t,"SubEmitter",(function(){return i.SubEmitter})),n.d(t,"PhysicsEngine",(function(){return i.PhysicsEngine})),n.d(t,"PhysicsEngineSceneComponent",(function(){return i.PhysicsEngineSceneComponent})),n.d(t,"PhysicsHelper",(function(){return i.PhysicsHelper})),n.d(t,"PhysicsRadialExplosionEventOptions",(function(){return i.PhysicsRadialExplosionEventOptions})),n.d(t,"PhysicsUpdraftEventOptions",(function(){return i.PhysicsUpdraftEventOptions})),n.d(t,"PhysicsVortexEventOptions",(function(){return i.PhysicsVortexEventOptions})),n.d(t,"PhysicsRadialImpulseFalloff",(function(){return i.PhysicsRadialImpulseFalloff})),n.d(t,"PhysicsUpdraftMode",(function(){return i.PhysicsUpdraftMode})),n.d(t,"PhysicsImpostor",(function(){return i.PhysicsImpostor})),n.d(t,"PhysicsJoint",(function(){return i.PhysicsJoint})),n.d(t,"DistanceJoint",(function(){return i.DistanceJoint})),n.d(t,"MotorEnabledJoint",(function(){return i.MotorEnabledJoint})),n.d(t,"HingeJoint",(function(){return i.HingeJoint})),n.d(t,"Hinge2Joint",(function(){return i.Hinge2Joint})),n.d(t,"CannonJSPlugin",(function(){return i.CannonJSPlugin})),n.d(t,"AmmoJSPlugin",(function(){return i.AmmoJSPlugin})),n.d(t,"OimoJSPlugin",(function(){return i.OimoJSPlugin})),n.d(t,"AnaglyphPostProcess",(function(){return i.AnaglyphPostProcess})),n.d(t,"BlackAndWhitePostProcess",(function(){return i.BlackAndWhitePostProcess})),n.d(t,"BloomEffect",(function(){return i.BloomEffect})),n.d(t,"BloomMergePostProcess",(function(){return i.BloomMergePostProcess})),n.d(t,"BlurPostProcess",(function(){return i.BlurPostProcess})),n.d(t,"ChromaticAberrationPostProcess",(function(){return i.ChromaticAberrationPostProcess})),n.d(t,"CircleOfConfusionPostProcess",(function(){return i.CircleOfConfusionPostProcess})),n.d(t,"ColorCorrectionPostProcess",(function(){return i.ColorCorrectionPostProcess})),n.d(t,"ConvolutionPostProcess",(function(){return i.ConvolutionPostProcess})),n.d(t,"DepthOfFieldBlurPostProcess",(function(){return i.DepthOfFieldBlurPostProcess})),n.d(t,"DepthOfFieldEffectBlurLevel",(function(){return i.DepthOfFieldEffectBlurLevel})),n.d(t,"DepthOfFieldEffect",(function(){return i.DepthOfFieldEffect})),n.d(t,"DepthOfFieldMergePostProcessOptions",(function(){return i.DepthOfFieldMergePostProcessOptions})),n.d(t,"DepthOfFieldMergePostProcess",(function(){return i.DepthOfFieldMergePostProcess})),n.d(t,"DisplayPassPostProcess",(function(){return i.DisplayPassPostProcess})),n.d(t,"ExtractHighlightsPostProcess",(function(){return i.ExtractHighlightsPostProcess})),n.d(t,"FilterPostProcess",(function(){return i.FilterPostProcess})),n.d(t,"FxaaPostProcess",(function(){return i.FxaaPostProcess})),n.d(t,"GrainPostProcess",(function(){return i.GrainPostProcess})),n.d(t,"HighlightsPostProcess",(function(){return i.HighlightsPostProcess})),n.d(t,"ImageProcessingPostProcess",(function(){return i.ImageProcessingPostProcess})),n.d(t,"MotionBlurPostProcess",(function(){return i.MotionBlurPostProcess})),n.d(t,"PassPostProcess",(function(){return i.PassPostProcess})),n.d(t,"PassCubePostProcess",(function(){return i.PassCubePostProcess})),n.d(t,"PostProcess",(function(){return i.PostProcess})),n.d(t,"PostProcessManager",(function(){return i.PostProcessManager})),n.d(t,"RefractionPostProcess",(function(){return i.RefractionPostProcess})),n.d(t,"DefaultRenderingPipeline",(function(){return i.DefaultRenderingPipeline})),n.d(t,"LensRenderingPipeline",(function(){return i.LensRenderingPipeline})),n.d(t,"SSAO2RenderingPipeline",(function(){return i.SSAO2RenderingPipeline})),n.d(t,"SSAORenderingPipeline",(function(){return i.SSAORenderingPipeline})),n.d(t,"StandardRenderingPipeline",(function(){return i.StandardRenderingPipeline})),n.d(t,"PostProcessRenderEffect",(function(){return i.PostProcessRenderEffect})),n.d(t,"PostProcessRenderPipeline",(function(){return i.PostProcessRenderPipeline})),n.d(t,"PostProcessRenderPipelineManager",(function(){return i.PostProcessRenderPipelineManager})),n.d(t,"PostProcessRenderPipelineManagerSceneComponent",(function(){return i.PostProcessRenderPipelineManagerSceneComponent})),n.d(t,"SharpenPostProcess",(function(){return i.SharpenPostProcess})),n.d(t,"StereoscopicInterlacePostProcessI",(function(){return i.StereoscopicInterlacePostProcessI})),n.d(t,"StereoscopicInterlacePostProcess",(function(){return i.StereoscopicInterlacePostProcess})),n.d(t,"TonemappingOperator",(function(){return i.TonemappingOperator})),n.d(t,"TonemapPostProcess",(function(){return i.TonemapPostProcess})),n.d(t,"VolumetricLightScatteringPostProcess",(function(){return i.VolumetricLightScatteringPostProcess})),n.d(t,"VRDistortionCorrectionPostProcess",(function(){return i.VRDistortionCorrectionPostProcess})),n.d(t,"VRMultiviewToSingleviewPostProcess",(function(){return i.VRMultiviewToSingleviewPostProcess})),n.d(t,"ScreenSpaceReflectionPostProcess",(function(){return i.ScreenSpaceReflectionPostProcess})),n.d(t,"ScreenSpaceCurvaturePostProcess",(function(){return i.ScreenSpaceCurvaturePostProcess})),n.d(t,"ReflectionProbe",(function(){return i.ReflectionProbe})),n.d(t,"BoundingBoxRenderer",(function(){return i.BoundingBoxRenderer})),n.d(t,"DepthRenderer",(function(){return i.DepthRenderer})),n.d(t,"DepthRendererSceneComponent",(function(){return i.DepthRendererSceneComponent})),n.d(t,"DepthPeelingRenderer",(function(){return i.DepthPeelingRenderer})),n.d(t,"DepthPeelingSceneComponent",(function(){return i.DepthPeelingSceneComponent})),n.d(t,"EdgesRenderer",(function(){return i.EdgesRenderer})),n.d(t,"LineEdgesRenderer",(function(){return i.LineEdgesRenderer})),n.d(t,"GeometryBufferRenderer",(function(){return i.GeometryBufferRenderer})),n.d(t,"GeometryBufferRendererSceneComponent",(function(){return i.GeometryBufferRendererSceneComponent})),n.d(t,"PrePassRenderer",(function(){return i.PrePassRenderer})),n.d(t,"PrePassRendererSceneComponent",(function(){return i.PrePassRendererSceneComponent})),n.d(t,"SubSurfaceSceneComponent",(function(){return i.SubSurfaceSceneComponent})),n.d(t,"OutlineRenderer",(function(){return i.OutlineRenderer})),n.d(t,"RenderingGroup",(function(){return i.RenderingGroup})),n.d(t,"RenderingGroupInfo",(function(){return i.RenderingGroupInfo})),n.d(t,"RenderingManager",(function(){return i.RenderingManager})),n.d(t,"UtilityLayerRenderer",(function(){return i.UtilityLayerRenderer})),n.d(t,"Scene",(function(){return i.Scene})),n.d(t,"_injectLTSScene",(function(){return i._injectLTSScene})),n.d(t,"SceneComponentConstants",(function(){return i.SceneComponentConstants})),n.d(t,"Stage",(function(){return i.Stage})),n.d(t,"Sprite",(function(){return i.Sprite})),n.d(t,"SpriteManager",(function(){return i.SpriteManager})),n.d(t,"SpriteMap",(function(){return i.SpriteMap})),n.d(t,"SpritePackedManager",(function(){return i.SpritePackedManager})),n.d(t,"SpriteSceneComponent",(function(){return i.SpriteSceneComponent})),n.d(t,"AlphaState",(function(){return i.AlphaState})),n.d(t,"DepthCullingState",(function(){return i.DepthCullingState})),n.d(t,"StencilState",(function(){return i.StencilState})),n.d(t,"StencilStateComposer",(function(){return i.StencilStateComposer})),n.d(t,"AndOrNotEvaluator",(function(){return i.AndOrNotEvaluator})),n.d(t,"AssetTaskState",(function(){return i.AssetTaskState})),n.d(t,"AbstractAssetTask",(function(){return i.AbstractAssetTask})),n.d(t,"AssetsProgressEvent",(function(){return i.AssetsProgressEvent})),n.d(t,"ContainerAssetTask",(function(){return i.ContainerAssetTask})),n.d(t,"MeshAssetTask",(function(){return i.MeshAssetTask})),n.d(t,"TextFileAssetTask",(function(){return i.TextFileAssetTask})),n.d(t,"BinaryFileAssetTask",(function(){return i.BinaryFileAssetTask})),n.d(t,"ImageAssetTask",(function(){return i.ImageAssetTask})),n.d(t,"TextureAssetTask",(function(){return i.TextureAssetTask})),n.d(t,"CubeTextureAssetTask",(function(){return i.CubeTextureAssetTask})),n.d(t,"HDRCubeTextureAssetTask",(function(){return i.HDRCubeTextureAssetTask})),n.d(t,"EquiRectangularCubeTextureAssetTask",(function(){return i.EquiRectangularCubeTextureAssetTask})),n.d(t,"AssetsManager",(function(){return i.AssetsManager})),n.d(t,"BasisTranscodeConfiguration",(function(){return i.BasisTranscodeConfiguration})),n.d(t,"BasisToolsOptions",(function(){return i.BasisToolsOptions})),n.d(t,"GetInternalFormatFromBasisFormat",(function(){return i.GetInternalFormatFromBasisFormat})),n.d(t,"TranscodeAsync",(function(){return i.TranscodeAsync})),n.d(t,"LoadTextureFromTranscodeResult",(function(){return i.LoadTextureFromTranscodeResult})),n.d(t,"BasisTools",(function(){return i.BasisTools})),n.d(t,"DDSTools",(function(){return i.DDSTools})),n.d(t,"expandToProperty",(function(){return i.expandToProperty})),n.d(t,"serialize",(function(){return i.serialize})),n.d(t,"serializeAsTexture",(function(){return i.serializeAsTexture})),n.d(t,"serializeAsColor3",(function(){return i.serializeAsColor3})),n.d(t,"serializeAsFresnelParameters",(function(){return i.serializeAsFresnelParameters})),n.d(t,"serializeAsVector2",(function(){return i.serializeAsVector2})),n.d(t,"serializeAsVector3",(function(){return i.serializeAsVector3})),n.d(t,"serializeAsMeshReference",(function(){return i.serializeAsMeshReference})),n.d(t,"serializeAsColorCurves",(function(){return i.serializeAsColorCurves})),n.d(t,"serializeAsColor4",(function(){return i.serializeAsColor4})),n.d(t,"serializeAsImageProcessingConfiguration",(function(){return i.serializeAsImageProcessingConfiguration})),n.d(t,"serializeAsQuaternion",(function(){return i.serializeAsQuaternion})),n.d(t,"serializeAsMatrix",(function(){return i.serializeAsMatrix})),n.d(t,"serializeAsCameraReference",(function(){return i.serializeAsCameraReference})),n.d(t,"SerializationHelper",(function(){return i.SerializationHelper}));n.d(t,"nativeOverride",(function(){return i.nativeOverride})),n.d(t,"Deferred",(function(){return i.Deferred})),n.d(t,"GetEnvInfo",(function(){return i.GetEnvInfo})),n.d(t,"normalizeEnvInfo",(function(){return i.normalizeEnvInfo})),n.d(t,"CreateEnvTextureAsync",(function(){return i.CreateEnvTextureAsync})),n.d(t,"CreateImageDataArrayBufferViews",(function(){return i.CreateImageDataArrayBufferViews})),n.d(t,"UploadEnvLevelsAsync",(function(){return i.UploadEnvLevelsAsync})),n.d(t,"UploadLevelsAsync",(function(){return i.UploadLevelsAsync})),n.d(t,"UploadEnvSpherical",(function(){return i.UploadEnvSpherical})),n.d(t,"_UpdateRGBDAsync",(function(){return i._UpdateRGBDAsync})),n.d(t,"EnvironmentTextureTools",(function(){return i.EnvironmentTextureTools})),n.d(t,"MeshExploder",(function(){return i.MeshExploder})),n.d(t,"FilesInput",(function(){return i.FilesInput})),n.d(t,"CubeMapToSphericalPolynomialTools",(function(){return i.CubeMapToSphericalPolynomialTools})),n.d(t,"HDRTools",(function(){return i.HDRTools})),n.d(t,"PanoramaToCubeMapTools",(function(){return i.PanoramaToCubeMapTools})),n.d(t,"KhronosTextureContainer",(function(){return i.KhronosTextureContainer})),n.d(t,"EventState",(function(){return i.EventState})),n.d(t,"Observer",(function(){return i.Observer})),n.d(t,"MultiObserver",(function(){return i.MultiObserver})),n.d(t,"Observable",(function(){return i.Observable})),n.d(t,"PerformanceMonitor",(function(){return i.PerformanceMonitor})),n.d(t,"RollingAverage",(function(){return i.RollingAverage})),n.d(t,"PromisePolyfill",(function(){return i.PromisePolyfill})),n.d(t,"SceneOptimization",(function(){return i.SceneOptimization})),n.d(t,"TextureOptimization",(function(){return i.TextureOptimization})),n.d(t,"HardwareScalingOptimization",(function(){return i.HardwareScalingOptimization})),n.d(t,"ShadowsOptimization",(function(){return i.ShadowsOptimization})),n.d(t,"PostProcessesOptimization",(function(){return i.PostProcessesOptimization})),n.d(t,"LensFlaresOptimization",(function(){return i.LensFlaresOptimization})),n.d(t,"CustomOptimization",(function(){return i.CustomOptimization})),n.d(t,"ParticlesOptimization",(function(){return i.ParticlesOptimization})),n.d(t,"RenderTargetsOptimization",(function(){return i.RenderTargetsOptimization})),n.d(t,"MergeMeshesOptimization",(function(){return i.MergeMeshesOptimization})),n.d(t,"SceneOptimizerOptions",(function(){return i.SceneOptimizerOptions})),n.d(t,"SceneOptimizer",(function(){return i.SceneOptimizer})),n.d(t,"SceneSerializer",(function(){return i.SceneSerializer})),n.d(t,"SmartArray",(function(){return i.SmartArray})),n.d(t,"SmartArrayNoDuplicate",(function(){return i.SmartArrayNoDuplicate})),n.d(t,"StringDictionary",(function(){return i.StringDictionary})),n.d(t,"Tags",(function(){return i.Tags})),n.d(t,"CreateResizedCopy",(function(){return i.CreateResizedCopy})),n.d(t,"ApplyPostProcess",(function(){return i.ApplyPostProcess})),n.d(t,"ToHalfFloat",(function(){return i.ToHalfFloat})),n.d(t,"FromHalfFloat",(function(){return i.FromHalfFloat})),n.d(t,"TextureTools",(function(){return i.TextureTools})),n.d(t,"GetTGAHeader",(function(){return i.GetTGAHeader})),n.d(t,"UploadContent",(function(){return i.UploadContent})),n.d(t,"TGATools",(function(){return i.TGATools})),n.d(t,"Tools",(function(){return i.Tools})),n.d(t,"className",(function(){return i.className})),n.d(t,"AsyncLoop",(function(){return i.AsyncLoop})),n.d(t,"VideoRecorder",(function(){return i.VideoRecorder})),n.d(t,"JoystickAxis",(function(){return i.JoystickAxis})),n.d(t,"VirtualJoystick",(function(){return i.VirtualJoystick})),n.d(t,"WorkerPool",(function(){return i.WorkerPool})),n.d(t,"AutoReleaseWorkerPool",(function(){return i.AutoReleaseWorkerPool})),n.d(t,"Logger",(function(){return i.Logger})),n.d(t,"RegisterClass",(function(){return i.RegisterClass})),n.d(t,"GetClass",(function(){return i.GetClass})),n.d(t,"FilesInputStore",(function(){return i.FilesInputStore})),n.d(t,"DeepCopier",(function(){return i.DeepCopier})),n.d(t,"PivotTools",(function(){return i.PivotTools})),n.d(t,"PrecisionDate",(function(){return i.PrecisionDate})),n.d(t,"CreateScreenshot",(function(){return i.CreateScreenshot})),n.d(t,"CreateScreenshotAsync",(function(){return i.CreateScreenshotAsync})),n.d(t,"CreateScreenshotWithResizeAsync",(function(){return i.CreateScreenshotWithResizeAsync})),n.d(t,"CreateScreenshotUsingRenderTarget",(function(){return i.CreateScreenshotUsingRenderTarget})),n.d(t,"CreateScreenshotUsingRenderTargetAsync",(function(){return i.CreateScreenshotUsingRenderTargetAsync})),n.d(t,"ScreenshotTools",(function(){return i.ScreenshotTools})),n.d(t,"WebRequest",(function(){return i.WebRequest})),n.d(t,"InspectableType",(function(){return i.InspectableType})),n.d(t,"GetEnvironmentBRDFTexture",(function(){return i.GetEnvironmentBRDFTexture})),n.d(t,"BRDFTextureTools",(function(){return i.BRDFTextureTools})),n.d(t,"RGBDTextureTools",(function(){return i.RGBDTextureTools})),n.d(t,"ColorGradient",(function(){return i.ColorGradient})),n.d(t,"Color3Gradient",(function(){return i.Color3Gradient})),n.d(t,"FactorGradient",(function(){return i.FactorGradient})),n.d(t,"GradientHelper",(function(){return i.GradientHelper})),n.d(t,"PerfCounter",(function(){return i.PerfCounter})),n.d(t,"RetryStrategy",(function(){return i.RetryStrategy})),n.d(t,"LoadFileError",(function(){return i.LoadFileError})),n.d(t,"RequestFileError",(function(){return i.RequestFileError})),n.d(t,"ReadFileError",(function(){return i.ReadFileError})),n.d(t,"FileToolsOptions",(function(){return i.FileToolsOptions})),n.d(t,"SetCorsBehavior",(function(){return i.SetCorsBehavior})),n.d(t,"LoadImage",(function(){return i.LoadImage})),n.d(t,"ReadFile",(function(){return i.ReadFile})),n.d(t,"LoadFile",(function(){return i.LoadFile})),n.d(t,"RequestFile",(function(){return i.RequestFile})),n.d(t,"IsFileURL",(function(){return i.IsFileURL})),n.d(t,"IsBase64DataUrl",(function(){return i.IsBase64DataUrl})),n.d(t,"DecodeBase64UrlToBinary",(function(){return i.DecodeBase64UrlToBinary})),n.d(t,"DecodeBase64UrlToString",(function(){return i.DecodeBase64UrlToString})),n.d(t,"FileTools",(function(){return i.FileTools})),n.d(t,"_injectLTSFileTools",(function(){return i._injectLTSFileTools})),n.d(t,"EndsWith",(function(){return i.EndsWith})),n.d(t,"StartsWith",(function(){return i.StartsWith})),n.d(t,"Decode",(function(){return i.Decode})),n.d(t,"EncodeArrayBufferToBase64",(function(){return i.EncodeArrayBufferToBase64})),n.d(t,"DecodeBase64ToString",(function(){return i.DecodeBase64ToString})),n.d(t,"DecodeBase64ToBinary",(function(){return i.DecodeBase64ToBinary})),n.d(t,"PadNumber",(function(){return i.PadNumber})),n.d(t,"StringTools",(function(){return i.StringTools})),n.d(t,"DataReader",(function(){return i.DataReader})),n.d(t,"MinMaxReducer",(function(){return i.MinMaxReducer})),n.d(t,"DepthReducer",(function(){return i.DepthReducer})),n.d(t,"DataStorage",(function(){return i.DataStorage})),n.d(t,"SceneRecorder",(function(){return i.SceneRecorder})),n.d(t,"KhronosTextureContainer2",(function(){return i.KhronosTextureContainer2})),n.d(t,"Trajectory",(function(){return i.Trajectory})),n.d(t,"TrajectoryClassifier",(function(){return i.TrajectoryClassifier})),n.d(t,"TimerState",(function(){return i.TimerState})),n.d(t,"setAndStartTimer",(function(){return i.setAndStartTimer})),n.d(t,"AdvancedTimer",(function(){return i.AdvancedTimer})),n.d(t,"GenerateBase64StringFromPixelData",(function(){return i.GenerateBase64StringFromPixelData})),n.d(t,"GenerateBase64StringFromTexture",(function(){return i.GenerateBase64StringFromTexture})),n.d(t,"GenerateBase64StringFromTextureAsync",(function(){return i.GenerateBase64StringFromTextureAsync})),n.d(t,"CopyTools",(function(){return i.CopyTools})),n.d(t,"Reflector",(function(){return i.Reflector})),n.d(t,"IsWindowObjectExist",(function(){return i.IsWindowObjectExist})),n.d(t,"IsNavigatorAvailable",(function(){return i.IsNavigatorAvailable})),n.d(t,"IsDocumentAvailable",(function(){return i.IsDocumentAvailable})),n.d(t,"GetDOMTextContent",(function(){return i.GetDOMTextContent})),n.d(t,"DomManagement",(function(){return i.DomManagement})),n.d(t,"ComputePressureObserverWrapper",(function(){return i.ComputePressureObserverWrapper})),n.d(t,"PerformanceViewerCollector",(function(){return i.PerformanceViewerCollector})),n.d(t,"PerfCollectionStrategy",(function(){return i.PerfCollectionStrategy})),n.d(t,"DynamicFloat32Array",(function(){return i.DynamicFloat32Array})),n.d(t,"inlineScheduler",(function(){return i.inlineScheduler})),n.d(t,"createYieldingScheduler",(function(){return i.createYieldingScheduler})),n.d(t,"runCoroutine",(function(){return i.runCoroutine})),n.d(t,"runCoroutineSync",(function(){return i.runCoroutineSync})),n.d(t,"runCoroutineAsync",(function(){return i.runCoroutineAsync})),n.d(t,"makeSyncFunction",(function(){return i.makeSyncFunction})),n.d(t,"makeAsyncFunction",(function(){return i.makeAsyncFunction})),n.d(t,"RandomGUID",(function(){return i.RandomGUID})),n.d(t,"GUID",(function(){return i.GUID})),n.d(t,"BaseError",(function(){return i.BaseError})),n.d(t,"ErrorCodes",(function(){return i.ErrorCodes})),n.d(t,"RuntimeError",(function(){return i.RuntimeError})),n.d(t,"WebXRCamera",(function(){return i.WebXRCamera})),n.d(t,"WebXREnterExitUIButton",(function(){return i.WebXREnterExitUIButton})),n.d(t,"WebXREnterExitUIOptions",(function(){return i.WebXREnterExitUIOptions})),n.d(t,"WebXREnterExitUI",(function(){return i.WebXREnterExitUI})),n.d(t,"WebXRExperienceHelper",(function(){return i.WebXRExperienceHelper})),n.d(t,"WebXRInput",(function(){return i.WebXRInput})),n.d(t,"WebXRInputSource",(function(){return i.WebXRInputSource})),n.d(t,"WebXRManagedOutputCanvasOptions",(function(){return i.WebXRManagedOutputCanvasOptions})),n.d(t,"WebXRManagedOutputCanvas",(function(){return i.WebXRManagedOutputCanvas})),n.d(t,"WebXRState",(function(){return i.WebXRState})),n.d(t,"WebXRTrackingState",(function(){return i.WebXRTrackingState})),n.d(t,"WebXRSessionManager",(function(){return i.WebXRSessionManager})),n.d(t,"WebXRDefaultExperienceOptions",(function(){return i.WebXRDefaultExperienceOptions})),n.d(t,"WebXRDefaultExperience",(function(){return i.WebXRDefaultExperience})),n.d(t,"WebXRFeatureName",(function(){return i.WebXRFeatureName})),n.d(t,"WebXRFeaturesManager",(function(){return i.WebXRFeaturesManager})),n.d(t,"WebXRAbstractFeature",(function(){return i.WebXRAbstractFeature})),n.d(t,"WebXRHitTestLegacy",(function(){return i.WebXRHitTestLegacy})),n.d(t,"WebXRAnchorSystem",(function(){return i.WebXRAnchorSystem})),n.d(t,"WebXRPlaneDetector",(function(){return i.WebXRPlaneDetector})),n.d(t,"WebXRBackgroundRemover",(function(){return i.WebXRBackgroundRemover})),n.d(t,"WebXRMotionControllerTeleportation",(function(){return i.WebXRMotionControllerTeleportation})),n.d(t,"WebXRControllerPointerSelection",(function(){return i.WebXRControllerPointerSelection})),n.d(t,"IWebXRControllerPhysicsOptions",(function(){return i.IWebXRControllerPhysicsOptions})),n.d(t,"WebXRControllerPhysics",(function(){return i.WebXRControllerPhysics})),n.d(t,"WebXRHitTest",(function(){return i.WebXRHitTest})),n.d(t,"WebXRFeaturePointSystem",(function(){return i.WebXRFeaturePointSystem})),n.d(t,"WebXRHand",(function(){return i.WebXRHand})),n.d(t,"WebXRHandTracking",(function(){return i.WebXRHandTracking})),n.d(t,"WebXRMeshDetector",(function(){return i.WebXRMeshDetector})),n.d(t,"WebXRImageTracking",(function(){return i.WebXRImageTracking})),n.d(t,"WebXRNearControllerMode",(function(){return i.WebXRNearControllerMode})),n.d(t,"WebXRNearInteraction",(function(){return i.WebXRNearInteraction})),n.d(t,"WebXRDomOverlay",(function(){return i.WebXRDomOverlay})),n.d(t,"WebXRControllerMovement",(function(){return i.WebXRControllerMovement})),n.d(t,"WebXRLightEstimation",(function(){return i.WebXRLightEstimation})),n.d(t,"WebXREyeTracking",(function(){return i.WebXREyeTracking})),n.d(t,"WebXRWalkingLocomotion",(function(){return i.WebXRWalkingLocomotion})),n.d(t,"WebXRCompositionLayerWrapper",(function(){return i.WebXRCompositionLayerWrapper})),n.d(t,"WebXRProjectionLayerWrapper",(function(){return i.WebXRProjectionLayerWrapper})),n.d(t,"WebXRLayers",(function(){return i.WebXRLayers})),n.d(t,"WebXRAbstractMotionController",(function(){return i.WebXRAbstractMotionController})),n.d(t,"WebXRControllerComponent",(function(){return i.WebXRControllerComponent})),n.d(t,"WebXRGenericHandController",(function(){return i.WebXRGenericHandController})),n.d(t,"WebXRGenericTriggerMotionController",(function(){return i.WebXRGenericTriggerMotionController})),n.d(t,"WebXRMicrosoftMixedRealityController",(function(){return i.WebXRMicrosoftMixedRealityController})),n.d(t,"WebXRMotionControllerManager",(function(){return i.WebXRMotionControllerManager})),n.d(t,"WebXROculusTouchMotionController",(function(){return i.WebXROculusTouchMotionController})),n.d(t,"WebXRHTCViveMotionController",(function(){return i.WebXRHTCViveMotionController})),n.d(t,"WebXRProfiledMotionController",(function(){return i.WebXRProfiledMotionController})),n.d(t,"NativeXRLayerWrapper",(function(){return i.NativeXRLayerWrapper})),n.d(t,"NativeXRLayerRenderTargetTextureProvider",(function(){return i.NativeXRLayerRenderTargetTextureProvider})),n.d(t,"NativeXRRenderTarget",(function(){return i.NativeXRRenderTarget})),n.d(t,"NativeXRFrame",(function(){return i.NativeXRFrame})),n.d(t,"CompatibilityOptions",(function(){return i.CompatibilityOptions}));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 i)a[c]=i[c]}var u={AxesViewer:r.AxesViewer,BoneAxesViewer:r.BoneAxesViewer,PhysicsViewer:r.PhysicsViewer,SkeletonViewer:r.SkeletonViewer}}.call(this,n(192))}])})); \ No newline at end of file