/*! For license information please see app.f405a720dad48c67b649.js.LICENSE */ !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}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=253)}([function(e,t,n){"use strict";n.d(t,"u",(function(){return a})),n.d(t,"v",(function(){return s})),n.d(t,"h",(function(){return c})),n.d(t,"e",(function(){return l})),n.d(t,"f",(function(){return u})),n.d(t,"w",(function(){return h})),n.d(t,"x",(function(){return d})),n.d(t,"y",(function(){return f})),n.d(t,"r",(function(){return p})),n.d(t,"q",(function(){return m})),n.d(t,"j",(function(){return g})),n.d(t,"n",(function(){return _})),n.d(t,"z",(function(){return v})),n.d(t,"i",(function(){return b})),n.d(t,"s",(function(){return i})),n.d(t,"c",(function(){return x})),n.d(t,"d",(function(){return C})),n.d(t,"k",(function(){return y})),n.d(t,"a",(function(){return E})),n.d(t,"b",(function(){return T})),n.d(t,"l",(function(){return S})),n.d(t,"m",(function(){return A})),n.d(t,"g",(function(){return P})),n.d(t,"p",(function(){return M})),n.d(t,"o",(function(){return O})),n.d(t,"t",(function(){return R}));var i,r=n(49),o=n(13),a=1/2.2,s=2.2,c=.001,l=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=this.r||0;return e=397*(e=397*e^(this.g||0))^(this.b||0)},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,this},e.prototype.toColor4=function(e){return void 0===e&&(e=1),new u(this.r,this.g,this.b,e)},e.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},e.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,this},e.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},e.prototype.equalsFloats=function(e,t,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=o.a.Clamp(this.r,e,t),n.g=o.a.Clamp(this.g,e,t),n.b=o.a.Clamp(this.b,e,t),this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b)},e.prototype.addToRef=function(e,t){return t.r=this.r+e.r,t.g=this.g+e.g,t.b=this.b+e.b,this},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b)},e.prototype.subtractToRef=function(e,t){return t.r=this.r-e.r,t.g=this.g-e.g,t.b=this.b-e.b,this},e.prototype.clone=function(){return new e(this.r,this.g,this.b)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},e.prototype.copyFromFloats=function(e,t,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=255*this.r|0,t=255*this.g|0,n=255*this.b|0;return"#"+o.a.ToHex(e)+o.a.ToHex(t)+o.a.ToHex(n)},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,s),e.g=Math.pow(this.g,s),e.b=Math.pow(this.b,s),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,a),e.g=Math.pow(this.g,a),e.b=Math.pow(this.b,a),this},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.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.Red=function(){return new e(1,0,0)},e.Green=function(){return new e(0,1,0)},e.Blue=function(){return new e(0,0,1)},e.Black=function(){return new e(0,0,0)},Object.defineProperty(e,"BlackReadOnly",{get:function(){return e._BlackReadOnly},enumerable:!0,configurable:!0}),e.White=function(){return new e(1,1,1)},e.Purple=function(){return new e(.5,0,.5)},e.Magenta=function(){return new e(1,0,1)},e.Yellow=function(){return new e(1,1,0)},e.Gray=function(){return new e(.5,.5,.5)},e.Teal=function(){return new e(0,1,1)},e.Random=function(){return new e(Math.random(),Math.random(),Math.random())},e._BlackReadOnly=e.Black(),e}(),u=function(){function e(e,t,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.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=o.a.Clamp(this.r,e,t),n.g=o.a.Clamp(this.g,e,t),n.b=o.a.Clamp(this.b,e,t),n.a=o.a.Clamp(this.a,e,t),this},e.prototype.multiply=function(t){return new e(this.r*t.r,this.g*t.g,this.b*t.b,this.a*t.a)},e.prototype.multiplyToRef=function(e,t){return t.r=this.r*e.r,t.g=this.g*e.g,t.b=this.b*e.b,t.a=this.a*e.a,t},e.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},e.prototype.getClassName=function(){return"Color4"},e.prototype.getHashCode=function(){var e=this.r||0;return e=397*(e=397*(e=397*e^(this.g||0))^(this.b||0))^(this.a||0)},e.prototype.clone=function(){return new e(this.r,this.g,this.b,this.a)},e.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},e.prototype.copyFromFloats=function(e,t,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(){var e=255*this.r|0,t=255*this.g|0,n=255*this.b|0,i=255*this.a|0;return"#"+o.a.ToHex(e)+o.a.ToHex(t)+o.a.ToHex(n)+o.a.ToHex(i)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,s),e.g=Math.pow(this.g,s),e.b=Math.pow(this.b,s),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,a),e.g=Math.pow(this.g,a),e.b=Math.pow(this.b,a),e.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var n=parseInt(t.substring(1,3),16),i=parseInt(t.substring(3,5),16),r=parseInt(t.substring(5,7),16),o=parseInt(t.substring(7,9),16);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.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.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;ii.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(e,t){var n=e.add(t);return n.scaleInPlace(.5),n},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}(),d=function(){function e(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=0),this.x=e,this.y=t,this.z=n}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},e.prototype.getClassName=function(){return"Vector3"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*(e=397*e^(this.y||0))^(this.z||0)},e.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},e.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,this},e.prototype.toQuaternion=function(){return m.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.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t)},e.prototype.scaleToRef=function(e,t){return t.copyFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.scaleAndAddToRef=function(e,t){return t.addInPlaceFromFloats(this.x*e,this.y*e,this.z*e)},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},e.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=c),e&&o.a.WithinEpsilon(this.x,e.x,t)&&o.a.WithinEpsilon(this.y,e.y,t)&&o.a.WithinEpsilon(this.z,e.z,t)},e.prototype.equalsToFloats=function(e,t,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(!o.a.WithinEpsilon(t,n,e))return!0;var i=Math.abs(this.z);return!o.a.WithinEpsilon(t,i,e)||!o.a.WithinEpsilon(n,i,e)},Object.defineProperty(e.prototype,"isNonUniform",{get:function(){var e=Math.abs(this.x),t=Math.abs(this.y);if(e!==t)return!0;var n=Math.abs(this.z);return e!==n||t!==n},enumerable:!0,configurable:!0}),e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},e.prototype.normalize=function(){return this.normalizeFromLength(this.length())},e.prototype.reorderInPlace=function(e){var t=this;return"xyz"===(e=e.toLowerCase())?this:(w.Vector3[0].copyFrom(this),["x","y","z"].forEach((function(n,i){t[n]=w.Vector3[0][e[i]]})),this)},e.prototype.rotateByQuaternionToRef=function(t,n){return t.toRotationMatrix(w.Matrix[0]),e.TransformCoordinatesToRef(this,w.Matrix[0],n),n},e.prototype.rotateByQuaternionAroundPointToRef=function(e,t,n){return this.subtractToRef(t,w.Vector3[0]),w.Vector3[0].rotateByQuaternionToRef(e,w.Vector3[0]),t.addToRef(w.Vector3[0],n),n},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(w.Vector3[1]),o=n.normalizeToRef(w.Vector3[2]),a=e.Dot(r,o),s=w.Vector3[3];return e.CrossToRef(r,o,s),e.Dot(s,i)>0?Math.acos(a):-Math.acos(a)},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:!0,configurable:!0}),e.Down=function(){return new e(0,-1,0)},e.Forward=function(){return new e(0,0,1)},e.Backward=function(){return new e(0,0,-1)},e.Right=function(){return new e(1,0,0)},e.Left=function(){return new e(-1,0,0)},e.TransformCoordinates=function(t,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],l=1/(e*o[3]+t*o[7]+n*o[11]+o[15]);r.x=a*l,r.y=s*l,r.z=c*l},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)this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},e.prototype.floor=function(){return new e(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},e.prototype.fract=function(){return new e(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},e.prototype.normalize=function(){var e=this.length();return 0===e?this:this.scaleInPlace(1/e)},e.prototype.toVector3=function(){return new d(this.x,this.y,this.z)},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,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(e,t){var n=e.add(t);return n.scaleInPlace(.5),n},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){this.width=e,this.height=t}return e.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},e.prototype.getClassName=function(){return"Size"},e.prototype.getHashCode=function(){var e=this.width||0;return e=397*e^(this.height||0)},e.prototype.copyFrom=function(e){this.width=e.width,this.height=e.height},e.prototype.copyFromFloats=function(e,t){return this.width=e,this.height=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.multiplyByFloats=function(t,n){return new e(this.width*t,this.height*n)},e.prototype.clone=function(){return new e(this.width,this.height)},e.prototype.equals=function(e){return!!e&&(this.width===e.width&&this.height===e.height)},Object.defineProperty(e.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),e.Zero=function(){return new e(0,0)},e.prototype.add=function(t){return new e(this.width+t.width,this.height+t.height)},e.prototype.subtract=function(t){return new e(this.width-t.width,this.height-t.height)},e.Lerp=function(t,n,i){return new e(t.width+(n.width-t.width)*i,t.height+(n.height-t.height)*i)},e}(),m=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.x=e,this.y=t,this.z=n,this.w=i}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*(e=397*(e=397*e^(this.y||0))^(this.z||0))^(this.w||0)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,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(e){void 0===e&&(e="YZX");var t=d.Zero();return this.toEulerAnglesToRef(t),t},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,l=i*t-n*r;return l<-.4999999?(e.y=2*Math.atan2(i,r),e.x=Math.PI/2,e.z=0):l>.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 g.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],l=i[9],u=i[2],h=i[6],d=i[10],f=r+c+d;f>0?(n=.5/Math.sqrt(f+1),t.w=.25/n,t.x=(h-l)*n,t.y=(a-u)*n,t.z=(s-o)*n):r>c&&r>d?(n=2*Math.sqrt(1+r-c-d),t.w=(h-l)/n,t.x=.25*n,t.y=(o+s)/n,t.z=(a+u)/n):c>d?(n=2*Math.sqrt(1+c-r-d),t.w=(a-u)/n,t.x=(o+s)/n,t.y=.25*n,t.z=(l+h)/n):(n=2*Math.sqrt(1+d-r-c),t.w=(s-o)/n,t.x=(a+u)/n,t.y=(l+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.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.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.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),l=Math.sin(o),u=Math.cos(o),h=Math.sin(a),d=Math.cos(a);i.x=d*l*c+h*u*s,i.y=h*u*c-d*l*s,i.z=d*u*s-h*l*c,i.w=d*u*c+h*l*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=w.Matrix[0];g.FromXYZAxesToRef(t.normalize(),n.normalize(),i.normalize(),o),e.FromRotationMatrixToRef(o,r)},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),l=1/Math.sin(c);o=Math.sin((1-n)*c)*l,r=s?-Math.sin(n*c)*l:Math.sin(n*c)*l}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,l=-2*s+3*a,u=s-2*a+o,h=s-a;return new e(t.x*c+i.x*l+n.x*u+r.x*h,t.y*c+i.y*l+n.y*u+r.y*h,t.z*c+i.z*l+n.z*u+r.z*h,t.w*c+i.w*l+n.w*u+r.w*h)},e}(),g=function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this._isIdentity3x2=!0,this._isIdentity3x2Dirty=!0,this.updateFlag=-1,this._m=new Float32Array(16),this._updateIdentityStatus(!1)}return Object.defineProperty(e.prototype,"m",{get:function(){return this._m},enumerable:!0,configurable:!0}),e.prototype._markAsUpdated=function(){this.updateFlag=e._updateFlagSeed++,this._isIdentity=!1,this._isIdentity3x2=!1,this._isIdentityDirty=!0,this._isIdentity3x2Dirty=!0},e.prototype._updateIdentityStatus=function(t,n,i,r){void 0===n&&(n=!1),void 0===i&&(i=!1),void 0===r&&(r=!0),this.updateFlag=e._updateFlagSeed++,this._isIdentity=t,this._isIdentity3x2=t||i,this._isIdentityDirty=!this._isIdentity&&n,this._isIdentity3x2Dirty=!this._isIdentity3x2&&r},e.prototype.isIdentity=function(){if(this._isIdentityDirty){this._isIdentityDirty=!1;var e=this._m;this._isIdentity=1===e[0]&&0===e[1]&&0===e[2]&&0===e[3]&&0===e[4]&&1===e[5]&&0===e[6]&&0===e[7]&&0===e[8]&&0===e[9]&&1===e[10]&&0===e[11]&&0===e[12]&&0===e[13]&&0===e[14]&&1===e[15]}return this._isIdentity},e.prototype.isIdentityAs3x2=function(){return this._isIdentity3x2Dirty&&(this._isIdentity3x2Dirty=!1,1!==this._m[0]||1!==this._m[5]||1!==this._m[15]?this._isIdentity3x2=!1:0!==this._m[1]||0!==this._m[2]||0!==this._m[3]||0!==this._m[4]||0!==this._m[6]||0!==this._m[7]||0!==this._m[8]||0!==this._m[9]||0!==this._m[10]||0!==this._m[11]||0!==this._m[12]||0!==this._m[13]||0!==this._m[14]?this._isIdentity3x2=!1:this._isIdentity3x2=!0),this._isIdentity3x2},e.prototype.determinant=function(){if(!0===this._isIdentity)return 1;var e=this._m,t=e[0],n=e[1],i=e[2],r=e[3],o=e[4],a=e[5],s=e[6],c=e[7],l=e[8],u=e[9],h=e[10],d=e[11],f=e[12],p=e[13],m=e[14],g=e[15],_=h*g-m*d,v=u*g-p*d,b=u*m-p*h,y=l*g-f*d,x=l*m-h*f,C=l*p-f*u;return t*+(a*_-s*v+c*b)+n*-(o*_-s*y+c*x)+i*+(o*v-a*y+c*C)+r*-(o*b-a*x+s*C)},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],l=n[6],u=n[7],h=n[8],d=n[9],f=n[10],p=n[11],m=n[12],g=n[13],_=n[14],v=n[15],b=f*v-_*p,y=d*v-g*p,x=d*_-g*f,C=h*v-m*p,E=h*_-f*m,T=h*g-m*d,S=+(c*b-l*y+u*x),A=-(s*b-l*C+u*E),P=+(s*y-c*C+u*T),M=-(s*x-c*E+l*T),O=i*S+r*A+o*P+a*M;if(0===O)return t.copyFrom(this),this;var R=1/O,w=l*v-_*u,I=c*v-g*u,L=c*_-g*l,D=s*v-m*u,N=s*_-m*l,F=s*g-m*c,k=l*p-f*u,B=c*p-d*u,z=c*f-d*l,V=s*p-h*u,U=s*f-h*l,G=s*d-h*c,H=-(r*b-o*y+a*x),j=+(i*b-o*C+a*E),W=-(i*y-r*C+a*T),X=+(i*x-r*E+o*T),Y=+(r*w-o*I+a*L),K=-(i*w-o*D+a*N),Q=+(i*I-r*D+a*F),q=-(i*L-r*N+o*F),Z=-(r*k-o*B+a*z),J=+(i*k-o*V+a*U),$=-(i*B-r*V+a*G),ee=+(i*z-r*U+o*G);return e.FromValuesToRef(S*R,H*R,Y*R,Z*R,A*R,j*R,K*R,J*R,P*R,W*R,Q*R,$*R,M*R,X*R,q*R,ee*R,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 d(this._m[12],this._m[13],this._m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this._m[12],e.y=this._m[13],e.z=this._m[14],this},e.prototype.removeRotationAndScaling=function(){var t=this.m;return e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t[12],t[13],t[14],t[15],this),this._updateIdentityStatus(0===t[12]&&0===t[13]&&0===t[14]&&1===t[15]),this},e.prototype.multiply=function(t){var n=new e;return this.multiplyToRef(t,n),n},e.prototype.copyFrom=function(e){e.copyToArray(this._m);var t=e;return this._updateIdentityStatus(t._isIdentity,t._isIdentityDirty,t._isIdentity3x2,t._isIdentity3x2Dirty),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var n=0;n<16;n++)e[t+n]=this._m[n];return this},e.prototype.multiplyToRef=function(e,t){return this._isIdentity?(t.copyFrom(e),this):e._isIdentity?(t.copyFrom(this),this):(this.multiplyToArray(e,t._m,0),t._markAsUpdated(),this)},e.prototype.multiplyToArray=function(e,t,n){var i=this._m,r=e.m,o=i[0],a=i[1],s=i[2],c=i[3],l=i[4],u=i[5],h=i[6],d=i[7],f=i[8],p=i[9],m=i[10],g=i[11],_=i[12],v=i[13],b=i[14],y=i[15],x=r[0],C=r[1],E=r[2],T=r[3],S=r[4],A=r[5],P=r[6],M=r[7],O=r[8],R=r[9],w=r[10],I=r[11],L=r[12],D=r[13],N=r[14],F=r[15];return t[n]=o*x+a*S+s*O+c*L,t[n+1]=o*C+a*A+s*R+c*D,t[n+2]=o*E+a*P+s*w+c*N,t[n+3]=o*T+a*M+s*I+c*F,t[n+4]=l*x+u*S+h*O+d*L,t[n+5]=l*C+u*A+h*R+d*D,t[n+6]=l*E+u*P+h*w+d*N,t[n+7]=l*T+u*M+h*I+d*F,t[n+8]=f*x+p*S+m*O+g*L,t[n+9]=f*C+p*A+m*R+g*D,t[n+10]=f*E+p*P+m*w+g*N,t[n+11]=f*T+p*M+m*I+g*F,t[n+12]=_*x+v*S+b*O+y*L,t[n+13]=_*C+v*A+b*R+y*D,t[n+14]=_*E+v*P+b*w+y*N,t[n+15]=_*T+v*M+b*I+y*F,this},e.prototype.equals=function(e){var t=e;if(!t)return!1;if((this._isIdentity||t._isIdentity)&&!this._isIdentityDirty&&!t._isIdentityDirty)return this._isIdentity&&t._isIdentity;var 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=this._m[0]||0,t=1;t<16;t++)e=397*e^(this._m[t]||0);return e},e.prototype.decompose=function(t,n,i){if(this._isIdentity)return i&&i.setAll(0),t&&t.setAll(1),n&&n.copyFromFloats(0,0,0,1),!0;var r=this._m;if(i&&i.copyFromFloats(r[12],r[13],r[14]),(t=t||w.Vector3[0]).x=Math.sqrt(r[0]*r[0]+r[1]*r[1]+r[2]*r[2]),t.y=Math.sqrt(r[4]*r[4]+r[5]*r[5]+r[6]*r[6]),t.z=Math.sqrt(r[8]*r[8]+r[9]*r[9]+r[10]*r[10]),this.determinant()<=0&&(t.y*=-1),0===t.x||0===t.y||0===t.z)return n&&n.copyFromFloats(0,0,0,1),!1;if(n){var o=1/t.x,a=1/t.y,s=1/t.z;e.FromValuesToRef(r[0]*o,r[1]*o,r[2]*o,0,r[4]*a,r[5]*a,r[6]*a,0,r[8]*s,r[9]*s,r[10]*s,0,0,0,0,1,w.Matrix[0]),m.FromRotationMatrixToRef(w.Matrix[0],n)}return!0},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new f(this._m[t+0],this._m[t+1],this._m[t+2],this._m[t+3])},e.prototype.setRow=function(e,t){return this.setRowFromFloats(e,t.x,t.y,t.z,t.w)},e.prototype.transpose=function(){return e.Transpose(this)},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),this},e.prototype.setRowFromFloats=function(e,t,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=w.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=w.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:!0,configurable:!0}),e.FromValuesToRef=function(e,t,n,i,r,o,a,s,c,l,u,h,d,f,p,m,g){var _=g._m;_[0]=e,_[1]=t,_[2]=n,_[3]=i,_[4]=r,_[5]=o,_[6]=a,_[7]=s,_[8]=c,_[9]=l,_[10]=u,_[11]=h,_[12]=d,_[13]=f,_[14]=p,_[15]=m,g._markAsUpdated()},e.FromValues=function(t,n,i,r,o,a,s,c,l,u,h,d,f,p,m,g){var _=new e,v=_._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]=l,v[9]=u,v[10]=h,v[11]=d,v[12]=f,v[13]=p,v[14]=m,v[15]=g,_._markAsUpdated(),_},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,l=o+o,u=a+a,h=s+s,d=o*l,f=o*u,p=o*h,m=a*u,g=a*h,_=s*h,v=c*l,b=c*u,y=c*h,x=e.x,C=e.y,E=e.z;r[0]=(1-(m+_))*x,r[1]=(f+y)*x,r[2]=(p-b)*x,r[3]=0,r[4]=(f-y)*C,r[5]=(1-(d+_))*C,r[6]=(g+v)*C,r[7]=0,r[8]=(p+b)*E,r[9]=(g-v)*E,r[10]=(1-(d+m))*E,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=d.Cross(t,e),r=d.Dot(t,e),o=1/(1+r),a=n._m;a[0]=i.x*i.x*o+r,a[1]=i.y*i.x*o-i.z,a[2]=i.z*i.x*o+i.y,a[3]=0,a[4]=i.x*i.y*o+i.z,a[5]=i.y*i.y*o+r,a[6]=i.z*i.y*o-i.x,a[7]=0,a[8]=i.x*i.z*o-i.y,a[9]=i.y*i.z*o+i.x,a[10]=i.z*i.z*o+r,a[11]=0,a[12]=0,a[13]=0,a[14]=0,a[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){m.RotationYawPitchRollToRef(e,t,n,w.Quaternion[0]),w.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=w.Vector3[0],a=w.Quaternion[0],s=w.Vector3[1];t.decompose(o,a,s);var c=w.Vector3[2],l=w.Quaternion[1],u=w.Vector3[3];n.decompose(c,l,u);var h=w.Vector3[4];d.LerpToRef(o,c,i,h);var f=w.Quaternion[2];m.SlerpToRef(a,l,i,f);var p=w.Vector3[5];d.LerpToRef(s,u,i,p),e.ComposeToRef(h,f,p,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=w.Vector3[0],a=w.Vector3[1],s=w.Vector3[2];n.subtractToRef(t,s),s.normalize(),d.CrossToRef(i,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),d.CrossToRef(s,o,a),a.normalize();var l=-d.Dot(o,t),u=-d.Dot(a,t),h=-d.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,l,u,h,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=w.Vector3[0],a=w.Vector3[1],s=w.Vector3[2];t.subtractToRef(n,s),s.normalize(),d.CrossToRef(i,s,o);var c=o.lengthSquared();0===c?o.x=1:o.normalizeFromLength(Math.sqrt(c)),d.CrossToRef(s,o,a),a.normalize();var l=-d.Dot(o,t),u=-d.Dot(a,t),h=-d.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,l,u,h,1,r)},e.OrthoLH=function(t,n,i,r){var o=new e;return e.OrthoLHToRef(t,n,i,r,o),o},e.OrthoLHToRef=function(t,n,i,r,o){var a=2/t,s=2/n,c=2/(r-i),l=-(r+i)/(r-i);e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,0,0,0,l,1,o),o._updateIdentityStatus(1===a&&1===s&&1===c&&0===l)},e.OrthoOffCenterLH=function(t,n,i,r,o,a){var s=new e;return e.OrthoOffCenterLHToRef(t,n,i,r,o,a,s),s},e.OrthoOffCenterLHToRef=function(t,n,i,r,o,a,s){var c=2/(n-t),l=2/(r-i),u=2/(a-o),h=-(a+o)/(a-o),d=(t+n)/(t-n),f=(r+i)/(i-r);e.FromValuesToRef(c,0,0,0,0,l,0,0,0,0,u,0,d,f,h,1,s),s._markAsUpdated()},e.OrthoOffCenterRH=function(t,n,i,r,o,a){var s=new e;return e.OrthoOffCenterRHToRef(t,n,i,r,o,a,s),s},e.OrthoOffCenterRHToRef=function(t,n,i,r,o,a,s){e.OrthoOffCenterLHToRef(t,n,i,r,o,a,s),s._m[10]*=-1},e.PerspectiveLH=function(t,n,i,r){var o=new e,a=2*i/t,s=2*i/n,c=(r+i)/(r-i),l=-2*r*i/(r-i);return e.FromValuesToRef(a,0,0,0,0,s,0,0,0,0,c,1,0,0,l,0,o),o._updateIdentityStatus(!1),o},e.PerspectiveFovLH=function(t,n,i,r){var o=new e;return e.PerspectiveFovLHToRef(t,n,i,r,o),o},e.PerspectiveFovLHToRef=function(t,n,i,r,o,a){void 0===a&&(a=!0);var s=i,c=r,l=1/Math.tan(.5*t),u=a?l/n:l,h=a?l:l*n,d=(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovRH=function(t,n,i,r){var o=new e;return e.PerspectiveFovRHToRef(t,n,i,r,o),o},e.PerspectiveFovRHToRef=function(t,n,i,r,o,a){void 0===a&&(a=!0);var s=i,c=r,l=1/Math.tan(.5*t),u=a?l/n:l,h=a?l:l*n,d=-(c+s)/(c-s),f=-2*c*s/(c-s);e.FromValuesToRef(u,0,0,0,0,h,0,0,0,0,d,-1,0,0,f,0,o),o._updateIdentityStatus(!1)},e.PerspectiveFovWebVRToRef=function(e,t,n,i,r){void 0===r&&(r=!1);var o=r?-1:1,a=Math.tan(e.upDegrees*Math.PI/180),s=Math.tan(e.downDegrees*Math.PI/180),c=Math.tan(e.leftDegrees*Math.PI/180),l=Math.tan(e.rightDegrees*Math.PI/180),u=2/(c+l),h=2/(a+s),d=i._m;d[0]=u,d[1]=d[2]=d[3]=d[4]=0,d[5]=h,d[6]=d[7]=0,d[8]=(c-l)*u*.5,d[9]=-(a-s)*h*.5,d[10]=-n/(t-n),d[11]=1*o,d[12]=d[13]=d[15]=0,d[14]=-2*n*t/(n-t),i._markAsUpdated()},e.GetFinalMatrix=function(t,n,i,r,o,a){var s=t.width,c=t.height,l=t.x,u=t.y,h=e.FromValues(s/2,0,0,0,0,-c/2,0,0,0,0,a-o,0,l+s/2,c/2+u,o,1),d=w.Matrix[0];return n.multiplyToRef(i,d),d.multiplyToRef(r,d),d.multiply(h)},e.GetAsMatrix2x2=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[4],t[5]])},e.GetAsMatrix3x3=function(e){var t=e.m;return new Float32Array([t[0],t[1],t[2],t[4],t[5],t[6],t[8],t[9],t[10]])},e.Transpose=function(t){var 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._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,l=e.y*e.z,u=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*(l+u),t._m[7]=0,t._m[8]=2*(s+c),t._m[9]=2*(l-u),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(e,t,n,i){this.normal=new d(e,t,n),this.d=i}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(this.d||0)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var n=w.Matrix[0];g.TransposeToRef(t,n);var i=n.m,r=this.normal.x,o=this.normal.y,a=this.normal.z,s=this.d;return new e(r*i[0]+o*i[1]+a*i[2]+s*i[3],r*i[4]+o*i[5]+a*i[6]+s*i[7],r*i[8]+o*i[9]+a*i[10]+s*i[11],r*i[12]+o*i[13]+a*i[14]+s*i[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,n){var i,r=t.x-e.x,o=t.y-e.y,a=t.z-e.z,s=n.x-e.x,c=n.y-e.y,l=n.z-e.z,u=o*l-a*c,h=a*s-r*l,d=r*c-o*s,f=Math.sqrt(u*u+h*h+d*d);return i=0!==f?1/f:0,this.normal.x=u*i,this.normal.y=h*i,this.normal.z=d*i,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return d.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return d.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,n,i){var r=new e(0,0,0,0);return r.copyFromPoints(t,n,i),r},e.FromPositionAndNormal=function(t,n){var i=new e(0,0,0,0);return n.normalize(),i.normal=n,i.d=-(n.x*t.x+n.y*t.y+n.z*t.z),i},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,n){var i=-(t.x*e.x+t.y*e.y+t.z*e.z);return d.Dot(n,t)+i},e}(),v=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}(),b=function(){function e(){}return e.GetPlanes=function(t){for(var n=[],i=0;i<6;i++)n.push(new _(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){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"}(i||(i={}));var y,x=function(){function e(){}return e.X=new d(1,0,0),e.Y=new d(0,1,0),e.Z=new d(0,0,1),e}(),C=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,l=0;l<5;l++){var u=c*c;c-=(o*(u*c)+a*u+s*c-e)*(1/(3*o*u+2*a*c+s)),c=Math.min(1,Math.max(0,c))}return 3*Math.pow(1-c,2)*c*n+3*(1-c)*Math.pow(c,2)*r+Math.pow(c,3)},e}();!function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"}(y||(y={}));var E=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}(),T=function(e,t,n){this.startPoint=e,this.midPoint=t,this.endPoint=n;var i=Math.pow(t.x,2)+Math.pow(t.y,2),r=(Math.pow(e.x,2)+Math.pow(e.y,2)-i)/2,o=(i-Math.pow(n.x,2)-Math.pow(n.y,2))/2,a=(e.x-t.x)*(t.y-n.y)-(t.x-n.x)*(e.y-t.y);this.centerPoint=new h((r*(t.y-n.y)-o*(e.y-t.y))/a,((e.x-t.x)*o-(t.x-n.x)*r)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=E.BetweenTwoPoints(this.centerPoint,this.startPoint);var s=this.startAngle.degrees(),c=E.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),l=E.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();c-s>180&&(c-=360),c-s<-180&&(c+=360),l-c>180&&(l-=360),l-c<-180&&(l+=360),this.orientation=c-s<0?y.CW:y.CCW,this.angle=E.FromDegrees(this.orientation===y.CW?s-l:l-s)},S=function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new h(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var n=new h(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,i,r){if(void 0===r&&(r=36),this.closed)return this;var o=this._points[this._points.length-1],a=new h(e,t),s=new h(n,i),c=new T(o,a,s),l=c.angle.radians()/r;c.orientation===y.CW&&(l*=-1);for(var u=c.startAngle.radians()+l,d=0;d1)return h.Zero();for(var t=e*this.length(),n=0,i=0;i=n&&t<=s){var c=a.normalize(),l=t-n;return new h(o.x+c.x*l,o.y+c.y*l)}n=s}return h.Zero()},e.StartingAt=function(t,n){return new e(t,n)},e}(),A=function(){function e(e,t,n){void 0===t&&(t=null),this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var 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,r=e.length();(0===r&&(r=1),null==t)?(i=o.a.WithinEpsilon(Math.abs(e.y)/r,1,c)?o.a.WithinEpsilon(Math.abs(e.x)/r,1,c)?o.a.WithinEpsilon(Math.abs(e.z)/r,1,c)?d.Zero():new d(0,0,1):new d(1,0,0):new d(0,-1,0),n=d.Cross(e,i)):(n=d.Cross(e,t),d.CrossToRef(n,e,n));return n.normalize(),n},e}(),P=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 o=new Array,a=function(e,t,n,i){return(1-e)*(1-e)*t+2*e*(1-e)*n+e*e*i},s=0;s<=r;s++)o.push(new d(a(s/r,t.x,n.x,i.x),a(s/r,t.y,n.y,i.y),a(s/r,t.z,n.z,i.z)));return new e(o)},e.CreateCubicBezier=function(t,n,i,r,o){o=o>3?o:4;for(var a=new Array,s=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},c=0;c<=o;c++)a.push(new d(s(c/o,t.x,n.x,i.x,r.x),s(c/o,t.y,n.y,i.y,r.y),s(c/o,t.z,n.z,i.z,r.z)));return new e(a)},e.CreateHermiteSpline=function(t,n,i,r,o){for(var a=new Array,s=1/o,c=0;c<=o;c++)a.push(d.Hermite(t,n,i,r,c*s));return new e(a)},e.CreateCatmullRomSpline=function(t,n,i){var r=new Array,o=1/n,a=0;if(i){for(var s=t.length,c=0;c=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){e.done?r(e.value):new n((function(t){t(e.value)})).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=(r=a.trys).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]=e||-1!==n.indexOf("file:")?-1:Math.pow(2,r)*t}},e}(),x=function(){function e(){}return 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(t){if(e.RegisteredExternalClasses&&e.RegisteredExternalClasses[t])return e.RegisteredExternalClasses[t];var n=h.a.GetClass(t);if(n)return n;u.a.Warn(t+" not found, you may have missed an import.");for(var i=t.split("."),r=window||this,o=0,a=i.length;o>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=c.a.SCALEMODE_NEAREST),i){case c.a.SCALEMODE_FLOOR:r=e.FloorPOT(t);break;case c.a.SCALEMODE_NEAREST:r=e.NearestPOT(t);break;case c.a.SCALEMODE_CEILING:default:r=e.CeilingPOT(t)}return Math.min(r,n)},e.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},e.GetFolderPath=function(e,t){void 0===t&&(t=!1);var n=e.lastIndexOf("/");return n<0?t?e:"":e.substring(0,n+1)},e.ToDegrees=function(e){return 180*e/Math.PI},e.ToRadians=function(e){return e*Math.PI/180},e.EncodeArrayBufferTobase64=function(e){for(var t,n,i,r,o,a,s,c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",l="",u=0,h=new Uint8Array(e);u>2,o=(3&t)<<4|(n=u>4,a=(15&n)<<2|(i=u>6,s=63&i,isNaN(n)?a=s=64:isNaN(i)&&(s=64),l+=c.charAt(r)+c.charAt(o)+c.charAt(a)+c.charAt(s);return"data:image/png;base64,"+l},e.ExtractMinAndMaxIndexed=function(e,t,n,i,o){void 0===o&&(o=null);for(var a=new r.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new r.x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),c=n;c=200&&t.status<300||0===t.status&&(!l.a.IsWindowObjectExist()||e.IsFileURL()))return void n(o?t.response:t.responseText,t.responseURL);var i=e.DefaultRetryStrategy;if(i){var f=i(h,t,s);if(-1!==f)return t.removeEventListener("loadend",u),t=new m.a,void(r=setTimeout((function(){return a(s+1)}),f))}var g=new b("Error status: "+t.status+" "+t.statusText+" - Unable to load "+h,t);if(!c)throw g;c(t,g)}};t.addEventListener("readystatechange",p),t.send()};a(0)};if(r&&r.enableSceneOffline){var g=function(e){e&&e.status>400?c&&c(e):d||p()};r.open((function(){d||r&&r.loadFile(t,(function(e){d||n(e),f.onCompleteObservable.notifyObservers(f)}),i?function(e){d||i(e)}:void 0,g,o)}),g)}else p();return f},e.LoadScript=function(e,t,n,i){if(l.a.IsWindowObjectExist()){var r=document.getElementsByTagName("head")[0],o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("src",e),i&&(o.id=i),o.onload=function(){t&&t()},o.onerror=function(t){n&&n("Unable to load script '"+e+"'",t)},r.appendChild(o)}},e.LoadScriptAsync=function(e,t){return new Promise((function(n,i){if(l.a.IsWindowObjectExist()){var r=document.getElementsByTagName("head")[0],o=document.createElement("script");o.setAttribute("type","text/javascript"),o.setAttribute("src",e),t&&(o.id=t),o.onload=function(){n(!0)},o.onerror=function(e){n(!1)},r.appendChild(o)}else n(!1)}))},e.ReadFileAsDataURL=function(e,t,n){var i=new FileReader,r={onCompleteObservable:new a.c,abort:function(){return i.abort()}};return i.onloadend=function(e){r.onCompleteObservable.notifyObservers(r)},i.onload=function(e){t(e.target.result)},i.onprogress=n,i.readAsDataURL(e),r},e.ReadFile=function(e,t,n,i){var r=new FileReader,o={onCompleteObservable:new a.c,abort:function(){return r.abort()}};return r.onloadend=function(e){return o.onCompleteObservable.notifyObservers(o)},r.onerror=function(n){u.a.Log("Error while reading file: "+e.name),t(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},r.onload=function(e){t(e.target.result)},n&&(r.onprogress=n),i?r.readAsArrayBuffer(e):r.readAsText(e),o},e.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},e.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},e.CheckExtends=function(e,t,n){t.minimizeInPlace(e),n.maximizeInPlace(e)},e.DeepCopy=function(e,t,n,i){d.a.DeepCopy(e,t,n,i)},e.IsEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},e.EndsWith=function(e,t){return-1!==e.indexOf(t,e.length-t.length)},e.RegisterTopRootEvents=function(e){for(var t=0;t=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.BaseUrl="",e.UseCustomRequestHeaders=!1,e.CustomRequestHeaders=m.a.CustomRequestHeaders,e.DefaultRetryStrategy=y.ExponentialBackoff(),e.CorsBehavior="anonymous",e.UseFallbackTexture=!0,e.RegisteredExternalClasses={},e.fallbackTexture="data:image/jpg;base64,/9j/4AAQSkZJRgABAQEAYABgAAD/4QBmRXhpZgAATU0AKgAAAAgABAEaAAUAAAABAAAAPgEbAAUAAAABAAAARgEoAAMAAAABAAIAAAExAAIAAAAQAAAATgAAAAAAAABgAAAAAQAAAGAAAAABcGFpbnQubmV0IDQuMC41AP/bAEMABAIDAwMCBAMDAwQEBAQFCQYFBQUFCwgIBgkNCw0NDQsMDA4QFBEODxMPDAwSGBITFRYXFxcOERkbGRYaFBYXFv/bAEMBBAQEBQUFCgYGChYPDA8WFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWFv/AABEIAQABAAMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/APH6KKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76CiiigD5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BQooooA+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/voKKKKAPl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FCiiigD6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++gooooA+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gUKKKKAPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76Pl+iiivuj+BT6gooor4U/vo+X6KKK+6P4FPqCiiivhT++j5fooor7o/gU+oKKKK+FP76P//Z",e._tmpFloatArray=new Float32Array(1),e.GetDOMTextContent=l.a.GetDOMTextContent,e.PreprocessUrl=function(e){return e},e.NoneLogLevel=u.a.NoneLogLevel,e.MessageLogLevel=u.a.MessageLogLevel,e.WarningLogLevel=u.a.WarningLogLevel,e.ErrorLogLevel=u.a.ErrorLogLevel,e.AllLogLevel=u.a.AllLogLevel,e.IsWindowObjectExist=l.a.IsWindowObjectExist,e.PerformanceNoneLogLevel=0,e.PerformanceUserMarkLogLevel=1,e.PerformanceConsoleLogLevel=2,e.StartPerformanceCounter=e._StartPerformanceCounterDisabled,e.EndPerformanceCounter=e._EndPerformanceCounterDisabled,e}(),C=function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(t,n){e.Enabled&&(this._current+=t,n&&this._fetchResult())},e.prototype.beginMonitoring=function(){e.Enabled&&(this._startMonitoringTime=f.a.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var n=f.a.Now;this._current=n-this._startMonitoringTime,t&&this._fetchResult()}},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=f.a.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e}();function E(e,t){return function(n){n.__bjsclassName__=e,n.__bjsmoduleName__=null!=t?t:null}}var T=function(){function e(e,t,n,i){void 0===i&&(i=0),this.iterations=e,this.index=i-1,this._done=!1,this._fn=t,this._successCallback=n}return e.prototype.executeNext=function(){this._done||(this.index+1=t)break;if(i(a),o&&o()){e.breakLoop();break}}e.executeNext()}),a)}),r)},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var i=n(1),r=n(2),o=n(7),a=n(5),s=n(0),c=n(56),l=n(4),u=n(26),h=n(22),d=function(e){function t(n,i,r,s,c,u,h,d,f,p){void 0===r&&(r=!1),void 0===s&&(s=!0),void 0===c&&(c=t.TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null),void 0===h&&(h=null),void 0===d&&(d=null),void 0===f&&(f=!1);var m=e.call(this,i)||this;if(m.url=null,m.uOffset=0,m.vOffset=0,m.uScale=1,m.vScale=1,m.uAng=0,m.vAng=0,m.wAng=0,m.uRotationCenter=.5,m.vRotationCenter=.5,m.wRotationCenter=.5,m.inspectableCustomProperties=null,m._noMipmap=!1,m._invertY=!1,m._rowGenerationMatrix=null,m._cachedTextureMatrix=null,m._projectionModeMatrix=null,m._t0=null,m._t1=null,m._t2=null,m._cachedUOffset=-1,m._cachedVOffset=-1,m._cachedUScale=0,m._cachedVScale=0,m._cachedUAng=-1,m._cachedVAng=-1,m._cachedWAng=-1,m._cachedProjectionMatrixId=-1,m._cachedCoordinatesMode=-1,m._initialSamplingMode=t.BILINEAR_SAMPLINGMODE,m._buffer=null,m._deleteBuffer=!1,m._format=null,m._delayedOnLoad=null,m._delayedOnError=null,m.onLoadObservable=new o.c,m._isBlocking=!0,m.name=n||"",m.url=n,m._noMipmap=r,m._invertY=s,m._initialSamplingMode=c,m._buffer=d,m._deleteBuffer=f,p&&(m._format=p),!(i=m.getScene()))return m;i.getEngine().onBeforeTextureInitObservable.notifyObservers(m);var g=function(){m._texture&&m._texture._invertVScale&&(m.vScale=-1),m.onLoadObservable.hasObservers()&&m.onLoadObservable.notifyObservers(m),u&&u(),!m.isBlocking&&i&&i.resetCachedMaterial()};return m.url?(m._texture=m._getFromCache(m.url,r,c,s),m._texture?m._texture.isReady?a.h.SetImmediate((function(){return g()})):m._texture.onLoadedObservable.add(g):i.useDelayedTextureLoading?(m.delayLoadState=l.a.DELAYLOADSTATE_NOTLOADED,m._delayedOnLoad=g,m._delayedOnError=h):(m._texture=i.getEngine().createTexture(m.url,r,s,i,c,g,h,m._buffer,void 0,m._format),f&&delete m._buffer),m):(m._delayedOnLoad=g,m._delayedOnError=h,m)}return i.d(t,e),Object.defineProperty(t.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"samplingMode",{get:function(){return this._texture?this._texture.samplingMode:this._initialSamplingMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"invertY",{get:function(){return this._invertY},enumerable:!0,configurable:!0}),t.prototype.updateURL=function(e,t,n){void 0===t&&(t=null),this.url&&(this.releaseInternalTexture(),this.getScene().markAllMaterialsAsDirty(l.a.MATERIAL_TextureDirtyFlag)),this.url=e,this._buffer=t,this.delayLoadState=l.a.DELAYLOADSTATE_NOTLOADED,n&&(this._delayedOnLoad=n),this.delayLoad()},t.prototype.delayLoad=function(){if(this.delayLoadState===l.a.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=l.a.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this.samplingMode,this._invertY),this._texture?this._delayedOnLoad&&(this._texture.isReady?a.h.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=e.getEngine().createTexture(this.url,this._noMipmap,this._invertY,e,this.samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format),this._deleteBuffer&&delete this._buffer),this._delayedOnLoad=null,this._delayedOnError=null)}},t.prototype._prepareRowForTextureGeneration=function(e,t,n,i){e*=this.uScale,t*=this.vScale,e-=this.uRotationCenter*this.uScale,t-=this.vRotationCenter*this.vScale,n-=this.wRotationCenter,s.x.TransformCoordinatesFromFloatsToRef(e,t,n,this._rowGenerationMatrix,i),i.x+=this.uRotationCenter*this.uScale+this.uOffset,i.y+=this.vRotationCenter*this.vScale+this.vOffset,i.z+=this.wRotationCenter},t.prototype.getTextureMatrix=function(){var e=this;if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.uAng===this._cachedUAng&&this.vAng===this._cachedVAng&&this.wAng===this._cachedWAng)return this._cachedTextureMatrix;this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedUAng=this.uAng,this._cachedVAng=this.vAng,this._cachedWAng=this.wAng,this._cachedTextureMatrix||(this._cachedTextureMatrix=s.j.Zero(),this._rowGenerationMatrix=new s.j,this._t0=s.x.Zero(),this._t1=s.x.Zero(),this._t2=s.x.Zero()),s.j.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),s.j.FromValuesToRef(this._t1.x,this._t1.y,this._t1.z,0,this._t2.x,this._t2.y,this._t2.z,0,this._t0.x,this._t0.y,this._t0.z,0,0,0,0,1,this._cachedTextureMatrix);var t=this.getScene();return t?(t.markAllMaterialsAsDirty(l.a.MATERIAL_TextureDirtyFlag,(function(t){return t.hasTexture(e)})),this._cachedTextureMatrix):this._cachedTextureMatrix},t.prototype.getReflectionTextureMatrix=function(){var e=this,n=this.getScene();if(!n)return this._cachedTextureMatrix;if(this.uOffset===this._cachedUOffset&&this.vOffset===this._cachedVOffset&&this.uScale===this._cachedUScale&&this.vScale===this._cachedVScale&&this.coordinatesMode===this._cachedCoordinatesMode){if(this.coordinatesMode!==t.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===n.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=s.j.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=s.j.Zero()),this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case t.PLANAR_MODE:s.j.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case t.PROJECTION_MODE:s.j.FromValuesToRef(.5,0,0,0,0,-.5,0,0,0,0,0,0,.5,.5,1,1,this._projectionModeMatrix);var i=n.getProjectionMatrix();this._cachedProjectionMatrixId=i.updateFlag,i.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:s.j.IdentityToRef(this._cachedTextureMatrix)}return n.markAllMaterialsAsDirty(l.a.MATERIAL_TextureDirtyFlag,(function(t){return-1!==t.getActiveTextures().indexOf(e)})),this._cachedTextureMatrix},t.prototype.clone=function(){var e=this;return r.a.Clone((function(){return new t(e._texture?e._texture.url:null,e.getScene(),e._noMipmap,e._invertY,e.samplingMode,void 0,void 0,e._texture?e._texture._buffer:void 0)}),this)},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return"string"==typeof this._buffer&&"data:"===this._buffer.substr(0,5)&&(t.base64String=this._buffer,t.name=t.name.replace("data:","")),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t},t.prototype.getClassName=function(){return"Texture"},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null},t.Parse=function(e,n,i){if(e.customType){var o=a.h.Instantiate(e.customType).Parse(e,n,i);return e.samplingMode&&o.updateSamplingMode&&o._samplingMode&&o._samplingMode!==e.samplingMode&&o.updateSamplingMode(e.samplingMode),o}if(e.isCube&&!e.isRenderTarget)return t._CubeTextureParser(e,n,i);if(!e.name&&!e.isRenderTarget)return null;var c=r.a.Parse((function(){var r,o=!0;if(e.noMipmap&&(o=!1),e.mirrorPlane){var a=t._CreateMirror(e.name,e.renderTargetSize,n,o);return a._waitingRenderList=e.renderList,a.mirrorPlane=s.n.FromArray(e.mirrorPlane),a}if(e.isRenderTarget){var c=null;if(e.isCube){if(n.reflectionProbes)for(var l=0;l0},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;tthis._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,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0&&this._mesh.material){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var n=this._mesh.getScene(),i=0;i-1?t:e.ShadersRepository+t,this._engine._loadFile(i+".vertex.fx",n)):n(window.atob(t.substr(7)))},e.prototype._loadFragmentShader=function(t,n){var i;if(o.a.IsWindowObjectExist()&&t instanceof HTMLElement)return void n(o.a.GetDOMTextContent(t));"base64:"!==t.substr(0,7)?e.ShadersStore[t+"PixelShader"]?n(e.ShadersStore[t+"PixelShader"]):e.ShadersStore[t+"FragmentShader"]?n(e.ShadersStore[t+"FragmentShader"]):(i="."===t[0]||"/"===t[0]||t.indexOf("http")>-1?t:e.ShadersRepository+t,this._engine._loadFile(i+".fragment.fx",n)):n(window.atob(t.substr(7)))},e.prototype._dumpShadersSource=function(e,t,n){var i=(this._engine.webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"")+(n?n+"\n":"");t=i+t;var r=2,o=/\n/gm,s="\n1\t"+(e=i+e).replace(o,(function(){return"\n"+r+++"\t"}));r=2;var c="\n1\t"+t.replace(o,(function(){return"\n"+r+++"\t"}));this.name.vertexElement?(a.a.Error("Vertex shader: "+this.name.vertexElement+s),a.a.Error("Fragment shader: "+this.name.fragmentElement+c)):this.name.vertex?(a.a.Error("Vertex shader: "+this.name.vertex+s),a.a.Error("Fragment shader: "+this.name.fragment+c)):(a.a.Error("Vertex shader: "+this.name+s),a.a.Error("Fragment shader: "+this.name+c))},e.prototype._processShaderConversion=function(e,t,n){var i=this._processPrecision(e);if(1!=this._engine.webGLVersion)if(-1===i.indexOf("#version 3")){var r=-1!==i.search(/#extension.+GL_EXT_draw_buffers.+require/),o=i.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,"");o=(o=(o=(o=o.replace(/varying(?![\n\r])\s/g,t?"in ":"out ")).replace(/attribute[ \t]/g,"in ")).replace(/[ \t]attribute/g," in")).replace(/texture2D\s*\(/g,"texture("),t&&(o=(o=(o=(o=(o=(o=(o=o.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(r?"":"out vec4 glFragColor;\n")+"void main(")),-1!==this.defines.indexOf("#define MULTIVIEW\n")&&!t&&(o="#extension GL_OVR_multiview2 : require\nlayout (num_views = 2) in;\n"+o),n(o)}else n(i.replace("#version 300 es",""));else n(i)},e.prototype._processIncludes=function(t,n){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,o=r.exec(t),a=new String(t);null!=o;){var s=o[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),this._engine.supportsUniformBuffers&&(s=(s=s.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),s+="Declaration"),!e.IncludesShadersStore[s]){var c=e.ShadersRepository+"ShadersInclude/"+s+".fx";return void this._engine._loadFile(c,(function(t){e.IncludesShadersStore[s]=t,i._processIncludes(a,n)}))}var l=e.IncludesShadersStore[s];if(o[2])for(var u=o[3].split(","),h=0;h
";e._AddLogEntry(i)},e._WarnDisabled=function(e){},e._WarnEnabled=function(t){var n=e._FormatMessage(t);console.warn("BJS - "+n);var i="
"+n+"

";e._AddLogEntry(i)},e._ErrorDisabled=function(e){},e._ErrorEnabled=function(t){e.errorsCount++;var n=e._FormatMessage(t);console.error("BJS - "+n);var i="
"+n+"

";e._AddLogEntry(i)},Object.defineProperty(e,"LogCache",{get:function(){return e._LogCache},enumerable:!0,configurable:!0}),e.ClearLogCache=function(){e._LogCache="",e.errorsCount=0},Object.defineProperty(e,"LogLevels",{set:function(t){(t&e.MessageLogLevel)===e.MessageLogLevel?e.Log=e._LogEnabled:e.Log=e._LogDisabled,(t&e.WarningLogLevel)===e.WarningLogLevel?e.Warn=e._WarnEnabled:e.Warn=e._WarnDisabled,(t&e.ErrorLogLevel)===e.ErrorLogLevel?e.Error=e._ErrorEnabled:e.Error=e._ErrorDisabled},enumerable:!0,configurable:!0}),e.NoneLogLevel=0,e.MessageLogLevel=1,e.WarningLogLevel=2,e.ErrorLogLevel=4,e.AllLogLevel=7,e._LogCache="",e.errorsCount=0,e.Log=e._LogEnabled,e.Warn=e._WarnEnabled,e.Error=e._ErrorEnabled,e}()},function(e,t,n){"use strict";n.d(t,"d",(function(){return T})),n.d(t,"a",(function(){return S})),n.d(t,"c",(function(){return A})),n.d(t,"b",(function(){return P}));var i=n(1),r=n(7),o=n(159),a=n(88),s=n(160),c=n(5),l=n(0),u=n(13),h=n(8),d=n(16),f=n(32),p=n(142),m=n(4),g=n(50),_=n(9),v=n(27),b=n(140),y=n(22),x=n(161),C=n(112),E=function(){},T=function(){},S=function(){},A=function(){},P=function(){function e(t,n,i,a){var u=this;void 0===a&&(a=!1),this.forcePOTTextures=!1,this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.scenes=new Array,this.onNewSceneAddedObservable=new r.c,this.postProcesses=new Array,this.validateShaderPrograms=!1,this.onResizeObservable=new r.c,this.onCanvasBlurObservable=new r.c,this.onCanvasFocusObservable=new r.c,this.onCanvasPointerOutObservable=new r.c,this.onBeforeTextureInitObservable=new r.c,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this.onBeginFrameObservable=new r.c,this.customAnimationFrameRequester=null,this.onEndFrameObservable=new r.c,this.onBeforeShaderCompilationObservable=new r.c,this.onAfterShaderCompilationObservable=new r.c,this._windowIsBackground=!1,this._webGLVersion=1,this._highPrecisionShadersAllowed=!0,this._badOS=!1,this._badDesktopOS=!1,this._colorWrite=!0,this._drawCalls=new c.f,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this.onContextLostObservable=new r.c,this.onContextRestoredObservable=new r.c,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this._performanceMonitor=new o.a,this._fps=60,this._deltaTime=0,this.disablePerformanceMonitorInBackground=!1,this.disableVertexArrayObjects=!1,this._depthCullingState=new p.b,this._stencilState=new p.c,this._alphaState=new p.a,this._alphaMode=e.ALPHA_DISABLE,this._internalTexturesCache=new Array,this._activeChannel=0,this._currentTextureChannel=-1,this._boundTexturesCache={},this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._activeRequests=new Array,this._texturesSupported=new Array,this.premultipliedAlpha=!0,this._viewportCached=new l.y(0,0,0,0),this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},s.a.Apply();var h=null;if(e.Instances.push(this),t){if(i=i||{},t.getContext){if(h=t,this._renderingCanvas=h,null!=n&&(i.antialias=n),void 0===i.deterministicLockstep&&(i.deterministicLockstep=!1),void 0===i.lockstepMaxSteps&&(i.lockstepMaxSteps=4),void 0===i.preserveDrawingBuffer&&(i.preserveDrawingBuffer=!1),void 0===i.audioEngine&&(i.audioEngine=!0),void 0===i.stencil&&(i.stencil=!0),!1===i.premultipliedAlpha&&(this.premultipliedAlpha=!1),this._deterministicLockstep=i.deterministicLockstep,this._lockstepMaxSteps=i.lockstepMaxSteps,this._doNotHandleContextLost=!!i.doNotHandleContextLost,navigator&&navigator.userAgent)for(var d=navigator.userAgent,f=0,m=e.ExceptionList;f0)if(parseInt(T[T.length-1])>=C)continue}for(var S=0,A=y;S1&&!this.disableUniformBuffers},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_shouldUseHighPrecisionShader",{get:function(){return this._caps.highPrecisionShaderSupported&&this._highPrecisionShadersAllowed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,e.TEXTUREFORMAT_RGBA,!1,!1,e.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,e.TEXTUREFORMAT_RGBA,!1,!1,e.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var t=new Uint8Array(4),n=[t,t,t,t,t,t];this._emptyCubeTexture=this.createRawCubeTexture(n,1,e.TEXTUREFORMAT_RGBA,e.TEXTURETYPE_UNSIGNED_INT,!1,!1,e.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!0,configurable:!0}),e.prototype.initWebVR=function(){throw y.a.WarnImport("WebVRCamera")},e.prototype._prepareVRComponent=function(){},e.prototype._connectVREvents=function(e,t){},e.prototype._submitVRFrame=function(){},e.prototype.disableVR=function(){},e.prototype.isVRPresenting=function(){return!1},e.prototype._requestVRFrame=function(){},e.prototype._disableTouchAction=function(){this._renderingCanvas&&(this._renderingCanvas.setAttribute("touch-action","none"),this._renderingCanvas.style.touchAction="none",this._renderingCanvas.style.msTouchAction="none")},e.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e1||null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.astc=this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),this._caps.textureAnisotropicFilterExtension=this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.uintIndices=this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!1,this._caps.timerQuery=this._gl.getExtension("EXT_disjoint_timer_query_webgl2")||this._gl.getExtension("EXT_disjoint_timer_query"),this._caps.timerQuery&&(1===this._webGLVersion&&(this._gl.getQuery=this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery)),this._caps.canUseTimestampForTimerQuery=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)>0),this._caps.colorBufferFloat=this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),this._caps.textureFloat=!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloat=!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._webGLVersion>1&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._caps.textureLOD=!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),this._caps.multiview=this._gl.getExtension("OVR_multiview2"),this._webGLVersion>1)this._caps.drawBuffersExtension=!0;else{var t=this._gl.getExtension("WEBGL_draw_buffers");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var n=0;n<16;n++)this._gl["COLOR_ATTACHMENT"+n+"_WEBGL"]=t["COLOR_ATTACHMENT"+n+"_WEBGL"]}else this._caps.drawBuffersExtension=!1}if(this._caps.parallelShaderCompile=this._gl.getExtension("KHR_parallel_shader_compile"),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)):this._caps.vertexArrayObject=!1}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._caps.astc&&this.texturesSupported.push("-astc.ktx"),this._caps.s3tc&&this.texturesSupported.push("-dxt.ktx"),this._caps.pvrtc&&this.texturesSupported.push("-pvrtc.ktx"),this._caps.etc2&&this.texturesSupported.push("-etc2.ktx"),this._caps.etc1&&this.texturesSupported.push("-etc1.ktx"),this._gl.getShaderPrecisionFormat){var a=this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER,this._gl.HIGH_FLOAT),s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);a&&s&&(this._caps.highPrecisionShaderSupported=0!==a.precision&&0!==s.precision)}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var c=0;c=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.customAnimationFrameRequester?(this.customAnimationFrameRequester.requestID=c.h.QueueNewFrame(this.customAnimationFrameRequester.renderFunction||this._bindedRenderFunction,this.customAnimationFrameRequester),this._frameHandler=this.customAnimationFrameRequester.requestID):this.isVRPresenting()?this._requestVRFrame():this._frameHandler=c.h.QueueNewFrame(this._bindedRenderFunction):this._renderingQueueLaunched=!1},e.prototype.runRenderLoop=function(e){-1===this._activeRenderLoops.indexOf(e)&&(this._activeRenderLoops.push(e),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),this._frameHandler=c.h.QueueNewFrame(this._bindedRenderFunction)))},e.prototype.switchFullscreen=function(e){this.isFullscreen?this.exitFullscreen():this.enterFullscreen(e)},e.prototype.enterFullscreen=function(e){this.isFullscreen||(this._pointerLockRequested=e,this._renderingCanvas&&c.h.RequestFullscreen(this._renderingCanvas))},e.prototype.exitFullscreen=function(){this.isFullscreen&&c.h.ExitFullscreen()},e.prototype.clear=function(e,t,n,i){void 0===i&&(i=!1),this.applyStates();var r=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),r|=this._gl.COLOR_BUFFER_BIT),n&&(this._gl.clearDepth(1),r|=this._gl.DEPTH_BUFFER_BIT),i&&(this._gl.clearStencil(0),r|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(r)},e.prototype.scissorClear=function(e,t,n,i,r){this.enableScissor(e,t,n,i),this.clear(r,!0,!0,!0),this.disableScissor()},e.prototype.enableScissor=function(e,t,n,i){var r=this._gl;r.enable(r.SCISSOR_TEST),r.scissor(e,t,n,i)},e.prototype.disableScissor=function(){var e=this._gl;e.disable(e.SCISSOR_TEST)},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.setDirectViewport=function(e,t,n,i){var r=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,n,i),r},e.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this),this._measureFps()},e.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._submitVRFrame(),this.onEndFrameObservable.notifyObservers(this)},e.prototype.resize=function(){if(!this.isVRPresenting()){var e=this._renderingCanvas?this._renderingCanvas.clientWidth:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight:window.innerHeight;this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)}},e.prototype.setSize=function(e,t){if(this._renderingCanvas&&(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var n=0;n65535){o=!0;break}n=o?new Uint32Array(e):new Uint16Array(e)}else n=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,n,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),r.references=1,r.is32Bits=o,r},e.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},e.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e?e.underlyingResource:null)},e.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e?e.underlyingResource:null)},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],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){var n=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var i=0;i=0){var o=e[n[i]];if(!o)continue;this._gl.enableVertexAttribArray(r),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[r]=!0);var a=o.getBuffer();a&&(this._vertexAttribPointer(a,r,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(r,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(r),this._currentInstanceBuffers.push(a))))}}},e.prototype.recordVertexArrayObject=function(e,t,n){var i=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(i),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,n),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),i},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){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===n||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n,this._bindVertexBuffersAttributes(e,n)),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),l=this._createShaderProgram(e,s,c,r,o);return this.onAfterShaderCompilationObservable.notifyObservers(this),l},e.prototype.createPipelineContext=function(){var e=new x.a;return e.engine=this,this._caps.parallelShaderCompile&&(e.isParallelCompiled=!0),e},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");if(i.attachShader(o,t),i.attachShader(o,n),this.webGLVersion>1&&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},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 new Error(o);if(!this._gl.getShaderParameter(i,this._gl.COMPILE_STATUS))if(o=this._gl.getShaderInfoLog(i))throw new Error(o);if(a=t.getProgramInfoLog(r))throw new Error(a)}if(this.validateShaderPrograms&&(t.validateProgram(r),!t.getProgramParameter(r,t.VALIDATE_STATUS)&&(a=t.getProgramInfoLog(r))))throw 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){var s=e;s.program=i?this.createRawShaderProgram(s,t,n,void 0,a):this.createShaderProgram(s,t,n,o,void 0,a),s.program.__SPECTOR_rebuildProgram=r},e.prototype._isRenderingStateCompiled=function(e){var t=e;return!!this._gl.getProgramParameter(t.program,this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)&&(this._finalizePipelineContext(t),!0)},e.prototype._executeWhenRenderingStateIsCompiled=function(e,t){var n=e;n.isParallelCompiled?n.onCompiled=t:t()},e.prototype.getUniforms=function(e,t){for(var n=new Array,i=e,r=0;r-1?g.substring(x).toLowerCase():""),E=null,T=0,S=e._TextureLoaders;Tl||t.height>l||null===e._RescalePostProcessFactory)return m._prepareWorkingCanvas(),!(!m._workingCanvas||!m._workingContext)&&(m._workingCanvas.width=n,m._workingCanvas.height=i,m._workingContext.drawImage(t,0,0,t.width,t.height,0,0,n,i),a.texImage2D(a.TEXTURE_2D,0,c,c,a.UNSIGNED_BYTE,m._workingCanvas),y.width=n,y.height=i,!1);var u=new f.a(m,f.a.DATASOURCE_TEMP);return m._bindTextureDirectly(a.TEXTURE_2D,u,!0),a.texImage2D(a.TEXTURE_2D,0,c,c,a.UNSIGNED_BYTE,t),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_2D,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),m._rescaleTexture(u,y,r,c,(function(){m._releaseTexture(u),m._bindTextureDirectly(a.TEXTURE_2D,y,!0),o()})),!0}),o)};!_||b?l instanceof HTMLImageElement?R(l):c.h.LoadImage(g,R,M,r?r.offlineProvider:null):"string"==typeof l||l instanceof ArrayBuffer||l instanceof Blob?c.h.LoadImage(l,R,M,r?r.offlineProvider:null):R(l)}return y},e.prototype._rescaleTexture=function(t,n,i,r,o){var a=this,s=this.createRenderTargetTexture({width:n.width,height:n.height},{generateMipMaps:!1,type:e.TEXTURETYPE_UNSIGNED_INT,samplingMode:e.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});!this._rescalePostProcess&&e._RescalePostProcessFactory&&(this._rescalePostProcess=e._RescalePostProcessFactory(this)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(e){e._bindTexture("textureSampler",t)};var e=i;e||(e=a.scenes[a.scenes.length-1]),e.postProcessManager.directRender([a._rescalePostProcess],s,!0),a._bindTextureDirectly(a._gl.TEXTURE_2D,n,!0),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,r,0,0,n.width,n.height,0),a.unBindFramebuffer(s),a._releaseTexture(s),o&&o()}))},e.prototype.createRawTexture=function(t,n,i,r,o,a,s,c,l){throw void 0===c&&(c=null),void 0===l&&(l=e.TEXTURETYPE_UNSIGNED_INT),y.a.WarnImport("Engine.RawTexture")},e.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},e.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},e.prototype.createDynamicTexture=function(e,t,n,i){var r=new f.a(this,f.a.DATASOURCE_DYNAMIC);return r.baseWidth=e,r.baseHeight=t,n&&(e=this.needPOTTextures?c.h.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?c.h.GetExponentOfTwo(t,this._caps.maxTextureSize):t),r.width=e,r.height=t,r.isReady=!1,r.generateMipMaps=n,r.samplingMode=i,this.updateTextureSamplingMode(i,r),this._internalTexturesCache.push(r),r},e.prototype.updateTextureSamplingMode=function(e,t){var n=this._getSamplingParameters(e,t.generateMipMaps);t.isCube?(this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MAG_FILTER,n.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,n.min),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):t.is3D?(this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,n.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,n.min),this._bindTextureDirectly(this._gl.TEXTURE_3D,null)):(this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,n.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,n.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t.samplingMode=e},e.prototype.updateDynamicTexture=function(e,t,n,i,r,o){if(void 0===i&&(i=!1),void 0===o&&(o=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0,o),this._unpackFlipY(n),i&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var a=r?this._getInternalFormat(r):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,a,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),i&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}},e.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.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported)this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);else{if(!e._workingCanvas){e._workingCanvas=document.createElement("canvas");var 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.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}}},e.prototype.updateTextureComparisonFunction=function(t,n){if(1!==this.webGLVersion){var i=this._gl;t.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,t,!0),0===n?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,e.LEQUAL),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,n),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),0===n?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,e.LEQUAL),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,n),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t._comparisonFunction=n}else _.a.Error("WebGL 1 does not support texture comparison.")},e.prototype._setupDepthStencilTexture=function(t,n,i,r,o){var a=n.width||n,s=n.height||n;t.baseWidth=a,t.baseHeight=s,t.width=a,t.height=s,t.isReady=!0,t.samples=1,t.generateMipMaps=!1,t._generateDepthBuffer=!0,t._generateStencilBuffer=i,t.samplingMode=r?e.TEXTURE_BILINEAR_SAMPLINGMODE:e.TEXTURE_NEAREST_SAMPLINGMODE,t.type=e.TEXTURETYPE_UNSIGNED_INT,t._comparisonFunction=o;var c=this._gl,l=t.isCube?c.TEXTURE_CUBE_MAP:c.TEXTURE_2D,u=this._getSamplingParameters(t.samplingMode,!1);c.texParameteri(l,c.TEXTURE_MAG_FILTER,u.mag),c.texParameteri(l,c.TEXTURE_MIN_FILTER,u.min),c.texParameteri(l,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(l,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),0===o?(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,e.LEQUAL),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(l,c.TEXTURE_COMPARE_FUNC,o),c.texParameteri(l,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE))},e.prototype.createDepthStencilTexture=function(e,t){if(t.isCube){var n=e.width||e;return this._createDepthStencilCubeTexture(n,t)}return this._createDepthStencilTexture(e,t)},e.prototype._createDepthStencilTexture=function(e,t){var n=new f.a(this,f.a.DATASOURCE_DEPTHTEXTURE);if(!this._caps.depthTextureExtension)return _.a.Error("Depth texture is not supported by your browser or hardware."),n;var r=i.a({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),o=this._gl;return this._bindTextureDirectly(o.TEXTURE_2D,n,!0),this._setupDepthStencilTexture(n,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction),this.webGLVersion>1?r.generateStencil?o.texImage2D(o.TEXTURE_2D,0,o.DEPTH24_STENCIL8,n.width,n.height,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_COMPONENT24,n.width,n.height,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null):r.generateStencil?o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_STENCIL,n.width,n.height,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_COMPONENT,n.width,n.height,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null),this._bindTextureDirectly(o.TEXTURE_2D,null),n},e.prototype.setFrameBufferDepthStencilTexture=function(e){var t=e.getInternalTexture();if(t&&t._framebuffer&&e.depthStencilTexture){var n=this._gl,i=e.depthStencilTexture;this._bindUnboundFramebuffer(t._framebuffer),i.isCube?i._generateStencilBuffer?n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_CUBE_MAP_POSITIVE_X,i._webGLTexture,0):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_CUBE_MAP_POSITIVE_X,i._webGLTexture,0):i._generateStencilBuffer?n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_STENCIL_ATTACHMENT,n.TEXTURE_2D,i._webGLTexture,0):n.framebufferTexture2D(n.FRAMEBUFFER,n.DEPTH_ATTACHMENT,n.TEXTURE_2D,i._webGLTexture,0),this._bindUnboundFramebuffer(null)}},e.prototype.createRenderTargetTexture=function(t,n){var i=new b.a;void 0!==n&&"object"==typeof n?(i.generateMipMaps=n.generateMipMaps,i.generateDepthBuffer=void 0===n.generateDepthBuffer||n.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&n.generateStencilBuffer,i.type=void 0===n.type?e.TEXTURETYPE_UNSIGNED_INT:n.type,i.samplingMode=void 0===n.samplingMode?e.TEXTURE_TRILINEAR_SAMPLINGMODE:n.samplingMode,i.format=void 0===n.format?e.TEXTUREFORMAT_RGBA:n.format):(i.generateMipMaps=n,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=e.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=e.TEXTURE_TRILINEAR_SAMPLINGMODE,i.format=e.TEXTUREFORMAT_RGBA),(i.type!==e.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==e.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=e.TEXTURE_NEAREST_SAMPLINGMODE);var r=this._gl,o=new f.a(this,f.a.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(r.TEXTURE_2D,o,!0);var a=t.width||t,s=t.height||t,c=this._getSamplingParameters(i.samplingMode,!!i.generateMipMaps);i.type!==e.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=e.TEXTURETYPE_UNSIGNED_INT,_.a.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,c.mag),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,c.min),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE),r.texImage2D(r.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),a,s,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);var l=this._currentFramebuffer,u=r.createFramebuffer();return this._bindUnboundFramebuffer(u),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,o._webGLTexture,0),o._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!i.generateStencilBuffer,i.generateDepthBuffer,a,s),i.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this._bindUnboundFramebuffer(l),o._framebuffer=u,o.baseWidth=a,o.baseHeight=s,o.width=a,o.height=s,o.isReady=!0,o.samples=1,o.generateMipMaps=!!i.generateMipMaps,o.samplingMode=i.samplingMode,o.type=i.type,o.format=i.format,o._generateDepthBuffer=i.generateDepthBuffer,o._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(o),o},e.prototype._setupFramebufferDepthAttachments=function(e,t,n,i,r){void 0===r&&(r=1);var o=null,a=this._gl;return e?(o=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,o),r>1?a.renderbufferStorageMultisample(a.RENDERBUFFER,r,a.DEPTH24_STENCIL8,n,i):a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_STENCIL,n,i),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.RENDERBUFFER,o)):t&&(o=a.createRenderbuffer(),a.bindRenderbuffer(a.RENDERBUFFER,o),r>1?a.renderbufferStorageMultisample(a.RENDERBUFFER,r,a.DEPTH_COMPONENT16,n,i):a.renderbufferStorage(a.RENDERBUFFER,a.DEPTH_COMPONENT16,n,i),a.framebufferRenderbuffer(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.RENDERBUFFER,o)),o},e.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;var n=this._gl;if(t=Math.min(t,n.getParameter(n.MAX_SAMPLES)),e._depthStencilBuffer&&(n.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(n.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(n.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null),t>1){var i=n.createFramebuffer();if(!i)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=i,this._bindUnboundFramebuffer(e._MSAAFramebuffer);var r=n.createRenderbuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,r),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.RENDERBUFFER,r),e._MSAARenderBuffer=r}else this._bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),n.bindRenderbuffer(n.RENDERBUFFER,null),this._bindUnboundFramebuffer(null),t},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;e.isCube&&(c=s.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(c,a,t,n,i,0,r)},e.prototype._uploadDataToTextureDirectly=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0);var r=this._gl,o=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),s=this._getRGBABufferInternalSizedFormat(e.type,a);this._unpackFlipY(e.invertY);var c=r.TEXTURE_2D;e.isCube&&(c=r.TEXTURE_CUBE_MAP_POSITIVE_X+n);var l=Math.round(u.a.Log2(e.width)),h=Math.round(u.a.Log2(e.height)),d=Math.pow(2,Math.max(l-i,0)),f=Math.pow(2,Math.max(h-i,0));r.texImage2D(c,i,s,d,f,0,a,o,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._uploadImageToTexture=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0);var r=this._gl,o=this._getWebGLTextureType(e.type),a=this._getInternalFormat(e.format),s=this._getRGBABufferInternalSizedFormat(e.type,a),c=e.isCube?r.TEXTURE_CUBE_MAP:r.TEXTURE_2D;this._bindTextureDirectly(c,e,!0),this._unpackFlipY(e.invertY);var l=r.TEXTURE_2D;e.isCube&&(l=r.TEXTURE_CUBE_MAP_POSITIVE_X+n),r.texImage2D(l,i,s,a,o,t),this._bindTextureDirectly(c,null,!0)},e.prototype._setCubeMapTextureParams=function(e){var t=this._gl;t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_MIN_FILTER,e?t.LINEAR_MIPMAP_LINEAR:t.LINEAR),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_CUBE_MAP,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)},e.prototype.createRawCubeTexture=function(e,t,n,i,r,o,a,s){throw void 0===s&&(s=null),y.a.WarnImport("Engine.RawTexture")},e.prototype.createRawTexture3D=function(t,n,i,r,o,a,s,c,l,u){throw void 0===l&&(l=null),void 0===u&&(u=e.TEXTURETYPE_UNSIGNED_INT),y.a.WarnImport("Engine.RawTexture")},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,l,u){var h=this;void 0===u&&(u=e.TEXTURE_TRILINEAR_SAMPLINGMODE);var d=this.getCaps().maxTextureSize,f=Math.min(d,this.needPOTTextures?c.h.GetExponentOfTwo(i,d):i),p=Math.min(d,this.needPOTTextures?c.h.GetExponentOfTwo(r,d):r),m=this._gl;m&&(t._webGLTexture?(this._bindTextureDirectly(m.TEXTURE_2D,t,!0),this._unpackFlipY(void 0===o||!!o),t.baseWidth=i,t.baseHeight=r,t.width=f,t.height=p,t.isReady=!0,l(f,p,(function(){h._prepareWebGLTextureContinuation(t,n,a,s,u)}))||this._prepareWebGLTextureContinuation(t,n,a,s,u)):n&&n._removePendingData(t))},e.prototype._convertRGBtoRGBATextureData=function(t,n,i,r){var o;o=r===e.TEXTURETYPE_FLOAT?new Float32Array(n*i*4):new Uint32Array(n*i*4);for(var a=0;a-1;return n&&o&&(this._activeChannel=t._associatedChannel),this._boundTexturesCache[this._activeChannel]!==t||i?(this._activateCurrentTexture(),t&&t.isMultiview?this._gl.bindTexture(e,t?t._colorTextureArray:null):this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t&&(t._associatedChannel=this._activeChannel)):n&&(r=!0,this._activateCurrentTexture()),o&&!n&&this._bindSamplerUniformToChannel(t._associatedChannel,this._activeChannel),r},e.prototype._bindTexture=function(e,t){void 0!==e&&(t&&(t._associatedChannel=e),this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},e.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t?t._textures.data[t._currentRenderTextureInd]:null)},e.prototype.setTextureFromPostProcessOutput=function(e,t){this._bindTexture(e,t?t._outputTexture:null)},e.prototype.unbindAllTextures=function(){for(var e=0;e1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)},e.prototype.setTexture=function(e,t,n){void 0!==e&&(t&&(this._boundUniforms[e]=t),this._setTexture(e,n))},e.prototype.setDepthStencilTexture=function(e,t,n){void 0!==e&&(t&&(this._boundUniforms[e]=t),n&&n.depthStencilTexture?this._setTexture(e,n,!1,!0):this._setTexture(e,null))},e.prototype._bindSamplerUniformToChannel=function(e,t){var n=this._boundUniforms[e];n._currentState!==t&&(this._gl.uniform1i(n,t),n._currentState=t)},e.prototype._getTextureWrapMode=function(t){switch(t){case e.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case e.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case e.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},e.prototype._setTexture=function(t,n,i,r){if(void 0===i&&(i=!1),void 0===r&&(r=!1),!n)return null!=this._boundTexturesCache[t]&&(this._activeChannel=t,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)),!1;if(n.video)this._activeChannel=t,n.update();else if(n.delayLoadState===e.DELAYLOADSTATE_NOTLOADED)return n.delayLoad(),!1;var o;o=r?n.depthStencilTexture:n.isReady()?n.getInternalTexture():n.isCube?this.emptyCubeTexture:n.is3D?this.emptyTexture3D:this.emptyTexture,!i&&o&&(o._associatedChannel=t);var a=!0;if(this._boundTexturesCache[t]===o&&(i||this._bindSamplerUniformToChannel(o._associatedChannel,t),a=!1),this._activeChannel=t,o&&o.isMultiview)a&&this._bindTextureDirectly(this._gl.TEXTURE_2D_ARRAY,o,i);else if(o&&o.is3D)a&&this._bindTextureDirectly(this._gl.TEXTURE_3D,o,i),o&&o._cachedWrapU!==n.wrapU&&(o._cachedWrapU=n.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(n.wrapU),o)),o&&o._cachedWrapV!==n.wrapV&&(o._cachedWrapV=n.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(n.wrapV),o)),o&&o._cachedWrapR!==n.wrapR&&(o._cachedWrapR=n.wrapR,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(n.wrapR),o)),this._setAnisotropicLevel(this._gl.TEXTURE_3D,n);else if(o&&o.isCube){if(a&&this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,o,i),o._cachedCoordinatesMode!==n.coordinatesMode){o._cachedCoordinatesMode=n.coordinatesMode;var s=n.coordinatesMode!==e.TEXTURE_CUBIC_MODE&&n.coordinatesMode!==e.TEXTURE_SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,s,o),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,s)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,n)}else a&&this._bindTextureDirectly(this._gl.TEXTURE_2D,o,i),o&&o._cachedWrapU!==n.wrapU&&(o._cachedWrapU=n.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(n.wrapU),o)),o&&o._cachedWrapV!==n.wrapV&&(o._cachedWrapV=n.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(n.wrapV),o)),this._setAnisotropicLevel(this._gl.TEXTURE_2D,n);return!0},e.prototype.setTextureArray=function(e,t,n){if(void 0!==e&&t){this._textureUnits&&this._textureUnits.length===n.length||(this._textureUnits=new Int32Array(n.length));for(var i=0;i=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1)}},e.prototype.releaseEffects=function(){for(var e in this._compiledEffects){var t=this._compiledEffects[e].getPipelineContext();this._deletePipelineContext(t)}this._compiledEffects={}},e.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop(),this.onNewSceneAddedObservable.clear();this.postProcesses.length;)this.postProcesses[0].dispose();for(this._emptyTexture&&(this._releaseTexture(this._emptyTexture),this._emptyTexture=null),this._emptyCubeTexture&&(this._releaseTexture(this._emptyCubeTexture),this._emptyCubeTexture=null),this._rescalePostProcess&&this._rescalePostProcess.dispose();this.scenes.length;)this.scenes[0].dispose();1===e.Instances.length&&e.audioEngine&&e.audioEngine.dispose(),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.disableVR(),g.a.IsWindowObjectExist()&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),this._renderingCanvas&&(this._renderingCanvas.removeEventListener("focus",this._onCanvasFocus),this._renderingCanvas.removeEventListener("blur",this._onCanvasBlur),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasPointerOut),this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange));var t=e.Instances.indexOf(this);t>=0&&e.Instances.splice(t,1),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._bindedRenderFunction=null,this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear(),h.a.ResetCache();for(var n=0,i=this._activeRequests;n-1?a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+i,e._webGLTexture,r):a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_2D,e._webGLTexture,r);var c=void 0!==e.type?this._getWebGLTextureType(e.type):a.UNSIGNED_BYTE;switch(c){case a.UNSIGNED_BYTE:o||(o=new Uint8Array(4*t*n)),c=a.UNSIGNED_BYTE;break;default:o||(o=new Float32Array(4*t*n)),c=a.FLOAT}return a.readPixels(0,0,t,n,a.RGBA,c,o),a.bindFramebuffer(a.FRAMEBUFFER,this._currentFramebuffer),o},e.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.TEXTURETYPE_FLOAT)},e.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(e.TEXTURETYPE_HALF_FLOAT)},e.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var 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(t){if(1===this._webGLVersion){switch(t){case e.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case e.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case e.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE}return this._gl.UNSIGNED_BYTE}switch(t){case e.TEXTURETYPE_BYTE:return this._gl.BYTE;case e.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case e.TEXTURETYPE_SHORT:return this._gl.SHORT;case e.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case e.TEXTURETYPE_INT:return this._gl.INT;case e.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case e.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case e.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case e.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},e.prototype._getInternalFormat=function(t){var n=this._gl.RGBA;switch(t){case e.TEXTUREFORMAT_ALPHA:n=this._gl.ALPHA;break;case e.TEXTUREFORMAT_LUMINANCE:n=this._gl.LUMINANCE;break;case e.TEXTUREFORMAT_LUMINANCE_ALPHA:n=this._gl.LUMINANCE_ALPHA;break;case e.TEXTUREFORMAT_RED:n=this._gl.RED;break;case e.TEXTUREFORMAT_RG:n=this._gl.RG;break;case e.TEXTUREFORMAT_RGB:n=this._gl.RGB;break;case e.TEXTUREFORMAT_RGBA:n=this._gl.RGBA}if(this._webGLVersion>1)switch(t){case e.TEXTUREFORMAT_RED_INTEGER:n=this._gl.RED_INTEGER;break;case e.TEXTUREFORMAT_RG_INTEGER:n=this._gl.RG_INTEGER;break;case e.TEXTUREFORMAT_RGB_INTEGER:n=this._gl.RGB_INTEGER;break;case e.TEXTUREFORMAT_RGBA_INTEGER:n=this._gl.RGBA_INTEGER}return n},e.prototype._getRGBABufferInternalSizedFormat=function(t,n){if(1===this._webGLVersion){if(void 0!==n)switch(n){case e.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case e.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case e.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA}return this._gl.RGBA}switch(t){case e.TEXTURETYPE_BYTE:switch(n){case e.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case e.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case e.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case e.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case e.TEXTURETYPE_UNSIGNED_BYTE:switch(n){case e.TEXTUREFORMAT_RED:return this._gl.R8;case e.TEXTUREFORMAT_RG:return this._gl.RG8;case e.TEXTUREFORMAT_RGB:return this._gl.RGB8;case e.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case e.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;case e.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case e.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case e.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA;default:return this._gl.RGBA8}case e.TEXTURETYPE_SHORT:switch(n){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case e.TEXTURETYPE_UNSIGNED_SHORT:switch(n){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case e.TEXTURETYPE_INT:switch(n){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case e.TEXTURETYPE_UNSIGNED_INTEGER:switch(n){case e.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case e.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case e.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case e.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case e.TEXTURETYPE_FLOAT:switch(n){case e.TEXTUREFORMAT_RED:return this._gl.R32F;case e.TEXTUREFORMAT_RG:return this._gl.RG32F;case e.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case e.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case e.TEXTURETYPE_HALF_FLOAT:switch(n){case e.TEXTUREFORMAT_RED:return this._gl.R16F;case e.TEXTUREFORMAT_RG:return this._gl.RG16F;case e.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case e.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(n){case e.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case e.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},e.prototype._getRGBAMultiSampleBufferFormat=function(t){return t===e.TEXTURETYPE_FLOAT?this._gl.RGBA32F:t===e.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},e.prototype._loadFile=function(e,t,n,i,r,o){var a=this,s=c.h.LoadFile(e,t,n,i,r,o);return this._activeRequests.push(s),s.onCompleteObservable.add((function(e){a._activeRequests.splice(a._activeRequests.indexOf(e),1)})),s},e.prototype._loadFileAsync=function(e,t,n){var i=this;return new Promise((function(r,o){i._loadFile(e,(function(e){r(e)}),void 0,t,n,(function(e,t){o(t)}))}))},e.isSupported=function(){try{var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},e.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"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.ALPHA_DISABLE=m.a.ALPHA_DISABLE,e.ALPHA_ADD=m.a.ALPHA_ADD,e.ALPHA_COMBINE=m.a.ALPHA_COMBINE,e.ALPHA_SUBTRACT=m.a.ALPHA_SUBTRACT,e.ALPHA_MULTIPLY=m.a.ALPHA_MULTIPLY,e.ALPHA_MAXIMIZED=m.a.ALPHA_MAXIMIZED,e.ALPHA_ONEONE=m.a.ALPHA_ONEONE,e.ALPHA_PREMULTIPLIED=m.a.ALPHA_PREMULTIPLIED,e.ALPHA_PREMULTIPLIED_PORTERDUFF=m.a.ALPHA_PREMULTIPLIED_PORTERDUFF,e.ALPHA_INTERPOLATE=m.a.ALPHA_INTERPOLATE,e.ALPHA_SCREENMODE=m.a.ALPHA_SCREENMODE,e.DELAYLOADSTATE_NONE=m.a.DELAYLOADSTATE_NONE,e.DELAYLOADSTATE_LOADED=m.a.DELAYLOADSTATE_LOADED,e.DELAYLOADSTATE_LOADING=m.a.DELAYLOADSTATE_LOADING,e.DELAYLOADSTATE_NOTLOADED=m.a.DELAYLOADSTATE_NOTLOADED,e.NEVER=m.a.NEVER,e.ALWAYS=m.a.ALWAYS,e.LESS=m.a.LESS,e.EQUAL=m.a.EQUAL,e.LEQUAL=m.a.LEQUAL,e.GREATER=m.a.GREATER,e.GEQUAL=m.a.GEQUAL,e.NOTEQUAL=m.a.NOTEQUAL,e.KEEP=m.a.KEEP,e.REPLACE=m.a.REPLACE,e.INCR=m.a.INCR,e.DECR=m.a.DECR,e.INVERT=m.a.INVERT,e.INCR_WRAP=m.a.INCR_WRAP,e.DECR_WRAP=m.a.DECR_WRAP,e.TEXTURE_CLAMP_ADDRESSMODE=m.a.TEXTURE_CLAMP_ADDRESSMODE,e.TEXTURE_WRAP_ADDRESSMODE=m.a.TEXTURE_WRAP_ADDRESSMODE,e.TEXTURE_MIRROR_ADDRESSMODE=m.a.TEXTURE_MIRROR_ADDRESSMODE,e.TEXTUREFORMAT_ALPHA=m.a.TEXTUREFORMAT_ALPHA,e.TEXTUREFORMAT_LUMINANCE=m.a.TEXTUREFORMAT_LUMINANCE,e.TEXTUREFORMAT_LUMINANCE_ALPHA=m.a.TEXTUREFORMAT_LUMINANCE_ALPHA,e.TEXTUREFORMAT_RGB=m.a.TEXTUREFORMAT_RGB,e.TEXTUREFORMAT_RGBA=m.a.TEXTUREFORMAT_RGBA,e.TEXTUREFORMAT_RED=m.a.TEXTUREFORMAT_RED,e.TEXTUREFORMAT_R=m.a.TEXTUREFORMAT_R,e.TEXTUREFORMAT_RG=m.a.TEXTUREFORMAT_RG,e.TEXTUREFORMAT_RED_INTEGER=m.a.TEXTUREFORMAT_RED_INTEGER,e.TEXTUREFORMAT_R_INTEGER=m.a.TEXTUREFORMAT_R_INTEGER,e.TEXTUREFORMAT_RG_INTEGER=m.a.TEXTUREFORMAT_RG_INTEGER,e.TEXTUREFORMAT_RGB_INTEGER=m.a.TEXTUREFORMAT_RGB_INTEGER,e.TEXTUREFORMAT_RGBA_INTEGER=m.a.TEXTUREFORMAT_RGBA_INTEGER,e.TEXTURETYPE_UNSIGNED_BYTE=m.a.TEXTURETYPE_UNSIGNED_BYTE,e.TEXTURETYPE_UNSIGNED_INT=m.a.TEXTURETYPE_UNSIGNED_INT,e.TEXTURETYPE_FLOAT=m.a.TEXTURETYPE_FLOAT,e.TEXTURETYPE_HALF_FLOAT=m.a.TEXTURETYPE_HALF_FLOAT,e.TEXTURETYPE_BYTE=m.a.TEXTURETYPE_BYTE,e.TEXTURETYPE_SHORT=m.a.TEXTURETYPE_SHORT,e.TEXTURETYPE_UNSIGNED_SHORT=m.a.TEXTURETYPE_UNSIGNED_SHORT,e.TEXTURETYPE_INT=m.a.TEXTURETYPE_INT,e.TEXTURETYPE_UNSIGNED_INTEGER=m.a.TEXTURETYPE_UNSIGNED_INTEGER,e.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=m.a.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4,e.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=m.a.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1,e.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=m.a.TEXTURETYPE_UNSIGNED_SHORT_5_6_5,e.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=m.a.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV,e.TEXTURETYPE_UNSIGNED_INT_24_8=m.a.TEXTURETYPE_UNSIGNED_INT_24_8,e.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=m.a.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV,e.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=m.a.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV,e.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=m.a.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV,e.TEXTURE_NEAREST_SAMPLINGMODE=m.a.TEXTURE_NEAREST_SAMPLINGMODE,e.TEXTURE_BILINEAR_SAMPLINGMODE=m.a.TEXTURE_BILINEAR_SAMPLINGMODE,e.TEXTURE_TRILINEAR_SAMPLINGMODE=m.a.TEXTURE_TRILINEAR_SAMPLINGMODE,e.TEXTURE_NEAREST_NEAREST_MIPLINEAR=m.a.TEXTURE_NEAREST_NEAREST_MIPLINEAR,e.TEXTURE_LINEAR_LINEAR_MIPNEAREST=m.a.TEXTURE_LINEAR_LINEAR_MIPNEAREST,e.TEXTURE_LINEAR_LINEAR_MIPLINEAR=m.a.TEXTURE_LINEAR_LINEAR_MIPLINEAR,e.TEXTURE_NEAREST_NEAREST_MIPNEAREST=m.a.TEXTURE_NEAREST_NEAREST_MIPNEAREST,e.TEXTURE_NEAREST_LINEAR_MIPNEAREST=m.a.TEXTURE_NEAREST_LINEAR_MIPNEAREST,e.TEXTURE_NEAREST_LINEAR_MIPLINEAR=m.a.TEXTURE_NEAREST_LINEAR_MIPLINEAR,e.TEXTURE_NEAREST_LINEAR=m.a.TEXTURE_NEAREST_LINEAR,e.TEXTURE_NEAREST_NEAREST=m.a.TEXTURE_NEAREST_NEAREST,e.TEXTURE_LINEAR_NEAREST_MIPNEAREST=m.a.TEXTURE_LINEAR_NEAREST_MIPNEAREST,e.TEXTURE_LINEAR_NEAREST_MIPLINEAR=m.a.TEXTURE_LINEAR_NEAREST_MIPLINEAR,e.TEXTURE_LINEAR_LINEAR=m.a.TEXTURE_LINEAR_LINEAR,e.TEXTURE_LINEAR_NEAREST=m.a.TEXTURE_LINEAR_NEAREST,e.TEXTURE_EXPLICIT_MODE=m.a.TEXTURE_EXPLICIT_MODE,e.TEXTURE_SPHERICAL_MODE=m.a.TEXTURE_SPHERICAL_MODE,e.TEXTURE_PLANAR_MODE=m.a.TEXTURE_PLANAR_MODE,e.TEXTURE_CUBIC_MODE=m.a.TEXTURE_CUBIC_MODE,e.TEXTURE_PROJECTION_MODE=m.a.TEXTURE_PROJECTION_MODE,e.TEXTURE_SKYBOX_MODE=m.a.TEXTURE_SKYBOX_MODE,e.TEXTURE_INVCUBIC_MODE=m.a.TEXTURE_INVCUBIC_MODE,e.TEXTURE_EQUIRECTANGULAR_MODE=m.a.TEXTURE_EQUIRECTANGULAR_MODE,e.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=m.a.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,e.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=m.a.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,e.SCALEMODE_FLOOR=m.a.SCALEMODE_FLOOR,e.SCALEMODE_NEAREST=m.a.SCALEMODE_NEAREST,e.SCALEMODE_CEILING=m.a.SCALEMODE_CEILING,e.CollisionsEpsilon=.001,e._RescalePostProcessFactory=null,e}()},function(e,t,n){"use strict";n.r(t);var i=n(43),r=n(7),o=n(0),a=n(26),s=function(){function e(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new r.c,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger:this.trigger=e,this._nextActiveAction=this,this._condition=t}return e.prototype._prepare=function(){},e.prototype.getTriggerParameter=function(){return this._triggerParameter},e.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,n=this._actionManager.getScene().getRenderId();if(t._evaluationId===n){if(!t._currentResult)return}else{if(t._evaluationId=n,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(e),this.skipToNextActiveAction()},e.prototype.execute=function(e){},e.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},e.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(e){},e.prototype._serialize=function(e,t){var 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 o.w?e.x+", "+e.y:e instanceof o.x?e.x+", "+e.y+", "+e.z:e instanceof o.e?e.r+", "+e.g+", "+e.b:e instanceof o.f?e.r+", "+e.g+", "+e.b+", "+e.a:e},e._GetTargetProperty=function(e){return{name:"target",targetType:e._isMesh?"MeshProperties":e._isLight?"LightProperties":e._isCamera?"CameraProperties":"SceneProperties",value:e._isScene?"Scene":e.name}},e}();a.a.RegisteredTypes["BABYLON.Action"]=s;var c=n(51),l=n(1),u=function(){function e(e){this._actionManager=e}return e.prototype.isValid=function(){return!0},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(){},e.prototype._serialize=function(e){return{type:2,children:[],name:e.name,properties:e.properties}},e}(),h=function(e){function t(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 l.d(t,e),Object.defineProperty(t,"IsEqual",{get:function(){return t._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsDifferent",{get:function(){return t._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsGreater",{get:function(){return t._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(t,"IsLesser",{get:function(){return t._IsLesser},enumerable:!0,configurable:!0}),t.prototype.isValid=function(){switch(this.operator){case t.IsGreater:return this._effectiveTarget[this._property]>this.value;case t.IsLesser:return this._effectiveTarget[this._property]-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:!0,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:!0,configurable:!0}),t.prototype.registerAction=function(e){return e.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(p.a.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),t.Triggers[e.trigger]?t.Triggers[e.trigger]++:t.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)},t.prototype.unregisterAction=function(e){var 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],delete e._actionManager,!0)},t.prototype.processTrigger=function(e,n){for(var i=0;i0;if(2===e.type?f.push(r):f.push(n),g){for(var _=new Array,v=0;v0){var p=f.properties[0].value,m=null===f.properties[0].targetType?p:i.getMeshByName(p);m._meshId&&(m.mesh=i.getMeshByID(m._meshId)),d={trigger:t[f.name],parameter:m}}else d=t[f.name];for(var g=0;g=.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}(),k=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t}(F),B=function(e){function t(t){void 0===t&&(t=1);var n=e.call(this)||this;return n.amplitude=t,n}return l.d(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t}(F),z=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 l.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),l=c+1,u=(1-Math.pow(n,c))/(r*o),h=.5*(u+(1-Math.pow(n,l))/(r*o)),d=e-h,f=h-u;return-Math.pow(1/n,t-c)/(f*f)*(d-f)*(d+f)},t}(F),V=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e*e},t}(F),U=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 l.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}(F),G=function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.exponent=t,n}return l.d(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t}(F),H=function(e){function t(t){void 0===t&&(t=2);var n=e.call(this)||this;return n.power=t,n}return l.d(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t}(F),j=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e},t}(F),W=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t}(F),X=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t}(F),Y=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t}(F),K=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 l.d(t,e),t.prototype.easeInCore=function(e){return o.d.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},t}(F),Q=n(158),q=n(164),Z=n(109),J=n(116),$=n(95),ee=n(10),te=function(){function e(e){this.SMOOTHING=.75,this.FFT_SIZE=512,this.BARGRAPHAMPLITUDE=256,this.DEBUGCANVASPOS={x:20,y:20},this.DEBUGCANVASSIZE={width:320,height:200},this._scene=e,this._audioEngine=ee.b.audioEngine,this._audioEngine.canUseWebAudio&&this._audioEngine.audioContext&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))}return e.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},e.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},e.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},e.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},e.prototype.drawDebugCanvas=function(){var e=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){e.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc&&this._debugCanvasContext)){var t=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var n=0;n0?e.activeCameras[0]:e.activeCamera)&&n.audioContext){n.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var i,r=o.j.Invert(t.getViewMatrix()),a=o.x.TransformNormal(new o.x(0,0,-1),r);for(a.normalize(),isNaN(a.x)||isNaN(a.y)||isNaN(a.z)||n.audioContext.listener.setOrientation(a.x,a.y,a.z,0,1,0),i=0;i0},enumerable:!0,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!==le.a.POINTERDOWN?e.type===le.a.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=ue.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._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=ue.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}(),de=function(){function e(){this.transitionDuration=450,this.lowerRadiusTransitionRange=2,this.upperRadiusTransitionRange=-2,this._autoTransitionRange=!1,this._radiusIsAnimating=!1,this._radiusBounceTransition=null,this._animatables=new Array}return Object.defineProperty(e.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var t=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var 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:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var t=this;this._attachedCamera=e,this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._attachedCamera&&(t._isRadiusAtLimit(t._attachedCamera.lowerRadiusLimit)&&t._applyBoundRadiusAnimation(t.lowerRadiusTransitionRange),t._isRadiusAtLimit(t._attachedCamera.upperRadiusLimit)&&t._applyBoundRadiusAnimation(t.upperRadiusTransitionRange))}))},e.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},e.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},e.prototype._applyBoundRadiusAnimation=function(t){var n=this;if(this._attachedCamera){this._radiusBounceTransition||(e.EasingFunction.setEasingMode(e.EasingMode),this._radiusBounceTransition=w.a.CreateAnimation("radius",w.a.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=w.a.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 B(.3),e.EasingMode=F.EASINGMODE_EASEOUT,e}(),fe=n(5),pe=function(){function e(){this._mode=e.FitFrustumSidesMode,this._radiusScale=1,this._positionScale=.5,this._defaultElevation=.3,this._elevationReturnTime=1500,this._elevationReturnWaitTime=1e3,this._zoomStopsAnimation=!1,this._framingTime=1500,this.autoCorrectCameraLimitsAndSensibility=!0,this._isPointerDown=!1,this._lastInteractionTime=-1/0,this._animatables=new Array,this._betaIsAnimating=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"Framing"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var n=this;this._attachedCamera=t;var i=this._attachedCamera.getScene();e.EasingFunction.setEasingMode(e.EasingMode),this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==le.a.POINTERDOWN?e.type===le.a.POINTERUP&&(n._isPointerDown=!1):n._isPointerDown=!0})),this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){e&&n.zoomOnMesh(e)})),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 o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new o.x(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),a=0;al.upperRadiusLimit?l.upperRadiusLimit:c),c):0},e.prototype._maintainCameraAboveGround=function(){var t=this;if(!(this._elevationReturnTime<0)){var n=ue.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=w.a.CreateAnimation("beta",w.a.ANIMATIONTYPE_FLOAT,60,e.EasingFunction));var o=w.a.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 o.w.Zero();var t=e.getScene().getEngine().getAspectRatio(e),n=Math.tan(e.fov/2),i=n*t;return new o.w(i,n)},e.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},e.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=ue.a.Now,this.stopAllAnimations(),this._clearAnimationLocks())},e.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0]&&(this._animatables[0].onAnimationEnd=null,this._animatables[0].stop()),this._animatables.shift()},Object.defineProperty(e.prototype,"isUserIsMoving",{get:function(){return!!this._attachedCamera&&(0!==this._attachedCamera.inertialAlphaOffset||0!==this._attachedCamera.inertialBetaOffset||0!==this._attachedCamera.inertialRadiusOffset||0!==this._attachedCamera.inertialPanningX||0!==this._attachedCamera.inertialPanningY||this._isPointerDown)},enumerable:!0,configurable:!0}),e.EasingFunction=new G,e.EasingMode=F.EASINGMODE_EASEINOUT,e.IgnoreBoundsSizeMode=0,e.FitFrustumSidesMode=1,e}(),me=function(e,t,n,i){void 0===t&&(t=new o.x),void 0===n&&(n=0),void 0===i&&(i=!1),this.direction=e,this.rotatedDirection=t,this.diff=n,this.ignore=i},ge=function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new me(o.x.Up()),new me(o.x.Down()),new me(o.x.Left()),new me(o.x.Right()),new me(o.x.Forward()),new me(o.x.Forward().scaleInPlace(-1))],this._tmpMatrix=new o.j,this._tmpVector=new o.x,this._zeroVector=o.x.Zero(),this._lookAtTmpMatrix=new o.j}return e.prototype.init=function(){},e.prototype._closestFace=function(e){var t=this;return this._faceVectors.forEach((function(n){t._target.rotationQuaternion||(t._target.rotationQuaternion=o.q.RotationYawPitchRoll(t._target.rotation.y,t._target.rotation.x,t._target.rotation.z)),t._target.rotationQuaternion.toRotationMatrix(t._tmpMatrix),o.x.TransformCoordinatesToRef(n.direction,t._tmpMatrix,n.rotatedDirection),n.diff=o.x.GetAngleBetweenVectors(n.rotatedDirection,e,o.x.Cross(n.rotatedDirection,e))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore?e:e.diffl.x)return!1}else if(r=1/this.direction.x,o=(c.x-this.origin.x)*r,(a=(l.x-this.origin.x)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.yl.y)return!1}else if(r=1/this.direction.y,o=(c.y-this.origin.y)*r,(a=(l.y-this.origin.y)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.zl.z)return!1}else if(r=1/this.direction.z,o=(c.z-this.origin.z)*r,(a=(l.z-this.origin.z)*r)===-1/0&&(a=1/0),o>a&&(s=o,o=a,a=s),(u=Math.max(o,u))>(h=Math.min(a,h)))return!1;return!0},e.prototype.intersectsBox=function(e,t){return void 0===t&&(t=0),this.intersectsBoxMinMax(e.minimum,e.maximum,t)},e.prototype.intersectsSphere=function(e,t){void 0===t&&(t=0);var 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 r=e.TmpVector3[0],a=e.TmpVector3[1],s=e.TmpVector3[2],c=e.TmpVector3[3],l=e.TmpVector3[4];n.subtractToRef(t,r),i.subtractToRef(t,a),o.x.CrossToRef(this.direction,a,s);var u=o.x.Dot(r,s);if(0===u)return null;var h=1/u;this.origin.subtractToRef(t,c);var d=o.x.Dot(c,s)*h;if(d<0||d>1)return null;o.x.CrossToRef(c,r,l);var f=o.x.Dot(this.direction,l)*h;if(f<0||d+f>1)return null;var p=o.x.Dot(a,l)*h;return p>this.length?null:new xe.a(d,f,p)},e.prototype.intersectsPlane=function(e){var t,n=o.x.Dot(e.normal,this.direction);if(Math.abs(n)<9.99999997475243e-7)return null;var i=o.x.Dot(e.normal,this.origin);return(t=(-e.d-i)/n)<0?t<-9.99999997475243e-7?null:0:t},e.prototype.intersectsMesh=function(t,n){var i=o.t.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 r=this.origin,a=o.t.Vector3[0],s=o.t.Vector3[1],c=o.t.Vector3[2],l=o.t.Vector3[3];n.subtractToRef(t,a),this.direction.scaleToRef(e.rayl,c),r.addToRef(c,s),t.subtractToRef(r,l);var u,h,d,f,p=o.x.Dot(a,a),m=o.x.Dot(a,c),g=o.x.Dot(c,c),_=o.x.Dot(a,l),v=o.x.Dot(c,l),b=p*g-m*m,y=b,x=b;by&&(h=y,f=v+m,x=g)),f<0?(f=0,-_<0?h=0:-_>p?h=y:(h=-_,y=p)):f>x&&(f=x,-_+m<0?h=0:-_+m>p?h=y:(h=-_+m,y=p)),u=Math.abs(h)0&&d<=this.length&&T.lengthSquared()=r.distance))&&(r=c,n)))break}return r||new ye.a},ae.a.prototype._internalMultiPick=function(e,t,n){if(!ye.a)return null;for(var i=new Array,r=0;r1)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(e.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var n=this;this._scene=t.getScene(),this._attachedNode=t,e._planeScene||(this._debugMode?e._planeScene=this._scene:(e._planeScene=new ae.a(this._scene.getEngine(),{virtual:!0}),e._planeScene.detachControl(),this._scene.onDisposeObservable.addOnce((function(){e._planeScene.dispose(),e._planeScene=null})))),this._dragPlane=ve.a.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,e._planeScene,!1,ve.a.DOUBLESIDE),this.lastDragPosition=new o.x(0,0,0);this._pointerObserver=this._scene.onPointerObservable.add((function(t,i){var r;if(n.enabled)if(t.type==le.a.POINTERDOWN)!n.dragging&&t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh&&t.pickInfo.pickedPoint&&t.pickInfo.ray&&(r=t.pickInfo.pickedMesh,n._attachedNode==r||r.isDescendantOf(n._attachedNode))&&n._startDrag(t.event.pointerId,t.pickInfo.ray,t.pickInfo.pickedPoint);else if(t.type==le.a.POINTERUP)n.currentDraggingPointerID==t.event.pointerId&&n.releaseDrag();else if(t.type==le.a.POINTERMOVE){var a=t.event.pointerId;n.currentDraggingPointerID===e._AnyMouseID&&a!==e._AnyMouseID&&"mouse"==t.event.pointerType&&(n._lastPointerRay[n.currentDraggingPointerID]&&(n._lastPointerRay[a]=n._lastPointerRay[n.currentDraggingPointerID],delete n._lastPointerRay[n.currentDraggingPointerID]),n.currentDraggingPointerID=a),n._lastPointerRay[a]||(n._lastPointerRay[a]=new Ee(new o.x,new o.x)),t.pickInfo&&t.pickInfo.ray&&(n._lastPointerRay[a].origin.copyFrom(t.pickInfo.ray.origin),n._lastPointerRay[a].direction.copyFrom(t.pickInfo.ray.direction),n.currentDraggingPointerID==a&&n.dragging&&n._moveDrag(t.pickInfo.ray))}})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){n._moving&&n.moveAttached&&(Te._RemoveAndStorePivotPoint(n._attachedNode),n._targetPosition.subtractToRef(n._attachedNode.absolutePosition,n._tmpVector),n._tmpVector.scaleInPlace(n.dragDeltaRatio),n._attachedNode.getAbsolutePosition().addToRef(n._tmpVector,n._tmpVector),n.validateDrag(n._tmpVector)&&n._attachedNode.setAbsolutePosition(n._tmpVector),Te._RestorePivotPoint(n._attachedNode))}))},e.prototype.releaseDrag=function(){this.dragging=!1,this.onDragEndObservable.notifyObservers({dragPlanePoint:this.lastDragPosition,pointerId:this.currentDraggingPointerID}),this.currentDraggingPointerID=-1,this._moving=!1,this.detachCameraControls&&this._attachedElement&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&this._scene.activeCamera.attachControl(this._attachedElement,!0)},e.prototype.startDrag=function(t,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){Te._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.absolutePosition),this.detachCameraControls&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedElement?(this._attachedElement=this._scene.activeCamera.inputs.attachedElement,this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement)):this._attachedElement=null)),Te._RestorePivotPoint(this._attachedNode)}},e.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){this.updateDragPlane&&this._updateDragPlanePosition(e,t);var n=0;this._options.dragAxis?(o.x.TransformCoordinatesToRef(this._options.dragAxis,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),n=o.x.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)}},e.prototype._pickWithRayOnDragPlane=function(t){var n=this;if(!t)return null;var i=Math.acos(o.x.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*o.x.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var r=o.x.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 a=e._planeScene.pickWithRay(t,(function(e){return e==n._dragPlane}));return a&&a.hit&&a.pickedMesh&&a.pickedPoint?a.pickedPoint:null},e.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrienationForDragging?o.x.TransformCoordinatesToRef(this._options.dragAxis,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragAxis),this._pointA.addToRef(this._localAxis,this._pointB),e.origin.subtractToRef(this._pointA,this._pointC),this._pointA.addToRef(this._pointC.normalize(),this._pointC),this._pointB.subtractToRef(this._pointA,this._lineA),this._pointC.subtractToRef(this._pointA,this._lineB),o.x.CrossToRef(this._lineA,this._lineB,this._lookAt),o.x.CrossToRef(this._lineA,this._lookAt,this._lookAt),this._lookAt.normalize(),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrienationForDragging?o.x.TransformCoordinatesToRef(this._options.dragPlaneNormal,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.addToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(e.origin)),this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition),this._dragPlane.computeWorldMatrix(!0)},e.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver),this.releaseDrag()},e._AnyMouseID=-2,e}(),Pe=function(){function e(){this._startDistance=0,this._initialScale=new o.x(0,0,0),this._targetScale=new o.x(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new Ae({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new Ae({}),this._dragBehaviorB.moveAttached=!1}return Object.defineProperty(e.prototype,"name",{get:function(){return"MultiPointerScale"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype._getCurrentDistance=function(){return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length()},e.prototype.attach=function(e){var t=this;this._ownerNode=e,this._dragBehaviorA.onDragStartObservable.add((function(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}(),Me=n(28),Oe=function(){function e(){this._sceneRenderObserver=null,this._targetPosition=new o.x(0,0,0),this._moving=!1,this._startingOrientation=new o.q,this.zDragFactor=3,this.rotateDraggedObject=!0,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new r.c,this.onDragEndObservable=new r.c}return Object.defineProperty(e.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(t){var n=this;this._ownerNode=t,this._scene=this._ownerNode.getScene(),e._virtualScene||(e._virtualScene=new ae.a(this._scene.getEngine()),e._virtualScene.detachControl(),this._scene.getEngine().scenes.pop());var i=null,r=new o.x(0,0,0);this._virtualOriginMesh=new Me.a("",e._virtualScene),this._virtualOriginMesh.rotationQuaternion=new o.q,this._virtualDragMesh=new Me.a("",e._virtualScene),this._virtualDragMesh.rotationQuaternion=new o.q;var a=null;this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){if(e.type==le.a.POINTERDOWN){if(!n.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(h=e.pickInfo.pickedMesh,n._ownerNode==h||h.isDescendantOf(n._ownerNode))){n._scene.activeCamera&&n._scene.activeCamera.cameraRigMode==Ce.a.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(n._scene.activeCamera.globalPosition),i=n._ownerNode,Te._RemoveAndStorePivotPoint(i),r.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),n._virtualOriginMesh.removeChild(n._virtualDragMesh),i.computeWorldMatrix(),n._virtualDragMesh.position.copyFrom(i.absolutePosition),i.rotationQuaternion||(i.rotationQuaternion=o.q.RotationYawPitchRoll(i.rotation.y,i.rotation.x,i.rotation.z));var s=i.parent;i.setParent(null),n._virtualDragMesh.rotationQuaternion.copyFrom(i.rotationQuaternion),i.setParent(s),n._virtualOriginMesh.addChild(n._virtualDragMesh),n._targetPosition.copyFrom(n._virtualDragMesh.absolutePosition),n.dragging=!0,n.currentDraggingPointerID=e.event.pointerId,n.detachCameraControls&&n._scene.activeCamera&&!n._scene.activeCamera.leftCamera&&(n._scene.activeCamera.inputs.attachedElement?(a=n._scene.activeCamera.inputs.attachedElement,n._scene.activeCamera.detachControl(n._scene.activeCamera.inputs.attachedElement)):a=null),Te._RestorePivotPoint(i),n.onDragStartObservable.notifyObservers({})}}else if(e.type==le.a.POINTERUP)n.currentDraggingPointerID==e.event.pointerId&&(n.dragging=!1,n._moving=!1,n.currentDraggingPointerID=-1,i=null,n._virtualOriginMesh.removeChild(n._virtualDragMesh),n.detachCameraControls&&a&&n._scene.activeCamera&&!n._scene.activeCamera.leftCamera&&n._scene.activeCamera.attachControl(a,!0),n.onDragEndObservable.notifyObservers({}));else if(e.type==le.a.POINTERMOVE&&n.currentDraggingPointerID==e.event.pointerId&&n.dragging&&e.pickInfo&&e.pickInfo.ray&&i){var c=n.zDragFactor;n._scene.activeCamera&&n._scene.activeCamera.cameraRigMode==Ce.a.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(n._scene.activeCamera.globalPosition),c=0);var l=e.pickInfo.ray.origin.subtract(r);r.copyFrom(e.pickInfo.ray.origin);var u=-o.x.Dot(l,e.pickInfo.ray.direction);n._virtualOriginMesh.addChild(n._virtualDragMesh),n._virtualDragMesh.position.z-=n._virtualDragMesh.position.z<1?u*n.zDragFactor:u*c*n._virtualDragMesh.position.z,n._virtualDragMesh.position.z<0&&(n._virtualDragMesh.position.z=0),n._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),n._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.add(e.pickInfo.ray.direction)),n._virtualOriginMesh.removeChild(n._virtualDragMesh),n._targetPosition.copyFrom(n._virtualDragMesh.absolutePosition),i.parent&&o.x.TransformCoordinatesToRef(n._targetPosition,o.j.Invert(i.parent.getWorldMatrix()),n._targetPosition),n._moving||n._startingOrientation.copyFrom(n._virtualDragMesh.rotationQuaternion),n._moving=!0}var h}));var s=new o.q;this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(n.dragging&&n._moving&&i){if(Te._RemoveAndStorePivotPoint(i),i.position.addInPlace(n._targetPosition.subtract(i.position).scale(n.dragDeltaRatio)),n.rotateDraggedObject){s.copyFrom(n._startingOrientation),s.x=-s.x,s.y=-s.y,s.z=-s.z,n._virtualDragMesh.rotationQuaternion.multiplyToRef(s,s),o.q.RotationYawPitchRollToRef(s.toEulerAngles("xyz").y,0,0,s),s.multiplyToRef(n._startingOrientation,s);var e=i.parent;(!e||e.scaling&&!e.scaling.isNonUniformWithinEpsilon(.001))&&(i.setParent(null),o.q.SlerpToRef(i.rotationQuaternion,s,n.dragDeltaRatio,i.rotationQuaternion),i.setParent(e))}Te._RestorePivotPoint(i)}}))},e.prototype.detach=function(){this._scene&&this._scene.onPointerObservable.remove(this._pointerObserver),this._ownerNode&&this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),this._virtualOriginMesh&&this._virtualOriginMesh.dispose(),this._virtualDragMesh&&this._virtualDragMesh.dispose(),this.onDragEndObservable.clear(),this.onDragStartObservable.clear()},e}(),Re=n(79),we=function(){function e(e,t,n){if(this.targetPosition=o.x.Zero(),this.poleTargetPosition=o.x.Zero(),this.poleTargetLocalOffset=o.x.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=o.q.Identity(),this._bone1Mat=o.j.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=o.x.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var 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(),a=this._bone2.getScale();this._bone1Length=this._bone1.length*r.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*a.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(e),c=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=o.x.Distance(s,c),this._bone2Length=o.x.Distance(c,l)}this._bone1.getRotationMatrixToRef(o.s.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:!0,configurable:!0}),e.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,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],a=e._tmpMats[1];this.targetMesh&&n.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,i):this.poleTargetMesh&&o.x.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),i);var s=e._tmpVecs[0],c=e._tmpVecs[1],l=e._tmpVecs[2],u=e._tmpVecs[3],h=e._tmpVecs[4],d=e._tmpQuat;t.getAbsolutePositionToRef(this.mesh,s),i.subtractToRef(s,h),0==h.x&&0==h.y&&0==h.z?h.y=1:h.normalize(),n.subtractToRef(s,u),u.normalize(),o.x.CrossToRef(u,h,c),c.normalize(),o.x.CrossToRef(u,c,l),l.normalize(),o.j.FromXYZAxesToRef(l,u,c,r);var f=this._bone1Length,p=this._bone2Length,m=o.x.Distance(s,n);this._maxReach>0&&(m=Math.min(this._maxReach,m));var g=(p*p+m*m-f*f)/(2*p*m),_=(m*m+f*f-p*p)/(2*m*f);g>1&&(g=1),_>1&&(_=1),g<-1&&(g=-1),_<-1&&(_=-1);var v=Math.acos(g),b=Math.acos(_),y=-v-b;if(this._rightHandedSystem)o.j.RotationYawPitchRollToRef(0,0,this._adjustRoll,a),a.multiplyToRef(r,r),o.j.RotationAxisToRef(this._bendAxis,b,a),a.multiplyToRef(r,r);else{var x=e._tmpVecs[5];x.copyFrom(this._bendAxis),x.x*=-1,o.j.RotationAxisToRef(x,-b,a),a.multiplyToRef(r,r)}this.poleAngle&&(o.j.RotationAxisToRef(u,this.poleAngle,a),r.multiplyToRef(a,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||o.q.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),o.q.FromRotationMatrixToRef(r,d),o.q.SlerpToRef(this._bone1Quat,d,this.slerpAmount,this._bone1Quat),y=this._bone2Ang*(1-this.slerpAmount)+y*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,o.s.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,o.s.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,y,o.s.LOCAL),this._bone2Ang=y}},e._tmpVecs=[o.x.Zero(),o.x.Zero(),o.x.Zero(),o.x.Zero(),o.x.Zero(),o.x.Zero()],e._tmpQuat=o.q.Identity(),e._tmpMats=[o.j.Identity(),o.j.Identity()],e}(),Ie=function(){function e(e,t,n,i){if(this.upAxis=o.x.Up(),this.upAxisSpace=o.s.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=o.q.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=o.x.Forward(),this.mesh=e,this.bone=t,this.target=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=o.c.Y,a=o.c.X;null!=i.yawAxis&&(r=i.yawAxis.clone()).normalize(),null!=i.pitchAxis&&(a=i.pitchAxis.clone()).normalize();var s=o.x.Cross(a,r);this._transformYawPitch=o.j.Identity(),o.j.FromXYZAxesToRef(a,r,s,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=o.s.BONE||(this.upAxisSpace=o.s.LOCAL)}return Object.defineProperty(e.prototype,"minYaw",{get:function(){return this._minYaw},set:function(e){this._minYaw=e,this._minYawSin=Math.sin(e),this._minYawCos=Math.cos(e),null!=this._maxYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxYaw",{get:function(){return this._maxYaw},set:function(e){this._maxYaw=e,this._maxYawSin=Math.sin(e),this._maxYawCos=Math.cos(e),null!=this._minYaw&&(this._midYawConstraint=.5*this._getAngleDiff(this._minYaw,this._maxYaw)+this._minYaw,this._yawRange=this._maxYaw-this._minYaw)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),e.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var t=this.bone,n=e._tmpVecs[0];t.getAbsolutePositionToRef(this.mesh,n);var i=this.target,r=e._tmpMats[0],a=e._tmpMats[1],s=this.mesh,c=t.getParent(),l=e._tmpVecs[1];l.copyFrom(this.upAxis),this.upAxisSpace==o.s.BONE&&c?(this._transformYawPitch&&o.x.TransformCoordinatesToRef(l,this._transformYawPitchInv,l),c.getDirectionToRef(l,this.mesh,l)):this.upAxisSpace==o.s.LOCAL&&(s.getDirectionToRef(l,l),1==s.scaling.x&&1==s.scaling.y&&1==s.scaling.z||l.normalize());var u=!1,h=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(u=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(h=!0),u||h){var d=e._tmpMats[2],f=e._tmpMats[3];if(this.upAxisSpace==o.s.BONE&&1==l.y&&c)c.getRotationMatrixToRef(o.s.WORLD,this.mesh,d);else if(this.upAxisSpace!=o.s.LOCAL||1!=l.y||c){(m=e._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&o.x.TransformCoordinatesToRef(m,this._transformYawPitchInv,m),c?c.getDirectionToRef(m,this.mesh,m):s.getDirectionToRef(m,m);var p=o.x.Cross(l,m);p.normalize();var m=o.x.Cross(p,l);o.j.FromXYZAxesToRef(p,l,m,d)}else d.copyFrom(s.getWorldMatrix());d.invertToRef(f);var g=null;if(h){var _=e._tmpVecs[3];i.subtractToRef(n,_),o.x.TransformCoordinatesToRef(_,f,_),g=Math.sqrt(_.x*_.x+_.z*_.z);var v=Math.atan2(_.y,g),b=v;v>this._maxPitch?(_.y=this._maxPitchTan*g,b=this._maxPitch):vthis._maxYaw||yMath.PI?this._isAngleBetween(y,this._maxYaw,this._midYawConstraint)?(_.z=this._maxYawCos*g,_.x=this._maxYawSin*g,x=this._maxYaw):this._isAngleBetween(y,this._midYawConstraint,this._minYaw)&&(_.z=this._minYawCos*g,_.x=this._minYawSin*g,x=this._minYaw):y>this._maxYaw?(_.z=this._maxYawCos*g,_.x=this._maxYawSin*g,x=this._maxYaw):yMath.PI){var C=e._tmpVecs[8];C.copyFrom(o.c.Z),this._transformYawPitch&&o.x.TransformCoordinatesToRef(C,this._transformYawPitchInv,C);var E=e._tmpMats[4];this._boneQuat.toRotationMatrix(E),this.mesh.getWorldMatrix().multiplyToRef(E,E),o.x.TransformCoordinatesToRef(C,E,C),o.x.TransformCoordinatesToRef(C,f,C);var T=Math.atan2(C.x,C.z);if(this._getAngleBetween(T,y)>this._getAngleBetween(T,this._midYawConstraint)){null==g&&(g=Math.sqrt(_.x*_.x+_.z*_.z));var S=this._getAngleBetween(T,this._maxYaw);this._getAngleBetween(T,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&&e=2&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),this.browserGamepad.axes.length>=4&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(e.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!0,configurable:!0}),e.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},e.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(e.prototype,"leftStick",{get:function(){return this._leftStick},set:function(e){!this._onleftstickchanged||this._leftStick.x===e.x&&this._leftStick.y===e.y||this._onleftstickchanged(e),this._leftStick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightStick",{get:function(){return this._rightStick},set:function(e){!this._onrightstickchanged||this._rightStick.x===e.x&&this._rightStick.y===e.y||this._onrightstickchanged(e),this._rightStick=e},enumerable:!0,configurable:!0}),e.prototype.update=function(){this._leftStick&&(this.leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]},this._invertLeftStickY&&(this.leftStick.y*=-1)),this._rightStick&&(this.rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})},e.prototype.dispose=function(){},e.GAMEPAD=0,e.GENERIC=1,e.XBOX=2,e.POSE_ENABLED=3,e}(),Be=function(e){function t(t,n,i){var o=e.call(this,t,n,i)||this;return o.onButtonDownObservable=new r.c,o.onButtonUpObservable=new r.c,o.type=ke.GENERIC,o._buttons=new Array(i.buttons.length),o}return l.d(t,e),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype._setButtonValue=function(e,t,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;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"},l.c([Object(De.c)()],e.prototype,"gamepadRotationSensibility",void 0),l.c([Object(De.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();Ne.a.ArcRotateCameraGamepadInput=ze;var Ve=n(64),Ue=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0,this.angularSpeed=.01,this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var i,r=e.event;r.metaKey||(e.type===Ve.a.KEYDOWN?(n._ctrlPressed=r.ctrlKey,n._altPressed=r.altKey,(-1!==n.keysUp.indexOf(r.keyCode)||-1!==n.keysDown.indexOf(r.keyCode)||-1!==n.keysLeft.indexOf(r.keyCode)||-1!==n.keysRight.indexOf(r.keyCode)||-1!==n.keysReset.indexOf(r.keyCode))&&(-1===(i=n._keys.indexOf(r.keyCode))&&n._keys.push(r.keyCode),r.preventDefault&&(t||r.preventDefault()))):-1===n.keysUp.indexOf(r.keyCode)&&-1===n.keysDown.indexOf(r.keyCode)&&-1===n.keysLeft.indexOf(r.keyCode)&&-1===n.keysRight.indexOf(r.keyCode)&&-1===n.keysReset.indexOf(r.keyCode)||((i=n._keys.indexOf(r.keyCode))>=0&&n._keys.splice(i,1),r.preventDefault&&(t||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,t){var n=this;this._wheel=function(e,i){if(e.type===le.a.POINTERWHEEL){var r=e.event,o=0,a=r;if(a.wheelDelta)if(n.wheelDeltaPercentage){if((o=n.computeDeltaFromMouseWheelLegacyEvent(a,n.camera.radius))>0){for(var s=n.camera.radius,c=n.camera.inertialRadiusOffset+o,l=0;l<20&&Math.abs(c)>.001;l++)s-=c,c*=n.camera.inertia;s=Ge.a.Clamp(s,0,Number.MAX_VALUE),o=n.computeDeltaFromMouseWheelLegacyEvent(a,s)}}else o=a.wheelDelta/(40*n.wheelPrecision);else o=-(r.deltaY||r.detail)/n.wheelPrecision;o&&(n.camera.inertialRadiusOffset+=o),r.preventDefault&&(t||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,le.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},l.c([Object(De.c)()],e.prototype,"wheelPrecision",void 0),l.c([Object(De.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();Ne.a.ArcRotateCameraMouseWheelInput=He;var je=function(){function e(){this.buttons=[0,1,2]}return e.prototype.attachControl=function(e,t){var n=this,i=this.camera.getEngine(),r=0,o=null;this.pointA=null,this.pointB=null,this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0,this._pointerInput=function(a,s){var c=a.event,l="touch"===c.pointerType;if(!i.isInVRExclusivePointerMode&&(a.type===le.a.POINTERMOVE||-1!==n.buttons.indexOf(c.button))){var u=c.srcElement||c.target;if(n._altKey=c.altKey,n._ctrlKey=c.ctrlKey,n._metaKey=c.metaKey,n._shiftKey=c.shiftKey,n._buttonsPressed=c.buttons,i.isPointerLock){var h=c.movementX||c.mozMovementX||c.webkitMovementX||c.msMovementX||0,d=c.movementY||c.mozMovementY||c.webkitMovementY||c.msMovementY||0;n.onTouch(null,h,d),n.pointA=null,n.pointB=null}else if(a.type===le.a.POINTERDOWN&&u){try{u.setPointerCapture(c.pointerId)}catch(e){}null===n.pointA?n.pointA={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}:null===n.pointB&&(n.pointB={x:c.clientX,y:c.clientY,pointerId:c.pointerId,type:c.pointerType}),n.onButtonDown(c),t||(c.preventDefault(),e.focus())}else if(a.type===le.a.POINTERDOUBLETAP)n.onDoubleTap(c.pointerType);else if(a.type===le.a.POINTERUP&&u){try{u.releasePointerCapture(c.pointerId)}catch(e){}l||(n.pointB=null),i._badOS?n.pointA=n.pointB=null:n.pointB&&n.pointA&&n.pointA.pointerId==c.pointerId?(n.pointA=n.pointB,n.pointB=null):n.pointA&&n.pointB&&n.pointB.pointerId==c.pointerId?n.pointB=null:n.pointA=n.pointB=null,(0!==r||o)&&(n.onMultiTouch(n.pointA,n.pointB,r,0,o,null),r=0,o=null),n.onButtonUp(c),t||c.preventDefault()}else if(a.type===le.a.POINTERMOVE)if(t||c.preventDefault(),n.pointA&&null===n.pointB){h=c.clientX-n.pointA.x,d=c.clientY-n.pointA.y;n.onTouch(n.pointA,h,d),n.pointA.x=c.clientX,n.pointA.y=c.clientY}else if(n.pointA&&n.pointB){var f=n.pointA.pointerId===c.pointerId?n.pointA:n.pointB;f.x=c.clientX,f.y=c.clientY;var p=n.pointA.x-n.pointB.x,m=n.pointA.y-n.pointB.y,g=p*p+m*m,_={x:(n.pointA.x+n.pointB.x)/2,y:(n.pointA.y+n.pointB.y)/2,pointerId:c.pointerId,type:a.type};n.onMultiTouch(n.pointA,n.pointB,r,g,o,_),o=_,r=g}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,le.a.POINTERDOWN|le.a.POINTERUP|le.a.POINTERMOVE),this._onLostFocus=function(){n.pointA=n.pointB=null,r=0,o=null,n.onLostFocus()},e.addEventListener("contextmenu",this.onContextMenu.bind(this),!1),fe.h.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){this._onLostFocus&&fe.h.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),e&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this.onContextMenu&&e.removeEventListener("contextmenu",this.onContextMenu),this._onLostFocus=null),this._altKey=!1,this._ctrlKey=!1,this._metaKey=!1,this._shiftKey=!1,this._buttonsPressed=0},e.prototype.getClassName=function(){return"BaseCameraPointersInput"},e.prototype.getSimpleName=function(){return"pointers"},e.prototype.onDoubleTap=function(e){},e.prototype.onTouch=function(e,t,n){},e.prototype.onMultiTouch=function(e,t,n,i,r,o){},e.prototype.onContextMenu=function(e){e.preventDefault()},e.prototype.onButtonDown=function(e){},e.prototype.onButtonUp=function(e){},e.prototype.onLostFocus=function(){},l.c([Object(De.c)()],e.prototype,"buttons",void 0),e}(),We=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.buttons=[0,1,2],t.angularSensibilityX=1e3,t.angularSensibilityY=1e3,t.pinchPrecision=12,t.pinchDeltaPercentage=0,t.panningSensibility=1e3,t.multiTouchPanning=!0,t.multiTouchPanAndZoom=!0,t.pinchInwards=!0,t._isPanClick=!1,t._twoFingerActivityCount=0,t._isPinching=!1,t}return l.d(t,e),t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.onTouch=function(e,t,n){0!==this.panningSensibility&&(this._ctrlKey&&this.camera._useCtrlForPanning||this._isPanClick)?(this.camera.inertialPanningX+=-t/this.panningSensibility,this.camera.inertialPanningY+=n/this.panningSensibility):(this.camera.inertialAlphaOffset-=t/this.angularSensibilityX,this.camera.inertialBetaOffset-=n/this.angularSensibilityY)},t.prototype.onDoubleTap=function(e){this.camera.useInputToRestoreState&&this.camera.restoreState()},t.prototype.onMultiTouch=function(e,t,n,i,r,o){if(!(0===n&&null===r||0===i&&null===o)){var a=this.pinchInwards?1:-1;if(this.multiTouchPanAndZoom){if(this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(i-n)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(i-n)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),0!==this.panningSensibility&&r&&o){var s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/this.panningSensibility}}else{this._twoFingerActivityCount++;var l=Math.sqrt(n),u=Math.sqrt(i);if(this._isPinching||this._twoFingerActivityCount<20&&Math.abs(u-l)>this.camera.pinchToPanMaxDistance)this.pinchDeltaPercentage?this.camera.inertialRadiusOffset+=.001*(i-n)*this.camera.radius*this.pinchDeltaPercentage:this.camera.inertialRadiusOffset+=(i-n)/(this.pinchPrecision*a*(this.angularSensibilityX+this.angularSensibilityY)/2),this._isPinching=!0;else if(0!==this.panningSensibility&&this.multiTouchPanning&&o&&r){s=o.x-r.x,c=o.y-r.y;this.camera.inertialPanningX+=-s/this.panningSensibility,this.camera.inertialPanningY+=c/this.panningSensibility}}}},t.prototype.onButtonDown=function(e){this._isPanClick=e.button===this.camera._panningMouseButton},t.prototype.onButtonUp=function(e){this._twoFingerActivityCount=0,this._isPinching=!1},t.prototype.onLostFocus=function(){this._isPanClick=!1,this._twoFingerActivityCount=0,this._isPinching=!1},l.c([Object(De.c)()],t.prototype,"buttons",void 0),l.c([Object(De.c)()],t.prototype,"angularSensibilityX",void 0),l.c([Object(De.c)()],t.prototype,"angularSensibilityY",void 0),l.c([Object(De.c)()],t.prototype,"pinchPrecision",void 0),l.c([Object(De.c)()],t.prototype,"pinchDeltaPercentage",void 0),l.c([Object(De.c)()],t.prototype,"panningSensibility",void 0),l.c([Object(De.c)()],t.prototype,"multiTouchPanning",void 0),l.c([Object(De.c)()],t.prototype,"multiTouchPanAndZoom",void 0),t}(je);Ne.a.ArcRotateCameraPointersInput=We;var Xe=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.addMouseWheel=function(){return this.add(new He),this},t.prototype.addPointers=function(){return this.add(new We),this},t.prototype.addKeyboard=function(){return this.add(new Ue),this},t}(Ne.b);Xe.prototype.addVRDeviceOrientation=function(){return this.add(new Ye),this};var Ye=function(){function e(){this.alphaCorrection=1,this.gammaCorrection=1,this._alpha=0,this._gamma=0,this._dirty=!1,this._deviceOrientationHandler=this._onOrientationEvent.bind(this)}return e.prototype.attachControl=function(e,t){this.camera.attachControl(e,t),window.addEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype._onOrientationEvent=function(e){null!==e.alpha&&(this._alpha=(0|+e.alpha)*this.alphaCorrection),null!==e.gamma&&(this._gamma=(0|+e.gamma)*this.gammaCorrection),this._dirty=!0},e.prototype.checkInputs=function(){this._dirty&&(this._dirty=!1,this._gamma<0&&(this._gamma=180+this._gamma),this.camera.alpha=-this._alpha/180*Math.PI%Math.PI*2,this.camera.beta=this._gamma/180*Math.PI)},e.prototype.detachControl=function(e){window.removeEventListener("deviceorientation",this._deviceOrientationHandler)},e.prototype.getClassName=function(){return"ArcRotateCameraVRDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"VRDeviceOrientation"},e}();Ne.a.ArcRotateCameraVRDeviceOrientationInput=Ye;var Ke=function(){function e(){this.keysForward=[87],this.keysBackward=[83],this.keysUp=[69],this.keysDown=[81],this.keysRight=[68],this.keysLeft=[65],this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var i,r=e.event;e.type===Ve.a.KEYDOWN?-1===n.keysForward.indexOf(r.keyCode)&&-1===n.keysBackward.indexOf(r.keyCode)&&-1===n.keysUp.indexOf(r.keyCode)&&-1===n.keysDown.indexOf(r.keyCode)&&-1===n.keysLeft.indexOf(r.keyCode)&&-1===n.keysRight.indexOf(r.keyCode)||(-1===(i=n._keys.indexOf(r.keyCode))&&n._keys.push(r.keyCode),t||r.preventDefault()):-1===n.keysForward.indexOf(r.keyCode)&&-1===n.keysBackward.indexOf(r.keyCode)&&-1===n.keysUp.indexOf(r.keyCode)&&-1===n.keysDown.indexOf(r.keyCode)&&-1===n.keysLeft.indexOf(r.keyCode)&&-1===n.keysRight.indexOf(r.keyCode)||((i=n._keys.indexOf(r.keyCode))>=0&&n._keys.splice(i,1),t||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&&n._keys.splice(i,1),r.preventDefault&&(t||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},l.c([Object(De.c)()],e.prototype,"keysHeightOffsetIncr",void 0),l.c([Object(De.c)()],e.prototype,"keysHeightOffsetDecr",void 0),l.c([Object(De.c)()],e.prototype,"keysHeightOffsetModifierAlt",void 0),l.c([Object(De.c)()],e.prototype,"keysHeightOffsetModifierCtrl",void 0),l.c([Object(De.c)()],e.prototype,"keysHeightOffsetModifierShift",void 0),l.c([Object(De.c)()],e.prototype,"keysRotationOffsetIncr",void 0),l.c([Object(De.c)()],e.prototype,"keysRotationOffsetDecr",void 0),l.c([Object(De.c)()],e.prototype,"keysRotationOffsetModifierAlt",void 0),l.c([Object(De.c)()],e.prototype,"keysRotationOffsetModifierCtrl",void 0),l.c([Object(De.c)()],e.prototype,"keysRotationOffsetModifierShift",void 0),l.c([Object(De.c)()],e.prototype,"keysRadiusIncr",void 0),l.c([Object(De.c)()],e.prototype,"keysRadiusDecr",void 0),l.c([Object(De.c)()],e.prototype,"keysRadiusModifierAlt",void 0),l.c([Object(De.c)()],e.prototype,"keysRadiusModifierCtrl",void 0),l.c([Object(De.c)()],e.prototype,"keysRadiusModifierShift",void 0),l.c([Object(De.c)()],e.prototype,"heightSensibility",void 0),l.c([Object(De.c)()],e.prototype,"rotationSensibility",void 0),l.c([Object(De.c)()],e.prototype,"radiusSensibility",void 0),e}();Ne.a.FollowCameraKeyboardMoveInput=qe;var Ze=function(){function e(){this.axisControlRadius=!0,this.axisControlHeight=!1,this.axisControlRotation=!1,this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e,t){var n=this;this._wheel=function(e,i){if(e.type===le.a.POINTERWHEEL){var r=e.event,o=0,a=Math.max(-1,Math.min(1,r.deltaY||r.wheelDelta||-r.detail));n.wheelDeltaPercentage?(console.assert(n.axisControlRadius+n.axisControlHeight+n.axisControlRotation<=1,"wheelDeltaPercentage only usable when mouse wheel controlls ONE axis. Currently enabled: axisControlRadius: "+n.axisControlRadius+", axisControlHeightOffset: "+n.axisControlHeight+", axisControlRotationOffset: "+n.axisControlRotation),n.axisControlRadius?o=.01*a*n.wheelDeltaPercentage*n.camera.radius:n.axisControlHeight?o=.01*a*n.wheelDeltaPercentage*n.camera.heightOffset:n.axisControlRotation&&(o=.01*a*n.wheelDeltaPercentage*n.camera.rotationOffset)):o=a*n.wheelPrecision,o&&(n.axisControlRadius?n.camera.radius+=o:n.axisControlHeight?n.camera.heightOffset-=o:n.axisControlRotation&&(n.camera.rotationOffset-=o)),r.preventDefault&&(t||r.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,le.a.POINTERWHEEL)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},e.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},e.prototype.getSimpleName=function(){return"mousewheel"},l.c([Object(De.c)()],e.prototype,"axisControlRadius",void 0),l.c([Object(De.c)()],e.prototype,"axisControlHeight",void 0),l.c([Object(De.c)()],e.prototype,"axisControlRotation",void 0),l.c([Object(De.c)()],e.prototype,"wheelPrecision",void 0),l.c([Object(De.c)()],e.prototype,"wheelDeltaPercentage",void 0),e}();Ne.a.FollowCameraMouseWheelInput=Ze;var Je=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 l.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)}},l.c([Object(De.c)()],t.prototype,"angularSensibilityX",void 0),l.c([Object(De.c)()],t.prototype,"angularSensibilityY",void 0),l.c([Object(De.c)()],t.prototype,"pinchPrecision",void 0),l.c([Object(De.c)()],t.prototype,"pinchDeltaPercentage",void 0),l.c([Object(De.c)()],t.prototype,"axisXControlRadius",void 0),l.c([Object(De.c)()],t.prototype,"axisXControlHeight",void 0),l.c([Object(De.c)()],t.prototype,"axisXControlRotation",void 0),l.c([Object(De.c)()],t.prototype,"axisYControlRadius",void 0),l.c([Object(De.c)()],t.prototype,"axisYControlHeight",void 0),l.c([Object(De.c)()],t.prototype,"axisYControlRotation",void 0),l.c([Object(De.c)()],t.prototype,"axisPinchControlRadius",void 0),l.c([Object(De.c)()],t.prototype,"axisPinchControlHeight",void 0),l.c([Object(De.c)()],t.prototype,"axisPinchControlRotation",void 0),t}(je);Ne.a.FollowCameraPointersInput=Je;var $e=n(96);$e.a.prototype.addDeviceOrientation=function(){return this._deviceOrientationInput||(this._deviceOrientationInput=new et,this.add(this._deviceOrientationInput)),this};var et=function(){function e(){var e=this;this._screenOrientationAngle=0,this._screenQuaternion=new o.q,this._alpha=0,this._beta=0,this._gamma=0,this._onDeviceOrientationChangedObservable=new r.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=-fe.h.ToRadians(e._screenOrientationAngle/2),e._screenQuaternion.copyFromFloats(0,Math.sin(e._screenOrientationAngle),0,Math.cos(e._screenOrientationAngle))},this._deviceOrientation=function(t){e._alpha=null!==t.alpha?t.alpha:0,e._beta=null!==t.beta?t.beta:0,e._gamma=null!==t.gamma?t.gamma:0,null!==t.alpha&&e._onDeviceOrientationChangedObservable.notifyObservers()},this._constantTranform=new o.q(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},set:function(e){var t=this;this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new o.q),this._camera&&this._camera.onDisposeObservable.add((function(){t._onDeviceOrientationChangedObservable.clear()}))},enumerable:!0,configurable:!0}),e.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},e.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation),this._alpha=0},e.prototype.checkInputs=function(){this._alpha&&(o.q.RotationYawPitchRollToRef(fe.h.ToRadians(this._alpha),fe.h.ToRadians(this._beta),-fe.h.ToRadians(this._gamma),this.camera.rotationQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion),this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform),this._camera.rotationQuaternion.z*=-1,this._camera.rotationQuaternion.w*=-1)},e.prototype.getClassName=function(){return"FreeCameraDeviceOrientationInput"},e.prototype.getSimpleName=function(){return"deviceOrientation"},e}();Ne.a.FreeCameraDeviceOrientationInput=et;var tt=function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._cameraTransform=o.j.Identity(),this._deltaTransform=o.x.Zero(),this._vector3=o.x.Zero(),this._vector2=o.w.Zero()}return e.prototype.attachControl=function(e,t){var n=this,i=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=i.onGamepadConnectedObservable.add((function(e){e.type!==ke.POSE_ENABLED&&(n.gamepad&&e.type!==ke.XBOX||(n.gamepad=e))})),this._onGamepadDisconnectedObserver=i.onGamepadDisconnectedObservable.add((function(e){n.gamepad===e&&(n.gamepad=null)})),this.gamepad=i.getGamepadByType(ke.XBOX)},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick,n=t.x/this.gamepadMoveSensibility,i=t.y/this.gamepadMoveSensibility;t.x=Math.abs(n)>.005?0+n:0,t.y=Math.abs(i)>.005?0+i:0;var r=this.gamepad.rightStick;if(r){var a=r.x/this.gamepadAngularSensibility,s=r.y/this.gamepadAngularSensibility;r.x=Math.abs(a)>.001?0+a:0,r.y=Math.abs(s)>.001?0+s:0}else r={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):o.j.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var c=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*c,0,-t.y*c),o.x.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(r.y,r.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},l.c([Object(De.c)()],e.prototype,"gamepadAngularSensibility",void 0),l.c([Object(De.c)()],e.prototype,"gamepadMoveSensibility",void 0),e}();Ne.a.FreeCameraGamepadInput=tt;var nt,it=n(168),rt=n(169),ot=n(170),at=n(88);!function(e){e[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z"}(nt||(nt={}));var st=function(){function e(t){var n=this;if(this._leftJoystick=!!t,e._globalJoystickIndex++,this._axisTargetedByLeftAndRight=nt.X,this._axisTargetedByUpAndDown=nt.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new at.a,this.deltaPosition=o.x.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(t){e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas&&(e.Canvas.width=e.vjCanvasWidth,e.Canvas.height=e.vjCanvasHeight),e.halfWidth=e.vjCanvasWidth/2},!e.Canvas){window.addEventListener("resize",this._onResize,!1),e.Canvas=document.createElement("canvas"),e.vjCanvasWidth=window.innerWidth,e.vjCanvasHeight=window.innerHeight,e.Canvas.width=window.innerWidth,e.Canvas.height=window.innerHeight,e.Canvas.style.width="100%",e.Canvas.style.height="100%",e.Canvas.style.position="absolute",e.Canvas.style.backgroundColor="transparent",e.Canvas.style.top="0px",e.Canvas.style.left="0px",e.Canvas.style.zIndex="5",e.Canvas.style.msTouchAction="none",e.Canvas.setAttribute("touch-action","none");var i=e.Canvas.getContext("2d");if(!i)throw new Error("Unable to create canvas for virtual joystick");e.vjCanvasContext=i,e.vjCanvasContext.strokeStyle="#ffffff",e.vjCanvasContext.lineWidth=2,document.body.appendChild(e.Canvas)}e.halfWidth=e.Canvas.width/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new o.w(0,0),this._joystickPreviousPointerPos=new o.w(0,0),this._joystickPointerStartPos=new o.w(0,0),this._deltaJoystickVector=new o.w(0,0),this._onPointerDownHandlerRef=function(e){n._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){n._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){n._onPointerUp(e)},e.Canvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),e.Canvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),e.Canvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),e.Canvas.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){n._drawVirtualJoystick()}))}return e.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._joystickPointerStartPos.x=t.clientX,this._joystickPointerStartPos.y=t.clientY,this._joystickPointerPos=this._joystickPointerStartPos.clone(),this._joystickPreviousPointerPos=this._joystickPointerStartPos.clone(),this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this.pressed=!0,this._touches.add(t.pointerId.toString(),t)):e._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(t.pointerId.toString(),{x:t.clientX,y:t.clientY,prevX:t.clientX,prevY:t.clientY}))},e.prototype._onPointerMove=function(e){if(this._joystickPointerID==e.pointerId){this._joystickPointerPos.x=e.clientX,this._joystickPointerPos.y=e.clientY,this._deltaJoystickVector=this._joystickPointerPos.clone(),this._deltaJoystickVector=this._deltaJoystickVector.subtract(this._joystickPointerStartPos);var t=(this.reverseLeftRight?-1:1)*this._deltaJoystickVector.x/this._inversedSensibility;switch(this._axisTargetedByLeftAndRight){case nt.X:this.deltaPosition.x=Math.min(1,Math.max(-1,t));break;case nt.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,t));break;case nt.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,t))}var n=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case nt.X:this.deltaPosition.x=Math.min(1,Math.max(-1,n));break;case nt.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,n));break;case nt.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,n))}}else{var i=this._touches.get(e.pointerId.toString());i&&(i.x=e.clientX,i.y=e.clientY)}},e.prototype._onPointerUp=function(t){if(this._joystickPointerID==t.pointerId)e.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var n=this._touches.get(t.pointerId.toString());n&&e.vjCanvasContext.clearRect(n.prevX-44,n.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(t.pointerId.toString())},e.prototype.setJoystickColor=function(e){this._joystickColor=e},e.prototype.setActionOnTouch=function(e){this._action=e},e.prototype.setAxisForLeftRight=function(e){switch(e){case nt.X:case nt.Y:case nt.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=nt.X}},e.prototype.setAxisForUpDown=function(e){switch(e){case nt.X:case nt.Y:case nt.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=nt.Y}},e.prototype._drawVirtualJoystick=function(){var t=this;this.pressed&&this._touches.forEach((function(n,i){i.pointerId===t._joystickPointerID?(e.vjCanvasContext.clearRect(t._joystickPointerStartPos.x-64,t._joystickPointerStartPos.y-64,128,128),e.vjCanvasContext.clearRect(t._joystickPreviousPointerPos.x-42,t._joystickPreviousPointerPos.y-42,84,84),e.vjCanvasContext.beginPath(),e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.lineWidth=2,e.vjCanvasContext.arc(t._joystickPointerStartPos.x,t._joystickPointerStartPos.y,60,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle=t._joystickColor,e.vjCanvasContext.arc(t._joystickPointerPos.x,t._joystickPointerPos.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),t._joystickPreviousPointerPos=t._joystickPointerPos.clone()):(e.vjCanvasContext.clearRect(i.prevX-44,i.prevY-44,88,88),e.vjCanvasContext.beginPath(),e.vjCanvasContext.fillStyle="white",e.vjCanvasContext.beginPath(),e.vjCanvasContext.strokeStyle="red",e.vjCanvasContext.lineWidth=6,e.vjCanvasContext.arc(i.x,i.y,40,0,2*Math.PI,!0),e.vjCanvasContext.stroke(),e.vjCanvasContext.closePath(),i.prevX=i.x,i.prevY=i.y)})),requestAnimationFrame((function(){t._drawVirtualJoystick()}))},e.prototype.releaseCanvas=function(){e.Canvas&&(e.Canvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),e.Canvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),e.Canvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),e.Canvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(e.Canvas),e.Canvas=null)},e._globalJoystickIndex=0,e}();$e.a.prototype.addVirtualJoystick=function(){return this.add(new ct),this};var ct=function(){function e(){}return e.prototype.getLeftJoystick=function(){return this._leftjoystick},e.prototype.getRightJoystick=function(){return this._rightjoystick},e.prototype.checkInputs=function(){if(this._leftjoystick){var e=this.camera,t=50*e._computeLocalCameraSpeed(),n=o.j.RotationYawPitchRoll(e.rotation.y,e.rotation.x,0),i=o.x.TransformCoordinates(new o.x(this._leftjoystick.deltaPosition.x*t,this._leftjoystick.deltaPosition.y*t,this._leftjoystick.deltaPosition.z*t),n);e.cameraDirection=e.cameraDirection.add(i),e.cameraRotation=e.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},e.prototype.attachControl=function(e,t){this._leftjoystick=new st(!0),this._leftjoystick.setAxisForUpDown(nt.Z),this._leftjoystick.setAxisForLeftRight(nt.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new st(!1),this._rightjoystick.setAxisForUpDown(nt.X),this._rightjoystick.setAxisForLeftRight(nt.Y),this._rightjoystick.reverseUpDown=!0,this._rightjoystick.setJoystickSensibility(.05),this._rightjoystick.setJoystickColor("yellow")},e.prototype.detachControl=function(e){this._leftjoystick.releaseCanvas(),this._rightjoystick.releaseCanvas()},e.prototype.getClassName=function(){return"FreeCameraVirtualJoystickInput"},e.prototype.getSimpleName=function(){return"virtualJoystick"},e}();Ne.a.FreeCameraVirtualJoystickInput=ct;var lt=n(71),ut=n(53),ht=n(30);ht.a.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new dt(e,o.x.Zero(),t)}}));var dt=function(e){function t(t,n,i){var r=e.call(this,t,n,i)||this;return r.inputs.addTouch(),r._setupInputs(),r}return l.d(t,e),Object.defineProperty(t.prototype,"touchAngularSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchAngularSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"touchMoveSensibility",{get:function(){var e=this.inputs.attached.touch;return e?e.touchMoveSensibility:0},set:function(e){var t=this.inputs.attached.touch;t&&(t.touchMoveSensibility=e)},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"TouchCamera"},t.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},t}(ut.a);ht.a.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new ft(e,0,0,1,o.x.Zero(),t)}}));var ft=function(e){function t(t,n,i,a,s,c,l){void 0===l&&(l=!0);var u=e.call(this,t,o.x.Zero(),c,l)||this;return u._upVector=o.x.Up(),u.inertialAlphaOffset=0,u.inertialBetaOffset=0,u.inertialRadiusOffset=0,u.lowerAlphaLimit=null,u.upperAlphaLimit=null,u.lowerBetaLimit=.01,u.upperBetaLimit=Math.PI-.01,u.lowerRadiusLimit=null,u.upperRadiusLimit=null,u.inertialPanningX=0,u.inertialPanningY=0,u.pinchToPanMaxDistance=20,u.panningDistanceLimit=null,u.panningOriginTarget=o.x.Zero(),u.panningInertia=.9,u.zoomOnFactor=1,u.targetScreenOffset=o.w.Zero(),u.allowUpsideDown=!0,u.useInputToRestoreState=!0,u._viewMatrix=new o.j,u.panningAxis=new o.x(1,1,0),u.onMeshTargetChangedObservable=new r.c,u.checkCollisions=!1,u.collisionRadius=new o.x(.5,.5,.5),u._previousPosition=o.x.Zero(),u._collisionVelocity=o.x.Zero(),u._newPosition=o.x.Zero(),u._computationVector=o.x.Zero(),u._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null),n?(u.setPosition(t),u.onCollide&&u.onCollide(n)):u._previousPosition.copyFrom(u._position);var i=Math.cos(u.alpha),r=Math.sin(u.alpha),o=Math.cos(u.beta),a=Math.sin(u.beta);0===a&&(a=1e-4);var s=u._getTargetPosition();u._computationVector.copyFromFloats(u.radius*i*a,u.radius*o,u.radius*r*a),s.addToRef(u._computationVector,u._newPosition),u._position.copyFrom(u._newPosition);var c=u.upVector;u.allowUpsideDown&&u.beta<0&&(c=(c=c.clone()).negate()),u._computeViewMatrix(u._position,s,c),u._viewMatrix.addAtIndex(12,u.targetScreenOffset.x),u._viewMatrix.addAtIndex(13,u.targetScreenOffset.y),u._collisionTriggered=!1},u._target=o.x.Zero(),s&&u.setTarget(s),u.alpha=n,u.beta=i,u.radius=a,u.getViewMatrix(),u.inputs=new Xe(u),u.inputs.addKeyboard().addMouseWheel().addPointers(),u}return l.d(t,e),Object.defineProperty(t.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this.setPosition(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"upVector",{get:function(){return this._upVector},set:function(e){this._upToYMatrix||(this._YToUpMatrix=new o.j,this._upToYMatrix=new o.j,this._upVector=o.x.Zero()),e.normalize(),this._upVector.copyFrom(e),this.setMatUp()},enumerable:!0,configurable:!0}),t.prototype.setMatUp=function(){o.j.RotationAlignToRef(o.x.UpReadOnly,this._upVector,this._YToUpMatrix),o.j.RotationAlignToRef(this._upVector,o.x.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:!0,configurable:!0}),Object.defineProperty(t.prototype,"angularSensibilityY",{get:function(){var e=this.inputs.attached.pointers;return e?e.angularSensibilityY:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.angularSensibilityY=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchPrecision",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchPrecision:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pinchDeltaPercentage",{get:function(){var e=this.inputs.attached.pointers;return e?e.pinchDeltaPercentage:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.pinchDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"panningSensibility",{get:function(){var e=this.inputs.attached.pointers;return e?e.panningSensibility:0},set:function(e){var t=this.inputs.attached.pointers;t&&(t.panningSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelPrecision",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelPrecision:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wheelDeltaPercentage",{get:function(){var e=this.inputs.attached.mousewheel;return e?e.wheelDeltaPercentage:0},set:function(e){var t=this.inputs.attached.mousewheel;t&&(t.wheelDeltaPercentage=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new de,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new pe,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new he,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache._target=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=o.w.Zero()},t.prototype._updateCache=function(t){t||e.prototype._updateCache.call(this),this._cache._target.copyFrom(this._getTargetPosition()),this._cache.alpha=this.alpha,this._cache.beta=this.beta,this._cache.radius=this.radius,this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset)},t.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.absolutePosition;this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}var t=this._getLockedTargetPosition();return t||this._target},t.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),e.prototype.storeState.call(this)},t.prototype._restoreStateValues=function(){return!!e.prototype._restoreStateValues.call(this)&&(this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.setTarget(this._storedTarget.clone()),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)},t.prototype._isSynchronizedViewMatrix=function(){return!!e.prototype._isSynchronizedViewMatrix.call(this)&&(this._cache._target.equals(this._getTargetPosition())&&this._cache.alpha===this.alpha&&this._cache.beta===this.beta&&this._cache.radius===this.radius&&this._cache.targetScreenOffset.equals(this.targetScreenOffset))},t.prototype.attachControl=function(e,t,n,i){var r=this;void 0===n&&(n=!0),void 0===i&&(i=2),this._useCtrlForPanning=n,this._panningMouseButton=i,this.inputs.attachElement(e,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(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var t=this.inertialAlphaOffset;this.beta<=0&&(t*=-1),this.getScene().useRightHandedSystem&&(t*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(t*=-1),this.alpha+=t,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)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||o.x.TransformCoordinatesToRef(this._computationVector,this._upToYMatrix,this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4),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),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){if(void 0===t&&(t=!1),void 0===n&&(n=!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 i=e,r=this._getTargetPosition();if(r&&!n&&r.equals(i))return;this._targetHost=null,this._target=i,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}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);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||o.x.TransformCoordinatesToRef(this._computationVector,this._YToUpMatrix,this._computationVector),r.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions){var a=this.getScene().collisionCoordinator;this._collider||(this._collider=a.createCollider()),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this._position,this._collisionVelocity),this._collisionTriggered=!0,a.getNewPosition(this._position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)}else{this._position.copyFrom(this._newPosition);var s=this.upVector;this.allowUpsideDown&&i<0&&(s=(s=s.clone()).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=ve.a.MinMax(e),i=o.x.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=ve.a.MinMax(r),i=o.x.Distance(n.min,n.max)}else{n=e,i=e.distance}this._target=ve.a.Center(n),t||(this.maxZ=2*i)},t.prototype.createRigCamera=function(e,n){var i=0;switch(this.cameraRigMode){case Ce.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ce.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ce.a.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(0===n?1:-1);break;case Ce.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},t.prototype._updateRigCameras=function(){var t=this._rigCameras[0],n=this._rigCameras[1];switch(t.beta=n.beta=this.beta,this.cameraRigMode){case Ce.a.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Ce.a.RIG_MODE_STEREOSCOPIC_OVERUNDER:case Ce.a.RIG_MODE_VR:t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,n.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case Ce.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"},l.c([Object(De.c)()],t.prototype,"alpha",void 0),l.c([Object(De.c)()],t.prototype,"beta",void 0),l.c([Object(De.c)()],t.prototype,"radius",void 0),l.c([Object(De.o)("target")],t.prototype,"_target",void 0),l.c([Object(De.o)("upVector")],t.prototype,"_upVector",void 0),l.c([Object(De.c)()],t.prototype,"inertialAlphaOffset",void 0),l.c([Object(De.c)()],t.prototype,"inertialBetaOffset",void 0),l.c([Object(De.c)()],t.prototype,"inertialRadiusOffset",void 0),l.c([Object(De.c)()],t.prototype,"lowerAlphaLimit",void 0),l.c([Object(De.c)()],t.prototype,"upperAlphaLimit",void 0),l.c([Object(De.c)()],t.prototype,"lowerBetaLimit",void 0),l.c([Object(De.c)()],t.prototype,"upperBetaLimit",void 0),l.c([Object(De.c)()],t.prototype,"lowerRadiusLimit",void 0),l.c([Object(De.c)()],t.prototype,"upperRadiusLimit",void 0),l.c([Object(De.c)()],t.prototype,"inertialPanningX",void 0),l.c([Object(De.c)()],t.prototype,"inertialPanningY",void 0),l.c([Object(De.c)()],t.prototype,"pinchToPanMaxDistance",void 0),l.c([Object(De.c)()],t.prototype,"panningDistanceLimit",void 0),l.c([Object(De.o)()],t.prototype,"panningOriginTarget",void 0),l.c([Object(De.c)()],t.prototype,"panningInertia",void 0),l.c([Object(De.c)()],t.prototype,"zoomOnFactor",void 0),l.c([Object(De.c)()],t.prototype,"targetScreenOffset",void 0),l.c([Object(De.c)()],t.prototype,"allowUpsideDown",void 0),l.c([Object(De.c)()],t.prototype,"useInputToRestoreState",void 0),t}(lt.a);ht.a.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new pt(e,o.x.Zero(),t)}}));var pt=function(e){function t(t,n,i){var r=e.call(this,t,n,i)||this;return r._tmpDragQuaternion=new o.q,r._disablePointerInputWhenUsingDeviceOrientation=!0,r._dragFactor=0,r._quaternionCache=new o.q,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 o.q),o.q.FromEulerAnglesToRef(0,e.offsetX*r._dragFactor,0,r._tmpDragQuaternion),r._initialQuaternion.multiplyToRef(r._tmpDragQuaternion,r._initialQuaternion))})))})),r}return l.d(t,e),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=o.c.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new o.q),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}(ut.a),mt=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.addKeyboard=function(){return this.add(new Ke),this},t.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new Qe(e)),this},t}(Ne.b),gt=function(e){function t(t,n,i,r){void 0===r&&(r=!0);var a=e.call(this,t,n,i,r)||this;return a.ellipsoid=new o.x(1,1,1),a.ellipsoidOffset=new o.x(0,0,0),a.checkCollisions=!1,a.applyGravity=!1,a.cameraDirection=o.x.Zero(),a._trackRoll=0,a.rollCorrect=100,a.bankedTurn=!1,a.bankedTurnLimit=Math.PI/2,a.bankedTurnMultiplier=1,a._needMoveForGravity=!1,a._oldPosition=o.x.Zero(),a._diffPosition=o.x.Zero(),a._newPosition=o.x.Zero(),a._collisionMask=-1,a._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null);var i;i=t,a._newPosition.copyFrom(i),a._newPosition.subtractToRef(a._oldPosition,a._diffPosition),a._diffPosition.length()>ee.b.CollisionsEpsilon&&(a.position.addInPlace(a._diffPosition),a.onCollide&&n&&a.onCollide(n))},a.inputs=new mt(a),a.inputs.addKeyboard().addMouse(),a}return l.d(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysForward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysForward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysForward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysBackward",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysBackward:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysBackward=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new o.x(0,0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?o.x.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var 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=o.x.Zero(),this._transformedDirection=o.x.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.restoreRoll=function(e){var t=this._trackRoll,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"},l.c([Object(De.o)()],t.prototype,"ellipsoid",void 0),l.c([Object(De.o)()],t.prototype,"ellipsoidOffset",void 0),l.c([Object(De.c)()],t.prototype,"checkCollisions",void 0),l.c([Object(De.c)()],t.prototype,"applyGravity",void 0),t}(lt.a),_t=function(e){function t(t){return e.call(this,t)||this}return l.d(t,e),t.prototype.addKeyboard=function(){return this.add(new qe),this},t.prototype.addMouseWheel=function(){return this.add(new Ze),this},t.prototype.addPointers=function(){return this.add(new Je),this},t.prototype.addVRDeviceOrientation=function(){return console.warn("DeviceOrientation support not yet implemented for FollowCamera."),this},t}(Ne.b);ht.a.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new bt(e,o.x.Zero(),t)}})),ht.a.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new yt(e,0,0,1,null,t)}}));var vt,bt=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 _t(o),o.inputs.addKeyboard().addMouseWheel().addPointers(),o}return l.d(t,e),t.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var n=new o.j;e.rotationQuaternion.toRotationMatrix(n),t=Math.atan2(n.m[8],n.m[10])}else t=e.rotation.y;var i=fe.h.ToRadians(this.rotationOffset)+t,r=e.getAbsolutePosition(),a=r.x+Math.sin(i)*this.radius,s=r.z+Math.cos(i)*this.radius,c=a-this.position.x,l=r.y+this.heightOffset-this.position.y,u=s-this.position.z,h=c*this.cameraAcceleration*2,d=l*this.cameraAcceleration,f=u*this.cameraAcceleration*2;(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),(f>this.maxCameraSpeed||f<-this.maxCameraSpeed)&&(f=f<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new o.x(this.position.x+h,this.position.y+d,this.position.z+f),this.setTarget(r)}},t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t),this._reset=function(){}},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},t.prototype._checkInputs=function(){this.inputs.checkInputs(),this._checkLimits(),e.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},t.prototype._checkLimits=function(){null!==this.lowerRadiusLimit&&this.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"},l.c([Object(De.c)()],t.prototype,"radius",void 0),l.c([Object(De.c)()],t.prototype,"lowerRadiusLimit",void 0),l.c([Object(De.c)()],t.prototype,"upperRadiusLimit",void 0),l.c([Object(De.c)()],t.prototype,"rotationOffset",void 0),l.c([Object(De.c)()],t.prototype,"lowerRotationOffsetLimit",void 0),l.c([Object(De.c)()],t.prototype,"upperRotationOffsetLimit",void 0),l.c([Object(De.c)()],t.prototype,"heightOffset",void 0),l.c([Object(De.c)()],t.prototype,"lowerHeightOffsetLimit",void 0),l.c([Object(De.c)()],t.prototype,"upperHeightOffsetLimit",void 0),l.c([Object(De.c)()],t.prototype,"cameraAcceleration",void 0),l.c([Object(De.c)()],t.prototype,"maxCameraSpeed",void 0),l.c([Object(De.k)("lockedTargetId")],t.prototype,"lockedTarget",void 0),t}(lt.a),yt=function(e){function t(t,n,i,r,a,s){var c=e.call(this,t,o.x.Zero(),s)||this;return c.alpha=n,c.beta=i,c.radius=r,c.target=a,c._cartesianCoordinates=o.x.Zero(),c._follow(),c}return l.d(t,e),t.prototype._follow=function(){if(this.target){this._cartesianCoordinates.x=this.radius*Math.cos(this.alpha)*Math.cos(this.beta),this._cartesianCoordinates.y=this.radius*Math.sin(this.beta),this._cartesianCoordinates.z=this.radius*Math.sin(this.alpha)*Math.cos(this.beta);var e=this.target.getAbsolutePosition();this.position=e.add(this._cartesianCoordinates),this.setTarget(e)}},t.prototype._checkInputs=function(){e.prototype._checkInputs.call(this),this._follow()},t.prototype.getClassName=function(){return"ArcFollowCamera"},t}(lt.a),xt=n(50);!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"}(vt||(vt={}));var Ct,Et,Tt=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),a=Math.cos(-i);this._calculatedPosition.x=this._calculatedPosition.x*a-this._calculatedPosition.z*r,this._calculatedPosition.z=this._calculatedPosition.x*r+this._calculatedPosition.z*a}}o.x.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),o.q.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation),this._mesh&&(this._mesh.position.copyFrom(this.devicePosition),this._mesh.rotationQuaternion&&this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion))},t.prototype.updateFromDevice=function(e){if(e){this.rawPose=e,e.position&&(this._deviceRoomPosition.copyFromFloats(e.position[0],e.position[1],-e.position[2]),this._mesh&&this._mesh.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1),this._trackPosition&&this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor,this._calculatedPosition),this._calculatedPosition.addInPlace(this.position));var t=this.rawPose;e.orientation&&t.orientation&&(this._deviceRoomRotationQuaternion.copyFromFloats(t.orientation[0],t.orientation[1],-t.orientation[2],-t.orientation[3]),this._mesh&&(this._mesh.getScene().useRightHandedSystem?(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1):this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion,this._deviceRoomRotationQuaternion)),this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion,this._calculatedRotation))}},t.prototype.attachToMesh=function(e){if(this._mesh&&(this._mesh.parent=null),this._mesh=e,this._poseControlledCamera&&(this._mesh.parent=this._poseControlledCamera),this._mesh.rotationQuaternion||(this._mesh.rotationQuaternion=new o.q),this._updatePoseAndMesh(),this._pointingPoseNode){for(var t=[],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:!0,configurable:!0}),t.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new Ee(o.x.Zero(),new o.x(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),n=t.getTranslation(),i=new o.x(0,0,-1),r=o.x.TransformNormal(i,t),a=o.x.Normalize(r);return new Ee(n,a,e)},t.POINTING_POSE="POINTING_POSE",t}(ke);!function(e){e[e.A=0]="A",e[e.B=1]="B",e[e.X=2]="X",e[e.Y=3]="Y",e[e.Start=4]="Start",e[e.Back=5]="Back",e[e.LB=6]="LB",e[e.RB=7]="RB",e[e.LeftStick=8]="LeftStick",e[e.RightStick=9]="RightStick"}(Ct||(Ct={})),function(e){e[e.Up=0]="Up",e[e.Down=1]="Down",e[e.Left=2]="Left",e[e.Right=3]="Right"}(Et||(Et={}));var At=function(e){function t(t,n,i,o){void 0===o&&(o=!1);var a=e.call(this,t,n,i,0,1,2,3)||this;return a._leftTrigger=0,a._rightTrigger=0,a.onButtonDownObservable=new r.c,a.onButtonUpObservable=new r.c,a.onPadDownObservable=new r.c,a.onPadUpObservable=new r.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=ke.XBOX,a._isXboxOnePad=o,a}return l.d(t,e),t.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},t.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(t.prototype,"leftTrigger",{get:function(){return this._leftTrigger},set:function(e){this._onlefttriggerchanged&&this._leftTrigger!==e&&this._onlefttriggerchanged(e),this._leftTrigger=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightTrigger",{get:function(){return this._rightTrigger},set:function(e){this._onrighttriggerchanged&&this._rightTrigger!==e&&this._onrighttriggerchanged(e),this._rightTrigger=e},enumerable:!0,configurable:!0}),t.prototype.onbuttondown=function(e){this._onbuttondown=e},t.prototype.onbuttonup=function(e){this._onbuttonup=e},t.prototype.ondpaddown=function(e){this._ondpaddown=e},t.prototype.ondpadup=function(e){this._ondpadup=e},t.prototype._setButtonValue=function(e,t,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,Ct.A)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,Ct.B)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,Ct.X)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,Ct.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,Ct.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,Ct.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,Ct.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,Ct.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,Ct.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,Ct.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,Et.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,Et.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,Et.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,Et.Right)},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this),this._isXboxOnePad?(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.axes[2],this.rightTrigger=this.browserGamepad.axes[5],this.buttonBack=this.browserGamepad.buttons[9].value,this.buttonStart=this.browserGamepad.buttons[8].value,this.buttonLeftStick=this.browserGamepad.buttons[6].value,this.buttonRightStick=this.browserGamepad.buttons[7].value,this.dPadUp=this.browserGamepad.buttons[11].value,this.dPadDown=this.browserGamepad.buttons[12].value,this.dPadLeft=this.browserGamepad.buttons[13].value,this.dPadRight=this.browserGamepad.buttons[14].value):(this.buttonA=this.browserGamepad.buttons[0].value,this.buttonB=this.browserGamepad.buttons[1].value,this.buttonX=this.browserGamepad.buttons[2].value,this.buttonY=this.browserGamepad.buttons[3].value,this.buttonLB=this.browserGamepad.buttons[4].value,this.buttonRB=this.browserGamepad.buttons[5].value,this.leftTrigger=this.browserGamepad.buttons[6].value,this.rightTrigger=this.browserGamepad.buttons[7].value,this.buttonBack=this.browserGamepad.buttons[8].value,this.buttonStart=this.browserGamepad.buttons[9].value,this.buttonLeftStick=this.browserGamepad.buttons[10].value,this.buttonRightStick=this.browserGamepad.buttons[11].value,this.dPadUp=this.browserGamepad.buttons[12].value,this.dPadDown=this.browserGamepad.buttons[13].value,this.dPadLeft=this.browserGamepad.buttons[14].value,this.dPadRight=this.browserGamepad.buttons[15].value)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},t}(ke),Pt=function(){function e(e){var t=this;this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new r.c,xt.a.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new r.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);break}},this._gamepadSupport&&(this._updateGamepadObjects(),this._babylonGamepads.length&&this._startMonitoringGamepads(),this._gamepadEventSupported?(window.addEventListener("gamepadconnected",this._onGamepadConnectedEvent,!1),window.addEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent,!1)):this._startMonitoringGamepads())}return Object.defineProperty(e.prototype,"gamepads",{get:function(){return this._babylonGamepads},enumerable:!0,configurable:!0}),e.prototype.getGamepadByType=function(e){void 0===e&&(e=ke.XBOX);for(var t=0,n=this._babylonGamepads;t0.5;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else{\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}";Lt.a.ShadersStore.stereoscopicInterlacePixelShader=Vt;var Ut=function(e){function t(t,n,i,r,a,s){var c=e.call(this,t,"stereoscopicInterlace",["stepSize"],["camASampler"],1,n[1],r,a,s,i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return c._passedProcess=n[0]._rigPostProcess,c._stepSize=new o.w(1/c.width,1/c.height),c.onSizeChangedObservable.add((function(){c._stepSize=new o.w(1/c.width,1/c.height)})),c.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",c._passedProcess),e.setFloat2("stepSize",c._stepSize.x,c._stepSize.y)})),c}return l.d(t,e),t}(It.a);Ce.a._setStereoscopicRigMode=function(e){var t=e.cameraRigMode===Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||e.cameraRigMode===Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;e._rigCameras[0]._rigPostProcess=new wt.b(e.name+"_passthru",1,e._rigCameras[0]),e._rigCameras[1]._rigPostProcess=new Ut(e.name+"_stereoInterlace",e._rigCameras,t)},ht.a.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,n){return function(){return new Gt(e,0,0,1,o.x.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var Gt=function(e){function t(t,n,i,r,o,a,s,c){var l=e.call(this,t,n,i,r,o,c)||this;return l.interaxialDistance=a,l.isStereoscopicSideBySide=s,l.setCameraRigMode(s?Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ce.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:a}),l}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},t}(ft);ht.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new Ht(e,o.x.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var Ht=function(e){function t(t,n,i,r,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=i,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ce.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),a}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicFreeCamera"},t}(ut.a);ht.a.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,n){return function(){return new jt(e,o.x.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var jt=function(e){function t(t,n,i,r,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=i,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ce.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),a}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},t}(Rt);ht.a.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,n){return function(){return new Wt(e,o.x.Zero(),n.interaxial_distance,n.isStereoscopicSideBySide,t)}}));var Wt=function(e){function t(t,n,i,r,o){var a=e.call(this,t,n,o)||this;return a.interaxialDistance=i,a.isStereoscopicSideBySide=r,a.setCameraRigMode(r?Ce.a.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:Ce.a.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),a}return l.d(t,e),t.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},t}(Ot);ht.a.AddNodeConstructor("VirtualJoysticksCamera",(function(e,t){return function(){return new Xt(e,o.x.Zero(),t)}}));var Xt=function(e){function t(t,n,i){var r=e.call(this,t,n,i)||this;return r.inputs.addVirtualJoystick(),r}return l.d(t,e),t.prototype.getClassName=function(){return"VirtualJoysticksCamera"},t}(ut.a),Yt=function(){function e(){this.compensateDistortion=!0,this.multiviewEnabled=!1}return Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return o.j.Translation(e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return o.j.Translation(-e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftPreViewMatrix",{get:function(){return o.j.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightPreViewMatrix",{get:function(){return o.j.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),e.GetDefault=function(){var t=new e;return t.hResolution=1280,t.vResolution=800,t.hScreenSize=.149759993,t.vScreenSize=.0935999975,t.vScreenCenter=.0467999987,t.eyeToScreenDistance=.0410000011,t.lensSeparationDistance=.063500002,t.interpupillaryDistance=.064000003,t.distortionK=[1,.219999999,.239999995,0],t.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],t.postProcessScaleFactor=1.714605507808412,t.lensCenterOffset=.151976421,t},e}(),Kt=n(6),Qt="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 LensCenter;\nuniform vec2 Scale;\nuniform vec2 ScaleIn;\nuniform vec4 HmdWarpParam;\nvec2 HmdWarp(vec2 in01) {\nvec2 theta=(in01-LensCenter)*ScaleIn;\nfloat rSq=theta.x*theta.x+theta.y*theta.y;\nvec2 rvector=theta*(HmdWarpParam.x+HmdWarpParam.y*rSq+HmdWarpParam.z*rSq*rSq+HmdWarpParam.w*rSq*rSq*rSq);\nreturn LensCenter+Scale*rvector;\n}\nvoid main(void)\n{\nvec2 tc=HmdWarp(vUV);\nif (tc.x <0.0 || tc.x>1.0 || tc.y<0.0 || tc.y>1.0)\ngl_FragColor=vec4(0.0,0.0,0.0,0.0);\nelse{\ngl_FragColor=texture2D(textureSampler,tc);\n}\n}";Lt.a.ShadersStore.vrDistortionCorrectionPixelShader=Qt;var qt=function(e){function t(t,n,i,r){var a=e.call(this,t,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,r.postProcessScaleFactor,n,Kt.a.BILINEAR_SAMPLINGMODE)||this;return a._isRightEye=i,a._distortionFactors=r.distortionK,a._postProcessScaleFactor=r.postProcessScaleFactor,a._lensCenterOffset=r.lensCenterOffset,a.adaptScaleToCurrentViewport=!0,a.onSizeChangedObservable.add((function(){a._scaleIn=new o.w(2,2/a.aspectRatio),a._scaleFactor=new o.w(1/a._postProcessScaleFactor*.5,1/a._postProcessScaleFactor*.5*a.aspectRatio),a._lensCenter=new o.w(a._isRightEye?.5-.5*a._lensCenterOffset:.5+.5*a._lensCenterOffset,.5)})),a.onApplyObservable.add((function(e){e.setFloat2("LensCenter",a._lensCenter.x,a._lensCenter.y),e.setFloat2("Scale",a._scaleFactor.x,a._scaleFactor.y),e.setFloat2("ScaleIn",a._scaleIn.x,a._scaleIn.y),e.setFloat4("HmdWarpParam",a._distortionFactors[0],a._distortionFactors[1],a._distortionFactors[2],a._distortionFactors[3])})),a}return l.d(t,e),t}(It.a),Zt="#ifdef GL_ES\nprecision mediump sampler2DArray;\n#endif\nvarying vec2 vUV;\nuniform sampler2DArray multiviewSampler;\nuniform int imageIndex;\nvoid main(void)\n{\ngl_FragColor=texture(multiviewSampler,vec3(vUV,imageIndex));\n}";Lt.a.ShadersStore.vrMultiviewToSingleviewPixelShader=Zt;var Jt=n(32),$t=n(94),en=n(39),tn=function(e){function t(t,n){void 0===n&&(n=512);var i=e.call(this,"multiview rtt",n,t,!1,!0,Jt.a.DATASOURCE_UNKNOWN,!1,void 0,!1,!1,!0,void 0,!0)||this,r=t.getEngine().createMultiviewRenderTargetTexture(i.getRenderWidth(),i.getRenderHeight());return r.isMultiview=!0,i._texture=r,i}return l.d(t,e),t.prototype._bindFrameBuffer=function(e){void 0===e&&(e=0),this._texture&&this.getScene().getEngine().bindMultiviewFramebuffer(this._texture)},t.prototype.getViewCount=function(){return 2},t}(en.a);ee.b.prototype.createMultiviewRenderTargetTexture=function(e,t){var n=this._gl;if(!this.getCaps().multiview)throw"Multiview is not supported";var i=new Jt.a(this,Jt.a.DATASOURCE_UNKNOWN,!0);return i.width=e,i.height=t,i._framebuffer=n.createFramebuffer(),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.DEPTH32F_STENCIL8,e,t,2),i.isReady=!0,i},ee.b.prototype.bindMultiviewFramebuffer=function(e){var t=this._gl,n=this.getCaps().multiview;if(this.bindFramebuffer(e,void 0,void 0,void 0,!0),t.bindFramebuffer(t.DRAW_FRAMEBUFFER,e._framebuffer),!e._colorTextureArray||!e._depthStencilTextureArray)throw"Invalid multiview frame buffer";n.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.COLOR_ATTACHMENT0,e._colorTextureArray,0,0,2),n.framebufferTextureMultiviewOVR(t.DRAW_FRAMEBUFFER,t.DEPTH_STENCIL_ATTACHMENT,e._depthStencilTextureArray,0,0,2)},Ce.a.prototype._useMultiviewToSingleView=!1,Ce.a.prototype._multiviewTexture=null,Ce.a.prototype._resizeOrCreateMultiviewTexture=function(e,t){this._multiviewTexture?this._multiviewTexture.getRenderWidth()==e&&this._multiviewTexture.getRenderHeight()==t||(this._multiviewTexture.dispose(),this._multiviewTexture=new tn(this.getScene(),{width:e,height:t})):this._multiviewTexture=new tn(this.getScene(),{width:e,height:t})},ae.a.prototype._transformMatrixR=o.j.Zero(),ae.a.prototype._multiviewSceneUbo=null,ae.a.prototype._createMultiviewUbo=function(){this._multiviewSceneUbo=new $t.a(this.getEngine(),void 0,!0),this._multiviewSceneUbo.addUniform("viewProjection",16),this._multiviewSceneUbo.addUniform("viewProjectionR",16),this._multiviewSceneUbo.addUniform("view",16)},ae.a.prototype._updateMultiviewUbo=function(e,t){e&&t&&e.multiplyToRef(t,this._transformMatrixR),e&&t&&(e.multiplyToRef(t,o.t.Matrix[0]),o.i.GetRightPlaneToRef(o.t.Matrix[0],this._frustumPlanes[3])),this._multiviewSceneUbo&&(this._multiviewSceneUbo.updateMatrix("viewProjection",this.getTransformMatrix()),this._multiviewSceneUbo.updateMatrix("viewProjectionR",this._transformMatrixR),this._multiviewSceneUbo.updateMatrix("view",this._viewMatrix),this._multiviewSceneUbo.update())},ae.a.prototype._renderMultiviewToSingleView=function(e){e._resizeOrCreateMultiviewTexture(e._rigPostProcess&&e._rigPostProcess&&e._rigPostProcess.width>0?e._rigPostProcess.width/2:this.getEngine().getRenderWidth(!0)/2,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}(ut.a),ln=function(e){function t(t){var n=e.call(this,t)||this;return n.onTriggerStateChangedObservable=new r.c,n.onMainButtonStateChangedObservable=new r.c,n.onSecondaryButtonStateChangedObservable=new r.c,n.onPadStateChangedObservable=new r.c,n.onPadValuesChangedObservable=new r.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 l.d(t,e),t.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(t.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!0,configurable:!0}),t.prototype.update=function(){e.prototype.update.call(this);for(var t=0;t\n#include\n#include\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}");Lt.a.ShadersStore.imageProcessingPixelShader=fn;n(189);var pn=function(e){function t(t,n,i,r,o,a,s,c){void 0===i&&(i=null),void 0===s&&(s=m.a.TEXTURETYPE_UNSIGNED_INT);var l=e.call(this,t,"imageProcessing",[],[],n,i,r,o,a,null,s,"postprocess",null,!0)||this;return l._fromLinearSpace=!0,l._defines={IMAGEPROCESSING:!1,VIGNETTE:!1,VIGNETTEBLENDMODEMULTIPLY:!1,VIGNETTEBLENDMODEOPAQUE:!1,TONEMAPPING:!1,TONEMAPPING_ACES:!1,CONTRAST:!1,COLORCURVES:!1,COLORGRADING:!1,COLORGRADING3D:!1,FROMLINEARSPACE:!1,SAMPLER3DGREENDEPTH:!1,SAMPLER3DBGRMAP:!1,IMAGEPROCESSINGPOSTPROCESS:!1,EXPOSURE:!1},c?(c.applyByPostProcess=!0,l._attachImageProcessingConfiguration(c,!0),l.fromLinearSpace=!1):(l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0),l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return l.d(t,e),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e,t){var 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=A.a.LastCreatedScene;this._imageProcessingConfiguration=i.imageProcessingConfiguration}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){n._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(t.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingType",{get:function(){return this._imageProcessingConfiguration.toneMappingType},set:function(e){this._imageProcessingConfiguration.toneMappingType=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ImageProcessingPostProcess"},t.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var e="";for(var t in this._defines)this._defines[t]&&(e+="#define "+t+";\r\n");var n=["textureSampler"],i=["scale"];un.a&&(un.a.PrepareSamplers(n,this._defines),un.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)},l.c([Object(De.c)()],t.prototype,"_fromLinearSpace",void 0),t}(It.a),mn=n(14),gn=n(3);ve.a._GroundMeshParser=function(e,t){return _n.Parse(e,t)};var _n=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.generateOctree=!1,i}return l.d(t,e),t.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(t.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),t.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},t.prototype.getHeightAtCoordinates=function(e,t){var n=this.getWorldMatrix(),i=o.t.Matrix[5];n.invertToRef(i);var r=o.t.Vector3[8];if(o.x.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 a=this._getFacetAt(e,t),s=-(a.x*e+a.z*t+a.w)/a.y;return o.x.TransformCoordinatesFromFloatsToRef(0,s,0,n,r),r.y},t.prototype.getNormalAtCoordinates=function(e,t){var n=new o.x(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,n),n},t.prototype.getNormalAtCoordinatesToRef=function(e,t,n){var i=this.getWorldMatrix(),r=o.t.Matrix[5];i.invertToRef(r);var a=o.t.Vector3[8];if(o.x.TransformCoordinatesFromFloatsToRef(e,0,t,r,a),e=a.x,t=a.z,ethis._maxX||tthis._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,t);return o.x.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){u=!0;var h=e.maxHeight;e.maxHeight=e.minHeight,e.minHeight=h}for(t=0;t<=e.subdivisions;t++)for(n=0;n<=e.subdivisions;n++){var d=new o.x(n*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),f=4*(((d.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(d.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),p=e.buffer[f]/255,m=e.buffer[f+1]/255,g=e.buffer[f+2]/255,_=e.buffer[f+3]/255;u&&(p=1-p,m=1-m,g=1-g);var v=p*c.r+m*c.g+g*c.b;d.y=_>=l?e.minHeight+(e.maxHeight-e.minHeight)*v:e.minHeight-o.h,r.push(d.x,d.y,d.z),a.push(0,0,0),s.push(n/e.subdivisions,1-t/e.subdivisions)}for(t=0;t=e.minHeight,T=r[3*y+1]>=e.minHeight,S=r[3*x+1]>=e.minHeight;E&&T&&S&&(i.push(b),i.push(y),i.push(x)),r[3*C+1]>=e.minHeight&&E&&S&&(i.push(C),i.push(b),i.push(x))}mn.a.ComputeNormals(r,i,a);var A=new mn.a;return A.indices=i,A.positions=r,A.normals=a,A.uvs=s,A},ve.a.CreateGround=function(e,t,n,i,r,o){var a={width:t,height:n,subdivisions:i,updatable:o};return vn.CreateGround(e,a,r)},ve.a.CreateTiledGround=function(e,t,n,i,r,o,a,s,c){var l={xmin:t,zmin:n,xmax:i,zmax:r,subdivisions:o,precision:a,updatable:c};return vn.CreateTiledGround(e,l,s)},ve.a.CreateGroundFromHeightMap=function(e,t,n,i,r,o,a,s,c,l,u){var h={width:n,height:i,subdivisions:r,minHeight:o,maxHeight:a,updatable:c,onReady:l,alphaFilter:u};return vn.CreateGroundFromHeightMap(e,t,h,s)};var vn=function(){function e(){}return e.CreateGround=function(e,t,n){var i=new _n(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,mn.a.CreateGround(t).applyToMesh(i,t.updatable),i._setReady(!0),i},e.CreateTiledGround=function(e,t,n){void 0===n&&(n=null);var i=new ve.a(e,n);return mn.a.CreateTiledGround(t).applyToMesh(i,t.updatable),i},e.CreateGroundFromHeightMap=function(e,t,n,i){void 0===i&&(i=null);var r=n.width||10,a=n.height||10,s=n.subdivisions||1,c=n.minHeight||0,l=n.maxHeight||1,u=n.colorFilter||new o.e(.3,.59,.11),h=n.alphaFilter||0,d=n.updatable,f=n.onReady;i=i||A.a.LastCreatedScene;var p=new _n(e,i);p._subdivisionsX=s,p._subdivisionsY=s,p._width=r,p._height=a,p._maxX=p._width/2,p._maxZ=p._height/2,p._minX=-p._maxX,p._minZ=-p._maxZ,p._setReady(!1);return fe.h.LoadImage(t,(function(e){var t=document.createElement("canvas"),n=t.getContext("2d");if(!n)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!i.isDisposed){var o=e.width,m=e.height;t.width=o,t.height=m,n.drawImage(e,0,0);var g=n.getImageData(0,0,o,m).data;mn.a.CreateGroundFromHeightMap({width:r,height:a,subdivisions:s,minHeight:c,maxHeight:l,colorFilter:u,buffer:g,bufferWidth:o,bufferHeight:m,alphaFilter:h}).applyToMesh(p,d),f&&f(p),p._setReady(!0)}}),(function(){}),i.offlineProvider),p},e}();mn.a.CreateTorus=function(e){for(var t=[],n=[],i=[],r=[],a=e.diameter||1,s=e.thickness||.5,c=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||mn.a.DEFAULTSIDE,u=c+1,h=0;h<=c;h++)for(var d=h/c,f=h*Math.PI*2/c-Math.PI/2,p=o.j.Translation(a/2,0,0).multiply(o.j.RotationY(f)),m=0;m<=c;m++){var g=1-m/c,_=m*Math.PI*2/c+Math.PI,v=Math.cos(_),b=Math.sin(_),y=new o.x(v,b,0),x=y.scale(s/2),C=new o.w(d,g);x=o.x.TransformCoordinates(x,p),y=o.x.TransformNormal(y,p),n.push(x.x,x.y,x.z),i.push(y.x,y.y,y.z),r.push(C.x,C.y);var E=(h+1)%u,T=(m+1)%u;t.push(h*u+m),t.push(h*u+T),t.push(E*u+m),t.push(h*u+T),t.push(E*u+T),t.push(E*u+m)}mn.a._ComputeSides(l,n,t,i,r,e.frontUVs,e.backUVs);var S=new mn.a;return S.indices=t,S.positions=n,S.normals=i,S.uvs=r,S},ve.a.CreateTorus=function(e,t,n,i,r,o,a){var s={diameter:t,thickness:n,tessellation:i,sideOrientation:a,updatable:o};return bn.CreateTorus(e,s,r)};var bn=function(){function e(){}return e.CreateTorus=function(e,t,n){var i=new ve.a(e,n);return t.sideOrientation=ve.a._GetDefaultSideOrientation(t.sideOrientation),i._originalBuilderSideOrientation=t.sideOrientation,mn.a.CreateTorus(t).applyToMesh(i,t.updatable),i},e}();mn.a.CreateCylinder=function(e){var t,n=e.height||2,i=0===e.diameterTop?0:e.diameterTop||e.diameter||1,r=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1,a=e.tessellation||24,s=e.subdivisions||1,c=!!e.hasRings,l=!!e.enclose,u=e.arc&&(e.arc<=0||e.arc>1)?1:e.arc||1,h=0===e.sideOrientation?0:e.sideOrientation||mn.a.DEFAULTSIDE,d=e.faceUV||new Array(3),f=e.faceColors,p=2+(1+(1!==u&&l?2:0))*(c?s:1);for(t=0;t=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}(Cn),Tn=function(e){function t(t,n){var i=e.call(this,n)||this;return i.getCamera=t,i}return l.d(t,e),t.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new Ee(o.x.Zero(),o.x.Forward())},t}(Cn),Sn=function(){},An=function(){function e(e,t){var n=this;if(void 0===t&&(t={}),this.webVROptions=t,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.onEnteringVRObservable=new r.c,this.onAfterEnteringVRObservable=new r.c,this.onExitingVRObservable=new r.c,this.onControllerMeshLoadedObservable=new r.c,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._rotationAllowed=!0,this._teleportBackwardsVector=new o.x(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new o.x(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this.onNewMeshSelected=new r.c,this.onNewMeshPicked=new r.c,this.onBeforeCameraTeleport=new r.c,this.onAfterCameraTeleport=new r.c,this.onSelectedMeshUnselected=new r.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.requestPointerLockOnFullScreen=!0,this._onResize=function(){n.moveButtonToBottomRight(),n._fullscreenVRpresenting&&n._webVRready&&n.exitVR()},this._onFullscreenChange=function(){var e=document;void 0!==e.fullscreen?n._fullscreenVRpresenting=document.fullscreen:void 0!==e.mozFullScreen?n._fullscreenVRpresenting=e.mozFullScreen:void 0!==e.webkitIsFullScreen?n._fullscreenVRpresenting=e.webkitIsFullScreen:void 0!==e.msIsFullScreen?n._fullscreenVRpresenting=e.msIsFullScreen:void 0!==document.msFullscreenElement&&(n._fullscreenVRpresenting=document.msFullscreenElement),!n._fullscreenVRpresenting&&n._canvas&&(n.exitVR(),n._useCustomVRButton||(n._btnVR.style.top=n._canvas.offsetTop+n._canvas.offsetHeight-70+"px",n._btnVR.style.left=n._canvas.offsetLeft+n._canvas.offsetWidth-100+"px"))},this._cachedAngularSensibility={angularSensibilityX:null,angularSensibilityY:null,angularSensibility:null},this.beforeRender=function(){n._leftController&&n._leftController._activePointer&&n._castRayAndSelectObject(n._leftController),n._rightController&&n._rightController._activePointer&&n._castRayAndSelectObject(n._rightController),n._noControllerIsActive?n._castRayAndSelectObject(n._cameraGazer):n._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==ke.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){n._teleportationInitialized&&n.teleportationEnabled&&(!n._leftController&&!n._rightController||n._leftController&&!n._leftController._activePointer&&n._rightController&&!n._rightController._activePointer)&&(n._checkTeleportWithRay(e,n._cameraGazer),n._checkTeleportBackwards(e,n._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){n._teleportationInitialized&&n._checkRotate(e,n._cameraGazer)})),e.type===ke.XBOX&&(e.onbuttondown((function(e){n._interactionsEnabled&&e===Ct.A&&n._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){n._interactionsEnabled&&e===Ct.A&&n._cameraGazer._selectionPointerUp()})));else{var t=e,i=new En(t,n._scene,n._cameraGazer._gazeTracker);"right"===t.hand||n._leftController&&n._leftController.webVRController!=t?n._rightController=i:n._leftController=i,n._tryEnableInteractionOnController(i)}},this._tryEnableInteractionOnController=function(e){n._interactionsRequested&&!e._interactionsEnabled&&n._enableInteractionOnController(e),n._teleportationRequested&&!e._teleportationEnabled&&n._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof ln&&("left"===e.hand&&null!=n._leftController&&(n._leftController.dispose(),n._leftController=null),"right"===e.hand&&null!=n._rightController&&(n._rightController.dispose(),n._rightController=null))},this._workingVector=o.x.Zero(),this._workingQuaternion=o.q.Identity(),this._workingMatrix=o.j.Identity(),this._scene=e,this._canvas=e.getEngine().getRenderingCanvas(),void 0===t.createFallbackVRDeviceOrientationFreeCamera&&(t.createFallbackVRDeviceOrientationFreeCamera=!0),void 0===t.createDeviceOrientationCamera&&(t.createDeviceOrientationCamera=!0),void 0===t.laserToggle&&(t.laserToggle=!0),void 0===t.defaultHeight&&(t.defaultHeight=1.7),t.useCustomVRButton&&(this._useCustomVRButton=!0,t.customVRButton&&(this._btnVR=t.customVRButton)),t.rayLength&&(this._rayLength=t.rayLength),this._defaultHeight=t.defaultHeight,t.positionScale&&(this._rayLength*=t.positionScale,this._defaultHeight*=t.positionScale),this._hasEnteredVR=!1,this._scene.activeCamera?this._position=this._scene.activeCamera.position.clone():this._position=new o.x(0,this._defaultHeight,0),t.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new pt("deviceOrientationVRHelper",this._position.clone(),e),this._scene.activeCamera&&(this._deviceOrientationCamera.minZ=this._scene.activeCamera.minZ,this._deviceOrientationCamera.maxZ=this._scene.activeCamera.maxZ,this._scene.activeCamera instanceof lt.a&&this._scene.activeCamera.rotation)){var i=this._scene.activeCamera;i.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(i.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(o.q.RotationYawPitchRoll(i.rotation.y,i.rotation.x,i.rotation.z)),this._deviceOrientationCamera.rotation=i.rotation.clone()}this._scene.activeCamera=this._deviceOrientationCamera,this._canvas&&this._scene.activeCamera.attachControl(this._canvas)}else this._existingCamera=this._scene.activeCamera;if(t.createFallbackVRDeviceOrientationFreeCamera&&(t.useMultiview&&(t.vrDeviceOrientationCameraMetrics||(t.vrDeviceOrientationCameraMetrics=Yt.GetDefault()),t.vrDeviceOrientationCameraMetrics.multiviewEnabled=!0),this._vrDeviceOrientationCamera=new on("VRDeviceOrientationVRHelper",this._position,this._scene,!0,t.vrDeviceOrientationCameraMetrics),this._vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._webVRCamera=new cn("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new Tn((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";".babylonVRicon.vrdisplaypresenting { display: none; }";var a=document.createElement("style");a.appendChild(document.createTextNode(".babylonVRicon { position: absolute; right: 20px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20width%3D%222048%22%20height%3D%221152%22%20viewBox%3D%220%200%202048%201152%22%20version%3D%221.1%22%3E%3Cpath%20transform%3D%22rotate%28180%201024%2C576.0000000000001%29%22%20d%3D%22m1109%2C896q17%2C0%2030%2C-12t13%2C-30t-12.5%2C-30.5t-30.5%2C-12.5l-170%2C0q-18%2C0%20-30.5%2C12.5t-12.5%2C30.5t13%2C30t30%2C12l170%2C0zm-85%2C256q59%2C0%20132.5%2C-1.5t154.5%2C-5.5t164.5%2C-11.5t163%2C-20t150%2C-30t124.5%2C-41.5q23%2C-11%2042%2C-24t38%2C-30q27%2C-25%2041%2C-61.5t14%2C-72.5l0%2C-257q0%2C-123%20-47%2C-232t-128%2C-190t-190%2C-128t-232%2C-47l-81%2C0q-37%2C0%20-68.5%2C14t-60.5%2C34.5t-55.5%2C45t-53%2C45t-53%2C34.5t-55.5%2C14t-55.5%2C-14t-53%2C-34.5t-53%2C-45t-55.5%2C-45t-60.5%2C-34.5t-68.5%2C-14l-81%2C0q-123%2C0%20-232%2C47t-190%2C128t-128%2C190t-47%2C232l0%2C257q0%2C68%2038%2C115t97%2C73q54%2C24%20124.5%2C41.5t150%2C30t163%2C20t164.5%2C11.5t154.5%2C5.5t132.5%2C1.5zm939%2C-298q0%2C39%20-24.5%2C67t-58.5%2C42q-54%2C23%20-122%2C39.5t-143.5%2C28t-155.5%2C19t-157%2C11t-148.5%2C5t-129.5%2C1.5q-59%2C0%20-130%2C-1.5t-148%2C-5t-157%2C-11t-155.5%2C-19t-143.5%2C-28t-122%2C-39.5q-34%2C-14%20-58.5%2C-42t-24.5%2C-67l0%2C-257q0%2C-106%2040.5%2C-199t110%2C-162.5t162.5%2C-109.5t199%2C-40l81%2C0q27%2C0%2052%2C14t50%2C34.5t51%2C44.5t55.5%2C44.5t63.5%2C34.5t74%2C14t74%2C-14t63.5%2C-34.5t55.5%2C-44.5t51%2C-44.5t50%2C-34.5t52%2C-14l14%2C0q37%2C0%2070%2C0.5t64.5%2C4.5t63.5%2C12t68%2C23q71%2C30%20128.5%2C78.5t98.5%2C110t63.5%2C133.5t22.5%2C149l0%2C257z%22%20fill%3D%22white%22%20/%3E%3C/svg%3E%0A); background-size: 80%; background-repeat:no-repeat; background-position: center; border: none; outline: none; transition: transform 0.125s ease-out } .babylonVRicon:hover { transform: scale(1.05) } .babylonVRicon:active {background-color: rgba(51,51,51,1) } .babylonVRicon:focus {background-color: rgba(51,51,51,1) }.babylonVRicon.vrdisplaypresenting { display: none; }")),document.getElementsByTagName("head")[0].appendChild(a),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){n.isInVRMode?n.exitVR():n.enterVR()})),window.addEventListener("resize",this._onResize),document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),document.onmsfullscreenchange=this._onFullscreenChange,t.createFallbackVRDeviceOrientationFreeCamera?this.displayVRButton():this._scene.getEngine().onVRDisplayChangedObservable.add((function(e){e.vrDisplay&&n.displayVRButton()})),this._onKeyDown=function(e){27===e.keyCode&&n.isInVRMode&&n.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add((function(){n.isInVRMode&&(n.exitVR(),n._fullscreenVRpresenting&&n._scene.getEngine().exitFullscreen())}),le.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),window.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 k,this._circleEase.setEasingMode(F.EASINGMODE_EASEINOUT),this.webVROptions.floorMeshes&&this.enableTeleportation({floorMeshes:this.webVROptions.floorMeshes})}return Object.defineProperty(e.prototype,"onEnteringVR",{get:function(){return this.onEnteringVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onExitingVR",{get:function(){return this.onExitingVRObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onControllerMeshLoaded",{get:function(){return this.onControllerMeshLoadedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"teleportationTarget",{get:function(){return this._teleportationTarget},set:function(e){e&&(e.name="teleportationTarget",this._isDefaultTeleportationTarget=!1,this._teleportationTarget=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gazeTrackerMesh",{get:function(){return this._cameraGazer._gazeTracker},set:function(e){e&&(this._cameraGazer._gazeTracker&&this._cameraGazer._gazeTracker.dispose(),this._leftController&&this._leftController._gazeTracker&&this._leftController._gazeTracker.dispose(),this._rightController&&this._rightController._gazeTracker&&this._rightController._gazeTracker.dispose(),this._cameraGazer._gazeTracker=e,this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices(),this._cameraGazer._gazeTracker.isPickable=!1,this._cameraGazer._gazeTracker.isVisible=!1,this._cameraGazer._gazeTracker.name="gazeTracker",this._leftController&&(this._leftController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")),this._rightController&&(this._rightController._gazeTracker=this._cameraGazer._gazeTracker.clone("gazeTracker")))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"leftControllerGazeTrackerMesh",{get:function(){return this._leftController?this._leftController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightControllerGazeTrackerMesh",{get:function(){return this._rightController?this._rightController._gazeTracker:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayGaze",{get:function(){return this._displayGaze},set:function(e){this._displayGaze=e,e||(this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"displayLaserPointer",{get:function(){return this._displayLaserPointer},set:function(e){this._displayLaserPointer=e,e?(this._rightController&&this._rightController._activatePointer(),this._leftController&&this._leftController._activatePointer()):(this._rightController&&(this._rightController._deactivatePointer(),this._rightController._gazeTracker.isVisible=!1),this._leftController&&(this._leftController._deactivatePointer(),this._leftController._gazeTracker.isVisible=!1))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"deviceOrientationCamera",{get:function(){return this._deviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentVRCamera",{get:function(){return this._webVRready?this._webVRCamera:this._scene.activeCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"webVRCamera",{get:function(){return this._webVRCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vrDeviceOrientationCamera",{get:function(){return this._vrDeviceOrientationCamera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"_teleportationRequestInitiated",{get:function(){return this._cameraGazer._teleportationRequestInitiated||null!==this._leftController&&this._leftController._teleportationRequestInitiated||null!==this._rightController&&this._rightController._teleportationRequestInitiated},enumerable:!0,configurable:!0}),e.prototype._onDefaultMeshLoaded=function(e){this._leftController&&this._leftController.webVRController==e&&e.mesh&&this._leftController._setLaserPointerParent(e.mesh),this._rightController&&this._rightController.webVRController==e&&e.mesh&&this._rightController._setLaserPointerParent(e.mesh);try{this.onControllerMeshLoadedObservable.notifyObservers(e)}catch(e){p.a.Warn("Error in your custom logic onControllerMeshLoaded: "+e)}},Object.defineProperty(e.prototype,"isInVRMode",{get:function(){return this._webVRpresenting||this._fullscreenVRpresenting},enumerable:!0,configurable:!0}),e.prototype.onVrDisplayPresentChange=function(){var e=this._scene.getEngine().getVRDevice();if(e){var t=this._webVRpresenting;this._webVRpresenting=e.isPresenting,t&&!this._webVRpresenting&&this.exitVR()}else p.a.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");this.updateButtonVisibility()},e.prototype.onVRDisplayChanged=function(e){this._webVRsupported=e.vrSupported,this._webVRready=!!e.vrDisplay,this._webVRpresenting=e.vrDisplay&&e.vrDisplay.isPresenting,this.updateButtonVisibility()},e.prototype.moveButtonToBottomRight=function(){this._canvas&&!this._useCustomVRButton&&(this._btnVR.style.top=this._canvas.offsetTop+this._canvas.offsetHeight-70+"px",this._btnVR.style.left=this._canvas.offsetLeft+this._canvas.offsetWidth-100+"px")},e.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},e.prototype.updateButtonVisibility=function(){this._btnVR&&!this._useCustomVRButton&&(this._btnVR.className="babylonVRicon",this.isInVRMode?this._btnVR.className+=" vrdisplaypresenting":(this._webVRready&&(this._btnVR.className+=" vrdisplayready"),this._webVRsupported&&(this._btnVR.className+=" vrdisplaysupported"),this._webVRrequesting&&(this._btnVR.className+=" vrdisplayrequesting")))},e.prototype.enterVR=function(){var e=this;if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(e){p.a.Warn("Error in your custom logic onEnteringVR: "+e)}if(this._scene.activeCamera){if(this._position=this._scene.activeCamera.position.clone(),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.rotation=o.q.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles(),this.vrDeviceOrientationCamera.angularSensibility=2e3),this.webVRCamera){var t=this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y,n=o.q.FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y-t,i=this.webVRCamera.rotationQuaternion.toEulerAngles().y;this.webVRCamera.rotationQuaternion=o.q.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._canvas&&this._scene.activeCamera.attachControl(this._canvas),this._interactionsEnabled&&this._scene.registerBeforeRender(this.beforeRender),this._displayLaserPointer&&[this._leftController,this._rightController].forEach((function(e){e&&e._activatePointer()})),this._hasEnteredVR=!0)},e.prototype.exitVR=function(){if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){p.a.Warn("Error in your custom logic onExitingVR: "+e)}this._webVRpresenting&&this._scene.getEngine().disableVR(),this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone()),this.vrDeviceOrientationCamera&&(this.vrDeviceOrientationCamera.angularSensibility=Number.MAX_VALUE),this._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._canvas&&this._scene.activeCamera.attachControl(this._canvas),this._cachedAngularSensibility.angularSensibilityX&&(this._deviceOrientationCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._deviceOrientationCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._deviceOrientationCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera,this._cachedAngularSensibility.angularSensibilityX&&(this._existingCamera.angularSensibilityX=this._cachedAngularSensibility.angularSensibilityX,this._cachedAngularSensibility.angularSensibilityX=null),this._cachedAngularSensibility.angularSensibilityY&&(this._existingCamera.angularSensibilityY=this._cachedAngularSensibility.angularSensibilityY,this._cachedAngularSensibility.angularSensibilityY=null),this._cachedAngularSensibility.angularSensibility&&(this._existingCamera.angularSensibility=this._cachedAngularSensibility.angularSensibility,this._cachedAngularSensibility.angularSensibility=null)),this.updateButtonVisibility(),this._interactionsEnabled&&(this._scene.unregisterBeforeRender(this.beforeRender),this._cameraGazer._gazeTracker.isVisible=!1,this._leftController&&(this._leftController._gazeTracker.isVisible=!1),this._rightController&&(this._rightController._gazeTracker.isVisible=!1)),this._scene.getEngine().resize(),[this._leftController,this._rightController].forEach((function(e){e&&e._deactivatePointer()})),this._hasEnteredVR=!1;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:!0,configurable:!0}),e.prototype.enableInteractions=function(){var e=this;this._interactionsEnabled||(this._interactionsRequested=!0,this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),this.raySelectionPredicate=function(t){return t.isVisible&&(t.isPickable||t.name===e._floorMeshName)},this.meshSelectionPredicate=function(){return!0},this._raySelectionPredicate=function(t){return!!(e._isTeleportationFloor(t)||-1===t.name.indexOf("gazeTracker")&&-1===t.name.indexOf("teleportationTarget")&&-1===t.name.indexOf("torusTeleportation"))&&e.raySelectionPredicate(t)},this._interactionsEnabled=!0)},Object.defineProperty(e.prototype,"_noControllerIsActive",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!0,configurable:!0}),e.prototype._isTeleportationFloor=function(e){for(var t=0;t-1||this._floorMeshesCollection.push(e))},e.prototype.removeFloorMesh=function(e){if(this._floorMeshesCollection){var t=this._floorMeshesCollection.indexOf(e);-1!==t&&this._floorMeshesCollection.splice(t,1)}},e.prototype.enableTeleportation=function(e){if(void 0===e&&(e={}),!this._teleportationInitialized){this._teleportationRequested=!0,this.enableInteractions(),e.floorMeshName&&(this._floorMeshName=e.floorMeshName),e.floorMeshes&&(this._floorMeshesCollection=e.floorMeshes),null!=this._leftController&&this._enableTeleportationOnController(this._leftController),null!=this._rightController&&this._enableTeleportationOnController(this._rightController);var t=new un.a;t.vignetteColor=new o.f(0,0,0,0),t.vignetteEnabled=!0,this._postProcessMove=new pn("postProcessMove",1,this._webVRCamera,void 0,void 0,void 0,void 0,t),this._webVRCamera.detachPostProcess(this._postProcessMove),this._teleportationInitialized=!0,this._isDefaultTeleportationTarget&&(this._createTeleportationCircles(),this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor))}},e.prototype._enableInteractionOnController=function(e){var t=this;e.webVRController.mesh&&(e._interactionsEnabled=!0,this.isInVRMode&&this._displayLaserPointer&&e._activatePointer(),this.webVROptions.laserToggle&&e.webVRController.onMainButtonStateChangedObservable.add((function(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=o.q.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,o.q.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),o.x.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var r=new Ee(i,this._workingVector),a=this._scene.pickWithRay(r,this._raySelectionPredicate);a&&a.pickedPoint&&a.pickedMesh&&this._isTeleportationFloor(a.pickedMesh)&&a.distance<5&&this.teleportCamera(a.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===vt.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=ve.a.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new dn.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 hn.a("TextPlaneMaterial",this._scene);n.diffuseTexture=e,this._teleportationTarget.material=n;var i=ve.a.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);i.isPickable=!1,i.parent=this._teleportationTarget;var r=new w.a("animationInnerCircle","position.y",30,w.a.ANIMATIONTYPE_FLOAT,w.a.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 Y;a.setEasingMode(F.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 ut.a){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var n=o.q.FromRotationMatrix(o.j.RotationY(Math.PI/4*this._rotationAngle)),i=new w.a("animationRotation","rotationQuaternion",90,w.a.ANIMATIONTYPE_QUATERNION,w.a.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 a=new w.a("animationPP","vignetteWeight",90,w.a.ANIMATIONTYPE_FLOAT,w.a.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:3,value:4}),s.push({frame:6,value:0}),a.setKeys(s),a.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(a);var c=new w.a("animationPP2","vignetteStretch",90,w.a.ANIMATIONTYPE_FLOAT,w.a.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),c.setKeys(l),c.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(c),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,6,!1,1,(function(){t._webVRCamera.detachPostProcess(t._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},e.prototype._moveTeleportationSelectorTo=function(e,t,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=o.x.Cross(o.c.Y,i),a=o.x.Cross(i,r);o.x.RotationFromAxisToRef(a,i,r,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(e){var t=this;if(this.currentVRCamera instanceof ut.a){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),e.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(e),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector),this.currentVRCamera.animations=[];var n=new w.a("animationCameraTeleportation","position",90,w.a.ANIMATIONTYPE_VECTOR3,w.a.ANIMATIONLOOPMODE_CONSTANT),i=[{frame:0,value:this.currentVRCamera.position},{frame:11,value:this._workingVector}];n.setKeys(i),n.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(n),this._postProcessMove.animations=[];var r=new w.a("animationPP","vignetteWeight",90,w.a.ANIMATIONTYPE_FLOAT,w.a.ANIMATIONLOOPMODE_CONSTANT),o=[];o.push({frame:0,value:0}),o.push({frame:5,value:8}),o.push({frame:11,value:0}),r.setKeys(o),this._postProcessMove.animations.push(r);var a=new w.a("animationPP2","vignetteStretch",90,w.a.ANIMATIONTYPE_FLOAT,w.a.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:5,value:10}),s.push({frame:11,value:0}),a.setKeys(s),this._postProcessMove.animations.push(a),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,11,!1,1,(function(){t._webVRCamera.detachPostProcess(t._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,11,!1,1,(function(){t.onAfterCameraTeleport.notifyObservers(t._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(o.x.Dot(e,t.direction))e;){var n=this.rigCameras.pop();n&&n.dispose()}},t.prototype._updateForDualEyeDebugging=function(e){void 0===e&&(e=.01),this._updateNumberOfRigCameras(2),this.rigCameras[0].viewport=new o.z(0,0,.5,1),this.rigCameras[0].position.x=-e/2,this.rigCameras[0].outputRenderTarget=null,this.rigCameras[1].viewport=new o.z(.5,0,.5,1),this.rigCameras[1].position.x=e/2,this.rigCameras[1].outputRenderTarget=null},t.prototype.updateFromXRSessionManager=function(e){var n=this;if(!e._currentXRFrame||!e._currentXRFrame.getDevicePose)return!1;var i=e._currentXRFrame.getDevicePose(e._frameOfReference);return!(!i||!i.poseModelMatrix)&&(o.j.FromFloat32ArrayToRefScaled(i.poseModelMatrix,0,1,t._TmpMatrix),this._scene.useRightHandedSystem||t._TmpMatrix.toggleModelMatrixHandInPlace(),t._TmpMatrix.getTranslationToRef(this.position),t._TmpMatrix.getRotationMatrixToRef(t._TmpMatrix),o.q.FromRotationMatrixToRef(t._TmpMatrix,this.rotationQuaternion),this.computeWorldMatrix(),this._updateNumberOfRigCameras(e._currentXRFrame.views.length),e._currentXRFrame.views.forEach((function(t,r){o.j.FromFloat32ArrayToRefScaled(i.getViewMatrix(t),0,1,n.rigCameras[r]._computedViewMatrix),o.j.FromFloat32ArrayToRefScaled(t.projectionMatrix,0,1,n.rigCameras[r]._projectionMatrix),n._scene.useRightHandedSystem||(n.rigCameras[r]._computedViewMatrix.toggleModelMatrixHandInPlace(),n.rigCameras[r]._projectionMatrix.toggleProjectionMatrixHandInPlace());var a=e._xrSession.baseLayer.getViewport(t),s=e._xrSession.baseLayer.framebufferWidth,c=e._xrSession.baseLayer.framebufferHeight;n.rigCameras[r].viewport.width=a.width/s,n.rigCameras[r].viewport.height=a.height/c,n.rigCameras[r].viewport.x=a.x/s,n.rigCameras[r].viewport.y=a.y/c,n.rigCameras[r].outputRenderTarget=e._sessionRenderTargetTexture})),!0)},t._TmpMatrix=new o.j,t}(ut.a),Mn=function(){function e(e){this.scene=e,this.onXRFrameObservable=new r.c,this.onXRSessionEnded=new r.c,this._sessionRenderTargetTexture=null,this._tmpMatrix=new o.j}return e.prototype.initializeAsync=function(){var e=this;return p.a.Warn("The WebXR APIs are still under development and are subject to change in the future."),this._xrNavigator=navigator,this._xrNavigator.xr?this._xrNavigator.xr.requestDevice().then((function(t){return e._xrDevice=t,e.scene.getEngine()._gl.setCompatibleXRDevice(e._xrDevice)})):Promise.reject("webXR not supported by this browser")},e.prototype.enterXRAsync=function(t,n){var i=this;return this._xrDevice.requestSession(t).then((function(e){return i._xrSession=e,i._xrSession.addEventListener("end",(function(){i._sessionRenderTargetTexture=null,i.scene.getEngine().restoreDefaultFramebuffer(),i.scene.getEngine().customAnimationFrameRequester=null,i.onXRSessionEnded.notifyObservers(null),i.scene.getEngine()._renderLoop()}),{once:!0}),i._xrSession.baseLayer=new XRWebGLLayer(i._xrSession,i.scene.getEngine()._gl),i._xrSession.requestFrameOfReference(n)})).then((function(t){i._frameOfReference=t,i.scene.getEngine().customAnimationFrameRequester={requestAnimationFrame:i._xrSession.requestAnimationFrame.bind(i._xrSession),renderFunction:function(e,t){i._currentXRFrame=t,i.onXRFrameObservable.notifyObservers(null),i.scene.getEngine()._renderLoop()}},i._sessionRenderTargetTexture=e._CreateRenderTargetTextureFromSession(i._xrSession,i.scene),window.cancelAnimationFrame(i.scene.getEngine()._frameHandler),i.scene.getEngine()._renderLoop()}))},e.prototype.exitXRAsync=function(){return this._xrSession.end()},e.prototype.environmentPointHitTestAsync=function(e){var t=this;return new Promise((function(n){var i=new Float32Array([e.origin.x,e.origin.y,e.origin.z]),r=new Float32Array([e.direction.x,e.direction.y,e.direction.z]);t.scene.useRightHandedSystem||(i[2]*=-1,r[2]*=-1),t._xrSession.requestHitTest(i,r,t._frameOfReference).then((function(e){if(e.length>0){o.j.FromFloat32ArrayToRefScaled(e[0].hitMatrix,0,1,t._tmpMatrix);var i=t._tmpMatrix.getTranslation();t.scene.useRightHandedSystem||(i.z*=-1),n(i)}else n(null)})).catch((function(){n(null)}))}))},e.prototype.supportsSessionAsync=function(e){return this._xrDevice.supportsSession(e).then((function(){return!0})).catch((function(){return!1}))},e._CreateRenderTargetTextureFromSession=function(e,t){var n=new Jt.a(t.getEngine(),Jt.a.DATASOURCE_UNKNOWN,!0);n.width=e.baseLayer.framebufferWidth,n.height=e.baseLayer.framebufferHeight,n._framebuffer=e.baseLayer.framebuffer;var i=new en.a("XR renderTargetTexture",{width:n.width,height:n.height},t,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,!0);return i._texture=n,i},e.prototype.dispose=function(){this.onXRFrameObservable.clear(),this.onXRSessionEnded.clear()},e}();!function(e){e[e.ENTERING_XR=0]="ENTERING_XR",e[e.EXITING_XR=1]="EXITING_XR",e[e.IN_XR=2]="IN_XR",e[e.NOT_IN_XR=3]="NOT_IN_XR"}(yn||(yn={}));var On,Rn=function(){function e(e){this.scene=e,this.state=yn.NOT_IN_XR,this.onStateChangedObservable=new r.c,this._nonVRCamera=null,this._originalSceneAutoClear=!0,this._supported=!1,this.camera=new Pn("",e),this._sessionManager=new Mn(e),this.container=new Me.a("",e),this.camera.parent=this.container}return e.prototype._setState=function(e){this.state=e,this.onStateChangedObservable.notifyObservers(this.state)},e.CreateAsync=function(t){var n=new e(t);return n._sessionManager.initializeAsync().then((function(){return n._supported=!0,n})).catch((function(){return n}))},e.prototype.exitXRAsync=function(){return this._setState(yn.EXITING_XR),this._sessionManager.exitXRAsync()},e.prototype.enterXRAsync=function(e,t){var n=this;if(!this._supported)throw"XR session not supported by this browser";return this._setState(yn.ENTERING_XR),this._sessionManager.enterXRAsync(e,t).then((function(){n._originalSceneAutoClear=n.scene.autoClear,n._nonVRCamera=n.scene.activeCamera,n.scene.autoClear=!1,n.scene.activeCamera=n.camera,n._sessionManager.onXRFrameObservable.add((function(){n.camera.updateFromXRSessionManager(n._sessionManager)})),n._sessionManager.onXRSessionEnded.addOnce((function(){n.camera.rigCameras.forEach((function(e){e.outputRenderTarget=null})),n.scene.autoClear=n._originalSceneAutoClear,n.scene.activeCamera=n._nonVRCamera,n._sessionManager.onXRFrameObservable.clear(),n._setState(yn.NOT_IN_XR)})),n._setState(yn.IN_XR)}))},e.prototype.environmentPointHitTestAsync=function(e){return this._sessionManager.environmentPointHitTestAsync(e)},e.prototype.setPositionOfCameraUsingContainer=function(t){this.camera.globalPosition.subtractToRef(t,e._TmpVector),this.container.position.subtractInPlace(e._TmpVector)},e.prototype.rotateCameraByQuaternionUsingContainer=function(e){this.container.rotationQuaternion||(this.container.rotationQuaternion=o.q.FromEulerVector(this.container.rotation)),this.container.rotationQuaternion.multiplyInPlace(e),this.container.position.rotateByQuaternionAroundPointToRef(e,this.camera.globalPosition,this.container.position)},e.prototype.supportsSessionAsync=function(e){return this._supported?this._sessionManager.supportsSessionAsync(e):Promise.resolve(!1)},e.prototype.dispose=function(){this.camera.dispose(),this.container.dispose(),this.onStateChangedObservable.clear(),this._sessionManager.dispose()},e._TmpVector=new o.x,e}(),wn=function(){function e(e,t){this.element=e,this.initializationOptions=t}return e.prototype.update=function(e){},e}(),In=function(){},Ln=function(){function e(e,t){var n=this;if(this.scene=e,this._buttons=[],this._activeButton=null,this.activeButtonChangedObservable=new r.c,this._overlay=document.createElement("div"),this._overlay.style.cssText="z-index:11;position: absolute; right: 20px;bottom: 50px;",t.customButtons)this._buttons=t.customButtons;else{var i=document.createElement("button");i.style.cssText="color: #868686; border-color: #868686; border-style: solid; margin-left: 10px; height: 50px; width: 80px; background-color: rgba(51,51,51,0.7); background-repeat:no-repeat; background-position: center; outline: none;",i.innerText="HMD",this._buttons.push(new wn(i,{immersive:!0,outputContext:t.outputCanvasContext})),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",this.element.innerText=e===this?"EXIT":"HMD"};var o=document.createElement("button");o.style.cssText=i.style.cssText,o.innerText="Window",this._buttons.push(new wn(o,{immersive:!1,environmentIntegration:!0,outputContext:t.outputCanvasContext})),this._buttons[this._buttons.length-1].update=function(e){this.element.style.display=null===e||e===this?"":"none",this.element.innerText=e===this?"EXIT":"Window"},this._updateButtons(null)}var a=e.getEngine().getRenderingCanvas();a&&a.parentNode&&(a.parentNode.appendChild(this._overlay),e.onDisposeObservable.addOnce((function(){n.dispose()})))}return e.CreateAsync=function(t,n,i){var r=this,o=new e(t,i),a=o._buttons.map((function(e){return n.supportsSessionAsync(e.initializationOptions)}));return n.onStateChangedObservable.add((function(e){e==yn.NOT_IN_XR&&o._updateButtons(null)})),Promise.all(a).then((function(e){return e.forEach((function(e,t){e&&(o._overlay.appendChild(o._buttons[t].element),o._buttons[t].element.onclick=function(){return l.b(r,void 0,void 0,(function(){return l.e(this,(function(e){switch(e.label){case 0:return n.state!=yn.IN_XR?[3,2]:(o._updateButtons(null),[4,n.exitXRAsync()]);case 1:return e.sent(),[2];case 2:return n.state!=yn.NOT_IN_XR?[3,4]:(o._updateButtons(o._buttons[t]),[4,n.enterXRAsync(o._buttons[t].initializationOptions,"eye-level")]);case 3:e.sent(),e.label=4;case 4:return[2]}}))}))})})),o}))},e.prototype._updateButtons=function(e){var t=this;this._activeButton=e,this._buttons.forEach((function(e){e.update(t._activeButton)})),this.activeButtonChangedObservable.notifyObservers(this._activeButton)},e.prototype.dispose=function(){var e=this.scene.getEngine().getRenderingCanvas();e&&e.parentNode&&e.parentNode.contains(this._overlay)&&e.parentNode.removeChild(this._overlay),this.activeButtonChangedObservable.clear()},e}(),Dn=function(){function e(e){this.pointer=new Me.a("controllerPointer",e)}return e.prototype.dispose=function(){this.grip&&this.grip.dispose(),this.pointer.dispose()},e}(),Nn=function(){function e(e){var t=this;this.helper=e,this.controllers=[],this._tmpMatrix=new o.j,this._frameObserver=e._sessionManager.onXRFrameObservable.add((function(){if(e._sessionManager._currentXRFrame&&e._sessionManager._currentXRFrame.getDevicePose){var n=e._sessionManager._currentXRFrame;e._sessionManager._xrSession.getInputSources().forEach((function(i,r){var a=n.getInputPose(i,e._sessionManager._frameOfReference);if(a){t.controllers.length<=r&&t.controllers.push(new Dn(e.container.getScene()));var s=t.controllers[r];a.gripMatrix&&(s.grip||(s.grip=new Me.a("controllerGrip",e.container.getScene())),o.j.FromFloat32ArrayToRefScaled(a.gripMatrix,0,1,t._tmpMatrix),s.grip.getScene().useRightHandedSystem||t._tmpMatrix.toggleModelMatrixHandInPlace(),s.grip.rotationQuaternion||(s.grip.rotationQuaternion=new o.q),t._tmpMatrix.decompose(s.grip.scaling,s.grip.rotationQuaternion,s.grip.position)),o.j.FromFloat32ArrayToRefScaled(a.targetRay.transformMatrix,0,1,t._tmpMatrix),s.pointer.getScene().useRightHandedSystem||t._tmpMatrix.toggleModelMatrixHandInPlace(),s.pointer.rotationQuaternion||(s.pointer.rotationQuaternion=new o.q),t._tmpMatrix.decompose(s.pointer.scaling,s.pointer.rotationQuaternion,s.pointer.position)}}))}}))}return e.prototype.dispose=function(){this.controllers.forEach((function(e){e.dispose()})),this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver)},e}(),Fn=function(){function e(e,t){var n=this;this._canvas=null,this.canvasContext=null,t||((t=document.createElement("canvas")).style.cssText="position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;"),this._setManagedOutputCanvas(t),e.onStateChangedObservable.add((function(t){t==yn.ENTERING_XR?n._addCanvas():e.state==yn.NOT_IN_XR&&n._removeCanvas()}))}return e.prototype.dispose=function(){this._removeCanvas(),this._setManagedOutputCanvas(null)},e.prototype._setManagedOutputCanvas=function(e){this._removeCanvas(),e?(this._canvas=e,this.canvasContext=this._canvas.getContext("xrpresent")):(this._canvas=null,this.canvasContext=null)},e.prototype._addCanvas=function(){this._canvas&&document.body.appendChild(this._canvas)},e.prototype._removeCanvas=function(){this._canvas&&document.body.contains(this._canvas)&&document.body.removeChild(this._canvas)},e}(),kn=(On={root:0,found:!1},function(e,t,n,i){On.root=0,On.found=!1;var r=t*t-4*e*n;if(r<0)return On;var o=Math.sqrt(r),a=(-t-o)/(2*e),s=(-t+o)/(2*e);if(a>s){var c=s;s=a,a=c}return a>0&&a0&&s=0))},e.prototype._canDoCollision=function(e,t,n,i){var r=o.x.Distance(this._basePointWorld,e),a=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(r>this._velocityWorldLength+a+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+a)},e.prototype._testTriangle=function(e,t,n,i,r,a){var s,c=!1;t||(t=[]),t[e]||(t[e]=new o.n(0,0,0,0),t[e].copyFromPoints(n,i,r));var l=t[e];if(a||l.isFrontFacingTo(this._normalizedVelocity,0)){var u=l.signedDistanceTo(this._basePoint),h=o.x.Dot(l.normal,this._velocity);if(0==h){if(Math.abs(u)>=1)return;c=!0,s=0}else{var d=(1-u)/h;if((s=(-1-u)/h)>d){var f=d;d=s,s=f}if(s>1||d<0)return;s<0&&(s=0),s>1&&(s=1)}this._collisionPoint.copyFromFloats(0,0,0);var p=!1,m=1;if(c||(this._basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(s,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,i,r,l.normal)&&(p=!0,m=s,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!p){var g=this._velocity.lengthSquared(),_=g;this._basePoint.subtractToRef(n,this._tempVector);var v=2*o.x.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,y=kn(_,v,b,m);y.found&&(m=y.root,p=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(i,this._tempVector),v=2*o.x.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,(y=kn(_,v,b,m)).found&&(m=y.root,p=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(r,this._tempVector),v=2*o.x.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,(y=kn(_,v,b,m)).found&&(m=y.root,p=!0,this._collisionPoint.copyFrom(r)),i.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex);var x=this._edge.lengthSquared(),C=o.x.Dot(this._edge,this._velocity),E=o.x.Dot(this._edge,this._baseToVertex);if(_=x*-g+C*C,v=x*(2*o.x.Dot(this._velocity,this._baseToVertex))-2*C*E,b=x*(1-this._baseToVertex.lengthSquared())+E*E,(y=kn(_,v,b,m)).found){var T=(C*y.root-E)/x;T>=0&&T<=1&&(m=y.root,p=!0,this._edge.scaleInPlace(T),n.addToRef(this._edge,this._collisionPoint))}r.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex),x=this._edge.lengthSquared(),C=o.x.Dot(this._edge,this._velocity),E=o.x.Dot(this._edge,this._baseToVertex),_=x*-g+C*C,v=x*(2*o.x.Dot(this._velocity,this._baseToVertex))-2*C*E,b=x*(1-this._baseToVertex.lengthSquared())+E*E,(y=kn(_,v,b,m)).found&&(T=(C*y.root-E)/x)>=0&&T<=1&&(m=y.root,p=!0,this._edge.scaleInPlace(T),i.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),x=this._edge.lengthSquared(),C=o.x.Dot(this._edge,this._velocity),E=o.x.Dot(this._edge,this._baseToVertex),_=x*-g+C*C,v=x*(2*o.x.Dot(this._velocity,this._baseToVertex))-2*C*E,b=x*(1-this._baseToVertex.lengthSquared())+E*E,(y=kn(_,v,b,m)).found&&(T=(C*y.root-E)/x)>=0&&T<=1&&(m=y.root,p=!0,this._edge.scaleInPlace(T),r.addToRef(this._edge,this._collisionPoint))}if(p){var S=m*this._velocity.length();(!this.collisionFound||S=i)r.copyFrom(e);else{var s=o?o.collisionMask:n.collisionMask;n._initialize(e,t,a);for(var c=0;cthis.capacity&&this._depth-1&&this.entries.splice(n,1)}},e.prototype.addEntries=function(e){for(var t=0;ts.snapDistance){var t=Math.floor(Math.abs(h)/s.snapDistance);h%=s.snapDistance,p.normalizeToRef(d),d.scaleInPlace(s.snapDistance*t),s.attachedMesh.position.addInPlace(d),f.snapDistance=s.snapDistance*t,s.onSnapObservable.notifyObservers(f)}})),s._pointerObserver=a.utilityLayerScene.onPointerObservable.add((function(e){if(!s._customMeshSet){var t=e.pickInfo&&-1!=s._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?l:c;s._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var g=a._getSharedGizmoLight();return g.includedOnlyMeshes=g.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1)),s}return l.d(t,e),t._CreateArrow=function(e,t){var n=new Kn.a("arrow",e),i=xn.CreateCylinder("cylinder",{diameterTop:0,height:.075,diameterBottom:.0375,tessellation:96},e),r=xn.CreateCylinder("cylinder",{diameterTop:.005,height:.275,diameterBottom:.005,tessellation:96},e);return r.material=t,i.parent=n,r.parent=n,i.material=t,i.rotation.x=Math.PI/2,i.position.z+=.3,r.position.z+=.1375,r.rotation.x=Math.PI/2,n},t._CreateArrowInstance=function(e,t){for(var n=new Kn.a("arrow",e),i=0,r=t.getChildMeshes();i1)?1:e.arc||1,s=e.slice&&e.slice<=0?1:e.slice||1,c=0===e.sideOrientation?0:e.sideOrientation||mn.a.DEFAULTSIDE,l=new o.x(n/2,i/2,r/2),u=2+t,h=2*u,d=[],f=[],p=[],m=[],g=0;g<=u;g++){for(var _=g/u,v=_*Math.PI*s,b=0;b<=h;b++){var y=b/h,x=y*Math.PI*2*a,C=o.j.RotationZ(-v),E=o.j.RotationY(x),T=o.x.TransformCoordinates(o.x.Up(),C),S=o.x.TransformCoordinates(T,E),A=S.multiply(l),P=S.divide(l).normalize();f.push(A.x,A.y,A.z),p.push(P.x,P.y,P.z),m.push(y,_)}if(g>0)for(var M=f.length/3,O=M-2*(h+1);O+h+2100&&(this.soft=!0),this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=o.q.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new o.q),this._options.mass=void 0===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&&p.a.Warn("You must affect impostors to children before affecting impostor to parent.")):p.a.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):p.a.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(e.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mass",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyMass(this):0},set:function(e){this.setMass(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"friction",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyFriction(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyFriction(this,e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"restitution",{get:function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this):0},set:function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this,e)},enumerable:!0,configurable:!0}),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:!0,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:!0,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:!0,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:!0,configurable:!0}),e.prototype._init=function(){this._physicsEngine&&(this._physicsEngine.removeImpostor(this),this.physicsBody=null,this._parent=this._parent||this._getPhysicsParent(),this._isDisposed||this.parent&&!this._options.ignoreParent||this._physicsEngine.addImpostor(this))},e.prototype._getPhysicsParent=function(){return this.object.parent instanceof Me.a?this.object.parent.physicsImpostor:null},e.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},e.prototype.setScalingUpdated=function(){this.forceUpdate()},e.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(e.prototype,"physicsBody",{get:function(){return this._parent&&!this._options.ignoreParent?this._parent.physicsBody:this._physicsBody},set:function(e){this._physicsBody&&this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this),this._physicsBody=e,this.resetUpdateFlags()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!0,configurable:!0}),e.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},e.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var t=this.object.rotationQuaternion;this.object.rotationQuaternion=e.IDENTITY_QUATERNION,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);var n=this.object.getBoundingInfo().boundingBox.extendSizeWorld.scale(2);return this.object.rotationQuaternion=t,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),n}return e.DEFAULT_OBJECT_SIZE},e.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},e.prototype.getParam=function(e){return this._options[e]},e.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},e.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},e.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):o.x.Zero()},e.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},e.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):o.x.Zero()},e.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},e.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},e.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},e.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);t>-1?this._onBeforePhysicsStepCallbacks.splice(t,1):p.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):p.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],i=-1;this._onPhysicsCollideCallbacks.some((function(e,r){if(e.callback===t&&e.otherImpostors.length===n.length){var o=e.otherImpostors.every((function(e){return n.indexOf(e)>-1}));return o&&(i=r),o}return!1}))?this._onPhysicsCollideCallbacks.splice(i,1):p.a.Warn("Function to remove was not found")},e.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):o.q.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,e.rotation.z,this._tmpQuat2),this._tmpQuat.multiplyToRef(this._tmpQuat2,this._tmpQuat),e=e.parent;return this._tmpQuat},e.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},e.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},e.prototype.createJoint=function(e,t,n){var i=new ii(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.q),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},e.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},e.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},e.prototype.syncBoneWithImpostor=function(t,n,i,r,a){var s=e._tmpVecs[0],c=this.object;if(c.rotationQuaternion)if(a){var l=e._tmpQuat;c.rotationQuaternion.multiplyToRef(a,l),t.setRotationQuaternion(l,o.s.WORLD,n)}else t.setRotationQuaternion(c.rotationQuaternion,o.s.WORLD,n);s.x=0,s.y=0,s.z=0,i&&(s.x=i.x,s.y=i.y,s.z=i.z,t.getDirectionToRef(s,n,s),null==r&&(r=i.length()),s.x*=r,s.y*=r,s.z*=r),t.getParent()?(s.addInPlace(c.getAbsolutePosition()),t.setAbsolutePosition(s,n)):(n.setAbsolutePosition(c.getAbsolutePosition()),n.position.x-=s.x,n.position.y-=s.y,n.position.z-=s.z)},e.prototype.syncImpostorWithBone=function(t,n,i,r,a,s){var c=this.object;if(c.rotationQuaternion)if(a){var l=e._tmpQuat;t.getRotationQuaternionToRef(o.s.WORLD,n,l),l.multiplyToRef(a,c.rotationQuaternion)}else t.getRotationQuaternionToRef(o.s.WORLD,n,c.rotationQuaternion);var u=e._tmpVecs[0],h=e._tmpVecs[1];s||((s=e._tmpVecs[2]).x=0,s.y=1,s.z=0),t.getDirectionToRef(s,n,h),t.getAbsolutePositionToRef(n,u),null==r&&i&&(r=i.length()),null!=r&&(u.x+=h.x*r,u.y+=h.y*r,u.z+=h.z*r),c.setAbsolutePosition(u)},e.DEFAULT_OBJECT_SIZE=new o.x(1,1,1),e.IDENTITY_QUATERNION=o.q.Identity(),e._tmpVecs=be.a.BuildArray(3,o.x.Zero),e._tmpQuat=o.q.Identity(),e.NoImpostor=0,e.SphereImpostor=1,e.BoxImpostor=2,e.PlaneImpostor=3,e.MeshImpostor=4,e.CylinderImpostor=7,e.ParticleImpostor=8,e.HeightmapImpostor=9,e.ConvexHullImpostor=10,e.RopeImpostor=101,e.ClothImpostor=102,e.SoftbodyImpostor=103,e}(),li=function(){function e(e){this._impostors=[],this._meshes=[],this._numMeshes=0,this._debugMeshMeshes=new Array,this._scene=e||A.a.LastCreatedScene;var t=this._scene.getPhysicsEngine();t&&(this._physicsEnginePlugin=t.getPhysicsPlugin()),this._utilityLayer=new Qn.a(this._scene,!1),this._utilityLayer.pickUtilitySceneFirst=!1,this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil=!0}return e.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t-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 hn.a("",e),this._debugMaterial.wireframe=!0,this._debugMaterial.emissiveColor=o.e.White(),this._debugMaterial.disableLighting=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=ti.a.CreateBox("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.rotationQuaternion=o.q.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=ni.CreateSphere("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.rotationQuaternion=o.q.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),this._debugSphereMesh.setEnabled(!1)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugCylinderMesh=function(e){return this._debugCylinderMesh||(this._debugCylinderMesh=xn.CreateCylinder("physicsBodyCylinderViewMesh",{diameterTop:1,diameterBottom:1,height:1},e),this._debugCylinderMesh.rotationQuaternion=o.q.Identity(),this._debugCylinderMesh.material=this._getDebugMaterial(e),this._debugCylinderMesh.setEnabled(!1)),this._debugCylinderMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugMeshMesh=function(e,t){var n=new ve.a(e.name,t,null,e);return n.position=o.x.Zero(),n.setParent(e),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 ci.BoxImpostor:i=this._getDebugBoxMesh(r),e.getBoxSizeToRef(i.scaling);break;case ci.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 ci.MeshImpostor:t&&(i=this._getDebugMeshMesh(t,r));break;case ci.NoImpostor:if(t)t.getChildMeshes().filter((function(e){return e.physicsImpostor?1:0})).forEach((function(e){n._getDebugBoxMesh(r).parent=e}));break;case ci.CylinderImpostor:i=this._getDebugCylinderMesh(r);var a=e.object.getBoundingInfo();i.scaling.x=a.boundingBox.maximum.x-a.boundingBox.minimum.x,i.scaling.y=a.boundingBox.maximum.y-a.boundingBox.minimum.y,i.scaling.z=a.boundingBox.maximum.z-a.boundingBox.minimum.z}return i},e.prototype.dispose=function(){for(var e=this._numMeshes,t=0;t0&&(t.push(a-1),t.push(a)),a++}var h=new mn.a;return h.indices=t,h.positions=n,r&&(h.colors=o),h},mn.a.CreateDashedLines=function(e){var t,n,i=e.dashSize||3,r=e.gapSize||1,a=e.dashNb||200,s=e.points,c=new Array,l=new Array,u=o.x.Zero(),h=0,d=0,f=0,p=0,m=0;for(m=0;m=0;s--){var c=e[s],l=c.getParent();if(l){var u=this._debugLines[i];u||(u=[o.x.Zero(),o.x.Zero()],this._debugLines[i]=u),c.getAbsolutePositionToRef(r,u[0]),l.getAbsolutePositionToRef(r,u[1]),u[0].subtractInPlace(a),u[1].subtractInPlace(a),i++}}},e.prototype.update=function(){if(this._utilityLayer){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms();var e=this.mesh._effectiveMesh;void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,e.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,e.getWorldMatrix());var t=this._utilityLayer.utilityLayerScene;this._debugMesh?hi.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},t):(this._debugMesh=hi.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},t),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color}},e.prototype.dispose=function(){this.isEnabled=!1,this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null),this._utilityLayer&&(this._utilityLayer.dispose(),this._utilityLayer=null)},e}(),pi=n(198),mi=function(){this._timeElapsedQueryEnded=!1},gi=function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=Me.a.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=Me.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE};ee.b.prototype.createQuery=function(){return this._gl.createQuery()},ee.b.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},ee.b.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},ee.b.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},ee.b.prototype.beginOcclusionQuery=function(e,t){var n=this._getGlAlgorithmType(e);return this._gl.beginQuery(n,t),this},ee.b.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},ee.b.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},ee.b.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},ee.b.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},ee.b.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},ee.b.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var n=new mi;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),e.canUseTimestampForTimerQuery)n._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(n._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;n._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,n._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,n._timeElapsedQuery),this._currentNonTimestampToken=n}return n},ee.b.prototype.endTimeQuery=function(e){var t=this.getCaps(),n=t.timerQuery;if(!n||!e)return-1;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),n.queryCounterEXT(e._endTimeQuery,n.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;n.endQueryEXT?n.endQueryEXT(n.TIME_ELAPSED_EXT):this._gl.endQuery(n.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var i=this._gl.getParameter(n.GPU_DISJOINT_EXT),r=!1;if(e._endTimeQuery?r=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(r=this._getTimeQueryAvailability(e._timeElapsedQuery)),r&&!i){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var a=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-a,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;o=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return o}return-1},ee.b.prototype._getGlAlgorithmType=function(e){return e===Me.a.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(Me.a.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},enumerable:!1,configurable:!0}),Object.defineProperty(Me.a.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new gi),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(Me.a.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(Me.a.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Me.a.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Me.a.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),Me.a.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===Me.a.OCCLUSION_TYPE_NONE)return e.isOccluded=!1,!1;var t=this.getEngine();if(t.webGLVersion<2)return e.isOccluded=!1,!1;if(!t.isQueryResultAvailable)return e.isOccluded=!1,!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var n=t.getQueryResult(this._occlusionQuery);e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=1!==n}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return!1;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==Me.a.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var i=this.getScene();if(i.getBoundingBoxRenderer){var r=i.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),r.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded};ee.b.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},ee.b.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},ee.b.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},ee.b.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},ee.b.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},ee.b.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},ee.b.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e?e.underlyingResource:null)};var _i=n(161),vi=n(82),bi=n(34),yi=function(e){function t(t){var n=e.call(this,t)||this;return n.controllerType=vt.DAYDREAM,n}return l.d(t,e),t.prototype.initControllerMesh=function(e,n){var i=this;bi.a.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,(function(e){i._defaultModel=e[1],i.attachToMesh(i._defaultModel),n&&n(i._defaultModel)}))},t.prototype._handleButtonChange=function(e,t,n){if(0===e){var i=this.onTriggerStateChangedObservable;i&&i.notifyObservers(t)}else p.a.Warn("Unrecognized Daydream button index: "+e)},t.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",t.MODEL_FILENAME="generic.babylon",t.GAMEPAD_ID_PREFIX="Daydream",t}(ln);Tt._ControllerFactories.push({canCreate:function(e){return 0===e.id.indexOf(yi.GAMEPAD_ID_PREFIX)},create:function(e){return new yi(e)}});var xi=function(e){function t(t){var n=e.call(this,t)||this;return n._buttonIndexToObservableNameMap=["onPadStateChangedObservable","onTriggerStateChangedObservable"],n.controllerType=vt.GEAR_VR,n._calculatedPosition=new o.x("left"==n.hand?-.15:.15,-.5,.25),n._disableTrackPosition(n._calculatedPosition),n}return l.d(t,e),t.prototype.initControllerMesh=function(e,n){var i=this;bi.a.ImportMesh("",t.MODEL_BASE_URL,t.MODEL_FILENAME,e,(function(t){var r=new ve.a("",e);t[1].parent=r,t[1].position.z=-.15,i._defaultModel=r,i.attachToMesh(i._defaultModel),n&&n(i._defaultModel)}))},t.prototype._handleButtonChange=function(e,t,n){if(ea.snapDistance?(r=Math.floor(Math.abs(h)/a.snapDistance),h<0&&(r*=-1),h%=a.snapDistance,d.scaleToRef(a.snapDistance*r,d),i=!0):d.scaleInPlace(0)),a.attachedMesh.scaling.addInPlace(d),i&&(f.snapDistance=a.snapDistance*r,a.onSnapObservable.notifyObservers(f))}})),a._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){if(!a._customMeshSet){var t=e.pickInfo&&-1!=a._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?s:a._coloredMaterial;a._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var p=i._getSharedGizmoLight();return p.includedOnlyMeshes=p.includedOnlyMeshes.concat(a._rootMesh.getChildMeshes()),a}return l.d(t,e),t.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this)},t.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}(qn),Mi=function(e){function t(t,n){void 0===t&&(t=o.e.Gray()),void 0===n&&(n=Qn.a.DefaultKeepDepthUtilityLayer);var i=e.call(this,n)||this;i._boundingDimensions=new o.x(1,1,1),i._renderObserver=null,i._pointerObserver=null,i._scaleDragSpeed=.2,i._tmpQuaternion=new o.q,i._tmpVector=new o.x(0,0,0),i._tmpRotationMatrix=new o.j,i.ignoreChildren=!1,i.includeChildPredicate=null,i.rotationSphereSize=.1,i.scaleBoxSize=.1,i.fixedDragMeshScreenSize=!1,i.fixedDragMeshScreenSizeDistanceFactor=10,i.onDragStartObservable=new r.c,i.onScaleBoxDragObservable=new r.c,i.onScaleBoxDragEndObservable=new r.c,i.onRotationSphereDragObservable=new r.c,i.onRotationSphereDragEndObservable=new r.c,i.scalePivot=null,i._existingMeshScale=new o.x,i._dragMesh=null,i.pointerDragBehavior=new Ae,i._updateScale=!1,i._anchorMesh=new Me.a("anchor",n.utilityLayerScene),i.coloredMaterial=new hn.a("",n.utilityLayerScene),i.coloredMaterial.disableLighting=!0,i.hoverColoredMaterial=new hn.a("",n.utilityLayerScene),i.hoverColoredMaterial.disableLighting=!0,i._lineBoundingBox=new Me.a("",n.utilityLayerScene),i._lineBoundingBox.rotationQuaternion=new o.q;var a=[];a.push(hi.CreateLines("lines",{points:[new o.x(0,0,0),new o.x(i._boundingDimensions.x,0,0)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(0,0,0),new o.x(0,i._boundingDimensions.y,0)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(0,0,0),new o.x(0,0,i._boundingDimensions.z)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(i._boundingDimensions.x,0,0),new o.x(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(i._boundingDimensions.x,0,0),new o.x(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(0,i._boundingDimensions.y,0),new o.x(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(0,i._boundingDimensions.y,0),new o.x(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(0,0,i._boundingDimensions.z),new o.x(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(0,0,i._boundingDimensions.z),new o.x(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new o.x(0,i._boundingDimensions.y,i._boundingDimensions.z)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new o.x(i._boundingDimensions.x,0,i._boundingDimensions.z)]},n.utilityLayerScene)),a.push(hi.CreateLines("lines",{points:[new o.x(i._boundingDimensions.x,i._boundingDimensions.y,i._boundingDimensions.z),new o.x(i._boundingDimensions.x,i._boundingDimensions.y,0)]},n.utilityLayerScene)),a.forEach((function(e){e.color=t,e.position.addInPlace(new o.x(-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 Me.a("",n.utilityLayerScene),i._rotateSpheresParent.rotationQuaternion=new o.q;for(var s=function(e){var t=ni.CreateSphere("",{diameter:1},n.utilityLayerScene);t.rotationQuaternion=new o.q,t.material=c.coloredMaterial,(d=new Ae({})).moveAttached=!1,d.updateDragPlane=!1,t.addBehavior(d);var r=new o.x(1,0,0),a=0;d.onDragStartObservable.add((function(){r.copyFrom(t.forward),a=0})),d.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 p.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");Te._RemoveAndStorePivotPoint(i.attachedMesh);var s=r,c=t.dragPlaneNormal.scale(o.x.Dot(t.dragPlaneNormal,s)),l=s.subtract(c).normalizeToNew(),u=o.x.Dot(l,t.delta)<0?Math.abs(t.delta.length()):-Math.abs(t.delta.length());u=u/i._boundingDimensions.length()*i._anchorMesh.scaling.length(),i.attachedMesh.rotationQuaternion||(i.attachedMesh.rotationQuaternion=o.q.RotationYawPitchRoll(i.attachedMesh.rotation.y,i.attachedMesh.rotation.x,i.attachedMesh.rotation.z)),i._anchorMesh.rotationQuaternion||(i._anchorMesh.rotationQuaternion=o.q.RotationYawPitchRoll(i._anchorMesh.rotation.y,i._anchorMesh.rotation.x,i._anchorMesh.rotation.z)),a+=u,Math.abs(a)<=2*Math.PI&&(e>=8?o.q.RotationYawPitchRollToRef(0,0,u,i._tmpQuaternion):e>=4?o.q.RotationYawPitchRollToRef(u,0,0,i._tmpQuaternion):o.q.RotationYawPitchRollToRef(0,u,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(),Te._RestorePivotPoint(i.attachedMesh)}i._updateDummy()})),d.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({}),i._selectNode(t)})),d.onDragEndObservable.add((function(){i.onRotationSphereDragEndObservable.notifyObservers({}),i._selectNode(null),i._updateDummy()})),c._rotateSpheresParent.addChild(t)},c=this,l=0;l<12;l++)s(l);i._rootMesh.addChild(i._rotateSpheresParent),i._scaleBoxesParent=new Me.a("",n.utilityLayerScene),i._scaleBoxesParent.rotationQuaternion=new o.q;for(var u=0;u<2;u++)for(var h=0;h<2;h++)for(var d,f=function(){var e=ti.a.CreateBox("",{size:1},n.utilityLayerScene);e.material=m.coloredMaterial;var t=new o.x(0==u?-1:1,0==h?-1:1,0==g?-1:1);(d=new Ae({dragAxis:t})).moveAttached=!1,e.addBehavior(d),d.onDragObservable.add((function(t){if(i.onScaleBoxDragObservable.notifyObservers({}),i.attachedMesh){var n=i.attachedMesh.parent;if(n&&n.scaling&&n.scaling.isNonUniformWithinEpsilon(.001))return void p.a.Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");Te._RemoveAndStorePivotPoint(i.attachedMesh);var r=t.dragDistance/i._boundingDimensions.length()*i._anchorMesh.scaling.length(),a=new o.x(r,r,r);a.scaleInPlace(i._scaleDragSpeed),i.updateBoundingBox(),i.scalePivot?(i.attachedMesh.getWorldMatrix().getRotationMatrixToRef(i._tmpRotationMatrix),i._boundingDimensions.scaleToRef(.5,i._tmpVector),o.x.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector),i._boundingDimensions.multiplyToRef(i.scalePivot,i._tmpVector),o.x.TransformCoordinatesToRef(i._tmpVector,i._tmpRotationMatrix,i._tmpVector),i._anchorMesh.position.addInPlace(i._tmpVector)):(e.absolutePosition.subtractToRef(i._anchorMesh.position,i._tmpVector),i._anchorMesh.position.subtractInPlace(i._tmpVector)),i._anchorMesh.addChild(i.attachedMesh),i._anchorMesh.scaling.addInPlace(a),(i._anchorMesh.scaling.x<0||i._anchorMesh.scaling.y<0||i._anchorMesh.scaling.z<0)&&i._anchorMesh.scaling.subtractInPlace(a),i._anchorMesh.removeChild(i.attachedMesh),i.attachedMesh.setParent(n),Te._RestorePivotPoint(i.attachedMesh)}i._updateDummy()})),d.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({}),i._selectNode(e)})),d.onDragEndObservable.add((function(){i.onScaleBoxDragEndObservable.notifyObservers({}),i._selectNode(null),i._updateDummy()})),m._scaleBoxesParent.addChild(e)},m=this,g=0;g<2;g++)f();i._rootMesh.addChild(i._scaleBoxesParent);var _=new Array;return i._pointerObserver=n.utilityLayerScene.onPointerObservable.add((function(e){_[e.event.pointerId]?e.pickInfo&&e.pickInfo.pickedMesh!=_[e.event.pointerId]&&(_[e.event.pointerId].material=i.coloredMaterial,delete _[e.event.pointerId]):i._rotateSpheresParent.getChildMeshes().concat(i._scaleBoxesParent.getChildMeshes()).forEach((function(t){e.pickInfo&&e.pickInfo.pickedMesh==t&&(_[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._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 l.d(t,e),t.prototype.setColor=function(e){this.coloredMaterial.emissiveColor=e,this.hoverColoredMaterial.emissiveColor=e.clone().add(new o.e(.3,.3,.3)),this._lineBoundingBox.getChildren().forEach((function(t){t.color&&(t.color=e)}))},t.prototype._attachedMeshChanged=function(e){var t=this;if(e){Te._RemoveAndStorePivotPoint(e);var n=e.parent;this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),e.setParent(n),Te._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){Te._RemoveAndStorePivotPoint(this.attachedMesh);var e=this.attachedMesh.parent;this.attachedMesh.setParent(null);var t=null;this.attachedMesh.skeleton&&(t=this.attachedMesh.skeleton.overrideMesh,this.attachedMesh.skeleton.overrideMesh=null),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=o.q.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=o.q.RotationYawPitchRoll(this._anchorMesh.rotation.y,this._anchorMesh.rotation.x,this._anchorMesh.rotation.z)),this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion),this._tmpVector.copyFrom(this.attachedMesh.position),this.attachedMesh.rotationQuaternion.set(0,0,0,1),this.attachedMesh.position.set(0,0,0);var n=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);n.max.subtractToRef(n.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((n.max.x+n.min.x)/2,(n.max.y+n.min.y)/2,(n.max.z+n.min.z)/2),this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position),this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position),this._lineBoundingBox.computeWorldMatrix(),this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition),this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion),this.attachedMesh.position.copyFrom(this._tmpVector),this.attachedMesh.setParent(e),this.attachedMesh.skeleton&&(this.attachedMesh.skeleton.overrideMesh=t)}this._updateRotationSpheres(),this._updateScaleBoxes(),this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),Te._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 o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(o.x.Cross(e[r].position.normalizeToNew(),o.x.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 o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(o.x.Cross(e[r].position.normalizeToNew(),o.x.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 o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),e[r].lookAt(o.x.Cross(e[r].position.normalizeToNew(),o.x.Forward()).normalizeToNew().add(e[r].position))),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var a=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[r].scaling.set(a,a,a)}else e[r].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}},t.prototype._updateScaleBoxes=function(){for(var e=this._scaleBoxesParent.getChildMeshes(),t=0;t<2;t++)for(var n=0;n<2;n++)for(var i=0;i<2;i++){var r=4*t+2*n+i;if(e[r])if(e[r].position.set(this._boundingDimensions.x*t,this._boundingDimensions.y*n,this._boundingDimensions.z*i),e[r].position.addInPlace(new o.x(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize&&this.gizmoLayer.utilityLayerScene.activeCamera){e[r].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var a=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;e[r].scaling.set(a,a,a)}else e[r].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize)}},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){this._scaleBoxesParent.getChildMeshes().forEach((function(t,n){t.setEnabled(e)}))},t.prototype._updateDummy=function(){this._dragMesh&&(this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition()),this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling),this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion))},t.prototype.enableDragBehavior=function(){this._dragMesh=ve.a.CreateBox("dummy",1,this.gizmoLayer.utilityLayerScene),this._dragMesh.visibility=0,this._dragMesh.rotationQuaternion=new o.q,this.pointerDragBehavior.useObjectOrienationForDragging=!1,this._dragMesh.addBehavior(this.pointerDragBehavior)},t.prototype.dispose=function(){this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver),this._lineBoundingBox.dispose(),this._rotateSpheresParent.dispose(),this._scaleBoxesParent.dispose(),this._dragMesh&&this._dragMesh.dispose(),e.prototype.dispose.call(this)},t.MakeNotPickableAndWrapInBoundingBox=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e),e.rotationQuaternion||(e.rotationQuaternion=o.q.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var n=e.position.clone(),i=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var r=ti.a.CreateBox("box",{size:1},e.getScene()),a=e.getHierarchyBoundingVectors();return a.max.subtractToRef(a.min,r.scaling),0===r.scaling.y&&(r.scaling.y=o.h),0===r.scaling.x&&(r.scaling.x=o.h),0===r.scaling.z&&(r.scaling.z=o.h),r.position.set((a.max.x+a.min.x)/2,(a.max.y+a.min.y)/2,(a.max.z+a.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){p.a.Error("Custom meshes are not supported on this gizmo")},t}(qn),Oi=function(e){function t(t,n,i,a){void 0===n&&(n=o.e.Gray()),void 0===i&&(i=Qn.a.DefaultUtilityLayer),void 0===a&&(a=32);var s=e.call(this,i)||this;s._pointerObserver=null,s.snapDistance=0,s.onSnapObservable=new r.c;var c=new hn.a("",i.utilityLayerScene);c.diffuseColor=n,c.specularColor=n.subtract(new o.e(.1,.1,.1));var l=new hn.a("",i.utilityLayerScene);l.diffuseColor=n.add(new o.e(.3,.3,.3));var u=new Me.a("",i.utilityLayerScene),h=ve.a.CreateTorus("",.6,.03,a,i.utilityLayerScene);h.visibility=0;var d=ve.a.CreateTorus("",.6,.005,a,i.utilityLayerScene);d.material=c,d.rotation.x=Math.PI/2,h.rotation.x=Math.PI/2,u.addChild(d),u.addChild(h),u.lookAt(s._rootMesh.position.add(t)),s._rootMesh.addChild(u),u.scaling.scaleInPlace(1/3),s.dragBehavior=new Ae({dragPlaneNormal:t}),s.dragBehavior.moveAttached=!1,s.dragBehavior.maxDragAngle=9*Math.PI/20,s.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,s._rootMesh.addBehavior(s.dragBehavior);var f=new o.x;s.dragBehavior.onDragStartObservable.add((function(e){s.attachedMesh&&f.copyFrom(e.dragPlanePoint)}));var p=new o.j,m=new o.x,g=new o.x,_={snapDistance:0},v=0,b=new o.j,y=new o.x,x=new o.q;s.dragBehavior.onDragObservable.add((function(e){if(s.attachedMesh){s.attachedMesh.rotationQuaternion||(s.attachedMesh.rotationQuaternion=o.q.RotationYawPitchRoll(s.attachedMesh.rotation.y,s.attachedMesh.rotation.x,s.attachedMesh.rotation.z));var n=s.attachedMesh.parent;n&&s.attachedMesh.setParent(null);var r=e.dragPlanePoint.subtract(s.attachedMesh.absolutePosition).normalize(),a=f.subtract(s.attachedMesh.absolutePosition).normalize(),c=o.x.Cross(r,a),l=o.x.Dot(r,a),u=Math.atan2(c.length(),l);if(m.copyFrom(t),g.copyFrom(t),s.updateGizmoRotationToMatchAttachedMesh&&(s.attachedMesh.rotationQuaternion.toRotationMatrix(p),g=o.x.TransformCoordinates(m,p)),i.utilityLayerScene.activeCamera){var h=i.utilityLayerScene.activeCamera.position.subtract(s.attachedMesh.position);o.x.Dot(h,g)>0&&(m.scaleInPlace(-1),g.scaleInPlace(-1))}o.x.Dot(g,c)>0&&(u=-u);var d=!1;if(0!=s.snapDistance)if(v+=u,Math.abs(v)>s.snapDistance){var C=Math.floor(Math.abs(v)/s.snapDistance);v<0&&(C*=-1),v%=s.snapDistance,u=s.snapDistance*C,d=!0}else u=0;b.reset(),s.attachedMesh.parent&&(s.attachedMesh.parent.computeWorldMatrix().invertToRef(b),b.getRotationMatrixToRef(b),o.x.TransformCoordinatesToRef(m,b,m));var E=Math.sin(u/2);x.set(m.x*E,m.y*E,m.z*E,Math.cos(u/2)),b.determinant()>0&&(x.toEulerAnglesToRef(y),o.q.RotationYawPitchRollToRef(y.y,-y.x,-y.z,x)),s.updateGizmoRotationToMatchAttachedMesh?s.attachedMesh.rotationQuaternion.multiplyToRef(x,s.attachedMesh.rotationQuaternion):x.multiplyToRef(s.attachedMesh.rotationQuaternion,s.attachedMesh.rotationQuaternion),f.copyFrom(e.dragPlanePoint),d&&(_.snapDistance=u,s.onSnapObservable.notifyObservers(_)),n&&s.attachedMesh.setParent(n)}})),s._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e){if(!s._customMeshSet){var t=e.pickInfo&&-1!=s._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?l:c;s._rootMesh.getChildMeshes().forEach((function(e){e.material=t,e.color&&(e.color=t.diffuseColor)}))}}));var C=i._getSharedGizmoLight();return C.includedOnlyMeshes=C.includedOnlyMeshes.concat(s._rootMesh.getChildMeshes(!1)),s}return l.d(t,e),t.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},t.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),e.prototype.dispose.call(this)},t}(qn),Ri=function(e){function t(t,n){void 0===t&&(t=Qn.a.DefaultUtilityLayer),void 0===n&&(n=32);var i=e.call(this,t)||this;return i.onDragStartObservable=new r.c,i.onDragEndObservable=new r.c,i.xGizmo=new Oi(new o.x(1,0,0),o.e.Red().scale(.5),t,n),i.yGizmo=new Oi(new o.x(0,1,0),o.e.Green().scale(.5),t,n),i.zGizmo=new Oi(new o.x(0,0,1),o.e.Blue().scale(.5),t,n),[i.xGizmo,i.yGizmo,i.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){i.onDragEndObservable.notifyObservers({})}))})),i.attachedMesh=null,i}return l.d(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this.xGizmo.attachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){p.a.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},t}(qn),wi=function(e){function t(t){void 0===t&&(t=Qn.a.DefaultUtilityLayer);var n=e.call(this,t)||this;return n.onDragStartObservable=new r.c,n.onDragEndObservable=new r.c,n.xGizmo=new Zn(new o.x(1,0,0),o.e.Red().scale(.5),t),n.yGizmo=new Zn(new o.x(0,1,0),o.e.Green().scale(.5),t),n.zGizmo=new Zn(new o.x(0,0,1),o.e.Blue().scale(.5),t),[n.xGizmo,n.yGizmo,n.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){n.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){n.onDragEndObservable.notifyObservers({})}))})),n.attachedMesh=null,n}return l.d(t,e),Object.defineProperty(t.prototype,"attachedMesh",{get:function(){return this.xGizmo.attachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},t.prototype.setCustomMesh=function(e){p.a.Error("Custom meshes are not supported on this gizmo, please set the custom meshes on the gizmos contained within this one (gizmo.xGizmo, gizmo.yGizmo, gizmo.zGizmo)")},t}(qn);mn.a.CreatePolyhedron=function(e){var t=[];t[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},t[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},t[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},t[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},t[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},t[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},t[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},t[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},t[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},t[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},t[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},t[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},t[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},t[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},t[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var n,i,r,a,s,c,l=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,u=e.size,h=e.sizeX||u||1,d=e.sizeY||u||1,f=e.sizeZ||u||1,p=e.custom||t[l],m=p.face.length,g=e.faceUV||new Array(m),_=e.faceColors,v=void 0===e.flat||e.flat,b=0===e.sideOrientation?0:e.sideOrientation||mn.a.DEFAULTSIDE,y=new Array,x=new Array,C=new Array,E=new Array,T=new Array,S=0,A=0,P=new Array,M=0,O=0;if(v)for(O=0;O1e-4?(this._light.direction.copyFrom(this.attachedMesh.forward),this.cachedForward.copyFrom(this.attachedMesh.forward)):o.x.DistanceSquared(this.attachedMesh.forward,this._light.direction)>1e-4&&(this.attachedMesh.setDirection(this._light.direction),this.cachedForward.copyFrom(this._lightMesh.forward))),this._light.isEnabled()?this._material.diffuseColor.set(this._light.diffuse.r/3,this._light.diffuse.g/3,this._light.diffuse.b/3):this._material.diffuseColor.set(0,0,0))},t.prototype.dispose=function(){this._material.dispose(),e.prototype.dispose.call(this)},t._CreateHemisphericLightMesh=function(e){var n=new ve.a("hemisphereLight",e),i=Fi.CreateHemisphere(n.name,{segments:10,diameter:1},e);i.position.z=-.15,i.rotation.x=Math.PI/2,i.parent=n;var r=this._createLightLines(3,e);return r.parent=n,r.position.z,n.scaling.scaleInPlace(t._Scale),n.rotation.x=Math.PI/2,n},t._CreatePointLightMesh=function(e){var n=new ve.a("pointLight",e),i=ni.CreateSphere(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 ve.a("spotLight",e);ni.CreateSphere(n.name,{segments:10,diameter:1},e).parent=n;var i=Fi.CreateHemisphere(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 ve.a("directionalLight",e),i=new ve.a(n.name,e);i.parent=n,ni.CreateSphere(n.name,{diameter:1.2,segments:10},e).parent=i;var r=ve.a.CreateCylinder(n.name,6,.3,.3,6,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=ve.a.CreateCylinder(n.name,1,0,.6,6,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 ve.a("root",t);n.rotation.x=Math.PI/2;var i=new ve.a("linePivot",t);i.parent=n;var r=ve.a.CreateCylinder("line",2,.2,.3,6,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?n:((a=i.clone("linePivotClone")).rotation.z=Math.PI,n)},t}(qn),zi=n(56);Lt.a.IncludesShadersStore.kernelBlurVaryingDeclaration="varying vec2 sampleCoord{X};";var Vi="#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";Lt.a.IncludesShadersStore.kernelBlurFragment=Vi;var Ui="#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";Lt.a.IncludesShadersStore.kernelBlurFragment2=Ui;var Gi="\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g;\nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth;\n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r;\nreturn coc;\n}\n#endif\n#include[0..varyingCount]\n#ifdef PACKEDFLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT\nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT;\nfloat factor=0.0;\n\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include[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}";Lt.a.ShadersStore.kernelBlurPixelShader=Gi;Lt.a.IncludesShadersStore.kernelBlurVertex="sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";var Hi="\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nsampleCenter=(position*madd+madd);\n#include[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}";Lt.a.ShadersStore.kernelBlurVertexShader=Hi;var ji=function(e){function t(t,n,i,r,o,a,s,c,l,u,h){void 0===a&&(a=Kt.a.BILINEAR_SAMPLINGMODE),void 0===l&&(l=m.a.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u=""),void 0===h&&(h=!1);var d=e.call(this,t,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],r,o,a,s,c,null,l,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return d.direction=n,d.blockCompilation=h,d._packedFloat=!1,d._staticDefines="",d._staticDefines=u,d.onApplyObservable.add((function(e){d._outputTexture?e.setFloat2("delta",1/d._outputTexture.width*d.direction.x,1/d._outputTexture.height*d.direction.y):e.setFloat2("delta",1/d.width*d.direction.x,1/d.height*d.direction.y)})),d.kernel=i,d}return l.d(t,e),Object.defineProperty(t.prototype,"kernel",{get:function(){return this._idealKernel},set:function(e){this._idealKernel!==e&&(e=Math.max(e,1),this._idealKernel=e,this._kernel=this._nearestBestKernel(e),this.blockCompilation||this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this.blockCompilation||this._updateParameters())},enumerable:!0,configurable:!0}),t.prototype.updateEffect=function(e,t,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}(It.a),Wi=function(e){function t(t,n,i,r,a,s,c){void 0===a&&(a=m.a.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=Kt.a.BILINEAR_SAMPLINGMODE),void 0===c&&(c=!0);var l=e.call(this,t,n,i,r,!0,a,!1,s,c)||this;return l.scene=i,l.mirrorPlane=new o.n(0,1,0,1),l._transformMatrix=o.j.Zero(),l._mirrorMatrix=o.j.Zero(),l._adaptiveBlurKernel=0,l._blurKernelX=0,l._blurKernelY=0,l._blurRatio=1,l.ignoreCameraViewport=!0,l._updateGammaSpace(),l._imageProcessingConfigChangeObserver=i.imageProcessingConfiguration.onUpdateParameters.add((function(){l._updateGammaSpace})),l.onBeforeRenderObservable.add((function(){o.j.ReflectionToRef(l.mirrorPlane,l._mirrorMatrix),l._savedViewMatrix=i.getViewMatrix(),l._mirrorMatrix.multiplyToRef(l._savedViewMatrix,l._transformMatrix),i.setTransformMatrix(l._transformMatrix,i.getProjectionMatrix()),i.clipPlane=l.mirrorPlane,i.getEngine().cullBackFaces=!1,i._mirroredCameraPosition=o.x.TransformCoordinates(i.activeCamera.globalPosition,l._mirrorMatrix)})),l.onAfterRenderObservable.add((function(){i.setTransformMatrix(l._savedViewMatrix,i.getProjectionMatrix()),i.getEngine().cullBackFaces=!0,i._mirroredCameraPosition=null,i.clipPlane=null})),l}return l.d(t,e),Object.defineProperty(t.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),t.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),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?m.a.TEXTURETYPE_FLOAT:m.a.TEXTURETYPE_HALF_FLOAT;this._blurX=new ji("horizontal blur",new o.w(1,0),this._blurKernelX,this._blurRatio,null,Kt.a.BILINEAR_SAMPLINGMODE,e,!1,t),this._blurX.autoClear=!1,1===this._blurRatio&&this.samples<2&&this._texture?this._blurX.inputTexture=this._texture:this._blurX.alwaysForcePOT=!0,this._blurY=new ji("vertical blur",new o.w(0,1),this._blurKernelY,this._blurRatio,null,Kt.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(){e.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},t}(en.a);Kt.a._CreateMirror=function(e,t,n,i){return new Wi(e,t,n,i)};var Xi=n(80),Yi=n(18),Ki=n(83),Qi=n(97),qi=n(21),Zi=" uniform vec4 vPrimaryColor;\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nuniform vec4 vPrimaryColorShadow;\n#endif\nuniform float shadowLevel;\nuniform float alpha;\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif";Lt.a.IncludesShadersStore.backgroundFragmentDeclaration=Zi;var Ji="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";Lt.a.IncludesShadersStore.backgroundUboDeclaration=Ji;n(182),n(128),n(129),n(190),n(181),n(145),n(150),n(133),n(183),n(151);var $i="#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include\n#include\n#include\n#include\n#include\n\n#include\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow5(saturate(1.0-VdotN));\n}\n#endif\nvoid main(void) {\n#include\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=saturate(reflectionLOD);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(saturate(VdotN),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-saturate(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,saturate(reflectionAmount));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=saturate(viewAngleToFloor/startAngle);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";Lt.a.ShadersStore.backgroundPixelShader=$i;var er="uniform mat4 view;\nuniform mat4 viewProjection;\nuniform float shadowLevel;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif";Lt.a.IncludesShadersStore.backgroundVertexDeclaration=er;n(105),n(106),n(146),n(152),n(107),n(108),n(134),n(185),n(186);var tr="precision highp float;\n#include<__decl__backgroundVertex>\n#include\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include\n\n#include\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include\n#include\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include\n#include\n#ifdef MULTIVIEW\nif (gl_ViewID_OVR == 0u) {\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n} else {\ngl_Position=viewProjectionR*finalWorld*vec4(position,1.0);\n}\n#else\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#endif\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include\n\n#include\n\n#include[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";Lt.a.ShadersStore.backgroundVertexShader=tr;var nr=function(e){function t(){var t=e.call(this)||this;return t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.GAMMADIFFUSE=!1,t.DIFFUSEHASALPHA=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONBLUR=!1,t.REFLECTIONFRESNEL=!1,t.REFLECTIONFALLOFF=!1,t.TEXTURELODSUPPORT=!1,t.PREMULTIPLYALPHA=!1,t.USERGBCOLOR=!1,t.USEHIGHLIGHTANDSHADOWCOLORS=!1,t.NOISE=!1,t.REFLECTIONBGR=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.TONEMAPPING_ACES=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.MULTIVIEW=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1,t.EQUIRECTANGULAR_RELFECTION_FOV=!1,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.CLIPPLANE=!1,t.CLIPPLANE2=!1,t.CLIPPLANE3=!1,t.CLIPPLANE4=!1,t.POINTSIZE=!1,t.FOG=!1,t.NORMAL=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.SHADOWFLOAT=!1,t.rebuild(),t}return l.d(t,e),t}(Ki.a),ir=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.primaryColor=o.e.White(),i._primaryColorShadowLevel=0,i._primaryColorHighlightLevel=0,i.reflectionTexture=null,i.reflectionBlur=0,i.diffuseTexture=null,i._shadowLights=null,i.shadowLights=null,i.shadowLevel=0,i.sceneCenter=o.x.Zero(),i.opacityFresnel=!0,i.reflectionFresnel=!1,i.reflectionFalloffDistance=0,i.reflectionAmount=1,i.reflectionReflectance0=.05,i.reflectionReflectance90=.5,i.useRGBColor=!0,i.enableNoise=!1,i._fovMultiplier=1,i.useEquirectangularFOV=!1,i._maxSimultaneousLights=4,i.maxSimultaneousLights=4,i._imageProcessingObserver=null,i.switchToBGR=!1,i._renderTargets=new jn.a(16),i._reflectionControls=o.y.Zero(),i._white=o.e.White(),i._primaryShadowColor=o.e.Black(),i._primaryHighlightColor=o.e.Black(),i._attachImageProcessingConfiguration(null),i.getRenderTargetTextures=function(){return i._renderTargets.reset(),i._diffuseTexture&&i._diffuseTexture.isRenderTarget&&i._renderTargets.push(i._diffuseTexture),i._reflectionTexture&&i._reflectionTexture.isRenderTarget&&i._renderTargets.push(i._reflectionTexture),i._renderTargets},i}return l.d(t,e),Object.defineProperty(t.prototype,"_perceptualColor",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorShadowLevel",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"primaryColorHighlightLevel",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"reflectionStandardFresnelWeight",{set:function(e){var n=e;n<.5?(n*=2,this.reflectionReflectance0=t.StandardReflectance0*n,this.reflectionReflectance90=t.StandardReflectance90*n):(n=2*n-1,this.reflectionReflectance0=t.StandardReflectance0+(1-t.StandardReflectance0)*n,this.reflectionReflectance90=t.StandardReflectance90+(1-t.StandardReflectance90)*n)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._fovMultiplier},set:function(e){isNaN(e)&&(e=1),this._fovMultiplier=Math.max(0,Math.min(2,e))},enumerable:!0,configurable:!0}),t.prototype._attachImageProcessingConfiguration=function(e){var t=this;e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration=e||this.getScene().imageProcessingConfiguration,this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(){t._computePrimaryColorFromPerceptualColor(),t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),t.prototype.needAlphaTesting=function(){return!0},t.prototype.needAlphaBlending=function(){return this.alpha<0||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},t.prototype.isReadyForSubMesh=function(e,t,n){var i=this;if(void 0===n&&(n=!1),t.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new nr);var r=this.getScene(),o=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&o._renderId===r.getRenderId())return!0;var a=r.getEngine();if(Yi.a.PrepareDefinesForLights(r,e,o,!1,this._maxSimultaneousLights),o._needNormals=!0,Yi.a.PrepareDefinesForMultiview(r,o),o._areTexturesDirty){if(o._needUVs=!1,r.texturesEnabled){if(r.getEngine().getCaps().textureLOD&&(o.TEXTURELODSUPPORT=!0),this._diffuseTexture&&qi.a.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;Yi.a.PrepareDefinesForMergedUV(this._diffuseTexture,o,"DIFFUSE"),o.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,o.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,o.OPACITYFRESNEL=this._opacityFresnel}else o.DIFFUSE=!1,o.DIFFUSEHASALPHA=!1,o.GAMMADIFFUSE=!1,o.OPACITYFRESNEL=!1;var s=this._reflectionTexture;if(s&&qi.a.ReflectionTextureEnabled){if(!s.isReadyOrNotBlocking())return!1;switch(o.REFLECTION=!0,o.GAMMAREFLECTION=s.gammaSpace,o.RGBDREFLECTION=s.isRGBD,o.REFLECTIONBLUR=this._reflectionBlur>0,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,o.LODINREFLECTIONALPHA=s.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,s.coordinatesMode===Kt.a.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case Kt.a.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case Kt.a.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case Kt.a.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case Kt.a.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0,o.REFLECTIONMAP_SKYBOX_TRANSFORMED=!s.getReflectionTextureMatrix().isIdentity();break;case Kt.a.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case Kt.a.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case Kt.a.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case Kt.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case Kt.a.CUBIC_MODE:case Kt.a.INVCUBIC_MODE:default:o.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(o.REFLECTIONFRESNEL=!0,o.REFLECTIONFALLOFF=this.reflectionFalloffDistance>0,this._reflectionControls.x=this.reflectionAmount,this._reflectionControls.y=this.reflectionReflectance0,this._reflectionControls.z=this.reflectionReflectance90,this._reflectionControls.w=1/this.reflectionFalloffDistance):(o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1)}else o.REFLECTION=!1,o.REFLECTIONFRESNEL=!1,o.REFLECTIONFALLOFF=!1,o.REFLECTIONBLUR=!1,o.REFLECTIONMAP_3D=!1,o.REFLECTIONMAP_SPHERICAL=!1,o.REFLECTIONMAP_PLANAR=!1,o.REFLECTIONMAP_CUBIC=!1,o.REFLECTIONMAP_PROJECTION=!1,o.REFLECTIONMAP_SKYBOX=!1,o.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,o.REFLECTIONMAP_EXPLICIT=!1,o.REFLECTIONMAP_EQUIRECTANGULAR=!1,o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,o.INVERTCUBICMAP=!1,o.REFLECTIONMAP_OPPOSITEZ=!1,o.LODINREFLECTIONALPHA=!1,o.GAMMAREFLECTION=!1,o.RGBDREFLECTION=!1}o.PREMULTIPLYALPHA=this.alphaMode===m.a.ALPHA_PREMULTIPLIED||this.alphaMode===m.a.ALPHA_PREMULTIPLIED_PORTERDUFF,o.USERGBCOLOR=this._useRGBColor,o.NOISE=this._enableNoise}if(o._areLightsDirty&&(o.USEHIGHLIGHTANDSHADOWCOLORS=!this._useRGBColor&&(0!==this._primaryColorShadowLevel||0!==this._primaryColorHighlightLevel)),o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o)}if(Yi.a.PrepareDefinesForMisc(e,r,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),Yi.a.PrepareDefinesForFrameBoundValues(r,a,o,n),Yi.a.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(r.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(gn.b.NormalKind)||(e.createNormals(!0),p.a.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),r.resetCachedMaterial();var c=new Lt.c;o.FOG&&c.addFallback(0,"FOG"),o.POINTSIZE&&c.addFallback(1,"POINTSIZE"),o.MULTIVIEW&&c.addFallback(0,"MULTIVIEW"),Yi.a.HandleFallbacksForShadows(o,c,this._maxSimultaneousLights),o.NUM_BONE_INFLUENCERS>0&&c.addCPUSkinningFallback(0,e);var l=[gn.b.PositionKind];o.NORMAL&&l.push(gn.b.NormalKind),o.UV1&&l.push(gn.b.UVKind),o.UV2&&l.push(gn.b.UV2Kind),Yi.a.PrepareAttributesForBones(l,e,o,c),Yi.a.PrepareAttributesForInstances(l,o);var u=["world","view","viewProjection","vEyePosition","vLightsType","vFogInfos","vFogColor","pointSize","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","mBones","vPrimaryColor","vPrimaryColorShadow","vReflectionInfos","reflectionMatrix","vReflectionMicrosurfaceInfos","fFovMultiplier","shadowLevel","alpha","vBackgroundCenter","vReflectionControl","vDiffuseInfos","diffuseMatrix"],h=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],d=["Material","Scene"];un.a&&(un.a.PrepareUniforms(u,o),un.a.PrepareSamplers(h,o)),Yi.a.PrepareUniformsAndSamplersList({uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var f=o.toString();t.setEffect(r.getEngine().createEffect("background",{attributes:l,uniformsNames:u,uniformBuffersNames:d,samplers:h,defines:f,fallbacks:c,onCompiled:function(e){i.onCompiled&&i.onCompiled(e),i.bindSceneUniformBuffer(e,r.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},a),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=r.getRenderId(),this._wasPreviouslyReady=!0,!0)},t.prototype._computePrimaryColorFromPerceptualColor=function(){this.__perceptualColor&&(this._primaryColor.copyFrom(this.__perceptualColor),this._primaryColor.toLinearSpaceToRef(this._primaryColor),this._imageProcessingConfiguration&&this._primaryColor.scaleToRef(1/this._imageProcessingConfiguration.exposure,this._primaryColor),this._computePrimaryColors())},t.prototype._computePrimaryColors=function(){0===this._primaryColorShadowLevel&&0===this._primaryColorHighlightLevel||(this._primaryColor.scaleToRef(this._primaryColorShadowLevel,this._primaryShadowColor),this._primaryColor.subtractToRef(this._primaryShadowColor,this._primaryShadowColor),this._white.subtractToRef(this._primaryColor,this._primaryHighlightColor),this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel,this._primaryHighlightColor),this._primaryColor.addToRef(this._primaryHighlightColor,this._primaryHighlightColor))},t.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vPrimaryColor",4),this._uniformBuffer.addUniform("vPrimaryColorShadow",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("fFovMultiplier",1),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.addUniform("shadowLevel",1),this._uniformBuffer.addUniform("alpha",1),this._uniformBuffer.addUniform("vBackgroundCenter",3),this._uniformBuffer.addUniform("vReflectionControl",4),this._uniformBuffer.create()},t.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),e.prototype.unbind.call(this)},t.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},t.prototype.bindForSubMesh=function(e,t,n){var i=this.getScene(),r=n._materialDefines;if(r){var o=n.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),Yi.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&&qi.a.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),Yi.a.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),s&&qi.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&&qi.a.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),s&&qi.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)))),Yi.a.BindClipPlane(this._activeEffect,i),Yi.a.BindEyePosition(o,i)}!a&&this.isFrozen||(i.lightsEnabled&&Yi.a.BindLights(i,t,this._activeEffect,r,this._maxSimultaneousLights,!1),this.bindView(o),Yi.a.BindFogParameters(i,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},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 De.a.Clone((function(){return new t(e,n.getScene())}),this)},t.prototype.serialize=function(){var e=De.a.Serialize(this);return e.customType="BABYLON.BackgroundMaterial",e},t.prototype.getClassName=function(){return"BackgroundMaterial"},t.Parse=function(e,n,i){return De.a.Parse((function(){return new t(e.name,n)}),e,n,i)},t.StandardReflectance0=.05,t.StandardReflectance90=.5,l.c([Object(De.e)()],t.prototype,"_primaryColor",void 0),l.c([Object(De.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColor",void 0),l.c([Object(De.e)()],t.prototype,"__perceptualColor",void 0),l.c([Object(De.c)()],t.prototype,"_primaryColorShadowLevel",void 0),l.c([Object(De.c)()],t.prototype,"_primaryColorHighlightLevel",void 0),l.c([Object(De.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"primaryColorHighlightLevel",null),l.c([Object(De.m)()],t.prototype,"_reflectionTexture",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),l.c([Object(De.c)()],t.prototype,"_reflectionBlur",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionBlur",void 0),l.c([Object(De.m)()],t.prototype,"_diffuseTexture",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"diffuseTexture",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLights",void 0),l.c([Object(De.c)()],t.prototype,"_shadowLevel",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"shadowLevel",void 0),l.c([Object(De.o)()],t.prototype,"_sceneCenter",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"sceneCenter",void 0),l.c([Object(De.c)()],t.prototype,"_opacityFresnel",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"opacityFresnel",void 0),l.c([Object(De.c)()],t.prototype,"_reflectionFresnel",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFresnel",void 0),l.c([Object(De.c)()],t.prototype,"_reflectionFalloffDistance",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionFalloffDistance",void 0),l.c([Object(De.c)()],t.prototype,"_reflectionAmount",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionAmount",void 0),l.c([Object(De.c)()],t.prototype,"_reflectionReflectance0",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance0",void 0),l.c([Object(De.c)()],t.prototype,"_reflectionReflectance90",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionReflectance90",void 0),l.c([Object(De.c)()],t.prototype,"_useRGBColor",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRGBColor",void 0),l.c([Object(De.c)()],t.prototype,"_enableNoise",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableNoise",void 0),l.c([Object(De.c)()],t.prototype,"_maxSimultaneousLights",void 0),l.c([Object(De.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"maxSimultaneousLights",void 0),l.c([Object(De.i)()],t.prototype,"_imageProcessingConfiguration",void 0),t}(Qi.a);a.a.RegisteredTypes["BABYLON.BackgroundMaterial"]=ir;var rr=function(){function e(t,n){var i=this;this._errorHandler=function(e,t){i.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=l.a({},e._getDefaultOptions(),t),this._scene=n,this.onErrorObservable=new r.c,this._setupBackground(),this._setupImageProcessing()}return e._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new o.e(.2,.2,.3).toLinearSpace().scale(3),groundOpacity:.9,enableGroundShadow:!0,groundShadowLevel:.5,enableGroundMirror:!1,groundMirrorSizeRatio:.3,groundMirrorBlurKernel:64,groundMirrorAmount:1,groundMirrorFresnelWeight:1,groundMirrorFallOffDistance:0,groundMirrorTextureType:m.a.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new o.e(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:o.x.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(e.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skybox",{get:function(){return this._skybox},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ground",{get:function(){return this._ground},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!0,configurable:!0}),e.prototype.updateOptions=function(e){var t=l.a({},this._options,e);this._ground&&!t.createGround&&(this._ground.dispose(),this._ground=null),this._groundMaterial&&!t.createGround&&(this._groundMaterial.dispose(),this._groundMaterial=null),this._groundTexture&&this._options.groundTexture!=t.groundTexture&&(this._groundTexture.dispose(),this._groundTexture=null),this._skybox&&!t.createSkybox&&(this._skybox.dispose(),this._skybox=null),this._skyboxMaterial&&!t.createSkybox&&(this._skyboxMaterial.dispose(),this._skyboxMaterial=null),this._skyboxTexture&&this._options.skyboxTexture!=t.skyboxTexture&&(this._skyboxTexture.dispose(),this._skyboxTexture=null),this._groundMirror&&!t.enableGroundMirror&&(this._groundMirror.dispose(),this._groundMirror=null),this._scene.environmentTexture&&this._options.environmentTexture!=t.environmentTexture&&this._scene.environmentTexture.dispose(),this._options=t,this._setupBackground(),this._setupImageProcessing()},e.prototype.setMainColor=function(e){this.groundMaterial&&(this.groundMaterial.primaryColor=e),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=e),this.groundMirror&&(this.groundMirror.clearColor=new o.f(e.r,e.g,e.b,1))},e.prototype._setupImageProcessing=function(){this._options.setupImageProcessing&&(this._scene.imageProcessingConfiguration.contrast=this._options.cameraContrast,this._scene.imageProcessingConfiguration.exposure=this._options.cameraExposure,this._scene.imageProcessingConfiguration.toneMappingEnabled=this._options.toneMappingEnabled,this._setupEnvironmentTexture())},e.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof zi.a)this._scene.environmentTexture=this._options.environmentTexture;else{var e=Xi.a.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},e.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new ve.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 ft&&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=ve.a.CreatePlane("BackgroundPlane",e.groundSize,this._scene),this._ground.rotation.x=Math.PI/2,this._ground.parent=this._rootMesh,this._ground.onDisposeObservable.add((function(){t._ground=null}))),this._ground.receiveShadows=this._options.enableGroundShadow},e.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new ir("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=m.a.ALPHA_PREMULTIPLIED_PORTERDUFF,this._groundMaterial.shadowLevel=this._options.groundShadowLevel,this._groundMaterial.primaryColor=this._options.groundColor,this._groundMaterial.useRGBColor=!1,this._groundMaterial.enableNoise=!0,this._ground&&(this._ground.material=this._groundMaterial)},e.prototype._setupGroundDiffuseTexture=function(){if(this._groundMaterial&&!this._groundTexture)if(this._options.groundTexture instanceof zi.a)this._groundMaterial.diffuseTexture=this._options.groundTexture;else{var e=new Kt.a(this._options.groundTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler);e.gammaSpace=!1,e.hasAlpha=!0,this._groundMaterial.diffuseTexture=e}},e.prototype._setupGroundMirrorTexture=function(e){var t=Kt.a.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new Wi("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Kt.a.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new o.n(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var n=0;n>16&32768,r=n>>12&2047,o=n>>23&255;return o<103?i:o>142?(i|=31744,i|=(255==o?0:1)&&8388607&n):o<113?i|=((r|=2048)>>114-o)+(r>>113-o&1):(i|=o-112<<10|r>>1,i+=1&r)},e._FromHalfFloat=function(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))},e._GetHalfFloatAsFloatRGBAArrayBuffer=function(t,n,i,r,o,a){for(var s=new Float32Array(r),c=new Uint16Array(o,i),l=0,u=0;u>8)},e._GetRGBArrayBuffer=function(e,t,n,i,r,o,a,s){for(var c=new Uint8Array(i),l=new Uint8Array(r,n),u=0,h=0;h>8&255,S>>16&255,S>>24&255)))}var M=e._ExtractLongWordOrder(y[23]),O=e._ExtractLongWordOrder(y[24]),R=e._ExtractLongWordOrder(y[25]),w=e._ExtractLongWordOrder(y[26]);A&&(C=t._getRGBABufferInternalSizedFormat(r.textureType)),_=1,131072&y[2]&&!1!==o&&(_=Math.max(1,y[7]));for(var I=c||0;I0?r.sphericalPolynomial=cr.a.ConvertCubeMapToSphericalPolynomial({size:y[4],right:l[0],left:l[1],up:l[2],down:l[3],front:l[4],back:l[5],format:m.a.TEXTUREFORMAT_RGBA,type:m.a.TEXTURETYPE_FLOAT,gammaSpace:!1}):r.sphericalPolynomial=void 0}else p.a.Error("Compressed textures are not supported on this platform.");else p.a.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else p.a.Error("Invalid magic number in DDS header")},e.StoreLODInAlphaChannel=!1,e}();ee.b.prototype.createPrefilteredCubeTexture=function(e,t,n,i,r,o,a,s,c){var l=this;void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===c&&(c=!0);return this.createCubeTexture(e,t,null,!1,(function(e){if(e){var o=e.texture;if(c?e.info.sphericalPolynomial&&(o._sphericalPolynomial=e.info.sphericalPolynomial):o._sphericalPolynomial=new sr.b,o._dataSource=Jt.a.DATASOURCE_CUBEPREFILTERED,l.getCaps().textureLOD)r&&r(o);else{var a=l._gl,s=e.width;if(s){for(var u=[],h=0;h<3;h++){var d=1-h/2,f=i,m=Ge.a.Log2(s)*n+i,g=f+(m-f)*d,_=Math.round(Math.min(Math.max(g,0),m)),v=new Jt.a(l,Jt.a.DATASOURCE_TEMP);if(v.type=o.type,v.format=o.format,v.width=Math.pow(2,Math.max(Ge.a.Log2(s)-_,0)),v.height=v.width,v.isCube=!0,l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,v,!0),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 b=e.info,y=e.data;l._unpackFlipY(b.isCompressed),pr.UploadDDSLevels(l,v,y,b,!0,6,_)}else p.a.Warn("DDS is the only prefiltered cube map supported so far.");l._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var x=new zi.a(t);x.isCube=!0,x._texture=v,v.isReady=!0,u.push(x)}o._lodTextureHigh=u[2],o._lodTextureMid=u[1],o._lodTextureLow=u[0],r&&r(o)}}}else r&&r(null)}),o,a,s,c,n,i)};var mr=function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e,t,n,i,r){return 0===e.indexOf(".dds")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,n,i,r){var o,a=t.getEngine(),s=!1;if(Array.isArray(e))for(var c=0;c1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),pr.UploadDDSLevels(a,t,l,o,s,6,-1,c),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t)}else{var u=e;o=pr.GetDDSInfo(u),t.width=o.width,t.height=o.height,n&&(o.sphericalPolynomial=new sr.b),s=(o.isRGB||o.isLuminance||o.mipmapCount>1)&&t.generateMipMaps,a._unpackFlipY(o.isCompressed),pr.UploadDDSLevels(a,t,u,o,s,6),o.isFourCC||1!==o.mipmapCount||a.generateMipMapsForCubemap(t)}a._setCubeMapTextureParams(s),t.isReady=!0,i&&i({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,n){var i=pr.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(){pr.UploadDDSLevels(t.getEngine(),t,e,i,r,1)}))},e}();ee.b._TextureLoaders.push(new mr);var gr=n(120),_r=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,n,i,r){return 0===e.indexOf(".env")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,n,i,r){if(!Array.isArray(e)){e=e;var o=gr.a.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,gr.a.UploadEnvSpherical(t,o),gr.a.UploadEnvLevelsAsync(t,e,o).then((function(){t.isReady=!0,i&&i()}))):r&&r("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,n){throw".env not supported in 2d."},e}();ee.b._TextureLoaders.push(new _r);var vr=function(){function e(t,n,i,r){this.arrayBuffer=t,this.isInvalid=!1;var o=new Uint8Array(this.arrayBuffer,0,12);if(171!==o[0]||75!==o[1]||84!==o[2]||88!==o[3]||32!==o[4]||49!==o[5]||49!==o[6]||187!==o[7]||13!==o[8]||10!==o[9]||26!==o[10]||10!==o[11])return this.isInvalid=!0,void p.a.Error("texture missing KTX identifier");var a=Uint32Array.BYTES_PER_ELEMENT,s=new DataView(this.arrayBuffer,12,13*a),c=67305985===s.getUint32(0,!0);this.glType=s.getUint32(1*a,c),this.glTypeSize=s.getUint32(2*a,c),this.glFormat=s.getUint32(3*a,c),this.glInternalFormat=s.getUint32(4*a,c),this.glBaseInternalFormat=s.getUint32(5*a,c),this.pixelWidth=s.getUint32(6*a,c),this.pixelHeight=s.getUint32(7*a,c),this.pixelDepth=s.getUint32(8*a,c),this.numberOfArrayElements=s.getUint32(9*a,c),this.numberOfFaces=s.getUint32(10*a,c),this.numberOfMipmapLevels=s.getUint32(11*a,c),this.bytesOfKeyValueData=s.getUint32(12*a,c),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:p.a.Error("number of faces expected"+n+", but found "+this.numberOfFaces):p.a.Error("texture arrays not currently supported"):p.a.Error("only 2D textures currently supported")):p.a.Error("only compressed formats currently supported")}return e.prototype.uploadLevels=function(t,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-1?e.substring(0,n):e)+t},e.prototype.getFallbackTextureUrl=function(e,t){var n=new RegExp(t+"$");return e.replace(n,"")},e.prototype.loadCubeData=function(e,t,n,i,r){if(!Array.isArray(e)){t._invertVScale=!t.invertY;var o=t.getEngine(),a=new vr(e,6),s=a.numberOfMipmapLevels>1&&t.generateMipMaps;o._unpackFlipY(!0),a.uploadLevels(t,t.generateMipMaps),t.width=a.pixelWidth,t.height=a.pixelHeight,o._setCubeMapTextureParams(s),t.isReady=!0}},e.prototype.loadData=function(e,t,n){t._invertVScale=!t.invertY;var i=new vr(e,1);n(i.pixelWidth,i.pixelHeight,!1,!0,(function(){i.uploadLevels(t,t.generateMipMaps)}),i.isInvalid)},e}();ee.b._TextureLoaders.unshift(new br);ae.a.prototype.createDefaultLight=function(e){if(void 0===e&&(e=!1),e&&this.lights)for(var t=0;t=c.video.HAVE_CURRENT_DATA;return!s.poster||s.autoPlay&&l?l&&c._createInternalTexture():(c._texture=c._engine.createTexture(s.poster,!1,!0,i),c._displayingPosterTexture=!0),c}return l.d(t,e),Object.defineProperty(t.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new r.c),this._onUserActionRequestedObservable},enumerable:!0,configurable:!0}),t.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},t.prototype._getVideo=function(e){if(e instanceof HTMLVideoElement)return fe.h.SetCorsBehavior(e.currentSrc,e),e;var t=document.createElement("video");return"string"==typeof e?(fe.h.SetCorsBehavior(e,t),t.src=e):(fe.h.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},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener(this._createInternalTextureOnEvent,this._createInternalTexture),this.video.removeEventListener("paused",this._updateInternalTexture),this.video.removeEventListener("seeked",this._updateInternalTexture),this.video.removeEventListener("emptied",this.reset),this.video.pause()},t.CreateFromStreamAsync=function(e,n){var i=document.createElement("video");return i.setAttribute("autoplay",""),i.setAttribute("muted","true"),i.setAttribute("playsinline",""),i.muted=!0,void 0!==i.mozSrcObject?i.mozSrcObject=n:"object"==typeof i.srcObject?i.srcObject=n:(window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,i.src=window.URL&&window.URL.createObjectURL(n)),new Promise((function(n){var r=function(){n(new t("video",i,e,!0,!0)),i.removeEventListener("playing",r)};i.addEventListener("playing",r),i.play()}))},t.CreateFromWebCamAsync=function(e,t,n){var i,r=this;return void 0===n&&(n=!1),t&&t.deviceId&&(i={exact:t.deviceId}),navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:t,audio:n}).then((function(t){return r.CreateFromStreamAsync(e,t)})):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:i,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(t){return r.CreateFromStreamAsync(e,t)}),(function(e){p.a.Error(e.name)})),Promise.reject("No support for userMedia on this device"))},t.CreateFromWebCam=function(e,t,n,i){void 0===i&&(i=!1),this.CreateFromWebCamAsync(e,n,i).then((function(e){t&&t(e)})).catch((function(e){p.a.Error(e.name)}))},t}(Kt.a),xr=function(e){function t(n,i,r,a){var s=e.call(this,n,a)||this;s._useDirectMapping=!1,s._videoMode=t.MODE_MONOSCOPIC,s._onBeforeCameraRenderObserver=null,a=s.getScene(),n=n||"videoDome",r.resolution=0|Math.abs(r.resolution)||32,r.clickToPlay=Boolean(r.clickToPlay),r.autoPlay=void 0===r.autoPlay||Boolean(r.autoPlay),r.loop=void 0===r.loop||Boolean(r.loop),r.size=Math.abs(r.size)||(a.activeCamera?.48*a.activeCamera.maxZ:1e3),void 0===r.useDirectMapping?s._useDirectMapping=!0:s._useDirectMapping=r.useDirectMapping,void 0===r.faceForward&&(r.faceForward=!0),s._setReady(!1);var c={loop:r.loop,autoPlay:r.autoPlay,autoUpdateTexture:!0,poster:r.poster},l=s._material=new ir(n+"_material",a),u=s._videoTexture=new yr(n+"_texture",i,a,!1,s._useDirectMapping,Kt.a.TRILINEAR_SAMPLINGMODE,c);if(s._mesh=ve.a.CreateSphere(n+"_mesh",r.resolution,r.size,a,!1,ve.a.BACKSIDE),u.onLoadObservable.addOnce((function(){s._setReady(!0)})),l.useEquirectangularFOV=!0,l.fovMultiplier=1,l.opacityFresnel=!1,s._useDirectMapping?(u.wrapU=Kt.a.CLAMP_ADDRESSMODE,u.wrapV=Kt.a.CLAMP_ADDRESSMODE,l.diffuseTexture=u):(u.coordinatesMode=Kt.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,u.wrapV=Kt.a.CLAMP_ADDRESSMODE,l.reflectionTexture=u),s._mesh.material=l,s._mesh.parent=s,r.clickToPlay&&(a.onPointerUp=function(){s._videoTexture.video.play()}),r.faceForward&&a.activeCamera){var h=a.activeCamera,d=o.x.Forward(),f=o.x.TransformNormal(d,h.getViewMatrix());f.normalize(),s.rotation.y=Math.acos(o.x.Dot(d,f))}return s}return l.d(t,e),Object.defineProperty(t.prototype,"videoTexture",{get:function(){return this._videoTexture},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"videoMode",{get:function(){return this._videoMode},set:function(e){this._videoMode!==e&&this._changeVideoMode(e)},enumerable:!0,configurable:!0}),t.prototype._changeVideoMode=function(e){var n=this;switch(this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._videoMode=e,this._videoTexture.uScale=1,this._videoTexture.vScale=1,this._videoTexture.uOffset=0,this._videoTexture.vOffset=0,e){case t.MODE_SIDEBYSIDE:this._videoTexture.uScale=.5,this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){n._videoTexture.uOffset=e.isRightCamera?.5:0}));break;case t.MODE_TOPBOTTOM:this._videoTexture.vScale=.5,this._onBeforeCameraRenderObserver=this._scene.onBeforeCameraRenderObservable.add((function(e){n._videoTexture.vOffset=e.isRightCamera?.5:0}))}},t.prototype.dispose=function(t,n){void 0===n&&(n=!1),this._videoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),this._scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),e.prototype.dispose.call(this,t,n)},t.MODE_MONOSCOPIC=0,t.MODE_TOPBOTTOM=1,t.MODE_SIDEBYSIDE=2,t}(Kn.a),Cr=function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new fe.f,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new fe.f,this._onBeginFrameObserver=null,this._onEndFrameObserver=null,this._onBeforeShaderCompilationObserver=null,this._onAfterShaderCompilationObserver=null}return Object.defineProperty(e.prototype,"gpuFrameTimeCounter",{get:function(){return this._gpuFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureGPUFrameTime",{get:function(){return this._captureGPUFrameTime},set:function(e){var t=this;e!==this._captureGPUFrameTime&&(this._captureGPUFrameTime=e,e?(this._onBeginFrameObserver=this.engine.onBeginFrameObservable.add((function(){t._gpuFrameTimeToken||(t._gpuFrameTimeToken=t.engine.startTimeQuery())})),this._onEndFrameObserver=this.engine.onEndFrameObservable.add((function(){if(t._gpuFrameTimeToken){var e=t.engine.endTimeQuery(t._gpuFrameTimeToken);e>-1&&(t._gpuFrameTimeToken=null,t._gpuFrameTime.fetchNewFrame(),t._gpuFrameTime.addCount(e,!0))}}))):(this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shaderCompilationTimeCounter",{get:function(){return this._shaderCompilationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureShaderCompilationTime",{get:function(){return this._captureShaderCompilationTime},set:function(e){var t=this;e!==this._captureShaderCompilationTime&&(this._captureShaderCompilationTime=e,e?(this._onBeforeShaderCompilationObserver=this.engine.onBeforeShaderCompilationObservable.add((function(){t._shaderCompilationTime.fetchNewFrame(),t._shaderCompilationTime.beginMonitoring()})),this._onAfterShaderCompilationObserver=this.engine.onAfterShaderCompilationObservable.add((function(){t._shaderCompilationTime.endMonitoring()}))):(this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null))},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver),this._onBeginFrameObserver=null,this.engine.onEndFrameObservable.remove(this._onEndFrameObserver),this._onEndFrameObserver=null,this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver),this._onBeforeShaderCompilationObserver=null,this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver),this._onAfterShaderCompilationObserver=null,this.engine=null},e}(),Er=function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new fe.f,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new fe.f,this._captureFrameTime=!1,this._frameTime=new fe.f,this._captureRenderTime=!1,this._renderTime=new fe.f,this._captureInterFrameTime=!1,this._interFrameTime=new fe.f,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new fe.f,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new fe.f,this._capturePhysicsTime=!1,this._physicsTime=new fe.f,this._captureAnimationsTime=!1,this._animationsTime=new fe.f,this._captureCameraRenderTime=!1,this._cameraRenderTime=new fe.f,this._onBeforeActiveMeshesEvaluationObserver=null,this._onAfterActiveMeshesEvaluationObserver=null,this._onBeforeRenderTargetsRenderObserver=null,this._onAfterRenderTargetsRenderObserver=null,this._onAfterRenderObserver=null,this._onBeforeDrawPhaseObserver=null,this._onAfterDrawPhaseObserver=null,this._onBeforeAnimationsObserver=null,this._onBeforeParticlesRenderingObserver=null,this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver=null,this._onAfterSpritesRenderingObserver=null,this._onBeforePhysicsObserver=null,this._onAfterPhysicsObserver=null,this._onAfterAnimationsObserver=null,this._onBeforeCameraRenderObserver=null,this._onAfterCameraRenderObserver=null,this._onBeforeAnimationsObserver=e.onBeforeAnimationsObservable.add((function(){t._captureActiveMeshesEvaluationTime&&t._activeMeshesEvaluationTime.fetchNewFrame(),t._captureRenderTargetsRenderTime&&t._renderTargetsRenderTime.fetchNewFrame(),t._captureFrameTime&&(fe.h.StartPerformanceCounter("Scene rendering"),t._frameTime.beginMonitoring()),t._captureInterFrameTime&&t._interFrameTime.endMonitoring(),t._captureParticlesRenderTime&&t._particlesRenderTime.fetchNewFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.fetchNewFrame(),t._captureAnimationsTime&&t._animationsTime.beginMonitoring(),t.scene.getEngine()._drawCalls.fetchNewFrame()})),this._onAfterRenderObserver=e.onAfterRenderObservable.add((function(){t._captureFrameTime&&(fe.h.EndPerformanceCounter("Scene rendering"),t._frameTime.endMonitoring()),t._captureRenderTime&&t._renderTime.endMonitoring(!1),t._captureInterFrameTime&&t._interFrameTime.beginMonitoring()}))}return Object.defineProperty(e.prototype,"activeMeshesEvaluationTimeCounter",{get:function(){return this._activeMeshesEvaluationTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureActiveMeshesEvaluationTime",{get:function(){return this._captureActiveMeshesEvaluationTime},set:function(e){var t=this;e!==this._captureActiveMeshesEvaluationTime&&(this._captureActiveMeshesEvaluationTime=e,e?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add((function(){fe.h.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){fe.h.EndPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.endMonitoring()}))):(this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTargetsRenderTimeCounter",{get:function(){return this._renderTargetsRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTargetsRenderTime",{get:function(){return this._captureRenderTargetsRenderTime},set:function(e){var t=this;e!==this._captureRenderTargetsRenderTime&&(this._captureRenderTargetsRenderTime=e,e?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add((function(){fe.h.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){fe.h.EndPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"particlesRenderTimeCounter",{get:function(){return this._particlesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureParticlesRenderTime",{get:function(){return this._captureParticlesRenderTime},set:function(e){var t=this;e!==this._captureParticlesRenderTime&&(this._captureParticlesRenderTime=e,e?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add((function(){fe.h.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){fe.h.EndPerformanceCounter("Particles"),t._particlesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"spritesRenderTimeCounter",{get:function(){return this._spritesRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureSpritesRenderTime",{get:function(){return this._captureSpritesRenderTime},set:function(e){var t=this;e!==this._captureSpritesRenderTime&&(this._captureSpritesRenderTime=e,this.scene.spriteManagers&&(e?(this._onBeforeSpritesRenderingObserver=this.scene.onBeforeSpritesRenderingObservable.add((function(){fe.h.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){fe.h.EndPerformanceCounter("Sprites"),t._spritesRenderTime.endMonitoring(!1)}))):(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null,this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null)))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsTimeCounter",{get:function(){return this._physicsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"capturePhysicsTime",{get:function(){return this._capturePhysicsTime},set:function(e){var t=this;e!==this._capturePhysicsTime&&this.scene.onBeforePhysicsObservable&&(this._capturePhysicsTime=e,e?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add((function(){fe.h.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){fe.h.EndPerformanceCounter("Physics"),t._physicsTime.endMonitoring()}))):(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null,this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationsTimeCounter",{get:function(){return this._animationsTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureAnimationsTime",{get:function(){return this._captureAnimationsTime},set:function(e){var t=this;e!==this._captureAnimationsTime&&(this._captureAnimationsTime=e,e?this._onAfterAnimationsObserver=this.scene.onAfterAnimationsObservable.add((function(){t._animationsTime.endMonitoring()})):(this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frameTimeCounter",{get:function(){return this._frameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureFrameTime",{get:function(){return this._captureFrameTime},set:function(e){this._captureFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"interFrameTimeCounter",{get:function(){return this._interFrameTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureInterFrameTime",{get:function(){return this._captureInterFrameTime},set:function(e){this._captureInterFrameTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderTimeCounter",{get:function(){return this._renderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureRenderTime",{get:function(){return this._captureRenderTime},set:function(e){var t=this;e!==this._captureRenderTime&&(this._captureRenderTime=e,e?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add((function(){t._renderTime.beginMonitoring(),fe.h.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),fe.h.EndPerformanceCounter("Main render")}))):(this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cameraRenderTimeCounter",{get:function(){return this._cameraRenderTime},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"captureCameraRenderTime",{get:function(){return this._captureCameraRenderTime},set:function(e){var t=this;e!==this._captureCameraRenderTime&&(this._captureCameraRenderTime=e,e?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add((function(e){t._cameraRenderTime.beginMonitoring(),fe.h.StartPerformanceCounter("Rendering camera "+e.name)})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),fe.h.EndPerformanceCounter("Rendering camera "+e.name)}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!0,configurable:!0}),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}(),Tr=n(16),Sr="#ifdef DIFFUSE\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef OPACITY\nvarying vec2 vUVOpacity;\nuniform sampler2D opacitySampler;\nuniform float opacityIntensity;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef VERTEXALPHA\nvarying vec4 vColor;\n#endif\nuniform vec4 glowColor;\nvoid main(void)\n{\nvec4 finalColor=glowColor;\n\n#ifdef DIFFUSE\nvec4 albedoTexture=texture2D(diffuseSampler,vUVDiffuse);\nfinalColor.a*=albedoTexture.a;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vUVOpacity);\n#ifdef OPACITYRGB\nfinalColor.a*=getLuminance(opacityMap.rgb);\n#else\nfinalColor.a*=opacityMap.a;\n#endif\nfinalColor.a*=opacityIntensity;\n#endif\n#ifdef VERTEXALPHA\nfinalColor.a*=vColor.a;\n#endif\n#ifdef ALPHATEST\nif (finalColor.a4&&(o.push(gn.b.MatricesIndicesExtraKind),o.push(gn.b.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+a.numBoneInfluencers),r.push("#define BonesPerMesh "+(a.skeleton?a.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0");var f=a.morphTargetManager,p=0;f&&f.numInfluencers>0&&(r.push("#define MORPHTARGETS"),p=f.numInfluencers,r.push("#define NUM_MORPH_INFLUENCERS "+p),Yi.a.PrepareAttributesForMorphTargets(o,a,{NUM_MORPH_INFLUENCERS:p})),t&&(r.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3")),this._addCustomEffectDefines(r);var m=r.join("\n");return this._cachedDefines!==m&&(this._cachedDefines=m,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","glowColor","morphTargetInfluences","diffuseMatrix","emissiveMatrix","opacityMatrix","opacityIntensity"],["diffuseSampler","emissiveSampler","opacitySampler"],m,void 0,void 0,void 0,{maxSimultaneousMorphTargets:p})),this._effectLayerMapGenerationEffect.isReady()},e.prototype.render=function(){var e=this._mergeEffect;if(e.isReady()){for(var t=0;t-1&&this._scene.effectLayers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},e.prototype.getClassName=function(){return"EffectLayer"},e.Parse=function(e,t,n){return fe.h.Instantiate(e.customType).Parse(e,t,n)},e._SceneComponentInitialization=function(e){throw Pr.a.WarnImport("EffectLayerSceneComponent")},l.c([Object(De.c)()],e.prototype,"name",void 0),l.c([Object(De.f)()],e.prototype,"neutralColor",void 0),l.c([Object(De.c)()],e.prototype,"isEnabled",void 0),l.c([Object(De.d)()],e.prototype,"camera",null),l.c([Object(De.c)()],e.prototype,"renderingGroupId",null),e}();i.a.AddParser(oe.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;n0&&(e.x-=this.viewportBorder,e.y-=this.viewportBorder,e.width+=2*this.viewportBorder,e.height+=2*this.viewportBorder,t.x+=this.viewportBorder,t.y+=this.viewportBorder,this._positionX+=this.viewportBorder,this._positionY+=this.viewportBorder),t.z>0&&(this._positionX>e.x&&this._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 Ee(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._effect.isReady()||!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 a=1-Ge.a.Clamp(r/this.borderLimit,0,1);if(a<0)return!1;a>1&&(a=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,l=s-this._positionX,u=c-this._positionY;n.enableEffect(this._effect),n.setState(!1),n.setDepthBuffer(!1),n.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var h=0;h0);for(var n=0,i=t;n0)}},e}();Ur._SceneComponentInitialization=function(e){var t=e._getComponent(oe.a.NAME_LENSFLARESYSTEM);t||(t=new Gr(e),e._addComponent(t))};var Hr=n(44),jr=n(99),Wr="#ifndef FLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\nfloat depth=vDepthMetric;\n#ifdef ESM\ndepth=clamp(exp(-min(87.,biasAndScale.z*depth)),0.,1.);\n#endif\n#ifdef FLOAT\ngl_FragColor=vec4(depth,1.0,1.0,1.0);\n#else\ngl_FragColor=pack(depth);\n#endif\n}";Lt.a.ShadersStore.shadowMapPixelShader=Wr;var Xr="\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include\n#include\n#include[0..maxSimultaneousMorphTargets]\n\n#include\n#include\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include[0..maxSimultaneousMorphTargets]\n#include\n#include\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";Lt.a.ShadersStore.shadowMapVertexShader=Xr;var Yr="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nvoid main(void)\n{\nvec4 colorDepth=vec4(0.0);\nfor (int x=-OFFSET; x<=OFFSET; x++)\nfor (int y=-OFFSET; y<=OFFSET; y++)\ncolorDepth+=texture2D(textureSampler,vUV+vec2(x,y)/screenSize);\ngl_FragColor=(colorDepth/float((OFFSET*2+1)*(OFFSET*2+1)));\n}";Lt.a.ShadersStore.depthBoxBlurPixelShader=Yr;var Kr=function(){function e(t,n,i){this.onBeforeShadowMapRenderObservable=new r.c,this.onBeforeShadowMapRenderMeshObservable=new r.c,this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=e.FILTER_NONE,this._filteringQuality=e.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=o.x.Zero(),this._viewMatrix=o.j.Zero(),this._projectionMatrix=o.j.Zero(),this._transformMatrix=o.j.Zero(),this._cachedPosition=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new o.x(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=o.j.Identity(),this._mapSize=t,this._light=n,this._scene=n.getScene(),n._shadowGenerator=this,e._SceneComponentInitialization(this._scene);var a=this._scene.getEngine().getCaps();i?a.textureFloatRender&&a.textureFloatLinearFiltering?this._textureType=m.a.TEXTURETYPE_FLOAT:a.textureHalfFloatRender&&a.textureHalfFloatLinearFiltering?this._textureType=m.a.TEXTURETYPE_HALF_FLOAT:this._textureType=m.a.TEXTURETYPE_UNSIGNED_INT:a.textureHalfFloatRender&&a.textureHalfFloatLinearFiltering?this._textureType=m.a.TEXTURETYPE_HALF_FLOAT:a.textureFloatRender&&a.textureFloatLinearFiltering?this._textureType=m.a.TEXTURETYPE_FLOAT:this._textureType=m.a.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(e.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthScale",{get:function(){return void 0!==this._depthScale?this._depthScale:this._light.getDepthScale()},set:function(e){this._depthScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filter",{get:function(){return this._filter},set:function(t){if(this._light.needCube()){if(t===e.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(t===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(t===e.FILTER_PCF||t===e.FILTER_PCSS)return void(this.usePoissonSampling=!0)}t!==e.FILTER_PCF&&t!==e.FILTER_PCSS||1!==this._scene.getEngine().webGLVersion?this._filter!==t&&(this._filter=t,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePoissonSampling",{get:function(){return this.filter===e.FILTER_POISSONSAMPLING},set:function(t){(t||this.filter===e.FILTER_POISSONSAMPLING)&&(this.filter=t?e.FILTER_POISSONSAMPLING:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useExponentialShadowMap",{get:function(){return this.filter===e.FILTER_EXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_EXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_BLUREXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_CLOSEEXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(t){(t||this.filter===e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=t?e.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===e.FILTER_PCF},set:function(t){(t||this.filter===e.FILTER_PCF)&&(this.filter=t?e.FILTER_PCF:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"useContactHardeningShadow",{get:function(){return this.filter===e.FILTER_PCSS},set:function(t){(t||this.filter===e.FILTER_PCSS)&&(this.filter=t?e.FILTER_PCSS:e.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!0,configurable:!0}),e.prototype.getDarkness=function(){return this._darkness},e.prototype.setDarkness=function(e){return this._darkness=e>=1?1:e<=0?0:e,this},e.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},e.prototype.getShadowMap=function(){return this._shadowMap},e.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},e.prototype.addShadowCaster=function(e,t){var n;return void 0===t&&(t=!0),this._shadowMap?(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(n=this._shadowMap.renderList).push.apply(n,e.getChildMeshes()),this):this},e.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var n=this._shadowMap.renderList.indexOf(e);if(-1!==n&&this._shadowMap.renderList.splice(n,1),t)for(var i=0,r=e.getChildren();i1?(this._shadowMap=new en.a(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture(m.a.LESS,!0)):this._shadowMap=new en.a(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=Kt.a.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=Kt.a.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode(Kt.a.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._shadowMap.onBeforeRenderObservable.add((function(i){t._currentFaceIndex=i,t._filter===e.FILTER_PCF&&n.setColorWrite(!1)})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){if(t._filter===e.FILTER_PCF&&n.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var i=t.getShadowMapForRendering();i&&t._scene.postProcessManager.directRender(t._blurPostProcesses,i.getInternalTexture(),!0)}}));var i=new o.f(0,0,0,0),r=new o.f(1,1,1,1);this._shadowMap.onClearObservable.add((function(n){t._filter===e.FILTER_PCF?n.clear(r,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?n.clear(i,!0,!0,!1):n.clear(r,!0,!0,!1)}))},e.prototype._initializeBlurRTTAndPostProcesses=function(){var e=this,t=this._scene.getEngine(),n=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new en.a(this._light.name+"_shadowMap2",n,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=Kt.a.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=Kt.a.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode(Kt.a.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new ji(this._light.name+"KernelBlurX",new o.w(1,0),this.blurKernel,1,null,Kt.a.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),this._kernelBlurXPostprocess.width=n,this._kernelBlurXPostprocess.height=n,this._kernelBlurXPostprocess.onApplyObservable.add((function(t){t.setTexture("textureSampler",e._shadowMap)})),this._kernelBlurYPostprocess=new ji(this._light.name+"KernelBlurY",new o.w(0,1),this.blurKernel,1,null,Kt.a.BILINEAR_SAMPLINGMODE,t,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===m.a.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new It.a(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,Kt.a.BILINEAR_SAMPLINGMODE,t,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(t){t.setFloat2("screenSize",n,n),t.setTexture("textureSampler",e._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},e.prototype._renderForShadowMap=function(e,t,n,i){var r,o=this._scene.getEngine();if(i.length){for(o.setColorWrite(!1),r=0;r=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.isReady=function(e,t){var n=[];this._textureType!==m.a.TEXTURETYPE_UNSIGNED_INT&&n.push("#define FLOAT"),this.useExponentialShadowMap||this.useBlurExponentialShadowMap?n.push("#define ESM"):(this.usePercentageCloserFiltering||this.useContactHardeningShadow)&&n.push("#define DEPTHTEXTURE");var i=[gn.b.PositionKind],r=e.getMesh(),o=e.getMaterial();if(this.normalBias&&r.isVerticesDataPresent(gn.b.NormalKind)&&(i.push(gn.b.NormalKind),n.push("#define NORMAL"),r.nonUniformScaling&&n.push("#define NONUNIFORMSCALING"),this.getLight().getTypeID()===Hr.a.LIGHTTYPEID_DIRECTIONALLIGHT&&n.push("#define DIRECTIONINLIGHTDATA")),o&&o.needAlphaTesting()){var a=o.getAlphaTestTexture();a&&(n.push("#define ALPHATEST"),r.isVerticesDataPresent(gn.b.UVKind)&&(i.push(gn.b.UVKind),n.push("#define UV1")),r.isVerticesDataPresent(gn.b.UV2Kind)&&1===a.coordinatesIndex&&(i.push(gn.b.UV2Kind),n.push("#define UV2")))}if(r.useBones&&r.computeBonesUsingShaders&&r.skeleton){i.push(gn.b.MatricesIndicesKind),i.push(gn.b.MatricesWeightsKind),r.numBoneInfluencers>4&&(i.push(gn.b.MatricesIndicesExtraKind),i.push(gn.b.MatricesWeightsExtraKind));var s=r.skeleton;n.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),s.isUsingTextureForMatrices?n.push("#define BONETEXTURE"):n.push("#define BonesPerMesh "+(s.bones.length+1))}else n.push("#define NUM_BONE_INFLUENCERS 0");var c=r.morphTargetManager,l=0;if(c&&c.numInfluencers>0&&(n.push("#define MORPHTARGETS"),l=c.numInfluencers,n.push("#define NUM_MORPH_INFLUENCERS "+l),Yi.a.PrepareAttributesForMorphTargets(i,r,{NUM_MORPH_INFLUENCERS:l})),t&&(n.push("#define INSTANCES"),i.push("world0"),i.push("world1"),i.push("world2"),i.push("world3")),this.customShaderOptions&&this.customShaderOptions.defines)for(var u=0,h=this.customShaderOptions.defines;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 l=Math.round(s*i);l<0?l=0:l>=i&&(l=i-1);var u=i-l-1;return{r:t[u*n*3+3*c+0],g:t[u*n*3+3*c+1],b:t[u*n*3+3*c+2]}},e.FACE_FRONT=[new o.x(-1,-1,-1),new o.x(1,-1,-1),new o.x(-1,1,-1),new o.x(1,1,-1)],e.FACE_BACK=[new o.x(1,-1,1),new o.x(-1,-1,1),new o.x(1,1,1),new o.x(-1,1,1)],e.FACE_RIGHT=[new o.x(1,-1,-1),new o.x(1,-1,1),new o.x(1,1,-1),new o.x(1,1,1)],e.FACE_LEFT=[new o.x(-1,-1,1),new o.x(-1,-1,-1),new o.x(-1,1,1),new o.x(-1,1,-1)],e.FACE_DOWN=[new o.x(-1,1,-1),new o.x(1,1,-1),new o.x(-1,1,1),new o.x(1,1,1)],e.FACE_UP=[new o.x(-1,-1,1),new o.x(1,-1,1),new o.x(-1,-1,-1),new o.x(1,-1,-1)],e}(),to=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_RLE(n,i);return eo.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,l=t.dataPosition,u=0,h=0,d=0,f=new ArrayBuffer(4*c),p=new Uint8Array(f),m=new ArrayBuffer(t.width*t.height*4*3),g=new Float32Array(m);s>0;){if(n=e[l++],i=e[l++],r=e[l++],o=e[l++],2!=n||2!=i||128&r)throw"HDR Bad header format, not RLE";if((r<<8|o)!=c)throw"HDR Bad header format, wrong scan line width";for(u=0,d=0;d<4;d++)for(h=(d+1)*c;u128){if(0==(a=n-128)||a>h-u)throw"HDR Bad Format, bad scanline data (run)";for(;a-- >0;)p[u++]=i}else{if(0==(a=n)||a>h-u)throw"HDR Bad Format, bad scanline data (non-run)";if(p[u++]=i,--a>0)for(var _=0;_255){var _=255/g;f*=_,p*=_,m*=_}c[3*d+0]=f,c[3*d+1]=p,c[3*d+2]=m}c?s.push(c):s.push(h)}return s}),null,this._onLoad,this._onError))},t.prototype.clone=function(){var e=this.getScene();if(!e)return this;var n=new t(this.url,e,this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return n.level=this.level,n.wrapU=this.wrapU,n.wrapV=this.wrapV,n.coordinatesIndex=this.coordinatesIndex,n.coordinatesMode=this.coordinatesMode,n},t.prototype.delayLoad=function(){this.delayLoadState===ee.b.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=ee.b.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},t.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},t.prototype.setReflectionTextureMatrix=function(e){var t=this;this._textureMatrix=e,e.updateFlag!==this._textureMatrix.updateFlag&&e.isIdentity()!==this._textureMatrix.isIdentity()&&this.getScene().markAllMaterialsAsDirty(m.a.MATERIAL_TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(t)}))},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=o.x.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(r.boundingBoxSize=o.x.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}(zi.a));a.a.RegisteredTypes["BABYLON.HDRCubeTexture"]=no;var io=n(126),ro=function(){function e(t,n){if(void 0===n&&(n=e.DefaultPluginFactory()),this._physicsPlugin=n,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");t=t||new o.x(0,-9.807,0),this.setGravity(t),this.setTimeStep()}return e.DefaultPluginFactory=function(){throw Pr.a.WarnImport("CannonJSPlugin")},e.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},e.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},e.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},e.prototype.dispose=function(){this._impostors.forEach((function(e){e.dispose()})),this._physicsPlugin.dispose()},e.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},e.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},e.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);t>-1&&(this._impostors.splice(t,1).length&&this.getPhysicsPlugin().removePhysicsBody(e))},e.prototype.addJoint=function(e,t,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._removeAfterStep.forEach((function(e){t.world.remove(e.physicsBody)})),this._removeAfterStep=[])},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(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),this.world.add(e.physicsBody),n&&["force","torque","velocity","angularVelocity"].forEach((function(t){e.physicsBody[t].copy(n[t])})),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(n.length){var r=function(n,a){if(i&&a.rotationQuaternion){var s=a.getPhysicsImpostor();if(s)if(s.parent!==e){var c=a.getAbsolutePosition().subtract(e.object.getAbsolutePosition()),l=a.rotationQuaternion.multiply(o.q.Inverse(i));s.physicsBody&&(t.removePhysicsBody(s),s.physicsBody=null),s.parent=e,s.resetUpdateFlags(),e.physicsBody.addShape(t._createShape(s),new t.BJSCANNON.Vec3(c.x,c.y,c.z),new t.BJSCANNON.Quaternion(l.x,l.y,l.z,l.w)),e.physicsBody.mass+=s.getParam("mass")}i.multiplyInPlace(a.rotationQuaternion),a.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(r.bind(t,a.getAbsolutePosition()))}};n.filter((function(e){return!!e.physicsImpostor})).forEach(r.bind(this,e.object.getAbsolutePosition()))}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),this._removeAfterStep.push(e)},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).copy(r.mainPivot):null,pivotB:r.connectedPivot?(new this.BJSCANNON.Vec3).copy(r.connectedPivot):null,axisA:r.mainAxis?(new this.BJSCANNON.Vec3).copy(r.mainAxis):null,axisB:r.connectedAxis?(new this.BJSCANNON.Vec3).copy(r.connectedAxis):null,maxForce:r.nativeParams.maxForce,collideConnected:!!r.collision};switch(e.joint.type){case ii.HingeJoint:case ii.Hinge2Joint:i=new this.BJSCANNON.HingeConstraint(t,n,o);break;case ii.DistanceJoint:i=new this.BJSCANNON.DistanceConstraint(t,n,r.maxDistance||2);break;case ii.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 ii.LockJoint:i=new this.BJSCANNON.LockConstraint(t,n,o);break;case ii.PointToPointJoint:case ii.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!==ii.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!==ii.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,l=e,u=this.bodies,h=0;h!==u.length;h++){var d=u[h];d.type!==t.Body.STATIC&&d.sleepState!==t.Body.SLEEPING?(d.position.vsub(d.previousPosition,l),l.scale(c,l),d.position.vadd(l,d.interpolatedPosition)):(d.interpolatedPosition.copy(d.position),d.interpolatedQuaternion.copy(d.quaternion))}}}},e.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}();ro.DefaultPluginFactory=function(){return new ao};var so=function(){function e(e,t){void 0===t&&(t=OIMO),this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=o.x.Zero(),this.BJSOIMO=t,this.world=new this.BJSOIMO.World({iterations:e}),this.world.clear(),this._raycastResult=new oo}return e.prototype.setGravity=function(e){this.world.gravity.copy(e)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var n=this;t.forEach((function(e){e.beforeStep()})),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}),o.onCollide({body:r.physicsBody}),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){p.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")||1,e.getParam("friction"),e.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==e.getParam("mass"),density:e.getParam("mass"),friction:e.getParam("friction"),restitution:e.getParam("restitution"),world:this.world},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,ro.Epsilon)},a=new o.q;i.forEach((function(i){if(i.object.rotationQuaternion){var o=i.object.rotationQuaternion;a=o.clone();var s=o.toEulerAngles(),c=i.getObjectExtendSize();if(i===e){var l=e.getObjectCenter();e.object.getAbsolutePivotPoint().subtractToRef(l,t._tmpPositionVector),t._tmpPositionVector.divideInPlace(e.object.scaling),n.pos.push(l.x),n.pos.push(l.y),n.pos.push(l.z),n.posShape.push(0,0,0),n.rotShape.push(0,0,0)}else{var u=i.object.getAbsolutePosition().subtract(e.object.getAbsolutePosition());n.posShape.push(u.x),n.posShape.push(u.y),n.posShape.push(u.z),n.pos.push(0,0,0),n.rotShape.push(57.29577951308232*s.x),n.rotShape.push(57.29577951308232*s.y),n.rotShape.push(57.29577951308232*s.z)}switch(i.type){case ci.ParticleImpostor:p.a.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case ci.SphereImpostor:var h=c.x,d=c.y,f=c.z,m=Math.max(r(h),r(d),r(f))/2;n.type.push("sphere"),n.size.push(m),n.size.push(m),n.size.push(m);break;case ci.CylinderImpostor:var g=r(c.x)/2,_=r(c.y);n.type.push("cylinder"),n.size.push(g),n.size.push(_),n.size.push(_);break;case ci.PlaneImpostor:case ci.BoxImpostor:default:g=r(c.x),_=r(c.y);var v=r(c.z);n.type.push("box"),n.size.push(g),n.size.push(_),n.size.push(v)}i.object.rotationQuaternion=o}})),e.physicsBody=this.world.add(n),e.physicsBody.resetQuaternion(a),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 ii.BallAndSocketJoint:i="jointBall";break;case ii.SpringJoint:p.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 ii.DistanceJoint:i="jointDistance",a.max=r.maxDistance;break;case ii.PrismaticJoint:i="jointPrisme";break;case ii.SliderJoint:i="jointSlide";break;case ii.WheelJoint:i="jointWheel";break;case ii.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){p.a.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.sleeping||(e.object.position.copyFrom(e.physicsBody.getPosition()),e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion()))},e.prototype.setPhysicsBodyTransformation=function(e,t,n){var i=e.physicsBody;i.position.copy(t),i.orientation.copy(n),i.syncShapes(),i.awake()},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.copy(t)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new o.x(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new o.x(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var 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?p.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 p.a.Warn("raycast is not currently supported by the Oimo physics plugin"),this._raycastResult.reset(e,t),this._raycastResult},e}();mn.a.CreateRibbon=function(e){var t=e.pathArray,n=e.closeArray||!1,i=e.closePath||!1,r=e.invertUV||!1,o=Math.floor(t[0].length/2),a=e.offset||o;a=a>o?o:Math.floor(a);var s,c,l,u,h=0===e.sideOrientation?0:e.sideOrientation||mn.a.DEFAULTSIDE,d=e.uvs,f=e.colors,p=[],m=[],g=[],_=[],v=[],b=[],y=[],x=[],C=[],E=[];if(t.length<2){var T=[],S=[];for(l=0;l0&&(M=A[u].subtract(A[u-1]).length()+y[c],v[c].push(M),y[c]=M),u++;i&&(u--,p.push(A[0].x,A[0].y,A[0].z),M=A[u].subtract(A[0]).length()+y[c],v[c].push(M),y[c]=M),C[c]=P+I,E[c]=w,w+=P+I}var L,D,N=null,F=null;for(l=0;l3?0:u,h);var E=co.CreateRibbon(e,{pathArray:y,closeArray:c,closePath:l,updatable:f,sideOrientation:p,invertUV:g,frontUVs:_||void 0,backUVs:v||void 0},d);return E._creationDataStorage.pathArray=y,E._creationDataStorage.path3D=b,E._creationDataStorage.cap=u,E},e}(),uo=function(){function e(e,t){var n=this;void 0===e&&(e=!0),void 0===t&&(t=Ammo),this._useDeltaForWorldStep=e,this.bjsAMMO={},this.name="AmmoJSPlugin",this._timeStep=1/60,this._fixedTimeStep=1/60,this._maxSteps=5,this._tmpQuaternion=new o.q,this._tmpContactCallbackResult=!1,this._tmpVector=new o.x,this._tmpMatrix=new o.j,"function"==typeof t?t(this.bjsAMMO):this.bjsAMMO=t,this.isSupported()?(this._collisionConfiguration=new this.bjsAMMO.btSoftBodyRigidBodyCollisionConfiguration,this._dispatcher=new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration),this._overlappingPairCache=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(){n._tmpContactCallbackResult=!0},this._raycastResult=new oo,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)):p.a.Error("AmmoJS is not available. Please make sure you included the js file.")}return e.prototype.setGravity=function(e){this._tmpAmmoVectorA.setValue(e.x,e.y,e.z),this.world.setGravity(this._tmpAmmoVectorA),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,l=s._onPhysicsCollideCallbacks;c3?3:s;var c=(new Ammo.btSoftBodyHelpers).CreateRope(this.world.getWorldInfo(),this._tmpAmmoVectorA,this._tmpAmmoVectorB,n-1,s);return c.get_m_cfg().set_collisions(17),c},e.prototype._addHullVerts=function(e,t,n){var i=this,r=0;if(n&&n.getIndices&&n.getWorldMatrix&&n.getChildMeshes){var a=n.getIndices();a||(a=[]);var s=n.getVerticesData(gn.b.PositionKind);s||(s=[]),n.computeWorldMatrix(!1);for(var c=a.length/3,l=0;l0){if(e.type!=ci.NoImpostor){var l=this._createShape(e,!0);l&&(this._tmpAmmoTransform.getOrigin().setValue(0,0,0),this._tmpAmmoQuaternion.setValue(0,0,0,1),this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion),i.addChildShape(this._tmpAmmoTransform,l))}return i}Ammo.destroy(i),i=null}switch(e.type){case ci.SphereImpostor:i=new Ammo.btSphereShape(a.x/2);break;case ci.CylinderImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new Ammo.btCylinderShape(this._tmpAmmoVectorA);break;case ci.PlaneImpostor:case ci.BoxImpostor:this._tmpAmmoVectorA.setValue(a.x/2,a.y/2,a.z/2),i=new Ammo.btBoxShape(this._tmpAmmoVectorA);break;case ci.MeshImpostor:if(0==e.getParam("mass")){var u=new Ammo.btTriangleMesh;e._pluginData.toDispose.push(u);var h=this._addMeshVerts(u,r,r);i=0==h?new Ammo.btCompoundShape:new Ammo.btBvhTriangleMeshShape(u);break}case ci.ConvexHullImpostor:var d=new Ammo.btConvexHullShape;0==(h=this._addHullVerts(d,r,r))?(e._pluginData.toDispose.push(d),i=new Ammo.btCompoundShape):i=d;break;case ci.NoImpostor:i=new Ammo.btSphereShape(a.x/2);break;case ci.SoftbodyImpostor:i=this._createSoftbody(e);break;case ci.ClothImpostor:i=this._createCloth(e);break;case ci.RopeImpostor:i=this._createRope(e);break;default:p.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(i.getOrigin().x()!=t.x||i.getOrigin().y()!=t.y||i.getOrigin().z()!=t.z||i.getRotation().x()!=n.x||i.getRotation().y()!=n.y||i.getRotation().z()!=n.z||i.getRotation().w()!=n.w)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 o.x(t.x(),t.y(),t.z());return Ammo.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 o.x(t.x(),t.y(),t.z());return Ammo.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:(p.a.Warn("Pressure is not a property of a rigid body"),0)},e.prototype.setBodyPressure=function(e,t){e.soft?e.type===ci.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):p.a.Warn("Pressure can only be applied to a softbody")},e.prototype.getBodyStiffness=function(e){return e.soft?e._pluginData.stiffness||0:(p.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):p.a.Warn("Stiffness cannot be applied to a rigid body")},e.prototype.getBodyVelocityIterations=function(e){return e.soft?e._pluginData.velocityIterations||0:(p.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):p.a.Warn("Velocity iterations cannot be applied to a rigid body")},e.prototype.getBodyPositionIterations=function(e){return e.soft?e._pluginData.positionIterations||0:(p.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):p.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){p.a.Warn("sleepBody is not currently supported by the Ammo physics plugin")},e.prototype.wakeUpBody=function(e){e.physicsBody.activate()},e.prototype.updateDistanceJoint=function(e,t,n){p.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){p.a.Warn("setLimit is not currently supported by the Ammo physics plugin")},e.prototype.syncMeshWithImpostor=function(e,t){t.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform),e.position.x=this._tmpAmmoTransform.getOrigin().x(),e.position.y=this._tmpAmmoTransform.getOrigin().y(),e.position.z=this._tmpAmmoTransform.getOrigin().z(),e.rotationQuaternion&&(e.rotationQuaternion.x=this._tmpAmmoTransform.getRotation().x(),e.rotationQuaternion.y=this._tmpAmmoTransform.getRotation().y(),e.rotationQuaternion.z=this._tmpAmmoTransform.getRotation().z(),e.rotationQuaternion.w=this._tmpAmmoTransform.getRotation().w())},e.prototype.getRadius=function(e){return e.getObjectExtendSize().x/2},e.prototype.getBoxSizeToRef=function(e,t){var n=e.getObjectExtendSize();t.x=n.x,t.y=n.y,t.z=n.z},e.prototype.dispose=function(){Ammo.destroy(this.world),Ammo.destroy(this._solver),Ammo.destroy(this._overlappingPairCache),Ammo.destroy(this._dispatcher),Ammo.destroy(this._collisionConfiguration),Ammo.destroy(this._tmpAmmoVectorA),Ammo.destroy(this._tmpAmmoVectorB),Ammo.destroy(this._tmpAmmoVectorC),Ammo.destroy(this._tmpAmmoTransform),Ammo.destroy(this._tmpAmmoQuaternion),Ammo.destroy(this._tmpAmmoConcreteContactResultCallback),this.world=null},e.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()),Ammo.destroy(n),Ammo.destroy(this._tmpAmmoVectorRCA),Ammo.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 ho=function(){function e(e,t,n,i,r){var a=this;void 0===i&&(i=!0),void 0===r&&(r=!1),this.name=e,this._viewMatrix=o.j.Identity(),this._target=o.x.Zero(),this._add=o.x.Zero(),this._invertYAxis=!1,this.position=o.x.Zero(),this._scene=n,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this),this._renderTargetTexture=new en.a(e,t,n,i,!0,r?m.a.TEXTURETYPE_FLOAT:m.a.TEXTURETYPE_UNSIGNED_INT,!0),this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(e){case 0:a._add.copyFromFloats(1,0,0);break;case 1:a._add.copyFromFloats(-1,0,0);break;case 2:a._add.copyFromFloats(0,a._invertYAxis?1:-1,0);break;case 3:a._add.copyFromFloats(0,a._invertYAxis?-1:1,0);break;case 4:a._add.copyFromFloats(0,0,1);break;case 5:a._add.copyFromFloats(0,0,-1)}a._attachedMesh&&a.position.copyFrom(a._attachedMesh.getAbsolutePosition()),a.position.addToRef(a._add,a._target),o.j.LookAtLHToRef(a.position,a._target,o.x.Up(),a._viewMatrix),n.activeCamera&&(a._projectionMatrix=o.j.PerspectiveFovLH(Math.PI/2,1,n.activeCamera.minZ,n.activeCamera.maxZ),n.setTransformMatrix(a._viewMatrix,a._projectionMatrix)),n._forcedViewPosition=a.position})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){n._forcedViewPosition=null,n.updateTransformMatrix(!0)}))}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._renderTargetTexture.samples},set:function(e){this._renderTargetTexture.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"refreshRate",{get:function(){return this._renderTargetTexture.refreshRate},set:function(e){this._renderTargetTexture.refreshRate=e},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},Object.defineProperty(e.prototype,"cubeTexture",{get:function(){return this._renderTargetTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderList",{get:function(){return this._renderTargetTexture.renderList},enumerable:!0,configurable:!0}),e.prototype.attachToMesh=function(e){this._attachedMesh=e},e.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderTargetTexture.setRenderingAutoClearDepthStencil(e,t)},e.prototype.dispose=function(){var e=this._scene.reflectionProbes.indexOf(this);-1!==e&&this._scene.reflectionProbes.splice(e,1),this._renderTargetTexture&&(this._renderTargetTexture.dispose(),this._renderTargetTexture=null)},e.prototype.toString=function(e){var t="Name: "+this.name;return e&&(t+=", position: "+this.position.toString(),this._attachedMesh&&(t+=", attached mesh: "+this._attachedMesh.name)),t},e.prototype.getClassName=function(){return"ReflectionProbe"},e.prototype.serialize=function(){var e=De.a.Serialize(this,this._renderTargetTexture.serialize());return e.isReflectionProbe=!0,e},e.Parse=function(t,n,i){var r=null;if(n.reflectionProbes)for(var o=0;o0){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 fe.h.Warn("Invalid level of detail distances for "+t.name)}}t._waitingData.lods=null}},_o=function(e,t,n,r,o){void 0===o&&(o=!1);var s=new $.a(e),c="importScene has failed JSON parse";try{var l=JSON.parse(t);c="";var u,h,d=bi.a.loggingLevel===bi.a.DETAILED_LOGGING;if(void 0!==l.environmentTexture&&null!==l.environmentTexture){var f=void 0===l.isPBR||l.isPBR;if(l.environmentTextureType&&"BABYLON.HDRCubeTexture"===l.environmentTextureType){var m=l.environmentTextureSize?l.environmentTextureSize:128,g=new no((l.environmentTexture.match(/https?:\/\//g)?"":n)+l.environmentTexture,e,m,!0,!f);l.environmentTextureRotationY&&(g.rotationY=l.environmentTextureRotationY),e.environmentTexture=g}else if(fe.h.EndsWith(l.environmentTexture,".env")){var _=new Xi.a((l.environmentTexture.match(/https?:\/\//g)?"":n)+l.environmentTexture,e);l.environmentTextureRotationY&&(_.rotationY=l.environmentTextureRotationY),e.environmentTexture=_}else{var v=Xi.a.CreateFromPrefilteredData((l.environmentTexture.match(/https?:\/\//g)?"":n)+l.environmentTexture,e);l.environmentTextureRotationY&&(v.rotationY=l.environmentTextureRotationY),e.environmentTexture=v}if(!0===l.createDefaultSkybox){var b=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,y=l.skyboxBlurLevel||0;e.createDefaultSkybox(e.environmentTexture,f,b,y)}s.environmentTexture=e.environmentTexture}if(void 0!==l.lights&&null!==l.lights)for(u=0,h=l.lights.length;u0){for(var ne=0;ne0){for(var re=0;re-1&&void 0!==u.skeletons&&null!==u.skeletons)if(!1===_.indexOf(b.skeletonId)>-1)for(var R=0,w=u.skeletons.length;R1,i.wrapU=m.a.TEXTURE_CLAMP_ADDRESSMODE,i.wrapV=m.a.TEXTURE_CLAMP_ADDRESSMODE,i.wrapR=m.a.TEXTURE_CLAMP_ADDRESSMODE,i.anisotropicFilteringLevel=1,i._texture=i._getFromCache(t,!0),i._texture||(n.useDelayedTextureLoading?i.delayLoadState=m.a.DELAYLOADSTATE_NOTLOADED:i.loadTexture()),i):i}return l.d(t,e),t.prototype.getTextureMatrix=function(){return this._textureMatrix},t.prototype.load3dlTexture=function(){var e,n=this._engine;e=1===n.webGLVersion?n.createRawTexture(null,1,1,m.a.TEXTUREFORMAT_RGBA,!1,!1,m.a.TEXTURE_BILINEAR_SAMPLINGMODE):n.createRawTexture3D(null,1,1,1,m.a.TEXTUREFORMAT_RGBA,!1,!1,m.a.TEXTURE_BILINEAR_SAMPLINGMODE),this._texture=e;var i=function(i){if("string"==typeof i){for(var r,o=null,a=null,s=i.split("\n"),c=0,l=0,u=0,h=0,d=0,f=0;f0&&(f+1)%4==0)o[f]=255;else{var y=a[f];o[f]=y/d*255}e.is3D?(e.updateSize(c,c,c),n.updateRawTexture3D(e,o,m.a.TEXTUREFORMAT_RGBA,!1)):(e.updateSize(c*c,c),n.updateRawTexture(e,o,m.a.TEXTUREFORMAT_RGBA,!1))}},r=this.getScene();return r?r._loadFile(this.url,i):this._engine._loadFile(this.url,i),this._texture},t.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},t.prototype.clone=function(){var e=new t(this.url,this.getScene());return e.level=this.level,e},t.prototype.delayLoad=function(){this.delayLoadState===m.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=m.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}(zi.a);a.a.RegisteredTypes["BABYLON.ColorGradingTexture"]=Ao;var Po=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,c.coordinatesMode=Kt.a.CUBIC_MODE,!t)throw new Error("Image url is not set");return 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?fe.h.SetImmediate((function(){return a()})):c._texture.onLoadedObservable.add(a)):n.useDelayedTextureLoading?c.delayLoadState=ee.b.DELAYLOADSTATE_NOTLOADED:c.loadImage(c.loadTexture.bind(c),c._onError),c}return l.d(t,e),t.prototype.loadImage=function(e,t){var n=this,i=document.createElement("canvas"),r=new Image;r.addEventListener("load",(function(){n._width=r.width,n._height=r.height,i.width=n._width,i.height=n._height;var t=i.getContext("2d");t.drawImage(r,0,0);var o=t.getImageData(0,0,r.width,r.height);n._buffer=o.data.buffer,i.remove(),e()})),r.addEventListener("error",(function(e){t&&t(n.getClassName()+" could not be loaded",e)})),r.src=this.url},t.prototype.loadTexture=function(){var e=this,n=this.getScene();n&&(this._texture=n.getEngine().createRawCubeTextureFromUrl(this.url,n,this._size,ee.b.TEXTUREFORMAT_RGB,n.getEngine().getCaps().textureFloat?ee.b.TEXTURETYPE_FLOAT:ee.b.TEXTURETYPE_UNSIGNED_INTEGER,this._noMipmap,(function(){for(var n=e.getFloat32ArrayFromArrayBuffer(e._buffer),i=eo.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;rn.length)p.a.Error("Unable to load TGA file - Not enough data");else{i+=r.id_length;var o,a=!1,s=!1,c=!1;switch(r.image_type){case e._TYPE_RLE_INDEXED:a=!0;case e._TYPE_INDEXED:s=!0;break;case e._TYPE_RLE_RGB:a=!0;case e._TYPE_RGB:break;case e._TYPE_RLE_GREY:a=!0;case e._TYPE_GREY:c=!0}var l,u,h,d,f,m,g,_=r.pixel_size>>3,v=r.width*r.height*_;if(s&&(l=n.subarray(i,i+=r.colormap_length*(r.colormap_size>>3))),a){var b,y,x;o=new Uint8Array(v);for(var C=0,E=new Uint8Array(_);i>e._ORIGIN_SHIFT){default:case e._ORIGIN_UL:u=0,d=1,g=r.width,h=0,f=1,m=r.height;break;case e._ORIGIN_BL:u=0,d=1,g=r.width,h=r.height-1,f=-1,m=-1;break;case e._ORIGIN_UR:u=r.width-1,d=-1,g=-1,h=0,f=1,m=r.height;break;case e._ORIGIN_BR:u=r.width-1,d=-1,g=-1,h=r.height-1,f=-1,m=-1}var T=e["_getImageData"+(c?"Grey":"")+r.pixel_size+"bits"](r,l,o,h,f,m,u,d,g);t.getEngine()._uploadDataToTextureDirectly(t,T)}}},e._getImageData8bits=function(e,t,n,i,r,o,a,s,c){var l,u,h,d=n,f=t,p=e.width,m=e.height,g=0,_=new Uint8Array(p*m*4);for(h=i;h!==o;h+=r)for(u=a;u!==c;u+=s,g++)l=d[g],_[4*(u+p*h)+3]=255,_[4*(u+p*h)+2]=f[3*l+0],_[4*(u+p*h)+1]=f[3*l+1],_[4*(u+p*h)+0]=f[3*l+2];return _},e._getImageData16bits=function(e,t,n,i,r,o,a,s,c){var l,u,h,d=n,f=e.width,p=e.height,m=0,g=new Uint8Array(f*p*4);for(h=i;h!==o;h+=r)for(u=a;u!==c;u+=s,m+=2){var _=255*((31744&(l=d[m+0]+(d[m+1]<<8)))>>10)/31|0,v=255*((992&l)>>5)/31|0,b=255*(31&l)/31|0;g[4*(u+f*h)+0]=_,g[4*(u+f*h)+1]=v,g[4*(u+f*h)+2]=b,g[4*(u+f*h)+3]=32768&l?0:255}return g},e._getImageData24bits=function(e,t,n,i,r,o,a,s,c){var l,u,h=n,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(u=i;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=3)m[4*(l+d*u)+3]=255,m[4*(l+d*u)+2]=h[p+0],m[4*(l+d*u)+1]=h[p+1],m[4*(l+d*u)+0]=h[p+2];return m},e._getImageData32bits=function(e,t,n,i,r,o,a,s,c){var l,u,h=n,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(u=i;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=4)m[4*(l+d*u)+2]=h[p+0],m[4*(l+d*u)+1]=h[p+1],m[4*(l+d*u)+0]=h[p+2],m[4*(l+d*u)+3]=h[p+3];return m},e._getImageDataGrey8bits=function(e,t,n,i,r,o,a,s,c){var l,u,h,d=n,f=e.width,p=e.height,m=0,g=new Uint8Array(f*p*4);for(h=i;h!==o;h+=r)for(u=a;u!==c;u+=s,m++)l=d[m],g[4*(u+f*h)+0]=l,g[4*(u+f*h)+1]=l,g[4*(u+f*h)+2]=l,g[4*(u+f*h)+3]=255;return g},e._getImageDataGrey16bits=function(e,t,n,i,r,o,a,s,c){var l,u,h=n,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(u=i;u!==o;u+=r)for(l=a;l!==c;l+=s,p+=2)m[4*(l+d*u)+0]=h[p+0],m[4*(l+d*u)+1]=h[p+0],m[4*(l+d*u)+2]=h[p+0],m[4*(l+d*u)+3]=h[p+1];return m},e._TYPE_INDEXED=1,e._TYPE_RGB=2,e._TYPE_GREY=3,e._TYPE_RLE_INDEXED=9,e._TYPE_RLE_RGB=10,e._TYPE_RLE_GREY=11,e._ORIGIN_MASK=48,e._ORIGIN_SHIFT=4,e._ORIGIN_BL=0,e._ORIGIN_BR=1,e._ORIGIN_UL=2,e._ORIGIN_UR=3,e}(),Oo=function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,n,i,r){return 0===e.indexOf(".tga")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,n,i,r){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,n){var i=new Uint8Array(e),r=Mo.GetTGAHeader(i);n(r.width,r.height,t.generateMipMaps,!1,(function(){Mo.UploadContent(t,i)}))},e}();ee.b._TextureLoaders.push(new Oo),ee.b.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t,n){void 0===t&&(t=!1),this._currentRenderTarget=null;var i=this._gl;if(e[0]._MSAAFramebuffer){i.bindFramebuffer(i.READ_FRAMEBUFFER,e[0]._MSAAFramebuffer),i.bindFramebuffer(i.DRAW_FRAMEBUFFER,e[0]._framebuffer);var r=e[0]._attachments;r||(r=new Array(e.length),e[0]._attachments=r);for(var o=0;o1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],i.readBuffer(r[o]),i.drawBuffers(r),i.blitFramebuffer(0,0,a.width,a.height,0,0,a.width,a.height,i.COLOR_BUFFER_BIT,i.NEAREST)}for(o=0;o1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"];i.drawBuffers(r)}for(o=0;o1?"COLOR_ATTACHMENT"+b:"COLOR_ATTACHMENT"+b+"_WEBGL"];g.push(E),_.push(T),h.activeTexture(h["TEXTURE"+b]),h.bindTexture(h.TEXTURE_2D,E._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,C.mag),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,C.min),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(x),f,m,0,h.RGBA,this._getWebGLTextureType(x),null),h.framebufferTexture2D(h.DRAW_FRAMEBUFFER,T,h.TEXTURE_2D,E._webGLTexture,0),n&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(h.TEXTURE_2D,null),E._framebuffer=d,E._depthStencilBuffer=v,E.baseWidth=f,E.baseHeight=m,E.width=f,E.height=m,E.isReady=!0,E.samples=1,E.generateMipMaps=n,E.samplingMode=y,E.type=x,E._generateDepthBuffer=i,E._generateStencilBuffer=r,E._attachments=_,this._internalTexturesCache.push(E)}if(o&&this._caps.depthTextureExtension){var S=new Jt.a(this,Jt.a.DATASOURCE_MULTIRENDERTARGET);h.activeTexture(h.TEXTURE0),h.bindTexture(h.TEXTURE_2D,S._webGLTexture),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MAG_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_MIN_FILTER,h.NEAREST),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_S,h.CLAMP_TO_EDGE),h.texParameteri(h.TEXTURE_2D,h.TEXTURE_WRAP_T,h.CLAMP_TO_EDGE),h.texImage2D(h.TEXTURE_2D,0,this.webGLVersion<2?h.DEPTH_COMPONENT:h.DEPTH_COMPONENT16,f,m,0,h.DEPTH_COMPONENT,h.UNSIGNED_SHORT,null),h.framebufferTexture2D(h.FRAMEBUFFER,h.DEPTH_ATTACHMENT,h.TEXTURE_2D,S._webGLTexture,0),S._framebuffer=d,S.baseWidth=f,S.baseHeight=m,S.width=f,S.height=m,S.isReady=!0,S.samples=1,S.generateMipMaps=n,S.samplingMode=h.NEAREST,S._generateDepthBuffer=i,S._generateStencilBuffer=r,g.push(S),this._internalTexturesCache.push(S)}return h.drawBuffers(_),h.bindRenderbuffer(h.RENDERBUFFER,null),this._bindUnboundFramebuffer(null),this.resetTextureCache(),g},ee.b.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||0==e.length)return 1;if(e[0].samples===t)return t;var n=this._gl;t=Math.min(t,n.getParameter(n.MAX_SAMPLES)),e[0]._depthStencilBuffer&&(n.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(n.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var i=0;i1){var r=n.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");this._bindUnboundFramebuffer(r);var o=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),a=[];for(i=0;i1?"COLOR_ATTACHMENT"+i:"COLOR_ATTACHMENT"+i+"_WEBGL"],l=n.createRenderbuffer();if(!l)throw new Error("Unable to create multi sampled framebuffer");n.bindRenderbuffer(n.RENDERBUFFER,l),n.renderbufferStorageMultisample(n.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(s.type),s.width,s.height),n.framebufferRenderbuffer(n.FRAMEBUFFER,c,n.RENDERBUFFER,l),s._MSAAFramebuffer=r,s._MSAARenderBuffer=l,s.samples=t,s._depthStencilBuffer=o,n.bindRenderbuffer(n.RENDERBUFFER,null),a.push(c)}n.drawBuffers(a)}else this._bindUnboundFramebuffer(e[0]._framebuffer);return this._bindUnboundFramebuffer(null),t};var Ro=function(e){function t(t,n,i,r,o){var a=this,s=!(!o||!o.generateMipMaps)&&o.generateMipMaps,c=!(!o||!o.generateDepthTexture)&&o.generateDepthTexture,l=!o||void 0===o.doNotChangeAspectRatio||o.doNotChangeAspectRatio;if((a=e.call(this,t,n,r,s,l)||this)._engine=r.getEngine(),a.isSupported){for(var u=[],h=[],d=0;d1||this._engine.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t=0;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},t}(en.a),wo=n(102),Io=n(87),Lo=function(e){function t(t,n,i,r,o,a){var s=e.call(this,t,i,null,r,o,a)||this;return s._animate=!0,s._time=0,s._texturePath=n,s._loadJson(n),s.refreshRate=1,s}return l.d(t,e),t.prototype._loadJson=function(e){var t=this,n=function(){p.a.Log("No config file found in "+e+" trying to use ShadersStore or DOM element");try{t.setFragment(t._texturePath)}catch(e){p.a.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},i=e+"/config.json",r=new Io.a;r.open("GET",i),r.addEventListener("load",(function(){if(200===r.status||r.responseText&&r.responseText.length>0)try{t._config=JSON.parse(r.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+"/custom"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){n()}else n()}),!1),r.addEventListener("error",(function(){n()}),!1);try{r.send()}catch(e){p.a.Error("CustomProceduralTexture: Error on XHR send request.")}},t.prototype.isReady=function(){if(!e.prototype.isReady.call(this))return!1;for(var t in this._textures){if(!this._textures[t].isReady())return!1}return!0},t.prototype.render=function(t){var 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;ee.EPSILON?1:0;l|=h,u.push(h)}switch(l){case 0:(o.x.Dot(this.normal,t.plane.normal)>0?n:i).push(t);break;case 1:r.push(t);break;case 2:a.push(t);break;case 3:var d,f=[],p=[];for(s=0;s=3&&(d=new Yo(f,t.shared)).plane&&r.push(d),p.length>=3&&(d=new Yo(p,t.shared)).plane&&a.push(d)}},e.EPSILON=1e-5,e}(),Yo=function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=Xo.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}(),Ko=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;e1)?1:e.arc||1,c=0===e.sideOrientation?0:e.sideOrientation||mn.a.DEFAULTSIDE;t.push(0,0,0),r.push(.5,.5);for(var l=2*Math.PI*s,u=l/a,h=0;h1?1:t.arc:1,a=void 0===t.closed||t.closed,s=t.shape,c=t.radius||1,l=t.tessellation||64,u=t.clip||0,h=t.updatable,d=ve.a._GetDefaultSideOrientation(t.sideOrientation),f=t.cap||ve.a.NO_CAP,p=2*Math.PI,m=new Array,g=t.invertUV||!1,_=0,v=0,b=p/l*r,y=new Array;for(_=0;_<=l-u;_++){y=[];for(f!=ve.a.CAP_START&&f!=ve.a.CAP_ALL||(y.push(new o.x(0,s[0].y,0)),y.push(new o.x(Math.cos(_*b)*s[0].x*c,s[0].y,Math.sin(_*b)*s[0].x*c))),v=0;v1)?1:t.arc||1;var f,p,m=function(e,t,n,i,r,a,s,c){for(var l,u,h,d,f=t.getTangents(),p=t.getNormals(),m=t.getDistances(),g=2*Math.PI/r*c,_=a||function(){return i},v=o.t.Matrix[0],b=s===ve.a.NO_CAP||s===ve.a.CAP_END?0:2,y=0;y3?0:l,t.arc);var v=co.CreateRibbon(e,{pathArray:p,closePath:!0,closeArray:!1,updatable:h,sideOrientation:d,invertUV:u,frontUVs:t.frontUVs,backUVs:t.backUVs},n);return v._creationDataStorage.pathArray=p,v._creationDataStorage.path3D=f,v._creationDataStorage.tessellation=s,v._creationDataStorage.cap=l,v._creationDataStorage.arc=t.arc,v._creationDataStorage.radius=a,v},e}();mn.a.CreateIcoSphere=function(e){var t,n=e.sideOrientation||mn.a.DEFAULTSIDE,i=e.radius||1,r=void 0===e.flat||e.flat,a=e.subdivisions||4,s=e.radiusX||i,c=e.radiusY||i,l=e.radiusZ||i,u=(1+Math.sqrt(5))/2,h=[-1,u,-0,1,u,0,-1,-u,0,1,-u,0,0,-1,-u,0,1,-u,0,-1,u,0,1,u,u,0,1,u,0,-1,-u,0,1,-u,0,-1],d=[0,11,5,0,5,1,0,1,7,0,7,10,12,22,23,1,5,20,5,11,4,23,22,13,22,18,6,7,1,8,14,21,4,14,4,2,16,13,6,15,6,19,3,8,9,4,21,5,13,17,23,6,13,22,19,6,18,9,8,1],f=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],p=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],m=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],g=new Array,_=new Array,v=new Array,b=new Array,y=0,x=new Array(3),C=new Array(3);for(t=0;t<3;t++)x[t]=o.x.Zero(),C[t]=o.w.Zero();for(var E=0;E<20;E++){for(t=0;t<3;t++){var T=d[3*E+t];x[t].copyFromFloats(h[3*f[T]],h[3*f[T]+1],h[3*f[T]+2]),x[t].normalize().scaleInPlace(i),C[t].copyFromFloats(p[2*T]*(138/1024)+60/1024+m[E]*(-40/1024),p[2*T+1]*(239/1024)+26/1024+m[E]*(20/1024))}for(var S=function(e,t,n,i){var u,h=o.x.Lerp(x[0],x[2],t/a),d=o.x.Lerp(x[1],x[2],t/a),f=a===t?x[2]:o.x.Lerp(h,d,e/(a-t));if(f.normalize(),r){var p=o.x.Lerp(x[0],x[2],i/a),m=o.x.Lerp(x[1],x[2],i/a);u=o.x.Lerp(p,m,n/(a-i))}else u=new o.x(f.x,f.y,f.z);u.x/=s,u.y/=c,u.z/=l,u.normalize();var E=o.w.Lerp(C[0],C[2],t/a),T=o.w.Lerp(C[1],C[2],t/a),S=a===t?C[2]:o.w.Lerp(E,T,e/(a-t));_.push(f.x*s,f.y*c,f.z*l),v.push(u.x,u.y,u.z),b.push(S.x,S.y),g.push(y),y++},A=0;A0)?1:0)+((c=o.x.Dot(e[a+1].position,t)-n>0)?1:0)+((u=o.x.Dot(e[a+2].position,t)-n>0)?1:0)){case 0:r.push(e[a]),r.push(e[a+1]),r.push(e[a+2]);break;case 1:if(s&&(h=e[a+1],d=e[a+2],f=i(e[a],h),p=i(e[a],d)),c){h=e[a],d=e[a+2],f=i(e[a+1],h),p=i(e[a+1],d),r.push(f),r.push(d.clone()),r.push(h.clone()),r.push(d.clone()),r.push(f.clone()),r.push(p);break}u&&(h=e[a],d=e[a+1],f=i(e[a+2],h),p=i(e[a+2],d)),h&&d&&f&&p&&(r.push(h.clone()),r.push(d.clone()),r.push(f),r.push(p),r.push(f.clone()),r.push(d.clone()));break;case 2:s||(d=i(h=e[a].clone(),e[a+1]),f=i(h,e[a+2]),r.push(h),r.push(d),r.push(f)),c||(d=i(h=e[a+1].clone(),e[a+2]),f=i(h,e[a]),r.push(h),r.push(d),r.push(f)),u||(d=i(h=e[a+2].clone(),e[a]),f=i(h,e[a+1]),r.push(h),r.push(d),r.push(f))}}return r},T=0;Tc||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,a=o.x.FromArray(r,3*t),l=function(e){if(n)for(var t=0;t0&&this._reconstructedMesh.setVerticesData(gn.b.UVKind,s),c.length>0&&this._reconstructedMesh.setVerticesData(gn.b.ColorKind,c);var b=this._mesh.subMeshes[e];e>0&&(this._reconstructedMesh.subMeshes=[],g.forEach((function(e){Ho.b.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),Ho.b.AddToMesh(b.materialIndex,m,d,p,3*r.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new ve.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 a=0;a.999)return!0;var f=o.x.Cross(h,d).normalize();if(i[a]=!1,o.x.Dot(f,s.normal)<.2)return!0}else i[a]=!0,r.push(s)}}return!1},e.prototype.updateTriangles=function(e,t,n,i){for(var r=i,o=0;o=400&&o?o(l):n()}),!1),l.addEventListener("error",(function(){p.a.Error("error on XHR request."),n()}),!1),l.send()}else p.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=Mo.GetTGAHeader(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:/")?e._ParseURL(window.location.href)+t:t},e}(),Ca=function(){function e(){this.direction1=new o.x(0,1,0),this.direction2=new o.x(0,1,0),this.minEmitBox=new o.x(-.5,-.5,-.5),this.maxEmitBox=new o.x(.5,.5,.5)}return e.prototype.startDirectionFunction=function(e,t,n){var i=Ge.a.RandomRange(this.direction1.x,this.direction2.x),r=Ge.a.RandomRange(this.direction1.y,this.direction2.y),a=Ge.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(i,r,a,e,t)},e.prototype.startPositionFunction=function(e,t,n){var i=Ge.a.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),r=Ge.a.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),a=Ge.a.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);o.x.TransformCoordinatesFromFloatsToRef(i,r,a,e,t)},e.prototype.clone=function(){var t=new e;return P.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2),e.setVector3("minEmitBox",this.minEmitBox),e.setVector3("maxEmitBox",this.maxEmitBox)},e.prototype.getEffectDefines=function(){return"#define BOXEMITTER"},e.prototype.getClassName=function(){return"BoxParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e.minEmitBox=this.minEmitBox.asArray(),e.maxEmitBox=this.maxEmitBox.asArray(),e},e.prototype.parse=function(e){o.x.FromArrayToRef(e.direction1,0,this.direction1),o.x.FromArrayToRef(e.direction2,0,this.direction2),o.x.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),o.x.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},e}(),Ea=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===n&&(n=0),this.directionRandomizer=n,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(e.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!0,configurable:!0}),e.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},e.prototype.startDirectionFunction=function(e,t,n){if(1===Math.abs(Math.cos(this._angle)))o.x.TransformNormalFromFloatsToRef(0,1,0,e,t);else{var i=n.position.subtract(e.getTranslation()).normalize(),r=Ge.a.RandomRange(0,this.directionRandomizer),a=Ge.a.RandomRange(0,this.directionRandomizer),s=Ge.a.RandomRange(0,this.directionRandomizer);i.x+=r,i.y+=a,i.z+=s,i.normalize(),o.x.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)}},e.prototype.startPositionFunction=function(e,t,n){var i,r=Ge.a.RandomRange(0,2*Math.PI);i=this.emitFromSpawnPointOnly?1e-4:1-(i=Ge.a.RandomRange(0,this.heightRange))*i;var a=this._radius-Ge.a.RandomRange(0,this._radius*this.radiusRange),s=(a*=i)*Math.sin(r),c=a*Math.cos(r),l=i*this._height;o.x.TransformCoordinatesFromFloatsToRef(s,l,c,e,t)},e.prototype.clone=function(){var t=new e(this._radius,this._angle,this.directionRandomizer);return P.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat2("radius",this._radius,this.radiusRange),e.setFloat("coneAngle",this._angle),e.setFloat2("height",this._height,this.heightRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){var e="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(e+="\n#define CONEEMITTERSPAWNPOINT"),e},e.prototype.getClassName=function(){return"ConeParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer},e}(),Ta=function(){function e(e,t,n,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=1),void 0===i&&(i=0),this.radius=e,this.height=t,this.radiusRange=n,this.directionRandomizer=i}return e.prototype.startDirectionFunction=function(e,t,n){var i=n.position.subtract(e.getTranslation()).normalize(),r=Ge.a.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),a=Math.atan2(i.x,i.z);a+=Ge.a.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,i.y=r,i.x=Math.sin(a),i.z=Math.cos(a),i.normalize(),o.x.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n){var i=Ge.a.RandomRange(-this.height/2,this.height/2),r=Ge.a.RandomRange(0,2*Math.PI),a=Ge.a.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),s=Math.sqrt(a)*this.radius,c=s*Math.cos(r),l=s*Math.sin(r);o.x.TransformCoordinatesFromFloatsToRef(c,i,l,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return P.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},e.prototype.getClassName=function(){return"CylinderParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.height=this.height,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Sa=function(e){function t(t,n,i,r,a){void 0===t&&(t=1),void 0===n&&(n=1),void 0===i&&(i=1),void 0===r&&(r=new o.x(0,1,0)),void 0===a&&(a=new o.x(0,1,0));var s=e.call(this,t,n,i)||this;return s.direction1=r,s.direction2=a,s}return l.d(t,e),t.prototype.startDirectionFunction=function(e,t,n){var i=Ge.a.RandomRange(this.direction1.x,this.direction2.x),r=Ge.a.RandomRange(this.direction1.y,this.direction2.y),a=Ge.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(i,r,a,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return P.a.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("height",this.height),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER"},t.prototype.getClassName=function(){return"CylinderDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(Ta),Aa=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=n}return e.prototype.startDirectionFunction=function(e,t,n){var i=n.position.subtract(e.getTranslation()).normalize(),r=Ge.a.RandomRange(0,this.directionRandomizer),a=Ge.a.RandomRange(0,this.directionRandomizer),s=Ge.a.RandomRange(0,this.directionRandomizer);i.x+=r,i.y+=a,i.z+=s,i.normalize(),o.x.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n){var i=this.radius-Ge.a.RandomRange(0,this.radius*this.radiusRange),r=Ge.a.RandomRange(0,1),a=Ge.a.RandomRange(0,2*Math.PI),s=Math.acos(2*r-1),c=i*Math.cos(a)*Math.sin(s),l=i*Math.cos(s),u=i*Math.sin(a)*Math.sin(s);o.x.TransformCoordinatesFromFloatsToRef(c,Math.abs(l),u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return P.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},e.prototype.getClassName=function(){return"HemisphericParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Pa=function(){function e(){this.direction1=new o.x(0,1,0),this.direction2=new o.x(0,1,0)}return e.prototype.startDirectionFunction=function(e,t,n){var i=Ge.a.RandomRange(this.direction1.x,this.direction2.x),r=Ge.a.RandomRange(this.direction1.y,this.direction2.y),a=Ge.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(i,r,a,e,t)},e.prototype.startPositionFunction=function(e,t,n){o.x.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},e.prototype.clone=function(){var t=new e;return P.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},e.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},e.prototype.getClassName=function(){return"PointParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},e.prototype.parse=function(e){o.x.FromArrayToRef(e.direction1,0,this.direction1),o.x.FromArrayToRef(e.direction2,0,this.direction2)},e}(),Ma=function(){function e(e,t,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===n&&(n=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=n}return e.prototype.startDirectionFunction=function(e,t,n){var i=n.position.subtract(e.getTranslation()).normalize(),r=Ge.a.RandomRange(0,this.directionRandomizer),a=Ge.a.RandomRange(0,this.directionRandomizer),s=Ge.a.RandomRange(0,this.directionRandomizer);i.x+=r,i.y+=a,i.z+=s,i.normalize(),o.x.TransformNormalFromFloatsToRef(i.x,i.y,i.z,e,t)},e.prototype.startPositionFunction=function(e,t,n){var i=this.radius-Ge.a.RandomRange(0,this.radius*this.radiusRange),r=Ge.a.RandomRange(0,1),a=Ge.a.RandomRange(0,2*Math.PI),s=Math.acos(2*r-1),c=i*Math.cos(a)*Math.sin(s),l=i*Math.cos(s),u=i*Math.sin(a)*Math.sin(s);o.x.TransformCoordinatesFromFloatsToRef(c,l,u,e,t)},e.prototype.clone=function(){var t=new e(this.radius,this.directionRandomizer);return P.a.DeepCopy(this,t),t},e.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},e.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},e.prototype.getClassName=function(){return"SphereParticleEmitter"},e.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},e.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},e}(),Oa=function(e){function t(t,n,i){void 0===t&&(t=1),void 0===n&&(n=new o.x(0,1,0)),void 0===i&&(i=new o.x(0,1,0));var r=e.call(this,t)||this;return r.direction1=n,r.direction2=i,r}return l.d(t,e),t.prototype.startDirectionFunction=function(e,t,n){var i=Ge.a.RandomRange(this.direction1.x,this.direction2.x),r=Ge.a.RandomRange(this.direction1.y,this.direction2.y),a=Ge.a.RandomRange(this.direction1.z,this.direction2.z);o.x.TransformNormalFromFloatsToRef(i,r,a,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return P.a.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER"},t.prototype.getClassName=function(){return"SphereDirectedParticleEmitter"},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t},t.prototype.parse=function(t){e.prototype.parse.call(this,t),this.direction1.copyFrom(t.direction1),this.direction2.copyFrom(t.direction2)},t}(Ma),Ra=function(){function e(t){this.animations=[],this.renderingGroupId=0,this.emitter=null,this.emitRate=10,this.manualEmitCount=-1,this.updateSpeed=.01,this.targetStopDuration=0,this.disposeOnStop=!1,this.minEmitPower=1,this.maxEmitPower=1,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.minScaleX=1,this.maxScaleX=1,this.minScaleY=1,this.maxScaleY=1,this.minInitialRotation=0,this.maxInitialRotation=0,this.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.noiseStrength=new o.x(10,10,10),this.onAnimationEnd=null,this.blendMode=e.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.preWarmCycles=0,this.preWarmStepOffset=1,this.spriteCellChangeSpeed=1,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.spriteRandomStartCell=!1,this.translationPivot=new o.w(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.worldOffset=new o.x(0,0,0),this.gravity=o.x.Zero(),this._colorGradients=null,this._sizeGradients=null,this._lifeTimeGradients=null,this._angularSpeedGradients=null,this._velocityGradients=null,this._limitVelocityGradients=null,this._dragGradients=null,this._emitRateGradients=null,this._startSizeGradients=null,this._rampGradients=null,this._colorRemapGradients=null,this._alphaRemapGradients=null,this.startDelay=0,this.limitVelocityDamping=.4,this.color1=new o.f(1,1,1,1),this.color2=new o.f(1,1,1,1),this.colorDead=new o.f(0,0,0,1),this.textureMask=new o.f(1,1,1,1),this._isSubEmitter=!1,this.billboardMode=m.a.PARTICLES_BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new un.b,this.id=t,this.name=t}return Object.defineProperty(e.prototype,"noiseTexture",{get:function(){return this._noiseTexture},set:function(e){this._noiseTexture!==e&&(this._noiseTexture=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},set:function(e){this._isAnimationSheetEnabled!=e&&(this._isAnimationSheetEnabled=e,this._reset())},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype._hasTargetStopDurationDependantGradient=function(){return this._startSizeGradients&&this._startSizeGradients.length>0||this._emitRateGradients&&this._emitRateGradients.length>0||this._lifeTimeGradients&&this._lifeTimeGradients.length>0},e.prototype.getDragGradients=function(){return this._dragGradients},e.prototype.getLimitVelocityGradients=function(){return this._limitVelocityGradients},e.prototype.getColorGradients=function(){return this._colorGradients},e.prototype.getSizeGradients=function(){return this._sizeGradients},e.prototype.getColorRemapGradients=function(){return this._colorRemapGradients},e.prototype.getAlphaRemapGradients=function(){return this._alphaRemapGradients},e.prototype.getLifeTimeGradients=function(){return this._lifeTimeGradients},e.prototype.getAngularSpeedGradients=function(){return this._angularSpeedGradients},e.prototype.getVelocityGradients=function(){return this._velocityGradients},e.prototype.getStartSizeGradients=function(){return this._startSizeGradients},e.prototype.getEmitRateGradients=function(){return this._emitRateGradients},Object.defineProperty(e.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:o.x.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:o.x.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:o.x.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:o.x.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration=e||this._scene.imageProcessingConfiguration)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,n){if(!t)return this;for(var i=0,r=0,o=t;r0&&this._attachedSubEmitters.forEach((function(t){e._inheritParticleInfoToSubEmitter(t)}))},e.prototype._reset=function(){this.age=0,this._currentColorGradient=null,this._currentSizeGradient=null,this._currentAngularSpeedGradient=null,this._currentVelocityGradient=null,this._currentLimitVelocityGradient=null,this._currentDragGradient=null,this.cellIndex=this.particleSystem.startSpriteCellID,this._randomCellOffset=void 0},e.prototype.copyTo=function(e){e.position.copyFrom(this.position),this._initialDirection?e._initialDirection?e._initialDirection.copyFrom(this._initialDirection):e._initialDirection=this._initialDirection.clone():e._initialDirection=null,e.direction.copyFrom(this.direction),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e._randomCellOffset=this._randomCellOffset,e.size=this.size,e.scale.copyFrom(this.scale),e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex,e.id=this.id,e._attachedSubEmitters=this._attachedSubEmitters,this._currentColorGradient&&(e._currentColorGradient=this._currentColorGradient,e._currentColor1.copyFrom(this._currentColor1),e._currentColor2.copyFrom(this._currentColor2)),this._currentSizeGradient&&(e._currentSizeGradient=this._currentSizeGradient,e._currentSize1=this._currentSize1,e._currentSize2=this._currentSize2),this._currentAngularSpeedGradient&&(e._currentAngularSpeedGradient=this._currentAngularSpeedGradient,e._currentAngularSpeed1=this._currentAngularSpeed1,e._currentAngularSpeed2=this._currentAngularSpeed2),this._currentVelocityGradient&&(e._currentVelocityGradient=this._currentVelocityGradient,e._currentVelocity1=this._currentVelocity1,e._currentVelocity2=this._currentVelocity2),this._currentLimitVelocityGradient&&(e._currentLimitVelocityGradient=this._currentLimitVelocityGradient,e._currentLimitVelocity1=this._currentLimitVelocity1,e._currentLimitVelocity2=this._currentLimitVelocity2),this._currentDragGradient&&(e._currentDragGradient=this._currentDragGradient,e._currentDrag1=this._currentDrag1,e._currentDrag2=this._currentDrag2),this.particleSystem.isAnimationSheetEnabled&&(e._initialStartSpriteCellID=this._initialStartSpriteCellID,e._initialEndSpriteCellID=this._initialEndSpriteCellID),this.particleSystem.useRampGradients&&e.remapData.copyFrom(this.remapData),this._randomNoiseCoordinates1&&(e._randomNoiseCoordinates1?(e._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1),e._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2)):(e._randomNoiseCoordinates1=this._randomNoiseCoordinates1.clone(),e._randomNoiseCoordinates2=this._randomNoiseCoordinates2.clone()))},e._Count=0,e}();!function(e){e[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END"}(ya||(ya={}));var Ia=function(){function e(e){this.particleSystem=e,this.type=ya.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,e.emitter&&e.emitter.dispose||(e.emitter=new Me.a("SubemitterSystemEmitter",e.getScene())),e.onDisposeObservable.add((function(){e.emitter&&e.emitter.dispose&&e.emitter.dispose()}))}return e.prototype.clone=function(){var t=this.particleSystem.emitter;t?t instanceof o.x?t=t.clone():t instanceof Me.a&&((t=new ve.a("",t.getScene())).isVisible=!1):t=new o.x;var n=new e(this.particleSystem.clone("",t));return 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(){var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(),e},e._ParseParticleSystem=function(e,t,n){throw Pr.a.WarnImport("ParseParticle")},e.Parse=function(t,n,i){var r=t.particleSystem,o=new e(e._ParseParticleSystem(r,n,i));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}(),La="\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\nvoid main(void) {\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}";Lt.a.ShadersStore.particlesPixelShader=La;var Da="\nattribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET\nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD\nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction;\n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET\nuniform vec3 particlesInfos;\n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main(void) {\nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD\n\nvec3 rotatedCorner;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz;\n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner;\n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\n\ngl_Position=projection*vec4(viewPos,1.0);\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(worldPos,1.0);\n#endif\nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset*particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*vec4(viewPos,1.0);\n#endif\n#include\n}";Lt.a.ShadersStore.particlesVertexShader=Da;var Na=function(e){function t(t,n,i,a,s,c){void 0===a&&(a=null),void 0===s&&(s=!1),void 0===c&&(c=.01);var l=e.call(this,t)||this;return l._inheritedVelocityOffset=new o.x,l.onDisposeObservable=new r.c,l._particles=new Array,l._stockParticles=new Array,l._newPartsExcess=0,l._vertexBuffers={},l._scaledColorStep=new o.f(0,0,0,0),l._colorDiff=new o.f(0,0,0,0),l._scaledDirection=o.x.Zero(),l._scaledGravity=o.x.Zero(),l._currentRenderId=-1,l._useInstancing=!1,l._started=!1,l._stopped=!1,l._actualFrame=0,l._currentEmitRate1=0,l._currentEmitRate2=0,l._currentStartSize1=0,l._currentStartSize2=0,l._rawTextureWidth=256,l._useRampGradients=!1,l._disposeEmitterOnDispose=!1,l.recycleParticle=function(e){var t=l._particles.pop();t!==e&&t.copyTo(e),l._stockParticles.push(t)},l._createParticle=function(){var e;if(0!==l._stockParticles.length?(e=l._stockParticles.pop())._reset():e=new wa(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===ya.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===ya.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=c,l._isAnimationSheetEnabled=s,l._scene=i||A.a.LastCreatedScene,l._attachImageProcessingConfiguration(null),l._customEffect=a,l._scene.particleSystems.push(l),l._useInstancing=l._scene.getEngine().getCaps().instancedArrays,l._createIndexBuffer(),l._createVertexBuffers(),l.particleEmitterType=new Ca,l.updateFunction=function(e){var t=null,n=null;l.noiseTexture&&(t=l.noiseTexture.getSize(),n=l.noiseTexture.getContent());for(var i,r=function(){i=e[a];var r=l._scaledUpdateSpeed,s=i.age;if(i.age+=r,i.age>i.lifeTime){var c=i.age-s;r=(i.lifeTime-s)*r/c,i.age=i.lifeTime}var u=i.age/i.lifeTime;l._colorGradients&&l._colorGradients.length>0?fe.h.GetCurrentGradient(u,l._colorGradients,(function(e,t,n){e!==i._currentColorGradient&&(i._currentColor1.copyFrom(i._currentColor2),t.getColorToRef(i._currentColor2),i._currentColorGradient=e),o.f.LerpToRef(i._currentColor1,i._currentColor2,n,i.color)})):(i.colorStep.scaleToRef(r,l._scaledColorStep),i.color.addInPlace(l._scaledColorStep),i.color.a<0&&(i.color.a=0)),l._angularSpeedGradients&&l._angularSpeedGradients.length>0&&fe.h.GetCurrentGradient(u,l._angularSpeedGradients,(function(e,t,n){e!==i._currentAngularSpeedGradient&&(i._currentAngularSpeed1=i._currentAngularSpeed2,i._currentAngularSpeed2=t.getFactor(),i._currentAngularSpeedGradient=e),i.angularSpeed=Ge.a.Lerp(i._currentAngularSpeed1,i._currentAngularSpeed2,n)})),i.angle+=i.angularSpeed*r;var h=r;if(l._velocityGradients&&l._velocityGradients.length>0&&fe.h.GetCurrentGradient(u,l._velocityGradients,(function(e,t,n){e!==i._currentVelocityGradient&&(i._currentVelocity1=i._currentVelocity2,i._currentVelocity2=t.getFactor(),i._currentVelocityGradient=e),h*=Ge.a.Lerp(i._currentVelocity1,i._currentVelocity2,n)})),i.direction.scaleToRef(h,l._scaledDirection),l._limitVelocityGradients&&l._limitVelocityGradients.length>0&&fe.h.GetCurrentGradient(u,l._limitVelocityGradients,(function(e,t,n){e!==i._currentLimitVelocityGradient&&(i._currentLimitVelocity1=i._currentLimitVelocity2,i._currentLimitVelocity2=t.getFactor(),i._currentLimitVelocityGradient=e);var r=Ge.a.Lerp(i._currentLimitVelocity1,i._currentLimitVelocity2,n);i.direction.length()>r&&i.direction.scaleInPlace(l.limitVelocityDamping)})),l._dragGradients&&l._dragGradients.length>0&&fe.h.GetCurrentGradient(u,l._dragGradients,(function(e,t,n){e!==i._currentDragGradient&&(i._currentDrag1=i._currentDrag2,i._currentDrag2=t.getFactor(),i._currentDragGradient=e);var r=Ge.a.Lerp(i._currentDrag1,i._currentDrag2,n);l._scaledDirection.scaleInPlace(1-r)})),i.position.addInPlace(l._scaledDirection),n&&t&&i._randomNoiseCoordinates1){var d=l._fetchR(i._randomNoiseCoordinates1.x,i._randomNoiseCoordinates1.y,t.width,t.height,n),f=l._fetchR(i._randomNoiseCoordinates1.z,i._randomNoiseCoordinates2.x,t.width,t.height,n),p=l._fetchR(i._randomNoiseCoordinates2.y,i._randomNoiseCoordinates2.z,t.width,t.height,n),m=o.t.Vector3[0],g=o.t.Vector3[1];m.copyFromFloats((2*d-1)*l.noiseStrength.x,(2*f-1)*l.noiseStrength.y,(2*p-1)*l.noiseStrength.z),m.scaleToRef(r,g),i.direction.addInPlace(g)}if(l.gravity.scaleToRef(r,l._scaledGravity),i.direction.addInPlace(l._scaledGravity),l._sizeGradients&&l._sizeGradients.length>0&&fe.h.GetCurrentGradient(u,l._sizeGradients,(function(e,t,n){e!==i._currentSizeGradient&&(i._currentSize1=i._currentSize2,i._currentSize2=t.getFactor(),i._currentSizeGradient=e),i.size=Ge.a.Lerp(i._currentSize1,i._currentSize2,n)})),l._useRampGradients&&(l._colorRemapGradients&&l._colorRemapGradients.length>0&&fe.h.GetCurrentGradient(u,l._colorRemapGradients,(function(e,t,n){var r=Ge.a.Lerp(e.factor1,t.factor1,n),o=Ge.a.Lerp(e.factor2,t.factor2,n);i.remapData.x=r,i.remapData.y=o-r})),l._alphaRemapGradients&&l._alphaRemapGradients.length>0&&fe.h.GetCurrentGradient(u,l._alphaRemapGradients,(function(e,t,n){var r=Ge.a.Lerp(e.factor1,t.factor1,n),o=Ge.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),a--,"continue"},a=0;at.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(),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 fe.c;return i.gradient=e,i.color1=t,i.color2=n,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){this.emitter instanceof Me.a&&this.emitter.computeWorldMatrix(!0);var n=this.noiseTexture;if(n&&n.onGeneratedObservable)n.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped=!0,e&&this._stopSubEmitters()},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,n,i,r){var o=e*this._vertexBufferSize;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):n._initialDirection?(this._vertexData[o++]=n._initialDirection.x,this._vertexData[o++]=n._initialDirection.y,this._vertexData[o++]=n._initialDirection.z):(this._vertexData[o++]=n.direction.x,this._vertexData[o++]=n.direction.y,this._vertexData[o++]=n.direction.z),this._useRampGradients&&(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=o.j.Translation(r.x,r.y,r.z)}this.updateFunction(this._particles);for(var a,s=function(){if(c._particles.length===c._capacity)return"break";t=c._createParticle(),c._particles.push(t);var e=Ge.a.RandomRange(c.minEmitPower,c.maxEmitPower);if(c.startPositionFunction?c.startPositionFunction(c._emitterWorldMatrix,t.position,t):c.particleEmitterType.startPositionFunction(c._emitterWorldMatrix,t.position,t),c.startDirectionFunction?c.startDirectionFunction(c._emitterWorldMatrix,t.direction,t):c.particleEmitterType.startDirectionFunction(c._emitterWorldMatrix,t.direction,t),0===e?t._initialDirection?t._initialDirection.copyFrom(t.direction):t._initialDirection=t.direction.clone():t._initialDirection=null,t.direction.scaleInPlace(e),c.targetStopDuration&&c._lifeTimeGradients&&c._lifeTimeGradients.length>0){var i=Ge.a.Clamp(c._actualFrame/c.targetStopDuration);fe.h.GetCurrentGradient(i,c._lifeTimeGradients,(function(e,n){var r=e,o=n,a=r.getFactor(),s=o.getFactor(),c=(i-r.gradient)/(o.gradient-r.gradient);t.lifeTime=Ge.a.Lerp(a,s,c)}))}else t.lifeTime=Ge.a.RandomRange(c.minLifeTime,c.maxLifeTime);if(c._sizeGradients&&0!==c._sizeGradients.length?(t._currentSizeGradient=c._sizeGradients[0],t._currentSize1=t._currentSizeGradient.getFactor(),t.size=t._currentSize1,c._sizeGradients.length>1?t._currentSize2=c._sizeGradients[1].getFactor():t._currentSize2=t._currentSize1):t.size=Ge.a.RandomRange(c.minSize,c.maxSize),t.scale.copyFromFloats(Ge.a.RandomRange(c.minScaleX,c.maxScaleX),Ge.a.RandomRange(c.minScaleY,c.maxScaleY)),c._startSizeGradients&&c._startSizeGradients[0]&&c.targetStopDuration){var r=c._actualFrame/c.targetStopDuration;fe.h.GetCurrentGradient(r,c._startSizeGradients,(function(e,i,r){e!==n._currentStartSizeGradient&&(n._currentStartSize1=n._currentStartSize2,n._currentStartSize2=i.getFactor(),n._currentStartSizeGradient=e);var o=Ge.a.Lerp(n._currentStartSize1,n._currentStartSize2,r);t.scale.scaleInPlace(o)}))}c._angularSpeedGradients&&0!==c._angularSpeedGradients.length?(t._currentAngularSpeedGradient=c._angularSpeedGradients[0],t.angularSpeed=t._currentAngularSpeedGradient.getFactor(),t._currentAngularSpeed1=t.angularSpeed,c._angularSpeedGradients.length>1?t._currentAngularSpeed2=c._angularSpeedGradients[1].getFactor():t._currentAngularSpeed2=t._currentAngularSpeed1):t.angularSpeed=Ge.a.RandomRange(c.minAngularSpeed,c.maxAngularSpeed),t.angle=Ge.a.RandomRange(c.minInitialRotation,c.maxInitialRotation),c._velocityGradients&&c._velocityGradients.length>0&&(t._currentVelocityGradient=c._velocityGradients[0],t._currentVelocity1=t._currentVelocityGradient.getFactor(),c._velocityGradients.length>1?t._currentVelocity2=c._velocityGradients[1].getFactor():t._currentVelocity2=t._currentVelocity1),c._limitVelocityGradients&&c._limitVelocityGradients.length>0&&(t._currentLimitVelocityGradient=c._limitVelocityGradients[0],t._currentLimitVelocity1=t._currentLimitVelocityGradient.getFactor(),c._limitVelocityGradients.length>1?t._currentLimitVelocity2=c._limitVelocityGradients[1].getFactor():t._currentLimitVelocity2=t._currentLimitVelocity1),c._dragGradients&&c._dragGradients.length>0&&(t._currentDragGradient=c._dragGradients[0],t._currentDrag1=t._currentDragGradient.getFactor(),c._dragGradients.length>1?t._currentDrag2=c._dragGradients[1].getFactor():t._currentDrag2=t._currentDrag1),c._colorGradients&&0!==c._colorGradients.length?(t._currentColorGradient=c._colorGradients[0],t._currentColorGradient.getColorToRef(t.color),t._currentColor1.copyFrom(t.color),c._colorGradients.length>1?c._colorGradients[1].getColorToRef(t._currentColor2):t._currentColor2.copyFrom(t.color)):(a=Ge.a.RandomRange(0,1),o.f.LerpToRef(c.color1,c.color2,a,t.color),c.colorDead.subtractToRef(t.color,c._colorDiff),c._colorDiff.scaleToRef(1/t.lifeTime,t.colorStep)),c._isAnimationSheetEnabled&&(t._initialStartSpriteCellID=c.startSpriteCellID,t._initialEndSpriteCellID=c.endSpriteCellID),t.direction.addInPlace(c._inheritedVelocityOffset),c._useRampGradients&&(t.remapData=new o.y(0,1,0,1)),c.noiseTexture&&(t._randomNoiseCoordinates1?(t._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(t._randomNoiseCoordinates1=new o.x(Math.random(),Math.random(),Math.random()),t._randomNoiseCoordinates2=new o.x(Math.random(),Math.random(),Math.random()))),t._inheritParticleInfoToSubEmitters()},c=this,l=0;l-1)n=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var i=this.emitRate;if(this._emitRateGradients&&this._emitRateGradients.length>0&&this.targetStopDuration){var r=this._actualFrame/this.targetStopDuration;fe.h.GetCurrentGradient(r,this._emitRateGradients,(function(e,n,r){e!==t._currentEmitRateGradient&&(t._currentEmitRate1=t._currentEmitRate2,t._currentEmitRate2=n.getFactor(),t._currentEmitRateGradient=e),i=Ge.a.Lerp(t._currentEmitRate1,t._currentEmitRate2,r)}))}n=i*this._scaledUpdateSpeed>>0,this._newPartsExcess+=i*this._scaledUpdateSpeed-n}if(this._newPartsExcess>1&&(n+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?n=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(n),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this))),!e){for(var o=0,a=0;a-1&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.reset()},t.prototype.clone=function(e,n){var i=null,r=null;if(null!=this.customShader){var o=(r=this.customShader).shaderOptions.defines.length>0?r.shaderOptions.defines.join("\n"):"";i=this._scene.getEngine().createEffectForParticles(r.shaderPath.fragmentElement,r.shaderOptions.uniforms,r.shaderOptions.samplers,o)}else this._customEffect&&(i=this._customEffect);var a=new t(e,this._capacity,this._scene,i);return a.customShader=r,P.a.DeepCopy(this,a,["particles","customShader","noiseTexture"]),void 0===n&&(n=this.emitter),a.noiseTexture=this.noiseTexture,a.emitter=n,this.particleTexture&&(a.particleTexture=new Kt.a(this.particleTexture.url,this._scene)),this._colorGradients&&this._colorGradients.forEach((function(e){a.addColorGradient(e.gradient,e.color1,e.color2)})),this._dragGradients&&this._dragGradients.forEach((function(e){a.addDragGradient(e.gradient,e.factor1,e.factor2)})),this._angularSpeedGradients&&this._angularSpeedGradients.forEach((function(e){a.addAngularSpeedGradient(e.gradient,e.factor1,e.factor2)})),this._emitRateGradients&&this._emitRateGradients.forEach((function(e){a.addEmitRateGradient(e.gradient,e.factor1,e.factor2)})),this._lifeTimeGradients&&this._lifeTimeGradients.forEach((function(e){a.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)})),this._limitVelocityGradients&&this._limitVelocityGradients.forEach((function(e){a.addLimitVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._sizeGradients&&this._sizeGradients.forEach((function(e){a.addSizeGradient(e.gradient,e.factor1,e.factor2)})),this._startSizeGradients&&this._startSizeGradients.forEach((function(e){a.addStartSizeGradient(e.gradient,e.factor1,e.factor2)})),this._velocityGradients&&this._velocityGradients.forEach((function(e){a.addVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._rampGradients&&this._rampGradients.forEach((function(e){a.addRampGradient(e.gradient,e.color)})),this._colorRemapGradients&&this._colorRemapGradients.forEach((function(e){a.addColorRemapGradient(e.gradient,e.factor1,e.factor2)})),this._alphaRemapGradients&&this._alphaRemapGradients.forEach((function(e){a.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)})),this.preventAutoStart||a.start(),a},t.prototype.serialize=function(){var e={};if(t._Serialize(e,this),e.textureMask=this.textureMask.asArray(),e.customShader=this.customShader,e.preventAutoStart=this.preventAutoStart,this.subEmitters){e.subEmitters=[],this._subEmitters||this._prepareSubEmitterInternalArray();for(var n=0,i=this._subEmitters;n0?c.shaderOptions.defines.join("\n"):"";s=n.getEngine().createEffectForParticles(c.shaderPath.fragmentElement,c.shaderOptions.uniforms,c.shaderOptions.samplers,l)}var u=new t(a,e.capacity,n,s,e.isAnimationSheetEnabled);if(u.customShader=c,e.id&&(u.id=e.id),e.subEmitters){u.subEmitters=[];for(var h=0,d=e.subEmitters;h1},enumerable:!0,configurable:!0}),t.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(t.prototype,"activeParticleCount",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&this._imageProcessingConfiguration.isReady()&&this._renderEffect.isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.start=function(e){var t=this;if(void 0===e&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";e?setTimeout((function(){t.start(0)}),e):(this._started=!0,this._stopped=!1,this._preWarmDone=!1,this.beginAnimationOnStart&&this.animations&&this.animations.length>0&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},t.prototype.stop=function(){this._stopped=!0},t.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype._removeGradientAndTexture=function(t,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 fe.c;return i.gradient=e,i.color1=t,this._colorGradients.push(i),this._colorGradients.sort((function(e,t){return e.gradientt.gradient?1:0})),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},t.prototype._addFactorGradient=function(e,t,n){var i=new fe.d;i.gradient=t,i.factor1=n,e.push(i),e.sort((function(e,t){return e.gradientt.gradient?1:0})),this._releaseBuffers()},t.prototype.addSizeGradient=function(e,t){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},t.prototype.addAngularSpeedGradient=function(e,t){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},t.prototype.addVelocityGradient=function(e,t){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},t.prototype.addLimitVelocityGradient=function(e,t){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},t.prototype.addDragGradient=function(e,t){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._releaseBuffers(),this},t.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},t.prototype.addEmitRateGradient=function(e,t,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:!0,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._createUpdateVAO=function(e){var t={};t.position=e.createVertexBuffer("position",0,3),t.age=e.createVertexBuffer("age",3,1),t.life=e.createVertexBuffer("life",4,1),t.seed=e.createVertexBuffer("seed",5,4),t.size=e.createVertexBuffer("size",9,3);var n=12;this._colorGradientsTexture||(t.color=e.createVertexBuffer("color",n,4),n+=4),t.direction=e.createVertexBuffer("direction",n,3),n+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer("initialDirection",n,3),n+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer("angle",n,1),n+=1):(t.angle=e.createVertexBuffer("angle",n,2),n+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer("cellIndex",n,1),n+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer("cellStartOffset",n,1),n+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",n,3),n+=3,t.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",n,3),n+=3);var i=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),i},t.prototype._createRenderVAO=function(e,t){var n={};n.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0),n.age=e.createVertexBuffer("age",3,1,this._attributesStrideSize,!0),n.life=e.createVertexBuffer("life",4,1,this._attributesStrideSize,!0),n.size=e.createVertexBuffer("size",9,3,this._attributesStrideSize,!0);var i=12;this._colorGradientsTexture||(n.color=e.createVertexBuffer("color",i,4,this._attributesStrideSize,!0),i+=4),this.billboardMode===Na.BILLBOARDMODE_STRETCHED&&(n.direction=e.createVertexBuffer("direction",i,3,this._attributesStrideSize,!0)),i+=3,this._isBillboardBased||(n.initialDirection=e.createVertexBuffer("initialDirection",i,3,this._attributesStrideSize,!0),i+=3),n.angle=e.createVertexBuffer("angle",i,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?i++:i+=2,this._isAnimationSheetEnabled&&(n.cellIndex=e.createVertexBuffer("cellIndex",i,1,this._attributesStrideSize,!0),i+=1,this.spriteRandomStartCell&&(n.cellStartOffset=e.createVertexBuffer("cellStartOffset",i,1,this._attributesStrideSize,!0),i+=1)),this.noiseTexture&&(n.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",i,3,this._attributesStrideSize,!0),i+=3,n.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",i,3,this._attributesStrideSize,!0),i+=3),n.offset=t.createVertexBuffer("offset",0,2),n.uv=t.createVertexBuffer("uv",2,2);var r=this._engine.recordVertexArrayObject(n,null,this._renderEffect);return this._engine.bindArrayBuffer(null),r},t.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._scene.getEngine(),n=new Array;this._attributesStrideSize=21,this._targetIndex=0,this.isBillboardBased||(this._attributesStrideSize+=3),this._colorGradientsTexture&&(this._attributesStrideSize-=4),this._angularSpeedGradientsTexture&&(this._attributesStrideSize-=1),this._isAnimationSheetEnabled&&(this._attributesStrideSize+=1,this.spriteRandomStartCell&&(this._attributesStrideSize+=1)),this.noiseTexture&&(this._attributesStrideSize+=6);for(var i=0;i=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;r1){var n=0|this._accumulatedCount;this._accumulatedCount-=n,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+n)}if(!this._currentActiveCount)return 0;var i;if(this._engine.enableEffect(this._updateEffect),this._engine.setState(!1),this._updateEffect.setFloat("currentCount",this._currentActiveCount),this._updateEffect.setFloat("timeDelta",this._timeDelta),this._updateEffect.setFloat("stopFactor",this._stopped?0:1),this._updateEffect.setTexture("randomSampler",this._randomTexture),this._updateEffect.setTexture("randomSampler2",this._randomTexture2),this._updateEffect.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateEffect.setDirectColor4("color1",this.color1),this._updateEffect.setDirectColor4("color2",this.color2)),this._updateEffect.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateEffect.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateEffect.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateEffect.setVector3("gravity",this.gravity),this._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._sizeGradientsTexture),this._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._angularSpeedGradientsTexture),this._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._velocityGradientsTexture),this._limitVelocityGradientsTexture&&(this._updateEffect.setTexture("limitVelocityGradientSampler",this._limitVelocityGradientsTexture),this._updateEffect.setFloat("limitVelocityDamping",this.limitVelocityDamping)),this._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._dragGradientsTexture),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect),this._isAnimationSheetEnabled&&this._updateEffect.setFloat3("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed),this.noiseTexture&&(this._updateEffect.setTexture("noiseSampler",this.noiseTexture),this._updateEffect.setVector3("noiseStrength",this.noiseStrength)),this.emitter.position){i=this.emitter.getWorldMatrix()}else{var r=this.emitter;i=o.j.Translation(r.x,r.y,r.z)}if(this._updateEffect.setMatrix("emitterWM",i),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),this._engine.setRasterizerState(!1),this._engine.beginTransformFeedback(!0),this._engine.drawArraysType(Tr.a.PointListDrawMode,0,this._currentActiveCount),this._engine.endTransformFeedback(),this._engine.setRasterizerState(!0),this._engine.bindTransformFeedbackBuffer(null),!e){this._engine.enableEffect(this._renderEffect);var a=this._scene.getViewMatrix();if(this._renderEffect.setMatrix("view",a),this._renderEffect.setMatrix("projection",this._scene.getProjectionMatrix()),this._renderEffect.setTexture("textureSampler",this.particleTexture),this._renderEffect.setVector2("translationPivot",this.translationPivot),this._renderEffect.setVector3("worldOffset",this.worldOffset),this._colorGradientsTexture?this._renderEffect.setTexture("colorGradientSampler",this._colorGradientsTexture):this._renderEffect.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var s=this.particleTexture.getBaseSize();this._renderEffect.setFloat3("sheetInfos",this.spriteCellWidth/s.width,this.spriteCellHeight/s.height,s.width/this.spriteCellWidth)}if(this._isBillboardBased){var c=this._scene.activeCamera;this._renderEffect.setVector3("eyePosition",c.globalPosition)}if(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4){var l=a.clone();l.invert(),this._renderEffect.setMatrix("invView",l),Yi.a.BindClipPlane(this._renderEffect,this._scene)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._renderEffect),this.blendMode){case Na.BLENDMODE_ADD:this._engine.setAlphaMode(m.a.ALPHA_ADD);break;case Na.BLENDMODE_ONEONE:this._engine.setAlphaMode(m.a.ALPHA_ONEONE);break;case Na.BLENDMODE_STANDARD:this._engine.setAlphaMode(m.a.ALPHA_COMBINE);break;case Na.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(m.a.ALPHA_MULTIPLY)}this.forceDepthWrite&&this._engine.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._engine.drawArraysType(Tr.a.TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(m.a.ALPHA_DISABLE)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var u=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=u,this._currentActiveCount},t.prototype.rebuild=function(){this._initialize(!0)},t.prototype._releaseBuffers=function(){this._buffer0&&(this._buffer0.dispose(),this._buffer0=null),this._buffer1&&(this._buffer1.dispose(),this._buffer1=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null)},t.prototype._releaseVAOs=function(){if(this._updateVAO){for(var e=0;e-1&&this._scene.particleSystems.splice(t,1),this._releaseBuffers(),this._releaseVAOs(),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._sizeGradientsTexture&&(this._sizeGradientsTexture.dispose(),this._sizeGradientsTexture=null),this._angularSpeedGradientsTexture&&(this._angularSpeedGradientsTexture.dispose(),this._angularSpeedGradientsTexture=null),this._velocityGradientsTexture&&(this._velocityGradientsTexture.dispose(),this._velocityGradientsTexture=null),this._limitVelocityGradientsTexture&&(this._limitVelocityGradientsTexture.dispose(),this._limitVelocityGradientsTexture=null),this._dragGradientsTexture&&(this._dragGradientsTexture.dispose(),this._dragGradientsTexture=null),this._randomTexture&&(this._randomTexture.dispose(),this._randomTexture=null),this._randomTexture2&&(this._randomTexture2.dispose(),this._randomTexture2=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.clone=function(e,n){var i=new t(e,{capacity:this._capacity,randomTextureSize:this._randomTextureSize},this._scene);return P.a.DeepCopy(this,i),void 0===n&&(n=this.emitter),i.emitter=n,this.particleTexture&&(i.particleTexture=new Kt.a(this.particleTexture.url,this._scene)),i},t.prototype.serialize=function(){var e={};return Na._Serialize(e,this),e.activeParticleCount=this.activeParticleCount,e},t.Parse=function(e,n,i,r){void 0===r&&(r=!1);var o=new t(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},n);return e.activeParticleCount&&(o.activeParticleCount=e.activeParticleCount),Na._Parse(e,o,n,i),e.preventAutoStart&&(o.preventAutoStart=e.preventAutoStart),r||o.preventAutoStart||o.start(),o},t}(Ra),Ga=function(){function e(){this.systems=new Array}return Object.defineProperty(e.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!0,configurable:!0}),e.prototype.setEmitterAsSphere=function(e,t,n){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:e,renderingGroupId:t};var i=ni.CreateSphere("emitterSphere",{diameter:e.diameter,segments:e.segments},n);i.renderingGroupId=t;var r=new hn.a("emitterSphereMaterial",n);r.emissiveColor=e.color,i.material=r;for(var o=0,a=this.systems;o0&&t.set(this._uvs32,gn.b.UVKind),this._colors32.length>0&&t.set(this._colors32,gn.b.ColorKind);var n=new ve.a(this.name,this._scene);return t.applyToMesh(n,this._updatable),this.mesh=n,this.mesh.isPickable=this._pickable,this._depthSort||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0),n},e.prototype.digest=function(e,t){var n=t&&t.facetNb||1,i=t&&t.number||0,r=t&&t.delta||0,a=e.getVerticesData(gn.b.PositionKind),s=e.getIndices(),c=e.getVerticesData(gn.b.UVKind),l=e.getVerticesData(gn.b.ColorKind),u=e.getVerticesData(gn.b.NormalKind),h=0,d=s.length/3;i?(i=i>d?d:i,n=Math.round(d/i),r=0):n=n>d?d:n;for(var f=[],p=[],m=[],g=[],_=o.x.Zero(),v=n;hd-(n=v+Math.floor((1+r)*Math.random()))&&(n=d-h),f.length=0,p.length=0,m.length=0,g.length=0;for(var b=0,y=3*h;y<3*(h+n);y++){p.push(b);var x=s[y];f.push(a[3*x],a[3*x+1],a[3*x+2]),c&&m.push(c[2*x],c[2*x+1]),l&&g.push(l[4*x],l[4*x+1],l[4*x+2],l[4*x+3]),b++}var C,E,T=this.nbParticles,S=this._posToShape(f),A=this._uvsToShapeUV(m);for(C=0;C65535&&(this._needs32Bits=!0)}if(this._pickable){var M=i.length/3;for(m=0;m=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0!=e||t!=this.nbParticles-1)){var R=this.mesh._boundingInfo;R&&(v.copyFrom(R.minimum),b.copyFrom(R.maximum))}var w=(T=this.particles[e]._pos)/3|0;A=4*w,M=2*w;for(var I=e;I<=t;I++){var L=this.particles[I];this.updateParticle(L);var D=L._model._shape,N=L._model._shapeUV,F=L._rotationMatrix,k=L.position,B=L.rotation,z=L.scaling,V=L._globalPosition;if(this._depthSort&&this._depthSortParticles){var U=this.depthSortedParticles[I];U.ind=L._ind,U.indicesLength=L._model._indicesLength,U.sqDistance=o.x.DistanceSquared(L.position,y)}if(!L.alive||L._stillInvisible&&!L.isVisible)T+=3*(O=D.length),A+=4*O,M+=2*O;else{if(L.isVisible){L._stillInvisible=!1;var G=p[12];if(L.pivot.multiplyToRef(z,G),this.billboard&&(B.x=0,B.y=0),(this._computeParticleRotation||this.billboard)&&L.getRotationMatrix(i),null!==L.parentId){var H=this.particles[L.parentId],j=H._rotationMatrix,W=H._globalPosition,X=k.x*j[1]+k.y*j[4]+k.z*j[7],Y=k.x*j[0]+k.y*j[3]+k.z*j[6],K=k.x*j[2]+k.y*j[5]+k.z*j[8];if(V.x=W.x+Y,V.y=W.y+X,V.z=W.z+K,this._computeParticleRotation||this.billboard){var Q=i.m;F[0]=Q[0]*j[0]+Q[1]*j[3]+Q[2]*j[6],F[1]=Q[0]*j[1]+Q[1]*j[4]+Q[2]*j[7],F[2]=Q[0]*j[2]+Q[1]*j[5]+Q[2]*j[8],F[3]=Q[4]*j[0]+Q[5]*j[3]+Q[6]*j[6],F[4]=Q[4]*j[1]+Q[5]*j[4]+Q[6]*j[7],F[5]=Q[4]*j[2]+Q[5]*j[5]+Q[6]*j[8],F[6]=Q[8]*j[0]+Q[9]*j[3]+Q[10]*j[6],F[7]=Q[8]*j[1]+Q[9]*j[4]+Q[10]*j[7],F[8]=Q[8]*j[2]+Q[9]*j[5]+Q[10]*j[8]}}else if(V.x=k.x,V.y=k.y,V.z=k.z,this._computeParticleRotation||this.billboard){Q=i.m;F[0]=Q[0],F[1]=Q[1],F[2]=Q[2],F[3]=Q[4],F[4]=Q[5],F[5]=Q[6],F[6]=Q[8],F[7]=Q[9],F[8]=Q[10]}var q=p[11];for(L.translateFromPivot?q.setAll(0):q.copyFrom(G),O=0;Othis._options.radius)return null;var a=this._options.falloff===Qa.Constant?this._options.strength:this._options.strength*(1-r/this._options.radius);return{force:n.multiplyByFloats(a,a,a),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=ni.CreateSphere("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 o.x(2*n,2*n,2*n),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(i,!0)},e}(),es=function(){function e(e,t,n,i){this._physicsHelper=e,this._scene=t,this._origin=n,this._options=i,this._dataFetched=!1,this._options=l.a({},new is,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}(),ts=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,this._originTop=o.x.Zero(),this._originDirection=o.x.Zero(),this._cylinderPosition=o.x.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=l.a({},new rs,this._options),this._origin.addToRef(new o.x(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new o.x(0,this._options.height,0),this._originTop),this._options.updraftMode===qa.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===qa.Perpendicular)var n=this._originDirection;else n=t.subtract(this._originTop);var i=o.x.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=xn.CreateCylinder("updraftEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),ns=function(){function e(e,t,n){this._scene=e,this._origin=t,this._options=n,this._originTop=o.x.Zero(),this._cylinderPosition=o.x.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._options=l.a({},new os,this._options),this._origin.addToRef(new o.x(0,this._options.height/2,0),this._cylinderPosition),this._origin.addToRef(new o.x(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 o.x(this._origin.x,t.y,this._origin.z),i=t.subtract(n),r=new Ee(n,i,this._options.radius).intersectsMesh(e.object),a=r.pickedPoint;if(!a)return null;var s=r.distance/this._options.radius,c=a.normalize();if(s>this._options.centripetalForceThreshold&&(c=c.negate()),s>this._options.centripetalForceThreshold)var l=c.x*this._options.centripetalForceMultiplier,u=c.y*this._options.updraftForceMultiplier,h=c.z*this._options.centripetalForceMultiplier;else{var d=o.x.Cross(n,t).normalize();l=(d.x+c.x)*this._options.centrifugalForceMultiplier,u=this._originTop.y*this._options.updraftForceMultiplier,h=(d.z+c.z)*this._options.centrifugalForceMultiplier}var f=new o.x(l,u,h);return{force:f=f.multiplyByFloats(this._options.strength,this._options.strength,this._options.strength),contactPoint:t,distanceFromOrigin:s}},e.prototype._tick=function(){var e=this;this._physicsEngine.getImpostors().forEach((function(t){var n=e.getImpostorHitData(t);n&&t.applyForce(n.force,n.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=xn.CreateCylinder("vortexEventCylinder",{height:this._options.height,diameter:2*this._options.radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e}(),is=function(){this.radius=5,this.strength=10,this.falloff=Qa.Constant,this.sphere={segments:32,diameter:1}},rs=function(){this.radius=5,this.strength=10,this.height=10,this.updraftMode=qa.Center},os=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"}(Qa||(Qa={})),function(e){e[e.Center=0]="Center",e[e.Perpendicular=1]="Perpendicular"}(qa||(qa={}));var as="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float degree;\nvoid main(void)\n{\nvec3 color=texture2D(textureSampler,vUV).rgb;\nfloat luminance=dot(color,vec3(0.3,0.59,0.11));\nvec3 blackAndWhite=vec3(luminance,luminance,luminance);\ngl_FragColor=vec4(color-((color-blackAndWhite)*degree),1.0);\n}";Lt.a.ShadersStore.blackAndWhitePixelShader=as;var ss=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 l.d(t,e),t}(It.a),cs=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}(It.a),Ns="#include\n\nuniform sampler2D textureSampler;\n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\n\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}";Lt.a.ShadersStore.grainPixelShader=Ns;var Fs=function(e){function t(t,n,i,r,o,a,s,c){void 0===s&&(s=m.a.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var l=e.call(this,t,"grain",["intensity","animatedSeed"],[],n,i,r,o,a,null,s,void 0,null,c)||this;return l.intensity=30,l.animated=!1,l.onApplyObservable.add((function(e){e.setFloat("intensity",l.intensity),e.setFloat("animatedSeed",l.animated?Math.random()+1:1)})),l}return l.d(t,e),t}(It.a),ks="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nconst vec3 RGBLuminanceCoefficients=vec3(0.2126,0.7152,0.0722);\nvoid main(void)\n{\nvec4 tex=texture2D(textureSampler,vUV);\nvec3 c=tex.rgb;\nfloat luma=dot(c.rgb,RGBLuminanceCoefficients);\n\n\ngl_FragColor=vec4(pow(c,vec3(25.0-luma*15.0)),tex.a);\n}";Lt.a.ShadersStore.highlightsPixelShader=ks;var Bs=function(e){function t(t,n,i,r,o,a,s){return void 0===s&&(s=m.a.TEXTURETYPE_UNSIGNED_INT),e.call(this,t,"highlights",null,null,n,i,r,o,a,null,s)||this}return l.d(t,e),t}(It.a);Lt.a.IncludesShadersStore.mrtFragmentDeclaration="#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";var zs="#extension GL_EXT_draw_buffers : require\nprecision highp float;\nprecision highp int;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include[RENDER_TARGET_COUNT]\nvoid main() {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragData[0]=vec4(vViewPos.z/vViewPos.w,0.0,0.0,1.0);\n\ngl_FragData[1]=vec4(normalize(vNormalV),1.0);\n\n#ifdef POSITION\ngl_FragData[POSITION_INDEX]=vec4(vPosition,1.0);\n#endif\n#ifdef VELOCITY\nvec2 a=(vCurrentPosition.xy/vCurrentPosition.w)*0.5+0.5;\nvec2 b=(vPreviousPosition.xy/vPreviousPosition.w)*0.5+0.5;\nvec2 velocity=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}";Lt.a.ShadersStore.geometryPixelShader=zs;var Vs="precision highp float;\nprecision highp int;\n#include\n#include\nattribute vec3 position;\nattribute vec3 normal;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n\nuniform mat4 viewProjection;\nuniform mat4 view;\nvarying vec3 vNormalV;\nvarying vec4 vViewPos;\n#ifdef POSITION\nvarying vec3 vPosition;\n#endif\n#ifdef VELOCITY\nuniform mat4 previousWorld;\nuniform mat4 previousViewProjection;\n#ifdef BONES_VELOCITY_ENABLED\n#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mPreviousBones[BonesPerMesh];\n#endif\n#endif\nvarying vec4 vCurrentPosition;\nvarying vec4 vPreviousPosition;\n#endif\nvoid main(void)\n{\n#include\n#if defined(VELOCITY) && !defined(BONES_VELOCITY_ENABLED)\n\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\nvPreviousPosition=previousViewProjection*previousWorld*vec4(position,1.0);\n#endif\n#include\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#if defined(VELOCITY) && defined(BONES_VELOCITY_ENABLED)\nvCurrentPosition=viewProjection*finalWorld*vec4(position,1.0);\n#if NUM_BONE_INFLUENCERS>0\nmat4 previousInfluence;\npreviousInfluence=mPreviousBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\npreviousInfluence+=mPreviousBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\npreviousInfluence+=mPreviousBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\npreviousInfluence+=mPreviousBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\npreviousInfluence+=mPreviousBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\nvPreviousPosition=previousViewProjection*previousWorld*previousInfluence*vec4(position,1.0);\n#else\nvPreviousPosition=previousViewProjection*previousWorld*vec4(position,1.0);\n#endif\n#endif\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}";Lt.a.ShadersStore.geometryVertexShader=Vs;var Us=function(){function e(t,n){void 0===n&&(n=1),this._previousTransformationMatrices={},this._previousBonesTransformationMatrices={},this.excludedSkinnedMeshesFromVelocity=[],this._enablePosition=!1,this._enableVelocity=!1,this._positionIndex=-1,this._velocityIndex=-1,this._scene=t,this._ratio=n,e._SceneComponentInitialization(this._scene),this._createRenderTargets()}return Object.defineProperty(e.prototype,"renderList",{set:function(e){this._multiRenderTarget.renderList=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._multiRenderTarget.isSupported},enumerable:!0,configurable:!0}),e.prototype.getTextureIndex=function(t){switch(t){case e.POSITION_TEXTURE_TYPE:return this._positionIndex;case e.VELOCITY_TEXTURE_TYPE:return this._velocityIndex;default:return-1}},Object.defineProperty(e.prototype,"enablePosition",{get:function(){return this._enablePosition},set:function(e){this._enablePosition=e,this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"enableVelocity",{get:function(){return this._enableVelocity},set:function(e){this._enableVelocity=e,e||(this._previousTransformationMatrices={}),this.dispose(),this._createRenderTargets()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return this._ratio},enumerable:!0,configurable:!0}),e.prototype.isReady=function(e,t){var n=e.getMaterial();if(n&&n.disableDepthWrite)return!1;var i=[],r=[gn.b.PositionKind,gn.b.NormalKind],o=e.getMesh();n&&n.needAlphaTesting()&&(i.push("#define ALPHATEST"),o.isVerticesDataPresent(gn.b.UVKind)&&(r.push(gn.b.UVKind),i.push("#define UV1")),o.isVerticesDataPresent(gn.b.UV2Kind)&&(r.push(gn.b.UV2Kind),i.push("#define UV2"))),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")),o.useBones&&o.computeBonesUsingShaders?(r.push(gn.b.MatricesIndicesKind),r.push(gn.b.MatricesWeightsKind),o.numBoneInfluencers>4&&(r.push(gn.b.MatricesIndicesExtraKind),r.push(gn.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"),t&&(i.push("#define INSTANCES"),r.push("world0"),r.push("world1"),r.push("world2"),r.push("world3")),i.push("#define RENDER_TARGET_COUNT "+this._multiRenderTarget.textures.length);var a=i.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("geometry",r,["world","mBones","viewProjection","diffuseMatrix","view","previousWorld","previousViewProjection","mPreviousBones"],["diffuseSampler"],a,void 0,void 0,void 0,{buffersCount:this._enablePosition?3:2})),this._effect.isReady()},e.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(e.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.getGBuffer().dispose()},e.prototype._createRenderTargets=function(){var e=this,t=this._scene.getEngine(),n=2;if(this._enablePosition&&(this._positionIndex=n,n++),this._enableVelocity&&(this._velocityIndex=n,n++),this._multiRenderTarget=new Ro("gBuffer",{width:t.getRenderWidth()*this._ratio,height:t.getRenderHeight()*this._ratio},n,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:m.a.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=Kt.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=Kt.a.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(e){e.clear(new o.f(0,0,0,1),!0,!0,!0)}));var i=function(t){var n=t.getRenderingMesh(),i=e._scene,r=i.getEngine(),a=t.getMaterial();if(a){if(e._enableVelocity&&!e._previousTransformationMatrices[n.uniqueId]&&(e._previousTransformationMatrices[n.uniqueId]={world:o.j.Identity(),viewProjection:i.getTransformMatrix()},n.skeleton)){var s=n.skeleton.getTransformMatrices(n);e._previousBonesTransformationMatrices[n.uniqueId]=e._copyBonesTransformationMatrices(s,new Float32Array(s.length))}r.setState(a.backFaceCulling,0,!1,i.useRightHandedSystem);var c=n._getInstancesRenderList(t._id);if(!c.mustReturn){var l=r.getCaps().instancedArrays&&null!==c.visibleInstances[t._id];if(e.isReady(t,l)){if(r.enableEffect(e._effect),n._bind(t,e._effect,Tr.a.TriangleFillMode),e._effect.setMatrix("viewProjection",i.getTransformMatrix()),e._effect.setMatrix("view",i.getViewMatrix()),a&&a.needAlphaTesting()){var u=a.getAlphaTestTexture();u&&(e._effect.setTexture("diffuseSampler",u),e._effect.setMatrix("diffuseMatrix",u.getTextureMatrix()))}n.useBones&&n.computeBonesUsingShaders&&n.skeleton&&(e._effect.setMatrices("mBones",n.skeleton.getTransformMatrices(n)),e._enableVelocity&&e._effect.setMatrices("mPreviousBones",e._previousBonesTransformationMatrices[n.uniqueId])),e._enableVelocity&&(e._effect.setMatrix("previousWorld",e._previousTransformationMatrices[n.uniqueId].world),e._effect.setMatrix("previousViewProjection",e._previousTransformationMatrices[n.uniqueId].viewProjection)),n._processRendering(t,e._effect,Tr.a.TriangleFillMode,c,l,(function(t,n){return e._effect.setMatrix("world",n)}))}e._enableVelocity&&(e._previousTransformationMatrices[n.uniqueId].world=n.getWorldMatrix().clone(),e._previousTransformationMatrices[n.uniqueId].viewProjection=e._scene.getTransformMatrix().clone(),n.skeleton&&e._copyBonesTransformationMatrices(n.skeleton.getTransformMatrices(n),e._previousBonesTransformationMatrices[n.uniqueId]))}}};this._multiRenderTarget.customRenderFunction=function(e,n,r,o){var a;if(o.length){for(t.setColorWrite(!1),a=0;a0){var n=this._renderEffects[t[0]].getPostProcesses();n&&(n[0].samples=e)}return!0},e.prototype.dispose=function(){},l.c([Object(De.c)()],e.prototype,"_name",void 0),e}(),Zs=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:!0,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(ae.a.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(oe.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new Js(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new Zs}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var Js=function(){function e(e){this.name=oe.a.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(oe.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}(),$s=function(e){function t(t,n,i,r,o){void 0===t&&(t=""),void 0===n&&(n=!0),void 0===i&&(i=A.a.LastCreatedScene),void 0===o&&(o=!0);var a=e.call(this,i.getEngine(),t)||this;a._camerasToBeAttached=[],a.SharpenPostProcessId="SharpenPostProcessEffect",a.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",a.FxaaPostProcessId="FxaaPostProcessEffect",a.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",a.GrainPostProcessId="GrainPostProcessEffect",a._glowLayer=null,a.animations=[],a._imageProcessingConfigurationObserver=null,a._sharpenEnabled=!1,a._bloomEnabled=!1,a._depthOfFieldEnabled=!1,a._depthOfFieldBlurLevel=Ts.Low,a._fxaaEnabled=!1,a._imageProcessingEnabled=!0,a._bloomScale=.5,a._chromaticAberrationEnabled=!1,a._grainEnabled=!1,a._buildAllowed=!0,a._resizeObserver=null,a._hardwareScaleLevel=1,a._bloomKernel=64,a._bloomWeight=.15,a._bloomThreshold=.9,a._samples=1,a._hasCleared=!1,a._prevPostProcess=null,a._prevPrevPostProcess=null,a._depthOfFieldSceneObserver=null,a._cameras=r||i.cameras,a._cameras=a._cameras.slice(),a._camerasToBeAttached=a._cameras.slice(),a._buildAllowed=o,a._scene=i;var s=a._scene.getEngine().getCaps();a._hdr=n&&(s.textureHalfFloatRender||s.textureFloatRender),a._hdr?s.textureHalfFloatRender?a._defaultPipelineTextureType=m.a.TEXTURETYPE_HALF_FLOAT:s.textureFloatRender&&(a._defaultPipelineTextureType=m.a.TEXTURETYPE_FLOAT):a._defaultPipelineTextureType=m.a.TEXTURETYPE_UNSIGNED_INT,i.postProcessRenderPipelineManager.addPipeline(a);var c=a._scene.getEngine();return a.sharpen=new Qs("sharpen",1,null,Kt.a.BILINEAR_SAMPLINGMODE,c,!1,a._defaultPipelineTextureType,!0),a._sharpenEffect=new cs(c,a.SharpenPostProcessId,(function(){return a.sharpen}),!0),a.depthOfField=new Ps(a._scene,null,a._depthOfFieldBlurLevel,a._defaultPipelineTextureType,!0),a.bloom=new fs(a._scene,a._bloomScale,a._bloomWeight,a.bloomKernel,a._defaultPipelineTextureType,!0),a.chromaticAberration=new ms("ChromaticAberration",c.getRenderWidth(),c.getRenderHeight(),1,null,Kt.a.BILINEAR_SAMPLINGMODE,c,!1,a._defaultPipelineTextureType,!0),a._chromaticAberrationEffect=new cs(c,a.ChromaticAberrationPostProcessId,(function(){return a.chromaticAberration}),!0),a.grain=new Fs("Grain",1,null,Kt.a.BILINEAR_SAMPLINGMODE,c,!1,a._defaultPipelineTextureType,!0),a._grainEffect=new cs(c,a.GrainPostProcessId,(function(){return a.grain}),!0),a._resizeObserver=c.onResizeObservable.add((function(){a._hardwareScaleLevel=c.getHardwareScalingLevel(),a.bloomKernel=a.bloomKernel})),a._imageProcessingConfigurationObserver=a._scene.imageProcessingConfiguration.onUpdateParameters.add((function(){a.bloom._downscale._exposure=a._scene.imageProcessingConfiguration.exposure})),a._buildPipeline(),a}return l.d(t,e),Object.defineProperty(t.prototype,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomKernel",{get:function(){return this._bloomKernel},set:function(e){this._bloomKernel=e,this.bloom.kernel=e/this._hardwareScaleLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomWeight",{get:function(){return this._bloomWeight},set:function(e){this._bloomWeight!==e&&(this.bloom.weight=e,this._bloomWeight=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomThreshold",{get:function(){return this._bloomThreshold},set:function(e){this._bloomThreshold!==e&&(this.bloom.threshold=e,this._bloomThreshold=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomScale",{get:function(){return this._bloomScale},set:function(e){this._bloomScale!==e&&(this._bloomScale=e,this._rebuildBloom(),this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),t.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new fs(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 pn("imageProcessing",1,null,Kt.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new cs(t,this.ImageProcessingPostProcessId,(function(){return e.imageProcessing}),!0)),this._setAutoClearAndTextureSharing(this.imageProcessing)):this._scene.imageProcessingConfiguration.applyByPostProcess=!1),this.sharpenEnabled&&(this.sharpen.isReady()||this.sharpen.updateEffect(),this.addEffect(this._sharpenEffect),this._setAutoClearAndTextureSharing(this.sharpen)),this.grainEnabled&&(this.grain.isReady()||this.grain.updateEffect(),this.addEffect(this._grainEffect),this._setAutoClearAndTextureSharing(this.grain)),this.chromaticAberrationEnabled&&(this.chromaticAberration.isReady()||this.chromaticAberration.updateEffect(),this.addEffect(this._chromaticAberrationEffect),this._setAutoClearAndTextureSharing(this.chromaticAberration)),this.fxaaEnabled&&(this.fxaa=new Ds("fxaa",1,null,Kt.a.BILINEAR_SAMPLINGMODE,t,!1,this._defaultPipelineTextureType),this.addEffect(new cs(t,this.FxaaPostProcessId,(function(){return e.fxaa}),!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this.samples)&&this.samples>1&&p.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")}},t.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t0?n._ssaoCombinePostProcess.width:n._originalColorPostProcess.width),e.setFloat("near",n._scene.activeCamera.minZ),e.setFloat("far",n._scene.activeCamera.maxZ),e.setFloat("radius",n.radius),e.setTexture("depthSampler",n._depthTexture),n._firstUpdate&&e.setArray("samplerOffsets",n._samplerOffsets))},this._blurVPostProcess=new It.a("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],t,null,Kt.a.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(i?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){n._scene.activeCamera&&(e.setFloat("outSize",n._ssaoCombinePostProcess.height>0?n._ssaoCombinePostProcess.height:n._originalColorPostProcess.height),e.setFloat("near",n._scene.activeCamera.minZ),e.setFloat("far",n._scene.activeCamera.maxZ),e.setFloat("radius",n.radius),e.setTexture("depthSampler",n._depthTexture),n._firstUpdate&&(e.setArray("samplerOffsets",n._samplerOffsets),n._firstUpdate=!1))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},t.prototype._rebuild=function(){this._firstUpdate=!0,e.prototype._rebuild.call(this)},t.prototype._radicalInverse_VdC=function(e){return this._bits[0]=e,this._bits[0]=(this._bits[0]<<16|this._bits[0]>>16)>>>0,this._bits[0]=(1431655765&this._bits[0])<<1|(2863311530&this._bits[0])>>>1>>>0,this._bits[0]=(858993459&this._bits[0])<<2|(3435973836&this._bits[0])>>>2>>>0,this._bits[0]=(252645135&this._bits[0])<<4|(4042322160&this._bits[0])>>>4>>>0,this._bits[0]=(16711935&this._bits[0])<<8|(4278255360&this._bits[0])>>>8>>>0,2.3283064365386963e-10*this._bits[0]},t.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},t.prototype._hemisphereSample_uniform=function(e,t){var n=2*t*Math.PI,i=1-(.85*e+.15),r=Math.sqrt(1-i*i);return new o.x(Math.cos(n)*r,Math.sin(n)*r,i)},t.prototype._generateHemisphere=function(){for(var e,t=this.samples,n=[],i=0;i1&&p.a.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},t.prototype._createDownSampleX4PostProcess=function(e,t){var n=this,i=new Array(32);this.downSampleX4PostProcess=new It.a("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",m.a.TEXTURETYPE_UNSIGNED_INT),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 cs(e.getEngine(),"HDRDownSampleX4",(function(){return n.downSampleX4PostProcess}),!0))},t.prototype._createBrightPassPostProcess=function(e,t){var n=this,i=new Array(8);this.brightPassPostProcess=new It.a("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",m.a.TEXTURETYPE_UNSIGNED_INT),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 cs(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 a=e.getEngine(),s=new ji("HDRBlurH_"+n,new o.w(1,0),this[i],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,m.a.TEXTURETYPE_UNSIGNED_INT),c=new ji("HDRBlurV_"+n,new o.w(0,1),this[i],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,m.a.TEXTURETYPE_UNSIGNED_INT);s.onActivateObservable.add((function(){var e=s.width/a.getRenderWidth();s.kernel=r[i]*e})),c.onActivateObservable.add((function(){var e=c.height/a.getRenderHeight();c.kernel=r.horizontalBlur?64*e:r[i]*e})),this.addEffect(new cs(e.getEngine(),"HDRBlurH"+n,(function(){return s}),!0)),this.addEffect(new cs(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 It.a("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",m.a.TEXTURETYPE_UNSIGNED_INT),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 cs(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 It.a("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var a=o.w.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),a.x=n.sourceLight.getDepthMinZ(n._scene.activeCamera),a.y=n.sourceLight.getDepthMaxZ(n._scene.activeCamera),e.setVector2("depthValues",a)}},this.addEffect(new cs(e.getEngine(),"HDRVLS",(function(){return n.volumetricLightPostProcess}),!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new It.a("HDRVLSMerge","standard",[],["originalSampler"],t,null,Kt.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 cs(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 It.a("HDRLuminance","standard",["lumOffsets"],[],{width:r,height:r},null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LUMINANCE",n);var a=[];this.luminancePostProcess.onApply=function(e){var t=1/i.luminancePostProcess.width,n=1/i.luminancePostProcess.height;a[0]=-.5*t,a[1]=.5*n,a[2]=.5*t,a[3]=.5*n,a[4]=-.5*t,a[5]=-.5*n,a[6]=.5*t,a[7]=-.5*n,e.setArray2("lumOffsets",a)},this.addEffect(new cs(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 l=new It.a("HDRLuminanceDownSample"+s,"standard",["dsOffsets","halfDestPixelSize"],[],{width:r,height:r},null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,c,n);this.luminanceDownSamplePostProcesses.push(l)}var u=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(t,n){var r=new Array(18);t.onApply=function(e){if(u){for(var o=0,a=-1;a<2;a++)for(var s=-1;s<2;s++)r[o]=a/u.width,r[o+1]=s/u.height,o+=2;e.setArray2("dsOffsets",r),e.setFloat("halfDestPixelSize",.5/u.width),u=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 o.y(1/16581375,1/65025,1/255,1);i._hdrCurrentLuminance=(t[0]*n.x+t[1]*n.y+t[2]*n.z+t[3]*n.w)/100}),i.addEffect(new cs(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 It.a("HDR","standard",["averageLuminance"],["textureAdderSampler"],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,i.join("\n"),m.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=Ge.a.Clamp(r,n.hdrMinimumLuminance,1e20),t.setFloat("averageLuminance",r)),a=o,n._currentDepthOfFieldSource=n.hdrFinalPostProcess},this.addEffect(new cs(e.getEngine(),"HDR",(function(){return n.hdrPostProcess}),!0))},t.prototype._createLensFlarePostProcess=function(e,t){var n=this;this.lensFlarePostProcess=new It.a("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",m.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new cs(e.getEngine(),"HDRLensFlare",(function(){return n.lensFlarePostProcess}),!0)),this._createBlurPostProcesses(e,t/4,2),this.lensFlareComposePostProcess=new It.a("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",m.a.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new cs(e.getEngine(),"HDRLensFlareCompose",(function(){return n.lensFlareComposePostProcess}),!0));var i=new o.w(0,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=o.j.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),a=o.j.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(n._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",n._currentDepthOfFieldSource),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=o.x.Dot(t.toVector3(),new o.x(1,0,0))+o.x.Dot(i.toVector3(),new o.x(0,0,1));s*=4;var c=o.j.FromValues(.5*Math.cos(s),-Math.sin(s),0,0,Math.sin(s),.5*Math.cos(s),0,0,0,0,1,0,0,0,0,1),l=a.multiply(c).multiply(r);e.setMatrix("lensStarMatrix",l),n._currentDepthOfFieldSource=n.lensFlareFinalPostProcess}}},t.prototype._createDepthOfFieldPostProcess=function(e,t){var n=this;this.depthOfFieldPostProcess=new It.a("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",m.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 cs(e.getEngine(),"HDRDepthOfField",(function(){return n.depthOfFieldPostProcess}),!0))},t.prototype._createMotionBlurPostProcess=function(e,t){var n=this;this.motionBlurPostProcess=new It.a("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],t,null,Kt.a.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),m.a.TEXTURETYPE_UNSIGNED_INT);var i=0,r=o.j.Identity(),a=o.j.Identity(),s=o.j.Identity(),c=o.w.Zero();this.motionBlurPostProcess.onApply=function(t){(s=e.getProjectionMatrix().multiply(e.getViewMatrix())).invertToRef(a),t.setMatrix("inverseViewProjection",a),t.setMatrix("prevViewProjection",r),r=s,c.x=n.motionBlurPostProcess.width,c.y=n.motionBlurPostProcess.height,t.setVector2("screenSize",c),i=e.getEngine().getFps()/60,t.setFloat("motionScale",i),t.setFloat("motionStrength",n.motionStrength),t.setTexture("depthSampler",n._getDepthTexture())},this.addEffect(new cs(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 en.a("volumetricLightScatteringMap",{width:i.getRenderWidth()*t,height:i.getRenderHeight()*t},e,!1,!0,m.a.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Kt.a.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Kt.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 a,s=function(e){var t=e.getRenderingMesh();if(!n._meshExcluded(t)){var i=e.getMaterial();if(i){var r=t.getScene(),o=r.getEngine();o.setState(i.backFaceCulling);var a=t._getInstancesRenderList(e._id);if(!a.mustReturn){var s=o.getCaps().instancedArrays&&null!==a.visibleInstances[e._id];if(n._isReady(e,s)){var c=n._volumetricLightScatteringPass;if(t===n.mesh&&(c=e.effect?e.effect:i.getEffect()),o.enableEffect(c),t._bind(e,c,Tr.a.TriangleFillMode),t===n.mesh)i.bind(t.getWorldMatrix(),t);else{if(n._volumetricLightScatteringPass.setMatrix("viewProjection",r.getTransformMatrix()),i&&i.needAlphaTesting()){var l=i.getAlphaTestTexture();n._volumetricLightScatteringPass.setTexture("diffuseSampler",l),l&&n._volumetricLightScatteringPass.setMatrix("diffuseMatrix",l.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&n._volumetricLightScatteringPass.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(e,n._volumetricLightScatteringPass,Tr.a.TriangleFillMode,a,s,(function(e,t){return c.setMatrix("world",t)}))}}}}},c=new o.f(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){a=e.clearColor,e.clearColor=c})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){e.clearColor=a})),this._volumetricLightScatteringRTT.customRenderFunction=function(t,n,i,r){var o,a=e.getEngine();if(r.length){for(a.setColorWrite(!1),o=0;ot._alphaIndex?1:e._alphaIndext._distanceToCamera?-1:0})),a.setAlphaMode(m.a.ALPHA_COMBINE),o=0;o4&&(r.push(gn.b.MatricesIndicesExtraKind),r.push(gn.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"),t&&(i.push("#define INSTANCES"),r.push("world0"),r.push("world1"),r.push("world2"),r.push("world3"));var a=i.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this._scene.getEngine().createEffect("depth",r,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],a)),this._effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){this._depthMap.dispose()},e._SceneComponentInitialization=function(e){throw Pr.a.WarnImport("DepthRendererSceneComponent")},e}();ae.a.prototype.enableDepthRenderer=function(e){if(!(e=e||this.activeCamera))throw"No camera available to enable depth renderer";if(this._depthRenderer||(this._depthRenderer={}),!this._depthRenderer[e.id]){var t=0;if(this.getEngine().getCaps().textureHalfFloatRender)t=m.a.TEXTURETYPE_HALF_FLOAT;else{if(!this.getEngine().getCaps().textureFloatRender)throw"Depth renderer does not support int texture type";t=m.a.TEXTURETYPE_FLOAT}this._depthRenderer[e.id]=new bc(this,t,e)}return this._depthRenderer[e.id]},ae.a.prototype.disableDepthRenderer=function(e){(e=e||this.activeCamera)&&this._depthRenderer&&this._depthRenderer[e.id]&&(this._depthRenderer[e.id].dispose(),delete this._depthRenderer[e.id])};var yc=function(){function e(e){this.name=oe.a.NAME_DEPTHRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(oe.a.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(oe.a.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){for(var e in this.scene._depthRenderer)this.scene._depthRenderer[e].dispose()},e.prototype._gatherRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var n=this.scene._depthRenderer[t];n.useOnlyInActiveCamera||e.push(n.getDepthMap())}},e.prototype._gatherActiveCameraRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var n=this.scene._depthRenderer[t];n.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(n.getDepthMap())}},e}();bc._SceneComponentInitialization=function(e){var t=e._getComponent(oe.a.NAME_DEPTHRENDERER);t||(t=new yc(e),e._addComponent(t))};var xc="uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";Lt.a.ShadersStore.linePixelShader=xc;var Cc="\nattribute vec3 position;\nattribute vec4 normal;\n\nuniform mat4 worldViewProjection;\nuniform float width;\nuniform float aspectRatio;\nvoid main(void) {\nvec4 viewPosition=worldViewProjection*vec4(position,1.0);\nvec4 viewPositionNext=worldViewProjection*vec4(normal.xyz,1.0);\nvec2 currentScreen=viewPosition.xy/viewPosition.w;\nvec2 nextScreen=viewPositionNext.xy/viewPositionNext.w;\ncurrentScreen.x*=aspectRatio;\nnextScreen.x*=aspectRatio;\nvec2 dir=normalize(nextScreen-currentScreen);\nvec2 normalDir=vec2(-dir.y,dir.x);\nnormalDir*=width/2.0;\nnormalDir.x/=aspectRatio;\nvec4 offset=vec4(normalDir*normal.w,0.0,0.0);\ngl_Position=viewPosition+offset;\n}";Lt.a.ShadersStore.lineVertexShader=Cc;Me.a.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},Me.a.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Tc(this,e,t),this},Object.defineProperty(Me.a.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),ui.b.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new Sc(this,e,t),this},ui.a.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),ui.b.prototype.enableEdgesRendering.apply(this,arguments),this};var Ec=function(){this.edges=new Array,this.edgesConnectedCount=0},Tc=function(){function e(e,t,n,i){var r=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._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this._source=e,this._checkVerticesInsteadOfIndices=n,this._epsilon=t,this._prepareRessources(),i&&this._generateEdgesLines(),this._meshRebuildObserver=this._source.onRebuildObservable.add((function(){r._rebuild()})),this._meshDisposeObserver=this._source.onDisposeObservable.add((function(){r.dispose()}))}return e.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new So.a("lineShader",this._source.getScene(),"line",{attributes:["position","normal"],uniforms:["worldViewProjection","color","width","aspectRatio"]}),this._lineShader.disableDepthWrite=!0,this._lineShader.backFaceCulling=!1)},e.prototype._rebuild=function(){var e=this._buffers[gn.b.PositionKind];e&&e._rebuild(),(e=this._buffers[gn.b.NormalKind])&&e._rebuild();var t=this._source.getScene().getEngine();this._ib=t.createIndexBuffer(this._linesIndices)},e.prototype.dispose=function(){this._source.onRebuildObservable.remove(this._meshRebuildObserver),this._source.onDisposeObservable.remove(this._meshDisposeObserver);var e=this._buffers[gn.b.PositionKind];e&&(e.dispose(),this._buffers[gn.b.PositionKind]=null),(e=this._buffers[gn.b.NormalKind])&&(e.dispose(),this._buffers[gn.b.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.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){return e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?0:e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?1:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?2:-1},e.prototype._checkEdge=function(e,t,n,i,r){var a;void 0===t?a=!0:a=o.x.Dot(n[e],n[t])\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include\ngl_FragColor=color;\n}");Lt.a.ShadersStore.outlinePixelShader=Ac;n(187);var Pc="\nattribute vec3 position;\nattribute vec3 normal;\n#include\n\nuniform float offset;\n#include\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include\n#include\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include\n}\n";Lt.a.ShadersStore.outlineVertexShader=Pc;ae.a.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new Mc(this)),this._outlineRenderer},Object.defineProperty(Me.a.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(Me.a.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var Mc=function(){function e(e){this.name=oe.a.NAME_OUTLINERENDERER,this.zOffset=1,this.scene=e,this._engine=e.getEngine(),this.scene._addComponent(this)}return e.prototype.register=function(){this.scene._beforeRenderingMeshStage.registerStep(oe.a.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(oe.a.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype.render=function(e,t,n){var i=this;void 0===n&&(n=!1);var r=this.scene,o=r.getEngine(),a=o.getCaps().instancedArrays&&null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id];if(this.isReady(e,a)){var s=e.getRenderingMesh(),c=e.getMaterial();if(c&&r.activeCamera){if(o.enableEffect(this._effect),c.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(r.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",n?0:s.outlineWidth),this._effect.setColor4("color",n?s.overlayColor:s.outlineColor,n?s.overlayAlpha:c.alpha),this._effect.setMatrix("viewProjection",r.getTransformMatrix()),s.useBones&&s.computeBonesUsingShaders&&s.skeleton&&this._effect.setMatrices("mBones",s.skeleton.getTransformMatrices(s)),s._bind(e,this._effect,Tr.a.TriangleFillMode),c&&c.needAlphaTesting()){var l=c.getAlphaTestTexture();l&&(this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix()))}o.setZOffset(-this.zOffset),s._processRendering(e,this._effect,Tr.a.TriangleFillMode,t,a,(function(e,t){i._effect.setMatrix("world",t)})),o.setZOffset(0)}}},e.prototype.isReady=function(e,t){var n=[],i=[gn.b.PositionKind,gn.b.NormalKind],r=e.getMesh(),o=e.getMaterial();o&&(o.needAlphaTesting()&&(n.push("#define ALPHATEST"),r.isVerticesDataPresent(gn.b.UVKind)&&(i.push(gn.b.UVKind),n.push("#define UV1")),r.isVerticesDataPresent(gn.b.UV2Kind)&&(i.push(gn.b.UV2Kind),n.push("#define UV2"))),o.useLogarithmicDepth&&n.push("#define LOGARITHMICDEPTH")),r.useBones&&r.computeBonesUsingShaders?(i.push(gn.b.MatricesIndicesKind),i.push(gn.b.MatricesWeightsKind),r.numBoneInfluencers>4&&(i.push(gn.b.MatricesIndicesExtraKind),i.push(gn.b.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+r.numBoneInfluencers),n.push("#define BonesPerMesh "+(r.skeleton?r.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0"),t&&(n.push("#define INSTANCES"),i.push("world0"),i.push("world1"),i.push("world2"),i.push("world3"));var a=n.join("\n");return this._cachedDefines!==a&&(this._cachedDefines=a,this._effect=this.scene.getEngine().createEffect("outline",i,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant"],["diffuseSampler"],a)),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(t,n,i){if(this._savedDepthWrite=this._engine.getDepthWrite(),t.renderOutline){var r=n.getMaterial();r&&r.needAlphaBlending&&(this._engine.cacheStencilState(),this._engine.setDepthWrite(!1),this._engine.setColorWrite(!1),this._engine.setStencilBuffer(!0),this._engine.setStencilOperationPass(m.a.REPLACE),this._engine.setStencilFunction(m.a.ALWAYS),this._engine.setStencilMask(e._StencilReference),this._engine.setStencilFunctionReference(e._StencilReference),this.render(n,i,!0),this._engine.setColorWrite(!0),this._engine.setStencilFunction(m.a.NOTEQUAL)),this._engine.setDepthWrite(!1),this.render(n,i),this._engine.setDepthWrite(this._savedDepthWrite),r&&r.needAlphaBlending&&this._engine.restoreStencilState()}},e.prototype._afterRenderingMesh=function(e,t,n){if(e.renderOverlay){var i=this._engine.getAlphaMode();this._engine.setAlphaMode(m.a.ALPHA_COMBINE),this.render(t,n,!0),this._engine.setAlphaMode(i)}e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,n),this._engine.setColorWrite(!0))},e._StencilReference=4,e}(),Oc=n(163),Rc=n(135),wc=function(){function e(e,t){this.name=e,this.color=new o.f(1,1,1,1),this.width=1,this.height=1,this.angle=0,this.cellIndex=0,this.invertU=0,this.invertV=0,this.animations=new Array,this.isPickable=!1,this._animationStarted=!1,this._loopAnimation=!1,this._fromIndex=0,this._toIndex=0,this._delay=0,this._direction=1,this._time=0,this.isVisible=!0,this._manager=t,this._manager.sprites.push(this),this.position=o.x.Zero()}return Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),e.prototype.playAnimation=function(e,t,n,i,r){this._fromIndex=e,this._toIndex=t,this._loopAnimation=n,this._delay=i,this._animationStarted=!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._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},e.prototype.dispose=function(){for(var e=0;e0)for(var o=0;o=r.distance))&&(r=s,n))break}}return r||new ye.a},ae.a.prototype.pickSprite=function(e,t,n,i,r){return this.createPickingRayInCameraSpaceToRef(e,t,this._tempSpritePickingRay,r),this._internalPickSprites(this._tempSpritePickingRay,n,i,r)},ae.a.prototype.pickSpriteWithRay=function(e,t,n,i){if(!this._tempSpritePickingRay)return null;if(!i){if(!this.activeCamera)return null;i=this.activeCamera}return Ee.TransformToRef(e,i.getViewMatrix(),this._tempSpritePickingRay),this._internalPickSprites(this._tempSpritePickingRay,t,n,i)},ae.a.prototype.setPointerOverSprite=function(e){this._pointerOverSprite!==e&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(m.a.ACTION_OnPointerOutTrigger,c.a.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=e,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(m.a.ACTION_OnPointerOverTrigger,c.a.CreateNewFromSprite(this._pointerOverSprite,this)))},ae.a.prototype.getPointerOverSprite=function(){return this._pointerOverSprite};var Ic=function(){function e(e){this.name=oe.a.NAME_SPRITE,this.scene=e,this.scene.spriteManagers=new Array,this.scene._tempSpritePickingRay=Ee?Ee.Zero():null,this.scene.onBeforeSpritesRenderingObservable=new r.c,this.scene.onAfterSpritesRenderingObservable=new r.c,this._spritePredicate=function(e){return!!e.actionManager&&(e.isPickable&&e.actionManager.hasPointerTriggers)}}return e.prototype.register=function(){this.scene._pointerMoveStage.registerStep(oe.a.STEP_POINTERMOVE_SPRITE,this,this._pointerMove),this.scene._pointerDownStage.registerStep(oe.a.STEP_POINTERDOWN_SPRITE,this,this._pointerDown),this.scene._pointerUpStage.registerStep(oe.a.STEP_POINTERUP_SPRITE,this,this._pointerUp)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforeSpritesRenderingObservable.clear(),this.scene.onAfterSpritesRenderingObservable.clear();for(var e=this.scene.spriteManagers;e.length;)e[0].dispose()},e.prototype._pickSpriteButKeepRay=function(e,t,n,i,r){var o=this.scene.pickSprite(t,n,this._spritePredicate,i,r);return o&&(o.ray=e?e.ray:null),o},e.prototype._pointerMove=function(e,t,n,i,r){var o=this.scene;return i?o.setPointerOverSprite(null):(n=this._pickSpriteButKeepRay(n,e,t,!1,o.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite?(o.setPointerOverSprite(n.pickedSprite),o._pointerOverSprite&&o._pointerOverSprite.actionManager&&o._pointerOverSprite.actionManager.hoverCursor?r.style.cursor=o._pointerOverSprite.actionManager.hoverCursor:r.style.cursor=o.hoverCursor):o.setPointerOverSprite(null),n},e.prototype._pointerDown=function(e,t,n,i){var r=this.scene;if(r._pickedDownSprite=null,r.spriteManagers.length>0&&(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(m.a.ACTION_OnLeftPickTrigger,c.a.CreateNewFromSprite(n.pickedSprite,r,i));break;case 1:n.pickedSprite.actionManager.processTrigger(m.a.ACTION_OnCenterPickTrigger,c.a.CreateNewFromSprite(n.pickedSprite,r,i));break;case 2:n.pickedSprite.actionManager.processTrigger(m.a.ACTION_OnRightPickTrigger,c.a.CreateNewFromSprite(n.pickedSprite,r,i))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(m.a.ACTION_OnPickDownTrigger,c.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(m.a.ACTION_OnPickUpTrigger,c.a.CreateNewFromSprite(o.pickedSprite,r,i)),o.pickedSprite.actionManager&&(this.scene._inputManager._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(m.a.ACTION_OnPickTrigger,c.a.CreateNewFromSprite(o.pickedSprite,r,i)))),r._pickedDownSprite&&r._pickedDownSprite.actionManager&&r._pickedDownSprite!==o.pickedSprite&&r._pickedDownSprite.actionManager.processTrigger(m.a.ACTION_OnPickOutTrigger,c.a.CreateNewFromSprite(r._pickedDownSprite,r,i)))}return n},e}(),Lc="uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest)\n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include\ngl_FragColor=color;\n}";Lt.a.ShadersStore.spritesPixelShader=Lc;var Dc="\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include\nvoid main(void) {\nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz;\nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0);\n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}";Lt.a.ShadersStore.spritesVertexShader=Dc;var Nc,Fc=function(){function e(e,t,n,i,o,a,s){if(void 0===a&&(a=.01),void 0===s&&(s=Kt.a.TRILINEAR_SAMPLINGMODE),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this.onDisposeObservable=new r.c,this._vertexBuffers={},o._getComponent(oe.a.NAME_SPRITE)||o._addComponent(new Ic(o)),this._capacity=n,this._spriteTexture=new Kt.a(t,o,!0,!1,s),this._spriteTexture.wrapU=Kt.a.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=Kt.a.CLAMP_ADDRESSMODE,i.width&&i.height)this.cellWidth=i.width,this.cellHeight=i.height;else{if(void 0===i)return;this.cellWidth=i,this.cellHeight=i}this._epsilon=a,this._scene=o,this._scene.spriteManagers.push(this);for(var c=[],l=0,u=0;u>0;this._vertexData[o+10]=t.cellIndex-a*r,this._vertexData[o+11]=a,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},e.prototype.intersects=function(e,t,n,i){for(var r=Math.min(this._capacity,this.sprites.length),a=o.x.Zero(),s=o.x.Zero(),c=Number.MAX_VALUE,l=null,u=o.x.Zero(),h=o.x.Zero(),d=t.getViewMatrix(),f=0;fm&&(c=m,l=p,i))break}}}if(l){var g=new ye.a;d.invertToRef(o.t.Matrix[0]),g.hit=!0,g.pickedSprite=l,g.distance=c;var _=o.t.Vector3[0];return _.copyFrom(e.direction),_.normalize(),_.scaleInPlace(c),e.origin.addToRef(_,u),g.pickedPoint=o.x.TransformCoordinates(u,o.t.Matrix[0]),g}return null},e.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()&&this.sprites.length){for(var e=this._scene.getEngine(),t=this._spriteTexture.getBaseSize(),n=e.getDeltaTime(),i=Math.min(this._capacity,this.sprites.length),r=t.width/this.cellWidth,o=0,a=!0,s=0;s-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 Uc(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){p.a.Error("Error running progress callbacks."),console.log(e)}if(0===this._waitingTasksCount){try{this.onFinish&&this.onFinish(this._tasks);for(var t=this._tasks.slice(),n=0,i=t;n-1&&this._tasks.splice(r,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){p.a.Error("Error running tasks-done callbacks."),console.log(e)}this._isLoading=!1,this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(e){var t=this,n=function(n,i){e._setErrorObject(n,i),t.onTaskError&&t.onTaskError(e),t.onTaskErrorObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)};e.run(this._scene,(function(){try{t.onTaskSuccess&&t.onTaskSuccess(e),t.onTaskSuccessObservable.notifyObservers(e),t._decreaseWaitingTasksCount(e)}catch(e){n("Error executing task success callbacks",e)}}),n)},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&&p.a.ClearLogCache(),this._engine.stopRenderLoop()),bi.a.LoadAsync("file:",this._sceneFileToLoad,this._engine,(function(t){e._progressCallback&&e._progressCallback(t)})).then((function(t){e._currentScene&&e._currentScene.dispose(),e._currentScene=t,e._sceneLoadedCallback&&e._sceneLoadedCallback(e._sceneFileToLoad,e._currentScene),e._currentScene.executeWhenReady((function(){e._engine.runRenderLoop((function(){e.renderFunction()}))}))})).catch((function(t){e._errorCallback&&e._errorCallback(e._sceneFileToLoad,e._currentScene,t.message)}))):p.a.Error("Please provide a valid .babylon file.")},e}(),tl=n(159),nl=n(160),il=function(){function e(e){void 0===e&&(e=0),this.priority=e}return e.prototype.getDescription=function(){return""},e.prototype.apply=function(e,t){return!0},e}(),rl=function(e){function t(t,n,i){void 0===t&&(t=0),void 0===n&&(n=1024),void 0===i&&(i=.5);var r=e.call(this,t)||this;return r.priority=t,r.maximumSize=n,r.step=i,r}return l.d(t,e),t.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},t.prototype.apply=function(e,t){for(var n=!0,i=0;ithis.maximumSize&&(r.scale(this.step),n=!1)}}return n},t}(il),ol=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 l.d(t,e),t.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},t.prototype.apply=function(e,t){return-1===this._currentScale&&(this._currentScale=e.getEngine().getHardwareScalingLevel(),this._currentScale>this.maximumScale&&(this._directionOffset=-1)),this._currentScale+=this._directionOffset*this.step,e.getEngine().setHardwareScalingLevel(this._currentScale),1===this._directionOffset?this._currentScale>=this.maximumScale:this._currentScale<=this.maximumScale},t}(il),al=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t}(il),sl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning post-processes on/off"},t.prototype.apply=function(e,t){return e.postProcessesEnabled=t.isInImprovementMode,!0},t}(il),cl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning lens flares on/off"},t.prototype.apply=function(e,t){return e.lensFlaresEnabled=t.isInImprovementMode,!0},t}(il),ll=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return this.onGetDescription?this.onGetDescription():"Running user defined callback"},t.prototype.apply=function(e,t){return!this.onApply||this.onApply(e,t)},t}(il),ul=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t}(il),hl=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return l.d(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t}(il),dl=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._canBeMerged=function(e){if(!(e instanceof ve.a))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(t.instances.length>0)&&(!t.skeleton&&!t.hasLODLevels)))},t}return l.d(t,e),Object.defineProperty(t,"UpdateSelectionTree",{get:function(){return t._UpdateSelectionTree},set:function(e){t._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),t.prototype.getDescription=function(){return"Merging similar meshes together"},t.prototype.apply=function(e,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)for(o.reflectionProbes=[],n=0;n0&&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&&fe.h.Download(e,this._fileName)},e._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},e}(),Cl=n(175),El=function(){function e(){}return e.CreateScreenshot=function(e,t,n,i,r){var o,a;if(void 0===r&&(r="image/png"),n.precision)o=Math.round(e.getRenderWidth()*n.precision),a=Math.round(o/e.getAspectRatio(t));else if(n.width&&n.height)o=n.width,a=n.height;else if(n.width&&!n.height)o=n.width,a=Math.round(o/e.getAspectRatio(t));else if(n.height&&!n.width)a=n.height,o=Math.round(a*e.getAspectRatio(t));else{if(isNaN(n))return void p.a.Error("Invalid 'size' parameter !");a=n,o=n}fe.h._ScreenshotCanvas||(fe.h._ScreenshotCanvas=document.createElement("canvas")),fe.h._ScreenshotCanvas.width=o,fe.h._ScreenshotCanvas.height=a;var s=fe.h._ScreenshotCanvas.getContext("2d"),c=e.getRenderWidth()/e.getRenderHeight(),l=o,u=l/c;u>a&&(l=(u=a)*c);var h=Math.max(0,o-l)/2,d=Math.max(0,a-u)/2,f=e.getRenderingCanvas();s&&f&&s.drawImage(f,h,d,l,u),fe.h.EncodeScreenshotCanvasData(i,r)},e.CreateScreenshotUsingRenderTarget=function(e,t,n,i,r,o,a,s){var c,l;if(void 0===r&&(r="image/png"),void 0===o&&(o=1),void 0===a&&(a=!1),n.precision)c=Math.round(e.getRenderWidth()*n.precision),l=Math.round(c/e.getAspectRatio(t)),n={width:c,height:l};else if(n.width&&n.height)c=n.width,l=n.height;else if(n.width&&!n.height)c=n.width,l=Math.round(c/e.getAspectRatio(t)),n={width:c,height:l};else if(n.height&&!n.width)l=n.height,n={width:c=Math.round(l*e.getAspectRatio(t)),height:l};else{if(isNaN(n))return void p.a.Error("Invalid 'size' parameter !");l=n,c=n}var u=t.getScene(),h=null;u.activeCamera!==t&&(h=u.activeCamera,u.activeCamera=t);var d=e.getRenderingCanvas();if(d){var f={width:d.width,height:d.height};e.setSize(c,l),u.render();var g=new en.a("screenShot",n,u,!1,!1,m.a.TEXTURETYPE_UNSIGNED_INT,!1,Kt.a.NEAREST_SAMPLINGMODE);g.renderList=null,g.samples=o,a&&g.addPostProcess(new Ds("antialiasing",1,u.activeCamera)),g.onAfterRenderObservable.add((function(){fe.h.DumpFramebuffer(c,l,e,i,r,s)})),u.incrementRenderId(),u.resetCachedMaterial(),g.render(!0),g.dispose(),h&&(u.activeCamera=h),e.setSize(f.width,f.height),t.getProjectionMatrix(!0)}else p.a.Error("No rendering canvas found !")},e}();fe.h.CreateScreenshot=El.CreateScreenshot,fe.h.CreateScreenshotUsingRenderTarget=El.CreateScreenshotUsingRenderTarget,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"}(zc||(zc={})),n.d(t,"AbstractScene",(function(){return i.a})),n.d(t,"Action",(function(){return s})),n.d(t,"ActionEvent",(function(){return c.a})),n.d(t,"ActionManager",(function(){return M})),n.d(t,"Condition",(function(){return u})),n.d(t,"ValueCondition",(function(){return h})),n.d(t,"PredicateCondition",(function(){return d})),n.d(t,"StateCondition",(function(){return f})),n.d(t,"SwitchBooleanAction",(function(){return g})),n.d(t,"SetStateAction",(function(){return _})),n.d(t,"SetValueAction",(function(){return v})),n.d(t,"IncrementValueAction",(function(){return b})),n.d(t,"PlayAnimationAction",(function(){return y})),n.d(t,"StopAnimationAction",(function(){return x})),n.d(t,"DoNothingAction",(function(){return C})),n.d(t,"CombineAction",(function(){return E})),n.d(t,"ExecuteCodeAction",(function(){return T})),n.d(t,"SetParentAction",(function(){return S})),n.d(t,"PlaySoundAction",(function(){return O})),n.d(t,"StopSoundAction",(function(){return R})),n.d(t,"InterpolateValueAction",(function(){return I})),n.d(t,"Animatable",(function(){return L.a})),n.d(t,"_IAnimationState",(function(){return w.b})),n.d(t,"Animation",(function(){return w.a})),n.d(t,"TargetedAnimation",(function(){return D.b})),n.d(t,"AnimationGroup",(function(){return D.a})),n.d(t,"AnimationPropertiesOverride",(function(){return N})),n.d(t,"EasingFunction",(function(){return F})),n.d(t,"CircleEase",(function(){return k})),n.d(t,"BackEase",(function(){return B})),n.d(t,"BounceEase",(function(){return z})),n.d(t,"CubicEase",(function(){return V})),n.d(t,"ElasticEase",(function(){return U})),n.d(t,"ExponentialEase",(function(){return G})),n.d(t,"PowerEase",(function(){return H})),n.d(t,"QuadraticEase",(function(){return j})),n.d(t,"QuarticEase",(function(){return W})),n.d(t,"QuinticEase",(function(){return X})),n.d(t,"SineEase",(function(){return Y})),n.d(t,"BezierCurveEase",(function(){return K})),n.d(t,"RuntimeAnimation",(function(){return Q.a})),n.d(t,"AnimationEvent",(function(){return q.a})),n.d(t,"AnimationKeyInterpolation",(function(){return Z.a})),n.d(t,"AnimationRange",(function(){return J.a})),n.d(t,"KeepAssets",(function(){return $.b})),n.d(t,"AssetContainer",(function(){return $.a})),n.d(t,"Analyser",(function(){return te})),n.d(t,"AudioEngine",(function(){return ne})),n.d(t,"AudioSceneComponent",(function(){return se})),n.d(t,"Sound",(function(){return ie.a})),n.d(t,"SoundTrack",(function(){return re})),n.d(t,"WeightedSound",(function(){return ce.a})),n.d(t,"AutoRotationBehavior",(function(){return he})),n.d(t,"BouncingBehavior",(function(){return de})),n.d(t,"FramingBehavior",(function(){return pe})),n.d(t,"PointerDragBehavior",(function(){return Ae})),n.d(t,"AttachToBoxBehavior",(function(){return ge})),n.d(t,"FadeInOutBehavior",(function(){return _e.a})),n.d(t,"MultiPointerScaleBehavior",(function(){return Pe})),n.d(t,"SixDofDragBehavior",(function(){return Oe})),n.d(t,"Bone",(function(){return Re.a})),n.d(t,"BoneIKController",(function(){return we})),n.d(t,"BoneLookController",(function(){return Ie})),n.d(t,"Skeleton",(function(){return Le.a})),n.d(t,"CameraInputTypes",(function(){return Ne.a})),n.d(t,"CameraInputsManager",(function(){return Ne.b})),n.d(t,"Camera",(function(){return Ce.a})),n.d(t,"TargetCamera",(function(){return lt.a})),n.d(t,"FreeCamera",(function(){return ut.a})),n.d(t,"FreeCameraInputsManager",(function(){return $e.a})),n.d(t,"TouchCamera",(function(){return dt})),n.d(t,"ArcRotateCamera",(function(){return ft})),n.d(t,"ArcRotateCameraInputsManager",(function(){return Xe})),n.d(t,"DeviceOrientationCamera",(function(){return pt})),n.d(t,"FlyCamera",(function(){return gt})),n.d(t,"FlyCameraInputsManager",(function(){return mt})),n.d(t,"FollowCamera",(function(){return bt})),n.d(t,"ArcFollowCamera",(function(){return yt})),n.d(t,"GamepadCamera",(function(){return Rt})),n.d(t,"UniversalCamera",(function(){return Ot})),n.d(t,"VirtualJoysticksCamera",(function(){return Xt})),n.d(t,"ArcRotateCameraGamepadInput",(function(){return ze})),n.d(t,"ArcRotateCameraKeyboardMoveInput",(function(){return Ue})),n.d(t,"ArcRotateCameraMouseWheelInput",(function(){return He})),n.d(t,"ArcRotateCameraPointersInput",(function(){return We})),n.d(t,"ArcRotateCameraVRDeviceOrientationInput",(function(){return Ye})),n.d(t,"FlyCameraKeyboardInput",(function(){return Ke})),n.d(t,"FlyCameraMouseInput",(function(){return Qe})),n.d(t,"FollowCameraKeyboardMoveInput",(function(){return qe})),n.d(t,"FollowCameraMouseWheelInput",(function(){return Ze})),n.d(t,"FollowCameraPointersInput",(function(){return Je})),n.d(t,"FreeCameraDeviceOrientationInput",(function(){return et})),n.d(t,"FreeCameraGamepadInput",(function(){return tt})),n.d(t,"FreeCameraKeyboardMoveInput",(function(){return it.a})),n.d(t,"FreeCameraMouseInput",(function(){return rt.a})),n.d(t,"FreeCameraTouchInput",(function(){return ot.a})),n.d(t,"FreeCameraVirtualJoystickInput",(function(){return ct})),n.d(t,"AnaglyphArcRotateCamera",(function(){return Ft})),n.d(t,"AnaglyphFreeCamera",(function(){return kt})),n.d(t,"AnaglyphGamepadCamera",(function(){return Bt})),n.d(t,"AnaglyphUniversalCamera",(function(){return zt})),n.d(t,"StereoscopicArcRotateCamera",(function(){return Gt})),n.d(t,"StereoscopicFreeCamera",(function(){return Ht})),n.d(t,"StereoscopicGamepadCamera",(function(){return jt})),n.d(t,"StereoscopicUniversalCamera",(function(){return Wt})),n.d(t,"VRCameraMetrics",(function(){return Yt})),n.d(t,"VRDeviceOrientationArcRotateCamera",(function(){return rn})),n.d(t,"VRDeviceOrientationFreeCamera",(function(){return on})),n.d(t,"VRDeviceOrientationGamepadCamera",(function(){return an})),n.d(t,"OnAfterEnteringVRObservableEvent",(function(){return Sn})),n.d(t,"VRExperienceHelper",(function(){return An})),n.d(t,"WebVRFreeCamera",(function(){return cn})),n.d(t,"WebXRCamera",(function(){return Pn})),n.d(t,"WebXREnterExitUIButton",(function(){return wn})),n.d(t,"WebXREnterExitUIOptions",(function(){return In})),n.d(t,"WebXREnterExitUI",(function(){return Ln})),n.d(t,"WebXRState",(function(){return yn})),n.d(t,"WebXRExperienceHelper",(function(){return Rn})),n.d(t,"WebXRController",(function(){return Dn})),n.d(t,"WebXRInput",(function(){return Nn})),n.d(t,"WebXRManagedOutputCanvas",(function(){return Fn})),n.d(t,"WebXRSessionManager",(function(){return Mn})),n.d(t,"Collider",(function(){return Bn})),n.d(t,"DefaultCollisionCoordinator",(function(){return zn})),n.d(t,"PickingInfo",(function(){return ye.a})),n.d(t,"IntersectionInfo",(function(){return xe.a})),n.d(t,"_MeshCollisionData",(function(){return Vn.a})),n.d(t,"BoundingBox",(function(){return Un.a})),n.d(t,"BoundingInfo",(function(){return Gn.a})),n.d(t,"BoundingSphere",(function(){return Hn.a})),n.d(t,"Ray",(function(){return Ee})),n.d(t,"Octree",(function(){return Xn})),n.d(t,"OctreeBlock",(function(){return Wn})),n.d(t,"OctreeSceneComponent",(function(){return Yn})),n.d(t,"AxesViewer",(function(){return Jn})),n.d(t,"BoneAxesViewer",(function(){return $n})),n.d(t,"DebugLayer",(function(){return ei})),n.d(t,"PhysicsViewer",(function(){return li})),n.d(t,"RayHelper",(function(){return di})),n.d(t,"SkeletonViewer",(function(){return fi})),n.d(t,"InstancingAttributeInfo",(function(){return ee.d})),n.d(t,"DepthTextureCreationOptions",(function(){return ee.a})),n.d(t,"EngineCapabilities",(function(){return ee.c})),n.d(t,"Engine",(function(){return ee.b})),n.d(t,"Constants",(function(){return m.a})),n.d(t,"EngineStore",(function(){return A.a})),n.d(t,"NullEngineOptions",(function(){return pi.b})),n.d(t,"NullEngine",(function(){return pi.a})),n.d(t,"WebGLPipelineContext",(function(){return _i.a})),n.d(t,"_OcclusionDataStorage",(function(){return gi})),n.d(t,"_forceTransformFeedbackToBundle",(function(){return!0})),n.d(t,"KeyboardEventTypes",(function(){return Ve.a})),n.d(t,"KeyboardInfo",(function(){return Ve.b})),n.d(t,"KeyboardInfoPre",(function(){return Ve.c})),n.d(t,"PointerEventTypes",(function(){return le.a})),n.d(t,"PointerInfoBase",(function(){return le.c})),n.d(t,"PointerInfoPre",(function(){return le.d})),n.d(t,"PointerInfo",(function(){return le.b})),n.d(t,"ClipboardEventTypes",(function(){return vi.a})),n.d(t,"ClipboardInfo",(function(){return vi.b})),n.d(t,"DaydreamController",(function(){return yi})),n.d(t,"GearVRController",(function(){return xi})),n.d(t,"GenericController",(function(){return Ci})),n.d(t,"OculusTouchController",(function(){return Ei})),n.d(t,"PoseEnabledControllerType",(function(){return vt})),n.d(t,"PoseEnabledControllerHelper",(function(){return Tt})),n.d(t,"PoseEnabledController",(function(){return St})),n.d(t,"ViveController",(function(){return Ti})),n.d(t,"WebVRController",(function(){return ln})),n.d(t,"WindowsMotionController",(function(){return Ai})),n.d(t,"StickValues",(function(){return Fe})),n.d(t,"Gamepad",(function(){return ke})),n.d(t,"GenericPad",(function(){return Be})),n.d(t,"GamepadManager",(function(){return Pt})),n.d(t,"GamepadSystemSceneComponent",(function(){return Mt})),n.d(t,"Xbox360Button",(function(){return Ct})),n.d(t,"Xbox360Dpad",(function(){return Et})),n.d(t,"Xbox360Pad",(function(){return At})),n.d(t,"AxisDragGizmo",(function(){return Zn})),n.d(t,"AxisScaleGizmo",(function(){return Pi})),n.d(t,"BoundingBoxGizmo",(function(){return Mi})),n.d(t,"Gizmo",(function(){return qn})),n.d(t,"GizmoManager",(function(){return Di})),n.d(t,"PlaneRotationGizmo",(function(){return Oi})),n.d(t,"PositionGizmo",(function(){return wi})),n.d(t,"RotationGizmo",(function(){return Ri})),n.d(t,"ScaleGizmo",(function(){return Li})),n.d(t,"LightGizmo",(function(){return Bi})),n.d(t,"EnvironmentHelper",(function(){return rr})),n.d(t,"PhotoDome",(function(){return or})),n.d(t,"_forceSceneHelpersToBundle",(function(){return!0})),n.d(t,"VideoDome",(function(){return xr})),n.d(t,"EngineInstrumentation",(function(){return Cr})),n.d(t,"SceneInstrumentation",(function(){return Er})),n.d(t,"_TimeToken",(function(){return mi})),n.d(t,"Layer",(function(){return Fr.a})),n.d(t,"EffectLayer",(function(){return Mr})),n.d(t,"EffectLayerSceneComponent",(function(){return Or})),n.d(t,"GlowLayer",(function(){return Ir})),n.d(t,"HighlightLayer",(function(){return Nr})),n.d(t,"LayerSceneComponent",(function(){return kr.a})),n.d(t,"LensFlare",(function(){return Br})),n.d(t,"LensFlareSystem",(function(){return Ur})),n.d(t,"LensFlareSystemSceneComponent",(function(){return Gr})),n.d(t,"Light",(function(){return Hr.a})),n.d(t,"ShadowLight",(function(){return jr.a})),n.d(t,"DirectionalLight",(function(){return Ni.a})),n.d(t,"HemisphericLight",(function(){return sn.a})),n.d(t,"PointLight",(function(){return qr.a})),n.d(t,"SpotLight",(function(){return ki.a})),n.d(t,"ShadowGenerator",(function(){return Kr})),n.d(t,"ShadowGeneratorSceneComponent",(function(){return Qr})),n.d(t,"DefaultLoadingScreen",(function(){return Zr})),n.d(t,"SceneLoaderProgressEvent",(function(){return bi.b})),n.d(t,"SceneLoader",(function(){return bi.a})),n.d(t,"SceneLoaderFlags",(function(){return vo.a})),n.d(t,"_BabylonLoaderRegistered",(function(){return!0})),n.d(t,"StandardMaterialDefines",(function(){return hn.b})),n.d(t,"StandardMaterial",(function(){return hn.a})),n.d(t,"ColorCurves",(function(){return bo.a})),n.d(t,"EffectFallbacks",(function(){return Lt.c})),n.d(t,"EffectCreationOptions",(function(){return Lt.b})),n.d(t,"Effect",(function(){return Lt.a})),n.d(t,"FresnelParameters",(function(){return yo})),n.d(t,"ImageProcessingConfigurationDefines",(function(){return un.b})),n.d(t,"ImageProcessingConfiguration",(function(){return un.a})),n.d(t,"Material",(function(){return Tr.a})),n.d(t,"MaterialDefines",(function(){return Ki.a})),n.d(t,"MaterialHelper",(function(){return Yi.a})),n.d(t,"MultiMaterial",(function(){return $r.a})),n.d(t,"PushMaterial",(function(){return Qi.a})),n.d(t,"ShaderMaterial",(function(){return So.a})),n.d(t,"DynamicTexture",(function(){return dn.a})),n.d(t,"Texture",(function(){return Kt.a})),n.d(t,"UniformBuffer",(function(){return $t.a})),n.d(t,"MaterialFlags",(function(){return qi.a})),n.d(t,"BackgroundMaterial",(function(){return ir})),n.d(t,"PBRMaterialDefines",(function(){return xo.b})),n.d(t,"PBRBaseMaterial",(function(){return xo.a})),n.d(t,"PBRBaseSimpleMaterial",(function(){return Co.a})),n.d(t,"PBRMaterial",(function(){return ar.a})),n.d(t,"PBRMetallicRoughnessMaterial",(function(){return Eo.a})),n.d(t,"PBRSpecularGlossinessMaterial",(function(){return To})),n.d(t,"BaseTexture",(function(){return zi.a})),n.d(t,"ColorGradingTexture",(function(){return Ao})),n.d(t,"CubeTexture",(function(){return Xi.a})),n.d(t,"EquiRectangularCubeTexture",(function(){return Po})),n.d(t,"HDRCubeTexture",(function(){return no})),n.d(t,"InternalTexture",(function(){return Jt.a})),n.d(t,"MirrorTexture",(function(){return Wi})),n.d(t,"MultiRenderTarget",(function(){return Ro})),n.d(t,"RawCubeTexture",(function(){return ko.a})),n.d(t,"RawTexture",(function(){return Bo.a})),n.d(t,"RawTexture3D",(function(){return zo})),n.d(t,"RefractionTexture",(function(){return Vo})),n.d(t,"RenderTargetTexture",(function(){return en.a})),n.d(t,"VideoTexture",(function(){return yr})),n.d(t,"HtmlElementTexture",(function(){return Uo})),n.d(t,"_DDSTextureLoader",(function(){return mr})),n.d(t,"_ENVTextureLoader",(function(){return _r})),n.d(t,"_KTXTextureLoader",(function(){return br})),n.d(t,"_TGATextureLoader",(function(){return Oo})),n.d(t,"CustomProceduralTexture",(function(){return Lo})),n.d(t,"NoiseProceduralTexture",(function(){return No})),n.d(t,"ProceduralTexture",(function(){return wo.a})),n.d(t,"ProceduralTextureSceneComponent",(function(){return Fo.a})),n.d(t,"ToGammaSpace",(function(){return o.u})),n.d(t,"ToLinearSpace",(function(){return o.v})),n.d(t,"Epsilon",(function(){return o.h})),n.d(t,"Color3",(function(){return o.e})),n.d(t,"Color4",(function(){return o.f})),n.d(t,"Vector2",(function(){return o.w})),n.d(t,"Vector3",(function(){return o.x})),n.d(t,"Vector4",(function(){return o.y})),n.d(t,"Size",(function(){return o.r})),n.d(t,"Quaternion",(function(){return o.q})),n.d(t,"Matrix",(function(){return o.j})),n.d(t,"Plane",(function(){return o.n})),n.d(t,"Viewport",(function(){return o.z})),n.d(t,"Frustum",(function(){return o.i})),n.d(t,"Space",(function(){return o.s})),n.d(t,"Axis",(function(){return o.c})),n.d(t,"BezierCurve",(function(){return o.d})),n.d(t,"Orientation",(function(){return o.k})),n.d(t,"Angle",(function(){return o.a})),n.d(t,"Arc2",(function(){return o.b})),n.d(t,"Path2",(function(){return o.l})),n.d(t,"Path3D",(function(){return o.m})),n.d(t,"Curve3",(function(){return o.g})),n.d(t,"PositionNormalVertex",(function(){return o.p})),n.d(t,"PositionNormalTextureVertex",(function(){return o.o})),n.d(t,"Tmp",(function(){return o.t})),n.d(t,"Scalar",(function(){return Ge.a})),n.d(t,"SphericalHarmonics",(function(){return sr.a})),n.d(t,"SphericalPolynomial",(function(){return sr.b})),n.d(t,"AbstractMesh",(function(){return Me.a})),n.d(t,"Buffer",(function(){return gn.a})),n.d(t,"VertexBuffer",(function(){return gn.b})),n.d(t,"CSG",(function(){return Qo})),n.d(t,"Geometry",(function(){return Jr.a})),n.d(t,"GroundMesh",(function(){return _n})),n.d(t,"TrailMesh",(function(){return qo})),n.d(t,"InstancedMesh",(function(){return Zo.a})),n.d(t,"LinesMesh",(function(){return ui.b})),n.d(t,"InstancedLinesMesh",(function(){return ui.a})),n.d(t,"_CreationDataStorage",(function(){return ve.b})),n.d(t,"_InstancesBatch",(function(){return ve.c})),n.d(t,"Mesh",(function(){return ve.a})),n.d(t,"VertexData",(function(){return mn.a})),n.d(t,"MeshBuilder",(function(){return sa})),n.d(t,"SimplificationSettings",(function(){return ca})),n.d(t,"SimplificationQueue",(function(){return la})),n.d(t,"SimplificationType",(function(){return oa})),n.d(t,"SimplicationQueueSceneComponent",(function(){return ma})),n.d(t,"Polygon",(function(){return ea.a})),n.d(t,"PolygonMeshBuilder",(function(){return ea.b})),n.d(t,"BaseSubMesh",(function(){return Ho.a})),n.d(t,"SubMesh",(function(){return Ho.b})),n.d(t,"MeshLODLevel",(function(){return ga.a})),n.d(t,"TransformNode",(function(){return Kn.a})),n.d(t,"BoxBuilder",(function(){return ti.a})),n.d(t,"CylinderBuilder",(function(){return xn})),n.d(t,"PlaneBuilder",(function(){return Se.a})),n.d(t,"DataBuffer",(function(){return _a.a})),n.d(t,"WebGLDataBuffer",(function(){return va.a})),n.d(t,"DracoCompression",(function(){return Go.a})),n.d(t,"DiscBuilder",(function(){return Jo})),n.d(t,"RibbonBuilder",(function(){return co})),n.d(t,"SphereBuilder",(function(){return ni})),n.d(t,"HemisphereBuilder",(function(){return Fi})),n.d(t,"TorusBuilder",(function(){return bn})),n.d(t,"TorusKnotBuilder",(function(){return $o})),n.d(t,"LinesBuilder",(function(){return hi})),n.d(t,"PolygonBuilder",(function(){return ta})),n.d(t,"ShapeBuilder",(function(){return lo})),n.d(t,"LatheBuilder",(function(){return na})),n.d(t,"GroundBuilder",(function(){return vn})),n.d(t,"TubeBuilder",(function(){return ia})),n.d(t,"PolyhedronBuilder",(function(){return Ii})),n.d(t,"IcoSphereBuilder",(function(){return ra})),n.d(t,"DecalBuilder",(function(){return aa})),n.d(t,"MorphTarget",(function(){return ba.a})),n.d(t,"MorphTargetManager",(function(){return io.a})),n.d(t,"Node",(function(){return ht.a})),n.d(t,"Database",(function(){return xa})),n.d(t,"BaseParticleSystem",(function(){return Ra})),n.d(t,"GPUParticleSystem",(function(){return Ua})),n.d(t,"Particle",(function(){return wa})),n.d(t,"ParticleHelper",(function(){return Ha})),n.d(t,"ParticleSystem",(function(){return Na})),n.d(t,"_IDoNeedToBeInTheBuild",(function(){return 42})),n.d(t,"ParticleSystemSet",(function(){return Ga})),n.d(t,"SolidParticle",(function(){return ja})),n.d(t,"ModelShape",(function(){return Wa})),n.d(t,"DepthSortedParticle",(function(){return Xa})),n.d(t,"SolidParticleSystem",(function(){return Ka})),n.d(t,"SubEmitterType",(function(){return ya})),n.d(t,"SubEmitter",(function(){return Ia})),n.d(t,"BoxParticleEmitter",(function(){return Ca})),n.d(t,"ConeParticleEmitter",(function(){return Ea})),n.d(t,"CylinderParticleEmitter",(function(){return Ta})),n.d(t,"CylinderDirectedParticleEmitter",(function(){return Sa})),n.d(t,"HemisphericParticleEmitter",(function(){return Aa})),n.d(t,"PointParticleEmitter",(function(){return Pa})),n.d(t,"SphereParticleEmitter",(function(){return Ma})),n.d(t,"SphereDirectedParticleEmitter",(function(){return Oa})),n.d(t,"PhysicsEngine",(function(){return ro})),n.d(t,"PhysicsEngineSceneComponent",(function(){return Za})),n.d(t,"PhysicsHelper",(function(){return Ja})),n.d(t,"PhysicsRadialExplosionEventOptions",(function(){return is})),n.d(t,"PhysicsUpdraftEventOptions",(function(){return rs})),n.d(t,"PhysicsVortexEventOptions",(function(){return os})),n.d(t,"PhysicsRadialImpulseFalloff",(function(){return Qa})),n.d(t,"PhysicsUpdraftMode",(function(){return qa})),n.d(t,"PhysicsImpostor",(function(){return ci})),n.d(t,"PhysicsJoint",(function(){return ii})),n.d(t,"DistanceJoint",(function(){return ri})),n.d(t,"MotorEnabledJoint",(function(){return oi})),n.d(t,"HingeJoint",(function(){return ai})),n.d(t,"Hinge2Joint",(function(){return si})),n.d(t,"CannonJSPlugin",(function(){return ao})),n.d(t,"AmmoJSPlugin",(function(){return uo})),n.d(t,"OimoJSPlugin",(function(){return so})),n.d(t,"AnaglyphPostProcess",(function(){return Nt})),n.d(t,"BlackAndWhitePostProcess",(function(){return ss})),n.d(t,"BloomEffect",(function(){return fs})),n.d(t,"BloomMergePostProcess",(function(){return ds})),n.d(t,"BlurPostProcess",(function(){return ji})),n.d(t,"ChromaticAberrationPostProcess",(function(){return ms})),n.d(t,"CircleOfConfusionPostProcess",(function(){return _s})),n.d(t,"ColorCorrectionPostProcess",(function(){return bs})),n.d(t,"ConvolutionPostProcess",(function(){return xs})),n.d(t,"DepthOfFieldBlurPostProcess",(function(){return Cs})),n.d(t,"DepthOfFieldEffectBlurLevel",(function(){return Ts})),n.d(t,"DepthOfFieldEffect",(function(){return Ps})),n.d(t,"DepthOfFieldMergePostProcessOptions",(function(){return Ss})),n.d(t,"DepthOfFieldMergePostProcess",(function(){return As})),n.d(t,"DisplayPassPostProcess",(function(){return Os})),n.d(t,"ExtractHighlightsPostProcess",(function(){return us})),n.d(t,"FilterPostProcess",(function(){return ws})),n.d(t,"FxaaPostProcess",(function(){return Ds})),n.d(t,"GrainPostProcess",(function(){return Fs})),n.d(t,"HighlightsPostProcess",(function(){return Bs})),n.d(t,"ImageProcessingPostProcess",(function(){return pn})),n.d(t,"MotionBlurPostProcess",(function(){return js})),n.d(t,"PassPostProcess",(function(){return wt.b})),n.d(t,"PassCubePostProcess",(function(){return wt.a})),n.d(t,"PostProcess",(function(){return It.a})),n.d(t,"PostProcessManager",(function(){return Ws.a})),n.d(t,"RefractionPostProcess",(function(){return Ys})),n.d(t,"SharpenPostProcess",(function(){return Qs})),n.d(t,"StereoscopicInterlacePostProcess",(function(){return Ut})),n.d(t,"TonemappingOperator",(function(){return hc})),n.d(t,"TonemapPostProcess",(function(){return dc})),n.d(t,"VolumetricLightScatteringPostProcess",(function(){return gc})),n.d(t,"VRDistortionCorrectionPostProcess",(function(){return qt})),n.d(t,"VRMultiviewToSingleviewPostProcess",(function(){return nn})),n.d(t,"PostProcessRenderEffect",(function(){return cs})),n.d(t,"PostProcessRenderPipeline",(function(){return qs})),n.d(t,"PostProcessRenderPipelineManager",(function(){return Zs})),n.d(t,"PostProcessRenderPipelineManagerSceneComponent",(function(){return Js})),n.d(t,"DefaultRenderingPipeline",(function(){return $s})),n.d(t,"LensRenderingPipeline",(function(){return nc})),n.d(t,"SSAO2RenderingPipeline",(function(){return oc})),n.d(t,"SSAORenderingPipeline",(function(){return sc})),n.d(t,"StandardRenderingPipeline",(function(){return lc})),n.d(t,"ReflectionProbe",(function(){return ho})),n.d(t,"BoundingBoxRenderer",(function(){return _c})),n.d(t,"DepthRenderer",(function(){return bc})),n.d(t,"DepthRendererSceneComponent",(function(){return yc})),n.d(t,"EdgesRenderer",(function(){return Tc})),n.d(t,"LineEdgesRenderer",(function(){return Sc})),n.d(t,"GeometryBufferRenderer",(function(){return Us})),n.d(t,"GeometryBufferRendererSceneComponent",(function(){return Gs})),n.d(t,"OutlineRenderer",(function(){return Mc})),n.d(t,"RenderingGroup",(function(){return Oc.a})),n.d(t,"RenderingGroupInfo",(function(){return Rc.a})),n.d(t,"RenderingManager",(function(){return Rc.b})),n.d(t,"UtilityLayerRenderer",(function(){return Qn.a})),n.d(t,"Scene",(function(){return ae.a})),n.d(t,"SceneComponentConstants",(function(){return oe.a})),n.d(t,"Stage",(function(){return oe.b})),n.d(t,"Sprite",(function(){return wc})),n.d(t,"SpriteManager",(function(){return Fc})),n.d(t,"SpriteSceneComponent",(function(){return Ic})),n.d(t,"_AlphaState",(function(){return kc.a})),n.d(t,"_DepthCullingState",(function(){return kc.b})),n.d(t,"_StencilState",(function(){return kc.c})),n.d(t,"EventState",(function(){return r.a})),n.d(t,"Observer",(function(){return r.d})),n.d(t,"MultiObserver",(function(){return r.b})),n.d(t,"Observable",(function(){return r.c})),n.d(t,"ColorGradient",(function(){return fe.c})),n.d(t,"Color3Gradient",(function(){return fe.b})),n.d(t,"FactorGradient",(function(){return fe.d})),n.d(t,"LoadFileError",(function(){return fe.e})),n.d(t,"RetryStrategy",(function(){return fe.g})),n.d(t,"Tools",(function(){return fe.h})),n.d(t,"PerfCounter",(function(){return fe.f})),n.d(t,"className",(function(){return fe.i})),n.d(t,"AsyncLoop",(function(){return fe.a})),n.d(t,"AndOrNotEvaluator",(function(){return Bc.a})),n.d(t,"AssetTaskState",(function(){return Nc})),n.d(t,"AbstractAssetTask",(function(){return Vc})),n.d(t,"AssetsProgressEvent",(function(){return Uc})),n.d(t,"MeshAssetTask",(function(){return Gc})),n.d(t,"TextFileAssetTask",(function(){return Hc})),n.d(t,"BinaryFileAssetTask",(function(){return jc})),n.d(t,"ImageAssetTask",(function(){return Wc})),n.d(t,"TextureAssetTask",(function(){return Xc})),n.d(t,"CubeTextureAssetTask",(function(){return Yc})),n.d(t,"HDRCubeTextureAssetTask",(function(){return Kc})),n.d(t,"EquiRectangularCubeTextureAssetTask",(function(){return Qc})),n.d(t,"AssetsManager",(function(){return qc})),n.d(t,"DDSTools",(function(){return pr})),n.d(t,"expandToProperty",(function(){return De.b})),n.d(t,"serialize",(function(){return De.c})),n.d(t,"serializeAsTexture",(function(){return De.m})),n.d(t,"serializeAsColor3",(function(){return De.e})),n.d(t,"serializeAsFresnelParameters",(function(){return De.h})),n.d(t,"serializeAsVector2",(function(){return De.n})),n.d(t,"serializeAsVector3",(function(){return De.o})),n.d(t,"serializeAsMeshReference",(function(){return De.k})),n.d(t,"serializeAsColorCurves",(function(){return De.g})),n.d(t,"serializeAsColor4",(function(){return De.f})),n.d(t,"serializeAsImageProcessingConfiguration",(function(){return De.i})),n.d(t,"serializeAsQuaternion",(function(){return De.l})),n.d(t,"serializeAsMatrix",(function(){return De.j})),n.d(t,"serializeAsCameraReference",(function(){return De.d})),n.d(t,"SerializationHelper",(function(){return De.a})),n.d(t,"Deferred",(function(){return Zc.a})),n.d(t,"EnvironmentTextureTools",(function(){return gr.a})),n.d(t,"MeshExploder",(function(){return Jc})),n.d(t,"FilesInput",(function(){return el})),n.d(t,"KhronosTextureContainer",(function(){return vr})),n.d(t,"PerformanceMonitor",(function(){return tl.a})),n.d(t,"RollingAverage",(function(){return tl.b})),n.d(t,"PromisePolyfill",(function(){return nl.a})),n.d(t,"SceneOptimization",(function(){return il})),n.d(t,"TextureOptimization",(function(){return rl})),n.d(t,"HardwareScalingOptimization",(function(){return ol})),n.d(t,"ShadowsOptimization",(function(){return al})),n.d(t,"PostProcessesOptimization",(function(){return sl})),n.d(t,"LensFlaresOptimization",(function(){return cl})),n.d(t,"CustomOptimization",(function(){return ll})),n.d(t,"ParticlesOptimization",(function(){return ul})),n.d(t,"RenderTargetsOptimization",(function(){return hl})),n.d(t,"MergeMeshesOptimization",(function(){return dl})),n.d(t,"SceneOptimizerOptions",(function(){return fl})),n.d(t,"SceneOptimizer",(function(){return pl})),n.d(t,"SceneSerializer",(function(){return vl})),n.d(t,"SmartArray",(function(){return jn.a})),n.d(t,"SmartArrayNoDuplicate",(function(){return jn.b})),n.d(t,"StringDictionary",(function(){return at.a})),n.d(t,"Tags",(function(){return bl.a})),n.d(t,"TextureTools",(function(){return yl.a})),n.d(t,"TGATools",(function(){return Mo})),n.d(t,"VideoRecorder",(function(){return xl})),n.d(t,"JoystickAxis",(function(){return nt})),n.d(t,"VirtualJoystick",(function(){return st})),n.d(t,"WorkerPool",(function(){return Cl.a})),n.d(t,"Logger",(function(){return p.a})),n.d(t,"_TypeStore",(function(){return a.a})),n.d(t,"FilesInputStore",(function(){return $c.a})),n.d(t,"DeepCopier",(function(){return P.a})),n.d(t,"PivotTools",(function(){return Te})),n.d(t,"PrecisionDate",(function(){return ue.a})),n.d(t,"ScreenshotTools",(function(){return El})),n.d(t,"WebRequest",(function(){return Io.a})),n.d(t,"InspectableType",(function(){return zc})),n.d(t,"CubeMapToSphericalPolynomialTools",(function(){return cr.a})),n.d(t,"HDRTools",(function(){return to})),n.d(t,"PanoramaToCubeMapTools",(function(){return eo}))},function(e,t,n){"use strict";n.d(t,"b",(function(){return A})),n.d(t,"c",(function(){return M})),n.d(t,"a",(function(){return R}));var i=n(1),r=n(7),o=n(5),a=n(46),s=n(41),c=n(0),l=n(30),u=n(3),h=n(14),d=n(58),f=n(28),p=n(61),m=n(54),g=n(16),_=n(77),v=n(73),b=n(4),y=n(2),x=n(9),C=n(26),E=n(22),T=n(17),S=n(165),A=function(){},P=function(){this.visibleInstances={},this.batchCache=new M,this.instancesBufferSize=2048},M=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array,this.hardwareInstancedRendering=new Array},O=function(){this._areNormalsFrozen=!1,this._source=null,this.meshMap=null,this._preActivateId=-1,this._LODLevels=new Array,this._morphTargetManager=null},R=function(e){function t(n,i,r,o,c,l){void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===l&&(l=!0);var u=e.call(this,n,i)||this;if(u._internalMeshDataInfo=new O,u.delayLoadState=b.a.DELAYLOADSTATE_NONE,u.instances=new Array,u._creationDataStorage=null,u._geometry=null,u._instanceDataStorage=new P,u._effectiveMaterial=null,u._shouldGenerateFlatShading=!1,u._originalBuilderSideOrientation=t.DEFAULTSIDE,u.overrideMaterialSideOrientation=null,i=u.getScene(),o){if(o._geometry&&o._geometry.applyToMesh(u),a.a.DeepCopy(o,u,["name","material","skeleton","instances","parent","uniqueId","source","metadata","hasLODLevels","geometry","isBlocked","areNormalsFrozen","onBeforeDrawObservable","onBeforeRenderObservable","onAfterRenderObservable","onBeforeDraw","onAfterWorldMatrixUpdateObservable","onCollideObservable","onCollisionPositionChangeObservable","onRebuildObservable","onDisposeObservable"],["_poseMatrix"]),u._internalMeshDataInfo._source=o,i.useClonedMeshhMap&&(o._internalMeshDataInfo.meshMap||(o._internalMeshDataInfo.meshMap={}),o._internalMeshDataInfo.meshMap[u.uniqueId]=u),u._originalBuilderSideOrientation=o._originalBuilderSideOrientation,u._creationDataStorage=o._creationDataStorage,o._ranges){var h=o._ranges;for(var n in h)h.hasOwnProperty(n)&&h[n]&&u.createAnimationRange(n,h[n].from,h[n].to)}var d;if(o.metadata&&o.metadata.clone?u.metadata=o.metadata.clone():u.metadata=o.metadata,s.a&&s.a.HasTags(o)&&s.a.AddTagsTo(u,s.a.GetTags(o,!0)),u.parent=o.parent,u.setPivotMatrix(o.getPivotMatrix()),u.id=n+"."+o.id,u.material=o.material,!c)for(var f=o.getDescendants(!0),p=0;p0},enumerable:!0,configurable:!0}),t.prototype.getLODLevels=function(){return this._internalMeshDataInfo._LODLevels},t.prototype._sortLODLevels=function(){this._internalMeshDataInfo._LODLevels.sort((function(e,t){return e.distancet.distance?-1:0}))},t.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return x.a.Warn("You cannot use a mesh as LOD level twice"),this;var n=new S.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;nr)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,i._LODLevels[i._LODLevels.length-1].mesh),this;for(var o=0;o0;this.computeWorldMatrix();var a=this.material||r.defaultMaterial;if(a)if(a._storeEffectOnSubMeshes)for(var s=0,c=this.subMeshes;s0){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;o=i){r=!0;break}if(s.verticesStart+s.verticesCount>=t){r=!0;break}}if(!r)return this.subMeshes[0]}return this.releaseSubMeshes(),new p.b(0,0,t,0,this.getTotalIndices(),this)},t.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),n=t/e|0,i=0;n%3!=0;)n++;this.releaseSubMeshes();for(var r=0;r=t);r++)p.b.CreateFromIndices(0,i,Math.min(n,t-i),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 h.a;r.set(t,e);var o=this.getScene();new d.a(d.a.RandomId(),o,r,n,this)}return this},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){return this._geometry||(this._geometry=d.a.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),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(u.b.PositionKind);if(!n)return this;if(e(n),this.updateVerticesData(u.b.PositionKind,n,!1,!1),t){var i=this.getIndices(),r=this.getVerticesData(u.b.NormalKind);if(!r)return this;h.a.ComputeNormals(n,i,r),this.updateVerticesData(u.b.NormalKind,r,!1,!1)}return this},t.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;var e=this._geometry,t=this._geometry.copy(d.a.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},t.prototype.setIndices=function(e,t,n){if(void 0===t&&(t=null),void 0===n&&(n=!1),this._geometry)this._geometry.setIndices(e,t,n);else{var i=new h.a;i.indices=e;var r=this.getScene();new d.a(d.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._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._geometry._bind(t,i),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,n):t==g.a.WireFrameFillMode?i.drawElementsType(t,0,e._linesIndexCount,n):i.drawElementsType(t,e.indexStart,e.indexCount,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){if(this._instanceDataStorage.isFrozen&&this._instanceDataStorage.previousBatch)return this._instanceDataStorage.previousBatch;var t=this.getScene(),n=t._isInIntermediateRendering(),i=n?this._internalAbstractMeshDataInfo._onlyForInstancesIntermediate:this._internalAbstractMeshDataInfo._onlyForInstances,r=this._instanceDataStorage.batchCache;if(r.mustReturn=!1,r.renderSelf[e]=!i&&this.isEnabled()&&this.isVisible,r.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances){var o=this._instanceDataStorage.visibleInstances,a=t.getRenderId(),s=n?o.intermediateDefaultRenderId:o.defaultRenderId;r.visibleInstances[e]=o[a],!r.visibleInstances[e]&&s&&(r.visibleInstances[e]=o[s])}return r.hardwareInstancedRendering[e]=this._instanceDataStorage.hardwareInstancedRendering&&null!==r.visibleInstances[e]&&void 0!==r.visibleInstances[e],this._instanceDataStorage.previousBatch=r,r},t.prototype._renderWithInstances=function(e,t,n,i,r){var o=n.visibleInstances[e._id];if(!o)return this;for(var a=this._instanceDataStorage,s=a.instancesBufferSize,c=a.instancesBuffer,l=16*(o.length+1)*4;a.instancesBufferSizeh&&i++,0!==m&&f++,d+=m,h=m}if(c[f]++,f>o&&(o=f),0===d)r++;else{var g=1/d,_=0;for(p=0;p.001&&a++}}var v=this.skeleton.bones.length,b=this.getVerticesData(u.b.MatricesIndicesKind),y=this.getVerticesData(u.b.MatricesIndicesExtraKind),x=0;for(l=0;l=v||C<0)&&x++}return{skinned:!0,valid:0===r&&0===a&&0===x,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 = "+x}},t.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===b.a.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=b.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.h.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=b.a.DELAYLOADSTATE_LOADED,e._removePendingData(t)}),(function(){}),e.offlineProvider,n),this},t.prototype.isInFrustum=function(t){return this.delayLoadState!==b.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(u.b.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var n,i=this.getVerticesData(u.b.PositionKind),r=new Array;for(n=0;n-1&&(r.morphTargetManager=n.getMorphTargetManagerById(e.morphTargetManagerId)),e.skeletonId>-1&&(r.skeleton=n.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var o=0;o4,h=l?this.getVerticesData(u.b.MatricesIndicesExtraKind):null,d=l?this.getVerticesData(u.b.MatricesWeightsExtraKind):null,f=e.getTransformMatrices(this),p=c.x.Zero(),m=new c.j,g=new c.j,_=0,v=0;v0&&(c.j.FromFloat32ArrayToRefScaled(f,Math.floor(16*o[_+s]),b,g),m.addToSelf(g));if(l)for(s=0;s<4;s++)(b=d[_+s])>0&&(c.j.FromFloat32ArrayToRefScaled(f,Math.floor(16*h[_+s]),b,g),m.addToSelf(g));c.x.TransformCoordinatesFromFloatsToRef(t._sourcePositions[v],t._sourcePositions[v+1],t._sourcePositions[v+2],m,p),p.toArray(i,v),c.x.TransformNormalFromFloatsToRef(t._sourceNormals[v],t._sourceNormals[v+1],t._sourceNormals[v+2],m,p),p.toArray(r,v),m.reset()}return this.updateVerticesData(u.b.PositionKind,i),this.updateVerticesData(u.b.NormalKind,r),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:c.x.Zero(),max:c.x.Zero()}},t.Center=function(e){var n=e instanceof Array?t.MinMax(e):e;return c.x.Center(n.min,n.max)},t.MergeMeshes=function(e,n,i,r,o,a){var s;if(void 0===n&&(n=!0),!i){var c=0;for(s=0;s65536)return x.a.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}if(a){var l,u,d=null;o=!1}var f,m=new Array,g=new Array,v=null,b=new Array,y=null;for(s=0;s0?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.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.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.TwoPi=2*Math.PI,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(0),r=n(3),o=n(22),a=function(){function e(){}return e.prototype.set=function(e,t){switch(t){case r.b.PositionKind:this.positions=e;break;case r.b.NormalKind:this.normals=e;break;case r.b.TangentKind:this.tangents=e;break;case r.b.UVKind:this.uvs=e;break;case r.b.UV2Kind:this.uvs2=e;break;case r.b.UV3Kind:this.uvs3=e;break;case r.b.UV4Kind:this.uvs4=e;break;case r.b.UV5Kind:this.uvs5=e;break;case r.b.UV6Kind:this.uvs6=e;break;case r.b.ColorKind:this.colors=e;break;case r.b.MatricesIndicesKind:this.matricesIndices=e;break;case r.b.MatricesWeightsKind:this.matricesWeights=e;break;case r.b.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case r.b.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}},e.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},e.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},e.prototype.updateMesh=function(e){return this._update(e),this},e.prototype.updateGeometry=function(e){return this._update(e),this},e.prototype._applyTo=function(e,t){return void 0===t&&(t=!1),this.positions&&e.setVerticesData(r.b.PositionKind,this.positions,t),this.normals&&e.setVerticesData(r.b.NormalKind,this.normals,t),this.tangents&&e.setVerticesData(r.b.TangentKind,this.tangents,t),this.uvs&&e.setVerticesData(r.b.UVKind,this.uvs,t),this.uvs2&&e.setVerticesData(r.b.UV2Kind,this.uvs2,t),this.uvs3&&e.setVerticesData(r.b.UV3Kind,this.uvs3,t),this.uvs4&&e.setVerticesData(r.b.UV4Kind,this.uvs4,t),this.uvs5&&e.setVerticesData(r.b.UV5Kind,this.uvs5,t),this.uvs6&&e.setVerticesData(r.b.UV6Kind,this.uvs6,t),this.colors&&e.setVerticesData(r.b.ColorKind,this.colors,t),this.matricesIndices&&e.setVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t),this.matricesWeights&&e.setVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t),this.matricesIndicesExtra&&e.setVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),this.matricesWeightsExtra&&e.setVerticesData(r.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),this.indices?e.setIndices(this.indices,null,t):e.setIndices([],null),this},e.prototype._update=function(e,t,n){return this.positions&&e.updateVerticesData(r.b.PositionKind,this.positions,t,n),this.normals&&e.updateVerticesData(r.b.NormalKind,this.normals,t,n),this.tangents&&e.updateVerticesData(r.b.TangentKind,this.tangents,t,n),this.uvs&&e.updateVerticesData(r.b.UVKind,this.uvs,t,n),this.uvs2&&e.updateVerticesData(r.b.UV2Kind,this.uvs2,t,n),this.uvs3&&e.updateVerticesData(r.b.UV3Kind,this.uvs3,t,n),this.uvs4&&e.updateVerticesData(r.b.UV4Kind,this.uvs4,t,n),this.uvs5&&e.updateVerticesData(r.b.UV5Kind,this.uvs5,t,n),this.uvs6&&e.updateVerticesData(r.b.UV6Kind,this.uvs6,t,n),this.colors&&e.updateVerticesData(r.b.ColorKind,this.colors,t,n),this.matricesIndices&&e.updateVerticesData(r.b.MatricesIndicesKind,this.matricesIndices,t,n),this.matricesWeights&&e.updateVerticesData(r.b.MatricesWeightsKind,this.matricesWeights,t,n),this.matricesIndicesExtra&&e.updateVerticesData(r.b.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,n),this.matricesWeightsExtra&&e.updateVerticesData(r.b.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,n),this.indices&&e.setIndices(this.indices,null),this},e.prototype.transform=function(e){var t,n=e.m[0]*e.m[5]*e.m[10]<0,r=i.x.Zero();if(this.positions){var o=i.x.Zero();for(t=0;tr.bbSize.y?r.bbSize.x:r.bbSize.y;$=$>r.bbSize.z?$:r.bbSize.z,L=r.subDiv.X*R/r.bbSize.x,D=r.subDiv.Y*R/r.bbSize.y,N=r.subDiv.Z*R/r.bbSize.z,F=r.subDiv.max*r.subDiv.max,r.facetPartitioning.length=0}for(o=0;o0,t.NUM_MORPH_INFLUENCERS=l.numInfluencers):(t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)}return!0},e.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.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=!1,l=!1,u=!1,h=!1,d=!1;if(e.lightsEnabled&&!o)for(var f=0,p=t.lightSources;f0&&(h=!0,g.prepareDefines(n,a))}}if(m.lightmapMode!=c.a.LIGHTMAP_DEFAULT?(u=!0,n["LIGHTMAPEXCLUDED"+a]=!0,n["LIGHTMAPNOSPECULAR"+a]=m.lightmapMode==c.a.LIGHTMAP_SHADOWSONLY):(n["LIGHTMAPEXCLUDED"+a]=!1,n["LIGHTMAPNOSPECULAR"+a]=!1),++a===r)break}n.SPECULARTERM=d,n.SHADOWS=h;for(var v=a;v0&&(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));return r++},e.PrepareAttributesForMorphTargets=function(e,t,n){var r=n.NUM_MORPH_INFLUENCERS;if(r>0&&a.a.LastCreatedEngine)for(var o=a.a.LastCreatedEngine.getCaps().maxVertexAttribs,c=t.morphTargetManager,l=c&&c.supportsNormals&&n.NORMAL,u=c&&c.supportsTangents&&n.TANGENT,h=0;ho&&i.a.Error("Cannot add more vertex attributes for mesh "+t.name)},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&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},e.BindLightShadow=function(e,t,n,i){if(e.shadowEnabled&&t.receiveShadows){var r=e.getShadowGenerator();r&&r.bindShadowLight(n,i)}},e.BindLightProperties=function(e,t,n){e.transferToEffect(t,n+"")},e.BindLights=function(t,n,i,r,a,s){void 0===a&&(a=4),void 0===s&&(s=!1);for(var c=Math.min(n.lightSources.length,a),l=0;l-1){var i=n.getTransformMatrixTexture();t.setTexture("boneSampler",i),t.setFloat("boneTextureWidth",4*(n.bones.length+1))}else{var r=n.getTransformMatrices(e);r&&t.setMatrices("mBones",r)}}},e.BindMorphTargetParameters=function(e,t){var n=e.morphTargetManager;e&&n&&t.setFloatArray("morphTargetInfluences",n.influences)},e.BindLogDepth=function(e,t,n){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(n.activeCamera.maxZ+1)/Math.LN2))},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)}},e._tempFogColor=o.e.Black(),e}()},function(e,t,n){"use strict";var i=n(1),r=n(5),o=n(63),a=n(7),s=n(40),c=n(88),l=n(41),u=n(0),h=n(42),d=n(28),f=n(24),p=n(43),m=n(45),g=n(94),_=n(44),v=n(67),b=n(51),y=n(124),x=n(135),C=n(17),E=n(4),T=n(50),S=n(9),A=n(27),P=n(22),M=n(15),O=n(121),R=n(64),w=function(){function e(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}return Object.defineProperty(e.prototype,"singleClick",{get:function(){return this._singleClick},set:function(e){this._singleClick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"doubleClick",{get:function(){return this._doubleClick},set:function(e){this._doubleClick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasSwiped",{get:function(){return this._hasSwiped},set:function(e){this._hasSwiped=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ignore",{get:function(){return this._ignore},set:function(e){this._ignore=e},enumerable:!0,configurable:!0}),e}(),I=function(){function e(e){this._wheelEventName="",this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._totalPointersPressed=0,this._doubleClickOccured=!1,this._pointerX=0,this._pointerY=0,this._startingPointerPosition=new u.w(0,0),this._previousStartingPointerPosition=new u.w(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._scene=e}return Object.defineProperty(e.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"unTranslatedPointer",{get:function(){return new u.w(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pointerX",{get:function(){return this._pointerX},set:function(e){this._pointerX=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"pointerY",{get:function(){return this._pointerY},set:function(e){this._pointerY=e},enumerable:!0,configurable:!0}),e.prototype._updatePointerPosition=function(e){var t=this._scene.getEngine().getRenderingCanvasClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)},e.prototype._processPointerMove=function(e,t){var n=this._scene,i=n.getEngine().getRenderingCanvas();if(i){i.tabIndex=1,i.style.cursor=n.defaultCursor;var r=!!(e&&e.hit&&e.pickedMesh);r?(n.setPointerOverMesh(e.pickedMesh),this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.hasPointerTriggers&&(this._pointerOverMesh.actionManager.hoverCursor?i.style.cursor=this._pointerOverMesh.actionManager.hoverCursor:i.style.cursor=n.hoverCursor)):n.setPointerOverMesh(null);for(var o=0,a=n._pointerMoveStage;oe.LongPressDelay&&!i._isPointerSwiping()&&(i._startingPointerTime=0,o.processTrigger(E.a.ACTION_OnLongPressTrigger,b.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),r=new w;n?r.doubleClick=!0:r.singleClick=!0,this._checkPrePointerObservable(e,i,M.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=M.a.POINTERPICK,o=new M.b(r,t,e);this._setRayOnPointerInfo(o),i.onPointerObservable.notifyObservers(o,r)}var a=e.pickedMesh._getActionManagerForTrigger();if(a&&!n.ignore){a.processTrigger(E.a.ACTION_OnPickUpTrigger,b.a.CreateNew(e.pickedMesh,t)),!n.hasSwiped&&n.singleClick&&a.processTrigger(E.a.ACTION_OnPickTrigger,b.a.CreateNew(e.pickedMesh,t));var s=e.pickedMesh._getActionManagerForTrigger(E.a.ACTION_OnDoublePickTrigger);n.doubleClick&&s&&s.processTrigger(E.a.ACTION_OnDoublePickTrigger,b.a.CreateNew(e.pickedMesh,t))}}else if(!n.ignore)for(var c=0,l=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 w;o._currentPickResult=null;var s=null,c=t.hasSpecificMask(M.a.POINTERPICK)||n.hasSpecificMask(M.a.POINTERPICK)||t.hasSpecificMask(M.a.POINTERTAP)||n.hasSpecificMask(M.a.POINTERTAP)||t.hasSpecificMask(M.a.POINTERDOUBLETAP)||n.hasSpecificMask(M.a.POINTERDOUBLETAP);!c&&O.a&&(s=o._initActionManager(s,a))&&(c=s.hasPickTriggers);var l=!1;if(c){var u=i.button;if(a.hasSwiped=o._isPointerSwiping(),!a.hasSwiped){var h=!e.ExclusiveDoubleClickMode;h||(h=!t.hasSpecificMask(M.a.POINTERDOUBLETAP)&&!n.hasSpecificMask(M.a.POINTERDOUBLETAP))&&!O.a.HasSpecificTrigger(E.a.ACTION_OnDoublePickTrigger)&&(s=o._initActionManager(s,a))&&(h=!s.hasSpecificTrigger(E.a.ACTION_OnDoublePickTrigger)),h?(Date.now()-o._previousStartingPointerTime>e.DoubleClickDelay||u!==o._previousButtonPressed)&&(a.singleClick=!0,r(a,o._currentPickResult),l=!0):(o._previousDelayedSimpleClickTimeout=o._delayedSimpleClickTimeout,o._delayedSimpleClickTimeout=window.setTimeout(o._delayedSimpleClick.bind(o,u,a,r),e.DoubleClickDelay));var d=t.hasSpecificMask(M.a.POINTERDOUBLETAP)||n.hasSpecificMask(M.a.POINTERDOUBLETAP);!d&&O.a.HasSpecificTrigger(E.a.ACTION_OnDoublePickTrigger)&&(s=o._initActionManager(s,a))&&(d=s.hasSpecificTrigger(E.a.ACTION_OnDoublePickTrigger)),d&&(u===o._previousButtonPressed&&Date.now()-o._previousStartingPointerTime0){for(var e=0,t=this._transientComponents;e0)return!1;for(e=0;e0,r=0,o=this._isReadyForMeshStage;r0)for(var a=0,s=this.activeCameras;a0},enumerable:!0,configurable:!0}),t.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},t.prototype.whenReadyAsync=function(){var e=this;return new Promise((function(t){e.executeWhenReady((function(){t()}))}))},t.prototype._checkIsReady=function(){var e=this;if(this._registerTransientComponents(),this.isReady())return this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1);this._executeWhenReadyTimeoutId=setTimeout((function(){e._checkIsReady()}),150)},Object.defineProperty(t.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),t.prototype.resetLastAnimationTimeFrame=function(){this._animationTimeLast=o.a.Now},t.prototype.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){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?u.i.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=u.i.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.update()))},t.prototype.getSceneUniformBuffer=function(){return this._multiviewSceneUbo?this._multiviewSceneUbo:this._sceneUbo},t.prototype.getUniqueId=function(){var e=t._uniqueIdCounter;return t._uniqueIdCounter++,e},t.prototype.addMesh=function(e,t){var n=this;void 0===t&&(t=!1),this.meshes.push(e),e._resyncLightSources(),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()),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){n.removeMesh(e)})),i},t.prototype.addTransformNode=function(e){e._indexInSceneTransformNodesArray=this.transformNodes.length,this.transformNodes.push(e),this.onNewTransformNodeAddedObservable.notifyObservers(e)},t.prototype.removeTransformNode=function(e){var t=e._indexInSceneTransformNodesArray;if(-1!==t){if(t!==this.transformNodes.length-1){var n=this.transformNodes[this.transformNodes.length-1];this.transformNodes[t]=n,n._indexInSceneTransformNodesArray=t}e._indexInSceneTransformNodesArray=-1,this.transformNodes.pop()}return this.onTransformNodeRemovedObservable.notifyObservers(e),t},t.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&(this.skeletons.splice(t,1),this.onSkeletonRemovedObservable.notifyObservers(e)),t},t.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},t.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var 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),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),t},t.prototype.removeMaterial=function(e){var t=e._indexInSceneMaterialArray;if(-1!==t&&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&&0!=(a.layerMask&this.activeCamera.layerMask)&&(a.alwaysSelectAsActiveMesh||a.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(a),this.activeCamera._activeMeshes.push(a),s!==a&&s._activate(this._renderId,!1),a._activate(this._renderId,!1)&&(a.isAnInstance||(s._internalAbstractMeshDataInfo._onlyForInstances=!1),s._internalAbstractMeshDataInfo._isActive=!0,this._activeMesh(a,s)),a._postActivate()))}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var c=0;c0)for(var r=this.getActiveSubMeshCandidates(t),o=r.length,a=0;a1)this.activeCamera.outputRenderTarget._bindFrameBuffer();else{var e=this.activeCamera.outputRenderTarget.getInternalTexture();e?this.getEngine().bindFramebuffer(e):S.a.Error("Camera contains invalid customDefaultRenderTarget")}}else this.getEngine().restoreDefaultFramebuffer()},t.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var n=this._engine;if(this._activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");n.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.getEngine().getCaps().multiview&&e.outputRenderTarget&&e.outputRenderTarget.getViewCount()>1?this.setTransformMatrix(e._rigCameras[0].getViewMatrix(),e._rigCameras[0].getProjectionMatrix(),e._rigCameras[1].getViewMatrix(),e._rigCameras[1].getProjectionMatrix()):this.updateTransformMatrix(),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var i=0;i0&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var a=0,s=this._gatherActiveCameraRenderTargetsStage;a0){r.h.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var l=0;l0),this._renderId++}for(var d=0,f=this._cameraDrawRenderTargetStage;d1&&this.getEngine().getCaps().multiview)this._renderForCamera(e);else{if(e._useMultiviewToSingleView)this._renderMultiviewToSingleView(e);else for(var t=0;t-1&&(i.trigger===E.a.ACTION_OnIntersectionExitTrigger&&i._executeCurrent(b.a.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(E.a.ACTION_OnIntersectionExitTrigger,(function(e){var t=e instanceof d.a?e:e.mesh;return o===t}))&&i.trigger!==E.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.getDeterministicFrameTime(),i=0,r=this._engine.getLockstepMaxSteps(),o=Math.floor(e/60);o=Math.min(o,r);do{this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=.06*n,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._advancePhysicsEngineStep(n),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,i++,e-=n}while(e>0&&i0)for(var o=0;o0),this._intermediateRendering=!0;for(var u=0;u0),this._intermediateRendering=!1,this._renderId++}this.activeCamera=l,this._bindFrameBuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this);for(var d=0,p=this._beforeClearStage;d0)for(o=0;o0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[o]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var _=0,v=this._afterRenderStage;_-1&&this._engine.scenes.splice(r,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(t.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),t.prototype.clearCachedVertexData=function(){for(var e=0;e1?this.notRenderable=!0:this.notRenderable=!1}else s.h.Error("Cannot move a control to a vector3 if the control is not at root level")},e.prototype._getDescendants=function(e,t,n){void 0===t&&(t=!1)},e.prototype.getDescendants=function(e,t){var n=new Array;return this._getDescendants(n,e,t),n},e.prototype.linkWithMesh=function(t){if(!this._host||this.parent&&this.parent!==this._host._rootContainer)t&&s.h.Error("Cannot link a control to a mesh if the control is not at root level");else{var n=this._host._linkedControls.indexOf(this);if(-1!==n)return this._linkedMesh=t,void(t||this._host._linkedControls.splice(n,1));t&&(this.horizontalAlignment=e.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=e.VERTICAL_ALIGNMENT_TOP,this._linkedMesh=t,this._host._linkedControls.push(this))}},e.prototype._moveToProjectedPosition=function(e){var t=this._left.getValue(this._host),n=this._top.getValue(this._host),i=e.x+this._linkOffsetX.getValue(this._host)-this._currentMeasure.width/2,r=e.y+this._linkOffsetY.getValue(this._host)-this._currentMeasure.height/2;this._left.ignoreAdaptiveScaling&&this._top.ignoreAdaptiveScaling&&(Math.abs(i-t)<.5&&(i=t),Math.abs(r-n)<.5&&(r=n)),this.left=i+"px",this.top=r+"px",this._left.ignoreAdaptiveScaling=!0,this._top.ignoreAdaptiveScaling=!0,this._markAsDirty()},e.prototype._offsetLeft=function(e){this._isDirty=!0,this._currentMeasure.left+=e},e.prototype._offsetTop=function(e){this._isDirty=!0,this._currentMeasure.top+=e},e.prototype._markMatrixAsDirty=function(){this._isMatrixDirty=!0,this._flagDescendantsAsMatrixDirty()},e.prototype._flagDescendantsAsMatrixDirty=function(){},e.prototype._intersectsRect=function(e){return this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),!(this._tmpMeasureA.left>=e.left+e.width)&&(!(this._tmpMeasureA.top>=e.top+e.height)&&(!(this._tmpMeasureA.left+this._tmpMeasureA.width<=e.left)&&!(this._tmpMeasureA.top+this._tmpMeasureA.height<=e.top)))},e.prototype.invalidateRect=function(){if(this._transform(),this.host&&this.host.useInvalidateRectOptimization)if(this._currentMeasure.transformToRef(this._transformMatrix,this._tmpMeasureA),l.a.CombineToRef(this._tmpMeasureA,this._prevCurrentMeasureTransformedIntoGlobalSpace,this._tmpMeasureA),this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY){var e=this.shadowOffsetX,t=this.shadowOffsetY,n=this.shadowBlur,i=Math.min(Math.min(e,0)-2*n,0),r=Math.max(Math.max(e,0)+2*n,0),o=Math.min(Math.min(t,0)-2*n,0),a=Math.max(Math.max(t,0)+2*n,0);this.host.invalidateRect(Math.floor(this._tmpMeasureA.left+i),Math.floor(this._tmpMeasureA.top+o),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width+r),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height+a))}else this.host.invalidateRect(Math.floor(this._tmpMeasureA.left),Math.floor(this._tmpMeasureA.top),Math.ceil(this._tmpMeasureA.left+this._tmpMeasureA.width),Math.ceil(this._tmpMeasureA.top+this._tmpMeasureA.height))},e.prototype._markAsDirty=function(e){void 0===e&&(e=!1),(this._isVisible||e)&&(this._isDirty=!0,this._host&&this._host.markAsDirty())},e.prototype._markAllAsDirty=function(){this._markAsDirty(),this._font&&this._prepareFont()},e.prototype._link=function(e){this._host=e,this._host&&(this.uniqueId=this._host.getScene().getUniqueId())},e.prototype._transform=function(e){if(this._isMatrixDirty||1!==this._scaleX||1!==this._scaleY||0!==this._rotation){var t=this._currentMeasure.width*this._transformCenterX+this._currentMeasure.left,n=this._currentMeasure.height*this._transformCenterY+this._currentMeasure.top;e&&(e.translate(t,n),e.rotate(this._rotation),e.scale(this._scaleX,this._scaleY),e.translate(-t,-n)),(this._isMatrixDirty||this._cachedOffsetX!==t||this._cachedOffsetY!==n)&&(this._cachedOffsetX=t,this._cachedOffsetY=n,this._isMatrixDirty=!1,this._flagDescendantsAsMatrixDirty(),u.a.ComposeToRef(-t,-n,this._rotation,this._scaleX,this._scaleY,this.parent?this.parent._transformMatrix:null,this._transformMatrix),this._transformMatrix.invertToRef(this._invertTransformMatrix))}},e.prototype._renderHighlight=function(e){this.isHighlighted&&(e.save(),e.strokeStyle="#4affff",e.lineWidth=2,this._renderHighlightSpecific(e),e.restore())},e.prototype._renderHighlightSpecific=function(e){e.strokeRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)},e.prototype._applyStates=function(t){this._isFontSizeInPercentage&&(this._fontSet=!0),this._fontSet&&(this._prepareFont(),this._fontSet=!1),this._font&&(t.font=this._font),this._color&&(t.fillStyle=this._color),e.AllowAlphaInheritance?t.globalAlpha*=this._alpha:this._alphaSet&&(t.globalAlpha=this.parent?this.parent.alpha*this._alpha:this._alpha)},e.prototype._layout=function(e,t){if(!this.isDirty&&(!this.isVisible||this.notRenderable))return!1;if(this._isDirty||!this._cachedParentMeasure.isEqualsTo(e)){this._currentMeasure.transformToRef(this._transformMatrix,this._prevCurrentMeasureTransformedIntoGlobalSpace),t.save(),this._applyStates(t);var n=0;do{this._rebuildLayout=!1,this._processMeasures(e,t),n++}while(this._rebuildLayout&&n<3);n>=3&&a.a.Error("Layout cycle detected in GUI (Control name="+this.name+", uniqueId="+this.uniqueId+")"),t.restore(),this.invalidateRect(),this._evaluateClippingState(e)}return this._wasDirty=this._isDirty,this._isDirty=!1,!0},e.prototype._processMeasures=function(e,t){this._currentMeasure.copyFrom(e),this._preMeasure(e,t),this._measure(),this._computeAlignment(e,t),this._currentMeasure.left=0|this._currentMeasure.left,this._currentMeasure.top=0|this._currentMeasure.top,this._currentMeasure.width=0|this._currentMeasure.width,this._currentMeasure.height=0|this._currentMeasure.height,this._additionalProcessing(e,t),this._cachedParentMeasure.copyFrom(e),this.onDirtyObservable.hasObservers()&&this.onDirtyObservable.notifyObservers(this)},e.prototype._evaluateClippingState=function(e){if(this.parent&&this.parent.clipChildren){if(this._currentMeasure.left>e.left+e.width)return void(this._isClipped=!0);if(this._currentMeasure.left+this._currentMeasure.widthe.top+e.height)return void(this._isClipped=!0);if(this._currentMeasure.top+this._currentMeasure.heightthis._currentMeasure.left+this._currentMeasure.width)&&(!(tthis._currentMeasure.top+this._currentMeasure.height)&&(this.isPointerBlocker&&(this._host._shouldBlockPointer=!0),!0))))},e.prototype._processPicking=function(e,t,n,i,r){return!!this._isEnabled&&(!(!this.isHitTestVisible||!this.isVisible||this._doNotRender)&&(!!this.contains(e,t)&&(this._processObservables(n,e,t,i,r),!0)))},e.prototype._onPointerMove=function(e,t,n){this.onPointerMoveObservable.notifyObservers(t,-1,e,this)&&null!=this.parent&&this.parent._onPointerMove(e,t,n)},e.prototype._onPointerEnter=function(e){return!!this._isEnabled&&(!(this._enterCount>0)&&(-1===this._enterCount&&(this._enterCount=0),this._enterCount++,this.onPointerEnterObservable.notifyObservers(this,-1,e,this)&&null!=this.parent&&this.parent._onPointerEnter(e),!0))},e.prototype._onPointerOut=function(e,t){if(void 0===t&&(t=!1),t||this._isEnabled&&e!==this){this._enterCount=0;var n=!0;e.isAscendant(this)||(n=this.onPointerOutObservable.notifyObservers(this,-1,e,this)),n&&null!=this.parent&&this.parent._onPointerOut(e,t)}},e.prototype._onPointerDown=function(e,t,n,i){return this._onPointerEnter(this),0===this._downCount&&(this._downCount++,this._downPointerIds[n]=!0,this.onPointerDownObservable.notifyObservers(new u.b(t,i),-1,e,this)&&null!=this.parent&&this.parent._onPointerDown(e,t,n,i),!0)},e.prototype._onPointerUp=function(e,t,n,i,r){if(this._isEnabled){this._downCount=0,delete this._downPointerIds[n];var o=r;r&&(this._enterCount>0||-1===this._enterCount)&&(o=this.onPointerClickObservable.notifyObservers(new u.b(t,i),-1,e,this)),this.onPointerUpObservable.notifyObservers(new u.b(t,i),-1,e,this)&&null!=this.parent&&this.parent._onPointerUp(e,t,n,i,o)}},e.prototype._forcePointerUp=function(e){if(void 0===e&&(e=null),null!==e)this._onPointerUp(this,r.w.Zero(),e,0,!0);else for(var t in this._downPointerIds)this._onPointerUp(this,r.w.Zero(),+t,0,!0)},e.prototype._processObservables=function(e,t,n,i,r){if(!this._isEnabled)return!1;if(this._dummyVector2.copyFromFloats(t,n),e===o.a.POINTERMOVE){this._onPointerMove(this,this._dummyVector2,i);var a=this._host._lastControlOver[i];return a&&a!==this&&a._onPointerOut(this),a!==this&&this._onPointerEnter(this),this._host._lastControlOver[i]=this,!0}return e===o.a.POINTERDOWN?(this._onPointerDown(this,this._dummyVector2,i,r),this._host._registerLastControlDown(this,i),this._host._lastPickedControl=this,!0):e===o.a.POINTERUP&&(this._host._lastControlDown[i]&&this._host._lastControlDown[i]._onPointerUp(this,this._dummyVector2,i,r,!0),delete this._host._lastControlDown[i],!0)},e.prototype._prepareFont=function(){(this._font||this._fontSet)&&(this._style?this._font=this._style.fontStyle+" "+this._style.fontWeight+" "+this.fontSizeInPixels+"px "+this._style.fontFamily:this._font=this._fontStyle+" "+this._fontWeight+" "+this.fontSizeInPixels+"px "+this._fontFamily,this._fontOffset=e._GetFontOffset(this._font))},e.prototype.dispose=function(){(this.onDirtyObservable.clear(),this.onBeforeDrawObservable.clear(),this.onAfterDrawObservable.clear(),this.onPointerDownObservable.clear(),this.onPointerEnterObservable.clear(),this.onPointerMoveObservable.clear(),this.onPointerOutObservable.clear(),this.onPointerUpObservable.clear(),this.onPointerClickObservable.clear(),this._styleObserver&&this._style&&(this._style.onChangedObservable.remove(this._styleObserver),this._styleObserver=null),this.parent&&(this.parent.removeControl(this),this.parent=null),this._host)&&(this._host._linkedControls.indexOf(this)>-1&&this.linkWithMesh(null))},Object.defineProperty(e,"HORIZONTAL_ALIGNMENT_LEFT",{get:function(){return e._HORIZONTAL_ALIGNMENT_LEFT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"HORIZONTAL_ALIGNMENT_RIGHT",{get:function(){return e._HORIZONTAL_ALIGNMENT_RIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"HORIZONTAL_ALIGNMENT_CENTER",{get:function(){return e._HORIZONTAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),Object.defineProperty(e,"VERTICAL_ALIGNMENT_TOP",{get:function(){return e._VERTICAL_ALIGNMENT_TOP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"VERTICAL_ALIGNMENT_BOTTOM",{get:function(){return e._VERTICAL_ALIGNMENT_BOTTOM},enumerable:!0,configurable:!0}),Object.defineProperty(e,"VERTICAL_ALIGNMENT_CENTER",{get:function(){return e._VERTICAL_ALIGNMENT_CENTER},enumerable:!0,configurable:!0}),e._GetFontOffset=function(t){if(e._FontHeightSizes[t])return e._FontHeightSizes[t];var n=document.createElement("span");n.innerHTML="Hg",n.style.font=t;var i=document.createElement("div");i.style.display="inline-block",i.style.width="1px",i.style.height="0px",i.style.verticalAlign="bottom";var r=document.createElement("div");r.appendChild(n),r.appendChild(i),document.body.appendChild(r);var o=0,a=0;try{a=i.getBoundingClientRect().top-n.getBoundingClientRect().top,i.style.verticalAlign="baseline",o=i.getBoundingClientRect().top-n.getBoundingClientRect().top}finally{document.body.removeChild(r)}var s={ascent:o,height:a,descent:a-o};return e._FontHeightSizes[t]=s,s},e.drawEllipse=function(e,t,n,i,r){r.translate(e,t),r.scale(n,i),r.beginPath(),r.arc(0,0,1,0,2*Math.PI),r.closePath(),r.scale(1/n,1/i),r.translate(-e,-t)},e.AllowAlphaInheritance=!1,e._ClipMeasure=new l.a(0,0,0,0),e._HORIZONTAL_ALIGNMENT_LEFT=0,e._HORIZONTAL_ALIGNMENT_RIGHT=1,e._HORIZONTAL_ALIGNMENT_CENTER=2,e._VERTICAL_ALIGNMENT_TOP=0,e._VERTICAL_ALIGNMENT_BOTTOM=1,e._VERTICAL_ALIGNMENT_CENTER=2,e._FontHeightSizes={},e.AddHeader=function(){},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(10),r=n(4),o=function(){function e(){}return Object.defineProperty(e,"DiffuseTextureEnabled",{get:function(){return this._DiffuseTextureEnabled},set:function(e){this._DiffuseTextureEnabled!==e&&(this._DiffuseTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AmbientTextureEnabled",{get:function(){return this._AmbientTextureEnabled},set:function(e){this._AmbientTextureEnabled!==e&&(this._AmbientTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"OpacityTextureEnabled",{get:function(){return this._OpacityTextureEnabled},set:function(e){this._OpacityTextureEnabled!==e&&(this._OpacityTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ReflectionTextureEnabled",{get:function(){return this._ReflectionTextureEnabled},set:function(e){this._ReflectionTextureEnabled!==e&&(this._ReflectionTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EmissiveTextureEnabled",{get:function(){return this._EmissiveTextureEnabled},set:function(e){this._EmissiveTextureEnabled!==e&&(this._EmissiveTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"SpecularTextureEnabled",{get:function(){return this._SpecularTextureEnabled},set:function(e){this._SpecularTextureEnabled!==e&&(this._SpecularTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"BumpTextureEnabled",{get:function(){return this._BumpTextureEnabled},set:function(e){this._BumpTextureEnabled!==e&&(this._BumpTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"LightmapTextureEnabled",{get:function(){return this._LightmapTextureEnabled},set:function(e){this._LightmapTextureEnabled!==e&&(this._LightmapTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"RefractionTextureEnabled",{get:function(){return this._RefractionTextureEnabled},set:function(e){this._RefractionTextureEnabled!==e&&(this._RefractionTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ColorGradingTextureEnabled",{get:function(){return this._ColorGradingTextureEnabled},set:function(e){this._ColorGradingTextureEnabled!==e&&(this._ColorGradingTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"FresnelEnabled",{get:function(){return this._FresnelEnabled},set:function(e){this._FresnelEnabled!==e&&(this._FresnelEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_FresnelDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatTextureEnabled",{get:function(){return this._ClearCoatTextureEnabled},set:function(e){this._ClearCoatTextureEnabled!==e&&(this._ClearCoatTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatBumpTextureEnabled",{get:function(){return this._ClearCoatBumpTextureEnabled},set:function(e){this._ClearCoatBumpTextureEnabled!==e&&(this._ClearCoatBumpTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ClearCoatTintTextureEnabled",{get:function(){return this._ClearCoatTintTextureEnabled},set:function(e){this._ClearCoatTintTextureEnabled!==e&&(this._ClearCoatTintTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"SheenTextureEnabled",{get:function(){return this._SheenTextureEnabled},set:function(e){this._SheenTextureEnabled!==e&&(this._SheenTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"AnisotropicTextureEnabled",{get:function(){return this._AnisotropicTextureEnabled},set:function(e){this._AnisotropicTextureEnabled!==e&&(this._AnisotropicTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e,"ThicknessTextureEnabled",{get:function(){return this._ThicknessTextureEnabled},set:function(e){this._ThicknessTextureEnabled!==e&&(this._ThicknessTextureEnabled=e,i.b.MarkAllMaterialsAsDirty(r.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),e._DiffuseTextureEnabled=!0,e._AmbientTextureEnabled=!0,e._OpacityTextureEnabled=!0,e._ReflectionTextureEnabled=!0,e._EmissiveTextureEnabled=!0,e._SpecularTextureEnabled=!0,e._BumpTextureEnabled=!0,e._LightmapTextureEnabled=!0,e._RefractionTextureEnabled=!0,e._ColorGradingTextureEnabled=!0,e._FresnelEnabled=!0,e._ClearCoatTextureEnabled=!0,e._ClearCoatBumpTextureEnabled=!0,e._ClearCoatTintTextureEnabled=!0,e._SheenTextureEnabled=!0,e._AnisotropicTextureEnabled=!0,e._ThicknessTextureEnabled=!0,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){}return e.WarnImport=function(e){return e+" needs to be imported before as it contains a side-effect required by your code."},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var i=n(5),r=n(40),o=n(7),a=n(0),s=n(4),c=(n(189),function(){function e(e,t,n,i,c,l,u,h,d,f,p,m,g,_){void 0===u&&(u=s.a.TEXTURE_NEAREST_SAMPLINGMODE),void 0===f&&(f=null),void 0===p&&(p=s.a.TEXTURETYPE_UNSIGNED_INT),void 0===m&&(m="postprocess"),void 0===_&&(_=!1),this.name=e,this.width=-1,this.height=-1,this._outputTexture=null,this.autoClear=!0,this.alphaMode=s.a.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=s.a.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new r.a(2),this._currentRenderTextureInd=0,this._scaleRatio=new a.w(1,1),this._texelSize=a.w.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,null!=l?(this._camera=l,this._scene=l.getScene(),l.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this),this.uniqueId=this._scene.getUniqueId()):h&&(this._engine=h,this._engine.postProcesses.push(this)),this._options=c,this.renderTargetSamplingMode=u||s.a.TEXTURE_NEAREST_SAMPLINGMODE,this._reusable=d||!1,this._textureType=p,this._samplers=i||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=m,this._parameters=n||[],this._parameters.push("scale"),this._indexParameters=g,_||this.updateEffect(f)}return Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){var t=this;this._samples=e,this._textures.forEach((function(e){e.samples!==t._samples&&t._engine.updateRenderTargetTextureSampleCount(e,t._samples)}))},enumerable:!0,configurable:!0}),e.prototype.getEffectName=function(){return this._fragmentUrl},Object.defineProperty(e.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"PostProcess"},e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new r.a(2)),this._shareOutputWithPostProcess=null},e.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._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment: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.activate=function(e,t,n){var r=this;void 0===t&&(t=null);var o=(e=e||this._camera).getScene(),a=o.getEngine(),c=a.getCaps().maxTextureSize,l=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,u=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0,h=e.parent;!h||h.leftCamera!=e&&h.rightCamera!=e||(l/=2);var d,f=this._options.width||l,p=this._options.height||u;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var m=a.currentViewport;m&&(f*=m.width,p*=m.height)}if((this.renderTargetSamplingMode===s.a.TEXTURE_TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(f=a.needPOTTextures?i.h.GetExponentOfTwo(f,c,this.scaleMode):f),this._options.height||(p=a.needPOTTextures?i.h.GetExponentOfTwo(p,c,this.scaleMode):p)),this.width!==f||this.height!==p){if(this._textures.length>0){for(var g=0;g0)for(var e=0;e0){var i=this._camera._getFirstPostProcess();i&&i.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e}())},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var i=n(1),r=n(2),o=n(40),a=n(5),s=n(7),c=n(0),l=n(30),u=n(9),h=n(26),d=n(22),f=function(e){function t(n,i,r,a){void 0===a&&(a=!0);var l=e.call(this,n,r)||this;return l._position=c.x.Zero(),l.upVector=c.x.Up(),l.orthoLeft=null,l.orthoRight=null,l.orthoBottom=null,l.orthoTop=null,l.fov=.8,l.minZ=1,l.maxZ=1e4,l.inertia=.9,l.mode=t.PERSPECTIVE_CAMERA,l.isIntermediate=!1,l.viewport=new c.z(0,0,1,1),l.layerMask=268435455,l.fovMode=t.FOVMODE_VERTICAL_FIXED,l.cameraRigMode=t.RIG_MODE_NONE,l.customRenderTargets=new Array,l.outputRenderTarget=null,l.onViewMatrixChangedObservable=new s.c,l.onProjectionMatrixChangedObservable=new s.c,l.onAfterCheckInputsObservable=new s.c,l.onRestoreStateObservable=new s.c,l._rigCameras=new Array,l._webvrViewMatrix=c.j.Identity(),l._skipRendering=!1,l._projectionMatrix=new c.j,l._postProcesses=new Array,l._activeMeshes=new o.a(256),l._globalPosition=c.x.Zero(),l._computedViewMatrix=c.j.Identity(),l._doNotComputeProjectionMatrix=!1,l._transformMatrix=c.j.Zero(),l._refreshFrustumPlanes=!0,l._isCamera=!0,l._isLeftCamera=!1,l._isRightCamera=!0,l.getScene().addCamera(l),a&&!l.getScene().activeCamera&&(l.getScene().activeCamera=l),l.position=i,l}return i.d(t,e),Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e},enumerable:!0,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?(u.a.Error("You're trying to reuse a post process not defined as reusable."),0):(null==t||t<0?this._postProcesses.push(e):null===this._postProcesses[t]?this._postProcesses[t]=e:this._postProcesses.splice(t,0,e),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(e))},t.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._cascadePostProcessesToRigCams()},t.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()?this._worldMatrix:(this.getViewMatrix(),this._worldMatrix)},t.prototype._getViewMatrix=function(){return c.j.Identity()},t.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._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){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 n=this.getEngine(),i=this.getScene();if(this.mode===t.PERSPECTIVE_CAMERA)this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=n.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1),i.useRightHandedSystem?c.j.PerspectiveFovRHToRef(this.fov,n.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED):c.j.PerspectiveFovLHToRef(this.fov,n.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===t.FOVMODE_VERTICAL_FIXED);else{var r=n.getRenderWidth()/2,o=n.getRenderHeight()/2;i.useRightHandedSystem?c.j.OrthoOffCenterRHToRef(this.orthoLeft||-r,this.orthoRight||r,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix):c.j.OrthoOffCenterLHToRef(this.orthoLeft||-r,this.orthoRight||r,this.orthoBottom||-o,this.orthoTop||o,this.minZ,this.maxZ,this._projectionMatrix),this._cache.orthoLeft=this.orthoLeft,this._cache.orthoRight=this.orthoRight,this._cache.orthoBottom=this.orthoBottom,this._cache.orthoTop=this.orthoTop,this._cache.renderWidth=n.getRenderWidth(),this._cache.renderHeight=n.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},t.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},t.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?c.i.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=c.i.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},t.prototype.isInFrustum=function(e,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),d.a.WarnImport("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._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==t.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var o=this._postProcesses.length;--o>=0;){var a=this._postProcesses[o];a&&a.dispose(this)}for(o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),e.prototype.dispose.call(this,n,i)},Object.defineProperty(t.prototype,"isLeftCamera",{get:function(){return this._isLeftCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRightCamera",{get:function(){return this._isRightCamera},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!0,configurable:!0}),t.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},t.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},t.prototype.setCameraRigMode=function(e,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.h.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==t.RIG_MODE_NONE){var r=this.createRigCamera(this.name+"_L",0);r&&(r._isLeftCamera=!0);var o=this.createRigCamera(this.name+"_R",1);o&&(o._isRightCamera=!0),r&&o&&(this._rigCameras.push(r),this._rigCameras.push(o))}switch(this.cameraRigMode){case t.RIG_MODE_STEREOSCOPIC_ANAGLYPH:t._setStereoscopicAnaglyphRigMode(this);break;case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case t.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case t.RIG_MODE_STEREOSCOPIC_OVERUNDER:t._setStereoscopicRigMode(this);break;case t.RIG_MODE_VR:t._setVRRigMode(this,n);break;case t.RIG_MODE_WEBVR:t._setWebVRRigMode(this,n)}this._cascadePostProcessesToRigCams(),this.update()}},t._setStereoscopicRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode"},t._setStereoscopicAnaglyphRigMode=function(e){throw"Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode"},t._setVRRigMode=function(e,t){throw"Import Cameras/RigModes/vrRigMode before using VR rig mode"},t._setWebVRRigMode=function(e,t){throw"Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode"},t.prototype._getVRProjectionMatrix=function(){return c.j.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},t.prototype._updateCameraRotationMatrix=function(){},t.prototype._updateWebVRCameraRotationMatrix=function(){},t.prototype._getWebVRProjectionMatrix=function(){return c.j.Identity()},t.prototype._getWebVRViewMatrix=function(){return c.j.Identity()},t.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=a.h.ToRadians(t/.0637))},t.prototype.createRigCamera=function(e,t){return null},t.prototype._updateRigCameras=function(){for(var e=0;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 c=i[o],l=this._getKeyValue(c.value);if(c.interpolation===s.a.STEP)return l;var u=this._getKeyValue(a.value),h=void 0!==c.outTangent&&void 0!==a.inTangent,d=a.frame-c.frame,f=(t-c.frame)/d,p=this.getEasingFunction();switch(null!=p&&(f=p.ease(f)),this.dataType){case e.ANIMATIONTYPE_FLOAT:var m=h?this.floatInterpolateFunctionWithTangents(l,c.outTangent*d,u,a.inTangent*d,f):this.floatInterpolateFunction(l,u,f);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return m;case e.ANIMATIONLOOPMODE_RELATIVE:return n.offsetValue*n.repeatCount+m}break;case e.ANIMATIONTYPE_QUATERNION:var g=h?this.quaternionInterpolateFunctionWithTangents(l,c.outTangent.scale(d),u,a.inTangent.scale(d),f):this.quaternionInterpolateFunction(l,u,f);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return g;case e.ANIMATIONLOOPMODE_RELATIVE:return g.addInPlace(n.offsetValue.scale(n.repeatCount))}return g;case e.ANIMATIONTYPE_VECTOR3:var _=h?this.vector3InterpolateFunctionWithTangents(l,c.outTangent.scale(d),u,a.inTangent.scale(d),f):this.vector3InterpolateFunction(l,u,f);switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return _;case e.ANIMATIONLOOPMODE_RELATIVE:return _.add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_VECTOR2:var v=h?this.vector2InterpolateFunctionWithTangents(l,c.outTangent.scale(d),u,a.inTangent.scale(d),f):this.vector2InterpolateFunction(l,u,f);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_SIZE:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(l,u,f);case e.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(l,u,f).add(n.offsetValue.scale(n.repeatCount))}case e.ANIMATIONTYPE_COLOR3:switch(n.loopMode){case e.ANIMATIONLOOPMODE_CYCLE:case e.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(l,u,f);case e.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(l,u,f).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(l,u,f,n.workValue);case e.ANIMATIONLOOPMODE_RELATIVE:return l}}break}}return this._getKeyValue(i[i.length-1].value)},e.prototype.matrixInterpolateFunction=function(t,n,r,o){return e.AllowMatrixDecomposeForInterpolation?o?(i.j.DecomposeLerpToRef(t,n,r,o),o):i.j.DecomposeLerp(t,n,r):o?(i.j.LerpToRef(t,n,r,o),o):i.j.Lerp(t,n,r)},e.prototype.clone=function(){var t=new e(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(t.enableBlending=this.enableBlending,t.blendingSpeed=this.blendingSpeed,this._keys&&t.setKeys(this._keys),this._ranges)for(var 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=1&&(c=u.values[1]),u.values.length>=2&&(l=u.values[2]);break;case e.ANIMATIONTYPE_QUATERNION:if(n=i.q.FromArray(u.values),u.values.length>=8){var h=i.q.FromArray(u.values.slice(4,8));h.equals(i.q.Zero())||(c=h)}if(u.values.length>=12){var d=i.q.FromArray(u.values.slice(8,12));d.equals(i.q.Zero())||(l=d)}break;case e.ANIMATIONTYPE_MATRIX:n=i.j.FromArray(u.values);break;case e.ANIMATIONTYPE_COLOR3:n=i.e.FromArray(u.values);break;case e.ANIMATIONTYPE_VECTOR3:default:n=i.x.FromArray(u.values)}var f={};f.frame=u.frame,f.value=n,null!=c&&(f.inTangent=c),null!=l&&(f.outTangent=l),s.push(f)}if(o.setKeys(s),t.ranges)for(r=0;rs.b.CollisionsEpsilon&&r.position.addInPlace(r._meshCollisionData._diffPositionForCollisions),n&&r.onCollideObservable.notifyObservers(n),r.onCollisionPositionChangeObservable.notifyObservers(r.position)},r.getScene().addMesh(r),r._resyncLightSources(),r}return i.d(t,e),Object.defineProperty(t,"BILLBOARDMODE_NONE",{get:function(){return u.a.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_X",{get:function(){return u.a.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Y",{get:function(){return u.a.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_Z",{get:function(){return u.a.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BILLBOARDMODE_ALL",{get:function(){return u.a.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetNb",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningSubdivisions",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"partitioningBBoxRatio",{get:function(){return this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio},set:function(e){this._internalAbstractMeshDataInfo._facetData.partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"mustDepthSortFacets",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSort},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"facetDepthSortFrom",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom},set:function(e){this._internalAbstractMeshDataInfo._facetData.facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isFacetDataEnabled",{get:function(){return this._internalAbstractMeshDataInfo._facetData.facetDataEnabled},enumerable:!0,configurable:!0}),t.prototype._updateNonUniformScalingState=function(t){return!!e.prototype._updateNonUniformScalingState.call(this,t)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(t.prototype,"onCollide",{set:function(e){this._meshCollisionData._onCollideObserver&&this.onCollideObservable.remove(this._meshCollisionData._onCollideObserver),this._meshCollisionData._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onCollisionPositionChange",{set:function(e){this._meshCollisionData._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._meshCollisionData._onCollisionPositionChangeObserver),this._meshCollisionData._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"visibility",{get:function(){return this._internalAbstractMeshDataInfo._visibility},set:function(e){this._internalAbstractMeshDataInfo._visibility!==e&&(this._internalAbstractMeshDataInfo._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"material",{get:function(){return this._material},set:function(e){this._material!==e&&(this._material&&this._material.meshMap&&(this._material.meshMap[this.uniqueId]=void 0),this._material=e,e&&e.meshMap&&(e.meshMap[this.uniqueId]=this),this.onMaterialChangedObservable.hasObservers&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"receiveShadows",{get:function(){return this._internalAbstractMeshDataInfo._receiveShadows},set:function(e){this._internalAbstractMeshDataInfo._receiveShadows!==e&&(this._internalAbstractMeshDataInfo._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,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:!0,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:!0,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:!0,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:!0,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:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._meshCollisionData._collisionMask},set:function(e){this._meshCollisionData._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collisionGroup",{get:function(){return this._meshCollisionData._collisionGroup},set:function(e){this._meshCollisionData._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lightSources",{get:function(){return this._lightSources},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_positions",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"skeleton",{get:function(){return this._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:!0,configurable:!0}),t.prototype.getClassName=function(){return"AbstractMesh"},t.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+("InstancedMesh"!==this.getClassName()?"YES":"NO");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!==u.a.BILLBOARDMODE_NONE?this._masterMesh:e.prototype._getEffectiveParent.call(this)},t.prototype._getActionManagerForTrigger=function(e,t){if(void 0===t&&(t=!0),this.actionManager&&(t||this.actionManager.isRecursive)){if(!e)return this.actionManager;if(this.actionManager.hasSpecificTrigger(e))return this.actionManager}return this.parent?this.parent._getActionManagerForTrigger(e,!1):null},t.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e4,s=o?this.getVerticesData(c.b.MatricesIndicesExtraKind):null,l=o?this.getVerticesData(c.b.MatricesWeightsExtraKind):null;this.skeleton.prepare();for(var u=this.skeleton.getTransformMatrices(this),h=a.t.Vector3[0],d=a.t.Matrix[0],f=a.t.Matrix[1],p=0,m=0;m0&&(a.j.FromFloat32ArrayToRefScaled(u,Math.floor(16*n[p+g]),_,f),d.addToSelf(f));if(o)for(g=0;g<4;g++)(_=l[p+g])>0&&(a.j.FromFloat32ArrayToRefScaled(u,Math.floor(16*s[p+g]),_,f),d.addToSelf(f));a.x.TransformCoordinatesFromFloatsToRef(t[m],t[m+1],t[m+2],d,h),h.toArray(t,m),this._positions&&this._positions[m/3].copyFrom(h)}}}return t},t.prototype._updateBoundingInfo=function(){var e=this._effectiveMesh;return this._boundingInfo?this._boundingInfo.update(e.worldMatrixFromCache):this._boundingInfo=new d.a(this.absolutePosition,this.absolutePosition,e.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(e.worldMatrixFromCache),this},t.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,n=0;n1||!i.IsGlobal)&&i.updateBoundingInfo(e)}return this},t.prototype._afterComputeWorldMatrix=function(){this.doNotSyncBoundingInfo||this._updateBoundingInfo()},Object.defineProperty(t.prototype,"_effectiveMesh",{get:function(){return this.skeleton&&this.skeleton.overrideMesh||this},enumerable:!0,configurable:!0}),t.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},t.prototype.intersectsMesh=function(e,t,n){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(n)for(var i=0,r=this.getChildMeshes();i1&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},t.prototype._checkCollision=function(e){if(!this._boundingInfo||!this._boundingInfo._checkCollision(e))return this;var t=a.t.Matrix[0],n=a.t.Matrix[1];return a.j.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){var i=new h.a,r="InstancedLinesMesh"===this.getClassName()||"LinesMesh"===this.getClassName()?this.intersectionThreshold:0,o=this._boundingInfo;if(!(this.subMeshes&&o&&e.intersectsSphere(o.boundingSphere,r)&&e.intersectsBox(o.boundingBox,r)))return i;if(!this._generatePointsArray())return i;for(var s=null,c=this._scene.getIntersectingSubMeshCandidates(this,e),l=c.length,u=0;u1)||d.canIntersects(e)){var f=d.intersects(e,this._positions,this.getIndices(),t,n);if(f&&(t||!s||f.distance65535){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 u=this.getScene().activeCamera;e.facetDepthSortFrom=u?u.position:a.x.Zero()}e.depthSortedFacets=[];for(var h=0;ha.h?r.maximum.x-r.minimum.x:a.h,e.bbSize.y=r.maximum.y-r.minimum.y>a.h?r.maximum.y-r.minimum.y:a.h,e.bbSize.z=r.maximum.z-r.minimum.z>a.h?r.maximum.z-r.minimum.z:a.h;var f=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(f=f>e.bbSize.z?f:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/f),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/f),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/f),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=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.x.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,l.a.ComputeNormals(t,n,i,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var p=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.t.Matrix[5];s.invertToRef(c);var l=a.t.Vector3[8];a.x.TransformCoordinatesFromFloatsToRef(e,t,n,c,l);var u=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,i,r,o);return i&&a.x.TransformCoordinatesFromFloatsToRef(i.x,i.y,i.z,s,i),u},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,l=0,u=0,h=0,d=0,f=0,p=0,m=this.getFacetLocalPositions(),g=this.getFacetLocalNormals(),_=this.getFacetsAtLocalCoordinates(e,t,n);if(!_)return null;for(var v,b,y,x=Number.MAX_VALUE,C=x,E=0;E<_.length;E++)b=g[v=_[E]],u=(e-(y=m[v]).x)*b.x+(t-y.y)*b.y+(n-y.z)*b.z,(!r||r&&o&&u>=0||r&&!o&&u<=0)&&(u=b.x*y.x+b.y*y.y+b.z*y.z,h=-(b.x*e+b.y*t+b.z*n-u)/(b.x*b.x+b.y*b.y+b.z*b.z),(C=(s=(d=e+b.x*h)-e)*s+(c=(f=t+b.y*h)-t)*c+(l=(p=n+b.z*h)-n)*l)0){if(this._isTextHighlightOn)return this.text=this._text.slice(0,this._startHighlightIndex)+this._text.slice(this._endHighlightIndex),this._isTextHighlightOn=!1,this._cursorOffset=this.text.length-this._startHighlightIndex,this._blinkIsEven=!1,void(n&&n.preventDefault());if(0===this._cursorOffset)this.text=this._text.substr(0,this._text.length-1);else(r=this._text.length-this._cursorOffset)>0&&(this.text=this._text.slice(0,r-1)+this._text.slice(r))}return void(n&&n.preventDefault());case 46:if(this._isTextHighlightOn){this.text=this._text.slice(0,this._startHighlightIndex)+this._text.slice(this._endHighlightIndex);for(var i=this._endHighlightIndex-this._startHighlightIndex;i>0&&this._cursorOffset>0;)this._cursorOffset--;return this._isTextHighlightOn=!1,this._cursorOffset=this.text.length-this._startHighlightIndex,void(n&&n.preventDefault())}if(this._text&&this._text.length>0&&this._cursorOffset>0){var r=this._text.length-this._cursorOffset;this.text=this._text.slice(0,r)+this._text.slice(r+1),this._cursorOffset--}return void(n&&n.preventDefault());case 13:return this._host.focusedControl=null,void(this._isTextHighlightOn=!1);case 35:return this._cursorOffset=0,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 36:return this._cursorOffset=this._text.length,this._blinkIsEven=!1,this._isTextHighlightOn=!1,void this._markAsDirty();case 37:if(this._cursorOffset++,this._cursorOffset>this._text.length&&(this._cursorOffset=this._text.length),n&&n.shiftKey){if(this._blinkIsEven=!1,n.ctrlKey||n.metaKey){if(!this._isTextHighlightOn){if(this._text.length===this._cursorOffset)return;this._endHighlightIndex=this._text.length-this._cursorOffset+1}return this._startHighlightIndex=0,this._cursorIndex=this._text.length-this._endHighlightIndex,this._cursorOffset=this._text.length,this._isTextHighlightOn=!0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._text.length-this._endHighlightIndex,this._cursorOffset=0===this._startHighlightIndex?this._text.length:this._text.length-this._startHighlightIndex+1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset>=this._text.length?this._text.length:this._cursorOffset-1),this._cursorIndexthis._cursorOffset?(this._endHighlightIndex=this._text.length-this._cursorOffset,this._startHighlightIndex=this._text.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._text.length-this._startHighlightIndex,this._isTextHighlightOn=!1),n&&(n.ctrlKey||n.metaKey)&&(this._cursorOffset=this.text.length,n.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 39:if(this._cursorOffset--,this._cursorOffset<0&&(this._cursorOffset=0),n&&n.shiftKey){if(this._blinkIsEven=!1,n.ctrlKey||n.metaKey){if(!this._isTextHighlightOn){if(0===this._cursorOffset)return;this._startHighlightIndex=this._text.length-this._cursorOffset-1}return this._endHighlightIndex=this._text.length,this._isTextHighlightOn=!0,this._cursorIndex=this._text.length-this._startHighlightIndex,this._cursorOffset=0,void this._markAsDirty()}return this._isTextHighlightOn?-1===this._cursorIndex&&(this._cursorIndex=this._text.length-this._startHighlightIndex,this._cursorOffset=this._text.length===this._endHighlightIndex?0:this._text.length-this._endHighlightIndex-1):(this._isTextHighlightOn=!0,this._cursorIndex=this._cursorOffset<=0?0:this._cursorOffset+1),this._cursorIndexthis._cursorOffset?(this._endHighlightIndex=this._text.length-this._cursorOffset,this._startHighlightIndex=this._text.length-this._cursorIndex):this._isTextHighlightOn=!1,void this._markAsDirty()}return this._isTextHighlightOn&&(this._cursorOffset=this._text.length-this._endHighlightIndex,this._isTextHighlightOn=!1),n&&(n.ctrlKey||n.metaKey)&&(this._cursorOffset=0,n.preventDefault()),this._blinkIsEven=!1,this._isTextHighlightOn=!1,this._cursorIndex=-1,void this._markAsDirty();case 222:n&&n.preventDefault(),this._cursorIndex=-1,this.deadKey=!0}if(t&&(-1===e||32===e||e>47&&e<64||e>64&&e<91||e>159&&e<193||e>218&&e<223||e>95&&e<112)&&(this._currentKey=t,this.onBeforeKeyAddObservable.notifyObservers(this),t=this._currentKey,this._addKey))if(this._isTextHighlightOn)this.text=this._text.slice(0,this._startHighlightIndex)+t+this._text.slice(this._endHighlightIndex),this._cursorOffset=this.text.length-(this._startHighlightIndex+1),this._isTextHighlightOn=!1,this._blinkIsEven=!1,this._markAsDirty();else if(0===this._cursorOffset)this.text+=t;else{var o=this._text.length-this._cursorOffset;this.text=this._text.slice(0,o)+t+this._text.slice(o)}}},t.prototype._updateValueFromCursorIndex=function(e){if(this._blinkIsEven=!1,-1===this._cursorIndex)this._cursorIndex=e;else if(this._cursorIndexthis._cursorOffset))return this._isTextHighlightOn=!1,void this._markAsDirty();this._endHighlightIndex=this._text.length-this._cursorOffset,this._startHighlightIndex=this._text.length-this._cursorIndex}this._isTextHighlightOn=!0,this._markAsDirty()},t.prototype._processDblClick=function(e){this._startHighlightIndex=this._text.length-this._cursorOffset,this._endHighlightIndex=this._startHighlightIndex;var t,n,i=/\w+/g;do{n=this._endHighlightIndex0&&-1!==this._text[this._startHighlightIndex-1].search(i)?--this._startHighlightIndex:0}while(t||n);this._cursorOffset=this.text.length-this._startHighlightIndex,this.onTextHighlightObservable.notifyObservers(this),this._isTextHighlightOn=!0,this._clickedCoordinate=null,this._blinkIsEven=!0,this._cursorIndex=-1,this._markAsDirty()},t.prototype._selectAllText=function(){this._blinkIsEven=!0,this._isTextHighlightOn=!0,this._startHighlightIndex=0,this._endHighlightIndex=this._text.length,this._cursorOffset=this._text.length,this._cursorIndex=-1,this._markAsDirty()},t.prototype.processKeyboard=function(e){this.processKey(e.keyCode,e.key,e),this.onKeyboardEventProcessedObservable.notifyObservers(e)},t.prototype._onCopyText=function(e){this._isTextHighlightOn=!1;try{e.clipboardData&&e.clipboardData.setData("text/plain",this._highlightedText)}catch(e){}this._host.clipboardData=this._highlightedText},t.prototype._onCutText=function(e){if(this._highlightedText){this.text=this._text.slice(0,this._startHighlightIndex)+this._text.slice(this._endHighlightIndex),this._isTextHighlightOn=!1,this._cursorOffset=this.text.length-this._startHighlightIndex;try{e.clipboardData&&e.clipboardData.setData("text/plain",this._highlightedText)}catch(e){}this._host.clipboardData=this._highlightedText,this._highlightedText=""}},t.prototype._onPasteText=function(e){var t="";t=e.clipboardData&&-1!==e.clipboardData.types.indexOf("text/plain")?e.clipboardData.getData("text/plain"):this._host.clipboardData;var n=this._text.length-this._cursorOffset;this.text=this._text.slice(0,n)+t+this._text.slice(n)},t.prototype._draw=function(e){var t=this;e.save(),this._applyStates(e),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._isFocused?this._focusedBackground&&(e.fillStyle=this._isEnabled?this._focusedBackground:this._disabledColor,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)):this._background&&(e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height)),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._fontOffset||(this._fontOffset=a.a._GetFontOffset(e.font));var n=this._currentMeasure.left+this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this.color&&(e.fillStyle=this.color);var i=this._beforeRenderText(this._text);this._isFocused||this._text||!this._placeholderText||(i=this._placeholderText,this._placeholderColor&&(e.fillStyle=this._placeholderColor)),this._textWidth=e.measureText(i).width;var r=2*this._margin.getValueInPixel(this._host,this._tempParentMeasure.width);this._autoStretchWidth&&(this.width=Math.min(this._maxWidth.getValueInPixel(this._host,this._tempParentMeasure.width),this._textWidth+r)+"px");var o=this._fontOffset.ascent+(this._currentMeasure.height-this._fontOffset.height)/2,s=this._width.getValueInPixel(this._host,this._tempParentMeasure.width)-r;if(e.save(),e.beginPath(),e.rect(n,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,s+2,this._currentMeasure.height),e.clip(),this._isFocused&&this._textWidth>s){var c=n-this._textWidth+s;this._scrollLeft||(this._scrollLeft=c)}else this._scrollLeft=n;if(e.fillText(i,this._scrollLeft,this._currentMeasure.top+o),this._isFocused){if(this._clickedCoordinate){var l=this._scrollLeft+this._textWidth-this._clickedCoordinate,u=0;this._cursorOffset=0;var h=0;do{this._cursorOffset&&(h=Math.abs(l-u)),this._cursorOffset++,u=e.measureText(i.substr(i.length-this._cursorOffset,this._cursorOffset)).width}while(u=this._cursorOffset);Math.abs(l-u)>h&&this._cursorOffset--,this._blinkIsEven=!1,this._clickedCoordinate=null}if(!this._blinkIsEven){var d=this.text.substr(this._text.length-this._cursorOffset),f=e.measureText(d).width,p=this._scrollLeft+this._textWidth-f;pn+s&&(this._scrollLeft+=n+s-p,p=n+s,this._markAsDirty()),this._isTextHighlightOn||e.fillRect(p,this._currentMeasure.top+(this._currentMeasure.height-this._fontOffset.height)/2,2,this._fontOffset.height)}if(clearTimeout(this._blinkTimeout),this._blinkTimeout=setTimeout((function(){t._blinkIsEven=!t._blinkIsEven,t._markAsDirty()}),500),this._isTextHighlightOn){clearTimeout(this._blinkTimeout);var m=e.measureText(this.text.substring(this._startHighlightIndex)).width,g=this._scrollLeft+this._textWidth-m;this._highlightedText=this.text.substring(this._startHighlightIndex,this._endHighlightIndex);var _=e.measureText(this.text.substring(this._startHighlightIndex,this._endHighlightIndex)).width;g=this._rowDefinitions.length?null:this._rowDefinitions[e]},t.prototype.getColumnDefinition=function(e){return e<0||e>=this._columnDefinitions.length?null:this._columnDefinitions[e]},t.prototype.addRowDefinition=function(e,t){return void 0===t&&(t=!1),this._rowDefinitions.push(new g.a(e,t?g.a.UNITMODE_PIXEL:g.a.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},t.prototype.addColumnDefinition=function(e,t){return void 0===t&&(t=!1),this._columnDefinitions.push(new g.a(e,t?g.a.UNITMODE_PIXEL:g.a.UNITMODE_PERCENTAGE)),this._markAsDirty(),this},t.prototype.setRowDefinition=function(e,t,n){if(void 0===n&&(n=!1),e<0||e>=this._rowDefinitions.length)return this;var i=this._rowDefinitions[e];return i&&i.isPixel===n&&i.internalValue===t?this:(this._rowDefinitions[e]=new g.a(t,n?g.a.UNITMODE_PIXEL:g.a.UNITMODE_PERCENTAGE),this._markAsDirty(),this)},t.prototype.setColumnDefinition=function(e,t,n){if(void 0===n&&(n=!1),e<0||e>=this._columnDefinitions.length)return this;var i=this._columnDefinitions[e];return i&&i.isPixel===n&&i.internalValue===t?this:(this._columnDefinitions[e]=new g.a(t,n?g.a.UNITMODE_PIXEL:g.a.UNITMODE_PERCENTAGE),this._markAsDirty(),this)},t.prototype.getChildrenAt=function(e,t){var n=this._cells[e+":"+t];return n?n.children:null},t.prototype.getChildCellInfo=function(e){return e._tag},t.prototype._removeCell=function(t,n){if(t){e.prototype.removeControl.call(this,t);for(var i=0,r=t.children;i=this._columnDefinitions.length)return this;for(var t=0;t=this._rowDefinitions.length)return this;for(var t=0;t=1-t._Epsilon&&(this._value.r=1),this._value.g>=1-t._Epsilon&&(this._value.g=1),this._value.b>=1-t._Epsilon&&(this._value.b=1),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._width.toString(this._host)!==e&&this._width.fromString(e)&&(this._height.fromString(e),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(e){this._height.toString(this._host)!==e&&this._height.fromString(e)&&(this._width.fromString(e),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e},enumerable:!0,configurable:!0}),t.prototype._getTypeName=function(){return"ColorPicker"},t.prototype._preMeasure=function(e,t){e.widths||d150?.04:-.16*(e-50)/100+.2;var _=(f-c)/(e-c);o[m+3]=_1-g?255*(1-(_-(1-g))/g):255}}return i.putImageData(r,0,0),n},t.prototype._RGBtoHSV=function(e,t){var n=e.r,i=e.g,r=e.b,o=Math.max(n,i,r),a=Math.min(n,i,r),s=0,c=0,l=o,u=o-a;0!==o&&(c=u/o),o!=a&&(o==n?(s=(i-r)/u,i=0&&o<=1?(s=r,c=a):o>=1&&o<=2?(s=a,c=r):o>=2&&o<=3?(c=r,l=a):o>=3&&o<=4?(c=a,l=r):o>=4&&o<=5?(s=a,l=r):o>=5&&o<=6&&(s=r,l=a);var u=n-r;i.set(s+u,c+u,l+u)},t.prototype._draw=function(e){e.save(),this._applyStates(e);var t=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),n=.2*t,i=this._currentMeasure.left,r=this._currentMeasure.top;this._colorWheelCanvas&&this._colorWheelCanvas.width==2*t||(this._colorWheelCanvas=this._createColorWheelCanvas(t,n)),this._updateSquareProps(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY,e.fillRect(this._squareLeft,this._squareTop,this._squareSize,this._squareSize)),e.drawImage(this._colorWheelCanvas,i,r),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._drawGradientSquare(this._h,this._squareLeft,this._squareTop,this._squareSize,this._squareSize,e);var o=this._squareLeft+this._squareSize*this._s,a=this._squareTop+this._squareSize*(1-this._v);this._drawCircle(o,a,.04*t,e);var s=t-.5*n;o=i+t+Math.cos((this._h-180)*Math.PI/180)*s,a=r+t+Math.sin((this._h-180)*Math.PI/180)*s,this._drawCircle(o,a,.35*n,e),e.restore()},t.prototype._updateValueFromPointer=function(e,n){if(this._pointerStartedOnWheel){var i=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),r=i+this._currentMeasure.left,o=i+this._currentMeasure.top;this._h=180*Math.atan2(n-o,e-r)/Math.PI+180}else this._pointerStartedOnSquare&&(this._updateSquareProps(),this._s=(e-this._squareLeft)/this._squareSize,this._v=1-(n-this._squareTop)/this._squareSize,this._s=Math.min(this._s,1),this._s=Math.max(this._s,t._Epsilon),this._v=Math.min(this._v,1),this._v=Math.max(this._v,t._Epsilon));this._HSVtoRGB(this._h,this._s,this._v,this._tmpColor),this.value=this._tmpColor},t.prototype._isPointOnSquare=function(e,t){this._updateSquareProps();var n=this._squareLeft,i=this._squareTop,r=this._squareSize;return e>=n&&e<=n+r&&t>=i&&t<=i+r},t.prototype._isPointOnWheel=function(e,t){var n=.5*Math.min(this._currentMeasure.width,this._currentMeasure.height),i=n-.2*n,r=e-(n+this._currentMeasure.left),o=t-(n+this._currentMeasure.top),a=r*r+o*o;return a<=n*n&&a>=i*i},t.prototype._onPointerDown=function(t,n,i,r){if(!e.prototype._onPointerDown.call(this,t,n,i,r))return!1;this._pointerIsDown=!0,this._pointerStartedOnSquare=!1,this._pointerStartedOnWheel=!1,this._invertTransformMatrix.transformCoordinates(n.x,n.y,this._transformedPosition);var o=this._transformedPosition.x,a=this._transformedPosition.y;return this._isPointOnSquare(o,a)?this._pointerStartedOnSquare=!0:this._isPointOnWheel(o,a)&&(this._pointerStartedOnWheel=!0),this._updateValueFromPointer(o,a),this._host._capturingControl[i]=this,this._lastPointerDownID=i,!0},t.prototype._onPointerMove=function(t,n,i){if(i==this._lastPointerDownID){this._invertTransformMatrix.transformCoordinates(n.x,n.y,this._transformedPosition);var r=this._transformedPosition.x,o=this._transformedPosition.y;this._pointerIsDown&&this._updateValueFromPointer(r,o),e.prototype._onPointerMove.call(this,t,n,i)}},t.prototype._onPointerUp=function(t,n,i,r,o){this._pointerIsDown=!1,delete this._host._capturingControl[i],e.prototype._onPointerUp.call(this,t,n,i,r,o)},t.ShowPickerDialogAsync=function(e,n){return new Promise((function(i,r){n.pickerWidth=n.pickerWidth||"640px",n.pickerHeight=n.pickerHeight||"400px",n.headerHeight=n.headerHeight||"35px",n.lastColor=n.lastColor||"#000000",n.swatchLimit=n.swatchLimit||20,n.numSwatchesPerLine=n.numSwatchesPerLine||10;var c,u,h,d,p,m,g,v,y,x,C,E,T,S,A,P,M,O,R,w=n.swatchLimit/n.numSwatchesPerLine,I=parseFloat(n.pickerWidth)/n.numSwatchesPerLine,L=Math.floor(.25*I),D=L*(n.numSwatchesPerLine+1),N=Math.floor((parseFloat(n.pickerWidth)-D)/n.numSwatchesPerLine),F=N*w+L*(w+1),k=(parseInt(n.pickerHeight)+F+Math.floor(.25*N)).toString()+"px",B="#c0c0c0",z="#535353",V="#414141",U="515151",G="#555555",H="#454545",j=f.e.FromHexString("#dddddd"),W=j.r+j.g+j.b,X="#aaaaaa",Y="#ffffff",K=["R","G","B"],Q=!1;function q(e,t){R=t;var n=e.toHexString();if(M.background=n,x.name!=R&&(x.text=Math.floor(255*e.r).toString()),C.name!=R&&(C.text=Math.floor(255*e.g).toString()),E.name!=R&&(E.text=Math.floor(255*e.b).toString()),T.name!=R&&(T.text=e.r.toString()),S.name!=R&&(S.text=e.g.toString()),A.name!=R&&(A.text=e.b.toString()),P.name!=R){var i=n.split("#");P.text=i[1]}y.name!=R&&(y.value=e)}function Z(e,t){var n=e.text;if(/[^0-9]/g.test(n))e.text=O;else if(""!=n&&(Math.floor(parseInt(n))<0?n="0":Math.floor(parseInt(n))>255?n="255":isNaN(parseInt(n))&&(n="0")),R==e.name&&(O=n),""!=n){n=parseInt(n).toString(),e.text=n;var i=f.e.FromHexString(M.background);R==e.name&&q("r"==t?new f.e(parseInt(n)/255,i.g,i.b):"g"==t?new f.e(i.r,parseInt(n)/255,i.b):new f.e(i.r,i.g,parseInt(n)/255),e.name)}}function J(e,t){var n=e.text;if(/[^0-9\.]/g.test(n))e.text=O;else{""!=n&&"."!=n&&0!=parseFloat(n)&&(parseFloat(n)<0?n="0.0":parseFloat(n)>1?n="1.0":isNaN(parseFloat(n))&&(n="0.0")),R==e.name&&(O=n),""!=n&&"."!=n&&0!=parseFloat(n)?(n=parseFloat(n).toString(),e.text=n):n="0.0";var i=f.e.FromHexString(M.background);R==e.name&&q("r"==t?new f.e(parseFloat(n),i.g,i.b):"g"==t?new f.e(i.r,parseFloat(n),i.b):new f.e(i.r,i.g,parseFloat(n)),e.name)}}function $(){if(n.savedColors&&n.savedColors[g]){if(Q)var e="b";else e="";var t=l.CreateSimpleButton("Swatch_"+g,e);t.fontFamily="BabylonJSglyphs";var i=f.e.FromHexString(n.savedColors[g]),r=i.r+i.g+i.b;t.color=r>W?X:Y,t.fontSize=Math.floor(.7*N),t.textBlock.verticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,t.height=t.width=N.toString()+"px",t.background=n.savedColors[g],t.thickness=2;var o=g;return t.pointerDownAnimation=function(){t.thickness=4},t.pointerUpAnimation=function(){t.thickness=3},t.pointerEnterAnimation=function(){t.thickness=3},t.pointerOutAnimation=function(){t.thickness=2},t.onPointerClickObservable.add((function(){var e;Q?(e=o,n.savedColors&&n.savedColors.splice(e,1),n.savedColors&&0==n.savedColors.length&&(ne(!1),Q=!1),te("",Fe)):n.savedColors&&q(f.e.FromHexString(n.savedColors[o]),t.name)})),t}return null}function ee(e){if(void 0!==e&&(Q=e),Q){for(var t=0;tc*n.numSwatchesPerLine)var l=n.numSwatchesPerLine;else l=n.savedColors.length-(c-1)*n.numSwatchesPerLine;for(var u=Math.min(Math.max(l,0),n.numSwatchesPerLine),h=0,d=1;hn.numSwatchesPerLine)){var f=$();null!=f&&(v.addControl(f,s,d),d+=2,g++)}}n.savedColors.length>=n.swatchLimit?ie(t,!0):ie(t,!1)}}function ne(e){e?((h=l.CreateSimpleButton("butEdit","Edit")).width=d,h.height=p,h.left=Math.floor(.1*parseInt(d)).toString()+"px",h.top=(-1*parseFloat(h.left)).toString()+"px",h.verticalAlignment=a.a.VERTICAL_ALIGNMENT_BOTTOM,h.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,h.thickness=2,h.color=B,h.fontSize=u,h.background=z,h.onPointerEnterObservable.add((function(){h.background=V})),h.onPointerOutObservable.add((function(){h.background=z})),h.pointerDownAnimation=function(){h.background=U},h.pointerUpAnimation=function(){h.background=V},h.onPointerClickObservable.add((function(){Q=!Q,ee()})),ve.addControl(h,1,0)):ve.removeControl(h)}function ie(e,t){t?(e.color=G,e.background=H):(e.color=B,e.background=z)}function re(t){n.savedColors&&n.savedColors.length>0?i({savedColors:n.savedColors,pickedColor:t}):i({pickedColor:t}),e.removeControl(oe)}var oe=new b;if(oe.name="Dialog Container",oe.width=n.pickerWidth,n.savedColors){oe.height=k;var ae=parseInt(n.pickerHeight)/parseInt(k);oe.addRowDefinition(ae,!1),oe.addRowDefinition(1-ae,!1)}else oe.height=n.pickerHeight,oe.addRowDefinition(1,!1);if(e.addControl(oe),n.savedColors){(v=new b).name="Swatch Drawer",v.verticalAlignment=a.a.VERTICAL_ALIGNMENT_TOP,v.background=z,v.width=n.pickerWidth;var se=n.savedColors.length/n.numSwatchesPerLine;if(0==se)var ce=0;else ce=se+1;v.height=(N*se+ce*L).toString()+"px",v.top=Math.floor(.25*N).toString()+"px";for(var le=0;le<2*Math.ceil(n.savedColors.length/n.numSwatchesPerLine)+1;le++)le%2!=0?v.addRowDefinition(N,!0):v.addRowDefinition(L,!0);for(le=0;le<2*n.numSwatchesPerLine+1;le++)le%2!=0?v.addColumnDefinition(N,!0):v.addColumnDefinition(L,!0);oe.addControl(v,1,0)}var ue=new b;ue.name="Picker Panel",ue.height=n.pickerHeight;var he=parseInt(n.headerHeight)/parseInt(n.pickerHeight),de=[he,1-he];ue.addRowDefinition(de[0],!1),ue.addRowDefinition(de[1],!1),oe.addControl(ue,0,0);var fe=new o;fe.name="Dialogue Header Bar",fe.background="#cccccc",fe.thickness=0,ue.addControl(fe,0,0);var pe=l.CreateSimpleButton("closeButton","a");pe.fontFamily="BabylonJSglyphs";var me=f.e.FromHexString(fe.background);c=new f.e(1-me.r,1-me.g,1-me.b),pe.color=c.toHexString(),pe.fontSize=Math.floor(.6*parseInt(n.headerHeight)),pe.textBlock.textVerticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,pe.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_RIGHT,pe.height=pe.width=n.headerHeight,pe.background=fe.background,pe.thickness=0,pe.pointerDownAnimation=function(){},pe.pointerUpAnimation=function(){pe.background=fe.background},pe.pointerEnterAnimation=function(){pe.color=fe.background,pe.background="red"},pe.pointerOutAnimation=function(){pe.color=c.toHexString(),pe.background=fe.background},pe.onPointerClickObservable.add((function(){re(Re.background)})),ue.addControl(pe,0,0);var ge=new b;ge.name="Dialogue Body",ge.background=z;var _e=[.4375,.5625];ge.addRowDefinition(1,!1),ge.addColumnDefinition(_e[0],!1),ge.addColumnDefinition(_e[1],!1),ue.addControl(ge,1,0);var ve=new b;ve.name="Picker Grid",ve.addRowDefinition(.85,!1),ve.addRowDefinition(.15,!1),ge.addControl(ve,0,0),(y=new t).name="GUI Color Picker",n.pickerHeightn.pickerHeight)var Me=Pe;else Me=Ae;var Oe=new s.a;Oe.text="new",Oe.name="New Color Label",Oe.color=B,Oe.fontSize=Me,Ee.addControl(Oe,1,0),(M=new o).name="New Color Swatch",M.background=n.lastColor,M.thickness=0,Se.addControl(M,0,0);var Re=l.CreateSimpleButton("currentSwatch","");Re.background=n.lastColor,Re.thickness=0,Re.onPointerClickObservable.add((function(){q(f.e.FromHexString(Re.background),Re.name),ee(!1)})),Re.pointerDownAnimation=function(){},Re.pointerUpAnimation=function(){},Re.pointerEnterAnimation=function(){},Re.pointerOutAnimation=function(){},Se.addControl(Re,1,0);var we=new o;we.name="Swatch Outline",we.width=.67,we.thickness=2,we.color="#404040",we.isHitTestVisible=!1,Ee.addControl(we,2,0);var Ie=new s.a;Ie.name="Current Color Label",Ie.text="current",Ie.color=B,Ie.fontSize=Me,Ee.addControl(Ie,3,0);var Le=new b;Le.name="Button Grid",Le.height=.8;Le.addRowDefinition(1/3,!1),Le.addRowDefinition(1/3,!1),Le.addRowDefinition(1/3,!1),xe.addControl(Le,0,1),d=Math.floor(parseInt(n.pickerWidth)*_e[1]*Ce[1]*.67).toString()+"px",p=Math.floor(parseInt(n.pickerHeight)*de[1]*ye[0]*(parseFloat(Le.height.toString())/100)*(1/3)*.7).toString()+"px",u=parseFloat(d)>parseFloat(p)?Math.floor(.45*parseFloat(p)):Math.floor(.11*parseFloat(d));var De=l.CreateSimpleButton("butOK","OK");De.width=d,De.height=p,De.verticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,De.thickness=2,De.color=B,De.fontSize=u,De.background=z,De.onPointerEnterObservable.add((function(){De.background=V})),De.onPointerOutObservable.add((function(){De.background=z})),De.pointerDownAnimation=function(){De.background=U},De.pointerUpAnimation=function(){De.background=V},De.onPointerClickObservable.add((function(){ee(!1),re(M.background)})),Le.addControl(De,0,0);var Ne=l.CreateSimpleButton("butCancel","Cancel");if(Ne.width=d,Ne.height=p,Ne.verticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,Ne.thickness=2,Ne.color=B,Ne.fontSize=u,Ne.background=z,Ne.onPointerEnterObservable.add((function(){Ne.background=V})),Ne.onPointerOutObservable.add((function(){Ne.background=z})),Ne.pointerDownAnimation=function(){Ne.background=U},Ne.pointerUpAnimation=function(){Ne.background=V},Ne.onPointerClickObservable.add((function(){ee(!1),re(Re.background)})),Le.addControl(Ne,1,0),n.savedColors){var Fe=l.CreateSimpleButton("butSave","Save");Fe.width=d,Fe.height=p,Fe.verticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,Fe.thickness=2,Fe.fontSize=u,n.savedColors.length0&&ne(!0),Le.addControl(Fe,2,0)}var ke=new b;ke.name="Dialog Lower Right",ke.addRowDefinition(.02,!1),ke.addRowDefinition(.63,!1),ke.addRowDefinition(.21,!1),ke.addRowDefinition(.14,!1),be.addControl(ke,1,0),m=f.e.FromHexString(n.lastColor);var Be=new b;Be.name="RGB Values",Be.width=.82,Be.verticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,Be.addRowDefinition(1/3,!1),Be.addRowDefinition(1/3,!1),Be.addRowDefinition(1/3,!1),Be.addColumnDefinition(.1,!1),Be.addColumnDefinition(.2,!1),Be.addColumnDefinition(.7,!1),ke.addControl(Be,1,0);for(le=0;le6||t)&&R==P.name)P.text=O;else{if(P.text.length<6)for(var n=6-P.text.length,i=0;i0&&te("",Fe)}))},t._Epsilon=1e-6,t}(a.a),x=function(e){function t(t){var n=e.call(this,t)||this;return n.name=t,n._thickness=1,n}return i.d(t,e),Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!0,configurable:!0}),t.prototype._getTypeName=function(){return"Ellipse"},t.prototype._localDraw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),a.a.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,e),this._background&&(e.fillStyle=this._background,e.fill()),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),this._thickness&&(this.color&&(e.strokeStyle=this.color),e.lineWidth=this._thickness,e.stroke()),e.restore()},t.prototype._additionalProcessing=function(t,n){e.prototype._additionalProcessing.call(this,t,n),this._measureForChildren.width-=2*this._thickness,this._measureForChildren.height-=2*this._thickness,this._measureForChildren.left+=this._thickness,this._measureForChildren.top+=this._thickness},t.prototype._clipForChildren=function(e){a.a.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2,this._currentMeasure.height/2,e),e.clip()},t}(r.a),C=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i.d(t,e),t.prototype._beforeRenderText=function(e){for(var t="",n=0;n1?this.notRenderable=!0:this.notRenderable=!1}else v.h.Error("Cannot move a control to a vector3 if the control is not at root level")},t.prototype._moveToProjectedPosition=function(e,t){void 0===t&&(t=!1);var n=e.x+this._linkOffsetX.getValue(this._host)+"px",i=e.y+this._linkOffsetY.getValue(this._host)+"px";t?(this.x2=n,this.y2=i,this._x2.ignoreAdaptiveScaling=!0,this._y2.ignoreAdaptiveScaling=!0):(this.x1=n,this.y1=i,this._x1.ignoreAdaptiveScaling=!0,this._y1.ignoreAdaptiveScaling=!0)},t}(a.a),T=n(28),S=function(){function e(e){this._multiLine=e,this._x=new g.a(0),this._y=new g.a(0),this._point=new f.w(0,0)}return Object.defineProperty(e.prototype,"x",{get:function(){return this._x.toString(this._multiLine._host)},set:function(e){this._x.toString(this._multiLine._host)!==e&&this._x.fromString(e)&&this._multiLine._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y.toString(this._multiLine._host)},set:function(e){this._y.toString(this._multiLine._host)!==e&&this._y.fromString(e)&&this._multiLine._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"control",{get:function(){return this._control},set:function(e){this._control!==e&&(this._control&&this._controlObserver&&(this._control.onDirtyObservable.remove(this._controlObserver),this._controlObserver=null),this._control=e,this._control&&(this._controlObserver=this._control.onDirtyObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},set:function(e){this._mesh!==e&&(this._mesh&&this._meshObserver&&this._mesh.getScene().onAfterCameraRenderObservable.remove(this._meshObserver),this._mesh=e,this._mesh&&(this._meshObserver=this._mesh.getScene().onAfterCameraRenderObservable.add(this._multiLine.onPointUpdate)),this._multiLine._markAsDirty())},enumerable:!0,configurable:!0}),e.prototype.resetLinks=function(){this.control=null,this.mesh=null},e.prototype.translate=function(){return this._point=this._translatePoint(),this._point},e.prototype._translatePoint=function(){if(null!=this._mesh)return this._multiLine._host.getProjectedPosition(this._mesh.getBoundingInfo().boundingSphere.center,this._mesh.getWorldMatrix());if(null!=this._control)return new f.w(this._control.centerX,this._control.centerY);var e=this._multiLine._host,t=this._x.getValueInPixel(e,Number(e._canvas.width)),n=this._y.getValueInPixel(e,Number(e._canvas.height));return new f.w(t,n)},e.prototype.dispose=function(){this.resetLinks()},e}(),A=function(e){function t(t){var n=e.call(this,t)||this;return n.name=t,n._lineWidth=1,n.onPointUpdate=function(){n._markAsDirty()},n.isHitTestVisible=!1,n._horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,n._verticalAlignment=a.a.VERTICAL_ALIGNMENT_TOP,n._dash=[],n._points=[],n}return i.d(t,e),Object.defineProperty(t.prototype,"dash",{get:function(){return this._dash},set:function(e){this._dash!==e&&(this._dash=e,this._markAsDirty())},enumerable:!0,configurable:!0}),t.prototype.getAt=function(e){return this._points[e]||(this._points[e]=new S(this)),this._points[e]},t.prototype.add=function(){for(var e=this,t=[],n=0;n0;)this.remove(this._points.length-1)},t.prototype.resetLinks=function(){this._points.forEach((function(e){null!=e&&e.resetLinks()}))},Object.defineProperty(t.prototype,"lineWidth",{get:function(){return this._lineWidth},set:function(e){this._lineWidth!==e&&(this._lineWidth=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"horizontalAlignment",{set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"verticalAlignment",{set:function(e){},enumerable:!0,configurable:!0}),t.prototype._getTypeName=function(){return"MultiLine"},t.prototype._draw=function(e){e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),this._applyStates(e),e.strokeStyle=this.color,e.lineWidth=this._lineWidth,e.setLineDash(this._dash),e.beginPath();var t=!0;this._points.forEach((function(n){n&&(t?(e.moveTo(n._point.x,n._point.y),t=!1):e.lineTo(n._point.x,n._point.y))})),e.stroke(),e.restore()},t.prototype._additionalProcessing=function(e,t){var n=this;this._minX=null,this._minY=null,this._maxX=null,this._maxY=null,this._points.forEach((function(e,t){e&&(e.translate(),(null==n._minX||e._point.xn._maxX)&&(n._maxX=e._point.x),(null==n._maxY||e._point.y>n._maxY)&&(n._maxY=e._point.y))})),null==this._minX&&(this._minX=0),null==this._minY&&(this._minY=0),null==this._maxX&&(this._maxX=0),null==this._maxY&&(this._maxY=0)},t.prototype._measure=function(){null!=this._minX&&null!=this._maxX&&null!=this._minY&&null!=this._maxY&&(this._currentMeasure.width=Math.abs(this._maxX-this._minX)+this._lineWidth,this._currentMeasure.height=Math.abs(this._maxY-this._minY)+this._lineWidth)},t.prototype._computeAlignment=function(e,t){null!=this._minX&&null!=this._minY&&(this._currentMeasure.left=this._minX-this._lineWidth/2,this._currentMeasure.top=this._minY-this._lineWidth/2)},t.prototype.dispose=function(){this.reset(),e.prototype.dispose.call(this)},t}(a.a),P=function(e){function t(t){var n=e.call(this,t)||this;return n.name=t,n._isChecked=!1,n._background="black",n._checkSizeRatio=.8,n._thickness=1,n.group="",n.onIsCheckedChangedObservable=new u.c,n.isPointerBlocker=!0,n}return i.d(t,e),Object.defineProperty(t.prototype,"thickness",{get:function(){return this._thickness},set:function(e){this._thickness!==e&&(this._thickness=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"checkSizeRatio",{get:function(){return this._checkSizeRatio},set:function(e){e=Math.max(Math.min(1,e),0),this._checkSizeRatio!==e&&(this._checkSizeRatio=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isChecked",{get:function(){return this._isChecked},set:function(e){var t=this;this._isChecked!==e&&(this._isChecked=e,this._markAsDirty(),this.onIsCheckedChangedObservable.notifyObservers(e),this._isChecked&&this._host&&this._host.executeOnAllControls((function(e){if(e!==t&&void 0!==e.group){var n=e;n.group===t.group&&(n.isChecked=!1)}})))},enumerable:!0,configurable:!0}),t.prototype._getTypeName=function(){return"RadioButton"},t.prototype._draw=function(e){e.save(),this._applyStates(e);var t=this._currentMeasure.width-this._thickness,n=this._currentMeasure.height-this._thickness;if((this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),a.a.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,this._currentMeasure.width/2-this._thickness/2,this._currentMeasure.height/2-this._thickness/2,e),e.fillStyle=this._isEnabled?this._background:this._disabledColor,e.fill(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowBlur=0,e.shadowOffsetX=0,e.shadowOffsetY=0),e.strokeStyle=this.color,e.lineWidth=this._thickness,e.stroke(),this._isChecked){e.fillStyle=this._isEnabled?this.color:this._disabledColor;var i=t*this._checkSizeRatio,r=n*this._checkSizeRatio;a.a.drawEllipse(this._currentMeasure.left+this._currentMeasure.width/2,this._currentMeasure.top+this._currentMeasure.height/2,i/2-this._thickness/2,r/2-this._thickness/2,e),e.fill()}e.restore()},t.prototype._onPointerDown=function(t,n,i,r){return!!e.prototype._onPointerDown.call(this,t,n,i,r)&&(this.isChecked||(this.isChecked=!0),!0)},t.AddRadioButtonWithHeader=function(e,n,i,r){var o=new h.a;o.isVertical=!1,o.height="30px";var c=new t;c.width="20px",c.height="20px",c.isChecked=i,c.color="green",c.group=n,c.onIsCheckedChangedObservable.add((function(e){return r(c,e)})),o.addControl(c);var l=new s.a;return l.text=e,l.width="180px",l.paddingLeft="5px",l.textHorizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,l.color="white",o.addControl(l),o},t}(a.a),M=function(e){function t(t){var n=e.call(this,t)||this;return n.name=t,n._thumbWidth=new g.a(20,g.a.UNITMODE_PIXEL,!1),n._minimum=0,n._maximum=100,n._value=50,n._isVertical=!1,n._barOffset=new g.a(5,g.a.UNITMODE_PIXEL,!1),n._isThumbClamped=!1,n._displayThumb=!0,n._step=0,n._lastPointerDownID=-1,n._effectiveBarOffset=0,n.onValueChangedObservable=new u.c,n._pointerIsDown=!1,n.isPointerBlocker=!0,n}return i.d(t,e),Object.defineProperty(t.prototype,"displayThumb",{get:function(){return this._displayThumb},set:function(e){this._displayThumb!==e&&(this._displayThumb=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"step",{get:function(){return this._step},set:function(e){this._step!==e&&(this._step=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"barOffset",{get:function(){return this._barOffset.toString(this._host)},set:function(e){this._barOffset.toString(this._host)!==e&&this._barOffset.fromString(e)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"barOffsetInPixels",{get:function(){return this._barOffset.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"thumbWidth",{get:function(){return this._thumbWidth.toString(this._host)},set:function(e){this._thumbWidth.toString(this._host)!==e&&this._thumbWidth.fromString(e)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"thumbWidthInPixels",{get:function(){return this._thumbWidth.getValueInPixel(this._host,this._cachedParentMeasure.width)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minimum",{get:function(){return this._minimum},set:function(e){this._minimum!==e&&(this._minimum=e,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maximum",{get:function(){return this._maximum},set:function(e){this._maximum!==e&&(this._maximum=e,this._markAsDirty(),this.value=Math.max(Math.min(this.value,this._maximum),this._minimum))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._value},set:function(e){e=Math.max(Math.min(e,this._maximum),this._minimum),this._value!==e&&(this._value=e,this._markAsDirty(),this.onValueChangedObservable.notifyObservers(this._value))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isVertical",{get:function(){return this._isVertical},set:function(e){this._isVertical!==e&&(this._isVertical=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isThumbClamped",{get:function(){return this._isThumbClamped},set:function(e){this._isThumbClamped!==e&&(this._isThumbClamped=e,this._markAsDirty())},enumerable:!0,configurable:!0}),t.prototype._getTypeName=function(){return"BaseSlider"},t.prototype._getThumbPosition=function(){return this.isVertical?(this.maximum-this.value)/(this.maximum-this.minimum)*this._backgroundBoxLength:(this.value-this.minimum)/(this.maximum-this.minimum)*this._backgroundBoxLength},t.prototype._getThumbThickness=function(e){var t=0;switch(e){case"circle":t=this._thumbWidth.isPixel?Math.max(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host);break;case"rectangle":t=this._thumbWidth.isPixel?Math.min(this._thumbWidth.getValue(this._host),this._backgroundBoxThickness):this._backgroundBoxThickness*this._thumbWidth.getValue(this._host)}return t},t.prototype._prepareRenderingData=function(e){this._effectiveBarOffset=0,this._renderLeft=this._currentMeasure.left,this._renderTop=this._currentMeasure.top,this._renderWidth=this._currentMeasure.width,this._renderHeight=this._currentMeasure.height,this._backgroundBoxLength=Math.max(this._currentMeasure.width,this._currentMeasure.height),this._backgroundBoxThickness=Math.min(this._currentMeasure.width,this._currentMeasure.height),this._effectiveThumbThickness=this._getThumbThickness(e),this.displayThumb&&(this._backgroundBoxLength-=this._effectiveThumbThickness),this.isVertical&&this._currentMeasure.height=this._selectors.length))return this._selectors[e]},e.prototype.removeSelector=function(e){e<0||e>=this._selectors.length||(this._groupPanel.removeControl(this._selectors[e]),this._selectors.splice(e,1))},e}(),w=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i.d(t,e),t.prototype.addCheckbox=function(e,t,n){void 0===t&&(t=function(e){}),void 0===n&&(n=!1);n=n||!1;var i=new d;i.width="20px",i.height="20px",i.color="#364249",i.background="#CCCCCC",i.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,i.onIsCheckedChangedObservable.add((function(e){t(e)}));var r=a.a.AddHeader(i,e,"200px",{isHorizontal:!0,controlFirst:!0});r.height="30px",r.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,r.left="4px",this.groupPanel.addControl(r),this.selectors.push(r),i.isChecked=n,this.groupPanel.parent&&this.groupPanel.parent.parent&&(i.color=this.groupPanel.parent.parent.buttonColor,i.background=this.groupPanel.parent.parent.buttonBackground)},t.prototype._setSelectorLabel=function(e,t){this.selectors[e].children[1].text=t},t.prototype._setSelectorLabelColor=function(e,t){this.selectors[e].children[1].color=t},t.prototype._setSelectorButtonColor=function(e,t){this.selectors[e].children[0].color=t},t.prototype._setSelectorButtonBackground=function(e,t){this.selectors[e].children[0].background=t},t}(R),I=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._selectNb=0,t}return i.d(t,e),t.prototype.addRadio=function(e,t,n){void 0===t&&(t=function(e){}),void 0===n&&(n=!1);var i=this._selectNb++,r=new P;r.name=e,r.width="20px",r.height="20px",r.color="#364249",r.background="#CCCCCC",r.group=this.name,r.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,r.onIsCheckedChangedObservable.add((function(e){e&&t(i)}));var o=a.a.AddHeader(r,e,"200px",{isHorizontal:!0,controlFirst:!0});o.height="30px",o.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,o.left="4px",this.groupPanel.addControl(o),this.selectors.push(o),r.isChecked=n,this.groupPanel.parent&&this.groupPanel.parent.parent&&(r.color=this.groupPanel.parent.parent.buttonColor,r.background=this.groupPanel.parent.parent.buttonBackground)},t.prototype._setSelectorLabel=function(e,t){this.selectors[e].children[1].text=t},t.prototype._setSelectorLabelColor=function(e,t){this.selectors[e].children[1].color=t},t.prototype._setSelectorButtonColor=function(e,t){this.selectors[e].children[0].color=t},t.prototype._setSelectorButtonBackground=function(e,t){this.selectors[e].children[0].background=t},t}(R),L=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return i.d(t,e),t.prototype.addSlider=function(e,t,n,i,r,o,s){void 0===t&&(t=function(e){}),void 0===n&&(n="Units"),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=0),void 0===s&&(s=function(e){return 0|e});var c=new O;c.name=n,c.value=o,c.minimum=i,c.maximum=r,c.width=.9,c.height="20px",c.color="#364249",c.background="#CCCCCC",c.borderColor="black",c.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,c.left="4px",c.paddingBottom="4px",c.onValueChangedObservable.add((function(e){c.parent.children[0].text=c.parent.children[0].name+": "+s(e)+" "+c.name,t(e)}));var l=a.a.AddHeader(c,e+": "+s(o)+" "+n,"30px",{isHorizontal:!1,controlFirst:!1});l.height="60px",l.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,l.left="4px",l.children[0].name=e,this.groupPanel.addControl(l),this.selectors.push(l),this.groupPanel.parent&&this.groupPanel.parent.parent&&(c.color=this.groupPanel.parent.parent.buttonColor,c.background=this.groupPanel.parent.parent.buttonBackground)},t.prototype._setSelectorLabel=function(e,t){this.selectors[e].children[0].name=t,this.selectors[e].children[0].text=t+": "+this.selectors[e].children[1].value+" "+this.selectors[e].children[1].name},t.prototype._setSelectorLabelColor=function(e,t){this.selectors[e].children[0].color=t},t.prototype._setSelectorButtonColor=function(e,t){this.selectors[e].children[1].color=t},t.prototype._setSelectorButtonBackground=function(e,t){this.selectors[e].children[1].background=t},t}(R),D=function(e){function t(t,n){void 0===n&&(n=[]);var i=e.call(this,t)||this;if(i.name=t,i.groups=n,i._buttonColor="#364249",i._buttonBackground="#CCCCCC",i._headerColor="black",i._barColor="white",i._barHeight="2px",i._spacerHeight="20px",i._bars=new Array,i._groups=n,i.thickness=2,i._panel=new h.a,i._panel.verticalAlignment=a.a.VERTICAL_ALIGNMENT_TOP,i._panel.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,i._panel.top=5,i._panel.left=5,i._panel.width=.95,n.length>0){for(var r=0;r0&&this._addSpacer(),this._panel.addControl(e.groupPanel),this._groups.push(e),e.groupPanel.children[0].color=this._headerColor;for(var t=0;t=this._groups.length)){var t=this._groups[e];this._panel.removeControl(t.groupPanel),this._groups.splice(e,1),e=this._groups.length||(this._groups[t].groupPanel.children[0].text=e)},t.prototype.relabel=function(e,t,n){if(!(t<0||t>=this._groups.length)){var i=this._groups[t];n<0||n>=i.selectors.length||i._setSelectorLabel(n,e)}},t.prototype.removeFromGroupSelector=function(e,t){if(!(e<0||e>=this._groups.length)){var n=this._groups[e];t<0||t>=n.selectors.length||n.removeSelector(t)}},t.prototype.addToGroupCheckbox=function(e,t,n,i){(void 0===n&&(n=function(){}),void 0===i&&(i=!1),e<0||e>=this._groups.length)||this._groups[e].addCheckbox(t,n,i)},t.prototype.addToGroupRadio=function(e,t,n,i){(void 0===n&&(n=function(){}),void 0===i&&(i=!1),e<0||e>=this._groups.length)||this._groups[e].addRadio(t,n,i)},t.prototype.addToGroupSlider=function(e,t,n,i,r,o,a,s){(void 0===n&&(n=function(){}),void 0===i&&(i="Units"),void 0===r&&(r=0),void 0===o&&(o=0),void 0===a&&(a=0),void 0===s&&(s=function(e){return 0|e}),e<0||e>=this._groups.length)||this._groups[e].addSlider(t,n,i,r,o,a,s)},t}(o),N=function(e){function t(t){return e.call(this,t)||this}return i.d(t,e),t.prototype._getTypeName=function(){return"ScrollViewerWindow"},t.prototype._additionalProcessing=function(t,n){e.prototype._additionalProcessing.call(this,t,n),this._measureForChildren.left=this._currentMeasure.left,this._measureForChildren.top=this._currentMeasure.top,this._measureForChildren.width=t.width,this._measureForChildren.height=t.height},t.prototype._postMeasure=function(){for(var t=this.parentClientWidth,n=this.parentClientHeight,i=0,r=this.children;ithis._thumbMeasure.left+this._thumbMeasure.width||tthis._thumbMeasure.top+this._thumbMeasure.height)&&(this.isVertical?this.value=this.minimum+(1-(t-this._currentMeasure.top)/this._currentMeasure.height)*(this.maximum-this.minimum):this.value=this.minimum+(e-this._currentMeasure.left)/this._currentMeasure.width*(this.maximum-this.minimum)));var n=0;n=this.isVertical?-(t-this._originY)/(this._currentMeasure.height-this._effectiveThumbThickness):(e-this._originX)/(this._currentMeasure.width-this._effectiveThumbThickness),this.value+=n*(this.maximum-this.minimum),this._originX=e,this._originY=t},t.prototype._onPointerDown=function(t,n,i,r){return this._first=!0,e.prototype._onPointerDown.call(this,t,n,i,r)},t}(M),B=function(e){function t(t){var n=e.call(this,t)||this;return n._barSize=20,n._pointerIsOver=!1,n._wheelPrecision=.05,n.onDirtyObservable.add((function(){n._horizontalBarSpace.color=n.color,n._verticalBarSpace.color=n.color,n._dragSpace.color=n.color})),n.onPointerEnterObservable.add((function(){n._pointerIsOver=!0})),n.onPointerOutObservable.add((function(){n._pointerIsOver=!1})),n._grid=new b,n._horizontalBar=new k,n._verticalBar=new k,n._window=new N,n._window.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,n._window.verticalAlignment=a.a.VERTICAL_ALIGNMENT_TOP,n._grid.addColumnDefinition(1),n._grid.addColumnDefinition(0,!0),n._grid.addRowDefinition(1),n._grid.addRowDefinition(0,!0),e.prototype.addControl.call(n,n._grid),n._grid.addControl(n._window,0,0),n._verticalBar.paddingLeft=0,n._verticalBar.width="100%",n._verticalBar.height="100%",n._verticalBar.barOffset=0,n._verticalBar.value=0,n._verticalBar.maximum=1,n._verticalBar.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_CENTER,n._verticalBar.verticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,n._verticalBar.isVertical=!0,n._verticalBar.rotation=Math.PI,n._verticalBar.isVisible=!1,n._verticalBarSpace=new o,n._verticalBarSpace.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,n._verticalBarSpace.verticalAlignment=a.a.VERTICAL_ALIGNMENT_TOP,n._verticalBarSpace.thickness=1,n._grid.addControl(n._verticalBarSpace,0,1),n._verticalBarSpace.addControl(n._verticalBar),n._verticalBar.onValueChangedObservable.add((function(e){n._window.top=e*n._endTop+"px"})),n._horizontalBar.paddingLeft=0,n._horizontalBar.width="100%",n._horizontalBar.height="100%",n._horizontalBar.barOffset=0,n._horizontalBar.value=0,n._horizontalBar.maximum=1,n._horizontalBar.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_CENTER,n._horizontalBar.verticalAlignment=a.a.VERTICAL_ALIGNMENT_CENTER,n._horizontalBar.isVisible=!1,n._horizontalBarSpace=new o,n._horizontalBarSpace.horizontalAlignment=a.a.HORIZONTAL_ALIGNMENT_LEFT,n._horizontalBarSpace.verticalAlignment=a.a.VERTICAL_ALIGNMENT_TOP,n._horizontalBarSpace.thickness=1,n._grid.addControl(n._horizontalBarSpace,1,0),n._horizontalBarSpace.addControl(n._horizontalBar),n._horizontalBar.onValueChangedObservable.add((function(e){n._window.left=e*n._endLeft+"px"})),n._dragSpace=new o,n._dragSpace.thickness=1,n._grid.addControl(n._dragSpace,1,1),n.barColor="grey",n.barBackground="transparent",n}return i.d(t,e),Object.defineProperty(t.prototype,"horizontalBar",{get:function(){return this._horizontalBar},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"verticalBar",{get:function(){return this._verticalBar},enumerable:!0,configurable:!0}),t.prototype.addControl=function(e){return e?(this._window.addControl(e),this):this},t.prototype.removeControl=function(e){return this._window.removeControl(e),this},Object.defineProperty(t.prototype,"children",{get:function(){return this._window.children},enumerable:!0,configurable:!0}),t.prototype._flagDescendantsAsMatrixDirty=function(){for(var e=0,t=this._children;e1&&(e=1),this._wheelPrecision=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"barColor",{get:function(){return this._barColor},set:function(e){this._barColor!==e&&(this._barColor=e,this._horizontalBar.color=e,this._verticalBar.color=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"barSize",{get:function(){return this._barSize},set:function(e){this._barSize!==e&&(this._barSize=e,this._markAsDirty(),this._horizontalBar.isVisible&&this._grid.setRowDefinition(1,this._barSize,!0),this._verticalBar.isVisible&&this._grid.setColumnDefinition(1,this._barSize,!0))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"barBackground",{get:function(){return this._barBackground},set:function(e){this._barBackground!==e&&(this._barBackground=e,this._horizontalBar.background=e,this._verticalBar.background=e,this._dragSpace.background=e)},enumerable:!0,configurable:!0}),t.prototype._updateScroller=function(){var e=this._window._currentMeasure.width,t=this._window._currentMeasure.height;this._horizontalBar.isVisible&&e<=this._clientWidth?(this._grid.setRowDefinition(1,0,!0),this._horizontalBar.isVisible=!1,this._horizontalBar.value=0,this._rebuildLayout=!0):!this._horizontalBar.isVisible&&e>this._clientWidth&&(this._grid.setRowDefinition(1,this._barSize,!0),this._horizontalBar.isVisible=!0,this._rebuildLayout=!0),this._verticalBar.isVisible&&t<=this._clientHeight?(this._grid.setColumnDefinition(1,0,!0),this._verticalBar.isVisible=!1,this._verticalBar.value=0,this._rebuildLayout=!0):!this._verticalBar.isVisible&&t>this._clientHeight&&(this._grid.setColumnDefinition(1,this._barSize,!0),this._verticalBar.isVisible=!0,this._rebuildLayout=!0),this._buildClientSizes(),this._endLeft=this._clientWidth-e,this._endTop=this._clientHeight-t;var n=this._horizontalBar.value*this._endLeft+"px",i=this._verticalBar.value*this._endTop+"px";n!==this._window.left&&(this._window.left=n,this._rebuildLayout=!0),i!==this._window.top&&(this._window.top=i,this._rebuildLayout=!0);var r=this._clientWidth/e,o=this._clientHeight/t;this._horizontalBar.thumbWidth=this._clientWidth*r+"px",this._verticalBar.thumbWidth=this._clientHeight*o+"px"},t.prototype._link=function(t){e.prototype._link.call(this,t),this._attachWheel()},t.prototype._attachWheel=function(){var e=this;if(this._host&&!this._onPointerObserver){var t=this._host.getScene();this._onPointerObserver=t.onPointerObservable.add((function(t,n){e._pointerIsOver&&t.type===m.a.POINTERWHEEL&&(1==e._verticalBar.isVisible&&(t.event.deltaY<0&&e._verticalBar.value>0?e._verticalBar.value-=e._wheelPrecision:t.event.deltaY>0&&e._verticalBar.value0&&e._horizontalBar.value>0&&(e._horizontalBar.value-=e._wheelPrecision)))}))}},t.prototype._renderHighlightSpecific=function(t){this.isHighlighted&&(e.prototype._renderHighlightSpecific.call(this,t),this._grid._renderHighlightSpecific(t),t.restore())},t.prototype.dispose=function(){var t=this._host.getScene();t&&this._onPointerObserver&&(t.onPointerObservable.remove(this._onPointerObserver),this._onPointerObserver=null),e.prototype.dispose.call(this)},t}(o),z=function(){},V=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.onKeyPressObservable=new u.c,t.defaultButtonWidth="40px",t.defaultButtonHeight="40px",t.defaultButtonPaddingLeft="2px",t.defaultButtonPaddingRight="2px",t.defaultButtonPaddingTop="2px",t.defaultButtonPaddingBottom="2px",t.defaultButtonColor="#DDD",t.defaultButtonBackground="#070707",t.shiftButtonColor="#7799FF",t.selectedShiftThickness=1,t.shiftState=0,t._currentlyConnectedInputText=null,t._connectedInputTexts=[],t._onKeyPressObserver=null,t}return i.d(t,e),t.prototype._getTypeName=function(){return"VirtualKeyboard"},t.prototype._createKey=function(e,t){var n=this,i=l.CreateSimpleButton(e,e);return i.width=t&&t.width?t.width:this.defaultButtonWidth,i.height=t&&t.height?t.height:this.defaultButtonHeight,i.color=t&&t.color?t.color:this.defaultButtonColor,i.background=t&&t.background?t.background:this.defaultButtonBackground,i.paddingLeft=t&&t.paddingLeft?t.paddingLeft:this.defaultButtonPaddingLeft,i.paddingRight=t&&t.paddingRight?t.paddingRight:this.defaultButtonPaddingRight,i.paddingTop=t&&t.paddingTop?t.paddingTop:this.defaultButtonPaddingTop,i.paddingBottom=t&&t.paddingBottom?t.paddingBottom:this.defaultButtonPaddingBottom,i.thickness=0,i.isFocusInvisible=!0,i.shadowColor=this.shadowColor,i.shadowBlur=this.shadowBlur,i.shadowOffsetX=this.shadowOffsetX,i.shadowOffsetY=this.shadowOffsetY,i.onPointerUpObservable.add((function(){n.onKeyPressObservable.notifyObservers(e)})),i},t.prototype.addKeysRow=function(e,t){var n=new h.a;n.isVertical=!1,n.isFocusInvisible=!0;for(var i=null,r=0;ri.heightInPixels)&&(i=a),n.addControl(a)}n.height=i?i.height:this.defaultButtonHeight,this.addControl(n)},t.prototype.applyShiftState=function(e){if(this.children)for(var t=0;t1?this.selectedShiftThickness:0),a.text=e>0?a.text.toUpperCase():a.text.toLowerCase()}}}},Object.defineProperty(t.prototype,"connectedInputText",{get:function(){return this._currentlyConnectedInputText},enumerable:!0,configurable:!0}),t.prototype.connect=function(e){var t=this;if(!this._connectedInputTexts.some((function(t){return t.input===e}))){null===this._onKeyPressObserver&&(this._onKeyPressObserver=this.onKeyPressObservable.add((function(e){if(t._currentlyConnectedInputText){switch(t._currentlyConnectedInputText._host.focusedControl=t._currentlyConnectedInputText,e){case"⇧":return t.shiftState++,t.shiftState>2&&(t.shiftState=0),void t.applyShiftState(t.shiftState);case"←":return void t._currentlyConnectedInputText.processKey(8);case"↵":return void t._currentlyConnectedInputText.processKey(13)}t._currentlyConnectedInputText.processKey(-1,t.shiftState?e.toUpperCase():e),1===t.shiftState&&(t.shiftState=0,t.applyShiftState(t.shiftState))}}))),this.isVisible=!1,this._currentlyConnectedInputText=e,e._connectedVirtualKeyboard=this;var n=e.onFocusObservable.add((function(){t._currentlyConnectedInputText=e,e._connectedVirtualKeyboard=t,t.isVisible=!0})),i=e.onBlurObservable.add((function(){e._connectedVirtualKeyboard=null,t._currentlyConnectedInputText=null,t.isVisible=!1}));this._connectedInputTexts.push({input:e,onBlurObserver:i,onFocusObserver:n})}},t.prototype.disconnect=function(e){var t=this;if(e){var n=this._connectedInputTexts.filter((function(t){return t.input===e}));1===n.length&&(this._removeConnectedInputObservables(n[0]),this._connectedInputTexts=this._connectedInputTexts.filter((function(t){return t.input!==e})),this._currentlyConnectedInputText===e&&(this._currentlyConnectedInputText=null))}else this._connectedInputTexts.forEach((function(e){t._removeConnectedInputObservables(e)})),this._connectedInputTexts=[];0===this._connectedInputTexts.length&&(this._currentlyConnectedInputText=null,this.onKeyPressObservable.remove(this._onKeyPressObserver),this._onKeyPressObserver=null)},t.prototype._removeConnectedInputObservables=function(e){e.input._connectedVirtualKeyboard=null,e.input.onFocusObservable.remove(e.onFocusObserver),e.input.onBlurObservable.remove(e.onBlurObserver)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.disconnect()},t.CreateDefaultLayout=function(e){var n=new t(e);return n.addKeysRow(["1","2","3","4","5","6","7","8","9","0","←"]),n.addKeysRow(["q","w","e","r","t","y","u","i","o","p"]),n.addKeysRow(["a","s","d","f","g","h","j","k","l",";","'","↵"]),n.addKeysRow(["⇧","z","x","c","v","b","n","m",",",".","/"]),n.addKeysRow([" "],[{width:"200px"}]),n},t}(h.a),U=function(e){function t(t){var n=e.call(this,t)||this;return n.name=t,n._cellWidth=20,n._cellHeight=20,n._minorLineTickness=1,n._minorLineColor="DarkGray",n._majorLineTickness=2,n._majorLineColor="White",n._majorLineFrequency=5,n._background="Black",n._displayMajorLines=!0,n._displayMinorLines=!0,n}return i.d(t,e),Object.defineProperty(t.prototype,"displayMinorLines",{get:function(){return this._displayMinorLines},set:function(e){this._displayMinorLines!==e&&(this._displayMinorLines=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"displayMajorLines",{get:function(){return this._displayMajorLines},set:function(e){this._displayMajorLines!==e&&(this._displayMajorLines=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(e){this._cellWidth=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(e){this._cellHeight=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minorLineTickness",{get:function(){return this._minorLineTickness},set:function(e){this._minorLineTickness=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minorLineColor",{get:function(){return this._minorLineColor},set:function(e){this._minorLineColor=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"majorLineTickness",{get:function(){return this._majorLineTickness},set:function(e){this._majorLineTickness=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"majorLineColor",{get:function(){return this._majorLineColor},set:function(e){this._majorLineColor=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"majorLineFrequency",{get:function(){return this._majorLineFrequency},set:function(e){this._majorLineFrequency=e,this._markAsDirty()},enumerable:!0,configurable:!0}),t.prototype._draw=function(e){if(e.save(),this._applyStates(e),this._isEnabled){this._background&&(e.fillStyle=this._background,e.fillRect(this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height));var t=this._currentMeasure.width/this._cellWidth,n=this._currentMeasure.height/this._cellHeight,i=this._currentMeasure.left+this._currentMeasure.width/2,r=this._currentMeasure.top+this._currentMeasure.height/2;if(this._displayMinorLines){e.strokeStyle=this._minorLineColor,e.lineWidth=this._minorLineTickness;for(var o=-t/2;oe.value).reduce((e,t)=>e|t,0))}and(...e){return r.of(this,...e)}isSubset(e){return this.isSubsetRaw(e.value)}isSubsetRaw(e){return(this.value&e)===this.value}}r.nextIndex=0,r.None=new r(0),r.Visible=new r,r.Mobile=new r,r.HeroMoveObstacle=new r,r.EnemyMoveObstacle=new r,r.HeroDamagable=new r;class o{constructor(e,t){this.position=e,this.radius=t,this.layer=r.None.value,this.identity=this}}function a(e,t){const n=e.radius+t.radius,i=e.position.x-t.position.x;if(i>n)return!1;const r=e.position.z-t.position.z;return!(r>n)&&i*i+r*r0,o.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,o.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===p.a.INVCUBIC_MODE,o.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case p.a.EXPLICIT_MODE:o.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case p.a.PLANAR_MODE:o.setReflectionMode("REFLECTIONMAP_PLANAR");break;case p.a.PROJECTION_MODE:o.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case p.a.SKYBOX_MODE:o.setReflectionMode("REFLECTIONMAP_SKYBOX"),o.REFLECTIONMAP_SKYBOX_TRANSFORMED=!this._reflectionTexture.getReflectionTextureMatrix().isIdentity();break;case p.a.SPHERICAL_MODE:o.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case p.a.EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case p.a.FIXED_EQUIRECTANGULAR_MODE:o.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case p.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case p.a.CUBIC_MODE:case p.a.INVCUBIC_MODE:default:o.setReflectionMode("REFLECTIONMAP_CUBIC")}o.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else o.REFLECTION=!1;if(this._emissiveTexture&&t.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._emissiveTexture,o,"EMISSIVE")}else o.EMISSIVE=!1;if(this._lightmapTexture&&t.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._lightmapTexture,o,"LIGHTMAP"),o.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else o.LIGHTMAP=!1;if(this._specularTexture&&t.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;f.a.PrepareDefinesForMergedUV(this._specularTexture,o,"SPECULAR"),o.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else o.SPECULAR=!1;if(r.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&t.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;f.a.PrepareDefinesForMergedUV(this._bumpTexture,o,"BUMP"),o.PARALLAX=this._useParallax,o.PARALLAXOCCLUSION=this._useParallaxOcclusion,o.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else o.BUMP=!1;if(this._refractionTexture&&t.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;o._needUVs=!0,o.REFRACTION=!0,o.REFRACTIONMAP_3D=this._refractionTexture.isCube}else o.REFRACTION=!1;o.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else o.DIFFUSE=!1,o.AMBIENT=!1,o.OPACITY=!1,o.REFLECTION=!1,o.EMISSIVE=!1,o.LIGHTMAP=!1,o.BUMP=!1,o.REFRACTION=!1;o.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),o.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,o.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,o.SPECULAROVERALPHA=this._useSpecularOverAlpha,o.PREMULTIPLYALPHA=this.alphaMode===E.a.ALPHA_PREMULTIPLIED||this.alphaMode===E.a.ALPHA_PREMULTIPLIED_PORTERDUFF}if(o._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(o),o.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,o.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(o._areFresnelDirty&&(t.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(o.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,o.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,o.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,o.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,o.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,o.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,o._needNormals=!0,o.FRESNEL=!0):o.FRESNEL=!1),f.a.PrepareDefinesForMisc(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),f.a.PrepareDefinesForAttributes(e,o,!0,!0,!0),f.a.PrepareDefinesForFrameBoundValues(r,a,o,i),o.isDirty){o.markAsProcessed();var s=new u.c;o.REFLECTION&&s.addFallback(0,"REFLECTION"),o.SPECULAR&&s.addFallback(0,"SPECULAR"),o.BUMP&&s.addFallback(0,"BUMP"),o.PARALLAX&&s.addFallback(1,"PARALLAX"),o.PARALLAXOCCLUSION&&s.addFallback(0,"PARALLAXOCCLUSION"),o.SPECULAROVERALPHA&&s.addFallback(0,"SPECULAROVERALPHA"),o.FOG&&s.addFallback(1,"FOG"),o.POINTSIZE&&s.addFallback(0,"POINTSIZE"),o.LOGARITHMICDEPTH&&s.addFallback(0,"LOGARITHMICDEPTH"),f.a.HandleFallbacksForShadows(o,s,this._maxSimultaneousLights),o.SPECULARTERM&&s.addFallback(0,"SPECULARTERM"),o.DIFFUSEFRESNEL&&s.addFallback(1,"DIFFUSEFRESNEL"),o.OPACITYFRESNEL&&s.addFallback(2,"OPACITYFRESNEL"),o.REFLECTIONFRESNEL&&s.addFallback(3,"REFLECTIONFRESNEL"),o.EMISSIVEFRESNEL&&s.addFallback(4,"EMISSIVEFRESNEL"),o.FRESNEL&&s.addFallback(4,"FRESNEL"),o.MULTIVIEW&&s.addFallback(0,"MULTIVIEW");var h=[c.b.PositionKind];o.NORMAL&&h.push(c.b.NormalKind),o.UV1&&h.push(c.b.UVKind),o.UV2&&h.push(c.b.UV2Kind),o.VERTEXCOLOR&&h.push(c.b.ColorKind),f.a.PrepareAttributesForBones(h,e,o,s),f.a.PrepareAttributesForInstances(h,o),f.a.PrepareAttributesForMorphTargets(h,e,o);var d="default",m=["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","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff","boneTextureWidth"],g=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler","boneSampler"],_=["Material","Scene"];l.a&&(l.a.PrepareUniforms(m,o),l.a.PrepareSamplers(g,o)),f.a.PrepareUniformsAndSamplersList({uniformsNames:m,uniformBuffersNames:_,samplers:g,defines:o,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(d=this.customShaderNameResolve(d,m,_,g,o));var v=o.toString(),b=n.effect,y=r.getEngine().createEffect(d,{attributes:h,uniformsNames:m,uniformBuffersNames:_,samplers:g,defines:v,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:o.NUM_MORPH_INFLUENCERS}},a);y&&(this.allowShaderHotSwapping&&b&&!y.isReady()?(y=b,o.markAsUnprocessed()):(r.resetCachedMaterial(),n.setEffect(y,o),this.buildUniformLayout()))}return!(!n.effect||!n.effect.isReady())&&(o._renderId=r.getRenderId(),this._wasPreviouslyReady=!0,!0)},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("diffuseLeftColor",4),e.addUniform("diffuseRightColor",4),e.addUniform("opacityParts",4),e.addUniform("reflectionLeftColor",4),e.addUniform("reflectionRightColor",4),e.addUniform("refractionLeftColor",4),e.addUniform("refractionRightColor",4),e.addUniform("emissiveLeftColor",4),e.addUniform("emissiveRightColor",4),e.addUniform("vDiffuseInfos",2),e.addUniform("vAmbientInfos",2),e.addUniform("vOpacityInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vSpecularInfos",2),e.addUniform("vBumpInfos",3),e.addUniform("diffuseMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("reflectionMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("specularMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("pointSize",1),e.addUniform("refractionMatrix",16),e.addUniform("vRefractionInfos",4),e.addUniform("vSpecularColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),e.addUniform("vDiffuseColor",4),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,n,i){var r=this.getScene(),o=i._materialDefines;if(o){var c=i.effect;if(c){this._activeEffect=c,o.INSTANCES||this.bindOnlyWorldMatrix(e),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(r,c,n.visibility);f.a.BindBonesParameters(n,c);var u=this._uniformBuffer;if(l){if(u.bindToEffect(c,"Material"),this.bindViewProjection(c),!u.useUbo||!this.isFrozen||!u.isSync){if(t.FresnelEnabled&&o.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(u.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),u.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&u.updateColor4("opacityParts",new s.e(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(u.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),u.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(u.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),u.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(u.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),u.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),r.texturesEnabled){if(this._diffuseTexture&&t.DiffuseTextureEnabled&&(u.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),f.a.BindTextureMatrix(this._diffuseTexture,u,"diffuse"),this._diffuseTexture.hasAlpha&&c.setFloat("alphaCutOff",this.alphaCutOff)),this._ambientTexture&&t.AmbientTextureEnabled&&(u.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),f.a.BindTextureMatrix(this._ambientTexture,u,"ambient")),this._opacityTexture&&t.OpacityTextureEnabled&&(u.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),f.a.BindTextureMatrix(this._opacityTexture,u,"opacity")),this._reflectionTexture&&t.ReflectionTextureEnabled&&(u.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),u.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var h=this._reflectionTexture;u.updateVector3("vReflectionPosition",h.boundingBoxPosition),u.updateVector3("vReflectionSize",h.boundingBoxSize)}if(this._emissiveTexture&&t.EmissiveTextureEnabled&&(u.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),f.a.BindTextureMatrix(this._emissiveTexture,u,"emissive")),this._lightmapTexture&&t.LightmapTextureEnabled&&(u.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),f.a.BindTextureMatrix(this._lightmapTexture,u,"lightmap")),this._specularTexture&&t.SpecularTextureEnabled&&(u.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),f.a.BindTextureMatrix(this._specularTexture,u,"specular")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&(u.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),f.a.BindTextureMatrix(this._bumpTexture,u,"bump"),r._mirroredCameraPosition?u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):u.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&t.RefractionTextureEnabled){var d=1;this._refractionTexture.isCube||(u.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(d=this._refractionTexture.depth)),u.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,d,this.invertRefractionY?-1:1)}}this.pointsCloud&&u.updateFloat("pointSize",this.pointSize),o.SPECULARTERM&&u.updateColor4("vSpecularColor",this.specularColor,this.specularPower),u.updateColor3("vEmissiveColor",t.EmissiveTextureEnabled?this.emissiveColor:s.e.BlackReadOnly),u.updateFloat("visibility",n.visibility),u.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha)}if(r.texturesEnabled&&(this._diffuseTexture&&t.DiffuseTextureEnabled&&c.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&t.AmbientTextureEnabled&&c.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&t.OpacityTextureEnabled&&c.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&t.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?c.setTexture("reflectionCubeSampler",this._reflectionTexture):c.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&t.EmissiveTextureEnabled&&c.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&t.LightmapTextureEnabled&&c.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&t.SpecularTextureEnabled&&c.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&t.BumpTextureEnabled&&c.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&t.RefractionTextureEnabled)){d=1;this._refractionTexture.isCube?c.setTexture("refractionCubeSampler",this._refractionTexture):c.setTexture("refraction2DSampler",this._refractionTexture)}f.a.BindClipPlane(c,r),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),f.a.BindEyePosition(c,r),c.setColor3("vAmbientColor",this._globalAmbientColor)}!l&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&f.a.BindLights(r,n,c,o,this._maxSimultaneousLights),(r.fogEnabled&&n.applyFog&&r.fogMode!==a.a.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(c),f.a.BindFogParameters(r,n,c),o.NUM_MORPH_INFLUENCERS&&f.a.BindMorphTargetParameters(n,c),f.a.BindLogDepth(o,c,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),u.update(),this._afterBind(n,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._diffuseTexture&&t.push(this._diffuseTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._specularTexture&&t.push(this._specularTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this._refractionTexture&&t.push(this._refractionTexture),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._diffuseTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._emissiveTexture===t||(this._specularTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||this._refractionTexture===t))))))))},t.prototype.dispose=function(t,n){n&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,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,i},t.prototype.serialize=function(){return r.a.Serialize(this)},t.Parse=function(e,n,i){return r.a.Parse((function(){return new t(e.name,n)}),e,n,i)},Object.defineProperty(t,"DiffuseTextureEnabled",{get:function(){return g.a.DiffuseTextureEnabled},set:function(e){g.a.DiffuseTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AmbientTextureEnabled",{get:function(){return g.a.AmbientTextureEnabled},set:function(e){g.a.AmbientTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OpacityTextureEnabled",{get:function(){return g.a.OpacityTextureEnabled},set:function(e){g.a.OpacityTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ReflectionTextureEnabled",{get:function(){return g.a.ReflectionTextureEnabled},set:function(e){g.a.ReflectionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"EmissiveTextureEnabled",{get:function(){return g.a.EmissiveTextureEnabled},set:function(e){g.a.EmissiveTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"SpecularTextureEnabled",{get:function(){return g.a.SpecularTextureEnabled},set:function(e){g.a.SpecularTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"BumpTextureEnabled",{get:function(){return g.a.BumpTextureEnabled},set:function(e){g.a.BumpTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightmapTextureEnabled",{get:function(){return g.a.LightmapTextureEnabled},set:function(e){g.a.LightmapTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"RefractionTextureEnabled",{get:function(){return g.a.RefractionTextureEnabled},set:function(e){g.a.RefractionTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorGradingTextureEnabled",{get:function(){return g.a.ColorGradingTextureEnabled},set:function(e){g.a.ColorGradingTextureEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelEnabled",{get:function(){return g.a.FresnelEnabled},set:function(e){g.a.FresnelEnabled=e},enumerable:!0,configurable:!0}),i.c([Object(r.m)("diffuseTexture")],t.prototype,"_diffuseTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"diffuseTexture",void 0),i.c([Object(r.m)("ambientTexture")],t.prototype,"_ambientTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),i.c([Object(r.m)("opacityTexture")],t.prototype,"_opacityTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),i.c([Object(r.m)("reflectionTexture")],t.prototype,"_reflectionTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),i.c([Object(r.m)("emissiveTexture")],t.prototype,"_emissiveTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),i.c([Object(r.m)("specularTexture")],t.prototype,"_specularTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularTexture",void 0),i.c([Object(r.m)("bumpTexture")],t.prototype,"_bumpTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),i.c([Object(r.m)("lightmapTexture")],t.prototype,"_lightmapTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"lightmapTexture",void 0),i.c([Object(r.m)("refractionTexture")],t.prototype,"_refractionTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"refractionTexture",void 0),i.c([Object(r.e)("ambient")],t.prototype,"ambientColor",void 0),i.c([Object(r.e)("diffuse")],t.prototype,"diffuseColor",void 0),i.c([Object(r.e)("specular")],t.prototype,"specularColor",void 0),i.c([Object(r.e)("emissive")],t.prototype,"emissiveColor",void 0),i.c([Object(r.c)()],t.prototype,"specularPower",void 0),i.c([Object(r.c)("useAlphaFromDiffuseTexture")],t.prototype,"_useAlphaFromDiffuseTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFromDiffuseTexture",void 0),i.c([Object(r.c)("useEmissiveAsIllumination")],t.prototype,"_useEmissiveAsIllumination",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useEmissiveAsIllumination",void 0),i.c([Object(r.c)("linkEmissiveWithDiffuse")],t.prototype,"_linkEmissiveWithDiffuse",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"linkEmissiveWithDiffuse",void 0),i.c([Object(r.c)("useSpecularOverAlpha")],t.prototype,"_useSpecularOverAlpha",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),i.c([Object(r.c)("useReflectionOverAlpha")],t.prototype,"_useReflectionOverAlpha",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useReflectionOverAlpha",void 0),i.c([Object(r.c)("disableLighting")],t.prototype,"_disableLighting",void 0),i.c([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),i.c([Object(r.c)("useObjectSpaceNormalMap")],t.prototype,"_useObjectSpaceNormalMap",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),i.c([Object(r.c)("useParallax")],t.prototype,"_useParallax",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),i.c([Object(r.c)("useParallaxOcclusion")],t.prototype,"_useParallaxOcclusion",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),i.c([Object(r.c)()],t.prototype,"parallaxScaleBias",void 0),i.c([Object(r.c)("roughness")],t.prototype,"_roughness",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),i.c([Object(r.c)()],t.prototype,"indexOfRefraction",void 0),i.c([Object(r.c)()],t.prototype,"invertRefractionY",void 0),i.c([Object(r.c)()],t.prototype,"alphaCutOff",void 0),i.c([Object(r.c)("useLightmapAsShadowmap")],t.prototype,"_useLightmapAsShadowmap",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),i.c([Object(r.h)("diffuseFresnelParameters")],t.prototype,"_diffuseFresnelParameters",void 0),i.c([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"diffuseFresnelParameters",void 0),i.c([Object(r.h)("opacityFresnelParameters")],t.prototype,"_opacityFresnelParameters",void 0),i.c([Object(r.b)("_markAllSubMeshesAsFresnelAndMiscDirty")],t.prototype,"opacityFresnelParameters",void 0),i.c([Object(r.h)("reflectionFresnelParameters")],t.prototype,"_reflectionFresnelParameters",void 0),i.c([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"reflectionFresnelParameters",void 0),i.c([Object(r.h)("refractionFresnelParameters")],t.prototype,"_refractionFresnelParameters",void 0),i.c([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"refractionFresnelParameters",void 0),i.c([Object(r.h)("emissiveFresnelParameters")],t.prototype,"_emissiveFresnelParameters",void 0),i.c([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"emissiveFresnelParameters",void 0),i.c([Object(r.c)("useReflectionFresnelFromSpecular")],t.prototype,"_useReflectionFresnelFromSpecular",void 0),i.c([Object(r.b)("_markAllSubMeshesAsFresnelDirty")],t.prototype,"useReflectionFresnelFromSpecular",void 0),i.c([Object(r.c)("useGlossinessFromSpecularMapAlpha")],t.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useGlossinessFromSpecularMapAlpha",void 0),i.c([Object(r.c)("maxSimultaneousLights")],t.prototype,"_maxSimultaneousLights",void 0),i.c([Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),i.c([Object(r.c)("invertNormalMapX")],t.prototype,"_invertNormalMapX",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),i.c([Object(r.c)("invertNormalMapY")],t.prototype,"_invertNormalMapY",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),i.c([Object(r.c)("twoSidedLighting")],t.prototype,"_twoSidedLighting",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),i.c([Object(r.c)()],t.prototype,"useLogarithmicDepth",null),t}(d.a);m.a.RegisteredTypes["BABYLON.StandardMaterial"]=S,a.a.DefaultMaterialFactory=function(e){return new S("default material",e)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return P}));var i=n(224),r=n.n(i),o=n(225),a=n.n(o),s=n(226),c=n.n(s),l=n(227),u=n.n(l),h=n(228),d=n.n(h),f=n(229),p=n.n(f),m=n(230),g=n.n(m),_=n(231),v=n.n(_),b=n(232),y=n.n(b),x=n(233),C=n.n(x),E=n(234),T=n.n(E),S=n(235),A=n.n(S);class P{constructor(e,t,n){this.index=e,this.name=t,this.image=n}}P.SelfRune=new P(0,"self",T.a),P.CircleRune=new P(1,"circle",a.a),P.LineRune=new P(2,"line",y.a),P.IncreaseRune=new P(3,"increase",p.a),P.DecreaseRune=new P(4,"decrease",u.a),P.LifeRune=new P(5,"life",g.a),P.FireRune=new P(6,"fire",d.a),P.TerrainRune=new P(7,"terrain",A.a),P.ChaosRune=new P(8,"chaos",r.a),P.ReverseRune=new P(9,"reverse",C.a),P.LightningRune=new P(10,"lightning",v.a),P.CopyRune=new P(11,"copy",c.a),P.RUNES=[P.SelfRune,P.CircleRune,P.LineRune,P.IncreaseRune,P.DecreaseRune,P.LifeRune,P.FireRune,P.TerrainRune,P.ChaosRune,P.ReverseRune,P.LightningRune,P.CopyRune]},function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n.d(t,"b",(function(){return s}));var i=n(9),r=n(2),o=n(24),a={},s=function(){function e(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return e.prototype.add=function(e){var t=e.getSimpleName();this.attached[t]?i.a.Warn("camera input of type "+t+" already exists on camera"):(this.attached[t]=e,e.camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedElement&&e.attachControl(this.attachedElement))},e.prototype.remove=function(e){for(var t in this.attached){var n=this.attached[t];n===e&&(n.detachControl(this.attachedElement),n.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype.removeByType=function(e){for(var t in this.attached){var n=this.attached[t];n.getClassName()===e&&(n.detachControl(this.attachedElement),n.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},e.prototype.attachInput=function(e){this.attachedElement&&e.attachControl(this.attachedElement,this.noPreventDefault)},e.prototype.attachElement=function(e,t){if(void 0===t&&(t=!1),!this.attachedElement)for(var n in t=!o.a.ForceAttachControlToAlwaysPreventDefault&&t,this.attachedElement=e,this.noPreventDefault=t,this.attached)this.attached[n].attachControl(e,t)},e.prototype.detachElement=function(e,t){if(void 0===t&&(t=!1),this.attachedElement===e){for(var n in this.attached)this.attached[n].detachControl(e),t&&(this.attached[n].camera=null);this.attachedElement=null}},e.prototype.rebuildInputCheck=function(){for(var e in this.checkInputs=function(){},this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},e.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement,!0),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},e.prototype.serialize=function(e){var t={};for(var n in this.attached){var i=this.attached[n],o=r.a.Serialize(i);t[i.getClassName()]=o}e.inputsmgr=t},e.prototype.parse=function(e){var t=e.inputsmgr;if(t)for(var n in this.clear(),t){if(s=a[n]){var i=t[n],o=r.a.Parse((function(){return new s}),i,null);this.add(o)}}else for(var n in this.attached){var s;if(s=a[this.attached[n].getClassName()]){o=r.a.Parse((function(){return new s}),e,null);this.remove(this.attached[n]),this.add(o)}}},e}()},function(e,t,n){"use strict";var i=n(11);class r{constructor(e,t,n){this.basemap=e,this.xsize=t,this.ysize=e.length/t,this.heroSpawn=n||i.Vector2.Zero()}static generate(e,t,n){return new r(Array.from(Array(e*t).keys()).map((t,i)=>n(i%e,Math.floor(i/e))),e)}static fromAscii(e){return new r([...e.reverse().join("")].map(e=>parseInt(e,10)),e[0].length)}static fromHex(e,t){return new r(e.reverse().join("").match(/../g).map(e=>.125*parseInt(`0x${e}`,16)),e[0].length/2,t)}getHeightOrNull(e){if(e.x<0||e.x>=this.xsize)return null;if(e.y<0||e.y>=this.ysize)return null;const t=Math.floor(e.x)+Math.floor(e.y)*this.xsize;return this.basemap[t]}clampLocation(e){return e.x<0?e.x=0:e.x>=this.xsize&&(e.x=this.xsize-1),e.y<0?e.y=0:e.y>=this.ysize&&(e.y=this.ysize-1),e}drawTo(e,t){const n=Math.min(...this.basemap),i=Math.max(...this.basemap);for(let r=0;rt,l=Math.abs(a-s)>n;(c||l)&&(e.strokeStyle=l?"rgb(0, 255, 255)":"rgb(255, 0, 255)",e.beginPath(),e.moveTo(r*i,(o+1)*i),e.lineTo((r+1)*i,(o+1)*i),e.closePath(),e.stroke())}if(r+1t,l=Math.abs(a-s)>n;(c||l)&&(e.strokeStyle=l?"rgb(0, 255, 255)":"rgb(255, 0, 255)",e.beginPath(),e.moveTo((r+1)*i,o*i),e.lineTo((r+1)*i,(o+1)*i),e.closePath(),e.stroke())}}}}n.d(t,"f",(function(){return s})),n.d(t,"d",(function(){return c})),n.d(t,"e",(function(){return l})),n.d(t,"b",(function(){return u})),n.d(t,"c",(function(){return h})),n.d(t,"a",(function(){return d}));class o{constructor(e,t){this.name=e,this.url=t}}function a(e,t){!function(e,t){t(e);for(const n of e.getChildMeshes(!1))t(n)}(e,e=>e.isVisible=t)}function s(e,t){e.layerMask=t.value}class c extends o{constructor(e,t,n=0){super(e,t),this.rotation=n,this.count=0}onMeshLoaded(e){if(e.loadedMeshes.forEach(e=>{console.log(`Loaded ${this.name}.${e.name}`,e)}),this.master=e.loadedMeshes[0],a(this.master,!1),this.rotation)for(let t=1;te.onMeshLoaded(t)}addSound(e){this.manager.addBinaryFileTask(`sound: ${e.url}`,e.url).onSuccess=t=>e.onFileLoaded(this.scene,t)}addImage(e){const t=this.manager.addImageTask(`image: ${e.url}`,e.url);console.log("Loading: "+t.url),t.onSuccess=t=>e.onImageLoaded(t)}addMap(e){const t=this.manager.addTextureTask(`texture: ${e.url}`,e.url);console.log(`Loading: ${t.url}`),t.onSuccess=t=>e.onLoaded(t)}load(){return new Promise((e,t)=>{let n=0;this.manager.onProgress=(e,t)=>{console.log(`Loading asset ${t-e} / ${t}`)},this.manager.onTaskError=e=>{n+=1,console.error(`Failed to load asset ${e.name}`)},this.manager.onFinish=()=>{n>0?t(`Failed to load ${n} assets`):e()},this.manager.load()})}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var i=n(1),r=n(7),o=n(5),a=n(0),s=n(6),c=n(124),l=n(135),u=n(4),h=(n(180),function(e){function t(t,n,i,o,c,h,d,f,p,m,g,_,v){void 0===c&&(c=!0),void 0===h&&(h=u.a.TEXTURETYPE_UNSIGNED_INT),void 0===d&&(d=!1),void 0===f&&(f=s.a.TRILINEAR_SAMPLINGMODE),void 0===p&&(p=!0),void 0===m&&(m=!1),void 0===g&&(g=!1),void 0===_&&(_=u.a.TEXTUREFORMAT_RGBA),void 0===v&&(v=!1);var b=e.call(this,null,i,!o)||this;return b.isCube=d,b.renderParticles=!0,b.renderSprites=!1,b.coordinatesMode=s.a.PROJECTION_MODE,b.ignoreCameraViewport=!1,b.onBeforeBindObservable=new r.c,b.onAfterUnbindObservable=new r.c,b.onBeforeRenderObservable=new r.c,b.onAfterRenderObservable=new r.c,b.onClearObservable=new r.c,b._currentRefreshId=-1,b._refreshRate=1,b._samples=1,b.boundingBoxPosition=a.x.Zero(),(i=b.getScene())?(b.renderList=new Array,b._engine=i.getEngine(),b.name=t,b.isRenderTarget=!0,b._initialSizeParameter=n,b._processSizeParameter(n),b._resizeObserver=b.getScene().getEngine().onResizeObservable.add((function(){})),b._generateMipMaps=!!o,b._doNotChangeAspectRatio=c,b._renderingManager=new l.b(i),b._renderingManager._useSceneAutoClearSetup=!0,g?b:(b._renderTargetOptions={generateMipMaps:o,type:h,format:_,samplingMode:f,generateDepthBuffer:p,generateStencilBuffer:m},f===s.a.NEAREST_SAMPLINGMODE&&(b.wrapU=s.a.CLAMP_ADDRESSMODE,b.wrapV=s.a.CLAMP_ADDRESSMODE),v||(d?(b._texture=i.getEngine().createRenderTargetCubeTexture(b.getRenderSize(),b._renderTargetOptions),b.coordinatesMode=s.a.INVCUBIC_MODE,b._textureMatrix=a.j.Identity()):b._texture=i.getEngine().createRenderTargetTexture(b._size,b._renderTargetOptions)),b)):b}return i.d(t,e),Object.defineProperty(t.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!0,configurable:!0}),t.prototype._hookArray=function(e){var t=this,n=e.push;e.push=function(){for(var i=[],r=0;r0&&(this._postProcesses[0].autoClear=!1))}},t.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},t.prototype.getRenderSize=function(){return this.getRenderWidth()},t.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},t.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.scale=function(e){var t=this.getRenderSize()*e;this.resize(t)},t.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:e.prototype.getReflectionTextureMatrix.call(this)},t.prototype.resize=function(e){var t=this.isCube;this.releaseInternalTexture();var n=this.getScene();n&&(this._processSizeParameter(e),this._texture=t?n.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):n.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions))},t.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),s=this.getScene()){var n,i=s.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var r=0;r=0&&this._renderingManager.dispatchParticles(v))}if(this.isCube)for(var y=0;y<6;y++)this.renderToTarget(y,u,e,t),s.incrementRenderId(),s.resetCachedMaterial();else this.renderToTarget(0,u,e,t);this.onAfterUnbindObservable.notifyObservers(this),s.activeCamera&&(this.activeCamera&&this.activeCamera!==s.activeCamera&&s.setTransformMatrix(s.activeCamera.getViewMatrix(),s.activeCamera.getProjectionMatrix(!0)),i.setViewport(s.activeCamera.viewport)),s.resetCachedMaterial()}},t.prototype._bestReflectionRenderTargetDimension=function(e,t){var n=e*t,i=o.h.NearestPOT(n+16384/(128+n));return Math.min(o.h.FloorPOT(e),i)},t.prototype._bindFrameBuffer=function(e){void 0===e&&(e=0);var t=this.getScene();if(t){var n=t.getEngine();this._texture&&n.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,this.depthStencilTexture?this.depthStencilTexture:void 0)}},t.prototype.unbindFrameBuffer=function(e,t){var n=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,(function(){n.onAfterRenderObservable.notifyObservers(t)}))},t.prototype.renderToTarget=function(e,t,n,i){var r=this.getScene();if(r){var a=r.getEngine();if(this._texture){this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):n&&r.postProcessManager._prepareFrame(this._texture)||this._bindFrameBuffer(e),this.onBeforeRenderObservable.notifyObservers(e),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(a):a.clear(this.clearColor||r.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||r.updateTransformMatrix(!0);for(var s=0,c=r._beforeRenderTargetDrawStage;s=0&&t.customRenderTargets.splice(n,1);for(var i=0,r=t.cameras;i=0&&o.customRenderTargets.splice(n,1)}e.prototype.dispose.call(this)}},t.prototype._rebuild=function(){this.refreshRate===t.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=t.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},t.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},t.prototype.getViewCount=function(){return 1},t.REFRESHRATE_RENDER_ONCE=0,t.REFRESHRATE_RENDER_ONEVERYFRAME=1,t.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,t}(s.a));s.a._CreateRenderTargetTexture=function(e,t,n,i){return new h(e,t,n,i)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o}));var i=n(1),r=function(){function e(t){this.length=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;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 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;t0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},t.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},t.prototype.dispose=function(t,n){void 0===n&&(n=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var i=0,r=this.getScene().meshes;i0&&(e.excludedMeshesIds=[],this.excludedMeshes.forEach((function(t){e.excludedMeshesIds.push(t.id)}))),this.includedOnlyMeshes.length>0&&(e.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(t){e.includedOnlyMeshesIds.push(t.id)}))),r.a.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},t.GetConstructorFromName=function(e,t,n){var i=a.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),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 s=0;s0)if("object"==typeof a[0])for(var c=0;cthis.onKeyEvent(e))),e.actionManager.registerAction(new o.ExecuteCodeAction(o.ActionManager.OnKeyUpTrigger,e=>this.onKeyEvent(e))),e.onPointerDown=(e,t,n)=>this.onPointerDown(e,t,n),e.onPointerUp=(e,t,n)=>this.onPointerUp(e,t,n)}registerKey(e,...t){t.forEach(t=>this.keys[t]=e)}registerMouseButton(e,...t){t.forEach(t=>this.mouseButtons[t]=e)}onKeyEvent(e){if(e.sourceEvent.repeat)return;if(!(e.sourceEvent.code in this.keys))return;const t=this.keys[e.sourceEvent.code];t.isDown="keydown"===e.sourceEvent.type,t.isDown&&t.callback&&t.callback()}onPointerDown(e,t,n){if(!(e.button in this.mouseButtons))return;const i=this.mouseButtons[e.button];if(i.isDown=!0,i.callback){if(i.predicate){const n=i.predicate,r=this.scene.getEngine().getRenderingCanvasClientRect();if(!r)return;t=this.scene.pick(e.clientX-r.left,e.clientY-r.top,e=>{const t=h(e);return void 0!==t&&n(t)})}if(t&&t.hit&&t.pickedMesh){const n=h(t.pickedMesh);n&&i.callback(n,t.pickedPoint,e.button)}}}onPointerUp(e,t,n){if(!(e.button in this.mouseButtons))return;this.mouseButtons[e.button].isDown=!1}}function l(e,t=!1){for(;e.parent;)e=e.parent;const n=e;return t&&!n.handlers&&(n.handlers={}),n.handlers}function u(e,t){l(e,!0).pickable=t}function h(e){const t=l(e);return t?t.pickable:void 0}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var i=n(11),r=n(31),o=n(47),a=n(38),s=n(65);class c{constructor(e,t,n,r=100){this.mesh=e,this.terrain=t,this._health=r,this._attachedOutgoingEffects=[],this._attachedIncomingEffects=[],this._facingVector=i.Vector3.Zero(),this.damageRate=.5,this._velocity=i.Vector3.Zero(),Object(a.f)(this.mesh,n),Object(o.f)(this.mesh,this),c.mobs.push(this),s.c&&t.map.addMob(this),this.mesh.onDispose=()=>{this.onDispose(),s.c&&t.map.removeMob(this),c.mobs.splice(c.mobs.findIndex(e=>e===this),1),c.mobs.length<10&&console.log(`Only ${c.mobs.length-1} left...`)}}attachOutgoingEffect(e){this._attachedOutgoingEffects.push(e)}clearAttachedOutgoingEffects(){this._attachedOutgoingEffects.forEach(e=>{e.stop()}),this._attachedOutgoingEffects=[]}get attachedOutgoingEffects(){return this._attachedOutgoingEffects}attachIncomingEffect(e){this._attachedIncomingEffects.push(e)}clearAttachedIncomingEffects(){this._attachedIncomingEffects.forEach(e=>{e.stop()}),this._attachedIncomingEffects=[]}get attachedIncomingEffects(){return this._attachedIncomingEffects}set health(e){this._health<=0||(this._health=e,this._health<=0&&this.canDie()&&this.mesh.dispose())}get health(){return this._health}takeDamage(e){this.health-=e,this.onDamage(e,this.health)}canDie(){return!0}get name(){return this.mesh.name}set position(e){const t=this.mesh.position;this.mesh.position=e,s.c&&this.terrain.map.mobMoved(this,t)}get position(){return this.mesh.position}get identity(){return this}get layer(){return this.mesh.layerMask}teleport(e){this.position=e}get facingVector(){return this._facingVector}simAt(e){return{position:e,radius:this.radius,identity:this,layer:r.b.None.value}}lookAt(e){const t=new i.Vector3(e.x,this.position.y,e.z),n=this.mesh.position.subtract(t),r=this.position.add(n);return this.mesh.lookAt(r),this._facingVector=n,r}lookAwayFrom(e){const t=new i.Vector3(e.x,this.position.y,e.z);this.mesh.lookAt(t)}update(e){let t=[];this.attachedOutgoingEffects.forEach(n=>{n.update(e),n.stopped&&t.push(n)}),t.forEach(e=>{this.attachedOutgoingEffects.splice(this.attachedOutgoingEffects.findIndex(t=>t===e),1)}),t=[],this.attachedIncomingEffects.forEach(e=>{this.takeDamage(this.damageRate),e.stopped&&t.push(e)}),t.forEach(e=>{this.attachedIncomingEffects.splice(this.attachedIncomingEffects.findIndex(t=>t===e),1)})}set velocity(e){this._velocity=e}get velocity(){return this._velocity}isVisibleToCamera(){const e=i.Frustum.GetPlanes(this.mesh.getScene().getTransformMatrix());return this.mesh.isInFrustum(e)}sortMobsByDistance(e){return e.map(e=>({d:Math.pow(e.position.x-this.position.x,2)+Math.pow(e.position.y-this.position.y,2)+Math.pow(e.position.z-this.position.z,2),m:e})).sort((e,t)=>e.d>t.d?1:e.de.m)}onDispose(){this._health=0,this.clearAttachedIncomingEffects(),this.clearAttachedOutgoingEffects()}}c.mobs=[]},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){}return e.BuildArray=function(e,t){for(var n=[],i=0;i0)):!n._pointerCaptures[c.pointerId]&&a.distance>s.distance&&(n.mainSceneTrackerPredicate&&n.mainSceneTrackerPredicate(s.pickedMesh)?(n._notifyObservers(t,s,c),t.skipOnPointerObservable=!0):n._lastPointerEvents[c.pointerId]&&(n.onPointerOutObservable.notifyObservers(c.pointerId),delete n._lastPointerEvents[c.pointerId])),t.type===o.a.POINTERUP&&n._pointerCaptures[c.pointerId]&&(n._pointerCaptures[c.pointerId]=!1))}}}})),this._originalPointerObserver&&e.onPrePointerObservable.makeObserverTopPriority(this._originalPointerObserver)),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterRenderObservable.add((function(){n.shouldRender&&n.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){n.dispose()})),this._updateCamera()}return e.prototype._getSharedGizmoLight=function(){return this._sharedGizmoLight||(this._sharedGizmoLight=new s.a("shared gizmo light",new c.x(0,1,0),this.utilityLayerScene),this._sharedGizmoLight.intensity=2,this._sharedGizmoLight.groundColor=c.e.Gray()),this._sharedGizmoLight},Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultUtilityLayer=null}))),e._DefaultUtilityLayer},enumerable:!0,configurable:!0}),Object.defineProperty(e,"DefaultKeepDepthUtilityLayer",{get:function(){return null==e._DefaultKeepDepthUtilityLayer&&(e._DefaultKeepDepthUtilityLayer=new e(a.a.LastCreatedScene),e._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!0,configurable:!0}),e.prototype._notifyObservers=function(e,t,n){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new o.b(e.type,e.event,t)),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.onAfterRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()},e.prototype._updateCamera=function(){this.originalScene.activeCameras.length>1?this.utilityLayerScene.activeCamera=this.originalScene.activeCameras[this.originalScene.activeCameras.length-1]:this.utilityLayerScene.activeCamera=this.originalScene.activeCamera},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1),r=n(2),o=n(0),a=n(10),s=n(71),c=n(96),l=function(e){function t(t,n,i,r){void 0===r&&(r=!0);var s=e.call(this,t,n,i,r)||this;return s.ellipsoid=new o.x(.5,1,.5),s.ellipsoidOffset=new o.x(0,0,0),s.checkCollisions=!1,s.applyGravity=!1,s._needMoveForGravity=!1,s._oldPosition=o.x.Zero(),s._diffPosition=o.x.Zero(),s._newPosition=o.x.Zero(),s._collisionMask=-1,s._onCollisionPositionChange=function(e,t,n){void 0===n&&(n=null);var i;i=t,s._newPosition.copyFrom(i),s._newPosition.subtractToRef(s._oldPosition,s._diffPosition),s._diffPosition.length()>a.b.CollisionsEpsilon&&(s.position.addInPlace(s._diffPosition),s.onCollide&&n&&s.onCollide(n))},s.inputs=new c.a(s),s.inputs.addKeyboard().addMouse(),s}return i.d(t,e),Object.defineProperty(t.prototype,"angularSensibility",{get:function(){var e=this.inputs.attached.mouse;return e?e.angularSensibility:0},set:function(e){var t=this.inputs.attached.mouse;t&&(t.angularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysUp",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysUp:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysUp=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysDown",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysDown:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysDown=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysLeft",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysLeft:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysLeft=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"keysRight",{get:function(){var e=this.inputs.attached.keyboard;return e?e.keysRight:[]},set:function(e){var t=this.inputs.attached.keyboard;t&&(t.keysRight=e)},enumerable:!0,configurable:!0}),t.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},t.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new o.x(0,0,0),this.cameraRotation=new o.w(0,0)},Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),t.prototype._collideWithWorld=function(e){(this.parent?o.x.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset);var t=this.getScene().collisionCoordinator;this._collider||(this._collider=t.createCollider()),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var 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=o.x.Zero(),this._transformedDirection=o.x.Zero()),this.inputs.checkInputs(),e.prototype._checkInputs.call(this)},t.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):e.prototype._updatePosition.call(this)},t.prototype.dispose=function(){this.inputs.clear(),e.prototype.dispose.call(this)},t.prototype.getClassName=function(){return"FreeCamera"},i.c([Object(r.o)()],t.prototype,"ellipsoid",void 0),i.c([Object(r.o)()],t.prototype,"ellipsoidOffset",void 0),i.c([Object(r.c)()],t.prototype,"checkCollisions",void 0),i.c([Object(r.c)()],t.prototype,"applyGravity",void 0),t}(s.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return d}));var i=n(49),r=n(0),o=n(4),a=n(117),s=n(123),c={min:0,max:0},l={min:0,max:0},u=function(e,t,n){var i=r.x.Dot(t.centerWorld,e),o=Math.abs(r.x.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(r.x.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(r.x.Dot(t.directions[2],e))*t.extendSize.z;n.min=i-o,n.max=i+o},h=function(e,t,n){return u(e,t,c),u(e,n,l),!(c.min>l.max||l.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:!0,configurable:!0}),Object.defineProperty(e.prototype,"maximum",{get:function(){return this.boundingBox.maximum},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),e.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},e.prototype.centerOn=function(t,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.scale=function(e){return this.boundingBox.scale(e),this.boundingSphere.scale(e),this},e.prototype.isInFrustum=function(e,t){return void 0===t&&(t=o.a.MESHES_CULLINGSTRATEGY_STANDARD),!(t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY||!this.boundingSphere.isCenterInFrustum(e))||!!this.boundingSphere.isInFrustum(e)&&(!(t!==o.a.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY&&t!==o.a.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY)||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,"diagonalLength",{get:function(){var t=this.boundingBox;return t.maximumWorld.subtractToRef(t.minimumWorld,e.TmpVector3[0]).length()},enumerable:!0,configurable:!0}),e.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},e.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},e.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},e.prototype.intersects=function(e,t){if(!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.x.Cross(n.directions[0],i.directions[0]),n,i)&&(!!h(r.x.Cross(n.directions[0],i.directions[1]),n,i)&&(!!h(r.x.Cross(n.directions[0],i.directions[2]),n,i)&&(!!h(r.x.Cross(n.directions[1],i.directions[0]),n,i)&&(!!h(r.x.Cross(n.directions[1],i.directions[1]),n,i)&&(!!h(r.x.Cross(n.directions[1],i.directions[2]),n,i)&&(!!h(r.x.Cross(n.directions[2],i.directions[0]),n,i)&&(!!h(r.x.Cross(n.directions[2],i.directions[1]),n,i)&&!!h(r.x.Cross(n.directions[2],i.directions[2]),n,i))))))))))))))},e.TmpVector3=i.a.BuildArray(2,r.x.Zero),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1),r=n(2),o=n(178),a=n(0),s=n(68),c=n(26),l=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.ambientColor=new a.e(0,0,0),r.albedoColor=new a.e(1,1,1),r.reflectivityColor=new a.e(1,1,1),r.reflectionColor=new a.e(1,1,1),r.emissiveColor=new a.e(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=o.a.GetEnvironmentBRDFTexture(i),r}return i.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:!0,configurable:!0}),Object.defineProperty(t.prototype,"indexOfRefraction",{get:function(){return 1/this.subSurface.indexOfRefraction},set:function(e){this.subSurface.indexOfRefraction=1/e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"invertRefractionY",{get:function(){return this.subSurface.invertRefractionY},set:function(e){this.subSurface.invertRefractionY=e},enumerable:!0,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:!0,configurable:!0}),Object.defineProperty(t.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===s.a.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?s.a.LIGHTFALLOFF_PHYSICAL:s.a.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===s.a.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?s.a.LIGHTFALLOFF_GLTF:s.a.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"PBRMaterial"},t.prototype.clone=function(e){var n=this,i=r.a.Clone((function(){return new t(e,n.getScene())}),this);return i.id=e,i.name=e,this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),i},t.prototype.serialize=function(){var e=r.a.Serialize(this);return e.customType="BABYLON.PBRMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e},t.Parse=function(e,n,i){var o=r.a.Parse((function(){return new t(e.name,n)}),e,n,i);return e.clearCoat&&o.clearCoat.parse(e.clearCoat),e.anisotropy&&o.anisotropy.parse(e.anisotropy),e.brdf&&o.brdf.parse(e.brdf),e.sheen&&o.sheen.parse(e.brdf),o},t.PBRMATERIAL_OPAQUE=s.a.PBRMATERIAL_OPAQUE,t.PBRMATERIAL_ALPHATEST=s.a.PBRMATERIAL_ALPHATEST,t.PBRMATERIAL_ALPHABLEND=s.a.PBRMATERIAL_ALPHABLEND,t.PBRMATERIAL_ALPHATESTANDBLEND=s.a.PBRMATERIAL_ALPHATESTANDBLEND,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=s.a.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"directIntensity",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveIntensity",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentIntensity",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"specularIntensity",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"disableBumpMap",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTexture",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureStrength",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"opacityTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallicTexture",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurfaceTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"bumpTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty",null)],t.prototype,"lightmapTexture",void 0),i.c([Object(r.e)("ambient"),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"ambientColor",void 0),i.c([Object(r.e)("albedo"),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"albedoColor",void 0),i.c([Object(r.e)("reflectivity"),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectivityColor",void 0),i.c([Object(r.e)("reflection"),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"reflectionColor",void 0),i.c([Object(r.e)("emissive"),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"emissiveColor",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"microSurface",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLightmapAsShadowmap",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"useAlphaFromAlbedoTexture",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"forceAlphaTest",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesAndMiscDirty")],t.prototype,"alphaCutOff",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useSpecularOverAlpha",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRoughnessFromMetallicTextureGreen",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useMetallnessFromMetallicTextureBlue",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAmbientInGrayScale",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),i.c([Object(r.c)()],t.prototype,"usePhysicalLightFalloff",null),i.c([Object(r.c)()],t.prototype,"useGLTFLightFalloff",null),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOverAlpha",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useObjectSpaceNormalMap",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallax",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useParallaxOcclusion",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"parallaxScaleBias",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"disableLighting",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceIrradianceInFragment",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsLightsDirty")],t.prototype,"maxSimultaneousLights",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapX",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"invertNormalMapY",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"twoSidedLighting",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useAlphaFresnel",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useLinearAlphaFresnel",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"environmentBRDFTexture",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"forceNormalForward",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"enableSpecularAntiAliasing",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useHorizonOcclusion",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"useRadianceOcclusion",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"unlit",void 0),t}(s.a);c.a.RegisteredTypes["BABYLON.PBRMaterial"]=l},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var i=n(1),r=n(2),o=n(7),a=n(5),s=n(110),c=n(0),l=n(27),u=n(4),h=function(){function e(t){this.metadata=null,this.reservedDataStore=null,this._hasAlpha=!1,this.getAlphaFromRGB=!1,this.level=1,this.coordinatesIndex=0,this._coordinatesMode=u.a.TEXTURE_EXPLICIT_MODE,this.wrapU=u.a.TEXTURE_WRAP_ADDRESSMODE,this.wrapV=u.a.TEXTURE_WRAP_ADDRESSMODE,this.wrapR=u.a.TEXTURE_WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=e.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this.gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new o.c,this._onDisposeObserver=null,this.delayLoadState=u.a.DELAYLOADSTATE_NONE,this._scene=null,this._texture=null,this._uid=null,this._cachedSize=c.r.Zero(),this._scene=t||l.a.LastCreatedScene,this._scene&&(this.uniqueId=this._scene.getUniqueId(),this._scene.addTexture(this)),this._uid=null}return Object.defineProperty(e.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(u.a.MATERIAL_TextureDirtyFlag|u.a.MATERIAL_MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(u.a.MATERIAL_TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isCube",{get:function(){return!!this._texture&&this._texture.isCube},set:function(e){this._texture&&(this._texture.isCube=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"is3D",{get:function(){return!!this._texture&&this._texture.is3D},set:function(e){this._texture&&(this._texture.is3D=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isRGBD",{get:function(){return null!=this._texture&&this._texture._isRGBD},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"noMipmap",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(e){this._texture&&(this._texture._lodGenerationOffset=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0},set:function(e){this._texture&&(this._texture._lodGenerationScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uid",{get:function(){return this._uid||(this._uid=a.h.RandomId()),this._uid},enumerable:!0,configurable:!0}),e.prototype.toString=function(){return this.name},e.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBlocking",{get:function(){return!0},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getTextureMatrix=function(){return c.j.IdentityReadOnly},e.prototype.getReflectionTextureMatrix=function(){return c.j.IdentityReadOnly},e.prototype.getInternalTexture=function(){return this._texture},e.prototype.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()},e.prototype.isReady=function(){return this.delayLoadState===u.a.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},e.prototype.getSize=function(){if(this._texture){if(this._texture.width)return this._cachedSize.width=this._texture.width,this._cachedSize.height=this._texture.height,this._cachedSize;if(this._texture._size)return this._cachedSize.width=this._texture._size,this._cachedSize.height=this._texture._size,this._cachedSize}return this._cachedSize},e.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new c.r(this._texture._size,this._texture._size):new c.r(this._texture.baseWidth,this._texture.baseHeight):c.r.Zero()},e.prototype.updateSamplingMode=function(e){if(this._texture){var t=this.getScene();t&&t.getEngine().updateTextureSamplingMode(e,this._texture)}},e.prototype.scale=function(e){},Object.defineProperty(e.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),e.prototype._getFromCache=function(e,t,n,i){if(!this._scene)return null;for(var r=this._scene.getEngine().getLoadedTexturesCache(),o=0;o=0&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())}},e.prototype.serialize=function(){if(!this.name)return null;var e=r.a.Serialize(this);return r.a.AppendSerializedAnimations(this,e),e},e.WhenAllReady=function(e,t){var n=e.length;if(0!==n)for(var i,r,o=function(){if((i=e[a]).isReady())0==--n&&t();else{r=i.onLoadObservable;var o=function(){r.removeCallback(o),0==--n&&t()};r.add(o)}},a=0;ar&&(r=c.width)}if(this._resizeToFit){if(this._textWrapping===i.Clip){var l=this.paddingLeftInPixels+this.paddingRightInPixels+r;l!==this._width.internalValue&&(this._width.updateInPlace(l,a.a.UNITMODE_PIXEL),this._rebuildLayout=!0)}var u=this.paddingTopInPixels+this.paddingBottomInPixels+this._fontOffset.height*this._lines.length;u!==this._height.internalValue&&(this._height.updateInPlace(u,a.a.UNITMODE_PIXEL),this._rebuildLayout=!0)}},t.prototype._drawText=function(e,t,n,i){var r=this._currentMeasure.width,o=0;switch(this._textHorizontalAlignment){case s.a.HORIZONTAL_ALIGNMENT_LEFT:o=0;break;case s.a.HORIZONTAL_ALIGNMENT_RIGHT:o=r-t;break;case s.a.HORIZONTAL_ALIGNMENT_CENTER:o=(r-t)/2}(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(i.shadowColor=this.shadowColor,i.shadowBlur=this.shadowBlur,i.shadowOffsetX=this.shadowOffsetX,i.shadowOffsetY=this.shadowOffsetY),this.outlineWidth&&i.strokeText(e,this._currentMeasure.left+o,n),i.fillText(e,this._currentMeasure.left+o,n)},t.prototype._draw=function(e){e.save(),this._applyStates(e),this._renderLines(e),e.restore()},t.prototype._applyStates=function(t){e.prototype._applyStates.call(this,t),this.outlineWidth&&(t.lineWidth=this.outlineWidth,t.strokeStyle=this.outlineColor)},t.prototype._breakLines=function(e,t){var n=[],r=this.text.split("\n");if(this._textWrapping===i.Ellipsis)for(var o=0,a=r;ot&&(e+="…");e.length>2&&i>t;)e=e.slice(0,-2)+"…",i=n.measureText(e).width;return{text:e,width:i}},t.prototype._parseLineWordWrap=function(e,t,n){void 0===e&&(e="");for(var i=[],r=e.split(" "),o=0,a=0;a0?e+" "+r[a]:r[0],c=n.measureText(s).width;c>t&&a>0?(i.push({text:e,width:o}),e=r[a],o=n.measureText(e).width):(o=c,e=s)}return i.push({text:e,width:o}),i},t.prototype._renderLines=function(e){var t=this._currentMeasure.height,n=0;switch(this._textVerticalAlignment){case s.a.VERTICAL_ALIGNMENT_TOP:n=this._fontOffset.ascent;break;case s.a.VERTICAL_ALIGNMENT_BOTTOM:n=t-this._fontOffset.height*(this._lines.length-1)-this._fontOffset.descent;break;case s.a.VERTICAL_ALIGNMENT_CENTER:n=this._fontOffset.ascent+(t-this._fontOffset.height*this._lines.length)/2}n+=this._currentMeasure.top;for(var i=0;i0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=t),e._syncGeometryWithMorphTargetManager(),e.synchronizeInstances()},e.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,n=this._meshes;t0){for(var t=0;t0){for(t=0;t0){for(t=0;t0){var u=new Float32Array(t,l.positionsAttrDesc.offset,l.positionsAttrDesc.count);n.setVerticesData(o.b.PositionKind,u,!1)}if(l.normalsAttrDesc&&l.normalsAttrDesc.count>0){var h=new Float32Array(t,l.normalsAttrDesc.offset,l.normalsAttrDesc.count);n.setVerticesData(o.b.NormalKind,h,!1)}if(l.tangetsAttrDesc&&l.tangetsAttrDesc.count>0){var d=new Float32Array(t,l.tangetsAttrDesc.offset,l.tangetsAttrDesc.count);n.setVerticesData(o.b.TangentKind,d,!1)}if(l.uvsAttrDesc&&l.uvsAttrDesc.count>0){var f=new Float32Array(t,l.uvsAttrDesc.offset,l.uvsAttrDesc.count);n.setVerticesData(o.b.UVKind,f,!1)}if(l.uvs2AttrDesc&&l.uvs2AttrDesc.count>0){var p=new Float32Array(t,l.uvs2AttrDesc.offset,l.uvs2AttrDesc.count);n.setVerticesData(o.b.UV2Kind,p,!1)}if(l.uvs3AttrDesc&&l.uvs3AttrDesc.count>0){var m=new Float32Array(t,l.uvs3AttrDesc.offset,l.uvs3AttrDesc.count);n.setVerticesData(o.b.UV3Kind,m,!1)}if(l.uvs4AttrDesc&&l.uvs4AttrDesc.count>0){var g=new Float32Array(t,l.uvs4AttrDesc.offset,l.uvs4AttrDesc.count);n.setVerticesData(o.b.UV4Kind,g,!1)}if(l.uvs5AttrDesc&&l.uvs5AttrDesc.count>0){var _=new Float32Array(t,l.uvs5AttrDesc.offset,l.uvs5AttrDesc.count);n.setVerticesData(o.b.UV5Kind,_,!1)}if(l.uvs6AttrDesc&&l.uvs6AttrDesc.count>0){var v=new Float32Array(t,l.uvs6AttrDesc.offset,l.uvs6AttrDesc.count);n.setVerticesData(o.b.UV6Kind,v,!1)}if(l.colorsAttrDesc&&l.colorsAttrDesc.count>0){var b=new Float32Array(t,l.colorsAttrDesc.offset,l.colorsAttrDesc.count);n.setVerticesData(o.b.ColorKind,b,!1,l.colorsAttrDesc.stride)}if(l.matricesIndicesAttrDesc&&l.matricesIndicesAttrDesc.count>0){for(var y=new Int32Array(t,l.matricesIndicesAttrDesc.offset,l.matricesIndicesAttrDesc.count),x=[],C=0;C>8),x.push((16711680&E)>>16),x.push(E>>24)}n.setVerticesData(o.b.MatricesIndicesKind,x,!1)}if(l.matricesWeightsAttrDesc&&l.matricesWeightsAttrDesc.count>0){var T=new Float32Array(t,l.matricesWeightsAttrDesc.offset,l.matricesWeightsAttrDesc.count);n.setVerticesData(o.b.MatricesWeightsKind,T,!1)}if(l.indicesAttrDesc&&l.indicesAttrDesc.count>0){var S=new Int32Array(t,l.indicesAttrDesc.offset,l.indicesAttrDesc.count);n.setIndices(S,null)}if(l.subMeshesAttrDesc&&l.subMeshesAttrDesc.count>0){var A=new Int32Array(t,l.subMeshesAttrDesc.offset,5*l.subMeshesAttrDesc.count);n.subMeshes=[];for(C=0;C>8),x.push((16711680&I)>>16),x.push(I>>24)}n.setVerticesData(o.b.MatricesIndicesKind,x,t.matricesIndices._updatable)}if(t.matricesIndicesExtra)if(t.matricesIndicesExtra._isExpanded)delete t.matricesIndices._isExpanded,n.setVerticesData(o.b.MatricesIndicesExtraKind,t.matricesIndicesExtra,t.matricesIndicesExtra._updatable);else{for(x=[],C=0;C>8),x.push((16711680&I)>>16),x.push(I>>24)}n.setVerticesData(o.b.MatricesIndicesExtraKind,x,t.matricesIndicesExtra._updatable)}t.matricesWeights&&(e._CleanMatricesWeights(t,n),n.setVerticesData(o.b.MatricesWeightsKind,t.matricesWeights,t.matricesWeights._updatable)),t.matricesWeightsExtra&&n.setVerticesData(o.b.MatricesWeightsExtraKind,t.matricesWeightsExtra,t.matricesWeights._updatable),n.setIndices(t.indices,null)}if(t.subMeshes){n.subMeshes=[];for(var L=0;L-1){var i=t.getScene().getLastSkeletonByID(e.skeletonId);if(i){n=i.bones.length;for(var r=t.getVerticesData(o.b.MatricesIndicesKind),a=t.getVerticesData(o.b.MatricesIndicesExtraKind),c=e.matricesWeights,l=e.matricesWeightsExtra,u=e.numBoneInfluencer,h=c.length,d=0;du-1)&&(p=u-1),f>.001){var _=1/f;for(m=0;m<4;m++)c[d+m]*=_;if(l)for(m=0;m<4;m++)l[d+m]*=_}else p>=4?(l[d+p-4]=1-f,a[d+p-4]=n):(c[d+p]=1-f,r[d+p]=n)}t.setVerticesData(o.b.MatricesIndicesKind,r),e.matricesWeightsExtra&&t.setVerticesData(o.b.MatricesIndicesExtraKind,a)}}}},e.Parse=function(t,n,a){if(n.getGeometryByID(t.id))return null;var s=new e(t.id,n,void 0,t.updatable);return h.a&&h.a.AddTagsTo(s,t.tags),t.delayLoadingFile?(s.delayLoadState=l.a.DELAYLOADSTATE_NOTLOADED,s.delayLoadingFile=a+t.delayLoadingFile,s._boundingInfo=new c.a(i.x.FromArray(t.boundingBoxMinimum),i.x.FromArray(t.boundingBoxMaximum)),s._delayInfo=[],t.hasUVs&&s._delayInfo.push(o.b.UVKind),t.hasUVs2&&s._delayInfo.push(o.b.UV2Kind),t.hasUVs3&&s._delayInfo.push(o.b.UV3Kind),t.hasUVs4&&s._delayInfo.push(o.b.UV4Kind),t.hasUVs5&&s._delayInfo.push(o.b.UV5Kind),t.hasUVs6&&s._delayInfo.push(o.b.UV6Kind),t.hasColors&&s._delayInfo.push(o.b.ColorKind),t.hasMatricesIndices&&s._delayInfo.push(o.b.MatricesIndicesKind),t.hasMatricesWeights&&s._delayInfo.push(o.b.MatricesWeightsKind),s._delayLoadingFunction=r.a.ImportVertexData):r.a.ImportVertexData(t,s),n.pushGeometry(s,!0),s},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(0),r=n(138),o=function(){function e(e,t,n,i){this.left=e,this.top=t,this.width=n,this.height=i}return e.prototype.copyFrom=function(e){this.left=e.left,this.top=e.top,this.width=e.width,this.height=e.height},e.prototype.copyFromFloats=function(e,t,n,i){this.left=e,this.top=t,this.width=n,this.height=i},e.CombineToRef=function(e,t,n){var i=Math.min(e.left,t.left),r=Math.min(e.top,t.top),o=Math.max(e.left+e.width,t.left+t.width),a=Math.max(e.top+e.height,t.top+t.height);n.left=i,n.top=r,n.width=o-i,n.height=a-r},e.prototype.transformToRef=function(e,t){for(var n=r.a.Rectangle(this.left,this.top,this.left+this.width,this.top+this.height),o=new i.w(Number.MAX_VALUE,Number.MAX_VALUE),a=new i.w(0,0),s=0;s<4;s++)e.transformCoordinates(n[s].x,n[s].y,n[s]),o.x=Math.floor(Math.min(o.x,n[s].x)),o.y=Math.floor(Math.min(o.y,n[s].y)),a.x=Math.ceil(Math.max(a.x,n[s].x)),a.y=Math.ceil(Math.max(a.y,n[s].y));t.left=o.x,t.top=o.y,t.width=a.x-o.x,t.height=a.y-o.y},e.prototype.isEqualsTo=function(e){return this.left===e.left&&(this.top===e.top&&(this.width===e.width&&this.height===e.height))},e.Empty=function(){return new e(0,0,0,0)},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(0),r=n(12),o=n(14);o.a.CreateBox=function(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],r=[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],a=[],s=e.width||e.size||1,c=e.height||e.size||1,l=e.depth||e.size||1,u=e.wrap||!1,h=void 0===e.topBaseAt?1:e.topBaseAt,d=void 0===e.bottomBaseAt?0:e.bottomBaseAt,f=[2,0,3,1][h=(h+4)%4],p=[2,0,1,3][d=(d+4)%4],m=[1,-1,1,-1,-1,1,-1,1,1,1,1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,-1,1,-1,1,1,1,1,-1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,-1,1,-1,1,1,-1,1,1,1,1,-1,1,1,-1,-1,-1,-1,-1,-1,-1,1];if(u){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],m=[-1,1,1,1,1,1,1,-1,1,-1,-1,1,1,1,-1,-1,1,-1,-1,-1,-1,1,-1,-1,1,1,1,1,1,-1,1,-1,-1,1,-1,1,-1,1,-1,-1,1,1,-1,-1,1,-1,-1,-1];for(var g=[[1,1,1],[-1,1,1],[-1,1,-1],[1,1,-1]],_=[[-1,-1,1],[1,-1,1],[1,-1,-1],[-1,-1,-1]],v=[17,18,19,16],b=[22,23,20,21];f>0;)g.unshift(g.pop()),v.unshift(v.pop()),f--;for(;p>0;)_.unshift(_.pop()),b.unshift(b.pop()),p--;g=g.flat(),_=_.flat(),m=m.concat(g).concat(_),n.push(v[0],v[2],v[3],v[0],v[1],v[2]),n.push(b[0],b[2],b[3],b[0],b[1],b[2])}var y=[s/2,c/2,l/2];t=m.reduce((function(e,t,n){return e.concat(t*y[n%3])}),[]);for(var x=0===e.sideOrientation?0:e.sideOrientation||o.a.DEFAULTSIDE,C=e.faceUV||new Array(6),E=e.faceColors,T=[],S=0;S<6;S++)void 0===C[S]&&(C[S]=new i.y(0,0,1,1)),E&&void 0===E[S]&&(E[S]=new i.f(1,1,1,1));for(var A=0;A<6;A++)if(a.push(C[A].z,C[A].w),a.push(C[A].x,C[A].w),a.push(C[A].x,C[A].y),a.push(C[A].z,C[A].y),E)for(var P=0;P<4;P++)T.push(E[A].r,E[A].g,E[A].b,E[A].a);o.a._ComputeSides(x,t,n,r,a,e.frontUVs,e.backUVs);var M=new o.a;if(M.indices=n,M.positions=t,M.normals=r,M.uvs=a,E){var O=x===o.a.DOUBLESIDE?T.concat(T):T;M.colors=O}return M},r.a.CreateBox=function(e,t,n,i,r){void 0===n&&(n=null);var o={size:t,sideOrientation:r,updatable:i};return a.CreateBox(e,o,n)};var a=function(){function e(){}return e.CreateBox=function(e,t,n){void 0===n&&(n=null);var i=new r.a(e,n);return t.sideOrientation=r.a._GetDefaultSideOrientation(t.sideOrientation),i._originalBuilderSideOrientation=t.sideOrientation,o.a.CreateBox(t).applyToMesh(i,t.updatable),i},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return l})),n.d(t,"b",(function(){return u}));var i=n(1),r=n(5),o=n(3),a=n(122),s=n(54),c=n(4),l=function(){function e(){this._materialDefines=null,this._materialEffect=null}return Object.defineProperty(e.prototype,"effect",{get:function(){return this._materialEffect},enumerable:!0,configurable:!0}),e.prototype.setEffect=function(e,t){void 0===t&&(t=null),this._materialEffect!==e?(this._materialDefines=t,this._materialEffect=e):e||(this._materialDefines=null)},e}(),u=function(e){function t(t,n,i,r,o,a,s,c){void 0===c&&(c=!0);var l=e.call(this)||this;return l.materialIndex=t,l.verticesStart=n,l.verticesCount=i,l.indexStart=r,l.indexCount=o,l._linesIndexCount=0,l._linesIndexBuffer=null,l._lastColliderWorldVertices=null,l._lastColliderTransformMatrix=null,l._renderId=0,l._alphaIndex=0,l._distanceToCamera=0,l._currentMaterial=null,l._mesh=a,l._renderingMesh=s||a,a.subMeshes.push(l),l._trianglePlanes=[],l._id=a.subMeshes.length-1,c&&(l.refreshBoundingInfo(),a.computeWorldMatrix(!0)),l}return i.d(t,e),t.AddToMesh=function(e,n,i,r,o,a,s,c){return void 0===c&&(c=!0),new t(e,n,i,r,o,a,s,c)},Object.defineProperty(t.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!0,configurable:!0}),t.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},t.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},t.prototype.getMesh=function(){return this._mesh},t.prototype.getRenderingMesh=function(){return this._renderingMesh},t.prototype.getMaterial=function(){var e=this._renderingMesh.material;if(null==e)return this._mesh.getScene().defaultMaterial;if(e.getSubMaterial){var t=e.getSubMaterial(this.materialIndex);return this._currentMaterial!==t&&(this._currentMaterial=t,this._materialDefines=null),t}return e},t.prototype.refreshBoundingInfo=function(e){if(void 0===e&&(e=null),this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;if(e||(e=this._renderingMesh.getVerticesData(o.b.PositionKind)),!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var t,n=this._renderingMesh.getIndices();if(0===this.indexStart&&this.indexCount===n.length){var i=this._renderingMesh.getBoundingInfo();t={minimum:i.minimum.clone(),maximum:i.maximum.clone()}}else t=r.h.ExtractMinAndMaxIndexed(e,n,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo?this._boundingInfo.reConstruct(t.minimum,t.maximum):this._boundingInfo=new s.a(t.minimum,t.maximum),this},t.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},t.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t.update(e),this},t.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)},t.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)},t.prototype.render=function(e){return this._renderingMesh.render(this,e),this},t.prototype._getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var n=[],i=this.indexStart;is&&(s=u)}return new t(e,a,s-a+1,n,i,r,o)},t}(l)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));class i{containsRunes(e){for(const t of e)if(!this.requiredRunes().has(t))return!1;return!0}missingRunes(e){const t=new Set(this.requiredRunes());for(const n of e)t.delete(n);return t}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(50),r=function(){function e(){}return Object.defineProperty(e,"Now",{get:function(){return i.a.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!0,configurable:!0}),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(1),r=function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e}(),o=function(e,t){this.type=e,this.event=t},a=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i.type=t,i.event=n,i.skipOnPointerObservable=!1,i}return i.d(t,e),t}(o)},function(e,t,n){"use strict";n.d(t,"e",(function(){return i})),n.d(t,"f",(function(){return r})),n.d(t,"c",(function(){return o})),n.d(t,"b",(function(){return a})),n.d(t,"d",(function(){return s})),n.d(t,"a",(function(){return c}));const i=12,r=900,o=!0,a=250,s=!1,c=!1},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(1),r=n(9),o=n(20),a=n(59),s=function(e){function t(t){var n=e.call(this,t)||this;return n.name=t,n._children=new Array,n._measureForChildren=a.a.Empty(),n._background="",n._adaptWidthToChildren=!1,n._adaptHeightToChildren=!1,n}return i.d(t,e),Object.defineProperty(t.prototype,"adaptHeightToChildren",{get:function(){return this._adaptHeightToChildren},set:function(e){this._adaptHeightToChildren!==e&&(this._adaptHeightToChildren=e,e&&(this.height="100%"),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"adaptWidthToChildren",{get:function(){return this._adaptWidthToChildren},set:function(e){this._adaptWidthToChildren!==e&&(this._adaptWidthToChildren=e,e&&(this.width="100%"),this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"children",{get:function(){return this._children},enumerable:!0,configurable:!0}),t.prototype._getTypeName=function(){return"Container"},t.prototype._flagDescendantsAsMatrixDirty=function(){for(var e=0,t=this.children;ee.zIndex){this._children.splice(n,0,e),t=!0;break}t||this._children.push(e),e.parent=this,this._markAsDirty()},t.prototype._offsetLeft=function(t){e.prototype._offsetLeft.call(this,t);for(var n=0,i=this._children;n=0&&this.width!==i+"px"&&(this.width=i+"px",this._rebuildLayout=!0),this.adaptHeightToChildren&&o>=0&&this.height!==o+"px"&&(this.height=o+"px",this._rebuildLayout=!0),this._postMeasure()}n++}while(this._rebuildLayout&&n<3);return n>=3&&r.a.Error("Layout cycle detected in GUI (Container name="+this.name+", uniqueId="+this.uniqueId+")"),t.restore(),this._isDirty&&(this.invalidateRect(),this._isDirty=!1),!0},t.prototype._postMeasure=function(){},t.prototype._draw=function(e,t){this._localDraw(e),this.clipChildren&&this._clipForChildren(e);for(var n=0,i=this._children;n=0;a--){var s=this._children[a];if(s._processPicking(t,n,i,r,o))return s.hoverCursor&&this._host._changeCursor(s.hoverCursor),!0}return!!this.isHitTestVisible&&this._processObservables(i,t,n,r,o)},t.prototype._additionalProcessing=function(t,n){e.prototype._additionalProcessing.call(this,t,n),this._measureForChildren.copyFrom(this._currentMeasure)},t.prototype.dispose=function(){e.prototype.dispose.call(this);for(var t=this.children.length-1;t>=0;t--)this.children[t].dispose()},t}(o.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(0),r=n(3),o=function(){function e(){this._pickingUnavailable=!1,this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshId=0,this.pickedSprite=null,this.originMesh=null,this.ray=null}return e.prototype.getNormal=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(r.b.NormalKind))return null;var n,o=this.pickedMesh.getIndices();if(!o)return null;if(t){var a=this.pickedMesh.getVerticesData(r.b.NormalKind),s=i.x.FromArray(a,3*o[3*this.faceId]),c=i.x.FromArray(a,3*o[3*this.faceId+1]),l=i.x.FromArray(a,3*o[3*this.faceId+2]);s=s.scale(this.bu),c=c.scale(this.bv),l=l.scale(1-this.bu-this.bv),n=new i.x(s.x+c.x+l.x,s.y+c.y+l.y,s.z+c.z+l.z)}else{var u=this.pickedMesh.getVerticesData(r.b.PositionKind),h=i.x.FromArray(u,3*o[3*this.faceId]),d=i.x.FromArray(u,3*o[3*this.faceId+1]),f=i.x.FromArray(u,3*o[3*this.faceId+2]),p=h.subtract(d),m=f.subtract(d);n=i.x.Cross(p,m)}if(e){var g=this.pickedMesh.getWorldMatrix();this.pickedMesh.nonUniformScaling&&(i.t.Matrix[0].copyFrom(g),(g=i.t.Matrix[0]).setTranslationFromFloats(0,0,0),g.invert(),g.transposeToRef(i.t.Matrix[1]),g=i.t.Matrix[1]),n=i.x.TransformNormal(n,g)}return n.normalize(),n},e.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(r.b.UVKind))return null;var e=this.pickedMesh.getIndices();if(!e)return null;var t=this.pickedMesh.getVerticesData(r.b.UVKind);if(!t)return null;var n=i.w.FromArray(t,2*e[3*this.faceId]),o=i.w.FromArray(t,2*e[3*this.faceId+1]),a=i.w.FromArray(t,2*e[3*this.faceId+2]);return n=n.scale(1-this.bu-this.bv),o=o.scale(this.bu),a=a.scale(this.bv),new i.w(n.x+o.x+a.x,n.y+o.y+a.y)},e}()},function(e,t,n){"use strict";var i=n(1),r=n(2),o=n(9),a=n(40),s=n(178),c=n(19),l=n(0),u=n(3),h=n(21),d=n(18),f=function(){function e(t){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.roughness=0,this._indiceOfRefraction=e._DefaultIndiceOfRefraction,this.indiceOfRefraction=e._DefaultIndiceOfRefraction,this._texture=null,this.texture=null,this._bumpTexture=null,this.bumpTexture=null,this._isTintEnabled=!1,this.isTintEnabled=!1,this.tintColor=l.e.White(),this.tintColorAtDistance=1,this.tintThickness=1,this._tintTexture=null,this.tintTexture=null,this._internalMarkAllSubMeshesAsTexturesDirty=t}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t,n,i){if(e._areTexturesDirty&&t.texturesEnabled){if(this._texture&&h.a.ClearCoatTextureEnabled&&!this._texture.isReadyOrNotBlocking())return!1;if(n.getCaps().standardDerivatives&&this._bumpTexture&&h.a.ClearCoatBumpTextureEnabled&&!i&&!this._bumpTexture.isReady())return!1;if(this._isTintEnabled&&this._tintTexture&&h.a.ClearCoatTintTextureEnabled&&!this._tintTexture.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(t,n){this._isEnabled?(t.CLEARCOAT=!0,t._areTexturesDirty&&n.texturesEnabled&&(this._texture&&h.a.ClearCoatTextureEnabled?d.a.PrepareDefinesForMergedUV(this._texture,t,"CLEARCOAT_TEXTURE"):t.CLEARCOAT_TEXTURE=!1,this._bumpTexture&&h.a.ClearCoatBumpTextureEnabled?d.a.PrepareDefinesForMergedUV(this._bumpTexture,t,"CLEARCOAT_BUMP"):t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_DEFAULTIOR=this._indiceOfRefraction===e._DefaultIndiceOfRefraction,this._isTintEnabled?(t.CLEARCOAT_TINT=!0,this._tintTexture&&h.a.ClearCoatTintTextureEnabled?d.a.PrepareDefinesForMergedUV(this._tintTexture,t,"CLEARCOAT_TINT_TEXTURE"):t.CLEARCOAT_TINT_TEXTURE=!1):(t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1))):(t.CLEARCOAT=!1,t.CLEARCOAT_TEXTURE=!1,t.CLEARCOAT_BUMP=!1,t.CLEARCOAT_TINT=!1,t.CLEARCOAT_TINT_TEXTURE=!1)},e.prototype.bindForSubMesh=function(e,t,n,i,r,o,a){if(!e.useUbo||!r||!e.isSync){this._texture&&h.a.ClearCoatTextureEnabled&&(e.updateFloat2("vClearCoatInfos",this._texture.coordinatesIndex,this._texture.level),d.a.BindTextureMatrix(this._texture,e,"clearCoat")),this._bumpTexture&&n.getCaps().standardDerivatives&&h.a.ClearCoatTextureEnabled&&!i&&(e.updateFloat2("vClearCoatBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level),d.a.BindTextureMatrix(this._bumpTexture,e,"clearCoatBump"),t._mirroredCameraPosition?e.updateFloat2("vClearCoatTangentSpaceParams",o?1:-1,a?1:-1):e.updateFloat2("vClearCoatTangentSpaceParams",o?-1:1,a?-1:1)),this._tintTexture&&h.a.ClearCoatTintTextureEnabled&&(e.updateFloat2("vClearCoatTintInfos",this._tintTexture.coordinatesIndex,this._tintTexture.level),d.a.BindTextureMatrix(this._tintTexture,e,"clearCoatTint")),e.updateFloat2("vClearCoatParams",this.intensity,this.roughness);var s=1-this._indiceOfRefraction,c=1+this._indiceOfRefraction,l=Math.pow(-s/c,2),u=1/this._indiceOfRefraction;e.updateFloat4("vClearCoatRefractionParams",l,u,s,c),this._isTintEnabled&&(e.updateFloat4("vClearCoatTintParams",this.tintColor.r,this.tintColor.g,this.tintColor.b,Math.max(1e-5,this.tintThickness)),e.updateFloat("clearCoatColorAtDistance",Math.max(1e-5,this.tintColorAtDistance)))}t.texturesEnabled&&(this._texture&&h.a.ClearCoatTextureEnabled&&e.setTexture("clearCoatSampler",this._texture),this._bumpTexture&&n.getCaps().standardDerivatives&&h.a.ClearCoatBumpTextureEnabled&&!i&&e.setTexture("clearCoatBumpSampler",this._bumpTexture),this._isTintEnabled&&this._tintTexture&&h.a.ClearCoatTintTextureEnabled&&e.setTexture("clearCoatTintSampler",this._tintTexture))},e.prototype.hasTexture=function(e){return this._texture===e||(this._bumpTexture===e||this._tintTexture===e)},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture),this._bumpTexture&&e.push(this._bumpTexture),this._tintTexture&&e.push(this._tintTexture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._tintTexture&&this._tintTexture.animations&&this._tintTexture.animations.length>0&&e.push(this._tintTexture)},e.prototype.dispose=function(e){e&&(this._texture&&this._texture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._tintTexture&&this._tintTexture.dispose())},e.prototype.getClassName=function(){return"PBRClearCoatConfiguration"},e.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},e.AddUniforms=function(e){e.push("vClearCoatTangentSpaceParams","vClearCoatParams","vClearCoatRefractionParams","vClearCoatTintParams","clearCoatColorAtDistance","clearCoatMatrix","clearCoatBumpMatrix","clearCoatTintMatrix","vClearCoatInfos","vClearCoatBumpInfos","vClearCoatTintInfos")},e.AddSamplers=function(e){e.push("clearCoatSampler","clearCoatBumpSampler","clearCoatTintSampler")},e.PrepareUniformBuffer=function(e){e.addUniform("vClearCoatParams",2),e.addUniform("vClearCoatRefractionParams",4),e.addUniform("vClearCoatInfos",2),e.addUniform("clearCoatMatrix",16),e.addUniform("vClearCoatBumpInfos",2),e.addUniform("vClearCoatTangentSpaceParams",2),e.addUniform("clearCoatBumpMatrix",16),e.addUniform("vClearCoatTintParams",4),e.addUniform("clearCoatColorAtDistance",1),e.addUniform("vClearCoatTintInfos",2),e.addUniform("clearCoatTintMatrix",16)},e.prototype.copyTo=function(e){r.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.prototype.parse=function(e){var t=this;r.a.Parse((function(){return t}),e,null)},e._DefaultIndiceOfRefraction=1.5,i.c([Object(r.c)()],e.prototype,"_isEnabled",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),i.c([Object(r.c)()],e.prototype,"intensity",void 0),i.c([Object(r.c)()],e.prototype,"roughness",void 0),i.c([Object(r.c)()],e.prototype,"_indiceOfRefraction",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indiceOfRefraction",void 0),i.c([Object(r.m)()],e.prototype,"_texture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),i.c([Object(r.m)()],e.prototype,"_bumpTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"bumpTexture",void 0),i.c([Object(r.c)()],e.prototype,"_isTintEnabled",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTintEnabled",void 0),i.c([Object(r.e)()],e.prototype,"tintColor",void 0),i.c([Object(r.c)()],e.prototype,"tintColorAtDistance",void 0),i.c([Object(r.c)()],e.prototype,"tintThickness",void 0),i.c([Object(r.m)()],e.prototype,"_tintTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"tintTexture",void 0),e}(),p=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this.intensity=1,this.direction=new l.w(1,0),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&h.a.AnisotropicTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t,n){this._isEnabled?(e.ANISOTROPIC=this._isEnabled,this._isEnabled&&!t.isVerticesDataPresent(u.b.TangentKind)&&(e._needUVs=!0,e.MAINUV1=!0),e._areTexturesDirty&&n.texturesEnabled&&(this._texture&&h.a.AnisotropicTextureEnabled?d.a.PrepareDefinesForMergedUV(this._texture,e,"ANISOTROPIC_TEXTURE"):e.ANISOTROPIC_TEXTURE=!1)):(e.ANISOTROPIC=!1,e.ANISOTROPIC_TEXTURE=!1)},e.prototype.bindForSubMesh=function(e,t,n){e.useUbo&&n&&e.isSync||(this._texture&&h.a.AnisotropicTextureEnabled&&(e.updateFloat2("vAnisotropyInfos",this._texture.coordinatesIndex,this._texture.level),d.a.BindTextureMatrix(this._texture,e,"anisotropy")),e.updateFloat3("vAnisotropy",this.direction.x,this.direction.y,this.intensity)),t.texturesEnabled&&this._texture&&h.a.AnisotropicTextureEnabled&&e.setTexture("anisotropySampler",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return"PBRAnisotropicConfiguration"},e.AddFallbacks=function(e,t,n){return e.ANISOTROPIC&&t.addFallback(n++,"ANISOTROPIC"),n},e.AddUniforms=function(e){e.push("vAnisotropy","vAnisotropyInfos","anisotropyMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vAnisotropy",3),e.addUniform("vAnisotropyInfos",2),e.addUniform("anisotropyMatrix",16)},e.AddSamplers=function(e){e.push("anisotropySampler")},e.prototype.copyTo=function(e){r.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.prototype.parse=function(e){var t=this;r.a.Parse((function(){return t}),e,null)},i.c([Object(r.c)()],e.prototype,"_isEnabled",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),i.c([Object(r.c)()],e.prototype,"intensity",void 0),i.c([Object(r.n)()],e.prototype,"direction",void 0),i.c([Object(r.m)()],e.prototype,"_texture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),m=function(){function e(t){this._useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this.useEnergyConservation=e.DEFAULT_USE_ENERGY_CONSERVATION,this._useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this.useSmithVisibilityHeightCorrelated=e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED,this._useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this.useSphericalHarmonics=e.DEFAULT_USE_SPHERICAL_HARMONICS,this._internalMarkAllSubMeshesAsMiscDirty=t}return e.prototype._markAllSubMeshesAsMiscDirty=function(){this._internalMarkAllSubMeshesAsMiscDirty()},e.prototype.prepareDefines=function(e){e.BRDF_V_HEIGHT_CORRELATED=this._useSmithVisibilityHeightCorrelated,e.MS_BRDF_ENERGY_CONSERVATION=this._useEnergyConservation&&this._useSmithVisibilityHeightCorrelated,e.SPHERICAL_HARMONICS=this._useSphericalHarmonics},e.prototype.getClassName=function(){return"PBRBRDFConfiguration"},e.prototype.copyTo=function(e){r.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.prototype.parse=function(e){var t=this;r.a.Parse((function(){return t}),e,null)},e.DEFAULT_USE_ENERGY_CONSERVATION=!0,e.DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED=!0,e.DEFAULT_USE_SPHERICAL_HARMONICS=!0,i.c([Object(r.c)()],e.prototype,"_useEnergyConservation",void 0),i.c([Object(r.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useEnergyConservation",void 0),i.c([Object(r.c)()],e.prototype,"_useSmithVisibilityHeightCorrelated",void 0),i.c([Object(r.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSmithVisibilityHeightCorrelated",void 0),i.c([Object(r.c)()],e.prototype,"_useSphericalHarmonics",void 0),i.c([Object(r.b)("_markAllSubMeshesAsMiscDirty")],e.prototype,"useSphericalHarmonics",void 0),e}(),g=function(){function e(e){this._isEnabled=!1,this.isEnabled=!1,this._linkSheenWithAlbedo=!1,this.linkSheenWithAlbedo=!1,this.intensity=1,this.color=l.e.White(),this._texture=null,this.texture=null,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){return!(e._areTexturesDirty&&t.texturesEnabled&&this._texture&&h.a.SheenTextureEnabled&&!this._texture.isReadyOrNotBlocking())},e.prototype.prepareDefines=function(e,t){this._isEnabled?(e.SHEEN=this._isEnabled,e.SHEEN_LINKWITHALBEDO=this._linkSheenWithAlbedo,e._areTexturesDirty&&t.texturesEnabled&&(this._texture&&h.a.SheenTextureEnabled?d.a.PrepareDefinesForMergedUV(this._texture,e,"SHEEN_TEXTURE"):e.SHEEN_TEXTURE=!1)):(e.SHEEN=!1,e.SHEEN_TEXTURE=!1,e.SHEEN_LINKWITHALBEDO=!1)},e.prototype.bindForSubMesh=function(e,t,n){e.useUbo&&n&&e.isSync||(this._texture&&h.a.SheenTextureEnabled&&(e.updateFloat2("vSheenInfos",this._texture.coordinatesIndex,this._texture.level),d.a.BindTextureMatrix(this._texture,e,"sheen")),e.updateFloat4("vSheenColor",this.color.r,this.color.g,this.color.b,this.intensity)),t.texturesEnabled&&this._texture&&h.a.SheenTextureEnabled&&e.setTexture("sheenSampler",this._texture)},e.prototype.hasTexture=function(e){return this._texture===e},e.prototype.getActiveTextures=function(e){this._texture&&e.push(this._texture)},e.prototype.getAnimatables=function(e){this._texture&&this._texture.animations&&this._texture.animations.length>0&&e.push(this._texture)},e.prototype.dispose=function(e){e&&this._texture&&this._texture.dispose()},e.prototype.getClassName=function(){return"PBRSheenConfiguration"},e.AddFallbacks=function(e,t,n){return e.SHEEN&&t.addFallback(n++,"SHEEN"),n},e.AddUniforms=function(e){e.push("vSheenColor","vSheenInfos","sheenMatrix")},e.PrepareUniformBuffer=function(e){e.addUniform("vSheenColor",4),e.addUniform("vSheenInfos",2),e.addUniform("sheenMatrix",16)},e.AddSamplers=function(e){e.push("sheenSampler")},e.prototype.copyTo=function(e){r.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.prototype.parse=function(e){var t=this;r.a.Parse((function(){return t}),e,null)},i.c([Object(r.c)()],e.prototype,"_isEnabled",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isEnabled",void 0),i.c([Object(r.c)()],e.prototype,"_linkSheenWithAlbedo",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkSheenWithAlbedo",void 0),i.c([Object(r.c)()],e.prototype,"intensity",void 0),i.c([Object(r.e)()],e.prototype,"color",void 0),i.c([Object(r.m)()],e.prototype,"_texture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"texture",void 0),e}(),_=function(){function e(e){this._isRefractionEnabled=!1,this.isRefractionEnabled=!1,this._isTranslucencyEnabled=!1,this.isTranslucencyEnabled=!1,this._isScatteringEnabled=!1,this.refractionIntensity=1,this.translucencyIntensity=1,this.scatteringIntensity=1,this._thicknessTexture=null,this.thicknessTexture=null,this._refractionTexture=null,this.refractionTexture=null,this._indexOfRefraction=1,this.indexOfRefraction=1,this._invertRefractionY=!1,this.invertRefractionY=!1,this._linkRefractionWithTransparency=!1,this.linkRefractionWithTransparency=!1,this.minimumThickness=0,this.maximumThickness=1,this.tintColor=l.e.White(),this.tintColorAtDistance=1,this.diffusionDistance=l.e.White(),this._useMaskFromThicknessTexture=!1,this.useMaskFromThicknessTexture=!1,this._internalMarkAllSubMeshesAsTexturesDirty=e}return e.prototype._markAllSubMeshesAsTexturesDirty=function(){this._internalMarkAllSubMeshesAsTexturesDirty()},e.prototype.isReadyForSubMesh=function(e,t){if(e._areTexturesDirty&&t.texturesEnabled){if(this._thicknessTexture&&h.a.ThicknessTextureEnabled&&!this._thicknessTexture.isReadyOrNotBlocking())return!1;var n=this._getRefractionTexture(t);if(n&&h.a.RefractionTextureEnabled&&!n.isReadyOrNotBlocking())return!1}return!0},e.prototype.prepareDefines=function(e,t){if(e._areTexturesDirty&&(e.SUBSURFACE=!1,e.SS_TRANSLUCENCY=this._isTranslucencyEnabled,e.SS_SCATERRING=this._isScatteringEnabled,e.SS_THICKNESSANDMASK_TEXTURE=!1,e.SS_MASK_FROM_THICKNESS_TEXTURE=!1,e.SS_REFRACTION=!1,e.SS_REFRACTIONMAP_3D=!1,e.SS_GAMMAREFRACTION=!1,e.SS_RGBDREFRACTION=!1,e.SS_REFRACTIONMAP_OPPOSITEZ=!1,e.SS_LODINREFRACTIONALPHA=!1,e.SS_LINKREFRACTIONTOTRANSPARENCY=!1,(this._isRefractionEnabled||this._isTranslucencyEnabled||this._isScatteringEnabled)&&(e.SUBSURFACE=!0,e._areTexturesDirty&&t.texturesEnabled&&this._thicknessTexture&&h.a.ThicknessTextureEnabled&&d.a.PrepareDefinesForMergedUV(this._thicknessTexture,e,"SS_THICKNESSANDMASK_TEXTURE"),e.SS_MASK_FROM_THICKNESS_TEXTURE=this._useMaskFromThicknessTexture),this._isRefractionEnabled&&t.texturesEnabled)){var n=this._getRefractionTexture(t);n&&h.a.RefractionTextureEnabled&&(e.SS_REFRACTION=!0,e.SS_REFRACTIONMAP_3D=n.isCube,e.SS_GAMMAREFRACTION=n.gammaSpace,e.SS_RGBDREFRACTION=n.isRGBD,e.SS_REFRACTIONMAP_OPPOSITEZ=n.invertZ,e.SS_LODINREFRACTIONALPHA=n.lodLevelInAlpha,e.SS_LINKREFRACTIONTOTRANSPARENCY=this._linkRefractionWithTransparency)}},e.prototype.bindForSubMesh=function(e,t,n,i,r){var o=this._getRefractionTexture(t);if(!e.useUbo||!i||!e.isSync){if(this._thicknessTexture&&h.a.ThicknessTextureEnabled&&(e.updateFloat2("vThicknessInfos",this._thicknessTexture.coordinatesIndex,this._thicknessTexture.level),d.a.BindTextureMatrix(this._thicknessTexture,e,"thickness")),e.updateFloat2("vThicknessParam",this.minimumThickness,this.maximumThickness-this.minimumThickness),o&&h.a.RefractionTextureEnabled){e.updateMatrix("refractionMatrix",o.getReflectionTextureMatrix());var a=1;o.isCube||o.depth&&(a=o.depth),e.updateFloat4("vRefractionInfos",o.level,1/this._indexOfRefraction,a,this._invertRefractionY?-1:1),e.updateFloat3("vRefractionMicrosurfaceInfos",o.getSize().width,o.lodGenerationScale,o.lodGenerationOffset)}e.updateColor3("vDiffusionDistance",this.diffusionDistance),e.updateFloat4("vTintColor",this.tintColor.r,this.tintColor.g,this.tintColor.b,this.tintColorAtDistance),e.updateFloat3("vSubSurfaceIntensity",this.refractionIntensity,this.translucencyIntensity,this.scatteringIntensity)}t.texturesEnabled&&(this._thicknessTexture&&h.a.ThicknessTextureEnabled&&e.setTexture("thicknessSampler",this._thicknessTexture),o&&h.a.RefractionTextureEnabled&&(r?e.setTexture("refractionSampler",o):(e.setTexture("refractionSampler",o._lodTextureMid||o),e.setTexture("refractionSamplerLow",o._lodTextureLow||o),e.setTexture("refractionSamplerHigh",o._lodTextureHigh||o))))},e.prototype.unbind=function(e){return!(!this._refractionTexture||!this._refractionTexture.isRenderTarget)&&(e.setTexture("refractionSampler",null),!0)},e.prototype._getRefractionTexture=function(e){return this._refractionTexture?this._refractionTexture:this._isRefractionEnabled?e.environmentTexture:null},Object.defineProperty(e.prototype,"disableAlphaBlending",{get:function(){return this.isRefractionEnabled&&this._linkRefractionWithTransparency},enumerable:!0,configurable:!0}),e.prototype.fillRenderTargetTextures=function(e){h.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget&&e.push(this._refractionTexture)},e.prototype.hasTexture=function(e){return this._thicknessTexture===e||this._refractionTexture===e},e.prototype.hasRenderTargetTextures=function(){return!!(h.a.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},e.prototype.getActiveTextures=function(e){this._thicknessTexture&&e.push(this._thicknessTexture),this._refractionTexture&&e.push(this._refractionTexture)},e.prototype.getAnimatables=function(e){this._thicknessTexture&&this._thicknessTexture.animations&&this._thicknessTexture.animations.length>0&&e.push(this._thicknessTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture)},e.prototype.dispose=function(e){e&&(this._thicknessTexture&&this._thicknessTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose())},e.prototype.getClassName=function(){return"PBRSubSurfaceConfiguration"},e.AddFallbacks=function(e,t,n){return e.SS_SCATERRING&&t.addFallback(n++,"SS_SCATERRING"),e.SS_TRANSLUCENCY&&t.addFallback(n++,"SS_TRANSLUCENCY"),n},e.AddUniforms=function(e){e.push("vDiffusionDistance","vTintColor","vSubSurfaceIntensity","vRefractionMicrosurfaceInfos","vRefractionInfos","vThicknessInfos","vThicknessParam","refractionMatrix","thicknessMatrix")},e.AddSamplers=function(e){e.push("thicknessSampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh")},e.PrepareUniformBuffer=function(e){e.addUniform("vRefractionMicrosurfaceInfos",3),e.addUniform("vRefractionInfos",4),e.addUniform("refractionMatrix",16),e.addUniform("vThicknessInfos",2),e.addUniform("thicknessMatrix",16),e.addUniform("vThicknessParam",2),e.addUniform("vDiffusionDistance",3),e.addUniform("vTintColor",4),e.addUniform("vSubSurfaceIntensity",3)},e.prototype.copyTo=function(e){r.a.Clone((function(){return e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.prototype.parse=function(e){var t=this;r.a.Parse((function(){return t}),e,null)},i.c([Object(r.c)()],e.prototype,"_isRefractionEnabled",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isRefractionEnabled",void 0),i.c([Object(r.c)()],e.prototype,"_isTranslucencyEnabled",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"isTranslucencyEnabled",void 0),i.c([Object(r.c)()],e.prototype,"_isScatteringEnabled",void 0),i.c([Object(r.c)()],e.prototype,"refractionIntensity",void 0),i.c([Object(r.c)()],e.prototype,"translucencyIntensity",void 0),i.c([Object(r.c)()],e.prototype,"scatteringIntensity",void 0),i.c([Object(r.m)()],e.prototype,"_thicknessTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"thicknessTexture",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"refractionTexture",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"indexOfRefraction",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"invertRefractionY",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"linkRefractionWithTransparency",void 0),i.c([Object(r.c)()],e.prototype,"minimumThickness",void 0),i.c([Object(r.c)()],e.prototype,"maximumThickness",void 0),i.c([Object(r.e)()],e.prototype,"tintColor",void 0),i.c([Object(r.c)()],e.prototype,"tintColorAtDistance",void 0),i.c([Object(r.e)()],e.prototype,"diffusionDistance",void 0),i.c([Object(r.c)()],e.prototype,"_useMaskFromThicknessTexture",void 0),i.c([Object(r.b)("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useMaskFromThicknessTexture",void 0),e}(),v=n(45),b=n(8),y=n(83),x=n(97),C=n(6),E=n(4),T="uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(SS_REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#ifdef CLEARCOAT_TINT\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\n#ifdef CLEARCOAT_TINT_TEXTURE\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\n#endif\n#endif\n#endif\n\n#ifdef ANISOTROPIC\nuniform vec3 vAnisotropy;\n#ifdef ANISOTROPIC_TEXTURE\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\n#endif\n#endif\n\n#ifdef SHEEN\nuniform vec4 vSheenColor;\n#ifdef SHEEN_TEXTURE\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\n#endif\n#endif\n\n#ifdef SUBSURFACE\n#ifdef SS_REFRACTION\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;;\n#endif\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n#endif";b.a.IncludesShadersStore.pbrFragmentDeclaration=T;var S="layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float pointSize;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float visibility;\nuniform vec2 vClearCoatParams;\nuniform vec4 vClearCoatRefractionParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform vec4 vClearCoatTintParams;\nuniform float clearCoatColorAtDistance;\nuniform vec2 vClearCoatTintInfos;\nuniform mat4 clearCoatTintMatrix;\nuniform vec3 vAnisotropy;\nuniform vec2 vAnisotropyInfos;\nuniform mat4 anisotropyMatrix;\nuniform vec4 vSheenColor;\nuniform vec2 vSheenInfos;\nuniform mat4 sheenMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec2 vThicknessInfos;\nuniform mat4 thicknessMatrix;\nuniform vec2 vThicknessParam;\nuniform vec3 vDiffusionDistance;\nuniform vec4 vTintColor;\nuniform vec3 vSubSurfaceIntensity;\n};\nuniform Scene {\nmat4 viewProjection;\n#ifdef MULTIVIEW\nmat4 viewProjectionR;\n#endif\nmat4 view;\n};";b.a.IncludesShadersStore.pbrUboDeclaration=S;var A="uniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#if DEBUGMODE>0\nuniform vec2 vDebugMode;\nvarying vec4 vClipSpacePosition;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif";b.a.IncludesShadersStore.pbrFragmentExtraDeclaration=A;n(128),n(129);var P="#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\n#if CLEARCOAT_TEXTUREDIRECTUV == 1\n#define vClearCoatUV vMainUV1\n#elif CLEARCOAT_TEXTUREDIRECTUV == 2\n#define vClearCoatUV vMainUV2\n#else\nvarying vec2 vClearCoatUV;\n#endif\nuniform sampler2D clearCoatSampler;\n#endif\n#ifdef CLEARCOAT_BUMP\n#if CLEARCOAT_BUMPDIRECTUV == 1\n#define vClearCoatBumpUV vMainUV1\n#elif CLEARCOAT_BUMPDIRECTUV == 2\n#define vClearCoatBumpUV vMainUV2\n#else\nvarying vec2 vClearCoatBumpUV;\n#endif\nuniform sampler2D clearCoatBumpSampler;\n#endif\n#ifdef CLEARCOAT_TINT_TEXTURE\n#if CLEARCOAT_TINT_TEXTUREDIRECTUV == 1\n#define vClearCoatTintUV vMainUV1\n#elif CLEARCOAT_TINT_TEXTUREDIRECTUV == 2\n#define vClearCoatTintUV vMainUV2\n#else\nvarying vec2 vClearCoatTintUV;\n#endif\nuniform sampler2D clearCoatTintSampler;\n#endif\n#endif\n#ifdef SHEEN\n#ifdef SHEEN_TEXTURE\n#if SHEEN_TEXTUREDIRECTUV == 1\n#define vSheenUV vMainUV1\n#elif SHEEN_TEXTUREDIRECTUV == 2\n#define vSheenUV vMainUV2\n#else\nvarying vec2 vSheenUV;\n#endif\nuniform sampler2D sheenSampler;\n#endif\n#endif\n#ifdef ANISOTROPIC\n#ifdef ANISOTROPIC_TEXTURE\n#if ANISOTROPIC_TEXTUREDIRECTUV == 1\n#define vAnisotropyUV vMainUV1\n#elif ANISOTROPIC_TEXTUREDIRECTUV == 2\n#define vAnisotropyUV vMainUV2\n#else\nvarying vec2 vAnisotropyUV;\n#endif\nuniform sampler2D anisotropySampler;\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#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 samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n#ifdef SS_THICKNESSANDMASK_TEXTURE\n#if SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 1\n#define vThicknessUV vMainUV1\n#elif SS_THICKNESSANDMASK_TEXTUREDIRECTUV == 2\n#define vThicknessUV vMainUV2\n#else\nvarying vec2 vThicknessUV;\n#endif\nuniform sampler2D thicknessSampler;\n#endif\n#endif";b.a.IncludesShadersStore.pbrFragmentSamplersDeclaration=P;n(130),n(145),n(132),n(150),n(75);var M="\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";b.a.IncludesShadersStore.pbrHelperFunctions=M;n(131),n(181);var O="#ifdef USESPHERICALFROMREFLECTIONMAP\n#ifdef SPHERICAL_HARMONICS\nuniform vec3 vSphericalL00;\nuniform vec3 vSphericalL1_1;\nuniform vec3 vSphericalL10;\nuniform vec3 vSphericalL11;\nuniform vec3 vSphericalL2_2;\nuniform vec3 vSphericalL2_1;\nuniform vec3 vSphericalL20;\nuniform vec3 vSphericalL21;\nuniform vec3 vSphericalL22;\n\n\n\n\n\n\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\nreturn vSphericalL00\n+vSphericalL1_1*(normal.y)\n+vSphericalL10*(normal.z)\n+vSphericalL11*(normal.x)\n+vSphericalL2_2*(normal.y*normal.x)\n+vSphericalL2_1*(normal.y*normal.z)\n+vSphericalL20*((3.0*normal.z*normal.z)-1.0)\n+vSphericalL21*(normal.z*normal.x)\n+vSphericalL22*(normal.x*normal.x-(normal.y*normal.y));\n}\n#else\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\n\nvec3 computeEnvironmentIrradiance(vec3 normal) {\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif\n#endif";b.a.IncludesShadersStore.harmonicsFunctions=O;var R="\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}";b.a.IncludesShadersStore.pbrDirectLightingSetupFunctions=R;var w="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}";b.a.IncludesShadersStore.pbrDirectLightingFalloffFunctions=w;var I="\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,sampler2D brdfSampler) {\n\nvec2 UV=vec2(NdotV,perceptualRoughness);\n\nvec4 brdfLookup=texture2D(brdfSampler,UV);\n#ifdef ENVIRONMENTBRDF_RGBD\nbrdfLookup.rgb=fromRGBD(brdfLookup.rgba);\n#endif\nreturn brdfLookup.rgb;\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#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(REFLECTION)\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\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\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#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";b.a.IncludesShadersStore.pbrBRDFFunctions=I;var L="#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}\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 visibility=smithVisibility_GGXCorrelated(info.NdotL,info.NdotV,alphaG);\n#else\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(info.NdotL,info.NdotV,alphaG);\n#endif\nvec3 specTerm=fresnel*distribution*visibility;\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 visibility=smithVisibility_GGXCorrelated_Anisotropic(info.NdotL,info.NdotV,TdotV,BdotV,TdotL,BdotL,alphaTB);\nvec3 specTerm=fresnel*distribution*visibility;\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 visibility=visibility_Kelemen(info.VdotH);\nfloat clearCoatTerm=fresnel*distribution*visibility;\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\nvec3 fresnel=reflectance0;\nfloat distribution=normalDistributionFunction_CharlieSheen(NdotH,alphaG);\nfloat visibility=visibility_Ashikhmin(info.NdotL,info.NdotV);\nvec3 sheenTerm=fresnel*distribution*visibility;\nreturn sheenTerm*info.attenuation*info.NdotL*lightColor;\n}\n#endif\n";b.a.IncludesShadersStore.pbrDirectLightingFunctions=L;var D="#if defined(REFLECTION) || defined(SS_REFRACTION)\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float microsurfaceAverageSlope) {\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\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) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=saturate(1.0+1.1*dot(reflection,normal));\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";b.a.IncludesShadersStore.pbrIBLFunctions=D;n(191),n(182),n(133),n(192),n(193),n(183),n(184),n(151);var N="#if DEBUGMODE>0\nif (vClipSpacePosition.x/vClipSpacePosition.w=1)&&e.prototype.needAlphaBlendingForMesh.call(this,t)},t.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this.subSurface.disableAlphaBlending&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&(null==this._transparencyMode||this._transparencyMode===t.PBRMATERIAL_ALPHATEST))},t.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==t.PBRMATERIAL_OPAQUE},t.prototype.getAlphaTestTexture=function(){return this._albedoTexture},t.prototype.isReadyForSubMesh=function(e,t,n){if(t.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new z);var i=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&i._renderId===this.getScene().getRenderId())return!0;var r=this.getScene(),a=r.getEngine();if(i._areTexturesDirty&&r.texturesEnabled){if(this._albedoTexture&&h.a.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&h.a.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&h.a.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var s=this._getReflectionTexture();if(s&&h.a.ReflectionTextureEnabled&&!s.isReadyOrNotBlocking())return!1;if(this._lightmapTexture&&h.a.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&h.a.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(h.a.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(a.getCaps().standardDerivatives&&this._bumpTexture&&h.a.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;if(this._environmentBRDFTexture&&h.a.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(!(this.subSurface.isReadyForSubMesh(i,r)&&this.clearCoat.isReadyForSubMesh(i,r,a,this._disableBumpMap)&&this.sheen.isReadyForSubMesh(i,r)&&this.anisotropy.isReadyForSubMesh(i,r)))return!1;if(i._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;a.getCaps().standardDerivatives||e.isVerticesDataPresent(u.b.NormalKind)||(e.createNormals(!0),o.a.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var c=t.effect,l=this._prepareEffect(e,i,this.onCompiled,this.onError,n);return l&&(this.allowShaderHotSwapping&&c&&!l.isReady()?(l=c,i.markAsUnprocessed()):(r.resetCachedMaterial(),t.setEffect(l,i),this.buildUniformLayout())),!(!t.effect||!t.effect.isReady())&&(i._renderId=r.getRenderId(),this._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){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),!t.isDirty)return null;t.markAsProcessed();var a=this.getScene().getEngine(),s=new b.c,c=0;t.USESPHERICALINVERTEX&&s.addFallback(c++,"USESPHERICALINVERTEX"),t.FOG&&s.addFallback(c,"FOG"),t.SPECULARAA&&s.addFallback(c,"SPECULARAA"),t.POINTSIZE&&s.addFallback(c,"POINTSIZE"),t.LOGARITHMICDEPTH&&s.addFallback(c,"LOGARITHMICDEPTH"),t.PARALLAX&&s.addFallback(c,"PARALLAX"),t.PARALLAXOCCLUSION&&s.addFallback(c++,"PARALLAXOCCLUSION"),c=p.AddFallbacks(t,s,c),c=p.AddFallbacks(t,s,c),c=_.AddFallbacks(t,s,c),c=g.AddFallbacks(t,s,c),t.ENVIRONMENTBRDF&&s.addFallback(c++,"ENVIRONMENTBRDF"),t.TANGENT&&s.addFallback(c++,"TANGENT"),t.BUMP&&s.addFallback(c++,"BUMP"),c=d.a.HandleFallbacksForShadows(t,s,this._maxSimultaneousLights,c++),t.SPECULARTERM&&s.addFallback(c++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&s.addFallback(c++,"USESPHERICALFROMREFLECTIONMAP"),t.LIGHTMAP&&s.addFallback(c++,"LIGHTMAP"),t.NORMAL&&s.addFallback(c++,"NORMAL"),t.AMBIENT&&s.addFallback(c++,"AMBIENT"),t.EMISSIVE&&s.addFallback(c++,"EMISSIVE"),t.VERTEXCOLOR&&s.addFallback(c++,"VERTEXCOLOR"),t.NUM_BONE_INFLUENCERS>0&&s.addCPUSkinningFallback(c++,e),t.MORPHTARGETS&&s.addFallback(c++,"MORPHTARGETS"),t.MULTIVIEW&&s.addFallback(0,"MULTIVIEW");var l=[u.b.PositionKind];t.NORMAL&&l.push(u.b.NormalKind),t.TANGENT&&l.push(u.b.TangentKind),t.UV1&&l.push(u.b.UVKind),t.UV2&&l.push(u.b.UV2Kind),t.VERTEXCOLOR&&l.push(u.b.ColorKind),d.a.PrepareAttributesForBones(l,e,t,s),d.a.PrepareAttributesForInstances(l,t),d.a.PrepareAttributesForMorphTargets(l,e,t);var h="pbr",m=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","visibility","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","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"],y=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler","boneSampler"],x=["Material","Scene"];_.AddUniforms(m),_.AddSamplers(y),f.AddUniforms(m),f.AddSamplers(y),p.AddUniforms(m),p.AddSamplers(y),g.AddUniforms(m),g.AddSamplers(y),v.a&&(v.a.PrepareUniforms(m,t),v.a.PrepareSamplers(y,t)),d.a.PrepareUniformsAndSamplersList({uniformsNames:m,uniformBuffersNames:x,samplers:y,defines:t,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(h=this.customShaderNameResolve(h,m,x,y,t));var C=t.toString();return a.createEffect(h,{attributes:l,uniformsNames:m,uniformBuffersNames:x,samplers:y,defines:C,fallbacks:s,onCompiled:n,onError:i,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS}},a)},t.prototype._prepareDefines=function(e,n,i,r){void 0===i&&(i=null),void 0===r&&(r=null);var o=this.getScene(),a=o.getEngine();if(d.a.PrepareDefinesForLights(o,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._needNormals=!0,d.a.PrepareDefinesForMultiview(o,n),n.METALLICWORKFLOW=this.isMetallicWorkflow(),n._areTexturesDirty){if(n._needUVs=!1,o.texturesEnabled){o.getEngine().getCaps().textureLOD&&(n.LODBASEDMICROSFURACE=!0),this._albedoTexture&&h.a.DiffuseTextureEnabled?d.a.PrepareDefinesForMergedUV(this._albedoTexture,n,"ALBEDO"):n.ALBEDO=!1,this._ambientTexture&&h.a.AmbientTextureEnabled?(d.a.PrepareDefinesForMergedUV(this._ambientTexture,n,"AMBIENT"),n.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):n.AMBIENT=!1,this._opacityTexture&&h.a.OpacityTextureEnabled?(d.a.PrepareDefinesForMergedUV(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):n.OPACITY=!1;var s=this._getReflectionTexture();if(s&&h.a.ReflectionTextureEnabled){switch(n.REFLECTION=!0,n.GAMMAREFLECTION=s.gammaSpace,n.RGBDREFLECTION=s.isRGBD,n.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,n.LODINREFLECTIONALPHA=s.lodLevelInAlpha,s.coordinatesMode===C.a.INVCUBIC_MODE&&(n.INVERTCUBICMAP=!0),n.REFLECTIONMAP_3D=s.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,n.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,s.coordinatesMode){case C.a.EXPLICIT_MODE:n.REFLECTIONMAP_EXPLICIT=!0;break;case C.a.PLANAR_MODE:n.REFLECTIONMAP_PLANAR=!0;break;case C.a.PROJECTION_MODE:n.REFLECTIONMAP_PROJECTION=!0;break;case C.a.SKYBOX_MODE:n.REFLECTIONMAP_SKYBOX=!0;break;case C.a.SPHERICAL_MODE:n.REFLECTIONMAP_SPHERICAL=!0;break;case C.a.EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case C.a.FIXED_EQUIRECTANGULAR_MODE:n.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case C.a.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case C.a.CUBIC_MODE:case C.a.INVCUBIC_MODE:default:n.REFLECTIONMAP_CUBIC=!0,n.USE_LOCAL_REFLECTIONMAP_CUBIC=!!s.boundingBoxSize}s.coordinatesMode!==C.a.SKYBOX_MODE?s.sphericalPolynomial&&(n.USESPHERICALFROMREFLECTIONMAP=!0,this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8?n.USESPHERICALINVERTEX=!1:n.USESPHERICALINVERTEX=!0):n.REFLECTIONMAP_SKYBOX_TRANSFORMED=!s.getReflectionTextureMatrix().isIdentity()}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_SKYBOX_TRANSFORMED=!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.USESPHERICALINVERTEX=!1,n.REFLECTIONMAP_OPPOSITEZ=!1,n.LODINREFLECTIONALPHA=!1,n.GAMMAREFLECTION=!1,n.RGBDREFLECTION=!1;this._lightmapTexture&&h.a.LightmapTextureEnabled?(d.a.PrepareDefinesForMergedUV(this._lightmapTexture,n,"LIGHTMAP"),n.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,n.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace):n.LIGHTMAP=!1,this._emissiveTexture&&h.a.EmissiveTextureEnabled?d.a.PrepareDefinesForMergedUV(this._emissiveTexture,n,"EMISSIVE"):n.EMISSIVE=!1,h.a.SpecularTextureEnabled?(this._metallicTexture?(d.a.PrepareDefinesForMergedUV(this._metallicTexture,n,"REFLECTIVITY"),n.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,n.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,n.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,n.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed):this._reflectivityTexture?(d.a.PrepareDefinesForMergedUV(this._reflectivityTexture,n,"REFLECTIVITY"),n.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,n.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):n.REFLECTIVITY=!1,this._microSurfaceTexture?d.a.PrepareDefinesForMergedUV(this._microSurfaceTexture,n,"MICROSURFACEMAP"):n.MICROSURFACEMAP=!1):(n.REFLECTIVITY=!1,n.MICROSURFACEMAP=!1),o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&h.a.BumpTextureEnabled&&!this._disableBumpMap?(d.a.PrepareDefinesForMergedUV(this._bumpTexture,n,"BUMP"),this._useParallax&&this._albedoTexture&&h.a.DiffuseTextureEnabled?(n.PARALLAX=!0,n.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):n.PARALLAX=!1,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):n.BUMP=!1,this._environmentBRDFTexture&&h.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.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),n.PREMULTIPLYALPHA=this.alphaMode===E.a.ALPHA_PREMULTIPLIED||this.alphaMode===E.a.ALPHA_PREMULTIPLIED_PORTERDUFF,n.ALPHABLEND=this.needAlphaBlendingForMesh(e),n.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,n.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel,n.SPECULARAA=o.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}n._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(n),n.FORCENORMALFORWARD=this._forceNormalForward,n.RADIANCEOCCLUSION=this._useRadianceOcclusion,n.HORIZONOCCLUSION=this._useHorizonOcclusion,n._areMiscDirty&&(d.a.PrepareDefinesForMisc(e,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,n),n.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(u.b.NormalKind),n.DEBUGMODE=this._debugMode),this.subSurface.prepareDefines(n,o),this.clearCoat.prepareDefines(n,o),this.anisotropy.prepareDefines(n,e,o),this.brdf.prepareDefines(n),this.sheen.prepareDefines(n,o),d.a.PrepareDefinesForFrameBoundValues(o,a,n,!!i,r),d.a.PrepareDefinesForAttributes(e,n,!0,!0,!0,this._transparencyMode!==t.PBRMATERIAL_OPAQUE)},t.prototype.forceCompilation=function(e,t,n){var r=this,o=i.a({clipPlane:!1},n),a=new z,s=this._prepareEffect(e,a,void 0,void 0,void 0,o.clipPlane);s.isReady()?t&&t(this):s.onCompileObservable.add((function(){t&&t(r)}))},t.prototype.buildUniformLayout=function(){var e=this._uniformBuffer;e.addUniform("vAlbedoInfos",2),e.addUniform("vAmbientInfos",4),e.addUniform("vOpacityInfos",2),e.addUniform("vEmissiveInfos",2),e.addUniform("vLightmapInfos",2),e.addUniform("vReflectivityInfos",3),e.addUniform("vMicroSurfaceSamplerInfos",2),e.addUniform("vReflectionInfos",2),e.addUniform("vReflectionPosition",3),e.addUniform("vReflectionSize",3),e.addUniform("vBumpInfos",3),e.addUniform("albedoMatrix",16),e.addUniform("ambientMatrix",16),e.addUniform("opacityMatrix",16),e.addUniform("emissiveMatrix",16),e.addUniform("lightmapMatrix",16),e.addUniform("reflectivityMatrix",16),e.addUniform("microSurfaceSamplerMatrix",16),e.addUniform("bumpMatrix",16),e.addUniform("vTangentSpaceParams",2),e.addUniform("reflectionMatrix",16),e.addUniform("vReflectionColor",3),e.addUniform("vAlbedoColor",4),e.addUniform("vLightingIntensity",4),e.addUniform("vReflectionMicrosurfaceInfos",3),e.addUniform("pointSize",1),e.addUniform("vReflectivityColor",4),e.addUniform("vEmissiveColor",3),e.addUniform("visibility",1),f.PrepareUniformBuffer(e),p.PrepareUniformBuffer(e),g.PrepareUniformBuffer(e),_.PrepareUniformBuffer(e),e.create()},t.prototype.unbind=function(){if(this._activeEffect){var t=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),t=!0),this.subSurface.unbind(this._activeEffect)&&(t=!0),t&&this._markAllSubMeshesAsTexturesDirty()}e.prototype.unbind.call(this)},t.prototype.bindForSubMesh=function(e,n,i){var r=this.getScene(),o=i._materialDefines;if(o){var a=i.effect;if(a){this._activeEffect=a,o.INSTANCES||this.bindOnlyWorldMatrix(e),o.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var s=this._mustRebind(r,a,n.visibility);d.a.BindBonesParameters(n,this._activeEffect);var u=null,f=this._uniformBuffer;if(s){var p=r.getEngine();if(f.bindToEffect(a,"Material"),this.bindViewProjection(a),u=this._getReflectionTexture(),!f.useUbo||!this.isFrozen||!f.isSync){if(r.texturesEnabled){if(this._albedoTexture&&h.a.DiffuseTextureEnabled&&(f.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),d.a.BindTextureMatrix(this._albedoTexture,f,"albedo")),this._ambientTexture&&h.a.AmbientTextureEnabled&&(f.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),d.a.BindTextureMatrix(this._ambientTexture,f,"ambient")),this._opacityTexture&&h.a.OpacityTextureEnabled&&(f.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),d.a.BindTextureMatrix(this._opacityTexture,f,"opacity")),u&&h.a.ReflectionTextureEnabled){if(f.updateMatrix("reflectionMatrix",u.getReflectionTextureMatrix()),f.updateFloat2("vReflectionInfos",u.level,0),u.boundingBoxSize){var m=u;f.updateVector3("vReflectionPosition",m.boundingBoxPosition),f.updateVector3("vReflectionSize",m.boundingBoxSize)}var g=u.sphericalPolynomial;if(o.USESPHERICALFROMREFLECTIONMAP&&g)if(o.SPHERICAL_HARMONICS){var _=g.preScaledHarmonics;this._activeEffect.setVector3("vSphericalL00",_.l00),this._activeEffect.setVector3("vSphericalL1_1",_.l1_1),this._activeEffect.setVector3("vSphericalL10",_.l10),this._activeEffect.setVector3("vSphericalL11",_.l11),this._activeEffect.setVector3("vSphericalL2_2",_.l2_2),this._activeEffect.setVector3("vSphericalL2_1",_.l2_1),this._activeEffect.setVector3("vSphericalL20",_.l20),this._activeEffect.setVector3("vSphericalL21",_.l21),this._activeEffect.setVector3("vSphericalL22",_.l22)}else this._activeEffect.setFloat3("vSphericalX",g.x.x,g.x.y,g.x.z),this._activeEffect.setFloat3("vSphericalY",g.y.x,g.y.y,g.y.z),this._activeEffect.setFloat3("vSphericalZ",g.z.x,g.z.y,g.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",g.xx.x-g.zz.x,g.xx.y-g.zz.y,g.xx.z-g.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",g.yy.x-g.zz.x,g.yy.y-g.zz.y,g.yy.z-g.zz.z),this._activeEffect.setFloat3("vSphericalZZ",g.zz.x,g.zz.y,g.zz.z),this._activeEffect.setFloat3("vSphericalXY",g.xy.x,g.xy.y,g.xy.z),this._activeEffect.setFloat3("vSphericalYZ",g.yz.x,g.yz.y,g.yz.z),this._activeEffect.setFloat3("vSphericalZX",g.zx.x,g.zx.y,g.zx.z);f.updateFloat3("vReflectionMicrosurfaceInfos",u.getSize().width,u.lodGenerationScale,u.lodGenerationOffset)}this._emissiveTexture&&h.a.EmissiveTextureEnabled&&(f.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),d.a.BindTextureMatrix(this._emissiveTexture,f,"emissive")),this._lightmapTexture&&h.a.LightmapTextureEnabled&&(f.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),d.a.BindTextureMatrix(this._lightmapTexture,f,"lightmap")),h.a.SpecularTextureEnabled&&(this._metallicTexture?(f.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),d.a.BindTextureMatrix(this._metallicTexture,f,"reflectivity")):this._reflectivityTexture&&(f.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),d.a.BindTextureMatrix(this._reflectivityTexture,f,"reflectivity")),this._microSurfaceTexture&&(f.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),d.a.BindTextureMatrix(this._microSurfaceTexture,f,"microSurfaceSampler"))),this._bumpTexture&&p.getCaps().standardDerivatives&&h.a.BumpTextureEnabled&&!this._disableBumpMap&&(f.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),d.a.BindTextureMatrix(this._bumpTexture,f,"bump"),r._mirroredCameraPosition?f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):f.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1))}this.pointsCloud&&f.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(l.t.Color3[0].r=void 0===this._metallic||null===this._metallic?1:this._metallic,l.t.Color3[0].g=void 0===this._roughness||null===this._roughness?1:this._roughness,f.updateColor4("vReflectivityColor",l.t.Color3[0],0)):f.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),f.updateColor3("vEmissiveColor",h.a.EmissiveTextureEnabled?this._emissiveColor:l.e.BlackReadOnly),f.updateColor3("vReflectionColor",this._reflectionColor),f.updateColor4("vAlbedoColor",this._albedoColor,this.alpha),f.updateFloat("visibility",n.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,f.updateVector4("vLightingIntensity",this._lightingInfos)}r.texturesEnabled&&(this._albedoTexture&&h.a.DiffuseTextureEnabled&&f.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&h.a.AmbientTextureEnabled&&f.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&h.a.OpacityTextureEnabled&&f.setTexture("opacitySampler",this._opacityTexture),u&&h.a.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?f.setTexture("reflectionSampler",u):(f.setTexture("reflectionSampler",u._lodTextureMid||u),f.setTexture("reflectionSamplerLow",u._lodTextureLow||u),f.setTexture("reflectionSamplerHigh",u._lodTextureHigh||u))),o.ENVIRONMENTBRDF&&f.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),this._emissiveTexture&&h.a.EmissiveTextureEnabled&&f.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&h.a.LightmapTextureEnabled&&f.setTexture("lightmapSampler",this._lightmapTexture),h.a.SpecularTextureEnabled&&(this._metallicTexture?f.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&f.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&f.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&p.getCaps().standardDerivatives&&h.a.BumpTextureEnabled&&!this._disableBumpMap&&f.setTexture("bumpSampler",this._bumpTexture)),this.subSurface.bindForSubMesh(f,r,p,this.isFrozen,o.LODBASEDMICROSFURACE),this.clearCoat.bindForSubMesh(f,r,p,this._disableBumpMap,this.isFrozen,this._invertNormalMapX,this._invertNormalMapY),this.anisotropy.bindForSubMesh(f,r,this.isFrozen),this.sheen.bindForSubMesh(f,r,this.isFrozen),d.a.BindClipPlane(this._activeEffect,r),r.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var v=r._forcedViewPosition?r._forcedViewPosition:r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.globalPosition,b=r.useRightHandedSystem===(null!=r._mirroredCameraPosition);a.setFloat4("vEyePosition",v.x,v.y,v.z,b?-1:1),a.setColor3("vAmbientColor",this._globalAmbientColor),a.setFloat2("vDebugMode",this.debugLimit,this.debugFactor)}!s&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&d.a.BindLights(r,n,this._activeEffect,o,this._maxSimultaneousLights,this._lightFalloff!==t.LIGHTFALLOFF_STANDARD),(r.fogEnabled&&n.applyFog&&r.fogMode!==c.a.FOGMODE_NONE||u)&&this.bindView(a),d.a.BindFogParameters(r,n,this._activeEffect,!0),o.NUM_MORPH_INFLUENCERS&&d.a.BindMorphTargetParameters(n,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),d.a.BindLogDepth(o,this._activeEffect,r)),f.update(),this._afterBind(n,this._activeEffect)}}},t.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this.subSurface.getAnimatables(e),this.clearCoat.getAnimatables(e),this.sheen.getAnimatables(e),this.anisotropy.getAnimatables(e),e},t.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},t.prototype.getActiveTextures=function(){var t=e.prototype.getActiveTextures.call(this);return this._albedoTexture&&t.push(this._albedoTexture),this._ambientTexture&&t.push(this._ambientTexture),this._opacityTexture&&t.push(this._opacityTexture),this._reflectionTexture&&t.push(this._reflectionTexture),this._emissiveTexture&&t.push(this._emissiveTexture),this._reflectivityTexture&&t.push(this._reflectivityTexture),this._metallicTexture&&t.push(this._metallicTexture),this._microSurfaceTexture&&t.push(this._microSurfaceTexture),this._bumpTexture&&t.push(this._bumpTexture),this._lightmapTexture&&t.push(this._lightmapTexture),this.subSurface.getActiveTextures(t),this.clearCoat.getActiveTextures(t),this.sheen.getActiveTextures(t),this.anisotropy.getActiveTextures(t),t},t.prototype.hasTexture=function(t){return!!e.prototype.hasTexture.call(this,t)||(this._albedoTexture===t||(this._ambientTexture===t||(this._opacityTexture===t||(this._reflectionTexture===t||(this._reflectivityTexture===t||(this._metallicTexture===t||(this._microSurfaceTexture===t||(this._bumpTexture===t||(this._lightmapTexture===t||(this.subSurface.hasTexture(t)||this.clearCoat.hasTexture(t)||this.sheen.hasTexture(t)||this.anisotropy.hasTexture(t)))))))))))},t.prototype.dispose=function(t,n){n&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this.getScene().environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose()),this.subSurface.dispose(n),this.clearCoat.dispose(n),this.sheen.dispose(n),this.anisotropy.dispose(n),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e.prototype.dispose.call(this,t,n)},t.PBRMATERIAL_OPAQUE=0,t.PBRMATERIAL_ALPHATEST=1,t.PBRMATERIAL_ALPHABLEND=2,t.PBRMATERIAL_ALPHATESTANDBLEND=3,t.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=0,t.LIGHTFALLOFF_PHYSICAL=0,t.LIGHTFALLOFF_GLTF=1,t.LIGHTFALLOFF_STANDARD=2,i.c([Object(r.i)()],t.prototype,"_imageProcessingConfiguration",void 0),i.c([Object(r.b)("_markAllSubMeshesAsMiscDirty")],t.prototype,"debugMode",void 0),i.c([Object(r.c)()],t.prototype,"useLogarithmicDepth",null),i.c([Object(r.c)()],t.prototype,"transparencyMode",null),t}(x.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var i=n(1),r=n(2),o=n(0),a=n(30),s=n(44);a.a.AddNodeConstructor("Light_Type_3",(function(e,t){return function(){return new c(e,o.x.Zero(),t)}}));var c=function(e){function t(t,n,i){var r=e.call(this,t,i)||this;return r.groundColor=new o.e(0,0,0),r.direction=n||o.x.Up(),r}return i.d(t,e),t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightGround",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.getClassName=function(){return"HemisphericLight"},t.prototype.setDirectionToTarget=function(e){return this.direction=o.x.Normalize(e.subtract(o.x.Zero())),this.direction},t.prototype.getShadowGenerator=function(){return null},t.prototype.transferToEffect=function(e,t){var n=o.x.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.computeWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=o.j.Identity()),this._worldMatrix},t.prototype.getTypeID=function(){return s.a.LIGHTTYPEID_HEMISPHERICLIGHT},t.prototype.prepareLightSpecificDefines=function(e,t){e["HEMILIGHT"+t]=!0},i.c([Object(r.e)()],t.prototype,"groundColor",void 0),i.c([Object(r.o)()],t.prototype,"direction",void 0),t}(s.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(1),r=n(5),o=n(66),a=n(20),s=function(e){function t(t){var n=e.call(this,t)||this;return n.name=t,n._isVertical=!0,n._manualWidth=!1,n._manualHeight=!1,n._doNotTrackManualChanges=!1,n}return i.d(t,e),Object.defineProperty(t.prototype,"isVertical",{get:function(){return this._isVertical},set:function(e){this._isVertical!==e&&(this._isVertical=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"width",{get:function(){return this._width.toString(this._host)},set:function(e){this._doNotTrackManualChanges||(this._manualWidth=!0),this._width.toString(this._host)!==e&&this._width.fromString(e)&&this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"height",{get:function(){return this._height.toString(this._host)},set:function(e){this._doNotTrackManualChanges||(this._manualHeight=!0),this._height.toString(this._host)!==e&&this._height.fromString(e)&&this._markAsDirty()},enumerable:!0,configurable:!0}),t.prototype._getTypeName=function(){return"StackPanel"},t.prototype._preMeasure=function(t,n){for(var i=0,r=this._children;i=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.q.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},t.prototype.getTarget=function(){return this._currentTarget},t.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},t.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(a.t.Matrix[0]),a.x.TransformNormalToRef(this.cameraDirection,a.t.Matrix[0],a.t.Vector3[0]),void this.position.addInPlace(a.t.Vector3[0]);this.position.addInPlace(this.cameraDirection)},t.prototype._checkInputs=function(){var t=this._decideIfNeedsToMove(),n=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(t&&this._updatePosition(),n){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion)this.rotation.lengthSquared()&&a.q.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion);if(!this.noRotationConstraint){var i=Math.PI/2*.95;this.rotation.x>i&&(this.rotation.x=i),this.rotation.x<-i&&(this.rotation.x=-i)}}t&&(Math.abs(this.cameraDirection.x){this.selectSlot(e)}),this.spellBook.runeToggleCallbacks.push(e=>{this.updateSpells()}),this.updateSpells()}selectSlot(e){for(const e of this.spellPanels)e.color="white",e.thickness=1,e.background="grey";this.spellPanels[e].color="blue",this.spellPanels[e].thickness=3,this.spellPanels[e].background="lightgrey"}updateSpells(){let e=0;for(const t of this.spellBook.slots){const n=Array.from(t.getRunes()).sort((e,t)=>e-t);for(let t=0;t0)for(const e of n)e.takeDamage(10),e.damageRate=.1,e instanceof c.a&&e.health>0&&e.setOnFire(2e3)}}O.RUNES=[f.a.SelfRune,f.a.FireRune,f.a.CircleRune];class R{constructor(){this.loadedRunes=new Set}isFull(){return this.loadedRunes.size>=5}addRune(e){this.isFull()||this.loadedRunes.add(e)}addRunes(e){for(const t of e)this.addRune(t)}removeRune(e){this.loadedRunes.delete(e)}getRunes(){return this.loadedRunes}}class w extends A.a{name(){return"Fear"}requiredRunes(){return new Set([f.a.SelfRune.index,f.a.ChaosRune.index,f.a.IncreaseRune.index])}cast(e,t){const n=Object(T.d)(new T.a(e.position,2),x.a.mobs,T.b.HeroDamagable,!0);if(n)for(const e of n)e instanceof c.a&&e.startFleeing();C.a.FEAR.playNext()}}class I extends A.a{name(){return"Credits"}requiredRunes(){return new Set([f.a.SelfRune.index])}cast(e,t){if(I.exists)return;const n=r.a.CreateFullscreenUI("Credits",void 0,Ee.i.scene),i=new r.y;i.horizontalAlignment=r.i.HORIZONTAL_ALIGNMENT_CENTER,i.verticalAlignment=r.i.VERTICAL_ALIGNMENT_TOP,i.top="25%",i.height="50%",i.width="25%",i.alpha=.25,i.background="black",i.isPointerBlocker=!0,n.addControl(i);const o=new r.F;i.addControl(o),this.addTextLine("Credits:",o,100);for(let e=0;e<2;++e)this.addTextLine("",o);this.addTextLine("Tony Aquino",o),this.addTextLine("Warren Dukes",o),this.addTextLine("Brian McBarron",o),this.addTextLine("Christopher Pitstick",o),this.addTextLine("Kevin Pitstick",o),this.addTextLine("Zak Wise",o),this.addTextLine("",o),this.addTextLine("Created using BabylonJS",o),i.onPointerClickObservable.add(()=>{n.dispose(),I.exists=!1}),I.exists=!0}addTextLine(e,t,n=40){const i=new r.H;i.text=e,i.color="white",i.fontSize=n,i.height=n+10+"px",i.fontFamily="Papyrus",t.addControl(i)}}I.exists=!1;class L extends A.a{name(){return"Light"}requiredRunes(){return new Set(L.RUNES.map(e=>e.index))}cast(e,t){Ee.i.particles.light(e)}}L.RUNES=[f.a.SelfRune,f.a.LightningRune,f.a.CircleRune];class D extends A.a{name(){return"Blink"}requiredRunes(){return new Set([f.a.SelfRune.index,f.a.TerrainRune.index])}cast(e,t){e.position=t}}class N extends A.a{name(){return"Send"}requiredRunes(){return new Set([f.a.CircleRune.index,f.a.TerrainRune.index])}cast(e,t){const n=Object(T.d)(new T.a(e.position,N.RADIUS),x.a.mobs,T.b.of(T.b.HeroDamagable,T.b.Mobile));n&&n[0].teleport(t)}}N.RADIUS=2;const F=150;class k extends A.a{name(){return"Zap"}requiredRunes(){return new Set([f.a.LightningRune.index])}cast(e,t){Ee.i.particles.stationaryLightning(t,S.e,.2).start();const n=Object(T.d)(new T.a(t,S.e),x.a.mobs,T.b.HeroDamagable,!0);if(n)for(const e of n)e.takeDamage(F);C.a.ZAP.playNext()}}var B=n(241);class z{constructor(e){this.NUM_SPELL_SLOTS=5,this.activeSlot=0,this.slots=new Array,this.spellSelectCallbacks=[],this.runeToggleCallbacks=[];for(let e=0;e{this.slots[0].addRunes(z.SPELLS[0].requiredRunes()),this.slots[1].addRunes(z.SPELLS[1].requiredRunes()),this.slots[2].addRunes(z.SPELLS[2].requiredRunes()),this.slots[3].addRunes(z.SPELLS[3].requiredRunes()),this.slots[4].addRunes(z.SPELLS[4].requiredRunes())},()=>{this.slots[0].addRunes(z.SPELLS[0].requiredRunes())});for(let t=0;t<5;++t){const n=new v.b;e.registerKey(n,"Digit"+(t+1)),n.callback=()=>{this.selectSpell(t)}}const t=new v.b;e.registerKey(t,v.a.Space),t.callback=()=>{this.selectNextSpell()}}loadRune(e){this.slots[this.activeSlot].addRune(e);for(const t of this.runeToggleCallbacks)t(e)}unloadRune(e){this.slots[this.activeSlot].removeRune(e);for(const t of this.runeToggleCallbacks)t(e)}selectSpell(e){this.activeSlot=e;for(const t of this.spellSelectCallbacks)t(e)}selectNextSpell(){this.selectSpell((this.activeSlot+1)%5)}findValidRunes(e){const t=new Set;for(const n of z.SPELLS)if(n.containsRunes(e)){const i=n.missingRunes(e);for(const e of i)t.add(e)}return t}lookupSpell(){const e=this.slots[this.activeSlot].getRunes();for(const t of z.SPELLS){if(t.requiredRunes().size!==e.size)continue;if(new Set([...e,...t.requiredRunes()]).size===t.requiredRunes().size)return t}return null}}z.SPELLS=[new k,new M,new E.a,new O,new w,new I,new L,new D,new N,new B.a];const V=.003,U=.006;class G extends x.a{constructor(e,t,n){super(G.MESH.create(),t,T.b.of(T.b.Visible,T.b.Mobile,T.b.EnemyMoveObstacle)),this.up=new v.b,this.down=new v.b,this.left=new v.b,this.right=new v.b,this.stepTimeLeft=0,this.stepDuration=0,this.spellBook=new z(Ee.i.input),this.rocketMode=!1,this.cameraTarget=new i.TransformNode("HeroTarget",Ee.i.scene,!0),this.cameraTarget.position=this.mesh.position,this.crystalNode=new i.TransformNode("HeroCrystal",Ee.i.scene),this.crystalNode.parent=this.mesh,this.crystalNode.position.z=-.3125,this.crystalNode.position.y=.4375,Ee.i.input.registerKey(this.up,"KeyW",v.a.Up),Ee.i.input.registerKey(this.down,"KeyS",v.a.Down),Ee.i.input.registerKey(this.left,"KeyA",v.a.Left),Ee.i.input.registerKey(this.right,"KeyD",v.a.Right),this.wand=n}get radius(){return.35}onDeath(){}canDie(){return Ee.i.currentScreen=xe.Lose,!1}onDamage(e,t){this.wand&&(this.wand.emissiveColor=i.Color3.Red(),Ee.i.time.wait(100,()=>{this.wand&&(this.wand.emissiveColor=i.Color3.Green().scale(t/100))}))}castSpell(e){const t=this.spellBook.lookupSpell();t&&t.cast(this,e)}update(e){super.update(e);const t=this.position;this.health<10&&console.log(`Health: ${this.health}`);const n=i.Vector3.Zero();if(this.rocketMode?n.addInPlace(this.facingVector.negate()):(this.up.isDown?this.down.isDown||(n.z-=1):this.down.isDown&&(n.z+=1),this.left.isDown?this.right.isDown||(n.x-=1):this.right.isDown&&(n.x+=1)),this.rocketMode||n.length()>.1){const t=this.terrain.Travel(this.position,n.normalize().scale((this.rocketMode?U:V)*e));Object(T.d)(this.simAt(t),u.c?this.terrain.map.mobsNear(t,1):x.a.mobs,T.b.HeroMoveObstacle)||(this.position=t)}const r=i.Ray.Zero();Ee.i.scene.createPickingRayToRef(Ee.i.scene.pointerX,Ee.i.scene.pointerY,this.terrain.map.mesh.getWorldMatrix(),r,null);const o=this.terrain.map.mesh.intersects(r);if(null!==o.pickedPoint){const e=o.pickedPoint;this.lookAt(e)}const a=this.velocity;this.velocity=n,this.cameraTarget.position.x=this.mesh.position.x,this.cameraTarget.position.z=this.mesh.position.z,this.stepTimeLeft-=e,this.stepTimeLeft=Math.max(0,this.stepTimeLeft),t.equals(this.position)||(a.equals(i.Vector3.Zero())&&(this.stepDuration=600),this.stepTimeLeft<=0&&(C.a.STEPS.playNext(),this.stepDuration=300,this.stepTimeLeft=this.stepDuration))}}G.MESH=new o.d("hero",y.a,-Math.PI/4);var H=n(242),j=n.n(H);const W=[new i.Vector2(42.5,50),new i.Vector2(20,32),new i.Vector2(27,32),new i.Vector2(13,8),new i.Vector2(18,12),new i.Vector2(23,9),new i.Vector2(6,41)],X=new o.c("marcys_playground",j.a,new i.Vector2(19,21),W);var Y=n(19),K=n(0),Q=n(101);class q extends r.y{constructor(e,t){super(),this.selected=!1,this.index=e,this.thickness=0,this.alpha=.6;const n=f.a.RUNES[e].name,i="runeButton-"+e;this.button=r.d.CreateImageOnlyButton(i,t),this.button=r.d.CreateImageWithCenterTextButton(i,n,t),this.button.color="white",this.button.thickness=2,this.button.image.stretch=r.m.STRETCH_UNIFORM,this.button.width="1.0",this.button.height="1.0",this.button.paddingTop="2%",this.button.paddingBottom="2%",this.button.paddingLeft="2%",this.button.paddingRight="2%",this.button.cornerRadius=20,this.button.textBlock&&(this.button.textBlock.verticalAlignment=r.i.VERTICAL_ALIGNMENT_BOTTOM,this.button.textBlock.height=.15),this.addControl(this.button)}deselect(){this.selected=!1,this.alpha=.6,this.button.background="",this.button.color="black",this.button.background="darkgrey",this.button.thickness=1}select(){this.selected=!0}setInvalid(){this.button.color="#145214",this.alpha=1,this.button.background="#609075",this.button.thickness=5}setValid(){this.button.color="black",this.alpha=1,this.button.background="mediumseagreen",this.button.thickness=10}enable(){this.isEnabled=!0,this.selected?this.select():this.deselect()}disable(){this.isEnabled=!1,this.alpha=.2,this.button.color="black",this.button.background="darkgrey"}}class Z extends r.y{constructor(e,t,n){super(),this.selected=!1,this.index=e,this.group=n,this.thickness=0,this.alpha=.6;const i="slotButton"+e;this.button=r.d.CreateSimpleButton(i,t),this.button.color="white",this.button.thickness=2,this.button.paddingTop="10%",this.button.paddingBottom="10%",this.button.paddingLeft="5%",this.button.paddingRight="5%",this.button.background="deepskyblue",this.button.fontFamily="Papyrus",this.addControl(this.button),this.group.addSlotButton(this)}select(){this.selected=!0,this.button.color="black",this.alpha=1}deselect(){this.selected=!1,this.button.color="white",this.alpha=.6}}class J{constructor(){this.selectedIndex=0,this.buttonList=[]}addSlotButton(e){0===this.buttonList.length&&e.select(),this.buttonList.push(e)}selectIndex(e){this.select(this.buttonList[e])}select(e){if(!e.selected){this.selectedIndex=e.index,e.select();for(const t of this.buttonList)t!==e&&t.deselect()}}}class $ extends Y.a{constructor(e){super(e),this.slotButtonGroup=new J,this.runeButtons=[],this.toggle=!1,this.autoClear=!1;const t=new i.FreeCamera("camera1",new K.x(0,5,-10),this);t.setTarget(K.x.Zero()),t.attachControl(this.getEngine().getRenderingCanvas(),!0);const o=Q.a.CreateFullscreenUI("UI"),a=new r.y("filter");a.alpha=.5,a.background="black",a.thickness=1,a.color="black",o.addControl(a);const s=new r.y("panel");s.width=.8,s.height=.8,s.thickness=0,o.addControl(s);const c=n(127),l=new r.m("paper",c);l.width=1,l.height=1,s.addControl(l);const u=this.createHeaderGrid();u.width=.8,u.height=.8,s.addControl(u);const h=this.createHeaderText(),d=this.createSlotGrid(),f=this.createRuneGrid();this.spellNameText=this.createSpellNameText(),u.addControl(h,0,0),u.addControl(d,1,0),u.addControl(f,2,0),u.addControl(this.spellNameText,3,0)}createHeaderGrid(){const e=new r.l;return e.addColumnDefinition(1),e.addRowDefinition(.1),e.addRowDefinition(.1),e.addRowDefinition(.8),e.addRowDefinition(.1),e}createSlotGrid(){const e=new r.l;e.addColumnDefinition(.1);for(let t=0;t<5;++t){const n=t+1,i=new Z(t,p.numToRoman(n),this.slotButtonGroup);i.button.onPointerClickObservable.add(()=>{this.toggle&&this.spellBook.selectSpell(t)}),e.addColumnDefinition(.1),e.addControl(i,0,n)}return e.addColumnDefinition(.1),e}createRuneGrid(){const e=new r.l;e.paddingTop="5%",e.paddingBottom="5%",e.paddingLeft="5%",e.paddingRight="5%";const t=f.a.RUNES.length,n=Math.ceil(Math.sqrt(t/2)),i=2*n;let o=0;for(let r=0;r{this.toggle&&(t.selected?(t.deselect(),this.spellBook.unloadRune(t.index)):(this.spellBook.loadRune(t.index),t.select()),this.updateGui())}),this.runeButtons.push(t),e.addControl(t,r,n),++o}}return e}createHeaderText(){const e=new r.H;return e.text="Spell Book",e.fontWeight="bold",e.fontFamily="Papyrus",e.color="black",e.fontSize=40,e}createSpellNameText(){const e=new r.H;return e.fontWeight="bold",e.fontFamily="Papyrus",e.color="black",e.fontSize=40,e}setSpellBook(e){this.spellBook=e,this.spellBook.spellSelectCallbacks.push(e=>{this.loadSpellSlot(e)})}openBook(){this.toggle=!0,Ee.i.paused=!0,this.loadSpellSlot(this.spellBook.activeSlot)}closeBook(){Ee.i.paused=!1,this.toggle=!1}loadSpellSlot(e){this.slotButtonGroup.selectIndex(e);const t=this.spellBook.slots[e];this.clearRunes();for(const e of t.getRunes())this.runeButtons[e].select();this.updateGui()}clearRunes(){for(const e of this.runeButtons)e.deselect()}getSlotIndex(){return this.slotButtonGroup.selectedIndex}updateGui(){for(const e of this.runeButtons)e.disable();const e=this.spellBook.slots[this.getSlotIndex()],t=this.spellBook.lookupSpell();this.spellNameText.text=t?t.name():"";for(const n of e.getRunes())this.runeButtons[n].enable(),t?this.runeButtons[n].setValid():this.runeButtons[n].setInvalid();const n=this.spellBook.findValidRunes(e.getRunes());for(const e of n)this.runeButtons[e].enable()}}var ee=n(243),te=n.n(ee);class ne{constructor(e,t,n){this.spawnTemplate=e,this.interval=t,this.map=n,this.stopped=!1}nextDelay(){return Math.round(this.interval*(Math.random()+.5))}startSpawn(){return Ee.i.time.wait(this.nextDelay(),()=>{if(!this.stopped)return this.spawn(),this.nextDelay()}),this}stopSpawn(){this.stopped=!0}_invokeSpawn(e){this.map.isValidLocation(e)&&(this.map.setYToMapHeight(e),this.spawnTemplate(e))}}class ie extends x.a{constructor(e,t){super(ie.MESH.create(),e,T.b.of(T.b.Visible,T.b.HeroMoveObstacle,T.b.HeroDamagable),500),this.spawner=t}get radius(){return.7}onDispose(){this.spawner.stopSpawn(),super.onDispose()}onDamage(e,t){}}ie.MESH=new o.d("spawner",te.a);class re extends ne{constructor(e,t,n,r){super(e,t,n.map),this.position=n.map.setYToMapHeight(new i.Vector3(r.x,0,-r.y)),new ie(n,this).position=this.position}spawn(){this._invokeSpawn(this.position)}}class oe{constructor(e,t,n){this.map=t,this.game=n,Object(v.f)(this.map.mesh,this)}get name(){return this.map.mesh.name}IsValidStep(e,t,n=!1){const i=t.y-e.y;return!(i>oe.VALID_STEP_UP)&&!(!n&&i<-oe.VALID_STEP_DOWN)}MakeValidLocation(e){return this.map.makeValidLocation(e)}Travel(e,t,n=!1){const i=e.add(t);t.length()>1&&t.normalize();let r=e.clone();do{const e=r;if(r=r.add(t),!this.map.isValidLocation(r))return e;if(this.map.setYToMapHeight(r),!this.IsValidStep(e,r,n))return e}while(i.subtract(r).multiplyByFloats(1,0,1).length()>oe.EPSILON);return r}}oe.STEP_SIZE=.04,oe.VALID_STEP_UP=1.5*oe.STEP_SIZE,oe.VALID_STEP_DOWN=4.5*oe.STEP_SIZE,oe.EPSILON=.5;var ae=n(90);const se=6e4,ce=36e5,le=i.Color3.White(),ue=(new i.Color3(249,255,173),new i.Color3(255,46,30),i.Color3.White(),i.Color3.White()),he=i.Color3.Blue();class de{constructor(e,t){this.scene=e,this.day=new v.b,this.night=new v.b,this.timeOfDayMs=u.e*ce,this.sunColor=new ae.a,this.sunIntensity=new ae.b,this.sunAngle=new ae.b,this.ambientColor=new ae.a,this.ambientIntensity=new ae.b,this.glowIntensity=new ae.b,this.timers=[],this.curves=[],d(()=>{t.registerKey(this.day,v.a.BracketLeft),t.registerKey(this.night,v.a.BracketRight),this.day.callback=()=>{this.timeOfDay=6},this.night.callback=()=>{this.timeOfDay=20}}),this.sunColor.add(5,le),this.sunIntensity.add(5,0),this.sunIntensity.add(6,.5),this.sunIntensity.add(8,1),this.sunIntensity.add(18,1),this.sunIntensity.add(20,.5),this.sunIntensity.add(21,0),this.sunAngle.add(6,2*Math.PI/3),this.sunAngle.add(18,2*-Math.PI/3),this.sun=new i.DirectionalLight("sun",new i.Vector3(1,-1,0),this.scene),this.sun.specular=i.Color3.Gray(),this.ambientColor.add(5,he),this.ambientColor.add(7,ue),this.ambientColor.add(17,ue),this.ambientColor.add(19,he),this.ambientIntensity.add(4,.5),this.ambientIntensity.add(6,.3),this.ambientIntensity.add(18,.3),this.ambientIntensity.add(18,.5),this.ambient=new i.HemisphericLight("ambient",new i.Vector3(0,1,0),this.scene),this.ambient.specular=i.Color3.Black(),this.ambient.groundColor=i.Color3.Black(),this.glowIntensity.add(4,2),this.glowIntensity.add(5,0),this.glowIntensity.add(21,0),this.glowIntensity.add(22,2),this.sun.setEnabled(!0),this.ambient.setEnabled(!0),this.updateLighting()}get timeOfDay(){return this.timeOfDayMs/ce}set timeOfDay(e){this.timeOfDayMs=Math.round(e*ce)}get hour(){return Math.floor(this.timeOfDay)}get minute(){return Math.floor(this.timeOfDayMs/se)-60*this.hour}get second(){return Math.floor(this.timeOfDayMs/1e3)-60*this.hour*60-60*this.minute}update(e){for(let t=0;t0){t+=1;continue}const n=this.timers[t].callback();void 0===n?this.timers.splice(t,1):(this.timers[t].delay=n,t+=1)}for(let t=0;t24*ce&&(this.timeOfDayMs=this.timeOfDayMs%(24*ce)),this.updateLighting(),Ee.i.glowIntensity=2*(1-this.sun.intensity)}wait(e,t){this.timers.push({delay:e,callback:t})}curve(e,t){return this.curves.push({elapsed:0,gradient:e,callback:t}),e}updateLighting(){const e=this.timeOfDay,t=i.Quaternion.RotationAxis(i.Vector3.Right(),4*-Math.PI/6),n=i.Quaternion.RotationAxis(i.Vector3.Backward(),this.sunAngle.lerp(e));i.Vector3.Backward().rotateByQuaternionToRef(t.add(n),this.sun.direction),this.sun.diffuse=this.sunColor.lerp(e),this.sun.intensity=this.sunIntensity.lerp(e),this.ambient.diffuse=this.ambientColor.lerp(e),this.ambient.intensity=this.ambientIntensity.lerp(e)}}class fe{constructor(e){this.scene=e,this.positions=[],this.indices=[],this.colors=[],this.normals=[],this.minHeight=0,this.maxHeight=1}build(e,t){const n=new i.Mesh(e,this.scene);this.maxHeight=Math.max(...t.basemap),this.minHeight=Math.min(Math.min(...t.basemap),this.maxHeight-1);for(let e=0;e{Ee.i.currentScreen=xe.MainGame}),e.addControl(t)}}class ve extends i.Scene{constructor(e){super(e);const t=new i.FreeCamera("camera1",new i.Vector3(0,5,-10),this);t.setTarget(i.Vector3.Zero()),t.attachControl(this.getEngine().getRenderingCanvas(),!0);const n=r.a.CreateFullscreenUI("UI"),o=new r.y("panel");n.addControl(o);const a=new r.m("paper",ge.a);a.width=1,a.height=1,o.addControl(a);const s=new r.F;this.addTextLine("The council of wizards finally breaks through the barrier.",s,50),this.addTextLine("As sunlight from the astral plane breaks the darkness,",s,50),this.addTextLine("You find yourself once again in full human form.",s,60),this.addTextLine("You were almost lost to void.",s,50),this.addEnterGameButton(s),o.addControl(s)}addTextLine(e,t,n=40){const i=new r.H;i.text=e,i.color="black",i.fontSize="50vh",i.fontFamily="Papyrus",i.resizeToFit=!0,i.textWrapping=!0,t.addControl(i)}addEnterGameButton(e){const t=new r.H;t.text="You will never go back (Or will you? Refresh to play again!)",t.color="white",t.fontSize="50vh",t.fontFamily="Papyrus",t.resizeToFit=!0,t.textWrapping=!0,e.addControl(t)}}class be extends i.Scene{constructor(e){super(e);const t=new i.FreeCamera("camera1",new i.Vector3(0,5,-10),this);t.setTarget(i.Vector3.Zero()),t.attachControl(this.getEngine().getRenderingCanvas(),!0);const n=r.a.CreateFullscreenUI("UI"),o=new r.y("panel");n.addControl(o);const a=new r.m("paper",ge.a);a.width=1,a.height=1,o.addControl(a);const s=new r.F;this.addTextLine("You died.",s,60),this.addTextLine("Blackness from the void of madness envelopes you forever.",s,45),this.addRejoinGameButton(s),o.addControl(s)}addTextLine(e,t,n=40){const i=new r.H;i.text=e,i.color="black",i.fontSize=n+"vh",i.fontFamily="Papyrus",i.resizeToFit=!0,i.textWrapping=!0,t.addControl(i)}addRejoinGameButton(e){const t=new r.H;t.text="Bummer. Keep going?",t.color="white",t.fontSize="50vh",t.fontFamily="Papyrus",t.isPointerBlocker=!0,t.resizeToFit=!0,t.textWrapping=!0,t.onPointerClickObservable.add(()=>{Ee.i.gameHero.health=100,Ee.i.currentScreen=xe.MainGame}),e.addControl(t)}}class ye extends r.y{constructor(){super(),this.name="InstructionPanel",this.alpha=.5,this.widthInPixels=250,this.heightInPixels=200,this.thickness=2,this.horizontalAlignment=r.i.HORIZONTAL_ALIGNMENT_LEFT,this.verticalAlignment=r.i.VERTICAL_ALIGNMENT_BOTTOM,this.background="black";const e=new r.l;e.verticalAlignment=r.i.VERTICAL_ALIGNMENT_BOTTOM,e.paddingLeftInPixels=10,e.paddingTopInPixels=10,e.paddingBottomInPixels=10,e.addRowDefinition(1),e.addRowDefinition(1),e.addRowDefinition(1),e.addRowDefinition(1),e.addRowDefinition(1),this.addControl(e);const t=new r.H("moveText","◆ WASD/Arrow Key -> Move");t.fontSize=16,t.fontFamily="Papyrus",t.fontStyle="bold",t.heightInPixels=25,t.color="white",t.textHorizontalAlignment=r.i.HORIZONTAL_ALIGNMENT_LEFT,e.addControl(t,0,0);const n=new r.H("castText","◆ Click -> Cast Spell");n.fontSize=16,n.fontFamily="Papyrus",n.fontStyle="bold",n.heightInPixels=25,n.color="white",n.textHorizontalAlignment=r.i.HORIZONTAL_ALIGNMENT_LEFT,e.addControl(n,1,0);const i=new r.H("spellBookText","◆ Shift -> Open Spell Book");i.fontSize=16,i.fontFamily="Papyrus",i.fontStyle="bold",i.heightInPixels=25,i.color="white",i.textHorizontalAlignment=r.i.HORIZONTAL_ALIGNMENT_LEFT,e.addControl(i,2,0);const o=new r.H("spellSlotText","◆ 1 - 5 -> Select Spell Slot");o.fontSize=16,o.fontFamily="Papyrus",o.fontStyle="bold",o.heightInPixels=25,o.color="white",o.textHorizontalAlignment=r.i.HORIZONTAL_ALIGNMENT_LEFT,e.addControl(o,3,0);const a=new r.H("toggleSpellSlotText","◆ Space -> Toggle Spell Slot");a.fontSize=16,a.fontFamily="Papyrus",a.fontStyle="bold",a.heightInPixels=25,a.color="white",a.textHorizontalAlignment=r.i.HORIZONTAL_ALIGNMENT_LEFT,e.addControl(a,4,0)}}n.d(t,"b",(function(){return xe})),n.d(t,"a",(function(){return Ee}));var xe,Ce=function(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(e){e[e.Intro=0]="Intro",e[e.Win=1]="Win",e[e.Lose=2]="Lose",e[e.MainGame=3]="MainGame"}(xe||(xe={}));class Ee{constructor(e){this.spawners=[],this.paused=!1,this.mousePrimary=new v.e,this.mouseSecondary=new v.e,this.engine=new i.Engine(e,!0),this.scene=new i.Scene(this.engine),this.scene.useRightHandedSystem=!0,this.introscene=new _e(this.engine),this.input=new v.c(this.scene),this.inventoryScene=new $(this.engine),this.assets=new o.a(this.scene),this.assets.addSound(Ee.MUSIC),this.assets.addMesh(G.MESH),this.assets.addMesh(c.a.MESH),this.assets.addMesh(ie.MESH),this.assets.addImage(new o.b("empty",g.a));for(const e of f.a.RUNES)this.assets.addImage(new o.b(e.name,e.image));for(const e of C.a.AllAssets())this.assets.addSound(e);this.particles=new S.d(this.scene);const t=new i.ArcRotateCamera("Camera",Math.PI/2,Math.PI/30,12,i.Vector3.Zero(),this.scene);t.layerMask=T.b.Visible.value,d(()=>{console.log(`camera a:${t.alpha} b:${t.beta}`),t.attachControl(e,!0),t.inputs.remove(t.inputs.attached.pointers);const n=t.inputs.attached.keyboard;n.keysLeft=[74],n.keysRight=[76],n.keysUp=[73],n.keysDown=[75],t.wheelPrecision=50}),this.camera=t,this.glow=new i.GlowLayer("glow",this.scene),this.glow.intensity=0,this.time=new de(this.scene,this.input);const n=new v.b;this.input.registerKey(n,v.a.ShiftLeft,v.a.ShiftRight),n.callback=()=>{this.inventoryScene.toggle?(this.inventoryScene.closeBook(),this.activeSpellPanel.updateSpells()):this.inventoryScene.openBook()},this.mousePrimary.callback=(e,t,n)=>{this.inventoryScene.toggle||this.hero.castSpell(t)},this.mousePrimary.predicate=e=>e instanceof oe,this.input.registerMouseButton(this.mousePrimary,v.d.Primary),this.input.registerMouseButton(this.mouseSecondary,v.d.Secondary);const a=r.a.CreateFullscreenUI("UI",void 0,this.scene);this.activeSpellPanel=new _,a.addControl(this.activeSpellPanel),this.instructionPanel=new ye,a.addControl(this.instructionPanel),h(this.scene),Ee.i=this}set currentScreen(e){e===xe.MainGame&&(void 0!==this.introscene&&(this.introscene.dispose(),this.introscene=void 0),void 0!==this.losescene&&(this.losescene.dispose(),this.losescene=void 0),void 0!==this.winscene&&(this.winscene.dispose(),this.winscene=void 0)),e===xe.Intro&&(this.introscene=new _e(this.engine)),e===xe.Lose&&(this.losescene=new be(this.engine)),e===xe.Win&&(this.winscene=new ve(this.engine)),Ee._currentScreen=e}get currentScreen(){return Ee._currentScreen}get gameHero(){return this.hero}get glowIntensity(){return this.glow.intensity}set glowIntensity(e){this.glow.intensity=e}updateFoV(){const e=this.engine.getRenderingCanvasClientRect();if(!e)return;const t=e.width/e.height<1?i.Camera.FOVMODE_VERTICAL_FIXED:i.Camera.FOVMODE_HORIZONTAL_FIXED;t!==this.camera.fovMode&&(console.log(`Changing FoV mode to ${t===i.Camera.FOVMODE_VERTICAL_FIXED?"vertical":"horizontal"}`),this.camera.fovMode=t)}createLevel(){return Ce(this,void 0,void 0,(function*(){const e=X;this.assets.addMap(e),yield this.assets.load(),c.a.MESH.setEmissive(i.Color3.Red());const t=G.MESH.setEmissive(i.Color3.Green());ie.MESH.setEmissive(i.Color3.Purple());const n=new pe("map",e.create(oe.STEP_SIZE),e=>new i.Vector2(e.x,-e.z),(e,t)=>new i.Vector3(e.x,t,-e.y),oe.VALID_STEP_UP,oe.VALID_STEP_DOWN,this.scene);this.terrain=new oe("land",n,this),this.hero=new G(this,this.terrain,t),this.hero.position=n.heroSpawn,this.inventoryScene.setSpellBook(this.hero.spellBook),this.activeSpellPanel.setSpellBook(this.hero.spellBook),this.camera.lockedTarget=this.hero.cameraTarget;const r=e=>{if(x.a.mobs.length>u.b)return;new c.a(this.hero,this.terrain,e)};e.enemySpawn.forEach(e=>{this.spawners.push(new re(r,2e3,this.terrain,e).startSpawn())})}))}loop(){let e=performance.now();this.engine.runRenderLoop(()=>{switch(this.currentScreen){case xe.Intro:this.introscene.render();break;case xe.Win:this.winscene.render();break;case xe.Lose:this.losescene.render();break;case xe.MainGame:if(1===x.a.mobs.length)return void(this.currentScreen=xe.Win);const t=performance.now(),n=this.paused?0:Math.max(0,t-e);e=t;for(const e of x.a.mobs)e.update(n);this.time.update(n),this.scene.render(),this.inventoryScene.toggle&&this.inventoryScene.render()}})}}Ee._currentScreen=xe.Intro,Ee.MUSIC=new o.e("Music",s.a,!0,.5)},function(e,t,n){"use strict";var i="helperFunctions",r="const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nconst float Epsilon=0.0000001;\n#define saturate(x) clamp(x,0.0,1.0)\n#define absEps(x) abs(x)+Epsilon\n#define maxEps(x) max(x,Epsilon)\n#define saturateEps(x) clamp(x,Epsilon,1.0)\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat pow5(float value) {\nfloat sq=value*value;\nreturn sq*sq*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=maxEps(max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";n(8).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i=n(1),r=n(4),o=n(23),a=n(10),s=n(8),c="\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";s.a.ShadersStore.passPixelShader=c;var l="\nvarying vec2 vUV;\nuniform samplerCube textureSampler;\nvoid main(void)\n{\nvec2 uv=vUV*2.0-1.0;\n#ifdef POSITIVEX\ngl_FragColor=textureCube(textureSampler,vec3(1.001,uv.y,uv.x));\n#endif\n#ifdef NEGATIVEX\ngl_FragColor=textureCube(textureSampler,vec3(-1.001,uv.y,uv.x));\n#endif\n#ifdef POSITIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,1.001,uv.x));\n#endif\n#ifdef NEGATIVEY\ngl_FragColor=textureCube(textureSampler,vec3(uv.y,-1.001,uv.x));\n#endif\n#ifdef POSITIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,1.001));\n#endif\n#ifdef NEGATIVEZ\ngl_FragColor=textureCube(textureSampler,vec3(uv,-1.001));\n#endif\n}";s.a.ShadersStore.passCubePixelShader=l;n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return h}));var u=function(e){function t(t,n,i,o,a,s,c,l){return void 0===i&&(i=null),void 0===c&&(c=r.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1),e.call(this,t,"pass",null,null,n,i,o,a,s,void 0,c,void 0,null,l)||this}return i.d(t,e),t}(o.a),h=function(e){function t(t,n,i,o,a,s,c,l){void 0===i&&(i=null),void 0===c&&(c=r.a.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1);var u=e.call(this,t,"passCube",null,null,n,i,o,a,s,"#define POSITIVEX",c,void 0,null,l)||this;return u._face=0,u}return i.d(t,e),Object.defineProperty(t.prototype,"face",{get:function(){return this._face},set:function(e){if(!(e<0||e>5))switch(this._face=e,this._face){case 0:this.updateEffect("#define POSITIVEX");break;case 1:this.updateEffect("#define NEGATIVEX");break;case 2:this.updateEffect("#define POSITIVEY");break;case 3:this.updateEffect("#define NEGATIVEY");break;case 4:this.updateEffect("#define POSITIVEZ");break;case 5:this.updateEffect("#define NEGATIVEZ")}},enumerable:!0,configurable:!0}),t}(o.a);a.b._RescalePostProcessFactory=function(e){return new u("rescale",1,null,a.b.TEXTURE_BILINEAR_SAMPLINGMODE,e,!1,a.b.TEXTURETYPE_UNSIGNED_INT)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(1),r=n(16),o=n(41),a=n(26),s=function(e){function t(t,n){var i=e.call(this,t,n,!0)||this;return n.multiMaterials.push(i),i.subMaterials=new Array,i._storeEffectOnSubMeshes=!0,i}return i.d(t,e),Object.defineProperty(t.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),t.prototype.getChildren=function(){return this.subMaterials},t.prototype._hookArray=function(e){var t=this,n=e.push;e.push=function(){for(var i=[],r=0;r=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},t.prototype.getActiveTextures=function(){var t;return(t=e.prototype.getActiveTextures.call(this)).concat.apply(t,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})))},t.prototype.getClassName=function(){return"MultiMaterial"},t.prototype.isReadyForSubMesh=function(e,t,n){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);i.id=e.id,o.a&&o.a.AddTagsTo(i,e.tags);for(var r=0;r-1?t.substring(b).toLowerCase():""),x=".dds"===y,C=".env"===y;if(C?(v.gammaSpace=!1,v._prefiltered=!1):(v._prefiltered=f,f&&(v.gammaSpace=!1)),v._texture=v._getFromCache(t,r),!s&&(C||x||i||(i=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),s=[],i))for(var E=0;E4&&(o.push(a.b.MatricesIndicesExtraKind),o.push(a.b.MatricesWeightsExtraKind));var h=e.skeleton;r.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),s.addCPUSkinningFallback(0,e),h.isUsingTextureForMatrices?(r.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")):(r.push("#define BonesPerMesh "+(h.bones.length+1)),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones"))}else r.push("#define NUM_BONE_INFLUENCERS 0");for(var d in this._textures)if(!this._textures[d].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&r.push("#define ALPHATEST");var f=this._effect,p=r.join("\n");return this._effect=i.createEffect(this._shaderPath,{attributes:o,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:p,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError},i),!!this._effect.isReady()&&(f!==this._effect&&n.resetCachedMaterial(),this._renderId=n.getRenderId(),!0)},t.prototype.bindOnlyWorldMatrix=function(e){var t=this.getScene();this._effect&&(-1!==this._options.uniforms.indexOf("world")&&this._effect.setMatrix("world",e),-1!==this._options.uniforms.indexOf("worldView")&&(e.multiplyToRef(t.getViewMatrix(),this._cachedWorldViewMatrix),this._effect.setMatrix("worldView",this._cachedWorldViewMatrix)),-1!==this._options.uniforms.indexOf("worldViewProjection")&&this._effect.setMatrix("worldViewProjection",e.multiply(t.getTransformMatrix())))},t.prototype.bind=function(e,t){if(this.bindOnlyWorldMatrix(e),this._effect&&this.getScene().getCachedMaterial()!==this){var n;for(n in-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),c.a.BindBonesParameters(t,this._effect),this._textures)this._effect.setTexture(n,this._textures[n]);for(n in this._textureArrays)this._effect.setTextureArray(n,this._textureArrays[n]);for(n in this._ints)this._effect.setInt(n,this._ints[n]);for(n in this._floats)this._effect.setFloat(n,this._floats[n]);for(n in this._floatsArrays)this._effect.setArray(n,this._floatsArrays[n]);for(n in this._colors3)this._effect.setColor3(n,this._colors3[n]);for(n in this._colors3Arrays)this._effect.setArray3(n,this._colors3Arrays[n]);for(n in this._colors4){var i=this._colors4[n];this._effect.setFloat4(n,i.r,i.g,i.b,i.a)}for(n in this._vectors2)this._effect.setVector2(n,this._vectors2[n]);for(n in this._vectors3)this._effect.setVector3(n,this._vectors3[n]);for(n in this._vectors4)this._effect.setVector4(n,this._vectors4[n]);for(n in this._matrices)this._effect.setMatrix(n,this._matrices[n]);for(n in this._matrices3x3)this._effect.setMatrix3x3(n,this._matrices3x3[n]);for(n in this._matrices2x2)this._effect.setMatrix2x2(n,this._matrices2x2[n]);for(n in this._vectors2Arrays)this._effect.setArray2(n,this._vectors2Arrays[n]);for(n in this._vectors3Arrays)this._effect.setArray3(n,this._vectors3Arrays[n])}this._afterBind(t)},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;re.index-t.index),this}lerp(e){for(let t=0;t=this.values[t].index)continue;if(0===t)return this.values[0].value;const n=this.values[t-1],i=this.values[t],r=(e-n.index)/(i.index-n.index);return this.lerpFn(n.value,i.value,r)}return this.values[this.values.length-1].value}}class o extends r{constructor(){super((e,t,n)=>e*(1-n)+t*n)}}class a extends r{constructor(){super(i.Color3.Lerp)}}},function(e,t,n){"use strict";n.d(t,"b",(function(){return f})),n.d(t,"c",(function(){return p})),n.d(t,"a",(function(){return m})),n.d(t,"e",(function(){return _})),n.d(t,"d",(function(){return y}));var i=n(11),r=n(74),o=n(90),a=n(238),s=n.n(a),c=n(149),l=n.n(c),u=n(72),h=n(239),d=n.n(h);n(240);const f=1,p=2,m=4,g=.25,_=.1;class v{constructor(){this._stopped=!1}get stopped(){return this._stopped}set stopped(e){this._stopped=e}}class b extends v{constructor(e,t=(()=>{})){super(),this.system=e,this.updater=t}start(){this.system.start()}stop(){this.system.stop(),this.stopped=!0}update(e){this.updater(e)}}class y{constructor(e){this.scene=e,this.explosion=this.createExplosion(i.Vector3.Zero(),f),this.miniExplosion=this.createExplosion(i.Vector3.Zero(),.1),this.scorch=this.createFireball(i.Vector3.Zero(),p)}light(e){const t=new i.PointLight("staffLight",i.Vector3.Zero(),this.scene);t.parent=e.crystalNode,t.intensity=0,t.radius=g,t.diffuse=t.specular=i.Color3.FromHexString("#00FF00");r.a.i.time.curve(new o.b,e=>e<=0?(t.dispose(),!1):(t.intensity=e,!0)).add(0,.1).add(400,.5).add(3600,.5).add(4e3,0)}miniExplode(e){const t=new i.PointLight("explosionLight",e.add(new i.Vector3(0,.05,0)),this.scene);t.intensity=2,t.radius=.4,t.diffuse=t.specular=i.Color3.FromHexString("#FA1111");const n=1e3*this.miniExplosion.targetStopDuration;return r.a.i.time.curve(new o.b,e=>e<=0?(t.dispose(),!1):(t.intensity=e,!0)).add(0,.1).add(.1*n,2).add(n,2).add(2*n,0),this.miniExplosion.emitter=e,this.miniExplosion.start(),u.a.EXPLOSIONS.playNext(),new b(this.miniExplosion)}explode(e){const t=new i.PointLight("explosionLight",e.add(new i.Vector3(0,f/2,0)),this.scene);t.intensity=2,t.radius=4*f,t.diffuse=t.specular=i.Color3.FromHexString("#FA1111");const n=1e3*this.explosion.targetStopDuration;return r.a.i.time.curve(new o.b,e=>e<=0?(t.dispose(),!1):(t.intensity=e,!0)).add(0,.1).add(.1*n,2).add(n,2).add(2*n,0),this.explosion.emitter=e,this.explosion.start(),u.a.EXPLOSIONS.playNext(),new b(this.explosion)}fireball(e){const t=new i.PointLight("fireballLight",e.add(new i.Vector3(0,f/2,0)),this.scene);t.intensity=2,t.radius=4*f,t.diffuse=t.specular=i.Color3.FromHexString("#FA1111");const n=1e3*this.explosion.targetStopDuration;return r.a.i.time.curve(new o.b,e=>e<=0?(t.dispose(),!1):(t.intensity=e,!0)).add(0,.1).add(.1*n,2).add(n,2).add(2*n,0),this.scorch.emitter=e,this.scorch.start(),u.a.FIREBALL.playNext(),new b(this.scorch)}chainLightning(e,t){const n=t.subtract(e.position),r=new i.ParticleSystem("lightning",1e3,this.scene,null,!1);return r.particleTexture=new i.Texture(l.a,this.scene),r.emitter=e.mesh,r.createBoxEmitter(n,n,i.Vector3.Zero(),i.Vector3.Zero()),r.color1=new i.Color4(.7,.8,1,1),r.color2=new i.Color4(.2,.5,1,1),r.colorDead=new i.Color4(0,0,.2,0),r.minSize=.075,r.maxSize=.15,r.minLifeTime=.75,r.maxLifeTime=.75,r.emitRate=200,r.blendMode=i.ParticleSystem.BLENDMODE_ONEONE,r.gravity=i.Vector3.Zero(),r.minAngularSpeed=0,r.maxAngularSpeed=2*Math.PI,r.minEmitPower=5,r.maxEmitPower=10,r.disposeOnStop=!0,r.targetStopDuration=.5,u.a.LIGHTNING.playNext(),new b(r,n=>{const i=t.subtract(e.position);r.emitter=e.position,r.direction1=i,r.direction2=i})}stationaryLightning(e,t,n=10){const r=new i.ParticleSystem("lightning",1e3,this.scene,null,!1);return r.particleTexture=new i.Texture(l.a,this.scene),r.emitter=e,r.createSphereEmitter(t),r.blendMode=i.ParticleSystem.BLENDMODE_ONEONE,r.color1=new i.Color4(.7,.8,1,1),r.color2=new i.Color4(.2,.5,1,1),r.colorDead=new i.Color4(0,0,.2,0),r.minSize=.025,r.maxSize=.075,r.minLifeTime=0,r.maxLifeTime=.3,r.emitRate=200,r.gravity=i.Vector3.Zero(),r.minAngularSpeed=0,r.maxAngularSpeed=2*Math.PI,r.minEmitPower=1,r.maxEmitPower=3,r.disposeOnStop=!0,r.targetStopDuration=n,new b(r)}createExplosion(e,t){const n=new i.ParticleSystem("explosion",1e3,this.scene,null,!0);return n.emitter=e,n.createSphereEmitter(t),n.blendMode=i.ParticleSystem.BLENDMODE_STANDARD,n.particleTexture=new i.Texture(s.a,this.scene,!1,!1,i.Texture.TRILINEAR_SAMPLINGMODE),n.spriteCellWidth=256,n.spriteCellHeight=256,n.startSpriteCellID=0,n.endSpriteCellID=15,n.spriteCellChangeSpeed=.05,n.minInitialRotation=0,n.maxInitialRotation=2*Math.PI,n.minLifeTime=.5,n.maxLifeTime=.8,n.targetStopDuration=.15,n.emitRate=4e3,n.addSizeGradient(0,.2,.3),n.addSizeGradient(.4,.3,.4),n.addSizeGradient(1,.7,1.5),n.addColorGradient(0,i.Color4.FromHexString("#FAF603FF")),n.addColorGradient(.15,i.Color4.FromHexString("#FA1111FF")),n.addColorGradient(.3,i.Color4.FromHexString("#22222255")),n.addColorGradient(1,i.Color4.FromHexString("#00000000")),n}createFireball(e,t){const n=new i.ParticleSystem("fireball",1e3,this.scene,null,!1);return n.emitter=e,n.createSphereEmitter(t),n.blendMode=i.ParticleSystem.BLENDMODE_ONEONE,n.particleTexture=new i.Texture(d.a,this.scene),n.minInitialRotation=0,n.maxInitialRotation=2*Math.PI,n.minLifeTime=.1,n.maxLifeTime=.3,n.targetStopDuration=1,n.emitRate=1e3,n}setOnFire(e,t,n){const r=new i.ParticleSystem("fire",2e3,this.scene);return r.particleTexture=new i.Texture(l.a,this.scene),r.emitter=e.mesh,r.minEmitBox=new i.Vector3(-.2,e.radius,-.2),r.maxEmitBox=new i.Vector3(.2,e.radius,.2),r.color1=new i.Color4(1,.5,0,1),r.color2=new i.Color4(1,.5,0,1),r.colorDead=new i.Color4(0,0,0,0),r.minSize=.3,r.maxSize=.6,r.minLifeTime=.1,r.maxLifeTime=.3,r.emitRate=300,r.blendMode=i.ParticleSystem.BLENDMODE_ONEONE,r.gravity=new i.Vector3(0,0,0),r.direction1=new i.Vector3(0,2,0),r.direction2=new i.Vector3(0,2,0),r.minAngularSpeed=0,r.maxAngularSpeed=Math.PI,r.minEmitPower=1,r.maxEmitPower=3,r.updateSpeed=.008,r.disposeOnStop=!0,r.targetStopDuration=n,r.addEmitRateGradient(0,300),r.addEmitRateGradient(.5,100),r.addEmitRateGradient(.7,50),r.addEmitRateGradient(.8,20),r.addEmitRateGradient(.9,10),r.addEmitRateGradient(1,1),r.start(),new b(r)}melt(e,t){const n=new i.ParticleSystem("Melt",2e3,this.scene);return n.particleTexture=new i.Texture(l.a,this.scene),n.emitter=e,n.minEmitBox=new i.Vector3(-.2,e.y,-.2),n.maxEmitBox=new i.Vector3(.2,e.y,.2),n.color1=new i.Color4(0,.5,1,1),n.color2=new i.Color4(1,.5,0,1),n.colorDead=new i.Color4(0,0,0,0),n.minSize=.05,n.maxSize=.2,n.minLifeTime=.1,n.maxLifeTime=.3,n.emitRate=400,n.blendMode=i.ParticleSystem.BLENDMODE_ONEONE,n.gravity=new i.Vector3(0,-10,0),n.direction1=new i.Vector3(0,2,0),n.direction2=new i.Vector3(0,2,0),n.minAngularSpeed=0,n.maxAngularSpeed=Math.PI,n.minEmitPower=1,n.maxEmitPower=3,n.updateSpeed=.008,n.disposeOnStop=!0,n.targetStopDuration=.2,n.addEmitRateGradient(0,300),n.addEmitRateGradient(.5,100),n.addEmitRateGradient(.7,50),n.addEmitRateGradient(.8,20),n.addEmitRateGradient(.9,10),n.addEmitRateGradient(1,1),n.start(),new b(n)}}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(1),r=n(7),o=n(5),a=function(e){function t(n,i){void 0===i&&(i=null);var o=e.call(this,n)||this;return o.name=n,o._loaded=!1,o._stretch=t.STRETCH_FILL,o._autoScale=!1,o._sourceLeft=0,o._sourceTop=0,o._sourceWidth=0,o._sourceHeight=0,o._cellWidth=0,o._cellHeight=0,o._cellId=-1,o._populateNinePatchSlicesFromImage=!1,o.onImageLoadedObservable=new r.c,o.source=i,o}return i.d(t,e),Object.defineProperty(t.prototype,"isLoaded",{get:function(){return this._loaded},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"populateNinePatchSlicesFromImage",{get:function(){return this._populateNinePatchSlicesFromImage},set:function(e){this._populateNinePatchSlicesFromImage!==e&&(this._populateNinePatchSlicesFromImage=e,this._populateNinePatchSlicesFromImage&&this._loaded&&this._extractNinePatchSliceDataFromImage())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"detectPointerOnOpaqueOnly",{get:function(){return this._detectPointerOnOpaqueOnly},set:function(e){this._detectPointerOnOpaqueOnly!==e&&(this._detectPointerOnOpaqueOnly=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sliceLeft",{get:function(){return this._sliceLeft},set:function(e){this._sliceLeft!==e&&(this._sliceLeft=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sliceRight",{get:function(){return this._sliceRight},set:function(e){this._sliceRight!==e&&(this._sliceRight=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sliceTop",{get:function(){return this._sliceTop},set:function(e){this._sliceTop!==e&&(this._sliceTop=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sliceBottom",{get:function(){return this._sliceBottom},set:function(e){this._sliceBottom!==e&&(this._sliceBottom=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sourceLeft",{get:function(){return this._sourceLeft},set:function(e){this._sourceLeft!==e&&(this._sourceLeft=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sourceTop",{get:function(){return this._sourceTop},set:function(e){this._sourceTop!==e&&(this._sourceTop=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sourceWidth",{get:function(){return this._sourceWidth},set:function(e){this._sourceWidth!==e&&(this._sourceWidth=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"sourceHeight",{get:function(){return this._sourceHeight},set:function(e){this._sourceHeight!==e&&(this._sourceHeight=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"autoScale",{get:function(){return this._autoScale},set:function(e){this._autoScale!==e&&(this._autoScale=e,e&&this._loaded&&this.synchronizeSizeWithContent())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"stretch",{get:function(){return this._stretch},set:function(e){this._stretch!==e&&(this._stretch=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"domImage",{get:function(){return this._domImage},set:function(e){var t=this;this._domImage=e,this._loaded=!1,this._domImage.width?this._onImageLoaded():this._domImage.onload=function(){t._onImageLoaded()}},enumerable:!0,configurable:!0}),t.prototype._onImageLoaded=function(){this._imageWidth=this._domImage.width,this._imageHeight=this._domImage.height,this._loaded=!0,this._populateNinePatchSlicesFromImage&&this._extractNinePatchSliceDataFromImage(),this._autoScale&&this.synchronizeSizeWithContent(),this.onImageLoadedObservable.notifyObservers(this),this._markAsDirty()},t.prototype._extractNinePatchSliceDataFromImage=function(){t._WorkingCanvas||(t._WorkingCanvas=document.createElement("canvas"));var e=t._WorkingCanvas,n=e.getContext("2d"),i=this._domImage.width,r=this._domImage.height;e.width=i,e.height=r,n.drawImage(this._domImage,0,0,i,r);var o=n.getImageData(0,0,i,r);this._sliceLeft=-1,this._sliceRight=-1;for(var a=0;a127&&-1===this._sliceLeft)this._sliceLeft=a;else if(c<127&&this._sliceLeft>-1){this._sliceRight=a;break}}this._sliceTop=-1,this._sliceBottom=-1;for(var s=0;s127&&-1===this._sliceTop)this._sliceTop=s;else if(c<127&&this._sliceTop>-1){this._sliceBottom=s;break}}},Object.defineProperty(t.prototype,"source",{set:function(e){var t=this;this._source!==e&&(this._loaded=!1,this._source=e,this._domImage=document.createElement("img"),this._domImage.onload=function(){t._onImageLoaded()},e&&(o.h.SetCorsBehavior(e,this._domImage),this._domImage.src=e))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cellWidth",{get:function(){return this._cellWidth},set:function(e){this._cellWidth!==e&&(this._cellWidth=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cellHeight",{get:function(){return this._cellHeight},set:function(e){this._cellHeight!==e&&(this._cellHeight=e,this._markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"cellId",{get:function(){return this._cellId},set:function(e){this._cellId!==e&&(this._cellId=e,this._markAsDirty())},enumerable:!0,configurable:!0}),t.prototype.contains=function(n,i){if(!e.prototype.contains.call(this,n,i))return!1;if(!this._detectPointerOnOpaqueOnly||!t._WorkingCanvas)return!0;var r=t._WorkingCanvas.getContext("2d"),o=0|this._currentMeasure.width,a=0|this._currentMeasure.height;return r.getImageData(0,0,o,a).data[4*((n=n-this._currentMeasure.left|0)+(i=i-this._currentMeasure.top|0)*this._currentMeasure.width)+3]>0},t.prototype._getTypeName=function(){return"Image"},t.prototype.synchronizeSizeWithContent=function(){this._loaded&&(this.width=this._domImage.width+"px",this.height=this._domImage.height+"px")},t.prototype._processMeasures=function(n,i){if(this._loaded)switch(this._stretch){case t.STRETCH_NONE:case t.STRETCH_FILL:case t.STRETCH_UNIFORM:case t.STRETCH_NINE_PATCH:break;case t.STRETCH_EXTEND:this._autoScale&&this.synchronizeSizeWithContent(),this.parent&&this.parent.parent&&(this.parent.adaptWidthToChildren=!0,this.parent.adaptHeightToChildren=!0)}e.prototype._processMeasures.call(this,n,i)},t.prototype._prepareWorkingCanvasForOpaqueDetection=function(){if(this._detectPointerOnOpaqueOnly){t._WorkingCanvas||(t._WorkingCanvas=document.createElement("canvas"));var e=t._WorkingCanvas,n=this._currentMeasure.width,i=this._currentMeasure.height,r=e.getContext("2d");e.width=n,e.height=i,r.clearRect(0,0,n,i)}},t.prototype._drawImage=function(e,n,i,r,o,a,s,c,l){(e.drawImage(this._domImage,n,i,r,o,a,s,c,l),this._detectPointerOnOpaqueOnly)&&(e=t._WorkingCanvas.getContext("2d")).drawImage(this._domImage,n,i,r,o,a-this._currentMeasure.left,s-this._currentMeasure.top,c,l)},t.prototype._draw=function(e){var n,i,r,o;if(e.save(),(this.shadowBlur||this.shadowOffsetX||this.shadowOffsetY)&&(e.shadowColor=this.shadowColor,e.shadowBlur=this.shadowBlur,e.shadowOffsetX=this.shadowOffsetX,e.shadowOffsetY=this.shadowOffsetY),-1==this.cellId)n=this._sourceLeft,i=this._sourceTop,r=this._sourceWidth?this._sourceWidth:this._imageWidth,o=this._sourceHeight?this._sourceHeight:this._imageHeight;else{var a=this._domImage.naturalWidth/this.cellWidth,s=this.cellId/a>>0,c=this.cellId%a;n=this.cellWidth*c,i=this.cellHeight*s,r=this.cellWidth,o=this.cellHeight}if(this._prepareWorkingCanvasForOpaqueDetection(),this._applyStates(e),this._loaded)switch(this._stretch){case t.STRETCH_NONE:case t.STRETCH_FILL:this._drawImage(e,n,i,r,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case t.STRETCH_UNIFORM:var l=this._currentMeasure.width/r,u=this._currentMeasure.height/o,h=Math.min(l,u),d=(this._currentMeasure.width-r*h)/2,f=(this._currentMeasure.height-o*h)/2;this._drawImage(e,n,i,r,o,this._currentMeasure.left+d,this._currentMeasure.top+f,r*h,o*h);break;case t.STRETCH_EXTEND:this._drawImage(e,n,i,r,o,this._currentMeasure.left,this._currentMeasure.top,this._currentMeasure.width,this._currentMeasure.height);break;case t.STRETCH_NINE_PATCH:this._renderNinePatch(e)}e.restore()},t.prototype._renderCornerPatch=function(e,t,n,i,r,o,a){this._drawImage(e,t,n,i,r,this._currentMeasure.left+o,this._currentMeasure.top+a,i,r)},t.prototype._renderNinePatch=function(e){var t=this._imageHeight,n=this._sliceLeft,i=this._sliceTop,r=this._imageHeight-this._sliceBottom,o=this._imageWidth-this._sliceRight,a=0,s=0;this._populateNinePatchSlicesFromImage&&(a=1,s=1,t-=2,n-=1,i-=1,r-=1,o-=1);var c=this._sliceRight-this._sliceLeft+1,l=this._currentMeasure.width-o-this.sliceLeft+1,u=this._currentMeasure.height-t+this._sliceBottom;this._renderCornerPatch(e,a,s,n,i,0,0),this._renderCornerPatch(e,a,this._sliceBottom,n,t-this._sliceBottom,0,u),this._renderCornerPatch(e,this._sliceRight,s,o,i,this._currentMeasure.width-o,0),this._renderCornerPatch(e,this._sliceRight,this._sliceBottom,o,t-this._sliceBottom,this._currentMeasure.width-o,u),this._drawImage(e,this._sliceLeft,this._sliceTop,c,this._sliceBottom-this._sliceTop+1,this._currentMeasure.left+n,this._currentMeasure.top+i,l,u-i+1),this._drawImage(e,a,this._sliceTop,n,this._sliceBottom-this._sliceTop,this._currentMeasure.left,this._currentMeasure.top+i,n,u-i),this._drawImage(e,this._sliceRight,this._sliceTop,n,this._sliceBottom-this._sliceTop,this._currentMeasure.left+this._currentMeasure.width-o,this._currentMeasure.top+i,n,u-i),this._drawImage(e,this._sliceLeft,s,c,i,this._currentMeasure.left+n,this._currentMeasure.top,l,i),this._drawImage(e,this._sliceLeft,this._sliceBottom,c,r,this._currentMeasure.left+n,this._currentMeasure.top+u,l,r)},t.prototype.dispose=function(){e.prototype.dispose.call(this),this.onImageLoadedObservable.clear()},t._WorkingCanvas=null,t.STRETCH_NONE=0,t.STRETCH_FILL=1,t.STRETCH_UNIFORM=2,t.STRETCH_EXTEND=3,t.STRETCH_NINE_PATCH=4,t}(n(20).a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(12),r=n(14);r.a.CreatePlane=function(e){var t=[],n=[],i=[],o=[],a=e.width||e.size||1,s=e.height||e.size||1,c=0===e.sideOrientation?0:e.sideOrientation||r.a.DEFAULTSIDE,l=a/2,u=s/2;n.push(-l,-u,0),i.push(0,0,-1),o.push(0,0),n.push(l,-u,0),i.push(0,0,-1),o.push(1,0),n.push(l,u,0),i.push(0,0,-1),o.push(1,1),n.push(-l,u,0),i.push(0,0,-1),o.push(0,1),t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),r.a._ComputeSides(c,n,t,i,o,e.frontUVs,e.backUVs);var h=new r.a;return h.indices=t,h.positions=n,h.normals=i,h.uvs=o,h},i.a.CreatePlane=function(e,t,n,i,r){var a={size:t,width:t,height:t,sideOrientation:r,updatable:i};return o.CreatePlane(e,a,n)};var o=function(){function e(){}return e.CreatePlane=function(e,t,n){void 0===n&&(n=null);var o=new i.a(e,n);return t.sideOrientation=i.a._GetDefaultSideOrientation(t.sideOrientation),o._originalBuilderSideOrientation=t.sideOrientation,r.a.CreatePlane(t).applyToMesh(o,t.updatable),t.sourcePlane&&(o.translate(t.sourcePlane.normal,-t.sourcePlane.d),o.setDirection(t.sourcePlane.normal.scale(-1))),o},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(9),r=function(){function e(e,t,n){this._engine=e,this._noUBO=!e.supportsUniformBuffers,this._dynamic=n,this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformLocationPointer=0,this._needSync=!1,this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform)}return Object.defineProperty(e.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!0,configurable:!0}),e.prototype.isDynamic=function(){return void 0!==this._dynamic},e.prototype.getData=function(){return this._bufferData},e.prototype.getBuffer=function(){return this._buffer},e.prototype._fillAlignment=function(e){var t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){var n=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;for(var i=this._uniformLocationPointer-n,r=0;r0?this._setDefaultFixedFrustumShadowProjectionMatrix(e):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,n)},t.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e){var t=this.getScene().activeCamera;t&&o.j.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:t.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:t.maxZ,e)},t.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,n){var i=this.getScene().activeCamera;if(i){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var r=o.x.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var a=0;athis._orthoRight&&(this._orthoRight=r.x),r.y>this._orthoTop&&(this._orthoTop=r.y)}}var u=this._orthoRight-this._orthoLeft,h=this._orthoTop-this._orthoBottom;o.j.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-h*this.shadowOrthoScale,this._orthoTop+h*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,e)}},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},t.prototype.getDepthMinZ=function(e){return 1},t.prototype.getDepthMaxZ=function(e){return 1},t.prototype.prepareLightSpecificDefines=function(e,t){e["DIRLIGHT"+t]=!0},i.c([Object(r.c)()],t.prototype,"shadowFrustumSize",null),i.c([Object(r.c)()],t.prototype,"shadowOrthoScale",null),i.c([Object(r.c)()],t.prototype,"autoUpdateExtends",void 0),t}(c.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(1),r=n(2),o=n(0),a=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._needProjectionMatrixCompute=!0,t}return i.d(t,e),t.prototype._setPosition=function(e){this._position=e},Object.defineProperty(t.prototype,"position",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!0,configurable:!0}),t.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(t.prototype,"direction",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),t.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=o.x.Zero()),o.x.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=o.x.Zero()),o.x.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},t.prototype.getDepthScale=function(){return 50},t.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},t.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},t.prototype.setDirectionToTarget=function(e){return this.direction=o.x.Normalize(e.subtract(this.position)),this.direction},t.prototype.getRotation=function(){this.direction.normalize();var e=o.x.Cross(this.direction,o.c.Y),t=o.x.Cross(e,this.direction);return o.x.RotationFromAxis(e,t,this.direction)},t.prototype.needCube=function(){return!1},t.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},t.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},t.prototype._initCache=function(){e.prototype._initCache.call(this),this._cache.position=o.x.Zero()},t.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},t.prototype.computeWorldMatrix=function(e){return!e&&this.isSynchronized()?(this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix):(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=o.j.Identity()),o.j.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._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},i.c([Object(r.o)()],t.prototype,"position",null),i.c([Object(r.o)()],t.prototype,"direction",null),i.c([Object(r.c)()],t.prototype,"shadowMinZ",null),i.c([Object(r.c)()],t.prototype,"shadowMaxZ",null),t}(n(44).a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1),r=n(2),o=n(0),a=n(30),s=n(44),c=n(99);a.a.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new l(e,o.x.Zero(),o.x.Zero(),0,0,t)}}));var l=function(e){function t(t,n,i,r,a,s){var c=e.call(this,t,s)||this;return c._innerAngle=0,c._projectionTextureMatrix=o.j.Zero(),c._projectionTextureLightNear=1e-6,c._projectionTextureLightFar=1e3,c._projectionTextureUpDirection=o.x.Up(),c._projectionTextureViewLightDirty=!0,c._projectionTextureProjectionLightDirty=!0,c._projectionTextureDirty=!0,c._projectionTextureViewTargetVector=o.x.Zero(),c._projectionTextureViewLightMatrix=o.j.Zero(),c._projectionTextureProjectionLightMatrix=o.j.Zero(),c._projectionTextureScalingMatrix=o.j.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),c.position=n,c.direction=i,c.angle=r,c.exponent=a,c}return i.d(t,e),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._cosHalfAngle=Math.cos(.5*e),this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute(),this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){var t=this;if(this._projectionTexture!==e&&(this._projectionTexture=e,this._projectionTextureDirty=!0,this._projectionTexture&&!this._projectionTexture.isReady())){var n=this._projectionTexture;n.onLoadObservable&&n.onLoadObservable.addOnce((function(){t._markMeshesAsLightDirty()}))}},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"SpotLight"},t.prototype.getTypeID=function(){return s.a.LIGHTTYPEID_SPOTLIGHT},t.prototype._setDirection=function(t){e.prototype._setDirection.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setPosition=function(t){e.prototype._setPosition.call(this,t),this._projectionTextureViewLightDirty=!0},t.prototype._setDefaultShadowProjectionMatrix=function(e,t,n){var i=this.getScene().activeCamera;if(i){this._shadowAngleScale=this._shadowAngleScale||1;var r=this._shadowAngleScale*this._angle;o.j.PerspectiveFovLHToRef(r,1,this.getDepthMinZ(i),this.getDepthMaxZ(i),e)}},t.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),o.j.LookAtLHToRef(this.position,this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},t.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,n=e/(e-t),i=-n*t,r=1/Math.tan(this._angle/2);o.j.FromValuesToRef(r/1,0,0,0,0,r,0,0,0,0,n,1,0,0,i,0,this._projectionTextureProjectionLightMatrix)},t.prototype._computeProjectionTextureMatrix=function(){this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)},t.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightDirection",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},t.prototype._computeAngleValues=function(){this._lightAngleScale=1/Math.max(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},t.prototype.transferToEffect=function(e,t){var n;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),n=o.x.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),n=o.x.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",n.x,n.y,n.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightSampler"+t,this.projectionTexture)),this},t.prototype.dispose=function(){e.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},t.prototype.prepareLightSpecificDefines=function(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!(!this.projectionTexture||!this.projectionTexture.isReady())},i.c([Object(r.c)()],t.prototype,"angle",null),i.c([Object(r.c)()],t.prototype,"innerAngle",null),i.c([Object(r.c)()],t.prototype,"shadowAngleScale",null),i.c([Object(r.c)()],t.prototype,"exponent",void 0),i.c([Object(r.c)()],t.prototype,"projectionTextureLightNear",null),i.c([Object(r.c)()],t.prototype,"projectionTextureLightFar",null),i.c([Object(r.c)()],t.prototype,"projectionTextureUpDirection",null),i.c([Object(r.m)("projectedLightTexture")],t.prototype,"_projectionTexture",void 0),t}(c.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return v}));var i=n(1),r=n(7),o=n(0),a=n(5),s=n(15),c=n(82),l=n(64),u=n(35),h=n(6),d=n(84),f=n(177),p=n(10),m=n(66),g=n(176),_=n(59),v=function(e){function t(t,n,i,a,s,u){void 0===n&&(n=0),void 0===i&&(i=0),void 0===s&&(s=!1),void 0===u&&(u=h.a.NEAREST_SAMPLINGMODE);var d=e.call(this,t,{width:n,height:i},a,s,u,p.b.TEXTUREFORMAT_RGBA)||this;return d._isDirty=!1,d._rootContainer=new m.a("root"),d._lastControlOver={},d._lastControlDown={},d._capturingControl={},d._linkedControls=new Array,d._isFullscreen=!1,d._fullscreenViewport=new o.z(0,0,1,1),d._idealWidth=0,d._idealHeight=0,d._useSmallestIdeal=!1,d._renderAtIdealSize=!1,d._blockNextFocusCheck=!1,d._renderScale=1,d._cursorChanged=!1,d._clipboardData="",d.onClipboardObservable=new r.c,d.onControlPickedObservable=new r.c,d.onBeginLayoutObservable=new r.c,d.onEndLayoutObservable=new r.c,d.onBeginRenderObservable=new r.c,d.onEndRenderObservable=new r.c,d.premulAlpha=!1,d._useInvalidateRectOptimization=!0,d._invalidatedRectangle=null,d._clearMeasure=new _.a(0,0,0,0),d.onClipboardCopy=function(e){var t=e,n=new c.b(c.a.COPY,t);d.onClipboardObservable.notifyObservers(n),t.preventDefault()},d.onClipboardCut=function(e){var t=e,n=new c.b(c.a.CUT,t);d.onClipboardObservable.notifyObservers(n),t.preventDefault()},d.onClipboardPaste=function(e){var t=e,n=new c.b(c.a.PASTE,t);d.onClipboardObservable.notifyObservers(n),t.preventDefault()},(a=d.getScene())&&d._texture?(d._rootCanvas=a.getEngine().getRenderingCanvas(),d._renderObserver=a.onBeforeCameraRenderObservable.add((function(e){return d._checkUpdate(e)})),d._preKeyboardObserver=a.onPreKeyboardObservable.add((function(e){d._focusedControl&&(e.type===l.a.KEYDOWN&&d._focusedControl.processKeyboard(e.event),e.skipOnPointerObservable=!0)})),d._rootContainer._link(d),d.hasAlpha=!0,n&&i||(d._resizeObserver=a.getEngine().onResizeObservable.add((function(){return d._onResize()})),d._onResize()),d._texture.isReady=!0,d):d}return i.d(t,e),Object.defineProperty(t.prototype,"renderScale",{get:function(){return this._renderScale},set:function(e){e!==this._renderScale&&(this._renderScale=e,this._onResize())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"background",{get:function(){return this._background},set:function(e){this._background!==e&&(this._background=e,this.markAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idealWidth",{get:function(){return this._idealWidth},set:function(e){this._idealWidth!==e&&(this._idealWidth=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"idealHeight",{get:function(){return this._idealHeight},set:function(e){this._idealHeight!==e&&(this._idealHeight=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"useSmallestIdeal",{get:function(){return this._useSmallestIdeal},set:function(e){this._useSmallestIdeal!==e&&(this._useSmallestIdeal=e,this.markAsDirty(),this._rootContainer._markAllAsDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"renderAtIdealSize",{get:function(){return this._renderAtIdealSize},set:function(e){this._renderAtIdealSize!==e&&(this._renderAtIdealSize=e,this._onResize())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"layer",{get:function(){return this._layerToDispose},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rootContainer",{get:function(){return this._rootContainer},enumerable:!0,configurable:!0}),t.prototype.getChildren=function(){return[this._rootContainer]},t.prototype.getDescendants=function(e,t){return this._rootContainer.getDescendants(e,t)},Object.defineProperty(t.prototype,"focusedControl",{get:function(){return this._focusedControl},set:function(e){this._focusedControl!=e&&(this._focusedControl&&this._focusedControl.onBlur(),e&&e.onFocus(),this._focusedControl=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isForeground",{get:function(){return!this.layer||!this.layer.isBackground},set:function(e){this.layer&&this.layer.isBackground!==!e&&(this.layer.isBackground=!e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"clipboardData",{get:function(){return this._clipboardData},set:function(e){this._clipboardData=e},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"AdvancedDynamicTexture"},t.prototype.executeOnAllControls=function(e,t){t||(t=this._rootContainer),e(t);for(var n=0,i=t.children;n1?s.notRenderable=!0:(s.notRenderable=!1,u.scaleInPlace(this.renderScale),s._moveToProjectedPosition(u))}else a.h.SetImmediate((function(){s.linkWithMesh(null)}))}}}(this._isDirty||this._rootContainer.isDirty)&&(this._isDirty=!1,this._render(),this.update(!0,this.premulAlpha))}},t.prototype._render=function(){var e=this.getSize(),t=e.width,n=e.height,i=this.getContext();i.font="18px Arial",i.strokeStyle="white",this.onBeginLayoutObservable.notifyObservers(this);var r=new _.a(0,0,t,n);this._rootContainer._layout(r,i),this.onEndLayoutObservable.notifyObservers(this),this._isDirty=!1,this._invalidatedRectangle?this._clearMeasure.copyFrom(this._invalidatedRectangle):this._clearMeasure.copyFromFloats(0,0,t,n),i.clearRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),this._background&&(i.save(),i.fillStyle=this._background,i.fillRect(this._clearMeasure.left,this._clearMeasure.top,this._clearMeasure.width,this._clearMeasure.height),i.restore()),this.onBeginRenderObservable.notifyObservers(this),this._rootContainer._render(i,this._invalidatedRectangle),this.onEndRenderObservable.notifyObservers(this),this._invalidatedRectangle=null},t.prototype._changeCursor=function(e){this._rootCanvas&&(this._rootCanvas.style.cursor=e,this._cursorChanged=!0)},t.prototype._registerLastControlDown=function(e,t){this._lastControlDown[t]=e,this.onControlPickedObservable.notifyObservers(e)},t.prototype._doPicking=function(e,t,n,i,r){var o=this.getScene();if(o){var a=o.getEngine(),c=this.getSize();if(this._isFullscreen){var l=(o.cameraToUseForPointers||o.activeCamera).viewport;e*=c.width/(a.getRenderWidth()*l.width),t*=c.height/(a.getRenderHeight()*l.height)}this._capturingControl[i]?this._capturingControl[i]._processObservables(n,e,t,i,r):(this._cursorChanged=!1,this._rootContainer._processPicking(e,t,n,i,r)||(this._changeCursor(""),n===s.a.POINTERMOVE&&this._lastControlOver[i]&&(this._lastControlOver[i]._onPointerOut(this._lastControlOver[i]),delete this._lastControlOver[i])),this._cursorChanged||this._changeCursor(""),this._manageFocus())}},t.prototype._cleanControlAfterRemovalFromList=function(e,t){for(var n in e){if(e.hasOwnProperty(n))e[n]===t&&delete e[n]}},t.prototype._cleanControlAfterRemoval=function(e){this._cleanControlAfterRemovalFromList(this._lastControlDown,e),this._cleanControlAfterRemovalFromList(this._lastControlOver,e)},t.prototype.attach=function(){var e=this,t=this.getScene();if(t){var n=new o.z(0,0,0,0);this._pointerMoveObserver=t.onPrePointerObservable.add((function(i,r){if(!t.isPointerCaptured(i.event.pointerId)&&(i.type===s.a.POINTERMOVE||i.type===s.a.POINTERUP||i.type===s.a.POINTERDOWN)&&t){var o=t.cameraToUseForPointers||t.activeCamera,a=t.getEngine();o?o.viewport.toGlobalToRef(a.getRenderWidth(),a.getRenderHeight(),n):(n.x=0,n.y=0,n.width=a.getRenderWidth(),n.height=a.getRenderHeight());var c=t.pointerX/a.getHardwareScalingLevel()-n.x,l=t.pointerY/a.getHardwareScalingLevel()-(a.getRenderHeight()-n.y-n.height);e._shouldBlockPointer=!1,e._doPicking(c,l,i.type,i.event.pointerId||0,i.event.button),e._shouldBlockPointer&&(i.skipOnPointerObservable=e._shouldBlockPointer)}})),this._attachToOnPointerOut(t)}},t.prototype.registerClipboardEvents=function(){self.addEventListener("copy",this.onClipboardCopy,!1),self.addEventListener("cut",this.onClipboardCut,!1),self.addEventListener("paste",this.onClipboardPaste,!1)},t.prototype.unRegisterClipboardEvents=function(){self.removeEventListener("copy",this.onClipboardCopy),self.removeEventListener("cut",this.onClipboardCut),self.removeEventListener("paste",this.onClipboardPaste)},t.prototype.attachToMesh=function(e,t){var n=this;void 0===t&&(t=!0);var i=this.getScene();i&&(this._pointerObserver=i.onPointerObservable.add((function(t,i){if(t.type===s.a.POINTERMOVE||t.type===s.a.POINTERUP||t.type===s.a.POINTERDOWN){var r=t.event.pointerId||0;if(t.pickInfo&&t.pickInfo.hit&&t.pickInfo.pickedMesh===e){var o=t.pickInfo.getTextureCoordinates();if(o){var a=n.getSize();n._doPicking(o.x*a.width,(1-o.y)*a.height,t.type,r,t.event.button)}}else if(t.type===s.a.POINTERUP){if(n._lastControlDown[r]&&n._lastControlDown[r]._forcePointerUp(r),delete n._lastControlDown[r],n.focusedControl){var c=n.focusedControl.keepsFocusWith(),l=!0;if(c)for(var u=0,h=c;u=0&&t.proceduralTextures.splice(n,1);var i=this._vertexBuffers[a.b.PositionKind];i&&(i.dispose(),this._vertexBuffers[a.b.PositionKind]=null),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),e.prototype.dispose.call(this)}},i.c([Object(r.c)()],t.prototype,"isEnabled",void 0),i.c([Object(r.c)()],t.prototype,"autoClear",void 0),i.c([Object(r.c)()],t.prototype,"_generateMipMaps",void 0),i.c([Object(r.c)()],t.prototype,"_size",void 0),i.c([Object(r.c)()],t.prototype,"refreshRate",null),t}(l.a)},function(e,t,n){"use strict";n.d(t,"a",(function(){return f}));var i=n(79),r=n(7),o=n(0),a=n(81),s=n(25),c=n(116),l=n(27),u=n(4),h=n(9),d=n(46),f=function(){function e(e,t,n){this.name=e,this.id=t,this.bones=new Array,this.needInitialSkinMatrix=!1,this.overrideMesh=null,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=o.j.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this._canUseTextureForBones=!1,this._uniqueId=0,this._numBonesWithLinkedTransformNode=0,this._hasWaitingData=null,this.doNotSerialize=!1,this._useTextureToStoreBoneMatrices=!0,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new r.c,this.bones=[],this._scene=n||l.a.LastCreatedScene,this._uniqueId=this._scene.getUniqueId(),this._scene.addSkeleton(this),this._isDirty=!0;var i=this._scene.getEngine().getCaps();this._canUseTextureForBones=i.textureFloat&&i.maxVertexTextureImageUnits>0}return Object.defineProperty(e.prototype,"useTextureToStoreBoneMatrices",{get:function(){return this._useTextureToStoreBoneMatrices},set:function(e){this._useTextureToStoreBoneMatrices=e,this._markAsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isUsingTextureForMatrices",{get:function(){return this.useTextureToStoreBoneMatrices&&this._canUseTextureForBones&&!this.needInitialSkinMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"Skeleton"},e.prototype.getChildren=function(){return this.bones.filter((function(e){return!e.getParent()}))},e.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},e.prototype.getTransformMatrixTexture=function(){return this._transformMatrixTexture},e.prototype.getScene=function(){return this._scene},e.prototype.toString=function(e){var t="Name: "+this.name+", nBones: "+this.bones.length;if(t+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var 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;e0&&(r.animation=n.animations[0].serialize()),e.ranges=[],this._ranges){var a=this._ranges[o];if(a){var s={};s.name=o,s.from=a.from,s.to=a.to,e.ranges.push(s)}}}return e},e.Parse=function(t,n){var r,a=new e(t.name,t.id,n);for(t.dimensionsAtRest&&(a.dimensionsAtRest=o.x.FromArray(t.dimensionsAtRest)),a.needInitialSkinMatrix=t.needInitialSkinMatrix,r=0;r-1&&(l=a.bones[c.parentBoneIndex]);var u=c.rest?o.j.FromArray(c.rest):null,h=new i.a(c.name,a,l,o.j.FromArray(c.matrix),u);void 0!==c.id&&null!==c.id&&(h.id=c.id),c.length&&(h.length=c.length),c.metadata&&(h.metadata=c.metadata),c.animation&&h.animations.push(s.a.Parse(c.animation)),void 0!==c.linkedTransformNodeId&&null!==c.linkedTransformNodeId&&(a._hasWaitingData=!0,h._waitingTransformNodeId=c.linkedTransformNodeId)}if(t.ranges)for(r=0;r0&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},e.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),n=0;nf.AGGRO_DROP_RADIUS&&this.startRoaming(),this.mode===i.Fleeing&&this.timer>=f.FLEE_TIME&&this.startSeeking(),this.mode===i.StandingStill)return this.timer>=f.STAND_TIME&&this.startRoaming(),void this.checkBounce(this.position);if(this.angryTimeLeft>0){const t=Math.max(this.angryTimeLeft-e,0);if(0===t){const e=Math.max(this.size*this.size/64,1);Math.round(e*(Math.random()+Math.random())/2+(1-e)*this.size);for(let e=0;e1?this.angryTimeLeft=f.ANGRY_TIME_SCALE*this.size:this.angryTimeLeft>0&&!this.position.equals(c)&&(this.angryTimeLeft=0))}mergeOverlaps(){const e=Object(a.d)(this,d.c?this.terrain.map.mobsNear(this.position,1):u.a.mobs,a.b.EnemyMoveObstacle,!0);if(!e)return;e.length;for(const t of e)t instanceof f&&t.size<=this.size&&(t.mesh.dispose(),this.size+=t.size);this.angryTimeLeft=0;const t=Math.cbrt(this.size);this.mesh.scaling=r.Vector3.One().scale(t)}bounce(e){if(this.timer>125)return void this.startSeeking();const t=this.bounceVelocity*e/1e3,n=this.velocity.normalize().scale(t);this.position=this.terrain.Travel(this.position,n,!0)}startBounce(){const e=this.position.subtract(this.attackTarget.position);e.y=0,this.velocity=e.normalize().scale(this.bounceVelocity),this.mode=i.Bouncing,this.timer=0,this.stunned=!1,h.a.BUMPS.playNext()}startSeeking(){this.mergeOverlaps(),this.velocity=r.Vector3.One().scale(this.seekVelocity),this.mode=i.Seeking}startRoaming(){const e=2*Math.random()*Math.PI,t=Math.random()*(f.MAX_ROAM_DISTANCE-f.MIN_ROAM_DISTANCE)+f.MIN_ROAM_DISTANCE,n=new r.Vector3(Math.cos(e),0,Math.sin(e)).scaleInPlace(t);this.target=this.terrain.MakeValidLocation(this.position.add(n)),this.velocity=r.Vector3.One().scale(this.roamVelocity),this.mode=i.Roaming}startStandingStill(){this.timer=0,this.mode=i.StandingStill}randomStep(e,t){const n=new r.Vector3(Math.random()-.5,0,Math.random()-.5).normalize().scale(2*e),i=this.target.subtract(this.position),o=this.target.subtract(this.position.add(n)).length()-i.length();return t*o>0&&Math.exp(o*o/(e*e))this.burnTime)return void(this.burning=!1);const e={position:this.position,radius:3*this.radius,identity:this,layer:a.b.None.value},t=Object(a.d)(e,u.a.mobs,a.b.HeroDamagable);if(t)for(const e of t)if(e instanceof f&&!e.burning){const t=this.burnTime-this.timer;t>500&&e.setOnFire(.75*t)}}teleport(e){super.teleport(e),this.mergeOverlaps()}}f.MESH=new o.d("enemy",l.a),f.ANGRY_TIME_SCALE=2e3,f.FLEE_TIME=2e3,f.STAND_TIME=1500,f.MAX_ROAM_DISTANCE=3,f.MIN_ROAM_DISTANCE=1,f.AGGRO_RADIUS=3,f.AGGRO_DROP_RADIUS=5},function(e,t,n){"use strict";var i="bonesDeclaration",r="#if NUM_BONE_INFLUENCERS>0\n#ifdef BONETEXTURE\nuniform sampler2D boneSampler;\nuniform float boneTextureWidth;\n#else\nuniform mat4 mBones[BonesPerMesh];\n#endif\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#ifdef BONETEXTURE\nmat4 readMatrixFromRawSampler(sampler2D smp,float index)\n{\nfloat offset=index*4.0;\nfloat dx=1.0/boneTextureWidth;\nvec4 m0=texture2D(smp,vec2(dx*(offset+0.5),0.));\nvec4 m1=texture2D(smp,vec2(dx*(offset+1.5),0.));\nvec4 m2=texture2D(smp,vec2(dx*(offset+2.5),0.));\nvec4 m3=texture2D(smp,vec2(dx*(offset+3.5),0.));\nreturn mat4(m0,m1,m2,m3);\n}\n#endif\n#endif";n(8).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#else\nuniform mat4 world;\n#endif";n(8).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="instancesVertex",r="#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";n(8).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";var i="#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\n#ifdef BONETEXTURE\ninfluence=readMatrixFromRawSampler(boneSampler,matricesIndices[0])*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[1])*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[2])*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndices[3])*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[0])*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[1])*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[2])*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=readMatrixFromRawSampler(boneSampler,matricesIndicesExtra[3])*matricesWeightsExtra[3];\n#endif\n#else\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif\n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif\n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif\n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif\n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif\n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif\n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif\n#endif\nfinalWorld=finalWorld*influence;\n#endif";n(8).a.IncludesShadersStore.bonesVertex=i},function(e,t,n){"use strict";var i;n.d(t,"a",(function(){return i})),function(e){e[e.STEP=1]="STEP"}(i||(i={}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var i=n(0),r=n(13),o=n(78),a=n(4),s=function(e,t,n,i){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=n,this.worldAxisForFileY=i},c=function(){function e(){}return e.ConvertCubeMapTextureToSphericalPolynomial=function(e){if(!e.isCube)return null;var t,n,i=e.getSize().width,r=e.readPixels(0),o=e.readPixels(1);e.isRenderTarget?(t=e.readPixels(3),n=e.readPixels(2)):(t=e.readPixels(2),n=e.readPixels(3));var s=e.readPixels(4),c=e.readPixels(5),l=e.gammaSpace,u=a.a.TEXTUREFORMAT_RGBA,h=a.a.TEXTURETYPE_UNSIGNED_INT;e.textureType&&e.textureType!==a.a.TEXTURETYPE_UNSIGNED_INT&&(h=a.a.TEXTURETYPE_FLOAT);var d={size:i,right:r,left:o,up:t,down:n,front:s,back:c,format:u,type:h,gammaSpace:l};return this.ConvertCubeMapToSphericalPolynomial(d)},e.ConvertCubeMapToSphericalPolynomial=function(e){for(var t=new o.a,n=0,s=2/e.size,c=s,l=.5*s-1,u=0;u<6;u++)for(var h=this.FileFaces[u],d=e[h.name],f=l,p=e.format===a.a.TEXTUREFORMAT_RGBA?4:3,m=0;m0&&(p=!0,this._soundLoaded(n));break;case"String":f.push(n);case"Array":0===f.length&&(f=n);for(var m=0;m0&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect(),this.isPlaying=!1;else if(a.b.audioEngine.audioContext&&this._soundSource){var n=e?a.b.audioEngine.audioContext.currentTime+e:a.b.audioEngine.audioContext.currentTime;this._soundSource.stop(n),this._soundSource.onended=function(){t.isPlaying=!1},this.isPaused||(this._startOffset=0)}},e.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():a.b.audioEngine.audioContext&&(this.stop(0),this._startOffset+=a.b.audioEngine.audioContext.currentTime-this._startTime))},e.prototype.setVolume=function(e,t){a.b.audioEngine.canUseWebAudio&&this._soundGain&&(t&&a.b.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(a.b.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,a.b.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,a.b.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},e.prototype.setPlaybackRate=function(e){this._playbackRate=e,this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate))},e.prototype.getVolume=function(){return this._volume},e.prototype.attachToMesh=function(e){var t=this;this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedTransformNode=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc)},e.prototype.detachFromMesh=function(){this._connectedTransformNode&&this._registerFunc&&(this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedTransformNode=null)},e.prototype._onRegisterAfterWorldMatrixUpdate=function(e){if(e.getBoundingInfo){var t=e;if(this._positionInEmitterSpace)t.worldMatrixFromCache.invertToRef(o.t.Matrix[0]),this.setPosition(o.t.Matrix[0].getTranslation());else{var n=t.getBoundingInfo();this.setPosition(n.boundingSphere.centerWorld)}a.b.audioEngine.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()):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.serialize=function(){var e={name:this.name,url:this.name,autoplay:this.autoplay,loop:this.loop,volume:this._volume,spatialSound:this.spatialSound,maxDistance:this.maxDistance,rolloffFactor:this.rolloffFactor,refDistance:this.refDistance,distanceModel:this.distanceModel,playbackRate:this._playbackRate,panningModel:this._panningModel,soundTrackId:this.soundTrackId};return this.spatialSound&&(this._connectedTransformNode&&(e.connectedMeshId=this._connectedTransformNode.id),e.position=this._position.asArray(),e.refDistance=this.refDistance,e.distanceModel=this.distanceModel,e.isDirectional=this._isDirectional,e.localDirectionToMesh=this._localDirection.asArray(),e.coneInnerAngle=this._coneInnerAngle,e.coneOuterAngle=this._coneOuterAngle,e.coneOuterGain=this._coneOuterGain),e},e.Parse=function(t,n,i,r){var a,s=t.name;a=t.url?i+t.url:i+s;var c,l={autoplay:t.autoplay,loop:t.loop,volume:t.volume,spatialSound:t.spatialSound,maxDistance:t.maxDistance,rolloffFactor:t.rolloffFactor,refDistance:t.refDistance,distanceModel:t.distanceModel,playbackRate:t.playbackRate};if(r){var u=function(){r._isReadyToPlay?(c._audioBuffer=r.getAudioBuffer(),c._isReadyToPlay=!0,c.autoplay&&c.play()):window.setTimeout(u,300)};c=new e(s,new ArrayBuffer(0),n,null,l),u()}else c=new e(s,a,n,(function(){n._removePendingData(c)}),l),n._addPendingData(c);if(t.position){var h=o.x.FromArray(t.position);c.setPosition(h)}if(t.isDirectional&&(c.setDirectionalCone(t.coneInnerAngle||360,t.coneOuterAngle||360,t.coneOuterGain||0),t.localDirectionToMesh)){var d=o.x.FromArray(t.localDirectionToMesh);c.setLocalDirectionToMesh(d)}if(t.connectedMeshId){var f=n.getMeshByID(t.connectedMeshId);f&&c.attachToMesh(f)}return c},e._SceneComponentInitialization=function(e){throw c.a.WarnImport("AudioSceneComponent")},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(1),r=function(e){function t(t){var n=e.call(this)||this;return n._buffer=t,n}return i.d(t,e),Object.defineProperty(t.prototype,"underlyingResource",{get:function(){return this._buffer},enumerable:!0,configurable:!0}),t}(n(118).a)},function(e,t,n){"use strict";n.d(t,"b",(function(){return o})),n.d(t,"a",(function(){return a}));var i=n(1),r=n(0),o=function(e){function t(t,n){void 0===n&&(n=0);var i=e.call(this,t.x,t.y)||this;return i.buttonIndex=n,i}return i.d(t,e),t}(r.w),a=function(){function e(e,t,n,i,r,o){this.m=new Float32Array(6),this.fromValues(e,t,n,i,r,o)}return e.prototype.fromValues=function(e,t,n,i,r,o){return this.m[0]=e,this.m[1]=t,this.m[2]=n,this.m[3]=i,this.m[4]=r,this.m[5]=o,this},e.prototype.determinant=function(){return this.m[0]*this.m[3]-this.m[1]*this.m[2]},e.prototype.invertToRef=function(e){var t=this.m[0],n=this.m[1],i=this.m[2],o=this.m[3],a=this.m[4],s=this.m[5],c=this.determinant();if(ci[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.framei&&this._speedRatio>0&&(this._speedRatio=-t);return this._isStarted=!0,this._isPaused=!1,this.onAnimationGroupPlayObservable.notifyObservers(this),this},e.prototype.pause=function(){if(!this._isStarted)return this;this._isPaused=!0;for(var e=0;e-1&&this._scene.animationGroups.splice(e,1),this.onAnimationEndObservable.clear(),this.onAnimationGroupEndObservable.clear(),this.onAnimationGroupPauseObservable.clear(),this.onAnimationGroupPlayObservable.clear(),this.onAnimationLoopObservable.clear()},e.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);t>-1&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},e.prototype.clone=function(t,n){for(var i=new e(t||this.name,this._scene),r=0,o=this._targetedAnimations;ru-i)&&(!(c-hh-o)&&!(l-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,l=i.z,u=e.x,h=e.y,d=e.z,f=t.x,p=t.y,m=t.z;return!(sf)&&(!(cp)&&!(lm))},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.x.ClampToRef(i,t,n,a),r.x.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.x.Zero),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){this.references=0,this.capacity=0,this.is32Bits=!1}return Object.defineProperty(e.prototype,"underlyingResource",{get:function(){return null},enumerable:!0,configurable:!0}),e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(){var e=this;this.promise=new Promise((function(t,n){e._resolve=t,e._reject=n}))}return Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!0,configurable:!0}),e}()},function(e,t,n){"use strict";var i=n(5),r=n(0),o=n(13),a=n(78),s=n(32),c=n(56),l=n(4),u=n(19),h=n(23),d=n(9),f=(n(180),n(8)),p=(n(75),"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}");f.a.ShadersStore.rgbdEncodePixelShader=p;n(200);n.d(t,"a",(function(){return m}));var m=function(){function e(){}return e.GetEnvInfo=function(t){for(var n=new DataView(t),i=0,r=0;r=i.a.ACTION_OnPickTrigger&&n<=i.a.ACTION_OnPickUpTrigger)return!0}return!1},enumerable:!0,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 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";n.d(t,"a",(function(){return o}));var i=n(49),r=n(0),o=function(){function e(e,t,n){this.center=r.x.Zero(),this.centerWorld=r.x.Zero(),this.minimum=r.x.Zero(),this.maximum=r.x.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.x.Distance(e,t);t.addToRef(e,this.center).scaleInPlace(.5),this.radius=.5*i,this._update(n||r.j.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.x.TransformCoordinatesToRef(this.center,t,this.centerWorld);var n=e.TmpVector3[0];r.x.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.x.DistanceSquared(this.centerWorld,e);return!(this.radiusWorld*this.radiusWorld=0&&(this._targets.splice(t,1),e.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(t,1)[0]),e._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(t,1)[0]),this._syncActiveTargets(!0))},e.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,n=this._targets;tt.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}(),d=function(){function e(){}return e.Rectangle=function(e,t,n,i){return[new o.w(e,t),new o.w(n,t),new o.w(n,i),new o.w(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,a=0,s=2*Math.PI/i,c=0;c0){var h=r.length/3;this._points.elements.forEach((function(t){i.push(0,-1,0),r.push(t.x,-e,t.y),o.push(1-(t.x-a.min.x)/a.width,1-(t.y-a.min.y)/a.height)}));var d=s.length;for(u=0;ua.elements.length-1?a.elements[0]:a.elements[h+1],e.push(f.x,0,f.y),e.push(f.x,-s,f.y),e.push(d.x,0,d.y),e.push(d.x,-s,d.y);var p=new o.x(f.x,0,f.y),m=new o.x(d.x,0,d.y).subtract(p),g=new o.x(0,1,0),_=o.x.Cross(m,g);_=_.normalize(),n.push(u/r.width,0),n.push(u/r.width,1),u+=m.length(),n.push(u/r.width,0),n.push(u/r.width,1),c?(t.push(_.x,_.y,_.z),t.push(_.x,_.y,_.z),t.push(_.x,_.y,_.z),t.push(_.x,_.y,_.z),i.push(l),i.push(l+2),i.push(l+1),i.push(l+1),i.push(l+2),i.push(l+3)):(t.push(-_.x,-_.y,-_.z),t.push(-_.x,-_.y,-_.z),t.push(-_.x,-_.y,-_.z),t.push(-_.x,-_.y,-_.z),i.push(l),i.push(l+1),i.push(l+2),i.push(l+1),i.push(l+3),i.push(l+2)),l+=4}},e}()},function(e,t,n){"use strict";e.exports=n(244)},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){}},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var i=n(1),r=n(2),o=n(0),a=function(){function e(){this._dirty=!0,this._tempColor=new o.f(0,0,0,0),this._globalCurve=new o.f(0,0,0,0),this._highlightsCurve=new o.f(0,0,0,0),this._midtonesCurve=new o.f(0,0,0,0),this._shadowsCurve=new o.f(0,0,0,0),this._positiveCurve=new o.f(0,0,0,0),this._negativeCurve=new o.f(0,0,0,0),this._globalHue=30,this._globalDensity=0,this._globalSaturation=0,this._globalExposure=0,this._highlightsHue=30,this._highlightsDensity=0,this._highlightsSaturation=0,this._highlightsExposure=0,this._midtonesHue=30,this._midtonesDensity=0,this._midtonesSaturation=0,this._midtonesExposure=0,this._shadowsHue=30,this._shadowsDensity=0,this._shadowsSaturation=0,this._shadowsExposure=0}return Object.defineProperty(e.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"globalExposure",{get:function(){return this._globalExposure},set:function(e){this._globalExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"ColorCurves"},e.Bind=function(e,t,n,i,r){void 0===n&&(n="vCameraColorCurvePositive"),void 0===i&&(i="vCameraColorCurveNeutral"),void 0===r&&(r="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(n,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(i,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(r,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},e.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},e.prototype.getColorGradingDataToRef=function(t,n,i,r,o){null!=t&&(t=e.clamp(t,0,360),n=e.clamp(n,-100,100),i=e.clamp(i,-100,100),r=e.clamp(r,-100,100),n=e.applyColorGradingSliderNonlinear(n),n*=.5,r=e.applyColorGradingSliderNonlinear(r),n<0&&(n*=-1,t=(t+180)%360),e.fromHSBToRef(t,n,50+.25*r,o),o.scaleToRef(2,o),o.a=1+.01*i)},e.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},e.fromHSBToRef=function(t,n,i,r){var o=e.clamp(t,0,360),a=e.clamp(n/100,0,1),s=e.clamp(i/100,0,1);if(0===a)r.r=s,r.g=s,r.b=s;else{o/=60;var c=Math.floor(o),l=o-c,u=s*(1-a),h=s*(1-a*l),d=s*(1-a*(1-l));switch(c){case 0:r.r=s,r.g=d,r.b=u;break;case 1:r.r=h,r.g=s,r.b=u;break;case 2:r.r=u,r.g=s,r.b=d;break;case 3:r.r=u,r.g=h,r.b=s;break;case 4:r.r=d,r.g=u,r.b=s;break;default:r.r=s,r.g=u,r.b=h}}r.a=1},e.clamp=function(e,t,n){return Math.min(Math.max(e,t),n)},e.prototype.clone=function(){return r.a.Clone((function(){return new e}),this)},e.prototype.serialize=function(){return r.a.Serialize(this)},e.Parse=function(t){return r.a.Parse((function(){return new e}),t,null,null)},i.c([Object(r.c)()],e.prototype,"_globalHue",void 0),i.c([Object(r.c)()],e.prototype,"_globalDensity",void 0),i.c([Object(r.c)()],e.prototype,"_globalSaturation",void 0),i.c([Object(r.c)()],e.prototype,"_globalExposure",void 0),i.c([Object(r.c)()],e.prototype,"_highlightsHue",void 0),i.c([Object(r.c)()],e.prototype,"_highlightsDensity",void 0),i.c([Object(r.c)()],e.prototype,"_highlightsSaturation",void 0),i.c([Object(r.c)()],e.prototype,"_highlightsExposure",void 0),i.c([Object(r.c)()],e.prototype,"_midtonesHue",void 0),i.c([Object(r.c)()],e.prototype,"_midtonesDensity",void 0),i.c([Object(r.c)()],e.prototype,"_midtonesSaturation",void 0),i.c([Object(r.c)()],e.prototype,"_midtonesExposure",void 0),e}();r.a._ColorCurvesParser=a.Parse},function(e,t,n){"use strict";var i=function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,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}(),r=function(){function e(){this._isDepthTestDirty=!1,this._isDepthMaskDirty=!1,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDepthFuncDirty||this._isDepthTestDirty||this._isDepthMaskDirty||this._isCullFaceDirty||this._isCullDirty||this._isZOffsetDirty||this._isFrontFaceDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zOffset",{get:function(){return this._zOffset},set:function(e){this._zOffset!==e&&(this._zOffset=e,this._isZOffsetDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cullFace",{get:function(){return this._cullFace},set:function(e){this._cullFace!==e&&(this._cullFace=e,this._isCullFaceDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"cull",{get:function(){return this._cull},set:function(e){this._cull!==e&&(this._cull=e,this._isCullDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthFunc",{get:function(){return this._depthFunc},set:function(e){this._depthFunc!==e&&(this._depthFunc=e,this._isDepthFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthMask",{get:function(){return this._depthMask},set:function(e){this._depthMask!==e&&(this._depthMask=e,this._isDepthMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthTest",{get:function(){return this._depthTest},set:function(e){this._depthTest!==e&&(this._depthTest=e,this._isDepthTestDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"frontFace",{get:function(){return this._frontFace},set:function(e){this._frontFace!==e&&(this._frontFace=e,this._isFrontFaceDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._depthMask=!0,this._depthTest=!0,this._depthFunc=null,this._cullFace=null,this._cull=null,this._zOffset=0,this._frontFace=null,this._isDepthTestDirty=!0,this._isDepthMaskDirty=!0,this._isDepthFuncDirty=!1,this._isCullFaceDirty=!1,this._isCullDirty=!1,this._isZOffsetDirty=!1,this._isFrontFaceDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isCullDirty&&(this.cull?e.enable(e.CULL_FACE):e.disable(e.CULL_FACE),this._isCullDirty=!1),this._isCullFaceDirty&&(e.cullFace(this.cullFace),this._isCullFaceDirty=!1),this._isDepthMaskDirty&&(e.depthMask(this.depthMask),this._isDepthMaskDirty=!1),this._isDepthTestDirty&&(this.depthTest?e.enable(e.DEPTH_TEST):e.disable(e.DEPTH_TEST),this._isDepthTestDirty=!1),this._isDepthFuncDirty&&(e.depthFunc(this.depthFunc),this._isDepthFuncDirty=!1),this._isZOffsetDirty&&(this.zOffset?(e.enable(e.POLYGON_OFFSET_FILL),e.polygonOffset(this.zOffset,0)):e.disable(e.POLYGON_OFFSET_FILL),this._isZOffsetDirty=!1),this._isFrontFaceDirty&&(e.frontFace(this.frontFace),this._isFrontFaceDirty=!1))},e}(),o=n(4),a=function(){function e(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilFunc",{get:function(){return this._stencilFunc},set:function(e){this._stencilFunc!==e&&(this._stencilFunc=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncRef",{get:function(){return this._stencilFuncRef},set:function(e){this._stencilFuncRef!==e&&(this._stencilFuncRef=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilFuncMask",{get:function(){return this._stencilFuncMask},set:function(e){this._stencilFuncMask!==e&&(this._stencilFuncMask=e,this._isStencilFuncDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilFail",{get:function(){return this._stencilOpStencilFail},set:function(e){this._stencilOpStencilFail!==e&&(this._stencilOpStencilFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpDepthFail",{get:function(){return this._stencilOpDepthFail},set:function(e){this._stencilOpDepthFail!==e&&(this._stencilOpDepthFail=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilOpStencilDepthPass",{get:function(){return this._stencilOpStencilDepthPass},set:function(e){this._stencilOpStencilDepthPass!==e&&(this._stencilOpStencilDepthPass=e,this._isStencilOpDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilMask",{get:function(){return this._stencilMask},set:function(e){this._stencilMask!==e&&(this._stencilMask=e,this._isStencilMaskDirty=!0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.KEEP,this._stencilOpDepthFail=e.KEEP,this._stencilOpStencilDepthPass=e.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},e.prototype.apply=function(e){this.isDirty&&(this._isStencilTestDirty&&(this.stencilTest?e.enable(e.STENCIL_TEST):e.disable(e.STENCIL_TEST),this._isStencilTestDirty=!1),this._isStencilMaskDirty&&(e.stencilMask(this.stencilMask),this._isStencilMaskDirty=!1),this._isStencilFuncDirty&&(e.stencilFunc(this.stencilFunc,this.stencilFuncRef,this.stencilFuncMask),this._isStencilFuncDirty=!1),this._isStencilOpDirty&&(e.stencilOp(this.stencilOpStencilFail,this.stencilOpDepthFail,this.stencilOpStencilDepthPass),this._isStencilOpDirty=!1))},e.ALWAYS=o.a.ALWAYS,e.KEEP=o.a.KEEP,e.REPLACE=o.a.REPLACE,e}();n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return r})),n.d(t,"c",(function(){return a}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return u}));var i=n(25),r=n(158),o=n(7),a=n(19),s=n(0),c=n(63),l=n(79),u=function(){function e(e,t,n,i,r,a,s,c,l){void 0===n&&(n=0),void 0===i&&(i=100),void 0===r&&(r=!1),void 0===a&&(a=1),this.target=t,this.fromFrame=n,this.toFrame=i,this.loopAnimation=r,this.onAnimationEnd=s,this.onAnimationLoop=l,this._localDelayOffset=null,this._pausedDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this._syncRoot=null,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new o.c,this.onAnimationLoopObservable=new o.c,this._scene=e,c&&this.appendAnimations(t,c),this._speedRatio=a,e._activeAnimatables.push(this)}return Object.defineProperty(e.prototype,"syncRoot",{get:function(){return this._syncRoot},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"masterFrame",{get:function(){return 0===this._runtimeAnimations.length?0:this._runtimeAnimations[0].currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},set:function(e){this._weight=-1!==e?Math.min(Math.max(e,0),1):-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){for(var t=0;t-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=t}var n=this.useConstantAnimationDeltaTime?16:(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=n;var i=this._animationTime;this._animationTimeLast=t;for(var r=0;rn&&r>0&&(r*=-1),s&&this.stopAnimation(e,void 0,c),a||(a=new u(this,e,t,n,i,r,o,void 0,l));var h=!c||c(e);if(e.animations&&h&&a.appendAnimations(e,e.animations),e.getAnimatables)for(var d=e.getAnimatables(),f=0;f=u&&s.frame<=h&&(r?(l=s.value.clone(),g?(c=l.getTranslation(),l.setTranslation(c.scaleInPlace(_))):v&&o?(c=l.getTranslation(),l.setTranslation(c.multiplyInPlace(o))):l=s.value):l=s.value,b.push({frame:s.frame+n,value:l}));return this.animations[0].createRange(t,u+n,h+n),!0}},function(e,t,n){"use strict";var i=n(10),r=n(32),o=n(9),a=n(5);i.b.prototype.updateRawTexture=function(e,t,n,r,o,a){if(void 0===o&&(o=null),void 0===a&&(a=i.b.TEXTURETYPE_UNSIGNED_INT),e){var s=this._getRGBABufferInternalSizedFormat(a,n),c=this._getInternalFormat(n),l=this._getWebGLTextureType(a);this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===r||!!r),this._doNotHandleContextLost||(e._bufferView=t,e.format=n,e.type=a,e.invertY=r,e._compression=o),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[o],e.width,e.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,s,e.width,e.height,0,c,l,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}},i.b.prototype.createRawTexture=function(e,t,n,o,a,s,c,l,u){void 0===l&&(l=null),void 0===u&&(u=i.b.TEXTURETYPE_UNSIGNED_INT);var h=new r.a(this,r.a.DATASOURCE_RAW);h.baseWidth=t,h.baseHeight=n,h.width=t,h.height=n,h.format=o,h.generateMipMaps=a,h.samplingMode=c,h.invertY=s,h._compression=l,h.type=u,this._doNotHandleContextLost||(h._bufferView=e),this.updateRawTexture(h,e,o,s,l,u),this._bindTextureDirectly(this._gl.TEXTURE_2D,h,!0);var d=this._getSamplingParameters(c,a);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,d.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,d.min),a&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(h),h},i.b.prototype.createRawCubeTexture=function(e,t,n,s,c,l,u,h){void 0===h&&(h=null);var d=this._gl,f=new r.a(this,r.a.DATASOURCE_CUBERAW);f.isCube=!0,f.format=n,f.type=s,this._doNotHandleContextLost||(f._bufferViewArray=e);var p=this._getWebGLTextureType(s),m=this._getInternalFormat(n);m===d.RGB&&(m=d.RGBA),p!==d.FLOAT||this._caps.textureFloatLinearFiltering?p!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?p!==d.FLOAT||this._caps.textureFloatRender?p!==d.HALF_FLOAT||this._caps.colorBufferFloat||(c=!1,o.a.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(c=!1,o.a.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(c=!1,u=i.b.TEXTURE_NEAREST_SAMPLINGMODE,o.a.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(c=!1,u=i.b.TEXTURE_NEAREST_SAMPLINGMODE,o.a.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var g=t,_=g;f.width=g,f.height=_,!this.needPOTTextures||a.h.IsExponentOfTwo(f.width)&&a.h.IsExponentOfTwo(f.height)||(c=!1),e&&this.updateRawCubeTexture(f,e,n,s,l,h),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,f,!0),e&&c&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var v=this._getSamplingParameters(u,c);return d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MAG_FILTER,v.mag),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_MIN_FILTER,v.min),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_CUBE_MAP,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),this._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null),f.generateMipMaps=c,f},i.b.prototype.updateRawCubeTexture=function(e,t,n,i,r,o,s){void 0===o&&(o=null),void 0===s&&(s=0),e._bufferViewArray=t,e.format=n,e.type=i,e.invertY=r,e._compression=o;var c=this._gl,l=this._getWebGLTextureType(i),u=this._getInternalFormat(n),h=this._getRGBABufferInternalSizedFormat(i),d=!1;u===c.RGB&&(u=c.RGBA,d=!0),this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(void 0===r||!!r),e.width%4!=0&&c.pixelStorei(c.UNPACK_ALIGNMENT,1);for(var f=0;f<6;f++){var p=t[f];o?c.compressedTexImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,s,this.getCaps().s3tc[o],e.width,e.height,0,p):(d&&(p=this._convertRGBtoRGBATextureData(p,e.width,e.height,i)),c.texImage2D(c.TEXTURE_CUBE_MAP_POSITIVE_X+f,s,h,e.width,e.height,0,u,l,p))}(!this.needPOTTextures||a.h.IsExponentOfTwo(e.width)&&a.h.IsExponentOfTwo(e.height))&&e.generateMipMaps&&0===s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),e.isReady=!0},i.b.prototype.createRawCubeTextureFromUrl=function(e,t,n,r,o,a,s,c,l,u,h,d){var f=this;void 0===l&&(l=null),void 0===u&&(u=null),void 0===h&&(h=i.b.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===d&&(d=!1);var p=this._gl,m=this.createRawCubeTexture(null,n,r,o,!a,d,h);t._addPendingData(m),m.url=e,this._internalTexturesCache.push(m);return this._loadFile(e,(function(e){!function(e){var n=m.width,i=s(e);if(i){if(c){var a=f._getWebGLTextureType(o),u=f._getInternalFormat(r),h=f._getRGBABufferInternalSizedFormat(o),g=!1;u===p.RGB&&(u=p.RGBA,g=!0),f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,m,!0),f._unpackFlipY(!1);for(var _=c(i),v=0;v<_.length;v++)for(var b=n>>v,y=0;y<6;y++){var x=_[v][y];g&&(x=f._convertRGBtoRGBATextureData(x,b,b,o)),p.texImage2D(y,v,h,b,b,0,u,a,x)}f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,null)}else f.updateRawCubeTexture(m,i,r,o,d);m.isReady=!0,t._removePendingData(m),l&&l()}}(e)}),void 0,t.offlineProvider,!0,(function(e,n){t._removePendingData(m),u&&e&&u(e.status+" "+e.statusText,n)})),m},i.b.prototype.createRawTexture3D=function(e,t,n,o,a,s,c,l,u,h){void 0===u&&(u=null),void 0===h&&(h=i.b.TEXTURETYPE_UNSIGNED_INT);var d=new r.a(this,r.a.DATASOURCE_RAW3D);d.baseWidth=t,d.baseHeight=n,d.baseDepth=o,d.width=t,d.height=n,d.depth=o,d.format=a,d.type=h,d.generateMipMaps=s,d.samplingMode=l,d.is3D=!0,this._doNotHandleContextLost||(d._bufferView=e),this.updateRawTexture3D(d,e,a,c,u,h),this._bindTextureDirectly(this._gl.TEXTURE_3D,d,!0);var f=this._getSamplingParameters(l,s);return this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,f.mag),this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,f.min),s&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._internalTexturesCache.push(d),d},i.b.prototype.updateRawTexture3D=function(e,t,n,r,o,a){void 0===o&&(o=null),void 0===a&&(a=i.b.TEXTURETYPE_UNSIGNED_INT);var s=this._getWebGLTextureType(a),c=this._getInternalFormat(n),l=this._getRGBABufferInternalSizedFormat(a,n);this._bindTextureDirectly(this._gl.TEXTURE_3D,e,!0),this._unpackFlipY(void 0===r||!!r),this._doNotHandleContextLost||(e._bufferView=t,e.format=n,e.invertY=r,e._compression=o),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&t?this._gl.compressedTexImage3D(this._gl.TEXTURE_3D,0,this.getCaps().s3tc[o],e.width,e.height,e.depth,0,t):this._gl.texImage3D(this._gl.TEXTURE_3D,0,l,e.width,e.height,e.depth,0,c,s,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),e.isReady=!0}},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(8).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(8).a.IncludesShadersStore[i]=r},function(e,t,n){"use strict";n.d(t,"a",(function(){return h}));var i=n(5),r=n(175),o=n(14);function a(e){return"function"==typeof importScripts?(importScripts(e),Promise.resolve()):new Promise((function(t,n){i.h.LoadScript(e,(function(){t()}),(function(e){n(new Error(e))}))}))}function s(e,t,n){var i=t&&e||n;if(i)return a(i).then((function(){return new Promise((function(e){DracoDecoderModule({wasmBinary:t}).then((function(t){e({module:t})}))}))}))}function c(e,t,n,i,r){var o=new e.DecoderBuffer;o.Init(t,t.byteLength);var a,s,c=new e.Decoder;try{var l=c.GetEncodedGeometryType(o);switch(l){case e.TRIANGULAR_MESH:a=new e.Mesh,s=c.DecodeBufferToMesh(o,a);break;case e.POINT_CLOUD:a=new e.PointCloud,s=c.DecodeBufferToPointCloud(o,a);break;default:throw new Error("Invalid geometry type "+l)}if(!s.ok()||!a.ptr)throw new Error(s.error_msg());var u=a.num_points();if(l===e.TRIANGULAR_MESH){var h=a.num_faces(),d=new e.DracoInt32Array;try{for(var f=new Uint32Array(3*h),p=0;p1)for(var c=0;c0&&d.forEach((function(e){a._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:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._currentActiveTarget},enumerable:!0,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),this._currentFrame=e;var n=this._animation._interpolate(e,this._animationState);this.setValue(n,-1)},e.prototype._prepareForSpeedRatioChange=function(e){var t=this._previousDelay*(this._animation.framePerSecond*e)/1e3;this._ratioOffset=this._previousRatio-t},e.prototype.animate=function(e,t,n,i,u,h){void 0===h&&(h=-1);var d=this._animation,f=d.targetPropertyPath;if(!f||f.length<1)return this._stopped=!0,!1;var p=!0;(tthis._maxFrame)&&(t=this._minFrame),(nthis._maxFrame)&&(n=this._maxFrame);var m,g,_=n-t,v=e*(d.framePerSecond*u)/1e3+this._ratioOffset,b=0;if(this._previousDelay=e,this._previousRatio=v,!i&&n>=t&&v>=_)p=!1,b=d._getKeyValue(this._maxValue);else if(!i&&t>=n&&v<=_)p=!1,b=d._getKeyValue(this._minValue);else if(this._animationState.loopMode!==r.a.ANIMATIONLOOPMODE_CYCLE){var y=n.toString()+t.toString();if(!this._offsetsCache[y]){this._animationState.repeatCount=0,this._animationState.loopMode=r.a.ANIMATIONLOOPMODE_CYCLE;var x=d._interpolate(t,this._animationState),C=d._interpolate(n,this._animationState);switch(this._animationState.loopMode=this._getCorrectLoopMode(),d.dataType){case r.a.ANIMATIONTYPE_FLOAT:this._offsetsCache[y]=C-x;break;case r.a.ANIMATIONTYPE_QUATERNION:this._offsetsCache[y]=C.subtract(x);break;case r.a.ANIMATIONTYPE_VECTOR3:this._offsetsCache[y]=C.subtract(x);case r.a.ANIMATIONTYPE_VECTOR2:this._offsetsCache[y]=C.subtract(x);case r.a.ANIMATIONTYPE_SIZE:this._offsetsCache[y]=C.subtract(x);case r.a.ANIMATIONTYPE_COLOR3:this._offsetsCache[y]=C.subtract(x)}this._highLimitsCache[y]=C}b=this._highLimitsCache[y],m=this._offsetsCache[y]}if(void 0===m)switch(d.dataType){case r.a.ANIMATIONTYPE_FLOAT:m=0;break;case r.a.ANIMATIONTYPE_QUATERNION:m=o;break;case r.a.ANIMATIONTYPE_VECTOR3:m=a;break;case r.a.ANIMATIONTYPE_VECTOR2:m=s;break;case r.a.ANIMATIONTYPE_SIZE:m=c;break;case r.a.ANIMATIONTYPE_COLOR3:m=l}if(this._host&&this._host.syncRoot){var E=this._host.syncRoot;g=t+(n-t)*((E.masterFrame-E.fromFrame)/(E.toFrame-E.fromFrame))}else g=p&&0!==_?t+v%_:n;var T=this._events;if((_>0&&this.currentFrame>g||_<0&&this.currentFrame>0,this._animationState.highLimitValue=b,this._animationState.offsetValue=m;var A=d._interpolate(g,this._animationState);if(this.setValue(A,h),T.length)for(S=0;S0&&g>=T[S].frame&&T[S].frame>=t||_<0&&g<=T[S].frame&&T[S].frame<=t){var P=T[S];P.isDone||(P.onlyOnce&&(T.splice(S,1),S--),P.isDone=!0,P.action(g))}return p||(this._stopped=!0),p},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return r})),n.d(t,"b",(function(){return o}));var i=n(63),r=function(){function e(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new o(e)}return e.prototype.sampleFrame=function(e){if(void 0===e&&(e=i.a.Now),this._enabled){if(null!=this._lastFrameTimeMs){var t=e-this._lastFrameTimeMs;this._rollingFrameTime.add(t)}this._lastFrameTimeMs=e}},Object.defineProperty(e.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"instantaneousFPS",{get:function(){var e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!0,configurable:!0}),e.prototype.enable=function(){this._enabled=!0},e.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null},Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),e.prototype.reset=function(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()},e}(),o=function(){function e(e){this._samples=new Array(e),this.reset()}return e.prototype.add=function(e){var t;if(this.isSaturated()){var n=this._samples[this._pos];t=n-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(n-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length},e.prototype.history=function(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i,r=n(5);!function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"}(i||(i={}));var o=function(){this.count=0,this.target=0,this.results=[]},a=function(){function e(e){var t=this;if(this._state=i.Pending,this._children=new Array,this._rejectWasConsumed=!1,e)try{e((function(e){t._resolve(e)}),(function(e){t._reject(e)}))}catch(e){this._reject(e)}}return Object.defineProperty(e.prototype,"_result",{get:function(){return this._resultValue},set:function(e){this._resultValue=e,this._parent&&void 0===this._parent._result&&(this._parent._result=e)},enumerable:!0,configurable:!0}),e.prototype.catch=function(e){return this.then(void 0,e)},e.prototype.then=function(t,n){var o=this,a=new e;return a._onFulfilled=t,a._onRejected=n,this._children.push(a),a._parent=this,this._state!==i.Pending&&r.h.SetImmediate((function(){if(o._state===i.Fulfilled||o._rejectWasConsumed){var e=a._resolve(o._result);if(null!=e)if(void 0!==e._state){var t=e;a._children.push(t),t._parent=a,a=t}else a._result=e}else a._reject(o._reason)})),a},e.prototype._moveChildren=function(e){var t,n=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=n})),this._state===i.Fulfilled)for(var r=0,o=this._children;rn._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.push(t._edgesRenderer))},e.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},e.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},e.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var n=0;n0?1/r:0,c=0;c1)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}return Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var n=this;e.visibility=t,e.getChildMeshes().forEach((function(e){n._setAllVisibility(e,t)}))},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var i=n(1),r=n(2),o=n(37),a=n(64),s=n(0),c=function(){function e(){this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this._keys=new Array}return e.prototype.attachControl=function(e,t){var n=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){n._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(e){var i,r=e.event;r.metaKey||(e.type===a.a.KEYDOWN?-1===n.keysUp.indexOf(r.keyCode)&&-1===n.keysDown.indexOf(r.keyCode)&&-1===n.keysLeft.indexOf(r.keyCode)&&-1===n.keysRight.indexOf(r.keyCode)||(-1===(i=n._keys.indexOf(r.keyCode))&&n._keys.push(r.keyCode),t||r.preventDefault()):-1===n.keysUp.indexOf(r.keyCode)&&-1===n.keysDown.indexOf(r.keyCode)&&-1===n.keysLeft.indexOf(r.keyCode)&&-1===n.keysRight.indexOf(r.keyCode)||((i=n._keys.indexOf(r.keyCode))>=0&&n._keys.splice(i,1),t||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 s.x(0,0,t*this._offsetY/this.touchMoveSensibility);s.j.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(s.x.TransformCoordinates(n,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},i.c([Object(r.c)()],e.prototype,"touchAngularSensibility",void 0),i.c([Object(r.c)()],e.prototype,"touchMoveSensibility",void 0),e}();o.a.FreeCameraTouchInput=c},function(e,t,n){"use strict";n.d(t,"a",(function(){return r}));var i=n(17),r=function(){function e(e){this.name=i.a.NAME_LAYER,this.scene=e,this._engine=e.getEngine(),e.layers=new Array}return e.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(i.a.STEP_BEFORECAMERADRAW_LAYER,this,this._drawCameraBackground),this.scene._afterCameraDrawStage.registerStep(i.a.STEP_AFTERCAMERADRAW_LAYER,this,this._drawCameraForeground),this.scene._beforeRenderTargetDrawStage.registerStep(i.a.STEP_BEFORERENDERTARGETDRAW_LAYER,this,this._drawRenderTargetBackground),this.scene._afterRenderTargetDrawStage.registerStep(i.a.STEP_AFTERRENDERTARGETDRAW_LAYER,this,this._drawRenderTargetForeground)},e.prototype.rebuild=function(){for(var e=0,t=this.scene.layers;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}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var i=n(1),r=n(2),o=n(137),a=n(26),s=function(e){function t(t,n){var i=e.call(this,t,n)||this;return i._useRoughnessFromMetallicTextureAlpha=!1,i._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i.metallic=1,i.roughness=1,i}return i.d(t,e),t.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},t.prototype.clone=function(e){var n=this,i=r.a.Clone((function(){return new t(e,n.getScene())}),this);return i.id=e,i.name=e,this.clearCoat.copyTo(i.clearCoat),this.anisotropy.copyTo(i.anisotropy),this.brdf.copyTo(i.brdf),this.sheen.copyTo(i.sheen),i},t.prototype.serialize=function(){var e=r.a.Serialize(this);return e.customType="BABYLON.PBRMetallicRoughnessMaterial",e.clearCoat=this.clearCoat.serialize(),e.anisotropy=this.anisotropy.serialize(),e.brdf=this.brdf.serialize(),e.sheen=this.sheen.serialize(),e},t.Parse=function(e,n,i){var o=r.a.Parse((function(){return new t(e.name,n)}),e,n,i);return e.clearCoat&&o.clearCoat.parse(e.clearCoat),e.anisotropy&&o.anisotropy.parse(e.anisotropy),e.brdf&&o.brdf.parse(e.brdf),e.sheen&&o.sheen.parse(e.brdf),o},i.c([Object(r.e)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty","_albedoColor")],t.prototype,"baseColor",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],t.prototype,"baseTexture",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"metallic",void 0),i.c([Object(r.c)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty")],t.prototype,"roughness",void 0),i.c([Object(r.m)(),Object(r.b)("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],t.prototype,"metallicRoughnessTexture",void 0),t}(o.a);a.a.RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"]=s},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var i=n(5),r=n(17),o=function(){function e(e){this.name=r.a.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array,e.layers=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(r.a.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){i.h.StartPerformanceCounter("Procedural textures",this.scene.proceduralTextures.length>0);for(var e=0;e0)}},e}()},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var i=n(1),r=n(2),o=n(120),a=n(32),s=n(80),c=n(4),l=(n(144),function(e){function t(t,n,i,r,o,a,s,l,u){void 0===r&&(r=c.a.TEXTUREFORMAT_RGBA),void 0===o&&(o=c.a.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1),void 0===s&&(s=!1),void 0===l&&(l=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===u&&(u=null);var h=e.call(this,"",t)||this;return h._texture=t.getEngine().createRawCubeTexture(n,i,r,o,a,s,l,u),h}return i.d(t,e),t.prototype.update=function(e,t,n,i,r){void 0===r&&(r=null),this._texture.getEngine().updateRawCubeTexture(this._texture,e,t,n,i,r)},t.prototype.updateRGBDAsync=function(e,n,i,r){return void 0===n&&(n=null),void 0===i&&(i=.8),void 0===r&&(r=0),t._UpdateRGBDAsync(this._texture,e,n,i,r)},t.prototype.clone=function(){var e=this;return r.a.Clone((function(){var n=e.getScene(),i=e._texture,r=new t(n,i._bufferViewArray,i.width,i.format,i.type,i.generateMipMaps,i.invertY,i.samplingMode,i._compression);return i.dataSource===a.a.DATASOURCE_CUBERAW_RGBD&&r.updateRGBDAsync(i._bufferViewArrayArray,i._sphericalPolynomial,i._lodGenerationScale,i._lodGenerationOffset),r}),this)},t._UpdateRGBDAsync=function(e,t,n,i,r){return e._dataSource=a.a.DATASOURCE_CUBERAW_RGBD,e._bufferViewArrayArray=t,e._lodGenerationScale=i,e._lodGenerationOffset=r,e._sphericalPolynomial=n,o.a.UploadLevelsAsync(e,t).then((function(){e.isReady=!0}))},t}(s.a))},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var i=function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{worker:e,active:!1}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;e\nvoid main(void) {\n#include\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";i.a.ShadersStore[r]=o},function(e,t,n){"use strict";var i=n(8),r=(n(105),n(146),n(106),n(107),n(108),n(134),"colorVertexShader"),o="\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include\n#include\n\n#include\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include\n#include\nvec4 worldPos=finalWorld*vec4(position,1.0);\ngl_Position=viewProjection*worldPos;\n#include\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";i.a.ShadersStore[r]=o},function(e,t,n){"use strict";(function(e){n.d(t,"b",(function(){return u})),n.d(t,"a",(function(){return h}));var i=n(1),r=n(9),o=n(10),a=n(140),s=n(32),c=n(4),l=n(118),u=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4},h=function(t){function n(n){void 0===n&&(n=new u);var i=t.call(this,null)||this;void 0===n.deterministicLockstep&&(n.deterministicLockstep=!1),void 0===n.lockstepMaxSteps&&(n.lockstepMaxSteps=4),i._options=n,i._caps=new o.c,i._caps.maxTexturesImageUnits=16,i._caps.maxVertexTextureImageUnits=16,i._caps.maxTextureSize=512,i._caps.maxCubemapTextureSize=512,i._caps.maxRenderTextureSize=512,i._caps.maxVertexAttribs=16,i._caps.maxVaryingVectors=16,i._caps.maxFragmentUniformVectors=16,i._caps.maxVertexUniformVectors=16,i._caps.standardDerivatives=!1,i._caps.astc=null,i._caps.s3tc=null,i._caps.pvrtc=null,i._caps.etc1=null,i._caps.etc2=null,i._caps.textureAnisotropicFilterExtension=null,i._caps.maxAnisotropy=0,i._caps.uintIndices=!1,i._caps.fragmentDepthSupported=!1,i._caps.highPrecisionShaderSupported=!0,i._caps.colorBufferFloat=!1,i._caps.textureFloat=!1,i._caps.textureFloatLinearFiltering=!1,i._caps.textureFloatRender=!1,i._caps.textureHalfFloat=!1,i._caps.textureHalfFloatLinearFiltering=!1,i._caps.textureHalfFloatRender=!1,i._caps.textureLOD=!1,i._caps.drawBuffersExtension=!1,i._caps.depthTextureExtension=!1,i._caps.vertexArrayObject=!1,i._caps.instancedArrays=!1,r.a.Log("Babylon.js v"+o.b.Version+" - Null engine");var a="undefined"!=typeof self?self:void 0!==e?e:window;return"undefined"==typeof URL&&(a.URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(a.Blob=function(){}),i}return i.d(n,t),n.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},n.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},n.prototype.getHardwareScalingLevel=function(){return 1},n.prototype.createVertexBuffer=function(e){var t=new l.a;return t.references=1,t},n.prototype.createIndexBuffer=function(e){var t=new l.a;return t.references=1,t},n.prototype.clear=function(e,t,n,i){void 0===i&&(i=!1)},n.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},n.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},n.prototype.setViewport=function(e,t,n){this._cachedViewport=e},n.prototype.createShaderProgram=function(e,t,n,i,r){return{__SPECTOR_rebuildProgram:null}},n.prototype.getUniforms=function(e,t){return[]},n.prototype.getAttributes=function(e,t){return[]},n.prototype.bindSamplers=function(e){this._currentEffect=null},n.prototype.enableEffect=function(e){this._currentEffect=e,e.onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e)},n.prototype.setState=function(e,t,n,i){void 0===t&&(t=0),void 0===i&&(i=!1)},n.prototype.setIntArray=function(e,t){},n.prototype.setIntArray2=function(e,t){},n.prototype.setIntArray3=function(e,t){},n.prototype.setIntArray4=function(e,t){},n.prototype.setFloatArray=function(e,t){},n.prototype.setFloatArray2=function(e,t){},n.prototype.setFloatArray3=function(e,t){},n.prototype.setFloatArray4=function(e,t){},n.prototype.setArray=function(e,t){},n.prototype.setArray2=function(e,t){},n.prototype.setArray3=function(e,t){},n.prototype.setArray4=function(e,t){},n.prototype.setMatrices=function(e,t){},n.prototype.setMatrix=function(e,t){},n.prototype.setMatrix3x3=function(e,t){},n.prototype.setMatrix2x2=function(e,t){},n.prototype.setFloat=function(e,t){},n.prototype.setFloat2=function(e,t,n){},n.prototype.setFloat3=function(e,t,n,i){},n.prototype.setBool=function(e,t){},n.prototype.setFloat4=function(e,t,n,i,r){},n.prototype.setColor3=function(e,t){},n.prototype.setColor4=function(e,t,n){},n.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(this._alphaState.alphaBlend=e!==c.a.ALPHA_DISABLE,t||this.setDepthWrite(e===c.a.ALPHA_DISABLE),this._alphaMode=e)},n.prototype.bindBuffers=function(e,t,n){},n.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames||(this.resetTextureCache(),this._currentEffect=null,e&&(this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this._alphaState.reset()),this._cachedVertexBuffers=null,this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null)},n.prototype.draw=function(e,t,n,i){},n.prototype.drawElementsType=function(e,t,n,i){},n.prototype.drawArraysType=function(e,t,n,i){},n.prototype._createTexture=function(){return{}},n.prototype._releaseTexture=function(e){},n.prototype.createTexture=function(e,t,n,i,r,o,a,l,u,h){void 0===r&&(r=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===a&&(a=null),void 0===l&&(l=null);var d=new s.a(this,s.a.DATASOURCE_URL),f=String(e);return d.url=f,d.generateMipMaps=!t,d.samplingMode=r,d.invertY=n,d.baseWidth=this._options.textureSize,d.baseHeight=this._options.textureSize,d.width=this._options.textureSize,d.height=this._options.textureSize,h&&(d.format=h),d.isReady=!0,o&&o(),this._internalTexturesCache.push(d),d},n.prototype.createRenderTargetTexture=function(e,t){var n=new a.a;void 0!==t&&"object"==typeof t?(n.generateMipMaps=t.generateMipMaps,n.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,n.generateStencilBuffer=n.generateDepthBuffer&&t.generateStencilBuffer,n.type=void 0===t.type?c.a.TEXTURETYPE_UNSIGNED_INT:t.type,n.samplingMode=void 0===t.samplingMode?c.a.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode):(n.generateMipMaps=t,n.generateDepthBuffer=!0,n.generateStencilBuffer=!1,n.type=c.a.TEXTURETYPE_UNSIGNED_INT,n.samplingMode=c.a.TEXTURE_TRILINEAR_SAMPLINGMODE);var i=new s.a(this,s.a.DATASOURCE_RENDERTARGET),r=e.width||e,o=e.height||e;return i._depthStencilBuffer={},i._framebuffer={},i.baseWidth=r,i.baseHeight=o,i.width=r,i.height=o,i.isReady=!0,i.samples=1,i.generateMipMaps=!!n.generateMipMaps,i.samplingMode=n.samplingMode,i.type=n.type,i._generateDepthBuffer=n.generateDepthBuffer,i._generateStencilBuffer=!!n.generateStencilBuffer,this._internalTexturesCache.push(i),i},n.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},n.prototype.bindFramebuffer=function(e,t,n,i,r){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!r&&this.setViewport(this._cachedViewport,n,i)},n.prototype.unBindFramebuffer=function(e,t,n){void 0===t&&(t=!1),this._currentRenderTarget=null,n&&(e._MSAAFramebuffer&&(this._currentFramebuffer=e._framebuffer),n()),this._currentFramebuffer=null},n.prototype.createDynamicVertexBuffer=function(e){var t=new l.a;return t.references=1,t.capacity=1,t},n.prototype.updateDynamicTexture=function(e,t,n,i,r){void 0===i&&(i=!1)},n.prototype.areAllEffectsReady=function(){return!0},n.prototype.getError=function(){return 0},n.prototype._getUnpackAlignement=function(){return 1},n.prototype._unpackFlipY=function(e){},n.prototype.updateDynamicIndexBuffer=function(e,t,n){void 0===n&&(n=0)},n.prototype.updateDynamicVertexBuffer=function(e,t,n,i){},n.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},n.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},n.prototype._releaseBuffer=function(e){return e.references--,0===e.references},n.prototype.releaseEffects=function(){},n.prototype.displayLoadingUI=function(){},n.prototype.hideLoadingUI=function(){},n.prototype._uploadCompressedDataToTextureDirectly=function(e,t,n,i,r,o,a){void 0===o&&(o=0),void 0===a&&(a=0)},n.prototype._uploadDataToTextureDirectly=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0)},n.prototype._uploadArrayBufferViewToTexture=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0)},n.prototype._uploadImageToTexture=function(e,t,n,i){void 0===n&&(n=0),void 0===i&&(i=0)},n}(o.b)}).call(this,n(156))},function(e,t,n){"use strict";var i=n(1),r=n(10),o=n(32),a=n(9),s=n(5);r.b.prototype._createDepthStencilCubeTexture=function(e,t){var n=new o.a(this,o.a.DATASOURCE_UNKNOWN);if(n.isCube=!0,1===this.webGLVersion)return a.a.Error("Depth cube texture is not supported by WebGL 1."),n;var r=i.a({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),s=this._gl;this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,n,!0),this._setupDepthStencilTexture(n,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction);for(var c=0;c<6;c++)r.generateStencil?s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,s.DEPTH24_STENCIL8,e,e,0,s.DEPTH_STENCIL,s.UNSIGNED_INT_24_8,null):s.texImage2D(s.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,s.DEPTH_COMPONENT24,e,e,0,s.DEPTH_COMPONENT,s.UNSIGNED_INT,null);return this._bindTextureDirectly(s.TEXTURE_CUBE_MAP,null),n},r.b.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)}))},r.b.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)},r.b.prototype._cascadeLoadImgs=function(e,t,n,i){void 0===i&&(i=null);var r=[];r._internalCount=0;for(var o=0;o<6;o++)this._partialLoadImg(n[o],o,r,e,t,i)},r.b.prototype._partialLoadImg=function(e,t,n,i,r,o){var a;void 0===o&&(o=null);a=s.h.LoadImage(e,(function(){n[t]=a,n._internalCount++,i&&i._removePendingData(a),6===n._internalCount&&r(n)}),(function(e,t){i&&i._removePendingData(a),o&&o(e,t)}),i?i.offlineProvider:null),i&&i._addPendingData(a)},r.b.prototype.createCubeTexture=function(e,t,n,i,c,l,u,h,d,f,p,m,g){var _=this;void 0===c&&(c=null),void 0===l&&(l=null),void 0===h&&(h=null),void 0===d&&(d=!1),void 0===f&&(f=0),void 0===p&&(p=0),void 0===m&&(m=null),void 0===g&&(g=[]);var v=this._gl,b=m||new o.a(this,o.a.DATASOURCE_CUBE);b.isCube=!0,b.url=e,b.generateMipMaps=!i,b._lodGenerationScale=f,b._lodGenerationOffset=p,this._doNotHandleContextLost||(b._extension=h,b._files=n);for(var y=e.lastIndexOf("."),x=h||(y>-1?e.substring(y).toLowerCase():""),C=null,E=0,T=r.b._TextureLoaders;E\nvoid main(void)\n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}";i.a.ShadersStore[r]=o},function(e,t,n){"use strict";!function e(){if("undefined"!=typeof __REACT_DEVTOOLS_GLOBAL_HOOK__&&"function"==typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE){0;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(e){console.error(e)}}}(),e.exports=n(245)},function(e,t,n){e.exports=n.p+"c10d9ad6392e3b1800661ce06dbcb0c7.mp3"},function(e,t,n){e.exports=n.p+"a318886a967c436a5614c1425f845579.glb"},function(e,t,n){e.exports=n.p+"cf16b613d508eb3135192cbc31634f20.mp3"},function(e,t,n){e.exports=n.p+"7c019dfe533d5d84d11d518927b8d60f.mp3"},function(e,t,n){e.exports=n.p+"6711be730a6e1e940029e6c6dec4850f.mp3"},function(e,t,n){e.exports=n.p+"b812786005094b68a61ae8548e832adf.mp3"},function(e,t,n){e.exports=n.p+"e5927454cc22b2d191f59828ffe50aec.mp3"},function(e,t,n){e.exports=n.p+"f75d767152b97cd5904e71fce80f4a6b.mp3"},function(e,t,n){e.exports=n.p+"8bd2c27b0bc8aba09fff2a1874bb0b9d.mp3"},function(e,t,n){e.exports=n.p+"8c110eb5705f7d17a3c1a00549fa63bc.mp3"},function(e,t,n){e.exports=n.p+"76f406ef4d1ad75dbcc5f8e8a960bacc.mp3"},function(e,t,n){e.exports=n.p+"b19c8646789b771b5134694c7fcc7065.mp3"},function(e,t,n){e.exports=n.p+"6b162f1a40c1b6c74f69528008c313fc.mp3"},function(e,t,n){e.exports=n.p+"e7749ceb6601da421a788d526bbffa2d.mp3"},function(e,t,n){e.exports=n.p+"5cb2392e20e21997a176423ed4f55a57.mp3"},function(e,t,n){e.exports=n.p+"9d3db1542810a5f5889384299324825b.mp3"},function(e,t,n){e.exports=n.p+"54c33937f659e1f29e7c09e706628a78.mp3"},function(e,t,n){e.exports=n.p+"f189258057c3bcc83f0c0b99b8c813f6.mp3"},function(e,t,n){e.exports=n.p+"34d1d55bd2ecb4084bcc73a6a471b220.mp3"},function(e,t,n){e.exports=n.p+"69e30e909b2a7c2d10e21b2c7a153bb8.mp3"},function(e,t,n){e.exports=n.p+"5a2e37c64105680936e6f6a611c978ab.mp3"},function(e,t,n){e.exports=n.p+"aa0e92503e74f75bb924502e016afa40.mp3"},function(e,t,n){e.exports=n.p+"4caba6319507b7cf7c216315ee660091.svg"},function(e,t,n){e.exports=n.p+"c8f627749172d6773cb09069e2ac2b8c.svg"},function(e,t,n){e.exports=n.p+"5e5b803f24b8336f193822dd63cd262b.svg"},function(e,t,n){e.exports=n.p+"74314484d300a1e2a9f024b0050fc6bd.svg"},function(e,t,n){e.exports=n.p+"7646d97a882b10f2b27db4cb59267249.svg"},function(e,t,n){e.exports=n.p+"cd84bc7d65acad7e2ee307bf04732b4b.svg"},function(e,t,n){e.exports=n.p+"7fd98de59e095f4eea4112cac51d4c6e.svg"},function(e,t,n){e.exports=n.p+"db8bcc3c7abd125ee9dd584f1cbba30a.svg"},function(e,t,n){e.exports=n.p+"943482232e98618273b80b651dcf9e1d.svg"},function(e,t,n){e.exports=n.p+"24bd05cffd1a46748e005634de320bca.svg"},function(e,t,n){e.exports=n.p+"01350f42a4e8c32b94a8e942bcf9f505.svg"},function(e,t,n){e.exports=n.p+"899108cd678314cfafc76269ba696810.svg"},function(e,t,n){e.exports=n.p+"31913e31f3adace6dcff8b63372d94e2.glb"},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return u}));var i=n(31),r=n(104),o=n(74),a=n(48),s=n(91),c=n(36),l=n(62);class u extends l.a{name(){return"Chain Lightning"}requiredRunes(){return new Set([c.a.LightningRune.index,c.a.CopyRune.index,c.a.LineRune.index])}cast(t,n){const c=Object(i.e)(new i.a(t.position,s.a),a.a.mobs,i.b.HeroDamagable,!0,t.facingVector.normalize(),Math.PI/2);if(c&&c.length>0){const n=t.sortMobsByDistance(c).slice(0,5);n.unshift(t);for(let t=0;t=n.length&&(i=n.length-t);const a=n[t];for(let s=1;s<=i&&t+s{const e=o.a.i.particles.chainLightning(a,i.position),t=o.a.i.particles.stationaryLightning(i.position,i.radius);a.health>0&&i.health>0&&(a.attachOutgoingEffect(e),i.attachIncomingEffect(e),i.attachIncomingEffect(t),e.start(),t.start())},225*t)}}}}}}).call(this,n(156))},function(e,t,n){e.exports=n.p+"2591d385729b9ce8442d2bc19c90735e.png"},function(e,t,n){e.exports=n.p+"8fc7c4ad5401f3420cefd6fcca4979b0.png"},function(e,t,n){e.exports=n.p+"4f049eb3eb675d6b486a1b14361018b3.png"},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return c}));var i=n(62),r=n(36),o=n(31),a=n(74),s=n(48);class c extends i.a{name(){return"Rocket Wizard"}requiredRunes(){return new Set([r.a.SelfRune.index,r.a.LineRune.index,r.a.IncreaseRune.index,r.a.FireRune.index,r.a.ChaosRune.index])}cast(t,n){if(t.rocketMode)return clearTimeout(this.tmout),void(this.tmout=e.setTimeout(()=>{t.rocketMode=!1,clearInterval(this.interval)},2e3));t.rocketMode=!0,this.interval=e.setInterval(()=>{a.a.i.particles.miniExplode(t.position).start();const e=Object(o.d)(new o.a(t.position,.5),s.a.mobs,o.b.HeroDamagable,!0);if(e)for(const t of e)t.mesh.dispose()},100),this.tmout=e.setTimeout(()=>{t.rocketMode=!1,clearInterval(this.interval)},2e3)}}}).call(this,n(156))},function(e,t,n){e.exports=n.p+"5e1edd329eca2b0942b8572932a5e5a3.png"},function(e,t,n){e.exports=n.p+"d654b2328f8b01f8bed1445671e52a45.glb"},function(e,t,n){"use strict";var i=n(188),r="function"==typeof Symbol&&Symbol.for,o=r?Symbol.for("react.element"):60103,a=r?Symbol.for("react.portal"):60106,s=r?Symbol.for("react.fragment"):60107,c=r?Symbol.for("react.strict_mode"):60108,l=r?Symbol.for("react.profiler"):60114,u=r?Symbol.for("react.provider"):60109,h=r?Symbol.for("react.context"):60110,d=r?Symbol.for("react.forward_ref"):60112,f=r?Symbol.for("react.suspense"):60113,p=r?Symbol.for("react.suspense_list"):60120,m=r?Symbol.for("react.memo"):60115,g=r?Symbol.for("react.lazy"):60116;r&&Symbol.for("react.fundamental"),r&&Symbol.for("react.responder"),r&&Symbol.for("react.scope");var _="function"==typeof Symbol&&Symbol.iterator;function v(e){for(var t=e.message,n="https://reactjs.org/docs/error-decoder.html?invariant="+t,i=1;iL.length&&L.push(e)}function F(e,t,n){return null==e?0:function e(t,n,i,r){var s=typeof t;"undefined"!==s&&"boolean"!==s||(t=null);var c=!1;if(null===t)c=!0;else switch(s){case"string":case"number":c=!0;break;case"object":switch(t.$$typeof){case o:case a:c=!0}}if(c)return i(r,t,""===n?"."+k(t,0):n),1;if(c=0,n=""===n?".":n+":",Array.isArray(t))for(var l=0;l