babylon.worker.js 2.1 MB

1
  1. !(function(e,t){var i=[],r=e.CANNON||this.CANNON,n=e.OIMO||this.OIMO,o=e.earcut||this.earcut;if("object"==typeof exports&&"object"==typeof module){try{r=r||require("cannon")}catch(e){}try{n=n||require("oimo")}catch(e){}try{o=o||require("earcut")}catch(e){}module.exports=t(r,n,o)}else if("function"==typeof define&&define.amd)require.specified&&require.specified("cannon")&&i.push("cannon"),require.specified&&require.specified("oimo")&&i.push("oimo"),require.specified&&require.specified("earcut")&&i.push("earcut"),define("babylonjs",i,t);else if("object"==typeof exports){try{r=r||require("cannon")}catch(e){}try{n=n||require("oimo")}catch(e){}try{o=o||require("earcut")}catch(e){}exports.babylonjs=t(r,n,o)}else e.BABYLON=t(r,n,o)})(this,(function(i,t,_){i=i||this.CANNON,t=t||this.OIMO,_=_||this.earcut;var r,e,n,o,s,a,l,c,h,u,d,f,p,m,g,v,b=this&&this.__decorate||function(e,t,i,r){var n,o=arguments.length,s=o<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;0<=a;a--)(n=e[a])&&(s=(o<3?n(s):3<o?n(t,i,s):n(t,i))||s);return 3<o&&s&&Object.defineProperty(t,i,s),s},T=this&&this.__extends||(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])},function(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)});!(function(b){var e=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.unBindMesh=function(){this._mesh=null},e.prototype.addFallback=function(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&0<this._mesh.numBoneInfluencers&&this._mesh.material){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),r=0;r<i.meshes.length;r++){var n=i.meshes[r];if(n.material&&(n.computeBonesUsingShaders&&0!==n.numBoneInfluencers))if(n.material.getEffect()===t)n.computeBonesUsingShaders=!1;else if(n.subMeshes)for(var o=0,s=n.subMeshes;o<s.length;o++){if(s[o].effect===t){n.computeBonesUsingShaders=!1;break}}}}else{var a=this._defines[this._currentRank];if(a)for(r=0;r<a.length;r++)e=e.replace("#define "+a[r],"");this._currentRank++}return e},e})();b.EffectFallbacks=e;var t=function(){};b.EffectCreationOptions=t;var i=(function(){function y(n,e,t,i,r,o,s,a,l,c){void 0===i&&(i=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null);var h,u,d=this;if(this.uniqueId=0,this.onCompileObservable=new b.Observable,this.onErrorObservable=new b.Observable,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._isReady=!1,this._compilationError="",this.name=n,e.attributes){var f=e;if(this._engine=t,this._attributesNames=f.attributes,this._uniformsNames=f.uniformsNames.concat(f.samplers),this._samplers=f.samplers.slice(),this.defines=f.defines,this.onError=f.onError,this.onCompiled=f.onCompiled,this._fallbacks=f.fallbacks,this._indexParameters=f.indexParameters,this._transformFeedbackVaryings=f.transformFeedbackVaryings,f.uniformBuffersNames)for(var p=0;p<f.uniformBuffersNames.length;p++)this._uniformBuffersNames[f.uniformBuffersNames[p]]=p}else this._engine=r,this.defines=o,this._uniformsNames=t.concat(i),this._samplers=i?i.slice():[],this._attributesNames=e,this.onError=l,this.onCompiled=a,this._indexParameters=c,this._fallbacks=s;this.uniqueId=y._uniqueIdSeed++,n.vertexElement?(h=document.getElementById(n.vertexElement))||(h=n.vertexElement):h=n.vertex||n,n.fragmentElement?(u=document.getElementById(n.fragmentElement))||(u=n.fragmentElement):u=n.fragment||n,this._loadVertexShader(h,(function(e){d._processIncludes(e,(function(e){d._processShaderConversion(e,!1,(function(r){d._loadFragmentShader(u,(function(e){d._processIncludes(e,(function(e){d._processShaderConversion(e,!0,(function(e){if(n){var t=n.vertexElement||n.vertex||n,i=n.fragmentElement||n.fragment||n;d._vertexSourceCode="#define SHADER_NAME vertex:"+t+"\n"+r,d._fragmentSourceCode="#define SHADER_NAME fragment:"+i+"\n"+e}else d._vertexSourceCode=r,d._fragmentSourceCode=e;d._prepareEffect()}))}))}))}))}))}))}return Object.defineProperty(y.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new b.Observable),this._onBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(y.prototype,"key",{get:function(){return this._key},enumerable:!0,configurable:!0}),y.prototype.isReady=function(){return this._isReady},y.prototype.getEngine=function(){return this._engine},y.prototype.getProgram=function(){return this._program},y.prototype.getAttributesNames=function(){return this._attributesNames},y.prototype.getAttributeLocation=function(e){return this._attributes[e]},y.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},y.prototype.getAttributesCount=function(){return this._attributes.length},y.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},y.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},y.prototype.getSamplers=function(){return this._samplers},y.prototype.getCompilationError=function(){return this._compilationError},y.prototype.executeWhenCompiled=function(t){this.isReady()?t(this):this.onCompileObservable.add((function(e){t(e)}))},y.prototype._loadVertexShader=function(e,t){var i;if(b.Tools.IsWindowObjectExist()&&e instanceof HTMLElement)return void t(b.Tools.GetDOMTextContent(e));"base64:"!==e.substr(0,7)?y.ShadersStore[e+"VertexShader"]?t(y.ShadersStore[e+"VertexShader"]):(i="."===e[0]||"/"===e[0]||-1<e.indexOf("http")?e:b.Engine.ShadersRepository+e,this._engine._loadFile(i+".vertex.fx",t)):t(window.atob(e.substr(7)))},y.prototype._loadFragmentShader=function(e,t){var i;if(b.Tools.IsWindowObjectExist()&&e instanceof HTMLElement)return void t(b.Tools.GetDOMTextContent(e));"base64:"!==e.substr(0,7)?y.ShadersStore[e+"PixelShader"]?t(y.ShadersStore[e+"PixelShader"]):y.ShadersStore[e+"FragmentShader"]?t(y.ShadersStore[e+"FragmentShader"]):(i="."===e[0]||"/"===e[0]||-1<e.indexOf("http")?e:b.Engine.ShadersRepository+e,this._engine._loadFile(i+".fragment.fx",t)):t(window.atob(e.substr(7)))},y.prototype._dumpShadersSource=function(e,t,i){var r=(1<this._engine.webGLVersion?"#version 300 es\n#define WEBGL2 \n":"")+(i?i+"\n":"");t=r+t;var n=2,o=/\n/gm,s="\n1\t"+(e=r+e).replace(o,(function(){return"\n"+n+++"\t"}));n=2;var a="\n1\t"+t.replace(o,(function(){return"\n"+n+++"\t"}));this.name.vertexElement?(b.Tools.Error("Vertex shader: "+this.name.vertexElement+s),b.Tools.Error("Fragment shader: "+this.name.fragmentElement+a)):this.name.vertex?(b.Tools.Error("Vertex shader: "+this.name.vertex+s),b.Tools.Error("Fragment shader: "+this.name.fragment+a)):(b.Tools.Error("Vertex shader: "+this.name+s),b.Tools.Error("Fragment shader: "+this.name+a))},y.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1!=this._engine.webGLVersion)if(-1===r.indexOf("#version 3")){var n=-1!==r.search(/#extension.+GL_EXT_draw_buffers.+require/),o=r.replace(/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,"");o=(o=(o=o.replace(/varying(?![\n\r])\s/g,t?"in ":"out ")).replace(/attribute[ \t]/g,"in ")).replace(/[ \t]attribute/g," in"),t&&(o=(o=(o=(o=(o=(o=(o=(o=o.replace(/texture2DLodEXT\s*\(/g,"textureLod(")).replace(/textureCubeLodEXT\s*\(/g,"textureLod(")).replace(/texture2D\s*\(/g,"texture(")).replace(/textureCube\s*\(/g,"texture(")).replace(/gl_FragDepthEXT/g,"gl_FragDepth")).replace(/gl_FragColor/g,"glFragColor")).replace(/gl_FragData/g,"glFragData")).replace(/void\s+?main\s*\(/g,(n?"":"out vec4 glFragColor;\n")+"void main(")),i(o)}else i(r.replace("#version 300 es",""));else i(r)},y.prototype._processIncludes=function(e,t){for(var i=this,r=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,n=r.exec(e),o=new String(e);null!=n;){var s=n[1];if(-1!==s.indexOf("__decl__")&&(s=s.replace(/__decl__/,""),this._engine.supportsUniformBuffers&&(s=(s=s.replace(/Vertex/,"Ubo")).replace(/Fragment/,"Ubo")),s+="Declaration"),!y.IncludesShadersStore[s]){var a=b.Engine.ShadersRepository+"ShadersInclude/"+s+".fx";return void this._engine._loadFile(a,(function(e){y.IncludesShadersStore[s]=e,i._processIncludes(o,t)}))}var l=y.IncludesShadersStore[s];if(n[2])for(var c=n[3].split(","),h=0;h<c.length;h+=2){var u=new RegExp(c[h],"g"),d=c[h+1];l=l.replace(u,d)}if(n[4]){var f=n[5];if(-1!==f.indexOf("..")){var p=f.split(".."),m=parseInt(p[0]),_=parseInt(p[1]),g=l.slice(0);l="",isNaN(_)&&(_=this._indexParameters[p[1]]);for(var v=m;v<_;v++)this._engine.supportsUniformBuffers||(g=g.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),l+=g.replace(/\{X\}/g,v.toString())+"\n"}else this._engine.supportsUniformBuffers||(l=l.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),l=l.replace(/\{X\}/g,f)}o=o.replace(n[0],l),n=r.exec(e)}t(o)},y.prototype._processPrecision=function(e){return-1===e.indexOf("precision highp float")?e=this._engine.getCaps().highPrecisionShaderSupported?"precision highp float;\n"+e:"precision mediump float;\n"+e:this._engine.getCaps().highPrecisionShaderSupported||(e=e.replace("precision highp float","precision mediump float")),e},y.prototype._rebuildProgram=function(e,t,i,r){var n=this;this._isReady=!1,this._vertexSourceCodeOverride=e,this._fragmentSourceCodeOverride=t,this.onError=function(e,t){r&&r(t)},this.onCompiled=function(){for(var e=n.getEngine().scenes,t=0;t<e.length;t++)e[t].markAllMaterialsAsDirty(b.Material.TextureDirtyFlag);i&&i(n._program)},this._fallbacks=null,this._prepareEffect()},y.prototype.getSpecificUniformLocations=function(e){return this._engine.getUniforms(this._program,e)},y.prototype._prepareEffect=function(){var t=this._attributesNames,e=this.defines,i=this._fallbacks;this._valueCache={};var r=this._program;try{var n,o=this._engine;if(this._vertexSourceCodeOverride&&this._fragmentSourceCodeOverride?this._program=o.createRawShaderProgram(this._vertexSourceCodeOverride,this._fragmentSourceCodeOverride,void 0,this._transformFeedbackVaryings):this._program=o.createShaderProgram(this._vertexSourceCode,this._fragmentSourceCode,e,void 0,this._transformFeedbackVaryings),this._program.__SPECTOR_rebuildProgram=this._rebuildProgram.bind(this),o.supportsUniformBuffers)for(var s in this._uniformBuffersNames)this.bindUniformBlock(s,this._uniformBuffersNames[s]);for(this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,t),n=0;n<this._samplers.length;n++){null==this.getUniform(this._samplers[n])&&(this._samplers.splice(n,1),n--)}o.bindSamplers(this),this._compilationError="",this._isReady=!0,this.onCompiled&&this.onCompiled(this),this.onCompileObservable.notifyObservers(this),this.onCompileObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh(),r&&this.getEngine()._deleteProgram(r)}catch(e){this._compilationError=e.message,b.Tools.Error("Unable to compile effect:"),b.Tools.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),b.Tools.Error("Attributes: "+t.map((function(e){return" "+e}))),b.Tools.Error("Error: "+this._compilationError),r&&(this._program=r,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),i&&i.isMoreFallbacks?(b.Tools.Error("Trying next fallback."),this.defines=i.reduce(this.defines,this),this._prepareEffect()):(this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())}},Object.defineProperty(y.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!0,configurable:!0}),y.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},y.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),this.getUniform(e),t)},y.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers.indexOf(e),this.getUniform(e),t)},y.prototype.setTextureArray=function(e,t){if(-1===this._samplers.indexOf(e+"Ex"))for(var i=this._samplers.indexOf(e),r=1;r<t.length;r++)this._samplers.splice(i+r,0,e+"Ex");this._engine.setTextureArray(this._samplers.indexOf(e),this.getUniform(e),t)},y.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},y.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(e),t)},y.prototype._cacheMatrix=function(e,t){var i=this._valueCache[e],r=t.updateFlag;return(void 0===i||i!==r)&&(this._valueCache[e]=r,!0)},y.prototype._cacheFloat2=function(e,t,i){var r=this._valueCache[e];if(!r)return r=[t,i],this._valueCache[e]=r,!0;var n=!1;return r[0]!==t&&(r[0]=t,n=!0),r[1]!==i&&(r[1]=i,n=!0),n},y.prototype._cacheFloat3=function(e,t,i,r){var n=this._valueCache[e];if(!n)return n=[t,i,r],this._valueCache[e]=n,!0;var o=!1;return n[0]!==t&&(n[0]=t,o=!0),n[1]!==i&&(n[1]=i,o=!0),n[2]!==r&&(n[2]=r,o=!0),o},y.prototype._cacheFloat4=function(e,t,i,r,n){var o=this._valueCache[e];if(!o)return o=[t,i,r,n],this._valueCache[e]=o,!0;var s=!1;return o[0]!==t&&(o[0]=t,s=!0),o[1]!==i&&(o[1]=i,s=!0),o[2]!==r&&(o[2]=r,s=!0),o[3]!==n&&(o[3]=n,s=!0),s},y.prototype.bindUniformBuffer=function(e,t){var i=this._uniformBuffersNames[t];void 0!==i&&y._baseCache[i]!==e&&(y._baseCache[i]=e,this._engine.bindUniformBufferBase(e,i))},y.prototype.bindUniformBlock=function(e,t){this._engine.bindUniformBlock(this._program,e,t)},y.prototype.setInt=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||(this._valueCache[e]=t,this._engine.setInt(this.getUniform(e),t)),this},y.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this.getUniform(e),t),this},y.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this.getUniform(e),t),this},y.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this.getUniform(e),t),this},y.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this.getUniform(e),t),this},y.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray(this.getUniform(e),t),this},y.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray2(this.getUniform(e),t),this},y.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray3(this.getUniform(e),t),this},y.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray4(this.getUniform(e),t),this},y.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this.getUniform(e),t),this},y.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this.getUniform(e),t),this},y.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this.getUniform(e),t),this},y.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this.getUniform(e),t),this},y.prototype.setMatrices=function(e,t){return t&&(this._valueCache[e]=null,this._engine.setMatrices(this.getUniform(e),t)),this},y.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&this._engine.setMatrix(this.getUniform(e),t),this},y.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this.getUniform(e),t),this},y.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this.getUniform(e),t),this},y.prototype.setFloat=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||(this._valueCache[e]=t,this._engine.setFloat(this.getUniform(e),t)),this},y.prototype.setBool=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t||(this._valueCache[e]=t,this._engine.setBool(this.getUniform(e),t?1:0)),this},y.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&this._engine.setFloat2(this.getUniform(e),t.x,t.y),this},y.prototype.setFloat2=function(e,t,i){return this._cacheFloat2(e,t,i)&&this._engine.setFloat2(this.getUniform(e),t,i),this},y.prototype.setVector3=function(e,t){return this._cacheFloat3(e,t.x,t.y,t.z)&&this._engine.setFloat3(this.getUniform(e),t.x,t.y,t.z),this},y.prototype.setFloat3=function(e,t,i,r){return this._cacheFloat3(e,t,i,r)&&this._engine.setFloat3(this.getUniform(e),t,i,r),this},y.prototype.setVector4=function(e,t){return this._cacheFloat4(e,t.x,t.y,t.z,t.w)&&this._engine.setFloat4(this.getUniform(e),t.x,t.y,t.z,t.w),this},y.prototype.setFloat4=function(e,t,i,r,n){return this._cacheFloat4(e,t,i,r,n)&&this._engine.setFloat4(this.getUniform(e),t,i,r,n),this},y.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&this._engine.setColor3(this.getUniform(e),t),this},y.prototype.setColor4=function(e,t,i){return this._cacheFloat4(e,t.r,t.g,t.b,i)&&this._engine.setColor4(this.getUniform(e),t,i),this},y.prototype.setDirectColor4=function(e,t){return this._cacheFloat4(e,t.r,t.g,t.b,t.a)&&this._engine.setDirectColor4(this.getUniform(e),t),this},y.RegisterShader=function(e,t,i){t&&(y.ShadersStore[e+"PixelShader"]=t),i&&(y.ShadersStore[e+"VertexShader"]=i)},y.ResetCache=function(){y._baseCache={}},y._uniqueIdSeed=0,y._baseCache={},y.ShadersStore={},y.IncludesShadersStore={},y})();b.Effect=i})($a||($a={})),(function(e){var t=(function(){function e(){}return e.KEYDOWN=1,e.KEYUP=2,e})();e.KeyboardEventTypes=t;var i=function(e,t){this.type=e,this.event=t},r=(function(r){function e(e,t){var i=r.call(this,e,t)||this;return i.type=e,i.event=t,i.skipOnPointerObservable=!1,i}return T(e,r),e})(e.KeyboardInfo=i);e.KeyboardInfoPre=r})($a||($a={})),(function(s){var e=(function(){function e(){}return e.POINTERDOWN=1,e.POINTERUP=2,e.POINTERMOVE=4,e.POINTERWHEEL=8,e.POINTERPICK=16,e.POINTERTAP=32,e.POINTERDOUBLETAP=64,e})();s.PointerEventTypes=e;var t=function(e,t){this.type=e,this.event=t},i=(function(o){function e(e,t,i,r){var n=o.call(this,e,t)||this;return n.ray=null,n.skipOnPointerObservable=!1,n.localPosition=new s.Vector2(i,r),n}return T(e,o),e})(s.PointerInfoBase=t);s.PointerInfoPre=i;var r=(function(n){function e(e,t,i){var r=n.call(this,e,t)||this;return r.pickInfo=i,r}return T(e,n),e})(t);s.PointerInfo=r})($a||($a={})),(function(f){f.ToGammaSpace=1/2.2,f.ToLinearSpace=2.2,f.Epsilon=.001;var t=(function(){function n(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.r=e,this.g=t,this.b=i}return n.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},n.prototype.getClassName=function(){return"Color3"},n.prototype.getHashCode=function(){var e=this.r||0;return e=397*(e=397*e^(this.g||0))^(this.b||0)},n.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},n.prototype.toColor4=function(e){return void 0===e&&(e=1),new i(this.r,this.g,this.b,e)},n.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},n.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},n.prototype.multiply=function(e){return new n(this.r*e.r,this.g*e.g,this.b*e.b)},n.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},n.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},n.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},n.prototype.scale=function(e){return new n(this.r*e,this.g*e,this.b*e)},n.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},n.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},n.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=f.Scalar.Clamp(this.r,e,t),i.g=f.Scalar.Clamp(this.g,e,t),i.b=f.Scalar.Clamp(this.b,e,t),this},n.prototype.add=function(e){return new n(this.r+e.r,this.g+e.g,this.b+e.b)},n.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},n.prototype.subtract=function(e){return new n(this.r-e.r,this.g-e.g,this.b-e.b)},n.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},n.prototype.clone=function(){return new n(this.r,this.g,this.b)},n.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},n.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},n.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},n.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,i=255*this.b|0;return"#"+f.Scalar.ToHex(e)+f.Scalar.ToHex(t)+f.Scalar.ToHex(i)},n.prototype.toLinearSpace=function(){var e=new n;return this.toLinearSpaceToRef(e),e},n.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,f.ToLinearSpace),e.g=Math.pow(this.g,f.ToLinearSpace),e.b=Math.pow(this.b,f.ToLinearSpace),this},n.prototype.toGammaSpace=function(){var e=new n;return this.toGammaSpaceToRef(e),e},n.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,f.ToGammaSpace),e.g=Math.pow(this.g,f.ToGammaSpace),e.b=Math.pow(this.b,f.ToGammaSpace),this},n.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new n(0,0,0);var t=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16);return n.FromInts(t,i,r)},n.FromArray=function(e,t){return void 0===t&&(t=0),new n(e[t],e[t+1],e[t+2])},n.FromInts=function(e,t,i){return new n(e/255,t/255,i/255)},n.Lerp=function(e,t,i){var r=new n(0,0,0);return n.LerpToRef(e,t,i,r),r},n.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i},n.Red=function(){return new n(1,0,0)},n.Green=function(){return new n(0,1,0)},n.Blue=function(){return new n(0,0,1)},n.Black=function(){return new n(0,0,0)},n.White=function(){return new n(1,1,1)},n.Purple=function(){return new n(.5,0,.5)},n.Magenta=function(){return new n(1,0,1)},n.Yellow=function(){return new n(1,1,0)},n.Gray=function(){return new n(.5,.5,.5)},n.Teal=function(){return new n(0,1,1)},n.Random=function(){return new n(Math.random(),Math.random(),Math.random())},n})();f.Color3=t;var i=(function(){function o(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.r=e,this.g=t,this.b=i,this.a=r}return o.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},o.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},o.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},o.prototype.add=function(e){return new o(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)},o.prototype.subtract=function(e){return new o(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)},o.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},o.prototype.scale=function(e){return new o(this.r*e,this.g*e,this.b*e,this.a*e)},o.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},o.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},o.prototype.clampToRef=function(e,t,i){return void 0===e&&(e=0),void 0===t&&(t=1),i.r=f.Scalar.Clamp(this.r,e,t),i.g=f.Scalar.Clamp(this.g,e,t),i.b=f.Scalar.Clamp(this.b,e,t),i.a=f.Scalar.Clamp(this.a,e,t),this},o.prototype.multiply=function(e){return new o(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)},o.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},o.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},o.prototype.getClassName=function(){return"Color4"},o.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)},o.prototype.clone=function(){return new o(this.r,this.g,this.b,this.a)},o.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},o.prototype.copyFromFloats=function(e,t,i,r){return this.r=e,this.g=t,this.b=i,this.a=r,this},o.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},o.prototype.toHexString=function(){var e=255*this.r|0,t=255*this.g|0,i=255*this.b|0,r=255*this.a|0;return"#"+f.Scalar.ToHex(e)+f.Scalar.ToHex(t)+f.Scalar.ToHex(i)+f.Scalar.ToHex(r)},o.prototype.toLinearSpace=function(){var e=new o;return this.toLinearSpaceToRef(e),e},o.prototype.toLinearSpaceToRef=function(e){return e.r=Math.pow(this.r,f.ToLinearSpace),e.g=Math.pow(this.g,f.ToLinearSpace),e.b=Math.pow(this.b,f.ToLinearSpace),e.a=this.a,this},o.prototype.toGammaSpace=function(){var e=new o;return this.toGammaSpaceToRef(e),e},o.prototype.toGammaSpaceToRef=function(e){return e.r=Math.pow(this.r,f.ToGammaSpace),e.g=Math.pow(this.g,f.ToGammaSpace),e.b=Math.pow(this.b,f.ToGammaSpace),e.a=this.a,this},o.FromHexString=function(e){if("#"!==e.substring(0,1)||9!==e.length)return new o(0,0,0,0);var t=parseInt(e.substring(1,3),16),i=parseInt(e.substring(3,5),16),r=parseInt(e.substring(5,7),16),n=parseInt(e.substring(7,9),16);return o.FromInts(t,i,r,n)},o.Lerp=function(e,t,i){var r=new o(0,0,0,0);return o.LerpToRef(e,t,i,r),r},o.LerpToRef=function(e,t,i,r){r.r=e.r+(t.r-e.r)*i,r.g=e.g+(t.g-e.g)*i,r.b=e.b+(t.b-e.b)*i,r.a=e.a+(t.a-e.a)*i},o.FromColor3=function(e,t){return void 0===t&&(t=1),new o(e.r,e.g,e.b,t)},o.FromArray=function(e,t){return void 0===t&&(t=0),new o(e[t],e[t+1],e[t+2],e[t+3])},o.FromInts=function(e,t,i,r){return new o(e/255,t/255,i/255,r/255)},o.CheckColors4=function(e,t){if(e.length===3*t){for(var i=[],r=0;r<e.length;r+=3){var n=r/3*4;i[n]=e[r],i[n+1]=e[r+1],i[n+2]=e[r+2],i[n+3]=1}return i}return e},o})();f.Color4=i;var p=(function(){function u(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.x=e,this.y=t}return u.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},u.prototype.getClassName=function(){return"Vector2"},u.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0)},u.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},u.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},u.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},u.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},u.prototype.set=function(e,t){return this.copyFromFloats(e,t)},u.prototype.add=function(e){return new u(this.x+e.x,this.y+e.y)},u.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},u.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},u.prototype.addVector3=function(e){return new u(this.x+e.x,this.y+e.y)},u.prototype.subtract=function(e){return new u(this.x-e.x,this.y-e.y)},u.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},u.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},u.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},u.prototype.multiply=function(e){return new u(this.x*e.x,this.y*e.y)},u.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},u.prototype.multiplyByFloats=function(e,t){return new u(this.x*e,this.y*t)},u.prototype.divide=function(e){return new u(this.x/e.x,this.y/e.y)},u.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},u.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},u.prototype.negate=function(){return new u(-this.x,-this.y)},u.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},u.prototype.scale=function(e){var t=new u(0,0);return this.scaleToRef(e,t),t},u.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,this},u.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,this},u.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},u.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=f.Epsilon),e&&f.Scalar.WithinEpsilon(this.x,e.x,t)&&f.Scalar.WithinEpsilon(this.y,e.y,t)},u.prototype.floor=function(){return new u(Math.floor(this.x),Math.floor(this.y))},u.prototype.fract=function(){return new u(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},u.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},u.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},u.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},u.prototype.clone=function(){return new u(this.x,this.y)},u.Zero=function(){return new u(0,0)},u.One=function(){return new u(1,1)},u.FromArray=function(e,t){return void 0===t&&(t=0),new u(e[t],e[t+1])},u.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},u.CatmullRom=function(e,t,i,r,n){var o=n*n,s=n*o;return new u(.5*(2*t.x+(-e.x+i.x)*n+(2*e.x-5*t.x+4*i.x-r.x)*o+(-e.x+3*t.x-3*i.x+r.x)*s),.5*(2*t.y+(-e.y+i.y)*n+(2*e.y-5*t.y+4*i.y-r.y)*o+(-e.y+3*t.y-3*i.y+r.y)*s))},u.Clamp=function(e,t,i){var r=e.x;r=(r=r>i.x?i.x:r)<t.x?t.x:r;var n=e.y;return new u(r,n=(n=n>i.y?i.y:n)<t.y?t.y:n)},u.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o,a=2*s-3*o+1,l=-2*s+3*o,c=s-2*o+n,h=s-o;return new u(e.x*a+i.x*l+t.x*c+r.x*h,e.y*a+i.y*l+t.y*c+r.y*h)},u.Lerp=function(e,t,i){return new u(e.x+(t.x-e.x)*i,e.y+(t.y-e.y)*i)},u.Dot=function(e,t){return e.x*t.x+e.y*t.y},u.Normalize=function(e){var t=e.clone();return t.normalize(),t},u.Minimize=function(e,t){return new u(e.x<t.x?e.x:t.x,e.y<t.y?e.y:t.y)},u.Maximize=function(e,t){return new u(e.x>t.x?e.x:t.x,e.y>t.y?e.y:t.y)},u.Transform=function(e,t){var i=u.Zero();return u.TransformToRef(e,t,i),i},u.TransformToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+t.m[13];i.x=r,i.y=n},u.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=n<0?-1:1,s=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return 0<s&&0<a&&s+a<2*n*o},u.Distance=function(e,t){return Math.sqrt(u.DistanceSquared(e,t))},u.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},u.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},u.DistanceOfPointFromSegment=function(e,t,i){var r=u.DistanceSquared(t,i);if(0===r)return u.Distance(e,t);var n=i.subtract(t),o=Math.max(0,Math.min(1,u.Dot(e.subtract(t),n)/r)),s=t.add(n.multiplyByFloats(o,o));return u.Distance(e,s)},u})();f.Vector2=p;var m=(function(){function d(e,t,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),this.x=e,this.y=t,this.z=i}return d.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},d.prototype.getClassName=function(){return"Vector3"},d.prototype.getHashCode=function(){var e=this.x||0;return e=397*(e=397*e^(this.y||0))^(this.z||0)},d.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},d.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},d.prototype.toQuaternion=function(){return f.Quaternion.RotationYawPitchRoll(this.x,this.y,this.z)},d.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},d.prototype.add=function(e){return new d(this.x+e.x,this.y+e.y,this.z+e.z)},d.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,this},d.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},d.prototype.subtract=function(e){return new d(this.x-e.x,this.y-e.y,this.z-e.z)},d.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,this},d.prototype.subtractFromFloats=function(e,t,i){return new d(this.x-e,this.y-t,this.z-i)},d.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,this},d.prototype.negate=function(){return new d(-this.x,-this.y,-this.z)},d.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},d.prototype.scale=function(e){return new d(this.x*e,this.y*e,this.z*e)},d.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,this},d.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,t.z+=this.z*e,this},d.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},d.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=f.Epsilon),e&&f.Scalar.WithinEpsilon(this.x,e.x,t)&&f.Scalar.WithinEpsilon(this.y,e.y,t)&&f.Scalar.WithinEpsilon(this.z,e.z,t)},d.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},d.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},d.prototype.multiply=function(e){return new d(this.x*e.x,this.y*e.y,this.z*e.z)},d.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,this},d.prototype.multiplyByFloats=function(e,t,i){return new d(this.x*e,this.y*t,this.z*i)},d.prototype.divide=function(e){return new d(this.x/e.x,this.y/e.y,this.z/e.z)},d.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,this},d.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},d.prototype.minimizeInPlace=function(e){return this.minimizeInPlaceFromFloats(e.x,e.y,e.z)},d.prototype.maximizeInPlace=function(e){return this.maximizeInPlaceFromFloats(e.x,e.y,e.z)},d.prototype.minimizeInPlaceFromFloats=function(e,t,i){return e<this.x&&(this.x=e),t<this.y&&(this.y=t),i<this.z&&(this.z=i),this},d.prototype.maximizeInPlaceFromFloats=function(e,t,i){return e>this.x&&(this.x=e),t>this.y&&(this.y=t),i>this.z&&(this.z=i),this},Object.defineProperty(d.prototype,"isNonUniform",{get:function(){var e=Math.abs(this.x),t=Math.abs(this.y);if(e!==t)return!0;var i=Math.abs(this.z);return e!==i||t!==i},enumerable:!0,configurable:!0}),d.prototype.floor=function(){return new d(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},d.prototype.fract=function(){return new d(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z))},d.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},d.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},d.prototype.normalize=function(){var e=this.length();if(0===e||1===e)return this;var t=1/e;return this.x*=t,this.y*=t,this.z*=t,this},d.prototype.normalizeToNew=function(){var e=new d(0,0,0);return this.normalizeToRef(e),e},d.prototype.normalizeToRef=function(e){var t=this.length();if(0===t||1===t)return e.set(this.x,this.y,this.z),e;var i=1/t;return this.scaleToRef(i,e),e},d.prototype.clone=function(){return new d(this.x,this.y,this.z)},d.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},d.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},d.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},d.GetClipFactor=function(e,t,i,r){var n=d.Dot(e,i)-r;return n/(n-(d.Dot(t,i)-r))},d.GetAngleBetweenVectors=function(e,t,i){var r=P.Vector3[1].copyFrom(e).normalize(),n=P.Vector3[2].copyFrom(t).normalize(),o=d.Dot(r,n),s=P.Vector3[3];return d.CrossToRef(r,n,s),0<d.Dot(s,i)?Math.acos(o):-Math.acos(o)},d.FromArray=function(e,t){return t||(t=0),new d(e[t],e[t+1],e[t+2])},d.FromFloatArray=function(e,t){return d.FromArray(e,t)},d.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},d.FromFloatArrayToRef=function(e,t,i){return d.FromArrayToRef(e,t,i)},d.FromFloatsToRef=function(e,t,i,r){r.x=e,r.y=t,r.z=i},d.Zero=function(){return new d(0,0,0)},d.One=function(){return new d(1,1,1)},d.Up=function(){return new d(0,1,0)},d.Down=function(){return new d(0,-1,0)},d.Forward=function(){return new d(0,0,1)},d.Backward=function(){return new d(0,0,-1)},d.Right=function(){return new d(1,0,0)},d.Left=function(){return new d(-1,0,0)},d.TransformCoordinates=function(e,t){var i=d.Zero();return d.TransformCoordinatesToRef(e,t,i),i},d.TransformCoordinatesToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8]+t.m[12],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9]+t.m[13],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10]+t.m[14],s=e.x*t.m[3]+e.y*t.m[7]+e.z*t.m[11]+t.m[15];i.x=r/s,i.y=n/s,i.z=o/s},d.TransformCoordinatesFromFloatsToRef=function(e,t,i,r,n){var o=e*r.m[0]+t*r.m[4]+i*r.m[8]+r.m[12],s=e*r.m[1]+t*r.m[5]+i*r.m[9]+r.m[13],a=e*r.m[2]+t*r.m[6]+i*r.m[10]+r.m[14],l=e*r.m[3]+t*r.m[7]+i*r.m[11]+r.m[15];n.x=o/l,n.y=s/l,n.z=a/l},d.TransformNormal=function(e,t){var i=d.Zero();return d.TransformNormalToRef(e,t,i),i},d.TransformNormalToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o},d.TransformNormalFromFloatsToRef=function(e,t,i,r,n){n.x=e*r.m[0]+t*r.m[4]+i*r.m[8],n.y=e*r.m[1]+t*r.m[5]+i*r.m[9],n.z=e*r.m[2]+t*r.m[6]+i*r.m[10]},d.CatmullRom=function(e,t,i,r,n){var o=n*n,s=n*o;return new d(.5*(2*t.x+(-e.x+i.x)*n+(2*e.x-5*t.x+4*i.x-r.x)*o+(-e.x+3*t.x-3*i.x+r.x)*s),.5*(2*t.y+(-e.y+i.y)*n+(2*e.y-5*t.y+4*i.y-r.y)*o+(-e.y+3*t.y-3*i.y+r.y)*s),.5*(2*t.z+(-e.z+i.z)*n+(2*e.z-5*t.z+4*i.z-r.z)*o+(-e.z+3*t.z-3*i.z+r.z)*s))},d.Clamp=function(e,t,i){var r=e.x;r=(r=r>i.x?i.x:r)<t.x?t.x:r;var n=e.y;n=(n=n>i.y?i.y:n)<t.y?t.y:n;var o=e.z;return new d(r,n,o=(o=o>i.z?i.z:o)<t.z?t.z:o)},d.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o,a=2*s-3*o+1,l=-2*s+3*o,c=s-2*o+n,h=s-o;return new d(e.x*a+i.x*l+t.x*c+r.x*h,e.y*a+i.y*l+t.y*c+r.y*h,e.z*a+i.z*l+t.z*c+r.z*h)},d.Lerp=function(e,t,i){var r=new d(0,0,0);return d.LerpToRef(e,t,i,r),r},d.LerpToRef=function(e,t,i,r){r.x=e.x+(t.x-e.x)*i,r.y=e.y+(t.y-e.y)*i,r.z=e.z+(t.z-e.z)*i},d.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},d.Cross=function(e,t){var i=d.Zero();return d.CrossToRef(e,t,i),i},d.CrossToRef=function(e,t,i){P.Vector3[0].x=e.y*t.z-e.z*t.y,P.Vector3[0].y=e.z*t.x-e.x*t.z,P.Vector3[0].z=e.x*t.y-e.y*t.x,i.copyFrom(P.Vector3[0])},d.Normalize=function(e){var t=d.Zero();return d.NormalizeToRef(e,t),t},d.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},d.Project=function(e,t,i,r){var n=r.width,o=r.height,s=r.x,a=r.y,l=d._viewportMatrixCache?d._viewportMatrixCache:d._viewportMatrixCache=new h;h.FromValuesToRef(n/2,0,0,0,0,-o/2,0,0,0,0,.5,0,s+n/2,o/2+a,.5,1,l);var c=P.Matrix[0];return t.multiplyToRef(i,c),c.multiplyToRef(l,c),d.TransformCoordinates(e,c)},d.UnprojectFromTransform=function(e,t,i,r,n){var o=P.Matrix[0];r.multiplyToRef(n,o),o.invert(),e.x=e.x/t*2-1,e.y=-(e.y/i*2-1);var s=d.TransformCoordinates(e,o),a=e.x*o.m[3]+e.y*o.m[7]+e.z*o.m[11]+o.m[15];return f.Scalar.WithinEpsilon(a,1)&&(s=s.scale(1/a)),s},d.Unproject=function(e,t,i,r,n,o){var s=d.Zero();return d.UnprojectToRef(e,t,i,r,n,o,s),s},d.UnprojectToRef=function(e,t,i,r,n,o,s){d.UnprojectFloatsToRef(e.x,e.y,e.z,t,i,r,n,o,s)},d.UnprojectFloatsToRef=function(e,t,i,r,n,o,s,a,l){var c=P.Matrix[0];o.multiplyToRef(s,c),c.multiplyToRef(a,c),c.invert();var h=P.Vector3[0];h.x=e/r*2-1,h.y=-(t/n*2-1),h.z=2*i-1,d.TransformCoordinatesToRef(h,c,l);var u=h.x*c.m[3]+h.y*c.m[7]+h.z*c.m[11]+c.m[15];f.Scalar.WithinEpsilon(u,1)&&l.scaleInPlace(1/u)},d.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},d.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},d.Distance=function(e,t){return Math.sqrt(d.DistanceSquared(e,t))},d.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z;return i*i+r*r+n*n},d.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},d.RotationFromAxis=function(e,t,i){var r=d.Zero();return d.RotationFromAxisToRef(e,t,i,r),r},d.RotationFromAxisToRef=function(e,t,i,r){var n=P.Quaternion[0];_.RotationQuaternionFromAxisToRef(e,t,i,n),n.toEulerAnglesToRef(r)},d})();f.Vector3=m;var r=(function(){function n(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return n.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},n.prototype.getClassName=function(){return"Vector4"},n.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)},n.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},n.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e[t+3]=this.w,this},n.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},n.prototype.add=function(e){return new n(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},n.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,t.z=this.z+e.z,t.w=this.w+e.w,this},n.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},n.prototype.subtract=function(e){return new n(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},n.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,t.z=this.z-e.z,t.w=this.w-e.w,this},n.prototype.subtractFromFloats=function(e,t,i,r){return new n(this.x-e,this.y-t,this.z-i,this.w-r)},n.prototype.subtractFromFloatsToRef=function(e,t,i,r,n){return n.x=this.x-e,n.y=this.y-t,n.z=this.z-i,n.w=this.w-r,this},n.prototype.negate=function(){return new n(-this.x,-this.y,-this.z,-this.w)},n.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},n.prototype.scale=function(e){return new n(this.x*e,this.y*e,this.z*e,this.w*e)},n.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},n.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},n.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},n.prototype.equalsWithEpsilon=function(e,t){return void 0===t&&(t=f.Epsilon),e&&f.Scalar.WithinEpsilon(this.x,e.x,t)&&f.Scalar.WithinEpsilon(this.y,e.y,t)&&f.Scalar.WithinEpsilon(this.z,e.z,t)&&f.Scalar.WithinEpsilon(this.w,e.w,t)},n.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},n.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},n.prototype.multiply=function(e){return new n(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},n.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,t.z=this.z*e.z,t.w=this.w*e.w,this},n.prototype.multiplyByFloats=function(e,t,i,r){return new n(this.x*e,this.y*t,this.z*i,this.w*r)},n.prototype.divide=function(e){return new n(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},n.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,t.z=this.z/e.z,t.w=this.w/e.w,this},n.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},n.prototype.minimizeInPlace=function(e){return e.x<this.x&&(this.x=e.x),e.y<this.y&&(this.y=e.y),e.z<this.z&&(this.z=e.z),e.w<this.w&&(this.w=e.w),this},n.prototype.maximizeInPlace=function(e){return e.x>this.x&&(this.x=e.x),e.y>this.y&&(this.y=e.y),e.z>this.z&&(this.z=e.z),e.w>this.w&&(this.w=e.w),this},n.prototype.floor=function(){return new n(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},n.prototype.fract=function(){return new n(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},n.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},n.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},n.prototype.toVector3=function(){return new m(this.x,this.y,this.z)},n.prototype.clone=function(){return new n(this.x,this.y,this.z,this.w)},n.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},n.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},n.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},n.FromArray=function(e,t){return t||(t=0),new n(e[t],e[t+1],e[t+2],e[t+3])},n.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},n.FromFloatArrayToRef=function(e,t,i){n.FromArrayToRef(e,t,i)},n.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},n.Zero=function(){return new n(0,0,0,0)},n.One=function(){return new n(1,1,1,1)},n.Normalize=function(e){var t=n.Zero();return n.NormalizeToRef(e,t),t},n.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},n.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},n.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},n.Distance=function(e,t){return Math.sqrt(n.DistanceSquared(e,t))},n.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y,n=e.z-t.z,o=e.w-t.w;return i*i+r*r+n*n+o*o},n.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},n.TransformNormal=function(e,t){var i=n.Zero();return n.TransformNormalToRef(e,t,i),i},n.TransformNormalToRef=function(e,t,i){var r=e.x*t.m[0]+e.y*t.m[4]+e.z*t.m[8],n=e.x*t.m[1]+e.y*t.m[5]+e.z*t.m[9],o=e.x*t.m[2]+e.y*t.m[6]+e.z*t.m[10];i.x=r,i.y=n,i.z=o,i.w=e.w},n.TransformNormalFromFloatsToRef=function(e,t,i,r,n,o){o.x=e*n.m[0]+t*n.m[4]+i*n.m[8],o.y=e*n.m[1]+t*n.m[5]+i*n.m[9],o.z=e*n.m[2]+t*n.m[6]+i*n.m[10],o.w=r},n})();f.Vector4=r;var e=(function(){function r(e,t){this.width=e,this.height=t}return r.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},r.prototype.getClassName=function(){return"Size"},r.prototype.getHashCode=function(){var e=this.width||0;return e=397*e^(this.height||0)},r.prototype.copyFrom=function(e){this.width=e.width,this.height=e.height},r.prototype.copyFromFloats=function(e,t){return this.width=e,this.height=t,this},r.prototype.set=function(e,t){return this.copyFromFloats(e,t)},r.prototype.multiplyByFloats=function(e,t){return new r(this.width*e,this.height*t)},r.prototype.clone=function(){return new r(this.width,this.height)},r.prototype.equals=function(e){return!!e&&(this.width===e.width&&this.height===e.height)},Object.defineProperty(r.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),r.Zero=function(){return new r(0,0)},r.prototype.add=function(e){return new r(this.width+e.width,this.height+e.height)},r.prototype.subtract=function(e){return new r(this.width-e.width,this.height-e.height)},r.Lerp=function(e,t,i){return new r(e.width+(t.width-e.width)*i,e.height+(t.height-e.height)*i)},r})();f.Size=e;var _=(function(){function u(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return u.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},u.prototype.getClassName=function(){return"Quaternion"},u.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)},u.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},u.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},u.prototype.clone=function(){return new u(this.x,this.y,this.z,this.w)},u.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},u.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},u.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},u.prototype.add=function(e){return new u(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},u.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},u.prototype.subtract=function(e){return new u(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},u.prototype.scale=function(e){return new u(this.x*e,this.y*e,this.z*e,this.w*e)},u.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},u.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},u.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},u.prototype.multiply=function(e){var t=new u(0,0,0,1);return this.multiplyToRef(e,t),t},u.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,o),this},u.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},u.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},u.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},u.prototype.conjugate=function(){return new u(-this.x,-this.y,-this.z,this.w)},u.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},u.prototype.normalize=function(){var e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},u.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=m.Zero();return this.toEulerAnglesToRef(t,e),t},u.prototype.toEulerAnglesToRef=function(e,t){void 0===t&&(t="YZX");var i=this.z,r=this.x,n=this.y,o=this.w,s=o*o,a=i*i,l=r*r,c=n*n,h=n*i-r*o;return h<-.4999999?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):.4999999<h?(e.y=2*Math.atan2(n,o),e.x=-Math.PI/2,e.z=0):(e.z=Math.atan2(2*(r*n+i*o),-a-l+c+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-l-c+s)),this},u.prototype.toRotationMatrix=function(e){var t=this.x*this.x,i=this.y*this.y,r=this.z*this.z,n=this.x*this.y,o=this.z*this.w,s=this.z*this.x,a=this.y*this.w,l=this.y*this.z,c=this.x*this.w;return e.m[0]=1-2*(i+r),e.m[1]=2*(n+o),e.m[2]=2*(s-a),e.m[3]=0,e.m[4]=2*(n-o),e.m[5]=1-2*(r+t),e.m[6]=2*(l+c),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(l-c),e.m[10]=1-2*(i+t),e.m[11]=0,e.m[12]=0,e.m[13]=0,e.m[14]=0,e.m[15]=1,e._markAsUpdated(),this},u.prototype.fromRotationMatrix=function(e){return u.FromRotationMatrixToRef(e,this),this},u.FromRotationMatrix=function(e){var t=new u;return u.FromRotationMatrixToRef(e,t),t},u.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],l=r[5],c=r[9],h=r[2],u=r[6],d=r[10],f=n+l+d;0<f?(i=.5/Math.sqrt(f+1),t.w=.25/i,t.x=(u-c)*i,t.y=(s-h)*i,t.z=(a-o)*i):l<n&&d<n?(i=2*Math.sqrt(1+n-l-d),t.w=(u-c)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+h)/i):d<l?(i=2*Math.sqrt(1+l-n-d),t.w=(s-h)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(c+u)/i):(i=2*Math.sqrt(1+d-n-l),t.w=(a-o)/i,t.x=(s+h)/i,t.y=(c+u)/i,t.z=.25*i)},u.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},u.AreClose=function(e,t){return 0<=u.Dot(e,t)},u.Zero=function(){return new u(0,0,0,0)},u.Inverse=function(e){return new u(-e.x,-e.y,-e.z,e.w)},u.Identity=function(){return new u(0,0,0,1)},u.IsIdentity=function(e){return e&&0===e.x&&0===e.y&&0===e.z&&1===e.w},u.RotationAxis=function(e,t){return u.RotationAxisToRef(e,t,new u)},u.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},u.FromArray=function(e,t){return t||(t=0),new u(e[t],e[t+1],e[t+2],e[t+3])},u.RotationYawPitchRoll=function(e,t,i){var r=new u;return u.RotationYawPitchRollToRef(e,t,i,r),r},u.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),l=Math.cos(n),c=Math.sin(o),h=Math.cos(o),u=Math.sin(s),d=Math.cos(s);r.x=d*c*l+u*h*a,r.y=u*h*l-d*c*a,r.z=d*h*a-u*c*l,r.w=d*h*l+u*c*a},u.RotationAlphaBetaGamma=function(e,t,i){var r=new u;return u.RotationAlphaBetaGammaToRef(e,t,i,r),r},u.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},u.RotationQuaternionFromAxis=function(e,t,i){var r=new u(0,0,0,0);return u.RotationQuaternionFromAxisToRef(e,t,i,r),r},u.RotationQuaternionFromAxisToRef=function(e,t,i,r){var n=P.Matrix[0];h.FromXYZAxesToRef(e.normalize(),t.normalize(),i.normalize(),n),u.FromRotationMatrixToRef(n,r)},u.Slerp=function(e,t,i){var r=u.Identity();return u.SlerpToRef(e,t,i,r),r},u.SlerpToRef=function(e,t,i,r){var n,o,s=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,a=!1;if(s<0&&(a=!0,s=-s),.999999<s)o=1-i,n=a?-i:i;else{var l=Math.acos(s),c=1/Math.sin(l);o=Math.sin((1-i)*l)*c,n=a?-Math.sin(i*l)*c:Math.sin(i*l)*c}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},u.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o,a=2*s-3*o+1,l=-2*s+3*o,c=s-2*o+n,h=s-o;return new u(e.x*a+i.x*l+t.x*c+r.x*h,e.y*a+i.y*l+t.y*c+r.y*h,e.z*a+i.z*l+t.z*c+r.z*h,e.w*a+i.w*l+t.w*c+r.w*h)},u})();f.Quaternion=_;var h=(function(){function g(){this._isIdentity=!1,this._isIdentityDirty=!0,this.m=new Float32Array(16),this._markAsUpdated()}return g.prototype._markAsUpdated=function(){this.updateFlag=g._updateFlagSeed++,this._isIdentityDirty=!0},g.prototype.isIdentity=function(e){return void 0===e&&(e=!1),this._isIdentityDirty&&(this._isIdentityDirty=!1,1!==this.m[0]||1!==this.m[5]||1!==this.m[15]?this._isIdentity=!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[11]||0!==this.m[12]||0!==this.m[13]||0!==this.m[14]?this._isIdentity=!1:this._isIdentity=!0,e||1===this.m[10]||(this._isIdentity=!1)),this._isIdentity},g.prototype.determinant=function(){var e=this.m[10]*this.m[15]-this.m[11]*this.m[14],t=this.m[9]*this.m[15]-this.m[11]*this.m[13],i=this.m[9]*this.m[14]-this.m[10]*this.m[13],r=this.m[8]*this.m[15]-this.m[11]*this.m[12],n=this.m[8]*this.m[14]-this.m[10]*this.m[12],o=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*e-this.m[6]*t+this.m[7]*i)-this.m[1]*(this.m[4]*e-this.m[6]*r+this.m[7]*n)+this.m[2]*(this.m[4]*t-this.m[5]*r+this.m[7]*o)-this.m[3]*(this.m[4]*i-this.m[5]*n+this.m[6]*o)},g.prototype.toArray=function(){return this.m},g.prototype.asArray=function(){return this.toArray()},g.prototype.invert=function(){return this.invertToRef(this),this},g.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this._markAsUpdated(),this},g.prototype.add=function(e){var t=new g;return this.addToRef(e,t),t},g.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return t._markAsUpdated(),this},g.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this._markAsUpdated(),this},g.prototype.invertToRef=function(e){var t=this.m[0],i=this.m[1],r=this.m[2],n=this.m[3],o=this.m[4],s=this.m[5],a=this.m[6],l=this.m[7],c=this.m[8],h=this.m[9],u=this.m[10],d=this.m[11],f=this.m[12],p=this.m[13],m=this.m[14],_=this.m[15],g=u*_-d*m,v=h*_-d*p,y=h*m-u*p,b=c*_-d*f,T=c*m-u*f,x=c*p-h*f,E=s*g-a*v+l*y,A=-(o*g-a*b+l*T),P=o*v-s*b+l*x,S=-(o*y-s*T+a*x),R=1/(t*E+i*A+r*P+n*S),M=a*_-l*m,C=s*_-l*p,O=s*m-a*p,D=o*_-l*f,I=o*m-a*f,w=o*p-s*f,L=a*d-l*u,F=s*d-l*h,B=s*u-a*h,N=o*d-l*c,V=o*u-a*c,U=o*h-s*c;return e.m[0]=E*R,e.m[4]=A*R,e.m[8]=P*R,e.m[12]=S*R,e.m[1]=-(i*g-r*v+n*y)*R,e.m[5]=(t*g-r*b+n*T)*R,e.m[9]=-(t*v-i*b+n*x)*R,e.m[13]=(t*y-i*T+r*x)*R,e.m[2]=(i*M-r*C+n*O)*R,e.m[6]=-(t*M-r*D+n*I)*R,e.m[10]=(t*C-i*D+n*w)*R,e.m[14]=-(t*O-i*I+r*w)*R,e.m[3]=-(i*L-r*F+n*B)*R,e.m[7]=(t*L-r*N+n*V)*R,e.m[11]=-(t*F-i*N+n*U)*R,e.m[15]=(t*B-i*V+r*U)*R,e._markAsUpdated(),this},g.prototype.setTranslationFromFloats=function(e,t,i){return this.m[12]=e,this.m[13]=t,this.m[14]=i,this._markAsUpdated(),this},g.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this._markAsUpdated(),this},g.prototype.getTranslation=function(){return new m(this.m[12],this.m[13],this.m[14])},g.prototype.getTranslationToRef=function(e){return e.x=this.m[12],e.y=this.m[13],e.z=this.m[14],this},g.prototype.removeRotationAndScaling=function(){return this.setRowFromFloats(0,1,0,0,0),this.setRowFromFloats(1,0,1,0,0),this.setRowFromFloats(2,0,0,1,0),this},g.prototype.multiply=function(e){var t=new g;return this.multiplyToRef(e,t),t},g.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this._markAsUpdated(),this},g.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},g.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),t._markAsUpdated(),this},g.prototype.multiplyToArray=function(e,t,i){var r=this.m[0],n=this.m[1],o=this.m[2],s=this.m[3],a=this.m[4],l=this.m[5],c=this.m[6],h=this.m[7],u=this.m[8],d=this.m[9],f=this.m[10],p=this.m[11],m=this.m[12],_=this.m[13],g=this.m[14],v=this.m[15],y=e.m[0],b=e.m[1],T=e.m[2],x=e.m[3],E=e.m[4],A=e.m[5],P=e.m[6],S=e.m[7],R=e.m[8],M=e.m[9],C=e.m[10],O=e.m[11],D=e.m[12],I=e.m[13],w=e.m[14],L=e.m[15];return t[i]=r*y+n*E+o*R+s*D,t[i+1]=r*b+n*A+o*M+s*I,t[i+2]=r*T+n*P+o*C+s*w,t[i+3]=r*x+n*S+o*O+s*L,t[i+4]=a*y+l*E+c*R+h*D,t[i+5]=a*b+l*A+c*M+h*I,t[i+6]=a*T+l*P+c*C+h*w,t[i+7]=a*x+l*S+c*O+h*L,t[i+8]=u*y+d*E+f*R+p*D,t[i+9]=u*b+d*A+f*M+p*I,t[i+10]=u*T+d*P+f*C+p*w,t[i+11]=u*x+d*S+f*O+p*L,t[i+12]=m*y+_*E+g*R+v*D,t[i+13]=m*b+_*A+g*M+v*I,t[i+14]=m*T+_*P+g*C+v*w,t[i+15]=m*x+_*S+g*O+v*L,this},g.prototype.equals=function(e){return e&&this.m[0]===e.m[0]&&this.m[1]===e.m[1]&&this.m[2]===e.m[2]&&this.m[3]===e.m[3]&&this.m[4]===e.m[4]&&this.m[5]===e.m[5]&&this.m[6]===e.m[6]&&this.m[7]===e.m[7]&&this.m[8]===e.m[8]&&this.m[9]===e.m[9]&&this.m[10]===e.m[10]&&this.m[11]===e.m[11]&&this.m[12]===e.m[12]&&this.m[13]===e.m[13]&&this.m[14]===e.m[14]&&this.m[15]===e.m[15]},g.prototype.clone=function(){return g.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},g.prototype.getClassName=function(){return"Matrix"},g.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},g.prototype.decompose=function(e,t,i){return i&&(i.x=this.m[12],i.y=this.m[13],i.z=this.m[14]),(e=e||P.Vector3[0]).x=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),e.y=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),e.z=Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),this.determinant()<=0&&(e.y*=-1),0===e.x||0===e.y||0===e.z?(t&&(t.x=0,t.y=0,t.z=0,t.w=1),!1):(t&&(g.FromValuesToRef(this.m[0]/e.x,this.m[1]/e.x,this.m[2]/e.x,0,this.m[4]/e.y,this.m[5]/e.y,this.m[6]/e.y,0,this.m[8]/e.z,this.m[9]/e.z,this.m[10]/e.z,0,0,0,0,1,P.Matrix[0]),_.FromRotationMatrixToRef(P.Matrix[0],t)),!0)},g.prototype.getRow=function(e){if(e<0||3<e)return null;var t=4*e;return new r(this.m[t+0],this.m[t+1],this.m[t+2],this.m[t+3])},g.prototype.setRow=function(e,t){if(e<0||3<e)return this;var i=4*e;return this.m[i+0]=t.x,this.m[i+1]=t.y,this.m[i+2]=t.z,this.m[i+3]=t.w,this._markAsUpdated(),this},g.prototype.transpose=function(){return g.Transpose(this)},g.prototype.transposeToRef=function(e){return g.TransposeToRef(this,e),this},g.prototype.setRowFromFloats=function(e,t,i,r,n){if(e<0||3<e)return this;var o=4*e;return this.m[o+0]=t,this.m[o+1]=i,this.m[o+2]=r,this.m[o+3]=n,this._markAsUpdated(),this},g.prototype.scale=function(e){var t=new g;return this.scaleToRef(e,t),t},g.prototype.scaleToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]*e;return t._markAsUpdated(),this},g.prototype.scaleAndAddToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]+=this.m[i]*e;return t._markAsUpdated(),this},g.prototype.toNormalMatrix=function(e){this.invertToRef(e),e.transpose();var t=e.m;g.FromValuesToRef(t[0],t[1],t[2],0,t[4],t[5],t[6],0,t[8],t[9],t[10],0,0,0,0,1,e)},g.prototype.getRotationMatrix=function(){var e=g.Identity();return this.getRotationMatrixToRef(e),e},g.prototype.getRotationMatrixToRef=function(e){var t=this.m,i=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]),r=Math.sqrt(t[4]*t[4]+t[5]*t[5]+t[6]*t[6]),n=Math.sqrt(t[8]*t[8]+t[9]*t[9]+t[10]*t[10]);return this.determinant()<=0&&(r*=-1),0===i||0===r||0===n?g.IdentityToRef(e):g.FromValuesToRef(t[0]/i,t[1]/i,t[2]/i,0,t[4]/r,t[5]/r,t[6]/r,0,t[8]/n,t[9]/n,t[10]/n,0,0,0,0,1,e),this},g.FromArray=function(e,t){var i=new g;return t||(t=0),g.FromArrayToRef(e,t,i),i},g.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t];i._markAsUpdated()},g.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i;r._markAsUpdated()},g.FromValuesToRef=function(e,t,i,r,n,o,s,a,l,c,h,u,d,f,p,m,_){_.m[0]=e,_.m[1]=t,_.m[2]=i,_.m[3]=r,_.m[4]=n,_.m[5]=o,_.m[6]=s,_.m[7]=a,_.m[8]=l,_.m[9]=c,_.m[10]=h,_.m[11]=u,_.m[12]=d,_.m[13]=f,_.m[14]=p,_.m[15]=m,_._markAsUpdated()},Object.defineProperty(g,"IdentityReadOnly",{get:function(){return g._identityReadOnly},enumerable:!0,configurable:!0}),g.FromValues=function(e,t,i,r,n,o,s,a,l,c,h,u,d,f,p,m){var _=new g;return _.m[0]=e,_.m[1]=t,_.m[2]=i,_.m[3]=r,_.m[4]=n,_.m[5]=o,_.m[6]=s,_.m[7]=a,_.m[8]=l,_.m[9]=c,_.m[10]=h,_.m[11]=u,_.m[12]=d,_.m[13]=f,_.m[14]=p,_.m[15]=m,_},g.Compose=function(e,t,i){var r=g.Identity();return g.ComposeToRef(e,t,i,r),r},g.ComposeToRef=function(e,t,i,r){g.FromValuesToRef(e.x,0,0,0,0,e.y,0,0,0,0,e.z,0,0,0,0,1,P.Matrix[1]),t.toRotationMatrix(P.Matrix[0]),P.Matrix[1].multiplyToRef(P.Matrix[0],r),r.setTranslation(i)},g.Identity=function(){return g.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},g.IdentityToRef=function(e){g.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,e)},g.Zero=function(){return g.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},g.RotationX=function(e){var t=new g;return g.RotationXToRef(e,t),t},g.Invert=function(e){var t=new g;return e.invertToRef(t),t},g.RotationXToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[0]=1,t.m[15]=1,t.m[5]=r,t.m[10]=r,t.m[9]=-i,t.m[6]=i,t.m[1]=0,t.m[2]=0,t.m[3]=0,t.m[4]=0,t.m[7]=0,t.m[8]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},g.RotationY=function(e){var t=new g;return g.RotationYToRef(e,t),t},g.RotationYToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[5]=1,t.m[15]=1,t.m[0]=r,t.m[2]=-i,t.m[8]=i,t.m[10]=r,t.m[1]=0,t.m[3]=0,t.m[4]=0,t.m[6]=0,t.m[7]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},g.RotationZ=function(e){var t=new g;return g.RotationZToRef(e,t),t},g.RotationZToRef=function(e,t){var i=Math.sin(e),r=Math.cos(e);t.m[10]=1,t.m[15]=1,t.m[0]=r,t.m[1]=i,t.m[4]=-i,t.m[5]=r,t.m[2]=0,t.m[3]=0,t.m[6]=0,t.m[7]=0,t.m[8]=0,t.m[9]=0,t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t._markAsUpdated()},g.RotationAxis=function(e,t){var i=g.Zero();return g.RotationAxisToRef(e,t,i),i},g.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize(),i.m[0]=e.x*e.x*o+n,i.m[1]=e.x*e.y*o-e.z*r,i.m[2]=e.x*e.z*o+e.y*r,i.m[3]=0,i.m[4]=e.y*e.x*o+e.z*r,i.m[5]=e.y*e.y*o+n,i.m[6]=e.y*e.z*o-e.x*r,i.m[7]=0,i.m[8]=e.z*e.x*o-e.y*r,i.m[9]=e.z*e.y*o+e.x*r,i.m[10]=e.z*e.z*o+n,i.m[11]=0,i.m[15]=1,i._markAsUpdated()},g.RotationYawPitchRoll=function(e,t,i){var r=new g;return g.RotationYawPitchRollToRef(e,t,i,r),r},g.RotationYawPitchRollToRef=function(e,t,i,r){_.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},g.Scaling=function(e,t,i){var r=g.Zero();return g.ScalingToRef(e,t,i,r),r},g.ScalingToRef=function(e,t,i,r){r.m[0]=e,r.m[1]=0,r.m[2]=0,r.m[3]=0,r.m[4]=0,r.m[5]=t,r.m[6]=0,r.m[7]=0,r.m[8]=0,r.m[9]=0,r.m[10]=i,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1,r._markAsUpdated()},g.Translation=function(e,t,i){var r=g.Identity();return g.TranslationToRef(e,t,i,r),r},g.TranslationToRef=function(e,t,i,r){g.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,e,t,i,1,r)},g.Lerp=function(e,t,i){var r=g.Zero();return g.LerpToRef(e,t,i,r),r},g.LerpToRef=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e.m[n]*(1-i)+t.m[n]*i;r._markAsUpdated()},g.DecomposeLerp=function(e,t,i){var r=g.Zero();return g.DecomposeLerpToRef(e,t,i,r),r},g.DecomposeLerpToRef=function(e,t,i,r){var n=P.Vector3[0],o=P.Quaternion[0],s=P.Vector3[1];e.decompose(n,o,s);var a=P.Vector3[2],l=P.Quaternion[1],c=P.Vector3[3];t.decompose(a,l,c);var h=P.Vector3[4];m.LerpToRef(n,a,i,h);var u=P.Quaternion[2];_.SlerpToRef(o,l,i,u);var d=P.Vector3[5];m.LerpToRef(s,c,i,d),g.ComposeToRef(h,u,d,r)},g.LookAtLH=function(e,t,i){var r=g.Zero();return g.LookAtLHToRef(e,t,i,r),r},g.LookAtLHToRef=function(e,t,i,r){t.subtractToRef(e,this._zAxis),this._zAxis.normalize(),m.CrossToRef(i,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),m.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var n=-m.Dot(this._xAxis,e),o=-m.Dot(this._yAxis,e),s=-m.Dot(this._zAxis,e);return g.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,n,o,s,1,r)},g.LookAtRH=function(e,t,i){var r=g.Zero();return g.LookAtRHToRef(e,t,i,r),r},g.LookAtRHToRef=function(e,t,i,r){e.subtractToRef(t,this._zAxis),this._zAxis.normalize(),m.CrossToRef(i,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),m.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var n=-m.Dot(this._xAxis,e),o=-m.Dot(this._yAxis,e),s=-m.Dot(this._zAxis,e);return g.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,n,o,s,1,r)},g.OrthoLH=function(e,t,i,r){var n=g.Zero();return g.OrthoLHToRef(e,t,i,r,n),n},g.OrthoLHToRef=function(e,t,i,r,n){g.FromValuesToRef(2/e,0,0,0,0,2/t,0,0,0,0,2/(r-i),0,0,0,-(r+i)/(r-i),1,n)},g.OrthoOffCenterLH=function(e,t,i,r,n,o){var s=g.Zero();return g.OrthoOffCenterLHToRef(e,t,i,r,n,o,s),s},g.OrthoOffCenterLHToRef=function(e,t,i,r,n,o,s){g.FromValuesToRef(2/(t-e),0,0,0,0,2/(r-i),0,0,0,0,2/(o-n),0,(e+t)/(e-t),(r+i)/(i-r),-(o+n)/(o-n),1,s)},g.OrthoOffCenterRH=function(e,t,i,r,n,o){var s=g.Zero();return g.OrthoOffCenterRHToRef(e,t,i,r,n,o,s),s},g.OrthoOffCenterRHToRef=function(e,t,i,r,n,o,s){g.OrthoOffCenterLHToRef(e,t,i,r,n,o,s),s.m[10]*=-1},g.PerspectiveLH=function(e,t,i,r){var n=g.Zero();return g.FromValuesToRef(2*i/e,0,0,0,0,2*i/t,0,0,0,0,(r+i)/(r-i),1,0,0,-2*r*i/(r-i),0,n),n},g.PerspectiveFovLH=function(e,t,i,r){var n=g.Zero();return g.PerspectiveFovLHToRef(e,t,i,r,n),n},g.PerspectiveFovLHToRef=function(e,t,i,r,n,o){void 0===o&&(o=!0);var s=i,a=r,l=1/Math.tan(.5*e);g.FromValuesToRef(o?l/t:l,0,0,0,0,o?l:l*t,0,0,0,0,(a+s)/(a-s),1,0,0,-2*a*s/(a-s),0,n)},g.PerspectiveFovRH=function(e,t,i,r){var n=g.Zero();return g.PerspectiveFovRHToRef(e,t,i,r,n),n},g.PerspectiveFovRHToRef=function(e,t,i,r,n,o){void 0===o&&(o=!0);var s=i,a=r,l=1/Math.tan(.5*e);g.FromValuesToRef(o?l/t:l,0,0,0,0,o?l:l*t,0,0,0,0,-(a+s)/(a-s),-1,0,0,-2*a*s/(a-s),0,n)},g.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!1);var o=n?-1:1,s=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),l=Math.tan(e.leftDegrees*Math.PI/180),c=Math.tan(e.rightDegrees*Math.PI/180),h=2/(l+c),u=2/(s+a);r.m[0]=h,r.m[1]=r.m[2]=r.m[3]=r.m[4]=0,r.m[5]=u,r.m[6]=r.m[7]=0,r.m[8]=(l-c)*h*.5,r.m[9]=-(s-a)*u*.5,r.m[10]=-i/(t-i),r.m[11]=1*o,r.m[12]=r.m[13]=r.m[15]=0,r.m[14]=-2*i*t/(i-t),r._markAsUpdated()},g.GetFinalMatrix=function(e,t,i,r,n,o){var s=e.width,a=e.height,l=e.x,c=e.y,h=g.FromValues(s/2,0,0,0,0,-a/2,0,0,0,0,o-n,0,l+s/2,a/2+c,n,1);return t.multiply(i).multiply(r).multiply(h)},g.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},g.GetAsMatrix3x3=function(e){return new Float32Array([e.m[0],e.m[1],e.m[2],e.m[4],e.m[5],e.m[6],e.m[8],e.m[9],e.m[10]])},g.Transpose=function(e){var t=new g;return g.TransposeToRef(e,t),t},g.TransposeToRef=function(e,t){t.m[0]=e.m[0],t.m[1]=e.m[4],t.m[2]=e.m[8],t.m[3]=e.m[12],t.m[4]=e.m[1],t.m[5]=e.m[5],t.m[6]=e.m[9],t.m[7]=e.m[13],t.m[8]=e.m[2],t.m[9]=e.m[6],t.m[10]=e.m[10],t.m[11]=e.m[14],t.m[12]=e.m[3],t.m[13]=e.m[7],t.m[14]=e.m[11],t.m[15]=e.m[15]},g.Reflection=function(e){var t=new g;return g.ReflectionToRef(e,t),t},g.ReflectionToRef=function(e,t){e.normalize();var i=e.normal.x,r=e.normal.y,n=e.normal.z,o=-2*i,s=-2*r,a=-2*n;t.m[0]=o*i+1,t.m[1]=s*i,t.m[2]=a*i,t.m[3]=0,t.m[4]=o*r,t.m[5]=s*r+1,t.m[6]=a*r,t.m[7]=0,t.m[8]=o*n,t.m[9]=s*n,t.m[10]=a*n+1,t.m[11]=0,t.m[12]=o*e.d,t.m[13]=s*e.d,t.m[14]=a*e.d,t.m[15]=1,t._markAsUpdated()},g.FromXYZAxesToRef=function(e,t,i,r){r.m[0]=e.x,r.m[1]=e.y,r.m[2]=e.z,r.m[3]=0,r.m[4]=t.x,r.m[5]=t.y,r.m[6]=t.z,r.m[7]=0,r.m[8]=i.x,r.m[9]=i.y,r.m[10]=i.z,r.m[11]=0,r.m[12]=0,r.m[13]=0,r.m[14]=0,r.m[15]=1,r._markAsUpdated()},g.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,l=e.y*e.w,c=e.y*e.z,h=e.x*e.w;t.m[0]=1-2*(r+n),t.m[1]=2*(o+s),t.m[2]=2*(a-l),t.m[3]=0,t.m[4]=2*(o-s),t.m[5]=1-2*(n+i),t.m[6]=2*(c+h),t.m[7]=0,t.m[8]=2*(a+l),t.m[9]=2*(c-h),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,t._markAsUpdated()},g._tempQuaternion=new _,g._xAxis=m.Zero(),g._yAxis=m.Zero(),g._zAxis=m.Zero(),g._updateFlagSeed=0,g._identityReadOnly=g.Identity(),g})();f.Matrix=h;var n=(function(){function s(e,t,i,r){this.normal=new m(e,t,i),this.d=r}return s.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},s.prototype.clone=function(){return new s(this.normal.x,this.normal.y,this.normal.z,this.d)},s.prototype.getClassName=function(){return"Plane"},s.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(this.d||0)},s.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},s.prototype.transform=function(e){var t=h.Transpose(e),i=this.normal.x,r=this.normal.y,n=this.normal.z,o=this.d;return new s(i*t.m[0]+r*t.m[1]+n*t.m[2]+o*t.m[3],i*t.m[4]+r*t.m[5]+n*t.m[6]+o*t.m[7],i*t.m[8]+r*t.m[9]+n*t.m[10]+o*t.m[11],i*t.m[12]+r*t.m[13]+n*t.m[14]+o*t.m[15])},s.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},s.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,l=i.y-e.y,c=i.z-e.z,h=o*c-s*l,u=s*a-n*c,d=n*l-o*a,f=Math.sqrt(h*h+u*u+d*d);return r=0!==f?1/f:0,this.normal.x=h*r,this.normal.y=u*r,this.normal.z=d*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},s.prototype.isFrontFacingTo=function(e,t){return m.Dot(this.normal,e)<=t},s.prototype.signedDistanceTo=function(e){return m.Dot(e,this.normal)+this.d},s.FromArray=function(e){return new s(e[0],e[1],e[2],e[3])},s.FromPoints=function(e,t,i){var r=new s(0,0,0,0);return r.copyFromPoints(e,t,i),r},s.FromPositionAndNormal=function(e,t){var i=new s(0,0,0,0);return t.normalize(),i.normal=t,i.d=-(t.x*e.x+t.y*e.y+t.z*e.z),i},s.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return m.Dot(i,t)+r},s})();f.Plane=n;var o=(function(){function n(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return n.prototype.toGlobal=function(e,t){if(e.getRenderWidth){var i=e;return this.toGlobal(i.getRenderWidth(),i.getRenderHeight())}var r=e;return new n(this.x*r,this.y*t,this.width*r,this.height*t)},n.prototype.clone=function(){return new n(this.x,this.y,this.width,this.height)},n})();f.Viewport=o;var s,a=(function(){function r(){}return r.GetPlanes=function(e){for(var t=[],i=0;i<6;i++)t.push(new n(0,0,0,0));return r.GetPlanesToRef(e,t),t},r.GetNearPlaneToRef=function(e,t){t.normal.x=e.m[3]+e.m[2],t.normal.y=e.m[7]+e.m[6],t.normal.z=e.m[11]+e.m[10],t.d=e.m[15]+e.m[14],t.normalize()},r.GetFarPlaneToRef=function(e,t){t.normal.x=e.m[3]-e.m[2],t.normal.y=e.m[7]-e.m[6],t.normal.z=e.m[11]-e.m[10],t.d=e.m[15]-e.m[14],t.normalize()},r.GetLeftPlaneToRef=function(e,t){t.normal.x=e.m[3]+e.m[0],t.normal.y=e.m[7]+e.m[4],t.normal.z=e.m[11]+e.m[8],t.d=e.m[15]+e.m[12],t.normalize()},r.GetRightPlaneToRef=function(e,t){t.normal.x=e.m[3]-e.m[0],t.normal.y=e.m[7]-e.m[4],t.normal.z=e.m[11]-e.m[8],t.d=e.m[15]-e.m[12],t.normalize()},r.GetTopPlaneToRef=function(e,t){t.normal.x=e.m[3]-e.m[1],t.normal.y=e.m[7]-e.m[5],t.normal.z=e.m[11]-e.m[9],t.d=e.m[15]-e.m[13],t.normalize()},r.GetBottomPlaneToRef=function(e,t){t.normal.x=e.m[3]+e.m[1],t.normal.y=e.m[7]+e.m[5],t.normal.z=e.m[11]+e.m[9],t.d=e.m[15]+e.m[13],t.normalize()},r.GetPlanesToRef=function(e,t){r.GetNearPlaneToRef(e,t[0]),r.GetFarPlaneToRef(e,t[1]),r.GetLeftPlaneToRef(e,t[2]),r.GetRightPlaneToRef(e,t[3]),r.GetTopPlaneToRef(e,t[4]),r.GetBottomPlaneToRef(e,t[5])},r})();f.Frustum=a,(s=f.Space||(f.Space={}))[s.LOCAL=0]="LOCAL",s[s.WORLD=1]="WORLD",s[s.BONE=2]="BONE";var l=(function(){function e(){}return e.X=new m(1,0,0),e.Y=new m(0,1,0),e.Z=new m(0,0,1),e})();f.Axis=l;var g,c,u=(function(){function e(){}return e.Interpolate=function(e,t,i,r,n){for(var o=1-3*r+3*t,s=3*r-6*t,a=3*t,l=e,c=0;c<5;c++){var h=l*l;l-=(o*(h*l)+s*h+a*l-e)*(1/(3*o*h+2*s*l+a)),l=Math.min(1,Math.max(0,l))}return 3*Math.pow(1-l,2)*l*i+3*(1-l)*Math.pow(l,2)*n+Math.pow(l,3)},e})();f.BezierCurve=u,(c=g=f.Orientation||(f.Orientation={}))[c.CW=0]="CW",c[c.CCW=1]="CCW";var d=(function(){function r(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return r.prototype.degrees=function(){return 180*this._radians/Math.PI},r.prototype.radians=function(){return this._radians},r.BetweenTwoPoints=function(e,t){var i=t.subtract(e);return new r(Math.atan2(i.y,i.x))},r.FromRadians=function(e){return new r(e)},r.FromDegrees=function(e){return new r(e*Math.PI/180)},r})();f.Angle=d;var v=function(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var r=Math.pow(t.x,2)+Math.pow(t.y,2),n=(Math.pow(e.x,2)+Math.pow(e.y,2)-r)/2,o=(r-Math.pow(i.x,2)-Math.pow(i.y,2))/2,s=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new p((n*(t.y-i.y)-o*(e.y-t.y))/s,((e.x-t.x)*o-(t.x-i.x)*n)/s),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=d.BetweenTwoPoints(this.centerPoint,this.startPoint);var a=this.startAngle.degrees(),l=d.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),c=d.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();180<l-a&&(l-=360),l-a<-180&&(l+=360),180<c-l&&(c-=360),c-l<-180&&(c+=360),this.orientation=l-a<0?g.CW:g.CCW,this.angle=d.FromDegrees(this.orientation===g.CW?a-c:c-a)};f.Arc2=v;var y=(function(){function i(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new p(e,t))}return i.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new p(e,t),r=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(r).length(),this},i.prototype.addArcTo=function(e,t,i,r,n){if(void 0===n&&(n=36),this.closed)return this;var o=this._points[this._points.length-1],s=new p(e,t),a=new p(i,r),l=new v(o,s,a),c=l.angle.radians()/n;l.orientation===g.CW&&(c*=-1);for(var h=l.startAngle.radians()+c,u=0;u<n;u++){var d=Math.cos(h)*l.radius+l.centerPoint.x,f=Math.sin(h)*l.radius+l.centerPoint.y;this.addLineTo(d,f),h+=c}return this},i.prototype.close=function(){return this.closed=!0,this},i.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},i.prototype.getPoints=function(){return this._points},i.prototype.getPointAtLengthPosition=function(e){if(e<0||1<e)return p.Zero();for(var t=e*this.length(),i=0,r=0;r<this._points.length;r++){var n=(r+1)%this._points.length,o=this._points[r],s=this._points[n].subtract(o),a=s.length()+i;if(i<=t&&t<=a){var l=s.normalize(),c=t-i;return new p(o.x+l.x*c,o.y+l.y*c)}i=a}return p.Zero()},i.StartingAt=function(e,t){return new i(e,t)},i})();f.Path2=y;var b=(function(){function e(e,t,i){void 0===t&&(t=null),this.path=e,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var r=0;r<e.length;r++)this._curve[r]=e[r].clone();this._raw=i||!1,this._compute(t)}return e.prototype.getCurve=function(){return this._curve},e.prototype.getTangents=function(){return this._tangents},e.prototype.getNormals=function(){return this._normals},e.prototype.getBinormals=function(){return this._binormals},e.prototype.getDistances=function(){return this._distances},e.prototype.update=function(e,t){void 0===t&&(t=null);for(var i=0;i<e.length;i++)this._curve[i].x=e[i].x,this._curve[i].y=e[i].y,this._curve[i].z=e[i].z;return this._compute(t),this},e.prototype._compute=function(e){var t=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[t-1]=this._curve[t-1].subtract(this._curve[t-2]),this._raw||this._tangents[t-1].normalize();var i,r,n,o,s=this._tangents[0],a=this._normalVector(this._curve[0],s,e);this._normals[0]=a,this._raw||this._normals[0].normalize(),this._binormals[0]=m.Cross(s,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var l=1;l<t;l++)i=this._getLastNonNullVector(l),l<t-1&&(r=this._getFirstNonNullVector(l),this._tangents[l]=i.add(r),this._tangents[l].normalize()),this._distances[l]=this._distances[l-1]+i.length(),n=this._tangents[l],o=this._binormals[l-1],this._normals[l]=m.Cross(o,n),this._raw||this._normals[l].normalize(),this._binormals[l]=m.Cross(n,this._normals[l]),this._raw||this._binormals[l].normalize()},e.prototype._getFirstNonNullVector=function(e){for(var t=1,i=this._curve[e+t].subtract(this._curve[e]);0===i.length()&&e+t+1<this._curve.length;)t++,i=this._curve[e+t].subtract(this._curve[e]);return i},e.prototype._getLastNonNullVector=function(e){for(var t=1,i=this._curve[e].subtract(this._curve[e-t]);0===i.length()&&t+1<e;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},e.prototype._normalVector=function(e,t,i){var r,n,o=t.length();(0===o&&(o=1),null==i)?(n=f.Scalar.WithinEpsilon(Math.abs(t.y)/o,1,f.Epsilon)?f.Scalar.WithinEpsilon(Math.abs(t.x)/o,1,f.Epsilon)?f.Scalar.WithinEpsilon(Math.abs(t.z)/o,1,f.Epsilon)?m.Zero():new m(0,0,1):new m(1,0,0):new m(0,-1,0),r=m.Cross(t,n)):(r=m.Cross(t,i),m.CrossToRef(r,t,r));return r.normalize(),r},e})();f.Path3D=b;var T=(function(){function h(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return h.CreateQuadraticBezier=function(e,t,i,r){r=2<r?r:3;for(var n=new Array,o=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},s=0;s<=r;s++)n.push(new m(o(s/r,e.x,t.x,i.x),o(s/r,e.y,t.y,i.y),o(s/r,e.z,t.z,i.z)));return new h(n)},h.CreateCubicBezier=function(e,t,i,r,n){n=3<n?n:4;for(var o=new Array,s=function(e,t,i,r,n){return(1-e)*(1-e)*(1-e)*t+3*e*(1-e)*(1-e)*i+3*e*e*(1-e)*r+e*e*e*n},a=0;a<=n;a++)o.push(new m(s(a/n,e.x,t.x,i.x,r.x),s(a/n,e.y,t.y,i.y,r.y),s(a/n,e.z,t.z,i.z,r.z)));return new h(o)},h.CreateHermiteSpline=function(e,t,i,r,n){for(var o=new Array,s=1/n,a=0;a<=n;a++)o.push(m.Hermite(e,t,i,r,a*s));return new h(o)},h.CreateCatmullRomSpline=function(e,t,i){var r=new Array,n=1/t,o=0;if(i){for(var s=e.length,a=0;a<s;a++)for(var l=o=0;l<t;l++)r.push(m.CatmullRom(e[a%s],e[(a+1)%s],e[(a+2)%s],e[(a+3)%s],o)),o+=n;r.push(r[0])}else{var c=new Array;c.push(e[0].clone()),Array.prototype.push.apply(c,e),c.push(e[e.length-1].clone());for(a=0;a<c.length-3;a++)for(l=o=0;l<t;l++)r.push(m.CatmullRom(c[a],c[a+1],c[a+2],c[a+3],o)),o+=n;a--,r.push(m.CatmullRom(c[a],c[a+1],c[a+2],c[a+3],o))}return new h(r)},h.prototype.getPoints=function(){return this._points},h.prototype.length=function(){return this._length},h.prototype.continue=function(e){for(var t=this._points[this._points.length-1],i=this._points.slice(),r=e.getPoints(),n=1;n<r.length;n++)i.push(r[n].subtract(r[0]).add(t));return new h(i)},h.prototype._computeLength=function(e){for(var t=0,i=1;i<e.length;i++)t+=e[i].subtract(e[i-1]).length();return t},h})();f.Curve3=T;var x=(function(){function e(e,t){void 0===e&&(e=m.Zero()),void 0===t&&(t=m.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e})();f.PositionNormalVertex=x;var E=(function(){function e(e,t,i){void 0===e&&(e=m.Zero()),void 0===t&&(t=m.Up()),void 0===i&&(i=p.Zero()),this.position=e,this.normal=t,this.uv=i}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone(),this.uv.clone())},e})();f.PositionNormalTextureVertex=E;var A=(function(){function e(){}return e.Color3=[t.Black(),t.Black(),t.Black()],e.Color4=[new i(0,0,0,0),new i(0,0,0,0)],e.Vector2=[p.Zero(),p.Zero(),p.Zero()],e.Vector3=[m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero()],e.Vector4=[r.Zero(),r.Zero(),r.Zero()],e.Quaternion=[_.Zero(),_.Zero()],e.Matrix=[h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero(),h.Zero()],e})();f.Tmp=A;var P=(function(){function e(){}return e.Vector3=[m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero()],e.Matrix=[h.Zero(),h.Zero()],e.Quaternion=[_.Zero(),_.Zero(),_.Zero()],e})()})($a||($a={})),e=$a||($a={}),n=(function(){function n(){}return n.WithinEpsilon=function(e,t,i){void 0===i&&(i=1401298e-51);var r=e-t;return-i<=r&&r<=i},n.ToHex=function(e){var t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()},n.Sign=function(e){return 0===(e=+e)||isNaN(e)?e:0<e?1:-1},n.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},n.Log2=function(e){return Math.log(e)*Math.LOG2E},n.Repeat=function(e,t){return e-Math.floor(e/t)*t},n.Normalize=function(e,t,i){return(e-t)/(i-t)},n.Denormalize=function(e,t,i){return e*(i-t)+t},n.DeltaAngle=function(e,t){var i=n.Repeat(t-e,360);return 180<i&&(i-=360),i},n.PingPong=function(e,t){var i=n.Repeat(e,2*t);return t-Math.abs(i-t)},n.SmoothStep=function(e,t,i){var r=n.Clamp(i);return t*(r=-2*r*r*r+3*r*r)+e*(1-r)},n.MoveTowards=function(e,t,i){return Math.abs(t-e)<=i?t:e+n.Sign(t-e)*i},n.MoveTowardsAngle=function(e,t,i){var r=n.DeltaAngle(e,t);return-i<r&&r<i?t:n.MoveTowards(e,t=e+r,i)},n.Lerp=function(e,t,i){return e+(t-e)*i},n.LerpAngle=function(e,t,i){var r=n.Repeat(t-e,360);return 180<r&&(r-=360),e+r*n.Clamp(i)},n.InverseLerp=function(e,t,i){return e!=t?n.Clamp((i-e)/(t-e)):0},n.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o;return e*(2*s-3*o+1)+i*(-2*s+3*o)+t*(s-2*o+n)+r*(s-o)},n.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},n.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},n.PercentToRange=function(e,t,i){return(i-t)*e+t},n.NormalizeRadians=function(e){return e-=n.TwoPi*Math.floor((e+Math.PI)/n.TwoPi)},n.TwoPi=2*Math.PI,n})(),e.Scalar=n,(function(u){var c={},h={},i=function(e,t,i){var r=e();u.Tags&&u.Tags.AddTagsTo(r,t.tags);var n=d(r);for(var o in n){var s=n[o],a=t[o],l=s.type;if(null!=a)switch(l){case 0:case 6:case 11:r[o]=a;break;case 1:r[o]=i||a.isRenderTarget?a:a.clone();break;case 2:case 3:case 4:case 5:case 7:case 10:r[o]=i?a:a.clone()}}return r};function d(e){var t=e.getClassName();if(h[t])return h[t];h[t]={};for(var i=h[t],r=e,n=t;n;){var o=c[n];for(var s in o)i[s]=o[s];var a=void 0,l=!1;do{if(!(a=Object.getPrototypeOf(r)).getClassName){l=!0;break}if(a.getClassName()!==n)break;r=a}while(a);if(l)break;n=a.getClassName(),r=a}return i}function t(n,o){return function(e,t){var i,r=(i=e.getClassName(),c[i]||(c[i]={}),c[i]);r[t]||(r[t]={type:n,sourceName:o})}}u.expandToProperty=function(e,t){return void 0===t&&(t=null),r=e,void 0===(n=t)&&(n=null),function(t,e){var i=n||"_"+e;Object.defineProperty(t,e,{get:function(){return this[i]},set:function(e){this[i]!==e&&(this[i]=e,t[r].apply(this))},enumerable:!0,configurable:!0})};var r,n},u.serialize=function(e){return t(0,e)},u.serializeAsTexture=function(e){return t(1,e)},u.serializeAsColor3=function(e){return t(2,e)},u.serializeAsFresnelParameters=function(e){return t(3,e)},u.serializeAsVector2=function(e){return t(4,e)},u.serializeAsVector3=function(e){return t(5,e)},u.serializeAsMeshReference=function(e){return t(6,e)},u.serializeAsColorCurves=function(e){return t(7,e)},u.serializeAsColor4=function(e){return t(8,e)},u.serializeAsImageProcessingConfiguration=function(e){return t(9,e)},u.serializeAsQuaternion=function(e){return t(10,e)},u.serializeAsCameraReference=function(e){return t(11,e)};var e=(function(){function e(){}return e.Serialize=function(e,t){t||(t={}),u.Tags&&(t.tags=u.Tags.GetTags(e));var i=d(e);for(var r in i){var n=i[r],o=n.sourceName||r,s=n.type,a=e[r];if(null!=a)switch(s){case 0:t[o]=a;break;case 1:t[o]=a.serialize();break;case 2:t[o]=a.asArray();break;case 3:t[o]=a.serialize();break;case 4:case 5:t[o]=a.asArray();break;case 6:t[o]=a.id;break;case 7:t[o]=a.serialize();break;case 8:t[o]=a.asArray();break;case 9:t[o]=a.serialize();break;case 10:t[o]=a.asArray();break;case 11:t[o]=a.id}}return t},e.Parse=function(e,t,i,r){void 0===r&&(r=null);var n=e();r||(r=""),u.Tags&&u.Tags.AddTagsTo(n,t.tags);var o=d(n);for(var s in o){var a=o[s],l=t[a.sourceName||s],c=a.type;if(null!=l){var h=n;switch(c){case 0:h[s]=l;break;case 1:i&&(h[s]=u.Texture.Parse(l,i,r));break;case 2:h[s]=u.Color3.FromArray(l);break;case 3:h[s]=u.FresnelParameters.Parse(l);break;case 4:h[s]=u.Vector2.FromArray(l);break;case 5:h[s]=u.Vector3.FromArray(l);break;case 6:i&&(h[s]=i.getLastMeshByID(l));break;case 7:h[s]=u.ColorCurves.Parse(l);break;case 8:h[s]=u.Color4.FromArray(l);break;case 9:h[s]=u.ImageProcessingConfiguration.Parse(l);break;case 10:h[s]=u.Quaternion.FromArray(l);break;case 11:i&&(h[s]=i.getCameraByID(l))}}}return n},e.Clone=function(e,t){return i(e,t,!1)},e.Instanciate=function(e,t){return i(e,t,!0)},e})();u.SerializationHelper=e})($a||($a={})),o=$a||($a={}),s=(function(){function e(){var i=this;this.promise=new Promise(function(e,t){i._resolve=e,i._reject=t})}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})(),o.Deferred=s,(function(i){var r=(function(){function e(e,t,i,r){void 0===t&&(t=!1),this.initalize(e,t,i,r)}return e.prototype.initalize=function(e,t,i,r){return void 0===t&&(t=!1),this.mask=e,this.skipNextObservers=t,this.target=i,this.currentTarget=r,this},e})();i.EventState=r;var s=function(e,t,i){void 0===i&&(i=null),this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1};i.Observer=s;var e=(function(){function l(){}return l.prototype.dispose=function(){if(this._observers&&this._observables)for(var e=0;e<this._observers.length;e++)this._observables[e].remove(this._observers[e]);this._observers=null,this._observables=null},l.Watch=function(e,t,i,r){void 0===i&&(i=-1),void 0===r&&(r=null);var n=new l;n._observers=new Array;for(var o=0,s=n._observables=e;o<s.length;o++){var a=s[o].add(t,i,!1,r);a&&n._observers.push(a)}return n},l})();i.MultiObserver=e;var t=(function(){function t(e){this._observers=new Array,this._eventState=new r(0),e&&(this._onObserverAdded=e)}return t.prototype.add=function(e,t,i,r,n){if(void 0===t&&(t=-1),void 0===i&&(i=!1),void 0===r&&(r=null),void 0===n&&(n=!1),!e)return null;var o=new s(e,t,r);return o.unregisterOnNextCall=n,i?this._observers.unshift(o):this._observers.push(o),this._onObserverAdded&&this._onObserverAdded(o),o},t.prototype.addOnce=function(e){return this.add(e,void 0,void 0,void 0,!0)},t.prototype.remove=function(e){return!!e&&(-1!==this._observers.indexOf(e)&&(this._deferUnregister(e),!0))},t.prototype.removeCallback=function(e,t){for(var i=0;i<this._observers.length;i++)if(this._observers[i].callback===e&&(!t||t===this._observers[i].scope))return this._deferUnregister(this._observers[i]),!0;return!1},t.prototype._deferUnregister=function(e){var t=this;e.unregisterOnNextCall=!1,e._willBeUnregistered=!0,i.Tools.SetImmediate((function(){t._remove(e)}))},t.prototype._remove=function(e){if(!e)return!1;var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},t.prototype.notifyObservers=function(e,t,i,r){if(void 0===t&&(t=-1),!this._observers.length)return!0;var n=this._eventState;n.mask=t,n.target=i,n.currentTarget=r,n.skipNextObservers=!1,n.lastReturnValue=e;for(var o=0,s=this._observers;o<s.length;o++){var a=s[o];if(!a._willBeUnregistered&&(a.mask&t&&(a.scope?n.lastReturnValue=a.callback.apply(a.scope,[e,n]):n.lastReturnValue=a.callback(e,n),a.unregisterOnNextCall&&this._deferUnregister(a)),n.skipNextObservers))return!1}return!0},t.prototype.notifyObserversWithPromise=function(i,e,t,r){var n=this;void 0===e&&(e=-1);var o=Promise.resolve(i);if(!this._observers.length)return o;var s=this._eventState;return s.mask=e,s.target=t,s.currentTarget=r,s.skipNextObservers=!1,this._observers.forEach((function(t){s.skipNextObservers||t._willBeUnregistered||t.mask&e&&(o=t.scope?o.then((function(e){return s.lastReturnValue=e,t.callback.apply(t.scope,[i,s])})):o.then((function(e){return s.lastReturnValue=e,t.callback(i,s)})),t.unregisterOnNextCall&&n._deferUnregister(t))})),o.then((function(){return i}))},t.prototype.notifyObserver=function(e,t,i){void 0===i&&(i=-1);var r=this._eventState;r.mask=i,r.skipNextObservers=!1,e.callback(t,r)},t.prototype.hasObservers=function(){return 0<this._observers.length},t.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},t.prototype.clone=function(){var e=new t;return e._observers=this._observers.slice(0),e},t.prototype.hasSpecificMask=function(e){void 0===e&&(e=-1);for(var t=0,i=this._observers;t<i.length;t++){var r=i[t];if(r.mask&e||r.mask===e)return!0}return!1},t})();i.Observable=t})($a||($a={})),a=$a||($a={}),l=(function(){function t(e){this.length=0,this.data=new Array(e),this._id=t._GlobalId++}return t.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},t.prototype.forEach=function(e){for(var t=0;t<this.length;t++)e(this.data[t])},t.prototype.sort=function(e){this.data.sort(e)},t.prototype.reset=function(){this.length=0},t.prototype.dispose=function(){this.reset(),this.data&&(this.data.length=0,this.data=[])},t.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},t.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},t.prototype.contains=function(e){return-1!==this.indexOf(e)},t._GlobalId=0,t})(),c=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._duplicateId=0,e}return T(e,t),e.prototype.push=function(e){t.prototype.push.call(this,e),e.__smartArrayFlags||(e.__smartArrayFlags={}),e.__smartArrayFlags[this._id]=this._duplicateId},e.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},e.prototype.reset=function(){t.prototype.reset.call(this),this._duplicateId++},e.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var i=(e.data||e)[t];this.pushNoDuplicate(i)}}},e})(a.SmartArray=l),a.SmartArrayNoDuplicate=c,(function(m){var e=(function(){function e(){}return e.prototype.getColorToRef=function(e){this.color2?m.Color4.LerpToRef(this.color1,this.color2,Math.random(),e):e.copyFrom(this.color1)},e})();m.ColorGradient=e;var t=function(){};m.Color3Gradient=t;var i=(function(){function e(){}return e.prototype.getFactor=function(){return void 0===this.factor2?this.factor1:m.Scalar.Lerp(this.factor1,this.factor2,Math.random())},e})();m.FactorGradient=i;var g=(function(r){function n(e,t){var i=r.call(this,e)||this;return i.request=t,i.name="LoadFileError",n._setPrototypeOf(i,n.prototype),i}return T(n,r),n._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},n})(Error);m.LoadFileError=g;var v,r=(function(){function e(){}return e.ExponentialBackoff=function(r,n){return void 0===r&&(r=3),void 0===n&&(n=500),function(e,t,i){return 0!==t.status||r<=i||-1!==e.indexOf("file:")?-1:Math.pow(2,i)*n}},e})();m.RetryStrategy=r;var c=function(e,t){return e?e instanceof m.Mesh?null:e instanceof m.SubMesh?e.clone(t):e.clone?e.clone():null:null},n=(function(){function _(){}return _.FetchToRef=function(e,t,i,r,n,o){var s=4*((Math.abs(e)*i%i|0)+(Math.abs(t)*r%r|0)*i);o.r=n[s]/255,o.g=n[s+1]/255,o.b=n[s+2]/255,o.a=n[s+3]/255},_.Mix=function(e,t,i){return e*(1-i)+t*i},_.Instantiate=function(e){if(_.RegisteredExternalClasses&&_.RegisteredExternalClasses[e])return _.RegisteredExternalClasses[e];for(var t=e.split("."),i=window||this,r=0,n=t.length;r<n;r++)i=i[t[r]];return"function"!=typeof i?null:i},_.Slice=function(e,t,i){return e.slice?e.slice(t,i):Array.prototype.slice.call(e,t,i)},_.SetImmediate=function(e){_.IsWindowObjectExist()&&window.setImmediate?window.setImmediate(e):setTimeout(e,1)},_.IsExponentOfTwo=function(e){for(var t=1;(t*=2)<e;);return t===e},_.FloatRound=function(e){return Math.fround?Math.fround(e):_._tmpFloatArray[0]=e},_.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},_.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},_.NearestPOT=function(e){var t=_.CeilingPOT(e),i=_.FloorPOT(e);return e-i<t-e?i:t},_.GetExponentOfTwo=function(e,t,i){var r;switch(void 0===i&&(i=m.Engine.SCALEMODE_NEAREST),i){case m.Engine.SCALEMODE_FLOOR:r=_.FloorPOT(e);break;case m.Engine.SCALEMODE_NEAREST:r=_.NearestPOT(e);break;case m.Engine.SCALEMODE_CEILING:default:r=_.CeilingPOT(e)}return Math.min(r,t)},_.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},_.GetFolderPath=function(e,t){void 0===t&&(t=!1);var i=e.lastIndexOf("/");return i<0?t?e:"":e.substring(0,i+1)},_.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},_.ToDegrees=function(e){return 180*e/Math.PI},_.ToRadians=function(e){return e*Math.PI/180},_.EncodeArrayBufferTobase64=function(e){for(var t,i,r,n,o,s,a,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",c="",h=0,u=new Uint8Array(e);h<u.length;)n=(t=u[h++])>>2,o=(3&t)<<4|(i=h<u.length?u[h++]:Number.NaN)>>4,s=(15&i)<<2|(r=h<u.length?u[h++]:Number.NaN)>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),c+=l.charAt(n)+l.charAt(o)+l.charAt(s)+l.charAt(a);return"data:image/png;base64,"+c},_.ExtractMinAndMaxIndexed=function(e,t,i,r,n){void 0===n&&(n=null);for(var o=new m.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new m.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),a=i;a<i+r;a++){var l=3*t[a],c=e[l],h=e[l+1],u=e[l+2];o.minimizeInPlaceFromFloats(c,h,u),s.maximizeInPlaceFromFloats(c,h,u)}return n&&(o.x-=o.x*n.x+n.y,o.y-=o.y*n.x+n.y,o.z-=o.z*n.x+n.y,s.x+=s.x*n.x+n.y,s.y+=s.y*n.x+n.y,s.z+=s.z*n.x+n.y),{minimum:o,maximum:s}},_.ExtractMinAndMax=function(e,t,i,r,n){void 0===r&&(r=null);var o=new m.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),s=new m.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);n||(n=3);for(var a=t,l=t*n;a<t+i;a++,l+=n){var c=e[l],h=e[l+1],u=e[l+2];o.minimizeInPlaceFromFloats(c,h,u),s.maximizeInPlaceFromFloats(c,h,u)}return r&&(o.x-=o.x*r.x+r.y,o.y-=o.y*r.x+r.y,o.z-=o.z*r.x+r.y,s.x+=s.x*r.x+r.y,s.y+=s.y*r.x+r.y,s.z+=s.z*r.x+r.y),{minimum:o,maximum:s}},_.MakeArray=function(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:null},_.GetPointerPrefix=function(){var e="pointer";return!_.IsWindowObjectExist()||window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},_.QueueNewFrame=function(e,t){return _.IsWindowObjectExist()?(t||(t=window),t.requestAnimationFrame?t.requestAnimationFrame(e):t.msRequestAnimationFrame?t.msRequestAnimationFrame(e):t.webkitRequestAnimationFrame?t.webkitRequestAnimationFrame(e):t.mozRequestAnimationFrame?t.mozRequestAnimationFrame(e):t.oRequestAnimationFrame?t.oRequestAnimationFrame(e):window.setTimeout(e,16)):setTimeout(e,16)},_.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},_.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},_.SetCorsBehavior=function(e,t){if((!e||0!==e.indexOf("data:"))&&_.CorsBehavior)if("string"==typeof _.CorsBehavior||_.CorsBehavior instanceof String)t.crossOrigin=_.CorsBehavior;else{var i=_.CorsBehavior(e);i&&(t.crossOrigin=i)}},_.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},_.LoadImage=function(t,e,i,r){var n,o=!1;t instanceof ArrayBuffer?(n=URL.createObjectURL(new Blob([t])),o=!0):t instanceof Blob?(n=URL.createObjectURL(t),o=!0):(n=_.CleanUrl(t),n=_.PreprocessUrl(t));var s=new Image;_.SetCorsBehavior(n,s);var a=function(){o&&s.src&&URL.revokeObjectURL(s.src),s.removeEventListener("load",a),s.removeEventListener("error",l),e(s)},l=function(e){o&&s.src&&URL.revokeObjectURL(s.src),s.removeEventListener("load",a),s.removeEventListener("error",l),_.Error("Error while trying to load image: "+t),i&&i("Error while trying to load image: "+t,e)};s.addEventListener("load",a),s.addEventListener("error",l);var c=function(){s.src=n};if("data:"!==n.substr(0,5)&&r&&r.enableTexturesOffline&&m.Database.IsUASupportingBlobStorage)r.openAsync((function(){r&&r.loadImageFromDB(n,s)}),c);else{if(-1!==n.indexOf("file:")){var h=decodeURIComponent(n.substring(5).toLowerCase());if(m.FilesInput.FilesToLoad[h]){try{var u;try{u=URL.createObjectURL(m.FilesInput.FilesToLoad[h])}catch(e){u=URL.createObjectURL(m.FilesInput.FilesToLoad[h])}s.src=u,o=!0}catch(e){s.src=""}return s}}c()}return s},_.LoadFile=function(e,c,t,i,h,u){if(e=_.CleanUrl(e),-1!==(e=_.PreprocessUrl(e)).indexOf("file:")){var r=decodeURIComponent(e.substring(5).toLowerCase());if(m.FilesInput.FilesToLoad[r])return _.ReadFile(m.FilesInput.FilesToLoad[r],c,t,h)}var d=_.BaseUrl+e,f=!1,p={onCompleteObservable:new m.Observable,abort:function(){return f=!0}},n=function(){var s=new XMLHttpRequest,a=null;p.abort=function(){f=!0,s.readyState!==(XMLHttpRequest.DONE||4)&&s.abort(),null!==a&&(clearTimeout(a),a=null)};var l=function(r){s.open("GET",d,!0),h&&(s.responseType="arraybuffer"),t&&s.addEventListener("progress",t);var n=function(){s.removeEventListener("loadend",n),p.onCompleteObservable.notifyObservers(p),p.onCompleteObservable.clear()};s.addEventListener("loadend",n);var o=function(){if(!f&&s.readyState===(XMLHttpRequest.DONE||4)){if(s.removeEventListener("readystatechange",o),200<=s.status&&s.status<300||0===s.status&&(!_.IsWindowObjectExist()||_.IsFileURL()))return void c(h?s.response:s.responseText,s.responseURL);var e=_.DefaultRetryStrategy;if(e){var t=e(d,s,r);if(-1!==t)return s.removeEventListener("loadend",n),s=new XMLHttpRequest,void(a=setTimeout((function(){return l(r+1)}),t))}var i=new g("Error status: "+s.status+" "+s.statusText+" - Unable to load "+d,s);if(!u)throw i;u(s,i)}};s.addEventListener("readystatechange",o),s.send()};l(0)};if(i&&i.enableSceneOffline){var o=function(e){e&&400<e.status?u&&u(e):f||n()};i.openAsync((function(){f||i&&i.loadFileFromDB(e,(function(e){f||c(e),p.onCompleteObservable.notifyObservers(p)}),t?function(e){f||t(e)}:void 0,o,h)}),o)}else n();return p},_.LoadScript=function(t,e,i){if(_.IsWindowObjectExist()){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=t,n.onload=function(){e&&e()},n.onerror=function(e){i&&i("Unable to load script '"+t+"'",e)},r.appendChild(n)}},_.ReadFileAsDataURL=function(e,t,i){var r=new FileReader,n={onCompleteObservable:new m.Observable,abort:function(){return r.abort()}};return r.onloadend=function(e){n.onCompleteObservable.notifyObservers(n)},r.onload=function(e){t(e.target.result)},r.onprogress=i,r.readAsDataURL(e),n},_.ReadFile=function(t,i,e,r){var n=new FileReader,o={onCompleteObservable:new m.Observable,abort:function(){return n.abort()}};return n.onloadend=function(e){return o.onCompleteObservable.notifyObservers(o)},n.onerror=function(e){_.Log("Error while reading file: "+t.name),i(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},n.onload=function(e){i(e.target.result)},e&&(n.onprogress=e),r?n.readAsArrayBuffer(t):n.readAsText(t),o},_.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},_.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},_.CheckExtends=function(e,t,i){e.x<t.x&&(t.x=e.x),e.y<t.y&&(t.y=e.y),e.z<t.z&&(t.z=e.z),e.x>i.x&&(i.x=e.x),e.y>i.y&&(i.y=e.y),e.z>i.z&&(i.z=e.z)},_.DeepCopy=function(e,t,i,r){for(var n in e)if(("_"!==n[0]||r&&-1!==r.indexOf(n))&&(!i||-1===i.indexOf(n))){var o=e[n],s=typeof o;if("function"!==s)try{if("object"===s)if(o instanceof Array){if(t[n]=[],0<o.length)if("object"==typeof o[0])for(var a=0;a<o.length;a++){var l=c(o[a],t);-1===t[n].indexOf(l)&&t[n].push(l)}else t[n]=o.slice(0)}else t[n]=c(o,t);else t[n]=o}catch(e){}}},_.IsEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},_.RegisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.addEventListener(i.name,i.handler,!1);try{window.parent&&window.parent.addEventListener(i.name,i.handler,!1)}catch(e){}}},_.UnregisterTopRootEvents=function(e){for(var t=0;t<e.length;t++){var i=e[t];window.removeEventListener(i.name,i.handler);try{window.parent&&window.parent.removeEventListener(i.name,i.handler)}catch(e){}}},_.DumpFramebuffer=function(e,t,i,r,n,o){void 0===n&&(n="image/png");for(var s=4*e,a=t/2,l=i.readPixels(0,0,e,t),c=0;c<a;c++)for(var h=0;h<s;h++){var u=h+c*s,d=h+(t-c-1)*s,f=l[u];l[u]=l[d],l[d]=f}v||(v=document.createElement("canvas")),v.width=e,v.height=t;var p=v.getContext("2d");if(p){var m=p.createImageData(e,t);m.data.set(l),p.putImageData(m,0,0),_.EncodeScreenshotCanvasData(r,n,o)}},_.ToBlob=function(e,t,i){void 0===i&&(i="image/png"),e.toBlob||(e.toBlob=function(n,o,s){var a=this;setTimeout((function(){for(var e=atob(a.toDataURL(o,s).split(",")[1]),t=e.length,i=new Uint8Array(t),r=0;r<t;r++)i[r]=e.charCodeAt(r);n(new Blob([i]))}))}),e.toBlob((function(e){t(e)}),i)},_.EncodeScreenshotCanvasData=function(e,t,s){(void 0===t&&(t="image/png"),e)?e(v.toDataURL(t)):this.ToBlob(v,(function(e){if("download"in document.createElement("a")){if(!s){var t=new Date,i=(t.getFullYear()+"-"+(t.getMonth()+1)).slice(2)+"-"+t.getDate()+"_"+t.getHours()+"-"+("0"+t.getMinutes()).slice(-2);s="screenshot_"+i+".png"}_.Download(e,s)}else{var r=URL.createObjectURL(e),n=window.open("");if(!n)return;var o=n.document.createElement("img");o.onload=function(){URL.revokeObjectURL(r)},o.src=r,n.document.body.appendChild(o)}}),t)},_.Download=function(e,t){if(navigator&&navigator.msSaveBlob)navigator.msSaveBlob(e,t);else{var i=window.URL.createObjectURL(e),r=document.createElement("a");document.body.appendChild(r),r.style.display="none",r.href=i,r.download=t,r.addEventListener("click",(function(){r.parentElement&&r.parentElement.removeChild(r)})),r.click(),window.URL.revokeObjectURL(i)}},_.CreateScreenshot=function(e,t,i,r,n){var o,s;if(void 0===n&&(n="image/png"),i.precision)o=Math.round(e.getRenderWidth()*i.precision),s=Math.round(o/e.getAspectRatio(t));else if(i.width&&i.height)o=i.width,s=i.height;else if(i.width&&!i.height)o=i.width,s=Math.round(o/e.getAspectRatio(t));else if(i.height&&!i.width)s=i.height,o=Math.round(s*e.getAspectRatio(t));else{if(isNaN(i))return void _.Error("Invalid 'size' parameter !");o=s=i}v||(v=document.createElement("canvas")),v.width=o,v.height=s;var a=v.getContext("2d"),l=e.getRenderWidth()/e.getRenderHeight(),c=o,h=c/l;s<h&&(c=(h=s)*l);var u=Math.max(0,o-c)/2,d=Math.max(0,s-h)/2,f=e.getRenderingCanvas();a&&f&&a.drawImage(f,u,d,c,h),_.EncodeScreenshotCanvasData(r,n)},_.CreateScreenshotUsingRenderTarget=function(e,t,i,r,n,o,s,a){var l,c;if(void 0===n&&(n="image/png"),void 0===o&&(o=1),void 0===s&&(s=!1),i.precision)l=Math.round(e.getRenderWidth()*i.precision),c=Math.round(l/e.getAspectRatio(t)),i={width:l,height:c};else if(i.width&&i.height)l=i.width,c=i.height;else if(i.width&&!i.height)l=i.width,c=Math.round(l/e.getAspectRatio(t)),i={width:l,height:c};else if(i.height&&!i.width)c=i.height,i={width:l=Math.round(c*e.getAspectRatio(t)),height:c};else{if(isNaN(i))return void _.Error("Invalid 'size' parameter !");l=c=i}var h=t.getScene(),u=null;h.activeCamera!==t&&(u=h.activeCamera,h.activeCamera=t);var d=new m.RenderTargetTexture("screenShot",i,h,!1,!1,m.Engine.TEXTURETYPE_UNSIGNED_INT,!1,m.Texture.NEAREST_SAMPLINGMODE);d.renderList=null,d.samples=o,s&&d.addPostProcess(new m.FxaaPostProcess("antialiasing",1,h.activeCamera)),d.onAfterRenderObservable.add((function(){_.DumpFramebuffer(l,c,e,r,n,a)})),h.incrementRenderId(),h.resetCachedMaterial(),d.render(!0),d.dispose(),u&&(h.activeCamera=u),t.getProjectionMatrix(!0)},_.ValidateXHRData=function(e,t){void 0===t&&(t=7);try{if(1&t){if(e.responseText&&0<e.responseText.length)return!0;if(1===t)return!1}if(2&t){var i=m.TGATools.GetTGAHeader(e.response);if(i.width&&i.height&&0<i.width&&0<i.height)return!0;if(2===t)return!1}if(4&t){var r=new Uint8Array(e.response,0,3);return 68===r[0]&&68===r[1]&&83===r[2]}}catch(e){}return!1},_.RandomId=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},_.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},_.DecodeBase64=function(e){for(var t=atob(e.split(",")[1]),i=t.length,r=new Uint8Array(new ArrayBuffer(i)),n=0;n<i;n++)r[n]=t.charCodeAt(n);return r.buffer},_._AddLogEntry=function(e){_._LogCache=e+_._LogCache,_.OnNewCacheEntry&&_.OnNewCacheEntry(e)},_._FormatMessage=function(e){var t=function(e){return e<10?"0"+e:""+e},i=new Date;return"["+t(i.getHours())+":"+t(i.getMinutes())+":"+t(i.getSeconds())+"]: "+e},_._LogDisabled=function(e){},_._LogEnabled=function(e){var t=_._FormatMessage(e);console.log("BJS - "+t),_._AddLogEntry("<div style='color:white'>"+t+"</div><br>")},_._WarnDisabled=function(e){},_._WarnEnabled=function(e){var t=_._FormatMessage(e);console.warn("BJS - "+t),_._AddLogEntry("<div style='color:orange'>"+t+"</div><br>")},_._ErrorDisabled=function(e){},_._ErrorEnabled=function(e){_.errorsCount++;var t=_._FormatMessage(e);console.error("BJS - "+t),_._AddLogEntry("<div style='color:red'>"+t+"</div><br>")},Object.defineProperty(_,"LogCache",{get:function(){return _._LogCache},enumerable:!0,configurable:!0}),_.ClearLogCache=function(){_._LogCache="",_.errorsCount=0},Object.defineProperty(_,"LogLevels",{set:function(e){_.Log=(e&_.MessageLogLevel)===_.MessageLogLevel?_._LogEnabled:_._LogDisabled,_.Warn=(e&_.WarningLogLevel)===_.WarningLogLevel?_._WarnEnabled:_._WarnDisabled,_.Error=(e&_.ErrorLogLevel)===_.ErrorLogLevel?_._ErrorEnabled:_._ErrorDisabled},enumerable:!0,configurable:!0}),_.IsFileURL=function(){return"file:"===location.protocol},_.IsWindowObjectExist=function(){return"undefined"!=typeof window},Object.defineProperty(_,"PerformanceLogLevel",{set:function(e){return(e&_.PerformanceUserMarkLogLevel)===_.PerformanceUserMarkLogLevel?(_.StartPerformanceCounter=_._StartUserMark,void(_.EndPerformanceCounter=_._EndUserMark)):(e&_.PerformanceConsoleLogLevel)===_.PerformanceConsoleLogLevel?(_.StartPerformanceCounter=_._StartPerformanceConsole,void(_.EndPerformanceCounter=_._EndPerformanceConsole)):(_.StartPerformanceCounter=_._StartPerformanceCounterDisabled,void(_.EndPerformanceCounter=_._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),_._StartPerformanceCounterDisabled=function(e,t){},_._EndPerformanceCounterDisabled=function(e,t){},_._StartUserMark=function(e,t){if(void 0===t&&(t=!0),!_._performance){if(!_.IsWindowObjectExist())return;_._performance=window.performance}t&&_._performance.mark&&_._performance.mark(e+"-Begin")},_._EndUserMark=function(e,t){void 0===t&&(t=!0),t&&_._performance.mark&&(_._performance.mark(e+"-End"),_._performance.measure(e,e+"-Begin",e+"-End"))},_._StartPerformanceConsole=function(e,t){void 0===t&&(t=!0),t&&(_._StartUserMark(e,t),console.time&&console.time(e))},_._EndPerformanceConsole=function(e,t){void 0===t&&(t=!0),t&&(_._EndUserMark(e,t),console.time&&console.timeEnd(e))},Object.defineProperty(_,"Now",{get:function(){return _.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!0,configurable:!0}),_.GetClassName=function(e,t){void 0===t&&(t=!1);var i=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object)i=(t?e:Object.getPrototypeOf(e)).constructor.__bjsclassName__;i||(i=typeof e)}return i},_.First=function(e,t){for(var i=0,r=e;i<r.length;i++){var n=r[i];if(t(n))return n}return null},_.getFullClassName=function(e,t){void 0===t&&(t=!1);var i=null,r=null;if(!t&&e.getClassName)i=e.getClassName();else{if(e instanceof Object){var n=t?e:Object.getPrototypeOf(e);i=n.constructor.__bjsclassName__,r=n.constructor.__bjsmoduleName__}i||(i=typeof e)}return i?(null!=r?r+".":"")+i:null},_.DelayAsync=function(t){return new Promise(function(e){setTimeout((function(){e()}),t)})},_.GetCurrentGradient=function(e,t,i){for(var r=0;r<t.length-1;r++){var n=t[r],o=t[r+1];if(e>=n.gradient&&e<=o.gradient)return void i(n,o,(e-n.gradient)/(o.gradient-n.gradient))}var s=t.length-1;i(t[s],t[s],1)},_.BaseUrl="",_.DefaultRetryStrategy=r.ExponentialBackoff(),_.CorsBehavior="anonymous",_.UseFallbackTexture=!0,_.RegisteredExternalClasses={},_.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",_._tmpFloatArray=new Float32Array(1),_.PreprocessUrl=function(e){return e},_.NoneLogLevel=0,_.MessageLogLevel=1,_.WarningLogLevel=2,_.ErrorLogLevel=4,_.AllLogLevel=7,_._LogCache="",_.errorsCount=0,_.Log=_._LogEnabled,_.Warn=_._WarnEnabled,_.Error=_._ErrorEnabled,_.PerformanceNoneLogLevel=0,_.PerformanceUserMarkLogLevel=1,_.PerformanceConsoleLogLevel=2,_.StartPerformanceCounter=_._StartPerformanceCounterDisabled,_.EndPerformanceCounter=_._EndPerformanceCounterDisabled,_})();m.Tools=n;var o=(function(){function i(){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(i.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!0,configurable:!0}),i.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},i.prototype.addCount=function(e,t){i.Enabled&&(this._current+=e,t&&this._fetchResult())},i.prototype.beginMonitoring=function(){i.Enabled&&(this._startMonitoringTime=n.Now)},i.prototype.endMonitoring=function(e){if(void 0===e&&(e=!0),i.Enabled){e&&this.fetchNewFrame();var t=n.Now;this._current=t-this._startMonitoringTime,e&&this._fetchResult()}},i.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=n.Now;1e3<e-this._lastSecTime&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},i.Enabled=!0,i})();m.PerfCounter=o,m.className=function(t,i){return function(e){e.__bjsclassName__=t,e.__bjsmoduleName__=null!=i?i:null}};var s=(function(){function a(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this.index=r-1,this._done=!1,this._fn=t,this._successCallback=i}return a.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},a.prototype.breakLoop=function(){this._done=!0,this._successCallback()},a.Run=function(e,t,i,r){void 0===r&&(r=0);var n=new a(e,t,i,r);return n.executeNext(),n},a.SyncAsyncForLoop=function(r,n,o,e,s,t){return void 0===t&&(t=0),a.Run(Math.ceil(r/n),(function(i){s&&s()?i.breakLoop():setTimeout((function(){for(var e=0;e<n;++e){var t=i.index*n+e;if(r<=t)break;if(o(t),s&&s()){i.breakLoop();break}}i.executeNext()}),t)}),e)},a})();m.AsyncLoop=s})($a||($a={})),(function(o){var a,e;(e=a||(a={}))[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected";var s=function(){this.count=0,this.target=0,this.results=[]},t=(function(){function n(e){var t=this;if(this._state=a.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(n.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}),n.prototype.catch=function(e){return this.then(void 0,e)},n.prototype.then=function(e,t){var i=this,r=new n;return r._onFulfilled=e,r._onRejected=t,this._children.push(r),(r._parent=this)._state!==a.Pending&&o.Tools.SetImmediate((function(){if(i._state===a.Fulfilled||i._rejectWasConsumed){var e=r._resolve(i._result);if(null!=e)if(void 0!==e._state){var t=e;r._children.push(t),t._parent=r,r=t}else r._result=e}else r._reject(i._reason)})),r},n.prototype._moveChildren=function(e){var t,i=this;if((t=this._children).push.apply(t,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=i})),this._state===a.Fulfilled)for(var r=0,n=this._children;r<n.length;r++){n[r]._resolve(this._result)}else if(this._state===a.Rejected)for(var o=0,s=this._children;o<s.length;o++){s[o]._reject(this._reason)}},n.prototype._resolve=function(e){try{this._state=a.Fulfilled;var t=null;if(this._onFulfilled&&(t=this._onFulfilled(e)),null!=t)if(void 0!==t._state){var i=t;i._parent=this,i._moveChildren(this._children),e=i._result}else e=t;this._result=e;for(var r=0,n=this._children;r<n.length;r++){n[r]._resolve(e)}this._children.length=0,delete this._onFulfilled,delete this._onRejected}catch(e){this._reject(e,!0)}},n.prototype._reject=function(t,e){if(void 0===e&&(e=!1),this._state=a.Rejected,this._reason=t,this._onRejected&&!e)try{this._onRejected(t),this._rejectWasConsumed=!0}catch(e){t=e}for(var i=0,r=this._children;i<r.length;i++){var n=r[i];this._rejectWasConsumed?n._resolve(null):n._reject(t)}this._children.length=0,delete this._onFulfilled,delete this._onRejected},n.resolve=function(e){var t=new n;return t._resolve(e),t},n._RegisterForFulfillment=function(e,t,i){e.then((function(e){return t.results[i]=e,t.count++,t.count===t.target&&t.rootPromise._resolve(t.results),null}),(function(e){t.rootPromise._state!==a.Rejected&&t.rootPromise._reject(e)}))},n.all=function(e){var t=new n,i=new s;if(i.target=e.length,i.rootPromise=t,e.length)for(var r=0;r<e.length;r++)n._RegisterForFulfillment(e[r],i,r);else t._resolve([]);return t},n.race=function(e){var t=new n;if(e.length)for(var i=0,r=e;i<r.length;i++){r[i].then((function(e){return t&&(t._resolve(e),t=null),null}),(function(e){t&&(t._reject(e),t=null)}))}return t},n})(),i=(function(){function e(){}return e.Apply=function(e){(void 0===e&&(e=!1),e||"undefined"==typeof Promise)&&(window.Promise=t)},e})();o.PromisePolyfill=i})($a||($a={})),h=$a||($a={}),u=(function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{worker:e,active:!1}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;e<t.length;e++){t[e].worker.terminate()}delete this._workerInfos,delete this._pendingActions},e.prototype.push=function(e){for(var t=0,i=this._workerInfos;t<i.length;t++){var r=i[t];if(!r.active)return void this._execute(r,e)}this._pendingActions.push(e)},e.prototype._execute=function(t,e){var i=this;t.active=!0,e(t.worker,(function(){t.active=!1;var e=i._pendingActions.shift();e&&i._execute(t,e)}))},e})(),h.WorkerPool=u,d=$a||($a={}),f=(function(){function e(){this._isAlphaBlendDirty=!1,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1,this._alphaBlend=!1,this._blendFunctionParameters=new Array(4),this._blendEquationParameters=new Array(2),this._blendConstants=new Array(4),this.reset()}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isAlphaBlendDirty||this._isBlendFunctionParametersDirty},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"alphaBlend",{get:function(){return this._alphaBlend},set:function(e){this._alphaBlend!==e&&(this._alphaBlend=e,this._isAlphaBlendDirty=!0)},enumerable:!0,configurable:!0}),e.prototype.setAlphaBlendConstants=function(e,t,i,r){this._blendConstants[0]===e&&this._blendConstants[1]===t&&this._blendConstants[2]===i&&this._blendConstants[3]===r||(this._blendConstants[0]=e,this._blendConstants[1]=t,this._blendConstants[2]=i,this._blendConstants[3]=r,this._isBlendConstantsDirty=!0)},e.prototype.setAlphaBlendFunctionParameters=function(e,t,i,r){this._blendFunctionParameters[0]===e&&this._blendFunctionParameters[1]===t&&this._blendFunctionParameters[2]===i&&this._blendFunctionParameters[3]===r||(this._blendFunctionParameters[0]=e,this._blendFunctionParameters[1]=t,this._blendFunctionParameters[2]=i,this._blendFunctionParameters[3]=r,this._isBlendFunctionParametersDirty=!0)},e.prototype.setAlphaEquationParameters=function(e,t){this._blendEquationParameters[0]===e&&this._blendEquationParameters[1]===t||(this._blendEquationParameters[0]=e,this._blendEquationParameters[1]=t,this._isBlendEquationParametersDirty=!0)},e.prototype.reset=function(){this._alphaBlend=!1,this._blendFunctionParameters[0]=null,this._blendFunctionParameters[1]=null,this._blendFunctionParameters[2]=null,this._blendFunctionParameters[3]=null,this._blendEquationParameters[0]=null,this._blendEquationParameters[1]=null,this._blendConstants[0]=null,this._blendConstants[1]=null,this._blendConstants[2]=null,this._blendConstants[3]=null,this._isAlphaBlendDirty=!0,this._isBlendFunctionParametersDirty=!1,this._isBlendEquationParametersDirty=!1,this._isBlendConstantsDirty=!1},e.prototype.apply=function(e){this.isDirty&&(this._isAlphaBlendDirty&&(this._alphaBlend?e.enable(e.BLEND):e.disable(e.BLEND),this._isAlphaBlendDirty=!1),this._isBlendFunctionParametersDirty&&(e.blendFuncSeparate(this._blendFunctionParameters[0],this._blendFunctionParameters[1],this._blendFunctionParameters[2],this._blendFunctionParameters[3]),this._isBlendFunctionParametersDirty=!1),this._isBlendEquationParametersDirty&&(e.blendEquationSeparate(this._blendEquationParameters[0],this._blendEquationParameters[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e})(),d._AlphaState=f,p=$a||($a={}),m=(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})(),p._DepthCullingState=m,g=$a||($a={}),v=(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=g.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=g.Engine.KEEP,this._stencilOpDepthFail=g.Engine.KEEP,this._stencilOpStencilDepthPass=g.Engine.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})(),g._StencilState=v;var y,x,E,A,P,S,R,M,C,O,D,I,w,L,F,B,N,V,U,z,G,k,W,H,X,j,Y,K,Q,Z,q,J,$,ee,te,ie,re,ne,oe,se,ae=this&&this.__assign||function(){return(ae=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!(function(M){var b=function(){},e=function(){};M.InstancingAttributeInfo=e;var h=function(){};M.RenderTargetCreationOptions=h;var t=function(){};M.DepthTextureCreationOptions=t;var l=function(){};M.EngineCapabilities=l;var i=(function(){function R(e,t,i,r){void 0===r&&(r=!1);var n=this;this.forcePOTTextures=!1,this.isFullscreen=!1,this.isPointerLock=!1,this.cullBackFaces=!0,this.renderEvenInBackground=!0,this.preventCacheWipeBetweenFrames=!1,this.enableOfflineSupport=!1,this.disableManifestCheck=!1,this.scenes=new Array,this.postProcesses=new Array,this.validateShaderPrograms=!1,this.onResizeObservable=new M.Observable,this.onCanvasBlurObservable=new M.Observable,this.onCanvasFocusObservable=new M.Observable,this.onCanvasPointerOutObservable=new M.Observable,this.onBeforeTextureInitObservable=new M.Observable,this._vrDisplay=void 0,this._vrSupported=!1,this._vrExclusivePointerMode=!1,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this.onBeginFrameObservable=new M.Observable,this.onEndFrameObservable=new M.Observable,this.onBeforeShaderCompilationObservable=new M.Observable,this.onAfterShaderCompilationObservable=new M.Observable,this._windowIsBackground=!1,this._webGLVersion=1,this._badOS=!1,this._badDesktopOS=!1,this.disableTextureBindingOptimization=!1,this.onVRDisplayChangedObservable=new M.Observable,this.onVRRequestPresentComplete=new M.Observable,this.onVRRequestPresentStart=new M.Observable,this._colorWrite=!0,this._drawCalls=new M.PerfCounter,this._textureCollisions=new M.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this.onContextLostObservable=new M.Observable,this.onContextRestoredObservable=new M.Observable,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this._performanceMonitor=new M.PerformanceMonitor,this._fps=60,this._deltaTime=0,this.disablePerformanceMonitorInBackground=!1,this._depthCullingState=new M._DepthCullingState,this._stencilState=new M._StencilState,this._alphaState=new M._AlphaState,this._alphaMode=R.ALPHA_DISABLE,this._internalTexturesCache=new Array,this._activeChannel=0,this._currentTextureChannel=-1,this._boundTexturesCache={},this._compiledEffects={},this._vertexAttribArraysEnabled=[],this._uintIndicesCurrentlySet=!1,this._currentBoundBuffer=new Array,this._currentFramebuffer=null,this._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._firstBoundInternalTextureTracker=new M.DummyInternalTextureTracker,this._lastBoundInternalTextureTracker=new M.DummyInternalTextureTracker,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 M.Vector4(0,0,0,0),this._onVRFullScreenTriggered=function(){if(n._vrDisplay&&n._vrDisplay.isPresenting){n._oldSize=new M.Size(n.getRenderWidth(),n.getRenderHeight()),n._oldHardwareScaleFactor=n.getHardwareScalingLevel();var e=n._vrDisplay.getEyeParameters("left");n.setHardwareScalingLevel(1),n.setSize(2*e.renderWidth,e.renderHeight)}else n.setHardwareScalingLevel(n._oldHardwareScaleFactor),n.setSize(n._oldSize.width,n._oldSize.height)},this._unpackFlipYCached=null,this.enableUnpackFlipYCached=!0,this._boundUniforms={},M.PromisePolyfill.Apply();var o=null;if(R.Instances.push(this),e){if(i=i||{},e.getContext){if(o=e,this._renderingCanvas=o,null!=t&&(i.antialias=t),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 s=navigator.userAgent,a=0,l=R.ExceptionList;a<l.length;a++){var c=l[a],h=c.key,u=c.targets;if(-1<s.indexOf(h)){if(c.capture&&c.captureConstraint){var d=c.capture,f=c.captureConstraint,p=new RegExp(d).exec(s);if(p&&0<p.length)if(f<=parseInt(p[p.length-1]))continue}for(var m=0,_=u;m<_.length;m++){switch(_[m]){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"textureBindingOptimization":this.disableTextureBindingOptimization=!0}}}}if(!i.disableWebGL2Support)try{this._gl=o.getContext("webgl2",i)||o.getContext("experimental-webgl2",i),this._gl&&(this._webGLVersion=2,this._gl.deleteQuery||(this._webGLVersion=1))}catch(e){}if(!this._gl){if(!o)throw new Error("The provided canvas is null or undefined.");try{this._gl=o.getContext("webgl",i)||o.getContext("experimental-webgl",i)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onCanvasFocus=function(){n.onCanvasFocusObservable.notifyObservers(n)},this._onCanvasBlur=function(){n.onCanvasBlurObservable.notifyObservers(n)},o.addEventListener("focus",this._onCanvasFocus),o.addEventListener("blur",this._onCanvasBlur),this._onBlur=function(){n.disablePerformanceMonitorInBackground&&n._performanceMonitor.disable(),n._windowIsBackground=!0},this._onFocus=function(){n.disablePerformanceMonitorInBackground&&n._performanceMonitor.enable(),n._windowIsBackground=!1},this._onCanvasPointerOut=function(e){n.onCanvasPointerOutObservable.notifyObservers(e)},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus),o.addEventListener("pointerout",this._onCanvasPointerOut),this._doNotHandleContextLost||(this._onContextLost=function(e){e.preventDefault(),n._contextWasLost=!0,M.Tools.Warn("WebGL context lost."),n.onContextLostObservable.notifyObservers(n)},this._onContextRestored=function(e){setTimeout((function(){n._initGLContext(),n._rebuildEffects(),n._rebuildInternalTextures(),n._rebuildBuffers(),n.wipeCaches(!0),M.Tools.Warn("WebGL context successfully restored."),n.onContextRestoredObservable.notifyObservers(n),n._contextWasLost=!1}),0)},o.addEventListener("webglcontextlost",this._onContextLost,!1),o.addEventListener("webglcontextrestored",this._onContextRestored,!1))}else{this._gl=e,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2);var g=this._gl.getContextAttributes();g&&(i.stencil=g.stencil)}var v=i.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=r?1/Math.min(v,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=!!i.stencil,this._initGLContext(),o&&(this._onFullscreenChange=function(){void 0!==document.fullscreen?n.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?n.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?n.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(n.isFullscreen=document.msIsFullScreen),n.isFullscreen&&n._pointerLockRequested&&o&&(o.requestPointerLock=o.requestPointerLock||o.msRequestPointerLock||o.mozRequestPointerLock||o.webkitRequestPointerLock,o.requestPointerLock&&o.requestPointerLock())},document.addEventListener("fullscreenchange",this._onFullscreenChange,!1),document.addEventListener("mozfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("webkitfullscreenchange",this._onFullscreenChange,!1),document.addEventListener("msfullscreenchange",this._onFullscreenChange,!1),this._onPointerLockChange=function(){n.isPointerLock=document.mozPointerLockElement===o||document.webkitPointerLockElement===o||document.msPointerLockElement===o||document.pointerLockElement===o},document.addEventListener("pointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mspointerlockchange",this._onPointerLockChange,!1),document.addEventListener("mozpointerlockchange",this._onPointerLockChange,!1),document.addEventListener("webkitpointerlockchange",this._onPointerLockChange,!1),this._onVRDisplayPointerRestricted=function(){o&&o.requestPointerLock()},this._onVRDisplayPointerUnrestricted=function(){document.exitPointerLock()},window.addEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted,!1),window.addEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted,!1)),!R.audioEngine&&i.audioEngine&&R.AudioEngineFactory&&(R.audioEngine=R.AudioEngineFactory(this.getRenderingCanvas()));for(var y=0;y<this._caps.maxVertexAttribs;y++)this._currentBufferPointers[y]=new b;this._linkTrackers(this._firstBoundInternalTextureTracker,this._lastBoundInternalTextureTracker),i.autoEnableWebVR&&this.initWebVR(),this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),console.log("Babylon.js engine (v"+R.Version+") launched"),this.enableOfflineSupport=void 0!==M.Database}}return Object.defineProperty(R,"LastCreatedEngine",{get:function(){return 0===R.Instances.length?null:R.Instances[R.Instances.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(R,"LastCreatedScene",{get:function(){var e=R.LastCreatedEngine;return e?0===e.scenes.length?null:e.scenes[e.scenes.length-1]:null},enumerable:!0,configurable:!0}),R.MarkAllMaterialsAsDirty=function(e,t){for(var i=0;i<R.Instances.length;i++)for(var r=R.Instances[i],n=0;n<r.scenes.length;n++)r.scenes[n].markAllMaterialsAsDirty(e,t)},Object.defineProperty(R,"Version",{get:function(){return"3.3.0"},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"isInVRExclusivePointerMode",{get:function(){return this._vrExclusivePointerMode},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"supportsUniformBuffers",{get:function(){return 1<this.webGLVersion&&!this.disableUniformBuffers},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"doNotHandleContextLost",{get:function(){return this._doNotHandleContextLost},set:function(e){this._doNotHandleContextLost=e},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,R.TEXTUREFORMAT_RGBA,!1,!1,R.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,R.TEXTUREFORMAT_RGBA,!1,!1,R.TEXTURE_NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var e=new Uint8Array(4),t=[e,e,e,e,e,e];this._emptyCubeTexture=this.createRawCubeTexture(t,1,R.TEXTUREFORMAT_RGBA,R.TEXTURETYPE_UNSIGNED_INT,!1,!1,R.TEXTURE_NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!0,configurable:!0}),R.prototype._rebuildInternalTextures=function(){for(var e=0,t=this._internalTexturesCache.slice();e<t.length;e++){t[e]._rebuild()}},R.prototype._rebuildEffects=function(){for(var e in this._compiledEffects){this._compiledEffects[e]._prepareEffect()}M.Effect.ResetCache()},R.prototype._rebuildBuffers=function(){for(var e=0,t=this.scenes;e<t.length;e++){var i=t[e];i.resetCachedMaterial(),i._rebuildGeometries(),i._rebuildTextures()}for(var r=0,n=this._uniformBuffers;r<n.length;r++){n[r]._rebuild()}},R.prototype._initGLContext=function(){this._caps=new l,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxCombinedTexturesImageUnits=this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureImageUnits=this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var e=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),this._gl.HALF_FLOAT_OES=36193,34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.standardDerivatives=1<this._webGLVersion||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=1<this._webGLVersion||null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=1<this._webGLVersion||null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!0,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=0<this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)),this._caps.colorBufferFloat=1<this._webGLVersion&&this._gl.getExtension("EXT_color_buffer_float"),this._caps.textureFloat=!!(1<this._webGLVersion||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=!!(1<this._webGLVersion||this._gl.getExtension("OES_texture_half_float")),this._caps.textureHalfFloatLinearFiltering=!!(1<this._webGLVersion||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),1<this._webGLVersion&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._caps.textureLOD=!!(1<this._webGLVersion||this._gl.getExtension("EXT_shader_texture_lod")),1<this._webGLVersion)this._caps.drawBuffersExtension=!0;else{var t=this._gl.getExtension("WEBGL_draw_buffers");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var i=0;i<16;i++)this._gl["COLOR_ATTACHMENT"+i+"_WEBGL"]=t["COLOR_ATTACHMENT"+i+"_WEBGL"]}else this._caps.drawBuffersExtension=!1}if(1<this._webGLVersion)this._caps.depthTextureExtension=!0;else{var r=this._gl.getExtension("WEBGL_depth_texture");null!=r&&(this._caps.depthTextureExtension=!0,this._gl.UNSIGNED_INT_24_8=r.UNSIGNED_INT_24_8_WEBGL)}if(1<this._webGLVersion)this._caps.vertexArrayObject=!0;else{var n=this._gl.getExtension("OES_vertex_array_object");null!=n?(this._caps.vertexArrayObject=!0,this._gl.createVertexArray=n.createVertexArrayOES.bind(n),this._gl.bindVertexArray=n.bindVertexArrayOES.bind(n),this._gl.deleteVertexArray=n.deleteVertexArrayOES.bind(n)):this._caps.vertexArrayObject=!1}if(1<this._webGLVersion)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 s=this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER,this._gl.HIGH_FLOAT);s&&(this._caps.highPrecisionShaderSupported=0!==s.precision)}this.setDepthBuffer(!0),this.setDepthFunctionToLessOrEqual(),this.setDepthWrite(!0),this._maxSimultaneousTextures=this._caps.maxCombinedTexturesImageUnits;for(var a=0;a<this._maxSimultaneousTextures;a++)this._nextFreeTextureSlots.push(a)},Object.defineProperty(R.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),R.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=document.createElement("canvas");var e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}},R.prototype.resetTextureCache=function(){for(var e in this._boundTexturesCache)if(this._boundTexturesCache.hasOwnProperty(e)){var t=this._boundTexturesCache[e];t&&this._removeDesignatedSlot(t),this._boundTexturesCache[e]=null}if(!this.disableTextureBindingOptimization){this._nextFreeTextureSlots=[];for(var i=0;i<this._maxSimultaneousTextures;i++)this._nextFreeTextureSlots.push(i)}this._currentTextureChannel=-1},R.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},R.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},R.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},R.prototype.getAspectRatio=function(e,t){void 0===t&&(t=!1);var i=e.viewport;return this.getRenderWidth(t)*i.width/(this.getRenderHeight(t)*i.height)},R.prototype.getScreenAspectRatio=function(){return this.getRenderWidth(!0)/this.getRenderHeight(!0)},R.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._gl.drawingBufferWidth},R.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._gl.drawingBufferHeight},R.prototype.getRenderingCanvas=function(){return this._renderingCanvas},R.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},R.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},R.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},R.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},R.prototype.getCaps=function(){return this._caps},Object.defineProperty(R.prototype,"drawCalls",{get:function(){return M.Tools.Warn("drawCalls is deprecated. Please use SceneInstrumentation class"),0},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"drawCallsPerfCounter",{get:function(){return M.Tools.Warn("drawCallsPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),R.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},R.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},R.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},R.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},R.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},R.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},R.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},R.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},R.prototype.getStencilMask=function(){return this._stencilState.stencilMask},R.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},R.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},R.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},R.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},R.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},R.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},R.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},R.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},R.prototype.getStencilOperationDepthFail=function(){return this._stencilState.stencilOpDepthFail},R.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},R.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},R.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},R.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},R.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},R.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},R.prototype.stopRenderLoop=function(e){if(e){var t=this._activeRenderLoops.indexOf(e);0<=t&&this._activeRenderLoops.splice(t,1)}else this._activeRenderLoops=[]},R.prototype._renderLoop=function(){if(!this._contextWasLost){var e=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(e=!1),e){this.beginFrame();for(var t=0;t<this._activeRenderLoops.length;t++){(0,this._activeRenderLoops[t])()}this.endFrame()}}if(0<this._activeRenderLoops.length){var i=null;this._vrDisplay&&this._vrDisplay.isPresenting&&(i=this._vrDisplay),this._frameHandler=M.Tools.QueueNewFrame(this._bindedRenderFunction,i)}else this._renderingQueueLaunched=!1},R.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=M.Tools.QueueNewFrame(this._bindedRenderFunction)))},R.prototype.switchFullscreen=function(e){this.isFullscreen?M.Tools.ExitFullscreen():(this._pointerLockRequested=e,this._renderingCanvas&&M.Tools.RequestFullscreen(this._renderingCanvas))},R.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1),this.applyStates();var n=0;t&&e&&(this._gl.clearColor(e.r,e.g,e.b,void 0!==e.a?e.a:1),n|=this._gl.COLOR_BUFFER_BIT),i&&(this._gl.clearDepth(1),n|=this._gl.DEPTH_BUFFER_BIT),r&&(this._gl.clearStencil(0),n|=this._gl.STENCIL_BUFFER_BIT),this._gl.clear(n)},R.prototype.scissorClear=function(e,t,i,r,n){var o=this._gl,s=o.getParameter(o.SCISSOR_TEST),a=o.getParameter(o.SCISSOR_BOX);o.enable(o.SCISSOR_TEST),o.scissor(e,t,i,r),this.clear(n,!0,!0,!0),o.scissor(a[0],a[1],a[2],a[3]),!0===s?o.enable(o.SCISSOR_TEST):o.disable(o.SCISSOR_TEST)},R.prototype._viewport=function(e,t,i,r){e===this._viewportCached.x&&t===this._viewportCached.y&&i===this._viewportCached.z&&r===this._viewportCached.w||(this._viewportCached.x=e,this._viewportCached.y=t,this._viewportCached.z=i,this._viewportCached.w=r,this._gl.viewport(e,t,i,r))},R.prototype.setViewport=function(e,t,i){var r=t||this.getRenderWidth(),n=i||this.getRenderHeight(),o=e.x||0,s=e.y||0;this._cachedViewport=e,this._viewport(o*r,s*n,r*e.width,n*e.height)},R.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._viewport(e,t,i,r),n},R.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this),this._measureFps()},R.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.submitFrame(),this.onEndFrameObservable.notifyObservers(this)},R.prototype.resize=function(){if(!this._vrDisplay||!this._vrDisplay.isPresenting){var e=this._renderingCanvas?this._renderingCanvas.clientWidth:window.innerWidth,t=this._renderingCanvas?this._renderingCanvas.clientHeight:window.innerHeight;this.setSize(e/this._hardwareScalingLevel,t/this._hardwareScalingLevel)}},R.prototype.setSize=function(e,t){if(this._renderingCanvas&&(this._renderingCanvas.width!==e||this._renderingCanvas.height!==t)){this._renderingCanvas.width=e,this._renderingCanvas.height=t;for(var i=0;i<this.scenes.length;i++)for(var r=this.scenes[i],n=0;n<r.cameras.length;n++){r.cameras[n]._currentRenderId=0}this.onResizeObservable.hasObservers&&this.onResizeObservable.notifyObservers(this)}},R.prototype.isVRDevicePresent=function(){return!!this._vrDisplay},R.prototype.getVRDevice=function(){return this._vrDisplay},R.prototype.initWebVR=function(){return this.initWebVRAsync(),this.onVRDisplayChangedObservable},R.prototype.initWebVRAsync=function(){var i=this,t=function(){var t={vrDisplay:i._vrDisplay,vrSupported:i._vrSupported};i.onVRDisplayChangedObservable.notifyObservers(t),i._webVRInitPromise=new Promise(function(e){e(t)})};return this._onVrDisplayConnect||(this._onVrDisplayConnect=function(e){i._vrDisplay=e.display,t()},this._onVrDisplayDisconnect=function(){i._vrDisplay.cancelAnimationFrame(i._frameHandler),i._vrDisplay=void 0,i._frameHandler=M.Tools.QueueNewFrame(i._bindedRenderFunction),t()},this._onVrDisplayPresentChange=function(){i._vrExclusivePointerMode=i._vrDisplay&&i._vrDisplay.isPresenting},window.addEventListener("vrdisplayconnect",this._onVrDisplayConnect),window.addEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),window.addEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange)),this._webVRInitPromise=this._webVRInitPromise||this._getVRDisplaysAsync(),this._webVRInitPromise.then(t),this._webVRInitPromise},R.prototype.enableVR=function(){var e=this;if(this._vrDisplay&&!this._vrDisplay.isPresenting){this.onVRRequestPresentStart.notifyObservers(this),this._vrDisplay.requestPresent([{source:this.getRenderingCanvas()}]).then((function(){e.onVRRequestPresentComplete.notifyObservers(!0),e._onVRFullScreenTriggered()})).catch((function(){e.onVRRequestPresentComplete.notifyObservers(!1)}))}},R.prototype.disableVR=function(){this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered)},R.prototype._getVRDisplaysAsync=function(){var i=this;return new Promise(function(t,e){navigator.getVRDisplays?navigator.getVRDisplays().then((function(e){i._vrSupported=!0,i._vrDisplay=e[0],t({vrDisplay:i._vrDisplay,vrSupported:i._vrSupported})})):(i._vrDisplay=void 0,i._vrSupported=!1,t({vrDisplay:i._vrDisplay,vrSupported:i._vrSupported}))})},R.prototype.bindFramebuffer=function(e,t,i,r,n,o,s){void 0===s&&(s=0),this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this.bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var a=this._gl;e.isCube&&(void 0===t&&(t=0),a.framebufferTexture2D(a.FRAMEBUFFER,a.COLOR_ATTACHMENT0,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,s),o&&(o._generateStencilBuffer?a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_STENCIL_ATTACHMENT,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,s):a.framebufferTexture2D(a.FRAMEBUFFER,a.DEPTH_ATTACHMENT,a.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,s))),this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,r):(i||(i=e.width,s&&(i/=Math.pow(2,s))),r||(r=e.height,s&&(r/=Math.pow(2,s))),this._viewport(0,0,i,r)),this.wipeCaches()},R.prototype.bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},R.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;e._MSAAFramebuffer&&(r.bindFramebuffer(r.READ_FRAMEBUFFER,e._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e._framebuffer),r.blitFramebuffer(0,0,e.width,e.height,0,0,e.width,e.height,r.COLOR_BUFFER_BIT,r.NEAREST)),!e.generateMipMaps||t||e.isCube||(this._bindTextureDirectly(r.TEXTURE_2D,e,!0),r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null)),i&&(e._MSAAFramebuffer&&this.bindUnboundFramebuffer(e._framebuffer),i()),this.bindUnboundFramebuffer(null)},R.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;if(e[0]._MSAAFramebuffer){r.bindFramebuffer(r.READ_FRAMEBUFFER,e[0]._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e[0]._framebuffer);var n=e[0]._attachments;n||(n=new Array(e.length),e[0]._attachments=n);for(var o=0;o<e.length;o++){for(var s=e[o],a=0;a<n.length;a++)n[a]=r.NONE;n[o]=r[1<this.webGLVersion?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],r.readBuffer(n[o]),r.drawBuffers(n),r.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,r.COLOR_BUFFER_BIT,r.NEAREST)}for(o=0;o<n.length;o++)n[o]=r[1<this.webGLVersion?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"];r.drawBuffers(n)}for(o=0;o<e.length;o++){!(s=e[o]).generateMipMaps||t||s.isCube||(this._bindTextureDirectly(r.TEXTURE_2D,s),r.generateMipmap(r.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null))}i&&(e[0]._MSAAFramebuffer&&this.bindUnboundFramebuffer(e[0]._framebuffer),i()),this.bindUnboundFramebuffer(null)},R.prototype.generateMipMapsForCubemap=function(e){if(e.generateMipMaps){var t=this._gl;this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,e,!0),t.generateMipmap(t.TEXTURE_CUBE_MAP),this._bindTextureDirectly(t.TEXTURE_CUBE_MAP,null)}},R.prototype.flushFramebuffer=function(){this._gl.flush()},R.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this.bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},R.prototype.createUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create uniform buffer");return this.bindUniformBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW),this.bindUniformBuffer(null),t.references=1,t},R.prototype.createDynamicUniformBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic uniform buffer");return this.bindUniformBuffer(t),e instanceof Float32Array?this._gl.bufferData(this._gl.UNIFORM_BUFFER,e,this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.UNIFORM_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW),this.bindUniformBuffer(null),t.references=1,t},R.prototype.updateUniformBuffer=function(e,t,i,r){this.bindUniformBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,t):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,i,new Float32Array(t)):t instanceof Float32Array?this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,t.subarray(i,i+r)):this._gl.bufferSubData(this._gl.UNIFORM_BUFFER,0,new Float32Array(t).subarray(i,i+r)),this.bindUniformBuffer(null)},R.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},R.prototype.createVertexBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create vertex buffer");return this.bindArrayBuffer(t),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.STATIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.STATIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},R.prototype.createDynamicVertexBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create dynamic vertex buffer");return this.bindArrayBuffer(t),e instanceof Array?this._gl.bufferData(this._gl.ARRAY_BUFFER,new Float32Array(e),this._gl.DYNAMIC_DRAW):this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),this._resetVertexBufferBinding(),t.references=1,t},R.prototype.updateDynamicIndexBuffer=function(e,t,i){var r;void 0===i&&(i=0),this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e),r=t instanceof Uint16Array||t instanceof Uint32Array?t:e.is32Bits?new Uint32Array(t):new Uint16Array(t),this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,this._gl.DYNAMIC_DRAW),this._resetIndexBufferBinding()},R.prototype.updateDynamicVertexBuffer=function(e,t,i,r){this.bindArrayBuffer(e),void 0===i&&(i=0),void 0===r?t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,new Float32Array(t)):this._gl.bufferSubData(this._gl.ARRAY_BUFFER,i,t):t instanceof Array?this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,new Float32Array(t).subarray(i,i+r)):(t=t instanceof ArrayBuffer?new Uint8Array(t,i,r):new Uint8Array(t.buffer,t.byteOffset+i,r),this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t)),this._resetVertexBufferBinding()},R.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},R.prototype.createIndexBuffer=function(e,t){var i,r=this._gl.createBuffer();if(!r)throw new Error("Unable to create index buffer");this.bindIndexBuffer(r);var n=!1;if(e instanceof Uint16Array)i=e;else if(this._caps.uintIndices)if(e instanceof Uint32Array)i=e,n=!0;else{for(var o=0;o<e.length;o++)if(65535<e[o]){n=!0;break}i=n?new Uint32Array(e):new Uint16Array(e)}else i=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,i,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),r.references=1,r.is32Bits=n,r},R.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},R.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e)},R.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e)},R.prototype.bindUniformBlock=function(e,t,i){var r=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,r,i)},R.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},R.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},R.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},R.prototype._vertexAttribPointer=function(e,t,i,r,n,o,s){var a=this._currentBufferPointers[t],l=!1;a.active?(a.buffer!==e&&(a.buffer=e,l=!0),a.size!==i&&(a.size=i,l=!0),a.type!==r&&(a.type=r,l=!0),a.normalized!==n&&(a.normalized=n,l=!0),a.stride!==o&&(a.stride=o,l=!0),a.offset!==s&&(a.offset=s,l=!0)):(l=!0,a.active=!0,a.index=t,a.size=i,a.type=r,a.normalized=n,a.stride=o,a.offset=s,a.buffer=e),(l||this._vaoRecordInProgress)&&(this.bindArrayBuffer(e),this._gl.vertexAttribPointer(t,i,r,n,o,s))},R.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},R.prototype._bindVertexBuffersAttributes=function(e,t){var i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var r=0;r<i.length;r++){var n=t.getAttributeLocation(r);if(0<=n){var o=e[i[r]];if(!o)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);var s=o.getBuffer();s&&(this._vertexAttribPointer(s,n,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(s))))}}},R.prototype.recordVertexArrayObject=function(e,t,i){var r=this._gl.createVertexArray();return this._vaoRecordInProgress=!0,this._gl.bindVertexArray(r),this._mustWipeVertexAttributes=!0,this._bindVertexBuffersAttributes(e,i),this.bindIndexBuffer(t),this._vaoRecordInProgress=!1,this._gl.bindVertexArray(null),r},R.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)},R.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e;var o=(this._cachedEffectForVertexBuffers=n).getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var s=0,a=0;a<o;a++)if(a<i.length){var l=n.getAttributeLocation(a);0<=l&&(this._gl.enableVertexAttribArray(l),this._vertexAttribArraysEnabled[l]=!0,this._vertexAttribPointer(e,l,i[a],this._gl.FLOAT,!1,r,s)),s+=4*i[a]}}this._bindIndexBufferWithCache(t)},R.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},R.prototype.bindBuffers=function(e,t,i){this._cachedVertexBuffers===e&&this._cachedEffectForVertexBuffers===i||(this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=i,this._bindVertexBuffersAttributes(e,i)),this._bindIndexBufferWithCache(t)},R.prototype.unbindInstanceAttributes=function(){for(var e,t=0,i=this._currentInstanceLocations.length;t<i;t++){var r=this._currentInstanceBuffers[t];e!=r&&r.references&&(e=r,this.bindArrayBuffer(r));var n=this._currentInstanceLocations[t];this._gl.vertexAttribDivisor(n,0)}this._currentInstanceBuffers.length=0,this._currentInstanceLocations.length=0},R.prototype.releaseVertexArrayObject=function(e){this._gl.deleteVertexArray(e)},R.prototype._releaseBuffer=function(e){return e.references--,0===e.references&&(this._gl.deleteBuffer(e),!0)},R.prototype.createInstancesBuffer=function(e){var t=this._gl.createBuffer();if(!t)throw new Error("Unable to create instance buffer");return t.capacity=e,this.bindArrayBuffer(t),this._gl.bufferData(this._gl.ARRAY_BUFFER,e,this._gl.DYNAMIC_DRAW),t},R.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},R.prototype.updateAndBindInstancesBuffer=function(e,t,i){if(this.bindArrayBuffer(e),t&&this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,t),void 0!==i[0].index){for(var r=0,n=0;n<i.length;n++){r+=4*(o=i[n]).attributeSize}for(n=0;n<i.length;n++){var o=i[n];this._vertexAttribArraysEnabled[o.index]||(this._gl.enableVertexAttribArray(o.index),this._vertexAttribArraysEnabled[o.index]=!0),this._vertexAttribPointer(e,o.index,o.attributeSize,o.attribyteType||this._gl.FLOAT,o.normalized||!1,r,o.offset),this._gl.vertexAttribDivisor(o.index,1),this._currentInstanceLocations.push(o.index),this._currentInstanceBuffers.push(e)}}else for(var s=0;s<4;s++){var a=i[s];this._vertexAttribArraysEnabled[a]||(this._gl.enableVertexAttribArray(a),this._vertexAttribArraysEnabled[a]=!0),this._vertexAttribPointer(e,a,4,this._gl.FLOAT,!1,64,16*s),this._gl.vertexAttribDivisor(a,1),this._currentInstanceLocations.push(a),this._currentInstanceBuffers.push(e)}},R.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl)},R.prototype.draw=function(e,t,i,r){this.drawElementsType(e?M.Material.TriangleFillMode:M.Material.WireFrameFillMode,t,i,r)},R.prototype.drawPointClouds=function(e,t,i){this.drawArraysType(M.Material.PointFillMode,e,t,i)},R.prototype.drawUnIndexed=function(e,t,i,r){this.drawArraysType(e?M.Material.TriangleFillMode:M.Material.WireFrameFillMode,t,i,r)},R.prototype.drawElementsType=function(e,t,i,r){this.applyStates(),this._drawCalls.addCount(1,!1);var n=this._drawMode(e),o=this._uintIndicesCurrentlySet?this._gl.UNSIGNED_INT:this._gl.UNSIGNED_SHORT,s=this._uintIndicesCurrentlySet?4:2;r?this._gl.drawElementsInstanced(n,i,o,t*s,r):this._gl.drawElements(n,i,o,t*s)},R.prototype.drawArraysType=function(e,t,i,r){this.applyStates(),this._drawCalls.addCount(1,!1);var n=this._drawMode(e);r?this._gl.drawArraysInstanced(n,t,i,r):this._gl.drawArrays(n,t,i)},R.prototype._drawMode=function(e){switch(e){case M.Material.TriangleFillMode:return this._gl.TRIANGLES;case M.Material.PointFillMode:return this._gl.POINTS;case M.Material.WireFrameFillMode:return this._gl.LINES;case M.Material.PointListDrawMode:return this._gl.POINTS;case M.Material.LineListDrawMode:return this._gl.LINES;case M.Material.LineLoopDrawMode:return this._gl.LINE_LOOP;case M.Material.LineStripDrawMode:return this._gl.LINE_STRIP;case M.Material.TriangleStripDrawMode:return this._gl.TRIANGLE_STRIP;case M.Material.TriangleFanDrawMode:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}},R.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deleteProgram(e.getProgram()))},R.prototype._deleteProgram=function(e){e&&(e.__SPECTOR_rebuildProgram=null,e.transformFeedback&&(this.deleteTransformFeedback(e.transformFeedback),e.transformFeedback=null),this._gl.deleteProgram(e))},R.prototype.createEffect=function(e,t,i,r,n,o,s,a,l){var c=(e.vertexElement||e.vertex||e)+"+"+(e.fragmentElement||e.fragment||e)+"@"+(n||t.defines);if(this._compiledEffects[c]){var h=this._compiledEffects[c];return s&&h.isReady()&&s(h),h}var u=new M.Effect(e,t,i,r,this,n,o,s,a,l);return u._key=c,this._compiledEffects[c]=u},R.prototype._compileShader=function(e,t,i,r){return this._compileRawShader(r+(i?i+"\n":"")+e,t)},R.prototype._compileRawShader=function(e,t){var i=this._gl,r=i.createShader("vertex"===t?i.VERTEX_SHADER:i.FRAGMENT_SHADER);if(!r)throw new Error("Something went wrong while compile the shader.");if(i.shaderSource(r,e),i.compileShader(r),!i.getShaderParameter(r,i.COMPILE_STATUS)){var n=i.getShaderInfoLog(r);if(n)throw new Error(n)}return r},R.prototype.createRawShaderProgram=function(e,t,i,r){void 0===r&&(r=null),i=i||this._gl;var n=this._compileRawShader(e,"vertex"),o=this._compileRawShader(t,"fragment");return this._createShaderProgram(n,o,i,r)},R.prototype.createShaderProgram=function(e,t,i,r,n){void 0===n&&(n=null),r=r||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var o=1<this._webGLVersion?"#version 300 es\n#define WEBGL2 \n":"",s=this._compileShader(e,"vertex",i,o),a=this._compileShader(t,"fragment",i,o),l=this._createShaderProgram(s,a,r,n);return this.onAfterShaderCompilationObservable.notifyObservers(this),l},R.prototype._createShaderProgram=function(e,t,i,r){void 0===r&&(r=null);var n,o=i.createProgram();if(!o)throw new Error("Unable to create program");if(i.attachShader(o,e),i.attachShader(o,t),1<this.webGLVersion&&r){var s=this.createTransformFeedback();this.bindTransformFeedback(s),this.setTranformFeedbackVaryings(o,r),o.transformFeedback=s}if((i.linkProgram(o),1<this.webGLVersion&&r&&this.bindTransformFeedback(null),!i.getProgramParameter(o,i.LINK_STATUS))&&(n=i.getProgramInfoLog(o)))throw new Error(n);if(this.validateShaderPrograms&&(i.validateProgram(o),!i.getProgramParameter(o,i.VALIDATE_STATUS)&&(n=i.getProgramInfoLog(o))))throw new Error(n);return i.deleteShader(e),i.deleteShader(t),o},R.prototype.getUniforms=function(e,t){for(var i=new Array,r=0;r<t.length;r++)i.push(this._gl.getUniformLocation(e,t[r]));return i},R.prototype.getAttributes=function(e,t){for(var i=[],r=0;r<t.length;r++)try{i.push(this._gl.getAttribLocation(e,t[r]))}catch(e){i.push(-1)}return i},R.prototype.enableEffect=function(e){e&&e!==this._currentEffect&&(this.bindSamplers(e),(this._currentEffect=e).onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e))},R.prototype.setIntArray=function(e,t){e&&this._gl.uniform1iv(e,t)},R.prototype.setIntArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2iv(e,t)},R.prototype.setIntArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3iv(e,t)},R.prototype.setIntArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4iv(e,t)},R.prototype.setFloatArray=function(e,t){e&&this._gl.uniform1fv(e,t)},R.prototype.setFloatArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},R.prototype.setFloatArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},R.prototype.setFloatArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},R.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},R.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},R.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},R.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},R.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},R.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},R.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},R.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},R.prototype.setInt=function(e,t){e&&this._gl.uniform1i(e,t)},R.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},R.prototype.setFloat2=function(e,t,i){e&&this._gl.uniform2f(e,t,i)},R.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},R.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},R.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},R.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},R.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},R.prototype.setDirectColor4=function(e,t){e&&this._gl.uniform4f(e,t.r,t.g,t.b,t.a)},R.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1),(this._depthCullingState.cull!==e||i)&&(this._depthCullingState.cull=e);var n=this.cullBackFaces?this._gl.BACK:this._gl.FRONT;(this._depthCullingState.cullFace!==n||i)&&(this._depthCullingState.cullFace=n),this.setZOffset(t);var o=r?this._gl.CW:this._gl.CCW;(this._depthCullingState.frontFace!==o||i)&&(this._depthCullingState.frontFace=o)},R.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},R.prototype.getZOffset=function(){return this._depthCullingState.zOffset},R.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},R.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},R.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},R.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e),this._colorWrite=e},R.prototype.getColorWrite=function(){return this._colorWrite},R.prototype.setAlphaConstants=function(e,t,i,r){this._alphaState.setAlphaBlendConstants(e,t,i,r)},R.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case R.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case R.ALPHA_PREMULTIPLIED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case R.ALPHA_PREMULTIPLIED_PORTERDUFF:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0;break;case R.ALPHA_COMBINE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_ALPHA,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case R.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case R.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case R.ALPHA_SUBTRACT:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case R.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case R.ALPHA_MAXIMIZED:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case R.ALPHA_INTERPOLATE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR,this._gl.ONE_MINUS_CONSTANT_COLOR,this._gl.CONSTANT_ALPHA,this._gl.ONE_MINUS_CONSTANT_ALPHA),this._alphaState.alphaBlend=!0;break;case R.ALPHA_SCREENMODE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE_MINUS_SRC_COLOR,this._gl.ONE,this._gl.ONE_MINUS_SRC_ALPHA),this._alphaState.alphaBlend=!0}t||this.setDepthWrite(e===R.ALPHA_DISABLE),this._alphaMode=e}},R.prototype.getAlphaMode=function(){return this._alphaMode},R.prototype.clearInternalTexturesCache=function(){this._internalTexturesCache=[]},R.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames&&!e||(this._currentEffect=null,this._viewportCached.x=0,this._viewportCached.y=0,this._viewportCached.z=0,this._viewportCached.w=0,e&&(this.resetTextureCache(),this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset(),this._unpackFlipYCached=null),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this._unbindVertexArrayObject(),this.bindIndexBuffer(null))},R.prototype.setTextureFormatToUse=function(e){for(var t=0,i=this.texturesSupported.length;t<i;t++)for(var r=0,n=e.length;r<n;r++)if(this._texturesSupported[t]===e[r].toLowerCase())return this._textureFormatInUse=this._texturesSupported[t];return this._textureFormatInUse=null},R.prototype._getSamplingParameters=function(e,t){var i=this._gl,r=i.NEAREST,n=i.NEAREST;switch(e){case R.TEXTURE_BILINEAR_SAMPLINGMODE:r=i.LINEAR,n=t?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case R.TEXTURE_TRILINEAR_SAMPLINGMODE:r=i.LINEAR,n=t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case R.TEXTURE_NEAREST_SAMPLINGMODE:r=i.NEAREST,n=t?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case R.TEXTURE_NEAREST_NEAREST_MIPNEAREST:r=i.NEAREST,n=t?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case R.TEXTURE_NEAREST_LINEAR_MIPNEAREST:r=i.NEAREST,n=t?i.LINEAR_MIPMAP_NEAREST:i.LINEAR;break;case R.TEXTURE_NEAREST_LINEAR_MIPLINEAR:r=i.NEAREST,n=t?i.LINEAR_MIPMAP_LINEAR:i.LINEAR;break;case R.TEXTURE_NEAREST_LINEAR:r=i.NEAREST,n=i.LINEAR;break;case R.TEXTURE_NEAREST_NEAREST:r=i.NEAREST,n=i.NEAREST;break;case R.TEXTURE_LINEAR_NEAREST_MIPNEAREST:r=i.LINEAR,n=t?i.NEAREST_MIPMAP_NEAREST:i.NEAREST;break;case R.TEXTURE_LINEAR_NEAREST_MIPLINEAR:r=i.LINEAR,n=t?i.NEAREST_MIPMAP_LINEAR:i.NEAREST;break;case R.TEXTURE_LINEAR_LINEAR:r=i.LINEAR,n=i.LINEAR;break;case R.TEXTURE_LINEAR_NEAREST:r=i.LINEAR,n=i.NEAREST}return{min:n,mag:r}},R.prototype._partialLoadImg=function(e,t,i,r,n,o){var s;void 0===o&&(o=null);s=M.Tools.LoadImage(e,(function(){i[t]=s,i._internalCount++,r&&r._removePendingData(s),6===i._internalCount&&n(i)}),(function(e,t){r&&r._removePendingData(s),o&&o(e,t)}),r?r.database:null),r&&r._addPendingData(s)},R.prototype._cascadeLoadImgs=function(e,t,i,r,n){void 0===n&&(n=null);for(var o=[],s=o._internalCount=0;s<6;s++)this._partialLoadImg(r[s],s,o,t,i,n)},R.prototype._createTexture=function(){var e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e},R.prototype.createTexture=function(r,n,o,c,s,e,a,l,t,h,i){var u=this;void 0===s&&(s=R.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===e&&(e=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===t&&(t=null),void 0===h&&(h=null),void 0===i&&(i=null);for(var d=String(r),f="data:"===d.substr(0,5),p="blob:"===d.substr(0,5),m=f&&-1!==d.indexOf(";base64,"),_=t||new M.InternalTexture(this,M.InternalTexture.DATASOURCE_URL),g=d.lastIndexOf("."),v=i||(-1<g?d.substring(g).toLowerCase():""),y=null,b=0,T=R._TextureLoaders;b<T.length;b++){var x=T[b];if(x.canLoad(v,this._textureFormatInUse,t,m,!!l)){y=x;break}}y&&(d=y.transformUrl(d,this._textureFormatInUse)),c&&c._addPendingData(_),_.url=d,_.generateMipMaps=!n,_.samplingMode=s,_.invertY=o,this._doNotHandleContextLost||(_._buffer=l);var E=null;e&&!t&&(E=_.onLoadedObservable.add(e)),t||this._internalTexturesCache.push(_);var A=function(e,t){c&&c._removePendingData(_);var i=!1;y&&(y.getFallbackTextureUrl(d,u._textureFormatInUse)&&(i=!0,u.createTexture(r,n,o,c,s,null,a,l,_)));i||(E&&_.onLoadedObservable.remove(E),M.Tools.UseFallbackTexture&&u.createTexture(M.Tools.fallbackTexture,n,o,c,s,null,a,l,_)),a&&a(e||"Unknown error",t)};if(y){var P=function(e){y.loadData(e,_,(function(e,t,i,r,n){u._prepareWebGLTexture(_,c,e,t,o,!i,r,(function(){return n(),!1}),s)}))};l?P(l):this._loadFile(d,P,void 0,c?c.database:void 0,!0,(function(e,t){A("Unable to load "+(e&&e.responseURL,t))}))}else{var S=function(l){p&&!u._doNotHandleContextLost&&(_._buffer=l),u._prepareWebGLTexture(_,c,l.width,l.height,o,n,!1,(function(e,t,i){var r=u._gl,n=l.width===e&&l.height===t,o=h?u._getInternalFormat(h):".jpg"===v?r.RGB:r.RGBA;if(n)return r.texImage2D(r.TEXTURE_2D,0,o,o,r.UNSIGNED_BYTE,l),!1;var s=u._caps.maxTextureSize;if(l.width>s||l.height>s)return u._prepareWorkingCanvas(),u._workingCanvas&&u._workingContext&&(u._workingCanvas.width=e,u._workingCanvas.height=t,u._workingContext.drawImage(l,0,0,l.width,l.height,0,0,e,t),r.texImage2D(r.TEXTURE_2D,0,o,o,r.UNSIGNED_BYTE,u._workingCanvas),_.width=e,_.height=t),!1;var a=new M.InternalTexture(u,M.InternalTexture.DATASOURCE_TEMP);return u._bindTextureDirectly(r.TEXTURE_2D,a,!0),r.texImage2D(r.TEXTURE_2D,0,o,o,r.UNSIGNED_BYTE,l),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,r.LINEAR),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,r.LINEAR),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),u._rescaleTexture(a,_,c,o,(function(){u._releaseTexture(a),u._bindTextureDirectly(r.TEXTURE_2D,_,!0),i()})),!0}),s)};!f||m?l instanceof HTMLImageElement?S(l):M.Tools.LoadImage(d,S,A,c?c.database:null):"string"==typeof l||l instanceof ArrayBuffer||l instanceof Blob?M.Tools.LoadImage(l,S,A,c?c.database:null):S(l)}return _},R.prototype._rescaleTexture=function(t,i,r,n,o){var s=this,a=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:R.TEXTURETYPE_UNSIGNED_INT,samplingMode:R.TEXTURE_BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});this._rescalePostProcess||(this._rescalePostProcess=new M.PassPostProcess("rescale",1,null,R.TEXTURE_BILINEAR_SAMPLINGMODE,this,!1,R.TEXTURETYPE_UNSIGNED_INT)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){s._rescalePostProcess.onApply=function(e){e._bindTexture("textureSampler",t)};var e=r;e||(e=s.scenes[s.scenes.length-1]),e.postProcessManager.directRender([s._rescalePostProcess],a,!0),s._bindTextureDirectly(s._gl.TEXTURE_2D,i,!0),s._gl.copyTexImage2D(s._gl.TEXTURE_2D,0,n,0,0,i.width,i.height,0),s.unBindFramebuffer(a),s._releaseTexture(a),o&&o()}))},R.prototype.updateRawTexture=function(e,t,i,r,n,o){if(void 0===n&&(n=null),void 0===o&&(o=R.TEXTURETYPE_UNSIGNED_INT),e){var s=this._getRGBABufferInternalSizedFormat(o,i),a=this._getInternalFormat(i),l=this._getWebGLTextureType(o);this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===r||!!r),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.type=o,e.invertY=r,e._compression=n),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[n],e.width,e.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,s,e.width,e.height,0,a,l,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}},R.prototype.createRawTexture=function(e,t,i,r,n,o,s,a,l){void 0===a&&(a=null),void 0===l&&(l=R.TEXTURETYPE_UNSIGNED_INT);var c=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_RAW);c.baseWidth=t,c.baseHeight=i,c.width=t,c.height=i,c.format=r,c.generateMipMaps=n,c.samplingMode=s,c.invertY=o,c._compression=a,c.type=l,this._doNotHandleContextLost||(c._bufferView=e),this.updateRawTexture(c,e,r,o,a,l),this._bindTextureDirectly(this._gl.TEXTURE_2D,c,!0);var h=this._getSamplingParameters(s,n);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,h.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,h.min),n&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(c),c},R.prototype._unpackFlipY=function(e){this._unpackFlipYCached!==e&&(this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,e?1:0),this.enableUnpackFlipYCached&&(this._unpackFlipYCached=e))},R.prototype._getUnpackAlignement=function(){return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT)},R.prototype.createDynamicTexture=function(e,t,i,r){var n=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_DYNAMIC);return n.baseWidth=e,n.baseHeight=t,i&&(e=this.needPOTTextures?M.Tools.GetExponentOfTwo(e,this._caps.maxTextureSize):e,t=this.needPOTTextures?M.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize):t),n.width=e,n.height=t,n.isReady=!1,n.generateMipMaps=i,n.samplingMode=r,this.updateTextureSamplingMode(r,n),this._internalTexturesCache.push(n),n},R.prototype.updateTextureSamplingMode=function(e,t){var i=this._getSamplingParameters(e,t.generateMipMaps);t.isCube?(this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):t.is3D?(this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_3D,null)):(this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,i.mag,t),this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,i.min),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t.samplingMode=e},R.prototype.updateDynamicTexture=function(e,t,i,r,n){if(void 0===r&&(r=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._unpackFlipY(i),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,1);var o=n?this._getInternalFormat(n):this._gl.RGBA;this._gl.texImage2D(this._gl.TEXTURE_2D,0,o,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),r&&this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL,0),e.isReady=!0}},R.prototype.updateVideoTexture=function(t,e,i){if(t&&!t._isDisabled){var r=this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0);this._unpackFlipY(!i);try{if(void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e),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,e);else{if(!t._workingCanvas){t._workingCanvas=document.createElement("canvas");var n=t._workingCanvas.getContext("2d");if(!n)throw new Error("Unable to get 2d context");t._workingContext=n,t._workingCanvas.width=t.width,t._workingCanvas.height=t.height}t._workingContext.drawImage(e,0,0,e.videoWidth,e.videoHeight,0,0,t.width,t.height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t._workingCanvas)}t.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),r||this._bindTextureDirectly(this._gl.TEXTURE_2D,null),t.isReady=!0}catch(e){t._isDisabled=!0}}},R.prototype.updateTextureComparisonFunction=function(e,t){if(1!==this.webGLVersion){var i=this._gl;e.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,e,!0),0===t?(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,R.LEQUAL),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),0===t?(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,R.LEQUAL),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.NONE)):(i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_FUNC,t),i.texParameteri(i.TEXTURE_2D,i.TEXTURE_COMPARE_MODE,i.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),e._comparisonFunction=t}else M.Tools.Error("WebGL 1 does not support texture comparison.")},R.prototype._setupDepthStencilTexture=function(e,t,i,r,n){var o=t.width||t,s=t.height||t;e.baseWidth=o,e.baseHeight=s,e.width=o,e.height=s,e.isReady=!0,e.samples=1,e.generateMipMaps=!1,e._generateDepthBuffer=!0,e._generateStencilBuffer=i,e.samplingMode=r?R.TEXTURE_BILINEAR_SAMPLINGMODE:R.TEXTURE_NEAREST_SAMPLINGMODE,e.type=R.TEXTURETYPE_UNSIGNED_INT,e._comparisonFunction=n;var a=this._gl,l=e.isCube?a.TEXTURE_CUBE_MAP:a.TEXTURE_2D,c=this._getSamplingParameters(e.samplingMode,!1);a.texParameteri(l,a.TEXTURE_MAG_FILTER,c.mag),a.texParameteri(l,a.TEXTURE_MIN_FILTER,c.min),a.texParameteri(l,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(l,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),0===n?(a.texParameteri(l,a.TEXTURE_COMPARE_FUNC,R.LEQUAL),a.texParameteri(l,a.TEXTURE_COMPARE_MODE,a.NONE)):(a.texParameteri(l,a.TEXTURE_COMPARE_FUNC,n),a.texParameteri(l,a.TEXTURE_COMPARE_MODE,a.COMPARE_REF_TO_TEXTURE))},R.prototype.createDepthStencilTexture=function(e,t){if(t.isCube){var i=e.width||e;return this._createDepthStencilCubeTexture(i,t)}return this._createDepthStencilTexture(e,t)},R.prototype._createDepthStencilTexture=function(e,t){var i=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_DEPTHTEXTURE);if(!this._caps.depthTextureExtension)return M.Tools.Error("Depth texture is not supported by your browser or hardware."),i;var r=ae({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),n=this._gl;return this._bindTextureDirectly(n.TEXTURE_2D,i,!0),this._setupDepthStencilTexture(i,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction),1<this.webGLVersion?r.generateStencil?n.texImage2D(n.TEXTURE_2D,0,n.DEPTH24_STENCIL8,i.width,i.height,0,n.DEPTH_STENCIL,n.UNSIGNED_INT_24_8,null):n.texImage2D(n.TEXTURE_2D,0,n.DEPTH_COMPONENT24,i.width,i.height,0,n.DEPTH_COMPONENT,n.UNSIGNED_INT,null):r.generateStencil?n.texImage2D(n.TEXTURE_2D,0,n.DEPTH_STENCIL,i.width,i.height,0,n.DEPTH_STENCIL,n.UNSIGNED_INT_24_8,null):n.texImage2D(n.TEXTURE_2D,0,n.DEPTH_COMPONENT,i.width,i.height,0,n.DEPTH_COMPONENT,n.UNSIGNED_INT,null),this._bindTextureDirectly(n.TEXTURE_2D,null),i},R.prototype._createDepthStencilCubeTexture=function(e,t){var i=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_UNKNOWN);if(i.isCube=!0,1===this.webGLVersion)return M.Tools.Error("Depth cube texture is not supported by WebGL 1."),i;var r=ae({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},t),n=this._gl;this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,i,!0),this._setupDepthStencilTexture(i,e,r.generateStencil,r.bilinearFiltering,r.comparisonFunction);for(var o=0;o<6;o++)r.generateStencil?n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,n.DEPTH24_STENCIL8,e,e,0,n.DEPTH_STENCIL,n.UNSIGNED_INT_24_8,null):n.texImage2D(n.TEXTURE_CUBE_MAP_POSITIVE_X+o,0,n.DEPTH_COMPONENT24,e,e,0,n.DEPTH_COMPONENT,n.UNSIGNED_INT,null);return this._bindTextureDirectly(n.TEXTURE_CUBE_MAP,null),i},R.prototype.setFrameBufferDepthStencilTexture=function(e){var t=e.getInternalTexture();if(t&&t._framebuffer&&e.depthStencilTexture){var i=this._gl,r=e.depthStencilTexture;this.bindUnboundFramebuffer(t._framebuffer),r.isCube?r._generateStencilBuffer?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_CUBE_MAP_POSITIVE_X,r._webGLTexture,0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_CUBE_MAP_POSITIVE_X,r._webGLTexture,0):r._generateStencilBuffer?i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_STENCIL_ATTACHMENT,i.TEXTURE_2D,r._webGLTexture,0):i.framebufferTexture2D(i.FRAMEBUFFER,i.DEPTH_ATTACHMENT,i.TEXTURE_2D,r._webGLTexture,0),this.bindUnboundFramebuffer(null)}},R.prototype.createRenderTargetTexture=function(e,t){var i=new h;void 0!==t&&"object"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&t.generateStencilBuffer,i.type=void 0===t.type?R.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?R.TEXTURE_TRILINEAR_SAMPLINGMODE:t.samplingMode,i.format=void 0===t.format?R.TEXTUREFORMAT_RGBA:t.format):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=R.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=R.TEXTURE_TRILINEAR_SAMPLINGMODE,i.format=R.TEXTUREFORMAT_RGBA),(i.type!==R.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==R.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=R.TEXTURE_NEAREST_SAMPLINGMODE);var r=this._gl,n=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(r.TEXTURE_2D,n,!0);var o=e.width||e,s=e.height||e,a=this._getSamplingParameters(i.samplingMode,!!i.generateMipMaps);i.type!==R.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=R.TEXTURETYPE_UNSIGNED_INT,M.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MAG_FILTER,a.mag),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_MIN_FILTER,a.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),o,s,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);var l=this._currentFramebuffer,c=r.createFramebuffer();return this.bindUnboundFramebuffer(c),r.framebufferTexture2D(r.FRAMEBUFFER,r.COLOR_ATTACHMENT0,r.TEXTURE_2D,n._webGLTexture,0),n._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!i.generateStencilBuffer,i.generateDepthBuffer,o,s),i.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(r.TEXTURE_2D,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(l),n._framebuffer=c,n.baseWidth=o,n.baseHeight=s,n.width=o,n.height=s,n.isReady=!0,n.samples=1,n.generateMipMaps=!!i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(n),n},R.prototype.createMultipleRenderTarget=function(e,t){var i=!1,r=!0,n=!1,o=!1,s=1,a=R.TEXTURETYPE_UNSIGNED_INT,l=R.TEXTURE_TRILINEAR_SAMPLINGMODE,c=new Array,h=new Array;void 0!==t&&(i=void 0!==t.generateMipMaps&&t.generateMipMaps,r=void 0===t.generateDepthBuffer||t.generateDepthBuffer,n=void 0!==t.generateStencilBuffer&&t.generateStencilBuffer,o=void 0!==t.generateDepthTexture&&t.generateDepthTexture,s=t.textureCount||1,t.types&&(c=t.types),t.samplingModes&&(h=t.samplingModes));var u=this._gl,d=u.createFramebuffer();this.bindUnboundFramebuffer(d);for(var f=e.width||e,p=e.height||e,m=[],_=[],g=this._setupFramebufferDepthAttachments(n,r,f,p),v=0;v<s;v++){var y=h[v]||l,b=c[v]||a;(b!==R.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(b!==R.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(y=R.TEXTURE_NEAREST_SAMPLINGMODE);var T=this._getSamplingParameters(y,i);b!==R.TEXTURETYPE_FLOAT||this._caps.textureFloat||(b=R.TEXTURETYPE_UNSIGNED_INT,M.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var x=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_MULTIRENDERTARGET),E=u[1<this.webGLVersion?"COLOR_ATTACHMENT"+v:"COLOR_ATTACHMENT"+v+"_WEBGL"];m.push(x),_.push(E),u.activeTexture(u["TEXTURE"+v]),u.bindTexture(u.TEXTURE_2D,x._webGLTexture),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,T.mag),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,T.min),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(b),f,p,0,u.RGBA,this._getWebGLTextureType(b),null),u.framebufferTexture2D(u.DRAW_FRAMEBUFFER,E,u.TEXTURE_2D,x._webGLTexture,0),i&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(u.TEXTURE_2D,null),x._framebuffer=d,x._depthStencilBuffer=g,x.baseWidth=f,x.baseHeight=p,x.width=f,x.height=p,x.isReady=!0,x.samples=1,x.generateMipMaps=i,x.samplingMode=y,x.type=b,x._generateDepthBuffer=r,x._generateStencilBuffer=n,x._attachments=_,this._internalTexturesCache.push(x)}if(o&&this._caps.depthTextureExtension){var A=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_MULTIRENDERTARGET);u.activeTexture(u.TEXTURE0),u.bindTexture(u.TEXTURE_2D,A._webGLTexture),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MAG_FILTER,u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_MIN_FILTER,u.NEAREST),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_S,u.CLAMP_TO_EDGE),u.texParameteri(u.TEXTURE_2D,u.TEXTURE_WRAP_T,u.CLAMP_TO_EDGE),u.texImage2D(u.TEXTURE_2D,0,this.webGLVersion<2?u.DEPTH_COMPONENT:u.DEPTH_COMPONENT16,f,p,0,u.DEPTH_COMPONENT,u.UNSIGNED_SHORT,null),u.framebufferTexture2D(u.FRAMEBUFFER,u.DEPTH_ATTACHMENT,u.TEXTURE_2D,A._webGLTexture,0),A._framebuffer=d,A.baseWidth=f,A.baseHeight=p,A.width=f,A.height=p,A.isReady=!0,A.samples=1,A.generateMipMaps=i,A.samplingMode=u.NEAREST,A._generateDepthBuffer=r,A._generateStencilBuffer=n,m.push(A),this._internalTexturesCache.push(A)}return u.drawBuffers(_),u.bindRenderbuffer(u.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),this.resetTextureCache(),m},R.prototype._setupFramebufferDepthAttachments=function(e,t,i,r,n){void 0===n&&(n=1);var o=null,s=this._gl;return e?(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),1<n?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,o)):t&&(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),1<n?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH_COMPONENT16,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_COMPONENT16,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,o)),o},R.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;var i=this._gl;if(t=Math.min(t,i.getParameter(i.MAX_SAMPLES)),e._depthStencilBuffer&&(i.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(i.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null),1<t){var r=i.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this.bindUnboundFramebuffer(e._MSAAFramebuffer);var n=i.createRenderbuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,n),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n),e._MSAARenderBuffer=n}else this.bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),i.bindRenderbuffer(i.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),t},R.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||0==e.length)return 1;if(e[0].samples===t)return t;var i=this._gl;t=Math.min(t,i.getParameter(i.MAX_SAMPLES)),e[0]._depthStencilBuffer&&(i.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(i.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var r=0;r<e.length;r++)e[r]._MSAARenderBuffer&&(i.deleteRenderbuffer(e[r]._MSAARenderBuffer),e[r]._MSAARenderBuffer=null);if(1<t){var n=i.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");this.bindUnboundFramebuffer(n);var o=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),s=[];for(r=0;r<e.length;r++){var a=e[r],l=i[1<this.webGLVersion?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],c=i.createRenderbuffer();if(!c)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,c),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(a.type),a.width,a.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,c),a._MSAAFramebuffer=n,a._MSAARenderBuffer=c,a.samples=t,a._depthStencilBuffer=o,i.bindRenderbuffer(i.RENDERBUFFER,null),s.push(l)}i.drawBuffers(s)}else this.bindUnboundFramebuffer(e[0]._framebuffer);return this.bindUnboundFramebuffer(null),t},R.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0);var a=this._gl,l=a.TEXTURE_2D;e.isCube&&(l=a.TEXTURE_CUBE_MAP_POSITIVE_X+o),this._gl.compressedTexImage2D(l,s,t,i,r,0,n)},R.prototype._uploadDataToTextureDirectly=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=this._getWebGLTextureType(e.type),s=this._getInternalFormat(e.format),a=this._getRGBABufferInternalSizedFormat(e.type,s);this._unpackFlipY(e.invertY);var l=n.TEXTURE_2D;e.isCube&&(l=n.TEXTURE_CUBE_MAP_POSITIVE_X+i);var c=Math.round(M.Scalar.Log2(e.width)),h=Math.round(M.Scalar.Log2(e.height)),u=Math.pow(2,Math.max(c-r,0)),d=Math.pow(2,Math.max(h-r,0));n.texImage2D(l,r,a,u,d,0,s,o,t)},R.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(o,e,!0),this._uploadDataToTextureDirectly(e,t,i,r),this._bindTextureDirectly(o,null,!0)},R.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0);var n=this._gl,o=this._getWebGLTextureType(e.type),s=this._getInternalFormat(e.format),a=this._getRGBABufferInternalSizedFormat(e.type,s),l=e.isCube?n.TEXTURE_CUBE_MAP:n.TEXTURE_2D;this._bindTextureDirectly(l,e,!0),this._unpackFlipY(e.invertY);var c=n.TEXTURE_2D;e.isCube&&(c=n.TEXTURE_CUBE_MAP_POSITIVE_X+i),n.texImage2D(c,r,a,s,o,t),this._bindTextureDirectly(l,null,!0)},R.prototype.createRenderTargetCubeTexture=function(e,t){var i=ae({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:R.TEXTURETYPE_UNSIGNED_INT,samplingMode:R.TEXTURE_TRILINEAR_SAMPLINGMODE,format:R.TEXTUREFORMAT_RGBA},t);i.generateStencilBuffer=i.generateDepthBuffer&&i.generateStencilBuffer,(i.type!==R.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering)&&(i.type!==R.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering)||(i.samplingMode=R.TEXTURE_NEAREST_SAMPLINGMODE);var r=this._gl,n=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,n,!0);var o=this._getSamplingParameters(i.samplingMode,i.generateMipMaps);i.type!==R.TEXTURETYPE_FLOAT||this._caps.textureFloat||(i.type=R.TEXTURETYPE_UNSIGNED_INT,M.Tools.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MAG_FILTER,o.mag),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_MIN_FILTER,o.min),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_S,r.CLAMP_TO_EDGE),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_WRAP_T,r.CLAMP_TO_EDGE);for(var s=0;s<6;s++)r.texImage2D(r.TEXTURE_CUBE_MAP_POSITIVE_X+s,0,this._getRGBABufferInternalSizedFormat(i.type,i.format),e,e,0,this._getInternalFormat(i.format),this._getWebGLTextureType(i.type),null);var a=r.createFramebuffer();return this.bindUnboundFramebuffer(a),n._depthStencilBuffer=this._setupFramebufferDepthAttachments(i.generateStencilBuffer,i.generateDepthBuffer,e,e),i.generateMipMaps&&r.generateMipmap(r.TEXTURE_CUBE_MAP),this._bindTextureDirectly(r.TEXTURE_CUBE_MAP,null),r.bindRenderbuffer(r.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),n._framebuffer=a,n.width=e,n.height=e,n.isReady=!0,n.isCube=!0,n.samples=1,n.generateMipMaps=i.generateMipMaps,n.samplingMode=i.samplingMode,n.type=i.type,n.format=i.format,n._generateDepthBuffer=i.generateDepthBuffer,n._generateStencilBuffer=i.generateStencilBuffer,this._internalTexturesCache.push(n),n},R.prototype.createPrefilteredCubeTexture=function(e,m,_,g,v,t,i,r,y){var b=this;void 0===v&&(v=null),void 0===t&&(t=null),void 0===r&&(r=null),void 0===y&&(y=!0);return this.createCubeTexture(e,m,null,!1,(function(e){if(e){var t=e.texture;if(y?e.info.sphericalPolynomial&&(t._sphericalPolynomial=e.info.sphericalPolynomial):t._sphericalPolynomial=new M.SphericalPolynomial,t._dataSource=M.InternalTexture.DATASOURCE_CUBEPREFILTERED,b._caps.textureLOD)v&&v(t);else{var i=b._gl,r=e.width;if(r){for(var n=[],o=0;o<3;o++){var s=1-o/2,a=g,l=M.Scalar.Log2(r)*_+g,c=a+(l-a)*s,h=Math.round(Math.min(Math.max(c,0),l)),u=new M.InternalTexture(b,M.InternalTexture.DATASOURCE_TEMP);if(u.type=t.type,u.format=t.format,u.width=Math.pow(2,Math.max(M.Scalar.Log2(r)-h,0)),u.height=u.width,u.isCube=!0,b._bindTextureDirectly(i.TEXTURE_CUBE_MAP,u,!0),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MAG_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_MIN_FILTER,i.LINEAR),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_S,i.CLAMP_TO_EDGE),i.texParameteri(i.TEXTURE_CUBE_MAP,i.TEXTURE_WRAP_T,i.CLAMP_TO_EDGE),e.isDDS){var d=e.info,f=e.data;b._unpackFlipY(d.isCompressed),M.DDSTools.UploadDDSLevels(b,u,f,d,!0,6,h)}else M.Tools.Warn("DDS is the only prefiltered cube map supported so far.");b._bindTextureDirectly(i.TEXTURE_CUBE_MAP,null);var p=new M.BaseTexture(m);p.isCube=!0,(p._texture=u).isReady=!0,n.push(p)}t._lodTextureHigh=n[2],t._lodTextureMid=n[1],t._lodTextureLow=n[0],v&&v(t)}}}else v&&v(null)}),t,i,r,y,_,g)},R.prototype.createCubeTexture=function(r,n,o,s,a,l,c,e,h,u,d,t){var f=this;void 0===a&&(a=null),void 0===l&&(l=null),void 0===e&&(e=null),void 0===h&&(h=!1),void 0===u&&(u=0),void 0===d&&(d=0),void 0===t&&(t=null);var p=this._gl,m=t||new M.InternalTexture(this,M.InternalTexture.DATASOURCE_CUBE);m.isCube=!0,m.url=r,m.generateMipMaps=!s,m._lodGenerationScale=u,m._lodGenerationOffset=d,this._doNotHandleContextLost||(m._extension=e,m._files=o);for(var i=r.lastIndexOf("."),_=e||(-1<i?r.substring(i).toLowerCase():""),g=null,v=0,y=R._TextureLoaders;v<y.length;v++){var b=y[v];if(b.canLoad(_,this._textureFormatInUse,t,!1,!1)){g=b;break}}if(g){r=g.transformUrl(r,this._textureFormatInUse);var T=function(e){f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,m,!0),g.loadCubeData(e,m,h,a,l)};o&&6===o.length?g.supportCascades?this._cascadeLoadFiles(n,T,o,l):l&&l("Textures type does not support cascades."):this._loadFile(r,T,void 0,void 0,!0,(function(e,t){if(g){var i=g.getFallbackTextureUrl(r,f._textureFormatInUse);i&&f.createCubeTexture(i,n,o,s,a,l,c,_,h,u,d,m)}l&&e&&l(e.status+" "+e.statusText,t)}))}else{if(!o)throw new Error("Cannot load cubemap because files were not defined");this._cascadeLoadImgs(r,n,(function(e){var t=f.needPOTTextures?M.Tools.GetExponentOfTwo(e[0].width,f._caps.maxCubemapTextureSize):e[0].width,i=t;if(f._prepareWorkingCanvas(),f._workingCanvas&&f._workingContext){f._workingCanvas.width=t,f._workingCanvas.height=i;var r=[p.TEXTURE_CUBE_MAP_POSITIVE_X,p.TEXTURE_CUBE_MAP_POSITIVE_Y,p.TEXTURE_CUBE_MAP_POSITIVE_Z,p.TEXTURE_CUBE_MAP_NEGATIVE_X,p.TEXTURE_CUBE_MAP_NEGATIVE_Y,p.TEXTURE_CUBE_MAP_NEGATIVE_Z];f._bindTextureDirectly(p.TEXTURE_CUBE_MAP,m,!0),f._unpackFlipY(!1);for(var n=c?f._getInternalFormat(c):f._gl.RGBA,o=0;o<r.length;o++)f._workingContext.drawImage(e[o],0,0,e[o].width,e[o].height,0,0,t,i),p.texImage2D(r[o],0,n,n,p.UNSIGNED_BYTE,f._workingCanvas);s||p.generateMipmap(p.TEXTURE_CUBE_MAP),f._setCubeMapTextureParams(!s),m.width=t,m.height=i,m.isReady=!0,c&&(m.format=c),m.onLoadedObservable.notifyObservers(m),m.onLoadedObservable.clear(),a&&a()}}),o,l)}return this._internalTexturesCache.push(m),m},R.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)},R.prototype.updateRawCubeTexture=function(e,t,i,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=0),e._bufferViewArray=t,e.format=i,e.type=r,e.invertY=n,e._compression=o;var a=this._gl,l=this._getWebGLTextureType(r),c=this._getInternalFormat(i),h=this._getRGBABufferInternalSizedFormat(r),u=!1;c===a.RGB&&(c=a.RGBA,u=!0),this._bindTextureDirectly(a.TEXTURE_CUBE_MAP,e,!0),this._unpackFlipY(void 0===n||!!n),e.width%4!=0&&a.pixelStorei(a.UNPACK_ALIGNMENT,1);for(var d=0;d<6;d++){var f=t[d];o?a.compressedTexImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+d,s,this.getCaps().s3tc[o],e.width,e.height,0,f):(u&&(f=this._convertRGBtoRGBATextureData(f,e.width,e.height,r)),a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+d,s,h,e.width,e.height,0,c,l,f))}(!this.needPOTTextures||M.Tools.IsExponentOfTwo(e.width)&&M.Tools.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},R.prototype.createRawCubeTexture=function(e,t,i,r,n,o,s,a){void 0===a&&(a=null);var l=this._gl,c=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_CUBERAW);c.isCube=!0,c.format=i,c.type=r,this._doNotHandleContextLost||(c._bufferViewArray=e);var h=this._getWebGLTextureType(r),u=this._getInternalFormat(i);u===l.RGB&&(u=l.RGBA),h!==l.FLOAT||this._caps.textureFloatLinearFiltering?h!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering?h!==l.FLOAT||this._caps.textureFloatRender?h!==l.HALF_FLOAT||this._caps.colorBufferFloat||(n=!1,M.Tools.Warn("Render to half float textures is not supported. Mipmap generation forced to false.")):(n=!1,M.Tools.Warn("Render to float textures is not supported. Mipmap generation forced to false.")):(n=!1,s=R.TEXTURE_NEAREST_SAMPLINGMODE,M.Tools.Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.")):(n=!1,s=R.TEXTURE_NEAREST_SAMPLINGMODE,M.Tools.Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively."));var d=t,f=d;c.width=d,c.height=f,!this.needPOTTextures||M.Tools.IsExponentOfTwo(c.width)&&M.Tools.IsExponentOfTwo(c.height)||(n=!1),e&&this.updateRawCubeTexture(c,e,i,r,o,a),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,c,!0),e&&n&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);var p=this._getSamplingParameters(s,n);return l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MAG_FILTER,p.mag),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_MIN_FILTER,p.min),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE),l.texParameteri(l.TEXTURE_CUBE_MAP,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE),this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,null),c.generateMipMaps=n,c},R.prototype.createRawCubeTextureFromUrl=function(e,d,t,f,p,i,m,_,g,r,n,v){var y=this;void 0===g&&(g=null),void 0===r&&(r=null),void 0===n&&(n=R.TEXTURE_TRILINEAR_SAMPLINGMODE),void 0===v&&(v=!1);var b=this._gl,T=this.createRawCubeTexture(null,t,f,p,!i,v,n);d._addPendingData(T),T.url=e,this._internalTexturesCache.push(T);return this._loadFile(e,(function(e){!(function(e){var t=T.width,i=m(e);if(i){if(_){var r=y._getWebGLTextureType(p),n=y._getInternalFormat(f),o=y._getRGBABufferInternalSizedFormat(p),s=!1;n===b.RGB&&(n=b.RGBA,s=!0),y._bindTextureDirectly(b.TEXTURE_CUBE_MAP,T,!0),y._unpackFlipY(!1);for(var a=_(i),l=0;l<a.length;l++)for(var c=t>>l,h=0;h<6;h++){var u=a[l][h];s&&(u=y._convertRGBtoRGBATextureData(u,c,c,p)),b.texImage2D(h,l,o,c,c,0,n,r,u)}y._bindTextureDirectly(b.TEXTURE_CUBE_MAP,null)}else y.updateRawCubeTexture(T,i,f,p,v);T.isReady=!0,d._removePendingData(T),g&&g()}})(e)}),void 0,d.database,!0,(function(e,t){d._removePendingData(T),r&&e&&r(e.status+" "+e.statusText,t)})),T},R.prototype.updateRawTexture3D=function(e,t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=R.TEXTURETYPE_UNSIGNED_INT);var s=this._getWebGLTextureType(o),a=this._getInternalFormat(i),l=this._getRGBABufferInternalSizedFormat(o,i);this._bindTextureDirectly(this._gl.TEXTURE_3D,e,!0),this._unpackFlipY(void 0===r||!!r),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.invertY=r,e._compression=n),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),n&&t?this._gl.compressedTexImage3D(this._gl.TEXTURE_3D,0,this.getCaps().s3tc[n],e.width,e.height,e.depth,0,t):this._gl.texImage3D(this._gl.TEXTURE_3D,0,l,e.width,e.height,e.depth,0,a,s,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),e.isReady=!0},R.prototype.createRawTexture3D=function(e,t,i,r,n,o,s,a,l,c){void 0===l&&(l=null),void 0===c&&(c=R.TEXTURETYPE_UNSIGNED_INT);var h=new M.InternalTexture(this,M.InternalTexture.DATASOURCE_RAW3D);h.baseWidth=t,h.baseHeight=i,h.baseDepth=r,h.width=t,h.height=i,h.depth=r,h.format=n,h.type=c,h.generateMipMaps=o,h.samplingMode=a,h.is3D=!0,this._doNotHandleContextLost||(h._bufferView=e),this.updateRawTexture3D(h,e,n,s,l,c),this._bindTextureDirectly(this._gl.TEXTURE_3D,h,!0);var u=this._getSamplingParameters(a,o);return this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,u.mag),this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,u.min),o&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._internalTexturesCache.push(h),h},R.prototype._prepareWebGLTextureContinuation=function(e,t,i,r,n){var o=this._gl;if(o){var s=this._getSamplingParameters(n,!i);o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MAG_FILTER,s.mag),o.texParameteri(o.TEXTURE_2D,o.TEXTURE_MIN_FILTER,s.min),i||r||o.generateMipmap(o.TEXTURE_2D),this._bindTextureDirectly(o.TEXTURE_2D,null),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},R.prototype._prepareWebGLTexture=function(e,t,i,r,n,o,s,a,l){var c=this;void 0===l&&(l=R.TEXTURE_TRILINEAR_SAMPLINGMODE);var h=this.getCaps().maxTextureSize,u=Math.min(h,this.needPOTTextures?M.Tools.GetExponentOfTwo(i,h):i),d=Math.min(h,this.needPOTTextures?M.Tools.GetExponentOfTwo(r,h):r),f=this._gl;f&&(e._webGLTexture?(this._bindTextureDirectly(f.TEXTURE_2D,e,!0),this._unpackFlipY(void 0===n||!!n),e.baseWidth=i,e.baseHeight=r,e.width=u,e.height=d,e.isReady=!0,a(u,d,(function(){c._prepareWebGLTextureContinuation(e,t,o,s,l)}))||this._prepareWebGLTextureContinuation(e,t,o,s,l)):t&&t._removePendingData(e))},R.prototype._convertRGBtoRGBATextureData=function(e,t,i,r){var n;n=r===R.TEXTURETYPE_FLOAT?new Float32Array(t*i*4):new Uint32Array(t*i*4);for(var o=0;o<t;o++)for(var s=0;s<i;s++){var a=3*(s*t+o),l=4*(s*t+o);n[l+0]=e[a+0],n[l+1]=e[a+1],n[l+2]=e[a+2],n[l+3]=1}return n},R.prototype._releaseFramebufferObjects=function(e){var t=this._gl;e._framebuffer&&(t.deleteFramebuffer(e._framebuffer),e._framebuffer=null),e._depthStencilBuffer&&(t.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(t.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(t.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null)},R.prototype._releaseTexture=function(t){var e=this._gl;this._releaseFramebufferObjects(t),e.deleteTexture(t._webGLTexture),this.unbindAllTextures();var i=this._internalTexturesCache.indexOf(t);-1!==i&&this._internalTexturesCache.splice(i,1),t._lodTextureHigh&&t._lodTextureHigh.dispose(),t._lodTextureMid&&t._lodTextureMid.dispose(),t._lodTextureLow&&t._lodTextureLow.dispose(),this.scenes.forEach((function(e){e.postProcesses.forEach((function(e){e._outputTexture==t&&(e._outputTexture=null)})),e.cameras.forEach((function(e){e._postProcesses.forEach((function(e){e&&e._outputTexture==t&&(e._outputTexture=null)}))}))}))},R.prototype.setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},R.prototype.bindSamplers=function(e){this.setProgram(e.getProgram());for(var t=e.getSamplers(),i=0;i<t.length;i++){var r=e.getUniform(t[i]);r&&(this._boundUniforms[i]=r)}this._currentEffect=null},R.prototype._moveBoundTextureOnTop=function(e){this.disableTextureBindingOptimization||this._lastBoundInternalTextureTracker.previous===e||(this._linkTrackers(e.previous,e.next),this._linkTrackers(this._lastBoundInternalTextureTracker.previous,e),this._linkTrackers(e,this._lastBoundInternalTextureTracker))},R.prototype._getCorrectTextureChannel=function(e,t){if(!t)return-1;if(t._initialSlot=e,this.disableTextureBindingOptimization)e!==t._designatedSlot&&this._textureCollisions.addCount(1,!1);else if(e!==t._designatedSlot)return-1<t._designatedSlot?t._designatedSlot:this._nextFreeTextureSlots.length?this._nextFreeTextureSlots[0]:(this._textureCollisions.addCount(1,!1),this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next));return e},R.prototype._linkTrackers=function(e,t){(e.next=t).previous=e},R.prototype._removeDesignatedSlot=function(e){var t=e._designatedSlot;return-1===t?-1:(e._designatedSlot=-1,this.disableTextureBindingOptimization?-1:(this._linkTrackers(e.previous,e.next),this._boundTexturesCache[t]=null,this._nextFreeTextureSlots.push(t),t))},R.prototype._activateCurrentTexture=function(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)},R.prototype._bindTextureDirectly=function(e,t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1);var n=!1;i&&t&&-1<t._designatedSlot&&(this._activeChannel=t._designatedSlot);var o=this._boundTexturesCache[this._activeChannel],s=t&&-1<t._initialSlot;if(o!==t||r){if(o&&this._removeDesignatedSlot(o),this._activateCurrentTexture(),this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t){if(!this.disableTextureBindingOptimization){var a=this._nextFreeTextureSlots.indexOf(this._activeChannel);-1<a&&this._nextFreeTextureSlots.splice(a,1),this._linkTrackers(this._lastBoundInternalTextureTracker.previous,t),this._linkTrackers(t,this._lastBoundInternalTextureTracker)}t._designatedSlot=this._activeChannel}}else i&&(n=!0,this._activateCurrentTexture());return s&&!i&&this._bindSamplerUniformToChannel(t._initialSlot,this._activeChannel),n},R.prototype._bindTexture=function(e,t){e<0||(t&&(e=this._getCorrectTextureChannel(e,t)),this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},R.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t?t._textures.data[t._currentRenderTextureInd]:null)},R.prototype.setTextureFromPostProcessOutput=function(e,t){this._bindTexture(e,t?t._outputTexture:null)},R.prototype.unbindAllTextures=function(){for(var e=0;e<this._maxSimultaneousTextures;e++)this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),1<this.webGLVersion&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)},R.prototype.setTexture=function(e,t,i){e<0||(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},R.prototype.setDepthStencilTexture=function(e,t,i){e<0||(t&&(this._boundUniforms[e]=t),i&&i.depthStencilTexture?this._setTexture(e,i,!1,!0):this._setTexture(e,null))},R.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},R.prototype._getTextureWrapMode=function(e){switch(e){case R.TEXTURE_WRAP_ADDRESSMODE:return this._gl.REPEAT;case R.TEXTURE_CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case R.TEXTURE_MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},R.prototype._setTexture=function(e,t,i,r){if(void 0===i&&(i=!1),void 0===r&&(r=!1),!t)return null!=this._boundTexturesCache[e]&&(this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),1<this.webGLVersion&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)),!1;if(t.video)this._activeChannel=e,t.update();else if(t.delayLoadState===R.DELAYLOADSTATE_NOTLOADED)return t.delayLoad(),!1;var n;n=r?t.depthStencilTexture:t.isReady()?t.getInternalTexture():t.isCube?this.emptyCubeTexture:t.is3D?this.emptyTexture3D:this.emptyTexture,i||(e=this._getCorrectTextureChannel(e,n));var o=!0;if(this._boundTexturesCache[e]===n&&(this._moveBoundTextureOnTop(n),i||this._bindSamplerUniformToChannel(n._initialSlot,e),o=!1),this._activeChannel=e,n&&n.is3D)o&&this._bindTextureDirectly(this._gl.TEXTURE_3D,n,i),n&&n._cachedWrapU!==t.wrapU&&(n._cachedWrapU=t.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),n)),n&&n._cachedWrapV!==t.wrapV&&(n._cachedWrapV=t.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),n)),n&&n._cachedWrapR!==t.wrapR&&(n._cachedWrapR=t.wrapR,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(t.wrapR),n)),this._setAnisotropicLevel(this._gl.TEXTURE_3D,t);else if(n&&n.isCube){if(o&&this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,n,i),n._cachedCoordinatesMode!==t.coordinatesMode){n._cachedCoordinatesMode=t.coordinatesMode;var s=t.coordinatesMode!==R.TEXTURE_CUBIC_MODE&&t.coordinatesMode!==R.TEXTURE_SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,s,n),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,s)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,t)}else o&&this._bindTextureDirectly(this._gl.TEXTURE_2D,n,i),n&&n._cachedWrapU!==t.wrapU&&(n._cachedWrapU=t.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(t.wrapU),n)),n&&n._cachedWrapV!==t.wrapV&&(n._cachedWrapV=t.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(t.wrapV),n)),this._setAnisotropicLevel(this._gl.TEXTURE_2D,t);return!0},R.prototype.setTextureArray=function(e,t,i){if(!(e<0)&&t){this._textureUnits&&this._textureUnits.length===i.length||(this._textureUnits=new Int32Array(i.length));for(var r=0;r<i.length;r++)this._textureUnits[r]=this._getCorrectTextureChannel(e+r,i[r].getInternalTexture());this._gl.uniform1iv(t,this._textureUnits);for(var n=0;n<i.length;n++)this._setTexture(this._textureUnits[n],i[n],!0)}},R.prototype._setAnisotropicLevel=function(e,t){var i=t.getInternalTexture();if(i){var r=this._caps.textureAnisotropicFilterExtension,n=t.anisotropicFilteringLevel;i.samplingMode!==R.TEXTURE_LINEAR_LINEAR_MIPNEAREST&&i.samplingMode!==R.TEXTURE_LINEAR_LINEAR_MIPLINEAR&&i.samplingMode!==R.TEXTURE_LINEAR_LINEAR&&(n=1),r&&i._cachedAnisotropicFilteringLevel!==n&&(this._setTextureParameterFloat(e,r.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(n,this._caps.maxAnisotropy),i),i._cachedAnisotropicFilteringLevel=n)}},R.prototype._setTextureParameterFloat=function(e,t,i,r){this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameterf(e,t,i)},R.prototype._setTextureParameterInteger=function(e,t,i,r){r&&this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameteri(e,t,i)},R.prototype.readPixels=function(e,t,i,r){var n=new Uint8Array(r*i*4);return this._gl.readPixels(e,t,i,r,this._gl.RGBA,this._gl.UNSIGNED_BYTE,n),n},R.prototype.addExternalData=function(e,t){return this._externalData||(this._externalData=new M.StringDictionary),this._externalData.add(e,t)},R.prototype.getExternalData=function(e){return this._externalData||(this._externalData=new M.StringDictionary),this._externalData.get(e)},R.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData||(this._externalData=new M.StringDictionary),this._externalData.getOrAddWithFactory(e,t)},R.prototype.removeExternalData=function(e){return this._externalData||(this._externalData=new M.StringDictionary),this._externalData.remove(e)},R.prototype.unbindAllAttributes=function(){if(this._mustWipeVertexAttributes){this._mustWipeVertexAttributes=!1;for(var e=0;e<this._caps.maxVertexAttribs;e++)this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1}else{e=0;for(var t=this._vertexAttribArraysEnabled.length;e<t;e++)e>=this._caps.maxVertexAttribs||!this._vertexAttribArraysEnabled[e]||(this._gl.disableVertexAttribArray(e),this._vertexAttribArraysEnabled[e]=!1,this._currentBufferPointers[e].active=!1)}},R.prototype.releaseEffects=function(){for(var e in this._compiledEffects)this._deleteProgram(this._compiledEffects[e]._program);this._compiledEffects={}},R.prototype.dispose=function(){for(this.hideLoadingUI(),this.stopRenderLoop();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===R.Instances.length&&R.audioEngine&&R.audioEngine.dispose(),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.disableVR(),M.Tools.IsWindowObjectExist()&&(window.removeEventListener("blur",this._onBlur),window.removeEventListener("focus",this._onFocus),window.removeEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted),window.removeEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted),this._renderingCanvas&&(this._renderingCanvas.removeEventListener("focus",this._onCanvasFocus),this._renderingCanvas.removeEventListener("blur",this._onCanvasBlur),this._renderingCanvas.removeEventListener("pointerout",this._onCanvasPointerOut),this._doNotHandleContextLost||(this._renderingCanvas.removeEventListener("webglcontextlost",this._onContextLost),this._renderingCanvas.removeEventListener("webglcontextrestored",this._onContextRestored))),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.removeEventListener("pointerlockchange",this._onPointerLockChange),document.removeEventListener("mspointerlockchange",this._onPointerLockChange),document.removeEventListener("mozpointerlockchange",this._onPointerLockChange),document.removeEventListener("webkitpointerlockchange",this._onPointerLockChange),this._onVrDisplayConnect&&(window.removeEventListener("vrdisplayconnect",this._onVrDisplayConnect),this._onVrDisplayDisconnect&&window.removeEventListener("vrdisplaydisconnect",this._onVrDisplayDisconnect),this._onVrDisplayPresentChange&&window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._onVrDisplayConnect=null,this._onVrDisplayDisconnect=null));var e=R.Instances.indexOf(this);0<=e&&R.Instances.splice(e,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(),M.Effect.ResetCache();for(var t=0,i=this._activeRequests;t<i.length;t++){i[t].abort()}},R.prototype.displayLoadingUI=function(){if(M.Tools.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.displayLoadingUI()}},R.prototype.hideLoadingUI=function(){if(M.Tools.IsWindowObjectExist()){var e=this.loadingScreen;e&&e.hideLoadingUI()}},Object.defineProperty(R.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&M.DefaultLoadingScreen&&this._renderingCanvas&&(this._loadingScreen=new M.DefaultLoadingScreen(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(R.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),R.prototype.attachContextLostEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},R.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},R.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null},R.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null},R.prototype.getError=function(){return this._gl.getError()},R.prototype.getFps=function(){return this._fps},R.prototype.getDeltaTime=function(){return this._deltaTime},R.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},R.prototype._readTexturePixels=function(e,t,i,r,n,o){void 0===r&&(r=-1),void 0===n&&(n=0),void 0===o&&(o=null);var s=this._gl;if(!this._dummyFramebuffer){var a=s.createFramebuffer();if(!a)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=a}s.bindFramebuffer(s.FRAMEBUFFER,this._dummyFramebuffer),-1<r?s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+r,e._webGLTexture,n):s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,e._webGLTexture,n);var l=void 0!==e.type?this._getWebGLTextureType(e.type):s.UNSIGNED_BYTE;switch(l){case s.UNSIGNED_BYTE:o||(o=new Uint8Array(4*t*i)),l=s.UNSIGNED_BYTE;break;default:o||(o=new Float32Array(4*t*i)),l=s.FLOAT}return s.readPixels(0,0,t,i,s.RGBA,l,o),s.bindFramebuffer(s.FRAMEBUFFER,this._currentFramebuffer),o},R.prototype._canRenderToFloatFramebuffer=function(){return 1<this._webGLVersion?this._caps.colorBufferFloat:this._canRenderToFramebuffer(R.TEXTURETYPE_FLOAT)},R.prototype._canRenderToHalfFloatFramebuffer=function(){return 1<this._webGLVersion?this._caps.colorBufferFloat:this._canRenderToFramebuffer(R.TEXTURETYPE_HALF_FLOAT)},R.prototype._canRenderToFramebuffer=function(e){for(var t=this._gl;t.getError()!==t.NO_ERROR;);var i=!0,r=t.createTexture();t.bindTexture(t.TEXTURE_2D,r),t.texImage2D(t.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(e),1,1,0,t.RGBA,this._getWebGLTextureType(e),null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.NEAREST),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.NEAREST);var n=t.createFramebuffer();t.bindFramebuffer(t.FRAMEBUFFER,n),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,r,0);var o=t.checkFramebufferStatus(t.FRAMEBUFFER);if((i=(i=i&&o===t.FRAMEBUFFER_COMPLETE)&&t.getError()===t.NO_ERROR)&&(t.clear(t.COLOR_BUFFER_BIT),i=i&&t.getError()===t.NO_ERROR),i){t.bindFramebuffer(t.FRAMEBUFFER,null);var s=t.RGBA,a=t.UNSIGNED_BYTE,l=new Uint8Array(4);t.readPixels(0,0,1,1,s,a,l),i=i&&t.getError()===t.NO_ERROR}for(t.deleteTexture(r),t.deleteFramebuffer(n),t.bindFramebuffer(t.FRAMEBUFFER,null);!i&&t.getError()!==t.NO_ERROR;);return i},R.prototype._getWebGLTextureType=function(e){if(1===this._webGLVersion){switch(e){case R.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case R.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT_OES;case R.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE}return this._gl.UNSIGNED_BYTE}switch(e){case R.TEXTURETYPE_BYTE:return this._gl.BYTE;case R.TEXTURETYPE_UNSIGNED_BYTE:return this._gl.UNSIGNED_BYTE;case R.TEXTURETYPE_SHORT:return this._gl.SHORT;case R.TEXTURETYPE_UNSIGNED_SHORT:return this._gl.UNSIGNED_SHORT;case R.TEXTURETYPE_INT:return this._gl.INT;case R.TEXTURETYPE_UNSIGNED_INTEGER:return this._gl.UNSIGNED_INT;case R.TEXTURETYPE_FLOAT:return this._gl.FLOAT;case R.TEXTURETYPE_HALF_FLOAT:return this._gl.HALF_FLOAT;case R.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.UNSIGNED_SHORT_4_4_4_4;case R.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.UNSIGNED_SHORT_5_5_5_1;case R.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.UNSIGNED_SHORT_5_6_5;case R.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:return this._gl.UNSIGNED_INT_2_10_10_10_REV;case R.TEXTURETYPE_UNSIGNED_INT_24_8:return this._gl.UNSIGNED_INT_24_8;case R.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.UNSIGNED_INT_10F_11F_11F_REV;case R.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.UNSIGNED_INT_5_9_9_9_REV;case R.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV}return this._gl.UNSIGNED_BYTE},R.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case R.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case R.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case R.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case R.TEXTUREFORMAT_RED:t=this._gl.RED;break;case R.TEXTUREFORMAT_RG:t=this._gl.RG;break;case R.TEXTUREFORMAT_RGB:t=this._gl.RGB;break;case R.TEXTUREFORMAT_RGBA:t=this._gl.RGBA}if(1<this._webGLVersion)switch(e){case R.TEXTUREFORMAT_RED_INTEGER:t=this._gl.RED_INTEGER;break;case R.TEXTUREFORMAT_RG_INTEGER:t=this._gl.RG_INTEGER;break;case R.TEXTUREFORMAT_RGB_INTEGER:t=this._gl.RGB_INTEGER;break;case R.TEXTUREFORMAT_RGBA_INTEGER:t=this._gl.RGBA_INTEGER}return t},R.prototype._getRGBABufferInternalSizedFormat=function(e,t){if(1===this._webGLVersion){if(void 0!==t)switch(t){case R.TEXTUREFORMAT_ALPHA:return this._gl.ALPHA;case R.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case R.TEXTUREFORMAT_LUMINANCE_ALPHA:return this._gl.LUMINANCE_ALPHA}return this._gl.RGBA}switch(e){case R.TEXTURETYPE_BYTE:switch(t){case R.TEXTUREFORMAT_RED:return this._gl.R8_SNORM;case R.TEXTUREFORMAT_RG:return this._gl.RG8_SNORM;case R.TEXTUREFORMAT_RGB:return this._gl.RGB8_SNORM;case R.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8I;case R.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8I;case R.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8I;case R.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8I;default:return this._gl.RGBA8_SNORM}case R.TEXTURETYPE_UNSIGNED_BYTE:switch(t){case R.TEXTUREFORMAT_RED:return this._gl.R8;case R.TEXTUREFORMAT_RG:return this._gl.RG8;case R.TEXTUREFORMAT_RGB:return this._gl.RGB8;case R.TEXTUREFORMAT_RGBA:return this._gl.RGBA8;case R.TEXTUREFORMAT_RED_INTEGER:return this._gl.R8UI;case R.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG8UI;case R.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB8UI;case R.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGBA8UI;default:return this._gl.RGBA8}case R.TEXTURETYPE_SHORT:switch(t){case R.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16I;case R.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16I;case R.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16I;case R.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16I}case R.TEXTURETYPE_UNSIGNED_SHORT:switch(t){case R.TEXTUREFORMAT_RED_INTEGER:return this._gl.R16UI;case R.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG16UI;case R.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB16UI;case R.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA16UI}case R.TEXTURETYPE_INT:switch(t){case R.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32I;case R.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32I;case R.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32I;case R.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32I}case R.TEXTURETYPE_UNSIGNED_INTEGER:switch(t){case R.TEXTUREFORMAT_RED_INTEGER:return this._gl.R32UI;case R.TEXTUREFORMAT_RG_INTEGER:return this._gl.RG32UI;case R.TEXTUREFORMAT_RGB_INTEGER:return this._gl.RGB32UI;case R.TEXTUREFORMAT_RGBA_INTEGER:default:return this._gl.RGBA32UI}case R.TEXTURETYPE_FLOAT:switch(t){case R.TEXTUREFORMAT_RED:return this._gl.R32F;case R.TEXTUREFORMAT_RG:return this._gl.RG32F;case R.TEXTUREFORMAT_RGB:return this._gl.RGB32F;case R.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA32F}case R.TEXTURETYPE_HALF_FLOAT:switch(t){case R.TEXTUREFORMAT_RED:return this._gl.R16F;case R.TEXTUREFORMAT_RG:return this._gl.RG16F;case R.TEXTUREFORMAT_RGB:return this._gl.RGB16F;case R.TEXTUREFORMAT_RGBA:default:return this._gl.RGBA16F}case R.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:return this._gl.RGB565;case R.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:return this._gl.R11F_G11F_B10F;case R.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:return this._gl.RGB9_E5;case R.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:return this._gl.RGBA4;case R.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:return this._gl.RGB5_A1;case R.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:switch(t){case R.TEXTUREFORMAT_RGBA:return this._gl.RGB10_A2;case R.TEXTUREFORMAT_RGBA_INTEGER:return this._gl.RGB10_A2UI;default:return this._gl.RGB10_A2}}return this._gl.RGBA8},R.prototype._getRGBAMultiSampleBufferFormat=function(e){return e===R.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===R.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},R.prototype._loadFile=function(e,t,i,r,n,o){var s=this,a=M.Tools.LoadFile(e,t,i,r,n,o);return this._activeRequests.push(a),a.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),a},R.prototype._loadFileAsync=function(e,r,n){var o=this;return new Promise(function(t,i){o._loadFile(e,(function(e){t(e)}),void 0,r,n,(function(e,t){i(t)}))})},R.prototype._partialLoadFile=function(e,t,i,r,n,o){void 0===o&&(o=null);this._loadFile(e,(function(e){i[t]=e,i._internalCount++,6===i._internalCount&&n(i)}),void 0,void 0,!0,(function(e,t){o&&e&&o(e.status+" "+e.statusText,t)}))},R.prototype._cascadeLoadFiles=function(e,t,i,r){void 0===r&&(r=null);for(var n=[],o=n._internalCount=0;o<6;o++)this._partialLoadFile(i[o],o,n,e,t,r)},R.isSupported=function(){try{var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},R.ExceptionList=[{key:"Chrome/63.0",capture:"63\\.0\\.3239\\.(\\d+)",captureConstraint:108,targets:["uniformBuffer"]},{key:"Firefox/58",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Firefox/59",capture:null,captureConstraint:null,targets:["uniformBuffer"]},{key:"Macintosh",capture:null,captureConstraint:null,targets:["textureBindingOptimization"]},{key:"iPhone",capture:null,captureConstraint:null,targets:["textureBindingOptimization"]},{key:"iPad",capture:null,captureConstraint:null,targets:["textureBindingOptimization"]}],R.Instances=new Array,R._TextureLoaders=[],R.ALPHA_DISABLE=0,R.ALPHA_ADD=1,R.ALPHA_COMBINE=2,R.ALPHA_SUBTRACT=3,R.ALPHA_MULTIPLY=4,R.ALPHA_MAXIMIZED=5,R.ALPHA_ONEONE=6,R.ALPHA_PREMULTIPLIED=7,R.ALPHA_PREMULTIPLIED_PORTERDUFF=8,R.ALPHA_INTERPOLATE=9,R.ALPHA_SCREENMODE=10,R.DELAYLOADSTATE_NONE=0,R.DELAYLOADSTATE_LOADED=1,R.DELAYLOADSTATE_LOADING=2,R.DELAYLOADSTATE_NOTLOADED=4,R.NEVER=512,R.ALWAYS=519,R.LESS=513,R.EQUAL=514,R.LEQUAL=515,R.GREATER=516,R.GEQUAL=518,R.NOTEQUAL=517,R.KEEP=7680,R.REPLACE=7681,R.INCR=7682,R.DECR=7683,R.INVERT=5386,R.INCR_WRAP=34055,R.DECR_WRAP=34056,R.TEXTURE_CLAMP_ADDRESSMODE=0,R.TEXTURE_WRAP_ADDRESSMODE=1,R.TEXTURE_MIRROR_ADDRESSMODE=2,R.TEXTUREFORMAT_ALPHA=0,R.TEXTUREFORMAT_LUMINANCE=1,R.TEXTUREFORMAT_LUMINANCE_ALPHA=2,R.TEXTUREFORMAT_RGB=4,R.TEXTUREFORMAT_RGBA=5,R.TEXTUREFORMAT_RED=6,R.TEXTUREFORMAT_R=6,R.TEXTUREFORMAT_RG=7,R.TEXTUREFORMAT_RED_INTEGER=8,R.TEXTUREFORMAT_R_INTEGER=8,R.TEXTUREFORMAT_RG_INTEGER=9,R.TEXTUREFORMAT_RGB_INTEGER=10,R.TEXTUREFORMAT_RGBA_INTEGER=11,R.TEXTURETYPE_UNSIGNED_BYTE=0,R.TEXTURETYPE_UNSIGNED_INT=0,R.TEXTURETYPE_FLOAT=1,R.TEXTURETYPE_HALF_FLOAT=2,R.TEXTURETYPE_BYTE=3,R.TEXTURETYPE_SHORT=4,R.TEXTURETYPE_UNSIGNED_SHORT=5,R.TEXTURETYPE_INT=6,R.TEXTURETYPE_UNSIGNED_INTEGER=7,R.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4=8,R.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1=9,R.TEXTURETYPE_UNSIGNED_SHORT_5_6_5=10,R.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV=11,R.TEXTURETYPE_UNSIGNED_INT_24_8=12,R.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV=13,R.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV=14,R.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV=15,R.TEXTURE_NEAREST_SAMPLINGMODE=1,R.TEXTURE_BILINEAR_SAMPLINGMODE=2,R.TEXTURE_TRILINEAR_SAMPLINGMODE=3,R.TEXTURE_NEAREST_NEAREST_MIPLINEAR=1,R.TEXTURE_LINEAR_LINEAR_MIPNEAREST=2,R.TEXTURE_LINEAR_LINEAR_MIPLINEAR=3,R.TEXTURE_NEAREST_NEAREST_MIPNEAREST=4,R.TEXTURE_NEAREST_LINEAR_MIPNEAREST=5,R.TEXTURE_NEAREST_LINEAR_MIPLINEAR=6,R.TEXTURE_NEAREST_LINEAR=7,R.TEXTURE_NEAREST_NEAREST=8,R.TEXTURE_LINEAR_NEAREST_MIPNEAREST=9,R.TEXTURE_LINEAR_NEAREST_MIPLINEAR=10,R.TEXTURE_LINEAR_LINEAR=11,R.TEXTURE_LINEAR_NEAREST=12,R.TEXTURE_EXPLICIT_MODE=0,R.TEXTURE_SPHERICAL_MODE=1,R.TEXTURE_PLANAR_MODE=2,R.TEXTURE_CUBIC_MODE=3,R.TEXTURE_PROJECTION_MODE=4,R.TEXTURE_SKYBOX_MODE=5,R.TEXTURE_INVCUBIC_MODE=6,R.TEXTURE_EQUIRECTANGULAR_MODE=7,R.TEXTURE_FIXED_EQUIRECTANGULAR_MODE=8,R.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,R.SCALEMODE_FLOOR=1,R.SCALEMODE_NEAREST=2,R.SCALEMODE_CEILING=3,R.CollisionsEpsilon=.001,R.CodeRepository="src/",R.ShadersRepository="src/Shaders/",R})();M.Engine=i})($a||($a={})),y=$a||($a={}),x=(function(){function e(e,t){void 0===t&&(t=null),this.state="",this.metadata=null,this.doNotSerialize=!1,this._isDisposed=!1,this.animations=new Array,this._ranges={},this._isEnabled=!0,this._isParentEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this._childRenderId=-1,this._worldMatrix=y.Matrix.Identity(),this._worldMatrixDeterminant=0,this._sceneRootNodesIndex=-1,this._animationPropertiesOverride=null,this.onDisposeObservable=new y.Observable,this._behaviors=new Array,this.name=e,this.id=e,this._scene=t||y.Engine.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache(),this.addToSceneRootNodes()}return e.AddNodeConstructor=function(e,t){this._NodeConstructors[e]=t},e.Construct=function(e,t,i,r){var n=this._NodeConstructors[e];return n?n(t,i,r):null},e.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(e.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){var t=this._parentNode;if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){var i=this._parentNode._children.indexOf(this);-1!==i&&this._parentNode._children.splice(i,1),e||this.addToSceneRootNodes()}this._parentNode=e,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this),t||this.removeFromSceneRootNodes()),this._syncParentEnabledState()}},enumerable:!0,configurable:!0}),e.prototype.addToSceneRootNodes=function(){-1===this._sceneRootNodesIndex&&(this._sceneRootNodesIndex=this._scene.rootNodes.length,this._scene.rootNodes.push(this))},e.prototype.removeFromSceneRootNodes=function(){if(-1!==this._sceneRootNodesIndex){var e=this._scene.rootNodes,t=e.length-1;e[this._sceneRootNodesIndex]=e[t],e[this._sceneRootNodesIndex]._sceneRootNodesIndex=this._sceneRootNodesIndex,this._scene.rootNodes.pop(),this._sceneRootNodesIndex=-1}},Object.defineProperty(e.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"Node"},Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),e.prototype.getScene=function(){return this._scene},e.prototype.getEngine=function(){return this._scene.getEngine()},e.prototype.addBehavior=function(e,t){var i=this;return void 0===t&&(t=!1),-1!==this._behaviors.indexOf(e)||(e.init(),this._scene.isLoading&&!t?this._scene.onDataLoadedObservable.addOnce((function(){e.attach(i)})):e.attach(this),this._behaviors.push(e)),this},e.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);return-1===t||(this._behaviors[t].detach(),this._behaviors.splice(t,1)),this},Object.defineProperty(e.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!0,configurable:!0}),e.prototype.getBehaviorByName=function(e){for(var t=0,i=this._behaviors;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},e.prototype.getWorldMatrix=function(){return this._currentRenderId!==this._scene.getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},e.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminant},Object.defineProperty(e.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),e.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},e.prototype.updateCache=function(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},e.prototype._updateCache=function(e){},e.prototype._isSynchronized=function(){return!0},e.prototype._markSyncedWithParent=function(){this._parentNode&&(this._parentRenderId=this._parentNode._childRenderId)},e.prototype.isSynchronizedWithParent=function(){return!this._parentNode||this._parentRenderId===this._parentNode._childRenderId&&this._parentNode.isSynchronized()},e.prototype.isSynchronized=function(){return this._cache.parent!=this._parentNode?(this._cache.parent=this._parentNode,!1):!(this._parentNode&&!this.isSynchronizedWithParent())&&this._isSynchronized()},e.prototype.isReady=function(e){return void 0===e&&(e=!1),this._isReady},e.prototype.isEnabled=function(e){return void 0===e&&(e=!0),!1===e?this._isEnabled:!!this._isEnabled&&this._isParentEnabled},e.prototype._syncParentEnabledState=function(){this._isParentEnabled=!this._parentNode||this._parentNode.isEnabled(),this._children&&this._children.forEach((function(e){e._syncParentEnabledState()}))},e.prototype.setEnabled=function(e){this._isEnabled=e,this._syncParentEnabledState()},e.prototype.isDescendantOf=function(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))},e.prototype._getDescendants=function(e,t,i){if(void 0===t&&(t=!1),this._children)for(var r=0;r<this._children.length;r++){var n=this._children[r];i&&!i(n)||e.push(n),t||n._getDescendants(e,!1,i)}},e.prototype.getDescendants=function(e,t){var i=new Array;return this._getDescendants(i,e,t),i},e.prototype.getChildMeshes=function(e,t){var i=[];return this._getDescendants(i,e,(function(e){return(!t||t(e))&&e instanceof y.AbstractMesh})),i},e.prototype.getChildTransformNodes=function(e,t){var i=[];return this._getDescendants(i,e,(function(e){return(!t||t(e))&&e instanceof y.TransformNode})),i},e.prototype.getChildren=function(e){return this.getDescendants(!0,e)},e.prototype._setReady=function(e){e!==this._isReady&&(e?(this.onReady&&this.onReady(this),this._isReady=!0):this._isReady=!1)},e.prototype.getAnimationByName=function(e){for(var t=0;t<this.animations.length;t++){var i=this.animations[t];if(i.name===e)return i}return null},e.prototype.createAnimationRange=function(e,t,i){if(!this._ranges[e]){this._ranges[e]=new y.AnimationRange(e,t,i);for(var r=0,n=this.animations.length;r<n;r++)this.animations[r]&&this.animations[r].createRange(e,t,i)}},e.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.animations.length;i<r;i++)this.animations[i]&&this.animations[i].deleteRange(e,t);this._ranges[e]=null},e.prototype.getAnimationRange=function(e){return this._ranges[e]},e.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},e.prototype.serializeAnimationRanges=function(){var e=[];for(var t in this._ranges){var i=this._ranges[t];if(i){var r={};r.name=t,r.from=i.from,r.to=i.to,e.push(r)}}return e},e.prototype.computeWorldMatrix=function(e){return this._worldMatrix||(this._worldMatrix=y.Matrix.Identity()),this._worldMatrix},e.prototype.dispose=function(e,t){if(void 0===t&&(t=!1),e)for(var i=0,r=this.getChildTransformNodes(!0);i<r.length;i++){var n=r[i];n.parent=null,n.computeWorldMatrix(!0)}else for(var o=0,s=this.getDescendants(!0);o<s.length;o++){s[o].dispose(e,t)}this.parent?this.parent=null:this.removeFromSceneRootNodes(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var a=0,l=this._behaviors;a<l.length;a++){l[a].detach()}this._behaviors=[],this._isDisposed=!0},e.ParseAnimationRanges=function(e,t,i){if(t.ranges)for(var r=0;r<t.ranges.length;r++){var n=t.ranges[r];e.createAnimationRange(n.name,n.from,n.to)}},e._NodeConstructors={},b([y.serialize()],e.prototype,"name",void 0),b([y.serialize()],e.prototype,"id",void 0),b([y.serialize()],e.prototype,"uniqueId",void 0),b([y.serialize()],e.prototype,"state",void 0),b([y.serialize()],e.prototype,"metadata",void 0),e})(),y.Node=x,E=$a||($a={}),A=E.Matrix.Identity(),P=(function(){function e(e,t){this.center=E.Vector3.Zero(),this.centerWorld=E.Vector3.Zero(),this.minimum=E.Vector3.Zero(),this.maximum=E.Vector3.Zero(),this.reConstruct(e,t)}return e.prototype.reConstruct=function(e,t){this.minimum.copyFrom(e),this.maximum.copyFrom(t);var i=E.Vector3.Distance(e,t);E.Vector3.LerpToRef(e,t,.5,this.center),this.radius=.5*i,this.centerWorld.set(0,0,0),this._update(A)},e.prototype.scale=function(e){var t=this.radius*e,i=E.Tmp.Vector3[0].set(t,t,t),r=E.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(i),n=E.Tmp.Vector3[2].copyFrom(this.center).addInPlace(i);return this.reConstruct(r,n),this},e.prototype._update=function(e){E.Vector3.TransformCoordinatesToRef(this.center,e,this.centerWorld);var t=E.Tmp.Vector3[0];E.Vector3.TransformNormalFromFloatsToRef(1,1,1,e,t),this.radiusWorld=Math.max(Math.abs(t.x),Math.abs(t.y),Math.abs(t.z))*this.radius},e.prototype.isInFrustum=function(e){for(var t=0;t<6;t++)if(e[t].dotCoordinate(this.centerWorld)<=-this.radiusWorld)return!1;return!0},e.prototype.intersectsPoint=function(e){var t=this.centerWorld.x-e.x,i=this.centerWorld.y-e.y,r=this.centerWorld.z-e.z,n=Math.sqrt(t*t+i*i+r*r);return!(this.radiusWorld<n)},e.Intersects=function(e,t){var i=e.centerWorld.x-t.centerWorld.x,r=e.centerWorld.y-t.centerWorld.y,n=e.centerWorld.z-t.centerWorld.z,o=Math.sqrt(i*i+r*r+n*n);return!(e.radiusWorld+t.radiusWorld<o)},e})(),E.BoundingSphere=P,S=$a||($a={}),R=(function(){function t(e,t){this.vectors=[S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero()],this.center=S.Vector3.Zero(),this.centerWorld=S.Vector3.Zero(),this.extendSize=S.Vector3.Zero(),this.extendSizeWorld=S.Vector3.Zero(),this.directions=[S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero()],this.vectorsWorld=[S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero(),S.Vector3.Zero()],this.minimumWorld=S.Vector3.Zero(),this.maximumWorld=S.Vector3.Zero(),this.minimum=S.Vector3.Zero(),this.maximum=S.Vector3.Zero(),this.reConstruct(e,t)}return t.prototype.reConstruct=function(e,t){this.minimum.copyFrom(e),this.maximum.copyFrom(t),this.vectors[0].copyFrom(this.minimum),this.vectors[1].copyFrom(this.maximum),this.vectors[2].copyFrom(this.minimum),this.vectors[3].copyFrom(this.minimum),this.vectors[4].copyFrom(this.minimum),this.vectors[5].copyFrom(this.maximum),this.vectors[6].copyFrom(this.maximum),this.vectors[7].copyFrom(this.maximum),this.vectors[2].x=this.maximum.x,this.vectors[3].y=this.maximum.y,this.vectors[4].z=this.maximum.z,this.vectors[5].z=this.minimum.z,this.vectors[6].x=this.minimum.x,this.vectors[7].y=this.minimum.y,this.center.copyFrom(this.maximum).addInPlace(this.minimum).scaleInPlace(.5),this.extendSize.copyFrom(this.maximum).subtractInPlace(this.minimum).scaleInPlace(.5);for(var i=0;i<3;i++)this.directions[i].copyFromFloats(0,0,0);for(i=0;i<8;i++)this.vectorsWorld[i].copyFromFloats(0,0,0);this.minimumWorld.copyFromFloats(0,0,0),this.maximumWorld.copyFromFloats(0,0,0),this.centerWorld.copyFromFloats(0,0,0),this.extendSizeWorld.copyFromFloats(0,0,0),this._update(this._worldMatrix||S.Matrix.Identity())},t.prototype.scale=function(e){var t=S.Tmp.Vector3[0].copyFrom(this.maximum).subtractInPlace(this.minimum),i=t.length()*e;t.normalize();var r=t.scaleInPlace(.5*i),n=S.Tmp.Vector3[1].copyFrom(this.center).subtractInPlace(r),o=S.Tmp.Vector3[2].copyFrom(this.center).addInPlace(r);return this.reConstruct(n,o),this},t.prototype.getWorldMatrix=function(){return this._worldMatrix},t.prototype.setWorldMatrix=function(e){return this._worldMatrix.copyFrom(e),this},t.prototype._update=function(e){S.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this.minimumWorld),S.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this.maximumWorld);for(var t=0;t<8;t++){var i=this.vectorsWorld[t];S.Vector3.TransformCoordinatesToRef(this.vectors[t],e,i),this.minimumWorld.minimizeInPlace(i),this.maximumWorld.maximizeInPlace(i)}this.maximumWorld.subtractToRef(this.minimumWorld,this.extendSizeWorld),this.extendSizeWorld.scaleInPlace(.5),this.maximumWorld.addToRef(this.minimumWorld,this.centerWorld),this.centerWorld.scaleInPlace(.5),S.Vector3.FromFloatArrayToRef(e.m,0,this.directions[0]),S.Vector3.FromFloatArrayToRef(e.m,4,this.directions[1]),S.Vector3.FromFloatArrayToRef(e.m,8,this.directions[2]),this._worldMatrix=e},t.prototype.isInFrustum=function(e){return t.IsInFrustum(this.vectorsWorld,e)},t.prototype.isCompletelyInFrustum=function(e){return t.IsCompletelyInFrustum(this.vectorsWorld,e)},t.prototype.intersectsPoint=function(e){var t=-S.Epsilon;return!(this.maximumWorld.x-e.x<t||t>e.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-e.y<t||t>e.y-this.minimumWorld.y)&&!(this.maximumWorld.z-e.z<t||t>e.z-this.minimumWorld.z))},t.prototype.intersectsSphere=function(e){return t.IntersectsSphere(this.minimumWorld,this.maximumWorld,e.centerWorld,e.radiusWorld)},t.prototype.intersectsMinMax=function(e,t){return!(this.maximumWorld.x<e.x||this.minimumWorld.x>t.x)&&(!(this.maximumWorld.y<e.y||this.minimumWorld.y>t.y)&&!(this.maximumWorld.z<e.z||this.minimumWorld.z>t.z))},t.Intersects=function(e,t){return!(e.maximumWorld.x<t.minimumWorld.x||e.minimumWorld.x>t.maximumWorld.x)&&(!(e.maximumWorld.y<t.minimumWorld.y||e.minimumWorld.y>t.maximumWorld.y)&&!(e.maximumWorld.z<t.minimumWorld.z||e.minimumWorld.z>t.maximumWorld.z))},t.IntersectsSphere=function(e,t,i,r){var n=S.Vector3.Clamp(i,e,t);return S.Vector3.DistanceSquared(i,n)<=r*r},t.IsCompletelyInFrustum=function(e,t){for(var i=0;i<6;i++)for(var r=0;r<8;r++)if(t[i].dotCoordinate(e[r])<0)return!1;return!0},t.IsInFrustum=function(e,t){for(var i=0;i<6;i++){for(var r=8,n=0;n<8&&t[i].dotCoordinate(e[n])<0;n++)--r;if(0===r)return!1}return!0},t})(),S.BoundingBox=R,M=$a||($a={}),C=function(e,t){var i=M.Vector3.Dot(t.centerWorld,e),r=Math.abs(M.Vector3.Dot(t.directions[0],e))*t.extendSize.x+Math.abs(M.Vector3.Dot(t.directions[1],e))*t.extendSize.y+Math.abs(M.Vector3.Dot(t.directions[2],e))*t.extendSize.z;return{min:i-r,max:i+r}},O=function(e,t,i){var r,n,o,s=C(e,t),a=C(e,i);return r=s.min,n=s.max,o=a.min,!(a.max<r||n<o)},D=(function(){function e(e,t){this._isLocked=!1,this.boundingBox=new M.BoundingBox(e,t),this.boundingSphere=new M.BoundingSphere(e,t)}return 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(e,t){var i=M.Tmp.Vector3[0].copyFrom(e).subtractInPlace(t),r=M.Tmp.Vector3[1].copyFrom(e).addInPlace(t);return this.boundingBox.reConstruct(i,r),this.boundingSphere.reConstruct(i,r),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=M.AbstractMesh.CULLINGSTRATEGY_STANDARD),!!this.boundingSphere.isInFrustum(e)&&(t===M.AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY||this.boundingBox.isInFrustum(e))},Object.defineProperty(e.prototype,"diagonalLength",{get:function(){var e=this.boundingBox;return e.maximumWorld.subtract(e.minimumWorld).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(!this.boundingSphere.centerWorld||!e.boundingSphere.centerWorld)return!1;if(!M.BoundingSphere.Intersects(this.boundingSphere,e.boundingSphere))return!1;if(!M.BoundingBox.Intersects(this.boundingBox,e.boundingBox))return!1;if(!t)return!0;var i=this.boundingBox,r=e.boundingBox;return!!O(i.directions[0],i,r)&&(!!O(i.directions[1],i,r)&&(!!O(i.directions[2],i,r)&&(!!O(r.directions[0],i,r)&&(!!O(r.directions[1],i,r)&&(!!O(r.directions[2],i,r)&&(!!O(M.Vector3.Cross(i.directions[0],r.directions[0]),i,r)&&(!!O(M.Vector3.Cross(i.directions[0],r.directions[1]),i,r)&&(!!O(M.Vector3.Cross(i.directions[0],r.directions[2]),i,r)&&(!!O(M.Vector3.Cross(i.directions[1],r.directions[0]),i,r)&&(!!O(M.Vector3.Cross(i.directions[1],r.directions[1]),i,r)&&(!!O(M.Vector3.Cross(i.directions[1],r.directions[2]),i,r)&&(!!O(M.Vector3.Cross(i.directions[2],r.directions[0]),i,r)&&(!!O(M.Vector3.Cross(i.directions[2],r.directions[1]),i,r)&&!!O(M.Vector3.Cross(i.directions[2],r.directions[2]),i,r))))))))))))))},e})(),M.BoundingInfo=D,I=$a||($a={}),w=(function(n){function h(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!0);var r=n.call(this,e,t)||this;return r._forward=new I.Vector3(0,0,1),r._forwardInverted=new I.Vector3(0,0,-1),r._up=new I.Vector3(0,1,0),r._right=new I.Vector3(1,0,0),r._rightInverted=new I.Vector3(-1,0,0),r._position=I.Vector3.Zero(),r._rotation=I.Vector3.Zero(),r._scaling=I.Vector3.One(),r._isDirty=!1,r.billboardMode=h.BILLBOARDMODE_NONE,r.scalingDeterminant=1,r.infiniteDistance=!1,r.ignoreNonUniformScaling=!1,r._localWorld=I.Matrix.Zero(),r._absolutePosition=I.Vector3.Zero(),r._pivotMatrix=I.Matrix.Identity(),r._postMultiplyPivotMatrix=!1,r._isWorldMatrixFrozen=!1,r.onAfterWorldMatrixUpdateObservable=new I.Observable,r._nonUniformScaling=!1,i&&r.getScene().addTransformNode(r),r}return T(h,n),h.prototype.getClassName=function(){return"TransformNode"},Object.defineProperty(h.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this._isDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){(this._rotationQuaternion=e)&&this.rotation.length()&&this.rotation.copyFromFloats(0,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"forward",{get:function(){return I.Vector3.Normalize(I.Vector3.TransformNormal(this.getScene().useRightHandedSystem?this._forwardInverted:this._forward,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"up",{get:function(){return I.Vector3.Normalize(I.Vector3.TransformNormal(this._up,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),Object.defineProperty(h.prototype,"right",{get:function(){return I.Vector3.Normalize(I.Vector3.TransformNormal(this.getScene().useRightHandedSystem?this._rightInverted:this._right,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),h.prototype.updatePoseMatrix=function(e){return this._poseMatrix.copyFrom(e),this},h.prototype.getPoseMatrix=function(){return this._poseMatrix},h.prototype._isSynchronized=function(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===h.BILLBOARDMODE_NONE&&(!this._cache.pivotMatrixUpdated&&(!this.infiniteDistance&&(!!this._cache.position.equals(this._position)&&(!(this._rotationQuaternion&&!this._cache.rotationQuaternion.equals(this._rotationQuaternion))&&(!!this._cache.rotation.equals(this._rotation)&&!!this._cache.scaling.equals(this._scaling)))))))},h.prototype._initCache=function(){n.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=I.Vector3.Zero(),this._cache.scaling=I.Vector3.Zero(),this._cache.rotation=I.Vector3.Zero(),this._cache.rotationQuaternion=new I.Quaternion(0,0,0,0),this._cache.billboardMode=-1},h.prototype.markAsDirty=function(e){return"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},Object.defineProperty(h.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),h.prototype.setPreTransformMatrix=function(e){return this.setPivotMatrix(e,!1)},h.prototype.setPivotMatrix=function(e,t){return void 0===t&&(t=!0),this._pivotMatrix=e.clone(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=t,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=I.Matrix.Invert(this._pivotMatrix)),this},h.prototype.getPivotMatrix=function(){return this._pivotMatrix},h.prototype.freezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0,this},h.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(h.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),h.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},h.prototype.setAbsolutePosition=function(e){if(!e)return this;var t,i,r;if(void 0===e.x){if(arguments.length<3)return this;t=e,i=arguments[1],r=arguments[2]}else t=e.x,i=e.y,r=e.z;if(this.parent){var n=this.parent.getWorldMatrix().clone();n.invert();var o=new I.Vector3(t,i,r);this.position=I.Vector3.TransformCoordinates(o,n)}else this.position.x=t,this.position.y=i,this.position.z=r;return this},h.prototype.setPositionWithLocalVector=function(e){return this.computeWorldMatrix(),this.position=I.Vector3.TransformNormal(e,this._localWorld),this},h.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var e=this._localWorld.clone();return e.invert(),I.Vector3.TransformNormal(this.position,e)},h.prototype.locallyTranslate=function(e){return this.computeWorldMatrix(!0),this.position=I.Vector3.TransformCoordinates(e,this._localWorld),this},h.prototype.lookAt=function(e,t,i,r,n){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===n&&(n=I.Space.LOCAL);var o=h._lookAtVectorCache,s=n===I.Space.LOCAL?this.position:this.getAbsolutePosition();e.subtractToRef(s,o);var a=-Math.atan2(o.z,o.x)-Math.PI/2,l=Math.sqrt(o.x*o.x+o.z*o.z),c=Math.atan2(o.y,l);return this.rotationQuaternion?I.Quaternion.RotationYawPitchRollToRef(a+t,c+i,r,this.rotationQuaternion):(this.rotation.x=c+i,this.rotation.y=a+t,this.rotation.z=r),this},h.prototype.getDirection=function(e){var t=I.Vector3.Zero();return this.getDirectionToRef(e,t),t},h.prototype.getDirectionToRef=function(e,t){return I.Vector3.TransformNormalToRef(e,this.getWorldMatrix(),t),this},h.prototype.setPivotPoint=function(e,t){void 0===t&&(t=I.Space.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var i=this.getWorldMatrix();if(t==I.Space.WORLD){var r=I.Tmp.Matrix[0];i.invertToRef(r),e=I.Vector3.TransformCoordinates(e,r)}return this.setPivotMatrix(I.Matrix.Translation(-e.x,-e.y,-e.z),!0)},h.prototype.getPivotPoint=function(){var e=I.Vector3.Zero();return this.getPivotPointToRef(e),e},h.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},h.prototype.getAbsolutePivotPoint=function(){var e=I.Vector3.Zero();return this.getAbsolutePivotPointToRef(e),e},h.prototype.getAbsolutePivotPointToRef=function(e){return e.x=this._pivotMatrix.m[12],e.y=this._pivotMatrix.m[13],e.z=this._pivotMatrix.m[14],this.getPivotPointToRef(e),I.Vector3.TransformCoordinatesToRef(e,this.getWorldMatrix(),e),this},h.prototype.setParent=function(e){if(!e&&!this.parent)return this;if(e){r=I.Tmp.Quaternion[0],n=I.Tmp.Vector3[0],o=I.Tmp.Vector3[1];var t=I.Tmp.Matrix[0],i=I.Tmp.Matrix[1];this.computeWorldMatrix(!0),e.computeWorldMatrix(!0),e.getWorldMatrix().invertToRef(i),this.getWorldMatrix().multiplyToRef(i,t),t.decompose(o,r,n),this.rotationQuaternion?this.rotationQuaternion.copyFrom(r):r.toEulerAnglesToRef(this.rotation),this.position.x=n.x,this.position.y=n.y,this.position.z=n.z,this.scaling.x=o.x,this.scaling.y=o.y,this.scaling.z=o.z}else{var r=I.Tmp.Quaternion[0],n=I.Tmp.Vector3[0],o=I.Tmp.Vector3[1];this.parent&&this.parent.computeWorldMatrix&&this.parent.computeWorldMatrix(!0),this.computeWorldMatrix(!0),this.getWorldMatrix().decompose(o,r,n),this.rotationQuaternion?this.rotationQuaternion.copyFrom(r):r.toEulerAnglesToRef(this.rotation),this.scaling.x=o.x,this.scaling.y=o.y,this.scaling.z=o.z,this.position.x=n.x,this.position.y=n.y,this.position.z=n.z}return this.parent=e,this},Object.defineProperty(h.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!0,configurable:!0}),h.prototype._updateNonUniformScalingState=function(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=e,!0)},h.prototype.attachToBone=function(e,t){return this._transformToBoneReferal=t,(this.parent=e).getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},h.prototype.detachFromBone=function(){return this.parent&&(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=null),this},h.prototype.rotate=function(e,t,i){var r;if(e.normalize(),this.rotationQuaternion||(this.rotationQuaternion=I.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=I.Vector3.Zero()),i&&i!==I.Space.LOCAL){if(this.parent){var n=this.parent.getWorldMatrix().clone();n.invert(),e=I.Vector3.TransformNormal(e,n)}(r=I.Quaternion.RotationAxisToRef(e,t,h._rotationAxisCache)).multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else r=I.Quaternion.RotationAxisToRef(e,t,h._rotationAxisCache),this.rotationQuaternion.multiplyToRef(r,this.rotationQuaternion);return this},h.prototype.rotateAround=function(e,t,i){return t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=I.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.copyFromFloats(0,0,0)),e.subtractToRef(this.position,I.Tmp.Vector3[0]),I.Matrix.TranslationToRef(I.Tmp.Vector3[0].x,I.Tmp.Vector3[0].y,I.Tmp.Vector3[0].z,I.Tmp.Matrix[0]),I.Tmp.Matrix[0].invertToRef(I.Tmp.Matrix[2]),I.Matrix.RotationAxisToRef(t,i,I.Tmp.Matrix[1]),I.Tmp.Matrix[2].multiplyToRef(I.Tmp.Matrix[1],I.Tmp.Matrix[2]),I.Tmp.Matrix[2].multiplyToRef(I.Tmp.Matrix[0],I.Tmp.Matrix[2]),I.Tmp.Matrix[2].decompose(I.Tmp.Vector3[0],I.Tmp.Quaternion[0],I.Tmp.Vector3[1]),this.position.addInPlace(I.Tmp.Vector3[1]),I.Tmp.Quaternion[0].multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},h.prototype.translate=function(e,t,i){var r=e.scale(t);if(i&&i!==I.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(r));else{var n=this.getPositionExpressedInLocalSpace().add(r);this.setPositionWithLocalVector(n)}return this},h.prototype.addRotation=function(e,t,i){var r;this.rotationQuaternion?r=this.rotationQuaternion:(r=I.Tmp.Quaternion[1],I.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,r));var n=I.Tmp.Quaternion[0];return I.Quaternion.RotationYawPitchRollToRef(t,e,i,n),r.multiplyInPlace(n),this.rotationQuaternion||r.toEulerAnglesToRef(this.rotation),this},h.prototype.computeWorldMatrix=function(e){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!e&&this.isSynchronized())return this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix;(this._updateCache(),this._cache.position.copyFrom(this.position),this._cache.scaling.copyFrom(this.scaling),this._cache.pivotMatrixUpdated=!1,this._cache.billboardMode=this.billboardMode,this._currentRenderId=this.getScene().getRenderId(),this._childRenderId=this.getScene().getRenderId(),this._isDirty=!1,I.Matrix.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,I.Tmp.Matrix[1]),this.rotationQuaternion)&&(this.rotation.length()&&(this.rotationQuaternion.multiplyInPlace(I.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)),this.rotation.copyFromFloats(0,0,0)));this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(I.Tmp.Matrix[0]),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(I.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,I.Tmp.Matrix[0]),this._cache.rotation.copyFrom(this.rotation));var t=this.getScene().activeCamera;if(this.infiniteDistance&&!this.parent&&t){var i=t.getWorldMatrix(),r=new I.Vector3(i.m[12],i.m[13],i.m[14]);I.Matrix.TranslationToRef(this.position.x+r.x,this.position.y+r.y,this.position.z+r.z,I.Tmp.Matrix[2])}else I.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,I.Tmp.Matrix[2]);if(this._pivotMatrix.multiplyToRef(I.Tmp.Matrix[1],I.Tmp.Matrix[4]),I.Tmp.Matrix[4].multiplyToRef(I.Tmp.Matrix[0],I.Tmp.Matrix[5]),this.billboardMode!==h.BILLBOARDMODE_NONE&&t){if((this.billboardMode&h.BILLBOARDMODE_ALL)!==h.BILLBOARDMODE_ALL){var n=I.Tmp.Vector3[3];this.parent&&this.parent.getWorldMatrix?this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),I.Tmp.Matrix[6]),I.Vector3.TransformCoordinatesToRef(this.position,I.Tmp.Matrix[6],n)):I.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),n):n.copyFrom(this.position),n.subtractInPlace(t.globalPosition);var o=I.Tmp.Vector3[4].copyFromFloats(0,0,0);(this.billboardMode&h.BILLBOARDMODE_X)===h.BILLBOARDMODE_X&&(o.x=Math.atan2(-n.y,n.z)),(this.billboardMode&h.BILLBOARDMODE_Y)===h.BILLBOARDMODE_Y&&(o.y=Math.atan2(n.x,n.z)),(this.billboardMode&h.BILLBOARDMODE_Z)===h.BILLBOARDMODE_Z&&(o.z=Math.atan2(n.y,n.x)),I.Matrix.RotationYawPitchRollToRef(o.y,o.x,o.z,I.Tmp.Matrix[0])}else I.Tmp.Matrix[1].copyFrom(t.getViewMatrix()),I.Tmp.Matrix[1].setTranslationFromFloats(0,0,0),I.Tmp.Matrix[1].invertToRef(I.Tmp.Matrix[0]);I.Tmp.Matrix[1].copyFrom(I.Tmp.Matrix[5]),I.Tmp.Matrix[1].multiplyToRef(I.Tmp.Matrix[0],I.Tmp.Matrix[5])}return this._postMultiplyPivotMatrix&&I.Tmp.Matrix[5].multiplyToRef(this._pivotMatrixInverse,I.Tmp.Matrix[5]),I.Tmp.Matrix[5].multiplyToRef(I.Tmp.Matrix[2],this._localWorld),this.parent&&this.parent.getWorldMatrix?(this.billboardMode!==h.BILLBOARDMODE_NONE?(this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),I.Tmp.Matrix[6]),I.Tmp.Matrix[5].copyFrom(I.Tmp.Matrix[6])):I.Tmp.Matrix[5].copyFrom(this.parent.getWorldMatrix()),this._localWorld.getTranslationToRef(I.Tmp.Vector3[5]),I.Vector3.TransformCoordinatesToRef(I.Tmp.Vector3[5],I.Tmp.Matrix[5],I.Tmp.Vector3[5]),this._worldMatrix.copyFrom(this._localWorld),this._worldMatrix.setTranslation(I.Tmp.Vector3[5])):this._transformToBoneReferal?(this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),I.Tmp.Matrix[6]),I.Tmp.Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),this._worldMatrix)):this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()):this._worldMatrix.copyFrom(this._localWorld),this.ignoreNonUniformScaling?this._updateNonUniformScalingState(!1):this.scaling.isNonUniform?this._updateNonUniformScalingState(!0):this.parent&&this.parent._nonUniformScaling?this._updateNonUniformScalingState(this.parent._nonUniformScaling):this._updateNonUniformScalingState(!1),this._afterComputeWorldMatrix(),this._absolutePosition.copyFromFloats(this._worldMatrix.m[12],this._worldMatrix.m[13],this._worldMatrix.m[14]),this.onAfterWorldMatrixUpdateObservable.notifyObservers(this),this._poseMatrix||(this._poseMatrix=I.Matrix.Invert(this._worldMatrix)),this._worldMatrixDeterminant=this._worldMatrix.determinant(),this._worldMatrix},h.prototype._afterComputeWorldMatrix=function(){},h.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},h.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},h.prototype.clone=function(e,t,i){var r=this,n=I.SerializationHelper.Clone((function(){return new h(e,r.getScene())}),this);if(n.name=e,n.id=e,t&&(n.parent=t),!i)for(var o=this.getDescendants(!0),s=0;s<o.length;s++){var a=o[s];a.clone&&a.clone(e+"."+a.name,n)}return n},h.prototype.serialize=function(e){var t=I.SerializationHelper.Serialize(this,e);return t.type=this.getClassName(),this.parent&&(t.parentId=this.parent.id),I.Tags&&I.Tags.HasTags(this)&&(t.tags=I.Tags.GetTags(this)),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(),this.parent&&(t.parentId=this.parent.id),t},h.Parse=function(e,t,i){var r=I.SerializationHelper.Parse((function(){return new h(e.name,t)}),e,t,i);return I.Tags&&I.Tags.AddTagsTo(r,e.tags),e.localMatrix?r.setPreTransformMatrix(I.Matrix.FromArray(e.localMatrix)):e.pivotMatrix&&r.setPivotMatrix(I.Matrix.FromArray(e.pivotMatrix)),r.setEnabled(e.isEnabled),e.parentId&&(r._waitingParentId=e.parentId),r},h.prototype.dispose=function(e,t){void 0===t&&(t=!1),this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this.onAfterWorldMatrixUpdateObservable.clear(),n.prototype.dispose.call(this,e,t)},h.BILLBOARDMODE_NONE=0,h.BILLBOARDMODE_X=1,h.BILLBOARDMODE_Y=2,h.BILLBOARDMODE_Z=4,h.BILLBOARDMODE_ALL=7,h._lookAtVectorCache=new I.Vector3(0,0,0),h._rotationAxisCache=new I.Quaternion,b([I.serializeAsVector3("position")],h.prototype,"_position",void 0),b([I.serializeAsVector3("rotation")],h.prototype,"_rotation",void 0),b([I.serializeAsQuaternion("rotationQuaternion")],h.prototype,"_rotationQuaternion",void 0),b([I.serializeAsVector3("scaling")],h.prototype,"_scaling",void 0),b([I.serialize()],h.prototype,"billboardMode",void 0),b([I.serialize()],h.prototype,"scalingDeterminant",void 0),b([I.serialize()],h.prototype,"infiniteDistance",void 0),b([I.serialize()],h.prototype,"ignoreNonUniformScaling",void 0),h})(I.Node),I.TransformNode=w,L=$a||($a={}),F=function(){this.facetNb=0,this.partitioningSubdivisions=10,this.partitioningBBoxRatio=1.01,this.facetDataEnabled=!1,this.facetParameters={},this.bbSize=L.Vector3.Zero(),this.subDiv={max:1,X:1,Y:1,Z:1},this.facetDepthSort=!1,this.facetDepthSortEnabled=!1},B=(function(a){function i(e,t){void 0===t&&(t=null);var r=a.call(this,e,t,!1)||this;return r._facetData=new F,r.cullingStrategy=i.CULLINGSTRATEGY_STANDARD,r.onCollideObservable=new L.Observable,r.onCollisionPositionChangeObservable=new L.Observable,r.onMaterialChangedObservable=new L.Observable,r.definedFacingForward=!0,r._visibility=1,r.alphaIndex=Number.MAX_VALUE,r.isVisible=!0,r.isPickable=!0,r.showSubMeshesBoundingBox=!1,r.isBlocker=!1,r.enablePointerMoveEvents=!1,r.renderingGroupId=0,r._receiveShadows=!1,r.outlineColor=L.Color3.Red(),r.outlineWidth=.02,r.overlayColor=L.Color3.Red(),r.overlayAlpha=.5,r._hasVertexAlpha=!1,r._useVertexColors=!0,r._computeBonesUsingShaders=!0,r._numBoneInfluencers=4,r._applyFog=!0,r.useOctreeForRenderingSelection=!0,r.useOctreeForPicking=!0,r.useOctreeForCollisions=!0,r._layerMask=268435455,r.alwaysSelectAsActiveMesh=!1,r.actionManager=null,r._checkCollisions=!1,r._collisionMask=-1,r._collisionGroup=-1,r.ellipsoid=new L.Vector3(.5,1,.5),r.ellipsoidOffset=new L.Vector3(0,0,0),r._oldPositionForCollisions=new L.Vector3(0,0,0),r._diffPositionForCollisions=new L.Vector3(0,0,0),r.edgesWidth=1,r.edgesColor=new L.Color4(1,0,0,1),r._renderId=0,r._intersectionsInProgress=new Array,r._unIndexed=!1,r._lightSources=new Array,r.onRebuildObservable=new L.Observable,r._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),r.getScene().workerCollisions&&t.multiplyInPlace(r._collider._radius),t.subtractToRef(r._oldPositionForCollisions,r._diffPositionForCollisions),r._diffPositionForCollisions.length()>L.Engine.CollisionsEpsilon&&r.position.addInPlace(r._diffPositionForCollisions),i&&r.onCollideObservable.notifyObservers(i),r.onCollisionPositionChangeObservable.notifyObservers(r.position)},r.getScene().addMesh(r),r._resyncLightSources(),r}return T(i,a),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return L.TransformNode.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return L.TransformNode.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return L.TransformNode.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return L.TransformNode.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return L.TransformNode.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"facetNb",{get:function(){return this._facetData.facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningSubdivisions",{get:function(){return this._facetData.partitioningSubdivisions},set:function(e){this._facetData.partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningBBoxRatio",{get:function(){return this._facetData.partitioningBBoxRatio},set:function(e){this._facetData.partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"mustDepthSortFacets",{get:function(){return this._facetData.facetDepthSort},set:function(e){this._facetData.facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"facetDepthSortFrom",{get:function(){return this._facetData.facetDepthSortFrom},set:function(e){this._facetData.facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isFacetDataEnabled",{get:function(){return this._facetData.facetDataEnabled},enumerable:!0,configurable:!0}),i.prototype._updateNonUniformScalingState=function(e){return!!a.prototype._updateNonUniformScalingState.call(this,e)&&(this._markSubMeshesAsMiscDirty(),!0)},Object.defineProperty(i.prototype,"onCollide",{set:function(e){this._onCollideObserver&&this.onCollideObservable.remove(this._onCollideObserver),this._onCollideObserver=this.onCollideObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onCollisionPositionChange",{set:function(e){this._onCollisionPositionChangeObserver&&this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver),this._onCollisionPositionChangeObserver=this.onCollisionPositionChangeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"visibility",{get:function(){return this._visibility},set:function(e){this._visibility!==e&&(this._visibility=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"material",{get:function(){return this._material},set:function(e){this._material!==e&&(this._material=e,this.onMaterialChangedObservable.hasObservers&&this.onMaterialChangedObservable.notifyObservers(this),this.subMeshes&&this._unBindEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"receiveShadows",{get:function(){return this._receiveShadows},set:function(e){this._receiveShadows!==e&&(this._receiveShadows=e,this._markSubMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"hasVertexAlpha",{get:function(){return this._hasVertexAlpha},set:function(e){this._hasVertexAlpha!==e&&(this._hasVertexAlpha=e,this._markSubMeshesAsAttributesDirty(),this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useVertexColors",{get:function(){return this._useVertexColors},set:function(e){this._useVertexColors!==e&&(this._useVertexColors=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"computeBonesUsingShaders",{get:function(){return this._computeBonesUsingShaders},set:function(e){this._computeBonesUsingShaders!==e&&(this._computeBonesUsingShaders=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"numBoneInfluencers",{get:function(){return this._numBoneInfluencers},set:function(e){this._numBoneInfluencers!==e&&(this._numBoneInfluencers=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"applyFog",{get:function(){return this._applyFog},set:function(e){this._applyFog!==e&&(this._applyFog=e,this._markSubMeshesAsMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"layerMask",{get:function(){return this._layerMask},set:function(e){e!==this._layerMask&&(this._layerMask=e,this._resyncLightSources())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"collisionGroup",{get:function(){return this._collisionGroup},set:function(e){this._collisionGroup=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"_positions",{get:function(){return null},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeleton",{get:function(){return this._skeleton},set:function(e){this._skeleton&&this._skeleton.needInitialSkinMatrix&&this._skeleton._unregisterMeshWithPoseMatrix(this),e&&e.needInitialSkinMatrix&&e._registerMeshWithPoseMatrix(this),this._skeleton=e,this._skeleton||(this._bonesTransformMatrices=null),this._markSubMeshesAsAttributesDirty()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"AbstractMesh"},i.prototype.toString=function(e){var t="Name: "+this.name+", isInstance: "+(this instanceof L.InstancedMesh?"YES":"NO");return t+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0),this._skeleton&&(t+=", skeleton: "+this._skeleton.name),e&&(t+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],t+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingFreezeWorldMatrix?"YES":"NO")),t},i.prototype._rebuild=function(){if(this.onRebuildObservable.notifyObservers(this),this._occlusionQuery&&(this._occlusionQuery=null),this.subMeshes)for(var e=0,t=this.subMeshes;e<t.length;e++){t[e]._rebuild()}},i.prototype._resyncLightSources=function(){for(var e=this._lightSources.length=0,t=this.getScene().lights;e<t.length;e++){var i=t[e];i.isEnabled()&&(i.canAffectMesh(this)&&this._lightSources.push(i))}this._markSubMeshesAsLightDirty()},i.prototype._resyncLighSource=function(e){var t=e.isEnabled()&&e.canAffectMesh(this),i=this._lightSources.indexOf(e);if(-1===i){if(!t)return;this._lightSources.push(e)}else{if(t)return;this._lightSources.splice(i,1)}this._markSubMeshesAsLightDirty()},i.prototype._unBindEffect=function(){for(var e=0,t=this.subMeshes;e<t.length;e++){t[e].setEffect(null)}},i.prototype._removeLightSource=function(e){var t=this._lightSources.indexOf(e);-1!==t&&(this._lightSources.splice(t,1),this._markSubMeshesAsLightDirty())},i.prototype._markSubMeshesAsDirty=function(e){if(this.subMeshes)for(var t=0,i=this.subMeshes;t<i.length;t++){var r=i[t];r._materialDefines&&e(r._materialDefines)}},i.prototype._markSubMeshesAsLightDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},i.prototype._markSubMeshesAsAttributesDirty=function(){this._markSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},i.prototype._markSubMeshesAsMiscDirty=function(){if(this.subMeshes)for(var e=0,t=this.subMeshes;e<t.length;e++){var i=t[e].getMaterial();i&&i.markAsDirty(L.Material.MiscDirtyFlag)}},Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e,this.physicsImpostor&&this.physicsImpostor.forceUpdate()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isBlocked",{get:function(){return!1},enumerable:!0,configurable:!0}),i.prototype.getLOD=function(e){return this},i.prototype.getTotalVertices=function(){return 0},i.prototype.getIndices=function(){return null},i.prototype.getVerticesData=function(e){return null},i.prototype.setVerticesData=function(e,t,i,r){return this},i.prototype.updateVerticesData=function(e,t,i,r){return this},i.prototype.setIndices=function(e,t){return this},i.prototype.isVerticesDataPresent=function(e){return!1},i.prototype.getBoundingInfo=function(){return this._masterMesh?this._masterMesh.getBoundingInfo():(this._boundingInfo||this._updateBoundingInfo(),this._boundingInfo)},i.prototype.normalizeToUnitCube=function(e){void 0===e&&(e=!0);var t=this.getHierarchyBoundingVectors(e),i=t.max.subtract(t.min),r=Math.max(i.x,i.y,i.z);if(0===r)return this;var n=1/r;return this.scaling.scaleInPlace(n),this},i.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},Object.defineProperty(i.prototype,"useBones",{get:function(){return this.skeleton&&this.getScene().skeletonsEnabled&&this.isVerticesDataPresent(L.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(L.VertexBuffer.MatricesWeightsKind)},enumerable:!0,configurable:!0}),i.prototype._preActivate=function(){},i.prototype._preActivateForIntermediateRendering=function(e){},i.prototype._activate=function(e){this._renderId=e},i.prototype.getWorldMatrix=function(){return this._masterMesh?this._masterMesh.getWorldMatrix():a.prototype.getWorldMatrix.call(this)},i.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():a.prototype._getWorldMatrixDeterminant.call(this)},i.prototype.movePOV=function(e,t,i){return this.position.addInPlace(this.calcMovePOV(e,t,i)),this},i.prototype.calcMovePOV=function(e,t,i){var r=new L.Matrix;(this.rotationQuaternion?this.rotationQuaternion:L.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(r);var n=L.Vector3.Zero(),o=this.definedFacingForward?-1:1;return L.Vector3.TransformCoordinatesFromFloatsToRef(e*o,t,i*o,r,n),n},i.prototype.rotatePOV=function(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this},i.prototype.calcRotatePOV=function(e,t,i){var r=this.definedFacingForward?1:-1;return new L.Vector3(e*r,t,i*r)},i.prototype.getHierarchyBoundingVectors=function(e,t){var i,r;void 0===e&&(e=!0),void 0===t&&(t=null),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);var n=this.getBoundingInfo();if(this.subMeshes?(i=n.boundingBox.minimumWorld,r=n.boundingBox.maximumWorld):(i=new L.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new L.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)),e)for(var o=0,s=this.getDescendants(!1);o<s.length;o++){var a=s[o];if(a.computeWorldMatrix(!0),(!t||t(a))&&a.getBoundingInfo&&0!==a.getTotalVertices()){var l=a.getBoundingInfo().boundingBox,c=l.minimumWorld,h=l.maximumWorld;L.Tools.CheckExtends(c,i,r),L.Tools.CheckExtends(h,i,r)}}return{min:i,max:r}},i.prototype._updateBoundingInfo=function(){return this._boundingInfo=this._boundingInfo||new L.BoundingInfo(this.absolutePosition,this.absolutePosition),this._boundingInfo.update(this.worldMatrixFromCache),this._updateSubMeshesBoundingInfo(this.worldMatrixFromCache),this},i.prototype._updateSubMeshesBoundingInfo=function(e){if(!this.subMeshes)return this;for(var t=this.subMeshes.length,i=0;i<t;i++){var r=this.subMeshes[i];(1<t||!r.IsGlobal)&&r.updateBoundingInfo(e)}return this},i.prototype._afterComputeWorldMatrix=function(){this._updateBoundingInfo()},i.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e,this.cullingStrategy)},i.prototype.isCompletelyInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isCompletelyInFrustum(e)},i.prototype.intersectsMesh=function(e,t,i){if(void 0===t&&(t=!1),!this._boundingInfo||!e._boundingInfo)return!1;if(this._boundingInfo.intersects(e._boundingInfo,t))return!0;if(i)for(var r=0,n=this.getChildMeshes();r<n.length;r++){if(n[r].intersectsMesh(e,t,!0))return!0}return!1},i.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},i.prototype.getPositionInCameraSpace=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),L.Vector3.TransformCoordinates(this.absolutePosition,e.getViewMatrix())},i.prototype.getDistanceToCamera=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},Object.defineProperty(i.prototype,"checkCollisions",{get:function(){return this._checkCollisions},set:function(e){this._checkCollisions=e,this.getScene().workerCollisions&&this.getScene().collisionCoordinator.onMeshUpdated(this)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"collider",{get:function(){return this._collider},enumerable:!0,configurable:!0}),i.prototype.moveWithCollisions=function(e){return this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._oldPositionForCollisions),this._collider||(this._collider=new L.Collider),this._collider._radius=this.ellipsoid,this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions,e,this._collider,3,this,this._onCollisionPositionChange,this.uniqueId),this},i.prototype._collideForSubMesh=function(e,t,i){if(this._generatePointsArray(),!this._positions)return this;if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(t)){e._lastColliderTransformMatrix=t.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];for(var r=e.verticesStart,n=e.verticesStart+e.verticesCount,o=r;o<n;o++)e._lastColliderWorldVertices.push(L.Vector3.TransformCoordinates(this._positions[o],t))}return i._collide(e._trianglePlanes,e._lastColliderWorldVertices,this.getIndices(),e.indexStart,e.indexStart+e.indexCount,e.verticesStart,!!e.getMaterial()),i.collisionFound&&(i.collidedMesh=this),this},i.prototype._processCollisionsForSubMeshes=function(e,t){for(var i=this._scene.getCollidingSubMeshCandidates(this,e),r=i.length,n=0;n<r;n++){var o=i.data[n];1<r&&!o._checkCollision(e)||this._collideForSubMesh(o,t,e)}return this},i.prototype._checkCollision=function(e){if(!this._boundingInfo||!this._boundingInfo._checkCollision(e))return this;var t=L.Tmp.Matrix[0],i=L.Tmp.Matrix[1];return L.Matrix.ScalingToRef(1/e._radius.x,1/e._radius.y,1/e._radius.z,t),this.worldMatrixFromCache.multiplyToRef(t,i),this._processCollisionsForSubMeshes(e,i),this},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(e,t){var i=new L.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&e.intersectsSphere(this._boundingInfo.boundingSphere)&&e.intersectsBox(this._boundingInfo.boundingBox)))return i;if(!this._generatePointsArray())return i;for(var r=null,n=this._scene.getIntersectingSubMeshCandidates(this,e),o=n.length,s=0;s<o;s++){var a=n.data[s];if(!(1<o)||a.canIntersects(e)){var l=a.intersects(e,this._positions,this.getIndices(),t);if(l&&(t||!r||l.distance<r.distance)&&((r=l).subMeshId=s,t))break}}if(r){var c=this.getWorldMatrix(),h=L.Vector3.TransformCoordinates(e.origin,c),u=e.direction.clone();u=u.scale(r.distance);var d=L.Vector3.TransformNormal(u,c),f=h.add(d);return i.hit=!0,i.distance=L.Vector3.Distance(h,f),i.pickedPoint=f,i.pickedMesh=this,i.bu=r.bu||0,i.bv=r.bv||0,i.faceId=r.faceId,i.subMeshId=r.subMeshId,i}return i},i.prototype.clone=function(e,t,i){return null},i.prototype.releaseSubMeshes=function(){if(this.subMeshes)for(;this.subMeshes.length;)this.subMeshes[0].dispose();else this.subMeshes=new Array;return this},i.prototype.dispose=function(e,t){var i,n=this;for(void 0===t&&(t=!1),this.getScene().freeActiveMeshes(),this.getScene().freeRenderingGroups(),void 0!==this.actionManager&&null!==this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this._skeleton=null,i=0;i<this._intersectionsInProgress.length;i++){var r=this._intersectionsInProgress[i],o=r._intersectionsInProgress.indexOf(this);r._intersectionsInProgress.splice(o,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach((function(e){var t=e.includedOnlyMeshes.indexOf(n);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(n))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();if(i){var r=i.getShadowMap();r&&r.renderList&&-1!==(t=r.renderList.indexOf(n))&&r.renderList.splice(t,1)}})),"InstancedMesh"!==this.getClassName()&&this.releaseSubMeshes();var s=this.getScene().getEngine();if(this._occlusionQuery&&(this.isOcclusionQueryInProgress=!1,s.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),s.wipeCaches(),this.getScene().removeMesh(this),t&&this.material&&this.material.dispose(!1,!0),!e)for(i=0;i<this.getScene().particleSystems.length;i++)this.getScene().particleSystems[i].emitter===this&&(this.getScene().particleSystems[i].dispose(),i--);this._facetData.facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),this.onRebuildObservable.clear(),a.prototype.dispose.call(this,e,t)},i.prototype.addChild=function(e){return e.setParent(this),this},i.prototype.removeChild=function(e){return e.setParent(null),this},i.prototype._initFacetData=function(){var e=this._facetData;e.facetNormals||(e.facetNormals=new Array),e.facetPositions||(e.facetPositions=new Array),e.facetPartitioning||(e.facetPartitioning=new Array),e.facetNb=this.getIndices().length/3|0,e.partitioningSubdivisions=e.partitioningSubdivisions?e.partitioningSubdivisions:10,e.partitioningBBoxRatio=e.partitioningBBoxRatio?e.partitioningBBoxRatio:1.01;for(var t=0;t<e.facetNb;t++)e.facetNormals[t]=L.Vector3.Zero(),e.facetPositions[t]=L.Vector3.Zero();return e.facetDataEnabled=!0,this},i.prototype.updateFacetData=function(){var e=this._facetData;e.facetDataEnabled||this._initFacetData();var t=this.getVerticesData(L.VertexBuffer.PositionKind),i=this.getIndices(),r=this.getVerticesData(L.VertexBuffer.NormalKind),n=this.getBoundingInfo();if(e.facetDepthSort&&!e.facetDepthSortEnabled){if(e.facetDepthSortEnabled=!0,i instanceof Uint16Array)e.depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)e.depthSortedIndices=new Uint32Array(i);else{for(var o=!1,s=0;s<i.length;s++)if(65535<i[s]){o=!0;break}e.depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(e.facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!e.facetDepthSortFrom){var a=this.getScene().activeCamera;e.facetDepthSortFrom=a?a.position:L.Vector3.Zero()}e.depthSortedFacets=[];for(var l=0;l<e.facetNb;l++){var c={ind:3*l,sqDistance:0};e.depthSortedFacets.push(c)}e.invertedMatrix=L.Matrix.Identity(),e.facetDepthSortOrigin=L.Vector3.Zero()}e.bbSize.x=n.maximum.x-n.minimum.x>L.Epsilon?n.maximum.x-n.minimum.x:L.Epsilon,e.bbSize.y=n.maximum.y-n.minimum.y>L.Epsilon?n.maximum.y-n.minimum.y:L.Epsilon,e.bbSize.z=n.maximum.z-n.minimum.z>L.Epsilon?n.maximum.z-n.minimum.z:L.Epsilon;var h=e.bbSize.x>e.bbSize.y?e.bbSize.x:e.bbSize.y;if(h=h>e.bbSize.z?h:e.bbSize.z,e.subDiv.max=e.partitioningSubdivisions,e.subDiv.X=Math.floor(e.subDiv.max*e.bbSize.x/h),e.subDiv.Y=Math.floor(e.subDiv.max*e.bbSize.y/h),e.subDiv.Z=Math.floor(e.subDiv.max*e.bbSize.z/h),e.subDiv.X=e.subDiv.X<1?1:e.subDiv.X,e.subDiv.Y=e.subDiv.Y<1?1:e.subDiv.Y,e.subDiv.Z=e.subDiv.Z<1?1:e.subDiv.Z,e.facetParameters.facetNormals=this.getFacetLocalNormals(),e.facetParameters.facetPositions=this.getFacetLocalPositions(),e.facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),e.facetParameters.bInfo=n,e.facetParameters.bbSize=e.bbSize,e.facetParameters.subDiv=e.subDiv,e.facetParameters.ratio=this.partitioningBBoxRatio,e.facetParameters.depthSort=e.facetDepthSort,e.facetDepthSort&&e.facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(e.invertedMatrix),L.Vector3.TransformCoordinatesToRef(e.facetDepthSortFrom,e.invertedMatrix,e.facetDepthSortOrigin),e.facetParameters.distanceTo=e.facetDepthSortOrigin),e.facetParameters.depthSortedFacets=e.depthSortedFacets,L.VertexData.ComputeNormals(t,i,r,e.facetParameters),e.facetDepthSort&&e.facetDepthSortEnabled){e.depthSortedFacets.sort(e.facetDepthSortFunction);var u=e.depthSortedIndices.length/3|0;for(l=0;l<u;l++){var d=e.depthSortedFacets[l].ind;e.depthSortedIndices[3*l]=i[d],e.depthSortedIndices[3*l+1]=i[d+1],e.depthSortedIndices[3*l+2]=i[d+2]}this.updateIndices(e.depthSortedIndices)}return this},i.prototype.getFacetLocalNormals=function(){return this._facetData.facetNormals||this.updateFacetData(),this._facetData.facetNormals},i.prototype.getFacetLocalPositions=function(){return this._facetData.facetPositions||this.updateFacetData(),this._facetData.facetPositions},i.prototype.getFacetLocalPartitioning=function(){return this._facetData.facetPartitioning||this.updateFacetData(),this._facetData.facetPartitioning},i.prototype.getFacetPosition=function(e){var t=L.Vector3.Zero();return this.getFacetPositionToRef(e,t),t},i.prototype.getFacetPositionToRef=function(e,t){var i=this.getFacetLocalPositions()[e],r=this.getWorldMatrix();return L.Vector3.TransformCoordinatesToRef(i,r,t),this},i.prototype.getFacetNormal=function(e){var t=L.Vector3.Zero();return this.getFacetNormalToRef(e,t),t},i.prototype.getFacetNormalToRef=function(e,t){var i=this.getFacetLocalNormals()[e];return L.Vector3.TransformNormalToRef(i,this.getWorldMatrix(),t),this},i.prototype.getFacetsAtLocalCoordinates=function(e,t,i){var r=this.getBoundingInfo(),n=this._facetData,o=Math.floor((e-r.minimum.x*n.partitioningBBoxRatio)*n.subDiv.X*n.partitioningBBoxRatio/n.bbSize.x),s=Math.floor((t-r.minimum.y*n.partitioningBBoxRatio)*n.subDiv.Y*n.partitioningBBoxRatio/n.bbSize.y),a=Math.floor((i-r.minimum.z*n.partitioningBBoxRatio)*n.subDiv.Z*n.partitioningBBoxRatio/n.bbSize.z);return o<0||o>n.subDiv.max||s<0||s>n.subDiv.max||a<0||a>n.subDiv.max?null:n.facetPartitioning[o+n.subDiv.max*s+n.subDiv.max*n.subDiv.max*a]},i.prototype.getClosestFacetAtCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=this.getWorldMatrix(),a=L.Tmp.Matrix[5];s.invertToRef(a);var l=L.Tmp.Vector3[8];L.Vector3.TransformCoordinatesFromFloatsToRef(e,t,i,a,l);var c=this.getClosestFacetAtLocalCoordinates(l.x,l.y,l.z,r,n,o);return r&&L.Vector3.TransformCoordinatesFromFloatsToRef(r.x,r.y,r.z,s,r),c},i.prototype.getClosestFacetAtLocalCoordinates=function(e,t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=!0);var s=null,a=0,l=0,c=0,h=0,u=0,d=0,f=0,p=0,m=this.getFacetLocalPositions(),_=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var v,y,b,T=Number.MAX_VALUE,x=T,E=0;E<g.length;E++)y=_[v=g[E]],h=(e-(b=m[v]).x)*y.x+(t-b.y)*y.y+(i-b.z)*y.z,(!n||n&&o&&0<=h||n&&!o&&h<=0)&&(h=y.x*b.x+y.y*b.y+y.z*b.z,u=-(y.x*e+y.y*t+y.z*i-h)/(y.x*y.x+y.y*y.y+y.z*y.z),(x=(a=(d=e+y.x*u)-e)*a+(l=(f=t+y.y*u)-t)*l+(c=(p=i+y.z*u)-i)*c)<T&&(T=x,s=v,r&&(r.x=d,r.y=f,r.z=p)));return s},i.prototype.getFacetDataParameters=function(){return this._facetData.facetParameters},i.prototype.disableFacetData=function(){return this._facetData.facetDataEnabled&&(this._facetData.facetDataEnabled=!1,this._facetData.facetPositions=new Array,this._facetData.facetNormals=new Array,this._facetData.facetPartitioning=new Array,this._facetData.facetParameters=null,this._facetData.depthSortedIndices=new Uint32Array(0)),this},i.prototype.updateIndices=function(e){return this},i.prototype.createNormals=function(e){var t,i=this.getVerticesData(L.VertexBuffer.PositionKind),r=this.getIndices();return t=this.isVerticesDataPresent(L.VertexBuffer.NormalKind)?this.getVerticesData(L.VertexBuffer.NormalKind):[],L.VertexData.ComputeNormals(i,r,t,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(L.VertexBuffer.NormalKind,t,e),this},i.prototype.alignWithNormal=function(e,t){t||(t=L.Axis.Y);var i=L.Tmp.Vector3[0],r=L.Tmp.Vector3[1];return L.Vector3.CrossToRef(t,e,r),L.Vector3.CrossToRef(e,r,i),this.rotationQuaternion?L.Quaternion.RotationQuaternionFromAxisToRef(i,e,r,this.rotationQuaternion):L.Vector3.RotationFromAxisToRef(i,e,r,this.rotation),this},i.prototype._checkOcclusionQuery=function(){return!1},i.OCCLUSION_TYPE_NONE=0,i.OCCLUSION_TYPE_OPTIMISTIC=1,i.OCCLUSION_TYPE_STRICT=2,i.OCCLUSION_ALGORITHM_TYPE_ACCURATE=0,i.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE=1,i.CULLINGSTRATEGY_STANDARD=0,i.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY=1,i})(L.TransformNode),L.AbstractMesh=B,N=$a||($a={}),V=(function(n){function s(e,t){var i=n.call(this,e,t)||this;return i.diffuse=new N.Color3(1,1,1),i.specular=new N.Color3(1,1,1),i.falloffType=s.FALLOFF_DEFAULT,i.intensity=1,i._range=Number.MAX_VALUE,i._inverseSquaredRange=0,i._photometricScale=1,i._intensityMode=s.INTENSITYMODE_AUTOMATIC,i._radius=1e-5,i.renderPriority=0,i._shadowEnabled=!0,i._excludeWithLayerMask=0,i._includeOnlyWithLayerMask=0,i._lightmapMode=0,i._excludedMeshesIds=new Array,i._includedOnlyMeshesIds=new Array,i.getScene().addLight(i),i._uniformBuffer=new N.UniformBuffer(i.getScene().getEngine()),i._buildUniformLayout(),i.includedOnlyMeshes=new Array,i.excludedMeshes=new Array,i._resyncMeshes(),i}return T(s,n),Object.defineProperty(s.prototype,"range",{get:function(){return this._range},set:function(e){this._range=e,this._inverseSquaredRange=1/(this.range*this.range)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"shadowEnabled",{get:function(){return this._shadowEnabled},set:function(e){this._shadowEnabled!==e&&(this._shadowEnabled=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),s.prototype.getClassName=function(){return"Light"},s.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+["Point","Directional","Spot","Hemispheric"][this.getTypeID()],this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},s.prototype._syncParentEnabledState=function(){n.prototype._syncParentEnabledState.call(this),this._resyncMeshes()},s.prototype.setEnabled=function(e){n.prototype.setEnabled.call(this,e),this._resyncMeshes()},s.prototype.getShadowGenerator=function(){return this._shadowGenerator},s.prototype.getAbsolutePosition=function(){return N.Vector3.Zero()},s.prototype.canAffectMesh=function(e){return!e||!(this.includedOnlyMeshes&&0<this.includedOnlyMeshes.length&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&0<this.excludedMeshes.length&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},s.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},s.prototype.dispose=function(e,t){void 0===t&&(t=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var i=0,r=this.getScene().meshes;i<r.length;i++){r[i]._removeLightSource(this)}this._uniformBuffer.dispose(),this.getScene().removeLight(this),n.prototype.dispose.call(this,e,t)},s.prototype.getTypeID=function(){return 0},s.prototype.getScaledIntensity=function(){return this._photometricScale*this.intensity},s.prototype.clone=function(e){var t=s.GetConstructorFromName(this.getTypeID(),e,this.getScene());return t?N.SerializationHelper.Clone(t,this):null},s.prototype.serialize=function(){var t=N.SerializationHelper.Serialize(this);return t.type=this.getTypeID(),this.parent&&(t.parentId=this.parent.id),0<this.excludedMeshes.length&&(t.excludedMeshesIds=[],this.excludedMeshes.forEach((function(e){t.excludedMeshesIds.push(e.id)}))),0<this.includedOnlyMeshes.length&&(t.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(e){t.includedOnlyMeshesIds.push(e.id)}))),N.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},s.GetConstructorFromName=function(e,t,i){var r=N.Node.Construct("Light_Type_"+e,t,i);return r||null},s.Parse=function(e,t){var i=s.GetConstructorFromName(e.type,e.name,t);if(!i)return null;var r=N.SerializationHelper.Parse(i,e,t);if(e.excludedMeshesIds&&(r._excludedMeshesIds=e.excludedMeshesIds),e.includedOnlyMeshesIds&&(r._includedOnlyMeshesIds=e.includedOnlyMeshesIds),e.parentId&&(r._waitingParentId=e.parentId),e.animations){for(var n=0;n<e.animations.length;n++){var o=e.animations[n];r.animations.push(N.Animation.Parse(o))}N.Node.ParseAnimationRanges(r,e,t)}return e.autoAnimate&&t.beginAnimation(r,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),r},s.prototype._hookArrayForExcluded=function(o){var s=this,a=o.push;o.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];for(var i=a.apply(o,e),r=0,n=e;r<n.length;r++){n[r]._resyncLighSource(s)}return i};var l=o.splice;o.splice=function(e,t){for(var i=l.apply(o,[e,t]),r=0,n=i;r<n.length;r++){n[r]._resyncLighSource(s)}return i};for(var e=0,t=o;e<t.length;e++){t[e]._resyncLighSource(this)}},s.prototype._hookArrayForIncludedOnly=function(r){var n=this,o=r.push;r.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=o.apply(r,e);return n._resyncMeshes(),i};var s=r.splice;r.splice=function(e,t){var i=s.apply(r,[e,t]);return n._resyncMeshes(),i},this._resyncMeshes()},s.prototype._resyncMeshes=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){t[e]._resyncLighSource(this)}},s.prototype._markMeshesAsLightDirty=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){var i=t[e];-1!==i._lightSources.indexOf(this)&&i._markSubMeshesAsLightDirty()}},s.prototype._computePhotometricScale=function(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()},s.prototype._getPhotometricScale=function(){var e=0,t=this.getTypeID(),i=this.intensityMode;switch(i===s.INTENSITYMODE_AUTOMATIC&&(i=t===s.LIGHTTYPEID_DIRECTIONALLIGHT?s.INTENSITYMODE_ILLUMINANCE:s.INTENSITYMODE_LUMINOUSINTENSITY),t){case s.LIGHTTYPEID_POINTLIGHT:case s.LIGHTTYPEID_SPOTLIGHT:switch(i){case s.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case s.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case s.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case s.LIGHTTYPEID_DIRECTIONALLIGHT:switch(i){case s.INTENSITYMODE_ILLUMINANCE:e=1;break;case s.INTENSITYMODE_LUMINANCE:var r=this.radius;r=Math.max(r,.001),e=2*Math.PI*(1-Math.cos(r))}break;case s.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e},s.prototype._reorderLightsInScene=function(){var e=this.getScene();0!=this._renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()},s.FALLOFF_DEFAULT=0,s.FALLOFF_PHYSICAL=1,s.FALLOFF_GLTF=2,s.FALLOFF_STANDARD=3,s.LIGHTMAP_DEFAULT=0,s.LIGHTMAP_SPECULAR=1,s.LIGHTMAP_SHADOWSONLY=2,s.INTENSITYMODE_AUTOMATIC=0,s.INTENSITYMODE_LUMINOUSPOWER=1,s.INTENSITYMODE_LUMINOUSINTENSITY=2,s.INTENSITYMODE_ILLUMINANCE=3,s.INTENSITYMODE_LUMINANCE=4,s.LIGHTTYPEID_POINTLIGHT=0,s.LIGHTTYPEID_DIRECTIONALLIGHT=1,s.LIGHTTYPEID_SPOTLIGHT=2,s.LIGHTTYPEID_HEMISPHERICLIGHT=3,b([N.serializeAsColor3()],s.prototype,"diffuse",void 0),b([N.serializeAsColor3()],s.prototype,"specular",void 0),b([N.serialize()],s.prototype,"falloffType",void 0),b([N.serialize()],s.prototype,"intensity",void 0),b([N.serialize()],s.prototype,"range",null),b([N.serialize()],s.prototype,"intensityMode",null),b([N.serialize()],s.prototype,"radius",null),b([N.serialize()],s.prototype,"_renderPriority",void 0),b([N.expandToProperty("_reorderLightsInScene")],s.prototype,"renderPriority",void 0),b([N.serialize("shadowEnabled")],s.prototype,"_shadowEnabled",void 0),b([N.serialize("excludeWithLayerMask")],s.prototype,"_excludeWithLayerMask",void 0),b([N.serialize("includeOnlyWithLayerMask")],s.prototype,"_includeOnlyWithLayerMask",void 0),b([N.serialize("lightmapMode")],s.prototype,"_lightmapMode",void 0),s})(N.Node),N.Light=V,U=$a||($a={}),z=(function(o){function c(e,t,i,r){void 0===r&&(r=!0);var n=o.call(this,e,i)||this;return n.upVector=U.Vector3.Up(),n.orthoLeft=null,n.orthoRight=null,n.orthoBottom=null,n.orthoTop=null,n.fov=.8,n.minZ=1,n.maxZ=1e4,n.inertia=.9,n.mode=c.PERSPECTIVE_CAMERA,n.isIntermediate=!1,n.viewport=new U.Viewport(0,0,1,1),n.layerMask=268435455,n.fovMode=c.FOVMODE_VERTICAL_FIXED,n.cameraRigMode=c.RIG_MODE_NONE,n.customRenderTargets=new Array,n.onViewMatrixChangedObservable=new U.Observable,n.onProjectionMatrixChangedObservable=new U.Observable,n.onAfterCheckInputsObservable=new U.Observable,n.onRestoreStateObservable=new U.Observable,n._rigCameras=new Array,n._webvrViewMatrix=U.Matrix.Identity(),n._skipRendering=!1,n._projectionMatrix=new U.Matrix,n._postProcesses=new Array,n._activeMeshes=new U.SmartArray(256),n._globalPosition=U.Vector3.Zero(),n._computedViewMatrix=U.Matrix.Identity(),n._doNotComputeProjectionMatrix=!1,n._transformMatrix=U.Matrix.Zero(),n._refreshFrustumPlanes=!0,n.getScene().addCamera(n),r&&!n.getScene().activeCamera&&(n.getScene().activeCamera=n),n.position=t,n}return T(c,o),c.prototype.storeState=function(){return this._stateStored=!0,this._storedFov=this.fov,this},c.prototype._restoreStateValues=function(){return!!this._stateStored&&(this.fov=this._storedFov,!0)},c.prototype.restoreState=function(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)},c.prototype.getClassName=function(){return"Camera"},c.prototype.toString=function(e){var t="Name: "+this.name;if(t+=", type: "+this.getClassName(),this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);return t},Object.defineProperty(c.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),c.prototype.getActiveMeshes=function(){return this._activeMeshes},c.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},c.prototype.isReady=function(e){if(void 0===e&&(e=!1),e)for(var t=0,i=this._postProcesses;t<i.length;t++){var r=i[t];if(r&&!r.isReady())return!1}return o.prototype.isReady.call(this,e)},c.prototype._initCache=function(){o.prototype._initCache.call(this),this._cache.position=new U.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new U.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.mode=void 0,this._cache.minZ=void 0,this._cache.maxZ=void 0,this._cache.fov=void 0,this._cache.fovMode=void 0,this._cache.aspectRatio=void 0,this._cache.orthoLeft=void 0,this._cache.orthoRight=void 0,this._cache.orthoBottom=void 0,this._cache.orthoTop=void 0,this._cache.renderWidth=void 0,this._cache.renderHeight=void 0},c.prototype._updateCache=function(e){e||o.prototype._updateCache.call(this),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)},c.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},c.prototype._isSynchronizedViewMatrix=function(){return!!o.prototype._isSynchronized.call(this)&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())},c.prototype._isSynchronizedProjectionMatrix=function(){var e=this._cache.mode===this.mode&&this._cache.minZ===this.minZ&&this._cache.maxZ===this.maxZ;if(!e)return!1;var t=this.getEngine();return e=this.mode===c.PERSPECTIVE_CAMERA?this._cache.fov===this.fov&&this._cache.fovMode===this.fovMode&&this._cache.aspectRatio===t.getAspectRatio(this):this._cache.orthoLeft===this.orthoLeft&&this._cache.orthoRight===this.orthoRight&&this._cache.orthoBottom===this.orthoBottom&&this._cache.orthoTop===this.orthoTop&&this._cache.renderWidth===t.getRenderWidth()&&this._cache.renderHeight===t.getRenderHeight()},c.prototype.attachControl=function(e,t){},c.prototype.detachControl=function(e){},c.prototype.update=function(){this._checkInputs(),this.cameraRigMode!==c.RIG_MODE_NONE&&this._updateRigCameras()},c.prototype._checkInputs=function(){this.onAfterCheckInputsObservable.notifyObservers(this)},Object.defineProperty(c.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!0,configurable:!0}),c.prototype._getFirstPostProcess=function(){for(var e=0;e<this._postProcesses.length;e++)if(null!==this._postProcesses[e])return this._postProcesses[e];return null},c.prototype._cascadePostProcessesToRigCams=function(){var e=this._getFirstPostProcess();e&&e.markTextureDirty();for(var t=0,i=this._rigCameras.length;t<i;t++){var r=this._rigCameras[t],n=r._rigPostProcess;if(n)n instanceof U.PassPostProcess&&(r.isIntermediate=0===this._postProcesses.length),r._postProcesses=this._postProcesses.slice(0).concat(n),n.markTextureDirty();else r._postProcesses=this._postProcesses.slice(0)}},c.prototype.attachPostProcess=function(e,t){return void 0===t&&(t=null),!e.isReusable()&&-1<this._postProcesses.indexOf(e)?(U.Tools.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))},c.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._cascadePostProcessesToRigCams()},c.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()||this.getViewMatrix(),this._worldMatrix},c.prototype._getViewMatrix=function(){return U.Matrix.Identity()},c.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()||(this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childRenderId=this._currentRenderId,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix)),this._computedViewMatrix},c.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},c.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},c.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 t=this.getEngine(),i=this.getScene();if(this.mode===c.PERSPECTIVE_CAMERA)this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=t.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1),i.useRightHandedSystem?U.Matrix.PerspectiveFovRHToRef(this.fov,t.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===c.FOVMODE_VERTICAL_FIXED):U.Matrix.PerspectiveFovLHToRef(this.fov,t.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===c.FOVMODE_VERTICAL_FIXED);else{var r=t.getRenderWidth()/2,n=t.getRenderHeight()/2;i.useRightHandedSystem?U.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-r,this.orthoRight||r,this.orthoBottom||-n,this.orthoTop||n,this.minZ,this.maxZ,this._projectionMatrix):U.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-r,this.orthoRight||r,this.orthoBottom||-n,this.orthoTop||n,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=t.getRenderWidth(),this._cache.renderHeight=t.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},c.prototype.getTransformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},c.prototype._updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTransformationMatrix(),this._frustumPlanes?U.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=U.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},c.prototype.isInFrustum=function(e){return this._updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},c.prototype.isCompletelyInFrustum=function(e){return this._updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},c.prototype.getForwardRay=function(e,t,i){void 0===e&&(e=100),t||(t=this.getWorldMatrix()),i||(i=this.position);var r=this._scene.useRightHandedSystem?new U.Vector3(0,0,-1):new U.Vector3(0,0,1),n=U.Vector3.TransformNormal(r,t),o=U.Vector3.Normalize(n);return new U.Ray(i,o,e)},c.prototype.dispose=function(e,t){for(void 0===t&&(t=!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);0<this._rigCameras.length;){var i=this._rigCameras.pop();i&&i.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==c.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var r=this._postProcesses.length;0<=--r;){var n=this._postProcesses[r];n&&n.dispose(this)}for(r=this.customRenderTargets.length;0<=--r;)this.customRenderTargets[r].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),o.prototype.dispose.call(this,e,t)},Object.defineProperty(c.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!0,configurable:!0}),c.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},c.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},c.prototype.setCameraRigMode=function(e,t){if(this.cameraRigMode!==e){for(;0<this._rigCameras.length;){var i=this._rigCameras.pop();i&&i.dispose()}if(this.cameraRigMode=e,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=t.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=U.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==c.RIG_MODE_NONE){var r=this.createRigCamera(this.name+"_L",0),n=this.createRigCamera(this.name+"_R",1);r&&n&&(this._rigCameras.push(r),this._rigCameras.push(n))}switch(this.cameraRigMode){case c.RIG_MODE_STEREOSCOPIC_ANAGLYPH:this._rigCameras[0]._rigPostProcess=new U.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new U.AnaglyphPostProcess(this.name+"_anaglyph",1,this._rigCameras);break;case c.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case c.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case c.RIG_MODE_STEREOSCOPIC_OVERUNDER:var o=this.cameraRigMode===c.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===c.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;this._rigCameras[0]._rigPostProcess=new U.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new U.StereoscopicInterlacePostProcess(this.name+"_stereoInterlace",this._rigCameras,o);break;case c.RIG_MODE_VR:var s=t.vrCameraMetrics||U.VRCameraMetrics.GetDefault();this._rigCameras[0]._cameraRigParams.vrMetrics=s,this._rigCameras[0].viewport=new U.Viewport(0,0,.5,1),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new U.Matrix,this._rigCameras[0]._cameraRigParams.vrHMatrix=s.leftHMatrix,this._rigCameras[0]._cameraRigParams.vrPreViewMatrix=s.leftPreViewMatrix,this._rigCameras[0].getProjectionMatrix=this._rigCameras[0]._getVRProjectionMatrix,this._rigCameras[1]._cameraRigParams.vrMetrics=s,this._rigCameras[1].viewport=new U.Viewport(.5,0,.5,1),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new U.Matrix,this._rigCameras[1]._cameraRigParams.vrHMatrix=s.rightHMatrix,this._rigCameras[1]._cameraRigParams.vrPreViewMatrix=s.rightPreViewMatrix,this._rigCameras[1].getProjectionMatrix=this._rigCameras[1]._getVRProjectionMatrix,s.compensateDistortion&&(this._rigCameras[0]._rigPostProcess=new U.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",this._rigCameras[0],!1,s),this._rigCameras[1]._rigPostProcess=new U.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",this._rigCameras[1],!0,s));break;case c.RIG_MODE_WEBVR:if(t.vrDisplay){var a=t.vrDisplay.getEyeParameters("left"),l=t.vrDisplay.getEyeParameters("right");this._rigCameras[0].viewport=new U.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("specs",t.specs),this._rigCameras[0].setCameraRigParameter("eyeParameters",a),this._rigCameras[0].setCameraRigParameter("frameData",t.frameData),this._rigCameras[0].setCameraRigParameter("parentCamera",t.parentCamera),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new U.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,(this._rigCameras[0].parent=this)._rigCameras[0]._getViewMatrix=this._getWebVRViewMatrix,this._rigCameras[1].viewport=new U.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("eyeParameters",l),this._rigCameras[1].setCameraRigParameter("specs",t.specs),this._rigCameras[1].setCameraRigParameter("frameData",t.frameData),this._rigCameras[1].setCameraRigParameter("parentCamera",t.parentCamera),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new U.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix,(this._rigCameras[1].parent=this)._rigCameras[1]._getViewMatrix=this._getWebVRViewMatrix,c.UseAlternateWebVRRendering&&(this._rigCameras[1]._skipRendering=!0,this._rigCameras[0]._alternateCamera=this._rigCameras[1])}}this._cascadePostProcessesToRigCams(),this.update()}},c.prototype._getVRProjectionMatrix=function(){return U.Matrix.PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov,this._cameraRigParams.vrMetrics.aspectRatio,this.minZ,this.maxZ,this._cameraRigParams.vrWorkMatrix),this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix,this._projectionMatrix),this._projectionMatrix},c.prototype._updateCameraRotationMatrix=function(){},c.prototype._updateWebVRCameraRotationMatrix=function(){},c.prototype._getWebVRProjectionMatrix=function(){return U.Matrix.Identity()},c.prototype._getWebVRViewMatrix=function(){return U.Matrix.Identity()},c.prototype.setCameraRigParameter=function(e,t){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[e]=t,"interaxialDistance"===e&&(this._cameraRigParams.stereoHalfAngle=U.Tools.ToRadians(t/.0637))},c.prototype.createRigCamera=function(e,t){return null},c.prototype._updateRigCameras=function(){for(var e=0;e<this._rigCameras.length;e++)this._rigCameras[e].minZ=this.minZ,this._rigCameras[e].maxZ=this.maxZ,this._rigCameras[e].fov=this.fov;this.cameraRigMode===c.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},c.prototype._setupInputs=function(){},c.prototype.serialize=function(){var e=U.SerializationHelper.Serialize(this);return e.type=this.getClassName(),this.parent&&(e.parentId=this.parent.id),this.inputs&&this.inputs.serialize(e),U.Animation.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e},c.prototype.clone=function(e){return U.SerializationHelper.Clone(c.GetConstructorFromName(this.getClassName(),e,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},c.prototype.getDirection=function(e){var t=U.Vector3.Zero();return this.getDirectionToRef(e,t),t},c.prototype.getDirectionToRef=function(e,t){U.Vector3.TransformNormalToRef(e,this.getWorldMatrix(),t)},c.GetConstructorFromName=function(e,t,i,r,n){void 0===r&&(r=0),void 0===n&&(n=!0);var o=U.Node.Construct(e,t,i,{interaxial_distance:r,isStereoscopicSideBySide:n});return o||function(){return new U.UniversalCamera(t,U.Vector3.Zero(),i)}},c.prototype.computeWorldMatrix=function(){return this.getWorldMatrix()},c.Parse=function(e,t){var i=e.type,r=c.GetConstructorFromName(i,e.name,t,e.interaxial_distance,e.isStereoscopicSideBySide),n=U.SerializationHelper.Parse(r,e,t);if(e.parentId&&(n._waitingParentId=e.parentId),n.inputs&&(n.inputs.parse(e),n._setupInputs()),n.setPosition&&(n.position.copyFromFloats(0,0,0),n.setPosition(U.Vector3.FromArray(e.position))),e.target&&n.setTarget&&n.setTarget(U.Vector3.FromArray(e.target)),e.cameraRigMode){var o=e.interaxial_distance?{interaxialDistance:e.interaxial_distance}:{};n.setCameraRigMode(e.cameraRigMode,o)}if(e.animations){for(var s=0;s<e.animations.length;s++){var a=e.animations[s];n.animations.push(U.Animation.Parse(a))}U.Node.ParseAnimationRanges(n,e,t)}return e.autoAnimate&&t.beginAnimation(n,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),n},c.PERSPECTIVE_CAMERA=0,c.ORTHOGRAPHIC_CAMERA=1,c.FOVMODE_VERTICAL_FIXED=0,c.FOVMODE_HORIZONTAL_FIXED=1,c.RIG_MODE_NONE=0,c.RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,c.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,c.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,c.RIG_MODE_STEREOSCOPIC_OVERUNDER=13,c.RIG_MODE_VR=20,c.RIG_MODE_WEBVR=21,c.ForceAttachControlToAlwaysPreventDefault=!1,c.UseAlternateWebVRRendering=!1,b([U.serializeAsVector3()],c.prototype,"position",void 0),b([U.serializeAsVector3()],c.prototype,"upVector",void 0),b([U.serialize()],c.prototype,"orthoLeft",void 0),b([U.serialize()],c.prototype,"orthoRight",void 0),b([U.serialize()],c.prototype,"orthoBottom",void 0),b([U.serialize()],c.prototype,"orthoTop",void 0),b([U.serialize()],c.prototype,"fov",void 0),b([U.serialize()],c.prototype,"minZ",void 0),b([U.serialize()],c.prototype,"maxZ",void 0),b([U.serialize()],c.prototype,"inertia",void 0),b([U.serialize()],c.prototype,"mode",void 0),b([U.serialize()],c.prototype,"layerMask",void 0),b([U.serialize()],c.prototype,"fovMode",void 0),b([U.serialize()],c.prototype,"cameraRigMode",void 0),b([U.serialize()],c.prototype,"interaxialDistance",void 0),b([U.serialize()],c.prototype,"isStereoscopicSideBySide",void 0),c})(U.Node),U.Camera=z,G=$a||($a={}),k=(function(){function p(e){this._useSceneAutoClearSetup=!1,this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderingGroupInfo=new G.RenderingGroupInfo,this._scene=e;for(var t=p.MIN_RENDERINGGROUPS;t<p.MAX_RENDERINGGROUPS;t++)this._autoClearDepthStencil[t]={autoClear:!0,depth:!0,stencil:!0}}return p.prototype._clearDepthStencilBuffer=function(e,t){void 0===e&&(e=!0),void 0===t&&(t=!0),this._depthStencilBufferAlreadyCleaned||(this._scene.getEngine().clear(null,!1,e,t),this._depthStencilBufferAlreadyCleaned=!0)},p.prototype.render=function(e,t,i,r){var n=this._renderingGroupInfo;if(n.scene=this._scene,n.camera=this._scene.activeCamera,this._scene.spriteManagers&&r)for(var o=0;o<this._scene.spriteManagers.length;o++){var s=this._scene.spriteManagers[o];this.dispatchSprites(s)}for(o=p.MIN_RENDERINGGROUPS;o<p.MAX_RENDERINGGROUPS;o++){this._depthStencilBufferAlreadyCleaned=o===p.MIN_RENDERINGGROUPS;var a=this._renderingGroups[o];if(a){var l=Math.pow(2,o);if(n.renderingGroupId=o,this._scene.onBeforeRenderingGroupObservable.notifyObservers(n,l),p.AUTOCLEAR){var c=this._useSceneAutoClearSetup?this._scene.getAutoClearDepthStencilSetup(o):this._autoClearDepthStencil[o];c&&c.autoClear&&this._clearDepthStencilBuffer(c.depth,c.stencil)}for(var h=0,u=this._scene._beforeRenderingGroupDrawStage;h<u.length;h++){u[h].action(o)}a.render(e,r,i,t);for(var d=0,f=this._scene._afterRenderingGroupDrawStage;d<f.length;d++){f[d].action(o)}this._scene.onAfterRenderingGroupObservable.notifyObservers(n,l)}}},p.prototype.reset=function(){for(var e=p.MIN_RENDERINGGROUPS;e<p.MAX_RENDERINGGROUPS;e++){var t=this._renderingGroups[e];t&&t.prepare()}},p.prototype.dispose=function(){this.freeRenderingGroups(),this._renderingGroups.length=0,this._renderingGroupInfo=null},p.prototype.freeRenderingGroups=function(){for(var e=p.MIN_RENDERINGGROUPS;e<p.MAX_RENDERINGGROUPS;e++){var t=this._renderingGroups[e];t&&t.dispose()}},p.prototype._prepareRenderingGroup=function(e){void 0===this._renderingGroups[e]&&(this._renderingGroups[e]=new G.RenderingGroup(e,this._scene,this._customOpaqueSortCompareFn[e],this._customAlphaTestSortCompareFn[e],this._customTransparentSortCompareFn[e]))},p.prototype.dispatchSprites=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchSprites(e)},p.prototype.dispatchParticles=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchParticles(e)},p.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh());var r=t.renderingGroupId||0;this._prepareRenderingGroup(r),this._renderingGroups[r].dispatch(e,t,i)},p.prototype.setRenderingOrder=function(e,t,i,r){if(void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._customOpaqueSortCompareFn[e]=t,this._customAlphaTestSortCompareFn[e]=i,this._customTransparentSortCompareFn[e]=r,this._renderingGroups[e]){var n=this._renderingGroups[e];n.opaqueSortCompareFn=this._customOpaqueSortCompareFn[e],n.alphaTestSortCompareFn=this._customAlphaTestSortCompareFn[e],n.transparentSortCompareFn=this._customTransparentSortCompareFn[e]}},p.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._autoClearDepthStencil[e]={autoClear:t,depth:i,stencil:r}},p.prototype.getAutoClearDepthStencilSetup=function(e){return this._autoClearDepthStencil[e]},p.MAX_RENDERINGGROUPS=4,p.MIN_RENDERINGGROUPS=0,p.AUTOCLEAR=!0,p})(),G.RenderingManager=k,W=$a||($a={}),H=(function(){function i(e,t,i,r,n){void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null),this.index=e,this._opaqueSubMeshes=new W.SmartArray(256),this._transparentSubMeshes=new W.SmartArray(256),this._alphaTestSubMeshes=new W.SmartArray(256),this._depthOnlySubMeshes=new W.SmartArray(256),this._particleSystems=new W.SmartArray(256),this._spriteManagers=new W.SmartArray(256),this._edgesRenderers=new W.SmartArray(16),this._scene=t,this.opaqueSortCompareFn=i,this.alphaTestSortCompareFn=r,this.transparentSortCompareFn=n}return Object.defineProperty(i.prototype,"opaqueSortCompareFn",{set:function(e){this._opaqueSortCompareFn=e,this._renderOpaque=e?this.renderOpaqueSorted:i.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"alphaTestSortCompareFn",{set:function(e){this._alphaTestSortCompareFn=e,this._renderAlphaTest=e?this.renderAlphaTestSorted:i.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"transparentSortCompareFn",{set:function(e){this._transparentSortCompareFn=e||i.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!0,configurable:!0}),i.prototype.render=function(e,t,i,r){if(e)e(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);else{var n=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(n.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),n.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);var o=n.getStencilBuffer();if(n.setStencilBuffer(!1),t&&this._renderSprites(),i&&this._renderParticles(r),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(this._renderTransparent(this._transparentSubMeshes),n.setAlphaMode(W.Engine.ALPHA_DISABLE)),n.setStencilBuffer(!1),this._edgesRenderers.length){for(var s=0;s<this._edgesRenderers.length;s++)this._edgesRenderers.data[s].render();n.setAlphaMode(W.Engine.ALPHA_DISABLE)}n.setStencilBuffer(o)}},i.prototype.renderOpaqueSorted=function(e){return i.renderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera,!1)},i.prototype.renderAlphaTestSorted=function(e){return i.renderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)},i.prototype.renderTransparentSorted=function(e){return i.renderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera,!0)},i.renderSorted=function(e,t,i,r){for(var n,o=0,s=i?i.globalPosition:W.Vector3.Zero();o<e.length;o++)(n=e.data[o])._alphaIndex=n.getMesh().alphaIndex,n._distanceToCamera=n.getBoundingInfo().boundingSphere.centerWorld.subtract(s).length();var a=e.data.slice(0,e.length);for(t&&a.sort(t),o=0;o<a.length;o++){if(n=a[o],r){var l=n.getMaterial();if(l&&l.needDepthPrePass){var c=l.getScene().getEngine();c.setColorWrite(!1),c.setAlphaMode(W.Engine.ALPHA_DISABLE),n.render(!1),c.setColorWrite(!0)}}n.render(r)}},i.renderUnsorted=function(e){for(var t=0;t<e.length;t++){e.data[t].render(!1)}},i.defaultTransparentSortCompare=function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:i.backToFrontSortCompare(e,t)},i.backToFrontSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0},i.frontToBackSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0},i.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},i.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},i.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!=i&&(i.needAlphaBlendingForMesh(t)?this._transparentSubMeshes.push(e):i.needAlphaTesting()?(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._alphaTestSubMeshes.push(e)):(i.needDepthPrePass&&this._depthOnlySubMeshes.push(e),this._opaqueSubMeshes.push(e)),t._edgesRenderer&&t._edgesRenderer.isEnabled&&this._edgesRenderers.push(t._edgesRenderer))},i.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},i.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},i.prototype._renderParticles=function(e){if(0!==this._particleSystems.length){var t=this._scene.activeCamera;this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);for(var i=0;i<this._particleSystems.length;i++){var r=this._particleSystems.data[i];if(0!==(t&&t.layerMask&r.layerMask)){var n=r.emitter;n.position&&e&&-1===e.indexOf(n)||this._scene._activeParticles.addCount(r.render(),!1)}}this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene)}},i.prototype._renderSprites=function(){if(this._scene.spritesEnabled&&0!==this._spriteManagers.length){var e=this._scene.activeCamera;this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);for(var t=0;t<this._spriteManagers.length;t++){var i=this._spriteManagers.data[t];0!==(e&&e.layerMask&i.layerMask)&&i.render()}this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene)}},i})(),W.RenderingGroup=H,(function(e){var t=(function(){function e(){}return e.NAME_EFFECTLAYER="EffectLayer",e.NAME_LAYER="Layer",e.NAME_LENSFLARESYSTEM="LensFlareSystem",e.NAME_BOUNDINGBOXRENDERER="BoundingBoxRenderer",e.NAME_PARTICLESYSTEM="ParticleSystem",e.NAME_GAMEPAD="Gamepad",e.NAME_SIMPLIFICATIONQUEUE="SimplificationQueue",e.NAME_GEOMETRYBUFFERRENDERER="GeometryBufferRenderer",e.NAME_DEPTHRENDERER="DepthRenderer",e.NAME_POSTPROCESSRENDERPIPELINEMANAGER="PostProcessRenderPipelineManager",e.NAME_SPRITE="Sprite",e.NAME_OUTLINERENDERER="Outline",e.NAME_PROCEDURALTEXTURE="ProceduralTexture",e.NAME_SHADOWGENERATOR="ShadowGenerator",e.NAME_OCTREE="Octree",e.NAME_PHYSICSENGINE="PhysicsEngine",e.NAME_AUDIO="Audio",e.STEP_ISREADYFORMESH_EFFECTLAYER=0,e.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER=0,e.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER=0,e.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER=1,e.STEP_BEFORECAMERADRAW_EFFECTLAYER=0,e.STEP_BEFORECAMERADRAW_LAYER=1,e.STEP_BEFORERENDERINGMESH_OUTLINE=0,e.STEP_AFTERRENDERINGMESH_OUTLINE=0,e.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW=0,e.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER=1,e.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE=0,e.STEP_BEFORECAMERAUPDATE_GAMEPAD=1,e.STEP_BEFORECLEAR_PROCEDURALTEXTURE=0,e.STEP_AFTERCAMERADRAW_EFFECTLAYER=0,e.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM=1,e.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW=2,e.STEP_AFTERCAMERADRAW_LAYER=3,e.STEP_AFTERRENDER_AUDIO=0,e.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR=0,e.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER=1,e.STEP_GATHERRENDERTARGETS_DEPTHRENDERER=2,e.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER=3,e.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER=0,e.STEP_POINTERMOVE_SPRITE=0,e.STEP_POINTERDOWN_SPRITE=0,e.STEP_POINTERUP_SPRITE=0,e})();e.SceneComponentConstants=t;var i=(function(t){function e(e){return t.apply(this,e)||this}return T(e,t),e.Create=function(){return Object.create(e.prototype)},e.prototype.registerStep=function(e,t,i){var r=0;for(Number.MAX_VALUE;r<this.length;r++){if(e<this[r].index)break}this.splice(r,0,{index:e,component:t,action:i.bind(t)})},e.prototype.clear=function(){this.length=0},e})(Array);e.Stage=i})($a||($a={})),X=$a||($a={}),j=(function(){function e(){this.rootNodes=new Array,this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=[],this.animationGroups=new Array,this.multiMaterials=new Array,this.materials=new Array,this.morphTargetManagers=new Array,this.geometries=new Array,this.transformNodes=new Array,this.actionManagers=new Array,this.textures=new Array}return e.AddParser=function(e,t){this._BabylonFileParsers[e]=t},e.GetParser=function(e){return this._BabylonFileParsers[e]?this._BabylonFileParsers[e]:null},e.AddIndividualParser=function(e,t){this._IndividualBabylonFileParsers[e]=t},e.GetIndividualParser=function(e){return this._IndividualBabylonFileParsers[e]?this._IndividualBabylonFileParsers[e]:null},e.Parse=function(e,t,i,r){for(var n in this._BabylonFileParsers)this._BabylonFileParsers.hasOwnProperty(n)&&this._BabylonFileParsers[n](e,t,i,r)},e._BabylonFileParsers={},e._IndividualBabylonFileParsers={},e})(),X.AbstractScene=j,(function(E){var u=(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})(),e=function(){};E.RenderingGroupInfo=e;var t=(function(i){function x(e){var t=i.call(this)||this;return t.autoClear=!0,t.autoClearDepthAndStencil=!0,t.clearColor=new E.Color4(.2,.2,.3,1),t.ambientColor=new E.Color3(0,0,0),t._forceWireframe=!1,t._forcePointsCloud=!1,t.animationsEnabled=!0,t._animationPropertiesOverride=null,t.useConstantAnimationDeltaTime=!1,t.constantlyUpdateMeshUnderPointer=!1,t.hoverCursor="pointer",t.defaultCursor="",t.preventDefaultOnPointerDown=!0,t.metadata=null,t.disableOfflineSupportExceptionRules=new Array,t.onDisposeObservable=new E.Observable,t._onDisposeObserver=null,t.onBeforeRenderObservable=new E.Observable,t._onBeforeRenderObserver=null,t.onAfterRenderObservable=new E.Observable,t._onAfterRenderObserver=null,t.onBeforeAnimationsObservable=new E.Observable,t.onAfterAnimationsObservable=new E.Observable,t.onBeforeDrawPhaseObservable=new E.Observable,t.onAfterDrawPhaseObservable=new E.Observable,t.onReadyObservable=new E.Observable,t.onBeforeCameraRenderObservable=new E.Observable,t._onBeforeCameraRenderObserver=null,t.onAfterCameraRenderObservable=new E.Observable,t._onAfterCameraRenderObserver=null,t.onBeforeActiveMeshesEvaluationObservable=new E.Observable,t.onAfterActiveMeshesEvaluationObservable=new E.Observable,t.onBeforeParticlesRenderingObservable=new E.Observable,t.onAfterParticlesRenderingObservable=new E.Observable,t.onDataLoadedObservable=new E.Observable,t.onNewCameraAddedObservable=new E.Observable,t.onCameraRemovedObservable=new E.Observable,t.onNewLightAddedObservable=new E.Observable,t.onLightRemovedObservable=new E.Observable,t.onNewGeometryAddedObservable=new E.Observable,t.onGeometryRemovedObservable=new E.Observable,t.onNewTransformNodeAddedObservable=new E.Observable,t.onTransformNodeRemovedObservable=new E.Observable,t.onNewMeshAddedObservable=new E.Observable,t.onMeshRemovedObservable=new E.Observable,t.onNewMaterialAddedObservable=new E.Observable,t.onMaterialRemovedObservable=new E.Observable,t.onNewTextureAddedObservable=new E.Observable,t.onTextureRemovedObservable=new E.Observable,t.onBeforeRenderTargetsRenderObservable=new E.Observable,t.onAfterRenderTargetsRenderObservable=new E.Observable,t.onBeforeStepObservable=new E.Observable,t.onAfterStepObservable=new E.Observable,t.onBeforeRenderingGroupObservable=new E.Observable,t.onAfterRenderingGroupObservable=new E.Observable,t.onMeshImportedObservable=new E.Observable,t._registeredForLateAnimationBindings=new E.SmartArrayNoDuplicate(256),t.onPrePointerObservable=new E.Observable,t.onPointerObservable=new E.Observable,t._meshPickProceed=!1,t._currentPickResult=null,t._previousPickResult=null,t._totalPointersPressed=0,t._doubleClickOccured=!1,t.cameraToUseForPointers=null,t._pointerX=0,t._pointerY=0,t._startingPointerPosition=new E.Vector2(0,0),t._previousStartingPointerPosition=new E.Vector2(0,0),t._startingPointerTime=0,t._previousStartingPointerTime=0,t._pointerCaptures={},t._timeAccumulator=0,t._currentStepId=0,t._currentInternalStep=0,t.onPreKeyboardObservable=new E.Observable,t.onKeyboardObservable=new E.Observable,t._useRightHandedSystem=!1,t._fogEnabled=!0,t._fogMode=x.FOGMODE_NONE,t.fogColor=new E.Color3(.2,.2,.3),t.fogDensity=.1,t.fogStart=0,t.fogEnd=1e3,t._shadowsEnabled=!0,t._lightsEnabled=!0,t.activeCameras=new Array,t._texturesEnabled=!0,t.particlesEnabled=!0,t.spritesEnabled=!0,t._skeletonsEnabled=!0,t.lensFlaresEnabled=!0,t.collisionsEnabled=!0,t.gravity=new E.Vector3(0,-9.807,0),t.postProcessesEnabled=!0,t.postProcesses=new Array,t.renderTargetsEnabled=!0,t.dumpNextRenderTargets=!1,t.customRenderTargets=new Array,t.importedMeshesFiles=new Array,t.probesEnabled=!0,t._meshesForIntersections=new E.SmartArrayNoDuplicate(256),t.proceduralTexturesEnabled=!0,t._totalVertices=new E.PerfCounter,t._activeIndices=new E.PerfCounter,t._activeParticles=new E.PerfCounter,t._activeBones=new E.PerfCounter,t._animationTime=0,t.animationTimeScale=1,t._renderId=0,t._frameId=0,t._executeWhenReadyTimeoutId=-1,t._intermediateRendering=!1,t._viewUpdateFlag=-1,t._projectionUpdateFlag=-1,t._alternateViewUpdateFlag=-1,t._alternateProjectionUpdateFlag=-1,t._toBeDisposed=new Array(256),t._activeRequests=new Array,t._pendingData=new Array,t._isDisposed=!1,t.dispatchAllSubMeshesOfActiveMeshes=!1,t._activeMeshes=new E.SmartArray(256),t._processedMaterials=new E.SmartArray(256),t._renderTargets=new E.SmartArrayNoDuplicate(256),t._activeParticleSystems=new E.SmartArray(256),t._activeSkeletons=new E.SmartArrayNoDuplicate(32),t._softwareSkinnedMeshes=new E.SmartArrayNoDuplicate(32),t._activeAnimatables=new Array,t._transformMatrix=E.Matrix.Zero(),t._useAlternateCameraConfiguration=!1,t._alternateRendering=!1,t.requireLightSorting=!1,t._components=[],t._serializableComponents=[],t._transientComponents=[],t._beforeCameraUpdateStage=E.Stage.Create(),t._beforeClearStage=E.Stage.Create(),t._gatherRenderTargetsStage=E.Stage.Create(),t._gatherActiveCameraRenderTargetsStage=E.Stage.Create(),t._isReadyForMeshStage=E.Stage.Create(),t._beforeEvaluateActiveMeshStage=E.Stage.Create(),t._evaluateSubMeshStage=E.Stage.Create(),t._activeMeshStage=E.Stage.Create(),t._cameraDrawRenderTargetStage=E.Stage.Create(),t._beforeCameraDrawStage=E.Stage.Create(),t._beforeRenderingGroupDrawStage=E.Stage.Create(),t._beforeRenderingMeshStage=E.Stage.Create(),t._afterRenderingMeshStage=E.Stage.Create(),t._afterRenderingGroupDrawStage=E.Stage.Create(),t._afterCameraDrawStage=E.Stage.Create(),t._afterRenderStage=E.Stage.Create(),t._pointerMoveStage=E.Stage.Create(),t._pointerDownStage=E.Stage.Create(),t._pointerUpStage=E.Stage.Create(),t._defaultMeshCandidates={data:[],length:0},t._defaultSubMeshCandidates={data:[],length:0},t._activeMeshesFrozen=!1,t._allowPostProcessClearColor=!0,t.getDeterministicFrameTime=function(){return 1e3/60},t._tempPickingRay=E.Ray?E.Ray.Zero():null,t._blockMaterialDirtyMechanism=!1,t._engine=e||E.Engine.LastCreatedEngine,t._engine.scenes.push(t),t._uid=null,t._renderingManager=new E.RenderingManager(t),E.PostProcessManager&&(t.postProcessManager=new E.PostProcessManager(t)),E.Tools.IsWindowObjectExist()&&t.attachControl(),t.workerCollisions=!1,t._createUbo(),E.ImageProcessingConfiguration&&(t._imageProcessingConfiguration=new E.ImageProcessingConfiguration),t.setDefaultCandidateProviders(),t}return T(x,i),Object.defineProperty(x.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(e){this._environmentTexture!==e&&(this._environmentTexture=e,this.markAllMaterialsAsDirty(E.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(e){this._forceWireframe!==e&&(this._forceWireframe=e,this.markAllMaterialsAsDirty(E.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(e){this._forcePointsCloud!==e&&(this._forcePointsCloud=e,this.markAllMaterialsAsDirty(E.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"beforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),e&&(this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"afterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),e&&(this._onAfterRenderObserver=this.onAfterRenderObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"unTranslatedPointer",{get:function(){return new E.Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(e){this._useRightHandedSystem!==e&&(this._useRightHandedSystem=e,this.markAllMaterialsAsDirty(E.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),x.prototype.setStepId=function(e){this._currentStepId=e},x.prototype.getStepId=function(){return this._currentStepId},x.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(x.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAllMaterialsAsDirty(E.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"fogMode",{get:function(){return this._fogMode},set:function(e){this._fogMode!==e&&(this._fogMode=e,this.markAllMaterialsAsDirty(E.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(e){this._shadowsEnabled!==e&&(this._shadowsEnabled=e,this.markAllMaterialsAsDirty(E.Material.LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(e){this._lightsEnabled!==e&&(this._lightsEnabled=e,this.markAllMaterialsAsDirty(E.Material.LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"defaultMaterial",{get:function(){return this._defaultMaterial||(this._defaultMaterial=new E.StandardMaterial("default material",this)),this._defaultMaterial},set:function(e){this._defaultMaterial=e},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(e){this._texturesEnabled!==e&&(this._texturesEnabled=e,this.markAllMaterialsAsDirty(E.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(e){this._skeletonsEnabled!==e&&(this._skeletonsEnabled=e,this.markAllMaterialsAsDirty(E.Material.AttributesDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"_isAlternateRenderingEnabled",{get:function(){return this._alternateRendering},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!0,configurable:!0}),x.prototype._registerTransientComponents=function(){if(0<this._transientComponents.length){for(var e=0,t=this._transientComponents;e<t.length;e++){t[e].register()}this._transientComponents=[]}},x.prototype._addComponent=function(e){this._components.push(e),this._transientComponents.push(e);var t=e;t.addFromContainer&&this._serializableComponents.push(t)},x.prototype._getComponent=function(e){for(var t=0,i=this._components;t<i.length;t++){var r=i[t];if(r.name===e)return r}return null},x.prototype._getDefaultMeshCandidates=function(){return this._defaultMeshCandidates.data=this.meshes,this._defaultMeshCandidates.length=this.meshes.length,this._defaultMeshCandidates},x.prototype._getDefaultSubMeshCandidates=function(e){return this._defaultSubMeshCandidates.data=e.subMeshes,this._defaultSubMeshCandidates.length=e.subMeshes.length,this._defaultSubMeshCandidates},x.prototype.setDefaultCandidateProviders=function(){this.getActiveMeshCandidates=this._getDefaultMeshCandidates.bind(this),this.getActiveSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getIntersectingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this),this.getCollidingSubMeshCandidates=this._getDefaultSubMeshCandidates.bind(this)},Object.defineProperty(x.prototype,"workerCollisions",{get:function(){return this._workerCollisions},set:function(e){E.CollisionCoordinatorLegacy&&(e=e&&!!Worker&&!!E.CollisionWorker,this._workerCollisions=e,this.collisionCoordinator&&this.collisionCoordinator.destroy(),this.collisionCoordinator=e?new E.CollisionCoordinatorWorker:new E.CollisionCoordinatorLegacy,this.collisionCoordinator.init(this))},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(x.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),x.prototype.getCachedMaterial=function(){return this._cachedMaterial},x.prototype.getCachedEffect=function(){return this._cachedEffect},x.prototype.getCachedVisibility=function(){return this._cachedVisibility},x.prototype.isCachedMaterialInvalid=function(e,t,i){return void 0===i&&(i=1),this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i},x.prototype.getEngine=function(){return this._engine},x.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(x.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!0,configurable:!0}),x.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(x.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!0,configurable:!0}),x.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(x.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!0,configurable:!0}),x.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(x.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!0,configurable:!0}),x.prototype.getInterFramePerfCounter=function(){return E.Tools.Warn("getInterFramePerfCounter is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(x.prototype,"interFramePerfCounter",{get:function(){return E.Tools.Warn("interFramePerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),x.prototype.getLastFrameDuration=function(){return E.Tools.Warn("getLastFrameDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(x.prototype,"lastFramePerfCounter",{get:function(){return E.Tools.Warn("lastFramePerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),x.prototype.getEvaluateActiveMeshesDuration=function(){return E.Tools.Warn("getEvaluateActiveMeshesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(x.prototype,"evaluateActiveMeshesDurationPerfCounter",{get:function(){return E.Tools.Warn("evaluateActiveMeshesDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),x.prototype.getActiveMeshes=function(){return this._activeMeshes},x.prototype.getRenderTargetsDuration=function(){return E.Tools.Warn("getRenderTargetsDuration is deprecated. Please use SceneInstrumentation class"),0},x.prototype.getRenderDuration=function(){return E.Tools.Warn("getRenderDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(x.prototype,"renderDurationPerfCounter",{get:function(){return E.Tools.Warn("renderDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),x.prototype.getParticlesDuration=function(){return E.Tools.Warn("getParticlesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(x.prototype,"particlesDurationPerfCounter",{get:function(){return E.Tools.Warn("particlesDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),x.prototype.getSpritesDuration=function(){return E.Tools.Warn("getSpritesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(x.prototype,"spriteDuractionPerfCounter",{get:function(){return E.Tools.Warn("spriteDuractionPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),x.prototype.getAnimationRatio=function(){return void 0!==this._animationRatio?this._animationRatio:1},x.prototype.getRenderId=function(){return this._renderId},x.prototype.getFrameId=function(){return this._frameId},x.prototype.incrementRenderId=function(){this._renderId++},x.prototype._updatePointerPosition=function(e){var t=this._engine.getRenderingCanvasClientRect();t&&(this._pointerX=e.clientX-t.left,this._pointerY=e.clientY-t.top,this._unTranslatedPointerX=this._pointerX,this._unTranslatedPointerY=this._pointerY)},x.prototype._createUbo=function(){this._sceneUbo=new E.UniformBuffer(this._engine,void 0,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},x.prototype._createAlternateUbo=function(){this._alternateSceneUbo=new E.UniformBuffer(this._engine,void 0,!0),this._alternateSceneUbo.addUniform("viewProjection",16),this._alternateSceneUbo.addUniform("view",16)},x.prototype._setRayOnPointerInfo=function(e){e.pickInfo&&(e.pickInfo.ray||(e.pickInfo.ray=this.createPickingRay(e.event.offsetX,e.event.offsetY,E.Matrix.Identity(),this.activeCamera)))},x.prototype.simulatePointerMove=function(e,t){var i=new PointerEvent("pointermove",t);return this._checkPrePointerObservable(e,i,E.PointerEventTypes.POINTERMOVE)?this:this._processPointerMove(e,i)},x.prototype._processPointerMove=function(e,t){var i=this._engine.getRenderingCanvas();if(!i)return this;i.style.cursor=this.defaultCursor;var r=!!(e&&e.hit&&e.pickedMesh);r?(this.setPointerOverMesh(e.pickedMesh),this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.hasPointerTriggers&&(this._pointerOverMesh.actionManager.hoverCursor?i.style.cursor=this._pointerOverMesh.actionManager.hoverCursor:i.style.cursor=this.hoverCursor)):this.setPointerOverMesh(null);for(var n=0,o=this._pointerMoveStage;n<o.length;n++){e=o[n].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,r,i)}if(e){var s="mousewheel"===t.type||"DOMMouseScroll"===t.type?E.PointerEventTypes.POINTERWHEEL:E.PointerEventTypes.POINTERMOVE;if(this.onPointerMove&&this.onPointerMove(t,e,s),this.onPointerObservable.hasObservers()){var a=new E.PointerInfo(s,t,e);this._setRayOnPointerInfo(a),this.onPointerObservable.notifyObservers(a,s)}}return this},x.prototype._checkPrePointerObservable=function(e,t,i){var r=new E.PointerInfoPre(i,t,this._unTranslatedPointerX,this._unTranslatedPointerY);return e&&(r.ray=e.ray),this.onPrePointerObservable.notifyObservers(r,i),!!r.skipOnPointerObservable},x.prototype.simulatePointerDown=function(e,t){var i=new PointerEvent("pointerdown",t);return this._checkPrePointerObservable(e,i,E.PointerEventTypes.POINTERDOWN)?this:this._processPointerDown(e,i)},x.prototype._processPointerDown=function(e,t){var i=this;if(e&&e.hit&&e.pickedMesh){this._pickedDownMesh=e.pickedMesh;var r=e.pickedMesh.actionManager;if(r){if(r.hasPickTriggers)switch(r.processTrigger(E.ActionManager.OnPickDownTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t)),t.button){case 0:r.processTrigger(E.ActionManager.OnLeftPickTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t));break;case 1:r.processTrigger(E.ActionManager.OnCenterPickTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t));break;case 2:r.processTrigger(E.ActionManager.OnRightPickTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t))}r.hasSpecificTrigger(E.ActionManager.OnLongPressTrigger)&&window.setTimeout((function(){var e=i.pick(i._unTranslatedPointerX,i._unTranslatedPointerY,(function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.actionManager&&e.actionManager.hasSpecificTrigger(E.ActionManager.OnLongPressTrigger)&&e==i._pickedDownMesh}),!1,i.cameraToUseForPointers);e&&e.hit&&e.pickedMesh&&r&&0!==i._totalPointersPressed&&Date.now()-i._startingPointerTime>x.LongPressDelay&&!i._isPointerSwiping()&&(i._startingPointerTime=0,r.processTrigger(E.ActionManager.OnLongPressTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t)))}),x.LongPressDelay)}}else for(var n=0,o=this._pointerDownStage;n<o.length;n++){e=o[n].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t)}if(e){var s=E.PointerEventTypes.POINTERDOWN;if(this.onPointerDown&&this.onPointerDown(t,e,s),this.onPointerObservable.hasObservers()){var a=new E.PointerInfo(s,t,e);this._setRayOnPointerInfo(a),this.onPointerObservable.notifyObservers(a,s)}}return this},x.prototype.simulatePointerUp=function(e,t){var i=new PointerEvent("pointerup",t),r=new u;return r.singleClick=!0,r.ignore=!0,this._checkPrePointerObservable(e,i,E.PointerEventTypes.POINTERUP)?this:this._processPointerUp(e,i,r)},x.prototype._processPointerUp=function(e,t,i){if(e&&e&&e.pickedMesh){if(this._pickedUpMesh=e.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(t,e),i.singleClick&&!i.ignore&&this.onPointerObservable.hasObservers())){var r=E.PointerEventTypes.POINTERPICK,n=new E.PointerInfo(r,t,e);this._setRayOnPointerInfo(n),this.onPointerObservable.notifyObservers(n,r)}e.pickedMesh.actionManager&&(i.ignore&&e.pickedMesh.actionManager.processTrigger(E.ActionManager.OnPickUpTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t)),i.hasSwiped||i.ignore||!i.singleClick||e.pickedMesh.actionManager.processTrigger(E.ActionManager.OnPickTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t)),i.doubleClick&&!i.ignore&&e.pickedMesh.actionManager.hasSpecificTrigger(E.ActionManager.OnDoublePickTrigger)&&e.pickedMesh.actionManager.processTrigger(E.ActionManager.OnDoublePickTrigger,E.ActionEvent.CreateNew(e.pickedMesh,t)))}else if(!i.ignore)for(var o=0,s=this._pointerUpStage;o<s.length;o++){e=s[o].action(this._unTranslatedPointerX,this._unTranslatedPointerY,e,t)}this._pickedDownMesh&&this._pickedDownMesh.actionManager&&this._pickedDownMesh.actionManager.hasSpecificTrigger(E.ActionManager.OnPickOutTrigger)&&this._pickedDownMesh!==this._pickedUpMesh&&this._pickedDownMesh.actionManager.processTrigger(E.ActionManager.OnPickOutTrigger,E.ActionEvent.CreateNew(this._pickedDownMesh,t));var a=E.PointerEventTypes.POINTERUP;if(this.onPointerObservable.hasObservers())if(i.ignore){n=new E.PointerInfo(a,t,e);this._setRayOnPointerInfo(n),this.onPointerObservable.notifyObservers(n,a)}else if(!i.hasSwiped){if(i.singleClick&&this.onPointerObservable.hasSpecificMask(E.PointerEventTypes.POINTERTAP)){var l=E.PointerEventTypes.POINTERTAP,n=new E.PointerInfo(l,t,e);this._setRayOnPointerInfo(n),this.onPointerObservable.notifyObservers(n,l)}if(i.doubleClick&&this.onPointerObservable.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP)){var c=E.PointerEventTypes.POINTERDOUBLETAP;n=new E.PointerInfo(c,t,e);this._setRayOnPointerInfo(n),this.onPointerObservable.notifyObservers(n,c)}}return this.onPointerUp&&this.onPointerUp(t,e,a),this},x.prototype.isPointerCaptured=function(e){return void 0===e&&(e=0),this._pointerCaptures[e]},x.prototype._isPointerSwiping=function(){return Math.abs(this._startingPointerPosition.x-this._pointerX)>x.DragMovementThreshold||Math.abs(this._startingPointerPosition.y-this._pointerY)>x.DragMovementThreshold},x.prototype.attachControl=function(e,t,i){var h=this;void 0===e&&(e=!0),void 0===t&&(t=!0),void 0===i&&(i=!0),this._initActionManager=function(e,t){if(!h._meshPickProceed){var i=h.pick(h._unTranslatedPointerX,h._unTranslatedPointerY,h.pointerDownPredicate,!1,h.cameraToUseForPointers);(h._currentPickResult=i)&&(e=i.hit&&i.pickedMesh?i.pickedMesh.actionManager:null),h._meshPickProceed=!0}return e},this._delayedSimpleClick=function(e,t,i){(Date.now()-h._previousStartingPointerTime>x.DoubleClickDelay&&!h._doubleClickOccured||e!==h._previousButtonPressed)&&(h._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,i(t,h._currentPickResult))},this._initClickEvent=function(e,t,i,r){var n=new u,o=h._currentPickResult=null,s=e.hasSpecificMask(E.PointerEventTypes.POINTERPICK)||t.hasSpecificMask(E.PointerEventTypes.POINTERPICK)||e.hasSpecificMask(E.PointerEventTypes.POINTERTAP)||t.hasSpecificMask(E.PointerEventTypes.POINTERTAP)||e.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP)||t.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP);if(!s&&E.ActionManager&&E.ActionManager.HasPickTriggers&&(o=h._initActionManager(o,n))&&(s=o.hasPickTriggers),s){var a=i.button;if(n.hasSwiped=h._isPointerSwiping(),!n.hasSwiped){var l=!x.ExclusiveDoubleClickMode;l||(l=!e.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP)&&!t.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP))&&!E.ActionManager.HasSpecificTrigger(E.ActionManager.OnDoublePickTrigger)&&(o=h._initActionManager(o,n))&&(l=!o.hasSpecificTrigger(E.ActionManager.OnDoublePickTrigger)),l?(Date.now()-h._previousStartingPointerTime>x.DoubleClickDelay||a!==h._previousButtonPressed)&&(n.singleClick=!0,r(n,h._currentPickResult)):(h._previousDelayedSimpleClickTimeout=h._delayedSimpleClickTimeout,h._delayedSimpleClickTimeout=window.setTimeout(h._delayedSimpleClick.bind(h,a,n,r),x.DoubleClickDelay));var c=e.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP)||t.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP);!c&&E.ActionManager.HasSpecificTrigger(E.ActionManager.OnDoublePickTrigger)&&(o=h._initActionManager(o,n))&&(c=o.hasSpecificTrigger(E.ActionManager.OnDoublePickTrigger)),c&&(a===h._previousButtonPressed&&Date.now()-h._previousStartingPointerTime<x.DoubleClickDelay&&!h._doubleClickOccured?n.hasSwiped||h._isPointerSwiping()?(h._doubleClickOccured=!1,h._previousStartingPointerTime=h._startingPointerTime,h._previousStartingPointerPosition.x=h._startingPointerPosition.x,h._previousStartingPointerPosition.y=h._startingPointerPosition.y,h._previousButtonPressed=a,x.ExclusiveDoubleClickMode?(h._previousDelayedSimpleClickTimeout&&clearTimeout(h._previousDelayedSimpleClickTimeout),h._previousDelayedSimpleClickTimeout=h._delayedSimpleClickTimeout,r(n,h._previousPickResult)):r(n,h._currentPickResult)):(h._previousStartingPointerTime=0,h._doubleClickOccured=!0,n.doubleClick=!0,n.ignore=!1,x.ExclusiveDoubleClickMode&&h._previousDelayedSimpleClickTimeout&&clearTimeout(h._previousDelayedSimpleClickTimeout),h._previousDelayedSimpleClickTimeout=h._delayedSimpleClickTimeout,r(n,h._currentPickResult)):(h._doubleClickOccured=!1,h._previousStartingPointerTime=h._startingPointerTime,h._previousStartingPointerPosition.x=h._startingPointerPosition.x,h._previousStartingPointerPosition.y=h._startingPointerPosition.y,h._previousButtonPressed=a))}}n.ignore=!0,r(n,h._currentPickResult)},this._onPointerMove=function(e){if(h._updatePointerPosition(e),!h._checkPrePointerObservable(null,e,"mousewheel"===e.type||"DOMMouseScroll"===e.type?E.PointerEventTypes.POINTERWHEEL:E.PointerEventTypes.POINTERMOVE)&&(h.cameraToUseForPointers||h.activeCamera)){h.pointerMovePredicate||(h.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||h.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var t=h.pick(h._unTranslatedPointerX,h._unTranslatedPointerY,h.pointerMovePredicate,!1,h.cameraToUseForPointers);h._processPointerMove(t,e)}},this._onPointerDown=function(e){if(h._totalPointersPressed++,h._pickedDownMesh=null,h._meshPickProceed=!1,h._updatePointerPosition(e),h.preventDefaultOnPointerDown&&o&&(e.preventDefault(),o.focus()),!h._checkPrePointerObservable(null,e,E.PointerEventTypes.POINTERDOWN)&&(h.cameraToUseForPointers||h.activeCamera)){h._pointerCaptures[e.pointerId]=!0,h._startingPointerPosition.x=h._pointerX,h._startingPointerPosition.y=h._pointerY,h._startingPointerTime=Date.now(),h.pointerDownPredicate||(h.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),h._pickedDownMesh=null;var t=h.pick(h._unTranslatedPointerX,h._unTranslatedPointerY,h.pointerDownPredicate,!1,h.cameraToUseForPointers);h._processPointerDown(t,e)}},this._onPointerUp=function(i){0!==h._totalPointersPressed&&(h._totalPointersPressed--,h._pickedUpMesh=null,h._meshPickProceed=!1,h._updatePointerPosition(i),h._initClickEvent(h.onPrePointerObservable,h.onPointerObservable,i,(function(e,t){if(h.onPrePointerObservable.hasObservers())if(e.ignore){if(h._checkPrePointerObservable(null,i,E.PointerEventTypes.POINTERUP))return}else if(!e.hasSwiped){if(e.singleClick&&h.onPrePointerObservable.hasSpecificMask(E.PointerEventTypes.POINTERTAP)&&h._checkPrePointerObservable(null,i,E.PointerEventTypes.POINTERTAP))return;if(e.doubleClick&&h.onPrePointerObservable.hasSpecificMask(E.PointerEventTypes.POINTERDOUBLETAP)&&h._checkPrePointerObservable(null,i,E.PointerEventTypes.POINTERDOUBLETAP))return}(h.cameraToUseForPointers||h.activeCamera)&&(h._pointerCaptures[i.pointerId]=!1,h.pointerUpPredicate||(h.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!h._meshPickProceed&&(E.ActionManager&&E.ActionManager.HasTriggers||h.onPointerObservable.hasObservers())&&h._initActionManager(null,e),t||(t=h._currentPickResult),h._processPointerUp(t,i,e),h._previousPickResult=h._currentPickResult)})))},this._onKeyDown=function(e){var t=E.KeyboardEventTypes.KEYDOWN;if(h.onPreKeyboardObservable.hasObservers()){var i=new E.KeyboardInfoPre(t,e);if(h.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(h.onKeyboardObservable.hasObservers()){i=new E.KeyboardInfo(t,e);h.onKeyboardObservable.notifyObservers(i,t)}h.actionManager&&h.actionManager.processTrigger(E.ActionManager.OnKeyDownTrigger,E.ActionEvent.CreateNewFromScene(h,e))},this._onKeyUp=function(e){var t=E.KeyboardEventTypes.KEYUP;if(h.onPreKeyboardObservable.hasObservers()){var i=new E.KeyboardInfoPre(t,e);if(h.onPreKeyboardObservable.notifyObservers(i,t),i.skipOnPointerObservable)return}if(h.onKeyboardObservable.hasObservers()){i=new E.KeyboardInfo(t,e);h.onKeyboardObservable.notifyObservers(i,t)}h.actionManager&&h.actionManager.processTrigger(E.ActionManager.OnKeyUpTrigger,E.ActionEvent.CreateNewFromScene(h,e))};var r=this.getEngine();this._onCanvasFocusObserver=r.onCanvasFocusObservable.add((function(){o&&(o.addEventListener("keydown",h._onKeyDown,!1),o.addEventListener("keyup",h._onKeyUp,!1))})),this._onCanvasBlurObserver=r.onCanvasBlurObservable.add((function(){o&&(o.removeEventListener("keydown",h._onKeyDown),o.removeEventListener("keyup",h._onKeyUp))}));var n=E.Tools.GetPointerPrefix(),o=this._engine.getRenderingCanvas();o&&(i&&(o.addEventListener(n+"move",this._onPointerMove,!1),o.addEventListener("mousewheel",this._onPointerMove,!1),o.addEventListener("DOMMouseScroll",this._onPointerMove,!1)),t&&o.addEventListener(n+"down",this._onPointerDown,!1),e&&window.addEventListener(n+"up",this._onPointerUp,!1),o.tabIndex=1)},x.prototype.detachControl=function(){var e=this.getEngine(),t=E.Tools.GetPointerPrefix(),i=e.getRenderingCanvas();i&&(i.removeEventListener(t+"move",this._onPointerMove),i.removeEventListener(t+"down",this._onPointerDown),window.removeEventListener(t+"up",this._onPointerUp),this._onCanvasBlurObserver&&e.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onCanvasFocusObserver&&e.onCanvasFocusObservable.remove(this._onCanvasFocusObserver),i.removeEventListener("mousewheel",this._onPointerMove),i.removeEventListener("DOMMouseScroll",this._onPointerMove),i.removeEventListener("keydown",this._onKeyDown),i.removeEventListener("keyup",this._onKeyUp),this.onKeyboardObservable.clear(),this.onPreKeyboardObservable.clear(),this.onPointerObservable.clear(),this.onPrePointerObservable.clear())},x.prototype.isReady=function(){if(this._isDisposed)return!1;if(0<this._pendingData.length)return!1;var e,t=this.getEngine();for(e=0;e<this.geometries.length;e++){if(this.geometries[e].delayLoadState===E.Engine.DELAYLOADSTATE_LOADING)return!1}for(e=0;e<this.meshes.length;e++){var i=this.meshes[e];if(i.isEnabled()&&(i.subMeshes&&0!==i.subMeshes.length)){if(!i.isReady(!0))return!1;for(var r="InstancedMesh"===i.getClassName()||t.getCaps().instancedArrays&&0<i.instances.length,n=0,o=this._isReadyForMeshStage;n<o.length;n++){if(!o[n].action(i,r))return!1}}}if(this.activeCameras&&0<this.activeCameras.length)for(var s=0,a=this.activeCameras;s<a.length;s++){if(!a[s].isReady(!0))return!1}else if(this.activeCamera&&!this.activeCamera.isReady(!0))return!1;for(var l=0,c=this.particleSystems;l<c.length;l++){if(!c[l].isReady())return!1}return!0},x.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},x.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},x.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},x.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},x.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},x.prototype._executeOnceBeforeRender=function(e){var t=this,i=function(){e(),setTimeout((function(){t.unregisterBeforeRender(i)}))};this.registerBeforeRender(i)},x.prototype.executeOnceBeforeRender=function(e,t){var i=this;void 0!==t?setTimeout((function(){i._executeOnceBeforeRender(e)}),t):this._executeOnceBeforeRender(e)},x.prototype._addPendingData=function(e){this._pendingData.push(e)},x.prototype._removePendingData=function(e){var t=this.isLoading,i=this._pendingData.indexOf(e);-1!==i&&this._pendingData.splice(i,1),t&&!this.isLoading&&this.onDataLoadedObservable.notifyObservers(this)},x.prototype.getWaitingItemsCount=function(){return this._pendingData.length},Object.defineProperty(x.prototype,"isLoading",{get:function(){return 0<this._pendingData.length},enumerable:!0,configurable:!0}),x.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},x.prototype.whenReadyAsync=function(){var t=this;return new Promise(function(e){t.executeWhenReady((function(){e()}))})},x.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)},x.prototype.beginWeightedAnimation=function(e,t,i,r,n,o,s,a,l){void 0===r&&(r=1),void 0===o&&(o=1);var c=this.beginAnimation(e,t,i,n,o,s,a,!1,l);return c.weight=r,c},x.prototype.beginAnimation=function(e,t,i,r,n,o,s,a,l){void 0===n&&(n=1),void 0===a&&(a=!0),i<t&&0<n&&(n*=-1),a&&this.stopAnimation(e,void 0,l),s||(s=new E.Animatable(this,e,t,i,r,n,o));var c=!l||l(e);if(e.animations&&c&&s.appendAnimations(e,e.animations),e.getAnimatables)for(var h=e.getAnimatables(),u=0;u<h.length;u++)this.beginAnimation(h[u],t,i,r,n,o,s,a,l);return s.reset(),s},x.prototype.beginDirectAnimation=function(e,t,i,r,n,o,s){return void 0===o&&(o=1),new E.Animatable(this,e,i,r,n,o,s,t)},x.prototype.beginDirectHierarchyAnimation=function(e,t,i,r,n,o,s,a){var l=e.getDescendants(t),c=[];c.push(this.beginDirectAnimation(e,i,r,n,o,s,a));for(var h=0,u=l;h<u.length;h++){var d=u[h];c.push(this.beginDirectAnimation(d,i,r,n,o,s,a))}return c},x.prototype.getAnimatableByTarget=function(e){for(var t=0;t<this._activeAnimatables.length;t++)if(this._activeAnimatables[t].target===e)return this._activeAnimatables[t];return null},x.prototype.getAllAnimatablesByTarget=function(e){for(var t=[],i=0;i<this._activeAnimatables.length;i++)this._activeAnimatables[i].target===e&&t.push(this._activeAnimatables[i]);return t},Object.defineProperty(x.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),x.prototype.stopAnimation=function(e,t,i){for(var r=0,n=this.getAllAnimatablesByTarget(e);r<n.length;r++){n[r].stop(t,i)}},x.prototype.stopAllAnimations=function(){if(this._activeAnimatables){for(var e=0;e<this._activeAnimatables.length;e++)this._activeAnimatables[e].stop();this._activeAnimatables=[]}for(var t=0,i=this.animationGroups;t<i.length;t++){i[t].stop()}},x.prototype._animate=function(){if(this.animationsEnabled&&0!==this._activeAnimatables.length){var e=E.Tools.Now;if(!this._animationTimeLast){if(0<this._pendingData.length)return;this._animationTimeLast=e}var t=this.useConstantAnimationDeltaTime?16:(e-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=t,this._animationTimeLast=e;for(var i=0;i<this._activeAnimatables.length;i++)this._activeAnimatables[i]._animate(this._animationTime);this._processLateAnimationBindings()}},x.prototype._registerTargetForLateAnimationBinding=function(e,t){var i=e.target;this._registeredForLateAnimationBindings.pushNoDuplicate(i),i._lateAnimationHolders||(i._lateAnimationHolders={}),i._lateAnimationHolders[e.targetPath]||(i._lateAnimationHolders[e.targetPath]={totalWeight:0,animations:[],originalValue:t}),i._lateAnimationHolders[e.targetPath].animations.push(e),i._lateAnimationHolders[e.targetPath].totalWeight+=e.weight},x.prototype._processLateAnimationBindingsForMatrices=function(e){var t=1,i=E.Tmp.Vector3[0],r=E.Tmp.Vector3[1],n=E.Tmp.Quaternion[0],o=0,s=e.animations[0],a=e.originalValue,l=1;if(e.totalWeight<1)a.decompose(r,n,i),l=1-e.totalWeight;else if(o=1,t=e.totalWeight,s.currentValue.decompose(r,n,i),1==(l=s.weight/t))return s.currentValue;r.scaleInPlace(l),i.scaleInPlace(l),n.scaleInPlace(l);for(var c=o;c<e.animations.length;c++){var h=e.animations[c],u=(l=h.weight/t,E.Tmp.Vector3[2]),d=E.Tmp.Vector3[3],f=E.Tmp.Quaternion[1];h.currentValue.decompose(d,f,u),d.scaleAndAddToRef(l,r),f.scaleAndAddToRef(l,n),u.scaleAndAddToRef(l,i)}return E.Matrix.ComposeToRef(r,n,i,s._workValue),s._workValue},x.prototype._processLateAnimationBindingsForQuaternions=function(e,t){var i=e.animations[0],r=e.originalValue;if(1===e.animations.length)return E.Quaternion.SlerpToRef(r,i.currentValue,Math.min(1,e.totalWeight),t),t;var n,o,s=1;if(e.totalWeight<1){var a=1-e.totalWeight;o=[],(n=[]).push(r),o.push(a)}else{if(2===e.animations.length)return E.Quaternion.SlerpToRef(e.animations[0].currentValue,e.animations[1].currentValue,e.animations[1].weight/e.totalWeight,t),t;n=[],o=[],s=e.totalWeight}for(var l=0;l<e.animations.length;l++){var c=e.animations[l];n.push(c.currentValue),o.push(c.weight/s)}for(var h=0,u=null,d=0;d<n.length;)u?(h+=o[d],E.Quaternion.SlerpToRef(u,n[d],o[d]/h,u),d++):(E.Quaternion.SlerpToRef(n[d],n[d+1],o[d+1]/(o[d]+o[d+1]),t),u=t,h=o[d]+o[d+1],d+=2);return u},x.prototype._processLateAnimationBindings=function(){if(this._registeredForLateAnimationBindings.length){for(var e=0;e<this._registeredForLateAnimationBindings.length;e++){var t=this._registeredForLateAnimationBindings.data[e];for(var i in t._lateAnimationHolders){var r=t._lateAnimationHolders[i],n=r.animations[0],o=r.originalValue,s=E.Animation.AllowMatrixDecomposeForInterpolation&&o.m,a=t[i];if(s)a=this._processLateAnimationBindingsForMatrices(r);else if(void 0!==o.w)a=this._processLateAnimationBindingsForQuaternions(r,a||E.Quaternion.Identity());else{var l=0,c=1;if(r.totalWeight<1)a=o.scale?o.scale(1-r.totalWeight):o*(1-r.totalWeight);else{c=r.totalWeight;var h=n.weight/c;a=1!==h?n.currentValue.scale?n.currentValue.scale(h):n.currentValue*h:n.currentValue,l=1}for(var u=l;u<r.animations.length;u++){var d=r.animations[u],f=d.weight/c;d.currentValue.scaleAndAddToRef?d.currentValue.scaleAndAddToRef(f,a):a+=d.currentValue*f}}t[i]=a}t._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},x.prototype._switchToAlternateCameraConfiguration=function(e){this._useAlternateCameraConfiguration=e},x.prototype.getViewMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateViewMatrix:this._viewMatrix},x.prototype.getProjectionMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateProjectionMatrix:this._projectionMatrix},x.prototype.getTransformMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateTransformMatrix:this._transformMatrix},x.prototype.setTransformMatrix=function(e,t){if(this._viewUpdateFlag!==e.updateFlag||this._projectionUpdateFlag!==t.updateFlag){if(this._viewUpdateFlag=e.updateFlag,this._projectionUpdateFlag=t.updateFlag,this._viewMatrix=e,this._projectionMatrix=t,this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._frustumPlanes?E.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=E.Frustum.GetPlanes(this._transformMatrix),this.activeCamera&&this.activeCamera._alternateCamera){var i=this.activeCamera._alternateCamera;i.getViewMatrix().multiplyToRef(i.getProjectionMatrix(),E.Tmp.Matrix[0]),E.Frustum.GetRightPlaneToRef(E.Tmp.Matrix[0],this._frustumPlanes[3])}this._sceneUbo.useUbo&&(this._sceneUbo.updateMatrix("viewProjection",this._transformMatrix),this._sceneUbo.updateMatrix("view",this._viewMatrix),this._sceneUbo.update())}},x.prototype._setAlternateTransformMatrix=function(e,t){this._alternateViewUpdateFlag===e.updateFlag&&this._alternateProjectionUpdateFlag===t.updateFlag||(this._alternateViewUpdateFlag=e.updateFlag,this._alternateProjectionUpdateFlag=t.updateFlag,this._alternateViewMatrix=e,this._alternateProjectionMatrix=t,this._alternateTransformMatrix||(this._alternateTransformMatrix=E.Matrix.Zero()),this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix,this._alternateTransformMatrix),this._alternateSceneUbo||this._createAlternateUbo(),this._alternateSceneUbo.useUbo&&(this._alternateSceneUbo.updateMatrix("viewProjection",this._alternateTransformMatrix),this._alternateSceneUbo.updateMatrix("view",this._alternateViewMatrix),this._alternateSceneUbo.update()))},x.prototype.getSceneUniformBuffer=function(){return this._useAlternateCameraConfiguration?this._alternateSceneUbo:this._sceneUbo},x.prototype.getUniqueId=function(){var e=x._uniqueIdCounter;return x._uniqueIdCounter++,e},x.prototype.addMesh=function(e,t){var i=this;void 0===t&&(t=!1),this.meshes.push(e),this.collisionCoordinator&&this.collisionCoordinator.onMeshAdded(e),e._resyncLightSources(),this.onNewMeshAddedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.addMesh(e)}))},x.prototype.removeMesh=function(e,t){var i=this;void 0===t&&(t=!1);var r=this.meshes.indexOf(e);return-1!==r&&this.meshes.splice(r,1),this.onMeshRemovedObservable.notifyObservers(e),t&&e.getChildMeshes().forEach((function(e){i.removeMesh(e)})),r},x.prototype.addTransformNode=function(e){this.transformNodes.push(e),this.onNewTransformNodeAddedObservable.notifyObservers(e)},x.prototype.removeTransformNode=function(e){var t=this.transformNodes.indexOf(e);return-1!==t&&this.transformNodes.splice(t,1),this.onTransformNodeRemovedObservable.notifyObservers(e),t},x.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},x.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},x.prototype.removeLight=function(e){var t=this.lights.indexOf(e);if(-1!==t){for(var i=0,r=this.meshes;i<r.length;i++){r[i]._removeLightSource(e)}this.lights.splice(t,1),this.sortLightsByPriority()}return this.onLightRemovedObservable.notifyObservers(e),t},x.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);-1!==t&&this.cameras.splice(t,1);var i=this.activeCameras.indexOf(e);return-1!==i&&this.activeCameras.splice(i,1),this.activeCamera===e&&(0<this.cameras.length?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},x.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},x.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},x.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},x.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),t},x.prototype.removeMaterial=function(e){var t=this.materials.indexOf(e);return-1!==t&&this.materials.splice(t,1),this.onMaterialRemovedObservable.notifyObservers(e),t},x.prototype.removeActionManager=function(e){var t=this.actionManagers.indexOf(e);return-1!==t&&this.actionManagers.splice(t,1),t},x.prototype.removeTexture=function(e){var t=this.textures.indexOf(e);return-1!==t&&this.textures.splice(t,1),this.onTextureRemovedObservable.notifyObservers(e),t},x.prototype.addLight=function(e){this.lights.push(e),this.sortLightsByPriority();for(var t=0,i=this.meshes;t<i.length;t++){var r=i[t];-1===r._lightSources.indexOf(e)&&(r._lightSources.push(e),r._resyncLightSources())}this.onNewLightAddedObservable.notifyObservers(e)},x.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(E.Light.CompareLightsPriority)},x.prototype.addCamera=function(e){this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e)},x.prototype.addSkeleton=function(e){this.skeletons.push(e)},x.prototype.addParticleSystem=function(e){this.particleSystems.push(e)},x.prototype.addAnimation=function(e){this.animations.push(e)},x.prototype.addAnimationGroup=function(e){this.animationGroups.push(e)},x.prototype.addMultiMaterial=function(e){this.multiMaterials.push(e)},x.prototype.addMaterial=function(e){this.materials.push(e),this.onNewMaterialAddedObservable.notifyObservers(e)},x.prototype.addMorphTargetManager=function(e){this.morphTargetManagers.push(e)},x.prototype.addGeometry=function(e){this.geometries.push(e)},x.prototype.addActionManager=function(e){this.actionManagers.push(e)},x.prototype.addTexture=function(e){this.textures.push(e),this.onNewTextureAddedObservable.notifyObservers(e)},x.prototype.switchActiveCamera=function(e,t){void 0===t&&(t=!0);var i=this._engine.getRenderingCanvas();i&&(this.activeCamera&&this.activeCamera.detachControl(i),this.activeCamera=e,t&&e.attachControl(i))},x.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?this.activeCamera=t:null},x.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?this.activeCamera=t:null},x.prototype.getAnimationGroupByName=function(e){for(var t=0;t<this.animationGroups.length;t++)if(this.animationGroups[t].name===e)return this.animationGroups[t];return null},x.prototype.getMaterialByID=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].id===e)return this.materials[t];return null},x.prototype.getMaterialByName=function(e){for(var t=0;t<this.materials.length;t++)if(this.materials[t].name===e)return this.materials[t];return null},x.prototype.getCameraByID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].id===e)return this.cameras[t];return null},x.prototype.getCameraByUniqueID=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].uniqueId===e)return this.cameras[t];return null},x.prototype.getCameraByName=function(e){for(var t=0;t<this.cameras.length;t++)if(this.cameras[t].name===e)return this.cameras[t];return null},x.prototype.getBoneByID=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].id===e)return i.bones[r];return null},x.prototype.getBoneByName=function(e){for(var t=0;t<this.skeletons.length;t++)for(var i=this.skeletons[t],r=0;r<i.bones.length;r++)if(i.bones[r].name===e)return i.bones[r];return null},x.prototype.getLightByName=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].name===e)return this.lights[t];return null},x.prototype.getLightByID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].id===e)return this.lights[t];return null},x.prototype.getLightByUniqueID=function(e){for(var t=0;t<this.lights.length;t++)if(this.lights[t].uniqueId===e)return this.lights[t];return null},x.prototype.getParticleSystemByID=function(e){for(var t=0;t<this.particleSystems.length;t++)if(this.particleSystems[t].id===e)return this.particleSystems[t];return null},x.prototype.getGeometryByID=function(e){for(var t=0;t<this.geometries.length;t++)if(this.geometries[t].id===e)return this.geometries[t];return null},x.prototype.pushGeometry=function(e,t){return!(!t&&this.getGeometryByID(e.id))&&(this.geometries.push(e),this.collisionCoordinator&&this.collisionCoordinator.onGeometryAdded(e),this.onNewGeometryAddedObservable.notifyObservers(e),!0)},x.prototype.removeGeometry=function(e){var t=this.geometries.indexOf(e);return-1<t&&(this.geometries.splice(t,1),this.collisionCoordinator&&this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},x.prototype.getGeometries=function(){return this.geometries},x.prototype.getMeshByID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].id===e)return this.meshes[t];return null},x.prototype.getMeshesByID=function(t){return this.meshes.filter((function(e){return e.id===t}))},x.prototype.getTransformNodeByID=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].id===e)return this.transformNodes[t];return null},x.prototype.getTransformNodesByID=function(t){return this.transformNodes.filter((function(e){return e.id===t}))},x.prototype.getMeshByUniqueID=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].uniqueId===e)return this.meshes[t];return null},x.prototype.getLastMeshByID=function(e){for(var t=this.meshes.length-1;0<=t;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},x.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;0<=t;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;0<=t;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;0<=t;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;0<=t;t--)if(this.lights[t].id===e)return this.lights[t];return null},x.prototype.getNodeByID=function(e){var t=this.getMeshByID(e);if(t)return t;var i=this.getLightByID(e);if(i)return i;var r=this.getCameraByID(e);return r||this.getBoneByID(e)},x.prototype.getNodeByName=function(e){var t=this.getMeshByName(e);if(t)return t;var i=this.getLightByName(e);if(i)return i;var r=this.getCameraByName(e);return r||this.getBoneByName(e)},x.prototype.getMeshByName=function(e){for(var t=0;t<this.meshes.length;t++)if(this.meshes[t].name===e)return this.meshes[t];return null},x.prototype.getTransformNodeByName=function(e){for(var t=0;t<this.transformNodes.length;t++)if(this.transformNodes[t].name===e)return this.transformNodes[t];return null},x.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;0<=t;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},x.prototype.getSkeletonById=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].id===e)return this.skeletons[t];return null},x.prototype.getSkeletonByName=function(e){for(var t=0;t<this.skeletons.length;t++)if(this.skeletons[t].name===e)return this.skeletons[t];return null},x.prototype.getMorphTargetManagerById=function(e){for(var t=0;t<this.morphTargetManagers.length;t++)if(this.morphTargetManagers[t].uniqueId===e)return this.morphTargetManagers[t];return null},x.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},Object.defineProperty(x.prototype,"uid",{get:function(){return this._uid||(this._uid=E.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),x.prototype.addExternalData=function(e,t){return this._externalData||(this._externalData=new E.StringDictionary),this._externalData.add(e,t)},x.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},x.prototype.getOrAddExternalDataWithFactory=function(e,t){return this._externalData||(this._externalData=new E.StringDictionary),this._externalData.getOrAddWithFactory(e,t)},x.prototype.removeExternalData=function(e){return this._externalData.remove(e)},x.prototype._evaluateSubMesh=function(e,t){if(this.dispatchAllSubMeshesOfActiveMeshes||t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){for(var i=0,r=this._evaluateSubMeshStage;i<r.length;i++){r[i].action(t,e)}var n=e.getMaterial();null!=n&&(n.hasRenderTargetTextures&&void 0!==n.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(n)&&(this._processedMaterials.push(n),this._renderTargets.concatWithNoDuplicate(n.getRenderTargetTextures())),this._activeIndices.addCount(e.indexCount,!1),this._renderingManager.dispatch(e,t,n))}},x.prototype.freeProcessedMaterials=function(){this._processedMaterials.dispose()},x.prototype.freeActiveMeshes=function(){if(this._activeMeshes.dispose(),this.activeCamera&&this.activeCamera._activeMeshes&&this.activeCamera._activeMeshes.dispose(),this.activeCameras)for(var e=0;e<this.activeCameras.length;e++){var t=this.activeCameras[e];t&&t._activeMeshes&&t._activeMeshes.dispose()}},x.prototype.freeRenderingGroups=function(){if(this._renderingManager&&this._renderingManager.freeRenderingGroups(),this.textures)for(var e=0;e<this.textures.length;e++){var t=this.textures[e];t&&t.renderList&&t.freeRenderingGroups()}},x.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},x.prototype.freezeActiveMeshes=function(){return this.activeCamera&&(this._frustumPlanes||this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0),this},x.prototype.unfreezeActiveMeshes=function(){return this._activeMeshesFrozen=!1,this},x.prototype._evaluateActiveMeshes=function(){if((!this._activeMeshesFrozen||!this._activeMeshes.length)&&this.activeCamera){this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this),this.activeCamera._activeMeshes.reset(),this._activeMeshes.reset(),this._renderingManager.reset(),this._processedMaterials.reset(),this._activeParticleSystems.reset(),this._activeSkeletons.reset(),this._softwareSkinnedMeshes.reset();for(var e=0,t=this._beforeEvaluateActiveMeshStage;e<t.length;e++){t[e].action()}for(var i=this.getActiveMeshCandidates(),r=i.length,n=0;n<r;n++){var o=i.data[n];if(!o.isBlocked&&(this._totalVertices.addCount(o.getTotalVertices(),!1),o.isReady()&&o.isEnabled())){o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers2(E.ActionManager.OnIntersectionEnterTrigger,E.ActionManager.OnIntersectionExitTrigger)&&this._meshesForIntersections.pushNoDuplicate(o);var s=o.getLOD(this.activeCamera);null!=s&&(o._preActivate(),o.isVisible&&0<o.visibility&&(o.alwaysSelectAsActiveMesh||0!=(o.layerMask&this.activeCamera.layerMask)&&o.isInFrustum(this._frustumPlanes))&&(this._activeMeshes.push(o),this.activeCamera._activeMeshes.push(o),o._activate(this._renderId),s!==o&&s._activate(this._renderId),this._activeMesh(o,s)))}}if(this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this),this.particlesEnabled){this.onBeforeParticlesRenderingObservable.notifyObservers(this);for(var a=0;a<this.particleSystems.length;a++){var l=this.particleSystems[a];if(l.isStarted()&&l.emitter){var c=l.emitter;c.position&&!c.isEnabled()||(this._activeParticleSystems.push(l),l.animate(),this._renderingManager.dispatchParticles(l))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},x.prototype._activeMesh=function(e,t){this._skeletonsEnabled&&null!==t.skeleton&&void 0!==t.skeleton&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t));for(var i=0,r=this._activeMeshStage;i<r.length;i++){r[i].action(e,t)}if(null!=t&&void 0!==t.subMeshes&&null!==t.subMeshes&&0<t.subMeshes.length)for(var n=this.getActiveSubMeshCandidates(t),o=n.length,s=0;s<o;s++){var a=n.data[s];this._evaluateSubMesh(a,t)}},x.prototype.updateTransformMatrix=function(e){this.activeCamera&&this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},x.prototype.updateAlternateTransformMatrix=function(e){this._setAlternateTransformMatrix(e.getViewMatrix(),e.getProjectionMatrix())},x.prototype._renderForCamera=function(e,t){if(!e||!e._skipRendering){var i=this._engine;if(this.activeCamera=e,!this.activeCamera)throw new Error("Active camera not set");i.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.updateTransformMatrix(),e._alternateCamera&&(this.updateAlternateTransformMatrix(e._alternateCamera),this._alternateRendering=!0),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var r=0;r<this._softwareSkinnedMeshes.length;r++){var n=this._softwareSkinnedMeshes.data[r];n.applySkeleton(n.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this),e.customRenderTargets&&0<e.customRenderTargets.length&&this._renderTargets.concatWithNoDuplicate(e.customRenderTargets),t&&t.customRenderTargets&&0<t.customRenderTargets.length&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets);for(var o=0,s=this._gatherActiveCameraRenderTargetsStage;o<s.length;o++){s[o].action(this._renderTargets)}if(this.renderTargetsEnabled){if(this._intermediateRendering=!0,0<this._renderTargets.length){E.Tools.StartPerformanceCounter("Render targets",0<this._renderTargets.length);for(var a=0;a<this._renderTargets.length;a++){var l=this._renderTargets.data[a];if(l._shouldRender()){this._renderId++;var c=l.activeCamera&&l.activeCamera!==this.activeCamera;l.render(c,this.dumpNextRenderTargets)}}E.Tools.EndPerformanceCounter("Render targets",0<this._renderTargets.length),this._renderId++}for(var h=0,u=this._cameraDrawRenderTargetStage;h<u.length;h++){u[h].action(this.activeCamera)}this._intermediateRendering=!1,i.restoreDefaultFramebuffer()}this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager&&this.postProcessManager._prepareFrame();for(var d=0,f=this._beforeCameraDrawStage;d<f.length;d++){f[d].action(this.activeCamera)}this.onBeforeDrawPhaseObservable.notifyObservers(this),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this);for(var p=0,m=this._afterCameraDrawStage;p<m.length;p++){m[p].action(this.activeCamera)}this.postProcessManager&&this.postProcessManager._finalizeFrame(e.isIntermediate),this._renderTargets.reset(),this._alternateRendering=!1,this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera)}},x.prototype._processSubCameras=function(e){if(e.cameraRigMode!==E.Camera.RIG_MODE_NONE){for(var t=0;t<e._rigCameras.length;t++)this._renderForCamera(e._rigCameras[t],e);this.activeCamera=e,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix())}else this._renderForCamera(e)},x.prototype._checkIntersections=function(){for(var e=0;e<this._meshesForIntersections.length;e++){var t=this._meshesForIntersections.data[e];if(t.actionManager)for(var i=0;i<t.actionManager.actions.length;i++){var r=t.actionManager.actions[i];if(r.trigger===E.ActionManager.OnIntersectionEnterTrigger||r.trigger===E.ActionManager.OnIntersectionExitTrigger){var n=r.getTriggerParameter(),o=n instanceof E.AbstractMesh?n:n.mesh,s=o.intersectsMesh(t,n.usePreciseIntersection),a=t._intersectionsInProgress.indexOf(o);s&&-1===a?r.trigger===E.ActionManager.OnIntersectionEnterTrigger?(r._executeCurrent(E.ActionEvent.CreateNew(t,void 0,o)),t._intersectionsInProgress.push(o)):r.trigger===E.ActionManager.OnIntersectionExitTrigger&&t._intersectionsInProgress.push(o):!s&&-1<a&&(r.trigger===E.ActionManager.OnIntersectionExitTrigger&&r._executeCurrent(E.ActionEvent.CreateNew(t,void 0,o)),t.actionManager.hasSpecificTrigger(E.ActionManager.OnIntersectionExitTrigger,(function(e){var t=e instanceof E.AbstractMesh?e:e.mesh;return o===t}))&&r.trigger!==E.ActionManager.OnIntersectionExitTrigger||t._intersectionsInProgress.splice(a,1))}}}},x.prototype._advancePhysicsEngineStep=function(e){},x.prototype.render=function(e){if(void 0===e&&(e=!0),!this.isDisposed){if(this._frameId++,this._registerTransientComponents(),this._activeParticles.fetchNewFrame(),this._totalVertices.fetchNewFrame(),this._activeIndices.fetchNewFrame(),this._activeBones.fetchNewFrame(),this._meshesForIntersections.reset(),this.resetCachedMaterial(),this.onBeforeAnimationsObservable.notifyObservers(this),this.actionManager&&this.actionManager.processTrigger(E.ActionManager.OnEveryFrameTrigger),this._engine.isDeterministicLockStep()){var t=Math.max(x.MinDeltaTime,Math.min(this._engine.getDeltaTime(),x.MaxDeltaTime))+this._timeAccumulator,i=this.getDeterministicFrameTime(),r=0,n=this._engine.getLockstepMaxSteps(),o=Math.floor(t/60);for(o=Math.min(o,n);this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=.06*i,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._advancePhysicsEngineStep(i),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,0<(t-=i)&&++r<o;);this._timeAccumulator=t<0?0:t}else{t=this.useConstantAnimationDeltaTime?16:Math.max(x.MinDeltaTime,Math.min(this._engine.getDeltaTime(),x.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._advancePhysicsEngineStep(t)}for(var s=0,a=this._beforeCameraUpdateStage;s<a.length;s++){a[s].action()}if(e)if(0<this.activeCameras.length)for(var l=0;l<this.activeCameras.length;l++){var c=this.activeCameras[l];if(c.update(),c.cameraRigMode!==E.Camera.RIG_MODE_NONE)for(var h=0;h<c._rigCameras.length;h++)c._rigCameras[h].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==E.Camera.RIG_MODE_NONE))for(h=0;h<this.activeCamera._rigCameras.length;h++)this.activeCamera._rigCameras[h].update();this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var u=this.getEngine(),d=this.activeCamera;if(this.renderTargetsEnabled){E.Tools.StartPerformanceCounter("Custom render targets",0<this.customRenderTargets.length),this._intermediateRendering=!0;for(var f=0;f<this.customRenderTargets.length;f++){var p=this.customRenderTargets[f];if(p._shouldRender()){if(this._renderId++,this.activeCamera=p.activeCamera||this.activeCamera,!this.activeCamera)throw new Error("Active camera not set");u.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),p.render(d!==this.activeCamera,this.dumpNextRenderTargets)}}E.Tools.EndPerformanceCounter("Custom render targets",0<this.customRenderTargets.length),this._intermediateRendering=!1,this._renderId++}0<this.customRenderTargets.length&&u.restoreDefaultFramebuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.activeCamera=d;for(var m=0,_=this._beforeClearStage;m<_.length;m++){_[m].action()}(this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil);for(var g=0,v=this._gatherRenderTargetsStage;g<v.length;g++){v[g].action(this._renderTargets)}if(0<this.activeCameras.length)for(l=0;l<this.activeCameras.length;l++)0<l&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[l]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections();for(var y=0,b=this._afterRenderStage;y<b.length;y++){b[y].action()}if(this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this),this._toBeDisposed.length){for(h=0;h<this._toBeDisposed.length;h++){var T=this._toBeDisposed[h];T&&T.dispose()}this._toBeDisposed=[]}this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)}},x.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},x.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},x.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this.morphTargetManagers=[],this._transientComponents=[],this._isReadyForMeshStage.clear(),this._beforeEvaluateActiveMeshStage.clear(),this._evaluateSubMeshStage.clear(),this._activeMeshStage.clear(),this._cameraDrawRenderTargetStage.clear(),this._beforeCameraDrawStage.clear(),this._beforeRenderingGroupDrawStage.clear(),this._beforeRenderingMeshStage.clear(),this._afterRenderingMeshStage.clear(),this._afterRenderingGroupDrawStage.clear(),this._afterCameraDrawStage.clear(),this._afterRenderStage.clear(),this._beforeCameraUpdateStage.clear(),this._beforeClearStage.clear(),this._gatherRenderTargetsStage.clear(),this._gatherActiveCameraRenderTargetsStage.clear(),this._pointerMoveStage.clear(),this._pointerDownStage.clear(),this._pointerUpStage.clear();for(var e=0,t=this._components;e<t.length;e++){t[e].dispose()}this.importedMeshesFiles=new Array,this.stopAllAnimations(),this.resetCachedMaterial(),this.activeCamera&&(this.activeCamera._activeMeshes.dispose(),this.activeCamera=null),this._activeMeshes.dispose(),this._renderingManager.dispose(),this._processedMaterials.dispose(),this._activeParticleSystems.dispose(),this._activeSkeletons.dispose(),this._softwareSkinnedMeshes.dispose(),this._renderTargets.dispose(),this._registeredForLateAnimationBindings.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed=[];for(var i=0,r=this._activeRequests;i<r.length;i++){r[i].abort()}this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderTargetsRenderObservable.clear(),this.onAfterRenderTargetsRenderObservable.clear(),this.onAfterStepObservable.clear(),this.onBeforeStepObservable.clear(),this.onBeforeActiveMeshesEvaluationObservable.clear(),this.onAfterActiveMeshesEvaluationObservable.clear(),this.onBeforeParticlesRenderingObservable.clear(),this.onAfterParticlesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.onBeforeRenderingGroupObservable.clear(),this.onAfterRenderingGroupObservable.clear(),this.onMeshImportedObservable.clear(),this.onBeforeCameraRenderObservable.clear(),this.onAfterCameraRenderObservable.clear(),this.onReadyObservable.clear(),this.onNewCameraAddedObservable.clear(),this.onCameraRemovedObservable.clear(),this.onNewLightAddedObservable.clear(),this.onLightRemovedObservable.clear(),this.onNewGeometryAddedObservable.clear(),this.onGeometryRemovedObservable.clear(),this.onNewTransformNodeAddedObservable.clear(),this.onTransformNodeRemovedObservable.clear(),this.onNewMeshAddedObservable.clear(),this.onMeshRemovedObservable.clear(),this.onNewMaterialAddedObservable.clear(),this.onMaterialRemovedObservable.clear(),this.onNewTextureAddedObservable.clear(),this.onTextureRemovedObservable.clear(),this.onPrePointerObservable.clear(),this.onPointerObservable.clear(),this.onPreKeyboardObservable.clear(),this.onKeyboardObservable.clear(),this.detachControl();var n,o=this._engine.getRenderingCanvas();if(o)for(n=0;n<this.cameras.length;n++)this.cameras[n].detachControl(o);for(;this.animationGroups.length;)this.animationGroups[0].dispose();for(;this.lights.length;)this.lights[0].dispose();for(;this.meshes.length;)this.meshes[0].dispose(!0);for(;this.transformNodes.length;)this.removeTransformNode(this.transformNodes[0]);for(;this.cameras.length;)this.cameras[0].dispose();for(this.defaultMaterial&&this.defaultMaterial.dispose();this.multiMaterials.length;)this.multiMaterials[0].dispose();for(;this.materials.length;)this.materials[0].dispose();for(;this.particleSystems.length;)this.particleSystems[0].dispose();for(;this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this._alternateSceneUbo&&this._alternateSceneUbo.dispose(),this.postProcessManager.dispose(),-1<(n=this._engine.scenes.indexOf(this))&&this._engine.scenes.splice(n,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(x.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),x.prototype.clearCachedVertexData=function(){for(var e=0;e<this.meshes.length;e++){var t=this.meshes[e].geometry;if(t)for(var i in t._indices=[],t._vertexBuffers)t._vertexBuffers.hasOwnProperty(i)&&(t._vertexBuffers[i]._buffer._data=null)}},x.prototype.cleanCachedTextureBuffer=function(){for(var e=0,t=this.textures;e<t.length;e++){var i=t[e];i._buffer&&(i._buffer=null)}},x.prototype.getWorldExtends=function(e){var n=new E.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),o=new E.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return e=e||function(){return!0},this.meshes.filter(e).forEach((function(e){if(e.computeWorldMatrix(!0),e.subMeshes&&0!==e.subMeshes.length&&!e.infiniteDistance){var t=e.getBoundingInfo(),i=t.boundingBox.minimumWorld,r=t.boundingBox.maximumWorld;E.Tools.CheckExtends(i,n,o),E.Tools.CheckExtends(r,n,o)}})),{min:n,max:o}},x.prototype.createPickingRay=function(e,t,i,r,n){void 0===n&&(n=!1);var o=E.Ray.Zero();return this.createPickingRayToRef(e,t,i,o,r,n),o},x.prototype.createPickingRayToRef=function(e,t,i,r,n,o){void 0===o&&(o=!1);var s=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var a=n.viewport.toGlobal(s.getRenderWidth(),s.getRenderHeight());return e=e/this._engine.getHardwareScalingLevel()-a.x,t=t/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-a.y-a.height),r.update(e,t,a.width,a.height,i||E.Matrix.Identity(),o?E.Matrix.Identity():n.getViewMatrix(),n.getProjectionMatrix()),this},x.prototype.createPickingRayInCameraSpace=function(e,t,i){var r=E.Ray.Zero();return this.createPickingRayInCameraSpaceToRef(e,t,r,i),r},x.prototype.createPickingRayInCameraSpaceToRef=function(e,t,i,r){if(!E.PickingInfo)return this;var n=this._engine;if(!r){if(!this.activeCamera)throw new Error("Active camera not set");r=this.activeCamera}var o=r.viewport.toGlobal(n.getRenderWidth(),n.getRenderHeight()),s=E.Matrix.Identity();return e=e/this._engine.getHardwareScalingLevel()-o.x,t=t/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-o.y-o.height),i.update(e,t,o.width,o.height,s,s,r.getProjectionMatrix()),this},x.prototype._internalPick=function(e,t,i){if(!E.PickingInfo)return null;for(var r=null,n=0;n<this.meshes.length;n++){var o=this.meshes[n];if(t){if(!t(o))continue}else if(!o.isEnabled()||!o.isVisible||!o.isPickable)continue;var s=e(o.getWorldMatrix()),a=o.intersects(s,i);if(a&&a.hit&&((i||null==r||!(a.distance>=r.distance))&&(r=a,i)))break}return r||new E.PickingInfo},x.prototype._internalMultiPick=function(e,t){if(!E.PickingInfo)return null;for(var i=new Array,r=0;r<this.meshes.length;r++){var n=this.meshes[r];if(t){if(!t(n))continue}else if(!n.isEnabled()||!n.isVisible||!n.isPickable)continue;var o=e(n.getWorldMatrix()),s=n.intersects(o,!1);s&&s.hit&&i.push(s)}return i},x.prototype.pick=function(t,i,e,r,n){var o=this;if(!E.PickingInfo)return null;var s=this._internalPick((function(e){return o.createPickingRayToRef(t,i,e,o._tempPickingRay,n||null),o._tempPickingRay}),e,r);return s&&(s.ray=this.createPickingRay(t,i,E.Matrix.Identity(),n||null)),s},x.prototype.pickWithRay=function(t,e,i){var r=this,n=this._internalPick((function(e){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=E.Matrix.Identity()),e.invertToRef(r._pickWithRayInverseMatrix),r._cachedRayForTransform||(r._cachedRayForTransform=E.Ray.Zero()),E.Ray.TransformToRef(t,r._pickWithRayInverseMatrix,r._cachedRayForTransform),r._cachedRayForTransform}),e,i);return n&&(n.ray=t),n},x.prototype.multiPick=function(t,i,e,r){var n=this;return this._internalMultiPick((function(e){return n.createPickingRay(t,i,e,r||null)}),e)},x.prototype.multiPickWithRay=function(t,e){var i=this;return this._internalMultiPick((function(e){return i._pickWithRayInverseMatrix||(i._pickWithRayInverseMatrix=E.Matrix.Identity()),e.invertToRef(i._pickWithRayInverseMatrix),i._cachedRayForTransform||(i._cachedRayForTransform=E.Ray.Zero()),E.Ray.TransformToRef(t,i._pickWithRayInverseMatrix,i._cachedRayForTransform),i._cachedRayForTransform}),e)},x.prototype.setPointerOverMesh=function(e){this._pointerOverMesh!==e&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(E.ActionManager.OnPointerOutTrigger,E.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=e,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(E.ActionManager.OnPointerOverTrigger,E.ActionEvent.CreateNew(this._pointerOverMesh)))},x.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},x.prototype._rebuildGeometries=function(){for(var e=0,t=this.geometries;e<t.length;e++){t[e]._rebuild()}for(var i=0,r=this.meshes;i<r.length;i++){r[i]._rebuild()}this.postProcessManager&&this.postProcessManager._rebuild();for(var n=0,o=this._components;n<o.length;n++){o[n].rebuild()}for(var s=0,a=this.particleSystems;s<a.length;s++){a[s].rebuild()}},x.prototype._rebuildTextures=function(){for(var e=0,t=this.textures;e<t.length;e++){t[e]._rebuild()}this.markAllMaterialsAsDirty(E.Material.TextureDirtyFlag)},x.prototype._getByTags=function(e,t,i){if(void 0===t)return e;var r=[];for(var n in i=i||function(e){},e){var o=e[n];E.Tags&&E.Tags.MatchesQuery(o,t)&&(r.push(o),i(o))}return r},x.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},x.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},x.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},x.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},x.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},x.prototype.setRenderingAutoClearDepthStencil=function(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)},x.prototype.getAutoClearDepthStencilSetup=function(e){return this._renderingManager.getAutoClearDepthStencilSetup(e)},Object.defineProperty(x.prototype,"blockMaterialDirtyMechanism",{get:function(){return this._blockMaterialDirtyMechanism},set:function(e){this._blockMaterialDirtyMechanism!==e&&((this._blockMaterialDirtyMechanism=e)||this.markAllMaterialsAsDirty(E.Material.AllDirtyFlag))},enumerable:!0,configurable:!0}),x.prototype.markAllMaterialsAsDirty=function(e,t){if(!this._blockMaterialDirtyMechanism)for(var i=0,r=this.materials;i<r.length;i++){var n=r[i];t&&!t(n)||n.markAsDirty(e)}},x.prototype._loadFile=function(e,t,i,r,n,o){var s=this,a=E.Tools.LoadFile(e,t,i,r?this.database:void 0,n,o);return this._activeRequests.push(a),a.onCompleteObservable.add((function(e){s._activeRequests.splice(s._activeRequests.indexOf(e),1)})),a},x.prototype._loadFileAsync=function(e,r,n){var o=this;return new Promise(function(t,i){o._loadFile(e,(function(e){t(e)}),void 0,r,n,(function(e,t){i(t)}))})},x._uniqueIdCounter=0,x.FOGMODE_NONE=0,x.FOGMODE_EXP=1,x.FOGMODE_EXP2=2,x.FOGMODE_LINEAR=3,x.MinDeltaTime=1,x.MaxDeltaTime=1e3,x.DragMovementThreshold=10,x.LongPressDelay=500,x.DoubleClickDelay=300,x.ExclusiveDoubleClickMode=!1,x})(E.AbstractScene);E.Scene=t})($a||($a={})),(function(r){var n=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t})(r.AbstractScene);r.KeepAssets=n;var e=(function(i){function e(e){var t=i.call(this)||this;return t.scene=e,t}return T(e,i),e.prototype.addAllToScene=function(){var t=this;this.cameras.forEach((function(e){t.scene.addCamera(e)})),this.lights.forEach((function(e){t.scene.addLight(e)})),this.meshes.forEach((function(e){t.scene.addMesh(e)})),this.skeletons.forEach((function(e){t.scene.addSkeleton(e)})),this.animations.forEach((function(e){t.scene.addAnimation(e)})),this.animationGroups.forEach((function(e){t.scene.addAnimationGroup(e)})),this.multiMaterials.forEach((function(e){t.scene.addMultiMaterial(e)})),this.materials.forEach((function(e){t.scene.addMaterial(e)})),this.morphTargetManagers.forEach((function(e){t.scene.addMorphTargetManager(e)})),this.geometries.forEach((function(e){t.scene.addGeometry(e)})),this.transformNodes.forEach((function(e){t.scene.addTransformNode(e)})),this.actionManagers.forEach((function(e){t.scene.addActionManager(e)})),this.textures.forEach((function(e){t.scene.addTexture(e)}));for(var e=0,i=this.scene._serializableComponents;e<i.length;e++){i[e].addFromContainer(this.scene)}},e.prototype.removeAllFromScene=function(){var t=this;this.cameras.forEach((function(e){t.scene.removeCamera(e)})),this.lights.forEach((function(e){t.scene.removeLight(e)})),this.meshes.forEach((function(e){t.scene.removeMesh(e)})),this.skeletons.forEach((function(e){t.scene.removeSkeleton(e)})),this.animations.forEach((function(e){t.scene.removeAnimation(e)})),this.animationGroups.forEach((function(e){t.scene.removeAnimationGroup(e)})),this.multiMaterials.forEach((function(e){t.scene.removeMultiMaterial(e)})),this.materials.forEach((function(e){t.scene.removeMaterial(e)})),this.morphTargetManagers.forEach((function(e){t.scene.removeMorphTargetManager(e)})),this.geometries.forEach((function(e){t.scene.removeGeometry(e)})),this.transformNodes.forEach((function(e){t.scene.removeTransformNode(e)})),this.actionManagers.forEach((function(e){t.scene.removeActionManager(e)})),this.textures.forEach((function(e){t.scene.removeTexture(e)}));for(var e=0,i=this.scene._serializableComponents;e<i.length;e++){i[e].removeFromContainer(this.scene)}},e.prototype._moveAssets=function(e,t,i){if(e)for(var r=0,n=e;r<n.length;r++){var o=n[r],s=!0;if(i)for(var a=0,l=i;a<l.length;a++){if(o===l[a]){s=!1;break}}s&&t.push(o)}},e.prototype.moveAllFromScene=function(e){for(var t in void 0===e&&(e=new n),this)this.hasOwnProperty(t)&&(this[t]=this[t]||[],this._moveAssets(this.scene[t],this[t],e[t]));this.removeAllFromScene()},e.prototype.createRootMesh=function(){var t=new r.Mesh("assetContainerRootMesh",this.scene);return this.meshes.forEach((function(e){e.parent||t.addChild(e)})),this.meshes.unshift(t),t},e})(r.AbstractScene);r.AssetContainer=e})($a||($a={})),Y=$a||($a={}),K=(function(){function e(e,t,i,r,n,o,s){void 0===r&&(r=0),void 0===n&&(n=!1),void 0===o&&(o=!1),void 0===s&&(s=!1),e instanceof Y.Mesh?this._engine=e.getScene().getEngine():this._engine=e,this._updatable=i,this._instanced=o,this._data=t,this.byteStride=s?r:r*Float32Array.BYTES_PER_ELEMENT,n||this.create()}return e.prototype.createVertexBuffer=function(e,t,i,r,n,o){void 0===o&&(o=!1);var s=o?t:t*Float32Array.BYTES_PER_ELEMENT,a=r?o?r:r*Float32Array.BYTES_PER_ELEMENT:this.byteStride;return new Y.VertexBuffer(this._engine,this,e,this._updatable,!0,a,void 0===n?this._instanced:n,s,i,void 0,void 0,!0)},e.prototype.isUpdatable=function(){return this._updatable},e.prototype.getData=function(){return this._data},e.prototype.getBuffer=function(){return this._buffer},e.prototype.getStrideSize=function(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT},e.prototype.create=function(e){void 0===e&&(e=null),!e&&this._buffer||(e=e||this._data)&&(this._buffer?this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e),this._data=e):this._updatable?(this._buffer=this._engine.createDynamicVertexBuffer(e),this._data=e):this._buffer=this._engine.createVertexBuffer(e))},e.prototype._rebuild=function(){this._buffer=null,this.create(this._data)},e.prototype.update=function(e){this.create(e)},e.prototype.updateDirectly=function(e,t,i,r){void 0===r&&(r=!1),this._buffer&&this._updatable&&(this._engine.updateDynamicVertexBuffer(this._buffer,e,r?t:t*Float32Array.BYTES_PER_ELEMENT,i?i*this.byteStride:void 0),this._data=null)},e.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},e})(),Y.Buffer=K,Q=$a||($a={}),Z=(function(){function m(e,t,i,r,n,o,s,a,l,c,h,u){if(void 0===h&&(h=!1),void 0===u&&(u=!1),t instanceof Q.Buffer?(this._buffer=t,this._ownsBuffer=!1):(this._buffer=new Q.Buffer(e,t,r,o,n,s,u),this._ownsBuffer=!0),this._kind=i,null==c){var d=this.getData();this.type=m.FLOAT,d instanceof Int8Array?this.type=m.BYTE:d instanceof Uint8Array?this.type=m.UNSIGNED_BYTE:d instanceof Int16Array?this.type=m.SHORT:d instanceof Uint16Array?this.type=m.UNSIGNED_SHORT:d instanceof Int32Array?this.type=m.INT:d instanceof Uint32Array&&(this.type=m.UNSIGNED_INT)}else this.type=c;var f=m.GetTypeByteLength(this.type);u?(this._size=l||(o?o/f:m.DeduceStride(i)),this.byteStride=o||this._buffer.byteStride||this._size*f,this.byteOffset=a||0):(this._size=l||o||m.DeduceStride(i),this.byteStride=o?o*f:this._buffer.byteStride||this._size*f,this.byteOffset=(a||0)*f),this.normalized=h,this._instanced=void 0!==s&&s,this._instanceDivisor=s?1:0}return Object.defineProperty(m.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(e){this._instanceDivisor=e,this._instanced=0!=e},enumerable:!0,configurable:!0}),m.prototype._rebuild=function(){this._buffer&&this._buffer._rebuild()},m.prototype.getKind=function(){return this._kind},m.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},m.prototype.getData=function(){return this._buffer.getData()},m.prototype.getBuffer=function(){return this._buffer.getBuffer()},m.prototype.getStrideSize=function(){return this.byteStride/m.GetTypeByteLength(this.type)},m.prototype.getOffset=function(){return this.byteOffset/m.GetTypeByteLength(this.type)},m.prototype.getSize=function(){return this._size},m.prototype.getIsInstanced=function(){return this._instanced},m.prototype.getInstanceDivisor=function(){return this._instanceDivisor},m.prototype.create=function(e){this._buffer.create(e)},m.prototype.update=function(e){this._buffer.update(e)},m.prototype.updateDirectly=function(e,t,i){void 0===i&&(i=!1),this._buffer.updateDirectly(e,t,void 0,i)},m.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},m.prototype.forEach=function(e,t){m.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,t)},m.DeduceStride=function(e){switch(e){case m.UVKind:case m.UV2Kind:case m.UV3Kind:case m.UV4Kind:case m.UV5Kind:case m.UV6Kind:return 2;case m.NormalKind:case m.PositionKind:return 3;case m.ColorKind:case m.MatricesIndicesKind:case m.MatricesIndicesExtraKind:case m.MatricesWeightsKind:case m.MatricesWeightsExtraKind:case m.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}},m.GetTypeByteLength=function(e){switch(e){case m.BYTE:case m.UNSIGNED_BYTE:return 1;case m.SHORT:case m.UNSIGNED_SHORT:return 2;case m.INT:case m.FLOAT:return 4;default:throw new Error("Invalid type '"+e+"'")}},m.ForEach=function(e,t,i,r,n,o,s,a){if(e instanceof Array)for(var l=t/4,c=i/4,h=0;h<o;h+=r){for(var u=0;u<r;u++)a(e[l+u],h+u);l+=c}else{var d=e instanceof ArrayBuffer?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),f=m.GetTypeByteLength(n);for(h=0;h<o;h+=r){var p=t;for(u=0;u<r;u++){a(m._GetFloatValue(d,n,p,s),h+u),p+=f}t+=i}}},m._GetFloatValue=function(e,t,i,r){switch(t){case m.BYTE:var n=e.getInt8(i);return r&&(n=Math.max(n/127,-1)),n;case m.UNSIGNED_BYTE:n=e.getUint8(i);return r&&(n/=255),n;case m.SHORT:n=e.getInt16(i,!0);return r&&(n=Math.max(n/16383,-1)),n;case m.UNSIGNED_SHORT:n=e.getUint16(i,!0);return r&&(n/=65535),n;case m.FLOAT:return e.getFloat32(i,!0);default:throw new Error("Invalid component type "+t)}},m.BYTE=5120,m.UNSIGNED_BYTE=5121,m.SHORT=5122,m.UNSIGNED_SHORT=5123,m.INT=5124,m.UNSIGNED_INT=5125,m.FLOAT=5126,m.PositionKind="position",m.NormalKind="normal",m.TangentKind="tangent",m.UVKind="uv",m.UV2Kind="uv2",m.UV3Kind="uv3",m.UV4Kind="uv4",m.UV5Kind="uv5",m.UV6Kind="uv6",m.ColorKind="color",m.MatricesIndicesKind="matricesIndices",m.MatricesWeightsKind="matricesWeights",m.MatricesIndicesExtraKind="matricesIndicesExtra",m.MatricesWeightsExtraKind="matricesWeightsExtra",m})(),Q.VertexBuffer=Z,q=function(){this.previous=null,this.next=null},($a||($a={})).DummyInternalTextureTracker=q,J=$a||($a={}),$=(function(){function o(e,t){this.onLoadedObservable=new J.Observable,this.previous=null,this.next=null,this._initialSlot=-1,this._designatedSlot=-1,this._dataSource=o.DATASOURCE_UNKNOWN,this._comparisonFunction=0,this._sphericalPolynomial=null,this._lodGenerationScale=0,this._lodGenerationOffset=0,this._isRGBD=!1,this._references=1,this._engine=e,this._dataSource=t,this._webGLTexture=e._createTexture()}return o.prototype.getEngine=function(){return this._engine},Object.defineProperty(o.prototype,"dataSource",{get:function(){return this._dataSource},enumerable:!0,configurable:!0}),o.prototype.incrementReferences=function(){this._references++},o.prototype.updateSize=function(e,t,i){void 0===i&&(i=1),this.width=e,this.height=t,this.depth=i,this.baseWidth=e,this.baseHeight=t,this.baseDepth=i,this._size=e*t*i},o.prototype._rebuild=function(){var e,t=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this._dataSource){case o.DATASOURCE_TEMP:return;case o.DATASOURCE_URL:return void(e=this._engine.createTexture(this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(function(){t.isReady=!0}),null,this._buffer,void 0,this.format))._swapAndDie(this);case o.DATASOURCE_RAW:return(e=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case o.DATASOURCE_RAW3D:return(e=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case o.DATASOURCE_DYNAMIC:return void(e=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode))._swapAndDie(this);case o.DATASOURCE_RENDERTARGET:var i=new J.RenderTargetCreationOptions;if(i.generateDepthBuffer=this._generateDepthBuffer,i.generateMipMaps=this.generateMipMaps,i.generateStencilBuffer=this._generateStencilBuffer,i.samplingMode=this.samplingMode,i.type=this.type,this.isCube)e=this._engine.createRenderTargetCubeTexture(this.width,i);else{var r={width:this.width,height:this.height};e=this._engine.createRenderTargetTexture(r,i)}return e._swapAndDie(this),void(this.isReady=!0);case o.DATASOURCE_DEPTHTEXTURE:var n={bilinearFiltering:this.samplingMode!==J.Texture.BILINEAR_SAMPLINGMODE,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube};return(e=this._engine.createDepthStencilTexture({width:this.width,height:this.height},n))._swapAndDie(this),void(this.isReady=!0);case o.DATASOURCE_CUBE:return void(e=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(function(){t.isReady=!0}),null,this.format,this._extension))._swapAndDie(this);case o.DATASOURCE_CUBERAW:return(e=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression))._swapAndDie(this),void(this.isReady=!0);case o.DATASOURCE_CUBERAW_RGBD:return e=this._engine.createRawCubeTexture(null,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),J.RawCubeTexture._UpdateRGBDAsync(e,this._bufferViewArrayArray,this._sphericalPolynomial,this._lodGenerationScale,this._lodGenerationOffset).then((function(){t.isReady=!0})),void e._swapAndDie(this);case o.DATASOURCE_CUBEPREFILTERED:return void((e=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(function(e){e&&e._swapAndDie(t),t.isReady=!0}),null,this.format,this._extension))._sphericalPolynomial=this._sphericalPolynomial)}},o.prototype._swapAndDie=function(e){e._webGLTexture=this._webGLTexture,this._framebuffer&&(e._framebuffer=this._framebuffer),this._depthStencilBuffer&&(e._depthStencilBuffer=this._depthStencilBuffer),this._lodTextureHigh&&(e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureHigh=this._lodTextureHigh),this._lodTextureMid&&(e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureMid=this._lodTextureMid),this._lodTextureLow&&(e._lodTextureLow&&e._lodTextureLow.dispose(),e._lodTextureLow=this._lodTextureLow);var t=this._engine.getLoadedTexturesCache(),i=t.indexOf(this);-1!==i&&t.splice(i,1)},o.prototype.dispose=function(){this._webGLTexture&&(this._references--,0===this._references&&(this._engine._releaseTexture(this),this._webGLTexture=null,this.previous=null,this.next=null))},o.DATASOURCE_UNKNOWN=0,o.DATASOURCE_URL=1,o.DATASOURCE_TEMP=2,o.DATASOURCE_RAW=3,o.DATASOURCE_DYNAMIC=4,o.DATASOURCE_RENDERTARGET=5,o.DATASOURCE_MULTIRENDERTARGET=6,o.DATASOURCE_CUBE=7,o.DATASOURCE_CUBERAW=8,o.DATASOURCE_CUBEPREFILTERED=9,o.DATASOURCE_RAW3D=10,o.DATASOURCE_DEPTHTEXTURE=11,o.DATASOURCE_CUBERAW_RGBD=12,o})(),J.InternalTexture=$,ee=$a||($a={}),te=(function(){function t(e){this._hasAlpha=!1,this.getAlphaFromRGB=!1,this.level=1,this.coordinatesIndex=0,this._coordinatesMode=ee.Texture.EXPLICIT_MODE,this.wrapU=ee.Texture.WRAP_ADDRESSMODE,this.wrapV=ee.Texture.WRAP_ADDRESSMODE,this.wrapR=ee.Texture.WRAP_ADDRESSMODE,this.anisotropicFilteringLevel=t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL,this.isCube=!1,this.is3D=!1,this.gammaSpace=!0,this.invertZ=!1,this.lodLevelInAlpha=!1,this.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new ee.Observable,this.delayLoadState=ee.Engine.DELAYLOADSTATE_NONE,this._cachedSize=ee.Size.Zero(),this._scene=e||ee.Engine.LastCreatedScene,this._scene&&(this._scene.textures.push(this),this._scene.onNewTextureAddedObservable.notifyObservers(this)),this._uid=null}return Object.defineProperty(t.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(e){this._hasAlpha!==e&&(this._hasAlpha=e,this._scene&&this._scene.markAllMaterialsAsDirty(ee.Material.TextureDirtyFlag|ee.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(e){this._coordinatesMode!==e&&(this._coordinatesMode=e,this._scene&&this._scene.markAllMaterialsAsDirty(ee.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isRGBD",{get:function(){return null!=this._texture&&this._texture._isRGBD},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lodGenerationOffset",{get:function(){return this._texture?this._texture._lodGenerationOffset:0},set:function(e){this._texture&&(this._texture._lodGenerationOffset=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"lodGenerationScale",{get:function(){return this._texture?this._texture._lodGenerationScale:0},set:function(e){this._texture&&(this._texture._lodGenerationScale=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=ee.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),t.prototype.toString=function(){return this.name},t.prototype.getClassName=function(){return"BaseTexture"},Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isBlocking",{get:function(){return!0},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getTextureMatrix=function(){return ee.Matrix.IdentityReadOnly},t.prototype.getReflectionTextureMatrix=function(){return ee.Matrix.IdentityReadOnly},t.prototype.getInternalTexture=function(){return this._texture},t.prototype.isReadyOrNotBlocking=function(){return!this.isBlocking||this.isReady()},t.prototype.isReady=function(){return this.delayLoadState===ee.Engine.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},t.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},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new ee.Size(this._texture._size,this._texture._size):new ee.Size(this._texture.baseWidth,this._texture.baseHeight):ee.Size.Zero()},t.prototype.scale=function(e){},Object.defineProperty(t.prototype,"canRescale",{get:function(){return!1},enumerable:!0,configurable:!0}),t.prototype._getFromCache=function(e,t,i){if(!this._scene)return null;for(var r=this._scene.getEngine().getLoadedTexturesCache(),n=0;n<r.length;n++){var o=r[n];if(o.url===e&&o.generateMipMaps===!t&&(!i||i===o.samplingMode))return o.incrementReferences(),o}return null},t.prototype._rebuild=function(){},t.prototype.delayLoad=function(){},t.prototype.clone=function(){return null},Object.defineProperty(t.prototype,"textureType",{get:function(){return this._texture&&void 0!==this._texture.type?this._texture.type:ee.Engine.TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"textureFormat",{get:function(){return this._texture&&void 0!==this._texture.format?this._texture.format:ee.Engine.TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),t.prototype.readPixels=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=null),!this._texture)return null;var r=this.getSize(),n=r.width,o=r.height,s=this.getScene();if(!s)return null;var a=s.getEngine();return 0!=t&&(n/=Math.pow(2,t),o/=Math.pow(2,t),n=Math.round(n),o=Math.round(o)),this._texture.isCube?a._readTexturePixels(this._texture,n,o,e,t,i):a._readTexturePixels(this._texture,n,o,-1,t,i)},t.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},Object.defineProperty(t.prototype,"sphericalPolynomial",{get:function(){return this._texture&&ee.CubeMapToSphericalPolynomialTools&&this.isReady()?(this._texture._sphericalPolynomial||(this._texture._sphericalPolynomial=ee.CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial(this)),this._texture._sphericalPolynomial):null},set:function(e){this._texture&&(this._texture._sphericalPolynomial=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureHigh",{get:function(){return this._texture?this._texture._lodTextureHigh:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureMid",{get:function(){return this._texture?this._texture._lodTextureMid:null},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"_lodTextureLow",{get:function(){return this._texture?this._texture._lodTextureLow:null},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){if(this._scene){this._scene.stopAnimation(this),this._scene._removePendingData(this);var e=this._scene.textures.indexOf(this);0<=e&&this._scene.textures.splice(e,1),this._scene.onTextureRemovedObservable.notifyObservers(this),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())}},t.prototype.serialize=function(){if(!this.name)return null;var e=ee.SerializationHelper.Serialize(this);return ee.Animation.AppendSerializedAnimations(this,e),e},t.WhenAllReady=function(t,i){var r=t.length;if(0!==r)for(var n,o,e=function(){if((n=t[s]).isReady())0==--r&&i();else{o=n.onLoadObservable;var e=function(){o.removeCallback(e),0==--r&&i()};o.add(e)}},s=0;s<t.length;s++)e();else i()},t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,b([ee.serialize()],t.prototype,"name",void 0),b([ee.serialize("hasAlpha")],t.prototype,"_hasAlpha",void 0),b([ee.serialize()],t.prototype,"getAlphaFromRGB",void 0),b([ee.serialize()],t.prototype,"level",void 0),b([ee.serialize()],t.prototype,"coordinatesIndex",void 0),b([ee.serialize("coordinatesMode")],t.prototype,"_coordinatesMode",void 0),b([ee.serialize()],t.prototype,"wrapU",void 0),b([ee.serialize()],t.prototype,"wrapV",void 0),b([ee.serialize()],t.prototype,"wrapR",void 0),b([ee.serialize()],t.prototype,"anisotropicFilteringLevel",void 0),b([ee.serialize()],t.prototype,"isCube",void 0),b([ee.serialize()],t.prototype,"is3D",void 0),b([ee.serialize()],t.prototype,"gammaSpace",void 0),b([ee.serialize()],t.prototype,"invertZ",void 0),b([ee.serialize()],t.prototype,"lodLevelInAlpha",void 0),b([ee.serialize()],t.prototype,"lodGenerationOffset",null),b([ee.serialize()],t.prototype,"lodGenerationScale",null),b([ee.serialize()],t.prototype,"isRenderTarget",void 0),t})(),ee.BaseTexture=te,ie=$a||($a={}),re=(function(d){function f(e,t,i,r,n,o,s,a,l,c){void 0===i&&(i=!1),void 0===r&&(r=!0),void 0===n&&(n=f.TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=!1);var h=d.call(this,t)||this;if(h.uOffset=0,h.vOffset=0,h.uScale=1,h.vScale=1,h.uAng=0,h.vAng=0,h.wAng=0,h.uRotationCenter=.5,h.vRotationCenter=.5,h.wRotationCenter=.5,h.onLoadObservable=new ie.Observable,h._isBlocking=!0,h.name=e||"",h.url=e,h._noMipmap=i,h._invertY=r,h._samplingMode=n,h._buffer=a,h._deleteBuffer=l,c&&(h._format=c),!(t=h.getScene()))return h;t.getEngine().onBeforeTextureInitObservable.notifyObservers(h);var u=function(){h.onLoadObservable.hasObservers()&&h.onLoadObservable.notifyObservers(h),o&&o(),!h.isBlocking&&t&&t.resetCachedMaterial()};return h.url?(h._texture=h._getFromCache(h.url,i,n),h._texture?h._texture.isReady?ie.Tools.SetImmediate((function(){return u()})):h._texture.onLoadedObservable.add(u):t.useDelayedTextureLoading?(h.delayLoadState=ie.Engine.DELAYLOADSTATE_NOTLOADED,h._delayedOnLoad=u,h._delayedOnError=s):(h._texture=t.getEngine().createTexture(h.url,i,r,t,h._samplingMode,u,s,h._buffer,void 0,h._format),l&&delete h._buffer)):(h._delayedOnLoad=u,h._delayedOnError=s),h}return T(f,d),Object.defineProperty(f.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"samplingMode",{get:function(){return this._samplingMode},enumerable:!0,configurable:!0}),f.prototype.updateURL=function(e,t){if(void 0===t&&(t=null),this.url)throw new Error("URL is already set");this.url=e,this._buffer=t,this.delayLoadState=ie.Engine.DELAYLOADSTATE_NOTLOADED,this.delayLoad()},f.prototype.delayLoad=function(){if(this.delayLoadState===ie.Engine.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=ie.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this._samplingMode),this._texture?this._delayedOnLoad&&(this._texture.isReady?ie.Tools.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)}},f.prototype.updateSamplingMode=function(e){if(this._texture){var t=this.getScene();t&&(this._samplingMode=e,t.getEngine().updateTextureSamplingMode(e,this._texture))}},f.prototype._prepareRowForTextureGeneration=function(e,t,i,r){e*=this.uScale,t*=this.vScale,e-=this.uRotationCenter*this.uScale,t-=this.vRotationCenter*this.vScale,i-=this.wRotationCenter,ie.Vector3.TransformCoordinatesFromFloatsToRef(e,t,i,this._rowGenerationMatrix,r),r.x+=this.uRotationCenter*this.uScale+this.uOffset,r.y+=this.vRotationCenter*this.vScale+this.vOffset,r.z+=this.wRotationCenter},f.prototype.getTextureMatrix=function(){var t=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=ie.Matrix.Zero(),this._rowGenerationMatrix=new ie.Matrix,this._t0=ie.Vector3.Zero(),this._t1=ie.Vector3.Zero(),this._t2=ie.Vector3.Zero()),ie.Matrix.RotationYawPitchRollToRef(this.vAng,this.uAng,this.wAng,this._rowGenerationMatrix),this._prepareRowForTextureGeneration(0,0,0,this._t0),this._prepareRowForTextureGeneration(1,0,0,this._t1),this._prepareRowForTextureGeneration(0,1,0,this._t2),this._t1.subtractInPlace(this._t0),this._t2.subtractInPlace(this._t0),ie.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix.m[0]=this._t1.x,this._cachedTextureMatrix.m[1]=this._t1.y,this._cachedTextureMatrix.m[2]=this._t1.z,this._cachedTextureMatrix.m[4]=this._t2.x,this._cachedTextureMatrix.m[5]=this._t2.y,this._cachedTextureMatrix.m[6]=this._t2.z,this._cachedTextureMatrix.m[8]=this._t0.x,this._cachedTextureMatrix.m[9]=this._t0.y,this._cachedTextureMatrix.m[10]=this._t0.z;var e=this.getScene();return e&&e.markAllMaterialsAsDirty(ie.Material.TextureDirtyFlag,(function(e){return e.hasTexture(t)})),this._cachedTextureMatrix},f.prototype.getReflectionTextureMatrix=function(){var t=this,e=this.getScene();if(!e)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!==f.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===e.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=ie.Matrix.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=ie.Matrix.Zero()),this._cachedUOffset=this.uOffset,this._cachedVOffset=this.vOffset,this._cachedUScale=this.uScale,this._cachedVScale=this.vScale,this._cachedCoordinatesMode=this.coordinatesMode,this.coordinatesMode){case f.PLANAR_MODE:ie.Matrix.IdentityToRef(this._cachedTextureMatrix),this._cachedTextureMatrix[0]=this.uScale,this._cachedTextureMatrix[5]=this.vScale,this._cachedTextureMatrix[12]=this.uOffset,this._cachedTextureMatrix[13]=this.vOffset;break;case f.PROJECTION_MODE:ie.Matrix.IdentityToRef(this._projectionModeMatrix),this._projectionModeMatrix.m[0]=.5,this._projectionModeMatrix.m[5]=-.5,this._projectionModeMatrix.m[10]=0,this._projectionModeMatrix.m[12]=.5,this._projectionModeMatrix.m[13]=.5,this._projectionModeMatrix.m[14]=1,this._projectionModeMatrix.m[15]=1;var i=e.getProjectionMatrix();this._cachedProjectionMatrixId=i.updateFlag,i.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:ie.Matrix.IdentityToRef(this._cachedTextureMatrix)}return e.markAllMaterialsAsDirty(ie.Material.TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(t)})),this._cachedTextureMatrix},f.prototype.clone=function(){var e=this;return ie.SerializationHelper.Clone((function(){return new f(e._texture?e._texture.url:null,e.getScene(),e._noMipmap,e._invertY,e._samplingMode)}),this)},f.prototype.serialize=function(){var e=d.prototype.serialize.call(this);return"string"==typeof this._buffer&&"data:"===this._buffer.substr(0,5)&&(e.base64String=this._buffer,e.name=e.name.replace("data:","")),e.invertY=this._invertY,e.samplingMode=this.samplingMode,e},f.prototype.getClassName=function(){return"Texture"},f.prototype.dispose=function(){d.prototype.dispose.call(this),this.onLoadObservable.clear(),this._delayedOnLoad=null,this._delayedOnError=null},f.Parse=function(o,s,a){if(o.customType){var e=ie.Tools.Instantiate(o.customType).Parse(o,s,a);return o.samplingMode&&e.updateSamplingMode&&e._samplingMode&&e._samplingMode!==o.samplingMode&&e.updateSamplingMode(o.samplingMode),e}if(o.isCube)return ie.CubeTexture.Parse(o,s,a);if(!o.name&&!o.isRenderTarget)return null;var t=ie.SerializationHelper.Parse((function(){var e,t=!0;if(o.noMipmap&&(t=!1),o.mirrorPlane){var i=new ie.MirrorTexture(o.name,o.renderTargetSize,s,t);return i._waitingRenderList=o.renderList,i.mirrorPlane=ie.Plane.FromArray(o.mirrorPlane),i}if(o.isRenderTarget){var r=new ie.RenderTargetTexture(o.name,o.renderTargetSize,s,t);return r._waitingRenderList=o.renderList,r}if(o.base64String)e=f.CreateFromBase64String(o.base64String,o.name,s,!t);else{var n=a+o.name;f.UseSerializedUrlIfAny&&o.url&&(n=o.url),e=new f(n,s,!t,o.invertY)}return e}),o,s);if(o.samplingMode){var i=o.samplingMode;t._samplingMode!==i&&t.updateSamplingMode(i)}if(o.animations)for(var r=0;r<o.animations.length;r++){var n=o.animations[r];t.animations.push(ie.Animation.Parse(n))}return t},f.CreateFromBase64String=function(e,t,i,r,n,o,s,a,l){return void 0===o&&(o=f.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=ie.Engine.TEXTUREFORMAT_RGBA),new f("data:"+t,i,r,n,o,s,a,e,!1,l)},f.LoadFromDataString=function(e,t,i,r,n,o,s,a,l,c){return void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=!0),void 0===s&&(s=f.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=null),void 0===l&&(l=null),void 0===c&&(c=ie.Engine.TEXTUREFORMAT_RGBA),"data:"!==e.substr(0,5)&&(e="data:"+e),new f(e,i,n,o,s,a,l,t,r,c)},f.NEAREST_SAMPLINGMODE=ie.Engine.TEXTURE_NEAREST_SAMPLINGMODE,f.NEAREST_NEAREST_MIPLINEAR=ie.Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR,f.BILINEAR_SAMPLINGMODE=ie.Engine.TEXTURE_BILINEAR_SAMPLINGMODE,f.LINEAR_LINEAR_MIPNEAREST=ie.Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST,f.TRILINEAR_SAMPLINGMODE=ie.Engine.TEXTURE_TRILINEAR_SAMPLINGMODE,f.LINEAR_LINEAR_MIPLINEAR=ie.Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR,f.NEAREST_NEAREST_MIPNEAREST=ie.Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST,f.NEAREST_LINEAR_MIPNEAREST=ie.Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST,f.NEAREST_LINEAR_MIPLINEAR=ie.Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR,f.NEAREST_LINEAR=ie.Engine.TEXTURE_NEAREST_LINEAR,f.NEAREST_NEAREST=ie.Engine.TEXTURE_NEAREST_NEAREST,f.LINEAR_NEAREST_MIPNEAREST=ie.Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST,f.LINEAR_NEAREST_MIPLINEAR=ie.Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR,f.LINEAR_LINEAR=ie.Engine.TEXTURE_LINEAR_LINEAR,f.LINEAR_NEAREST=ie.Engine.TEXTURE_LINEAR_NEAREST,f.EXPLICIT_MODE=ie.Engine.TEXTURE_EXPLICIT_MODE,f.SPHERICAL_MODE=ie.Engine.TEXTURE_SPHERICAL_MODE,f.PLANAR_MODE=ie.Engine.TEXTURE_PLANAR_MODE,f.CUBIC_MODE=ie.Engine.TEXTURE_CUBIC_MODE,f.PROJECTION_MODE=ie.Engine.TEXTURE_PROJECTION_MODE,f.SKYBOX_MODE=ie.Engine.TEXTURE_SKYBOX_MODE,f.INVCUBIC_MODE=ie.Engine.TEXTURE_INVCUBIC_MODE,f.EQUIRECTANGULAR_MODE=ie.Engine.TEXTURE_EQUIRECTANGULAR_MODE,f.FIXED_EQUIRECTANGULAR_MODE=ie.Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE,f.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=ie.Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE,f.CLAMP_ADDRESSMODE=ie.Engine.TEXTURE_CLAMP_ADDRESSMODE,f.WRAP_ADDRESSMODE=ie.Engine.TEXTURE_WRAP_ADDRESSMODE,f.MIRROR_ADDRESSMODE=ie.Engine.TEXTURE_MIRROR_ADDRESSMODE,f.UseSerializedUrlIfAny=!1,b([ie.serialize()],f.prototype,"url",void 0),b([ie.serialize()],f.prototype,"uOffset",void 0),b([ie.serialize()],f.prototype,"vOffset",void 0),b([ie.serialize()],f.prototype,"uScale",void 0),b([ie.serialize()],f.prototype,"vScale",void 0),b([ie.serialize()],f.prototype,"uAng",void 0),b([ie.serialize()],f.prototype,"vAng",void 0),b([ie.serialize()],f.prototype,"wAng",void 0),b([ie.serialize()],f.prototype,"uRotationCenter",void 0),b([ie.serialize()],f.prototype,"vRotationCenter",void 0),b([ie.serialize()],f.prototype,"wRotationCenter",void 0),b([ie.serialize()],f.prototype,"isBlocking",null),f})(ie.BaseTexture),ie.Texture=re,(function(S){var e=function(){};S._CreationDataStorage=e;var _=function(){this.visibleInstances={},this.renderIdForInstances=new Array,this.batchCache=new t,this.instancesBufferSize=2048},t=function(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array};S._InstancesBatch=t;var i=(function(v){function m(e,t,i,r,n,o){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=!0);var s=v.call(this,e,t)||this;if(s.delayLoadState=S.Engine.DELAYLOADSTATE_NONE,s.instances=new Array,s._LODLevels=new Array,s._instanceDataStorage=new _,s._originalBuilderSideOrientation=m.DEFAULTSIDE,s.overrideMaterialSideOrientation=null,s._areNormalsFrozen=!1,s._source=null,t=s.getScene(),r){if(r._geometry&&r._geometry.applyToMesh(s),S.Tools.DeepCopy(r,s,["name","material","skeleton","instances","parent","uniqueId","source","metadata","hasLODLevels","geometry","isBlocked","areNormalsFrozen","onBeforeDrawObservable","onBeforeRenderObservable","onAfterRenderObservable","onBeforeDraw"],["_poseMatrix"]),s._source=r,s._originalBuilderSideOrientation=r._originalBuilderSideOrientation,s._creationDataStorage=r._creationDataStorage,s._source._ranges){var a=s._source._ranges;for(var e in a)a.hasOwnProperty(e)&&a[e]&&s.createAnimationRange(e,a[e].from,a[e].to)}var l;if(r.metadata&&r.metadata.clone?s.metadata=r.metadata.clone():s.metadata=r.metadata,S.Tags&&S.Tags.HasTags(r)&&S.Tags.AddTagsTo(s,S.Tags.GetTags(r,!0)),s.parent=r.parent,s.setPivotMatrix(r.getPivotMatrix()),s.id=e+"."+r.id,s.material=r.material,!n)for(var c=r.getDescendants(!0),h=0;h<c.length;h++){var u=c[h];u.clone&&u.clone(e+"."+u.name,s)}var d=s.getScene().getPhysicsEngine();if(o&&d){var f=d.getImpostorForPhysicsObject(r);f&&(s.physicsImpostor=f.clone(s))}for(l=0;l<t.particleSystems.length;l++){var p=t.particleSystems[l];p.emitter===r&&p.clone(p.name,s)}s.refreshBoundingInfo(),s.computeWorldMatrix(!0)}return null!==i&&(s.parent=i),s}return T(m,v),Object.defineProperty(m.prototype,"onBeforeRenderObservable",{get:function(){return this._onBeforeRenderObservable||(this._onBeforeRenderObservable=new S.Observable),this._onBeforeRenderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"onAfterRenderObservable",{get:function(){return this._onAfterRenderObservable||(this._onAfterRenderObservable=new S.Observable),this._onAfterRenderObservable},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"onBeforeDrawObservable",{get:function(){return this._onBeforeDrawObservable||(this._onBeforeDrawObservable=new S.Observable),this._onBeforeDrawObservable},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"morphTargetManager",{get:function(){return this._morphTargetManager},set:function(e){this._morphTargetManager!==e&&(this._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"source",{get:function(){return this._source},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),m.prototype.getClassName=function(){return"Mesh"},m.prototype.toString=function(e){var t=v.prototype.toString.call(this,e);if(t+=", n vertices: "+this.getTotalVertices(),t+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var i=0;i<this.animations.length;i++)t+=", animation[0]: "+this.animations[i].toString(e);if(e)if(this._geometry){var r=this.getIndices(),n=this.getVerticesData(S.VertexBuffer.PositionKind);n&&r&&(t+=", flat shading: "+(n.length/3===r.length?"YES":"NO"))}else t+=", flat shading: UNKNOWN";return t},m.prototype._unBindEffect=function(){v.prototype._unBindEffect.call(this);for(var e=0,t=this.instances;e<t.length;e++){t[e]._unBindEffect()}},Object.defineProperty(m.prototype,"hasLODLevels",{get:function(){return 0<this._LODLevels.length},enumerable:!0,configurable:!0}),m.prototype.getLODLevels=function(){return this._LODLevels},m.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0}))},m.prototype.addLODLevel=function(e,t){if(t&&t._masterMesh)return S.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var i=new S.MeshLODLevel(e,t);return this._LODLevels.push(i),t&&(t._masterMesh=this),this._sortLODLevels(),this},m.prototype.getLODLevelAtDistance=function(e){for(var t=0;t<this._LODLevels.length;t++){var i=this._LODLevels[t];if(i.distance===e)return i.mesh}return null},m.prototype.removeLODLevel=function(e){for(var t=0;t<this._LODLevels.length;t++)this._LODLevels[t].mesh===e&&(this._LODLevels.splice(t,1),e&&(e._masterMesh=null));return this._sortLODLevels(),this},m.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var i;t?i=t:i=this.getBoundingInfo().boundingSphere;var r=i.centerWorld.subtract(e.globalPosition).length();if(this._LODLevels[this._LODLevels.length-1].distance>r)return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this._LODLevels[this._LODLevels.length-1].mesh),this;for(var n=0;n<this._LODLevels.length;n++){var o=this._LODLevels[n];if(o.distance<r)return o.mesh&&(o.mesh._preActivate(),o.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache)),this.onLODLevelSelection&&this.onLODLevelSelection(r,this,o.mesh),o.mesh}return this.onLODLevelSelection&&this.onLODLevelSelection(r,this,this),this},Object.defineProperty(m.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),m.prototype.getTotalVertices=function(){return null===this._geometry||void 0===this._geometry?0:this._geometry.getTotalVertices()},m.prototype.getVerticesData=function(e,t,i){return this._geometry?this._geometry.getVerticesData(e,t,i):null},m.prototype.getVertexBuffer=function(e){return this._geometry?this._geometry.getVertexBuffer(e):null},m.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},m.prototype.isVertexBufferUpdatable=function(e){return this._geometry?this._geometry.isVertexBufferUpdatable(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},m.prototype.getVerticesDataKinds=function(){if(!this._geometry){var r=new Array;return this._delayInfo&&this._delayInfo.forEach((function(e,t,i){r.push(e)})),r}return this._geometry.getVerticesDataKinds()},m.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},m.prototype.getIndices=function(e,t){return this._geometry?this._geometry.getIndices(e,t):[]},Object.defineProperty(m.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),m.prototype.isReady=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),this.delayLoadState===S.Engine.DELAYLOADSTATE_LOADING)return!1;if(!v.prototype.isReady.call(this,e))return!1;if(!this.subMeshes||0===this.subMeshes.length)return!0;if(!e)return!0;var i=this.getEngine(),r=this.getScene(),n=t||i.getCaps().instancedArrays&&0<this.instances.length;this.computeWorldMatrix();var o=this.material||r.defaultMaterial;if(o)if(o.storeEffectOnSubMeshes)for(var s=0,a=this.subMeshes;s<a.length;s++){var l=(p=a[s]).getMaterial();if(l)if(l.storeEffectOnSubMeshes){if(!l.isReadyForSubMesh(this,p,n))return!1}else if(!l.isReady(this,n))return!1}else if(!o.isReady(this,n))return!1;for(var c=0,h=this._lightSources;c<h.length;c++){var u=h[c].getShadowGenerator();if(u)for(var d=0,f=this.subMeshes;d<f.length;d++){var p=f[d];if(!u.isReady(p,n))return!1}}for(var m=0,_=this._LODLevels;m<_.length;m++){var g=_[m];if(g.mesh&&!g.mesh.isReady(n))return!1}return!0},Object.defineProperty(m.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),m.prototype.freezeNormals=function(){return this._areNormalsFrozen=!0,this},m.prototype.unfreezeNormals=function(){return this._areNormalsFrozen=!1,this},Object.defineProperty(m.prototype,"overridenInstanceCount",{set:function(e){this._instanceDataStorage.overridenInstanceCount=e},enumerable:!0,configurable:!0}),m.prototype._preActivate=function(){var e=this.getScene().getRenderId();return this._preActivateId===e||(this._preActivateId=e,this._instanceDataStorage.visibleInstances=null),this},m.prototype._preActivateForIntermediateRendering=function(e){return this._instanceDataStorage.visibleInstances&&(this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId=e),this},m.prototype._registerInstanceForRenderId=function(e,t){return this._instanceDataStorage.visibleInstances||(this._instanceDataStorage.visibleInstances={},this._instanceDataStorage.visibleInstances.defaultRenderId=t,this._instanceDataStorage.visibleInstances.selfDefaultRenderId=this._renderId),this._instanceDataStorage.visibleInstances[t]||(this._instanceDataStorage.visibleInstances[t]=new Array),this._instanceDataStorage.visibleInstances[t].push(e),this},m.prototype.refreshBoundingInfo=function(){return this._refreshBoundingInfo(!1)},m.prototype._refreshBoundingInfo=function(e){if(this._boundingInfo&&this._boundingInfo.isLocked)return this;var t=this._getPositionData(e);if(t){var i=this.geometry?this.geometry.boundingBias:null,r=S.Tools.ExtractMinAndMax(t,0,this.getTotalVertices(),i);this._boundingInfo=new S.BoundingInfo(r.minimum,r.maximum)}if(this.subMeshes)for(var n=0;n<this.subMeshes.length;n++)this.subMeshes[n].refreshBoundingInfo();return this._updateBoundingInfo(),this},m.prototype._getPositionData=function(e){var t=this.getVerticesData(S.VertexBuffer.PositionKind);if(t&&e&&this.skeleton){t=S.Tools.Slice(t);var i=this.getVerticesData(S.VertexBuffer.MatricesIndicesKind),r=this.getVerticesData(S.VertexBuffer.MatricesWeightsKind);if(r&&i)for(var n=4<this.numBoneInfluencers,o=n?this.getVerticesData(S.VertexBuffer.MatricesIndicesExtraKind):null,s=n?this.getVerticesData(S.VertexBuffer.MatricesWeightsExtraKind):null,a=this.skeleton.getTransformMatrices(this),l=S.Tmp.Vector3[0],c=S.Tmp.Matrix[0],h=S.Tmp.Matrix[1],u=0,d=0;d<t.length;d+=3,u+=4){var f,p;for(c.reset(),f=0;f<4;f++)0<(p=r[u+f])&&(S.Matrix.FromFloat32ArrayToRefScaled(a,Math.floor(16*i[u+f]),p,h),c.addToSelf(h));if(n)for(f=0;f<4;f++)0<(p=s[u+f])&&(S.Matrix.FromFloat32ArrayToRefScaled(a,Math.floor(16*o[u+f]),p,h),c.addToSelf(h));S.Vector3.TransformCoordinatesFromFloatsToRef(t[d],t[d+1],t[d+2],c,l),l.toArray(t,d)}}return t},m.prototype._createGlobalSubMesh=function(e){var t=this.getTotalVertices();if(!t||!this.getIndices())return null;if(this.subMeshes&&0<this.subMeshes.length){var i=this.getIndices();if(!i)return null;var r=i.length,n=!1;if(e)n=!0;else for(var o=0,s=this.subMeshes;o<s.length;o++){var a=s[o];if(a.indexStart+a.indexCount>=r){n=!0;break}if(a.verticesStart+a.verticesCount>=t){n=!0;break}}if(!n)return this.subMeshes[0]}return this.releaseSubMeshes(),new S.SubMesh(0,0,t,0,this.getTotalIndices(),this)},m.prototype.subdivide=function(e){if(!(e<1)){for(var t=this.getTotalIndices(),i=t/e|0,r=0;i%3!=0;)i++;this.releaseSubMeshes();for(var n=0;n<e&&!(t<=r);n++)S.SubMesh.CreateFromIndices(0,r,Math.min(i,t-r),this),r+=i;this.synchronizeInstances()}},m.prototype.setVerticesData=function(e,t,i,r){if(void 0===i&&(i=!1),this._geometry)this._geometry.setVerticesData(e,t,i,r);else{var n=new S.VertexData;n.set(t,e);var o=this.getScene();new S.Geometry(S.Geometry.RandomId(),o,n,i,this)}return this},m.prototype.markVerticesDataAsUpdatable=function(e,t){void 0===t&&(t=!0);var i=this.getVertexBuffer(e);i&&i.isUpdatable()!==t&&this.setVerticesData(e,this.getVerticesData(e),t)},m.prototype.setVerticesBuffer=function(e){return this._geometry||(this._geometry=S.Geometry.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(e),this},m.prototype.updateVerticesData=function(e,t,i,r){return this._geometry&&(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i)),this},m.prototype.updateMeshPositions=function(e,t){void 0===t&&(t=!0);var i=this.getVerticesData(S.VertexBuffer.PositionKind);if(!i)return this;if(e(i),this.updateVerticesData(S.VertexBuffer.PositionKind,i,!1,!1),t){var r=this.getIndices(),n=this.getVerticesData(S.VertexBuffer.NormalKind);if(!n)return this;S.VertexData.ComputeNormals(i,r,n),this.updateVerticesData(S.VertexBuffer.NormalKind,n,!1,!1)}return this},m.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;var e=this._geometry,t=this._geometry.copy(S.Geometry.RandomId());return e.releaseForMesh(this,!0),t.applyToMesh(this),this},m.prototype.setIndices=function(e,t,i){if(void 0===t&&(t=null),void 0===i&&(i=!1),this._geometry)this._geometry.setIndices(e,t,i);else{var r=new S.VertexData;r.indices=e;var n=this.getScene();new S.Geometry(S.Geometry.RandomId(),n,r,i,this)}return this},m.prototype.updateIndices=function(e,t){return this._geometry&&this._geometry.updateIndices(e,t),this},m.prototype.toLeftHanded=function(){return this._geometry&&this._geometry.toLeftHanded(),this},m.prototype._bind=function(e,t,i){if(!this._geometry)return this;var r,n=this.getScene().getEngine();if(this._unIndexed)r=null;else switch(i){case S.Material.PointFillMode:r=null;break;case S.Material.WireFrameFillMode:r=e._getLinesIndexBuffer(this.getIndices(),n);break;default:case S.Material.TriangleFillMode:r=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(t,r),this},m.prototype._draw=function(e,t,i,r){if(void 0===r&&(r=!1),!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._onBeforeDrawObservable&&this._onBeforeDrawObservable.notifyObservers(this);var n=this.getScene(),o=n.getEngine();if(this._unIndexed||t==S.Material.PointFillMode?o.drawArraysType(t,e.verticesStart,e.verticesCount,i):t==S.Material.WireFrameFillMode?o.drawElementsType(t,0,e._linesIndexCount,i):o.drawElementsType(t,e.indexStart,e.indexCount,i),n._isAlternateRenderingEnabled&&!r){var s=e.effect||this._effectiveMaterial.getEffect();if(!s||!n.activeCamera)return this;n._switchToAlternateCameraConfiguration(!0),this._effectiveMaterial.bindView(s),this._effectiveMaterial.bindViewProjection(s),o.setViewport(n.activeCamera._alternateCamera.viewport),this._draw(e,t,i,!0),o.setViewport(n.activeCamera.viewport),n._switchToAlternateCameraConfiguration(!1),this._effectiveMaterial.bindView(s),this._effectiveMaterial.bindViewProjection(s)}return this},m.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},m.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},m.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},m.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},m.prototype._getInstancesRenderList=function(e){var t=this.getScene(),i=this._instanceDataStorage.batchCache;if(i.mustReturn=!1,i.renderSelf[e]=this.isEnabled()&&this.isVisible,i.visibleInstances[e]=null,this._instanceDataStorage.visibleInstances){var r=this._instanceDataStorage.visibleInstances,n=t.getRenderId(),o=t._isInIntermediateRendering()?r.intermediateDefaultRenderId:r.defaultRenderId;i.visibleInstances[e]=r[n];var s=this._renderId;!i.visibleInstances[e]&&o&&(i.visibleInstances[e]=r[o],n=Math.max(o,n),s=Math.max(r.selfDefaultRenderId,n));var a=i.visibleInstances[e];if(a&&a.length){if(this._instanceDataStorage.renderIdForInstances[e]===n)return i.mustReturn=!0,i;n!==s&&(i.renderSelf[e]=!1)}this._instanceDataStorage.renderIdForInstances[e]=n}return i},m.prototype._renderWithInstances=function(e,t,i,r,n){var o=i.visibleInstances[e._id];if(!o)return this;for(var s=16*(o.length+1)*4,a=this._instanceDataStorage,l=a.instancesBufferSize,c=a.instancesBuffer;a.instancesBufferSize<s;)a.instancesBufferSize*=2;a.instancesData&&l==a.instancesBufferSize||(a.instancesData=new Float32Array(a.instancesBufferSize/4));var h=0,u=0,d=this.getWorldMatrix();if(i.renderSelf[e._id]&&(d.copyToArray(a.instancesData,h),h+=16,u++),o)for(var f=0;f<o.length;f++){o[f].getWorldMatrix().copyToArray(a.instancesData,h),h+=16,u++}return c&&l==a.instancesBufferSize?c.updateDirectly(a.instancesData,0,u):(c&&c.dispose(),c=new S.Buffer(n,a.instancesData,!0,16,!1,!0),a.instancesBuffer=c,this.setVerticesBuffer(c.createVertexBuffer("world0",0,4)),this.setVerticesBuffer(c.createVertexBuffer("world1",4,4)),this.setVerticesBuffer(c.createVertexBuffer("world2",8,4)),this.setVerticesBuffer(c.createVertexBuffer("world3",12,4))),this._bind(e,r,t),this._draw(e,t,u),n.unbindInstanceAttributes(),this},m.prototype._processRendering=function(e,t,i,r,n,o,s){var a=this.getScene().getEngine();if(n)this._renderWithInstances(e,i,r,t,a);else{r.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix(),s),this._draw(e,i,this._instanceDataStorage.overridenInstanceCount));var l=r.visibleInstances[e._id];if(l)for(var c=0;c<l.length;c++){var h=l[c].getWorldMatrix();o&&o(!0,h,s),this._draw(e,i)}}return this},m.prototype.render=function(e,t){if(this._checkOcclusionQuery())return this;var i=this.getScene(),r=this._getInstancesRenderList(e._id);if(r.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this._onBeforeRenderObservable&&this._onBeforeRenderObservable.notifyObservers(this);var n,o=i.getEngine(),s=o.getCaps().instancedArrays&&null!==r.visibleInstances[e._id]&&void 0!==r.visibleInstances[e._id],a=e.getMaterial();if(!a)return this;if(this._effectiveMaterial=a,this._effectiveMaterial.storeEffectOnSubMeshes){if(!this._effectiveMaterial.isReadyForSubMesh(this,e,s))return this}else if(!this._effectiveMaterial.isReady(this,s))return this;t&&o.setAlphaMode(this._effectiveMaterial.alphaMode);for(var l=0,c=i._beforeRenderingMeshStage;l<c.length;l++){c[l].action(this,e,r)}if(!(n=this._effectiveMaterial.storeEffectOnSubMeshes?e.effect:this._effectiveMaterial.getEffect()))return this;var h=this.overrideMaterialSideOrientation;null==h&&(h=this._effectiveMaterial.sideOrientation,this._getWorldMatrixDeterminant()<0&&(h=h===S.Material.ClockWiseSideOrientation?S.Material.CounterClockWiseSideOrientation:S.Material.ClockWiseSideOrientation));var u=this._effectiveMaterial._preBind(n,h);this._effectiveMaterial.forceDepthWrite&&o.setDepthWrite(!0);var d=i.forcePointsCloud?S.Material.PointFillMode:i.forceWireframe?S.Material.WireFrameFillMode:this._effectiveMaterial.fillMode;s||this._bind(e,n,d);var f=this.getWorldMatrix();this._effectiveMaterial.storeEffectOnSubMeshes?this._effectiveMaterial.bindForSubMesh(f,this,e):this._effectiveMaterial.bind(f,this),!this._effectiveMaterial.backFaceCulling&&this._effectiveMaterial.separateCullingPass&&(o.setState(!0,this._effectiveMaterial.zOffset,!1,!u),this._processRendering(e,n,d,r,s,this._onBeforeDraw,this._effectiveMaterial),o.setState(!0,this._effectiveMaterial.zOffset,!1,u)),this._processRendering(e,n,d,r,s,this._onBeforeDraw,this._effectiveMaterial),this._effectiveMaterial.unbind();for(var p=0,m=i._afterRenderingMeshStage;p<m.length;p++){m[p].action(this,e,r)}return this._onAfterRenderObservable&&this._onAfterRenderObservable.notifyObservers(this),this},m.prototype._onBeforeDraw=function(e,t,i){e&&i&&i.bindOnlyWorldMatrix(t)},m.prototype.cleanMatrixWeights=function(){this.isVerticesDataPresent(S.VertexBuffer.MatricesWeightsKind)&&(this.isVerticesDataPresent(S.VertexBuffer.MatricesWeightsExtraKind)?this.normalizeSkinWeightsAndExtra():this.normalizeSkinFourWeights())},m.prototype.normalizeSkinFourWeights=function(){for(var e=this.getVerticesData(S.VertexBuffer.MatricesWeightsKind),t=e.length,i=0;i<t;i+=4){var r=e[i]+e[i+1]+e[i+2]+e[i+3];if(0===r)e[i]=1;else{var n=1/r;e[i]*=n,e[i+1]*=n,e[i+2]*=n,e[i+3]*=n}}this.setVerticesData(S.VertexBuffer.MatricesWeightsKind,e)},m.prototype.normalizeSkinWeightsAndExtra=function(){for(var e=this.getVerticesData(S.VertexBuffer.MatricesWeightsExtraKind),t=this.getVerticesData(S.VertexBuffer.MatricesWeightsKind),i=t.length,r=0;r<i;r+=4){var n=t[r]+t[r+1]+t[r+2]+t[r+3];if(0===(n+=e[r]+e[r+1]+e[r+2]+e[r+3]))t[r]=1;else{var o=1/n;t[r]*=o,t[r+1]*=o,t[r+2]*=o,t[r+3]*=o,e[r]*=o,e[r+1]*=o,e[r+2]*=o,e[r+3]*=o}}this.setVerticesData(S.VertexBuffer.MatricesWeightsKind,t),this.setVerticesData(S.VertexBuffer.MatricesWeightsKind,e)},m.prototype.validateSkinning=function(){var e=this.getVerticesData(S.VertexBuffer.MatricesWeightsExtraKind),t=this.getVerticesData(S.VertexBuffer.MatricesWeightsKind);if(null===t||null==this.skeleton)return{skinned:!1,valid:!0,report:"not skinned"};for(var i=t.length,r=0,n=0,o=0,s=0,a=null===e?4:8,l=new Array,c=0;c<=a;c++)l[c]=0;for(c=0;c<i;c+=4){for(var h=t[c],u=h,d=0===u?0:1,f=1;f<a;f++){var p=f<4?t[c+f]:e[c+f-4];h<p&&r++,0!==p&&d++,u+=p,h=p}if(l[d]++,o<d&&(o=d),0===u)n++;else{var m=1/u,_=0;for(f=0;f<a;f++)_+=f<4?Math.abs(t[c+f]-t[c+f]*m):Math.abs(e[c+f-4]-e[c+f-4]*m);.001<_&&s++}}var g=this.skeleton.bones.length,v=this.getVerticesData(S.VertexBuffer.MatricesIndicesKind),y=this.getVerticesData(S.VertexBuffer.MatricesIndicesExtraKind),b=0;for(c=0;c<i;c++)for(f=0;f<a;f++){var T=f<4?v[f]:y[f-4];(g<=T||T<0)&&b++}return{skinned:!0,valid:0===n&&0===s&&0===b,report:"Number of Weights = "+i/4+"\nMaximum influences = "+o+"\nMissing Weights = "+n+"\nNot Sorted = "+r+"\nNot Normalized = "+s+"\nWeightCounts = ["+l+"]\nNumber of bones = "+g+"\nBad Bone Indices = "+b}},m.prototype._checkDelayState=function(){var e=this.getScene();return this._geometry?this._geometry.load(e):this.delayLoadState===S.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=S.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(e)),this},m.prototype._queueLoad=function(t){var i=this;t._addPendingData(this);var e=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return S.Tools.LoadFile(this.delayLoadingFile,(function(e){e instanceof ArrayBuffer?i._delayLoadingFunction(e,i):i._delayLoadingFunction(JSON.parse(e),i),i.instances.forEach((function(e){e._syncSubMeshes()})),i.delayLoadState=S.Engine.DELAYLOADSTATE_LOADED,t._removePendingData(i)}),(function(){}),t.database,e),this},m.prototype.isInFrustum=function(e){return this.delayLoadState!==S.Engine.DELAYLOADSTATE_LOADING&&(!!v.prototype.isInFrustum.call(this,e)&&(this._checkDelayState(),!0))},m.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=i.length-1;-1<t;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;-1<t;t--)if(r[t].id===e)return this.material=r[t],this;return this},m.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},m.prototype.bakeTransformIntoVertices=function(e){if(!this.isVerticesDataPresent(S.VertexBuffer.PositionKind))return this;var t=this.subMeshes.splice(0);this._resetPointsArrayCache();var i,r=this.getVerticesData(S.VertexBuffer.PositionKind),n=new Array;for(i=0;i<r.length;i+=3)S.Vector3.TransformCoordinates(S.Vector3.FromArray(r,i),e).toArray(n,i);if(this.setVerticesData(S.VertexBuffer.PositionKind,n,this.getVertexBuffer(S.VertexBuffer.PositionKind).isUpdatable()),this.isVerticesDataPresent(S.VertexBuffer.NormalKind)){for(r=this.getVerticesData(S.VertexBuffer.NormalKind),n=[],i=0;i<r.length;i+=3)S.Vector3.TransformNormal(S.Vector3.FromArray(r,i),e).normalize().toArray(n,i);this.setVerticesData(S.VertexBuffer.NormalKind,n,this.getVertexBuffer(S.VertexBuffer.NormalKind).isUpdatable())}return e.m[0]*e.m[5]*e.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=t,this},m.prototype.bakeCurrentTransformIntoVertices=function(){return this.bakeTransformIntoVertices(this.computeWorldMatrix(!0)),this.scaling.copyFromFloats(1,1,1),this.position.copyFromFloats(0,0,0),this.rotation.copyFromFloats(0,0,0),this.rotationQuaternion&&(this.rotationQuaternion=S.Quaternion.Identity()),this._worldMatrix=S.Matrix.Identity(),this},Object.defineProperty(m.prototype,"_positions",{get:function(){return this._geometry?this._geometry._positions:null},enumerable:!0,configurable:!0}),m.prototype._resetPointsArrayCache=function(){return this._geometry&&this._geometry._resetPointsArrayCache(),this},m.prototype._generatePointsArray=function(){return!!this._geometry&&this._geometry._generatePointsArray()},m.prototype.clone=function(e,t,i,r){return void 0===e&&(e=""),void 0===r&&(r=!0),new m(e,this.getScene(),t,this,i,r)},m.prototype.dispose=function(e,t){var i=this;for(void 0===t&&(t=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0),this._onBeforeDrawObservable&&this._onBeforeDrawObservable.clear(),this._onBeforeRenderObservable&&this._onBeforeRenderObservable.clear(),this._onAfterRenderObservable&&this._onAfterRenderObservable.clear(),this.getScene().meshes.forEach((function(e){var t=e;t._source&&t._source===i&&(t._source=null)})),this._source=null,this._instanceDataStorage.instancesBuffer&&(this._instanceDataStorage.instancesBuffer.dispose(),this._instanceDataStorage.instancesBuffer=null);this.instances.length;)this.instances[0].dispose();v.prototype.dispose.call(this,e,t)},m.prototype.applyDisplacementMap=function(e,s,a,l,c,h,u){var d=this;void 0===u&&(u=!1);var t=this.getScene();return S.Tools.LoadImage(e,(function(e){var t=document.createElement("canvas"),i=t.getContext("2d"),r=e.width,n=e.height;t.width=r,t.height=n,i.drawImage(e,0,0);var o=i.getImageData(0,0,r,n).data;d.applyDisplacementMapFromBuffer(o,r,n,s,a,c,h,u),l&&l(d)}),(function(){}),t.database),this},m.prototype.applyDisplacementMapFromBuffer=function(e,t,i,r,n,o,s,a){if(void 0===a&&(a=!1),!this.isVerticesDataPresent(S.VertexBuffer.PositionKind)||!this.isVerticesDataPresent(S.VertexBuffer.NormalKind)||!this.isVerticesDataPresent(S.VertexBuffer.UVKind))return S.Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var l=this.getVerticesData(S.VertexBuffer.PositionKind,!0,!0),c=this.getVerticesData(S.VertexBuffer.NormalKind),h=this.getVerticesData(S.VertexBuffer.UVKind),u=S.Vector3.Zero(),d=S.Vector3.Zero(),f=S.Vector2.Zero();o=o||S.Vector2.Zero(),s=s||new S.Vector2(1,1);for(var p=0;p<l.length;p+=3){S.Vector3.FromArrayToRef(l,p,u),S.Vector3.FromArrayToRef(c,p,d),S.Vector2.FromArrayToRef(h,p/3*2,f);var m=4*((Math.abs(f.x*s.x+o.x)*t%t|0)+(Math.abs(f.y*s.y+o.y)*i%i|0)*t),_=.3*(e[m]/255)+.59*(e[m+1]/255)+.11*(e[m+2]/255);d.normalize(),d.scaleInPlace(r+(n-r)*_),(u=u.add(d)).toArray(l,p)}return S.VertexData.ComputeNormals(l,this.getIndices(),c),a?(this.setVerticesData(S.VertexBuffer.PositionKind,l),this.setVerticesData(S.VertexBuffer.NormalKind,c)):(this.updateVerticesData(S.VertexBuffer.PositionKind,l),this.updateVerticesData(S.VertexBuffer.NormalKind,c)),this},m.prototype.convertToFlatShadedMesh=function(){var e,t,i=this.getVerticesDataKinds(),r={},n={},o={},s=!1;for(e=0;e<i.length;e++){t=i[e];var a=this.getVertexBuffer(t);t!==S.VertexBuffer.NormalKind?(r[t]=a,n[t]=r[t].getData(),o[t]=[]):(s=a.isUpdatable(),i.splice(e,1),e--)}var l,c=this.subMeshes.slice(0),h=this.getIndices(),u=this.getTotalIndices();for(l=0;l<u;l++){var d=h[l];for(e=0;e<i.length;e++)for(var f=r[t=i[e]].getStrideSize(),p=0;p<f;p++)o[t].push(n[t][d*f+p])}var m=[],_=o[S.VertexBuffer.PositionKind];for(l=0;l<u;l+=3){h[l]=l,h[l+1]=l+1,h[l+2]=l+2;for(var g=S.Vector3.FromArray(_,3*l),v=S.Vector3.FromArray(_,3*(l+1)),y=S.Vector3.FromArray(_,3*(l+2)),b=g.subtract(v),T=y.subtract(v),x=S.Vector3.Normalize(S.Vector3.Cross(b,T)),E=0;E<3;E++)m.push(x.x),m.push(x.y),m.push(x.z)}for(this.setIndices(h),this.setVerticesData(S.VertexBuffer.NormalKind,m,s),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],r[t].isUpdatable());this.releaseSubMeshes();for(var A=0;A<c.length;A++){var P=c[A];S.SubMesh.AddToMesh(P.materialIndex,P.indexStart,P.indexCount,P.indexStart,P.indexCount,this)}return this.synchronizeInstances(),this},m.prototype.convertToUnIndexedMesh=function(){var e,t,i=this.getVerticesDataKinds(),r={},n={},o={};for(e=0;e<i.length;e++){t=i[e];var s=this.getVertexBuffer(t);r[t]=s,n[t]=r[t].getData(),o[t]=[]}var a,l=this.subMeshes.slice(0),c=this.getIndices(),h=this.getTotalIndices();for(a=0;a<h;a++){var u=c[a];for(e=0;e<i.length;e++)for(var d=r[t=i[e]].getStrideSize(),f=0;f<d;f++)o[t].push(n[t][u*d+f])}for(a=0;a<h;a+=3)c[a]=a,c[a+1]=a+1,c[a+2]=a+2;for(this.setIndices(c),e=0;e<i.length;e++)t=i[e],this.setVerticesData(t,o[t],r[t].isUpdatable());this.releaseSubMeshes();for(var p=0;p<l.length;p++){var m=l[p];S.SubMesh.AddToMesh(m.materialIndex,m.indexStart,m.indexCount,m.indexStart,m.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},m.prototype.flipFaces=function(e){void 0===e&&(e=!1);var t,i,r=S.VertexData.ExtractFromMesh(this);if(e&&this.isVerticesDataPresent(S.VertexBuffer.NormalKind)&&r.normals)for(t=0;t<r.normals.length;t++)r.normals[t]*=-1;if(r.indices)for(t=0;t<r.indices.length;t+=3)i=r.indices[t+1],r.indices[t+1]=r.indices[t+2],r.indices[t+2]=i;return r.applyToMesh(this),this},m.prototype.createInstance=function(e){return new S.InstancedMesh(e,this)},m.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}return this},m.prototype.optimizeIndices=function(i){var r=this,n=this.getIndices(),e=this.getVerticesData(S.VertexBuffer.PositionKind);if(!e||!n)return this;for(var o=new Array,t=0;t<e.length;t+=3)o.push(S.Vector3.FromArray(e,t));var s=new Array;return S.AsyncLoop.SyncAsyncForLoop(o.length,40,(function(e){for(var t=o.length-1-e,i=o[t],r=0;r<t;++r){var n=o[r];if(i.equals(n)){s[t]=r;break}}}),(function(){for(var e=0;e<n.length;++e)n[e]=s[n[e]]||n[e];var t=r.subMeshes.slice(0);r.setIndices(n),r.subMeshes=t,i&&i(r)})),this},m.prototype.serialize=function(e){e.name=this.name,e.id=this.id,e.type=this.getClassName(),S.Tags&&S.Tags.HasTags(this)&&(e.tags=S.Tags.GetTags(this)),e.position=this.position.asArray(),this.rotationQuaternion?e.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(e.rotation=this.rotation.asArray()),e.scaling=this.scaling.asArray(),e.localMatrix=this.getPivotMatrix().asArray(),e.isEnabled=this.isEnabled(!1),e.isVisible=this.isVisible,e.infiniteDistance=this.infiniteDistance,e.pickable=this.isPickable,e.receiveShadows=this.receiveShadows,e.billboardMode=this.billboardMode,e.visibility=this.visibility,e.checkCollisions=this.checkCollisions,e.isBlocker=this.isBlocker,this.parent&&(e.parentId=this.parent.id),e.isUnIndexed=this.isUnIndexed;var t=this._geometry;if(t){var i=t.id;e.geometryId=i,e.subMeshes=[];for(var r=0;r<this.subMeshes.length;r++){var n=this.subMeshes[r];e.subMeshes.push({materialIndex:n.materialIndex,verticesStart:n.verticesStart,verticesCount:n.verticesCount,indexStart:n.indexStart,indexCount:n.indexCount})}}this.material?e.materialId=this.material.id:this.material=null,this.morphTargetManager&&(e.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(e.skeletonId=this.skeleton.id);var o=this.getPhysicsImpostor();o&&(e.physicsMass=o.getParam("mass"),e.physicsFriction=o.getParam("friction"),e.physicsRestitution=o.getParam("mass"),e.physicsImpostor=o.type),this.metadata&&(e.metadata=this.metadata),e.instances=[];for(var s=0;s<this.instances.length;s++){var a=this.instances[s];if(!a.doNotSerialize){var l={name:a.name,id:a.id,position:a.position.asArray(),scaling:a.scaling.asArray()};a.parent&&(l.parentId=a.parent.id),a.rotationQuaternion?l.rotationQuaternion=a.rotationQuaternion.asArray():a.rotation&&(l.rotation=a.rotation.asArray()),e.instances.push(l),S.Animation.AppendSerializedAnimations(a,l),l.ranges=a.serializeAnimationRanges()}}S.Animation.AppendSerializedAnimations(this,e),e.ranges=this.serializeAnimationRanges(),e.layerMask=this.layerMask,e.alphaIndex=this.alphaIndex,e.hasVertexAlpha=this.hasVertexAlpha,e.overlayAlpha=this.overlayAlpha,e.overlayColor=this.overlayColor.asArray(),e.renderOverlay=this.renderOverlay,e.applyFog=this.applyFog,this.actionManager&&(e.actions=this.actionManager.serialize(this.name))},m.prototype._syncGeometryWithMorphTargetManager=function(){if(this.geometry){this._markSubMeshesAsAttributesDirty();var e=this._morphTargetManager;if(e&&e.vertexCount){if(e.vertexCount!==this.getTotalVertices())return S.Tools.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=null);for(var t=0;t<e.numInfluencers;t++){var i=e.getActiveTarget(t),r=i.getPositions();if(!r)return void S.Tools.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(S.VertexBuffer.PositionKind+t,r,!1,3);var n=i.getNormals();n&&this.geometry.setVerticesData(S.VertexBuffer.NormalKind+t,n,!1,3);var o=i.getTangents();o&&this.geometry.setVerticesData(S.VertexBuffer.TangentKind+t,o,!1,3)}}else for(t=0;this.geometry.isVerticesDataPresent(S.VertexBuffer.PositionKind+t);)this.geometry.removeVerticesData(S.VertexBuffer.PositionKind+t),this.geometry.isVerticesDataPresent(S.VertexBuffer.NormalKind+t)&&this.geometry.removeVerticesData(S.VertexBuffer.NormalKind+t),this.geometry.isVerticesDataPresent(S.VertexBuffer.TangentKind+t)&&this.geometry.removeVerticesData(S.VertexBuffer.TangentKind+t),t++}},m.Parse=function(e,t,i){var r;if((r=e.type&&"GroundMesh"===e.type?S.GroundMesh.Parse(e,t):new m(e.name,t)).id=e.id,S.Tags&&S.Tags.AddTagsTo(r,e.tags),r.position=S.Vector3.FromArray(e.position),void 0!==e.metadata&&(r.metadata=e.metadata),e.rotationQuaternion?r.rotationQuaternion=S.Quaternion.FromArray(e.rotationQuaternion):e.rotation&&(r.rotation=S.Vector3.FromArray(e.rotation)),r.scaling=S.Vector3.FromArray(e.scaling),e.localMatrix?r.setPreTransformMatrix(S.Matrix.FromArray(e.localMatrix)):e.pivotMatrix&&r.setPivotMatrix(S.Matrix.FromArray(e.pivotMatrix)),r.setEnabled(e.isEnabled),r.isVisible=e.isVisible,r.infiniteDistance=e.infiniteDistance,r.showBoundingBox=e.showBoundingBox,r.showSubMeshesBoundingBox=e.showSubMeshesBoundingBox,void 0!==e.applyFog&&(r.applyFog=e.applyFog),void 0!==e.pickable&&(r.isPickable=e.pickable),void 0!==e.alphaIndex&&(r.alphaIndex=e.alphaIndex),r.receiveShadows=e.receiveShadows,r.billboardMode=e.billboardMode,void 0!==e.visibility&&(r.visibility=e.visibility),r.checkCollisions=e.checkCollisions,void 0!==e.isBlocker&&(r.isBlocker=e.isBlocker),r._shouldGenerateFlatShading=e.useFlatShading,e.freezeWorldMatrix&&(r._waitingFreezeWorldMatrix=e.freezeWorldMatrix),e.parentId&&(r._waitingParentId=e.parentId),void 0!==e.actions&&(r._waitingActions=e.actions),void 0!==e.overlayAlpha&&(r.overlayAlpha=e.overlayAlpha),void 0!==e.overlayColor&&(r.overlayColor=S.Color3.FromArray(e.overlayColor)),void 0!==e.renderOverlay&&(r.renderOverlay=e.renderOverlay),r.isUnIndexed=!!e.isUnIndexed,r.hasVertexAlpha=e.hasVertexAlpha,e.delayLoadingFile?(r.delayLoadState=S.Engine.DELAYLOADSTATE_NOTLOADED,r.delayLoadingFile=i+e.delayLoadingFile,r._boundingInfo=new S.BoundingInfo(S.Vector3.FromArray(e.boundingBoxMinimum),S.Vector3.FromArray(e.boundingBoxMaximum)),e._binaryInfo&&(r._binaryInfo=e._binaryInfo),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(S.VertexBuffer.UVKind),e.hasUVs2&&r._delayInfo.push(S.VertexBuffer.UV2Kind),e.hasUVs3&&r._delayInfo.push(S.VertexBuffer.UV3Kind),e.hasUVs4&&r._delayInfo.push(S.VertexBuffer.UV4Kind),e.hasUVs5&&r._delayInfo.push(S.VertexBuffer.UV5Kind),e.hasUVs6&&r._delayInfo.push(S.VertexBuffer.UV6Kind),e.hasColors&&r._delayInfo.push(S.VertexBuffer.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(S.VertexBuffer.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(S.VertexBuffer.MatricesWeightsKind),r._delayLoadingFunction=S.Geometry._ImportGeometry,S.SceneLoader.ForceFullSceneLoadingForIncremental&&r._checkDelayState()):S.Geometry._ImportGeometry(e,r),e.materialId?r.setMaterialByID(e.materialId):r.material=null,-1<e.morphTargetManagerId&&(r.morphTargetManager=t.getMorphTargetManagerById(e.morphTargetManagerId)),-1<e.skeletonId&&(r.skeleton=t.getLastSkeletonByID(e.skeletonId),e.numBoneInfluencers&&(r.numBoneInfluencers=e.numBoneInfluencers)),e.animations){for(var n=0;n<e.animations.length;n++){var o=e.animations[n];r.animations.push(S.Animation.Parse(o))}S.Node.ParseAnimationRanges(r,e,t)}if(e.autoAnimate&&t.beginAnimation(r,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),e.layerMask&&!isNaN(e.layerMask)?r.layerMask=Math.abs(parseInt(e.layerMask)):r.layerMask=268435455,e.physicsImpostor&&(r.physicsImpostor=new S.PhysicsImpostor(r,e.physicsImpostor,{mass:e.physicsMass,friction:e.physicsFriction,restitution:e.physicsRestitution},t)),e.instances)for(var s=0;s<e.instances.length;s++){var a=e.instances[s],l=r.createInstance(a.name);if(a.id&&(l.id=a.id),S.Tags&&(a.tags?S.Tags.AddTagsTo(l,a.tags):S.Tags.AddTagsTo(l,e.tags)),l.position=S.Vector3.FromArray(a.position),a.parentId&&(l._waitingParentId=a.parentId),a.rotationQuaternion?l.rotationQuaternion=S.Quaternion.FromArray(a.rotationQuaternion):a.rotation&&(l.rotation=S.Vector3.FromArray(a.rotation)),l.scaling=S.Vector3.FromArray(a.scaling),null!=a.checkCollisions&&null!=a.checkCollisions&&(l.checkCollisions=a.checkCollisions),null!=a.pickable&&null!=a.pickable&&(l.isPickable=a.pickable),null!=a.showBoundingBox&&null!=a.showBoundingBox&&(l.showBoundingBox=a.showBoundingBox),null!=a.showSubMeshesBoundingBox&&null!=a.showSubMeshesBoundingBox&&(l.showSubMeshesBoundingBox=a.showSubMeshesBoundingBox),null!=a.alphaIndex&&null!=a.showSubMeshesBoundingBox&&(l.alphaIndex=a.alphaIndex),a.physicsImpostor&&(l.physicsImpostor=new S.PhysicsImpostor(l,a.physicsImpostor,{mass:a.physicsMass,friction:a.physicsFriction,restitution:a.physicsRestitution},t)),a.animations){for(n=0;n<a.animations.length;n++)o=a.animations[n],l.animations.push(S.Animation.Parse(o));S.Node.ParseAnimationRanges(l,a,t),a.autoAnimate&&t.beginAnimation(l,a.autoAnimateFrom,a.autoAnimateTo,a.autoAnimateLoop,a.autoAnimateSpeed||1)}}return r},m.CreateRibbon=function(e,t,i,r,n,o,s,a,l){return void 0===i&&(i=!1),void 0===s&&(s=!1),S.MeshBuilder.CreateRibbon(e,{pathArray:t,closeArray:i,closePath:r,offset:n,updatable:s,sideOrientation:a,instance:l},o)},m.CreateDisc=function(e,t,i,r,n,o){void 0===r&&(r=null);var s={radius:t,tessellation:i,sideOrientation:o,updatable:n};return S.MeshBuilder.CreateDisc(e,s,r)},m.CreateBox=function(e,t,i,r,n){void 0===i&&(i=null);var o={size:t,sideOrientation:n,updatable:r};return S.MeshBuilder.CreateBox(e,o,i)},m.CreateSphere=function(e,t,i,r,n,o){var s={segments:t,diameterX:i,diameterY:i,diameterZ:i,sideOrientation:o,updatable:n};return S.MeshBuilder.CreateSphere(e,s,r)},m.CreateCylinder=function(e,t,i,r,n,o,s,a,l){void 0!==s&&s instanceof S.Scene||(void 0!==s&&(l=a||m.DEFAULTSIDE,a=s),s=o,o=1);var c={height:t,diameterTop:i,diameterBottom:r,tessellation:n,subdivisions:o,sideOrientation:l,updatable:a};return S.MeshBuilder.CreateCylinder(e,c,s)},m.CreateTorus=function(e,t,i,r,n,o,s){var a={diameter:t,thickness:i,tessellation:r,sideOrientation:s,updatable:o};return S.MeshBuilder.CreateTorus(e,a,n)},m.CreateTorusKnot=function(e,t,i,r,n,o,s,a,l,c){var h={radius:t,tube:i,radialSegments:r,tubularSegments:n,p:o,q:s,sideOrientation:c,updatable:l};return S.MeshBuilder.CreateTorusKnot(e,h,a)},m.CreateLines=function(e,t,i,r,n){void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=null);var o={points:t,updatable:r,instance:n};return S.MeshBuilder.CreateLines(e,o,i)},m.CreateDashedLines=function(e,t,i,r,n,o,s,a){void 0===o&&(o=null);var l={points:t,dashSize:i,gapSize:r,dashNb:n,updatable:s,instance:a};return S.MeshBuilder.CreateDashedLines(e,l,o)},m.CreatePolygon=function(e,t,i,r,n,o){var s={shape:t,holes:r,updatable:n,sideOrientation:o};return S.MeshBuilder.CreatePolygon(e,s,i)},m.ExtrudePolygon=function(e,t,i,r,n,o,s){var a={shape:t,holes:n,depth:i,updatable:o,sideOrientation:s};return S.MeshBuilder.ExtrudePolygon(e,a,r)},m.ExtrudeShape=function(e,t,i,r,n,o,s,a,l,c){void 0===s&&(s=null);var h={shape:t,path:i,scale:r,rotation:n,cap:0===o?0:o||m.NO_CAP,sideOrientation:l,instance:c,updatable:a};return S.MeshBuilder.ExtrudeShape(e,h,s)},m.ExtrudeShapeCustom=function(e,t,i,r,n,o,s,a,l,c,h,u){var d={shape:t,path:i,scaleFunction:r,rotationFunction:n,ribbonCloseArray:o,ribbonClosePath:s,cap:0===a?0:a||m.NO_CAP,sideOrientation:h,instance:u,updatable:c};return S.MeshBuilder.ExtrudeShapeCustom(e,d,l)},m.CreateLathe=function(e,t,i,r,n,o,s){var a={shape:t,radius:i,tessellation:r,sideOrientation:s,updatable:o};return S.MeshBuilder.CreateLathe(e,a,n)},m.CreatePlane=function(e,t,i,r,n){var o={size:t,width:t,height:t,sideOrientation:n,updatable:r};return S.MeshBuilder.CreatePlane(e,o,i)},m.CreateGround=function(e,t,i,r,n,o){var s={width:t,height:i,subdivisions:r,updatable:o};return S.MeshBuilder.CreateGround(e,s,n)},m.CreateTiledGround=function(e,t,i,r,n,o,s,a,l){var c={xmin:t,zmin:i,xmax:r,zmax:n,subdivisions:o,precision:s,updatable:l};return S.MeshBuilder.CreateTiledGround(e,c,a)},m.CreateGroundFromHeightMap=function(e,t,i,r,n,o,s,a,l,c,h){var u={width:i,height:r,subdivisions:n,minHeight:o,maxHeight:s,updatable:l,onReady:c,alphaFilter:h};return S.MeshBuilder.CreateGroundFromHeightMap(e,t,u,a)},m.CreateTube=function(e,t,i,r,n,o,s,a,l,c){var h={path:t,radius:i,tessellation:r,radiusFunction:n,arc:1,cap:o,updatable:a,sideOrientation:l,instance:c};return S.MeshBuilder.CreateTube(e,h,s)},m.CreatePolyhedron=function(e,t,i){return S.MeshBuilder.CreatePolyhedron(e,t,i)},m.CreateIcoSphere=function(e,t,i){return S.MeshBuilder.CreateIcoSphere(e,t,i)},m.CreateDecal=function(e,t,i,r,n,o){var s={position:i,normal:r,size:n,angle:o};return S.MeshBuilder.CreateDecal(e,t,s)},m.prototype.setPositionsForCPUSkinning=function(){if(!this._sourcePositions){var e=this.getVerticesData(S.VertexBuffer.PositionKind);if(!e)return this._sourcePositions;this._sourcePositions=new Float32Array(e),this.isVertexBufferUpdatable(S.VertexBuffer.PositionKind)||this.setVerticesData(S.VertexBuffer.PositionKind,e,!0)}return this._sourcePositions},m.prototype.setNormalsForCPUSkinning=function(){if(!this._sourceNormals){var e=this.getVerticesData(S.VertexBuffer.NormalKind);if(!e)return this._sourceNormals;this._sourceNormals=new Float32Array(e),this.isVertexBufferUpdatable(S.VertexBuffer.NormalKind)||this.setVerticesData(S.VertexBuffer.NormalKind,e,!0)}return this._sourceNormals},m.prototype.applySkeleton=function(e){if(!this.geometry)return this;if(this.geometry._softwareSkinningFrameId==this.getScene().getFrameId())return this;if(this.geometry._softwareSkinningFrameId=this.getScene().getFrameId(),!this.isVerticesDataPresent(S.VertexBuffer.PositionKind))return this;if(!this.isVerticesDataPresent(S.VertexBuffer.NormalKind))return this;if(!this.isVerticesDataPresent(S.VertexBuffer.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(S.VertexBuffer.MatricesWeightsKind))return this;if(!this._sourcePositions){var t=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=t}this._sourceNormals||this.setNormalsForCPUSkinning();var i=this.getVerticesData(S.VertexBuffer.PositionKind);if(!i)return this;i instanceof Float32Array||(i=new Float32Array(i));var r=this.getVerticesData(S.VertexBuffer.NormalKind);if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r));var n=this.getVerticesData(S.VertexBuffer.MatricesIndicesKind),o=this.getVerticesData(S.VertexBuffer.MatricesWeightsKind);if(!o||!n)return this;for(var s,a=4<this.numBoneInfluencers,l=a?this.getVerticesData(S.VertexBuffer.MatricesIndicesExtraKind):null,c=a?this.getVerticesData(S.VertexBuffer.MatricesWeightsExtraKind):null,h=e.getTransformMatrices(this),u=S.Vector3.Zero(),d=new S.Matrix,f=new S.Matrix,p=0,m=0;m<i.length;m+=3,p+=4){var _;for(s=0;s<4;s++)0<(_=o[p+s])&&(S.Matrix.FromFloat32ArrayToRefScaled(h,Math.floor(16*n[p+s]),_,f),d.addToSelf(f));if(a)for(s=0;s<4;s++)0<(_=c[p+s])&&(S.Matrix.FromFloat32ArrayToRefScaled(h,Math.floor(16*l[p+s]),_,f),d.addToSelf(f));S.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[m],this._sourcePositions[m+1],this._sourcePositions[m+2],d,u),u.toArray(i,m),S.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[m],this._sourceNormals[m+1],this._sourceNormals[m+2],d,u),u.toArray(r,m),d.reset()}return this.updateVerticesData(S.VertexBuffer.PositionKind,i),this.updateVerticesData(S.VertexBuffer.NormalKind,r),this},m.MinMax=function(e){var n=null,o=null;return e.forEach((function(e,t,i){var r=e.getBoundingInfo().boundingBox;n&&o?(n.minimizeInPlace(r.minimumWorld),o.maximizeInPlace(r.maximumWorld)):(n=r.minimumWorld,o=r.maximumWorld)})),n&&o?{min:n,max:o}:{min:S.Vector3.Zero(),max:S.Vector3.Zero()}},m.Center=function(e){var t=e instanceof Array?m.MinMax(e):e;return S.Vector3.Center(t.min,t.max)},m.MergeMeshes=function(e,t,i,r,n){var o;if(void 0===t&&(t=!0),!i){var s=0;for(o=0;o<e.length;o++)if(e[o]&&65536<(s+=e[o].getTotalVertices()))return S.Tools.Warn("Cannot merge meshes because resulting mesh will have more than 65536 vertices. Please use allow32BitsIndices = true to use 32 bits indices"),null}var a,l=null,c=new Array,h=null;for(o=0;o<e.length;o++)if(e[o]){var u=e[o].computeWorldMatrix(!0);(a=S.VertexData.ExtractFromMesh(e[o],!0,!0)).transform(u),l?l.merge(a,i):(l=a,h=e[o]),n&&c.push(e[o].getTotalIndices())}if(h=h,r||(r=new m(h.name+"_merged",h.getScene())),l.applyToMesh(r),r.material=h.material,r.checkCollisions=h.checkCollisions,t)for(o=0;o<e.length;o++)e[o]&&e[o].dispose();if(n){r.releaseSubMeshes();for(var d=o=0;o<c.length;)S.SubMesh.CreateFromIndices(0,d,c[o],r),d+=c[o],o++}return r},m.FRONTSIDE=0,m.BACKSIDE=1,m.DOUBLESIDE=2,m.DEFAULTSIDE=0,m.NO_CAP=0,m.CAP_START=1,m.CAP_END=2,m.CAP_ALL=3,m})(S.AbstractMesh);S.Mesh=i})($a||($a={})),ne=$a||($a={}),oe=(function(){function e(){}return Object.defineProperty(e.prototype,"effect",{get:function(){return this._materialEffect},enumerable:!0,configurable:!0}),e.prototype.setEffect=function(e,t){void 0===t&&(t=null),this._materialEffect!==e?(this._materialDefines=t,this._materialEffect=e):e||(this._materialDefines=null)},e})(),se=(function(c){function h(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var l=c.call(this)||this;return l.materialIndex=e,l.verticesStart=t,l.verticesCount=i,l.indexStart=r,l.indexCount=n,l._renderId=0,l._mesh=o,l._renderingMesh=s||o,o.subMeshes.push(l),l._trianglePlanes=[],l._id=o.subMeshes.length-1,a&&(l.refreshBoundingInfo(),o.computeWorldMatrix(!0)),l}return T(h,c),h.AddToMesh=function(e,t,i,r,n,o,s,a){return void 0===a&&(a=!0),new h(e,t,i,r,n,o,s,a)},Object.defineProperty(h.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount===this._mesh.getTotalVertices()},enumerable:!0,configurable:!0}),h.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},h.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},h.prototype.getMesh=function(){return this._mesh},h.prototype.getRenderingMesh=function(){return this._renderingMesh},h.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},h.prototype.refreshBoundingInfo=function(){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;var e=this._renderingMesh.getVerticesData(ne.VertexBuffer.PositionKind);if(!e)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var t,i=this._renderingMesh.getIndices();if(0===this.indexStart&&this.indexCount===i.length){var r=this._renderingMesh.getBoundingInfo();t={minimum:r.minimum.clone(),maximum:r.maximum.clone()}}else t=ne.Tools.ExtractMinAndMaxIndexed(e,i,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo=new ne.BoundingInfo(t.minimum,t.maximum),this},h.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},h.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t.update(e),this},h.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e,this._mesh.cullingStrategy)},h.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)},h.prototype.render=function(e){return this._renderingMesh.render(this,e),this},h.prototype._getLinesIndexBuffer=function(e,t){if(!this._linesIndexBuffer){for(var i=[],r=this.indexStart;r<this.indexStart+this.indexCount;r+=3)i.push(e[r],e[r+1],e[r+1],e[r+2],e[r+2],e[r]);this._linesIndexBuffer=t.createIndexBuffer(i),this._linesIndexCount=i.length}return this._linesIndexBuffer},h.prototype.canIntersects=function(e){var t=this.getBoundingInfo();return!!t&&e.intersectsBox(t.boundingBox)},h.prototype.intersects=function(e,t,i,r){var n=this.getMaterial();if(!n)return null;switch(n.fillMode){case ne.Material.PointListDrawMode:case ne.Material.LineListDrawMode:case ne.Material.LineLoopDrawMode:case ne.Material.LineStripDrawMode:case ne.Material.TriangleFanDrawMode:case ne.Material.TriangleStripDrawMode:return null}if(ne.LinesMesh){var o=this._mesh instanceof ne.InstancedMesh?this._mesh.sourceMesh:this._mesh;if(o instanceof ne.LinesMesh){var s=o;return this._intersectLines(e,t,i,s.intersectionThreshold,r)}}return this._intersectTriangles(e,t,i,r)},h.prototype._intersectLines=function(e,t,i,r,n){for(var o=null,s=this.indexStart;s<this.indexStart+this.indexCount;s+=2){var a=t[i[s]],l=t[i[s+1]],c=e.intersectionSegment(a,l,r);if(!(c<0)&&((n||!o||c<o.distance)&&(o=new ne.IntersectionInfo(null,null,c),n)))break}return o},h.prototype._intersectTriangles=function(e,t,i,r){for(var n=null,o=this.indexStart;o<this.indexStart+this.indexCount;o+=3){var s=t[i[o]],a=t[i[o+1]],l=t[i[o+2]],c=e.intersectsTriangle(s,a,l);if(c){if(c.distance<0)continue;if((r||!n||c.distance<n.distance)&&((n=c).faceId=o/3,r))break}}return n},h.prototype._rebuild=function(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)},h.prototype.clone=function(e,t){var i=new h(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,e,t,!1);if(!this.IsGlobal){var r=this.getBoundingInfo();if(!r)return i;i._boundingInfo=new ne.BoundingInfo(r.minimum,r.maximum)}return i},h.prototype.dispose=function(){this._linesIndexBuffer&&(this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer),this._linesIndexBuffer=null);var e=this._mesh.subMeshes.indexOf(this);this._mesh.subMeshes.splice(e,1)},h.CreateFromIndices=function(e,t,i,r,n){for(var o=Number.MAX_VALUE,s=-Number.MAX_VALUE,a=(n=n||r).getIndices(),l=t;l<t+i;l++){var c=a[l];c<o&&(o=c),s<c&&(s=c)}return new h(e,o,s-o+1,t,i,r,n)},h})(ne.BaseSubMesh=oe),ne.SubMesh=se;var le,ce,he,ue,de,fe,pe,me,_e,ge,ve,ye,be,Te,xe,Ee,Ae,Pe,Se,Re,Me,Ce,Oe,De,Ie,we,Le,Fe,Be,Ne,Ve,Ue,ze,Ge,ke,We,He,Xe,je,Ye,Ke,Qe,Ze,qe,Je,$e,et,tt,it,rt,nt,ot,st,at,lt,ct,ht,ut,dt,ft,pt,mt,_t,gt,vt,yt,bt,Tt,xt,Et,At,Pt,St,Rt,Mt,Ct,Ot,Dt,It,wt,Lt,Ft,Bt,Nt,Vt,Ut,zt,Gt,kt,Wt,Ht,Xt,jt,Yt,Kt,Qt,Zt,qt,Jt,$t,ei,ti,ii,ri,ni,oi,si,ai,li,ci,hi,ui,di,fi,pi,mi,_i,gi,vi,yi,bi,Ti,xi,Ei,Ai,Pi,Si,Ri,Mi,Ci,Oi,Di,Ii,wi,Li,Fi,Bi,Ni,Vi,Ui,zi,Gi,ki,Wi,Hi,Xi,ji,Yi,Ki,Qi,Zi,qi,Ji;ae=this&&this.__assign||function(){return(ae=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};!(function(l){var e=(function(){function e(){this._isDirty=!0,this._areLightsDirty=!0,this._areAttributesDirty=!0,this._areTexturesDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._normals=!1,this._uvs=!1,this._needNormals=!1,this._needUVs=!1}return Object.defineProperty(e.prototype,"isDirty",{get:function(){return this._isDirty},enumerable:!0,configurable:!0}),e.prototype.markAsProcessed=function(){this._isDirty=!1,this._areAttributesDirty=!1,this._areTexturesDirty=!1,this._areFresnelDirty=!1,this._areLightsDirty=!1,this._areMiscDirty=!1,this._areImageProcessingDirty=!1},e.prototype.markAsUnprocessed=function(){this._isDirty=!0},e.prototype.markAllAsDirty=function(){this._areTexturesDirty=!0,this._areAttributesDirty=!0,this._areLightsDirty=!0,this._areFresnelDirty=!0,this._areMiscDirty=!0,this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsImageProcessingDirty=function(){this._areImageProcessingDirty=!0,this._isDirty=!0},e.prototype.markAsLightDirty=function(){this._areLightsDirty=!0,this._isDirty=!0},e.prototype.markAsAttributesDirty=function(){this._areAttributesDirty=!0,this._isDirty=!0},e.prototype.markAsTexturesDirty=function(){this._areTexturesDirty=!0,this._isDirty=!0},e.prototype.markAsFresnelDirty=function(){this._areFresnelDirty=!0,this._isDirty=!0},e.prototype.markAsMiscDirty=function(){this._areMiscDirty=!0,this._isDirty=!0},e.prototype.rebuild=function(){this._keys&&delete this._keys,this._keys=[];for(var e=0,t=Object.keys(this);e<t.length;e++){var i=t[e];"_"!==i[0]&&this._keys.push(i)}},e.prototype.isEqual=function(e){if(this._keys.length!==e._keys.length)return!1;for(var t=0;t<this._keys.length;t++){var i=this._keys[t];if(this[i]!==e[i])return!1}return!0},e.prototype.cloneTo=function(e){this._keys.length!==e._keys.length&&(e._keys=this._keys.slice(0));for(var t=0;t<this._keys.length;t++){var i=this._keys[t];e[i]=this[i]}},e.prototype.reset=function(){for(var e=0;e<this._keys.length;e++){var t=this._keys[e];switch(typeof this[t]){case"number":this[t]=0;break;case"string":this[t]="";break;default:this[t]=!1}}},e.prototype.toString=function(){for(var e="",t=0;t<this._keys.length;t++){var i=this._keys[t],r=this[i];switch(typeof r){case"number":case"string":e+="#define "+i+" "+r+"\n";break;default:r&&(e+="#define "+i+"\n")}}return e},e})();l.MaterialDefines=e;var t=(function(){function n(e,t,i){this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this.doNotSerialize=!1,this.storeEffectOnSubMeshes=!1,this.onDisposeObservable=new l.Observable,this._alphaMode=l.Engine.ALPHA_COMBINE,this._needDepthPrePass=!1,this.disableDepthWrite=!1,this.forceDepthWrite=!1,this.separateCullingPass=!1,this._fogEnabled=!0,this.pointSize=1,this.zOffset=0,this._wasPreviouslyReady=!1,this._fillMode=n.TriangleFillMode,this.name=e,this.id=e||l.Tools.RandomId(),this._scene=t||l.Engine.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._scene.useRightHandedSystem?this.sideOrientation=n.ClockWiseSideOrientation:this.sideOrientation=n.CounterClockWiseSideOrientation,this._uniformBuffer=new l.UniformBuffer(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,i||(this._scene.materials.push(this),this._scene.onNewMaterialAddedObservable.notifyObservers(this))}return Object.defineProperty(n,"TriangleFillMode",{get:function(){return n._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"WireFrameFillMode",{get:function(){return n._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"PointFillMode",{get:function(){return n._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"PointListDrawMode",{get:function(){return n._PointListDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LineListDrawMode",{get:function(){return n._LineListDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LineLoopDrawMode",{get:function(){return n._LineLoopDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LineStripDrawMode",{get:function(){return n._LineStripDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TriangleStripDrawMode",{get:function(){return n._TriangleStripDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TriangleFanDrawMode",{get:function(){return n._TriangleFanDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ClockWiseSideOrientation",{get:function(){return n._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(n,"CounterClockWiseSideOrientation",{get:function(){return n._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"alpha",{get:function(){return this._alpha},set:function(e){this._alpha!==e&&(this._alpha=e,this.markAsDirty(n.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(n.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"hasRenderTargetTextures",{get:function(){return!1},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onBindObservable",{get:function(){return this._onBindObservable||(this._onBindObservable=new l.Observable),this._onBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onUnBindObservable",{get:function(){return this._onUnBindObservable||(this._onUnBindObservable=new l.Observable),this._onUnBindObservable},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(e){this._alphaMode!==e&&(this._alphaMode=e,this.markAsDirty(n.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"needDepthPrePass",{get:function(){return this._needDepthPrePass},set:function(e){this._needDepthPrePass!==e&&(this._needDepthPrePass=e,this._needDepthPrePass&&(this.checkReadyOnEveryCall=!0))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(n.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"wireframe",{get:function(){switch(this._fillMode){case n.WireFrameFillMode:case n.LineListDrawMode:case n.LineLoopDrawMode:case n.LineStripDrawMode:return!0}return this._scene.forceWireframe},set:function(e){this.fillMode=e?n.WireFrameFillMode:n.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"pointsCloud",{get:function(){switch(this._fillMode){case n.PointFillMode:case n.PointListDrawMode:return!0}return this._scene.forcePointsCloud},set:function(e){this.fillMode=e?n.PointFillMode:n.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(n.MiscDirtyFlag))},enumerable:!0,configurable:!0}),n.prototype.toString=function(e){return"Name: "+this.name},n.prototype.getClassName=function(){return"Material"},Object.defineProperty(n.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),n.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},n.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},n.prototype.isReady=function(e,t){return!0},n.prototype.isReadyForSubMesh=function(e,t,i){return!1},n.prototype.getEffect=function(){return this._effect},n.prototype.getScene=function(){return this._scene},n.prototype.needAlphaBlending=function(){return this.alpha<1},n.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha},n.prototype.needAlphaTesting=function(){return!1},n.prototype.getAlphaTestTexture=function(){return null},n.prototype.markDirty=function(){this._wasPreviouslyReady=!1},n.prototype._preBind=function(e,t){void 0===t&&(t=null);var i=this._scene.getEngine(),r=(null==t?this.sideOrientation:t)===n.ClockWiseSideOrientation;return i.enableEffect(e||this._effect),i.setState(this.backFaceCulling,this.zOffset,!1,r),r},n.prototype.bind=function(e,t){},n.prototype.bindForSubMesh=function(e,t,i){},n.prototype.bindOnlyWorldMatrix=function(e){},n.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},n.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},n.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},n.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},n.prototype._afterBind=function(e){if((this._scene._cachedMaterial=this)._scene._cachedVisibility=e?e.visibility:1,this._onBindObservable&&e&&this._onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},n.prototype.unbind=function(){(this._onUnBindObservable&&this._onUnBindObservable.notifyObservers(this),this.disableDepthWrite)&&this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)},n.prototype.getActiveTextures=function(){return[]},n.prototype.hasTexture=function(e){return!1},n.prototype.clone=function(e){return null},n.prototype.getBindedMeshes=function(){for(var e=new Array,t=0;t<this._scene.meshes.length;t++){var i=this._scene.meshes[t];i.material===this&&e.push(i)}return e},n.prototype.forceCompilation=function(t,i,e){var r=this,n=ae({clipPlane:!1},e),o=new l.BaseSubMesh,s=this.getScene(),a=function(){if(r._scene&&r._scene.getEngine()){o._materialDefines&&(o._materialDefines._renderId=-1);var e=s.clipPlane;n.clipPlane&&(s.clipPlane=new l.Plane(0,0,0,1)),r.storeEffectOnSubMeshes?r.isReadyForSubMesh(t,o)?i&&i(r):setTimeout(a,16):r.isReady(t)?i&&i(r):setTimeout(a,16),n.clipPlane&&(s.clipPlane=e)}};a()},n.prototype.forceCompilationAsync=function(t,i){var r=this;return new Promise(function(e){r.forceCompilation(t,(function(){e()}),i)})},n.prototype.markAsDirty=function(e){e&n.TextureDirtyFlag&&this._markAllSubMeshesAsTexturesDirty(),e&n.LightDirtyFlag&&this._markAllSubMeshesAsLightsDirty(),e&n.FresnelDirtyFlag&&this._markAllSubMeshesAsFresnelDirty(),e&n.AttributesDirtyFlag&&this._markAllSubMeshesAsAttributesDirty(),e&n.MiscDirtyFlag&&this._markAllSubMeshesAsMiscDirty(),this.getScene().resetCachedMaterial()},n.prototype._markAllSubMeshesAsDirty=function(e){for(var t=0,i=this.getScene().meshes;t<i.length;t++){var r=i[t];if(r.subMeshes)for(var n=0,o=r.subMeshes;n<o.length;n++){var s=o[n];s.getMaterial()===this&&(s._materialDefines&&e(s._materialDefines))}}},n.prototype._markAllSubMeshesAsImageProcessingDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsImageProcessingDirty()}))},n.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsTexturesDirty()}))},n.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsFresnelDirty()}))},n.prototype._markAllSubMeshesAsFresnelAndMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){e.markAsFresnelDirty(),e.markAsMiscDirty()}))},n.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},n.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},n.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsMiscDirty()}))},n.prototype._markAllSubMeshesAsTexturesAndMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){e.markAsTexturesDirty(),e.markAsMiscDirty()}))},n.prototype.dispose=function(e,t){this.getScene().stopAnimation(this),this.getScene().freeProcessedMaterials();var i=this._scene.materials.indexOf(this);for(0<=i&&this._scene.materials.splice(i,1),this._scene.onMaterialRemovedObservable.notifyObservers(this),i=0;i<this._scene.meshes.length;i++){var r=this._scene.meshes[i];if(r.material===this&&(r.material=null,r.geometry)){var n=r.geometry;if(this.storeEffectOnSubMeshes)for(var o=0,s=r.subMeshes;o<s.length;o++){var a=s[o];n._releaseVertexArrayObject(a._materialEffect),e&&a._materialEffect&&this._scene.getEngine()._releaseEffect(a._materialEffect)}else n._releaseVertexArrayObject(this._effect)}}this._uniformBuffer.dispose(),e&&this._effect&&(this.storeEffectOnSubMeshes||this._scene.getEngine()._releaseEffect(this._effect),this._effect=null),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this._onBindObservable&&this._onBindObservable.clear(),this._onUnBindObservable&&this._onUnBindObservable.clear()},n.prototype.serialize=function(){return l.SerializationHelper.Serialize(this)},n.ParseMultiMaterial=function(e,t){var i=new l.MultiMaterial(e.name,t);i.id=e.id,l.Tags&&l.Tags.AddTagsTo(i,e.tags);for(var r=0;r<e.materials.length;r++){var n=e.materials[r];n?i.subMaterials.push(t.getMaterialByID(n)):i.subMaterials.push(null)}return i},n.Parse=function(e,t,i){return e.customType&&"BABYLON.StandardMaterial"!==e.customType?"BABYLON.PBRMaterial"!==e.customType||!e.overloadedAlbedo||(e.customType="BABYLON.LegacyPBRMaterial",l.LegacyPBRMaterial)?l.Tools.Instantiate(e.customType).Parse(e,t,i):void l.Tools.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."):l.StandardMaterial.Parse(e,t,i)},n._TriangleFillMode=0,n._WireFrameFillMode=1,n._PointFillMode=2,n._PointListDrawMode=3,n._LineListDrawMode=4,n._LineLoopDrawMode=5,n._LineStripDrawMode=6,n._TriangleStripDrawMode=7,n._TriangleFanDrawMode=8,n._ClockWiseSideOrientation=0,n._CounterClockWiseSideOrientation=1,n.TextureDirtyFlag=1,n.LightDirtyFlag=2,n.FresnelDirtyFlag=4,n.AttributesDirtyFlag=8,n.MiscDirtyFlag=16,n.AllDirtyFlag=31,b([l.serialize()],n.prototype,"id",void 0),b([l.serialize()],n.prototype,"uniqueId",void 0),b([l.serialize()],n.prototype,"name",void 0),b([l.serialize()],n.prototype,"checkReadyOnEveryCall",void 0),b([l.serialize()],n.prototype,"checkReadyOnlyOnce",void 0),b([l.serialize()],n.prototype,"state",void 0),b([l.serialize("alpha")],n.prototype,"_alpha",void 0),b([l.serialize("backFaceCulling")],n.prototype,"_backFaceCulling",void 0),b([l.serialize()],n.prototype,"sideOrientation",void 0),b([l.serialize("alphaMode")],n.prototype,"_alphaMode",void 0),b([l.serialize()],n.prototype,"_needDepthPrePass",void 0),b([l.serialize()],n.prototype,"disableDepthWrite",void 0),b([l.serialize()],n.prototype,"forceDepthWrite",void 0),b([l.serialize()],n.prototype,"separateCullingPass",void 0),b([l.serialize("fogEnabled")],n.prototype,"_fogEnabled",void 0),b([l.serialize()],n.prototype,"pointSize",void 0),b([l.serialize()],n.prototype,"zOffset",void 0),b([l.serialize()],n.prototype,"wireframe",null),b([l.serialize()],n.prototype,"pointsCloud",null),b([l.serialize()],n.prototype,"fillMode",null),n})();l.Material=t})($a||($a={})),le=$a||($a={}),ce=(function(){function s(e,t,i){this._engine=e,this._noUBO=!e.supportsUniformBuffers,this._dynamic=i,this._data=t||[],this._uniformLocations={},this._uniformSizes={},this._uniformLocationPointer=0,this._needSync=!1,this._noUBO?(this.updateMatrix3x3=this._updateMatrix3x3ForEffect,this.updateMatrix2x2=this._updateMatrix2x2ForEffect,this.updateFloat=this._updateFloatForEffect,this.updateFloat2=this._updateFloat2ForEffect,this.updateFloat3=this._updateFloat3ForEffect,this.updateFloat4=this._updateFloat4ForEffect,this.updateMatrix=this._updateMatrixForEffect,this.updateVector3=this._updateVector3ForEffect,this.updateVector4=this._updateVector4ForEffect,this.updateColor3=this._updateColor3ForEffect,this.updateColor4=this._updateColor4ForEffect):(this._engine._uniformBuffers.push(this),this.updateMatrix3x3=this._updateMatrix3x3ForUniform,this.updateMatrix2x2=this._updateMatrix2x2ForUniform,this.updateFloat=this._updateFloatForUniform,this.updateFloat2=this._updateFloat2ForUniform,this.updateFloat3=this._updateFloat3ForUniform,this.updateFloat4=this._updateFloat4ForUniform,this.updateMatrix=this._updateMatrixForUniform,this.updateVector3=this._updateVector3ForUniform,this.updateVector4=this._updateVector4ForUniform,this.updateColor3=this._updateColor3ForUniform,this.updateColor4=this._updateColor4ForUniform)}return Object.defineProperty(s.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!0,configurable:!0}),s.prototype.isDynamic=function(){return void 0!==this._dynamic},s.prototype.getData=function(){return this._bufferData},s.prototype.getBuffer=function(){return this._buffer},s.prototype._fillAlignment=function(e){var t;if(t=e<=2?e:4,this._uniformLocationPointer%t!=0){var i=this._uniformLocationPointer;this._uniformLocationPointer+=t-this._uniformLocationPointer%t;for(var r=this._uniformLocationPointer-i,n=0;n<r;n++)this._data.push(0)}},s.prototype.addUniform=function(e,t){if(!this._noUBO&&void 0===this._uniformLocations[e]){var i;if(t instanceof Array)t=(i=t).length;else{t=t,i=[];for(var r=0;r<t;r++)i.push(0)}this._fillAlignment(t),this._uniformSizes[e]=t,this._uniformLocations[e]=this._uniformLocationPointer,this._uniformLocationPointer+=t;for(r=0;r<t;r++)this._data.push(i[r]);this._needSync=!0}},s.prototype.addMatrix=function(e,t){this.addUniform(e,Array.prototype.slice.call(t.toArray()))},s.prototype.addFloat2=function(e,t,i){var r=[t,i];this.addUniform(e,r)},s.prototype.addFloat3=function(e,t,i,r){var n=[t,i,r];this.addUniform(e,n)},s.prototype.addColor3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},s.prototype.addColor4=function(e,t,i){var r=new Array;t.toArray(r),r.push(i),this.addUniform(e,r)},s.prototype.addVector3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},s.prototype.addMatrix3x3=function(e){this.addUniform(e,12)},s.prototype.addMatrix2x2=function(e){this.addUniform(e,8)},s.prototype.create=function(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)},s.prototype._rebuild=function(){this._noUBO||(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData):this._buffer=this._engine.createUniformBuffer(this._bufferData))},s.prototype.update=function(){this._buffer?(this._dynamic||this._needSync)&&(this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1):this.create()},s.prototype.updateUniform=function(e,t,i){var r=this._uniformLocations[e];if(void 0===r){if(this._buffer)return void le.Tools.Error("Cannot add an uniform after UBO has been created.");this.addUniform(e,i),r=this._uniformLocations[e]}if(this._buffer||this.create(),this._dynamic)for(o=0;o<i;o++)this._bufferData[r+o]=t[o];else{for(var n=!1,o=0;o<i;o++)this._bufferData[r+o]!==t[o]&&(n=!0,this._bufferData[r+o]=t[o]);this._needSync=this._needSync||n}},s.prototype._updateMatrix3x3ForUniform=function(e,t){for(var i=0;i<3;i++)s._tempBuffer[4*i]=t[3*i],s._tempBuffer[4*i+1]=t[3*i+1],s._tempBuffer[4*i+2]=t[3*i+2],s._tempBuffer[4*i+3]=0;this.updateUniform(e,s._tempBuffer,12)},s.prototype._updateMatrix3x3ForEffect=function(e,t){this._currentEffect.setMatrix3x3(e,t)},s.prototype._updateMatrix2x2ForEffect=function(e,t){this._currentEffect.setMatrix2x2(e,t)},s.prototype._updateMatrix2x2ForUniform=function(e,t){for(var i=0;i<2;i++)s._tempBuffer[4*i]=t[2*i],s._tempBuffer[4*i+1]=t[2*i+1],s._tempBuffer[4*i+2]=0,s._tempBuffer[4*i+3]=0;this.updateUniform(e,s._tempBuffer,8)},s.prototype._updateFloatForEffect=function(e,t){this._currentEffect.setFloat(e,t)},s.prototype._updateFloatForUniform=function(e,t){s._tempBuffer[0]=t,this.updateUniform(e,s._tempBuffer,1)},s.prototype._updateFloat2ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setFloat2(e+r,t,i)},s.prototype._updateFloat2ForUniform=function(e,t,i,r){void 0===r&&(r=""),s._tempBuffer[0]=t,s._tempBuffer[1]=i,this.updateUniform(e,s._tempBuffer,2)},s.prototype._updateFloat3ForEffect=function(e,t,i,r,n){void 0===n&&(n=""),this._currentEffect.setFloat3(e+n,t,i,r)},s.prototype._updateFloat3ForUniform=function(e,t,i,r,n){void 0===n&&(n=""),s._tempBuffer[0]=t,s._tempBuffer[1]=i,s._tempBuffer[2]=r,this.updateUniform(e,s._tempBuffer,3)},s.prototype._updateFloat4ForEffect=function(e,t,i,r,n,o){void 0===o&&(o=""),this._currentEffect.setFloat4(e+o,t,i,r,n)},s.prototype._updateFloat4ForUniform=function(e,t,i,r,n,o){void 0===o&&(o=""),s._tempBuffer[0]=t,s._tempBuffer[1]=i,s._tempBuffer[2]=r,s._tempBuffer[3]=n,this.updateUniform(e,s._tempBuffer,4)},s.prototype._updateMatrixForEffect=function(e,t){this._currentEffect.setMatrix(e,t)},s.prototype._updateMatrixForUniform=function(e,t){this.updateUniform(e,t.toArray(),16)},s.prototype._updateVector3ForEffect=function(e,t){this._currentEffect.setVector3(e,t)},s.prototype._updateVector3ForUniform=function(e,t){t.toArray(s._tempBuffer),this.updateUniform(e,s._tempBuffer,3)},s.prototype._updateVector4ForEffect=function(e,t){this._currentEffect.setVector4(e,t)},s.prototype._updateVector4ForUniform=function(e,t){t.toArray(s._tempBuffer),this.updateUniform(e,s._tempBuffer,4)},s.prototype._updateColor3ForEffect=function(e,t,i){void 0===i&&(i=""),this._currentEffect.setColor3(e+i,t)},s.prototype._updateColor3ForUniform=function(e,t,i){void 0===i&&(i=""),t.toArray(s._tempBuffer),this.updateUniform(e,s._tempBuffer,3)},s.prototype._updateColor4ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setColor4(e+r,t,i)},s.prototype._updateColor4ForUniform=function(e,t,i,r){void 0===r&&(r=""),t.toArray(s._tempBuffer),s._tempBuffer[3]=i,this.updateUniform(e,s._tempBuffer,4)},s.prototype.setTexture=function(e,t){this._currentEffect.setTexture(e,t)},s.prototype.updateUniformDirectly=function(e,t){this.updateUniform(e,t,t.length),this.update()},s.prototype.bindToEffect=function(e,t){this._currentEffect=e,!this._noUBO&&this._buffer&&e.bindUniformBuffer(this._buffer,t)},s.prototype.dispose=function(){if(!this._noUBO){var e=this._engine._uniformBuffers.indexOf(this);-1!==e&&this._engine._uniformBuffers.splice(e,1),this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)}},s._MAX_UNIFORM_SIZE=256,s._tempBuffer=new Float32Array(s._MAX_UNIFORM_SIZE),s})(),le.UniformBuffer=ce,he=$a||($a={}),ue=(function(){function q(){}return q.prototype.set=function(e,t){switch(t){case he.VertexBuffer.PositionKind:this.positions=e;break;case he.VertexBuffer.NormalKind:this.normals=e;break;case he.VertexBuffer.TangentKind:this.tangents=e;break;case he.VertexBuffer.UVKind:this.uvs=e;break;case he.VertexBuffer.UV2Kind:this.uvs2=e;break;case he.VertexBuffer.UV3Kind:this.uvs3=e;break;case he.VertexBuffer.UV4Kind:this.uvs4=e;break;case he.VertexBuffer.UV5Kind:this.uvs5=e;break;case he.VertexBuffer.UV6Kind:this.uvs6=e;break;case he.VertexBuffer.ColorKind:this.colors=e;break;case he.VertexBuffer.MatricesIndicesKind:this.matricesIndices=e;break;case he.VertexBuffer.MatricesWeightsKind:this.matricesWeights=e;break;case he.VertexBuffer.MatricesIndicesExtraKind:this.matricesIndicesExtra=e;break;case he.VertexBuffer.MatricesWeightsExtraKind:this.matricesWeightsExtra=e}},q.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},q.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},q.prototype.updateMesh=function(e,t,i){return this._update(e),this},q.prototype.updateGeometry=function(e,t,i){return this._update(e),this},q.prototype._applyTo=function(e,t){return void 0===t&&(t=!1),this.positions&&e.setVerticesData(he.VertexBuffer.PositionKind,this.positions,t),this.normals&&e.setVerticesData(he.VertexBuffer.NormalKind,this.normals,t),this.tangents&&e.setVerticesData(he.VertexBuffer.TangentKind,this.tangents,t),this.uvs&&e.setVerticesData(he.VertexBuffer.UVKind,this.uvs,t),this.uvs2&&e.setVerticesData(he.VertexBuffer.UV2Kind,this.uvs2,t),this.uvs3&&e.setVerticesData(he.VertexBuffer.UV3Kind,this.uvs3,t),this.uvs4&&e.setVerticesData(he.VertexBuffer.UV4Kind,this.uvs4,t),this.uvs5&&e.setVerticesData(he.VertexBuffer.UV5Kind,this.uvs5,t),this.uvs6&&e.setVerticesData(he.VertexBuffer.UV6Kind,this.uvs6,t),this.colors&&e.setVerticesData(he.VertexBuffer.ColorKind,this.colors,t),this.matricesIndices&&e.setVerticesData(he.VertexBuffer.MatricesIndicesKind,this.matricesIndices,t),this.matricesWeights&&e.setVerticesData(he.VertexBuffer.MatricesWeightsKind,this.matricesWeights,t),this.matricesIndicesExtra&&e.setVerticesData(he.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,t),this.matricesWeightsExtra&&e.setVerticesData(he.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,t),this.indices?e.setIndices(this.indices,null,t):e.setIndices([],null),this},q.prototype._update=function(e,t,i){return this.positions&&e.updateVerticesData(he.VertexBuffer.PositionKind,this.positions,t,i),this.normals&&e.updateVerticesData(he.VertexBuffer.NormalKind,this.normals,t,i),this.tangents&&e.updateVerticesData(he.VertexBuffer.TangentKind,this.tangents,t,i),this.uvs&&e.updateVerticesData(he.VertexBuffer.UVKind,this.uvs,t,i),this.uvs2&&e.updateVerticesData(he.VertexBuffer.UV2Kind,this.uvs2,t,i),this.uvs3&&e.updateVerticesData(he.VertexBuffer.UV3Kind,this.uvs3,t,i),this.uvs4&&e.updateVerticesData(he.VertexBuffer.UV4Kind,this.uvs4,t,i),this.uvs5&&e.updateVerticesData(he.VertexBuffer.UV5Kind,this.uvs5,t,i),this.uvs6&&e.updateVerticesData(he.VertexBuffer.UV6Kind,this.uvs6,t,i),this.colors&&e.updateVerticesData(he.VertexBuffer.ColorKind,this.colors,t,i),this.matricesIndices&&e.updateVerticesData(he.VertexBuffer.MatricesIndicesKind,this.matricesIndices,t,i),this.matricesWeights&&e.updateVerticesData(he.VertexBuffer.MatricesWeightsKind,this.matricesWeights,t,i),this.matricesIndicesExtra&&e.updateVerticesData(he.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,t,i),this.matricesWeightsExtra&&e.updateVerticesData(he.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,t,i),this.indices&&e.setIndices(this.indices,null),this},q.prototype.transform=function(e){var t,i=e.m[0]*e.m[5]*e.m[10]<0,r=he.Vector3.Zero();if(this.positions){var n=he.Vector3.Zero();for(t=0;t<this.positions.length;t+=3)he.Vector3.FromArrayToRef(this.positions,t,n),he.Vector3.TransformCoordinatesToRef(n,e,r),this.positions[t]=r.x,this.positions[t+1]=r.y,this.positions[t+2]=r.z}if(this.normals){var o=he.Vector3.Zero();for(t=0;t<this.normals.length;t+=3)he.Vector3.FromArrayToRef(this.normals,t,o),he.Vector3.TransformNormalToRef(o,e,r),this.normals[t]=r.x,this.normals[t+1]=r.y,this.normals[t+2]=r.z}if(this.tangents){var s=he.Vector4.Zero(),a=he.Vector4.Zero();for(t=0;t<this.tangents.length;t+=4)he.Vector4.FromArrayToRef(this.tangents,t,s),he.Vector4.TransformNormalToRef(s,e,a),this.tangents[t]=a.x,this.tangents[t+1]=a.y,this.tangents[t+2]=a.z,this.tangents[t+3]=a.w}if(i&&this.indices)for(t=0;t<this.indices.length;t+=3){var l=this.indices[t+1];this.indices[t+1]=this.indices[t+2],this.indices[t+2]=l}return this},q.prototype.merge=function(e,t){if(void 0===t&&(t=!1),this._validate(),e._validate(),!this.normals!=!e.normals||!this.tangents!=!e.tangents||!this.uvs!=!e.uvs||!this.uvs2!=!e.uvs2||!this.uvs3!=!e.uvs3||!this.uvs4!=!e.uvs4||!this.uvs5!=!e.uvs5||!this.uvs6!=!e.uvs6||!this.colors!=!e.colors||!this.matricesIndices!=!e.matricesIndices||!this.matricesWeights!=!e.matricesWeights||!this.matricesIndicesExtra!=!e.matricesIndicesExtra||!this.matricesWeightsExtra!=!e.matricesWeightsExtra)throw new Error("Cannot merge vertex data that do not have the same set of attributes");if(e.indices){this.indices||(this.indices=[]);var i=this.positions?this.positions.length/3:0;if(void 0!==this.indices.BYTES_PER_ELEMENT){var r=this.indices.length+e.indices.length,n=t||this.indices instanceof Uint32Array?new Uint32Array(r):new Uint16Array(r);n.set(this.indices);for(var o=this.indices.length,s=0;s<e.indices.length;s++)n[o+s]=e.indices[s]+i;this.indices=n}else for(s=0;s<e.indices.length;s++)this.indices.push(e.indices[s]+i)}return this.positions=this._mergeElement(this.positions,e.positions),this.normals=this._mergeElement(this.normals,e.normals),this.tangents=this._mergeElement(this.tangents,e.tangents),this.uvs=this._mergeElement(this.uvs,e.uvs),this.uvs2=this._mergeElement(this.uvs2,e.uvs2),this.uvs3=this._mergeElement(this.uvs3,e.uvs3),this.uvs4=this._mergeElement(this.uvs4,e.uvs4),this.uvs5=this._mergeElement(this.uvs5,e.uvs5),this.uvs6=this._mergeElement(this.uvs6,e.uvs6),this.colors=this._mergeElement(this.colors,e.colors),this.matricesIndices=this._mergeElement(this.matricesIndices,e.matricesIndices),this.matricesWeights=this._mergeElement(this.matricesWeights,e.matricesWeights),this.matricesIndicesExtra=this._mergeElement(this.matricesIndicesExtra,e.matricesIndicesExtra),this.matricesWeightsExtra=this._mergeElement(this.matricesWeightsExtra,e.matricesWeightsExtra),this},q.prototype._mergeElement=function(e,t){if(!e)return t;if(!t)return e;var i=t.length+e.length,r=e instanceof Float32Array,n=t instanceof Float32Array;if(r){var o=new Float32Array(i);return o.set(e),o.set(t,e.length),o}if(n){var s=e.slice(0),a=0;for(i=t.length;a<i;a++)s.push(t[a]);return s}return e.concat(t)},q.prototype._validate=function(){if(!this.positions)throw new Error("Positions are required");var r=function(e,t){var i=he.VertexBuffer.DeduceStride(e);if(t.length%i!=0)throw new Error("The "+e+"s array count must be a multiple of "+i);return t.length/i},n=r(he.VertexBuffer.PositionKind,this.positions),e=function(e,t){var i=r(e,t);if(i!==n)throw new Error("The "+e+"s element count ("+i+") does not match the positions count ("+n+")")};this.normals&&e(he.VertexBuffer.NormalKind,this.normals),this.tangents&&e(he.VertexBuffer.TangentKind,this.tangents),this.uvs&&e(he.VertexBuffer.UVKind,this.uvs),this.uvs2&&e(he.VertexBuffer.UV2Kind,this.uvs2),this.uvs3&&e(he.VertexBuffer.UV3Kind,this.uvs3),this.uvs4&&e(he.VertexBuffer.UV4Kind,this.uvs4),this.uvs5&&e(he.VertexBuffer.UV5Kind,this.uvs5),this.uvs6&&e(he.VertexBuffer.UV6Kind,this.uvs6),this.colors&&e(he.VertexBuffer.ColorKind,this.colors),this.matricesIndices&&e(he.VertexBuffer.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&e(he.VertexBuffer.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&e(he.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&e(he.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra)},q.prototype.serialize=function(){var e=this.serialize();return this.positions&&(e.positions=this.positions),this.normals&&(e.normals=this.normals),this.tangents&&(e.tangents=this.tangents),this.uvs&&(e.uvs=this.uvs),this.uvs2&&(e.uvs2=this.uvs2),this.uvs3&&(e.uvs3=this.uvs3),this.uvs4&&(e.uvs4=this.uvs4),this.uvs5&&(e.uvs5=this.uvs5),this.uvs6&&(e.uvs6=this.uvs6),this.colors&&(e.colors=this.colors),this.matricesIndices&&(e.matricesIndices=this.matricesIndices,e.matricesIndices._isExpanded=!0),this.matricesWeights&&(e.matricesWeights=this.matricesWeights),this.matricesIndicesExtra&&(e.matricesIndicesExtra=this.matricesIndicesExtra,e.matricesIndicesExtra._isExpanded=!0),this.matricesWeightsExtra&&(e.matricesWeightsExtra=this.matricesWeightsExtra),e.indices=this.indices,e},q.ExtractFromMesh=function(e,t,i){return q._ExtractFrom(e,t,i)},q.ExtractFromGeometry=function(e,t,i){return q._ExtractFrom(e,t,i)},q._ExtractFrom=function(e,t,i){var r=new q;return e.isVerticesDataPresent(he.VertexBuffer.PositionKind)&&(r.positions=e.getVerticesData(he.VertexBuffer.PositionKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.NormalKind)&&(r.normals=e.getVerticesData(he.VertexBuffer.NormalKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.TangentKind)&&(r.tangents=e.getVerticesData(he.VertexBuffer.TangentKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.UVKind)&&(r.uvs=e.getVerticesData(he.VertexBuffer.UVKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.UV2Kind)&&(r.uvs2=e.getVerticesData(he.VertexBuffer.UV2Kind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.UV3Kind)&&(r.uvs3=e.getVerticesData(he.VertexBuffer.UV3Kind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.UV4Kind)&&(r.uvs4=e.getVerticesData(he.VertexBuffer.UV4Kind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.UV5Kind)&&(r.uvs5=e.getVerticesData(he.VertexBuffer.UV5Kind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.UV6Kind)&&(r.uvs6=e.getVerticesData(he.VertexBuffer.UV6Kind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.ColorKind)&&(r.colors=e.getVerticesData(he.VertexBuffer.ColorKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.MatricesIndicesKind)&&(r.matricesIndices=e.getVerticesData(he.VertexBuffer.MatricesIndicesKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.MatricesWeightsKind)&&(r.matricesWeights=e.getVerticesData(he.VertexBuffer.MatricesWeightsKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.MatricesIndicesExtraKind)&&(r.matricesIndicesExtra=e.getVerticesData(he.VertexBuffer.MatricesIndicesExtraKind,t,i)),e.isVerticesDataPresent(he.VertexBuffer.MatricesWeightsExtraKind)&&(r.matricesWeightsExtra=e.getVerticesData(he.VertexBuffer.MatricesWeightsExtraKind,t,i)),r.indices=e.getIndices(t,i),r},q.CreateRibbon=function(e){var t=e.pathArray,i=e.closeArray||!1,r=e.closePath||!1,n=e.invertUV||!1,o=Math.floor(t[0].length/2),s=e.offset||o;s=o<s?o:Math.floor(s);var a,l,c,h,u=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,d=e.uvs,f=e.colors,p=[],m=[],_=[],g=[],v=[],y=[],b=[],T=[],x=[],E=[];if(t.length<2){var A=[],P=[];for(c=0;c<t[0].length-s;c++)A.push(t[0][c]),P.push(t[0][c+s]);t=[A,P]}var S,R,M,C,O,D=0,I=r?1:0;for(a=t[0].length,l=0;l<t.length;l++){for(b[l]=0,v[l]=[0],a=a<(R=(S=t[l]).length)?a:R,h=0;h<R;)p.push(S[h].x,S[h].y,S[h].z),0<h&&(M=S[h].subtract(S[h-1]).length()+b[l],v[l].push(M),b[l]=M),h++;r&&(h--,p.push(S[0].x,S[0].y,S[0].z),M=S[h].subtract(S[0]).length()+b[l],v[l].push(M),b[l]=M),x[l]=R+I,E[l]=D,D+=R+I}var w,L,F=null,B=null;for(c=0;c<a+I;c++){for(T[c]=0,y[c]=[0],l=0;l<t.length-1;l++)C=t[l],O=t[l+1],c===a?(F=C[0],B=O[0]):(F=C[c],B=O[c]),M=B.subtract(F).length()+T[c],y[c].push(M),T[c]=M;i&&B&&F&&(C=t[l],O=t[0],c===a&&(B=O[0]),M=B.subtract(F).length()+T[c],T[c]=M)}if(d)for(l=0;l<d.length;l++)g.push(d[l].x,d[l].y);else for(l=0;l<t.length;l++)for(c=0;c<a+I;c++)w=0!=b[l]?v[l][c]/b[l]:0,L=0!=T[c]?y[c][l]/T[c]:0,n?g.push(L,w):g.push(w,L);for(var N=l=0,V=x[l]-1,U=x[l+1]-1,z=V<U?V:U,G=E[1]-E[0],k=i?x.length:x.length-1;N<=z&&l<k;)m.push(N,N+G,N+1),m.push(N+G+1,N+1,N+G),(N+=1)===z&&(++l===x.length-1?(G=E[0]-E[l],V=x[l]-1,U=x[0]-1):(G=E[l+1]-E[l],V=x[l]-1,U=x[l+1]-1),N=E[l],z=V<U?V+N:U+N);if(q.ComputeNormals(p,m,_),r){var W=0,H=0;for(l=0;l<t.length;l++)W=3*E[l],H=l+1<t.length?3*(E[l+1]-1):_.length-3,_[W]=.5*(_[W]+_[H]),_[W+1]=.5*(_[W+1]+_[H+1]),_[W+2]=.5*(_[W+2]+_[H+2]),_[H]=_[W],_[H+1]=_[W+1],_[H+2]=_[W+2]}q._ComputeSides(u,p,m,_,g,e.frontUVs,e.backUVs);var X=null;if(f){X=new Float32Array(4*f.length);for(var j=0;j<f.length;j++)X[4*j]=f[j].r,X[4*j+1]=f[j].g,X[4*j+2]=f[j].b,X[4*j+3]=f[j].a}var Y=new q,K=new Float32Array(p),Q=new Float32Array(_),Z=new Float32Array(g);return Y.indices=m,Y.positions=K,Y.normals=Q,Y.uvs=Z,X&&Y.set(X,he.VertexBuffer.ColorKind),r&&(Y._idx=E),Y},q.CreateBox=function(e){for(var t=[new he.Vector3(0,0,1),new he.Vector3(0,0,-1),new he.Vector3(1,0,0),new he.Vector3(-1,0,0),new he.Vector3(0,1,0),new he.Vector3(0,-1,0)],i=[],r=[],n=[],o=[],s=e.width||e.size||1,a=e.height||e.size||1,l=e.depth||e.size||1,c=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,h=e.faceUV||new Array(6),u=e.faceColors,d=[],f=0;f<6;f++)void 0===h[f]&&(h[f]=new he.Vector4(0,0,1,1)),u&&void 0===u[f]&&(u[f]=new he.Color4(1,1,1,1));for(var p=new he.Vector3(s/2,a/2,l/2),m=0;m<t.length;m++){var _=t[m],g=new he.Vector3(_.y,_.z,_.x),v=he.Vector3.Cross(_,g),y=r.length/3;i.push(y),i.push(y+1),i.push(y+2),i.push(y),i.push(y+2),i.push(y+3);var b=_.subtract(g).subtract(v).multiply(p);r.push(b.x,b.y,b.z),n.push(_.x,_.y,_.z),o.push(h[m].z,h[m].w),u&&d.push(u[m].r,u[m].g,u[m].b,u[m].a),b=_.subtract(g).add(v).multiply(p),r.push(b.x,b.y,b.z),n.push(_.x,_.y,_.z),o.push(h[m].x,h[m].w),u&&d.push(u[m].r,u[m].g,u[m].b,u[m].a),b=_.add(g).add(v).multiply(p),r.push(b.x,b.y,b.z),n.push(_.x,_.y,_.z),o.push(h[m].x,h[m].y),u&&d.push(u[m].r,u[m].g,u[m].b,u[m].a),b=_.add(g).subtract(v).multiply(p),r.push(b.x,b.y,b.z),n.push(_.x,_.y,_.z),o.push(h[m].z,h[m].y),u&&d.push(u[m].r,u[m].g,u[m].b,u[m].a)}q._ComputeSides(c,r,i,n,o,e.frontUVs,e.backUVs);var T=new q;if(T.indices=i,T.positions=r,T.normals=n,T.uvs=o,u){var x=c===he.Mesh.DOUBLESIDE?d.concat(d):d;T.colors=x}return T},q.CreateSphere=function(e){for(var t=e.segments||32,i=e.diameterX||e.diameter||1,r=e.diameterY||e.diameter||1,n=e.diameterZ||e.diameter||1,o=e.arc&&(e.arc<=0||1<e.arc)?1:e.arc||1,s=e.slice&&e.slice<=0?1:e.slice||1,a=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,l=new he.Vector3(i/2,r/2,n/2),c=2+t,h=2*c,u=[],d=[],f=[],p=[],m=0;m<=c;m++){for(var _=m/c,g=_*Math.PI*s,v=0;v<=h;v++){var y=v/h,b=y*Math.PI*2*o,T=he.Matrix.RotationZ(-g),x=he.Matrix.RotationY(b),E=he.Vector3.TransformCoordinates(he.Vector3.Up(),T),A=he.Vector3.TransformCoordinates(E,x),P=A.multiply(l),S=A.divide(l).normalize();d.push(P.x,P.y,P.z),f.push(S.x,S.y,S.z),p.push(y,_)}if(0<m)for(var R=d.length/3,M=R-2*(h+1);M+h+2<R;M++)u.push(M),u.push(M+1),u.push(M+h+1),u.push(M+h+1),u.push(M+1),u.push(M+h+2)}q._ComputeSides(a,d,u,f,p,e.frontUVs,e.backUVs);var C=new q;return C.indices=u,C.positions=d,C.normals=f,C.uvs=p,C},q.CreateCylinder=function(e){var t,p=e.height||2,m=0===e.diameterTop?0:e.diameterTop||e.diameter||1,_=0===e.diameterBottom?0:e.diameterBottom||e.diameter||1,g=e.tessellation||24,i=e.subdivisions||1,r=!!e.hasRings,n=!!e.enclose,v=e.arc&&(e.arc<=0||1<e.arc)?1:e.arc||1,o=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,y=e.faceUV||new Array(3),b=e.faceColors,T=2+(1+(1!==v&&n?2:0))*(r?i:1);for(t=0;t<T;t++)b&&void 0===b[t]&&(b[t]=new he.Color4(1,1,1,1));for(t=0;t<T;t++)y&&void 0===y[t]&&(y[t]=new he.Vector4(0,0,1,1));var s,a,l,c,h,u,x=new Array,E=new Array,A=new Array,P=new Array,S=new Array,d=2*Math.PI*v/g,f=(_-m)/2/p,R=he.Vector3.Zero(),M=he.Vector3.Zero(),C=he.Vector3.Zero(),O=he.Vector3.Zero(),D=he.Vector3.Zero(),I=he.Axis.Y,w=1,L=1,F=0,B=0;for(c=0;c<=i;c++)for(l=((a=c/i)*(m-_)+_)/2,w=r&&0!==c&&c!==i?2:1,u=0;u<w;u++){for(r&&(L+=u),n&&(L+=2*u),h=0;h<=g;h++)s=h*d,R.x=Math.cos(-s)*l,R.y=-p/2+a*p,R.z=Math.sin(-s)*l,0===m&&c===i?(M.x=A[A.length-3*(g+1)],M.y=A[A.length-3*(g+1)+1],M.z=A[A.length-3*(g+1)+2]):(M.x=R.x,M.z=R.z,M.y=Math.sqrt(M.x*M.x+M.z*M.z)*f,M.normalize()),0===h&&(C.copyFrom(R),O.copyFrom(M)),E.push(R.x,R.y,R.z),A.push(M.x,M.y,M.z),B=r?F!==L?y[L].y:y[L].w:y[L].y+(y[L].w-y[L].y)*a,P.push(y[L].x+(y[L].z-y[L].x)*h/g,B),b&&S.push(b[L].r,b[L].g,b[L].b,b[L].a);1!==v&&n&&(E.push(R.x,R.y,R.z),E.push(0,R.y,0),E.push(0,R.y,0),E.push(C.x,C.y,C.z),he.Vector3.CrossToRef(I,M,D),D.normalize(),A.push(D.x,D.y,D.z,D.x,D.y,D.z),he.Vector3.CrossToRef(O,I,D),D.normalize(),A.push(D.x,D.y,D.z,D.x,D.y,D.z),B=r?F!==L?y[L+1].y:y[L+1].w:y[L+1].y+(y[L+1].w-y[L+1].y)*a,P.push(y[L+1].x,B),P.push(y[L+1].z,B),B=r?F!==L?y[L+2].y:y[L+2].w:y[L+2].y+(y[L+2].w-y[L+2].y)*a,P.push(y[L+2].x,B),P.push(y[L+2].z,B),b&&(S.push(b[L+1].r,b[L+1].g,b[L+1].b,b[L+1].a),S.push(b[L+1].r,b[L+1].g,b[L+1].b,b[L+1].a),S.push(b[L+2].r,b[L+2].g,b[L+2].b,b[L+2].a),S.push(b[L+2].r,b[L+2].g,b[L+2].b,b[L+2].a))),F!==L&&(F=L)}var N=1!==v&&n?g+4:g;for(L=c=0;L<i;L++){var V=0,U=0,z=0,G=0;for(h=0;h<g;h++)V=c*(N+1)+h,U=(c+1)*(N+1)+h,z=c*(N+1)+(h+1),G=(c+1)*(N+1)+(h+1),x.push(V,U,z),x.push(G,z,U);1!==v&&n&&(x.push(V+2,U+2,z+2),x.push(G+2,z+2,U+2),x.push(V+4,U+4,z+4),x.push(G+4,z+4,U+4)),c=r?c+2:c+1}var k=function(e){var t=e?m/2:_/2;if(0!==t){var i,r,n,o=e?y[T-1]:y[0],s=null;b&&(s=e?b[T-1]:b[0]);var a=E.length/3,l=e?p/2:-p/2,c=new he.Vector3(0,l,0);E.push(c.x,c.y,c.z),A.push(0,e?1:-1,0),P.push(o.x+.5*(o.z-o.x),o.y+.5*(o.w-o.y)),s&&S.push(s.r,s.g,s.b,s.a);var h=new he.Vector2(.5,.5);for(n=0;n<=g;n++){i=2*Math.PI*n*v/g;var u=Math.cos(-i),d=Math.sin(-i);r=new he.Vector3(u*t,l,d*t);var f=new he.Vector2(u*h.x+.5,d*h.y+.5);E.push(r.x,r.y,r.z),A.push(0,e?1:-1,0),P.push(o.x+(o.z-o.x)*f.x,o.y+(o.w-o.y)*f.y),s&&S.push(s.r,s.g,s.b,s.a)}for(n=0;n<g;n++)e?(x.push(a),x.push(a+(n+2)),x.push(a+(n+1))):(x.push(a),x.push(a+(n+1)),x.push(a+(n+2)))}};k(!1),k(!0),q._ComputeSides(o,E,x,A,P,e.frontUVs,e.backUVs);var W=new q;return W.indices=x,W.positions=E,W.normals=A,W.uvs=P,b&&(W.colors=S),W},q.CreateTorus=function(e){for(var t=[],i=[],r=[],n=[],o=e.diameter||1,s=e.thickness||.5,a=e.tessellation||16,l=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,c=a+1,h=0;h<=a;h++)for(var u=h/a,d=h*Math.PI*2/a-Math.PI/2,f=he.Matrix.Translation(o/2,0,0).multiply(he.Matrix.RotationY(d)),p=0;p<=a;p++){var m=1-p/a,_=p*Math.PI*2/a+Math.PI,g=Math.cos(_),v=Math.sin(_),y=new he.Vector3(g,v,0),b=y.scale(s/2),T=new he.Vector2(u,m);b=he.Vector3.TransformCoordinates(b,f),y=he.Vector3.TransformNormal(y,f),i.push(b.x,b.y,b.z),r.push(y.x,y.y,y.z),n.push(T.x,T.y);var x=(h+1)%c,E=(p+1)%c;t.push(h*c+p),t.push(h*c+E),t.push(x*c+p),t.push(h*c+E),t.push(x*c+E),t.push(x*c+p)}q._ComputeSides(l,i,t,r,n,e.frontUVs,e.backUVs);var A=new q;return A.indices=t,A.positions=i,A.normals=r,A.uvs=n,A},q.CreateLineSystem=function(e){for(var t=[],i=[],r=e.lines,n=e.colors,o=[],s=0,a=0;a<r.length;a++)for(var l=r[a],c=0;c<l.length;c++){if(i.push(l[c].x,l[c].y,l[c].z),n){var h=n[a];o.push(h[c].r,h[c].g,h[c].b,h[c].a)}0<c&&(t.push(s-1),t.push(s)),s++}var u=new q;return u.indices=t,u.positions=i,n&&(u.colors=o),u},q.CreateDashedLines=function(e){var t,i,r=e.dashSize||3,n=e.gapSize||1,o=e.dashNb||200,s=e.points,a=new Array,l=new Array,c=he.Vector3.Zero(),h=0,u=0,d=0,f=0,p=0;for(p=0;p<s.length-1;p++)s[p+1].subtractToRef(s[p],c),h+=c.length();for(i=r*(t=h/o)/(r+n),p=0;p<s.length-1;p++){s[p+1].subtractToRef(s[p],c),u=Math.floor(c.length()/t),c.normalize();for(var m=0;m<u;m++)d=t*m,a.push(s[p].x+d*c.x,s[p].y+d*c.y,s[p].z+d*c.z),a.push(s[p].x+(d+i)*c.x,s[p].y+(d+i)*c.y,s[p].z+(d+i)*c.z),l.push(f,f+1),f+=2}var _=new q;return _.positions=a,_.indices=l,_},q.CreateGround=function(e){var t,i,r=[],n=[],o=[],s=[],a=e.width||1,l=e.height||1,c=e.subdivisionsX||e.subdivisions||1,h=e.subdivisionsY||e.subdivisions||1;for(t=0;t<=h;t++)for(i=0;i<=c;i++){var u=new he.Vector3(i*a/c-a/2,0,(h-t)*l/h-l/2),d=new he.Vector3(0,1,0);n.push(u.x,u.y,u.z),o.push(d.x,d.y,d.z),s.push(i/c,1-t/h)}for(t=0;t<h;t++)for(i=0;i<c;i++)r.push(i+1+(t+1)*(c+1)),r.push(i+1+t*(c+1)),r.push(i+t*(c+1)),r.push(i+(t+1)*(c+1)),r.push(i+1+(t+1)*(c+1)),r.push(i+t*(c+1));var f=new q;return f.indices=r,f.positions=n,f.normals=o,f.uvs=s,f},q.CreateTiledGround=function(e){var c,h,t,i,r=void 0!==e.xmin&&null!==e.xmin?e.xmin:-1,n=void 0!==e.zmin&&null!==e.zmin?e.zmin:-1,o=void 0!==e.xmax&&null!==e.xmax?e.xmax:1,s=void 0!==e.zmax&&null!==e.zmax?e.zmax:1,a=e.subdivisions||{w:1,h:1},u=e.precision||{w:1,h:1},d=new Array,f=new Array,p=new Array,m=new Array;a.h=a.h<1?1:a.h,a.w=a.w<1?1:a.w,u.w=u.w<1?1:u.w,u.h=u.h<1?1:u.h;var l=(o-r)/a.w,_=(s-n)/a.h;function g(e,t,i,r){var n=f.length/3,o=u.w+1;for(c=0;c<u.h;c++)for(h=0;h<u.w;h++){var s=[n+h+c*o,n+(h+1)+c*o,n+(h+1)+(c+1)*o,n+h+(c+1)*o];d.push(s[1]),d.push(s[2]),d.push(s[3]),d.push(s[0]),d.push(s[1]),d.push(s[3])}var a=he.Vector3.Zero(),l=new he.Vector3(0,1,0);for(c=0;c<=u.h;c++)for(a.z=c*(r-t)/u.h+t,h=0;h<=u.w;h++)a.x=h*(i-e)/u.w+e,a.y=0,f.push(a.x,a.y,a.z),p.push(l.x,l.y,l.z),m.push(h/u.w,c/u.h)}for(t=0;t<a.h;t++)for(i=0;i<a.w;i++)g(r+i*l,n+t*_,r+(i+1)*l,n+(t+1)*_);var v=new q;return v.indices=d,v.positions=f,v.normals=p,v.uvs=m,v},q.CreateGroundFromHeightMap=function(e){var t,i,r=[],n=[],o=[],s=[],a=e.colorFilter||new he.Color3(.3,.59,.11),l=e.alphaFilter||0;for(t=0;t<=e.subdivisions;t++)for(i=0;i<=e.subdivisions;i++){var c=new he.Vector3(i*e.width/e.subdivisions-e.width/2,0,(e.subdivisions-t)*e.height/e.subdivisions-e.height/2),h=4*(((c.x+e.width/2)/e.width*(e.bufferWidth-1)|0)+((1-(c.z+e.height/2)/e.height)*(e.bufferHeight-1)|0)*e.bufferWidth),u=e.buffer[h]/255,d=e.buffer[h+1]/255,f=e.buffer[h+2]/255,p=e.buffer[h+3]/255,m=u*a.r+d*a.g+f*a.b;c.y=l<=p?e.minHeight+(e.maxHeight-e.minHeight)*m:e.minHeight-he.Epsilon,n.push(c.x,c.y,c.z),o.push(0,0,0),s.push(i/e.subdivisions,1-t/e.subdivisions)}for(t=0;t<e.subdivisions;t++)for(i=0;i<e.subdivisions;i++){var _=i+1+(t+1)*(e.subdivisions+1),g=i+1+t*(e.subdivisions+1),v=i+t*(e.subdivisions+1),y=i+(t+1)*(e.subdivisions+1),b=n[3*_+1]>=e.minHeight,T=n[3*g+1]>=e.minHeight,x=n[3*v+1]>=e.minHeight;b&&T&&x&&(r.push(_),r.push(g),r.push(v)),n[3*y+1]>=e.minHeight&&b&&x&&(r.push(y),r.push(_),r.push(v))}q.ComputeNormals(n,r,o);var E=new q;return E.indices=r,E.positions=n,E.normals=o,E.uvs=s,E},q.CreatePlane=function(e){var t=[],i=[],r=[],n=[],o=e.width||e.size||1,s=e.height||e.size||1,a=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,l=o/2,c=s/2;i.push(-l,-c,0),r.push(0,0,-1),n.push(0,0),i.push(l,-c,0),r.push(0,0,-1),n.push(1,0),i.push(l,c,0),r.push(0,0,-1),n.push(1,1),i.push(-l,c,0),r.push(0,0,-1),n.push(0,1),t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),q._ComputeSides(a,i,t,r,n,e.frontUVs,e.backUVs);var h=new q;return h.indices=t,h.positions=i,h.normals=r,h.uvs=n,h},q.CreateDisc=function(e){var t=new Array,i=new Array,r=new Array,n=new Array,o=e.radius||.5,s=e.tessellation||64,a=e.arc&&(e.arc<=0||1<e.arc)?1:e.arc||1,l=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE;t.push(0,0,0),n.push(.5,.5);for(var c=2*Math.PI*a,h=c/s,u=0;u<c;u+=h){var d=Math.cos(u),f=Math.sin(u),p=(d+1)/2,m=(1-f)/2;t.push(o*d,o*f,0),n.push(p,m)}1===a&&(t.push(t[3],t[4],t[5]),n.push(n[2],n[3]));for(var _=t.length/3,g=1;g<_-1;g++)i.push(g+1,0,g);q.ComputeNormals(t,i,r),q._ComputeSides(l,t,i,r,n,e.frontUVs,e.backUVs);var v=new q;return v.indices=i,v.positions=t,v.normals=r,v.uvs=n,v},q.CreatePolygon=function(e,t,i,r,n,o){for(var s=i||new Array(3),a=r,l=[],c=0;c<3;c++)void 0===s[c]&&(s[c]=new he.Vector4(0,0,1,1)),a&&void 0===a[c]&&(a[c]=new he.Color4(1,1,1,1));for(var h=e.getVerticesData(he.VertexBuffer.PositionKind),u=e.getVerticesData(he.VertexBuffer.NormalKind),d=e.getVerticesData(he.VertexBuffer.UVKind),f=e.getIndices(),p=0,m=0,_=0;_<u.length;_+=3)Math.abs(u[_+1])<.001&&(m=1),Math.abs(u[_+1]-1)<.001&&(m=0),Math.abs(u[_+1]+1)<.001&&(m=2),d[2*(p=_/3)]=(1-d[2*p])*s[m].x+d[2*p]*s[m].z,d[2*p+1]=(1-d[2*p+1])*s[m].y+d[2*p+1]*s[m].w,a&&l.push(a[m].r,a[m].g,a[m].b,a[m].a);q._ComputeSides(t,h,f,u,d,n,o);var g=new q;if(g.indices=f,g.positions=h,g.normals=u,g.uvs=d,a){var v=t===he.Mesh.DOUBLESIDE?l.concat(l):l;g.colors=v}return g},q.CreateIcoSphere=function(e){var t,i=e.sideOrientation||he.Mesh.DEFAULTSIDE,r=e.radius||1,f=void 0===e.flat||e.flat,p=e.subdivisions||4,m=e.radiusX||r,_=e.radiusY||r,g=e.radiusZ||r,n=(1+Math.sqrt(5))/2,o=[-1,n,-0,1,n,0,-1,-n,0,1,-n,0,0,-1,-n,0,1,-n,0,-1,n,0,1,n,n,0,1,n,0,-1,-n,0,1,-n,0,-1],s=[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],a=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],l=[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],c=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],v=new Array,y=new Array,b=new Array,T=new Array,x=0,E=new Array(3),A=new Array(3);for(t=0;t<3;t++)E[t]=he.Vector3.Zero(),A[t]=he.Vector2.Zero();for(var h=0;h<20;h++){for(t=0;t<3;t++){var u=s[3*h+t];E[t].copyFromFloats(o[3*a[u]],o[3*a[u]+1],o[3*a[u]+2]),E[t].normalize().scaleInPlace(r),A[t].copyFromFloats(l[2*u]*(138/1024)+60/1024+c[h]*(-40/1024),l[2*u+1]*(239/1024)+26/1024+c[h]*(20/1024))}for(var d=function(e,t,i,r){var n,o=he.Vector3.Lerp(E[0],E[2],t/p),s=he.Vector3.Lerp(E[1],E[2],t/p),a=p===t?E[2]:he.Vector3.Lerp(o,s,e/(p-t));if(a.normalize(),f){var l=he.Vector3.Lerp(E[0],E[2],r/p),c=he.Vector3.Lerp(E[1],E[2],r/p);n=he.Vector3.Lerp(l,c,i/(p-r))}else n=new he.Vector3(a.x,a.y,a.z);n.x/=m,n.y/=_,n.z/=g,n.normalize();var h=he.Vector2.Lerp(A[0],A[2],t/p),u=he.Vector2.Lerp(A[1],A[2],t/p),d=p===t?A[2]:he.Vector2.Lerp(h,u,e/(p-t));y.push(a.x*m,a.y*_,a.z*g),b.push(n.x,n.y,n.z),T.push(d.x,d.y),v.push(x),x++},P=0;P<p;P++)for(var S=0;S+P<p;S++)d(S,P,S+1/3,P+1/3),d(S+1,P,S+1/3,P+1/3),d(S,P+1,S+1/3,P+1/3),S+P+1<p&&(d(S+1,P,S+2/3,P+2/3),d(S+1,P+1,S+2/3,P+2/3),d(S,P+1,S+2/3,P+2/3))}q._ComputeSides(i,y,v,b,T,e.frontUVs,e.backUVs);var R=new q;return R.indices=v,R.positions=y,R.normals=b,R.uvs=T,R},q.CreatePolyhedron=function(e){var t=[];t[0]={vertex:[[0,0,1.732051],[1.632993,0,-.5773503],[-.8164966,1.414214,-.5773503],[-.8164966,-1.414214,-.5773503]],face:[[0,1,2],[0,2,3],[0,3,1],[1,3,2]]},t[1]={vertex:[[0,0,1.414214],[1.414214,0,0],[0,1.414214,0],[-1.414214,0,0],[0,-1.414214,0],[0,0,-1.414214]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,1],[1,4,5],[1,5,2],[2,5,3],[3,5,4]]},t[2]={vertex:[[0,0,1.070466],[.7136442,0,.7978784],[-.3568221,.618034,.7978784],[-.3568221,-.618034,.7978784],[.7978784,.618034,.3568221],[.7978784,-.618034,.3568221],[-.9341724,.381966,.3568221],[.1362939,1,.3568221],[.1362939,-1,.3568221],[-.9341724,-.381966,.3568221],[.9341724,.381966,-.3568221],[.9341724,-.381966,-.3568221],[-.7978784,.618034,-.3568221],[-.1362939,1,-.3568221],[-.1362939,-1,-.3568221],[-.7978784,-.618034,-.3568221],[.3568221,.618034,-.7978784],[.3568221,-.618034,-.7978784],[-.7136442,0,-.7978784],[0,0,-1.070466]],face:[[0,1,4,7,2],[0,2,6,9,3],[0,3,8,5,1],[1,5,11,10,4],[2,7,13,12,6],[3,9,15,14,8],[4,10,16,13,7],[5,8,14,17,11],[6,12,18,15,9],[10,11,17,19,16],[12,13,16,19,18],[14,15,18,19,17]]},t[3]={vertex:[[0,0,1.175571],[1.051462,0,.5257311],[.3249197,1,.5257311],[-.8506508,.618034,.5257311],[-.8506508,-.618034,.5257311],[.3249197,-1,.5257311],[.8506508,.618034,-.5257311],[.8506508,-.618034,-.5257311],[-.3249197,1,-.5257311],[-1.051462,0,-.5257311],[-.3249197,-1,-.5257311],[0,0,-1.175571]],face:[[0,1,2],[0,2,3],[0,3,4],[0,4,5],[0,5,1],[1,5,7],[1,7,6],[1,6,2],[2,6,8],[2,8,3],[3,8,9],[3,9,4],[4,9,10],[4,10,5],[5,10,7],[6,7,11],[6,11,8],[7,10,11],[8,11,9],[9,11,10]]},t[4]={vertex:[[0,0,1.070722],[.7148135,0,.7971752],[-.104682,.7071068,.7971752],[-.6841528,.2071068,.7971752],[-.104682,-.7071068,.7971752],[.6101315,.7071068,.5236279],[1.04156,.2071068,.1367736],[.6101315,-.7071068,.5236279],[-.3574067,1,.1367736],[-.7888348,-.5,.5236279],[-.9368776,.5,.1367736],[-.3574067,-1,.1367736],[.3574067,1,-.1367736],[.9368776,-.5,-.1367736],[.7888348,.5,-.5236279],[.3574067,-1,-.1367736],[-.6101315,.7071068,-.5236279],[-1.04156,-.2071068,-.1367736],[-.6101315,-.7071068,-.5236279],[.104682,.7071068,-.7971752],[.6841528,-.2071068,-.7971752],[.104682,-.7071068,-.7971752],[-.7148135,0,-.7971752],[0,0,-1.070722]],face:[[0,2,3],[1,6,5],[4,9,11],[7,15,13],[8,16,10],[12,14,19],[17,22,18],[20,21,23],[0,1,5,2],[0,3,9,4],[0,4,7,1],[1,7,13,6],[2,5,12,8],[2,8,10,3],[3,10,17,9],[4,11,15,7],[5,6,14,12],[6,13,20,14],[8,12,19,16],[9,17,18,11],[10,16,22,17],[11,18,21,15],[13,15,21,20],[14,20,23,19],[16,19,23,22],[18,22,23,21]]},t[5]={vertex:[[0,0,1.322876],[1.309307,0,.1889822],[-.9819805,.8660254,.1889822],[.1636634,-1.299038,.1889822],[.3273268,.8660254,-.9449112],[-.8183171,-.4330127,-.9449112]],face:[[0,3,1],[2,4,5],[0,1,4,2],[0,2,5,3],[1,3,5,4]]},t[6]={vertex:[[0,0,1.159953],[1.013464,0,.5642542],[-.3501431,.9510565,.5642542],[-.7715208,-.6571639,.5642542],[.6633206,.9510565,-.03144481],[.8682979,-.6571639,-.3996071],[-1.121664,.2938926,-.03144481],[-.2348831,-1.063314,-.3996071],[.5181548,.2938926,-.9953061],[-.5850262,-.112257,-.9953061]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,9,7],[5,7,9,8],[0,3,7,5,1],[2,4,8,9,6]]},t[7]={vertex:[[0,0,1.118034],[.8944272,0,.6708204],[-.2236068,.8660254,.6708204],[-.7826238,-.4330127,.6708204],[.6708204,.8660254,.2236068],[1.006231,-.4330127,-.2236068],[-1.006231,.4330127,.2236068],[-.6708204,-.8660254,-.2236068],[.7826238,.4330127,-.6708204],[.2236068,-.8660254,-.6708204],[-.8944272,0,-.6708204],[0,0,-1.118034]],face:[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,11,8],[7,10,11,9],[0,3,7,9,5,1],[2,4,8,11,10,6]]},t[8]={vertex:[[-.729665,.670121,.319155],[-.655235,-.29213,-.754096],[-.093922,-.607123,.537818],[.702196,.595691,.485187],[.776626,-.36656,-.588064]],face:[[1,4,2],[0,1,2],[3,0,2],[4,3,2],[4,1,0,3]]},t[9]={vertex:[[-.868849,-.100041,.61257],[-.329458,.976099,.28078],[-.26629,-.013796,-.477654],[-.13392,-1.034115,.229829],[.738834,.707117,-.307018],[.859683,-.535264,-.338508]],face:[[3,0,2],[5,3,2],[4,5,2],[1,4,2],[0,1,2],[0,3,5,4,1]]},t[10]={vertex:[[-.610389,.243975,.531213],[-.187812,-.48795,-.664016],[-.187812,.9759,-.664016],[.187812,-.9759,.664016],[.798201,.243975,.132803]],face:[[1,3,0],[3,4,0],[3,1,4],[0,2,1],[0,4,2],[2,4,1]]},t[11]={vertex:[[-1.028778,.392027,-.048786],[-.640503,-.646161,.621837],[-.125162,-.395663,-.540059],[.004683,.888447,-.651988],[.125161,.395663,.540059],[.632925,-.791376,.433102],[1.031672,.157063,-.354165]],face:[[3,2,0],[2,1,0],[2,5,1],[0,4,3],[0,1,4],[4,1,5],[2,3,6],[3,4,6],[5,2,6],[4,5,6]]},t[12]={vertex:[[-.669867,.334933,-.529576],[-.669867,.334933,.529577],[-.4043,1.212901,0],[-.334933,-.669867,-.529576],[-.334933,-.669867,.529577],[.334933,.669867,-.529576],[.334933,.669867,.529577],[.4043,-1.212901,0],[.669867,-.334933,-.529576],[.669867,-.334933,.529577]],face:[[8,9,7],[6,5,2],[3,8,7],[5,0,2],[4,3,7],[0,1,2],[9,4,7],[1,6,2],[9,8,5,6],[8,3,0,5],[3,4,1,0],[4,9,6,1]]},t[13]={vertex:[[-.931836,.219976,-.264632],[-.636706,.318353,.692816],[-.613483,-.735083,-.264632],[-.326545,.979634,0],[-.318353,-.636706,.692816],[-.159176,.477529,-.856368],[.159176,-.477529,-.856368],[.318353,.636706,.692816],[.326545,-.979634,0],[.613482,.735082,-.264632],[.636706,-.318353,.692816],[.931835,-.219977,-.264632]],face:[[11,10,8],[7,9,3],[6,11,8],[9,5,3],[2,6,8],[5,0,3],[4,2,8],[0,1,3],[10,4,8],[1,7,3],[10,11,9,7],[11,6,5,9],[6,2,0,5],[2,4,1,0],[4,10,7,1]]},t[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var i,r,n,o,s,a,l=e.type&&(e.type<0||e.type>=t.length)?0:e.type||0,c=e.size,h=e.sizeX||c||1,u=e.sizeY||c||1,d=e.sizeZ||c||1,f=e.custom||t[l],p=f.face.length,m=e.faceUV||new Array(p),_=e.faceColors,g=void 0===e.flat||e.flat,v=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,y=new Array,b=new Array,T=new Array,x=new Array,E=new Array,A=0,P=0,S=new Array,R=0,M=0;if(g)for(M=0;M<p;M++)_&&void 0===_[M]&&(_[M]=new he.Color4(1,1,1,1)),m&&void 0===m[M]&&(m[M]=new he.Vector4(0,0,1,1));if(g)for(M=0;M<p;M++){var C=f.face[M].length;for(n=2*Math.PI/C,o=.5*Math.tan(n/2),s=.5,R=0;R<C;R++)y.push(f.vertex[f.face[M][R]][0]*h,f.vertex[f.face[M][R]][1]*u,f.vertex[f.face[M][R]][2]*d),S.push(A),A++,i=m[M].x+(m[M].z-m[M].x)*(.5+o),r=m[M].y+(m[M].w-m[M].y)*(s-.5),x.push(i,r),a=o*Math.cos(n)-s*Math.sin(n),s=o*Math.sin(n)+s*Math.cos(n),o=a,_&&E.push(_[M].r,_[M].g,_[M].b,_[M].a);for(R=0;R<C-2;R++)b.push(S[0+P],S[R+2+P],S[R+1+P]);P+=C}else{for(R=0;R<f.vertex.length;R++)y.push(f.vertex[R][0]*h,f.vertex[R][1]*u,f.vertex[R][2]*d),x.push(0,0);for(M=0;M<p;M++)for(R=0;R<f.face[M].length-2;R++)b.push(f.face[M][0],f.face[M][R+2],f.face[M][R+1])}q.ComputeNormals(y,b,T),q._ComputeSides(v,y,b,T,x,e.frontUVs,e.backUVs);var O=new q;return O.positions=y,O.indices=b,O.normals=T,O.uvs=x,_&&g&&(O.colors=E),O},q.CreateTorusKnot=function(e){var t,i,r=new Array,n=new Array,o=new Array,s=new Array,l=e.radius||2,a=e.tube||.5,c=e.radialSegments||32,h=e.tubularSegments||32,u=e.p||2,d=e.q||3,f=0===e.sideOrientation?0:e.sideOrientation||he.Mesh.DEFAULTSIDE,p=function(e){var t=Math.cos(e),i=Math.sin(e),r=d/u*e,n=Math.cos(r),o=l*(2+n)*.5*t,s=l*(2+n)*i*.5,a=l*Math.sin(r)*.5;return new he.Vector3(o,s,a)};for(t=0;t<=c;t++){var m=t%c/c*2*u*Math.PI,_=p(m),g=p(m+.01),v=g.subtract(_),y=g.add(_),b=he.Vector3.Cross(v,y);for(y=he.Vector3.Cross(b,v),b.normalize(),y.normalize(),i=0;i<h;i++){var T=i%h/h*2*Math.PI,x=-a*Math.cos(T),E=a*Math.sin(T);n.push(_.x+x*y.x+E*b.x),n.push(_.y+x*y.y+E*b.y),n.push(_.z+x*y.z+E*b.z),s.push(t/c),s.push(i/h)}}for(t=0;t<c;t++)for(i=0;i<h;i++){var A=(i+1)%h,P=t*h+i,S=(t+1)*h+i,R=(t+1)*h+A,M=t*h+A;r.push(M),r.push(S),r.push(P),r.push(M),r.push(R),r.push(S)}q.ComputeNormals(n,r,o),q._ComputeSides(f,n,r,o,s,e.frontUVs,e.backUVs);var C=new q;return C.indices=r,C.positions=n,C.normals=o,C.uvs=s,C},q.ComputeNormals=function(e,t,i,r){var n=0,o=0,s=0,a=0,l=0,c=0,h=0,u=0,d=0,f=0,p=0,m=0,_=0,g=0,v=0,y=0,b=0,T=0,x=0,E=0,A=!1,P=!1,S=!1,R=!1,M=1,C=0,O=null;if(r&&(A=!!r.facetNormals,P=!!r.facetPositions,S=!!r.facetPartitioning,M=!0===r.useRightHandedSystem?-1:1,C=r.ratio||0,R=!!r.depthSort,O=r.distanceTo,R)){void 0===O&&(O=he.Vector3.Zero());var D=r.depthSortedFacets}var I=0,w=0,L=0,F=0;if(S&&r&&r.bbSize){var B=0,N=0,V=0,U=0,z=0,G=0,k=0,W=0,H=0,X=0,j=0,Y=0,K=0,Q=0,Z=0,q=0,J=r.bbSize.x>r.bbSize.y?r.bbSize.x:r.bbSize.y;J=J>r.bbSize.z?J:r.bbSize.z,I=r.subDiv.X*C/r.bbSize.x,w=r.subDiv.Y*C/r.bbSize.y,L=r.subDiv.Z*C/r.bbSize.z,F=r.subDiv.max*r.subDiv.max,r.facetPartitioning.length=0}for(n=0;n<e.length;n++)i[n]=0;var $=t.length/3|0;for(n=0;n<$;n++){if(_=(m=3*t[3*n])+1,g=m+2,y=(v=3*t[3*n+1])+1,b=v+2,x=(T=3*t[3*n+2])+1,E=T+2,o=e[m]-e[v],s=e[_]-e[y],a=e[g]-e[b],l=e[T]-e[v],c=e[x]-e[y],u=M*(s*(h=e[E]-e[b])-a*c),d=M*(a*l-o*h),f=M*(o*c-s*l),u/=p=0===(p=Math.sqrt(u*u+d*d+f*f))?1:p,d/=p,f/=p,A&&r&&(r.facetNormals[n].x=u,r.facetNormals[n].y=d,r.facetNormals[n].z=f),P&&r&&(r.facetPositions[n].x=(e[m]+e[v]+e[T])/3,r.facetPositions[n].y=(e[_]+e[y]+e[x])/3,r.facetPositions[n].z=(e[g]+e[b]+e[E])/3),S&&r&&(B=Math.floor((r.facetPositions[n].x-r.bInfo.minimum.x*C)*I),N=Math.floor((r.facetPositions[n].y-r.bInfo.minimum.y*C)*w),V=Math.floor((r.facetPositions[n].z-r.bInfo.minimum.z*C)*L),U=Math.floor((e[m]-r.bInfo.minimum.x*C)*I),z=Math.floor((e[_]-r.bInfo.minimum.y*C)*w),G=Math.floor((e[g]-r.bInfo.minimum.z*C)*L),k=Math.floor((e[v]-r.bInfo.minimum.x*C)*I),W=Math.floor((e[y]-r.bInfo.minimum.y*C)*w),H=Math.floor((e[b]-r.bInfo.minimum.z*C)*L),X=Math.floor((e[T]-r.bInfo.minimum.x*C)*I),j=Math.floor((e[x]-r.bInfo.minimum.y*C)*w),Y=Math.floor((e[E]-r.bInfo.minimum.z*C)*L),Q=U+r.subDiv.max*z+F*G,Z=k+r.subDiv.max*W+F*H,q=X+r.subDiv.max*j+F*Y,K=B+r.subDiv.max*N+F*V,r.facetPartitioning[K]=r.facetPartitioning[K]?r.facetPartitioning[K]:new Array,r.facetPartitioning[Q]=r.facetPartitioning[Q]?r.facetPartitioning[Q]:new Array,r.facetPartitioning[Z]=r.facetPartitioning[Z]?r.facetPartitioning[Z]:new Array,r.facetPartitioning[q]=r.facetPartitioning[q]?r.facetPartitioning[q]:new Array,r.facetPartitioning[Q].push(n),Z!=Q&&r.facetPartitioning[Z].push(n),q!=Z&&q!=Q&&r.facetPartitioning[q].push(n),K!=Q&&K!=Z&&K!=q&&r.facetPartitioning[K].push(n)),R&&r&&r.facetPositions){var ee=D[n];ee.ind=3*n,ee.sqDistance=he.Vector3.DistanceSquared(r.facetPositions[n],O)}i[m]+=u,i[_]+=d,i[g]+=f,i[v]+=u,i[y]+=d,i[b]+=f,i[T]+=u,i[x]+=d,i[E]+=f}for(n=0;n<i.length/3;n++)u=i[3*n],d=i[3*n+1],f=i[3*n+2],u/=p=0===(p=Math.sqrt(u*u+d*d+f*f))?1:p,d/=p,f/=p,i[3*n]=u,i[3*n+1]=d,i[3*n+2]=f},q._ComputeSides=function(e,t,i,r,n,o,s){var a,l,c=i.length,h=r.length;switch(e=e||he.Mesh.DEFAULTSIDE){case he.Mesh.FRONTSIDE:break;case he.Mesh.BACKSIDE:var u;for(a=0;a<c;a+=3)u=i[a],i[a]=i[a+2],i[a+2]=u;for(l=0;l<h;l++)r[l]=-r[l];break;case he.Mesh.DOUBLESIDE:for(var d=t.length,f=d/3,p=0;p<d;p++)t[d+p]=t[p];for(a=0;a<c;a+=3)i[a+c]=i[a+2]+f,i[a+1+c]=i[a+1]+f,i[a+2+c]=i[a]+f;for(l=0;l<h;l++)r[h+l]=-r[l];var m=n.length,_=0;for(_=0;_<m;_++)n[_+m]=n[_];for(o=o||new he.Vector4(0,0,1,1),s=s||new he.Vector4(0,0,1,1),a=_=0;a<m/2;a++)n[_]=o.x+(o.z-o.x)*n[_],n[_+1]=o.y+(o.w-o.y)*n[_+1],n[_+m]=s.x+(s.z-s.x)*n[_+m],n[_+m+1]=s.y+(s.w-s.y)*n[_+m+1],_+=2}},q.ImportVertexData=function(e,t){var i=new q,r=e.positions;r&&i.set(r,he.VertexBuffer.PositionKind);var n=e.normals;n&&i.set(n,he.VertexBuffer.NormalKind);var o=e.tangents;o&&i.set(o,he.VertexBuffer.TangentKind);var s=e.uvs;s&&i.set(s,he.VertexBuffer.UVKind);var a=e.uv2s;a&&i.set(a,he.VertexBuffer.UV2Kind);var l=e.uv3s;l&&i.set(l,he.VertexBuffer.UV3Kind);var c=e.uv4s;c&&i.set(c,he.VertexBuffer.UV4Kind);var h=e.uv5s;h&&i.set(h,he.VertexBuffer.UV5Kind);var u=e.uv6s;u&&i.set(u,he.VertexBuffer.UV6Kind);var d=e.colors;d&&i.set(he.Color4.CheckColors4(d,r.length/3),he.VertexBuffer.ColorKind);var f=e.matricesIndices;f&&i.set(f,he.VertexBuffer.MatricesIndicesKind);var p=e.matricesWeights;p&&i.set(p,he.VertexBuffer.MatricesWeightsKind);var m=e.indices;m&&(i.indices=m),t.setAllVerticesData(i,e.updatable)},q})(),he.VertexData=ue,(function(I){var e=(function(){function D(e,t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null),this.delayLoadState=I.Engine.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this.id=e,this._engine=t.getEngine(),this._meshes=[],this._scene=t,this._vertexBuffers={},this._indices=[],this._updatable=r,i?this.setAllVerticesData(i,r):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),n&&("LinesMesh"===n.getClassName()&&(this.boundingBias=new I.Vector2(0,n.intersectionThreshold),this._updateExtend()),this.applyToMesh(n),n.computeWorldMatrix(!0))}return Object.defineProperty(D.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){if(this._boundingBias){if(this._boundingBias.equals(e))return;this._boundingBias.copyFrom(e)}else this._boundingBias=e.clone();this._updateBoundingInfo(!0,null)},enumerable:!0,configurable:!0}),D.CreateGeometryForMesh=function(e){var t=new D(D.RandomId(),e.getScene());return t.applyToMesh(e),t},Object.defineProperty(D.prototype,"extend",{get:function(){return this._extend},enumerable:!0,configurable:!0}),D.prototype.getScene=function(){return this._scene},D.prototype.getEngine=function(){return this._engine},D.prototype.isReady=function(){return this.delayLoadState===I.Engine.DELAYLOADSTATE_LOADED||this.delayLoadState===I.Engine.DELAYLOADSTATE_NONE},Object.defineProperty(D.prototype,"doNotSerialize",{get:function(){for(var e=0;e<this._meshes.length;e++)if(!this._meshes[e].doNotSerialize)return!1;return!0},enumerable:!0,configurable:!0}),D.prototype._rebuild=function(){for(var e in this._vertexArrayObjects&&(this._vertexArrayObjects={}),0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._vertexBuffers){this._vertexBuffers[e]._rebuild()}},D.prototype.setAllVerticesData=function(e,t){e.applyToGeometry(this,t),this.notifyUpdate()},D.prototype.setVerticesData=function(e,t,i,r){void 0===i&&(i=!1);var n=new I.VertexBuffer(this._engine,t,e,i,0===this._meshes.length,r);this.setVerticesBuffer(n)},D.prototype.removeVerticesData=function(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e])},D.prototype.setVerticesBuffer=function(e,t){void 0===t&&(t=null);var i=e.getKind();if(this._vertexBuffers[i]&&this._vertexBuffers[i].dispose(),this._vertexBuffers[i]=e,i===I.VertexBuffer.PositionKind){var r=e.getData();null!=t?this._totalVertices=t:null!=r&&(this._totalVertices=r.length/(e.byteStride/4)),this._updateExtend(r),this._resetPointsArrayCache();for(var n=this._meshes,o=n.length,s=0;s<o;s++){var a=n[s];a._boundingInfo=new I.BoundingInfo(this._extend.minimum,this._extend.maximum),a._createGlobalSubMesh(!1),a.computeWorldMatrix(!0)}}this.notifyUpdate(i),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},D.prototype.updateVerticesDataDirectly=function(e,t,i,r){void 0===r&&(r=!1);var n=this.getVertexBuffer(e);n&&(n.updateDirectly(t,i,r),this.notifyUpdate(e))},D.prototype.updateVerticesData=function(e,t,i){void 0===i&&(i=!1);var r=this.getVertexBuffer(e);r&&(r.update(t),e===I.VertexBuffer.PositionKind&&this._updateBoundingInfo(i,t),this.notifyUpdate(e))},D.prototype._updateBoundingInfo=function(e,t){e&&this._updateExtend(t);var i=this._meshes,r=i.length;this._resetPointsArrayCache();for(var n=0;n<r;n++){var o=i[n];if(e){o._boundingInfo=new I.BoundingInfo(this._extend.minimum,this._extend.maximum);for(var s=0;s<o.subMeshes.length;s++){o.subMeshes[s].refreshBoundingInfo()}}}},D.prototype._bind=function(e,t){if(e){void 0===t&&(t=this._indexBuffer);var i=this.getVertexBuffers();i&&(t==this._indexBuffer&&this._vertexArrayObjects?(this._vertexArrayObjects[e.key]||(this._vertexArrayObjects[e.key]=this._engine.recordVertexArrayObject(i,t,e)),this._engine.bindVertexArrayObject(this._vertexArrayObjects[e.key],t)):this._engine.bindBuffers(i,t,e))}},D.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},D.prototype.getVerticesData=function(e,t,i){var r=this.getVertexBuffer(e);if(!r)return null;var n=r.getData();if(!n)return null;var o=r.getSize()*I.VertexBuffer.GetTypeByteLength(r.type),s=this._totalVertices*r.getSize();if(r.type!==I.VertexBuffer.FLOAT||r.byteStride!==o){var a=new Array(s);return r.forEach(s,(function(e,t){a[t]=e})),a}if(!(n instanceof Array||n instanceof Float32Array)||0!==r.byteOffset||n.length!==s){if(n instanceof Array){var l=r.byteOffset/4;return I.Tools.Slice(n,l,l+s)}if(n instanceof ArrayBuffer)return new Float32Array(n,r.byteOffset,s);l=n.byteOffset+r.byteOffset;if(i||t&&1!==this._meshes.length){var c=new Float32Array(s),h=new Float32Array(n.buffer,l,s);return c.set(h),c}return new Float32Array(n.buffer,l,s)}return i||t&&1!==this._meshes.length?I.Tools.Slice(n):n},D.prototype.isVertexBufferUpdatable=function(e){var t=this._vertexBuffers[e];return!!t&&t.isUpdatable()},D.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},D.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},D.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},D.prototype.getVerticesDataKinds=function(){var e,t=[];if(!this._vertexBuffers&&this._delayInfo)for(e in this._delayInfo)t.push(e);else for(e in this._vertexBuffers)t.push(e);return t},D.prototype.updateIndices=function(e,t){this._indexBuffer&&(this._indexBufferIsUpdatable?this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t):this.setIndices(e,null,!0))},D.prototype.setIndices=function(e,t,i){void 0===t&&(t=null),void 0===i&&(i=!1),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._disposeVertexArrayObjects(),this._indices=e,this._indexBufferIsUpdatable=i,0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices,i)),null!=t&&(this._totalVertices=t);for(var r=this._meshes,n=r.length,o=0;o<n;o++)r[o]._createGlobalSubMesh(!0);this.notifyUpdate()},D.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},D.prototype.getIndices=function(e,t){if(!this.isReady())return null;var i=this._indices;if(t||e&&1!==this._meshes.length){for(var r=i.length,n=[],o=0;o<r;o++)n.push(i[o]);return n}return i},D.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},D.prototype._releaseVertexArrayObject=function(e){void 0===e&&(e=null),e&&this._vertexArrayObjects&&this._vertexArrayObjects[e.key]&&(this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e.key]),delete this._vertexArrayObjects[e.key])},D.prototype.releaseForMesh=function(e,t){var i=this._meshes,r=i.indexOf(e);-1!==r&&(i.splice(r,1),e._geometry=null,0===i.length&&t&&this.dispose())},D.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;(e._geometry=this)._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},D.prototype._updateExtend=function(e){void 0===e&&(e=null),e||(e=this.getVerticesData(I.VertexBuffer.PositionKind)),this._extend=I.Tools.ExtractMinAndMax(e,0,this._totalVertices,this.boundingBias,3)},D.prototype._applyToMesh=function(e){var t=this._meshes.length;for(var i in this._vertexBuffers){1===t&&this._vertexBuffers[i].create();var r=this._vertexBuffers[i].getBuffer();r&&(r.references=t),i===I.VertexBuffer.PositionKind&&(this._extend||this._updateExtend(),e._boundingInfo=new I.BoundingInfo(this._extend.minimum,this._extend.maximum),e._createGlobalSubMesh(!1),e._updateBoundingInfo())}1===t&&this._indices&&0<this._indices.length&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=t),e._syncGeometryWithMorphTargetManager()},D.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t<i.length;t++){i[t]._markSubMeshesAsAttributesDirty()}},D.prototype.load=function(e,t){this.delayLoadState!==I.Engine.DELAYLOADSTATE_LOADING&&(this.isReady()?t&&t():(this.delayLoadState=I.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(e,t)))},D.prototype._queueLoad=function(n,o){var s=this;this.delayLoadingFile&&(n._addPendingData(this),n._loadFile(this.delayLoadingFile,(function(e){if(s._delayLoadingFunction){s._delayLoadingFunction(JSON.parse(e),s),s.delayLoadState=I.Engine.DELAYLOADSTATE_LOADED,s._delayInfo=[],n._removePendingData(s);for(var t=s._meshes,i=t.length,r=0;r<i;r++)s._applyToMesh(t[r]);o&&o()}}),void 0,!0))},D.prototype.toLeftHanded=function(){var e=this.getIndices(!1);if(null!=e&&0<e.length){for(var t=0;t<e.length;t+=3){var i=e[t+0];e[t+0]=e[t+2],e[t+2]=i}this.setIndices(e)}var r=this.getVerticesData(I.VertexBuffer.PositionKind,!1);if(null!=r&&0<r.length){for(t=0;t<r.length;t+=3)r[t+2]=-r[t+2];this.setVerticesData(I.VertexBuffer.PositionKind,r,!1)}var n=this.getVerticesData(I.VertexBuffer.NormalKind,!1);if(null!=n&&0<n.length){for(t=0;t<n.length;t+=3)n[t+2]=-n[t+2];this.setVerticesData(I.VertexBuffer.NormalKind,n,!1)}},D.prototype._resetPointsArrayCache=function(){this._positions=null},D.prototype._generatePointsArray=function(){if(this._positions)return!0;var e=this.getVerticesData(I.VertexBuffer.PositionKind);if(!e||0===e.length)return!1;this._positions=[];for(var t=0;t<e.length;t+=3)this._positions.push(I.Vector3.FromArray(e,t));return!0},D.prototype.isDisposed=function(){return this._isDisposed},D.prototype._disposeVertexArrayObjects=function(){if(this._vertexArrayObjects){for(var e in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);this._vertexArrayObjects={}}},D.prototype.dispose=function(){var e,t=this._meshes,i=t.length;for(e=0;e<i;e++)this.releaseForMesh(t[e]);for(var r in this._meshes=[],this._disposeVertexArrayObjects(),this._vertexBuffers)this._vertexBuffers[r].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=I.Engine.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},D.prototype.copy=function(e){var t=new I.VertexData;t.indices=[];var i=this.getIndices();if(i)for(var r=0;r<i.length;r++)t.indices.push(i[r]);var n,o=!1,s=!1;for(n in this._vertexBuffers){var a=this.getVerticesData(n);if(a instanceof Float32Array?t.set(new Float32Array(a),n):t.set(a.slice(0),n),!s){var l=this.getVertexBuffer(n);l&&(s=!(o=l.isUpdatable()))}}var c=new D(e,this._scene,t,o);for(n in c.delayLoadState=this.delayLoadState,c.delayLoadingFile=this.delayLoadingFile,c._delayLoadingFunction=this._delayLoadingFunction,this._delayInfo)c._delayInfo=c._delayInfo||[],c._delayInfo.push(n);return c._boundingInfo=new I.BoundingInfo(this._extend.minimum,this._extend.maximum),c},D.prototype.serialize=function(){var e={};return e.id=this.id,e.updatable=this._updatable,I.Tags&&I.Tags.HasTags(this)&&(e.tags=I.Tags.GetTags(this)),e},D.prototype.toNumberArray=function(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)},D.prototype.serializeVerticeData=function(){var e=this.serialize();return this.isVerticesDataPresent(I.VertexBuffer.PositionKind)&&(e.positions=this.toNumberArray(this.getVerticesData(I.VertexBuffer.PositionKind)),this.isVertexBufferUpdatable(I.VertexBuffer.PositionKind)&&(e.positions._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.NormalKind)&&(e.normals=this.toNumberArray(this.getVerticesData(I.VertexBuffer.NormalKind)),this.isVertexBufferUpdatable(I.VertexBuffer.NormalKind)&&(e.normals._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.TangentKind)&&(e.tangets=this.toNumberArray(this.getVerticesData(I.VertexBuffer.TangentKind)),this.isVertexBufferUpdatable(I.VertexBuffer.TangentKind)&&(e.tangets._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.UVKind)&&(e.uvs=this.toNumberArray(this.getVerticesData(I.VertexBuffer.UVKind)),this.isVertexBufferUpdatable(I.VertexBuffer.UVKind)&&(e.uvs._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.UV2Kind)&&(e.uv2s=this.toNumberArray(this.getVerticesData(I.VertexBuffer.UV2Kind)),this.isVertexBufferUpdatable(I.VertexBuffer.UV2Kind)&&(e.uv2s._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.UV3Kind)&&(e.uv3s=this.toNumberArray(this.getVerticesData(I.VertexBuffer.UV3Kind)),this.isVertexBufferUpdatable(I.VertexBuffer.UV3Kind)&&(e.uv3s._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.UV4Kind)&&(e.uv4s=this.toNumberArray(this.getVerticesData(I.VertexBuffer.UV4Kind)),this.isVertexBufferUpdatable(I.VertexBuffer.UV4Kind)&&(e.uv4s._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.UV5Kind)&&(e.uv5s=this.toNumberArray(this.getVerticesData(I.VertexBuffer.UV5Kind)),this.isVertexBufferUpdatable(I.VertexBuffer.UV5Kind)&&(e.uv5s._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.UV6Kind)&&(e.uv6s=this.toNumberArray(this.getVerticesData(I.VertexBuffer.UV6Kind)),this.isVertexBufferUpdatable(I.VertexBuffer.UV6Kind)&&(e.uv6s._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.ColorKind)&&(e.colors=this.toNumberArray(this.getVerticesData(I.VertexBuffer.ColorKind)),this.isVertexBufferUpdatable(I.VertexBuffer.ColorKind)&&(e.colors._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.MatricesIndicesKind)&&(e.matricesIndices=this.toNumberArray(this.getVerticesData(I.VertexBuffer.MatricesIndicesKind)),e.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(I.VertexBuffer.MatricesIndicesKind)&&(e.matricesIndices._updatable=!0)),this.isVerticesDataPresent(I.VertexBuffer.MatricesWeightsKind)&&(e.matricesWeights=this.toNumberArray(this.getVerticesData(I.VertexBuffer.MatricesWeightsKind)),this.isVertexBufferUpdatable(I.VertexBuffer.MatricesWeightsKind)&&(e.matricesWeights._updatable=!0)),e.indices=this.toNumberArray(this.getIndices()),e},D.ExtractFromMesh=function(e,t){var i=e._geometry;return i?i.copy(t):null},D.RandomId=function(){return I.Tools.RandomId()},D._ImportGeometry=function(e,t){var i=t.getScene(),r=e.geometryId;if(r){var n=i.getGeometryByID(r);n&&n.applyToMesh(t)}else if(e instanceof ArrayBuffer){var o=t._binaryInfo;if(o.positionsAttrDesc&&0<o.positionsAttrDesc.count){var s=new Float32Array(e,o.positionsAttrDesc.offset,o.positionsAttrDesc.count);t.setVerticesData(I.VertexBuffer.PositionKind,s,!1)}if(o.normalsAttrDesc&&0<o.normalsAttrDesc.count){var a=new Float32Array(e,o.normalsAttrDesc.offset,o.normalsAttrDesc.count);t.setVerticesData(I.VertexBuffer.NormalKind,a,!1)}if(o.tangetsAttrDesc&&0<o.tangetsAttrDesc.count){var l=new Float32Array(e,o.tangetsAttrDesc.offset,o.tangetsAttrDesc.count);t.setVerticesData(I.VertexBuffer.TangentKind,l,!1)}if(o.uvsAttrDesc&&0<o.uvsAttrDesc.count){var c=new Float32Array(e,o.uvsAttrDesc.offset,o.uvsAttrDesc.count);t.setVerticesData(I.VertexBuffer.UVKind,c,!1)}if(o.uvs2AttrDesc&&0<o.uvs2AttrDesc.count){var h=new Float32Array(e,o.uvs2AttrDesc.offset,o.uvs2AttrDesc.count);t.setVerticesData(I.VertexBuffer.UV2Kind,h,!1)}if(o.uvs3AttrDesc&&0<o.uvs3AttrDesc.count){var u=new Float32Array(e,o.uvs3AttrDesc.offset,o.uvs3AttrDesc.count);t.setVerticesData(I.VertexBuffer.UV3Kind,u,!1)}if(o.uvs4AttrDesc&&0<o.uvs4AttrDesc.count){var d=new Float32Array(e,o.uvs4AttrDesc.offset,o.uvs4AttrDesc.count);t.setVerticesData(I.VertexBuffer.UV4Kind,d,!1)}if(o.uvs5AttrDesc&&0<o.uvs5AttrDesc.count){var f=new Float32Array(e,o.uvs5AttrDesc.offset,o.uvs5AttrDesc.count);t.setVerticesData(I.VertexBuffer.UV5Kind,f,!1)}if(o.uvs6AttrDesc&&0<o.uvs6AttrDesc.count){var p=new Float32Array(e,o.uvs6AttrDesc.offset,o.uvs6AttrDesc.count);t.setVerticesData(I.VertexBuffer.UV6Kind,p,!1)}if(o.colorsAttrDesc&&0<o.colorsAttrDesc.count){var m=new Float32Array(e,o.colorsAttrDesc.offset,o.colorsAttrDesc.count);t.setVerticesData(I.VertexBuffer.ColorKind,m,!1,o.colorsAttrDesc.stride)}if(o.matricesIndicesAttrDesc&&0<o.matricesIndicesAttrDesc.count){for(var _=new Int32Array(e,o.matricesIndicesAttrDesc.offset,o.matricesIndicesAttrDesc.count),g=[],v=0;v<_.length;v++){var y=_[v];g.push(255&y),g.push((65280&y)>>8),g.push((16711680&y)>>16),g.push(y>>24)}t.setVerticesData(I.VertexBuffer.MatricesIndicesKind,g,!1)}if(o.matricesWeightsAttrDesc&&0<o.matricesWeightsAttrDesc.count){var b=new Float32Array(e,o.matricesWeightsAttrDesc.offset,o.matricesWeightsAttrDesc.count);t.setVerticesData(I.VertexBuffer.MatricesWeightsKind,b,!1)}if(o.indicesAttrDesc&&0<o.indicesAttrDesc.count){var T=new Int32Array(e,o.indicesAttrDesc.offset,o.indicesAttrDesc.count);t.setIndices(T,null)}if(o.subMeshesAttrDesc&&0<o.subMeshesAttrDesc.count){var x=new Int32Array(e,o.subMeshesAttrDesc.offset,5*o.subMeshesAttrDesc.count);t.subMeshes=[];for(v=0;v<o.subMeshesAttrDesc.count;v++){var E=x[5*v+0],A=x[5*v+1],P=x[5*v+2],S=x[5*v+3],R=x[5*v+4];I.SubMesh.AddToMesh(E,A,P,S,R,t)}}}else if(e.positions&&e.normals&&e.indices){if(t.setVerticesData(I.VertexBuffer.PositionKind,e.positions,e.positions._updatable),t.setVerticesData(I.VertexBuffer.NormalKind,e.normals,e.normals._updatable),e.tangents&&t.setVerticesData(I.VertexBuffer.TangentKind,e.tangents,e.tangents._updatable),e.uvs&&t.setVerticesData(I.VertexBuffer.UVKind,e.uvs,e.uvs._updatable),e.uvs2&&t.setVerticesData(I.VertexBuffer.UV2Kind,e.uvs2,e.uvs2._updatable),e.uvs3&&t.setVerticesData(I.VertexBuffer.UV3Kind,e.uvs3,e.uvs3._updatable),e.uvs4&&t.setVerticesData(I.VertexBuffer.UV4Kind,e.uvs4,e.uvs4._updatable),e.uvs5&&t.setVerticesData(I.VertexBuffer.UV5Kind,e.uvs5,e.uvs5._updatable),e.uvs6&&t.setVerticesData(I.VertexBuffer.UV6Kind,e.uvs6,e.uvs6._updatable),e.colors&&t.setVerticesData(I.VertexBuffer.ColorKind,I.Color4.CheckColors4(e.colors,e.positions.length/3),e.colors._updatable),e.matricesIndices)if(e.matricesIndices._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(I.VertexBuffer.MatricesIndicesKind,e.matricesIndices,e.matricesIndices._updatable);else{for(g=[],v=0;v<e.matricesIndices.length;v++){var M=e.matricesIndices[v];g.push(255&M),g.push((65280&M)>>8),g.push((16711680&M)>>16),g.push(M>>24)}t.setVerticesData(I.VertexBuffer.MatricesIndicesKind,g,e.matricesIndices._updatable)}if(e.matricesIndicesExtra)if(e.matricesIndicesExtra._isExpanded)delete e.matricesIndices._isExpanded,t.setVerticesData(I.VertexBuffer.MatricesIndicesExtraKind,e.matricesIndicesExtra,e.matricesIndicesExtra._updatable);else{for(g=[],v=0;v<e.matricesIndicesExtra.length;v++){M=e.matricesIndicesExtra[v];g.push(255&M),g.push((65280&M)>>8),g.push((16711680&M)>>16),g.push(M>>24)}t.setVerticesData(I.VertexBuffer.MatricesIndicesExtraKind,g,e.matricesIndicesExtra._updatable)}e.matricesWeights&&(D._CleanMatricesWeights(e,t),t.setVerticesData(I.VertexBuffer.MatricesWeightsKind,e.matricesWeights,e.matricesWeights._updatable)),e.matricesWeightsExtra&&t.setVerticesData(I.VertexBuffer.MatricesWeightsExtraKind,e.matricesWeightsExtra,e.matricesWeights._updatable),t.setIndices(e.indices,null)}if(e.subMeshes){t.subMeshes=[];for(var C=0;C<e.subMeshes.length;C++){var O=e.subMeshes[C];I.SubMesh.AddToMesh(O.materialIndex,O.verticesStart,O.verticesCount,O.indexStart,O.indexCount,t)}}t._shouldGenerateFlatShading&&(t.convertToFlatShadedMesh(),delete t._shouldGenerateFlatShading),t.computeWorldMatrix(!0),i.onMeshImportedObservable.notifyObservers(t)},D._CleanMatricesWeights=function(e,t){if(I.SceneLoader.CleanBoneMatrixWeights){var i=0;if(-1<e.skeletonId){var r=t.getScene().getLastSkeletonByID(e.skeletonId);if(r){i=r.bones.length;for(var n=t.getVerticesData(I.VertexBuffer.MatricesIndicesKind),o=t.getVerticesData(I.VertexBuffer.MatricesIndicesExtraKind),s=e.matricesWeights,a=e.matricesWeightsExtra,l=e.numBoneInfluencer,c=s.length,h=0;h<c;h+=4){for(var u=0,d=-1,f=0;f<4;f++){u+=p=s[h+f],p<.001&&d<0&&(d=f)}if(a)for(f=0;f<4;f++){var p;u+=p=a[h+f],p<.001&&d<0&&(d=f+4)}if((d<0||l-1<d)&&(d=l-1),.001<u){var m=1/u;for(f=0;f<4;f++)s[h+f]*=m;if(a)for(f=0;f<4;f++)a[h+f]*=m}else 4<=d?(a[h+d-4]=1-u,o[h+d-4]=i):(s[h+d]=1-u,n[h+d]=i)}t.setVerticesData(I.VertexBuffer.MatricesIndicesKind,n),e.matricesWeightsExtra&&t.setVerticesData(I.VertexBuffer.MatricesIndicesExtraKind,o)}}}},D.Parse=function(e,t,i){if(t.getGeometryByID(e.id))return null;var r=new D(e.id,t,void 0,e.updatable);return I.Tags&&I.Tags.AddTagsTo(r,e.tags),e.delayLoadingFile?(r.delayLoadState=I.Engine.DELAYLOADSTATE_NOTLOADED,r.delayLoadingFile=i+e.delayLoadingFile,r._boundingInfo=new I.BoundingInfo(I.Vector3.FromArray(e.boundingBoxMinimum),I.Vector3.FromArray(e.boundingBoxMaximum)),r._delayInfo=[],e.hasUVs&&r._delayInfo.push(I.VertexBuffer.UVKind),e.hasUVs2&&r._delayInfo.push(I.VertexBuffer.UV2Kind),e.hasUVs3&&r._delayInfo.push(I.VertexBuffer.UV3Kind),e.hasUVs4&&r._delayInfo.push(I.VertexBuffer.UV4Kind),e.hasUVs5&&r._delayInfo.push(I.VertexBuffer.UV5Kind),e.hasUVs6&&r._delayInfo.push(I.VertexBuffer.UV6Kind),e.hasColors&&r._delayInfo.push(I.VertexBuffer.ColorKind),e.hasMatricesIndices&&r._delayInfo.push(I.VertexBuffer.MatricesIndicesKind),e.hasMatricesWeights&&r._delayInfo.push(I.VertexBuffer.MatricesWeightsKind),r._delayLoadingFunction=I.VertexData.ImportVertexData):I.VertexData.ImportVertexData(e,r),t.pushGeometry(r,!0),r},D})(),t=(function(o){function e(e,t,i,r){void 0===i&&(i=!1),void 0===r&&(r=null);var n=o.call(this,e,t,void 0,!1,r)||this;return n._canBeRegenerated=i,n._beingRegenerated=!0,n.regenerate(),n._beingRegenerated=!1,n}return T(e,o),e.prototype.canBeRegenerated=function(){return this._canBeRegenerated},e.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},e.prototype.asNewGeometry=function(e){return o.prototype.copy.call(this,e)},e.prototype.setAllVerticesData=function(e,t){this._beingRegenerated&&o.prototype.setAllVerticesData.call(this,e,!1)},e.prototype.setVerticesData=function(e,t,i){this._beingRegenerated&&o.prototype.setVerticesData.call(this,e,t,!1)},e.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},e.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},e.prototype.serialize=function(){var e=o.prototype.serialize.call(this);return e.canBeRegenerated=this.canBeRegenerated(),e},e})(I.Geometry=e),i=(function(h){function t(e,t,i,r,n,o,s,a,l){void 0===l&&(l=I.Mesh.DEFAULTSIDE);var c=h.call(this,e,t,s,a)||this;return c.pathArray=i,c.closeArray=r,c.closePath=n,c.offset=o,c.side=l,c}return T(t,h),t.prototype._regenerateVertexData=function(){return I.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},t.prototype.copy=function(e){return new t(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),void 0,this.side)},t})(I._PrimitiveGeometry=t);I.RibbonGeometry=i;var r=(function(a){function r(e,t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=I.Mesh.DEFAULTSIDE);var s=a.call(this,e,t,r,n)||this;return s.size=i,s.side=o,s}return T(r,a),r.prototype._regenerateVertexData=function(){return I.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),void 0,this.side)},r.prototype.serialize=function(){var e=a.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(e,t){if(t.getGeometryByID(e.id))return null;var i=new r(e.id,t,e.size,e.canBeRegenerated,null);return I.Tags&&I.Tags.AddTagsTo(i,e.tags),t.pushGeometry(i,!0),i},r})(t);I.BoxGeometry=r;var n=(function(l){function r(e,t,i,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=I.Mesh.DEFAULTSIDE);var a=l.call(this,e,t,n,o)||this;return a.segments=i,a.diameter=r,a.side=s,a}return T(r,l),r.prototype._regenerateVertexData=function(){return I.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=l.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},r.Parse=function(e,t){if(t.getGeometryByID(e.id))return null;var i=new r(e.id,t,e.segments,e.diameter,e.canBeRegenerated,null);return I.Tags&&I.Tags.AddTagsTo(i,e.tags),t.pushGeometry(i,!0),i},r})(t);I.SphereGeometry=n;var o=(function(l){function t(e,t,i,r,n,o,s){void 0===o&&(o=null),void 0===s&&(s=I.Mesh.DEFAULTSIDE);var a=l.call(this,e,t,n,o)||this;return a.radius=i,a.tessellation=r,a.side=s,a}return T(t,l),t.prototype._regenerateVertexData=function(){return I.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},t.prototype.copy=function(e){return new t(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},t})(t);I.DiscGeometry=o;var s=(function(u){function r(e,t,i,r,n,o,s,a,l,c){void 0===s&&(s=1),void 0===l&&(l=null),void 0===c&&(c=I.Mesh.DEFAULTSIDE);var h=u.call(this,e,t,a,l)||this;return h.height=i,h.diameterTop=r,h.diameterBottom=n,h.tessellation=o,h.subdivisions=s,h.side=c,h}return T(r,u),r.prototype._regenerateVertexData=function(){return I.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=u.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},r.Parse=function(e,t){if(t.getGeometryByID(e.id))return null;var i=new r(e.id,t,e.height,e.diameterTop,e.diameterBottom,e.tessellation,e.subdivisions,e.canBeRegenerated,null);return I.Tags&&I.Tags.AddTagsTo(i,e.tags),t.pushGeometry(i,!0),i},r})(t);I.CylinderGeometry=s;var a=(function(c){function r(e,t,i,r,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=I.Mesh.DEFAULTSIDE);var l=c.call(this,e,t,o,s)||this;return l.diameter=i,l.thickness=r,l.tessellation=n,l.side=a,l}return T(r,c),r.prototype._regenerateVertexData=function(){return I.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=c.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},r.Parse=function(e,t){if(t.getGeometryByID(e.id))return null;var i=new r(e.id,t,e.diameter,e.thickness,e.tessellation,e.canBeRegenerated,null);return I.Tags&&I.Tags.AddTagsTo(i,e.tags),t.pushGeometry(i,!0),i},r})(t);I.TorusGeometry=a;var l=(function(l){function r(e,t,i,r,n,o,s){void 0===s&&(s=null);var a=l.call(this,e,t,o,s)||this;return a.width=i,a.height=r,a.subdivisions=n,a}return T(r,l),r.prototype._regenerateVertexData=function(){return I.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},r.prototype.serialize=function(){var e=l.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},r.Parse=function(e,t){if(t.getGeometryByID(e.id))return null;var i=new r(e.id,t,e.width,e.height,e.subdivisions,e.canBeRegenerated,null);return I.Tags&&I.Tags.AddTagsTo(i,e.tags),t.pushGeometry(i,!0),i},r})(t);I.GroundGeometry=l;var c=(function(u){function t(e,t,i,r,n,o,s,a,l,c){void 0===c&&(c=null);var h=u.call(this,e,t,l,c)||this;return h.xmin=i,h.zmin=r,h.xmax=n,h.zmax=o,h.subdivisions=s,h.precision=a,h}return T(t,u),t.prototype._regenerateVertexData=function(){return I.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},t.prototype.copy=function(e){return new t(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},t})(t);I.TiledGroundGeometry=c;var h=(function(a){function r(e,t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=I.Mesh.DEFAULTSIDE);var s=a.call(this,e,t,r,n)||this;return s.size=i,s.side=o,s}return T(r,a),r.prototype._regenerateVertexData=function(){return I.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=a.prototype.serialize.call(this);return e.size=this.size,e},r.Parse=function(e,t){if(t.getGeometryByID(e.id))return null;var i=new r(e.id,t,e.size,e.canBeRegenerated,null);return I.Tags&&I.Tags.AddTagsTo(i,e.tags),t.pushGeometry(i,!0),i},r})(t);I.PlaneGeometry=h;var u=(function(d){function r(e,t,i,r,n,o,s,a,l,c,h){void 0===c&&(c=null),void 0===h&&(h=I.Mesh.DEFAULTSIDE);var u=d.call(this,e,t,l,c)||this;return u.radius=i,u.tube=r,u.radialSegments=n,u.tubularSegments=o,u.p=s,u.q=a,u.side=h,u}return T(r,d),r.prototype._regenerateVertexData=function(){return I.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},r.prototype.copy=function(e){return new r(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},r.prototype.serialize=function(){var e=d.prototype.serialize.call(this);return e.radius=this.radius,e.tube=this.tube,e.radialSegments=this.radialSegments,e.tubularSegments=this.tubularSegments,e.p=this.p,e.q=this.q,e},r.Parse=function(e,t){if(t.getGeometryByID(e.id))return null;var i=new r(e.id,t,e.radius,e.tube,e.radialSegments,e.tubularSegments,e.p,e.q,e.canBeRegenerated,null);return I.Tags&&I.Tags.AddTagsTo(i,e.tags),t.pushGeometry(i,!0),i},r})(t);I.TorusKnotGeometry=u})($a||($a={})),(function(i){var e=(function(){function e(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new t(e)}return e.prototype.sampleFrame=function(e){if(void 0===e&&(e=i.Tools.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})();i.PerformanceMonitor=e;var t=(function(){function e(e){this._samples=new Array(e),this.reset()}return e.prototype.add=function(e){var t;if(this.isSaturated()){var i=this._samples[this._pos];t=i-this.average,this.average-=t/(this._sampleCount-1),this._m2-=t*(i-this.average)}else this._sampleCount++;t=e-this.average,this.average+=t/this._sampleCount,this._m2+=t*(e-this.average),this.variance=this._m2/(this._sampleCount-1),this._samples[this._pos]=e,this._pos++,this._pos%=this._samples.length},e.prototype.history=function(e){if(e>=this._sampleCount||e>=this._samples.length)return 0;var t=this._wrapPosition(this._pos-1);return this._samples[this._wrapPosition(t-e)]},e.prototype.isSaturated=function(){return this._sampleCount>=this._samples.length},e.prototype.reset=function(){this.average=0,this.variance=0,this._sampleCount=0,this._pos=0,this._m2=0},e.prototype._wrapPosition=function(e){var t=this._samples.length;return(e%t+t)%t},e})();i.RollingAverage=t})($a||($a={})),de=$a||($a={}),fe=(function(){function u(){}return u.BindEyePosition=function(e,t){t._forcedViewPosition?e.setVector3("vEyePosition",t._forcedViewPosition):e.setVector3("vEyePosition",t._mirroredCameraPosition?t._mirroredCameraPosition:t.activeCamera.globalPosition)},u.PrepareDefinesForMergedUV=function(e,t,i){t._needUVs=!0,t[i]=!0,e.getTextureMatrix().isIdentity(!0)?(t[i+"DIRECTUV"]=e.coordinatesIndex+1,0===e.coordinatesIndex?t.MAINUV1=!0:t.MAINUV2=!0):t[i+"DIRECTUV"]=0},u.BindTextureMatrix=function(e,t,i){var r=e.getTextureMatrix();r.isIdentity(!0)||t.updateMatrix(i+"Matrix",r)},u.PrepareDefinesForMisc=function(e,t,i,r,n,o,s){s._areMiscDirty&&(s.LOGARITHMICDEPTH=i,s.POINTSIZE=r,s.FOG=t.fogEnabled&&e.applyFog&&t.fogMode!==de.Scene.FOGMODE_NONE&&n,s.NONUNIFORMSCALING=e.nonUniformScaling,s.ALPHATEST=o)},u.PrepareDefinesForFrameBoundValues=function(e,t,i,r,n){void 0===n&&(n=null);var o,s,a,l,c=!1;o=null==n?void 0!==e.clipPlane&&null!==e.clipPlane:n,s=null==n?void 0!==e.clipPlane2&&null!==e.clipPlane2:n,a=null==n?void 0!==e.clipPlane3&&null!==e.clipPlane3:n,l=null==n?void 0!==e.clipPlane4&&null!==e.clipPlane4:n,i.CLIPPLANE!==o&&(i.CLIPPLANE=o,c=!0),i.CLIPPLANE2!==s&&(i.CLIPPLANE2=s,c=!0),i.CLIPPLANE3!==a&&(i.CLIPPLANE3=a,c=!0),i.CLIPPLANE4!==l&&(i.CLIPPLANE4=l,c=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,c=!0),i.INSTANCES!==r&&(i.INSTANCES=r,c=!0),c&&i.markAsUnprocessed()},u.PrepareDefinesForAttributes=function(e,t,i,r,n,o){if(void 0===n&&(n=!1),void 0===o&&(o=!0),!t._areAttributesDirty&&t._needNormals===t._normals&&t._needUVs===t._uvs)return!1;if(t._normals=t._needNormals,t._uvs=t._needUVs,t.NORMAL=t._needNormals&&e.isVerticesDataPresent(de.VertexBuffer.NormalKind),t._needNormals&&e.isVerticesDataPresent(de.VertexBuffer.TangentKind)&&(t.TANGENT=!0),t._needUVs?(t.UV1=e.isVerticesDataPresent(de.VertexBuffer.UVKind),t.UV2=e.isVerticesDataPresent(de.VertexBuffer.UV2Kind)):(t.UV1=!1,t.UV2=!1),i){var s=e.useVertexColors&&e.isVerticesDataPresent(de.VertexBuffer.ColorKind);t.VERTEXCOLOR=s,t.VERTEXALPHA=e.hasVertexAlpha&&s&&o}if(r&&(e.useBones&&e.computeBonesUsingShaders&&e.skeleton?(t.NUM_BONE_INFLUENCERS=e.numBoneInfluencers,t.BonesPerMesh=e.skeleton.bones.length+1):(t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0)),n){var a=e.morphTargetManager;a?(t.MORPHTARGETS_TANGENT=a.supportsTangents&&t.TANGENT,t.MORPHTARGETS_NORMAL=a.supportsNormals&&t.NORMAL,t.MORPHTARGETS=0<a.numInfluencers,t.NUM_MORPH_INFLUENCERS=a.numInfluencers):(t.MORPHTARGETS_TANGENT=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS=!1,t.NUM_MORPH_INFLUENCERS=0)}return!0},u.PrepareDefinesForLights=function(e,t,i,r,n,o){if(void 0===n&&(n=4),void 0===o&&(o=!1),!i._areLightsDirty)return i._needNormals;var s=0,a=!1,l=!1,c=!1,h=!1,u=!1;if(e.lightsEnabled&&!o)for(var d=0,f=t._lightSources;d<f.length;d++){var p=f[d];switch(a=!0,void 0===i["LIGHT"+s]&&(l=!0),i["LIGHT"+s]=!0,i["SPOTLIGHT"+s]=!1,i["HEMILIGHT"+s]=!1,i["POINTLIGHT"+s]=!1,i["DIRLIGHT"+s]=!1,p.prepareLightSpecificDefines(i,s),i["LIGHT_FALLOFF_PHYSICAL"+s]=!1,i["LIGHT_FALLOFF_GLTF"+s]=!1,i["LIGHT_FALLOFF_STANDARD"+s]=!1,p.falloffType){case de.Light.FALLOFF_GLTF:i["LIGHT_FALLOFF_GLTF"+s]=!0;break;case de.Light.FALLOFF_PHYSICAL:i["LIGHT_FALLOFF_PHYSICAL"+s]=!0;break;case de.Light.FALLOFF_STANDARD:i["LIGHT_FALLOFF_STANDARD"+s]=!0}if(r&&!p.specular.equalsFloats(0,0,0)&&(u=!0),i["SHADOW"+s]=!1,i["SHADOWPCF"+s]=!1,i["SHADOWPCSS"+s]=!1,i["SHADOWPOISSON"+s]=!1,i["SHADOWESM"+s]=!1,i["SHADOWCUBE"+s]=!1,i["SHADOWLOWQUALITY"+s]=!1,i["SHADOWMEDIUMQUALITY"+s]=!1,t&&t.receiveShadows&&e.shadowsEnabled&&p.shadowEnabled){var m=p.getShadowGenerator();if(m){var _=m.getShadowMap();_&&_.renderList&&0<_.renderList.length&&(h=!0,m.prepareDefines(i,s))}}if(p.lightmapMode!=de.Light.LIGHTMAP_DEFAULT?(c=!0,i["LIGHTMAPEXCLUDED"+s]=!0,i["LIGHTMAPNOSPECULAR"+s]=p.lightmapMode==de.Light.LIGHTMAP_SHADOWSONLY):(i["LIGHTMAPEXCLUDED"+s]=!1,i["LIGHTMAPNOSPECULAR"+s]=!1),++s===n)break}i.SPECULARTERM=u,i.SHADOWS=h;for(var g=s;g<n;g++)void 0!==i["LIGHT"+g]&&(i["LIGHT"+g]=!1,i["HEMILIGHT"+s]=!1,i["POINTLIGHT"+s]=!1,i["DIRLIGHT"+s]=!1,i["SPOTLIGHT"+s]=!1,i["SHADOW"+s]=!1);var v=e.getEngine().getCaps();return void 0===i.SHADOWFLOAT&&(l=!0),i.SHADOWFLOAT=h&&(v.textureFloatRender&&v.textureFloatLinearFiltering||v.textureHalfFloatRender&&v.textureHalfFloatLinearFiltering),i.LIGHTMAPEXCLUDED=c,l&&i.rebuild(),a},u.PrepareUniformsAndSamplersList=function(e,t,i,r){var n;void 0===r&&(r=4);var o=null;if(e.uniformsNames){var s=e;n=s.uniformsNames,o=s.uniformBuffersNames,t=s.samplers,i=s.defines,r=s.maxSimultaneousLights}else n=e,t||(t=[]);for(var a=0;a<r&&i["LIGHT"+a];a++)n.push("vLightData"+a,"vLightDiffuse"+a,"vLightSpecular"+a,"vLightDirection"+a,"vLightFalloff"+a,"vLightGround"+a,"lightMatrix"+a,"shadowsInfo"+a,"depthValues"+a),o&&o.push("Light"+a),t.push("shadowSampler"+a),t.push("depthSampler"+a),i["PROJECTEDLIGHTTEXTURE"+a]&&(t.push("projectionLightSampler"+a),n.push("textureProjectionMatrix"+a));i.NUM_MORPH_INFLUENCERS&&n.push("morphTargetInfluences")},u.HandleFallbacksForShadows=function(e,t,i,r){void 0===i&&(i=4),void 0===r&&(r=0);for(var n=0,o=0;o<i&&e["LIGHT"+o];o++)0<o&&(n=r+o,t.addFallback(n,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(r,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(r,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o));return n++},u.PrepareAttributesForMorphTargets=function(e,t,i){var r=i.NUM_MORPH_INFLUENCERS;if(0<r&&de.Engine.LastCreatedEngine)for(var n=de.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,o=t.morphTargetManager,s=o&&o.supportsNormals&&i.NORMAL,a=o&&o.supportsTangents&&i.TANGENT,l=0;l<r;l++)e.push(de.VertexBuffer.PositionKind+l),s&&e.push(de.VertexBuffer.NormalKind+l),a&&e.push(de.VertexBuffer.TangentKind+l),e.length>n&&de.Tools.Error("Cannot add more vertex attributes for mesh "+t.name)},u.PrepareAttributesForBones=function(e,t,i,r){0<i.NUM_BONE_INFLUENCERS&&(r.addCPUSkinningFallback(0,t),e.push(de.VertexBuffer.MatricesIndicesKind),e.push(de.VertexBuffer.MatricesWeightsKind),4<i.NUM_BONE_INFLUENCERS&&(e.push(de.VertexBuffer.MatricesIndicesExtraKind),e.push(de.VertexBuffer.MatricesWeightsExtraKind)))},u.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},u.BindLightShadow=function(e,t,i,r,n){if(e.shadowEnabled&&i.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(r,n)}},u.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},u.BindLights=function(e,t,i,r,n,o){void 0===n&&(n=4),void 0===o&&(o=!1);for(var s=Math.min(t._lightSources.length,n),a=0;a<s;a++){var l=t._lightSources[a],c=a.toString(),h=l.getScaledIntensity();l._uniformBuffer.bindToEffect(i,"Light"+a),u.BindLightProperties(l,i,a),l.diffuse.scaleToRef(h,de.Tmp.Color3[0]),l._uniformBuffer.updateColor4("vLightDiffuse",de.Tmp.Color3[0],o?l.radius:l.range,c),r.SPECULARTERM&&(l.specular.scaleToRef(h,de.Tmp.Color3[1]),l._uniformBuffer.updateColor3("vLightSpecular",de.Tmp.Color3[1],c)),e.shadowsEnabled&&this.BindLightShadow(l,e,t,c,i),l._uniformBuffer.update()}},u.BindFogParameters=function(e,t,i,r){void 0===r&&(r=!1),e.fogEnabled&&t.applyFog&&e.fogMode!==de.Scene.FOGMODE_NONE&&(i.setFloat4("vFogInfos",e.fogMode,e.fogStart,e.fogEnd,e.fogDensity),r?(e.fogColor.toLinearSpaceToRef(this._tempFogColor),i.setColor3("vFogColor",this._tempFogColor)):i.setColor3("vFogColor",e.fogColor))},u.BindBonesParameters=function(e,t){if(t&&e&&(e.computeBonesUsingShaders&&t._bonesComputationForcedToCPU&&(e.computeBonesUsingShaders=!1),e.useBones&&e.computeBonesUsingShaders&&e.skeleton)){var i=e.skeleton.getTransformMatrices(e);i&&t.setMatrices("mBones",i)}},u.BindMorphTargetParameters=function(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)},u.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},u.BindClipPlane=function(e,t){if(t.clipPlane){var i=t.clipPlane;e.setFloat4("vClipPlane",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane2){i=t.clipPlane2;e.setFloat4("vClipPlane2",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane3){i=t.clipPlane3;e.setFloat4("vClipPlane3",i.normal.x,i.normal.y,i.normal.z,i.d)}if(t.clipPlane4){i=t.clipPlane4;e.setFloat4("vClipPlane4",i.normal.x,i.normal.y,i.normal.z,i.d)}},u._tempFogColor=de.Color3.Black(),u})(),de.MaterialHelper=fe,pe=$a||($a={}),me=(function(r){function e(e,t){var i=r.call(this,e,t)||this;return i._normalMatrix=new pe.Matrix,i.storeEffectOnSubMeshes=!0,i}return T(e,r),e.prototype.getEffect=function(){return this._activeEffect},e.prototype.isReady=function(e,t){return!!e&&(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))},e.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},e.prototype.bindOnlyNormalMatrix=function(e){this._activeEffect.setMatrix("normalMatrix",e)},e.prototype.bind=function(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])},e.prototype._afterBind=function(e,t){void 0===t&&(t=null),r.prototype._afterBind.call(this,e),this.getScene()._cachedEffect=t},e.prototype._mustRebind=function(e,t,i){return void 0===i&&(i=1),e.isCachedMaterialInvalid(this,t,i)},e})(pe.Material),pe.PushMaterial=me,(function(p){var m=(function(t){function e(){var e=t.call(this)||this;return e.MAINUV1=!1,e.MAINUV2=!1,e.DIFFUSE=!1,e.DIFFUSEDIRECTUV=0,e.AMBIENT=!1,e.AMBIENTDIRECTUV=0,e.OPACITY=!1,e.OPACITYDIRECTUV=0,e.OPACITYRGB=!1,e.REFLECTION=!1,e.EMISSIVE=!1,e.EMISSIVEDIRECTUV=0,e.SPECULAR=!1,e.SPECULARDIRECTUV=0,e.BUMP=!1,e.BUMPDIRECTUV=0,e.PARALLAX=!1,e.PARALLAXOCCLUSION=!1,e.SPECULAROVERALPHA=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.ALPHATEST=!1,e.DEPTHPREPASS=!1,e.ALPHAFROMDIFFUSE=!1,e.POINTSIZE=!1,e.FOG=!1,e.SPECULARTERM=!1,e.DIFFUSEFRESNEL=!1,e.OPACITYFRESNEL=!1,e.REFLECTIONFRESNEL=!1,e.REFRACTIONFRESNEL=!1,e.EMISSIVEFRESNEL=!1,e.FRESNEL=!1,e.NORMAL=!1,e.UV1=!1,e.UV2=!1,e.VERTEXCOLOR=!1,e.VERTEXALPHA=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.GLOSSINESS=!1,e.ROUGHNESS=!1,e.EMISSIVEASILLUMINATION=!1,e.LINKEMISSIVEWITHDIFFUSE=!1,e.REFLECTIONFRESNELFROMSPECULAR=!1,e.LIGHTMAP=!1,e.LIGHTMAPDIRECTUV=0,e.OBJECTSPACE_NORMALMAP=!1,e.USELIGHTMAPASSHADOWMAP=!1,e.REFLECTIONMAP_3D=!1,e.REFLECTIONMAP_SPHERICAL=!1,e.REFLECTIONMAP_PLANAR=!1,e.REFLECTIONMAP_CUBIC=!1,e.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,e.REFLECTIONMAP_PROJECTION=!1,e.REFLECTIONMAP_SKYBOX=!1,e.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,e.REFLECTIONMAP_EXPLICIT=!1,e.REFLECTIONMAP_EQUIRECTANGULAR=!1,e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.INVERTCUBICMAP=!1,e.LOGARITHMICDEPTH=!1,e.REFRACTION=!1,e.REFRACTIONMAP_3D=!1,e.REFLECTIONOVERALPHA=!1,e.TWOSIDEDLIGHTING=!1,e.SHADOWFLOAT=!1,e.MORPHTARGETS=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_TANGENT=!1,e.NUM_MORPH_INFLUENCERS=0,e.NONUNIFORMSCALING=!1,e.PREMULTIPLYALPHA=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.IS_REFLECTION_LINEAR=!1,e.IS_REFRACTION_LINEAR=!1,e.EXPOSURE=!1,e.rebuild(),e}return T(e,t),e.prototype.setReflectionMode=function(e){for(var t=0,i=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"];t<i.length;t++){var r=i[t];this[r]=r===e}},e})(p.MaterialDefines);p.StandardMaterialDefines=m;var e=(function(r){function f(e,t){var i=r.call(this,e,t)||this;return i.ambientColor=new p.Color3(0,0,0),i.diffuseColor=new p.Color3(1,1,1),i.specularColor=new p.Color3(1,1,1),i.emissiveColor=new p.Color3(0,0,0),i.specularPower=64,i._useAlphaFromDiffuseTexture=!1,i._useEmissiveAsIllumination=!1,i._linkEmissiveWithDiffuse=!1,i._useSpecularOverAlpha=!1,i._useReflectionOverAlpha=!1,i._disableLighting=!1,i._useObjectSpaceNormalMap=!1,i._useParallax=!1,i._useParallaxOcclusion=!1,i.parallaxScaleBias=.05,i._roughness=0,i.indexOfRefraction=.98,i.invertRefractionY=!0,i.alphaCutOff=.4,i._useLightmapAsShadowmap=!1,i._useReflectionFresnelFromSpecular=!1,i._useGlossinessFromSpecularMapAlpha=!1,i._maxSimultaneousLights=4,i._invertNormalMapX=!1,i._invertNormalMapY=!1,i._twoSidedLighting=!1,i._renderTargets=new p.SmartArray(16),i._worldViewProjectionMatrix=p.Matrix.Zero(),i._globalAmbientColor=new p.Color3(0,0,0),i._attachImageProcessingConfiguration(null),i.getRenderTargetTextures=function(){return i._renderTargets.reset(),f.ReflectionTextureEnabled&&i._reflectionTexture&&i._reflectionTexture.isRenderTarget&&i._renderTargets.push(i._reflectionTexture),f.RefractionTextureEnabled&&i._refractionTexture&&i._refractionTexture.isRenderTarget&&i._renderTargets.push(i._refractionTexture),i._renderTargets},i}return T(f,r),Object.defineProperty(f.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),f.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(e){t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(f.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(f.prototype,"hasRenderTargetTextures",{get:function(){return!!(f.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(f.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),f.prototype.getClassName=function(){return"StandardMaterial"},Object.defineProperty(f.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!0,configurable:!0}),f.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled},f.prototype.needAlphaTesting=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},f.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture},f.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},f.prototype.isReadyForSubMesh=function(e,t,i){if(void 0===i&&(i=!1),t.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new m);var r=this.getScene(),n=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&n._renderId===r.getRenderId())return!0;var o=r.getEngine();if(n._needNormals=p.MaterialHelper.PrepareDefinesForLights(r,e,n,!0,this._maxSimultaneousLights,this._disableLighting),n._areTexturesDirty){if(n._needUVs=!1,n.MAINUV1=!1,n.MAINUV2=!1,r.texturesEnabled){if(this._diffuseTexture&&f.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;p.MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture,n,"DIFFUSE")}else n.DIFFUSE=!1;if(this._ambientTexture&&f.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;p.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,n,"AMBIENT")}else n.AMBIENT=!1;if(this._opacityTexture&&f.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;p.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,n,"OPACITY"),n.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else n.OPACITY=!1;if(this._reflectionTexture&&f.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(n._needNormals=!0,n.REFLECTION=!0,n.ROUGHNESS=0<this._roughness,n.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,n.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===p.Texture.INVCUBIC_MODE,n.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case p.Texture.EXPLICIT_MODE:n.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case p.Texture.PLANAR_MODE:n.setReflectionMode("REFLECTIONMAP_PLANAR");break;case p.Texture.PROJECTION_MODE:n.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case p.Texture.SKYBOX_MODE:n.setReflectionMode("REFLECTIONMAP_SKYBOX"),n.REFLECTIONMAP_SKYBOX_TRANSFORMED=!this._reflectionTexture.getReflectionTextureMatrix().isIdentity();break;case p.Texture.SPHERICAL_MODE:n.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case p.Texture.EQUIRECTANGULAR_MODE:n.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case p.Texture.FIXED_EQUIRECTANGULAR_MODE:n.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case p.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:n.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case p.Texture.CUBIC_MODE:case p.Texture.INVCUBIC_MODE:default:n.setReflectionMode("REFLECTIONMAP_CUBIC")}n.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else n.REFLECTION=!1;if(this._emissiveTexture&&f.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;p.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,n,"EMISSIVE")}else n.EMISSIVE=!1;if(this._lightmapTexture&&f.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;p.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,n,"LIGHTMAP"),n.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else n.LIGHTMAP=!1;if(this._specularTexture&&f.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;p.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,n,"SPECULAR"),n.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else n.SPECULAR=!1;if(r.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&f.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;p.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,n,"BUMP"),n.PARALLAX=this._useParallax,n.PARALLAXOCCLUSION=this._useParallaxOcclusion,n.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else n.BUMP=!1;if(this._refractionTexture&&f.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;n._needUVs=!0,n.REFRACTION=!0,n.REFRACTIONMAP_3D=this._refractionTexture.isCube}else n.REFRACTION=!1;n.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else n.DIFFUSE=!1,n.AMBIENT=!1,n.OPACITY=!1,n.REFLECTION=!1,n.EMISSIVE=!1,n.LIGHTMAP=!1,n.BUMP=!1,n.REFRACTION=!1;n.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),n.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,n.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,n.SPECULAROVERALPHA=this._useSpecularOverAlpha,n.PREMULTIPLYALPHA=this.alphaMode===p.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===p.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF}if(n._areImageProcessingDirty&&this._imageProcessingConfiguration){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(n),n.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,n.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(n._areFresnelDirty&&(f.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(n.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,n.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,n.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,n.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,n.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,n.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,n._needNormals=!0,n.FRESNEL=!0):n.FRESNEL=!1),p.MaterialHelper.PrepareDefinesForMisc(e,r,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),n),p.MaterialHelper.PrepareDefinesForAttributes(e,n,!0,!0,!0),p.MaterialHelper.PrepareDefinesForFrameBoundValues(r,o,n,i),n.isDirty){n.markAsProcessed(),r.resetCachedMaterial();var s=new p.EffectFallbacks;n.REFLECTION&&s.addFallback(0,"REFLECTION"),n.SPECULAR&&s.addFallback(0,"SPECULAR"),n.BUMP&&s.addFallback(0,"BUMP"),n.PARALLAX&&s.addFallback(1,"PARALLAX"),n.PARALLAXOCCLUSION&&s.addFallback(0,"PARALLAXOCCLUSION"),n.SPECULAROVERALPHA&&s.addFallback(0,"SPECULAROVERALPHA"),n.FOG&&s.addFallback(1,"FOG"),n.POINTSIZE&&s.addFallback(0,"POINTSIZE"),n.LOGARITHMICDEPTH&&s.addFallback(0,"LOGARITHMICDEPTH"),p.MaterialHelper.HandleFallbacksForShadows(n,s,this._maxSimultaneousLights),n.SPECULARTERM&&s.addFallback(0,"SPECULARTERM"),n.DIFFUSEFRESNEL&&s.addFallback(1,"DIFFUSEFRESNEL"),n.OPACITYFRESNEL&&s.addFallback(2,"OPACITYFRESNEL"),n.REFLECTIONFRESNEL&&s.addFallback(3,"REFLECTIONFRESNEL"),n.EMISSIVEFRESNEL&&s.addFallback(4,"EMISSIVEFRESNEL"),n.FRESNEL&&s.addFallback(4,"FRESNEL");var a=[p.VertexBuffer.PositionKind];n.NORMAL&&a.push(p.VertexBuffer.NormalKind),n.UV1&&a.push(p.VertexBuffer.UVKind),n.UV2&&a.push(p.VertexBuffer.UV2Kind),n.VERTEXCOLOR&&a.push(p.VertexBuffer.ColorKind),p.MaterialHelper.PrepareAttributesForBones(a,e,n,s),p.MaterialHelper.PrepareAttributesForInstances(a,n),p.MaterialHelper.PrepareAttributesForMorphTargets(a,e,n);var l="default",c=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff"],h=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],u=["Material","Scene"];p.ImageProcessingConfiguration&&(p.ImageProcessingConfiguration.PrepareUniforms(c,n),p.ImageProcessingConfiguration.PrepareSamplers(h,n)),p.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:c,uniformBuffersNames:u,samplers:h,defines:n,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(l=this.customShaderNameResolve(l,c,u,h,n));var d=n.toString();t.setEffect(r.getEngine().createEffect(l,{attributes:a,uniformsNames:c,uniformBuffersNames:u,samplers:h,defines:d,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:n.NUM_MORPH_INFLUENCERS}},o),n),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(n._renderId=r.getRenderId(),this._wasPreviouslyReady=!0)},f.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("diffuseLeftColor",4),this._uniformBuffer.addUniform("diffuseRightColor",4),this._uniformBuffer.addUniform("opacityParts",4),this._uniformBuffer.addUniform("reflectionLeftColor",4),this._uniformBuffer.addUniform("reflectionRightColor",4),this._uniformBuffer.addUniform("refractionLeftColor",4),this._uniformBuffer.addUniform("refractionRightColor",4),this._uniformBuffer.addUniform("emissiveLeftColor",4),this._uniformBuffer.addUniform("emissiveRightColor",4),this._uniformBuffer.addUniform("vDiffuseInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",2),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vReflectionPosition",3),this._uniformBuffer.addUniform("vReflectionSize",3),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vSpecularInfos",2),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("diffuseMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("specularMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vSpecularColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("vDiffuseColor",4),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},f.prototype.unbind=function(){if(this._activeEffect){var e=!1;this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&(this._activeEffect.setTexture("reflection2DSampler",null),e=!0),this._refractionTexture&&this._refractionTexture.isRenderTarget&&(this._activeEffect.setTexture("refraction2DSampler",null),e=!0),e&&this._markAllSubMeshesAsTexturesDirty()}r.prototype.unbind.call(this)},f.prototype.bindForSubMesh=function(e,t,i){var r=this.getScene(),n=i._materialDefines;if(n){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),n.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var s=this._mustRebind(r,o,t.visibility);if(p.MaterialHelper.BindBonesParameters(t,o),s){if(this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(f.FresnelEnabled&&n.FRESNEL&&(this.diffuseFresnelParameters&&this.diffuseFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("diffuseLeftColor",this.diffuseFresnelParameters.leftColor,this.diffuseFresnelParameters.power),this._uniformBuffer.updateColor4("diffuseRightColor",this.diffuseFresnelParameters.rightColor,this.diffuseFresnelParameters.bias)),this.opacityFresnelParameters&&this.opacityFresnelParameters.isEnabled&&this._uniformBuffer.updateColor4("opacityParts",new p.Color3(this.opacityFresnelParameters.leftColor.toLuminance(),this.opacityFresnelParameters.rightColor.toLuminance(),this.opacityFresnelParameters.bias),this.opacityFresnelParameters.power),this.reflectionFresnelParameters&&this.reflectionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("reflectionLeftColor",this.reflectionFresnelParameters.leftColor,this.reflectionFresnelParameters.power),this._uniformBuffer.updateColor4("reflectionRightColor",this.reflectionFresnelParameters.rightColor,this.reflectionFresnelParameters.bias)),this.refractionFresnelParameters&&this.refractionFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("refractionLeftColor",this.refractionFresnelParameters.leftColor,this.refractionFresnelParameters.power),this._uniformBuffer.updateColor4("refractionRightColor",this.refractionFresnelParameters.rightColor,this.refractionFresnelParameters.bias)),this.emissiveFresnelParameters&&this.emissiveFresnelParameters.isEnabled&&(this._uniformBuffer.updateColor4("emissiveLeftColor",this.emissiveFresnelParameters.leftColor,this.emissiveFresnelParameters.power),this._uniformBuffer.updateColor4("emissiveRightColor",this.emissiveFresnelParameters.rightColor,this.emissiveFresnelParameters.bias))),r.texturesEnabled){if(this._diffuseTexture&&f.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),p.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse"),this._diffuseTexture.hasAlpha&&o.setFloat("alphaCutOff",this.alphaCutOff)),this._ambientTexture&&f.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),p.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&f.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),p.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&f.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var a=this._reflectionTexture;this._uniformBuffer.updateVector3("vReflectionPosition",a.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",a.boundingBoxSize)}if(this._emissiveTexture&&f.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),p.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&f.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),p.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&f.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),p.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&f.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),p.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),r._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),this._refractionTexture&&f.RefractionTextureEnabled){var l=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(l=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,l,this.invertRefractionY?-1:1)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),n.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*t.visibility)}if(r.texturesEnabled&&(this._diffuseTexture&&f.DiffuseTextureEnabled&&o.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&f.AmbientTextureEnabled&&o.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&f.OpacityTextureEnabled&&o.setTexture("opacitySampler",this._opacityTexture),this._reflectionTexture&&f.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?o.setTexture("reflectionCubeSampler",this._reflectionTexture):o.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&f.EmissiveTextureEnabled&&o.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&f.LightmapTextureEnabled&&o.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&f.SpecularTextureEnabled&&o.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&f.BumpTextureEnabled&&o.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&f.RefractionTextureEnabled)){l=1;this._refractionTexture.isCube?o.setTexture("refractionCubeSampler",this._refractionTexture):o.setTexture("refraction2DSampler",this._refractionTexture)}p.MaterialHelper.BindClipPlane(o,r),r.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),p.MaterialHelper.BindEyePosition(o,r),o.setColor3("vAmbientColor",this._globalAmbientColor)}!s&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&p.MaterialHelper.BindLights(r,t,o,n,this._maxSimultaneousLights),(r.fogEnabled&&t.applyFog&&r.fogMode!==p.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(o),p.MaterialHelper.BindFogParameters(r,t,o),n.NUM_MORPH_INFLUENCERS&&p.MaterialHelper.BindMorphTargetParameters(t,o),p.MaterialHelper.BindLogDepth(n,o,r),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},f.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&0<this._diffuseTexture.animations.length&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&0<this._ambientTexture.animations.length&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&0<this._opacityTexture.animations.length&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&0<this._reflectionTexture.animations.length&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&0<this._emissiveTexture.animations.length&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&0<this._specularTexture.animations.length&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&0<this._bumpTexture.animations.length&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&0<this._lightmapTexture.animations.length&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&0<this._refractionTexture.animations.length&&e.push(this._refractionTexture),e},f.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._diffuseTexture&&e.push(this._diffuseTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._specularTexture&&e.push(this._specularTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},f.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||(this._diffuseTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._emissiveTexture===e||(this._specularTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e))))))))},f.prototype.dispose=function(e,t){t&&(this._diffuseTexture&&this._diffuseTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._specularTexture&&this._specularTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},f.prototype.clone=function(e){var t=this,i=p.SerializationHelper.Clone((function(){return new f(e,t.getScene())}),this);return i.name=e,i.id=e,i},f.prototype.serialize=function(){return p.SerializationHelper.Serialize(this)},f.Parse=function(e,t,i){return p.SerializationHelper.Parse((function(){return new f(e.name,t)}),e,t,i)},Object.defineProperty(f,"DiffuseTextureEnabled",{get:function(){return f._DiffuseTextureEnabled},set:function(e){f._DiffuseTextureEnabled!==e&&(f._DiffuseTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"AmbientTextureEnabled",{get:function(){return f._AmbientTextureEnabled},set:function(e){f._AmbientTextureEnabled!==e&&(f._AmbientTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"OpacityTextureEnabled",{get:function(){return f._OpacityTextureEnabled},set:function(e){f._OpacityTextureEnabled!==e&&(f._OpacityTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"ReflectionTextureEnabled",{get:function(){return f._ReflectionTextureEnabled},set:function(e){f._ReflectionTextureEnabled!==e&&(f._ReflectionTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"EmissiveTextureEnabled",{get:function(){return f._EmissiveTextureEnabled},set:function(e){f._EmissiveTextureEnabled!==e&&(f._EmissiveTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"SpecularTextureEnabled",{get:function(){return f._SpecularTextureEnabled},set:function(e){f._SpecularTextureEnabled!==e&&(f._SpecularTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"BumpTextureEnabled",{get:function(){return f._BumpTextureEnabled},set:function(e){f._BumpTextureEnabled!==e&&(f._BumpTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"LightmapTextureEnabled",{get:function(){return f._LightmapTextureEnabled},set:function(e){f._LightmapTextureEnabled!==e&&(f._LightmapTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"RefractionTextureEnabled",{get:function(){return f._RefractionTextureEnabled},set:function(e){f._RefractionTextureEnabled!==e&&(f._RefractionTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"ColorGradingTextureEnabled",{get:function(){return f._ColorGradingTextureEnabled},set:function(e){f._ColorGradingTextureEnabled!==e&&(f._ColorGradingTextureEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(f,"FresnelEnabled",{get:function(){return f._FresnelEnabled},set:function(e){f._FresnelEnabled!==e&&(f._FresnelEnabled=e,p.Engine.MarkAllMaterialsAsDirty(p.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),f._DiffuseTextureEnabled=!0,f._AmbientTextureEnabled=!0,f._OpacityTextureEnabled=!0,f._ReflectionTextureEnabled=!0,f._EmissiveTextureEnabled=!0,f._SpecularTextureEnabled=!0,f._BumpTextureEnabled=!0,f._LightmapTextureEnabled=!0,f._RefractionTextureEnabled=!0,f._ColorGradingTextureEnabled=!0,f._FresnelEnabled=!0,b([p.serializeAsTexture("diffuseTexture")],f.prototype,"_diffuseTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],f.prototype,"diffuseTexture",void 0),b([p.serializeAsTexture("ambientTexture")],f.prototype,"_ambientTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"ambientTexture",void 0),b([p.serializeAsTexture("opacityTexture")],f.prototype,"_opacityTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],f.prototype,"opacityTexture",void 0),b([p.serializeAsTexture("reflectionTexture")],f.prototype,"_reflectionTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"reflectionTexture",void 0),b([p.serializeAsTexture("emissiveTexture")],f.prototype,"_emissiveTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"emissiveTexture",void 0),b([p.serializeAsTexture("specularTexture")],f.prototype,"_specularTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"specularTexture",void 0),b([p.serializeAsTexture("bumpTexture")],f.prototype,"_bumpTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"bumpTexture",void 0),b([p.serializeAsTexture("lightmapTexture")],f.prototype,"_lightmapTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"lightmapTexture",void 0),b([p.serializeAsTexture("refractionTexture")],f.prototype,"_refractionTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"refractionTexture",void 0),b([p.serializeAsColor3("ambient")],f.prototype,"ambientColor",void 0),b([p.serializeAsColor3("diffuse")],f.prototype,"diffuseColor",void 0),b([p.serializeAsColor3("specular")],f.prototype,"specularColor",void 0),b([p.serializeAsColor3("emissive")],f.prototype,"emissiveColor",void 0),b([p.serialize()],f.prototype,"specularPower",void 0),b([p.serialize("useAlphaFromDiffuseTexture")],f.prototype,"_useAlphaFromDiffuseTexture",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useAlphaFromDiffuseTexture",void 0),b([p.serialize("useEmissiveAsIllumination")],f.prototype,"_useEmissiveAsIllumination",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useEmissiveAsIllumination",void 0),b([p.serialize("linkEmissiveWithDiffuse")],f.prototype,"_linkEmissiveWithDiffuse",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"linkEmissiveWithDiffuse",void 0),b([p.serialize("useSpecularOverAlpha")],f.prototype,"_useSpecularOverAlpha",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useSpecularOverAlpha",void 0),b([p.serialize("useReflectionOverAlpha")],f.prototype,"_useReflectionOverAlpha",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useReflectionOverAlpha",void 0),b([p.serialize("disableLighting")],f.prototype,"_disableLighting",void 0),b([p.expandToProperty("_markAllSubMeshesAsLightsDirty")],f.prototype,"disableLighting",void 0),b([p.serialize("useObjectSpaceNormalMap")],f.prototype,"_useObjectSpaceNormalMap",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useObjectSpaceNormalMap",void 0),b([p.serialize("useParallax")],f.prototype,"_useParallax",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useParallax",void 0),b([p.serialize("useParallaxOcclusion")],f.prototype,"_useParallaxOcclusion",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useParallaxOcclusion",void 0),b([p.serialize()],f.prototype,"parallaxScaleBias",void 0),b([p.serialize("roughness")],f.prototype,"_roughness",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"roughness",void 0),b([p.serialize()],f.prototype,"indexOfRefraction",void 0),b([p.serialize()],f.prototype,"invertRefractionY",void 0),b([p.serialize()],f.prototype,"alphaCutOff",void 0),b([p.serialize("useLightmapAsShadowmap")],f.prototype,"_useLightmapAsShadowmap",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useLightmapAsShadowmap",void 0),b([p.serializeAsFresnelParameters("diffuseFresnelParameters")],f.prototype,"_diffuseFresnelParameters",void 0),b([p.expandToProperty("_markAllSubMeshesAsFresnelDirty")],f.prototype,"diffuseFresnelParameters",void 0),b([p.serializeAsFresnelParameters("opacityFresnelParameters")],f.prototype,"_opacityFresnelParameters",void 0),b([p.expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")],f.prototype,"opacityFresnelParameters",void 0),b([p.serializeAsFresnelParameters("reflectionFresnelParameters")],f.prototype,"_reflectionFresnelParameters",void 0),b([p.expandToProperty("_markAllSubMeshesAsFresnelDirty")],f.prototype,"reflectionFresnelParameters",void 0),b([p.serializeAsFresnelParameters("refractionFresnelParameters")],f.prototype,"_refractionFresnelParameters",void 0),b([p.expandToProperty("_markAllSubMeshesAsFresnelDirty")],f.prototype,"refractionFresnelParameters",void 0),b([p.serializeAsFresnelParameters("emissiveFresnelParameters")],f.prototype,"_emissiveFresnelParameters",void 0),b([p.expandToProperty("_markAllSubMeshesAsFresnelDirty")],f.prototype,"emissiveFresnelParameters",void 0),b([p.serialize("useReflectionFresnelFromSpecular")],f.prototype,"_useReflectionFresnelFromSpecular",void 0),b([p.expandToProperty("_markAllSubMeshesAsFresnelDirty")],f.prototype,"useReflectionFresnelFromSpecular",void 0),b([p.serialize("useGlossinessFromSpecularMapAlpha")],f.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"useGlossinessFromSpecularMapAlpha",void 0),b([p.serialize("maxSimultaneousLights")],f.prototype,"_maxSimultaneousLights",void 0),b([p.expandToProperty("_markAllSubMeshesAsLightsDirty")],f.prototype,"maxSimultaneousLights",void 0),b([p.serialize("invertNormalMapX")],f.prototype,"_invertNormalMapX",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"invertNormalMapX",void 0),b([p.serialize("invertNormalMapY")],f.prototype,"_invertNormalMapY",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"invertNormalMapY",void 0),b([p.serialize("twoSidedLighting")],f.prototype,"_twoSidedLighting",void 0),b([p.expandToProperty("_markAllSubMeshesAsTexturesDirty")],f.prototype,"twoSidedLighting",void 0),b([p.serialize()],f.prototype,"useLogarithmicDepth",null),f})(p.PushMaterial);p.StandardMaterial=e})($a||($a={})),(function(n){var e=(function(){function i(){this.x=n.Vector3.Zero(),this.y=n.Vector3.Zero(),this.z=n.Vector3.Zero(),this.xx=n.Vector3.Zero(),this.yy=n.Vector3.Zero(),this.zz=n.Vector3.Zero(),this.xy=n.Vector3.Zero(),this.yz=n.Vector3.Zero(),this.zx=n.Vector3.Zero()}return i.prototype.addAmbient=function(e){var t=new n.Vector3(e.r,e.g,e.b);this.xx=this.xx.add(t),this.yy=this.yy.add(t),this.zz=this.zz.add(t)},i.prototype.scale=function(e){this.x=this.x.scale(e),this.y=this.y.scale(e),this.z=this.z.scale(e),this.xx=this.xx.scale(e),this.yy=this.yy.scale(e),this.zz=this.zz.scale(e),this.yz=this.yz.scale(e),this.zx=this.zx.scale(e),this.xy=this.xy.scale(e)},i.FromHarmonics=function(e){var t=new i;return t.x=e.l11.scale(1.02333),t.y=e.l1_1.scale(1.02333),t.z=e.l10.scale(1.02333),t.xx=e.l00.scale(.886277).subtract(e.l20.scale(.247708)).add(e.lL22.scale(.429043)),t.yy=e.l00.scale(.886277).subtract(e.l20.scale(.247708)).subtract(e.lL22.scale(.429043)),t.zz=e.l00.scale(.886277).add(e.l20.scale(.495417)),t.yz=e.l2_1.scale(.858086),t.zx=e.l21.scale(.858086),t.xy=e.l2_2.scale(.858086),t.scale(1/Math.PI),t},i.FromArray=function(e){var t=new i;return n.Vector3.FromArrayToRef(e[0],0,t.x),n.Vector3.FromArrayToRef(e[1],0,t.y),n.Vector3.FromArrayToRef(e[2],0,t.z),n.Vector3.FromArrayToRef(e[3],0,t.xx),n.Vector3.FromArrayToRef(e[4],0,t.yy),n.Vector3.FromArrayToRef(e[5],0,t.zz),n.Vector3.FromArrayToRef(e[6],0,t.yz),n.Vector3.FromArrayToRef(e[7],0,t.zx),n.Vector3.FromArrayToRef(e[8],0,t.xy),t},i})();n.SphericalPolynomial=e;var t=(function(){function i(){this.l00=n.Vector3.Zero(),this.l1_1=n.Vector3.Zero(),this.l10=n.Vector3.Zero(),this.l11=n.Vector3.Zero(),this.l2_2=n.Vector3.Zero(),this.l2_1=n.Vector3.Zero(),this.l20=n.Vector3.Zero(),this.l21=n.Vector3.Zero(),this.lL22=n.Vector3.Zero()}return i.prototype.addLight=function(e,t,i){var r=new n.Vector3(t.r,t.g,t.b).scale(i);this.l00=this.l00.add(r.scale(.282095)),this.l1_1=this.l1_1.add(r.scale(.488603*e.y)),this.l10=this.l10.add(r.scale(.488603*e.z)),this.l11=this.l11.add(r.scale(.488603*e.x)),this.l2_2=this.l2_2.add(r.scale(1.092548*e.x*e.y)),this.l2_1=this.l2_1.add(r.scale(1.092548*e.y*e.z)),this.l21=this.l21.add(r.scale(1.092548*e.x*e.z)),this.l20=this.l20.add(r.scale(.315392*(3*e.z*e.z-1))),this.lL22=this.lL22.add(r.scale(.546274*(e.x*e.x-e.y*e.y)))},i.prototype.scale=function(e){this.l00=this.l00.scale(e),this.l1_1=this.l1_1.scale(e),this.l10=this.l10.scale(e),this.l11=this.l11.scale(e),this.l2_2=this.l2_2.scale(e),this.l2_1=this.l2_1.scale(e),this.l20=this.l20.scale(e),this.l21=this.l21.scale(e),this.lL22=this.lL22.scale(e)},i.prototype.convertIncidentRadianceToIrradiance=function(){this.l00=this.l00.scale(3.141593),this.l1_1=this.l1_1.scale(2.094395),this.l10=this.l10.scale(2.094395),this.l11=this.l11.scale(2.094395),this.l2_2=this.l2_2.scale(.785398),this.l2_1=this.l2_1.scale(.785398),this.l20=this.l20.scale(.785398),this.l21=this.l21.scale(.785398),this.lL22=this.lL22.scale(.785398)},i.prototype.convertIrradianceToLambertianRadiance=function(){this.scale(1/Math.PI)},i.FromPolynomial=function(e){var t=new i;return t.l00=e.xx.scale(.376127).add(e.yy.scale(.376127)).add(e.zz.scale(.376126)),t.l1_1=e.y.scale(.977204),t.l10=e.z.scale(.977204),t.l11=e.x.scale(.977204),t.l2_2=e.xy.scale(1.16538),t.l2_1=e.yz.scale(1.16538),t.l20=e.zz.scale(1.34567).subtract(e.xx.scale(.672834)).subtract(e.yy.scale(.672834)),t.l21=e.zx.scale(1.16538),t.lL22=e.xx.scale(1.16538).subtract(e.yy.scale(1.16538)),t.scale(Math.PI),t},i.FromArray=function(e){var t=new i;return n.Vector3.FromArrayToRef(e[0],0,t.l00),n.Vector3.FromArrayToRef(e[1],0,t.l1_1),n.Vector3.FromArrayToRef(e[2],0,t.l10),n.Vector3.FromArrayToRef(e[3],0,t.l11),n.Vector3.FromArrayToRef(e[4],0,t.l2_2),n.Vector3.FromArrayToRef(e[5],0,t.l2_1),n.Vector3.FromArrayToRef(e[6],0,t.l20),n.Vector3.FromArrayToRef(e[7],0,t.l21),n.Vector3.FromArrayToRef(e[8],0,t.lL22),t},i})();n.SphericalHarmonics=t})($a||($a={})),_e=$a||($a={}),ge=function(e,t,i,r){this.name=e,this.worldAxisForNormal=t,this.worldAxisForFileX=i,this.worldAxisForFileY=r},ve=(function(){function e(){}return e.ConvertCubeMapTextureToSphericalPolynomial=function(e){if(!e.isCube)return null;var t,i,r=e.getSize().width,n=e.readPixels(0),o=e.readPixels(1);e.isRenderTarget?(t=e.readPixels(3),i=e.readPixels(2)):(t=e.readPixels(2),i=e.readPixels(3));var s=e.readPixels(4),a=e.readPixels(5),l=e.gammaSpace,c=_e.Engine.TEXTUREFORMAT_RGBA,h=_e.Engine.TEXTURETYPE_UNSIGNED_INT;e.textureType&&e.textureType!==_e.Engine.TEXTURETYPE_UNSIGNED_INT&&(h=_e.Engine.TEXTURETYPE_FLOAT);var u={size:r,right:n,left:o,up:t,down:i,front:s,back:a,format:c,type:h,gammaSpace:l};return this.ConvertCubeMapToSphericalPolynomial(u)},e.ConvertCubeMapToSphericalPolynomial=function(e){for(var t=new _e.SphericalHarmonics,i=0,r=2/e.size,n=r,o=.5*r-1,s=0;s<6;s++)for(var a=this.FileFaces[s],l=e[a.name],c=o,h=e.format===_e.Engine.TEXTUREFORMAT_RGBA?4:3,u=0;u<e.size;u++){for(var d=o,f=0;f<e.size;f++){var p=a.worldAxisForFileX.scale(d).add(a.worldAxisForFileY.scale(c)).add(a.worldAxisForNormal);p.normalize();var m=Math.pow(1+d*d+c*c,-1.5),_=l[u*e.size*h+f*h+0],g=l[u*e.size*h+f*h+1],v=l[u*e.size*h+f*h+2];e.type===_e.Engine.TEXTURETYPE_UNSIGNED_INT&&(_/=255,g/=255,v/=255),e.gammaSpace&&(_=Math.pow(_e.Scalar.Clamp(_),_e.ToLinearSpace),g=Math.pow(_e.Scalar.Clamp(g),_e.ToLinearSpace),v=Math.pow(_e.Scalar.Clamp(v),_e.ToLinearSpace));var y=new _e.Color3(_,g,v);t.addLight(p,y,m),i+=m,d+=r}c+=n}var b=6*(4*Math.PI)/6/i;return t.scale(b),t.convertIncidentRadianceToIrradiance(),t.convertIrradianceToLambertianRadiance(),_e.SphericalPolynomial.FromHarmonics(t)},e.FileFaces=[new ge("right",new _e.Vector3(1,0,0),new _e.Vector3(0,0,-1),new _e.Vector3(0,-1,0)),new ge("left",new _e.Vector3(-1,0,0),new _e.Vector3(0,0,1),new _e.Vector3(0,-1,0)),new ge("up",new _e.Vector3(0,1,0),new _e.Vector3(1,0,0),new _e.Vector3(0,0,1)),new ge("down",new _e.Vector3(0,-1,0),new _e.Vector3(1,0,0),new _e.Vector3(0,0,-1)),new ge("front",new _e.Vector3(0,0,1),new _e.Vector3(1,0,0),new _e.Vector3(0,-1,0)),new ge("back",new _e.Vector3(0,0,-1),new _e.Vector3(-1,0,0),new _e.Vector3(0,-1,0))],e})(),_e.CubeMapToSphericalPolynomialTools=ve,ye=$a||($a={}),be=(function(t){function e(){var e=t.call(this)||this;return e.PBR=!0,e.MAINUV1=!1,e.MAINUV2=!1,e.UV1=!1,e.UV2=!1,e.ALBEDO=!1,e.ALBEDODIRECTUV=0,e.VERTEXCOLOR=!1,e.AMBIENT=!1,e.AMBIENTDIRECTUV=0,e.AMBIENTINGRAYSCALE=!1,e.OPACITY=!1,e.VERTEXALPHA=!1,e.OPACITYDIRECTUV=0,e.OPACITYRGB=!1,e.ALPHATEST=!1,e.DEPTHPREPASS=!1,e.ALPHABLEND=!1,e.ALPHAFROMALBEDO=!1,e.ALPHATESTVALUE="0.5",e.SPECULAROVERALPHA=!1,e.RADIANCEOVERALPHA=!1,e.ALPHAFRESNEL=!1,e.LINEARALPHAFRESNEL=!1,e.PREMULTIPLYALPHA=!1,e.EMISSIVE=!1,e.EMISSIVEDIRECTUV=0,e.REFLECTIVITY=!1,e.REFLECTIVITYDIRECTUV=0,e.SPECULARTERM=!1,e.MICROSURFACEFROMREFLECTIVITYMAP=!1,e.MICROSURFACEAUTOMATIC=!1,e.LODBASEDMICROSFURACE=!1,e.MICROSURFACEMAP=!1,e.MICROSURFACEMAPDIRECTUV=0,e.METALLICWORKFLOW=!1,e.ROUGHNESSSTOREINMETALMAPALPHA=!1,e.ROUGHNESSSTOREINMETALMAPGREEN=!1,e.METALLNESSSTOREINMETALMAPBLUE=!1,e.AOSTOREINMETALMAPRED=!1,e.ENVIRONMENTBRDF=!1,e.NORMAL=!1,e.TANGENT=!1,e.BUMP=!1,e.BUMPDIRECTUV=0,e.OBJECTSPACE_NORMALMAP=!1,e.PARALLAX=!1,e.PARALLAXOCCLUSION=!1,e.NORMALXYSCALE=!0,e.LIGHTMAP=!1,e.LIGHTMAPDIRECTUV=0,e.USELIGHTMAPASSHADOWMAP=!1,e.GAMMALIGHTMAP=!1,e.REFLECTION=!1,e.REFLECTIONMAP_3D=!1,e.REFLECTIONMAP_SPHERICAL=!1,e.REFLECTIONMAP_PLANAR=!1,e.REFLECTIONMAP_CUBIC=!1,e.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,e.REFLECTIONMAP_PROJECTION=!1,e.REFLECTIONMAP_SKYBOX=!1,e.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,e.REFLECTIONMAP_EXPLICIT=!1,e.REFLECTIONMAP_EQUIRECTANGULAR=!1,e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.INVERTCUBICMAP=!1,e.USESPHERICALFROMREFLECTIONMAP=!1,e.USESPHERICALINVERTEX=!1,e.REFLECTIONMAP_OPPOSITEZ=!1,e.LODINREFLECTIONALPHA=!1,e.GAMMAREFLECTION=!1,e.RGBDREFLECTION=!1,e.RADIANCEOCCLUSION=!1,e.HORIZONOCCLUSION=!1,e.REFRACTION=!1,e.REFRACTIONMAP_3D=!1,e.REFRACTIONMAP_OPPOSITEZ=!1,e.LODINREFRACTIONALPHA=!1,e.GAMMAREFRACTION=!1,e.RGBDREFRACTION=!1,e.LINKREFRACTIONTOTRANSPARENCY=!1,e.INSTANCES=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.NONUNIFORMSCALING=!1,e.MORPHTARGETS=!1,e.MORPHTARGETS_NORMAL=!1,e.MORPHTARGETS_TANGENT=!1,e.NUM_MORPH_INFLUENCERS=0,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.EXPOSURE=!1,e.USEPHYSICALLIGHTFALLOFF=!1,e.USEGLTFLIGHTFALLOFF=!1,e.TWOSIDEDLIGHTING=!1,e.SHADOWFLOAT=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.POINTSIZE=!1,e.FOG=!1,e.LOGARITHMICDEPTH=!1,e.FORCENORMALFORWARD=!1,e.SPECULARAA=!1,e.UNLIT=!1,e.rebuild(),e}return T(e,t),e.prototype.reset=function(){t.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0},e})(ye.MaterialDefines),Te=(function(r){function p(e,t){var i=r.call(this,e,t)||this;return i._directIntensity=1,i._emissiveIntensity=1,i._environmentIntensity=1,i._specularIntensity=1,i._lightingInfos=new ye.Vector4(i._directIntensity,i._emissiveIntensity,i._environmentIntensity,i._specularIntensity),i._disableBumpMap=!1,i._ambientTextureStrength=1,i._ambientTextureImpactOnAnalyticalLights=ye.PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,i._ambientColor=new ye.Color3(0,0,0),i._albedoColor=new ye.Color3(1,1,1),i._reflectivityColor=new ye.Color3(1,1,1),i._reflectionColor=new ye.Color3(1,1,1),i._emissiveColor=new ye.Color3(0,0,0),i._microSurface=.9,i._indexOfRefraction=.66,i._invertRefractionY=!1,i._linkRefractionWithTransparency=!1,i._useLightmapAsShadowmap=!1,i._useHorizonOcclusion=!0,i._useRadianceOcclusion=!0,i._useAlphaFromAlbedoTexture=!1,i._useSpecularOverAlpha=!0,i._useMicroSurfaceFromReflectivityMapAlpha=!1,i._useRoughnessFromMetallicTextureAlpha=!0,i._useRoughnessFromMetallicTextureGreen=!1,i._useMetallnessFromMetallicTextureBlue=!1,i._useAmbientOcclusionFromMetallicTextureRed=!1,i._useAmbientInGrayScale=!1,i._useAutoMicroSurfaceFromReflectivityMap=!1,i._lightFalloff=p.LIGHTFALLOFF_PHYSICAL,i._useRadianceOverAlpha=!0,i._useObjectSpaceNormalMap=!1,i._useParallax=!1,i._useParallaxOcclusion=!1,i._parallaxScaleBias=.05,i._disableLighting=!1,i._maxSimultaneousLights=4,i._invertNormalMapX=!1,i._invertNormalMapY=!1,i._twoSidedLighting=!1,i._alphaCutOff=.4,i._forceAlphaTest=!1,i._useAlphaFresnel=!1,i._useLinearAlphaFresnel=!1,i._transparencyMode=null,i._environmentBRDFTexture=null,i._forceIrradianceInFragment=!1,i._forceNormalForward=!1,i._enableSpecularAntiAliasing=!1,i._renderTargets=new ye.SmartArray(16),i._globalAmbientColor=new ye.Color3(0,0,0),i._unlit=!1,i._attachImageProcessingConfiguration(null),i.getRenderTargetTextures=function(){return i._renderTargets.reset(),ye.StandardMaterial.ReflectionTextureEnabled&&i._reflectionTexture&&i._reflectionTexture.isRenderTarget&&i._renderTargets.push(i._reflectionTexture),ye.StandardMaterial.RefractionTextureEnabled&&i._refractionTexture&&i._refractionTexture.isRenderTarget&&i._renderTargets.push(i._refractionTexture),i._renderTargets},i._environmentBRDFTexture=ye.TextureTools.GetEnvironmentBRDFTexture(t),i}return T(p,r),p.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(e){t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(p.prototype,"hasRenderTargetTextures",{get:function(){return!!(ye.StandardMaterial.ReflectionTextureEnabled&&this._reflectionTexture&&this._reflectionTexture.isRenderTarget)||!!(ye.StandardMaterial.RefractionTextureEnabled&&this._refractionTexture&&this._refractionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),p.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(p.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(e){this._transparencyMode!==e&&(this._transparencyMode=e,this._forceAlphaTest=e===ye.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"_disableAlphaBlending",{get:function(){return this._linkRefractionWithTransparency||this._transparencyMode===ye.PBRMaterial.PBRMATERIAL_OPAQUE||this._transparencyMode===ye.PBRMaterial.PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),p.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},p.prototype.needAlphaBlendingForMesh=function(e){return!this._disableAlphaBlending&&r.prototype.needAlphaBlendingForMesh.call(this,e)},p.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&(null==this._transparencyMode||this._transparencyMode===ye.PBRMaterial.PBRMATERIAL_ALPHATEST))},p.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==ye.PBRMaterial.PBRMATERIAL_OPAQUE},p.prototype.getAlphaTestTexture=function(){return this._albedoTexture},p.prototype.isReadyForSubMesh=function(e,t,i){if(t.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new be);var r=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&r._renderId===this.getScene().getRenderId())return!0;var n=this.getScene(),o=n.getEngine();if(r._areTexturesDirty&&n.texturesEnabled){if(this._albedoTexture&&ye.StandardMaterial.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&ye.StandardMaterial.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&ye.StandardMaterial.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var s=this._getReflectionTexture();if(s&&ye.StandardMaterial.ReflectionTextureEnabled&&!s.isReadyOrNotBlocking())return!1;if(this._lightmapTexture&&ye.StandardMaterial.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&ye.StandardMaterial.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(ye.StandardMaterial.SpecularTextureEnabled){if(this._metallicTexture){if(!this._metallicTexture.isReadyOrNotBlocking())return!1}else if(this._reflectivityTexture&&!this._reflectivityTexture.isReadyOrNotBlocking())return!1;if(this._microSurfaceTexture&&!this._microSurfaceTexture.isReadyOrNotBlocking())return!1}if(o.getCaps().standardDerivatives&&this._bumpTexture&&ye.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;var a=this._getRefractionTexture();if(a&&ye.StandardMaterial.RefractionTextureEnabled&&!a.isReadyOrNotBlocking())return!1;if(this._environmentBRDFTexture&&ye.StandardMaterial.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(r._areImageProcessingDirty&&this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.isReady())return!1;o.getCaps().standardDerivatives||e.isVerticesDataPresent(ye.VertexBuffer.NormalKind)||(e.createNormals(!0),ye.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+e.name));var l=this._prepareEffect(e,r,this.onCompiled,this.onError,i);return l&&(n.resetCachedMaterial(),t.setEffect(l,r),this.buildUniformLayout()),!(!t.effect||!t.effect.isReady())&&(r._renderId=n.getRenderId(),this._wasPreviouslyReady=!0)},p.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},p.prototype._prepareEffect=function(e,t,i,r,n,o){if(void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),this._prepareDefines(e,t,n,o),!t.isDirty)return null;t.markAsProcessed();var s=this.getScene().getEngine(),a=new ye.EffectFallbacks,l=0;t.USESPHERICALINVERTEX&&a.addFallback(l++,"USESPHERICALINVERTEX"),t.FOG&&a.addFallback(l,"FOG"),t.SPECULARAA&&a.addFallback(l,"SPECULARAA"),t.POINTSIZE&&a.addFallback(l,"POINTSIZE"),t.LOGARITHMICDEPTH&&a.addFallback(l,"LOGARITHMICDEPTH"),t.PARALLAX&&a.addFallback(l,"PARALLAX"),t.PARALLAXOCCLUSION&&a.addFallback(l++,"PARALLAXOCCLUSION"),t.ENVIRONMENTBRDF&&a.addFallback(l++,"ENVIRONMENTBRDF"),t.TANGENT&&a.addFallback(l++,"TANGENT"),t.BUMP&&a.addFallback(l++,"BUMP"),l=ye.MaterialHelper.HandleFallbacksForShadows(t,a,this._maxSimultaneousLights,l++),t.SPECULARTERM&&a.addFallback(l++,"SPECULARTERM"),t.USESPHERICALFROMREFLECTIONMAP&&a.addFallback(l++,"USESPHERICALFROMREFLECTIONMAP"),t.LIGHTMAP&&a.addFallback(l++,"LIGHTMAP"),t.NORMAL&&a.addFallback(l++,"NORMAL"),t.AMBIENT&&a.addFallback(l++,"AMBIENT"),t.EMISSIVE&&a.addFallback(l++,"EMISSIVE"),t.VERTEXCOLOR&&a.addFallback(l++,"VERTEXCOLOR"),0<t.NUM_BONE_INFLUENCERS&&a.addCPUSkinningFallback(l++,e),t.MORPHTARGETS&&a.addFallback(l++,"MORPHTARGETS");var c=[ye.VertexBuffer.PositionKind];t.NORMAL&&c.push(ye.VertexBuffer.NormalKind),t.TANGENT&&c.push(ye.VertexBuffer.TangentKind),t.UV1&&c.push(ye.VertexBuffer.UVKind),t.UV2&&c.push(ye.VertexBuffer.UV2Kind),t.VERTEXCOLOR&&c.push(ye.VertexBuffer.ColorKind),ye.MaterialHelper.PrepareAttributesForBones(c,e,t,a),ye.MaterialHelper.PrepareAttributesForInstances(c,t),ye.MaterialHelper.PrepareAttributesForMorphTargets(c,e,t);var h=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vAlbedoColor","vReflectivityColor","vEmissiveColor","vReflectionColor","vFogInfos","vFogColor","pointSize","vAlbedoInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vReflectionPosition","vReflectionSize","vEmissiveInfos","vReflectivityInfos","vMicroSurfaceSamplerInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","albedoMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","reflectivityMatrix","normalMatrix","microSurfaceSamplerMatrix","bumpMatrix","lightmapMatrix","refractionMatrix","vLightingIntensity","logarithmicDepthConstant","vSphericalX","vSphericalY","vSphericalZ","vSphericalXX","vSphericalYY","vSphericalZZ","vSphericalXY","vSphericalYZ","vSphericalZX","vReflectionMicrosurfaceInfos","vRefractionMicrosurfaceInfos","vTangentSpaceParams"],u=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],d=["Material","Scene"];ye.ImageProcessingConfiguration&&(ye.ImageProcessingConfiguration.PrepareUniforms(h,t),ye.ImageProcessingConfiguration.PrepareSamplers(u,t)),ye.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:d,samplers:u,defines:t,maxSimultaneousLights:this._maxSimultaneousLights});var f=t.toString();return s.createEffect("pbr",{attributes:c,uniformsNames:h,uniformBuffersNames:d,samplers:u,defines:f,fallbacks:a,onCompiled:i,onError:r,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:t.NUM_MORPH_INFLUENCERS}},s)},p.prototype._prepareDefines=function(e,t,i,r){void 0===i&&(i=null),void 0===r&&(r=null);var n=this.getScene(),o=n.getEngine();if(ye.MaterialHelper.PrepareDefinesForLights(n,e,t,!0,this._maxSimultaneousLights,this._disableLighting),t._needNormals=!0,t.METALLICWORKFLOW=this.isMetallicWorkflow(),t._areTexturesDirty){if(t._needUVs=!1,n.texturesEnabled){n.getEngine().getCaps().textureLOD&&(t.LODBASEDMICROSFURACE=!0),this._albedoTexture&&ye.StandardMaterial.DiffuseTextureEnabled?ye.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,t,"ALBEDO"):t.ALBEDO=!1,this._ambientTexture&&ye.StandardMaterial.AmbientTextureEnabled?(ye.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,t,"AMBIENT"),t.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):t.AMBIENT=!1,this._opacityTexture&&ye.StandardMaterial.OpacityTextureEnabled?(ye.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,t,"OPACITY"),t.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):t.OPACITY=!1;var s=this._getReflectionTexture();if(s&&ye.StandardMaterial.ReflectionTextureEnabled){switch(t.REFLECTION=!0,t.GAMMAREFLECTION=s.gammaSpace,t.RGBDREFLECTION=s.isRGBD,t.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!s.invertZ:s.invertZ,t.LODINREFLECTIONALPHA=s.lodLevelInAlpha,s.coordinatesMode===ye.Texture.INVCUBIC_MODE&&(t.INVERTCUBICMAP=!0),t.REFLECTIONMAP_3D=s.isCube,s.coordinatesMode){case ye.Texture.EXPLICIT_MODE:t.REFLECTIONMAP_EXPLICIT=!0;break;case ye.Texture.PLANAR_MODE:t.REFLECTIONMAP_PLANAR=!0;break;case ye.Texture.PROJECTION_MODE:t.REFLECTIONMAP_PROJECTION=!0;break;case ye.Texture.SKYBOX_MODE:t.REFLECTIONMAP_SKYBOX=!0;break;case ye.Texture.SPHERICAL_MODE:t.REFLECTIONMAP_SPHERICAL=!0;break;case ye.Texture.EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case ye.Texture.FIXED_EQUIRECTANGULAR_MODE:t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case ye.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case ye.Texture.CUBIC_MODE:case ye.Texture.INVCUBIC_MODE:default:t.REFLECTIONMAP_CUBIC=!0,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!!s.boundingBoxSize}s.coordinatesMode!==ye.Texture.SKYBOX_MODE?s.sphericalPolynomial&&(t.USESPHERICALFROMREFLECTIONMAP=!0,this._forceIrradianceInFragment||n.getEngine().getCaps().maxVaryingVectors<=8?t.USESPHERICALINVERTEX=!1:t.USESPHERICALINVERTEX=!0):t.REFLECTIONMAP_SKYBOX_TRANSFORMED=!s.getReflectionTextureMatrix().isIdentity()}else t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.USESPHERICALFROMREFLECTIONMAP=!1,t.USESPHERICALINVERTEX=!1,t.REFLECTIONMAP_OPPOSITEZ=!1,t.LODINREFLECTIONALPHA=!1,t.GAMMAREFLECTION=!1,t.RGBDREFLECTION=!1;this._lightmapTexture&&ye.StandardMaterial.LightmapTextureEnabled?(ye.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,t,"LIGHTMAP"),t.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,t.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace):t.LIGHTMAP=!1,this._emissiveTexture&&ye.StandardMaterial.EmissiveTextureEnabled?ye.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,t,"EMISSIVE"):t.EMISSIVE=!1,ye.StandardMaterial.SpecularTextureEnabled?(this._metallicTexture?(ye.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,t,"REFLECTIVITY"),t.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,t.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,t.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,t.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed):this._reflectivityTexture?(ye.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,t,"REFLECTIVITY"),t.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,t.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):t.REFLECTIVITY=!1,this._microSurfaceTexture?ye.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,t,"MICROSURFACEMAP"):t.MICROSURFACEMAP=!1):(t.REFLECTIVITY=!1,t.MICROSURFACEMAP=!1),n.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&ye.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap?(ye.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,t,"BUMP"),this._useParallax&&this._albedoTexture&&ye.StandardMaterial.DiffuseTextureEnabled?(t.PARALLAX=!0,t.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):t.PARALLAX=!1,t.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):t.BUMP=!1;var a=this._getRefractionTexture();a&&ye.StandardMaterial.RefractionTextureEnabled?(t.REFRACTION=!0,t.REFRACTIONMAP_3D=a.isCube,t.GAMMAREFRACTION=a.gammaSpace,t.RGBDREFRACTION=a.isRGBD,t.REFRACTIONMAP_OPPOSITEZ=a.invertZ,t.LODINREFRACTIONALPHA=a.lodLevelInAlpha,this._linkRefractionWithTransparency&&(t.LINKREFRACTIONTOTRANSPARENCY=!0)):t.REFRACTION=!1,this._environmentBRDFTexture&&ye.StandardMaterial.ReflectionTextureEnabled?t.ENVIRONMENTBRDF=!0:t.ENVIRONMENTBRDF=!1,this._shouldUseAlphaFromAlbedoTexture()?t.ALPHAFROMALBEDO=!0:t.ALPHAFROMALBEDO=!1}t.SPECULAROVERALPHA=this._useSpecularOverAlpha,this._lightFalloff===p.LIGHTFALLOFF_STANDARD?(t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!1):this._lightFalloff===p.LIGHTFALLOFF_GLTF?(t.USEPHYSICALLIGHTFALLOFF=!1,t.USEGLTFLIGHTFALLOFF=!0):(t.USEPHYSICALLIGHTFALLOFF=!0,t.USEGLTFLIGHTFALLOFF=!1),t.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?t.TWOSIDEDLIGHTING=!0:t.TWOSIDEDLIGHTING=!1,t.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),t.PREMULTIPLYALPHA=this.alphaMode===ye.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===ye.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,t.ALPHABLEND=this.needAlphaBlendingForMesh(e),t.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,t.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel,t.SPECULARAA=n.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}t._areImageProcessingDirty&&this._imageProcessingConfiguration&&this._imageProcessingConfiguration.prepareDefines(t),t.FORCENORMALFORWARD=this._forceNormalForward,t.RADIANCEOCCLUSION=this._useRadianceOcclusion,t.HORIZONOCCLUSION=this._useHorizonOcclusion,t._areMiscDirty&&(ye.MaterialHelper.PrepareDefinesForMisc(e,n,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e)||this._forceAlphaTest,t),t.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!e.isVerticesDataPresent(ye.VertexBuffer.NormalKind)),ye.MaterialHelper.PrepareDefinesForFrameBoundValues(n,o,t,!!i,r),ye.MaterialHelper.PrepareDefinesForAttributes(e,t,!0,!0,!0,this._transparencyMode!==ye.PBRMaterial.PBRMATERIAL_OPAQUE)},p.prototype.forceCompilation=function(e,t,i){var r=this,n=ae({clipPlane:!1},i),o=new be,s=this._prepareEffect(e,o,void 0,void 0,void 0,n.clipPlane);s.isReady()?t&&t(this):s.onCompileObservable.add((function(){t&&t(r)}))},p.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",4),this._uniformBuffer.addUniform("vOpacityInfos",2),this._uniformBuffer.addUniform("vEmissiveInfos",2),this._uniformBuffer.addUniform("vLightmapInfos",2),this._uniformBuffer.addUniform("vReflectivityInfos",3),this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos",2),this._uniformBuffer.addUniform("vRefractionInfos",4),this._uniformBuffer.addUniform("vReflectionInfos",2),this._uniformBuffer.addUniform("vReflectionPosition",3),this._uniformBuffer.addUniform("vReflectionSize",3),this._uniformBuffer.addUniform("vBumpInfos",3),this._uniformBuffer.addUniform("albedoMatrix",16),this._uniformBuffer.addUniform("ambientMatrix",16),this._uniformBuffer.addUniform("opacityMatrix",16),this._uniformBuffer.addUniform("emissiveMatrix",16),this._uniformBuffer.addUniform("lightmapMatrix",16),this._uniformBuffer.addUniform("reflectivityMatrix",16),this._uniformBuffer.addUniform("microSurfaceSamplerMatrix",16),this._uniformBuffer.addUniform("bumpMatrix",16),this._uniformBuffer.addUniform("vTangentSpaceParams",2),this._uniformBuffer.addUniform("refractionMatrix",16),this._uniformBuffer.addUniform("reflectionMatrix",16),this._uniformBuffer.addUniform("vReflectionColor",3),this._uniformBuffer.addUniform("vAlbedoColor",4),this._uniformBuffer.addUniform("vLightingIntensity",4),this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos",3),this._uniformBuffer.addUniform("vReflectivityColor",4),this._uniformBuffer.addUniform("vEmissiveColor",3),this._uniformBuffer.addUniform("pointSize",1),this._uniformBuffer.create()},p.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),r.prototype.unbind.call(this)},p.prototype.bindForSubMesh=function(e,t,i){var r=this.getScene(),n=i._materialDefines;if(n){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),n.OBJECTSPACE_NORMALMAP&&(e.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var s=this._mustRebind(r,o,t.visibility);ye.MaterialHelper.BindBonesParameters(t,this._activeEffect);var a=null;if(s){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o),a=this._getReflectionTexture();var l=this._getRefractionTexture();if(!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.texturesEnabled){if(this._albedoTexture&&ye.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),ye.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&ye.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat4("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength,this._ambientTextureImpactOnAnalyticalLights),ye.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&ye.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),ye.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),a&&ye.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,0),a.boundingBoxSize){var c=a;this._uniformBuffer.updateVector3("vReflectionPosition",c.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",c.boundingBoxSize)}var h=a.sphericalPolynomial;n.USESPHERICALFROMREFLECTIONMAP&&h&&(this._activeEffect.setFloat3("vSphericalX",h.x.x,h.x.y,h.x.z),this._activeEffect.setFloat3("vSphericalY",h.y.x,h.y.y,h.y.z),this._activeEffect.setFloat3("vSphericalZ",h.z.x,h.z.y,h.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",h.xx.x-h.zz.x,h.xx.y-h.zz.y,h.xx.z-h.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",h.yy.x-h.zz.x,h.yy.y-h.zz.y,h.yy.z-h.zz.z),this._activeEffect.setFloat3("vSphericalZZ",h.zz.x,h.zz.y,h.zz.z),this._activeEffect.setFloat3("vSphericalXY",h.xy.x,h.xy.y,h.xy.z),this._activeEffect.setFloat3("vSphericalYZ",h.yz.x,h.yz.y,h.yz.z),this._activeEffect.setFloat3("vSphericalZX",h.zx.x,h.zx.y,h.zx.z)),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset)}if(this._emissiveTexture&&ye.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),ye.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&ye.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),ye.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),ye.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),ye.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),ye.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),ye.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&ye.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),ye.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),r._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),l&&ye.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",l.getReflectionTextureMatrix());var u=1;l.isCube||l.depth&&(u=l.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",l.level,this._indexOfRefraction,u,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),n.METALLICWORKFLOW?(ye.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,ye.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",ye.PBRMaterial._scaledReflectivity,0)):this._uniformBuffer.updateColor4("vReflectivityColor",this._reflectivityColor,this._microSurface),this._uniformBuffer.updateColor3("vEmissiveColor",this._emissiveColor),this._uniformBuffer.updateColor3("vReflectionColor",this._reflectionColor),this._uniformBuffer.updateColor4("vAlbedoColor",this._albedoColor,this.alpha*t.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}r.texturesEnabled&&(this._albedoTexture&&ye.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&ye.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&ye.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),a&&ye.StandardMaterial.ReflectionTextureEnabled&&(n.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",a):(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a))),n.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),l&&ye.StandardMaterial.RefractionTextureEnabled&&(n.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",l):(this._uniformBuffer.setTexture("refractionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("refractionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("refractionSamplerHigh",l._lodTextureHigh||l))),this._emissiveTexture&&ye.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&ye.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),ye.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?this._uniformBuffer.setTexture("reflectivitySampler",this._metallicTexture):this._reflectivityTexture&&this._uniformBuffer.setTexture("reflectivitySampler",this._reflectivityTexture),this._microSurfaceTexture&&this._uniformBuffer.setTexture("microSurfaceSampler",this._microSurfaceTexture)),this._bumpTexture&&r.getEngine().getCaps().standardDerivatives&&ye.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),ye.MaterialHelper.BindClipPlane(this._activeEffect,r),r.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var d=r._forcedViewPosition?r._forcedViewPosition:r._mirroredCameraPosition?r._mirroredCameraPosition:r.activeCamera.globalPosition,f=r.useRightHandedSystem===(null!=r._mirroredCameraPosition);o.setFloat4("vEyePosition",d.x,d.y,d.z,f?-1:1),o.setColor3("vAmbientColor",this._globalAmbientColor)}!s&&this.isFrozen||(r.lightsEnabled&&!this._disableLighting&&ye.MaterialHelper.BindLights(r,t,this._activeEffect,n,this._maxSimultaneousLights,this._lightFalloff!==p.LIGHTFALLOFF_STANDARD),(r.fogEnabled&&t.applyFog&&r.fogMode!==ye.Scene.FOGMODE_NONE||a)&&this.bindView(o),ye.MaterialHelper.BindFogParameters(r,t,this._activeEffect,!0),n.NUM_MORPH_INFLUENCERS&&ye.MaterialHelper.BindMorphTargetParameters(t,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),ye.MaterialHelper.BindLogDepth(n,this._activeEffect,r)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},p.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&0<this._albedoTexture.animations.length&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&0<this._ambientTexture.animations.length&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&0<this._opacityTexture.animations.length&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&0<this._reflectionTexture.animations.length&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&0<this._emissiveTexture.animations.length&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&0<this._metallicTexture.animations.length?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&0<this._reflectivityTexture.animations.length&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&0<this._bumpTexture.animations.length&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&0<this._lightmapTexture.animations.length&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&0<this._refractionTexture.animations.length&&e.push(this._refractionTexture),e},p.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},p.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},p.prototype.dispose=function(e,t){t&&(this._albedoTexture&&this._albedoTexture.dispose(),this._ambientTexture&&this._ambientTexture.dispose(),this._opacityTexture&&this._opacityTexture.dispose(),this._reflectionTexture&&this._reflectionTexture.dispose(),this._environmentBRDFTexture&&this.getScene()._environmentBRDFTexture!==this._environmentBRDFTexture&&this._environmentBRDFTexture.dispose(),this._emissiveTexture&&this._emissiveTexture.dispose(),this._metallicTexture&&this._metallicTexture.dispose(),this._reflectivityTexture&&this._reflectivityTexture.dispose(),this._bumpTexture&&this._bumpTexture.dispose(),this._lightmapTexture&&this._lightmapTexture.dispose(),this._refractionTexture&&this._refractionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e,t)},p.LIGHTFALLOFF_PHYSICAL=0,p.LIGHTFALLOFF_GLTF=1,p.LIGHTFALLOFF_STANDARD=2,p._scaledReflectivity=new ye.Color3,b([ye.serializeAsImageProcessingConfiguration()],p.prototype,"_imageProcessingConfiguration",void 0),b([ye.serialize()],p.prototype,"useLogarithmicDepth",null),b([ye.serialize()],p.prototype,"transparencyMode",null),p})(ye.PushMaterial),ye.PBRBaseMaterial=Te,xe=$a||($a={}),Ee=(function(r){function e(e,t){var i=r.call(this,e,t)||this;return i.maxSimultaneousLights=4,i.disableLighting=!1,i.invertNormalMapX=!1,i.invertNormalMapY=!1,i.emissiveColor=new xe.Color3(0,0,0),i.occlusionStrength=1,i.useLightmapAsShadowmap=!1,i._useAlphaFromAlbedoTexture=!0,i._useAmbientInGrayScale=!0,i}return T(e,r),Object.defineProperty(e.prototype,"doubleSided",{get:function(){return this._twoSidedLighting},set:function(e){this._twoSidedLighting!==e&&(this._twoSidedLighting=e,this.backFaceCulling=!e,this._markAllSubMeshesAsTexturesDirty())},enumerable:!0,configurable:!0}),e.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this.environmentTexture&&e.push(this.environmentTexture),this.normalTexture&&e.push(this.normalTexture),this.emissiveTexture&&e.push(this.emissiveTexture),this.occlusionTexture&&e.push(this.occlusionTexture),this.lightmapTexture&&e.push(this.lightmapTexture),e},e.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||this.lightmapTexture===e},e.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},b([xe.serialize(),xe.expandToProperty("_markAllSubMeshesAsLightsDirty")],e.prototype,"maxSimultaneousLights",void 0),b([xe.serialize(),xe.expandToProperty("_markAllSubMeshesAsLightsDirty")],e.prototype,"disableLighting",void 0),b([xe.serializeAsTexture(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],e.prototype,"environmentTexture",void 0),b([xe.serialize(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty")],e.prototype,"invertNormalMapX",void 0),b([xe.serialize(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty")],e.prototype,"invertNormalMapY",void 0),b([xe.serializeAsTexture(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],e.prototype,"normalTexture",void 0),b([xe.serializeAsColor3("emissive"),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty")],e.prototype,"emissiveColor",void 0),b([xe.serializeAsTexture(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty")],e.prototype,"emissiveTexture",void 0),b([xe.serialize(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],e.prototype,"occlusionStrength",void 0),b([xe.serializeAsTexture(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],e.prototype,"occlusionTexture",void 0),b([xe.serialize(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],e.prototype,"alphaCutOff",void 0),b([xe.serialize()],e.prototype,"doubleSided",null),b([xe.serializeAsTexture(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],e.prototype,"lightmapTexture",void 0),b([xe.serialize(),xe.expandToProperty("_markAllSubMeshesAsTexturesDirty")],e.prototype,"useLightmapAsShadowmap",void 0),e})(xe.PBRBaseMaterial),xe.PBRBaseSimpleMaterial=Ee,Ae=$a||($a={}),Pe=(function(r){function n(e,t){var i=r.call(this,e,t)||this;return i.directIntensity=1,i.emissiveIntensity=1,i.environmentIntensity=1,i.specularIntensity=1,i.disableBumpMap=!1,i.ambientTextureStrength=1,i.ambientTextureImpactOnAnalyticalLights=n.DEFAULT_AO_ON_ANALYTICAL_LIGHTS,i.ambientColor=new Ae.Color3(0,0,0),i.albedoColor=new Ae.Color3(1,1,1),i.reflectivityColor=new Ae.Color3(1,1,1),i.reflectionColor=new Ae.Color3(1,1,1),i.emissiveColor=new Ae.Color3(0,0,0),i.microSurface=1,i.indexOfRefraction=.66,i.invertRefractionY=!1,i.linkRefractionWithTransparency=!1,i.useLightmapAsShadowmap=!1,i.useAlphaFromAlbedoTexture=!1,i.forceAlphaTest=!1,i.alphaCutOff=.4,i.useSpecularOverAlpha=!0,i.useMicroSurfaceFromReflectivityMapAlpha=!1,i.useRoughnessFromMetallicTextureAlpha=!0,i.useRoughnessFromMetallicTextureGreen=!1,i.useMetallnessFromMetallicTextureBlue=!1,i.useAmbientOcclusionFromMetallicTextureRed=!1,i.useAmbientInGrayScale=!1,i.useAutoMicroSurfaceFromReflectivityMap=!1,i.useRadianceOverAlpha=!0,i.useObjectSpaceNormalMap=!1,i.useParallax=!1,i.useParallaxOcclusion=!1,i.parallaxScaleBias=.05,i.disableLighting=!1,i.forceIrradianceInFragment=!1,i.maxSimultaneousLights=4,i.invertNormalMapX=!1,i.invertNormalMapY=!1,i.twoSidedLighting=!1,i.useAlphaFresnel=!1,i.useLinearAlphaFresnel=!1,i.environmentBRDFTexture=null,i.forceNormalForward=!1,i.enableSpecularAntiAliasing=!1,i.useHorizonOcclusion=!0,i.useRadianceOcclusion=!0,i.unlit=!1,i._environmentBRDFTexture=Ae.TextureTools.GetEnvironmentBRDFTexture(t),i}return T(n,r),Object.defineProperty(n.prototype,"usePhysicalLightFalloff",{get:function(){return this._lightFalloff===Ae.PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL},set:function(e){e!==this.usePhysicalLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?Ae.PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL:Ae.PBRBaseMaterial.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"useGLTFLightFalloff",{get:function(){return this._lightFalloff===Ae.PBRBaseMaterial.LIGHTFALLOFF_GLTF},set:function(e){e!==this.useGLTFLightFalloff&&(this._markAllSubMeshesAsTexturesDirty(),this._lightFalloff=e?Ae.PBRBaseMaterial.LIGHTFALLOFF_GLTF:Ae.PBRBaseMaterial.LIGHTFALLOFF_STANDARD)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),n.prototype.getClassName=function(){return"PBRMaterial"},n.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this._albedoTexture&&e.push(this._albedoTexture),this._ambientTexture&&e.push(this._ambientTexture),this._opacityTexture&&e.push(this._opacityTexture),this._reflectionTexture&&e.push(this._reflectionTexture),this._emissiveTexture&&e.push(this._emissiveTexture),this._reflectivityTexture&&e.push(this._reflectivityTexture),this._metallicTexture&&e.push(this._metallicTexture),this._microSurfaceTexture&&e.push(this._microSurfaceTexture),this._bumpTexture&&e.push(this._bumpTexture),this._lightmapTexture&&e.push(this._lightmapTexture),this._refractionTexture&&e.push(this._refractionTexture),e},n.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||(this._albedoTexture===e||(this._ambientTexture===e||(this._opacityTexture===e||(this._reflectionTexture===e||(this._reflectivityTexture===e||(this._metallicTexture===e||(this._microSurfaceTexture===e||(this._bumpTexture===e||(this._lightmapTexture===e||this._refractionTexture===e)))))))))},n.prototype.clone=function(e){var t=this,i=Ae.SerializationHelper.Clone((function(){return new n(e,t.getScene())}),this);return i.id=e,i.name=e,i},n.prototype.serialize=function(){var e=Ae.SerializationHelper.Serialize(this);return e.customType="BABYLON.PBRMaterial",e},n.Parse=function(e,t,i){return Ae.SerializationHelper.Parse((function(){return new n(e.name,t)}),e,t,i)},n.PBRMATERIAL_OPAQUE=0,n.PBRMATERIAL_ALPHATEST=1,n.PBRMATERIAL_ALPHABLEND=2,n.PBRMATERIAL_ALPHATESTANDBLEND=3,n.DEFAULT_AO_ON_ANALYTICAL_LIGHTS=1,b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"directIntensity",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"emissiveIntensity",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"environmentIntensity",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"specularIntensity",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"disableBumpMap",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"albedoTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"ambientTexture",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"ambientTextureStrength",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"ambientTextureImpactOnAnalyticalLights",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],n.prototype,"opacityTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"emissiveTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectivityTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"metallicTexture",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"metallic",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"roughness",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"microSurfaceTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"bumpTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],n.prototype,"lightmapTexture",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"refractionTexture",void 0),b([Ae.serializeAsColor3("ambient"),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"ambientColor",void 0),b([Ae.serializeAsColor3("albedo"),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"albedoColor",void 0),b([Ae.serializeAsColor3("reflectivity"),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectivityColor",void 0),b([Ae.serializeAsColor3("reflection"),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionColor",void 0),b([Ae.serializeAsColor3("emissive"),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"emissiveColor",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"microSurface",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"indexOfRefraction",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"invertRefractionY",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"linkRefractionWithTransparency",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useLightmapAsShadowmap",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],n.prototype,"useAlphaFromAlbedoTexture",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],n.prototype,"forceAlphaTest",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],n.prototype,"alphaCutOff",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useSpecularOverAlpha",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useRoughnessFromMetallicTextureGreen",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useMetallnessFromMetallicTextureBlue",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useAmbientInGrayScale",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),b([Ae.serialize()],n.prototype,"usePhysicalLightFalloff",null),b([Ae.serialize()],n.prototype,"useGLTFLightFalloff",null),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useRadianceOverAlpha",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useObjectSpaceNormalMap",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useParallax",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useParallaxOcclusion",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"parallaxScaleBias",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"disableLighting",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"forceIrradianceInFragment",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"maxSimultaneousLights",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"invertNormalMapX",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"invertNormalMapY",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"twoSidedLighting",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useAlphaFresnel",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useLinearAlphaFresnel",void 0),b([Ae.serializeAsTexture(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"environmentBRDFTexture",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"forceNormalForward",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"enableSpecularAntiAliasing",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useHorizonOcclusion",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useRadianceOcclusion",void 0),b([Ae.serialize(),Ae.expandToProperty("_markAllSubMeshesAsMiscDirty")],n.prototype,"unlit",void 0),n})(Ae.PBRBaseMaterial),Ae.PBRMaterial=Pe,Se=$a||($a={}),Re=(function(r){function n(e,t){var i=r.call(this,e,t)||this;return i._useRoughnessFromMetallicTextureAlpha=!1,i._useRoughnessFromMetallicTextureGreen=!0,i._useMetallnessFromMetallicTextureBlue=!0,i.metallic=1,i.roughness=1,i}return T(n,r),n.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},n.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},n.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},n.prototype.clone=function(e){var t=this,i=Se.SerializationHelper.Clone((function(){return new n(e,t.getScene())}),this);return i.id=e,i.name=e,i},n.prototype.serialize=function(){var e=Se.SerializationHelper.Serialize(this);return e.customType="BABYLON.PBRMetallicRoughnessMaterial",e},n.Parse=function(e,t,i){return Se.SerializationHelper.Parse((function(){return new n(e.name,t)}),e,t,i)},b([Se.serializeAsColor3(),Se.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],n.prototype,"baseColor",void 0),b([Se.serializeAsTexture(),Se.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],n.prototype,"baseTexture",void 0),b([Se.serialize(),Se.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"metallic",void 0),b([Se.serialize(),Se.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"roughness",void 0),b([Se.serializeAsTexture(),Se.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],n.prototype,"metallicRoughnessTexture",void 0),n})(Se.PBRBaseSimpleMaterial),Se.PBRMetallicRoughnessMaterial=Re,Me=$a||($a={}),Ce=(function(r){function n(e,t){var i=r.call(this,e,t)||this;return i._useMicroSurfaceFromReflectivityMapAlpha=!0,i}return T(n,r),n.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},n.prototype.getActiveTextures=function(){var e=r.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},n.prototype.hasTexture=function(e){return!!r.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},n.prototype.clone=function(e){var t=this,i=Me.SerializationHelper.Clone((function(){return new n(e,t.getScene())}),this);return i.id=e,i.name=e,i},n.prototype.serialize=function(){var e=Me.SerializationHelper.Serialize(this);return e.customType="BABYLON.PBRSpecularGlossinessMaterial",e},n.Parse=function(e,t,i){return Me.SerializationHelper.Parse((function(){return new n(e.name,t)}),e,t,i)},b([Me.serializeAsColor3("diffuse"),Me.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],n.prototype,"diffuseColor",void 0),b([Me.serializeAsTexture(),Me.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],n.prototype,"diffuseTexture",void 0),b([Me.serializeAsColor3("specular"),Me.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],n.prototype,"specularColor",void 0),b([Me.serialize(),Me.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],n.prototype,"glossiness",void 0),b([Me.serializeAsTexture(),Me.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],n.prototype,"specularGlossinessTexture",void 0),n})(Me.PBRBaseSimpleMaterial),Me.PBRSpecularGlossinessMaterial=Ce,(function(s){s.CameraInputTypes={};var e=(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]?s.Tools.Warn("camera input of type "+t+" already exists on camera"):((this.attached[t]=e).camera=this.camera,e.checkInputs&&(this.checkInputs=this._addCheckInputs(e.checkInputs.bind(e))),this.attachedElement&&e.attachControl(this.attachedElement))},e.prototype.remove=function(e){for(var t in this.attached){var i=this.attached[t];i===e&&(i.detachControl(this.attachedElement),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype.removeByType=function(e){for(var t in this.attached){var i=this.attached[t];i.getClassName()===e&&(i.detachControl(this.attachedElement),i.camera=null,delete this.attached[t],this.rebuildInputCheck())}},e.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},e.prototype.attachInput=function(e){this.attachedElement&&e.attachControl(this.attachedElement,this.noPreventDefault)},e.prototype.attachElement=function(e,t){if(void 0===t&&(t=!1),!this.attachedElement)for(var i in t=!s.Camera.ForceAttachControlToAlwaysPreventDefault&&t,this.attachedElement=e,this.noPreventDefault=t,this.attached)this.attached[i].attachControl(e,t)},e.prototype.detachElement=function(e,t){if(void 0===t&&(t=!1),this.attachedElement===e){for(var i in this.attached)this.attached[i].detachControl(e),t&&(this.attached[i].camera=null);this.attachedElement=null}},e.prototype.rebuildInputCheck=function(){for(var e in this.checkInputs=function(){},this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},e.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement,!0),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},e.prototype.serialize=function(e){var t={};for(var i in this.attached){var r=this.attached[i],n=s.SerializationHelper.Serialize(r);t[r.getClassName()]=n}e.inputsmgr=t},e.prototype.parse=function(e){var t=e.inputsmgr;if(t)for(var i in this.clear(),t){if(o=s.CameraInputTypes[i]){var r=t[i],n=s.SerializationHelper.Parse((function(){return new o}),r,null);this.add(n)}}else for(var i in this.attached){var o;if(o=s.CameraInputTypes[this.attached[i].getClassName()]){n=s.SerializationHelper.Parse((function(){return new o}),e,null);this.remove(this.attached[i]),this.add(n)}}},e})();s.CameraInputsManager=e})($a||($a={})),Oe=$a||($a={}),De=(function(o){function r(e,t,i,r){void 0===r&&(r=!0);var n=o.call(this,e,t,i,r)||this;return n.cameraDirection=new Oe.Vector3(0,0,0),n.cameraRotation=new Oe.Vector2(0,0),n.rotation=new Oe.Vector3(0,0,0),n.speed=2,n.noRotationConstraint=!1,n.lockedTarget=null,n._currentTarget=Oe.Vector3.Zero(),n._viewMatrix=Oe.Matrix.Zero(),n._camMatrix=Oe.Matrix.Zero(),n._cameraTransformMatrix=Oe.Matrix.Zero(),n._cameraRotationMatrix=Oe.Matrix.Zero(),n._referencePoint=new Oe.Vector3(0,0,1),n._transformedReferencePoint=Oe.Vector3.Zero(),n._globalCurrentTarget=Oe.Vector3.Zero(),n._globalCurrentUpVector=Oe.Vector3.Zero(),n._defaultUp=Oe.Vector3.Up(),n._cachedRotationZ=0,n._cachedQuaternionRotationZ=0,n}return T(r,o),r.prototype.getFrontPosition=function(e){this.getWorldMatrix();var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},r.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},r.prototype.storeState=function(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),o.prototype.storeState.call(this)},r.prototype._restoreStateValues=function(){return!!o.prototype._restoreStateValues.call(this)&&(this.position=this._storedPosition.clone(),this.rotation=this._storedRotation.clone(),this.rotationQuaternion&&(this.rotationQuaternion=this._storedRotationQuaternion.clone()),this.cameraDirection.copyFromFloats(0,0,0),this.cameraRotation.copyFromFloats(0,0),!0)},r.prototype._initCache=function(){o.prototype._initCache.call(this),this._cache.lockedTarget=new Oe.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new Oe.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new Oe.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},r.prototype._updateCache=function(e){e||o.prototype._updateCache.call(this);var t=this._getLockedTargetPosition();t?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(t):this._cache.lockedTarget=t.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},r.prototype._isSynchronizedViewMatrix=function(){if(!o.prototype._isSynchronizedViewMatrix.call(this))return!1;var e=this._getLockedTargetPosition();return(this._cache.lockedTarget?this._cache.lockedTarget.equals(e):!e)&&(this.rotationQuaternion?this.rotationQuaternion.equals(this._cache.rotationQuaternion):this._cache.rotation.equals(this.rotation))},r.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},r.prototype.setTarget=function(e){this.upVector.normalize(),this.position.z===e.z&&(this.position.z+=Oe.Epsilon),Oe.Matrix.LookAtLHToRef(this.position,e,this._defaultUp,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var t=e.subtract(this.position);0<=t.x?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&&Oe.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},r.prototype.getTarget=function(){return this._currentTarget},r.prototype._decideIfNeedsToMove=function(){return 0<Math.abs(this.cameraDirection.x)||0<Math.abs(this.cameraDirection.y)||0<Math.abs(this.cameraDirection.z)},r.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(Oe.Tmp.Matrix[0]),Oe.Vector3.TransformNormalToRef(this.cameraDirection,Oe.Tmp.Matrix[0],Oe.Tmp.Vector3[0]),void this.position.addInPlace(Oe.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},r.prototype._checkInputs=function(){var e=this._decideIfNeedsToMove(),t=0<Math.abs(this.cameraRotation.x)||0<Math.abs(this.cameraRotation.y);if(e&&this._updatePosition(),t){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion)this.rotation.lengthSquared()&&Oe.Quaternion.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)}}e&&(Math.abs(this.cameraDirection.x)<this.speed*Oe.Epsilon&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*Oe.Epsilon&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*Oe.Epsilon&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),t&&(Math.abs(this.cameraRotation.x)<this.speed*Oe.Epsilon&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*Oe.Epsilon&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),o.prototype._checkInputs.call(this)},r.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):Oe.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix)},r.prototype._rotateUpVectorWithCameraRotationMatrix=function(){return Oe.Vector3.TransformNormalToRef(this._defaultUp,this._cameraRotationMatrix,this.upVector),this},r.prototype._getViewMatrix=function(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),this.rotationQuaternion&&this._cachedQuaternionRotationZ!=this.rotationQuaternion.z?(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedQuaternionRotationZ=this.rotationQuaternion.z):this._cachedRotationZ!=this.rotation.z&&(this._rotateUpVectorWithCameraRotationMatrix(),this._cachedRotationZ=this.rotation.z),Oe.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this._computeViewMatrix(this.position,this._currentTarget,this.upVector),this._viewMatrix},r.prototype._computeViewMatrix=function(e,t,i){if(this.parent){var r=this.parent.getWorldMatrix();Oe.Vector3.TransformCoordinatesToRef(e,r,this._globalPosition),Oe.Vector3.TransformCoordinatesToRef(t,r,this._globalCurrentTarget),Oe.Vector3.TransformNormalToRef(i,r,this._globalCurrentUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(e),this._globalCurrentTarget.copyFrom(t),this._globalCurrentUpVector.copyFrom(i);this.getScene().useRightHandedSystem?Oe.Matrix.LookAtRHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix):Oe.Matrix.LookAtLHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix)},r.prototype.createRigCamera=function(e,t){if(this.cameraRigMode!==Oe.Camera.RIG_MODE_NONE){var i=new r(e,this.position.clone(),this.getScene());return this.cameraRigMode!==Oe.Camera.RIG_MODE_VR&&this.cameraRigMode!==Oe.Camera.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new Oe.Quaternion),i._cameraRigParams={},i.rotationQuaternion=new Oe.Quaternion),i}return null},r.prototype._updateRigCameras=function(){var e=this._rigCameras[0],t=this._rigCameras[1];switch(this.cameraRigMode){case Oe.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case Oe.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case Oe.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case Oe.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:var i=this.cameraRigMode===Oe.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,r=this.cameraRigMode===Oe.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*i,e.position),this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*r,t.position),e.setTarget(this.getTarget()),t.setTarget(this.getTarget());break;case Oe.Camera.RIG_MODE_VR:e.rotationQuaternion?(e.rotationQuaternion.copyFrom(this.rotationQuaternion),t.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.rotation.copyFrom(this.rotation),t.rotation.copyFrom(this.rotation)),e.position.copyFrom(this.position),t.position.copyFrom(this.position)}o.prototype._updateRigCameras.call(this)},r.prototype._getRigCamPosition=function(e,t){this._rigCamTransformMatrix||(this._rigCamTransformMatrix=new Oe.Matrix);var i=this.getTarget();Oe.Matrix.Translation(-i.x,-i.y,-i.z).multiplyToRef(Oe.Matrix.RotationY(e),this._rigCamTransformMatrix),this._rigCamTransformMatrix=this._rigCamTransformMatrix.multiply(Oe.Matrix.Translation(i.x,i.y,i.z)),Oe.Vector3.TransformCoordinatesToRef(this.position,this._rigCamTransformMatrix,t)},r.prototype.getClassName=function(){return"TargetCamera"},b([Oe.serializeAsVector3()],r.prototype,"rotation",void 0),b([Oe.serialize()],r.prototype,"speed",void 0),b([Oe.serializeAsMeshReference("lockedTargetId")],r.prototype,"lockedTarget",void 0),r})(Oe.Camera),Oe.TargetCamera=De,Ie=$a||($a={}),we=(function(){function e(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this.previousPosition=null}return e.prototype.attachControl=function(s,a){var l=this,c=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(e,t){var i=e.event;if(!c.isInVRExclusivePointerMode&&(l.touchEnabled||"touch"!==i.pointerType)&&(e.type===Ie.PointerEventTypes.POINTERMOVE||-1!==l.buttons.indexOf(i.button))){var r=i.srcElement||i.target;if(e.type===Ie.PointerEventTypes.POINTERDOWN&&r){try{r.setPointerCapture(i.pointerId)}catch(e){}l.previousPosition={x:i.clientX,y:i.clientY},a||(i.preventDefault(),s.focus())}else if(e.type===Ie.PointerEventTypes.POINTERUP&&r){try{r.releasePointerCapture(i.pointerId)}catch(e){}l.previousPosition=null,a||i.preventDefault()}else if(e.type===Ie.PointerEventTypes.POINTERMOVE){if(!l.previousPosition||c.isPointerLock)return;var n=i.clientX-l.previousPosition.x;l.camera.getScene().useRightHandedSystem&&(n*=-1),l.camera.parent&&l.camera.parent._getWorldMatrixDeterminant()<0&&(n*=-1),l.camera.cameraRotation.y+=n/l.angularSensibility;var o=i.clientY-l.previousPosition.y;l.camera.cameraRotation.x+=o/l.angularSensibility,l.previousPosition={x:i.clientX,y:i.clientY},a||i.preventDefault()}}}),this._onMouseMove=function(e){if(c.isPointerLock&&!c.isInVRExclusivePointerMode){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0;l.camera.getScene().useRightHandedSystem&&(t*=-1),l.camera.parent&&l.camera.parent._getWorldMatrixDeterminant()<0&&(t*=-1),l.camera.cameraRotation.y+=t/l.angularSensibility;var i=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;l.camera.cameraRotation.x+=i/l.angularSensibility,l.previousPosition=null,a||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,Ie.PointerEventTypes.POINTERDOWN|Ie.PointerEventTypes.POINTERUP|Ie.PointerEventTypes.POINTERMOVE),s.addEventListener("mousemove",this._onMouseMove,!1)},e.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._onMouseMove&&e.removeEventListener("mousemove",this._onMouseMove),this._observer=null,this._onMouseMove=null,this.previousPosition=null)},e.prototype.getClassName=function(){return"FreeCameraMouseInput"},e.prototype.getSimpleName=function(){return"mouse"},b([Ie.serialize()],e.prototype,"buttons",void 0),b([Ie.serialize()],e.prototype,"angularSensibility",void 0),e})(),Ie.FreeCameraMouseInput=we,Ie.CameraInputTypes.FreeCameraMouseInput=we,Le=$a||($a={}),Fe=(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,r){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 t,i=e.event;e.type===Le.KeyboardEventTypes.KEYDOWN?-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||(-1===(t=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),r||i.preventDefault()):-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)||(0<=(t=n._keys.indexOf(i.keyCode))&&n._keys.splice(t,1),r||i.preventDefault())})))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t],r=e._computeLocalCameraSpeed();-1!==this.keysLeft.indexOf(i)?e._localDirection.copyFromFloats(-r,0,0):-1!==this.keysUp.indexOf(i)?e._localDirection.copyFromFloats(0,0,r):-1!==this.keysRight.indexOf(i)?e._localDirection.copyFromFloats(r,0,0):-1!==this.keysDown.indexOf(i)&&e._localDirection.copyFromFloats(0,0,-r),e.getScene().useRightHandedSystem&&(e._localDirection.z*=-1),e.getViewMatrix().invertToRef(e._cameraTransformMatrix),Le.Vector3.TransformNormalToRef(e._localDirection,e._cameraTransformMatrix,e._transformedDirection),e.cameraDirection.addInPlace(e._transformedDirection)}},e.prototype.getClassName=function(){return"FreeCameraKeyboardMoveInput"},e.prototype._onLostFocus=function(e){this._keys=[]},e.prototype.getSimpleName=function(){return"keyboard"},b([Le.serialize()],e.prototype,"keysUp",void 0),b([Le.serialize()],e.prototype,"keysDown",void 0),b([Le.serialize()],e.prototype,"keysLeft",void 0),b([Le.serialize()],e.prototype,"keysRight",void 0),e})(),Le.FreeCameraKeyboardMoveInput=Fe,Le.CameraInputTypes.FreeCameraKeyboardMoveInput=Fe,Be=$a||($a={}),Ne=(function(t){function e(e){return t.call(this,e)||this}return T(e,t),e.prototype.addKeyboard=function(){return this.add(new Be.FreeCameraKeyboardMoveInput),this},e.prototype.addMouse=function(e){return void 0===e&&(e=!0),this.add(new Be.FreeCameraMouseInput(e)),this},e.prototype.addDeviceOrientation=function(){return this.add(new Be.FreeCameraDeviceOrientationInput),this},e.prototype.addTouch=function(){return this.add(new Be.FreeCameraTouchInput),this},e.prototype.addVirtualJoystick=function(){return this.add(new Be.FreeCameraVirtualJoystickInput),this},e})(Be.CameraInputsManager),Be.FreeCameraInputsManager=Ne,(function(s){s.Node.AddNodeConstructor("FreeCamera",(function(e,t){return function(){return new s.UniversalCamera(e,s.Vector3.Zero(),t)}}));var e=(function(o){function e(e,t,i,r){void 0===r&&(r=!0);var n=o.call(this,e,t,i,r)||this;return n.ellipsoid=new s.Vector3(.5,1,.5),n.ellipsoidOffset=new s.Vector3(0,0,0),n.checkCollisions=!1,n.applyGravity=!1,n._needMoveForGravity=!1,n._oldPosition=s.Vector3.Zero(),n._diffPosition=s.Vector3.Zero(),n._newPosition=s.Vector3.Zero(),n._collisionMask=-1,n._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),n.getScene().workerCollisions&&t.multiplyInPlace(n._collider._radius);var r;r=t,n._newPosition.copyFrom(r),n._newPosition.subtractToRef(n._oldPosition,n._diffPosition),n._diffPosition.length()>s.Engine.CollisionsEpsilon&&(n.position.addInPlace(n._diffPosition),n.onCollide&&i&&n.onCollide(i))},n.inputs=new s.FreeCameraInputsManager(n),n.inputs.addKeyboard().addMouse(),n}return T(e,o),Object.defineProperty(e.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(e.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(e.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(e.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(e.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}),e.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},e.prototype.detachControl=function(e){this.inputs.detachElement(e),this.cameraDirection=new s.Vector3(0,0,0),this.cameraRotation=new s.Vector2(0,0)},Object.defineProperty(e.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),e.prototype._collideWithWorld=function(e){(this.parent?s.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position).subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset),this._collider||(this._collider=new s.Collider),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var t=e;this.applyGravity&&(t=e.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,t,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},e.prototype._checkInputs=function(){this._localDirection||(this._localDirection=s.Vector3.Zero(),this._transformedDirection=s.Vector3.Zero()),this.inputs.checkInputs(),o.prototype._checkInputs.call(this)},e.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||0<Math.abs(this.cameraDirection.x)||0<Math.abs(this.cameraDirection.y)||0<Math.abs(this.cameraDirection.z)},e.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):o.prototype._updatePosition.call(this)},e.prototype.dispose=function(){this.inputs.clear(),o.prototype.dispose.call(this)},e.prototype.getClassName=function(){return"FreeCamera"},b([s.serializeAsVector3()],e.prototype,"ellipsoid",void 0),b([s.serializeAsVector3()],e.prototype,"ellipsoidOffset",void 0),b([s.serialize()],e.prototype,"checkCollisions",void 0),b([s.serialize()],e.prototype,"applyGravity",void 0),e})(s.TargetCamera);s.FreeCamera=e})($a||($a={})),Ve=$a||($a={}),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,r){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 t,i=e.event;e.type===Ve.KeyboardEventTypes.KEYDOWN?(n._ctrlPressed=i.ctrlKey,n._altPressed=i.altKey,(-1!==n.keysUp.indexOf(i.keyCode)||-1!==n.keysDown.indexOf(i.keyCode)||-1!==n.keysLeft.indexOf(i.keyCode)||-1!==n.keysRight.indexOf(i.keyCode)||-1!==n.keysReset.indexOf(i.keyCode))&&(-1===(t=n._keys.indexOf(i.keyCode))&&n._keys.push(i.keyCode),i.preventDefault&&(r||i.preventDefault()))):-1===n.keysUp.indexOf(i.keyCode)&&-1===n.keysDown.indexOf(i.keyCode)&&-1===n.keysLeft.indexOf(i.keyCode)&&-1===n.keysRight.indexOf(i.keyCode)&&-1===n.keysReset.indexOf(i.keyCode)||(0<=(t=n._keys.indexOf(i.keyCode))&&n._keys.splice(t,1),i.preventDefault&&(r||i.preventDefault()))})))},e.prototype.detachControl=function(e){this._scene&&(this._onKeyboardObserver&&this._scene.onKeyboardObservable.remove(this._onKeyboardObserver),this._onCanvasBlurObserver&&this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onKeyboardObserver=null,this._onCanvasBlurObserver=null),this._keys=[]},e.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var e=this.camera,t=0;t<this._keys.length;t++){var i=this._keys[t];-1!==this.keysLeft.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX-=1/this.panningSensibility:e.inertialAlphaOffset-=this.angularSpeed:-1!==this.keysUp.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY+=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset+=1/this.zoomingSensibility:e.inertialBetaOffset-=this.angularSpeed:-1!==this.keysRight.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=this.angularSpeed:-1!==this.keysDown.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningY-=1/this.panningSensibility:this._altPressed&&this.useAltToZoom?e.inertialRadiusOffset-=1/this.zoomingSensibility:e.inertialBetaOffset+=this.angularSpeed:-1!==this.keysReset.indexOf(i)&&e.useInputToRestoreState&&e.restoreState()}},e.prototype.getClassName=function(){return"ArcRotateCameraKeyboardMoveInput"},e.prototype.getSimpleName=function(){return"keyboard"},b([Ve.serialize()],e.prototype,"keysUp",void 0),b([Ve.serialize()],e.prototype,"keysDown",void 0),b([Ve.serialize()],e.prototype,"keysLeft",void 0),b([Ve.serialize()],e.prototype,"keysRight",void 0),b([Ve.serialize()],e.prototype,"keysReset",void 0),b([Ve.serialize()],e.prototype,"panningSensibility",void 0),b([Ve.serialize()],e.prototype,"zoomingSensibility",void 0),b([Ve.serialize()],e.prototype,"useAltToZoom",void 0),b([Ve.serialize()],e.prototype,"angularSpeed",void 0),e})(),Ve.ArcRotateCameraKeyboardMoveInput=Ue,Ve.CameraInputTypes.ArcRotateCameraKeyboardMoveInput=Ue,ze=$a||($a={}),Ge=(function(){function e(){this.wheelPrecision=3,this.wheelDeltaPercentage=0}return e.prototype.attachControl=function(e,o){var s=this;this._wheel=function(e,t){if(e.type===ze.PointerEventTypes.POINTERWHEEL){var i=e.event,r=0;if(i.wheelDelta)if(s.wheelDeltaPercentage){var n=.01*i.wheelDelta*s.wheelDeltaPercentage*s.camera.radius;r=0<i.wheelDelta?n/(1+s.wheelDeltaPercentage):n*(1+s.wheelDeltaPercentage)}else r=i.wheelDelta/(40*s.wheelPrecision);else i.detail&&(r=-i.detail/s.wheelPrecision);r&&(s.camera.inertialRadiusOffset+=r),i.preventDefault&&(o||i.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,ze.PointerEventTypes.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"},b([ze.serialize()],e.prototype,"wheelPrecision",void 0),b([ze.serialize()],e.prototype,"wheelDeltaPercentage",void 0),e})(),ze.ArcRotateCameraMouseWheelInput=Ge,ze.CameraInputTypes.ArcRotateCameraMouseWheelInput=Ge,ke=$a||($a={}),We=(function(){function e(){this.buttons=[0,1,2],this.angularSensibilityX=1e3,this.angularSensibilityY=1e3,this.pinchPrecision=12,this.pinchDeltaPercentage=0,this.panningSensibility=1e3,this.multiTouchPanning=!0,this.multiTouchPanAndZoom=!0,this.pinchInwards=!0,this._isPanClick=!1}return e.prototype.attachControl=function(g,v){var y,b=this,T=this.camera.getEngine(),x=null,E=null,A=0,P=0,S=0,R={x:0,y:0,isPaning:!1,isPinching:!1};this._pointerInput=function(e,t){var i=e.event,r="touch"===e.event.pointerType;if(!T.isInVRExclusivePointerMode&&(e.type===ke.PointerEventTypes.POINTERMOVE||-1!==b.buttons.indexOf(i.button))){var n=i.srcElement||i.target;if(e.type===ke.PointerEventTypes.POINTERDOWN&&n){try{n.setPointerCapture(i.pointerId)}catch(e){}b._isPanClick=i.button===b.camera._panningMouseButton,y={x:i.clientX,y:i.clientY,pointerId:i.pointerId,type:i.pointerType},null===x?x=y:null===E&&(E=y),v||(i.preventDefault(),g.focus())}else if(e.type===ke.PointerEventTypes.POINTERDOUBLETAP)b.camera.useInputToRestoreState&&b.camera.restoreState();else if(e.type===ke.PointerEventTypes.POINTERUP&&n){try{n.releasePointerCapture(i.pointerId)}catch(e){}y=null,A=0,R.isPaning=!1,R.isPinching=!1,P=S=0,r||(E=null),T._badOS?x=E=null:E&&x&&x.pointerId==i.pointerId?(x=E,E=null,y={x:x.x,y:x.y,pointerId:x.pointerId,type:i.pointerType}):x&&E&&E.pointerId==i.pointerId?(E=null,y={x:x.x,y:x.y,pointerId:x.pointerId,type:i.pointerType}):x=E=null,v||i.preventDefault()}else if(e.type===ke.PointerEventTypes.POINTERMOVE)if(v||i.preventDefault(),x&&null===E&&y){if(0!==b.panningSensibility&&(i.ctrlKey&&b.camera._useCtrlForPanning||b._isPanClick))b.camera.inertialPanningX+=-(i.clientX-y.x)/b.panningSensibility,b.camera.inertialPanningY+=(i.clientY-y.y)/b.panningSensibility;else{var o=i.clientX-y.x,s=i.clientY-y.y;b.camera.inertialAlphaOffset-=o/b.angularSensibilityX,b.camera.inertialBetaOffset-=s/b.angularSensibilityY}y.x=i.clientX,y.y=i.clientY}else if(x&&E){var a=x.pointerId===i.pointerId?x:E;a.x=i.clientX,a.y=i.clientY;var l=b.pinchInwards?1:-1,c=x.x-E.x,h=x.y-E.y,u=c*c+h*h,d=Math.sqrt(u);if(0===A)return P=d,A=u,R.x=(x.x+E.x)/2,void(R.y=(x.y+E.y)/2);if(b.multiTouchPanAndZoom){if(b.pinchDeltaPercentage?b.camera.inertialRadiusOffset+=.001*(u-A)*b.camera.radius*b.pinchDeltaPercentage:b.camera.inertialRadiusOffset+=(u-A)/(b.pinchPrecision*((b.angularSensibilityX+b.angularSensibilityY)/2)*l),0!==b.panningSensibility){var f=(x.x+E.x)/2,p=(x.y+E.y)/2,m=f-R.x,_=p-R.y;R.x=f,R.y=p,b.camera.inertialPanningX+=-m/b.panningSensibility,b.camera.inertialPanningY+=_/b.panningSensibility}}else{if(S++,R.isPinching||S<20&&Math.abs(d-P)>b.camera.pinchToPanMaxDistance)b.pinchDeltaPercentage?b.camera.inertialRadiusOffset+=.001*(u-A)*b.camera.radius*b.pinchDeltaPercentage:b.camera.inertialRadiusOffset+=(u-A)/(b.pinchPrecision*((b.angularSensibilityX+b.angularSensibilityY)/2)*l),R.isPaning=!1,R.isPinching=!0;else if(y&&y.pointerId===a.pointerId&&0!==b.panningSensibility&&b.multiTouchPanning){if(!R.isPaning)return R.isPaning=!0,R.isPinching=!1,R.x=a.x,void(R.y=a.y);b.camera.inertialPanningX+=-(a.x-R.x)/b.panningSensibility,b.camera.inertialPanningY+=(a.y-R.y)/b.panningSensibility}y&&y.pointerId===i.pointerId&&(R.x=a.x,R.y=a.y)}A=u}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,ke.PointerEventTypes.POINTERDOWN|ke.PointerEventTypes.POINTERUP|ke.PointerEventTypes.POINTERMOVE|ke.PointerEventTypes.POINTERDOUBLETAP),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||g.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){x=E=null,A=0,R.isPaning=!1,R.isPinching=!1,y=null,P=S=0},this._onMouseMove=function(e){if(T.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,i=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;b.camera.inertialAlphaOffset-=t/b.angularSensibilityX,b.camera.inertialBetaOffset-=i/b.angularSensibilityY,v||e.preventDefault()}},this._onGestureStart=function(e){void 0!==window.MSGesture&&(b._MSGestureHandler||(b._MSGestureHandler=new MSGesture,b._MSGestureHandler.target=g),b._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){b.camera.radius*=e.scale,e.preventDefault&&(v||(e.stopPropagation(),e.preventDefault()))},g.addEventListener("mousemove",this._onMouseMove,!1),g.addEventListener("MSPointerDown",this._onGestureStart,!1),g.addEventListener("MSGestureChange",this._onGesture,!1),ke.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},e.prototype.detachControl=function(e){this._onLostFocus&&ke.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),e&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._onContextMenu&&e.removeEventListener("contextmenu",this._onContextMenu),this._onMouseMove&&e.removeEventListener("mousemove",this._onMouseMove),this._onGestureStart&&e.removeEventListener("MSPointerDown",this._onGestureStart),this._onGesture&&e.removeEventListener("MSGestureChange",this._onGesture),this._isPanClick=!1,this.pinchInwards=!0,this._onMouseMove=null,this._onGestureStart=null,this._onGesture=null,this._MSGestureHandler=null,this._onLostFocus=null,this._onContextMenu=null)},e.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},e.prototype.getSimpleName=function(){return"pointers"},b([ke.serialize()],e.prototype,"buttons",void 0),b([ke.serialize()],e.prototype,"angularSensibilityX",void 0),b([ke.serialize()],e.prototype,"angularSensibilityY",void 0),b([ke.serialize()],e.prototype,"pinchPrecision",void 0),b([ke.serialize()],e.prototype,"pinchDeltaPercentage",void 0),b([ke.serialize()],e.prototype,"panningSensibility",void 0),b([ke.serialize()],e.prototype,"multiTouchPanning",void 0),b([ke.serialize()],e.prototype,"multiTouchPanAndZoom",void 0),e})(),ke.ArcRotateCameraPointersInput=We,ke.CameraInputTypes.ArcRotateCameraPointersInput=We,He=$a||($a={}),Xe=(function(t){function e(e){return t.call(this,e)||this}return T(e,t),e.prototype.addMouseWheel=function(){return this.add(new He.ArcRotateCameraMouseWheelInput),this},e.prototype.addPointers=function(){return this.add(new He.ArcRotateCameraPointersInput),this},e.prototype.addKeyboard=function(){return this.add(new He.ArcRotateCameraKeyboardMoveInput),this},e.prototype.addVRDeviceOrientation=function(){return this.add(new He.ArcRotateCameraVRDeviceOrientationInput),this},e})(He.CameraInputsManager),He.ArcRotateCameraInputsManager=Xe,(function(l){l.Node.AddNodeConstructor("ArcRotateCamera",(function(e,t){return function(){return new i(e,0,0,1,l.Vector3.Zero(),t)}}));var i=(function(a){function n(e,t,i,r,n,o,s){void 0===s&&(s=!0);var c=a.call(this,e,l.Vector3.Zero(),o,s)||this;return c.inertialAlphaOffset=0,c.inertialBetaOffset=0,c.inertialRadiusOffset=0,c.lowerAlphaLimit=null,c.upperAlphaLimit=null,c.lowerBetaLimit=.01,c.upperBetaLimit=Math.PI,c.lowerRadiusLimit=null,c.upperRadiusLimit=null,c.inertialPanningX=0,c.inertialPanningY=0,c.pinchToPanMaxDistance=20,c.panningDistanceLimit=null,c.panningOriginTarget=l.Vector3.Zero(),c.panningInertia=.9,c.zoomOnFactor=1,c.targetScreenOffset=l.Vector2.Zero(),c.allowUpsideDown=!0,c.useInputToRestoreState=!0,c._viewMatrix=new l.Matrix,c.panningAxis=new l.Vector3(1,1,0),c.onMeshTargetChangedObservable=new l.Observable,c.checkCollisions=!1,c.collisionRadius=new l.Vector3(.5,.5,.5),c._previousPosition=l.Vector3.Zero(),c._collisionVelocity=l.Vector3.Zero(),c._newPosition=l.Vector3.Zero(),c._computationVector=l.Vector3.Zero(),c._onCollisionPositionChange=function(e,t,i){void 0===i&&(i=null),c.getScene().workerCollisions&&c.checkCollisions&&t.multiplyInPlace(c._collider._radius),i?(c.setPosition(t),c.onCollide&&c.onCollide(i)):c._previousPosition.copyFrom(c.position);var r=Math.cos(c.alpha),n=Math.sin(c.alpha),o=Math.cos(c.beta),s=Math.sin(c.beta);0===s&&(s=1e-4);var a=c._getTargetPosition();c._computationVector.copyFromFloats(c.radius*r*s,c.radius*o,c.radius*n*s),a.addToRef(c._computationVector,c._newPosition),c.position.copyFrom(c._newPosition);var l=c.upVector;c.allowUpsideDown&&c.beta<0&&(l=(l=l.clone()).negate()),c._computeViewMatrix(c.position,a,l),c._viewMatrix.m[12]+=c.targetScreenOffset.x,c._viewMatrix.m[13]+=c.targetScreenOffset.y,c._collisionTriggered=!1},c._target=l.Vector3.Zero(),n&&c.setTarget(n),c.alpha=t,c.beta=i,c.radius=r,c.getViewMatrix(),c.inputs=new l.ArcRotateCameraInputsManager(c),c.inputs.addKeyboard().addMouseWheel().addPointers(),c}return T(n,a),Object.defineProperty(n.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(n.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(n.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(n.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(n.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(n.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(n.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(n.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(n.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(n.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(n.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(n.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(n.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(e){e!==this.useBouncingBehavior&&(e?(this._bouncingBehavior=new l.BouncingBehavior,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(e){e!==this.useFramingBehavior&&(e?(this._framingBehavior=new l.FramingBehavior,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(e){e!==this.useAutoRotationBehavior&&(e?(this._autoRotationBehavior=new l.AutoRotationBehavior,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),n.prototype._initCache=function(){a.prototype._initCache.call(this),this._cache._target=new l.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.alpha=void 0,this._cache.beta=void 0,this._cache.radius=void 0,this._cache.targetScreenOffset=l.Vector2.Zero()},n.prototype._updateCache=function(e){e||a.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)},n.prototype._getTargetPosition=function(){if(this._targetHost&&this._targetHost.getAbsolutePosition){var e=this._targetHost.getAbsolutePosition();this._targetBoundingCenter?e.addToRef(this._targetBoundingCenter,this._target):this._target.copyFrom(e)}var t=this._getLockedTargetPosition();return t||this._target},n.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),a.prototype.storeState.call(this)},n.prototype._restoreStateValues=function(){return!!a.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))},n.prototype._isSynchronizedViewMatrix=function(){return!!a.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))},n.prototype.attachControl=function(e,t,i,r){var n=this;void 0===i&&(i=!0),void 0===r&&(r=2),this._useCtrlForPanning=i,this._panningMouseButton=r,this.inputs.attachElement(e,t),this._reset=function(){n.inertialAlphaOffset=0,n.inertialBetaOffset=0,n.inertialRadiusOffset=0,n.inertialPanningX=0,n.inertialPanningY=0}},n.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},n.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var e=this.inertialAlphaOffset;this.beta<=0&&(e*=-1),this.getScene().useRightHandedSystem&&(e*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(e*=-1),this.alpha+=e,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<l.Epsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<l.Epsilon&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*l.Epsilon&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){if(this._localDirection||(this._localDirection=l.Vector3.Zero(),this._transformedDirection=l.Vector3.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),l.Vector3.TransformNormalToRef(this._localDirection,this._cameraTransformMatrix,this._transformedDirection),this.panningAxis.y||(this._transformedDirection.y=0),!this._targetHost)if(this.panningDistanceLimit)this._transformedDirection.addInPlace(this._target),l.Vector3.DistanceSquared(this._transformedDirection,this.panningOriginTarget)<=this.panningDistanceLimit*this.panningDistanceLimit&&this._target.copyFrom(this._transformedDirection);else this._target.addInPlace(this._transformedDirection);this.inertialPanningX*=this.panningInertia,this.inertialPanningY*=this.panningInertia,Math.abs(this.inertialPanningX)<this.speed*l.Epsilon&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*l.Epsilon&&(this.inertialPanningY=0)}this._checkLimits(),a.prototype._checkInputs.call(this)}},n.prototype._checkLimits=function(){null===this.lowerBetaLimit||void 0===this.lowerBetaLimit?this.allowUpsideDown&&this.beta>Math.PI&&(this.beta=this.beta-2*Math.PI):this.beta<this.lowerBetaLimit&&(this.beta=this.lowerBetaLimit),null===this.upperBetaLimit||void 0===this.upperBetaLimit?this.allowUpsideDown&&this.beta<-Math.PI&&(this.beta=this.beta+2*Math.PI):this.beta>this.upperBetaLimit&&(this.beta=this.upperBetaLimit),null!==this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),null!==this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),null!==this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),null!==this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},n.prototype.rebuildAnglesAndRadius=function(){this.position.subtractToRef(this._getTargetPosition(),this._computationVector),this.radius=this._computationVector.length(),0===this.radius&&(this.radius=1e-4),this.alpha=Math.acos(this._computationVector.x/Math.sqrt(Math.pow(this._computationVector.x,2)+Math.pow(this._computationVector.z,2))),this._computationVector.z<0&&(this.alpha=2*Math.PI-this.alpha),this.beta=Math.acos(this._computationVector.y/this.radius),this._checkLimits()},n.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},n.prototype.setTarget=function(e,t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!1),e.getBoundingInfo)this._targetBoundingCenter=t?e.getBoundingInfo().boundingBox.centerWorld.clone():null,this._targetHost=e,this._target=this._getTargetPosition(),this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);else{var r=e,n=this._getTargetPosition();if(n&&!i&&n.equals(r))return;this._targetHost=null,this._target=r,this._targetBoundingCenter=null,this.onMeshTargetChangedObservable.notifyObservers(null)}this.rebuildAnglesAndRadius()},n.prototype._getViewMatrix=function(){var e=Math.cos(this.alpha),t=Math.sin(this.alpha),i=Math.cos(this.beta),r=Math.sin(this.beta);0===r&&(r=1e-4);var n=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*e*r,this.radius*i,this.radius*t*r),n.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new l.Collider),this._collider._radius=this.collisionRadius,this._newPosition.subtractToRef(this.position,this._collisionVelocity),this._collisionTriggered=!0,this.getScene().collisionCoordinator.getNewPosition(this.position,this._collisionVelocity,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId);else{this.position.copyFrom(this._newPosition);var o=this.upVector;this.allowUpsideDown&&r<0&&(o=(o=o.clone()).negate()),this._computeViewMatrix(this.position,n,o),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=n,this._viewMatrix},n.prototype.zoomOn=function(e,t){void 0===t&&(t=!1),e=e||this.getScene().meshes;var i=l.Mesh.MinMax(e),r=l.Vector3.Distance(i.min,i.max);this.radius=r*this.zoomOnFactor,this.focusOn({min:i.min,max:i.max,distance:r},t)},n.prototype.focusOn=function(e,t){var i,r;if(void 0===t&&(t=!1),void 0===e.min){var n=e||this.getScene().meshes;i=l.Mesh.MinMax(n),r=l.Vector3.Distance(i.min,i.max)}else{var o=e;r=(i=o).distance}this._target=l.Mesh.Center(i),t||(this.maxZ=2*r)},n.prototype.createRigCamera=function(e,t){var i=0;switch(this.cameraRigMode){case l.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case l.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case l.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case l.Camera.RIG_MODE_VR:i=this._cameraRigParams.stereoHalfAngle*(0===t?1:-1);break;case l.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i=this._cameraRigParams.stereoHalfAngle*(0===t?-1:1)}var r=new n(e,this.alpha+i,this.beta,this.radius,this._target,this.getScene());return r._cameraRigParams={},r},n.prototype._updateRigCameras=function(){var e=this._rigCameras[0],t=this._rigCameras[1];switch(e.beta=t.beta=this.beta,e.radius=t.radius=this.radius,this.cameraRigMode){case l.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case l.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case l.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case l.Camera.RIG_MODE_VR:e.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case l.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:e.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,t.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}a.prototype._updateRigCameras.call(this)},n.prototype.dispose=function(){this.inputs.clear(),a.prototype.dispose.call(this)},n.prototype.getClassName=function(){return"ArcRotateCamera"},b([l.serialize()],n.prototype,"alpha",void 0),b([l.serialize()],n.prototype,"beta",void 0),b([l.serialize()],n.prototype,"radius",void 0),b([l.serializeAsVector3("target")],n.prototype,"_target",void 0),b([l.serialize()],n.prototype,"inertialAlphaOffset",void 0),b([l.serialize()],n.prototype,"inertialBetaOffset",void 0),b([l.serialize()],n.prototype,"inertialRadiusOffset",void 0),b([l.serialize()],n.prototype,"lowerAlphaLimit",void 0),b([l.serialize()],n.prototype,"upperAlphaLimit",void 0),b([l.serialize()],n.prototype,"lowerBetaLimit",void 0),b([l.serialize()],n.prototype,"upperBetaLimit",void 0),b([l.serialize()],n.prototype,"lowerRadiusLimit",void 0),b([l.serialize()],n.prototype,"upperRadiusLimit",void 0),b([l.serialize()],n.prototype,"inertialPanningX",void 0),b([l.serialize()],n.prototype,"inertialPanningY",void 0),b([l.serialize()],n.prototype,"pinchToPanMaxDistance",void 0),b([l.serialize()],n.prototype,"panningDistanceLimit",void 0),b([l.serializeAsVector3()],n.prototype,"panningOriginTarget",void 0),b([l.serialize()],n.prototype,"panningInertia",void 0),b([l.serialize()],n.prototype,"zoomOnFactor",void 0),b([l.serialize()],n.prototype,"targetScreenOffset",void 0),b([l.serialize()],n.prototype,"allowUpsideDown",void 0),b([l.serialize()],n.prototype,"useInputToRestoreState",void 0),n})(l.TargetCamera);l.ArcRotateCamera=i})($a||($a={})),(function(o){o.Node.AddNodeConstructor("Light_Type_3",(function(e,t){return function(){return new i(e,o.Vector3.Zero(),t)}}));var i=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r.groundColor=new o.Color3(0,0,0),r.direction=t||o.Vector3.Up(),r}return T(e,n),e.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()},e.prototype.getClassName=function(){return"HemisphericLight"},e.prototype.setDirectionToTarget=function(e){return this.direction=o.Vector3.Normalize(e.subtract(o.Vector3.Zero())),this.direction},e.prototype.getShadowGenerator=function(){return null},e.prototype.transferToEffect=function(e,t){var i=o.Vector3.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",i.x,i.y,i.z,0,t),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),t),this},e.prototype.computeWorldMatrix=function(e,t){return this._worldMatrix||(this._worldMatrix=o.Matrix.Identity()),this._worldMatrix},e.prototype.getTypeID=function(){return o.Light.LIGHTTYPEID_HEMISPHERICLIGHT},e.prototype.prepareLightSpecificDefines=function(e,t){e["HEMILIGHT"+t]=!0},b([o.serializeAsColor3()],e.prototype,"groundColor",void 0),b([o.serializeAsVector3()],e.prototype,"direction",void 0),e})(o.Light);o.HemisphericLight=i})($a||($a={})),je=$a||($a={}),Ye=(function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return T(e,t),e.prototype._setPosition=function(e){this._position=e},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!0,configurable:!0}),e.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),e.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=je.Vector3.Zero()),je.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=je.Vector3.Zero()),je.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},e.prototype.getDepthScale=function(){return 50},e.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},e.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},e.prototype.setDirectionToTarget=function(e){return this.direction=je.Vector3.Normalize(e.subtract(this.position)),this.direction},e.prototype.getRotation=function(){this.direction.normalize();var e=je.Vector3.Cross(this.direction,je.Axis.Y),t=je.Vector3.Cross(e,this.direction);return je.Vector3.RotationFromAxis(e,t,this.direction)},e.prototype.needCube=function(){return!1},e.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},e.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},e.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.position=je.Vector3.Zero()},e.prototype._isSynchronized=function(){return!!this._cache.position.equals(this.position)},e.prototype.computeWorldMatrix=function(e){return!e&&this.isSynchronized()?this._currentRenderId=this.getScene().getRenderId():(this._updateCache(),this._cache.position.copyFrom(this.position),this._worldMatrix||(this._worldMatrix=je.Matrix.Identity()),je.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this.parent&&this.parent.getWorldMatrix&&(this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(),this._worldMatrix),this._markSyncedWithParent()),this._worldMatrixDeterminant=this._worldMatrix.determinant()),this._worldMatrix},e.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},e.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},e.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},b([je.serializeAsVector3()],e.prototype,"position",null),b([je.serializeAsVector3()],e.prototype,"direction",null),b([je.serialize()],e.prototype,"shadowMinZ",null),b([je.serialize()],e.prototype,"shadowMaxZ",null),e})(je.Light),je.ShadowLight=Ye,(function(o){o.Node.AddNodeConstructor("Light_Type_0",(function(e,t){return function(){return new i(e,o.Vector3.Zero(),t)}}));var i=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r._shadowAngle=Math.PI/2,r.position=t,r}return T(e,n),Object.defineProperty(e.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"direction",{get:function(){return this._direction},set:function(e){var t=this.needCube();this._direction=e,this.needCube()!==t&&this._shadowGenerator&&this._shadowGenerator.recreateShadowMap()},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"PointLight"},e.prototype.getTypeID=function(){return o.Light.LIGHTTYPEID_POINTLIGHT},e.prototype.needCube=function(){return!this.direction},e.prototype.getShadowDirection=function(e){if(this.direction)return n.prototype.getShadowDirection.call(this,e);switch(e){case 0:return new o.Vector3(1,0,0);case 1:return new o.Vector3(-1,0,0);case 2:return new o.Vector3(0,-1,0);case 3:return new o.Vector3(0,1,0);case 4:return new o.Vector3(0,0,1);case 5:return new o.Vector3(0,0,-1)}return o.Vector3.Zero()},e.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;r&&o.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(r),this.getDepthMaxZ(r),e)},e.prototype._buildUniformLayout=function(){this._uniformBuffer.addUniform("vLightData",4),this._uniformBuffer.addUniform("vLightDiffuse",4),this._uniformBuffer.addUniform("vLightSpecular",3),this._uniformBuffer.addUniform("vLightFalloff",4),this._uniformBuffer.addUniform("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},e.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t):this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,0,0,t),this},e.prototype.prepareLightSpecificDefines=function(e,t){e["POINTLIGHT"+t]=!0},b([o.serialize()],e.prototype,"shadowAngle",null),e})(o.ShadowLight);o.PointLight=i})($a||($a={})),(function(u){u.Node.AddNodeConstructor("Light_Type_1",(function(e,t){return function(){return new i(e,u.Vector3.Zero(),t)}}));var i=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r._shadowFrustumSize=0,r._shadowOrthoScale=.1,r.autoUpdateExtends=!0,r._orthoLeft=Number.MAX_VALUE,r._orthoRight=Number.MIN_VALUE,r._orthoTop=Number.MIN_VALUE,r._orthoBottom=Number.MAX_VALUE,r.position=t.scale(-1),r.direction=t,r}return T(e,n),Object.defineProperty(e.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"DirectionalLight"},e.prototype.getTypeID=function(){return u.Light.LIGHTTYPEID_DIRECTIONALLIGHT},e.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){0<this.shadowFrustumSize?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},e.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(e,t){var i=this.getScene().activeCamera;i&&u.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:i.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:i.maxZ,e)},e.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;if(r){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var n=u.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var o=0;o<i.length;o++){var s=i[o];if(s)for(var a=s.getBoundingInfo().boundingBox,l=0;l<a.vectorsWorld.length;l++)u.Vector3.TransformCoordinatesToRef(a.vectorsWorld[l],t,n),n.x<this._orthoLeft&&(this._orthoLeft=n.x),n.y<this._orthoBottom&&(this._orthoBottom=n.y),n.x>this._orthoRight&&(this._orthoRight=n.x),n.y>this._orthoTop&&(this._orthoTop=n.y)}}var c=this._orthoRight-this._orthoLeft,h=this._orthoTop-this._orthoBottom;u.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-c*this.shadowOrthoScale,this._orthoRight+c*this.shadowOrthoScale,this._orthoBottom-h*this.shadowOrthoScale,this._orthoTop+h*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,e)}},e.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()},e.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t):this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this},e.prototype.getDepthMinZ=function(e){return 1},e.prototype.getDepthMaxZ=function(e){return 1},e.prototype.prepareLightSpecificDefines=function(e,t){e["DIRLIGHT"+t]=!0},b([u.serialize()],e.prototype,"shadowFrustumSize",null),b([u.serialize()],e.prototype,"shadowOrthoScale",null),b([u.serialize()],e.prototype,"autoUpdateExtends",void 0),e})(u.ShadowLight);u.DirectionalLight=i})($a||($a={})),(function(l){l.Node.AddNodeConstructor("Light_Type_2",(function(e,t){return function(){return new i(e,l.Vector3.Zero(),l.Vector3.Zero(),0,0,t)}}));var i=(function(a){function e(e,t,i,r,n,o){var s=a.call(this,e,o)||this;return s._innerAngle=0,s._projectionTextureMatrix=l.Matrix.Zero(),s._projectionTextureLightNear=1e-6,s._projectionTextureLightFar=1e3,s._projectionTextureUpDirection=l.Vector3.Up(),s._projectionTextureViewLightDirty=!0,s._projectionTextureProjectionLightDirty=!0,s._projectionTextureDirty=!0,s._projectionTextureViewTargetVector=l.Vector3.Zero(),s._projectionTextureViewLightMatrix=l.Matrix.Zero(),s._projectionTextureProjectionLightMatrix=l.Matrix.Zero(),s._projectionTextureScalingMatrix=l.Matrix.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),s.position=t,s.direction=i,s.angle=r,s.exponent=n,s}return T(e,a),Object.defineProperty(e.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(e.prototype,"innerAngle",{get:function(){return this._innerAngle},set:function(e){this._innerAngle=e,this._computeAngleValues()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){this._projectionTexture=e,this._projectionTextureDirty=!0},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"SpotLight"},e.prototype.getTypeID=function(){return l.Light.LIGHTTYPEID_SPOTLIGHT},e.prototype._setDirection=function(e){a.prototype._setDirection.call(this,e),this._projectionTextureViewLightDirty=!0},e.prototype._setPosition=function(e){a.prototype._setPosition.call(this,e),this._projectionTextureViewLightDirty=!0},e.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){var r=this.getScene().activeCamera;if(r){this._shadowAngleScale=this._shadowAngleScale||1;var n=this._shadowAngleScale*this._angle;l.Matrix.PerspectiveFovLHToRef(n,1,this.getDepthMinZ(r),this.getDepthMaxZ(r),e)}},e.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),l.Matrix.LookAtLHToRef(this.position,this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},e.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var e=this.projectionTextureLightFar,t=this.projectionTextureLightNear,i=e/(e-t),r=-i*t,n=1/Math.tan(this._angle/2);l.Matrix.FromValuesToRef(n/1,0,0,0,0,n,0,0,0,0,i,1,0,0,r,0,this._projectionTextureProjectionLightMatrix)},e.prototype._computeProjectionTextureMatrix=function(){this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)},e.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()},e.prototype._computeAngleValues=function(){this._lightAngleScale=1/Math.max(.001,Math.cos(.5*this._innerAngle)-this._cosHalfAngle),this._lightAngleOffset=-this._cosHalfAngle*this._lightAngleScale},e.prototype.transferToEffect=function(e,t){var i;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,t),i=l.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,t),i=l.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",i.x,i.y,i.z,this._cosHalfAngle,t),this._uniformBuffer.updateFloat4("vLightFalloff",this.range,this._inverseSquaredRange,this._lightAngleScale,this._lightAngleOffset,t),this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),e.setMatrix("textureProjectionMatrix"+t,this._projectionTextureMatrix),e.setTexture("projectionLightSampler"+t,this.projectionTexture)),this},e.prototype.dispose=function(){a.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},e.prototype.prepareLightSpecificDefines=function(e,t){e["SPOTLIGHT"+t]=!0,e["PROJECTEDLIGHTTEXTURE"+t]=!!this.projectionTexture},b([l.serialize()],e.prototype,"angle",null),b([l.serialize()],e.prototype,"innerAngle",null),b([l.serialize()],e.prototype,"shadowAngleScale",null),b([l.serialize()],e.prototype,"exponent",void 0),b([l.serialize()],e.prototype,"projectionTextureLightNear",null),b([l.serialize()],e.prototype,"projectionTextureLightFar",null),b([l.serialize()],e.prototype,"projectionTextureUpDirection",null),b([l.serializeAsTexture("projectedLightTexture")],e.prototype,"_projectionTexture",void 0),e})(l.ShadowLight);l.SpotLight=i})($a||($a={})),Ke=$a||($a={}),Qe=function(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=Ke.Animation.ANIMATIONLOOPMODE_CYCLE},Ke.AnimationPropertiesOverride=Qe,(function(d){var r=(function(){function e(e,t,i){this.name=e,this.from=t,this.to=i}return e.prototype.clone=function(){return new e(this.name,this.from,this.to)},e})();d.AnimationRange=r;var e=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e.prototype._clone=function(){return new e(this.frame,this.action,this.onlyOnce)},e})();d.AnimationEvent=e;var x,t,i=(function(){function e(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return e.prototype.getPoint=function(){var e=this.path.getPointAtLengthPosition(this.value);return new d.Vector3(e.x,0,e.y)},e.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},e.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},e.prototype.move=function(e){if(1<Math.abs(e))throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},e.prototype.ensureLimits=function(){for(;1<this.value;)this.value-=1;for(;this.value<0;)this.value+=1;return this},e.prototype.raiseOnChange=function(){var t=this;return this._onchange.forEach((function(e){return e(t)})),this},e.prototype.onchange=function(e){return this._onchange.push(e),this},e})();d.PathCursor=i,(t=x=d.AnimationKeyInterpolation||(d.AnimationKeyInterpolation={}))[t.STEP=1]="STEP";var n=(function(){function T(e,t,i,r,n,o){this.name=e,this.targetProperty=t,this.framePerSecond=i,this.dataType=r,this.loopMode=n,this.enableBlending=o,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=r,this.loopMode=void 0===n?T.ANIMATIONLOOPMODE_CYCLE:n}return T._PrepareAnimation=function(e,t,i,r,n,o,s,a){var l=void 0;if(!isNaN(parseFloat(n))&&isFinite(n)?l=T.ANIMATIONTYPE_FLOAT:n instanceof d.Quaternion?l=T.ANIMATIONTYPE_QUATERNION:n instanceof d.Vector3?l=T.ANIMATIONTYPE_VECTOR3:n instanceof d.Vector2?l=T.ANIMATIONTYPE_VECTOR2:n instanceof d.Color3?l=T.ANIMATIONTYPE_COLOR3:n instanceof d.Size&&(l=T.ANIMATIONTYPE_SIZE),null==l)return null;var c=new T(e,t,i,l,s),h=[{frame:0,value:n},{frame:r,value:o}];return c.setKeys(h),void 0!==a&&c.setEasingFunction(a),c},T.CreateAnimation=function(e,t,i,r){var n=new T(e+"Animation",e,i,t,T.ANIMATIONLOOPMODE_CONSTANT);return n.setEasingFunction(r),n},T.CreateAndStartAnimation=function(e,t,i,r,n,o,s,a,l,c){var h=T._PrepareAnimation(e,i,r,n,o,s,a,l);return h?t.getScene().beginDirectAnimation(t,[h],0,n,1===h.loopMode,1,c):null},T.CreateAndStartHierarchyAnimation=function(e,t,i,r,n,o,s,a,l,c,h){var u=T._PrepareAnimation(e,r,n,o,s,a,l,c);return u?t.getScene().beginDirectHierarchyAnimation(t,i,[u],0,o,1===u.loopMode,1,h):null},T.CreateMergeAndStartAnimation=function(e,t,i,r,n,o,s,a,l,c){var h=T._PrepareAnimation(e,i,r,n,o,s,a,l);return h?(t.animations.push(h),t.getScene().beginAnimation(t,0,n,1===h.loopMode,1,c)):null},T.TransitionTo=function(e,t,i,r,n,o,s,a){if(void 0===a&&(a=null),s<=0)return i[e]=t,a&&a(),null;var l=n*(s/1e3);o.setKeys([{frame:0,value:i[e].clone?i[e].clone():i[e]},{frame:l,value:t}]),i.animations||(i.animations=[]),i.animations.push(o);var c=r.beginAnimation(i,0,l,!1);return c.onAnimationEnd=a,c},Object.defineProperty(T.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!0,configurable:!0}),Object.defineProperty(T.prototype,"hasRunningRuntimeAnimations",{get:function(){for(var e=0,t=this._runtimeAnimations;e<t.length;e++){if(!t[e].isStopped)return!0}return!1},enumerable:!0,configurable:!0}),T.prototype.toString=function(e){var t="Name: "+this.name+", property: "+this.targetProperty;if(t+=", datatype: "+["Float","Vector3","Quaternion","Matrix","Color3","Vector2"][this.dataType],t+=", nKeys: "+(this._keys?this._keys.length:"none"),t+=", nRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},T.prototype.addEvent=function(e){this._events.push(e)},T.prototype.removeEvents=function(e){for(var t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)},T.prototype.getEvents=function(){return this._events},T.prototype.createRange=function(e,t,i){this._ranges[e]||(this._ranges[e]=new r(e,t,i))},T.prototype.deleteRange=function(e,t){void 0===t&&(t=!0);var i=this._ranges[e];if(i){if(t)for(var r=i.from,n=i.to,o=this._keys.length-1;0<=o;o--)this._keys[o].frame>=r&&this._keys[o].frame<=n&&this._keys.splice(o,1);this._ranges[e]=null}},T.prototype.getRange=function(e){return this._ranges[e]},T.prototype.getKeys=function(){return this._keys},T.prototype.getHighestFrame=function(){for(var e=0,t=0,i=this._keys.length;t<i;t++)e<this._keys[t].frame&&(e=this._keys[t].frame);return e},T.prototype.getEasingFunction=function(){return this._easingFunction},T.prototype.setEasingFunction=function(e){this._easingFunction=e},T.prototype.floatInterpolateFunction=function(e,t,i){return d.Scalar.Lerp(e,t,i)},T.prototype.floatInterpolateFunctionWithTangents=function(e,t,i,r,n){return d.Scalar.Hermite(e,t,i,r,n)},T.prototype.quaternionInterpolateFunction=function(e,t,i){return d.Quaternion.Slerp(e,t,i)},T.prototype.quaternionInterpolateFunctionWithTangents=function(e,t,i,r,n){return d.Quaternion.Hermite(e,t,i,r,n).normalize()},T.prototype.vector3InterpolateFunction=function(e,t,i){return d.Vector3.Lerp(e,t,i)},T.prototype.vector3InterpolateFunctionWithTangents=function(e,t,i,r,n){return d.Vector3.Hermite(e,t,i,r,n)},T.prototype.vector2InterpolateFunction=function(e,t,i){return d.Vector2.Lerp(e,t,i)},T.prototype.vector2InterpolateFunctionWithTangents=function(e,t,i,r,n){return d.Vector2.Hermite(e,t,i,r,n)},T.prototype.sizeInterpolateFunction=function(e,t,i){return d.Size.Lerp(e,t,i)},T.prototype.color3InterpolateFunction=function(e,t,i){return d.Color3.Lerp(e,t,i)},T.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},T.prototype._interpolate=function(e,t,i,r,n,o){if(r===T.ANIMATIONLOOPMODE_CONSTANT&&0<t)return o.clone?o.clone():o;var s=this.getKeys(),a=Math.max(0,Math.min(s.length-1,Math.floor(s.length*(e-s[0].frame)/(s[s.length-1].frame-s[0].frame))-1));if(s[a].frame>=e)for(;0<=a-1&&s[a].frame>=e;)a--;for(var l=a;l<s.length;l++){var c=s[l+1];if(c.frame>=e){var h=s[l],u=this._getKeyValue(h.value);if(h.interpolation===x.STEP)return u;var d=this._getKeyValue(c.value),f=void 0!==h.outTangent&&void 0!==c.inTangent,p=c.frame-h.frame,m=(e-h.frame)/p,_=this.getEasingFunction();switch(null!=_&&(m=_.ease(m)),this.dataType){case T.ANIMATIONTYPE_FLOAT:var g=f?this.floatInterpolateFunctionWithTangents(u,h.outTangent*p,d,c.inTangent*p,m):this.floatInterpolateFunction(u,d,m);switch(r){case T.ANIMATIONLOOPMODE_CYCLE:case T.ANIMATIONLOOPMODE_CONSTANT:return g;case T.ANIMATIONLOOPMODE_RELATIVE:return n*t+g}break;case T.ANIMATIONTYPE_QUATERNION:var v=f?this.quaternionInterpolateFunctionWithTangents(u,h.outTangent.scale(p),d,c.inTangent.scale(p),m):this.quaternionInterpolateFunction(u,d,m);switch(r){case T.ANIMATIONLOOPMODE_CYCLE:case T.ANIMATIONLOOPMODE_CONSTANT:return v;case T.ANIMATIONLOOPMODE_RELATIVE:return v.addInPlace(n.scale(t))}return v;case T.ANIMATIONTYPE_VECTOR3:var y=f?this.vector3InterpolateFunctionWithTangents(u,h.outTangent.scale(p),d,c.inTangent.scale(p),m):this.vector3InterpolateFunction(u,d,m);switch(r){case T.ANIMATIONLOOPMODE_CYCLE:case T.ANIMATIONLOOPMODE_CONSTANT:return y;case T.ANIMATIONLOOPMODE_RELATIVE:return y.add(n.scale(t))}case T.ANIMATIONTYPE_VECTOR2:var b=f?this.vector2InterpolateFunctionWithTangents(u,h.outTangent.scale(p),d,c.inTangent.scale(p),m):this.vector2InterpolateFunction(u,d,m);switch(r){case T.ANIMATIONLOOPMODE_CYCLE:case T.ANIMATIONLOOPMODE_CONSTANT:return b;case T.ANIMATIONLOOPMODE_RELATIVE:return b.add(n.scale(t))}case T.ANIMATIONTYPE_SIZE:switch(r){case T.ANIMATIONLOOPMODE_CYCLE:case T.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(u,d,m);case T.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(u,d,m).add(n.scale(t))}case T.ANIMATIONTYPE_COLOR3:switch(r){case T.ANIMATIONLOOPMODE_CYCLE:case T.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(u,d,m);case T.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(u,d,m).add(n.scale(t))}case T.ANIMATIONTYPE_MATRIX:switch(r){case T.ANIMATIONLOOPMODE_CYCLE:case T.ANIMATIONLOOPMODE_CONSTANT:if(T.AllowMatricesInterpolation)return this.matrixInterpolateFunction(u,d,m,i);case T.ANIMATIONLOOPMODE_RELATIVE:return u}}break}}return this._getKeyValue(s[s.length-1].value)},T.prototype.matrixInterpolateFunction=function(e,t,i,r){return T.AllowMatrixDecomposeForInterpolation?r?(d.Matrix.DecomposeLerpToRef(e,t,i,r),r):d.Matrix.DecomposeLerp(e,t,i):r?(d.Matrix.LerpToRef(e,t,i,r),r):d.Matrix.Lerp(e,t,i)},T.prototype.clone=function(){var e=new T(this.name,this.targetPropertyPath.join("."),this.framePerSecond,this.dataType,this.loopMode);if(e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed,this._keys&&e.setKeys(this._keys),this._ranges)for(var t in e._ranges={},this._ranges){var i=this._ranges[t];i&&(e._ranges[t]=i.clone())}return e},T.prototype.setKeys=function(e){this._keys=e.slice(0)},T.prototype.serialize=function(){var e={};e.name=this.name,e.property=this.targetProperty,e.framePerSecond=this.framePerSecond,e.dataType=this.dataType,e.loopBehavior=this.loopMode,e.enableBlending=this.enableBlending,e.blendingSpeed=this.blendingSpeed;var t=this.dataType;e.keys=[];for(var i=this.getKeys(),r=0;r<i.length;r++){var n=i[r],o={};switch(o.frame=n.frame,t){case T.ANIMATIONTYPE_FLOAT:o.values=[n.value];break;case T.ANIMATIONTYPE_QUATERNION:case T.ANIMATIONTYPE_MATRIX:case T.ANIMATIONTYPE_VECTOR3:case T.ANIMATIONTYPE_COLOR3:o.values=n.value.asArray()}e.keys.push(o)}for(var s in e.ranges=[],this._ranges){var a=this._ranges[s];if(a){var l={};l.name=s,l.from=a.from,l.to=a.to,e.ranges.push(l)}}return e},Object.defineProperty(T,"ANIMATIONTYPE_FLOAT",{get:function(){return T._ANIMATIONTYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONTYPE_VECTOR3",{get:function(){return T._ANIMATIONTYPE_VECTOR3},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONTYPE_VECTOR2",{get:function(){return T._ANIMATIONTYPE_VECTOR2},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONTYPE_SIZE",{get:function(){return T._ANIMATIONTYPE_SIZE},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONTYPE_QUATERNION",{get:function(){return T._ANIMATIONTYPE_QUATERNION},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONTYPE_MATRIX",{get:function(){return T._ANIMATIONTYPE_MATRIX},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONTYPE_COLOR3",{get:function(){return T._ANIMATIONTYPE_COLOR3},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONLOOPMODE_RELATIVE",{get:function(){return T._ANIMATIONLOOPMODE_RELATIVE},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONLOOPMODE_CYCLE",{get:function(){return T._ANIMATIONLOOPMODE_CYCLE},enumerable:!0,configurable:!0}),Object.defineProperty(T,"ANIMATIONLOOPMODE_CONSTANT",{get:function(){return T._ANIMATIONLOOPMODE_CONSTANT},enumerable:!0,configurable:!0}),T._UniversalLerp=function(e,t,i){var r=e.constructor;return r.Lerp?r.Lerp(e,t,i):r.Slerp?r.Slerp(e,t,i):e.toFixed?e*(1-i)+i*t:t},T.Parse=function(e){var t,i,r=new T(e.name,e.property,e.framePerSecond,e.dataType,e.loopBehavior),n=e.dataType,o=[];for(e.enableBlending&&(r.enableBlending=e.enableBlending),e.blendingSpeed&&(r.blendingSpeed=e.blendingSpeed),i=0;i<e.keys.length;i++){var s,a,l=e.keys[i];switch(n){case T.ANIMATIONTYPE_FLOAT:t=l.values[0],1<=l.values.length&&(s=l.values[1]),2<=l.values.length&&(a=l.values[2]);break;case T.ANIMATIONTYPE_QUATERNION:if(t=d.Quaternion.FromArray(l.values),8<=l.values.length){var c=d.Quaternion.FromArray(l.values.slice(4,8));c.equals(d.Quaternion.Zero())||(s=c)}if(12<=l.values.length){var h=d.Quaternion.FromArray(l.values.slice(8,12));h.equals(d.Quaternion.Zero())||(a=h)}break;case T.ANIMATIONTYPE_MATRIX:t=d.Matrix.FromArray(l.values);break;case T.ANIMATIONTYPE_COLOR3:t=d.Color3.FromArray(l.values);break;case T.ANIMATIONTYPE_VECTOR3:default:t=d.Vector3.FromArray(l.values)}var u={};u.frame=l.frame,u.value=t,null!=s&&(u.inTangent=s),null!=a&&(u.outTangent=a),o.push(u)}if(r.setKeys(o),e.ranges)for(i=0;i<e.ranges.length;i++)t=e.ranges[i],r.createRange(t.name,t.from,t.to);return r},T.AppendSerializedAnimations=function(e,t){if(e.animations){t.animations=[];for(var i=0;i<e.animations.length;i++){var r=e.animations[i];t.animations.push(r.serialize())}}},T.AllowMatricesInterpolation=!1,T.AllowMatrixDecomposeForInterpolation=!0,T._ANIMATIONTYPE_FLOAT=0,T._ANIMATIONTYPE_VECTOR3=1,T._ANIMATIONTYPE_QUATERNION=2,T._ANIMATIONTYPE_MATRIX=3,T._ANIMATIONTYPE_COLOR3=4,T._ANIMATIONTYPE_VECTOR2=5,T._ANIMATIONTYPE_SIZE=6,T._ANIMATIONLOOPMODE_RELATIVE=0,T._ANIMATIONLOOPMODE_CYCLE=1,T._ANIMATIONLOOPMODE_CONSTANT=2,T})();d.Animation=n})($a||($a={})),(function(l){var e=function(){};l.TargetedAnimation=e;var t=(function(){function e(e,t){void 0===t&&(t=null),this.name=e,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this.onAnimationEndObservable=new l.Observable,this.onAnimationGroupEndObservable=new l.Observable,this.onAnimationGroupPauseObservable=new l.Observable,this._scene=t||l.Engine.LastCreatedScene,this._scene.animationGroups.push(this)}return Object.defineProperty(e.prototype,"from",{get:function(){return this._from},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"to",{get:function(){return this._to},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){if(this._speedRatio!==e){this._speedRatio=e;for(var t=0;t<this._animatables.length;t++){this._animatables[t].speedRatio=this._speedRatio}}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetedAnimations",{get:function(){return this._targetedAnimations},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animatables",{get:function(){return this._animatables},enumerable:!0,configurable:!0}),e.prototype.addTargetedAnimation=function(e,t){var i={animation:e,target:t},r=e.getKeys();return this._from>r[0].frame&&(this._from=r[0].frame),this._to<r[r.length-1].frame&&(this._to=r[r.length-1].frame),this._targetedAnimations.push(i),i},e.prototype.normalize=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null),null==e&&(e=this._from),null==t&&(t=this._to);for(var i=0;i<this._targetedAnimations.length;i++){var r=this._targetedAnimations[i].animation.getKeys(),n=r[0],o=r[r.length-1];if(n.frame>e){var s={frame:e,value:n.value,inTangent:n.inTangent,outTangent:n.outTangent,interpolation:n.interpolation};r.splice(0,0,s)}if(o.frame<t){s={frame:t,value:o.value,inTangent:o.outTangent,outTangent:o.outTangent,interpolation:o.interpolation};r.push(s)}}return this._from=e,this._to=t,this},e.prototype.start=function(i,r,n,o){var s=this;if(void 0===i&&(i=!1),void 0===r&&(r=1),this._isStarted||0===this._targetedAnimations.length)return this;for(var e=function(e){var t=a._scene.beginDirectAnimation(e.target,[e.animation],void 0!==n?n:a._from,void 0!==o?o:a._to,i,r);t.onAnimationEnd=function(){s.onAnimationEndObservable.notifyObservers(e),s._checkAnimationGroupEnded(t)},a._animatables.push(t)},a=this,t=0,l=this._targetedAnimations;t<l.length;t++){e(l[t])}return this._speedRatio=r,this._isStarted=!0,this},e.prototype.pause=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].pause()}return this.onAnimationGroupPauseObservable.notifyObservers(this),this},e.prototype.play=function(e){if(this.isStarted&&this._animatables.length===this._targetedAnimations.length){if(void 0!==e)for(var t=0;t<this._animatables.length;t++){this._animatables[t].loopAnimation=e}this.restart()}else this.stop(),this.start(e,this._speedRatio);return this},e.prototype.reset=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].reset()}return this},e.prototype.restart=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].restart()}return this},e.prototype.stop=function(){if(!this._isStarted)return this;for(var e=this._animatables.slice(),t=0;t<e.length;t++)e[t].stop();return this._isStarted=!1,this},e.prototype.setWeightForAllAnimatables=function(e){for(var t=0;t<this._animatables.length;t++){this._animatables[t].weight=e}return this},e.prototype.syncAllAnimationsWith=function(e){for(var t=0;t<this._animatables.length;t++){this._animatables[t].syncWith(e)}return this},e.prototype.goToFrame=function(e){if(!this._isStarted)return this;for(var t=0;t<this._animatables.length;t++){this._animatables[t].goToFrame(e)}return this},e.prototype.dispose=function(){this._targetedAnimations=[],this._animatables=[];var e=this._scene.animationGroups.indexOf(this);-1<e&&this._scene.animationGroups.splice(e,1)},e.prototype._checkAnimationGroupEnded=function(e){var t=this._animatables.indexOf(e);-1<t&&this._animatables.splice(t,1),0===this._animatables.length&&(this._isStarted=!1,this.onAnimationGroupEndObservable.notifyObservers(this))},e.Parse=function(e,t){for(var i=new l.AnimationGroup(e.name,t),r=0;r<e.targetedAnimations.length;r++){var n=e.targetedAnimations[r],o=l.Animation.Parse(n.animation),s=n.targetId,a=t.getNodeByID(s);null!=a&&i.addTargetedAnimation(o,a)}return null!==e.from&&null!==e.from&&i.normalize(e.from,e.to),i},e.prototype.getClassName=function(){return"AnimationGroup"},e.prototype.toString=function(e){var t="Name: "+this.name;return t+=", type: "+this.getClassName(),e&&(t+=", from: "+this._from,t+=", to: "+this._to,t+=", isStarted: "+this._isStarted,t+=", speedRatio: "+this._speedRatio,t+=", targetedAnimations length: "+this._targetedAnimations.length,t+=", animatables length: "+this._animatables),t},e})();l.AnimationGroup=t})($a||($a={})),Ze=$a||($a={}),qe=Object.freeze(new Ze.Quaternion(0,0,0,0)),Je=Object.freeze(Ze.Vector3.Zero()),$e=Object.freeze(Ze.Vector2.Zero()),et=Object.freeze(Ze.Size.Zero()),tt=Object.freeze(Ze.Color3.Black()),it=(function(){function e(e,t,i,r){var n=this;this._events=new Array,this._currentFrame=0,this._originalValue=new Array,this._offsetsCache={},this._highLimitsCache={},this._stopped=!1,this._blendingFactor=0,this._targetPath="",this._weight=1,this._ratioOffset=0,this._previousDelay=0,this._previousRatio=0,this._animation=t,this._target=e,this._scene=i,this._host=r,t._runtimeAnimations.push(this);var o=t.getEvents();o&&0<o.length&&o.forEach((function(e){n._events.push(e._clone())}))}return Object.defineProperty(e.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"target",{get:function(){return this._activeTarget},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"animation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),e.prototype.reset=function(e){if(void 0===e&&(e=!1),e)if(this._target instanceof Array)for(var t=0,i=0,r=this._target;i<r.length;i++){var n=r[i];void 0!==this._originalValue[t]&&this._setValue(n,this._originalValue[t],-1),t++}else void 0!==this._originalValue[0]&&this._setValue(this._target,this._originalValue[0],-1);this._offsetsCache={},this._highLimitsCache={},this._currentFrame=0,this._blendingFactor=0,this._originalValue=new Array;for(t=0;t<this._events.length;t++)this._events[t].isDone=!1},e.prototype.isStopped=function(){return this._stopped},e.prototype.dispose=function(){var e=this._animation.runtimeAnimations.indexOf(this);-1<e&&this._animation.runtimeAnimations.splice(e,1)},e.prototype._interpolate=function(e,t,i,r,n){return this._currentFrame=e,this._animation.dataType!==Ze.Animation.ANIMATIONTYPE_MATRIX||this._workValue||(this._workValue=Ze.Matrix.Zero()),this._animation._interpolate(e,t,this._workValue,i,r,n)},e.prototype.setValue=function(e,t){if(void 0===t&&(t=1),this._target instanceof Array)for(var i=0,r=0,n=this._target;r<n.length;r++){var o=n[r];this._setValue(o,e,t,i),i++}else this._setValue(this._target,e,t)},e.prototype._setValue=function(e,t,i,r){var n,o;void 0===r&&(r=0);var s=this._animation.targetPropertyPath;if(1<s.length){for(var a=e[s[0]],l=1;l<s.length-1;l++)a=a[s[l]];n=s[s.length-1],o=a}else n=s[0],o=e;if(this._targetPath=n,this._activeTarget=o,this._weight=i,void 0===this._originalValue[r]){var c=void 0;(c=o.getRestPose&&"_matrix"===n?o.getRestPose():o[n])&&c.clone?this._originalValue[r]=c.clone():this._originalValue[r]=c}if((e&&e.animationPropertiesOverride?e.animationPropertiesOverride.enableBlending:this._animation.enableBlending)&&this._blendingFactor<=1){if(!this._originalBlendValue)(c=o[n]).clone?this._originalBlendValue=c.clone():this._originalBlendValue=c;this._originalBlendValue.m?Ze.Animation.AllowMatrixDecomposeForInterpolation?this._currentValue?Ze.Matrix.DecomposeLerpToRef(this._originalBlendValue,t,this._blendingFactor,this._currentValue):this._currentValue=Ze.Matrix.DecomposeLerp(this._originalBlendValue,t,this._blendingFactor):this._currentValue?Ze.Matrix.LerpToRef(this._originalBlendValue,t,this._blendingFactor,this._currentValue):this._currentValue=Ze.Matrix.Lerp(this._originalBlendValue,t,this._blendingFactor):this._currentValue=Ze.Animation._UniversalLerp(this._originalBlendValue,t,this._blendingFactor);var h=e&&e.animationPropertiesOverride?e.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=h}else this._currentValue=t;-1!==i?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[r]):o[n]=this._currentValue,e.markAsDirty&&e.markAsDirty(this._animation.targetProperty)},e.prototype._getCorrectLoopMode=function(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode},e.prototype.goToFrame=function(e){var t=this._animation.getKeys();e<t[0].frame?e=t[0].frame:e>t[t.length-1].frame&&(e=t[t.length-1].frame);var i=this._interpolate(e,0,this._getCorrectLoopMode());this.setValue(i,-1)},e.prototype._prepareForSpeedRatioChange=function(e){var t=this._previousDelay*(this._animation.framePerSecond*e)/1e3;this._ratioOffset=this._previousRatio-t},e.prototype.animate=function(e,t,i,r,n,o){void 0===o&&(o=-1);var s=this._animation.targetPropertyPath;if(!s||s.length<1)return!(this._stopped=!0);var a=!0,l=this._animation.getKeys();if(0!==l[0].frame){var c={frame:0,value:l[0].value};l.splice(0,0,c)}else if(1===l.length){c={frame:.001,value:l[0].value};l.push(c)}(t<l[0].frame||t>l[l.length-1].frame)&&(t=l[0].frame),(i<l[0].frame||i>l[l.length-1].frame)&&(i=l[l.length-1].frame),t===i&&(t>l[0].frame?t--:i<l[l.length-1].frame&&i++);var h,u=i-t,d=e*(this._animation.framePerSecond*n)/1e3+this._ratioOffset,f=0;if(this._previousDelay=e,this._previousRatio=d,(t<i&&u<=d||i<t&&d<=u)&&!r)a=!1,f=this._animation._getKeyValue(l[l.length-1].value);else if(this._getCorrectLoopMode()!==Ze.Animation.ANIMATIONLOOPMODE_CYCLE){var p=i.toString()+t.toString();if(!this._offsetsCache[p]){var m=this._interpolate(t,0,Ze.Animation.ANIMATIONLOOPMODE_CYCLE),_=this._interpolate(i,0,Ze.Animation.ANIMATIONLOOPMODE_CYCLE);switch(this._animation.dataType){case Ze.Animation.ANIMATIONTYPE_FLOAT:this._offsetsCache[p]=_-m;break;case Ze.Animation.ANIMATIONTYPE_QUATERNION:this._offsetsCache[p]=_.subtract(m);break;case Ze.Animation.ANIMATIONTYPE_VECTOR3:this._offsetsCache[p]=_.subtract(m);case Ze.Animation.ANIMATIONTYPE_VECTOR2:this._offsetsCache[p]=_.subtract(m);case Ze.Animation.ANIMATIONTYPE_SIZE:this._offsetsCache[p]=_.subtract(m);case Ze.Animation.ANIMATIONTYPE_COLOR3:this._offsetsCache[p]=_.subtract(m)}this._highLimitsCache[p]=_}f=this._highLimitsCache[p],h=this._offsetsCache[p]}if(void 0===h)switch(this._animation.dataType){case Ze.Animation.ANIMATIONTYPE_FLOAT:h=0;break;case Ze.Animation.ANIMATIONTYPE_QUATERNION:h=qe;break;case Ze.Animation.ANIMATIONTYPE_VECTOR3:h=Je;break;case Ze.Animation.ANIMATIONTYPE_VECTOR2:h=$e;break;case Ze.Animation.ANIMATIONTYPE_SIZE:h=et;break;case Ze.Animation.ANIMATIONTYPE_COLOR3:h=tt}var g=d/u>>0,v=a?t+d%u:i;if(this._host&&this._host.syncRoot){var y=this._host.syncRoot;v=t+(i-t)*((y.masterFrame-y.fromFrame)/(y.toFrame-y.fromFrame))}var b=this._events;if(0<u&&this.currentFrame>v||u<0&&this.currentFrame<v)for(var T=0;T<b.length;T++)b[T].onlyOnce||(b[T].isDone=!1);var x=this._interpolate(v,g,this._getCorrectLoopMode(),h,f);this.setValue(x,o);for(T=0;T<b.length;T++)if(0<u&&v>=b[T].frame&&b[T].frame>=t||u<0&&v<=b[T].frame&&b[T].frame<=t){var E=b[T];E.isDone||(E.onlyOnce&&(b.splice(T,1),T--),E.isDone=!0,E.action(v))}return a||(this._stopped=!0),a},e})(),Ze.RuntimeAnimation=it,rt=$a||($a={}),nt=(function(){function e(e,t,i,r,n,o,s,a){void 0===i&&(i=0),void 0===r&&(r=100),void 0===n&&(n=!1),void 0===o&&(o=1),this.target=t,this.fromFrame=i,this.toFrame=r,this.loopAnimation=n,this.onAnimationEnd=s,this._localDelayOffset=null,this._pausedDelay=null,this._runtimeAnimations=new Array,this._paused=!1,this._speedRatio=1,this._weight=-1,this.disposeOnEnd=!0,this.animationStarted=!1,this.onAnimationEndObservable=new rt.Observable,this._scene=e,a&&this.appendAnimations(t,a),this._speedRatio=o,e._activeAnimatables.push(this)}return Object.defineProperty(e.prototype,"syncRoot",{get:function(){return this._syncRoot},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"masterFrame",{get:function(){return 0===this._runtimeAnimations.length?0:this._runtimeAnimations[0].currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._weight},set:function(e){this._weight=-1!==e?Math.min(Math.max(e,0),1):-1},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"speedRatio",{get:function(){return this._speedRatio},set:function(e){for(var t=0;t<this._runtimeAnimations.length;t++){this._runtimeAnimations[t]._prepareForSpeedRatioChange(e)}this._speedRatio=e},enumerable:!0,configurable:!0}),e.prototype.syncWith=function(e){if(this._syncRoot=e){var t=this._scene._activeAnimatables.indexOf(this);-1<t&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this},e.prototype.getAnimations=function(){return this._runtimeAnimations},e.prototype.appendAnimations=function(e,t){for(var i=0;i<t.length;i++){var r=t[i];this._runtimeAnimations.push(new rt.RuntimeAnimation(e,r,this._scene,this))}},e.prototype.getAnimationByTargetProperty=function(e){for(var t=this._runtimeAnimations,i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i].animation;return null},e.prototype.getRuntimeAnimationByTargetProperty=function(e){for(var t=this._runtimeAnimations,i=0;i<t.length;i++)if(t[i].animation.targetProperty===e)return t[i];return null},e.prototype.reset=function(){for(var e=this._runtimeAnimations,t=0;t<e.length;t++)e[t].reset(!0);this._localDelayOffset=null,this._pausedDelay=null},e.prototype.enableBlending=function(e){for(var t=this._runtimeAnimations,i=0;i<t.length;i++)t[i].animation.enableBlending=!0,t[i].animation.blendingSpeed=e},e.prototype.disableBlending=function(){for(var e=this._runtimeAnimations,t=0;t<e.length;t++)e[t].animation.enableBlending=!1},e.prototype.goToFrame=function(e){var t=this._runtimeAnimations;if(t[0]){var i=t[0].animation.framePerSecond,r=1e3*(e-t[0].currentFrame)/(i*this.speedRatio);null===this._localDelayOffset&&(this._localDelayOffset=0),this._localDelayOffset-=r}for(var n=0;n<t.length;n++)t[n].goToFrame(e)},e.prototype.pause=function(){this._paused||(this._paused=!0)},e.prototype.restart=function(){this._paused=!1},e.prototype._raiseOnAnimationEnd=function(){this.onAnimationEnd&&this.onAnimationEnd(),this.onAnimationEndObservable.notifyObservers(this)},e.prototype.stop=function(e,t){if(e||t){var i=this._scene._activeAnimatables.indexOf(this);if(-1<i){for(var r=(o=this._runtimeAnimations).length-1;0<=r;r--){var n=o[r];e&&n.animation.name!=e||(t&&!t(n.target)||(n.dispose(),o.splice(r,1)))}0==o.length&&(this._scene._activeAnimatables.splice(i,1),this._raiseOnAnimationEnd())}}else{if(-1<(r=this._scene._activeAnimatables.indexOf(this))){this._scene._activeAnimatables.splice(r,1);var o=this._runtimeAnimations;for(r=0;r<o.length;r++)o[r].dispose();this._raiseOnAnimationEnd()}}},e.prototype.waitAsync=function(){var i=this;return new Promise(function(e,t){i.onAnimationEndObservable.add((function(){e(i)}),void 0,void 0,i,!0)})},e.prototype._animate=function(e){if(this._paused)return this.animationStarted=!1,null===this._pausedDelay&&(this._pausedDelay=e),!0;if(null===this._localDelayOffset?(this._localDelayOffset=e,this._pausedDelay=null):null!==this._pausedDelay&&(this._localDelayOffset+=e-this._pausedDelay,this._pausedDelay=null),0===this._weight)return!0;var t,i=!1,r=this._runtimeAnimations;for(t=0;t<r.length;t++){var n=r[t].animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);i=i||n}if(!(this.animationStarted=i)){if(this.disposeOnEnd)for(t=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(t,1),t=0;t<r.length;t++)r[t].dispose();this._raiseOnAnimationEnd(),this.disposeOnEnd&&(this.onAnimationEnd=null,this.onAnimationEndObservable.clear())}return i},e})(),rt.Animatable=nt,(function(t){var e=(function(){function t(){this._easingMode=t.EASINGMODE_EASEIN}return t.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},t.prototype.getEasingMode=function(){return this._easingMode},t.prototype.easeInCore=function(e){throw new Error("You must implement this method")},t.prototype.ease=function(e){switch(this._easingMode){case t.EASINGMODE_EASEIN:return this.easeInCore(e);case t.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-e)}return.5<=e?.5*(1-this.easeInCore(2*(1-e)))+.5:.5*this.easeInCore(2*e)},t.EASINGMODE_EASEIN=0,t.EASINGMODE_EASEOUT=1,t.EASINGMODE_EASEINOUT=2,t})(),i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t.EasingFunction=e);t.CircleEase=i;var r=(function(i){function e(e){void 0===e&&(e=1);var t=i.call(this)||this;return t.amplitude=e,t}return T(e,i),e.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},e})(e);t.BackEase=r;var n=(function(r){function e(e,t){void 0===e&&(e=3),void 0===t&&(t=2);var i=r.call(this)||this;return i.bounces=e,i.bounciness=t,i}return T(e,r),e.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),l=Math.floor(a),c=l+1,h=(1-Math.pow(i,l))/(n*o),u=.5*(h+(1-Math.pow(i,c))/(n*o)),d=e-u,f=u-h;return-Math.pow(1/i,t-l)/(f*f)*(d-f)*(d+f)},e})(e);t.BounceEase=n;var o=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(e);t.CubicEase=o;var s=(function(r){function e(e,t){void 0===e&&(e=3),void 0===t&&(t=3);var i=r.call(this)||this;return i.oscillations=e,i.springiness=t,i}return T(e,r),e.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},e})(e);t.ElasticEase=s;var a=(function(i){function e(e){void 0===e&&(e=2);var t=i.call(this)||this;return t.exponent=e,t}return T(e,i),e.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},e})(e);t.ExponentialEase=a;var l=(function(i){function e(e){void 0===e&&(e=2);var t=i.call(this)||this;return t.power=e,t}return T(e,i),e.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},e})(e);t.PowerEase=l;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.easeInCore=function(e){return e*e},t})(e);t.QuadraticEase=c;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(e);t.QuarticEase=h;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(e);t.QuinticEase=u;var d=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(e);t.SineEase=d;var f=(function(o){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=1),void 0===r&&(r=1);var n=o.call(this)||this;return n.x1=e,n.y1=t,n.x2=i,n.y2=r,n}return T(e,o),e.prototype.easeInCore=function(e){return t.BezierCurve.Interpolate(e,this.x1,this.y1,this.x2,this.y2)},e})(e);t.BezierCurveEase=f})($a||($a={})),(function(t){var e=(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})(),i=(function(s){function a(e,t,i,r,n){void 0===n&&(n=a.IsEqual);var o=s.call(this,e)||this;return o.propertyPath=i,o.value=r,o.operator=n,o._target=t,o._effectiveTarget=o._getEffectiveTarget(t,o.propertyPath),o._property=o._getProperty(o.propertyPath),o}return T(a,s),Object.defineProperty(a,"IsEqual",{get:function(){return a._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(a,"IsDifferent",{get:function(){return a._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(a,"IsGreater",{get:function(){return a._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(a,"IsLesser",{get:function(){return a._IsLesser},enumerable:!0,configurable:!0}),a.prototype.isValid=function(){switch(this.operator){case a.IsGreater:return this._effectiveTarget[this._property]>this.value;case a.IsLesser:return this._effectiveTarget[this._property]<this.value;case a.IsEqual:case a.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===a.IsEqual?e:!e}return!1},a.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[t.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:t.Action._SerializeValueAsString(this.value)},{name:"operator",value:a.GetOperatorName(this.operator)}]})},a.GetOperatorName=function(e){switch(e){case a._IsEqual:return"IsEqual";case a._IsDifferent:return"IsDifferent";case a._IsGreater:return"IsGreater";case a._IsLesser:return"IsLesser";default:return""}},a._IsEqual=0,a._IsDifferent=1,a._IsGreater=2,a._IsLesser=3,a})(t.Condition=e);t.ValueCondition=i;var r=(function(r){function e(e,t){var i=r.call(this,e)||this;return i.predicate=t,i}return T(e,r),e.prototype.isValid=function(){return this.predicate()},e})(e);t.PredicateCondition=r;var n=(function(n){function e(e,t,i){var r=n.call(this,e)||this;return r.value=i,r._target=t,r}return T(e,n),e.prototype.isValid=function(){return this._target.state===this.value},e.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[t.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]})},e})(e);t.StateCondition=n})($a||($a={})),ot=$a||($a={}),st=(function(){function e(e,t){this.triggerOptions=e,this.onBeforeExecuteObservable=new ot.Observable,e.parameter?(this.trigger=e.trigger,this._triggerParameter=e.parameter):e.trigger?this.trigger=e.trigger:this.trigger=e,(this._nextActiveAction=this)._condition=t}return e.prototype._prepare=function(){},e.prototype.getTriggerParameter=function(){return this._triggerParameter},e.prototype._executeCurrent=function(e){if(this._nextActiveAction._condition){var t=this._nextActiveAction._condition,i=this._actionManager.getScene().getRenderId();if(t._evaluationId===i){if(!t._currentResult)return}else{if(t._evaluationId=i,!t.isValid())return void(t._currentResult=!1);t._currentResult=!0}}this.onBeforeExecuteObservable.notifyObservers(this),this._nextActiveAction.execute(e),this.skipToNextActiveAction()},e.prototype.execute=function(e){},e.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},e.prototype.then=function(e){return(this._child=e)._actionManager=this._actionManager,e._prepare(),e},e.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},e.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},e.prototype.serialize=function(e){},e.prototype._serialize=function(e,t){var i={type:1,children:[],name:e.name,properties:e.properties||[]};if(this._child&&this._child.serialize(i),this._condition){var r=this._condition.serialize();return r.children.push(i),t&&t.children.push(r),r}return t&&t.children.push(i),i},e._SerializeValueAsString=function(e){return"number"==typeof e?e.toString():"boolean"==typeof e?e?"true":"false":e instanceof ot.Vector2?e.x+", "+e.y:e instanceof ot.Vector3?e.x+", "+e.y+", "+e.z:e instanceof ot.Color3?e.r+", "+e.g+", "+e.b:e instanceof ot.Color4?e.r+", "+e.g+", "+e.b+", "+e.a:e},e._GetTargetProperty=function(e){return{name:"target",targetType:e instanceof ot.Mesh?"MeshProperties":e instanceof ot.Light?"LightProperties":e instanceof ot.Camera?"CameraProperties":"SceneProperties",value:e instanceof ot.Scene?"Scene":e.name}},e})(),ot.Action=st,(function(S){var e=(function(){function n(e,t,i,r,n,o){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=o}return n.CreateNew=function(e,t,i){var r=e.getScene();return new n(e,r.pointerX,r.pointerY,r.meshUnderPointer,t,i)},n.CreateNewFromSprite=function(e,t,i,r){return new n(e,t.pointerX,t.pointerY,t.meshUnderPointer,i,r)},n.CreateNewFromScene=function(e,t){return new n(null,e.pointerX,e.pointerY,e.meshUnderPointer,t)},n.CreateNewFromPrimitive=function(e,t,i,r){return new n(e,t.x,t.y,null,i,r)},n})();S.ActionEvent=e;var t=(function(){function P(e){this.actions=new Array,this.hoverCursor="",this._scene=e||S.Engine.LastCreatedScene,e.actionManagers.push(this)}return P.prototype.dispose=function(){for(var e=this._scene.actionManagers.indexOf(this),t=0;t<this.actions.length;t++){var i=this.actions[t];P.Triggers[i.trigger]--,0===P.Triggers[i.trigger]&&delete P.Triggers[i.trigger]}-1<e&&this._scene.actionManagers.splice(e,1)},P.prototype.getScene=function(){return this._scene},P.prototype.hasSpecificTriggers=function(e){for(var t=0;t<this.actions.length;t++){var i=this.actions[t];if(-1<e.indexOf(i.trigger))return!0}return!1},P.prototype.hasSpecificTriggers2=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(e==r.trigger||t==r.trigger)return!0}return!1},P.prototype.hasSpecificTrigger=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(r.trigger===e){if(!t)return!0;if(t(r.getTriggerParameter()))return!0}}return!1},Object.defineProperty(P.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var t=this.actions[e];if(t.trigger>=P.OnPickTrigger&&t.trigger<=P.OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(P.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var t=this.actions[e];if(t.trigger>=P.OnPickTrigger&&t.trigger<=P.OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(P,"HasTriggers",{get:function(){for(var e in P.Triggers)if(P.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(P,"HasPickTriggers",{get:function(){for(var e in P.Triggers)if(P.Triggers.hasOwnProperty(e)){var t=parseInt(e);if(P.OnPickTrigger<=t&&t<=P.OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),P.HasSpecificTrigger=function(e){for(var t in P.Triggers){if(P.Triggers.hasOwnProperty(t))if(parseInt(t)===e)return!0}return!1},P.prototype.registerAction=function(e){return e.trigger===P.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(S.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(e),P.Triggers[e.trigger]?P.Triggers[e.trigger]++:P.Triggers[e.trigger]=1,e._actionManager=this,e._prepare(),e)},P.prototype.unregisterAction=function(e){var t=this.actions.indexOf(e);return-1!==t&&(this.actions.splice(t,1),P.Triggers[e.trigger]-=1,0===P.Triggers[e.trigger]&&delete P.Triggers[e.trigger],delete e._actionManager,!0)},P.prototype.processTrigger=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(r.trigger===e){if(t&&(e===P.OnKeyUpTrigger||e===P.OnKeyDownTrigger)){var n=r.getTriggerParameter();if(n&&n!==t.sourceEvent.keyCode){if(!n.toLowerCase)continue;var o=n.toLowerCase();if(o!==t.sourceEvent.key){var s=t.sourceEvent.charCode?t.sourceEvent.charCode:t.sourceEvent.keyCode;if(String.fromCharCode(s).toLowerCase()!==o)continue}}}r._executeCurrent(t)}}},P.prototype._getEffectiveTarget=function(e,t){for(var i=t.split("."),r=0;r<i.length-1;r++)e=e[i[r]];return e},P.prototype._getProperty=function(e){var t=e.split(".");return t[t.length-1]},P.prototype.serialize=function(e){for(var t={children:new Array,name:e,type:3,properties:new Array},i=0;i<this.actions.length;i++){var r={type:0,children:new Array,name:P.GetTriggerName(this.actions[i].trigger),properties:new Array},n=this.actions[i].triggerOptions;if(n&&"number"!=typeof n)if(n.parameter instanceof S.Node)r.properties.push(S.Action._GetTargetProperty(n.parameter));else{var o={};S.Tools.DeepCopy(n.parameter,o,["mesh"]),n.parameter&&n.parameter.mesh&&(o._meshId=n.parameter.mesh.id),r.properties.push({name:"parameter",targetType:null,value:o})}this.actions[i].serialize(r),t.children.push(r)}return t},P.Parse=function(e,t,T){var x=new P(T);null===t?T.actionManager=x:t.actionManager=x;for(var E=function(e,t,i,r){if(null===r){var n=parseFloat(t);return"true"===t||"false"===t?"true"===t:isNaN(n)?t:n}for(var o=r.split("."),s=t.split(","),a=0;a<o.length;a++)i=i[o[a]];if("boolean"==typeof i)return"true"===s[0];if("string"==typeof i)return s[0];var l=new Array;for(a=0;a<s.length;a++)l.push(parseFloat(s[a]));return i instanceof S.Vector3?S.Vector3.FromArray(l):i instanceof S.Vector4?S.Vector4.FromArray(l):i instanceof S.Color3?S.Color3.FromArray(l):i instanceof S.Color4?S.Color4.FromArray(l):parseFloat(s[0])},A=function(e,t,i,r,n){if(void 0===n&&(n=null),!e.detached){var o=new Array,s=null,a=null,l=e.combine&&0<e.combine.length;if(2===e.type?o.push(x):o.push(t),l){for(var c=new Array,h=0;h<e.combine.length;h++)A(e.combine[h],P.NothingTrigger,i,r,c);o.push(c)}else for(var u=0;u<e.properties.length;u++){var d=e.properties[u].value,f=e.properties[u].name,p=e.properties[u].targetType;"target"===f?d=s=null!==p&&"SceneProperties"===p?T:T.getNodeByName(d):"parent"===f?d=T.getNodeByName(d):"sound"===f?T.getSoundByName&&(d=T.getSoundByName(d)):"propertyPath"!==f?d=2===e.type&&"operator"===f?S.ValueCondition[d]:E(0,d,s,"value"===f?a:null):a=d,o.push(d)}if(null===n?o.push(i):o.push(null),"InterpolateValueAction"===e.name){var m=o[o.length-2];o[o.length-1]=m,o[o.length-2]=i}var _,g,v,y=(_=e.name,g=o,(v=Object.create(S.Tools.Instantiate("BABYLON."+_).prototype)).constructor.apply(v,g),v);if(y instanceof S.Condition&&null!==i){var b=new S.DoNothingAction(t,i);r?r.then(b):x.registerAction(b),r=b}null===n?y instanceof S.Condition?(i=y,y=r):(i=null,r?r.then(y):x.registerAction(y)):n.push(y);for(u=0;u<e.children.length;u++)A(e.children[u],t,i,y,null)}},i=0;i<e.children.length;i++){var r,n=e.children[i];if(0<n.properties.length){var o=n.properties[0].value,s=null===n.properties[0].targetType?o:T.getMeshByName(o);s._meshId&&(s.mesh=T.getMeshByID(s._meshId)),r={trigger:P[n.name],parameter:s}}else r=P[n.name];for(var a=0;a<n.children.length;a++)n.detached||A(n.children[a],r,null,null)}},P.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},P.NothingTrigger=0,P.OnPickTrigger=1,P.OnLeftPickTrigger=2,P.OnRightPickTrigger=3,P.OnCenterPickTrigger=4,P.OnPickDownTrigger=5,P.OnDoublePickTrigger=6,P.OnPickUpTrigger=7,P.OnPickOutTrigger=16,P.OnLongPressTrigger=8,P.OnPointerOverTrigger=9,P.OnPointerOutTrigger=10,P.OnEveryFrameTrigger=11,P.OnIntersectionEnterTrigger=12,P.OnIntersectionExitTrigger=13,P.OnKeyDownTrigger=14,P.OnKeyUpTrigger=15,P.Triggers={},P})();S.ActionManager=t})($a||($a={})),at=$a||($a={}),lt=(function(c){function e(e,t,i,r,n,o,s,a){void 0===n&&(n=1e3);var l=c.call(this,e,o)||this;return l.duration=1e3,l.onInterpolationDoneObservable=new at.Observable,l.propertyPath=i,l.value=r,l.duration=n,l.stopOtherAnimations=s,l.onInterpolationDone=a,l._target=l._effectiveTarget=t,l}return T(e,c),e.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},e.prototype.execute=function(){var e,t=this,i=this._actionManager.getScene(),r=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)e=at.Animation.ANIMATIONTYPE_FLOAT;else if(this.value instanceof at.Color3)e=at.Animation.ANIMATIONTYPE_COLOR3;else if(this.value instanceof at.Vector3)e=at.Animation.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof at.Matrix)e=at.Animation.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof at.Quaternion))return void at.Tools.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");e=at.Animation.ANIMATIONTYPE_QUATERNION}var n=new at.Animation("InterpolateValueAction",this._property,1e3/this.duration*100,e,at.Animation.ANIMATIONLOOPMODE_CONSTANT);n.setKeys(r),this.stopOtherAnimations&&i.stopAnimation(this._effectiveTarget);i.beginDirectAnimation(this._effectiveTarget,[n],0,100,!1,1,(function(){t.onInterpolationDoneObservable.notifyObservers(t),t.onInterpolationDone&&t.onInterpolationDone()}))},e.prototype.serialize=function(e){return c.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[at.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:at.Action._SerializeValueAsString(this.value)},{name:"duration",value:at.Action._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:at.Action._SerializeValueAsString(this.stopOtherAnimations)||!1}]},e)},e})(at.Action),at.InterpolateValueAction=lt,(function(r){var e=(function(o){function e(e,t,i,r){var n=o.call(this,e,r)||this;return n.propertyPath=i,n._target=n._effectiveTarget=t,n}return T(e,o),e.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},e.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},e.prototype.serialize=function(e){return o.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[r.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},e)},e})(r.Action);r.SwitchBooleanAction=e;var t=(function(o){function e(e,t,i,r){var n=o.call(this,e,r)||this;return n.value=i,n._target=t,n}return T(e,o),e.prototype.execute=function(){this._target.state=this.value},e.prototype.serialize=function(e){return o.prototype._serialize.call(this,{name:"SetStateAction",properties:[r.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]},e)},e})(r.Action);r.SetStateAction=t;var i=(function(s){function e(e,t,i,r,n){var o=s.call(this,e,n)||this;return o.propertyPath=i,o.value=r,o._target=o._effectiveTarget=t,o}return T(e,s),e.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},e.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},e.prototype.serialize=function(e){return s.prototype._serialize.call(this,{name:"SetValueAction",properties:[r.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:r.Action._SerializeValueAsString(this.value)}]},e)},e})(r.Action);r.SetValueAction=i;var n=(function(s){function e(e,t,i,r,n){var o=s.call(this,e,n)||this;return o.propertyPath=i,o.value=r,o._target=o._effectiveTarget=t,o}return T(e,s),e.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&r.Tools.Warn("Warning: IncrementValueAction can only be used with number values")},e.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},e.prototype.serialize=function(e){return s.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[r.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:r.Action._SerializeValueAsString(this.value)}]},e)},e})(r.Action);r.IncrementValueAction=n;var o=(function(a){function e(e,t,i,r,n,o){var s=a.call(this,e,o)||this;return s.from=i,s.to=r,s.loop=n,s._target=t,s}return T(e,a),e.prototype._prepare=function(){},e.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},e.prototype.serialize=function(e){return a.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[r.Action._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:r.Action._SerializeValueAsString(this.loop)||!1}]},e)},e})(r.Action);r.PlayAnimationAction=o;var s=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r._target=t,r}return T(e,n),e.prototype._prepare=function(){},e.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},e.prototype.serialize=function(e){return n.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[r.Action._GetTargetProperty(this._target)]},e)},e})(r.Action);r.StopAnimationAction=s;var a=(function(i){function e(e,t){return void 0===e&&(e=r.ActionManager.NothingTrigger),i.call(this,e,t)||this}return T(e,i),e.prototype.execute=function(){},e.prototype.serialize=function(e){return i.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},e)},e})(r.Action);r.DoNothingAction=a;var l=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r.children=t,r}return T(e,n),e.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},e.prototype.execute=function(e){for(var t=0;t<this.children.length;t++)this.children[t].execute(e)},e.prototype.serialize=function(e){for(var t=n.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},e),i=0;i<this.children.length;i++)t.combine.push(this.children[i].serialize(null));return t},e})(r.Action);r.CombineAction=l;var c=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r.func=t,r}return T(e,n),e.prototype.execute=function(e){this.func(e)},e})(r.Action);r.ExecuteCodeAction=c;var h=(function(o){function e(e,t,i,r){var n=o.call(this,e,r)||this;return n._target=t,n._parent=i,n}return T(e,o),e.prototype._prepare=function(){},e.prototype.execute=function(){if(this._target.parent!==this._parent){var e=this._parent.getWorldMatrix().clone();e.invert(),this._target.position=r.Vector3.TransformCoordinates(this._target.position,e),this._target.parent=this._parent}},e.prototype.serialize=function(e){return o.prototype._serialize.call(this,{name:"SetParentAction",properties:[r.Action._GetTargetProperty(this._target),r.Action._GetTargetProperty(this._parent)]},e)},e})(r.Action);r.SetParentAction=h})($a||($a={})),ct=$a||($a={}),ht=(function(){function e(e,t,i,r,n,o,s){if(void 0===o&&(o=.01),void 0===s&&(s=ct.Texture.TRILINEAR_SAMPLINGMODE),this.name=e,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this.onDisposeObservable=new ct.Observable,this._vertexBuffers={},n._getComponent(ct.SceneComponentConstants.NAME_SPRITE)||n._addComponent(new ct.SpriteSceneComponent(n)),this._capacity=i,this._spriteTexture=new ct.Texture(t,n,!0,!1,s),this._spriteTexture.wrapU=ct.Texture.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=ct.Texture.CLAMP_ADDRESSMODE,r.width&&r.height)this.cellWidth=r.width,this.cellHeight=r.height;else{if(void 0===r)return;this.cellWidth=r,this.cellHeight=r}this._epsilon=o,this._scene=n,this._scene.spriteManagers.push(this);for(var a=[],l=0,c=0;c<i;c++)a.push(l),a.push(l+1),a.push(l+2),a.push(l),a.push(l+2),a.push(l+3),l+=4;this._indexBuffer=n.getEngine().createIndexBuffer(a),this._vertexData=new Float32Array(16*i*4),this._buffer=new ct.Buffer(n.getEngine(),this._vertexData,!0,16);var h=this._buffer.createVertexBuffer(ct.VertexBuffer.PositionKind,0,4),u=this._buffer.createVertexBuffer("options",4,4),d=this._buffer.createVertexBuffer("cellInfo",8,4),f=this._buffer.createVertexBuffer(ct.VertexBuffer.ColorKind,12,4);this._vertexBuffers[ct.VertexBuffer.PositionKind]=h,this._vertexBuffers.options=u,this._vertexBuffers.cellInfo=d,this._vertexBuffers[ct.VertexBuffer.ColorKind]=f,this._effectBase=this._scene.getEngine().createEffect("sprites",[ct.VertexBuffer.PositionKind,"options","cellInfo",ct.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._effectFog=this._scene.getEngine().createEffect("sprites",[ct.VertexBuffer.PositionKind,"options","cellInfo",ct.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG")}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"texture",{get:function(){return this._spriteTexture},set:function(e){this._spriteTexture=e},enumerable:!0,configurable:!0}),e.prototype._appendSpriteVertex=function(e,t,i,r,n){var o=16*e;0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon),this._vertexData[o]=t.position.x,this._vertexData[o+1]=t.position.y,this._vertexData[o+2]=t.position.z,this._vertexData[o+3]=t.angle,this._vertexData[o+4]=t.width,this._vertexData[o+5]=t.height,this._vertexData[o+6]=i,this._vertexData[o+7]=r,this._vertexData[o+8]=t.invertU?1:0,this._vertexData[o+9]=t.invertV?1:0;var s=t.cellIndex/n>>0;this._vertexData[o+10]=t.cellIndex-s*n,this._vertexData[o+11]=s,this._vertexData[o+12]=t.color.r,this._vertexData[o+13]=t.color.g,this._vertexData[o+14]=t.color.b,this._vertexData[o+15]=t.color.a},e.prototype.intersects=function(e,t,i,r){for(var n=Math.min(this._capacity,this.sprites.length),o=ct.Vector3.Zero(),s=ct.Vector3.Zero(),a=Number.MAX_VALUE,l=null,c=ct.Vector3.Zero(),h=t.getViewMatrix(),u=0;u<n;u++){var d=this.sprites[u];if(d){if(i){if(!i(d))continue}else if(!d.isPickable)continue;if(ct.Vector3.TransformCoordinatesToRef(d.position,h,c),o.copyFromFloats(c.x-d.width/2,c.y-d.height/2,c.z),s.copyFromFloats(c.x+d.width/2,c.y+d.height/2,c.z),e.intersectsBoxMinMax(o,s)){var f=ct.Vector3.Distance(c,e.origin);if(f<a&&(a=f,l=d,r))break}}}if(l){var p=new ct.PickingInfo;return p.hit=!0,p.pickedSprite=l,p.distance=a,p}return null},e.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var e=this._scene.getEngine(),t=this._spriteTexture.getBaseSize(),i=e.getDeltaTime(),r=Math.min(this._capacity,this.sprites.length),n=t.width/this.cellWidth,o=0,s=0;s<r;s++){var a=this.sprites[s];a&&a.isVisible&&(a._animate(i),this._appendSpriteVertex(o++,a,0,0,n),this._appendSpriteVertex(o++,a,1,0,n),this._appendSpriteVertex(o++,a,1,1,n),this._appendSpriteVertex(o++,a,0,1,n))}this._buffer.update(this._vertexData);var l=this._effectBase;this._scene.fogEnabled&&this._scene.fogMode!==ct.Scene.FOGMODE_NONE&&this.fogEnabled&&(l=this._effectFog),e.enableEffect(l);var c=this._scene.getViewMatrix();l.setTexture("diffuseSampler",this._spriteTexture),l.setMatrix("view",c),l.setMatrix("projection",this._scene.getProjectionMatrix()),l.setFloat2("textureInfos",this.cellWidth/t.width,this.cellHeight/t.height),this._scene.fogEnabled&&this._scene.fogMode!==ct.Scene.FOGMODE_NONE&&this.fogEnabled&&(l.setFloat4("vFogInfos",this._scene.fogMode,this._scene.fogStart,this._scene.fogEnd,this._scene.fogDensity),l.setColor3("vFogColor",this._scene.fogColor)),e.bindBuffers(this._vertexBuffers,this._indexBuffer,l),e.setDepthFunctionToLessOrEqual(),l.setBool("alphaTest",!0),e.setColorWrite(!1),e.drawElementsType(ct.Material.TriangleFillMode,0,o/4*6),e.setColorWrite(!0),l.setBool("alphaTest",!1),e.setAlphaMode(ct.Engine.ALPHA_COMBINE),e.drawElementsType(ct.Material.TriangleFillMode,0,o/4*6),e.setAlphaMode(ct.Engine.ALPHA_DISABLE)}},e.prototype.dispose=function(){this._buffer&&(this._buffer.dispose(),this._buffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._spriteTexture&&(this._spriteTexture.dispose(),this._spriteTexture=null);var e=this._scene.spriteManagers.indexOf(this);this._scene.spriteManagers.splice(e,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},e})(),ct.SpriteManager=ht,ut=$a||($a={}),dt=(function(){function e(e,t){this.name=e,this.color=new ut.Color4(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=ut.Vector3.Zero()}return Object.defineProperty(e.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),e.prototype.playAnimation=function(e,t,i,r,n){this._fromIndex=e,this._toIndex=t,this._loopAnimation=i,this._delay=r,this._animationStarted=!0,this._direction=e<t?1:-1,this.cellIndex=e,this._time=0,this._onAnimationEnd=n},e.prototype.stopAnimation=function(){this._animationStarted=!1},e.prototype._animate=function(e){this._animationStarted&&(this._time+=e,this._time>this._delay&&(this._time=this._time%this._delay,this.cellIndex+=this._direction,this.cellIndex>this._toIndex&&(this._loopAnimation?this.cellIndex=this._fromIndex:(this.cellIndex=this._toIndex,this._animationStarted=!1,this._onAnimationEnd&&this._onAnimationEnd(),this.disposeWhenFinishedAnimating&&this.dispose()))))},e.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1)},e})(),ut.Sprite=dt,(function(l){l.Scene.prototype._internalPickSprites=function(e,t,i,r){if(!l.PickingInfo)return null;var n=null;if(!r){if(!this.activeCamera)return null;r=this.activeCamera}if(0<this.spriteManagers.length)for(var o=0;o<this.spriteManagers.length;o++){var s=this.spriteManagers[o];if(s.isPickable){var a=s.intersects(e,r,t,i);if(a&&a.hit&&(i||null==n||!(a.distance>=n.distance))&&(n=a,i))break}}return n||new l.PickingInfo},l.Scene.prototype.pickSprite=function(e,t,i,r,n){return this.createPickingRayInCameraSpaceToRef(e,t,this._tempSpritePickingRay,n),this._internalPickSprites(this._tempSpritePickingRay,i,r,n)},l.Scene.prototype.pickSpriteWithRay=function(e,t,i,r){if(!this._tempSpritePickingRay)return null;if(!r){if(!this.activeCamera)return null;r=this.activeCamera}return l.Ray.TransformToRef(e,r.getViewMatrix(),this._tempSpritePickingRay),this._internalPickSprites(this._tempSpritePickingRay,t,i,r)},l.Scene.prototype.setPointerOverSprite=function(e){this._pointerOverSprite!==e&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(l.ActionManager.OnPointerOutTrigger,l.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=e,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(l.ActionManager.OnPointerOverTrigger,l.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},l.Scene.prototype.getPointerOverSprite=function(){return this._pointerOverSprite};var e=(function(){function e(e){this.name=l.SceneComponentConstants.NAME_SPRITE,this.scene=e,this.scene.spriteManagers=new Array,this.scene._tempSpritePickingRay=l.Ray?l.Ray.Zero():null,this.scene.onBeforeSpritesRenderingObservable=new l.Observable,this.scene.onAfterSpritesRenderingObservable=new l.Observable,this._spritePredicate=function(e){return!!e.actionManager&&(e.isPickable&&e.actionManager.hasPointerTriggers)}}return e.prototype.register=function(){this.scene._pointerMoveStage.registerStep(l.SceneComponentConstants.STEP_POINTERMOVE_SPRITE,this,this._pointerMove),this.scene._pointerDownStage.registerStep(l.SceneComponentConstants.STEP_POINTERDOWN_SPRITE,this,this._pointerDown),this.scene._pointerUpStage.registerStep(l.SceneComponentConstants.STEP_POINTERUP_SPRITE,this,this._pointerUp)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforeSpritesRenderingObservable.clear(),this.scene.onAfterSpritesRenderingObservable.clear();for(var e=this.scene.spriteManagers;e.length;)e[0].dispose()},e.prototype._pickSpriteButKeepRay=function(e,t,i,r,n){var o=this.scene.pickSprite(t,i,this._spritePredicate,r,n);return o&&(o.ray=e?e.ray:null),o},e.prototype._pointerMove=function(e,t,i,r,n){var o=this.scene;return r?o.setPointerOverSprite(null):(i=this._pickSpriteButKeepRay(i,e,t,!1,o.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite?(o.setPointerOverSprite(i.pickedSprite),o._pointerOverSprite&&o._pointerOverSprite.actionManager&&o._pointerOverSprite.actionManager.hoverCursor?n.style.cursor=o._pointerOverSprite.actionManager.hoverCursor:n.style.cursor=o.hoverCursor):o.setPointerOverSprite(null),i},e.prototype._pointerDown=function(e,t,i,r){var n=this.scene;if(n._pickedDownSprite=null,0<n.spriteManagers.length&&(i=n.pickSprite(e,t,this._spritePredicate,!1,n.cameraToUseForPointers||void 0))&&i.hit&&i.pickedSprite&&i.pickedSprite.actionManager){switch(n._pickedDownSprite=i.pickedSprite,r.button){case 0:i.pickedSprite.actionManager.processTrigger(l.ActionManager.OnLeftPickTrigger,l.ActionEvent.CreateNewFromSprite(i.pickedSprite,n,r));break;case 1:i.pickedSprite.actionManager.processTrigger(l.ActionManager.OnCenterPickTrigger,l.ActionEvent.CreateNewFromSprite(i.pickedSprite,n,r));break;case 2:i.pickedSprite.actionManager.processTrigger(l.ActionManager.OnRightPickTrigger,l.ActionEvent.CreateNewFromSprite(i.pickedSprite,n,r))}i.pickedSprite.actionManager&&i.pickedSprite.actionManager.processTrigger(l.ActionManager.OnPickDownTrigger,l.ActionEvent.CreateNewFromSprite(i.pickedSprite,n,r))}return i},e.prototype._pointerUp=function(e,t,i,r){var n=this.scene;if(0<n.spriteManagers.length){var o=n.pickSprite(e,t,this._spritePredicate,!1,n.cameraToUseForPointers||void 0);o&&(o.hit&&o.pickedSprite&&o.pickedSprite.actionManager&&(o.pickedSprite.actionManager.processTrigger(l.ActionManager.OnPickUpTrigger,l.ActionEvent.CreateNewFromSprite(o.pickedSprite,n,r)),o.pickedSprite.actionManager&&(this.scene._isPointerSwiping()||o.pickedSprite.actionManager.processTrigger(l.ActionManager.OnPickTrigger,l.ActionEvent.CreateNewFromSprite(o.pickedSprite,n,r)))),n._pickedDownSprite&&n._pickedDownSprite.actionManager&&n._pickedDownSprite!==o.pickedSprite&&n._pickedDownSprite.actionManager.processTrigger(l.ActionManager.OnPickOutTrigger,l.ActionEvent.CreateNewFromSprite(n._pickedDownSprite,n,r)))}return i},e})();l.SpriteSceneComponent=e})($a||($a={})),(function(m){var e=function(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0};m.IntersectionInfo=e;var t=(function(){function e(){this.hit=!1,this.distance=0,this.pickedPoint=null,this.pickedMesh=null,this.bu=0,this.bv=0,this.faceId=-1,this.subMeshId=0,this.pickedSprite=null,this.originMesh=null,this.ray=null}return e.prototype.getNormal=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(m.VertexBuffer.NormalKind))return null;var i,r=this.pickedMesh.getIndices();if(!r)return null;if(t){var n=this.pickedMesh.getVerticesData(m.VertexBuffer.NormalKind),o=m.Vector3.FromArray(n,3*r[3*this.faceId]),s=m.Vector3.FromArray(n,3*r[3*this.faceId+1]),a=m.Vector3.FromArray(n,3*r[3*this.faceId+2]);o=o.scale(this.bu),s=s.scale(this.bv),a=a.scale(1-this.bu-this.bv),i=new m.Vector3(o.x+s.x+a.x,o.y+s.y+a.y,o.z+s.z+a.z)}else{var l=this.pickedMesh.getVerticesData(m.VertexBuffer.PositionKind),c=m.Vector3.FromArray(l,3*r[3*this.faceId]),h=m.Vector3.FromArray(l,3*r[3*this.faceId+1]),u=m.Vector3.FromArray(l,3*r[3*this.faceId+2]),d=c.subtract(h),f=u.subtract(h);i=m.Vector3.Cross(d,f)}if(e){var p=this.pickedMesh.getWorldMatrix();this.pickedMesh.nonUniformScaling&&(m.Tmp.Matrix[0].copyFrom(p),(p=m.Tmp.Matrix[0]).setTranslationFromFloats(0,0,0),p.invert(),p.transposeToRef(m.Tmp.Matrix[1]),p=m.Tmp.Matrix[1]),i=m.Vector3.TransformNormal(i,p)}return i.normalize(),i},e.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(m.VertexBuffer.UVKind))return null;var e=this.pickedMesh.getIndices();if(!e)return null;var t=this.pickedMesh.getVerticesData(m.VertexBuffer.UVKind);if(!t)return null;var i=m.Vector2.FromArray(t,2*e[3*this.faceId]),r=m.Vector2.FromArray(t,2*e[3*this.faceId+1]),n=m.Vector2.FromArray(t,2*e[3*this.faceId+2]);return i=i.scale(1-this.bu-this.bv),r=r.scale(this.bu),n=n.scale(this.bv),new m.Vector2(i.x+r.x+n.x,i.y+r.y+n.y)},e})();m.PickingInfo=t})($a||($a={})),ft=$a||($a={}),pt=(function(){function T(e,t,i){void 0===i&&(i=Number.MAX_VALUE),this.origin=e,this.direction=t,this.length=i}return T.prototype.intersectsBoxMinMax=function(e,t){var i,r,n,o,s=0,a=Number.MAX_VALUE;if(Math.abs(this.direction.x)<1e-7){if(this.origin.x<e.x||this.origin.x>t.x)return!1}else if(i=1/this.direction.x,r=(e.x-this.origin.x)*i,(n=(t.x-this.origin.x)*i)===-1/0&&(n=1/0),n<r&&(o=r,r=n,n=o),s=Math.max(r,s),(a=Math.min(n,a))<s)return!1;if(Math.abs(this.direction.y)<1e-7){if(this.origin.y<e.y||this.origin.y>t.y)return!1}else if(i=1/this.direction.y,r=(e.y-this.origin.y)*i,(n=(t.y-this.origin.y)*i)===-1/0&&(n=1/0),n<r&&(o=r,r=n,n=o),s=Math.max(r,s),(a=Math.min(n,a))<s)return!1;if(Math.abs(this.direction.z)<1e-7){if(this.origin.z<e.z||this.origin.z>t.z)return!1}else if(i=1/this.direction.z,r=(e.z-this.origin.z)*i,(n=(t.z-this.origin.z)*i)===-1/0&&(n=1/0),n<r&&(o=r,r=n,n=o),s=Math.max(r,s),(a=Math.min(n,a))<s)return!1;return!0},T.prototype.intersectsBox=function(e){return this.intersectsBoxMinMax(e.minimum,e.maximum)},T.prototype.intersectsSphere=function(e){var t=e.center.x-this.origin.x,i=e.center.y-this.origin.y,r=e.center.z-this.origin.z,n=t*t+i*i+r*r,o=e.radius*e.radius;if(n<=o)return!0;var s=t*this.direction.x+i*this.direction.y+r*this.direction.z;return!(s<0)&&n-s*s<=o},T.prototype.intersectsTriangle=function(e,t,i){this._edge1||(this._edge1=ft.Vector3.Zero(),this._edge2=ft.Vector3.Zero(),this._pvec=ft.Vector3.Zero(),this._tvec=ft.Vector3.Zero(),this._qvec=ft.Vector3.Zero()),t.subtractToRef(e,this._edge1),i.subtractToRef(e,this._edge2),ft.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var r=ft.Vector3.Dot(this._edge1,this._pvec);if(0===r)return null;var n=1/r;this.origin.subtractToRef(e,this._tvec);var o=ft.Vector3.Dot(this._tvec,this._pvec)*n;if(o<0||1<o)return null;ft.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var s=ft.Vector3.Dot(this.direction,this._qvec)*n;if(s<0||1<o+s)return null;var a=ft.Vector3.Dot(this._edge2,this._qvec)*n;return a>this.length?null:new ft.IntersectionInfo(o,s,a)},T.prototype.intersectsPlane=function(e){var t,i=ft.Vector3.Dot(e.normal,this.direction);if(Math.abs(i)<9.99999997475243e-7)return null;var r=ft.Vector3.Dot(e.normal,this.origin);return(t=(-e.d-r)/i)<0?t<-9.99999997475243e-7?null:0:t},T.prototype.intersectsMesh=function(e,t){var i=ft.Tmp.Matrix[0];return e.getWorldMatrix().invertToRef(i),this._tmpRay?T.TransformToRef(this,i,this._tmpRay):this._tmpRay=T.Transform(this,i),e.intersects(this._tmpRay,t)},T.prototype.intersectsMeshes=function(e,t,i){i?i.length=0:i=[];for(var r=0;r<e.length;r++){var n=this.intersectsMesh(e[r],t);n.hit&&i.push(n)}return i.sort(this._comparePickingInfo),i},T.prototype._comparePickingInfo=function(e,t){return e.distance<t.distance?-1:e.distance>t.distance?1:0},T.prototype.intersectionSegment=function(e,t,i){var r,n,o,s,a=this.origin.add(this.direction.multiplyByFloats(T.rayl,T.rayl,T.rayl)),l=t.subtract(e),c=a.subtract(this.origin),h=e.subtract(this.origin),u=ft.Vector3.Dot(l,l),d=ft.Vector3.Dot(l,c),f=ft.Vector3.Dot(c,c),p=ft.Vector3.Dot(l,h),m=ft.Vector3.Dot(c,h),_=u*f-d*d,g=_,v=_;_<T.smallnum?(n=0,g=1,s=m,v=f):(s=u*m-d*p,(n=d*m-f*p)<0?(n=0,s=m,v=f):g<n&&(n=g,s=m+d,v=f)),s<0?-p<(s=0)?n=0:u<-p?n=g:(n=-p,g=u):v<s&&(s=v,-p+d<0?n=0:u<-p+d?n=g:(n=-p+d,g=u)),r=Math.abs(n)<T.smallnum?0:n/g,o=Math.abs(s)<T.smallnum?0:s/v;var y=c.multiplyByFloats(o,o,o),b=h.add(l.multiplyByFloats(r,r,r)).subtract(y);return 0<o&&o<=this.length&&b.lengthSquared()<i*i?y.length():-1},T.prototype.update=function(e,t,i,r,n,o,s){return ft.Vector3.UnprojectFloatsToRef(e,t,0,i,r,n,o,s,this.origin),ft.Vector3.UnprojectFloatsToRef(e,t,1,i,r,n,o,s,ft.Tmp.Vector3[0]),ft.Tmp.Vector3[0].subtractToRef(this.origin,this.direction),this.direction.normalize(),this},T.Zero=function(){return new T(ft.Vector3.Zero(),ft.Vector3.Zero())},T.CreateNew=function(e,t,i,r,n,o,s){return T.Zero().update(e,t,i,r,n,o,s)},T.CreateNewFromTo=function(e,t,i){void 0===i&&(i=ft.Matrix.Identity());var r=t.subtract(e),n=Math.sqrt(r.x*r.x+r.y*r.y+r.z*r.z);return r.normalize(),T.Transform(new T(e,r,n),i)},T.Transform=function(e,t){var i=new T(new ft.Vector3(0,0,0),new ft.Vector3(0,0,0));return T.TransformToRef(e,t,i),i},T.TransformToRef=function(e,t,i){ft.Vector3.TransformCoordinatesToRef(e.origin,t,i.origin),ft.Vector3.TransformNormalToRef(e.direction,t,i.direction),i.length=e.length;var r=i.direction,n=r.length();if(0!==n&&1!==n){var o=1/n;r.x*=o,r.y*=o,r.z*=o,i.length*=n}},T.smallnum=1e-8,T.rayl=1e9,T})(),ft.Ray=pt,mt=$a||($a={}),_t={root:0,found:!1},gt=function(e,t,i,r){_t.root=0,_t.found=!1;var n=t*t-4*e*i;if(n<0)return _t;var o=Math.sqrt(n),s=(-t-o)/(2*e),a=(-t+o)/(2*e);if(a<s){var l=a;a=s,s=l}return 0<s&&s<r?(_t.root=s,_t.found=!0):0<a&&a<r&&(_t.root=a,_t.found=!0),_t},vt=(function(){function e(){this._collisionPoint=mt.Vector3.Zero(),this._planeIntersectionPoint=mt.Vector3.Zero(),this._tempVector=mt.Vector3.Zero(),this._tempVector2=mt.Vector3.Zero(),this._tempVector3=mt.Vector3.Zero(),this._tempVector4=mt.Vector3.Zero(),this._edge=mt.Vector3.Zero(),this._baseToVertex=mt.Vector3.Zero(),this._destinationPoint=mt.Vector3.Zero(),this._slidePlaneNormal=mt.Vector3.Zero(),this._displacementVector=mt.Vector3.Zero(),this._radius=mt.Vector3.One(),this._retry=0,this._basePointWorld=mt.Vector3.Zero(),this._velocityWorld=mt.Vector3.Zero(),this._normalizedVelocity=mt.Vector3.Zero(),this._collisionMask=-1}return Object.defineProperty(e.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!0,configurable:!0}),e.prototype._initialize=function(e,t,i){this._velocity=t,mt.Vector3.NormalizeToRef(t,this._normalizedVelocity),(this._basePoint=e).multiplyToRef(this._radius,this._basePointWorld),t.multiplyToRef(this._radius,this._velocityWorld),this._velocityWorldLength=this._velocityWorld.length(),this._epsilon=i,this.collisionFound=!1},e.prototype._checkPointInTriangle=function(e,t,i,r,n){t.subtractToRef(e,this._tempVector),i.subtractToRef(e,this._tempVector2),mt.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var o=mt.Vector3.Dot(this._tempVector4,n);return!(o<0)&&(r.subtractToRef(e,this._tempVector3),mt.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((o=mt.Vector3.Dot(this._tempVector4,n))<0)&&(mt.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),0<=(o=mt.Vector3.Dot(this._tempVector4,n))))},e.prototype._canDoCollision=function(e,t,i,r){var n,o,s,a,l=mt.Vector3.Distance(this._basePointWorld,e),c=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(l>this._velocityWorldLength+c+t)&&(n=i,o=r,s=this._basePointWorld,a=this._velocityWorldLength+c,!(n.x>s.x+a||s.x-a>o.x||n.y>s.y+a||s.y-a>o.y||n.z>s.z+a||s.z-a>o.z))},e.prototype._testTriangle=function(e,t,i,r,n,o){var s,a=!1;t||(t=[]),t[e]||(t[e]=new mt.Plane(0,0,0,0),t[e].copyFromPoints(i,r,n));var l=t[e];if(o||l.isFrontFacingTo(this._normalizedVelocity,0)){var c=l.signedDistanceTo(this._basePoint),h=mt.Vector3.Dot(l.normal,this._velocity);if(0==h){if(1<=Math.abs(c))return;a=!0,s=0}else{var u=(1-c)/h;if(u<(s=(-1-c)/h)){var d=u;u=s,s=d}if(1<s||u<0)return;s<0&&(s=0),1<s&&(s=1)}this._collisionPoint.copyFromFloats(0,0,0);var f=!1,p=1;if(a||(this._basePoint.subtractToRef(l.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(s,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,i,r,n,l.normal)&&(f=!0,p=s,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!f){var m=this._velocity.lengthSquared(),_=m;this._basePoint.subtractToRef(i,this._tempVector);var g=2*mt.Vector3.Dot(this._velocity,this._tempVector),v=this._tempVector.lengthSquared()-1,y=gt(_,g,v,p);y.found&&(p=y.root,f=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(r,this._tempVector),g=2*mt.Vector3.Dot(this._velocity,this._tempVector),v=this._tempVector.lengthSquared()-1,(y=gt(_,g,v,p)).found&&(p=y.root,f=!0,this._collisionPoint.copyFrom(r)),this._basePoint.subtractToRef(n,this._tempVector),g=2*mt.Vector3.Dot(this._velocity,this._tempVector),v=this._tempVector.lengthSquared()-1,(y=gt(_,g,v,p)).found&&(p=y.root,f=!0,this._collisionPoint.copyFrom(n)),r.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex);var b=this._edge.lengthSquared(),T=mt.Vector3.Dot(this._edge,this._velocity),x=mt.Vector3.Dot(this._edge,this._baseToVertex);if(_=b*-m+T*T,g=b*(2*mt.Vector3.Dot(this._velocity,this._baseToVertex))-2*T*x,v=b*(1-this._baseToVertex.lengthSquared())+x*x,(y=gt(_,g,v,p)).found){var E=(T*y.root-x)/b;0<=E&&E<=1&&(p=y.root,f=!0,this._edge.scaleInPlace(E),i.addToRef(this._edge,this._collisionPoint))}n.subtractToRef(r,this._edge),r.subtractToRef(this._basePoint,this._baseToVertex),b=this._edge.lengthSquared(),T=mt.Vector3.Dot(this._edge,this._velocity),x=mt.Vector3.Dot(this._edge,this._baseToVertex),_=b*-m+T*T,g=b*(2*mt.Vector3.Dot(this._velocity,this._baseToVertex))-2*T*x,v=b*(1-this._baseToVertex.lengthSquared())+x*x,(y=gt(_,g,v,p)).found&&0<=(E=(T*y.root-x)/b)&&E<=1&&(p=y.root,f=!0,this._edge.scaleInPlace(E),r.addToRef(this._edge,this._collisionPoint)),i.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex),b=this._edge.lengthSquared(),T=mt.Vector3.Dot(this._edge,this._velocity),x=mt.Vector3.Dot(this._edge,this._baseToVertex),_=b*-m+T*T,g=b*(2*mt.Vector3.Dot(this._velocity,this._baseToVertex))-2*T*x,v=b*(1-this._baseToVertex.lengthSquared())+x*x,(y=gt(_,g,v,p)).found&&0<=(E=(T*y.root-x)/b)&&E<=1&&(p=y.root,f=!0,this._edge.scaleInPlace(E),n.addToRef(this._edge,this._collisionPoint))}if(f){var A=p*this._velocity.length();(!this.collisionFound||A<this._nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this._nearestDistance=A,this.collisionFound=!0)}}},e.prototype._collide=function(e,t,i,r,n,o,s){for(var a=r;a<n;a+=3){var l=t[i[a]-o],c=t[i[a+1]-o],h=t[i[a+2]-o];this._testTriangle(a,e,h,c,l,s)}},e.prototype._getResponse=function(e,t){e.addToRef(t,this._destinationPoint),t.scaleInPlace(this._nearestDistance/t.length()),this._basePoint.addToRef(t,e),e.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this._epsilon,this._displacementVector),e.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(mt.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,t)},e})(),mt.Collider=vt,(function(h){var l,e,s,t;h.CollisionWorker="",(e=l=h.WorkerTaskType||(h.WorkerTaskType={}))[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE",(t=s=h.WorkerReplyType||(h.WorkerReplyType={}))[t.SUCCESS=0]="SUCCESS",t[t.UNKNOWN_ERROR=1]="UNKNOWN_ERROR";var i=(function(){function t(){var o=this;this._scaledPosition=h.Vector3.Zero(),this._scaledVelocity=h.Vector3.Zero(),this.onMeshUpdated=function(e){o._addUpdateMeshesList[e.uniqueId]=t.SerializeMesh(e)},this.onGeometryUpdated=function(e){o._addUpdateGeometriesList[e.id]=t.SerializeGeometry(e)},this._afterRender=function(){if(o._init&&!(0==o._toRemoveGeometryArray.length&&0==o._toRemoveMeshesArray.length&&0==Object.keys(o._addUpdateGeometriesList).length&&0==Object.keys(o._addUpdateMeshesList).length||4<o._runningUpdated)){++o._runningUpdated;var e={updatedMeshes:o._addUpdateMeshesList,updatedGeometries:o._addUpdateGeometriesList,removedGeometries:o._toRemoveGeometryArray,removedMeshes:o._toRemoveMeshesArray},t={payload:e,taskType:l.UPDATE},i=[];for(var r in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(r)&&(i.push(t.payload.updatedGeometries[r].indices.buffer),i.push(t.payload.updatedGeometries[r].normals.buffer),i.push(t.payload.updatedGeometries[r].positions.buffer));o._worker.postMessage(t,i),o._addUpdateMeshesList={},o._addUpdateGeometriesList={},o._toRemoveGeometryArray=[],o._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(e){var t=e.data;if(t.error==s.SUCCESS)switch(t.taskType){case l.INIT:o._init=!0,o._scene.meshes.forEach((function(e){o.onMeshAdded(e)})),o._scene.getGeometries().forEach((function(e){o.onGeometryAdded(e)}));break;case l.UPDATE:o._runningUpdated--;break;case l.COLLIDE:var i=t.payload;if(!o._collisionsCallbackArray[i.collisionId])return;var r=o._collisionsCallbackArray[i.collisionId];if(r){var n=o._scene.getMeshByUniqueID(i.collidedMeshUniqueId);n&&r(i.collisionId,h.Vector3.FromArray(i.newPosition),n)}o._collisionsCallbackArray[i.collisionId]=null}else h.Tools.Warn("error returned from worker!")},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return t.prototype.getNewPosition=function(e,t,i,r,n,o,s){if(this._init&&!this._collisionsCallbackArray[s]&&!this._collisionsCallbackArray[s+1e5]){e.divideToRef(i._radius,this._scaledPosition),t.divideToRef(i._radius,this._scaledVelocity),this._collisionsCallbackArray[s]=o;var a={payload:{collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:i._radius.asArray()},collisionId:s,excludedMeshUniqueId:n?n.uniqueId:null,maximumRetry:r},taskType:l.COLLIDE};this._worker.postMessage(a)}},t.prototype.init=function(e){this._scene=e,this._scene.registerAfterRender(this._afterRender);var t=h.WorkerIncluded?h.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([h.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(t),this._worker.onmessage=this._onMessageFromWorker;var i={payload:{},taskType:l.INIT};this._worker.postMessage(i)},t.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},t.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},t.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},t.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},t.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},t.SerializeMesh=function(e){var t=[];e.subMeshes&&(t=e.subMeshes.map((function(e,t){var i=e.getBoundingInfo();return{position:t,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:i.boundingSphere.centerWorld.asArray(),sphereRadius:i.boundingSphere.radiusWorld,boxMinimum:i.boundingBox.minimumWorld.asArray(),boxMaximum:i.boundingBox.maximumWorld.asArray()}})));var i=null;if(e instanceof h.Mesh)i=(r=e.geometry)?r.id:null;else if(e instanceof h.InstancedMesh){var r;i=(r=e.sourceMesh&&e.sourceMesh.geometry)?r.id:null}var n=e.getBoundingInfo();return{uniqueId:e.uniqueId,id:e.id,name:e.name,geometryId:i,sphereCenter:n.boundingSphere.centerWorld.asArray(),sphereRadius:n.boundingSphere.radiusWorld,boxMinimum:n.boundingBox.minimumWorld.asArray(),boxMaximum:n.boundingBox.maximumWorld.asArray(),worldMatrixFromCache:e.worldMatrixFromCache.asArray(),subMeshes:t,checkCollisions:e.checkCollisions}},t.SerializeGeometry=function(e){return{id:e.id,positions:new Float32Array(e.getVerticesData(h.VertexBuffer.PositionKind)||[]),normals:new Float32Array(e.getVerticesData(h.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(e.getIndices()||[])}},t})();h.CollisionCoordinatorWorker=i;var r=(function(){function e(){this._scaledPosition=h.Vector3.Zero(),this._scaledVelocity=h.Vector3.Zero(),this._finalPosition=h.Vector3.Zero()}return e.prototype.getNewPosition=function(e,t,i,r,n,o,s){e.divideToRef(i._radius,this._scaledPosition),t.divideToRef(i._radius,this._scaledVelocity),i.collidedMesh=null,i._retry=0,i._initialVelocity=this._scaledVelocity,i._initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,r,this._finalPosition,n),this._finalPosition.multiplyInPlace(i._radius),o(s,this._finalPosition,i.collidedMesh)},e.prototype.init=function(e){this._scene=e},e.prototype.destroy=function(){},e.prototype.onMeshAdded=function(e){},e.prototype.onMeshUpdated=function(e){},e.prototype.onMeshRemoved=function(e){},e.prototype.onGeometryAdded=function(e){},e.prototype.onGeometryUpdated=function(e){},e.prototype.onGeometryDeleted=function(e){},e.prototype._collideWithWorld=function(e,t,i,r,n,o){void 0===o&&(o=null);var s=10*h.Engine.CollisionsEpsilon;if(i._retry>=r)n.copyFrom(e);else{var a=o?o.collisionMask:i.collisionMask;i._initialize(e,t,s);for(var l=0;l<this._scene.meshes.length;l++){var c=this._scene.meshes[l];c.isEnabled()&&c.checkCollisions&&c.subMeshes&&c!==o&&0!=(a&c.collisionGroup)&&c._checkCollision(i)}i.collisionFound?(0===t.x&&0===t.y&&0===t.z||i._getResponse(e,t),t.length()<=s?n.copyFrom(e):(i._retry++,this._collideWithWorld(e,t,i,r,n,o))):e.addToRef(t,n)}},e})();h.CollisionCoordinatorLegacy=r})($a||($a={})),yt=$a||($a={}),bt=(function(){function t(e){this.particleSystem=e,this.position=yt.Vector3.Zero(),this.direction=yt.Vector3.Zero(),this.color=new yt.Color4(0,0,0,0),this.colorStep=new yt.Color4(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.scale=new yt.Vector2(1,1),this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._attachedSubEmitters=null,this._currentColor1=new yt.Color4(0,0,0,0),this._currentColor2=new yt.Color4(0,0,0,0),this._currentSize1=0,this._currentSize2=0,this._currentAngularSpeed1=0,this._currentAngularSpeed2=0,this._currentVelocity1=0,this._currentVelocity2=0,this._currentLimitVelocity1=0,this._currentLimitVelocity2=0,this._currentDrag1=0,this._currentDrag2=0,this.id=t._Count++,this.particleSystem.isAnimationSheetEnabled&&this.updateCellInfoFromSystem()}return t.prototype.updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID},t.prototype.updateCellIndex=function(){var e=this.age,t=this.particleSystem.spriteCellChangeSpeed;this.particleSystem.spriteRandomStartCell&&(void 0===this._randomCellOffset&&(this._randomCellOffset=Math.random()*this.lifeTime),0===t?(t=1,e=this._randomCellOffset):e+=this._randomCellOffset);var i=this._initialEndSpriteCellID-this._initialStartSpriteCellID,r=yt.Scalar.Clamp(e*t%this.lifeTime/this.lifeTime);this.cellIndex=this._initialStartSpriteCellID+r*i|0},t.prototype._inheritParticleInfoToSubEmitter=function(e){if(e.particleSystem.emitter.position){var t=e.particleSystem.emitter;t.position.copyFrom(this.position),e.inheritDirection&&(t.position.subtractToRef(this.direction,yt.Tmp.Vector3[0]),t.lookAt(yt.Tmp.Vector3[0],0,Math.PI/2))}else{e.particleSystem.emitter.copyFrom(this.position)}this.direction.scaleToRef(e.inheritedVelocityAmount/2,yt.Tmp.Vector3[0]),e.particleSystem._inheritedVelocityOffset.copyFrom(yt.Tmp.Vector3[0])},t.prototype._inheritParticleInfoToSubEmitters=function(){var t=this;this._attachedSubEmitters&&0<this._attachedSubEmitters.length&&this._attachedSubEmitters.forEach((function(e){t._inheritParticleInfoToSubEmitter(e)}))},t.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},t.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()))},t._Count=0,t})(),yt.Particle=bt,Tt=$a||($a={}),xt=(function(){function e(e){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 Tt.Vector3(10,10,10),this.onAnimationEnd=null,this.blendMode=Tt.ParticleSystem.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 Tt.Vector2(0,0),this.beginAnimationOnStart=!1,this.beginAnimationFrom=0,this.beginAnimationTo=60,this.beginAnimationLoop=!1,this.gravity=Tt.Vector3.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 Tt.Color4(1,1,1,1),this.color2=new Tt.Color4(1,1,1,1),this.colorDead=new Tt.Color4(0,0,0,1),this.textureMask=new Tt.Color4(1,1,1,1),this._isSubEmitter=!1,this.billboardMode=Tt.ParticleSystem.BILLBOARDMODE_ALL,this._isBillboardBased=!0,this._imageProcessingConfigurationDefines=new Tt.ImageProcessingConfigurationDefines,this.id=e,this.name=e}return 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&&0<this._startSizeGradients.length||this._emitRateGradients&&0<this._emitRateGradients.length||this._lifeTimeGradients&&0<this._lifeTimeGradients.length},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:Tt.Vector3.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:Tt.Vector3.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:Tt.Vector3.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:Tt.Vector3.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isBillboardBased",{get:function(){return this._isBillboardBased},set:function(e){this._isBillboardBased!==e&&(this._isBillboardBased=e,this._reset())},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e)},enumerable:!0,configurable:!0}),e.prototype._attachImageProcessingConfiguration=function(e){e!==this._imageProcessingConfiguration&&(this._imageProcessingConfiguration=e||this._scene.imageProcessingConfiguration)},e.prototype._reset=function(){},e.prototype._removeGradientAndTexture=function(e,t,i){if(!t)return this;for(var r=0,n=0,o=t;n<o.length;n++){if(o[n].gradient===e){t.splice(r,1);break}r++}return i&&i.dispose(),this},e.prototype.createPointEmitter=function(e,t){var i=new Tt.PointParticleEmitter;return i.direction1=e,i.direction2=t,this.particleEmitterType=i},e.prototype.createHemisphericEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=1);var i=new Tt.HemisphericParticleEmitter(e,t);return this.particleEmitterType=i},e.prototype.createSphereEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=1);var i=new Tt.SphereParticleEmitter(e,t);return this.particleEmitterType=i},e.prototype.createDirectedSphereEmitter=function(e,t,i){void 0===e&&(e=1),void 0===t&&(t=new Tt.Vector3(0,1,0)),void 0===i&&(i=new Tt.Vector3(0,1,0));var r=new Tt.SphereDirectedParticleEmitter(e,t,i);return this.particleEmitterType=r},e.prototype.createCylinderEmitter=function(e,t,i,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0);var n=new Tt.CylinderParticleEmitter(e,t,i,r);return this.particleEmitterType=n},e.prototype.createDirectedCylinderEmitter=function(e,t,i,r,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=new Tt.Vector3(0,1,0)),void 0===n&&(n=new Tt.Vector3(0,1,0));var o=new Tt.CylinderDirectedParticleEmitter(e,t,i,r,n);return this.particleEmitterType=o},e.prototype.createConeEmitter=function(e,t){void 0===e&&(e=1),void 0===t&&(t=Math.PI/4);var i=new Tt.ConeParticleEmitter(e,t);return this.particleEmitterType=i},e.prototype.createBoxEmitter=function(e,t,i,r){var n=new Tt.BoxParticleEmitter;return this.particleEmitterType=n,this.direction1=e,this.direction2=t,this.minEmitBox=i,this.maxEmitBox=r,n},e.BLENDMODE_ONEONE=0,e.BLENDMODE_STANDARD=1,e.BLENDMODE_ADD=2,e.BLENDMODE_MULTIPLY=3,e.BLENDMODE_MULTIPLYADD=4,e})(),Tt.BaseParticleSystem=xt,Et=$a||($a={}),At=(function(s){function m(e,t,i,r,n,o){void 0===r&&(r=null),void 0===n&&(n=!1),void 0===o&&(o=.01);var m=s.call(this,e)||this;return m._inheritedVelocityOffset=new Et.Vector3,m.onDisposeObservable=new Et.Observable,m._particles=new Array,m._stockParticles=new Array,m._newPartsExcess=0,m._vertexBuffers={},m._scaledColorStep=new Et.Color4(0,0,0,0),m._colorDiff=new Et.Color4(0,0,0,0),m._scaledDirection=Et.Vector3.Zero(),m._scaledGravity=Et.Vector3.Zero(),m._currentRenderId=-1,m._useInstancing=!1,m._started=!1,m._stopped=!1,m._actualFrame=0,m._currentEmitRate1=0,m._currentEmitRate2=0,m._currentStartSize1=0,m._currentStartSize2=0,m._rawTextureWidth=256,m._useRampGradients=!1,m._disposeEmitterOnDispose=!1,m.recycleParticle=function(e){var t=m._particles.pop();t!==e&&t.copyTo(e),m._stockParticles.push(t)},m._createParticle=function(){var i;if(0!==m._stockParticles.length?(i=m._stockParticles.pop())._reset():i=new Et.Particle(m),m._subEmitters&&0<m._subEmitters.length){var e=m._subEmitters[Math.floor(Math.random()*m._subEmitters.length)];i._attachedSubEmitters=[],e.forEach((function(e){if(e.type===Et.SubEmitterType.ATTACHED){var t=e.clone();i._attachedSubEmitters.push(t),t.particleSystem.start()}}))}return i},m._emitFromParticle=function(i){if(m._subEmitters&&0!==m._subEmitters.length){var e=Math.floor(Math.random()*m._subEmitters.length);m._subEmitters[e].forEach((function(e){if(e.type===Et.SubEmitterType.END){var t=e.clone();i._inheritParticleInfoToSubEmitter(t),(t.particleSystem._rootParticleSystem=m).activeSubSystems.push(t.particleSystem),t.particleSystem.start()}}))}},m._capacity=t,m._epsilon=o,m._isAnimationSheetEnabled=n,m._scene=i||Et.Engine.LastCreatedScene,m._attachImageProcessingConfiguration(null),m._customEffect=r,m._scene.particleSystems.push(m),m._useInstancing=m._scene.getEngine().getCaps().instancedArrays,m._createIndexBuffer(),m._createVertexBuffers(),m.particleEmitterType=new Et.BoxParticleEmitter,m.updateFunction=function(h){var u=null,d=null;m.noiseTexture&&(u=m.noiseTexture.getSize(),d=m.noiseTexture.getContent());for(var f,e=function(){f=h[p];var e=m._scaledUpdateSpeed,t=f.age;if(f.age+=e,f.age>f.lifeTime){var i=f.age-t;e=(f.lifeTime-t)*e/i,f.age=f.lifeTime}var r=f.age/f.lifeTime;m._colorGradients&&0<m._colorGradients.length?Et.Tools.GetCurrentGradient(r,m._colorGradients,(function(e,t,i){e!==f._currentColorGradient&&(f._currentColor1.copyFrom(f._currentColor2),t.getColorToRef(f._currentColor2),f._currentColorGradient=e),Et.Color4.LerpToRef(f._currentColor1,f._currentColor2,i,f.color)})):(f.colorStep.scaleToRef(e,m._scaledColorStep),f.color.addInPlace(m._scaledColorStep),f.color.a<0&&(f.color.a=0)),m._angularSpeedGradients&&0<m._angularSpeedGradients.length&&Et.Tools.GetCurrentGradient(r,m._angularSpeedGradients,(function(e,t,i){e!==f._currentAngularSpeedGradient&&(f._currentAngularSpeed1=f._currentAngularSpeed2,f._currentAngularSpeed2=t.getFactor(),f._currentAngularSpeedGradient=e),f.angularSpeed=Et.Scalar.Lerp(f._currentAngularSpeed1,f._currentAngularSpeed2,i)})),f.angle+=f.angularSpeed*e;var n=e;if(m._velocityGradients&&0<m._velocityGradients.length&&Et.Tools.GetCurrentGradient(r,m._velocityGradients,(function(e,t,i){e!==f._currentVelocityGradient&&(f._currentVelocity1=f._currentVelocity2,f._currentVelocity2=t.getFactor(),f._currentVelocityGradient=e),n*=Et.Scalar.Lerp(f._currentVelocity1,f._currentVelocity2,i)})),f.direction.scaleToRef(n,m._scaledDirection),m._limitVelocityGradients&&0<m._limitVelocityGradients.length&&Et.Tools.GetCurrentGradient(r,m._limitVelocityGradients,(function(e,t,i){e!==f._currentLimitVelocityGradient&&(f._currentLimitVelocity1=f._currentLimitVelocity2,f._currentLimitVelocity2=t.getFactor(),f._currentLimitVelocityGradient=e),Et.Scalar.Lerp(f._currentLimitVelocity1,f._currentLimitVelocity2,i)<f.direction.length()&&f.direction.scaleInPlace(m.limitVelocityDamping)})),m._dragGradients&&0<m._dragGradients.length&&Et.Tools.GetCurrentGradient(r,m._dragGradients,(function(e,t,i){e!==f._currentDragGradient&&(f._currentDrag1=f._currentDrag2,f._currentDrag2=t.getFactor(),f._currentDragGradient=e);var r=Et.Scalar.Lerp(f._currentDrag1,f._currentDrag2,i);m._scaledDirection.scaleInPlace(1-r)})),f.position.addInPlace(m._scaledDirection),d&&u){var o=m._fetchR(f._randomNoiseCoordinates1.x,f._randomNoiseCoordinates1.y,u.width,u.height,d),s=m._fetchR(f._randomNoiseCoordinates1.z,f._randomNoiseCoordinates2.x,u.width,u.height,d),a=m._fetchR(f._randomNoiseCoordinates2.y,f._randomNoiseCoordinates2.z,u.width,u.height,d),l=Et.Tmp.Vector3[0],c=Et.Tmp.Vector3[1];l.copyFromFloats((2*o-1)*m.noiseStrength.x,(2*s-1)*m.noiseStrength.y,(2*a-1)*m.noiseStrength.z),l.scaleToRef(e,c),f.direction.addInPlace(c)}if(m.gravity.scaleToRef(e,m._scaledGravity),f.direction.addInPlace(m._scaledGravity),m._sizeGradients&&0<m._sizeGradients.length&&Et.Tools.GetCurrentGradient(r,m._sizeGradients,(function(e,t,i){e!==f._currentSizeGradient&&(f._currentSize1=f._currentSize2,f._currentSize2=t.getFactor(),f._currentSizeGradient=e),f.size=Et.Scalar.Lerp(f._currentSize1,f._currentSize2,i)})),m._useRampGradients&&(m._colorRemapGradients&&0<m._colorRemapGradients.length&&Et.Tools.GetCurrentGradient(r,m._colorRemapGradients,(function(e,t,i){var r=Et.Scalar.Lerp(e.factor1,t.factor1,i),n=Et.Scalar.Lerp(e.factor2,t.factor2,i);f.remapData.x=r,f.remapData.y=n-r})),m._alphaRemapGradients&&0<m._alphaRemapGradients.length&&Et.Tools.GetCurrentGradient(r,m._alphaRemapGradients,(function(e,t,i){var r=Et.Scalar.Lerp(e.factor1,t.factor1,i),n=Et.Scalar.Lerp(e.factor2,t.factor2,i);f.remapData.z=r,f.remapData.w=n-r}))),m._isAnimationSheetEnabled&&f.updateCellIndex(),f._inheritParticleInfoToSubEmitters(),f.age>=f.lifeTime)return m._emitFromParticle(f),f._attachedSubEmitters&&(f._attachedSubEmitters.forEach((function(e){e.particleSystem.disposeOnStop=!0,e.particleSystem.stop()})),f._attachedSubEmitters=null),m.recycleParticle(f),p--,"continue"},p=0;p<h.length;p++)e()},m}return T(m,s),Object.defineProperty(m.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"useRampGradients",{get:function(){return this._useRampGradients},set:function(e){this._useRampGradients!==e&&(this._useRampGradients=e,this._resetEffect())},enumerable:!0,configurable:!0}),Object.defineProperty(m.prototype,"particles",{get:function(){return this._particles},enumerable:!0,configurable:!0}),m.prototype.getClassName=function(){return"ParticleSystem"},m.prototype._addFactorGradient=function(e,t,i,r){var n=new Et.FactorGradient;n.gradient=t,n.factor1=i,n.factor2=r,e.push(n),e.sort((function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0}))},m.prototype._removeFactorGradient=function(e,t){if(e)for(var i=0,r=0,n=e;r<n.length;r++){if(n[r].gradient===t){e.splice(i,1);break}i++}},m.prototype.addLifeTimeGradient=function(e,t,i){return this._lifeTimeGradients||(this._lifeTimeGradients=[]),this._addFactorGradient(this._lifeTimeGradients,e,t,i),this},m.prototype.removeLifeTimeGradient=function(e){return this._removeFactorGradient(this._lifeTimeGradients,e),this},m.prototype.addSizeGradient=function(e,t,i){return this._sizeGradients||(this._sizeGradients=[]),this._addFactorGradient(this._sizeGradients,e,t,i),this},m.prototype.removeSizeGradient=function(e){return this._removeFactorGradient(this._sizeGradients,e),this},m.prototype.addColorRemapGradient=function(e,t,i){return this._colorRemapGradients||(this._colorRemapGradients=[]),this._addFactorGradient(this._colorRemapGradients,e,t,i),this},m.prototype.removeColorRemapGradient=function(e){return this._removeFactorGradient(this._colorRemapGradients,e),this},m.prototype.addAlphaRemapGradient=function(e,t,i){return this._alphaRemapGradients||(this._alphaRemapGradients=[]),this._addFactorGradient(this._alphaRemapGradients,e,t,i),this},m.prototype.removeAlphaRemapGradient=function(e){return this._removeFactorGradient(this._alphaRemapGradients,e),this},m.prototype.addAngularSpeedGradient=function(e,t,i){return this._angularSpeedGradients||(this._angularSpeedGradients=[]),this._addFactorGradient(this._angularSpeedGradients,e,t,i),this},m.prototype.removeAngularSpeedGradient=function(e){return this._removeFactorGradient(this._angularSpeedGradients,e),this},m.prototype.addVelocityGradient=function(e,t,i){return this._velocityGradients||(this._velocityGradients=[]),this._addFactorGradient(this._velocityGradients,e,t,i),this},m.prototype.removeVelocityGradient=function(e){return this._removeFactorGradient(this._velocityGradients,e),this},m.prototype.addLimitVelocityGradient=function(e,t,i){return this._limitVelocityGradients||(this._limitVelocityGradients=[]),this._addFactorGradient(this._limitVelocityGradients,e,t,i),this},m.prototype.removeLimitVelocityGradient=function(e){return this._removeFactorGradient(this._limitVelocityGradients,e),this},m.prototype.addDragGradient=function(e,t,i){return this._dragGradients||(this._dragGradients=[]),this._addFactorGradient(this._dragGradients,e,t,i),this},m.prototype.removeDragGradient=function(e){return this._removeFactorGradient(this._dragGradients,e),this},m.prototype.addEmitRateGradient=function(e,t,i){return this._emitRateGradients||(this._emitRateGradients=[]),this._addFactorGradient(this._emitRateGradients,e,t,i),this},m.prototype.removeEmitRateGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},m.prototype.addStartSizeGradient=function(e,t,i){return this._startSizeGradients||(this._startSizeGradients=[]),this._addFactorGradient(this._startSizeGradients,e,t,i),this},m.prototype.removeStartSizeGradient=function(e){return this._removeFactorGradient(this._emitRateGradients,e),this},m.prototype._createRampGradientTexture=function(){if(this._rampGradients&&this._rampGradients.length&&!this._rampGradientsTexture){for(var r=new Uint8Array(4*this._rawTextureWidth),n=Et.Tmp.Color3[0],o=0;o<this._rawTextureWidth;o++){var e=o/this._rawTextureWidth;Et.Tools.GetCurrentGradient(e,this._rampGradients,(function(e,t,i){Et.Color3.LerpToRef(e.color,t.color,i,n),r[4*o]=255*n.r,r[4*o+1]=255*n.g,r[4*o+2]=255*n.b,r[4*o+3]=255}))}this._rampGradientsTexture=Et.RawTexture.CreateRGBATexture(r,this._rawTextureWidth,1,this._scene,!1,!1,Et.Texture.NEAREST_SAMPLINGMODE)}},m.prototype.getRampGradients=function(){return this._rampGradients},m.prototype.addRampGradient=function(e,t){this._rampGradients||(this._rampGradients=[]);var i=new Et.Color3Gradient;return i.gradient=e,i.color=t,this._rampGradients.push(i),this._rampGradients.sort((function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0})),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._createRampGradientTexture(),this},m.prototype.removeRampGradient=function(e){return this._removeGradientAndTexture(e,this._rampGradients,this._rampGradientsTexture),this._rampGradientsTexture=null,this._rampGradients&&0<this._rampGradients.length&&this._createRampGradientTexture(),this},m.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var r=new Et.ColorGradient;return r.gradient=e,r.color1=t,r.color2=i,this._colorGradients.push(r),this._colorGradients.sort((function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0})),this},m.prototype.removeColorGradient=function(e){if(!this._colorGradients)return this;for(var t=0,i=0,r=this._colorGradients;i<r.length;i++){if(r[i].gradient===e){this._colorGradients.splice(t,1);break}t++}return this},m.prototype._fetchR=function(e,t,i,r,n){return n[4*(((e=.5*Math.abs(e)+.5)*i%i|0)+((t=.5*Math.abs(t)+.5)*r%r|0)*i)]/255},m.prototype._reset=function(){this._resetEffect()},m.prototype._resetEffect=function(){this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._createVertexBuffers()},m.prototype._createVertexBuffers=function(){this._vertexBufferSize=this._useInstancing?10:12,this._isAnimationSheetEnabled&&(this._vertexBufferSize+=1),this._isBillboardBased&&this.billboardMode!==m.BILLBOARDMODE_STRETCHED||(this._vertexBufferSize+=3),this._useRampGradients&&(this._vertexBufferSize+=4);var e=this._scene.getEngine();this._vertexData=new Float32Array(this._capacity*this._vertexBufferSize*(this._useInstancing?1:4)),this._vertexBuffer=new Et.Buffer(e,this._vertexData,!0,this._vertexBufferSize);var t=0,i=this._vertexBuffer.createVertexBuffer(Et.VertexBuffer.PositionKind,t,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Et.VertexBuffer.PositionKind]=i,t+=3;var r=this._vertexBuffer.createVertexBuffer(Et.VertexBuffer.ColorKind,t,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers[Et.VertexBuffer.ColorKind]=r,t+=4;var n=this._vertexBuffer.createVertexBuffer("angle",t,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.angle=n,t+=1;var o,s=this._vertexBuffer.createVertexBuffer("size",t,2,this._vertexBufferSize,this._useInstancing);if(this._vertexBuffers.size=s,t+=2,this._isAnimationSheetEnabled){var a=this._vertexBuffer.createVertexBuffer("cellIndex",t,1,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.cellIndex=a,t+=1}if(!this._isBillboardBased||this.billboardMode===m.BILLBOARDMODE_STRETCHED){var l=this._vertexBuffer.createVertexBuffer("direction",t,3,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.direction=l,t+=3}if(this._useRampGradients){var c=this._vertexBuffer.createVertexBuffer("remapData",t,4,this._vertexBufferSize,this._useInstancing);this._vertexBuffers.remapData=c,t+=4}if(this._useInstancing){var h=new Float32Array([0,0,1,0,1,1,0,1]);this._spriteBuffer=new Et.Buffer(e,h,!1,2),o=this._spriteBuffer.createVertexBuffer("offset",0,2)}else o=this._vertexBuffer.createVertexBuffer("offset",t,2,this._vertexBufferSize,this._useInstancing),t+=2;this._vertexBuffers.offset=o},m.prototype._createIndexBuffer=function(){if(!this._useInstancing){for(var e=[],t=0,i=0;i<this._capacity;i++)e.push(t),e.push(t+1),e.push(t+2),e.push(t),e.push(t+2),e.push(t+3),t+=4;this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)}},m.prototype.getCapacity=function(){return this._capacity},m.prototype.isAlive=function(){return this._alive},m.prototype.isStarted=function(){return this._started},m.prototype._prepareSubEmitterInternalArray=function(){var t=this;this._subEmitters=new Array,this.subEmitters&&this.subEmitters.forEach((function(e){e instanceof m?t._subEmitters.push([new Et.SubEmitter(e)]):e instanceof Et.SubEmitter?t._subEmitters.push([e]):e instanceof Array&&t._subEmitters.push(e)}))},m.prototype.start=function(e){var t=this;if(void 0===e&&(e=this.startDelay),!this.targetStopDuration&&this._hasTargetStopDurationDependantGradient())throw"Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";if(e)setTimeout((function(){t.start(0)}),e);else{if(this._prepareSubEmitterInternalArray(),this._started=!0,this._stopped=!1,this._actualFrame=0,this._subEmitters&&0!=this._subEmitters.length&&(this.activeSubSystems=new Array),this._emitRateGradients&&(0<this._emitRateGradients.length&&(this._currentEmitRateGradient=this._emitRateGradients[0],this._currentEmitRate1=this._currentEmitRateGradient.getFactor(),this._currentEmitRate2=this._currentEmitRate1),1<this._emitRateGradients.length&&(this._currentEmitRate2=this._emitRateGradients[1].getFactor())),this._startSizeGradients&&(0<this._startSizeGradients.length&&(this._currentStartSizeGradient=this._startSizeGradients[0],this._currentStartSize1=this._currentStartSizeGradient.getFactor(),this._currentStartSize2=this._currentStartSize1),1<this._startSizeGradients.length&&(this._currentStartSize2=this._startSizeGradients[1].getFactor())),this.preWarmCycles){this.emitter instanceof Et.AbstractMesh&&this.emitter.computeWorldMatrix(!0);var i=this.noiseTexture;if(i&&i.onGeneratedObservable)i.onGeneratedObservable.addOnce((function(){setTimeout((function(){for(var e=0;e<t.preWarmCycles;e++)t.animate(!0),i.render()}))}));else for(var r=0;r<this.preWarmCycles;r++)this.animate(!0)}this.beginAnimationOnStart&&this.animations&&0<this.animations.length&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop)}},m.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped=!0,e&&this._stopSubEmitters()},m.prototype.reset=function(){this._stockParticles=[],this._particles=[]},m.prototype._appendParticleVertex=function(e,t,i,r){var n=e*this._vertexBufferSize;this._vertexData[n++]=t.position.x,this._vertexData[n++]=t.position.y,this._vertexData[n++]=t.position.z,this._vertexData[n++]=t.color.r,this._vertexData[n++]=t.color.g,this._vertexData[n++]=t.color.b,this._vertexData[n++]=t.color.a,this._vertexData[n++]=t.angle,this._vertexData[n++]=t.scale.x*t.size,this._vertexData[n++]=t.scale.y*t.size,this._isAnimationSheetEnabled&&(this._vertexData[n++]=t.cellIndex),this._isBillboardBased?this.billboardMode===m.BILLBOARDMODE_STRETCHED&&(this._vertexData[n++]=t.direction.x,this._vertexData[n++]=t.direction.y,this._vertexData[n++]=t.direction.z):t._initialDirection?(this._vertexData[n++]=t._initialDirection.x,this._vertexData[n++]=t._initialDirection.y,this._vertexData[n++]=t._initialDirection.z):(this._vertexData[n++]=t.direction.x,this._vertexData[n++]=t.direction.y,this._vertexData[n++]=t.direction.z),this._useRampGradients&&(this._vertexData[n++]=t.remapData.x,this._vertexData[n++]=t.remapData.y,this._vertexData[n++]=t.remapData.z,this._vertexData[n++]=t.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[n++]=i,this._vertexData[n++]=r)},m.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach((function(e){e.stop(!0)})),this.activeSubSystems=new Array)},m.prototype._removeFromRoot=function(){if(this._rootParticleSystem){var e=this._rootParticleSystem.activeSubSystems.indexOf(this);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1),this._rootParticleSystem=null}},m.prototype._update=function(e){var c,n=this;if(this._alive=0<this._particles.length,this.emitter.position){var t=this.emitter;this._emitterWorldMatrix=t.getWorldMatrix()}else{var i=this.emitter;this._emitterWorldMatrix=Et.Matrix.Translation(i.x,i.y,i.z)}this.updateFunction(this._particles);for(var r,o=function(){if(s._particles.length===s._capacity)return"break";c=s._createParticle(),s._particles.push(c);var e=Et.Scalar.RandomRange(s.minEmitPower,s.maxEmitPower);if(s.startPositionFunction?s.startPositionFunction(s._emitterWorldMatrix,c.position,c):s.particleEmitterType.startPositionFunction(s._emitterWorldMatrix,c.position,c),s.startDirectionFunction?s.startDirectionFunction(s._emitterWorldMatrix,c.direction,c):s.particleEmitterType.startDirectionFunction(s._emitterWorldMatrix,c.direction,c),0===e?c._initialDirection?c._initialDirection.copyFrom(c.direction):c._initialDirection=c.direction.clone():c._initialDirection=null,c.direction.scaleInPlace(e),s.targetStopDuration&&s._lifeTimeGradients&&0<s._lifeTimeGradients.length){var l=Et.Scalar.Clamp(s._actualFrame/s.targetStopDuration);Et.Tools.GetCurrentGradient(l,s._lifeTimeGradients,(function(e,t,i){var r=e,n=t,o=r.getFactor(),s=n.getFactor(),a=(l-r.gradient)/(n.gradient-r.gradient);c.lifeTime=Et.Scalar.Lerp(o,s,a)}))}else c.lifeTime=Et.Scalar.RandomRange(s.minLifeTime,s.maxLifeTime);if(s._sizeGradients&&0!==s._sizeGradients.length?(c._currentSizeGradient=s._sizeGradients[0],c._currentSize1=c._currentSizeGradient.getFactor(),c.size=c._currentSize1,1<s._sizeGradients.length?c._currentSize2=s._sizeGradients[1].getFactor():c._currentSize2=c._currentSize1):c.size=Et.Scalar.RandomRange(s.minSize,s.maxSize),c.scale.copyFromFloats(Et.Scalar.RandomRange(s.minScaleX,s.maxScaleX),Et.Scalar.RandomRange(s.minScaleY,s.maxScaleY)),s._startSizeGradients&&s._startSizeGradients[0]&&s.targetStopDuration){var t=s._actualFrame/s.targetStopDuration;Et.Tools.GetCurrentGradient(t,s._startSizeGradients,(function(e,t,i){e!==n._currentStartSizeGradient&&(n._currentStartSize1=n._currentStartSize2,n._currentStartSize2=t.getFactor(),n._currentStartSizeGradient=e);var r=Et.Scalar.Lerp(n._currentStartSize1,n._currentStartSize2,i);c.scale.scaleInPlace(r)}))}s._angularSpeedGradients&&0!==s._angularSpeedGradients.length?(c._currentAngularSpeedGradient=s._angularSpeedGradients[0],c.angularSpeed=c._currentAngularSpeedGradient.getFactor(),c._currentAngularSpeed1=c.angularSpeed,1<s._angularSpeedGradients.length?c._currentAngularSpeed2=s._angularSpeedGradients[1].getFactor():c._currentAngularSpeed2=c._currentAngularSpeed1):c.angularSpeed=Et.Scalar.RandomRange(s.minAngularSpeed,s.maxAngularSpeed),c.angle=Et.Scalar.RandomRange(s.minInitialRotation,s.maxInitialRotation),s._velocityGradients&&0<s._velocityGradients.length&&(c._currentVelocityGradient=s._velocityGradients[0],c._currentVelocity1=c._currentVelocityGradient.getFactor(),1<s._velocityGradients.length?c._currentVelocity2=s._velocityGradients[1].getFactor():c._currentVelocity2=c._currentVelocity1),s._limitVelocityGradients&&0<s._limitVelocityGradients.length&&(c._currentLimitVelocityGradient=s._limitVelocityGradients[0],c._currentLimitVelocity1=c._currentLimitVelocityGradient.getFactor(),1<s._limitVelocityGradients.length?c._currentLimitVelocity2=s._limitVelocityGradients[1].getFactor():c._currentLimitVelocity2=c._currentLimitVelocity1),s._dragGradients&&0<s._dragGradients.length&&(c._currentDragGradient=s._dragGradients[0],c._currentDrag1=c._currentDragGradient.getFactor(),1<s._dragGradients.length?c._currentDrag2=s._dragGradients[1].getFactor():c._currentDrag2=c._currentDrag1),s._colorGradients&&0!==s._colorGradients.length?(c._currentColorGradient=s._colorGradients[0],c._currentColorGradient.getColorToRef(c.color),c._currentColor1.copyFrom(c.color),1<s._colorGradients.length?s._colorGradients[1].getColorToRef(c._currentColor2):c._currentColor2.copyFrom(c.color)):(r=Et.Scalar.RandomRange(0,1),Et.Color4.LerpToRef(s.color1,s.color2,r,c.color),s.colorDead.subtractToRef(c.color,s._colorDiff),s._colorDiff.scaleToRef(1/c.lifeTime,c.colorStep)),s._isAnimationSheetEnabled&&(c._initialStartSpriteCellID=s.startSpriteCellID,c._initialEndSpriteCellID=s.endSpriteCellID),c.direction.addInPlace(s._inheritedVelocityOffset),s._useRampGradients&&(c.remapData=new Et.Vector4(0,1,0,1)),s.noiseTexture&&(c._randomNoiseCoordinates1?(c._randomNoiseCoordinates1.copyFromFloats(Math.random(),Math.random(),Math.random()),c._randomNoiseCoordinates2.copyFromFloats(Math.random(),Math.random(),Math.random())):(c._randomNoiseCoordinates1=new Et.Vector3(Math.random(),Math.random(),Math.random()),c._randomNoiseCoordinates2=new Et.Vector3(Math.random(),Math.random(),Math.random()))),c._inheritParticleInfoToSubEmitters()},s=this,a=0;a<e;a++){if("break"===o())break}},m._GetAttributeNamesOrOptions=function(e,t,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1);var r=[Et.VertexBuffer.PositionKind,Et.VertexBuffer.ColorKind,"angle","offset","size"];return e&&r.push("cellIndex"),t||r.push("direction"),i&&r.push("remapData"),r},m._GetEffectCreationOptions=function(e){void 0===e&&(e=!1);var t=["invView","view","projection","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","textureMask","translationPivot","eyePosition"];return e&&t.push("particlesInfos"),t},m.prototype._getEffect=function(e){if(this._customEffect)return this._customEffect;var t=[];if(this._scene.clipPlane&&t.push("#define CLIPPLANE"),this._scene.clipPlane2&&t.push("#define CLIPPLANE2"),this._scene.clipPlane3&&t.push("#define CLIPPLANE3"),this._scene.clipPlane4&&t.push("#define CLIPPLANE4"),this._isAnimationSheetEnabled&&t.push("#define ANIMATESHEET"),e===m.BLENDMODE_MULTIPLY&&t.push("#define BLENDMULTIPLYMODE"),this._useRampGradients&&t.push("#define RAMPGRADIENT"),this._isBillboardBased)switch(t.push("#define BILLBOARD"),this.billboardMode){case m.BILLBOARDMODE_Y:t.push("#define BILLBOARDY");break;case m.BILLBOARDMODE_STRETCHED:t.push("#define BILLBOARDSTRETCHED")}this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),t.push(this._imageProcessingConfigurationDefines.toString()));var i=t.join("\n");if(this._cachedDefines!==i){this._cachedDefines=i;var r=m._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled,this._isBillboardBased&&this.billboardMode!==m.BILLBOARDMODE_STRETCHED,this._useRampGradients),n=m._GetEffectCreationOptions(this._isAnimationSheetEnabled),o=["diffuseSampler","rampSampler"];Et.ImageProcessingConfiguration&&(Et.ImageProcessingConfiguration.PrepareUniforms(n,this._imageProcessingConfigurationDefines),Et.ImageProcessingConfiguration.PrepareSamplers(o,this._imageProcessingConfigurationDefines)),this._effect=this._scene.getEngine().createEffect("particles",r,n,o,i)}return this._effect},m.prototype.animate=function(e){var r=this;if(void 0===e&&(e=!1),this._started){if(!e){if(!this.isReady())return;if(this._currentRenderId===this._scene.getRenderId())return;this._currentRenderId=this._scene.getRenderId()}var t;if(this._scaledUpdateSpeed=this.updateSpeed*(e?this.preWarmStepOffset:this._scene.getAnimationRatio()),-1<this.manualEmitCount)t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0;else{var n=this.emitRate;if(this._emitRateGradients&&0<this._emitRateGradients.length&&this.targetStopDuration){var i=this._actualFrame/this.targetStopDuration;Et.Tools.GetCurrentGradient(i,this._emitRateGradients,(function(e,t,i){e!==r._currentEmitRateGradient&&(r._currentEmitRate1=r._currentEmitRate2,r._currentEmitRate2=t.getFactor(),r._currentEmitRateGradient=e),n=Et.Scalar.Lerp(r._currentEmitRate1,r._currentEmitRate2,i)}))}t=n*this._scaledUpdateSpeed>>0,this._newPartsExcess+=n*this._scaledUpdateSpeed-t}if(1<this._newPartsExcess&&(t+=this._newPartsExcess>>0,this._newPartsExcess-=this._newPartsExcess>>0),this._alive=!1,this._stopped?t=0:(this._actualFrame+=this._scaledUpdateSpeed,this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()),this._update(t),this._stopped&&(this._alive||(this._started=!1,this.onAnimationEnd&&this.onAnimationEnd(),this.disposeOnStop&&this._scene._toBeDisposed.push(this))),!e){for(var o=0,s=0;s<this._particles.length;s++){var a=this._particles[s];this._appendParticleVertices(o,a),o+=this._useInstancing?1:4}this._vertexBuffer&&this._vertexBuffer.update(this._vertexData)}0===this.manualEmitCount&&this.disposeOnStop&&this.stop()}},m.prototype._appendParticleVertices=function(e,t){this._appendParticleVertex(e++,t,0,0),this._useInstancing||(this._appendParticleVertex(e++,t,1,0),this._appendParticleVertex(e++,t,1,1),this._appendParticleVertex(e++,t,0,1))},m.prototype.rebuild=function(){this._createIndexBuffer(),this._vertexBuffer&&this._vertexBuffer._rebuild()},m.prototype.isReady=function(){if(!(this.emitter&&this._imageProcessingConfiguration.isReady()&&this.particleTexture&&this.particleTexture.isReady()))return!1;if(this.blendMode!==m.BLENDMODE_MULTIPLYADD){if(!this._getEffect(this.blendMode).isReady())return!1}else{if(!this._getEffect(m.BLENDMODE_MULTIPLY).isReady())return!1;if(!this._getEffect(m.BLENDMODE_ADD).isReady())return!1}return!0},m.prototype._render=function(e){var t=this._getEffect(e),i=this._scene.getEngine();i.enableEffect(t);var r=this._scene.getViewMatrix();if(t.setTexture("diffuseSampler",this.particleTexture),t.setMatrix("view",r),t.setMatrix("projection",this._scene.getProjectionMatrix()),this._isAnimationSheetEnabled&&this.particleTexture){var n=this.particleTexture.getBaseSize();t.setFloat3("particlesInfos",this.spriteCellWidth/n.width,this.spriteCellHeight/n.height,n.width/this.spriteCellWidth)}if(t.setVector2("translationPivot",this.translationPivot),t.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._isBillboardBased){var o=this._scene.activeCamera;t.setVector3("eyePosition",o.globalPosition)}if(this._rampGradientsTexture&&t.setTexture("rampSampler",this._rampGradientsTexture),this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4){var s=r.clone();s.invert(),t.setMatrix("invView",s),Et.MaterialHelper.BindClipPlane(t,this._scene)}switch(i.bindBuffers(this._vertexBuffers,this._indexBuffer,t),this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(t),e){case m.BLENDMODE_ADD:i.setAlphaMode(Et.Engine.ALPHA_ADD);break;case m.BLENDMODE_ONEONE:i.setAlphaMode(Et.Engine.ALPHA_ONEONE);break;case m.BLENDMODE_STANDARD:i.setAlphaMode(Et.Engine.ALPHA_COMBINE);break;case m.BLENDMODE_MULTIPLY:i.setAlphaMode(Et.Engine.ALPHA_MULTIPLY)}return this._useInstancing?i.drawArraysType(Et.Material.TriangleFanDrawMode,0,4,this._particles.length):i.drawElementsType(Et.Material.TriangleFillMode,0,6*this._particles.length),this._particles.length},m.prototype.render=function(){if(!this.isReady()||!this._particles.length)return 0;var e=this._scene.getEngine();e.setState(!1),this.forceDepthWrite&&e.setDepthWrite(!0);var t=0;return this.blendMode===m.BLENDMODE_MULTIPLYADD&&(t=this._render(m.BLENDMODE_MULTIPLY)+this._render(m.BLENDMODE_ADD)),t=this._render(this.blendMode),e.unbindInstanceAttributes(),e.setAlphaMode(Et.Engine.ALPHA_DISABLE),t},m.prototype.dispose=function(e){if(void 0===e&&(e=!0),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._spriteBuffer&&(this._spriteBuffer.dispose(),this._spriteBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),e&&this.noiseTexture&&(this.noiseTexture.dispose(),this.noiseTexture=null),this._rampGradientsTexture&&(this._rampGradientsTexture.dispose(),this._rampGradientsTexture=null),this._removeFromRoot(),this._subEmitters&&this._subEmitters.length){for(var t=0;t<this._subEmitters.length;t++)for(var i=0,r=this._subEmitters[t];i<r.length;i++){r[i].dispose()}this._subEmitters=[],this.subEmitters=[]}this._disposeEmitterOnDispose&&this.emitter&&this.emitter.dispose&&this.emitter.dispose(!0),-1<(t=this._scene.particleSystems.indexOf(this))&&this._scene.particleSystems.splice(t,1),this._scene._activeParticleSystems.dispose(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.reset()},m.prototype.clone=function(e,t){var i=null,r=null;if(null!=this.customShader){var n=0<(r=this.customShader).shaderOptions.defines.length?r.shaderOptions.defines.join("\n"):"";i=this._scene.getEngine().createEffectForParticles(r.shaderPath.fragmentElement,r.shaderOptions.uniforms,r.shaderOptions.samplers,n)}else this._customEffect&&(i=this._customEffect);var o=new m(e,this._capacity,this._scene,i);return o.customShader=r,Et.Tools.DeepCopy(this,o,["particles","customShader","noiseTexture"]),void 0===t&&(t=this.emitter),o.noiseTexture=this.noiseTexture,o.emitter=t,this.particleTexture&&(o.particleTexture=new Et.Texture(this.particleTexture.url,this._scene)),this._colorGradients&&this._colorGradients.forEach((function(e){o.addColorGradient(e.gradient,e.color1,e.color2)})),this._dragGradients&&this._dragGradients.forEach((function(e){o.addDragGradient(e.gradient,e.factor1,e.factor2)})),this._angularSpeedGradients&&this._angularSpeedGradients.forEach((function(e){o.addAngularSpeedGradient(e.gradient,e.factor1,e.factor2)})),this._emitRateGradients&&this._emitRateGradients.forEach((function(e){o.addEmitRateGradient(e.gradient,e.factor1,e.factor2)})),this._lifeTimeGradients&&this._lifeTimeGradients.forEach((function(e){o.addLifeTimeGradient(e.gradient,e.factor1,e.factor2)})),this._limitVelocityGradients&&this._limitVelocityGradients.forEach((function(e){o.addLimitVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._sizeGradients&&this._sizeGradients.forEach((function(e){o.addSizeGradient(e.gradient,e.factor1,e.factor2)})),this._startSizeGradients&&this._startSizeGradients.forEach((function(e){o.addStartSizeGradient(e.gradient,e.factor1,e.factor2)})),this._velocityGradients&&this._velocityGradients.forEach((function(e){o.addVelocityGradient(e.gradient,e.factor1,e.factor2)})),this._rampGradients&&this._rampGradients.forEach((function(e){o.addRampGradient(e.gradient,e.color)})),this._colorRemapGradients&&this._colorRemapGradients.forEach((function(e){o.addColorRemapGradient(e.gradient,e.factor1,e.factor2)})),this._alphaRemapGradients&&this._alphaRemapGradients.forEach((function(e){o.addAlphaRemapGradient(e.gradient,e.factor1,e.factor2)})),this.preventAutoStart||o.start(),o},m.prototype.serialize=function(){var e={};if(m._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 t=0,i=this._subEmitters;t<i.length;t++){for(var r=[],n=0,o=i[t];n<o.length;n++){var s=o[n];r.push(s.serialize())}e.subEmitters.push(r)}}return e},m._Serialize=function(e,t){if(e.name=t.name,e.id=t.id,e.capacity=t.getCapacity(),t.emitter.position){var i=t.emitter;e.emitterId=i.id}else{var r=t.emitter;e.emitter=r.asArray()}t.particleEmitterType&&(e.particleEmitterType=t.particleEmitterType.serialize()),t.particleTexture&&(e.textureName=t.particleTexture.name,e.invertY=t.particleTexture._invertY),Et.Animation.AppendSerializedAnimations(t,e),e.beginAnimationOnStart=t.beginAnimationOnStart,e.beginAnimationFrom=t.beginAnimationFrom,e.beginAnimationTo=t.beginAnimationTo,e.beginAnimationLoop=t.beginAnimationLoop,e.startDelay=t.startDelay,e.renderingGroupId=t.renderingGroupId,e.isBillboardBased=t.isBillboardBased,e.billboardMode=t.billboardMode,e.minAngularSpeed=t.minAngularSpeed,e.maxAngularSpeed=t.maxAngularSpeed,e.minSize=t.minSize,e.maxSize=t.maxSize,e.minScaleX=t.minScaleX,e.maxScaleX=t.maxScaleX,e.minScaleY=t.minScaleY,e.maxScaleY=t.maxScaleY,e.minEmitPower=t.minEmitPower,e.maxEmitPower=t.maxEmitPower,e.minLifeTime=t.minLifeTime,e.maxLifeTime=t.maxLifeTime,e.emitRate=t.emitRate,e.gravity=t.gravity.asArray(),e.noiseStrength=t.noiseStrength.asArray(),e.color1=t.color1.asArray(),e.color2=t.color2.asArray(),e.colorDead=t.colorDead.asArray(),e.updateSpeed=t.updateSpeed,e.targetStopDuration=t.targetStopDuration,e.blendMode=t.blendMode,e.preWarmCycles=t.preWarmCycles,e.preWarmStepOffset=t.preWarmStepOffset,e.minInitialRotation=t.minInitialRotation,e.maxInitialRotation=t.maxInitialRotation,e.startSpriteCellID=t.startSpriteCellID,e.endSpriteCellID=t.endSpriteCellID,e.spriteCellChangeSpeed=t.spriteCellChangeSpeed,e.spriteCellWidth=t.spriteCellWidth,e.spriteCellHeight=t.spriteCellHeight,e.spriteRandomStartCell=t.spriteRandomStartCell,e.isAnimationSheetEnabled=t.isAnimationSheetEnabled;var n=t.getColorGradients();if(n){e.colorGradients=[];for(var o=0,s=n;o<s.length;o++){var a=s[o],l={gradient:a.gradient,color1:a.color1.asArray()};a.color2&&(l.color2=a.color2.asArray()),e.colorGradients.push(l)}}var c=t.getRampGradients();if(c){e.rampGradients=[];for(var h=0,u=c;h<u.length;h++){var d=u[h];l={gradient:d.gradient,color:d.color.asArray()};e.rampGradients.push(l)}e.useRampGradients=t.useRampGradients}var f=t.getColorRemapGradients();if(f){e.colorRemapGradients=[];for(var p=0,m=f;p<m.length;p++){var _=m[p];l={gradient:_.gradient,factor1:_.factor1};void 0!==_.factor2&&(l.factor2=_.factor2),e.colorRemapGradients.push(l)}}var g=t.getAlphaRemapGradients();if(g){e.alphaRemapGradients=[];for(var v=0,y=g;v<y.length;v++){var b=y[v];l={gradient:b.gradient,factor1:b.factor1};void 0!==b.factor2&&(l.factor2=b.factor2),e.alphaRemapGradients.push(l)}}var T=t.getSizeGradients();if(T){e.sizeGradients=[];for(var x=0,E=T;x<E.length;x++){var A=E[x];l={gradient:A.gradient,factor1:A.factor1};void 0!==A.factor2&&(l.factor2=A.factor2),e.sizeGradients.push(l)}}var P=t.getAngularSpeedGradients();if(P){e.angularSpeedGradients=[];for(var S=0,R=P;S<R.length;S++){var M=R[S];l={gradient:M.gradient,factor1:M.factor1};void 0!==M.factor2&&(l.factor2=M.factor2),e.angularSpeedGradients.push(l)}}var C=t.getVelocityGradients();if(C){e.velocityGradients=[];for(var O=0,D=C;O<D.length;O++){var I=D[O];l={gradient:I.gradient,factor1:I.factor1};void 0!==I.factor2&&(l.factor2=I.factor2),e.velocityGradients.push(l)}}var w=t.getDragGradients();if(w){e.dragyGradients=[];for(var L=0,F=w;L<F.length;L++){var B=F[L];l={gradient:B.gradient,factor1:B.factor1};void 0!==B.factor2&&(l.factor2=B.factor2),e.dragGradients.push(l)}}var N=t.getEmitRateGradients();if(N){e.emitRateGradients=[];for(var V=0,U=N;V<U.length;V++){var z=U[V];l={gradient:z.gradient,factor1:z.factor1};void 0!==z.factor2&&(l.factor2=z.factor2),e.emitRateGradients.push(l)}}var G=t.getStartSizeGradients();if(G){e.startSizeGradients=[];for(var k=0,W=G;k<W.length;k++){var H=W[k];l={gradient:H.gradient,factor1:H.factor1};void 0!==H.factor2&&(l.factor2=H.factor2),e.startSizeGradients.push(l)}}var X=t.getLifeTimeGradients();if(X){e.lifeTimeGradients=[];for(var j=0,Y=X;j<Y.length;j++){var K=Y[j];l={gradient:K.gradient,factor1:K.factor1};void 0!==K.factor2&&(l.factor2=K.factor2),e.lifeTimeGradients.push(l)}}var Q=t.getLimitVelocityGradients();if(Q){e.limitVelocityGradients=[];for(var Z=0,q=Q;Z<q.length;Z++){var J=q[Z];l={gradient:J.gradient,factor1:J.factor1};void 0!==J.factor2&&(l.factor2=J.factor2),e.limitVelocityGradients.push(l)}e.limitVelocityDamping=t.limitVelocityDamping}t.noiseTexture&&(e.noiseTexture=t.noiseTexture.serialize())},m._Parse=function(e,t,i,r){if(e.textureName&&(t.particleTexture=new Et.Texture(r+e.textureName,i,!1,void 0===e.invertY||e.invertY),t.particleTexture.name=e.textureName),e.emitterId||0===e.emitterId||void 0!==e.emitter?e.emitterId?t.emitter=i.getLastMeshByID(e.emitterId):t.emitter=Et.Vector3.FromArray(e.emitter):t.emitter=Et.Vector3.Zero(),void 0!==e.renderingGroupId&&(t.renderingGroupId=e.renderingGroupId),void 0!==e.isBillboardBased&&(t.isBillboardBased=e.isBillboardBased),void 0!==e.billboardMode&&(t.billboardMode=e.billboardMode),e.animations){for(var n=0;n<e.animations.length;n++){var o=e.animations[n];t.animations.push(Et.Animation.Parse(o))}t.beginAnimationOnStart=e.beginAnimationOnStart,t.beginAnimationFrom=e.beginAnimationFrom,t.beginAnimationTo=e.beginAnimationTo,t.beginAnimationLoop=e.beginAnimationLoop}if(e.autoAnimate&&i.beginAnimation(t,e.autoAnimateFrom,e.autoAnimateTo,e.autoAnimateLoop,e.autoAnimateSpeed||1),t.startDelay=0|e.startDelay,t.minAngularSpeed=e.minAngularSpeed,t.maxAngularSpeed=e.maxAngularSpeed,t.minSize=e.minSize,t.maxSize=e.maxSize,e.minScaleX&&(t.minScaleX=e.minScaleX,t.maxScaleX=e.maxScaleX,t.minScaleY=e.minScaleY,t.maxScaleY=e.maxScaleY),void 0!==e.preWarmCycles&&(t.preWarmCycles=e.preWarmCycles,t.preWarmStepOffset=e.preWarmStepOffset),void 0!==e.minInitialRotation&&(t.minInitialRotation=e.minInitialRotation,t.maxInitialRotation=e.maxInitialRotation),t.minLifeTime=e.minLifeTime,t.maxLifeTime=e.maxLifeTime,t.minEmitPower=e.minEmitPower,t.maxEmitPower=e.maxEmitPower,t.emitRate=e.emitRate,t.gravity=Et.Vector3.FromArray(e.gravity),e.noiseStrength&&(t.noiseStrength=Et.Vector3.FromArray(e.noiseStrength)),t.color1=Et.Color4.FromArray(e.color1),t.color2=Et.Color4.FromArray(e.color2),t.colorDead=Et.Color4.FromArray(e.colorDead),t.updateSpeed=e.updateSpeed,t.targetStopDuration=e.targetStopDuration,t.blendMode=e.blendMode,e.colorGradients)for(var s=0,a=e.colorGradients;s<a.length;s++){var l=a[s];t.addColorGradient(l.gradient,Et.Color4.FromArray(l.color1),l.color2?Et.Color4.FromArray(l.color2):void 0)}if(e.rampGradients){for(var c=0,h=e.rampGradients;c<h.length;c++){var u=h[c];t.addRampGradient(u.gradient,Et.Color3.FromArray(u.color))}t.useRampGradients=e.useRampGradients}if(e.colorRemapGradients)for(var d=0,f=e.colorRemapGradients;d<f.length;d++){var p=f[d];t.addColorRemapGradient(p.gradient,void 0!==p.factor1?p.factor1:p.factor,p.factor2)}if(e.alphaRemapGradients)for(var m=0,_=e.alphaRemapGradients;m<_.length;m++){var g=_[m];t.addAlphaRemapGradient(g.gradient,void 0!==g.factor1?g.factor1:g.factor,g.factor2)}if(e.sizeGradients)for(var v=0,y=e.sizeGradients;v<y.length;v++){var b=y[v];t.addSizeGradient(b.gradient,void 0!==b.factor1?b.factor1:b.factor,b.factor2)}if(e.sizeGradients)for(var T=0,x=e.sizeGradients;T<x.length;T++){b=x[T];t.addSizeGradient(b.gradient,void 0!==b.factor1?b.factor1:b.factor,b.factor2)}if(e.angularSpeedGradients)for(var E=0,A=e.angularSpeedGradients;E<A.length;E++){var P=A[E];t.addAngularSpeedGradient(P.gradient,void 0!==P.factor1?P.factor1:P.factor,P.factor2)}if(e.velocityGradients)for(var S=0,R=e.velocityGradients;S<R.length;S++){var M=R[S];t.addVelocityGradient(M.gradient,void 0!==M.factor1?M.factor1:M.factor,M.factor2)}if(e.dragGradients)for(var C=0,O=e.dragGradients;C<O.length;C++){var D=O[C];t.addDragGradient(D.gradient,void 0!==D.factor1?D.factor1:D.factor,D.factor2)}if(e.emitRateGradients)for(var I=0,w=e.emitRateGradients;I<w.length;I++){var L=w[I];t.addEmitRateGradient(L.gradient,void 0!==L.factor1?L.factor1:L.factor,L.factor2)}if(e.startSizeGradients)for(var F=0,B=e.startSizeGradients;F<B.length;F++){var N=B[F];t.addStartSizeGradient(N.gradient,void 0!==N.factor1?N.factor1:N.factor,N.factor2)}if(e.lifeTimeGradients)for(var V=0,U=e.lifeTimeGradients;V<U.length;V++){var z=U[V];t.addLifeTimeGradient(z.gradient,void 0!==z.factor1?z.factor1:z.factor,z.factor2)}if(e.limitVelocityGradients){for(var G=0,k=e.limitVelocityGradients;G<k.length;G++){var W=k[G];t.addLimitVelocityGradient(W.gradient,void 0!==W.factor1?W.factor1:W.factor,W.factor2)}t.limitVelocityDamping=e.limitVelocityDamping}var H;if(e.noiseTexture&&(t.noiseTexture=Et.ProceduralTexture.Parse(e.noiseTexture,i,r)),e.particleEmitterType){switch(e.particleEmitterType.type){case"SphereParticleEmitter":H=new Et.SphereParticleEmitter;break;case"SphereDirectedParticleEmitter":H=new Et.SphereDirectedParticleEmitter;break;case"ConeEmitter":case"ConeParticleEmitter":H=new Et.ConeParticleEmitter;break;case"CylinderParticleEmitter":H=new Et.CylinderParticleEmitter;break;case"HemisphericParticleEmitter":H=new Et.HemisphericParticleEmitter;break;case"BoxEmitter":case"BoxParticleEmitter":default:H=new Et.BoxParticleEmitter}H.parse(e.particleEmitterType)}else(H=new Et.BoxParticleEmitter).parse(e);t.particleEmitterType=H,t.startSpriteCellID=e.startSpriteCellID,t.endSpriteCellID=e.endSpriteCellID,t.spriteCellWidth=e.spriteCellWidth,t.spriteCellHeight=e.spriteCellHeight,t.spriteCellChangeSpeed=e.spriteCellChangeSpeed,t.spriteRandomStartCell=e.spriteRandomStartCell},m.Parse=function(e,t,i,r){void 0===r&&(r=!1);var n=e.name,o=null,s=null;if(e.customShader){var a=0<(s=e.customShader).shaderOptions.defines.length?s.shaderOptions.defines.join("\n"):"";o=t.getEngine().createEffectForParticles(s.shaderPath.fragmentElement,s.shaderOptions.uniforms,s.shaderOptions.samplers,a)}var l=new m(n,e.capacity,t,o,e.isAnimationSheetEnabled);if(l.customShader=s,e.id&&(l.id=e.id),e.subEmitters){l.subEmitters=[];for(var c=0,h=e.subEmitters;c<h.length;c++){for(var u=[],d=0,f=h[c];d<f.length;d++){var p=f[d];u.push(Et.SubEmitter.Parse(p,t,i))}l.subEmitters.push(u)}}return m._Parse(e,l,t,i),l.textureMask=Et.Color4.FromArray(e.textureMask),e.preventAutoStart&&(l.preventAutoStart=e.preventAutoStart),r||l.preventAutoStart||l.start(),l},m.BILLBOARDMODE_Y=2,m.BILLBOARDMODE_ALL=7,m.BILLBOARDMODE_STRETCHED=8,m})(Et.BaseParticleSystem),Et.ParticleSystem=At,Pt=$a||($a={}),St=(function(){function t(){this.direction1=new Pt.Vector3(0,1,0),this.direction2=new Pt.Vector3(0,1,0),this.minEmitBox=new Pt.Vector3(-.5,-.5,-.5),this.maxEmitBox=new Pt.Vector3(.5,.5,.5)}return t.prototype.startDirectionFunction=function(e,t,i){var r=Pt.Scalar.RandomRange(this.direction1.x,this.direction2.x),n=Pt.Scalar.RandomRange(this.direction1.y,this.direction2.y),o=Pt.Scalar.RandomRange(this.direction1.z,this.direction2.z);Pt.Vector3.TransformNormalFromFloatsToRef(r,n,o,e,t)},t.prototype.startPositionFunction=function(e,t,i){var r=Pt.Scalar.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),n=Pt.Scalar.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),o=Pt.Scalar.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);Pt.Vector3.TransformCoordinatesFromFloatsToRef(r,n,o,e,t)},t.prototype.clone=function(){var e=new t;return Pt.Tools.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2),e.setVector3("minEmitBox",this.minEmitBox),e.setVector3("maxEmitBox",this.maxEmitBox)},t.prototype.getEffectDefines=function(){return"#define BOXEMITTER"},t.prototype.getClassName=function(){return"BoxParticleEmitter"},t.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},t.prototype.parse=function(e){Pt.Vector3.FromArrayToRef(e.direction1,0,this.direction1),Pt.Vector3.FromArrayToRef(e.direction2,0,this.direction2),Pt.Vector3.FromArrayToRef(e.minEmitBox,0,this.minEmitBox),Pt.Vector3.FromArrayToRef(e.maxEmitBox,0,this.maxEmitBox)},t})(),Pt.BoxParticleEmitter=St,Rt=$a||($a={}),Mt=(function(){function t(e,t,i,r){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=0),this.radius=e,this.height=t,this.radiusRange=i,this.directionRandomizer=r}return t.prototype.startDirectionFunction=function(e,t,i){var r=i.position.subtract(e.getTranslation()).normalize(),n=Rt.Scalar.RandomRange(-this.directionRandomizer/2,this.directionRandomizer/2),o=Math.atan2(r.x,r.z);o+=Rt.Scalar.RandomRange(-Math.PI/2,Math.PI/2)*this.directionRandomizer,r.y=n,r.x=Math.sin(o),r.z=Math.cos(o),r.normalize(),Rt.Vector3.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},t.prototype.startPositionFunction=function(e,t,i){var r=Rt.Scalar.RandomRange(-this.height/2,this.height/2),n=Rt.Scalar.RandomRange(0,2*Math.PI),o=Rt.Scalar.RandomRange((1-this.radiusRange)*(1-this.radiusRange),1),s=Math.sqrt(o)*this.radius,a=s*Math.cos(n),l=s*Math.sin(n);Rt.Vector3.TransformCoordinatesFromFloatsToRef(a,r,l,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.directionRandomizer);return Rt.Tools.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.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){return"#define CYLINDEREMITTER"},t.prototype.getClassName=function(){return"CylinderParticleEmitter"},t.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},t.prototype.parse=function(e){this.radius=e.radius,this.height=e.height,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},t})(),Ct=(function(s){function t(e,t,i,r,n){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=1),void 0===r&&(r=new Rt.Vector3(0,1,0)),void 0===n&&(n=new Rt.Vector3(0,1,0));var o=s.call(this,e,t,i)||this;return o.direction1=r,o.direction2=n,o}return T(t,s),t.prototype.startDirectionFunction=function(e,t,i){var r=Rt.Scalar.RandomRange(this.direction1.x,this.direction2.x),n=Rt.Scalar.RandomRange(this.direction1.y,this.direction2.y),o=Rt.Scalar.RandomRange(this.direction1.z,this.direction2.z);Rt.Vector3.TransformNormalFromFloatsToRef(r,n,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.height,this.radiusRange,this.direction1,this.direction2);return Rt.Tools.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 e=s.prototype.serialize.call(this);return e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},t.prototype.parse=function(e){s.prototype.parse.call(this,e),this.direction1.copyFrom(e.direction1),this.direction2.copyFrom(e.direction2)},t})(Rt.CylinderParticleEmitter=Mt),Rt.CylinderDirectedParticleEmitter=Ct,Ot=$a||($a={}),Dt=(function(){function t(e,t,i){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===i&&(i=0),this.directionRandomizer=i,this.radiusRange=1,this.heightRange=1,this.emitFromSpawnPointOnly=!1,this.angle=t,this.radius=e}return Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._buildHeight()},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._buildHeight()},enumerable:!0,configurable:!0}),t.prototype._buildHeight=function(){0!==this._angle?this._height=this._radius/Math.tan(this._angle/2):this._height=1},t.prototype.startDirectionFunction=function(e,t,i){if(1===Math.abs(Math.cos(this._angle)))Ot.Vector3.TransformNormalFromFloatsToRef(0,1,0,e,t);else{var r=i.position.subtract(e.getTranslation()).normalize(),n=Ot.Scalar.RandomRange(0,this.directionRandomizer),o=Ot.Scalar.RandomRange(0,this.directionRandomizer),s=Ot.Scalar.RandomRange(0,this.directionRandomizer);r.x+=n,r.y+=o,r.z+=s,r.normalize(),Ot.Vector3.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)}},t.prototype.startPositionFunction=function(e,t,i){var r,n=Ot.Scalar.RandomRange(0,2*Math.PI);r=this.emitFromSpawnPointOnly?1e-4:1-(r=Ot.Scalar.RandomRange(0,this.heightRange))*r;var o=this._radius-Ot.Scalar.RandomRange(0,this._radius*this.radiusRange),s=(o*=r)*Math.sin(n),a=o*Math.cos(n),l=r*this._height;Ot.Vector3.TransformCoordinatesFromFloatsToRef(s,l,a,e,t)},t.prototype.clone=function(){var e=new t(this._radius,this._angle,this.directionRandomizer);return Ot.Tools.DeepCopy(this,e),e},t.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)},t.prototype.getEffectDefines=function(){var e="#define CONEEMITTER";return this.emitFromSpawnPointOnly&&(e+="\n#define CONEEMITTERSPAWNPOINT"),e},t.prototype.getClassName=function(){return"ConeParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this._radius,e.angle=this._angle,e.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.angle=e.angle,this.directionRandomizer=e.directionRandomizer},t})(),Ot.ConeParticleEmitter=Dt,It=$a||($a={}),wt=(function(){function t(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return t.prototype.startDirectionFunction=function(e,t,i){var r=i.position.subtract(e.getTranslation()).normalize(),n=It.Scalar.RandomRange(0,this.directionRandomizer),o=It.Scalar.RandomRange(0,this.directionRandomizer),s=It.Scalar.RandomRange(0,this.directionRandomizer);r.x+=n,r.y+=o,r.z+=s,r.normalize(),It.Vector3.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},t.prototype.startPositionFunction=function(e,t,i){var r=this.radius-It.Scalar.RandomRange(0,this.radius*this.radiusRange),n=It.Scalar.RandomRange(0,1),o=It.Scalar.RandomRange(0,2*Math.PI),s=Math.acos(2*n-1),a=r*Math.cos(o)*Math.sin(s),l=r*Math.cos(s),c=r*Math.sin(o)*Math.sin(s);It.Vector3.TransformCoordinatesFromFloatsToRef(a,l,c,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.directionRandomizer);return It.Tools.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER"},t.prototype.getClassName=function(){return"SphereParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},t})(),Lt=(function(n){function t(e,t,i){void 0===e&&(e=1),void 0===t&&(t=new It.Vector3(0,1,0)),void 0===i&&(i=new It.Vector3(0,1,0));var r=n.call(this,e)||this;return r.direction1=t,r.direction2=i,r}return T(t,n),t.prototype.startDirectionFunction=function(e,t,i){var r=It.Scalar.RandomRange(this.direction1.x,this.direction2.x),n=It.Scalar.RandomRange(this.direction1.y,this.direction2.y),o=It.Scalar.RandomRange(this.direction1.z,this.direction2.z);It.Vector3.TransformNormalFromFloatsToRef(r,n,o,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.direction1,this.direction2);return It.Tools.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 e=n.prototype.serialize.call(this);return e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},t.prototype.parse=function(e){n.prototype.parse.call(this,e),this.direction1.copyFrom(e.direction1),this.direction2.copyFrom(e.direction2)},t})(It.SphereParticleEmitter=wt),It.SphereDirectedParticleEmitter=Lt,Ft=$a||($a={}),Bt=(function(){function t(e,t,i){void 0===e&&(e=1),void 0===t&&(t=1),void 0===i&&(i=0),this.radius=e,this.radiusRange=t,this.directionRandomizer=i}return t.prototype.startDirectionFunction=function(e,t,i){var r=i.position.subtract(e.getTranslation()).normalize(),n=Ft.Scalar.RandomRange(0,this.directionRandomizer),o=Ft.Scalar.RandomRange(0,this.directionRandomizer),s=Ft.Scalar.RandomRange(0,this.directionRandomizer);r.x+=n,r.y+=o,r.z+=s,r.normalize(),Ft.Vector3.TransformNormalFromFloatsToRef(r.x,r.y,r.z,e,t)},t.prototype.startPositionFunction=function(e,t,i){var r=this.radius-Ft.Scalar.RandomRange(0,this.radius*this.radiusRange),n=Ft.Scalar.RandomRange(0,1),o=Ft.Scalar.RandomRange(0,2*Math.PI),s=Math.acos(2*n-1),a=r*Math.cos(o)*Math.sin(s),l=r*Math.cos(s),c=r*Math.sin(o)*Math.sin(s);Ft.Vector3.TransformCoordinatesFromFloatsToRef(a,Math.abs(l),c,e,t)},t.prototype.clone=function(){var e=new t(this.radius,this.directionRandomizer);return Ft.Tools.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("radiusRange",this.radiusRange),e.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){return"#define HEMISPHERICEMITTER"},t.prototype.getClassName=function(){return"HemisphericParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.radius=this.radius,e.radiusRange=this.radiusRange,e.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.radiusRange=e.radiusRange,this.directionRandomizer=e.directionRandomizer},t})(),Ft.HemisphericParticleEmitter=Bt,Nt=$a||($a={}),Vt=(function(){function t(){this.direction1=new Nt.Vector3(0,1,0),this.direction2=new Nt.Vector3(0,1,0)}return t.prototype.startDirectionFunction=function(e,t,i){var r=Nt.Scalar.RandomRange(this.direction1.x,this.direction2.x),n=Nt.Scalar.RandomRange(this.direction1.y,this.direction2.y),o=Nt.Scalar.RandomRange(this.direction1.z,this.direction2.z);Nt.Vector3.TransformNormalFromFloatsToRef(r,n,o,e,t)},t.prototype.startPositionFunction=function(e,t,i){Nt.Vector3.TransformCoordinatesFromFloatsToRef(0,0,0,e,t)},t.prototype.clone=function(){var e=new t;return Nt.Tools.DeepCopy(this,e),e},t.prototype.applyToShader=function(e){e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},t.prototype.getEffectDefines=function(){return"#define POINTEMITTER"},t.prototype.getClassName=function(){return"PointParticleEmitter"},t.prototype.serialize=function(){var e={};return e.type=this.getClassName(),e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},t.prototype.parse=function(e){Nt.Vector3.FromArrayToRef(e.direction1,0,this.direction1),Nt.Vector3.FromArrayToRef(e.direction2,0,this.direction2)},t})(),Nt.PointParticleEmitter=Vt,(Ut=$a||($a={})).AbstractScene.AddParser(Ut.SceneComponentConstants.NAME_PARTICLESYSTEM,(function(e,t,i,r){var n=Ut.AbstractScene.GetIndividualParser(Ut.SceneComponentConstants.NAME_PARTICLESYSTEM);if(n&&void 0!==e.particleSystems&&null!==e.particleSystems)for(var o=0,s=e.particleSystems.length;o<s;o++){var a=e.particleSystems[o];i.particleSystems.push(n(a,t,r))}})),Ut.AbstractScene.AddIndividualParser(Ut.SceneComponentConstants.NAME_PARTICLESYSTEM,(function(e,t,i){return e.activeParticleCount?Ut.GPUParticleSystem.Parse(e,t,i):Ut.ParticleSystem.Parse(e,t,i)})),Ut.Engine.prototype.createEffectForParticles=function(e,t,i,r,n,o,s){void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===r&&(r="");var a=Ut.ParticleSystem._GetAttributeNamesOrOptions(),l=Ut.ParticleSystem._GetEffectCreationOptions();return-1===r.indexOf(" BILLBOARD")&&(r+="\n#define BILLBOARD\n"),-1===i.indexOf("diffuseSampler")&&i.push("diffuseSampler"),this.createEffect({vertex:"particles",fragmentElement:e},a,l.concat(t),i,r,n,o,s)},Ut.Mesh.prototype.getEmittedParticleSystems=function(){for(var e=new Array,t=0;t<this.getScene().particleSystems.length;t++){var i=this.getScene().particleSystems[t];i.emitter===this&&e.push(i)}return e},Ut.Mesh.prototype.getHierarchyEmittedParticleSystems=function(){var e=new Array,t=this.getDescendants();t.push(this);for(var i=0;i<this.getScene().particleSystems.length;i++){var r=this.getScene().particleSystems[i],n=r.emitter;n.position&&-1!==t.indexOf(n)&&e.push(r)}return e},(function(s){var t,e;(e=t=s.SubEmitterType||(s.SubEmitterType={}))[e.ATTACHED=0]="ATTACHED",e[e.END=1]="END";var i=(function(){function o(e){this.particleSystem=e,this.type=t.END,this.inheritDirection=!1,this.inheritedVelocityAmount=0,e.emitter&&e.emitter.dispose||(e.emitter=new s.AbstractMesh("SubemitterSystemEmitter",e.getScene())),e.onDisposeObservable.add((function(){e.emitter&&e.emitter.dispose&&e.emitter.dispose()}))}return o.prototype.clone=function(){var e=this.particleSystem.emitter;e?e instanceof s.Vector3?e=e.clone():e instanceof s.AbstractMesh&&((e=new s.Mesh("",e.getScene())).isVisible=!1):e=new s.Vector3;var t=new o(this.particleSystem.clone("",e));return t.type=this.type,t.inheritDirection=this.inheritDirection,t.inheritedVelocityAmount=this.inheritedVelocityAmount,t.particleSystem._disposeEmitterOnDispose=!0,t.particleSystem.disposeOnStop=!0,t},o.prototype.serialize=function(){var e={};return e.type=this.type,e.inheritDirection=this.inheritDirection,e.inheritedVelocityAmount=this.inheritedVelocityAmount,e.particleSystem=this.particleSystem.serialize(),e},o.Parse=function(e,t,i){var r=e.particleSystem,n=new o(s.ParticleSystem.Parse(r,t,i));return n.type=e.type,n.inheritDirection=e.inheritDirection,n.inheritedVelocityAmount=e.inheritedVelocityAmount,n.particleSystem._isSubEmitter=!0,n},o.prototype.dispose=function(){this.particleSystem.dispose()},o})();s.SubEmitter=i})($a||($a={})),zt=$a||($a={}),Gt=(function(o){function c(e,t,i,r){void 0===r&&(r={});var n=o.call(this,e,t)||this;return n._textures={},n._textureArrays={},n._floats={},n._ints={},n._floatsArrays={},n._colors3={},n._colors3Arrays={},n._colors4={},n._vectors2={},n._vectors3={},n._vectors4={},n._matrices={},n._matrices3x3={},n._matrices2x2={},n._vectors2Arrays={},n._vectors3Arrays={},n._cachedWorldViewMatrix=new zt.Matrix,n._shaderPath=i,n._options=ae({needAlphaBlending:!1,needAlphaTesting:!1,attributes:["position","normal","uv"],uniforms:["worldViewProjection"],uniformBuffers:[],samplers:[],defines:[]},r),n}return T(c,o),c.prototype.getClassName=function(){return"ShaderMaterial"},c.prototype.needAlphaBlending=function(){return this.alpha<1||this._options.needAlphaBlending},c.prototype.needAlphaTesting=function(){return this._options.needAlphaTesting},c.prototype._checkUniform=function(e){-1===this._options.uniforms.indexOf(e)&&this._options.uniforms.push(e)},c.prototype.setTexture=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._textures[e]=t,this},c.prototype.setTextureArray=function(e,t){return-1===this._options.samplers.indexOf(e)&&this._options.samplers.push(e),this._checkUniform(e),this._textureArrays[e]=t,this},c.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},c.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},c.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},c.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},c.prototype.setColor3Array=function(e,t){return this._checkUniform(e),this._colors3Arrays[e]=t.reduce((function(e,t){return t.toArray(e,e.length),e}),[]),this},c.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},c.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},c.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},c.prototype.setVector4=function(e,t){return this._checkUniform(e),this._vectors4[e]=t,this},c.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},c.prototype.setMatrix3x3=function(e,t){return this._checkUniform(e),this._matrices3x3[e]=t,this},c.prototype.setMatrix2x2=function(e,t){return this._checkUniform(e),this._matrices2x2[e]=t,this},c.prototype.setArray2=function(e,t){return this._checkUniform(e),this._vectors2Arrays[e]=t,this},c.prototype.setArray3=function(e,t){return this._checkUniform(e),this._vectors3Arrays[e]=t,this},c.prototype._checkCache=function(e,t,i){return!t||(this._effect&&this._effect.defines.indexOf("#define INSTANCES"),!1)},c.prototype.isReady=function(e,t){var i=this.getScene(),r=i.getEngine();if(!this.checkReadyOnEveryCall&&this._renderId===i.getRenderId()&&this._checkCache(i,e,t))return!0;for(var n=[],o=[],s=new zt.EffectFallbacks,a=0;a<this._options.defines.length;a++)n.push(this._options.defines[a]);for(a=0;a<this._options.attributes.length;a++)o.push(this._options.attributes[a]);for(var l in e&&e.isVerticesDataPresent(zt.VertexBuffer.ColorKind)&&(o.push(zt.VertexBuffer.ColorKind),n.push("#define VERTEXCOLOR")),t&&(n.push("#define INSTANCES"),zt.MaterialHelper.PrepareAttributesForInstances(o,n)),e&&e.useBones&&e.computeBonesUsingShaders&&e.skeleton?(o.push(zt.VertexBuffer.MatricesIndicesKind),o.push(zt.VertexBuffer.MatricesWeightsKind),4<e.numBoneInfluencers&&(o.push(zt.VertexBuffer.MatricesIndicesExtraKind),o.push(zt.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+e.numBoneInfluencers),n.push("#define BonesPerMesh "+(e.skeleton.bones.length+1)),s.addCPUSkinningFallback(0,e),-1===this._options.uniforms.indexOf("mBones")&&this._options.uniforms.push("mBones")):n.push("#define NUM_BONE_INFLUENCERS 0"),this._textures)if(!this._textures[l].isReady())return!1;e&&this._shouldTurnAlphaTestOn(e)&&n.push("#define ALPHATEST");var c=this._effect,h=n.join("\n");return this._effect=r.createEffect(this._shaderPath,{attributes:o,uniformsNames:this._options.uniforms,uniformBuffersNames:this._options.uniformBuffers,samplers:this._options.samplers,defines:h,fallbacks:s,onCompiled:this.onCompiled,onError:this.onError},r),!!this._effect.isReady()&&(c!==this._effect&&i.resetCachedMaterial(),this._renderId=i.getRenderId(),!0)},c.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())))},c.prototype.bind=function(e,t){if(this.bindOnlyWorldMatrix(e),this._effect&&this.getScene().getCachedMaterial()!==this){var i;for(i in-1!==this._options.uniforms.indexOf("view")&&this._effect.setMatrix("view",this.getScene().getViewMatrix()),-1!==this._options.uniforms.indexOf("projection")&&this._effect.setMatrix("projection",this.getScene().getProjectionMatrix()),-1!==this._options.uniforms.indexOf("viewProjection")&&this._effect.setMatrix("viewProjection",this.getScene().getTransformMatrix()),zt.MaterialHelper.BindBonesParameters(t,this._effect),this._textures)this._effect.setTexture(i,this._textures[i]);for(i in this._textureArrays)this._effect.setTextureArray(i,this._textureArrays[i]);for(i in this._ints)this._effect.setInt(i,this._ints[i]);for(i in this._floats)this._effect.setFloat(i,this._floats[i]);for(i in this._floatsArrays)this._effect.setArray(i,this._floatsArrays[i]);for(i in this._colors3)this._effect.setColor3(i,this._colors3[i]);for(i in this._colors3Arrays)this._effect.setArray3(i,this._colors3Arrays[i]);for(i in this._colors4){var r=this._colors4[i];this._effect.setFloat4(i,r.r,r.g,r.b,r.a)}for(i in this._vectors2)this._effect.setVector2(i,this._vectors2[i]);for(i in this._vectors3)this._effect.setVector3(i,this._vectors3[i]);for(i in this._vectors4)this._effect.setVector4(i,this._vectors4[i]);for(i in this._matrices)this._effect.setMatrix(i,this._matrices[i]);for(i in this._matrices3x3)this._effect.setMatrix3x3(i,this._matrices3x3[i]);for(i in this._matrices2x2)this._effect.setMatrix2x2(i,this._matrices2x2[i]);for(i in this._vectors2Arrays)this._effect.setArray2(i,this._vectors2Arrays[i]);for(i in this._vectors3Arrays)this._effect.setArray3(i,this._vectors3Arrays[i])}this._afterBind(t)},c.prototype.getActiveTextures=function(){var e=o.prototype.getActiveTextures.call(this);for(var t in this._textures)e.push(this._textures[t]);for(var t in this._textureArrays)for(var i=this._textureArrays[t],r=0;r<i.length;r++)e.push(i[r]);return e},c.prototype.hasTexture=function(e){if(o.prototype.hasTexture.call(this,e))return!0;for(var t in this._textures)if(this._textures[t]===e)return!0;for(var t in this._textureArrays)for(var i=this._textureArrays[t],r=0;r<i.length;r++)if(i[r]===e)return!0;return!1},c.prototype.clone=function(e){return new c(e,this.getScene(),this._shaderPath,this._options)},c.prototype.dispose=function(e,t){if(t){var i;for(i in this._textures)this._textures[i].dispose();for(i in this._textureArrays)for(var r=this._textureArrays[i],n=0;n<r.length;n++)r[n].dispose()}this._textures={},o.prototype.dispose.call(this,e,t)},c.prototype.serialize=function(){var e,t=zt.SerializationHelper.Serialize(this);for(e in t.customType="BABYLON.ShaderMaterial",t.options=this._options,t.shaderPath=this._shaderPath,t.textures={},this._textures)t.textures[e]=this._textures[e].serialize();for(e in t.textureArrays={},this._textureArrays){t.textureArrays[e]=[];for(var i=this._textureArrays[e],r=0;r<i.length;r++)t.textureArrays[e].push(i[r].serialize())}for(e in t.floats={},this._floats)t.floats[e]=this._floats[e];for(e in t.FloatArrays={},this._floatsArrays)t.FloatArrays[e]=this._floatsArrays[e];for(e in t.colors3={},this._colors3)t.colors3[e]=this._colors3[e].asArray();for(e in t.colors3Arrays={},this._colors3Arrays)t.colors3Arrays[e]=this._colors3Arrays[e];for(e in t.colors4={},this._colors4)t.colors4[e]=this._colors4[e].asArray();for(e in t.vectors2={},this._vectors2)t.vectors2[e]=this._vectors2[e].asArray();for(e in t.vectors3={},this._vectors3)t.vectors3[e]=this._vectors3[e].asArray();for(e in t.vectors4={},this._vectors4)t.vectors4[e]=this._vectors4[e].asArray();for(e in t.matrices={},this._matrices)t.matrices[e]=this._matrices[e].asArray();for(e in t.matrices3x3={},this._matrices3x3)t.matrices3x3[e]=this._matrices3x3[e];for(e in t.matrices2x2={},this._matrices2x2)t.matrices2x2[e]=this._matrices2x2[e];for(e in t.vectors2Arrays={},this._vectors2Arrays)t.vectors2Arrays[e]=this._vectors2Arrays[e];for(e in t.vectors3Arrays={},this._vectors3Arrays)t.vectors3Arrays[e]=this._vectors3Arrays[e];return t},c.Parse=function(e,t,i){var r,n=zt.SerializationHelper.Parse((function(){return new c(e.name,t,e.shaderPath,e.options)}),e,t,i);for(r in e.textures)n.setTexture(r,zt.Texture.Parse(e.textures[r],t,i));for(r in e.textureArrays){for(var o=e.textureArrays[r],s=new Array,a=0;a<o.length;a++)s.push(zt.Texture.Parse(o[a],t,i));n.setTextureArray(r,s)}for(r in e.floats)n.setFloat(r,e.floats[r]);for(r in e.floatsArrays)n.setFloats(r,e.floatsArrays[r]);for(r in e.colors3)n.setColor3(r,zt.Color3.FromArray(e.colors3[r]));for(r in e.colors3Arrays){var l=e.colors3Arrays[r].reduce((function(e,t,i){return i%3==0?e.push([t]):e[e.length-1].push(t),e}),[]).map((function(e){return zt.Color3.FromArray(e)}));n.setColor3Array(r,l)}for(r in e.colors4)n.setColor4(r,zt.Color4.FromArray(e.colors4[r]));for(r in e.vectors2)n.setVector2(r,zt.Vector2.FromArray(e.vectors2[r]));for(r in e.vectors3)n.setVector3(r,zt.Vector3.FromArray(e.vectors3[r]));for(r in e.vectors4)n.setVector4(r,zt.Vector4.FromArray(e.vectors4[r]));for(r in e.matrices)n.setMatrix(r,zt.Matrix.FromArray(e.matrices[r]));for(r in e.matrices3x3)n.setMatrix3x3(r,e.matrices3x3[r]);for(r in e.matrices2x2)n.setMatrix2x2(r,e.matrices2x2[r]);for(r in e.vectors2Arrays)n.setArray2(r,e.vectors2Arrays[r]);for(r in e.vectors3Arrays)n.setArray3(r,e.vectors3Arrays[r]);return n},c})(zt.Material),zt.ShaderMaterial=Gt,kt=$a||($a={}),Wt=(function(r){function n(e,t){var i=r.call(this,e,t)||this;return i.generateOctree=!1,i}return T(n,r),n.prototype.getClassName=function(){return"GroundMesh"},Object.defineProperty(n.prototype,"subdivisions",{get:function(){return Math.min(this._subdivisionsX,this._subdivisionsY)},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"subdivisionsX",{get:function(){return this._subdivisionsX},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"subdivisionsY",{get:function(){return this._subdivisionsY},enumerable:!0,configurable:!0}),n.prototype.optimize=function(e,t){void 0===t&&(t=32),this._subdivisionsX=e,this._subdivisionsY=e,this.subdivide(e);this.createOrUpdateSubmeshesOctree&&this.createOrUpdateSubmeshesOctree(t)},n.prototype.getHeightAtCoordinates=function(e,t){var i=this.getWorldMatrix(),r=kt.Tmp.Matrix[5];i.invertToRef(r);var n=kt.Tmp.Vector3[8];if(kt.Vector3.TransformCoordinatesFromFloatsToRef(e,0,t,r,n),e=n.x,t=n.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this.position.y;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var o=this._getFacetAt(e,t),s=-(o.x*e+o.z*t+o.w)/o.y;return kt.Vector3.TransformCoordinatesFromFloatsToRef(0,s,0,i,n),n.y},n.prototype.getNormalAtCoordinates=function(e,t){var i=new kt.Vector3(0,1,0);return this.getNormalAtCoordinatesToRef(e,t,i),i},n.prototype.getNormalAtCoordinatesToRef=function(e,t,i){var r=this.getWorldMatrix(),n=kt.Tmp.Matrix[5];r.invertToRef(n);var o=kt.Tmp.Vector3[8];if(kt.Vector3.TransformCoordinatesFromFloatsToRef(e,0,t,n,o),e=o.x,t=o.z,e<this._minX||e>this._maxX||t<this._minZ||t>this._maxZ)return this;this._heightQuads&&0!=this._heightQuads.length||(this._initHeightQuads(),this._computeHeightQuads());var s=this._getFacetAt(e,t);return kt.Vector3.TransformNormalFromFloatsToRef(s.x,s.y,s.z,r,i),this},n.prototype.updateCoordinateHeights=function(){return this._heightQuads&&0!=this._heightQuads.length||this._initHeightQuads(),this._computeHeightQuads(),this},n.prototype._getFacetAt=function(e,t){var i=Math.floor((e+this._maxX)*this._subdivisionsX/this._width),r=Math.floor(-(t+this._maxZ)*this._subdivisionsY/this._height+this._subdivisionsY),n=this._heightQuads[r*this._subdivisionsX+i];return t<n.slope.x*e+n.slope.y?n.facet1:n.facet2},n.prototype._initHeightQuads=function(){var e=this._subdivisionsX,t=this._subdivisionsY;this._heightQuads=new Array;for(var i=0;i<t;i++)for(var r=0;r<e;r++){var n={slope:kt.Vector2.Zero(),facet1:new kt.Vector4(0,0,0,0),facet2:new kt.Vector4(0,0,0,0)};this._heightQuads[i*e+r]=n}return this},n.prototype._computeHeightQuads=function(){var e=this.getVerticesData(kt.VertexBuffer.PositionKind);if(!e)return this;for(var t=kt.Tmp.Vector3[3],i=kt.Tmp.Vector3[2],r=kt.Tmp.Vector3[1],n=kt.Tmp.Vector3[0],o=kt.Tmp.Vector3[4],s=kt.Tmp.Vector3[5],a=kt.Tmp.Vector3[6],l=kt.Tmp.Vector3[7],c=kt.Tmp.Vector3[8],h=0,u=0,d=0,f=0,p=0,m=0,_=0,g=this._subdivisionsX,v=this._subdivisionsY,y=0;y<v;y++)for(var b=0;b<g;b++){h=3*b,u=y*(g+1)*3,d=(y+1)*(g+1)*3,t.x=e[u+h],t.y=e[u+h+1],t.z=e[u+h+2],i.x=e[u+h+3],i.y=e[u+h+4],i.z=e[u+h+5],r.x=e[d+h],r.y=e[d+h+1],r.z=e[d+h+2],n.x=e[d+h+3],n.y=e[d+h+4],n.z=e[d+h+5],f=(n.z-t.z)/(n.x-t.x),p=t.z-f*t.x,i.subtractToRef(t,o),r.subtractToRef(t,s),n.subtractToRef(t,a),kt.Vector3.CrossToRef(a,s,l),kt.Vector3.CrossToRef(o,a,c),l.normalize(),c.normalize(),m=-(l.x*t.x+l.y*t.y+l.z*t.z),_=-(c.x*i.x+c.y*i.y+c.z*i.z);var T=this._heightQuads[y*g+b];T.slope.copyFromFloats(f,p),T.facet1.copyFromFloats(l.x,l.y,l.z,m),T.facet2.copyFromFloats(c.x,c.y,c.z,_)}return this},n.prototype.serialize=function(e){r.prototype.serialize.call(this,e),e.subdivisionsX=this._subdivisionsX,e.subdivisionsY=this._subdivisionsY,e.minX=this._minX,e.maxX=this._maxX,e.minZ=this._minZ,e.maxZ=this._maxZ,e.width=this._width,e.height=this._height},n.Parse=function(e,t){var i=new n(e.name,t);return i._subdivisionsX=e.subdivisionsX||1,i._subdivisionsY=e.subdivisionsY||1,i._minX=e.minX,i._maxX=e.maxX,i._minZ=e.minZ,i._maxZ=e.maxZ,i._width=e.width,i._height=e.height,i},n})(kt.Mesh),kt.GroundMesh=Wt,Ht=$a||($a={}),Xt=(function(r){function e(e,t){var i=r.call(this,e,t.getScene())||this;return t.instances.push(i),i._sourceMesh=t,i.position.copyFrom(t.position),i.rotation.copyFrom(t.rotation),i.scaling.copyFrom(t.scaling),t.rotationQuaternion&&(i.rotationQuaternion=t.rotationQuaternion.clone()),i.infiniteDistance=t.infiniteDistance,i.setPivotMatrix(t.getPivotMatrix()),i.refreshBoundingInfo(),i._syncSubMeshes(),i}return T(e,r),e.prototype.getClassName=function(){return"InstancedMesh"},Object.defineProperty(e.prototype,"receiveShadows",{get:function(){return this._sourceMesh.receiveShadows},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"material",{get:function(){return this._sourceMesh.material},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"visibility",{get:function(){return this._sourceMesh.visibility},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"skeleton",{get:function(){return this._sourceMesh.skeleton},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._sourceMesh.renderingGroupId},set:function(e){this._sourceMesh&&e!==this._sourceMesh.renderingGroupId&&Ht.Tools.Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene")},enumerable:!0,configurable:!0}),e.prototype.getTotalVertices=function(){return this._sourceMesh.getTotalVertices()},Object.defineProperty(e.prototype,"sourceMesh",{get:function(){return this._sourceMesh},enumerable:!0,configurable:!0}),e.prototype.isReady=function(e){return void 0===e&&(e=!1),this._sourceMesh.isReady(e,!0)},e.prototype.getVerticesData=function(e,t){return this._sourceMesh.getVerticesData(e,t)},e.prototype.setVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.setVerticesData(e,t,i,r),this.sourceMesh},e.prototype.updateVerticesData=function(e,t,i,r){return this.sourceMesh&&this.sourceMesh.updateVerticesData(e,t,i,r),this.sourceMesh},e.prototype.setIndices=function(e,t){return void 0===t&&(t=null),this.sourceMesh&&this.sourceMesh.setIndices(e,t),this.sourceMesh},e.prototype.isVerticesDataPresent=function(e){return this._sourceMesh.isVerticesDataPresent(e)},e.prototype.getIndices=function(){return this._sourceMesh.getIndices()},Object.defineProperty(e.prototype,"_positions",{get:function(){return this._sourceMesh._positions},enumerable:!0,configurable:!0}),e.prototype.refreshBoundingInfo=function(){var e=this._sourceMesh.getBoundingInfo();return this._boundingInfo=new Ht.BoundingInfo(e.minimum.clone(),e.maximum.clone()),this._updateBoundingInfo(),this},e.prototype._preActivate=function(){return this._currentLOD&&this._currentLOD._preActivate(),this},e.prototype._activate=function(e){return this._currentLOD&&this._currentLOD._registerInstanceForRenderId(this,e),this},e.prototype.getLOD=function(e){if(!e)return this;var t=this.getBoundingInfo();return this._currentLOD=this.sourceMesh.getLOD(e,t.boundingSphere),this._currentLOD===this.sourceMesh?this:this._currentLOD},e.prototype._syncSubMeshes=function(){if(this.releaseSubMeshes(),this._sourceMesh.subMeshes)for(var e=0;e<this._sourceMesh.subMeshes.length;e++)this._sourceMesh.subMeshes[e].clone(this,this._sourceMesh);return this},e.prototype._generatePointsArray=function(){return this._sourceMesh._generatePointsArray()},e.prototype.clone=function(e,t,i){var r=this._sourceMesh.createInstance(e);if(Ht.Tools.DeepCopy(this,r,["name","subMeshes","uniqueId"],[]),this.refreshBoundingInfo(),t&&(r.parent=t),!i)for(var n=0;n<this.getScene().meshes.length;n++){var o=this.getScene().meshes[n];o.parent===this&&o.clone(o.name,r)}return r.computeWorldMatrix(!0),r},e.prototype.dispose=function(e,t){void 0===t&&(t=!1);var i=this._sourceMesh.instances.indexOf(this);this._sourceMesh.instances.splice(i,1),r.prototype.dispose.call(this,e,t)},e})(Ht.AbstractMesh),Ht.InstancedMesh=Xt,jt=$a||($a={}),Yt=(function(c){function r(e,t,i,r,n,o,s){void 0===t&&(t=null),void 0===i&&(i=null);var a=c.call(this,e,t,i,r,n)||this;a.useVertexColor=o,a.useVertexAlpha=s,a.color=new jt.Color3(1,1,1),a.alpha=1,r&&(a.color=r.color.clone(),a.alpha=r.alpha,a.useVertexColor=r.useVertexColor,a.useVertexAlpha=r.useVertexAlpha),a._intersectionThreshold=.1;var l={attributes:[jt.VertexBuffer.PositionKind,"world0","world1","world2","world3"],uniforms:["world","viewProjection"],needAlphaBlending:!0,defines:[]};return!1===s&&(l.needAlphaBlending=!1),o?(l.defines.push("#define VERTEXCOLOR"),l.attributes.push(jt.VertexBuffer.ColorKind)):l.uniforms.push("color"),a._colorShader=new jt.ShaderMaterial("colorShader",a.getScene(),"color",l),a}return T(r,c),Object.defineProperty(r.prototype,"intersectionThreshold",{get:function(){return this._intersectionThreshold},set:function(e){this._intersectionThreshold!==e&&(this._intersectionThreshold=e,this.geometry&&(this.geometry.boundingBias=new jt.Vector2(0,e)))},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"LinesMesh"},Object.defineProperty(r.prototype,"material",{get:function(){return this._colorShader},set:function(e){},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"checkCollisions",{get:function(){return!1},enumerable:!0,configurable:!0}),r.prototype._bind=function(e,t,i){return this._geometry&&(this._geometry._bind(this._colorShader.getEffect()),this.useVertexColor||this._colorShader.setColor4("color",this.color.toColor4(this.alpha))),this},r.prototype._draw=function(e,t,i){return this._geometry&&this._geometry.getVertexBuffers()&&(this._unIndexed||this._geometry.getIndexBuffer())&&this.getScene().getEngine().drawElementsType(jt.Material.LineListDrawMode,e.indexStart,e.indexCount,i),this},r.prototype.dispose=function(e){this._colorShader.dispose(),c.prototype.dispose.call(this,e)},r.prototype.clone=function(e,t,i){return new r(e,this.getScene(),t,this,i)},r})(jt.Mesh),jt.LinesMesh=Yt,Kt=$a||($a={}),Qt=(function(){function e(){this._count=0,this._data={}}return e.prototype.copyFrom=function(e){var i=this;this.clear(),e.forEach((function(e,t){return i.add(e,t)}))},e.prototype.get=function(e){var t=this._data[e];if(void 0!==t)return t},e.prototype.getOrAddWithFactory=function(e,t){var i=this.get(e);return void 0!==i||(i=t(e))&&this.add(e,i),i},e.prototype.getOrAdd=function(e,t){var i=this.get(e);return void 0!==i?i:(this.add(e,t),t)},e.prototype.contains=function(e){return void 0!==this._data[e]},e.prototype.add=function(e,t){return void 0===this._data[e]&&(this._data[e]=t,++this._count,!0)},e.prototype.set=function(e,t){return void 0!==this._data[e]&&(this._data[e]=t,!0)},e.prototype.getAndRemove=function(e){var t=this.get(e);return void 0!==t?(delete this._data[e],--this._count,t):null},e.prototype.remove=function(e){return!!this.contains(e)&&(delete this._data[e],--this._count,!0)},e.prototype.clear=function(){this._data={},this._count=0},Object.defineProperty(e.prototype,"count",{get:function(){return this._count},enumerable:!0,configurable:!0}),e.prototype.forEach=function(e){for(var t in this._data){e(t,this._data[t])}},e.prototype.first=function(e){for(var t in this._data){var i=e(t,this._data[t]);if(i)return i}return null},e})(),Kt.StringDictionary=Qt,Zt=$a||($a={}),qt=Zt.Debug||(Zt.Debug={}),Jt=(function(){function e(e,t,i,r,n){void 0===r&&(r=!0),void 0===n&&(n=1),this.skeleton=e,this.mesh=t,this.autoUpdateBonesMatrices=r,this.renderingGroupId=n,this.color=Zt.Color3.White(),this._debugLines=new Array,this._isEnabled=!1,this._scene=i,this.update(),this._renderFunction=this.update.bind(this)}return Object.defineProperty(e.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&((this._isEnabled=e)?this._scene.registerBeforeRender(this._renderFunction):this._scene.unregisterBeforeRender(this._renderFunction))},enumerable:!0,configurable:!0}),e.prototype._getBonePosition=function(e,t,i,r,n,o){void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=0);var s=Zt.Tmp.Matrix[0],a=t.getParent();if(s.copyFrom(t.getLocalMatrix()),0!==r||0!==n||0!==o){var l=Zt.Tmp.Matrix[1];Zt.Matrix.IdentityToRef(l),l.m[12]=r,l.m[13]=n,l.m[14]=o,l.multiplyToRef(s,s)}a&&s.multiplyToRef(a.getAbsoluteTransform(),s),s.multiplyToRef(i,s),e.x=s.m[12],e.y=s.m[13],e.z=s.m[14]},e.prototype._getLinesForBonesWithLength=function(e,t){for(var i=e.length,r=this.mesh.position,n=0;n<i;n++){var o=e[n],s=this._debugLines[n];s||(s=[Zt.Vector3.Zero(),Zt.Vector3.Zero()],this._debugLines[n]=s),this._getBonePosition(s[0],o,t),this._getBonePosition(s[1],o,t,0,o.length,0),s[0].subtractInPlace(r),s[1].subtractInPlace(r)}},e.prototype._getLinesForBonesNoLength=function(e,t){for(var i=e.length,r=0,n=this.mesh.position,o=i-1;0<=o;o--){var s=e[o],a=s.getParent();if(a){var l=this._debugLines[r];l||(l=[Zt.Vector3.Zero(),Zt.Vector3.Zero()],this._debugLines[r]=l),s.getAbsolutePositionToRef(this.mesh,l[0]),a.getAbsolutePositionToRef(this.mesh,l[1]),l[0].subtractInPlace(n),l[1].subtractInPlace(n),r++}}},e.prototype.update=function(){this.autoUpdateBonesMatrices&&this.skeleton.computeAbsoluteTransforms(),void 0===this.skeleton.bones[0].length?this._getLinesForBonesNoLength(this.skeleton.bones,this.mesh.getWorldMatrix()):this._getLinesForBonesWithLength(this.skeleton.bones,this.mesh.getWorldMatrix()),this._debugMesh?Zt.MeshBuilder.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:this._debugMesh},this._scene):(this._debugMesh=Zt.MeshBuilder.CreateLineSystem("",{lines:this._debugLines,updatable:!0,instance:null},this._scene),this._debugMesh.renderingGroupId=this.renderingGroupId),this._debugMesh.position.copyFrom(this.mesh.position),this._debugMesh.color=this.color},e.prototype.dispose=function(){this._debugMesh&&(this.isEnabled=!1,this._debugMesh.dispose(),this._debugMesh=null)},e})(),qt.SkeletonViewer=Jt,$t=$a||($a={}),ei=$t.Debug||($t.Debug={}),ti=(function(){function e(e,t){void 0===t&&(t=1),this._xline=[$t.Vector3.Zero(),$t.Vector3.Zero()],this._yline=[$t.Vector3.Zero(),$t.Vector3.Zero()],this._zline=[$t.Vector3.Zero(),$t.Vector3.Zero()],this.scaleLines=1,this.scaleLines=t,this._xmesh=$t.Mesh.CreateLines("xline",this._xline,e,!0),this._ymesh=$t.Mesh.CreateLines("yline",this._yline,e,!0),this._zmesh=$t.Mesh.CreateLines("zline",this._zline,e,!0),this._xmesh.renderingGroupId=2,this._ymesh.renderingGroupId=2,this._zmesh.renderingGroupId=2,this._xmesh.material.checkReadyOnlyOnce=!0,this._xmesh.color=new $t.Color3(1,0,0),this._ymesh.material.checkReadyOnlyOnce=!0,this._ymesh.color=new $t.Color3(0,1,0),this._zmesh.material.checkReadyOnlyOnce=!0,this._zmesh.color=new $t.Color3(0,0,1),this.scene=e}return e.prototype.update=function(e,t,i,r){var n=this.scaleLines;this._xmesh&&this._xmesh.position.copyFrom(e),this._ymesh&&this._ymesh.position.copyFrom(e),this._zmesh&&this._zmesh.position.copyFrom(e);var o=this._xline[1];o.x=t.x*n,o.y=t.y*n,o.z=t.z*n,$t.Mesh.CreateLines("",this._xline,null,!1,this._xmesh),(o=this._yline[1]).x=i.x*n,o.y=i.y*n,o.z=i.z*n,$t.Mesh.CreateLines("",this._yline,null,!1,this._ymesh),(o=this._zline[1]).x=r.x*n,o.y=r.y*n,o.z=r.z*n,$t.Mesh.CreateLines("",this._zline,null,!1,this._zmesh)},e.prototype.dispose=function(){this._xmesh&&this._xmesh.dispose(),this._ymesh&&this._ymesh.dispose(),this._zmesh&&this._zmesh.dispose(),this._xmesh=null,this._ymesh=null,this._zmesh=null,this.scene=null},e})(),ei.AxesViewer=ti,ii=$a||($a={}),ri=ii.Debug||(ii.Debug={}),ni=(function(o){function e(e,t,i,r){void 0===r&&(r=1);var n=o.call(this,e,r)||this;return n.pos=ii.Vector3.Zero(),n.xaxis=ii.Vector3.Zero(),n.yaxis=ii.Vector3.Zero(),n.zaxis=ii.Vector3.Zero(),n.mesh=i,n.bone=t,n}return T(e,o),e.prototype.update=function(){if(this.mesh&&this.bone){var e=this.bone;e.getAbsolutePositionToRef(this.mesh,this.pos),e.getDirectionToRef(ii.Axis.X,this.mesh,this.xaxis),e.getDirectionToRef(ii.Axis.Y,this.mesh,this.yaxis),e.getDirectionToRef(ii.Axis.Z,this.mesh,this.zaxis),o.prototype.update.call(this,this.pos,this.xaxis,this.yaxis,this.zaxis)}},e.prototype.dispose=function(){this.mesh&&(this.mesh=null,this.bone=null,o.prototype.dispose.call(this))},e})(ri.AxesViewer),ri.BoneAxesViewer=ni,oi=$a||($a={}),si=(function(){function n(e){this.ray=e}return n.CreateAndShow=function(e,t,i){var r=new n(e);return r.show(t,i),r},n.prototype.show=function(e,t){if(!this._renderFunction&&this.ray){var i=this.ray;this._renderFunction=this._render.bind(this),this._scene=e,this._renderPoints=[i.origin,i.origin.add(i.direction.scale(i.length))],this._renderLine=oi.Mesh.CreateLines("ray",this._renderPoints,e,!0),this._renderFunction&&this._scene.registerBeforeRender(this._renderFunction)}t&&this._renderLine&&this._renderLine.color.copyFrom(t)},n.prototype.hide=function(){this._renderFunction&&this._scene&&(this._scene.unregisterBeforeRender(this._renderFunction),this._scene=null,this._renderFunction=null,this._renderLine&&(this._renderLine.dispose(),this._renderLine=null),this._renderPoints=[])},n.prototype._render=function(){var e=this.ray;if(e){var t=this._renderPoints[1],i=Math.min(e.length,1e6);t.copyFrom(e.direction),t.scaleInPlace(i),t.addInPlace(e.origin),oi.Mesh.CreateLines("ray",this._renderPoints,this._scene,!0,this._renderLine)}},n.prototype.attachToMesh=function(e,t,i,r){this._attachedToMesh=e;var n=this.ray;n&&(n.direction||(n.direction=oi.Vector3.Zero()),n.origin||(n.origin=oi.Vector3.Zero()),r&&(n.length=r),i||(i=oi.Vector3.Zero()),t||(t=new oi.Vector3(0,0,-1)),this._meshSpaceDirection?(this._meshSpaceDirection.copyFrom(t),this._meshSpaceOrigin.copyFrom(i)):(this._meshSpaceDirection=t.clone(),this._meshSpaceOrigin=i.clone()),this._updateToMeshFunction||(this._updateToMeshFunction=this._updateToMesh.bind(this),this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction)),this._updateToMesh())},n.prototype.detachFromMesh=function(){this._attachedToMesh&&(this._updateToMeshFunction&&this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction),this._attachedToMesh=null,this._updateToMeshFunction=null)},n.prototype._updateToMesh=function(){var e=this.ray;this._attachedToMesh&&e&&(this._attachedToMesh._isDisposed?this.detachFromMesh():(this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection,e.direction),oi.Vector3.TransformCoordinatesToRef(this._meshSpaceOrigin,this._attachedToMesh.getWorldMatrix(),e.origin)))},n.prototype.dispose=function(){this.hide(),this.detachFromMesh(),this.ray=null},n})(),oi.RayHelper=si,(function(i){Object.defineProperty(i.Scene.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new e(this)),this._debugLayer},enumerable:!0,configurable:!0});var e=(function(){function t(e){var t=this;this.BJSINSPECTOR="undefined"!=typeof INSPECTOR?INSPECTOR:void 0,this.onPropertyChangedObservable=new i.Observable,this._scene=e,this._scene.onDisposeObservable.add((function(){t._scene._debugLayer&&t._scene._debugLayer.hide()}))}return t.prototype._createInspector=function(e){void 0===e&&(e={});var t=e.popup||!1,i=e.initialTab||0,r=e.parentElement||null;this._inspector||(this.BJSINSPECTOR=this.BJSINSPECTOR||"undefined"!=typeof INSPECTOR?INSPECTOR:void 0,this._inspector=new this.BJSINSPECTOR.Inspector(this._scene,t,i,r,e.newColors))},t.prototype.isVisible=function(){return!!this._inspector},t.prototype.hide=function(){if(this._inspector){try{this._inspector.dispose()}catch(e){}this.onPropertyChangedObservable.clear(),this._inspector=null}},t.prototype.show=function(e){void 0===e&&(e={}),void 0===this.BJSINSPECTOR?i.Tools.LoadScript(t.InspectorURL,this._createInspector.bind(this,e)):this._createInspector(e)},t.prototype.getActiveTab=function(){return this._inspector?this._inspector.getActiveTabIndex():-1},t.InspectorURL="https://preview.babylonjs.com/inspector/babylon.inspector.bundle.js",t})();i.DebugLayer=e})($a||($a={})),ai=$a||($a={}),li=ai.Debug||(ai.Debug={}),ci=(function(){function e(e){this._impostors=[],this._meshes=[],this._numMeshes=0,this._scene=e||ai.Engine.LastCreatedScene;var t=this._scene.getPhysicsEngine();t&&(this._physicsEnginePlugin=t.getPhysicsPlugin())}return e.prototype._updateDebugMeshes=function(){for(var e=this._physicsEnginePlugin,t=0;t<this._numMeshes;t++){var i=this._impostors[t];if(i)if(i.isDisposed)this.hideImpostor(this._impostors[t--]);else{var r=this._meshes[t];r&&e&&e.syncMeshWithImpostor(r,i)}}},e.prototype.showImpostor=function(e){if(this._scene){for(var t=0;t<this._numMeshes;t++)if(this._impostors[t]==e)return;var i=this._getDebugMesh(e,this._scene);i&&(this._impostors[this._numMeshes]=e,this._meshes[this._numMeshes]=i,0===this._numMeshes&&(this._renderFunction=this._updateDebugMeshes.bind(this),this._scene.registerBeforeRender(this._renderFunction)),this._numMeshes++)}},e.prototype.hideImpostor=function(e){if(e&&this._scene){for(var t=!1,i=0;i<this._numMeshes;i++)if(this._impostors[i]==e){var r=this._meshes[i];if(!r)continue;this._scene.removeMesh(r),r.dispose(),this._numMeshes--,0<this._numMeshes?(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 ai.StandardMaterial("",e),this._debugMaterial.wireframe=!0),this._debugMaterial},e.prototype._getDebugBoxMesh=function(e){return this._debugBoxMesh||(this._debugBoxMesh=ai.MeshBuilder.CreateBox("physicsBodyBoxViewMesh",{size:1},e),this._debugBoxMesh.renderingGroupId=1,this._debugBoxMesh.rotationQuaternion=ai.Quaternion.Identity(),this._debugBoxMesh.material=this._getDebugMaterial(e),e.removeMesh(this._debugBoxMesh)),this._debugBoxMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugSphereMesh=function(e){return this._debugSphereMesh||(this._debugSphereMesh=ai.MeshBuilder.CreateSphere("physicsBodySphereViewMesh",{diameter:1},e),this._debugSphereMesh.renderingGroupId=1,this._debugSphereMesh.rotationQuaternion=ai.Quaternion.Identity(),this._debugSphereMesh.material=this._getDebugMaterial(e),e.removeMesh(this._debugSphereMesh)),this._debugSphereMesh.createInstance("physicsBodyBoxViewInstance")},e.prototype._getDebugMesh=function(e,t){var i=null;if(e.type==ai.PhysicsImpostor.BoxImpostor)i=this._getDebugBoxMesh(t),e.getBoxSizeToRef(i.scaling);else if(e.type==ai.PhysicsImpostor.SphereImpostor){i=this._getDebugSphereMesh(t);var r=e.getRadius();i.scaling.x=2*r,i.scaling.y=2*r,i.scaling.z=2*r}return i},e.prototype.dispose=function(){for(var e=0;e<this._numMeshes;e++)this.hideImpostor(this._impostors[e]);this._debugBoxMesh&&this._debugBoxMesh.dispose(),this._debugSphereMesh&&this._debugSphereMesh.dispose(),this._debugMaterial&&this._debugMaterial.dispose(),this._impostors.length=0,this._scene=null,this._physicsEnginePlugin=null},e})(),li.PhysicsViewer=ci,(function(l){Object.defineProperty(l.Scene.prototype,"forceShowBoundingBoxes",{get:function(){return this._forceShowBoundingBoxes||!1},set:function(e){(this._forceShowBoundingBoxes=e)&&this.getBoundingBoxRenderer()},enumerable:!0,configurable:!0}),l.Scene.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new e(this)),this._boundingBoxRenderer},Object.defineProperty(l.AbstractMesh.prototype,"showBoundingBox",{get:function(){return this._showBoundingBox||!1},set:function(e){(this._showBoundingBox=e)&&this.getScene().getBoundingBoxRenderer()},enumerable:!0,configurable:!0});var e=(function(){function e(e){this.name=l.SceneComponentConstants.NAME_BOUNDINGBOXRENDERER,this.frontColor=new l.Color3(1,1,1),this.backColor=new l.Color3(.1,.1,.1),this.showBackLines=!0,this.renderList=new l.SmartArray(32),this._vertexBuffers={},(this.scene=e)._addComponent(this)}return e.prototype.register=function(){this.scene._beforeEvaluateActiveMeshStage.registerStep(l.SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER,this,this.reset),this.scene._activeMeshStage.registerStep(l.SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER,this,this._activeMesh),this.scene._evaluateSubMeshStage.registerStep(l.SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER,this,this._evaluateSubMesh),this.scene._afterRenderingGroupDrawStage.registerStep(l.SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER,this,this.render)},e.prototype._evaluateSubMesh=function(e,t){if(e.showSubMeshesBoundingBox){var i=t.getBoundingInfo();null!=i&&(i.boundingBox._tag=e.renderingGroupId,this.renderList.push(i.boundingBox))}},e.prototype._activeMesh=function(e,t){if(e.showBoundingBox||this.scene.forceShowBoundingBoxes){var i=e.getBoundingInfo();i.boundingBox._tag=t.renderingGroupId,this.renderList.push(i.boundingBox)}},e.prototype._prepareRessources=function(){if(!this._colorShader){this._colorShader=new l.ShaderMaterial("colorShader",this.scene,"color",{attributes:[l.VertexBuffer.PositionKind],uniforms:["world","viewProjection","color"]});var e=this.scene.getEngine(),t=l.VertexData.CreateBox({size:1});this._vertexBuffers[l.VertexBuffer.PositionKind]=new l.VertexBuffer(e,t.positions,l.VertexBuffer.PositionKind,!1),this._createIndexBuffer()}},e.prototype._createIndexBuffer=function(){var e=this.scene.getEngine();this._indexBuffer=e.createIndexBuffer([0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,7,1,6,2,5,3,4])},e.prototype.rebuild=function(){var e=this._vertexBuffers[l.VertexBuffer.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.reset=function(){this.renderList.reset()},e.prototype.render=function(e){if(0!==this.renderList.length&&(this._prepareRessources(),this._colorShader.isReady())){var t=this.scene.getEngine();t.setDepthWrite(!1),this._colorShader._preBind();for(var i=0;i<this.renderList.length;i++){var r=this.renderList.data[i];if(r._tag===e){var n=r.minimum,o=r.maximum.subtract(n),s=n.add(o.scale(.5)),a=l.Matrix.Scaling(o.x,o.y,o.z).multiply(l.Matrix.Translation(s.x,s.y,s.z)).multiply(r.getWorldMatrix());t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),this.showBackLines&&(t.setDepthFunctionToGreaterOrEqual(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.backColor.toColor4()),this._colorShader.bind(a),t.drawElementsType(l.Material.LineListDrawMode,0,24)),t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.setColor4("color",this.frontColor.toColor4()),this._colorShader.bind(a),t.drawElementsType(l.Material.LineListDrawMode,0,24)}}this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0)}},e.prototype.renderOcclusionBoundingBox=function(e){if(this._prepareRessources(),this._colorShader.isReady()&&e._boundingInfo){var t=this.scene.getEngine();t.setDepthWrite(!1),t.setColorWrite(!1),this._colorShader._preBind();var i=e._boundingInfo.boundingBox,r=i.minimum,n=i.maximum.subtract(r),o=r.add(n.scale(.5)),s=l.Matrix.Scaling(n.x,n.y,n.z).multiply(l.Matrix.Translation(o.x,o.y,o.z)).multiply(i.getWorldMatrix());t.bindBuffers(this._vertexBuffers,this._indexBuffer,this._colorShader.getEffect()),t.setDepthFunctionToLess(),this.scene.resetCachedMaterial(),this._colorShader.bind(s),t.drawElementsType(l.Material.LineListDrawMode,0,24),this._colorShader.unbind(),t.setDepthFunctionToLessOrEqual(),t.setDepthWrite(!0),t.setColorWrite(!0)}},e.prototype.dispose=function(){if(this._colorShader){this.renderList.dispose(),this._colorShader.dispose();var e=this._vertexBuffers[l.VertexBuffer.PositionKind];e&&(e.dispose(),this._vertexBuffers[l.VertexBuffer.PositionKind]=null),this.scene.getEngine()._releaseBuffer(this._indexBuffer)}},e})();l.BoundingBoxRenderer=e})($a||($a={})),(hi=$a||($a={})).Engine.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},hi.Engine.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},hi.Engine.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},hi.Engine.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},hi.Engine.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},hi.Engine.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},hi.Engine.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e)},ui=$a||($a={}),di=(function(h){function o(e,t,i,r){void 0===r&&(r=!1);var n=h.call(this,e)||this;n.layerMask=268435455,n._accumulatedCount=0,n._targetIndex=0,n._currentRenderId=-1,n._started=!1,n._stopped=!1,n._timeDelta=0,n._attributesStrideSize=21,n._actualFrame=0,n._rawTextureWidth=256,n.onDisposeObservable=new ui.Observable,n.forceDepthWrite=!1,n._preWarmDone=!1,n._scene=i||ui.Engine.LastCreatedScene,n._attachImageProcessingConfiguration(null),n._engine=n._scene.getEngine(),t.randomTextureSize||delete t.randomTextureSize;var o=ae({capacity:5e4,randomTextureSize:n._engine.getCaps().maxTextureSize},t),s=t;isFinite(s)&&(o.capacity=s),n._capacity=o.capacity,n._activeCount=o.capacity,n._currentActiveCount=0,n._isAnimationSheetEnabled=r,n._scene.particleSystems.push(n),n._updateEffectOptions={attributes:["position","age","life","seed","size","color","direction","initialDirection","angle","cellIndex","cellStartOffset","noiseCoordinates1","noiseCoordinates2"],uniformsNames:["currentCount","timeDelta","emitterWM","lifeTime","color1","color2","sizeRange","scaleRange","gravity","emitPower","direction1","direction2","minEmitBox","maxEmitBox","radius","directionRandomizer","height","coneAngle","stopFactor","angleRange","radiusRange","cellInfos","noiseStrength","limitVelocityDamping"],uniformBuffersNames:[],samplers:["randomSampler","randomSampler2","sizeGradientSampler","angularSpeedGradientSampler","velocityGradientSampler","limitVelocityGradientSampler","noiseSampler","dragGradientSampler"],defines:"",fallbacks:null,onCompiled:null,onError:null,indexParameters:null,maxSimultaneousLights:0,transformFeedbackVaryings:[]},n.particleEmitterType=new ui.BoxParticleEmitter;for(var a=Math.min(n._engine.getCaps().maxTextureSize,o.randomTextureSize),l=[],c=0;c<a;++c)l.push(Math.random()),l.push(Math.random()),l.push(Math.random()),l.push(Math.random());n._randomTexture=new ui.RawTexture(new Float32Array(l),a,1,ui.Engine.TEXTUREFORMAT_RGBA,n._scene,!1,!1,ui.Texture.NEAREST_SAMPLINGMODE,ui.Engine.TEXTURETYPE_FLOAT),n._randomTexture.wrapU=ui.Texture.WRAP_ADDRESSMODE,n._randomTexture.wrapV=ui.Texture.WRAP_ADDRESSMODE,l=[];for(c=0;c<a;++c)l.push(Math.random()),l.push(Math.random()),l.push(Math.random()),l.push(Math.random());return n._randomTexture2=new ui.RawTexture(new Float32Array(l),a,1,ui.Engine.TEXTUREFORMAT_RGBA,n._scene,!1,!1,ui.Texture.NEAREST_SAMPLINGMODE,ui.Engine.TEXTURETYPE_FLOAT),n._randomTexture2.wrapU=ui.Texture.WRAP_ADDRESSMODE,n._randomTexture2.wrapV=ui.Texture.WRAP_ADDRESSMODE,n._randomTextureSize=a,n}return T(o,h),Object.defineProperty(o,"IsSupported",{get:function(){return!!ui.Engine.LastCreatedEngine&&1<ui.Engine.LastCreatedEngine.webGLVersion},enumerable:!0,configurable:!0}),o.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(o.prototype,"activeParticleCount",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!0,configurable:!0}),o.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)},o.prototype.isStarted=function(){return this._started},o.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&&0<this.animations.length&&this.getScene().beginAnimation(this,this.beginAnimationFrom,this.beginAnimationTo,this.beginAnimationLoop))},o.prototype.stop=function(){this._stopped=!0},o.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},o.prototype.getClassName=function(){return"GPUParticleSystem"},o.prototype._removeGradientAndTexture=function(e,t,i){return h.prototype._removeGradientAndTexture.call(this,e,t,i),this._releaseBuffers(),this},o.prototype.addColorGradient=function(e,t,i){this._colorGradients||(this._colorGradients=[]);var r=new ui.ColorGradient;return r.gradient=e,r.color1=t,this._colorGradients.push(r),this._colorGradients.sort((function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0})),this._colorGradientsTexture&&(this._colorGradientsTexture.dispose(),this._colorGradientsTexture=null),this._releaseBuffers(),this},o.prototype.removeColorGradient=function(e){return this._removeGradientAndTexture(e,this._colorGradients,this._colorGradientsTexture),this._colorGradientsTexture=null,this},o.prototype._addFactorGradient=function(e,t,i){var r=new ui.FactorGradient;r.gradient=t,r.factor1=i,e.push(r),e.sort((function(e,t){return e.gradient<t.gradient?-1:e.gradient>t.gradient?1:0})),this._releaseBuffers()},o.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},o.prototype.removeSizeGradient=function(e){return this._removeGradientAndTexture(e,this._sizeGradients,this._sizeGradientsTexture),this._sizeGradientsTexture=null,this},o.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},o.prototype.removeAngularSpeedGradient=function(e){return this._removeGradientAndTexture(e,this._angularSpeedGradients,this._angularSpeedGradientsTexture),this._angularSpeedGradientsTexture=null,this},o.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},o.prototype.removeVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._velocityGradients,this._velocityGradientsTexture),this._velocityGradientsTexture=null,this},o.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},o.prototype.removeLimitVelocityGradient=function(e){return this._removeGradientAndTexture(e,this._limitVelocityGradients,this._limitVelocityGradientsTexture),this._limitVelocityGradientsTexture=null,this},o.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},o.prototype.removeDragGradient=function(e){return this._removeGradientAndTexture(e,this._dragGradients,this._dragGradientsTexture),this._dragGradientsTexture=null,this},o.prototype.addEmitRateGradient=function(e,t,i){return this},o.prototype.removeEmitRateGradient=function(e){return this},o.prototype.addStartSizeGradient=function(e,t,i){return this},o.prototype.removeStartSizeGradient=function(e){return this},o.prototype.addColorRemapGradient=function(e,t,i){return this},o.prototype.removeColorRemapGradient=function(e){return this},o.prototype.addAlphaRemapGradient=function(e,t,i){return this},o.prototype.removeAlphaRemapGradient=function(e){return this},o.prototype.addRampGradient=function(e,t){return this},o.prototype.removeRampGradient=function(e){return this},o.prototype.getRampGradients=function(){return null},Object.defineProperty(o.prototype,"useRampGradients",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0}),o.prototype.addLifeTimeGradient=function(e,t,i){return this},o.prototype.removeLifeTimeGradient=function(e){return this},o.prototype._reset=function(){this._releaseBuffers()},o.prototype._createUpdateVAO=function(e){var t={};t.position=e.createVertexBuffer("position",0,3),t.age=e.createVertexBuffer("age",3,1),t.life=e.createVertexBuffer("life",4,1),t.seed=e.createVertexBuffer("seed",5,4),t.size=e.createVertexBuffer("size",9,3);var i=12;this._colorGradientsTexture||(t.color=e.createVertexBuffer("color",i,4),i+=4),t.direction=e.createVertexBuffer("direction",i,3),i+=3,this._isBillboardBased||(t.initialDirection=e.createVertexBuffer("initialDirection",i,3),i+=3),this._angularSpeedGradientsTexture?(t.angle=e.createVertexBuffer("angle",i,1),i+=1):(t.angle=e.createVertexBuffer("angle",i,2),i+=2),this._isAnimationSheetEnabled&&(t.cellIndex=e.createVertexBuffer("cellIndex",i,1),i+=1,this.spriteRandomStartCell&&(t.cellStartOffset=e.createVertexBuffer("cellStartOffset",i,1),i+=1)),this.noiseTexture&&(t.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",i,3),i+=3,t.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",i,3),i+=3);var r=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),r},o.prototype._createRenderVAO=function(e,t){var i={};i.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0),i.age=e.createVertexBuffer("age",3,1,this._attributesStrideSize,!0),i.life=e.createVertexBuffer("life",4,1,this._attributesStrideSize,!0),i.size=e.createVertexBuffer("size",9,3,this._attributesStrideSize,!0);var r=12;this._colorGradientsTexture||(i.color=e.createVertexBuffer("color",r,4,this._attributesStrideSize,!0),r+=4),this.billboardMode===ui.ParticleSystem.BILLBOARDMODE_STRETCHED&&(i.direction=e.createVertexBuffer("direction",r,3,this._attributesStrideSize,!0)),r+=3,this._isBillboardBased||(i.initialDirection=e.createVertexBuffer("initialDirection",r,3,this._attributesStrideSize,!0),r+=3),i.angle=e.createVertexBuffer("angle",r,1,this._attributesStrideSize,!0),this._angularSpeedGradientsTexture?r++:r+=2,this._isAnimationSheetEnabled&&(i.cellIndex=e.createVertexBuffer("cellIndex",r,1,this._attributesStrideSize,!0),r+=1,this.spriteRandomStartCell&&(i.cellStartOffset=e.createVertexBuffer("cellStartOffset",r,1,this._attributesStrideSize,!0),r+=1)),this.noiseTexture&&(i.noiseCoordinates1=e.createVertexBuffer("noiseCoordinates1",r,3,this._attributesStrideSize,!0),r+=3,i.noiseCoordinates2=e.createVertexBuffer("noiseCoordinates2",r,3,this._attributesStrideSize,!0),r+=3),i.offset=t.createVertexBuffer("offset",0,2),i.uv=t.createVertexBuffer("uv",2,2);var n=this._engine.recordVertexArrayObject(i,null,this._renderEffect);return this._engine.bindArrayBuffer(null),n},o.prototype._initialize=function(e){if(void 0===e&&(e=!1),!this._buffer0||e){var t=this._scene.getEngine(),i=new Array;this.isBillboardBased||(this._attributesStrideSize+=3),this._colorGradientsTexture&&(this._attributesStrideSize-=4),this._angularSpeedGradientsTexture&&(this._attributesStrideSize-=1),this._isAnimationSheetEnabled&&(this._attributesStrideSize+=1,this.spriteRandomStartCell&&(this._attributesStrideSize+=1)),this.noiseTexture&&(this._attributesStrideSize+=6);for(var r=0;r<this._capacity;r++)i.push(0),i.push(0),i.push(0),i.push(0),i.push(0),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(0),i.push(0),i.push(0),this._colorGradientsTexture||(i.push(0),i.push(0),i.push(0),i.push(0)),i.push(0),i.push(0),i.push(0),this.isBillboardBased||(i.push(0),i.push(0),i.push(0)),i.push(0),this._angularSpeedGradientsTexture||i.push(0),this._isAnimationSheetEnabled&&(i.push(0),this.spriteRandomStartCell&&i.push(0)),this.noiseTexture&&(i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()),i.push(Math.random()));var n=new Float32Array([.5,.5,1,1,-.5,.5,0,1,-.5,-.5,0,0,.5,-.5,1,0]);this._buffer0=new ui.Buffer(t,i,!1,this._attributesStrideSize),this._buffer1=new ui.Buffer(t,i,!1,this._attributesStrideSize),this._spriteBuffer=new ui.Buffer(t,n,!1,4),this._updateVAO=[],this._updateVAO.push(this._createUpdateVAO(this._buffer0)),this._updateVAO.push(this._createUpdateVAO(this._buffer1)),this._renderVAO=[],this._renderVAO.push(this._createRenderVAO(this._buffer1,this._spriteBuffer)),this._renderVAO.push(this._createRenderVAO(this._buffer0,this._spriteBuffer)),this._sourceBuffer=this._buffer0,this._targetBuffer=this._buffer1}},o.prototype._recreateUpdateEffect=function(){var e=this.particleEmitterType?this.particleEmitterType.getEffectDefines():"";this._isBillboardBased&&(e+="\n#define BILLBOARD"),this._colorGradientsTexture&&(e+="\n#define COLORGRADIENTS"),this._sizeGradientsTexture&&(e+="\n#define SIZEGRADIENTS"),this._angularSpeedGradientsTexture&&(e+="\n#define ANGULARSPEEDGRADIENTS"),this._velocityGradientsTexture&&(e+="\n#define VELOCITYGRADIENTS"),this._limitVelocityGradientsTexture&&(e+="\n#define LIMITVELOCITYGRADIENTS"),this._dragGradientsTexture&&(e+="\n#define DRAGGRADIENTS"),this.isAnimationSheetEnabled&&(e+="\n#define ANIMATESHEET",this.spriteRandomStartCell&&(e+="\n#define ANIMATESHEETRANDOMSTART")),this.noiseTexture&&(e+="\n#define NOISE"),this._updateEffect&&this._updateEffectOptions.defines===e||(this._updateEffectOptions.transformFeedbackVaryings=["outPosition","outAge","outLife","outSeed","outSize"],this._colorGradientsTexture||this._updateEffectOptions.transformFeedbackVaryings.push("outColor"),this._updateEffectOptions.transformFeedbackVaryings.push("outDirection"),this._isBillboardBased||this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection"),this._updateEffectOptions.transformFeedbackVaryings.push("outAngle"),this.isAnimationSheetEnabled&&(this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex"),this.spriteRandomStartCell&&this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset")),this.noiseTexture&&(this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1"),this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2")),this._updateEffectOptions.defines=e,this._updateEffect=new ui.Effect("gpuUpdateParticles",this._updateEffectOptions,this._scene.getEngine()))},o.prototype._recreateRenderEffect=function(){var e="";if(this._scene.clipPlane&&(e="\n#define CLIPPLANE"),this._scene.clipPlane2&&(e="\n#define CLIPPLANE2"),this._scene.clipPlane3&&(e="\n#define CLIPPLANE3"),this._scene.clipPlane4&&(e="\n#define CLIPPLANE4"),this.blendMode===ui.ParticleSystem.BLENDMODE_MULTIPLY&&(e="\n#define BLENDMULTIPLYMODE"),this._isBillboardBased)switch(e+="\n#define BILLBOARD",this.billboardMode){case ui.ParticleSystem.BILLBOARDMODE_Y:e+="\n#define BILLBOARDY";break;case ui.ParticleSystem.BILLBOARDMODE_STRETCHED:e+="\n#define BILLBOARDSTRETCHED";break;case ui.ParticleSystem.BILLBOARDMODE_ALL:}if(this._colorGradientsTexture&&(e+="\n#define COLORGRADIENTS"),this.isAnimationSheetEnabled&&(e+="\n#define ANIMATESHEET"),this._imageProcessingConfiguration&&(this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines),e+="\n"+this._imageProcessingConfigurationDefines.toString()),!this._renderEffect||this._renderEffect.defines!==e){var t=["view","projection","colorDead","invView","vClipPlane","vClipPlane2","vClipPlane3","vClipPlane4","sheetInfos","translationPivot","eyePosition"],i=["textureSampler","colorGradientSampler"];ui.ImageProcessingConfiguration&&(ui.ImageProcessingConfiguration.PrepareUniforms(t,this._imageProcessingConfigurationDefines),ui.ImageProcessingConfiguration.PrepareSamplers(i,this._imageProcessingConfigurationDefines)),this._renderEffect=new ui.Effect("gpuRenderParticles",["position","age","life","size","color","offset","uv","direction","initialDirection","angle","cellIndex"],t,i,this._scene.getEngine(),e)}},o.prototype.animate=function(e){void 0===e&&(e=!1),this._timeDelta=this.updateSpeed*(e?this.preWarmStepOffset:this._scene.getAnimationRatio()),this._actualFrame+=this._timeDelta,this._stopped||this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()},o.prototype._createFactorGradientTexture=function(e,t){var i=this[t];if(e&&e.length&&!i){for(var r=new Float32Array(this._rawTextureWidth),n=0;n<this._rawTextureWidth;n++){var o=n/this._rawTextureWidth;ui.Tools.GetCurrentGradient(o,e,(function(e,t,i){r[n]=ui.Scalar.Lerp(e.factor1,t.factor1,i)}))}this[t]=ui.RawTexture.CreateRTexture(r,this._rawTextureWidth,1,this._scene,!1,!1,ui.Texture.NEAREST_SAMPLINGMODE)}},o.prototype._createSizeGradientTexture=function(){this._createFactorGradientTexture(this._sizeGradients,"_sizeGradientsTexture")},o.prototype._createAngularSpeedGradientTexture=function(){this._createFactorGradientTexture(this._angularSpeedGradients,"_angularSpeedGradientsTexture")},o.prototype._createVelocityGradientTexture=function(){this._createFactorGradientTexture(this._velocityGradients,"_velocityGradientsTexture")},o.prototype._createLimitVelocityGradientTexture=function(){this._createFactorGradientTexture(this._limitVelocityGradients,"_limitVelocityGradientsTexture")},o.prototype._createDragGradientTexture=function(){this._createFactorGradientTexture(this._dragGradients,"_dragGradientsTexture")},o.prototype._createColorGradientTexture=function(){if(this._colorGradients&&this._colorGradients.length&&!this._colorGradientsTexture){for(var r=new Uint8Array(4*this._rawTextureWidth),n=ui.Tmp.Color4[0],o=0;o<this._rawTextureWidth;o++){var e=o/this._rawTextureWidth;ui.Tools.GetCurrentGradient(e,this._colorGradients,(function(e,t,i){ui.Color4.LerpToRef(e.color1,t.color1,i,n),r[4*o]=255*n.r,r[4*o+1]=255*n.g,r[4*o+2]=255*n.b,r[4*o+3]=255*n.a}))}this._colorGradientsTexture=ui.RawTexture.CreateRGBATexture(r,this._rawTextureWidth,1,this._scene,!1,!1,ui.Texture.NEAREST_SAMPLINGMODE)}},o.prototype.render=function(e){if(void 0===e&&(e=!1),!this._started)return 0;if(this._createColorGradientTexture(),this._createSizeGradientTexture(),this._createAngularSpeedGradientTexture(),this._createVelocityGradientTexture(),this._createLimitVelocityGradientTexture(),this._createDragGradientTexture(),this._recreateUpdateEffect(),this._recreateRenderEffect(),!this.isReady())return 0;if(!e){if(!this._preWarmDone&&this.preWarmCycles){for(var t=0;t<this.preWarmCycles;t++)this.animate(!0),this.render(!0);this._preWarmDone=!0}if(this._currentRenderId===this._scene.getRenderId())return 0;this._currentRenderId=this._scene.getRenderId()}if(this._initialize(),this._accumulatedCount+=this.emitRate*this._timeDelta,1<this._accumulatedCount){var i=0|this._accumulatedCount;this._accumulatedCount-=i,this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+i)}if(!this._currentActiveCount)return 0;var r;if(this._engine.enableEffect(this._updateEffect),this._engine.setState(!1),this._updateEffect.setFloat("currentCount",this._currentActiveCount),this._updateEffect.setFloat("timeDelta",this._timeDelta),this._updateEffect.setFloat("stopFactor",this._stopped?0:1),this._updateEffect.setTexture("randomSampler",this._randomTexture),this._updateEffect.setTexture("randomSampler2",this._randomTexture2),this._updateEffect.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._colorGradientsTexture||(this._updateEffect.setDirectColor4("color1",this.color1),this._updateEffect.setDirectColor4("color2",this.color2)),this._updateEffect.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateEffect.setFloat4("scaleRange",this.minScaleX,this.maxScaleX,this.minScaleY,this.maxScaleY),this._updateEffect.setFloat4("angleRange",this.minAngularSpeed,this.maxAngularSpeed,this.minInitialRotation,this.maxInitialRotation),this._updateEffect.setVector3("gravity",this.gravity),this._sizeGradientsTexture&&this._updateEffect.setTexture("sizeGradientSampler",this._sizeGradientsTexture),this._angularSpeedGradientsTexture&&this._updateEffect.setTexture("angularSpeedGradientSampler",this._angularSpeedGradientsTexture),this._velocityGradientsTexture&&this._updateEffect.setTexture("velocityGradientSampler",this._velocityGradientsTexture),this._limitVelocityGradientsTexture&&(this._updateEffect.setTexture("limitVelocityGradientSampler",this._limitVelocityGradientsTexture),this._updateEffect.setFloat("limitVelocityDamping",this.limitVelocityDamping)),this._dragGradientsTexture&&this._updateEffect.setTexture("dragGradientSampler",this._dragGradientsTexture),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect),this._isAnimationSheetEnabled&&this._updateEffect.setFloat3("cellInfos",this.startSpriteCellID,this.endSpriteCellID,this.spriteCellChangeSpeed),this.noiseTexture&&(this._updateEffect.setTexture("noiseSampler",this.noiseTexture),this._updateEffect.setVector3("noiseStrength",this.noiseStrength)),this.emitter.position){r=this.emitter.getWorldMatrix()}else{var n=this.emitter;r=ui.Matrix.Translation(n.x,n.y,n.z)}if(this._updateEffect.setMatrix("emitterWM",r),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),this._engine.setRasterizerState(!1),this._engine.beginTransformFeedback(!0),this._engine.drawArraysType(ui.Material.PointListDrawMode,0,this._currentActiveCount),this._engine.endTransformFeedback(),this._engine.setRasterizerState(!0),this._engine.bindTransformFeedbackBuffer(null),!e){this._engine.enableEffect(this._renderEffect);var o=this._scene.getViewMatrix();if(this._renderEffect.setMatrix("view",o),this._renderEffect.setMatrix("projection",this._scene.getProjectionMatrix()),this._renderEffect.setTexture("textureSampler",this.particleTexture),this._renderEffect.setVector2("translationPivot",this.translationPivot),this._colorGradientsTexture?this._renderEffect.setTexture("colorGradientSampler",this._colorGradientsTexture):this._renderEffect.setDirectColor4("colorDead",this.colorDead),this._isAnimationSheetEnabled&&this.particleTexture){var s=this.particleTexture.getBaseSize();this._renderEffect.setFloat3("sheetInfos",this.spriteCellWidth/s.width,this.spriteCellHeight/s.height,s.width/this.spriteCellWidth)}if(this._isBillboardBased){var a=this._scene.activeCamera;this._renderEffect.setVector3("eyePosition",a.globalPosition)}if(this._scene.clipPlane||this._scene.clipPlane2||this._scene.clipPlane3||this._scene.clipPlane4){var l=o.clone();l.invert(),this._renderEffect.setMatrix("invView",l),ui.MaterialHelper.BindClipPlane(this._renderEffect,this._scene)}switch(this._imageProcessingConfiguration&&!this._imageProcessingConfiguration.applyByPostProcess&&this._imageProcessingConfiguration.bind(this._renderEffect),this.blendMode){case ui.ParticleSystem.BLENDMODE_ADD:this._engine.setAlphaMode(ui.Engine.ALPHA_ADD);break;case ui.ParticleSystem.BLENDMODE_ONEONE:this._engine.setAlphaMode(ui.Engine.ALPHA_ONEONE);break;case ui.ParticleSystem.BLENDMODE_STANDARD:this._engine.setAlphaMode(ui.Engine.ALPHA_COMBINE);break;case ui.ParticleSystem.BLENDMODE_MULTIPLY:this._engine.setAlphaMode(ui.Engine.ALPHA_MULTIPLY)}this.forceDepthWrite&&this._engine.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._engine.drawArraysType(ui.Material.TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(ui.Engine.ALPHA_DISABLE)}this._targetIndex++,2===this._targetIndex&&(this._targetIndex=0);var c=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=c,this._currentActiveCount},o.prototype.rebuild=function(){this._initialize(!0)},o.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)},o.prototype._releaseVAOs=function(){if(this._updateVAO){for(var e=0;e<this._updateVAO.length;e++)this._engine.releaseVertexArrayObject(this._updateVAO[e]);this._updateVAO=[];for(e=0;e<this._renderVAO.length;e++)this._engine.releaseVertexArrayObject(this._renderVAO[e]);this._renderVAO=[]}},o.prototype.dispose=function(e){void 0===e&&(e=!0);var t=this._scene.particleSystems.indexOf(this);-1<t&&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()},o.prototype.clone=function(e,t){var i=new o(e,{capacity:this._capacity,randomTextureSize:this._randomTextureSize},this._scene);return ui.Tools.DeepCopy(this,i),void 0===t&&(t=this.emitter),i.emitter=t,this.particleTexture&&(i.particleTexture=new ui.Texture(this.particleTexture.url,this._scene)),i},o.prototype.serialize=function(){var e={};return ui.ParticleSystem._Serialize(e,this),e.activeParticleCount=this.activeParticleCount,e},o.Parse=function(e,t,i,r){void 0===r&&(r=!1);var n=new o(e.name,{capacity:e.capacity,randomTextureSize:e.randomTextureSize},t);return e.activeParticleCount&&(n.activeParticleCount=e.activeParticleCount),ui.ParticleSystem._Parse(e,n,t,i),e.preventAutoStart&&(n.preventAutoStart=e.preventAutoStart),r||n.preventAutoStart||n.start(),n},o})(ui.BaseParticleSystem),ui.GPUParticleSystem=di,(function(l){var e=(function(){function e(e,t,i,r,n,o,s,a){void 0===a&&(a=null),this.idx=0,this.color=new l.Color4(1,1,1,1),this.position=l.Vector3.Zero(),this.rotation=l.Vector3.Zero(),this.scaling=l.Vector3.One(),this.uvs=new l.Vector4(0,0,1,1),this.velocity=l.Vector3.Zero(),this.pivot=l.Vector3.Zero(),this.translateFromPivot=!1,this.alive=!0,this.isVisible=!0,this._pos=0,this._ind=0,this.shapeId=0,this.idxInShape=0,this._stillInvisible=!1,this._rotationMatrix=[1,0,0,0,1,0,0,0,1],this.parentId=null,this._globalPosition=l.Vector3.Zero(),this.idx=e,this._pos=t,this._ind=i,this._model=r,this.shapeId=n,this.idxInShape=o,this._sps=s,a&&(this._modelBoundingInfo=a,this._boundingInfo=new l.BoundingInfo(a.minimum,a.maximum))}return Object.defineProperty(e.prototype,"scale",{get:function(){return this.scaling},set:function(e){this.scaling=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"quaternion",{get:function(){return this.rotationQuaternion},set:function(e){this.rotationQuaternion=e},enumerable:!0,configurable:!0}),e.prototype.intersectsMesh=function(e){return!(!this._boundingInfo||!e._boundingInfo)&&(this._sps._bSphereOnly?l.BoundingSphere.Intersects(this._boundingInfo.boundingSphere,e._boundingInfo.boundingSphere):this._boundingInfo.intersects(e._boundingInfo,!1))},e})();l.SolidParticle=e;var t=function(e,t,i,r,n,o){this._indicesLength=0,this.shapeID=e,this._shape=t,this._indicesLength=i,this._shapeUV=r,this._positionFunction=n,this._vertexFunction=o};l.ModelShape=t;var i=function(){this.ind=0,this.indicesLength=0,this.sqDistance=0};l.DepthSortedParticle=i})($a||($a={})),fi=$a||($a={}),pi=(function(){function e(e,t,i){this.particles=new Array,this.nbParticles=0,this.billboard=!1,this.recomputeNormals=!0,this.counter=0,this.vars={},this._bSphereOnly=!1,this._bSphereRadiusFactor=1,this._positions=new Array,this._indices=new Array,this._normals=new Array,this._colors=new Array,this._uvs=new Array,this._index=0,this._updatable=!0,this._pickable=!1,this._isVisibilityBoxLocked=!1,this._alwaysVisible=!1,this._depthSort=!1,this._shapeCounter=0,this._copy=new fi.SolidParticle(0,0,0,null,0,0,this),this._color=new fi.Color4(0,0,0,0),this._computeParticleColor=!0,this._computeParticleTexture=!0,this._computeParticleRotation=!0,this._computeParticleVertex=!1,this._computeBoundingBox=!1,this._depthSortParticles=!0,this._cam_axisZ=fi.Vector3.Zero(),this._cam_axisY=fi.Vector3.Zero(),this._cam_axisX=fi.Vector3.Zero(),this._axisZ=fi.Axis.Z,this._camDir=fi.Vector3.Zero(),this._camInvertedPosition=fi.Vector3.Zero(),this._rotMatrix=new fi.Matrix,this._invertMatrix=new fi.Matrix,this._rotated=fi.Vector3.Zero(),this._quaternion=new fi.Quaternion,this._vertex=fi.Vector3.Zero(),this._normal=fi.Vector3.Zero(),this._yaw=0,this._pitch=0,this._roll=0,this._halfroll=0,this._halfpitch=0,this._halfyaw=0,this._sinRoll=0,this._cosRoll=0,this._sinPitch=0,this._cosPitch=0,this._sinYaw=0,this._cosYaw=0,this._mustUnrotateFixedNormals=!1,this._minimum=fi.Vector3.Zero(),this._maximum=fi.Vector3.Zero(),this._minBbox=fi.Vector3.Zero(),this._maxBbox=fi.Vector3.Zero(),this._particlesIntersect=!1,this._depthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},this._needs32Bits=!1,this._pivotBackTranslation=fi.Vector3.Zero(),this._scaledPivot=fi.Vector3.Zero(),this._particleHasParent=!1,this.name=e,this._scene=t||fi.Engine.LastCreatedScene,this._camera=t.activeCamera,this._pickable=!!i&&i.isPickable,this._depthSort=!!i&&i.enableDepthSort,this._particlesIntersect=!!i&&i.particleIntersection,this._bSphereOnly=!!i&&i.boundingSphereOnly,this._bSphereRadiusFactor=i&&i.bSphereRadiusFactor?i.bSphereRadiusFactor:1,i&&void 0!==i.updatable?this._updatable=i.updatable:this._updatable=!0,this._pickable&&(this.pickedParticles=[]),this._depthSort&&(this.depthSortedParticles=[])}return e.prototype.buildMesh=function(){if(0===this.nbParticles){var e=fi.MeshBuilder.CreateDisc("",{radius:1,tessellation:3},this._scene);this.addShape(e,1),e.dispose()}this._indices32=this._needs32Bits?new Uint32Array(this._indices):new Uint16Array(this._indices),this._positions32=new Float32Array(this._positions),this._uvs32=new Float32Array(this._uvs),this._colors32=new Float32Array(this._colors),this.recomputeNormals&&fi.VertexData.ComputeNormals(this._positions32,this._indices32,this._normals),this._normals32=new Float32Array(this._normals),this._fixedNormal32=new Float32Array(this._normals),this._mustUnrotateFixedNormals&&this._unrotateFixedNormals();var t=new fi.VertexData;t.indices=this._depthSort?this._indices:this._indices32,t.set(this._positions32,fi.VertexBuffer.PositionKind),t.set(this._normals32,fi.VertexBuffer.NormalKind),0<this._uvs32.length&&t.set(this._uvs32,fi.VertexBuffer.UVKind),0<this._colors32.length&&t.set(this._colors32,fi.VertexBuffer.ColorKind);var i=new fi.Mesh(this.name,this._scene);return t.applyToMesh(i,this._updatable),this.mesh=i,this.mesh.isPickable=this._pickable,this._depthSort||(this._indices=null),this._positions=null,this._normals=null,this._uvs=null,this._colors=null,this._updatable||(this.particles.length=0),i},e.prototype.digest=function(e,t){var i=t&&t.facetNb||1,r=t&&t.number||0,n=t&&t.delta||0,o=e.getVerticesData(fi.VertexBuffer.PositionKind),s=e.getIndices(),a=e.getVerticesData(fi.VertexBuffer.UVKind),l=e.getVerticesData(fi.VertexBuffer.ColorKind),c=e.getVerticesData(fi.VertexBuffer.NormalKind),h=0,u=s.length/3;r?(r=u<r?u:r,i=Math.round(u/r),n=0):i=u<i?u:i;for(var d=[],f=[],p=[],m=[],_=fi.Vector3.Zero(),g=i;h<u;){u-(i=g+Math.floor((1+n)*Math.random()))<h&&(i=u-h),d.length=0,f.length=0,p.length=0;for(var v=m.length=0,y=3*h;y<3*(h+i);y++){f.push(v);var b=s[y];d.push(o[3*b],o[3*b+1],o[3*b+2]),a&&p.push(a[2*b],a[2*b+1]),l&&m.push(l[4*b],l[4*b+1],l[4*b+2],l[4*b+3]),v++}var T,x,E=this.nbParticles,A=this._posToShape(d),P=this._uvsToShapeUV(p);for(T=0;T<A.length;T++)_.addInPlace(A[T]);for(_.scaleInPlace(1/A.length),T=0;T<A.length;T++)A[T].subtractInPlace(_);this._particlesIntersect&&(x=new fi.BoundingInfo(_,_));var S=new fi.ModelShape(this._shapeCounter,A,3*i,P,null,null),R=this._positions.length,M=this._indices.length;this._meshBuilder(this._index,A,this._positions,f,this._indices,p,this._uvs,m,this._colors,c,this._normals,E,0,null),this._addParticle(E,R,M,S,this._shapeCounter,0,x),this.particles[this.nbParticles].position.addInPlace(_),this._index+=A.length,E++,this.nbParticles++,this._shapeCounter++,h+=i}return this},e.prototype._unrotateFixedNormals=function(){for(var e=0,t=0,i=0;i<this.particles.length;i++){this._particle=this.particles[i],this._shape=this._particle._model._shape,this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),this._rotMatrix.invertToRef(this._invertMatrix);for(var r=0;r<this._shape.length;r++)t=e+3*r,fi.Vector3.TransformNormalFromFloatsToRef(this._normals32[t],this._normals32[t+1],this._normals32[t+2],this._invertMatrix,this._normal),this._fixedNormal32[t]=this._normal.x,this._fixedNormal32[t+1]=this._normal.y,this._fixedNormal32[t+2]=this._normal.z;e=t+3}},e.prototype._resetCopy=function(){this._copy.position.x=0,this._copy.position.y=0,this._copy.position.z=0,this._copy.rotation.x=0,this._copy.rotation.y=0,this._copy.rotation.z=0,this._copy.rotationQuaternion=null,this._copy.scaling.x=1,this._copy.scaling.y=1,this._copy.scaling.z=1,this._copy.uvs.x=0,this._copy.uvs.y=0,this._copy.uvs.z=1,this._copy.uvs.w=1,this._copy.color=null,this._copy.translateFromPivot=!1},e.prototype._meshBuilder=function(e,t,i,r,n,o,s,a,l,c,h,u,d,f){var p,m=0,_=0,g=0;for(this._resetCopy(),f&&f.positionFunction&&(f.positionFunction(this._copy,u,d),this._mustUnrotateFixedNormals=!0),this._copy.rotationQuaternion?this._quaternion.copyFrom(this._copy.rotationQuaternion):(this._yaw=this._copy.rotation.y,this._pitch=this._copy.rotation.x,this._roll=this._copy.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),this._scaledPivot.x=this._copy.pivot.x*this._copy.scaling.x,this._scaledPivot.y=this._copy.pivot.y*this._copy.scaling.y,this._scaledPivot.z=this._copy.pivot.z*this._copy.scaling.z,this._copy.translateFromPivot?this._pivotBackTranslation.copyFromFloats(0,0,0):this._pivotBackTranslation.copyFrom(this._scaledPivot),p=0;p<t.length;p++)this._vertex.x=t[p].x,this._vertex.y=t[p].y,this._vertex.z=t[p].z,f&&f.vertexFunction&&f.vertexFunction(this._copy,this._vertex,p),this._vertex.x*=this._copy.scaling.x,this._vertex.y*=this._copy.scaling.y,this._vertex.z*=this._copy.scaling.z,this._vertex.x-=this._scaledPivot.x,this._vertex.y-=this._scaledPivot.y,this._vertex.z-=this._scaledPivot.z,fi.Vector3.TransformCoordinatesToRef(this._vertex,this._rotMatrix,this._rotated),this._rotated.addInPlace(this._pivotBackTranslation),i.push(this._copy.position.x+this._rotated.x,this._copy.position.y+this._rotated.y,this._copy.position.z+this._rotated.z),o&&(s.push((this._copy.uvs.z-this._copy.uvs.x)*o[m]+this._copy.uvs.x,(this._copy.uvs.w-this._copy.uvs.y)*o[m+1]+this._copy.uvs.y),m+=2),this._copy.color?this._color=this._copy.color:a&&void 0!==a[_]?(this._color.r=a[_],this._color.g=a[_+1],this._color.b=a[_+2],this._color.a=a[_+3]):(this._color.r=1,this._color.g=1,this._color.b=1,this._color.a=1),l.push(this._color.r,this._color.g,this._color.b,this._color.a),_+=4,!this.recomputeNormals&&c&&(this._normal.x=c[g],this._normal.y=c[g+1],this._normal.z=c[g+2],fi.Vector3.TransformNormalToRef(this._normal,this._rotMatrix,this._normal),h.push(this._normal.x,this._normal.y,this._normal.z),g+=3);for(p=0;p<r.length;p++){var v=e+r[p];n.push(v),65535<v&&(this._needs32Bits=!0)}if(this._pickable){var y=r.length/3;for(p=0;p<y;p++)this.pickedParticles.push({idx:u,faceId:p})}return this._depthSort&&this.depthSortedParticles.push(new fi.DepthSortedParticle),this._copy},e.prototype._posToShape=function(e){for(var t=[],i=0;i<e.length;i+=3)t.push(new fi.Vector3(e[i],e[i+1],e[i+2]));return t},e.prototype._uvsToShapeUV=function(e){var t=[];if(e)for(var i=0;i<e.length;i++)t.push(e[i]);return t},e.prototype._addParticle=function(e,t,i,r,n,o,s){void 0===s&&(s=null);var a=new fi.SolidParticle(e,t,i,r,n,o,this,s);return this.particles.push(a),a},e.prototype.addShape=function(e,t,i){var r,n=e.getVerticesData(fi.VertexBuffer.PositionKind),o=e.getIndices(),s=e.getVerticesData(fi.VertexBuffer.UVKind),a=e.getVerticesData(fi.VertexBuffer.ColorKind),l=e.getVerticesData(fi.VertexBuffer.NormalKind);this._particlesIntersect&&(r=e.getBoundingInfo());for(var c,h,u=this._posToShape(n),d=this._uvsToShapeUV(s),f=i?i.positionFunction:null,p=i?i.vertexFunction:null,m=new fi.ModelShape(this._shapeCounter,u,o.length,d,f,p),_=this.nbParticles,g=0;g<t;g++){var v=this._positions.length,y=this._indices.length;h=this._meshBuilder(this._index,u,this._positions,o,this._indices,s,this._uvs,a,this._colors,l,this._normals,_,g,i),this._updatable&&((c=this._addParticle(_,v,y,m,this._shapeCounter,g,r)).position.copyFrom(h.position),c.rotation.copyFrom(h.rotation),h.rotationQuaternion&&c.rotationQuaternion&&c.rotationQuaternion.copyFrom(h.rotationQuaternion),h.color&&c.color&&c.color.copyFrom(h.color),c.scaling.copyFrom(h.scaling),c.uvs.copyFrom(h.uvs)),this._index+=u.length,_++}return this.nbParticles+=t,this._shapeCounter++,this._shapeCounter-1},e.prototype._rebuildParticle=function(e){this._resetCopy(),e._model._positionFunction&&e._model._positionFunction(this._copy,e.idx,e.idxInShape),this._copy.rotationQuaternion?this._quaternion.copyFrom(this._copy.rotationQuaternion):(this._yaw=this._copy.rotation.y,this._pitch=this._copy.rotation.x,this._roll=this._copy.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix(),this._scaledPivot.x=this._particle.pivot.x*this._particle.scaling.x,this._scaledPivot.y=this._particle.pivot.y*this._particle.scaling.y,this._scaledPivot.z=this._particle.pivot.z*this._particle.scaling.z,this._copy.translateFromPivot?this._pivotBackTranslation.copyFromFloats(0,0,0):this._pivotBackTranslation.copyFrom(this._scaledPivot),this._shape=e._model._shape;for(var t=0;t<this._shape.length;t++)this._vertex.x=this._shape[t].x,this._vertex.y=this._shape[t].y,this._vertex.z=this._shape[t].z,e._model._vertexFunction&&e._model._vertexFunction(this._copy,this._vertex,t),this._vertex.x*=this._copy.scaling.x,this._vertex.y*=this._copy.scaling.y,this._vertex.z*=this._copy.scaling.z,this._vertex.x-=this._scaledPivot.x,this._vertex.y-=this._scaledPivot.y,this._vertex.z-=this._scaledPivot.z,fi.Vector3.TransformCoordinatesToRef(this._vertex,this._rotMatrix,this._rotated),this._rotated.addInPlace(this._pivotBackTranslation),this._positions32[e._pos+3*t]=this._copy.position.x+this._rotated.x,this._positions32[e._pos+3*t+1]=this._copy.position.y+this._rotated.y,this._positions32[e._pos+3*t+2]=this._copy.position.z+this._rotated.z;e.position.x=0,e.position.y=0,e.position.z=0,e.rotation.x=0,e.rotation.y=0,e.rotation.z=0,e.rotationQuaternion=null,e.scaling.x=1,e.scaling.y=1,e.scaling.z=1,e.uvs.x=0,e.uvs.y=0,e.uvs.z=1,e.uvs.w=1,e.pivot.x=0,e.pivot.y=0,e.pivot.z=0,e.translateFromPivot=!1,e.parentId=null},e.prototype.rebuildMesh=function(){for(var e=0;e<this.particles.length;e++)this._rebuildParticle(this.particles[e]);return this.mesh.updateVerticesData(fi.VertexBuffer.PositionKind,this._positions32,!1,!1),this},e.prototype.setParticles=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=this.nbParticles-1),void 0===i&&(i=!0),!this._updatable)return this;if(this.beforeUpdateParticles(e,t,i),this._cam_axisX.x=1,this._cam_axisX.y=0,this._cam_axisX.z=0,this._cam_axisY.x=0,this._cam_axisY.y=1,this._cam_axisY.z=0,this._cam_axisZ.x=0,this._cam_axisZ.y=0,this._cam_axisZ.z=1,(this.billboard||this._depthSort)&&(this.mesh.computeWorldMatrix(!0),this.mesh._worldMatrix.invertToRef(this._invertMatrix)),this.billboard){this._camera.getDirectionToRef(this._axisZ,this._camDir),fi.Vector3.TransformNormalToRef(this._camDir,this._invertMatrix,this._cam_axisZ),this._cam_axisZ.normalize();var r=this._camera.getViewMatrix(!0);fi.Vector3.TransformNormalFromFloatsToRef(r.m[1],r.m[5],r.m[9],this._invertMatrix,this._cam_axisY),fi.Vector3.CrossToRef(this._cam_axisY,this._cam_axisZ,this._cam_axisX),this._cam_axisY.normalize(),this._cam_axisX.normalize()}this._depthSort&&fi.Vector3.TransformCoordinatesToRef(this._camera.globalPosition,this._invertMatrix,this._camInvertedPosition),fi.Matrix.IdentityToRef(this._rotMatrix);var n=0,o=0,s=0,a=0,l=0,c=0,h=0;this.mesh.isFacetDataEnabled&&(this._computeBoundingBox=!0),t=t>=this.nbParticles?this.nbParticles-1:t,this._computeBoundingBox&&(0==e&&t==this.nbParticles-1?(fi.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this._minimum),fi.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this._maximum)):this.mesh._boundingInfo&&(this._minimum.copyFrom(this.mesh._boundingInfo.boundingBox.minimum),this._maximum.copyFrom(this.mesh._boundingInfo.boundingBox.maximum)));var u=(o=this.particles[e]._pos)/3|0;a=4*u,c=2*u;for(var d=e;d<=t;d++){if(this._particle=this.particles[d],this._shape=this._particle._model._shape,this._shapeUV=this._particle._model._shapeUV,this.updateParticle(this._particle),this._depthSort&&this._depthSortParticles){var f=this.depthSortedParticles[d];f.ind=this._particle._ind,f.indicesLength=this._particle._model._indicesLength,f.sqDistance=fi.Vector3.DistanceSquared(this._particle.position,this._camInvertedPosition)}if(!this._particle.alive||this._particle._stillInvisible&&!this._particle.isVisible)o+=3*(h=this._shape.length),a+=4*h,c+=2*h;else{if(this._particle.isVisible)for(this._particle._stillInvisible=!1,this._particleHasParent=null!==this._particle.parentId,this._scaledPivot.x=this._particle.pivot.x*this._particle.scaling.x,this._scaledPivot.y=this._particle.pivot.y*this._particle.scaling.y,this._scaledPivot.z=this._particle.pivot.z*this._particle.scaling.z,this.billboard&&(this._particle.rotation.x=0,this._particle.rotation.y=0),(this._computeParticleRotation||this.billboard)&&(this._particle.rotationQuaternion?this._quaternion.copyFrom(this._particle.rotationQuaternion):(this._yaw=this._particle.rotation.y,this._pitch=this._particle.rotation.x,this._roll=this._particle.rotation.z,this._quaternionRotationYPR()),this._quaternionToRotationMatrix()),this._particleHasParent?(this._parent=this.particles[this._particle.parentId],this._rotated.x=this._particle.position.x*this._parent._rotationMatrix[0]+this._particle.position.y*this._parent._rotationMatrix[3]+this._particle.position.z*this._parent._rotationMatrix[6],this._rotated.y=this._particle.position.x*this._parent._rotationMatrix[1]+this._particle.position.y*this._parent._rotationMatrix[4]+this._particle.position.z*this._parent._rotationMatrix[7],this._rotated.z=this._particle.position.x*this._parent._rotationMatrix[2]+this._particle.position.y*this._parent._rotationMatrix[5]+this._particle.position.z*this._parent._rotationMatrix[8],this._particle._globalPosition.x=this._parent._globalPosition.x+this._rotated.x,this._particle._globalPosition.y=this._parent._globalPosition.y+this._rotated.y,this._particle._globalPosition.z=this._parent._globalPosition.z+this._rotated.z,(this._computeParticleRotation||this.billboard)&&(this._particle._rotationMatrix[0]=this._rotMatrix.m[0]*this._parent._rotationMatrix[0]+this._rotMatrix.m[1]*this._parent._rotationMatrix[3]+this._rotMatrix.m[2]*this._parent._rotationMatrix[6],this._particle._rotationMatrix[1]=this._rotMatrix.m[0]*this._parent._rotationMatrix[1]+this._rotMatrix.m[1]*this._parent._rotationMatrix[4]+this._rotMatrix.m[2]*this._parent._rotationMatrix[7],this._particle._rotationMatrix[2]=this._rotMatrix.m[0]*this._parent._rotationMatrix[2]+this._rotMatrix.m[1]*this._parent._rotationMatrix[5]+this._rotMatrix.m[2]*this._parent._rotationMatrix[8],this._particle._rotationMatrix[3]=this._rotMatrix.m[4]*this._parent._rotationMatrix[0]+this._rotMatrix.m[5]*this._parent._rotationMatrix[3]+this._rotMatrix.m[6]*this._parent._rotationMatrix[6],this._particle._rotationMatrix[4]=this._rotMatrix.m[4]*this._parent._rotationMatrix[1]+this._rotMatrix.m[5]*this._parent._rotationMatrix[4]+this._rotMatrix.m[6]*this._parent._rotationMatrix[7],this._particle._rotationMatrix[5]=this._rotMatrix.m[4]*this._parent._rotationMatrix[2]+this._rotMatrix.m[5]*this._parent._rotationMatrix[5]+this._rotMatrix.m[6]*this._parent._rotationMatrix[8],this._particle._rotationMatrix[6]=this._rotMatrix.m[8]*this._parent._rotationMatrix[0]+this._rotMatrix.m[9]*this._parent._rotationMatrix[3]+this._rotMatrix.m[10]*this._parent._rotationMatrix[6],this._particle._rotationMatrix[7]=this._rotMatrix.m[8]*this._parent._rotationMatrix[1]+this._rotMatrix.m[9]*this._parent._rotationMatrix[4]+this._rotMatrix.m[10]*this._parent._rotationMatrix[7],this._particle._rotationMatrix[8]=this._rotMatrix.m[8]*this._parent._rotationMatrix[2]+this._rotMatrix.m[9]*this._parent._rotationMatrix[5]+this._rotMatrix.m[10]*this._parent._rotationMatrix[8])):(this._particle._globalPosition.x=this._particle.position.x,this._particle._globalPosition.y=this._particle.position.y,this._particle._globalPosition.z=this._particle.position.z,(this._computeParticleRotation||this.billboard)&&(this._particle._rotationMatrix[0]=this._rotMatrix.m[0],this._particle._rotationMatrix[1]=this._rotMatrix.m[1],this._particle._rotationMatrix[2]=this._rotMatrix.m[2],this._particle._rotationMatrix[3]=this._rotMatrix.m[4],this._particle._rotationMatrix[4]=this._rotMatrix.m[5],this._particle._rotationMatrix[5]=this._rotMatrix.m[6],this._particle._rotationMatrix[6]=this._rotMatrix.m[8],this._particle._rotationMatrix[7]=this._rotMatrix.m[9],this._particle._rotationMatrix[8]=this._rotMatrix.m[10])),this._particle.translateFromPivot?(this._pivotBackTranslation.x=0,this._pivotBackTranslation.y=0,this._pivotBackTranslation.z=0):(this._pivotBackTranslation.x=this._scaledPivot.x,this._pivotBackTranslation.y=this._scaledPivot.y,this._pivotBackTranslation.z=this._scaledPivot.z),h=0;h<this._shape.length;h++)n=o+3*h,s=a+4*h,l=c+2*h,this._vertex.x=this._shape[h].x,this._vertex.y=this._shape[h].y,this._vertex.z=this._shape[h].z,this._computeParticleVertex&&this.updateParticleVertex(this._particle,this._vertex,h),this._vertex.x*=this._particle.scaling.x,this._vertex.y*=this._particle.scaling.y,this._vertex.z*=this._particle.scaling.z,this._vertex.x-=this._scaledPivot.x,this._vertex.y-=this._scaledPivot.y,this._vertex.z-=this._scaledPivot.z,this._rotated.x=this._vertex.x*this._particle._rotationMatrix[0]+this._vertex.y*this._particle._rotationMatrix[3]+this._vertex.z*this._particle._rotationMatrix[6],this._rotated.y=this._vertex.x*this._particle._rotationMatrix[1]+this._vertex.y*this._particle._rotationMatrix[4]+this._vertex.z*this._particle._rotationMatrix[7],this._rotated.z=this._vertex.x*this._particle._rotationMatrix[2]+this._vertex.y*this._particle._rotationMatrix[5]+this._vertex.z*this._particle._rotationMatrix[8],this._rotated.x+=this._pivotBackTranslation.x,this._rotated.y+=this._pivotBackTranslation.y,this._rotated.z+=this._pivotBackTranslation.z,this._positions32[n]=this._particle._globalPosition.x+this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._positions32[n+1]=this._particle._globalPosition.y+this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._positions32[n+2]=this._particle._globalPosition.z+this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z,this._computeBoundingBox&&(this._positions32[n]<this._minimum.x&&(this._minimum.x=this._positions32[n]),this._positions32[n]>this._maximum.x&&(this._maximum.x=this._positions32[n]),this._positions32[n+1]<this._minimum.y&&(this._minimum.y=this._positions32[n+1]),this._positions32[n+1]>this._maximum.y&&(this._maximum.y=this._positions32[n+1]),this._positions32[n+2]<this._minimum.z&&(this._minimum.z=this._positions32[n+2]),this._positions32[n+2]>this._maximum.z&&(this._maximum.z=this._positions32[n+2])),this._computeParticleVertex||(this._normal.x=this._fixedNormal32[n],this._normal.y=this._fixedNormal32[n+1],this._normal.z=this._fixedNormal32[n+2],this._rotated.x=this._normal.x*this._particle._rotationMatrix[0]+this._normal.y*this._particle._rotationMatrix[3]+this._normal.z*this._particle._rotationMatrix[6],this._rotated.y=this._normal.x*this._particle._rotationMatrix[1]+this._normal.y*this._particle._rotationMatrix[4]+this._normal.z*this._particle._rotationMatrix[7],this._rotated.z=this._normal.x*this._particle._rotationMatrix[2]+this._normal.y*this._particle._rotationMatrix[5]+this._normal.z*this._particle._rotationMatrix[8],this._normals32[n]=this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,this._normals32[n+1]=this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,this._normals32[n+2]=this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z),this._computeParticleColor&&this._particle.color&&(this._colors32[s]=this._particle.color.r,this._colors32[s+1]=this._particle.color.g,this._colors32[s+2]=this._particle.color.b,this._colors32[s+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[l]=this._shapeUV[2*h]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[l+1]=this._shapeUV[2*h+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);else for(this._particle._stillInvisible=!0,h=0;h<this._shape.length;h++)n=o+3*h,s=a+4*h,l=c+2*h,this._positions32[n]=0,this._positions32[n+1]=0,this._positions32[n+2]=0,this._normals32[n]=0,this._normals32[n+1]=0,this._normals32[n+2]=0,this._computeParticleColor&&this._particle.color&&(this._colors32[s]=this._particle.color.r,this._colors32[s+1]=this._particle.color.g,this._colors32[s+2]=this._particle.color.b,this._colors32[s+3]=this._particle.color.a),this._computeParticleTexture&&(this._uvs32[l]=this._shapeUV[2*h]*(this._particle.uvs.z-this._particle.uvs.x)+this._particle.uvs.x,this._uvs32[l+1]=this._shapeUV[2*h+1]*(this._particle.uvs.w-this._particle.uvs.y)+this._particle.uvs.y);if(this._particlesIntersect){var p=this._particle._boundingInfo,m=p.boundingBox,_=p.boundingSphere;if(!this._bSphereOnly){for(var g=0;g<m.vectors.length;g++)this._vertex.x=this._particle._modelBoundingInfo.boundingBox.vectors[g].x*this._particle.scaling.x,this._vertex.y=this._particle._modelBoundingInfo.boundingBox.vectors[g].y*this._particle.scaling.y,this._vertex.z=this._particle._modelBoundingInfo.boundingBox.vectors[g].z*this._particle.scaling.z,this._rotated.x=this._vertex.x*this._particle._rotationMatrix[0]+this._vertex.y*this._particle._rotationMatrix[3]+this._vertex.z*this._particle._rotationMatrix[6],this._rotated.y=this._vertex.x*this._particle._rotationMatrix[1]+this._vertex.y*this._particle._rotationMatrix[4]+this._vertex.z*this._particle._rotationMatrix[7],this._rotated.z=this._vertex.x*this._particle._rotationMatrix[2]+this._vertex.y*this._particle._rotationMatrix[5]+this._vertex.z*this._particle._rotationMatrix[8],m.vectors[g].x=this._particle.position.x+this._cam_axisX.x*this._rotated.x+this._cam_axisY.x*this._rotated.y+this._cam_axisZ.x*this._rotated.z,m.vectors[g].y=this._particle.position.y+this._cam_axisX.y*this._rotated.x+this._cam_axisY.y*this._rotated.y+this._cam_axisZ.y*this._rotated.z,m.vectors[g].z=this._particle.position.z+this._cam_axisX.z*this._rotated.x+this._cam_axisY.z*this._rotated.y+this._cam_axisZ.z*this._rotated.z;m._update(this.mesh._worldMatrix)}this._minBbox.x=this._particle._modelBoundingInfo.minimum.x*this._particle.scaling.x,this._minBbox.y=this._particle._modelBoundingInfo.minimum.y*this._particle.scaling.y,this._minBbox.z=this._particle._modelBoundingInfo.minimum.z*this._particle.scaling.z,this._maxBbox.x=this._particle._modelBoundingInfo.maximum.x*this._particle.scaling.x,this._maxBbox.y=this._particle._modelBoundingInfo.maximum.y*this._particle.scaling.y,this._maxBbox.z=this._particle._modelBoundingInfo.maximum.z*this._particle.scaling.z,_.center.x=this._particle._globalPosition.x+.5*(this._minBbox.x+this._maxBbox.x),_.center.y=this._particle._globalPosition.y+.5*(this._minBbox.y+this._maxBbox.y),_.center.z=this._particle._globalPosition.z+.5*(this._minBbox.z+this._maxBbox.z),_.radius=.5*this._bSphereRadiusFactor*Math.sqrt((this._maxBbox.x-this._minBbox.x)*(this._maxBbox.x-this._minBbox.x)+(this._maxBbox.y-this._minBbox.y)*(this._maxBbox.y-this._minBbox.y)+(this._maxBbox.z-this._minBbox.z)*(this._maxBbox.z-this._minBbox.z)),_._update(this.mesh._worldMatrix)}o=n+3,a=s+4,c=l+2}}if(i){if(this._computeParticleColor&&this.mesh.updateVerticesData(fi.VertexBuffer.ColorKind,this._colors32,!1,!1),this._computeParticleTexture&&this.mesh.updateVerticesData(fi.VertexBuffer.UVKind,this._uvs32,!1,!1),this.mesh.updateVerticesData(fi.VertexBuffer.PositionKind,this._positions32,!1,!1),!this.mesh.areNormalsFrozen||this.mesh.isFacetDataEnabled){if(this._computeParticleVertex||this.mesh.isFacetDataEnabled){var v=this.mesh.isFacetDataEnabled?this.mesh.getFacetDataParameters():null;fi.VertexData.ComputeNormals(this._positions32,this._indices32,this._normals32,v);for(var y=0;y<this._normals32.length;y++)this._fixedNormal32[y]=this._normals32[y]}this.mesh.areNormalsFrozen||this.mesh.updateVerticesData(fi.VertexBuffer.NormalKind,this._normals32,!1,!1)}if(this._depthSort&&this._depthSortParticles){this.depthSortedParticles.sort(this._depthSortFunction);var b=this.depthSortedParticles.length,T=0,x=0,E=0,A=0;for(T=0;T<b;T++){x=this.depthSortedParticles[T].indicesLength,E=this.depthSortedParticles[T].ind;for(y=0;y<x;y++)this._indices32[A]=this._indices[E+y],A++}this.mesh.updateIndices(this._indices32)}}return this._computeBoundingBox&&(this.mesh._boundingInfo=new fi.BoundingInfo(this._minimum,this._maximum),this.mesh._boundingInfo.update(this.mesh._worldMatrix)),this.afterUpdateParticles(e,t,i),this},e.prototype._quaternionRotationYPR=function(){this._halfroll=.5*this._roll,this._halfpitch=.5*this._pitch,this._halfyaw=.5*this._yaw,this._sinRoll=Math.sin(this._halfroll),this._cosRoll=Math.cos(this._halfroll),this._sinPitch=Math.sin(this._halfpitch),this._cosPitch=Math.cos(this._halfpitch),this._sinYaw=Math.sin(this._halfyaw),this._cosYaw=Math.cos(this._halfyaw),this._quaternion.x=this._cosYaw*this._sinPitch*this._cosRoll+this._sinYaw*this._cosPitch*this._sinRoll,this._quaternion.y=this._sinYaw*this._cosPitch*this._cosRoll-this._cosYaw*this._sinPitch*this._sinRoll,this._quaternion.z=this._cosYaw*this._cosPitch*this._sinRoll-this._sinYaw*this._sinPitch*this._cosRoll,this._quaternion.w=this._cosYaw*this._cosPitch*this._cosRoll+this._sinYaw*this._sinPitch*this._sinRoll},e.prototype._quaternionToRotationMatrix=function(){this._rotMatrix.m[0]=1-2*(this._quaternion.y*this._quaternion.y+this._quaternion.z*this._quaternion.z),this._rotMatrix.m[1]=2*(this._quaternion.x*this._quaternion.y+this._quaternion.z*this._quaternion.w),this._rotMatrix.m[2]=2*(this._quaternion.z*this._quaternion.x-this._quaternion.y*this._quaternion.w),this._rotMatrix.m[3]=0,this._rotMatrix.m[4]=2*(this._quaternion.x*this._quaternion.y-this._quaternion.z*this._quaternion.w),this._rotMatrix.m[5]=1-2*(this._quaternion.z*this._quaternion.z+this._quaternion.x*this._quaternion.x),this._rotMatrix.m[6]=2*(this._quaternion.y*this._quaternion.z+this._quaternion.x*this._quaternion.w),this._rotMatrix.m[7]=0,this._rotMatrix.m[8]=2*(this._quaternion.z*this._quaternion.x+this._quaternion.y*this._quaternion.w),this._rotMatrix.m[9]=2*(this._quaternion.y*this._quaternion.z-this._quaternion.x*this._quaternion.w),this._rotMatrix.m[10]=1-2*(this._quaternion.y*this._quaternion.y+this._quaternion.x*this._quaternion.x),this._rotMatrix.m[11]=0,this._rotMatrix.m[12]=0,this._rotMatrix.m[13]=0,this._rotMatrix.m[14]=0,this._rotMatrix.m[15]=1},e.prototype.dispose=function(){this.mesh.dispose(),this.vars=null,this._positions=null,this._indices=null,this._normals=null,this._uvs=null,this._colors=null,this._indices32=null,this._positions32=null,this._normals32=null,this._fixedNormal32=null,this._uvs32=null,this._colors32=null,this.pickedParticles=null},e.prototype.refreshVisibleSize=function(){return this._isVisibilityBoxLocked||this.mesh.refreshBoundingInfo(),this},e.prototype.setVisibilityBox=function(e){var t=e/2;this.mesh._boundingInfo=new fi.BoundingInfo(new fi.Vector3(-t,-t,-t),new fi.Vector3(t,t,t))},Object.defineProperty(e.prototype,"isAlwaysVisible",{get:function(){return this._alwaysVisible},set:function(e){this._alwaysVisible=e,this.mesh.alwaysSelectAsActiveMesh=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"isVisibilityBoxLocked",{get:function(){return this._isVisibilityBoxLocked},set:function(e){this._isVisibilityBoxLocked=e,this.mesh.getBoundingInfo().isLocked=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleRotation",{get:function(){return this._computeParticleRotation},set:function(e){this._computeParticleRotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleColor",{get:function(){return this._computeParticleColor},set:function(e){this._computeParticleColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleTexture",{get:function(){return this._computeParticleTexture},set:function(e){this._computeParticleTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeParticleVertex",{get:function(){return this._computeParticleVertex},set:function(e){this._computeParticleVertex=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"computeBoundingBox",{get:function(){return this._computeBoundingBox},set:function(e){this._computeBoundingBox=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthSortParticles",{get:function(){return this._depthSortParticles},set:function(e){this._depthSortParticles=e},enumerable:!0,configurable:!0}),e.prototype.initParticles=function(){},e.prototype.recycleParticle=function(e){return e},e.prototype.updateParticle=function(e){return e},e.prototype.updateParticleVertex=function(e,t,i){return t},e.prototype.beforeUpdateParticles=function(e,t,i){},e.prototype.afterUpdateParticles=function(e,t,i){},e})(),fi.SolidParticleSystem=pi,mi=$a||($a={}),_i=(function(){function E(){}return E.updateSideOrientation=function(e){return e==mi.Mesh.DOUBLESIDE?mi.Mesh.DOUBLESIDE:null==e?mi.Mesh.FRONTSIDE:e},E.CreateBox=function(e,t,i){void 0===i&&(i=null);var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreateBox(t).applyToMesh(r,t.updatable),r},E.CreateSphere=function(e,t,i){var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreateSphere(t).applyToMesh(r,t.updatable),r},E.CreateDisc=function(e,t,i){void 0===i&&(i=null);var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreateDisc(t).applyToMesh(r,t.updatable),r},E.CreateIcoSphere=function(e,t,i){var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreateIcoSphere(t).applyToMesh(r,t.updatable),r},E.CreateRibbon=function(e,t,i){void 0===i&&(i=null);var h=t.pathArray,r=t.closeArray,n=t.closePath,o=E.updateSideOrientation(t.sideOrientation),u=t.instance,s=t.updatable;if(u){mi.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,mi.Tmp.Vector3[0]),mi.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,mi.Tmp.Vector3[1]);var a=u.getVerticesData(mi.VertexBuffer.PositionKind);if(function(e){for(var t=h[0].length,i=u,r=0,n=i._originalBuilderSideOrientation===mi.Mesh.DOUBLESIDE?2:1,o=1;o<=n;o++)for(var s=0;s<h.length;s++){var a=h[s],l=a.length;t=t<l?t:l;for(var c=0;c<t;)e[r]=a[c].x,e[r+1]=a[c].y,e[r+2]=a[c].z,a[c].x<mi.Tmp.Vector3[0].x&&(mi.Tmp.Vector3[0].x=a[c].x),a[c].x>mi.Tmp.Vector3[1].x&&(mi.Tmp.Vector3[1].x=a[c].x),a[c].y<mi.Tmp.Vector3[0].y&&(mi.Tmp.Vector3[0].y=a[c].y),a[c].y>mi.Tmp.Vector3[1].y&&(mi.Tmp.Vector3[1].y=a[c].y),a[c].z<mi.Tmp.Vector3[0].z&&(mi.Tmp.Vector3[0].z=a[c].z),a[c].z>mi.Tmp.Vector3[1].z&&(mi.Tmp.Vector3[1].z=a[c].z),c++,r+=3;i._creationDataStorage&&i._creationDataStorage.closePath&&(e[r]=a[0].x,e[r+1]=a[0].y,e[r+2]=a[0].z,r+=3)}}(a),u._boundingInfo=new mi.BoundingInfo(mi.Tmp.Vector3[2],mi.Tmp.Vector3[3]),u._boundingInfo.update(u._worldMatrix),u.updateVerticesData(mi.VertexBuffer.PositionKind,a,!1,!1),t.colors){for(var l=u.getVerticesData(mi.VertexBuffer.ColorKind),c=0;c<t.colors.length;c++)l[4*c]=t.colors[c].r,l[4*c+1]=t.colors[c].g,l[4*c+2]=t.colors[c].b,l[4*c+3]=t.colors[c].a;u.updateVerticesData(mi.VertexBuffer.ColorKind,l,!1,!1)}if(t.uvs){for(var d=u.getVerticesData(mi.VertexBuffer.UVKind),f=0;f<t.uvs.length;f++)d[2*f]=t.uvs[f].x,d[2*f+1]=t.uvs[f].y;u.updateVerticesData(mi.VertexBuffer.UVKind,d,!1,!1)}if(!u.areNormalsFrozen||u.isFacetDataEnabled){var p=u.getIndices(),m=u.getVerticesData(mi.VertexBuffer.NormalKind),_=u.isFacetDataEnabled?u.getFacetDataParameters():null;if(mi.VertexData.ComputeNormals(a,p,m,_),u._creationDataStorage&&u._creationDataStorage.closePath)for(var g=0,v=0,y=0;y<h.length;y++)g=3*u._creationDataStorage.idx[y],v=y+1<h.length?3*(u._creationDataStorage.idx[y+1]-1):m.length-3,m[g]=.5*(m[g]+m[v]),m[g+1]=.5*(m[g+1]+m[v+1]),m[g+2]=.5*(m[g+2]+m[v+2]),m[v]=m[g],m[v+1]=m[g+1],m[v+2]=m[g+2];u.areNormalsFrozen||u.updateVerticesData(mi.VertexBuffer.NormalKind,m,!1,!1)}return u}var b=new mi.Mesh(e,i);b._originalBuilderSideOrientation=o,b._creationDataStorage=new mi._CreationDataStorage;var T=mi.VertexData.CreateRibbon(t);return n&&(b._creationDataStorage.idx=T._idx),b._creationDataStorage.closePath=n,b._creationDataStorage.closeArray=r,T.applyToMesh(b,s),b},E.CreateCylinder=function(e,t,i){var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreateCylinder(t).applyToMesh(r,t.updatable),r},E.CreateTorus=function(e,t,i){var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreateTorus(t).applyToMesh(r,t.updatable),r},E.CreateTorusKnot=function(e,t,i){var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreateTorusKnot(t).applyToMesh(r,t.updatable),r},E.CreateLineSystem=function(e,t,i){var r=t.instance,n=t.lines,o=t.colors;if(r){var s,a,l=r.getVerticesData(mi.VertexBuffer.PositionKind);o&&(s=r.getVerticesData(mi.VertexBuffer.ColorKind));for(var c=0,h=0,u=0;u<n.length;u++)for(var d=n[u],f=0;f<d.length;f++)l[c]=d[f].x,l[c+1]=d[f].y,l[c+2]=d[f].z,o&&s&&(a=o[u],s[h]=a[f].r,s[h+1]=a[f].g,s[h+2]=a[f].b,s[h+3]=a[f].a,h+=4),c+=3;return r.updateVerticesData(mi.VertexBuffer.PositionKind,l,!1,!1),o&&s&&r.updateVerticesData(mi.VertexBuffer.ColorKind,s,!1,!1),r}var p=!!o,m=new mi.LinesMesh(e,i,null,void 0,void 0,p,t.useVertexAlpha);return mi.VertexData.CreateLineSystem(t).applyToMesh(m,t.updatable),m},E.CreateLines=function(e,t,i){void 0===i&&(i=null);var r=t.colors?[t.colors]:null;return E.CreateLineSystem(e,{lines:[t.points],updatable:t.updatable,instance:t.instance,colors:r,useVertexAlpha:t.useVertexAlpha},i)},E.CreateDashedLines=function(e,t,i){void 0===i&&(i=null);var d=t.points,f=t.instance,r=t.gapSize||1,n=t.dashSize||3;if(f){return f.updateMeshPositions((function(e){var t,i,r=mi.Vector3.Zero(),n=e.length/6,o=0,s=0,a=0,l=0,c=0,h=0;for(c=0;c<d.length-1;c++)d[c+1].subtractToRef(d[c],r),o+=r.length();t=o/n;var u=f._creationDataStorage.dashSize;for(i=u*t/(u+f._creationDataStorage.gapSize),c=0;c<d.length-1;c++)for(d[c+1].subtractToRef(d[c],r),s=Math.floor(r.length()/t),r.normalize(),h=0;h<s&&l<e.length;)a=t*h,e[l]=d[c].x+a*r.x,e[l+1]=d[c].y+a*r.y,e[l+2]=d[c].z+a*r.z,e[l+3]=d[c].x+(a+i)*r.x,e[l+4]=d[c].y+(a+i)*r.y,e[l+5]=d[c].z+(a+i)*r.z,l+=6,h++;for(;l<e.length;)e[l]=d[c].x,e[l+1]=d[c].y,e[l+2]=d[c].z,l+=3}),!1),f}var o=new mi.LinesMesh(e,i);return mi.VertexData.CreateDashedLines(t).applyToMesh(o,t.updatable),o._creationDataStorage=new mi._CreationDataStorage,o._creationDataStorage.dashSize=n,o._creationDataStorage.gapSize=r,o},E.ExtrudeShape=function(e,t,i){void 0===i&&(i=null);var r=t.path,n=t.shape,o=t.scale||1,s=t.rotation||0,a=0===t.cap?0:t.cap||mi.Mesh.NO_CAP,l=t.updatable,c=E.updateSideOrientation(t.sideOrientation),h=t.instance||null,u=t.invertUV||!1;return E._ExtrudeShapeGeneric(e,n,r,o,s,null,null,!1,!1,a,!1,i,!!l,c,h,u,t.frontUVs||null,t.backUVs||null)},E.ExtrudeShapeCustom=function(e,t,i){var r=t.path,n=t.shape,o=t.scaleFunction||function(){return 1},s=t.rotationFunction||function(){return 0},a=t.ribbonCloseArray||!1,l=t.ribbonClosePath||!1,c=0===t.cap?0:t.cap||mi.Mesh.NO_CAP,h=t.updatable,u=E.updateSideOrientation(t.sideOrientation),d=t.instance,f=t.invertUV||!1;return E._ExtrudeShapeGeneric(e,n,r,null,null,o,s,a,l,c,!0,i,!!h,u,d||null,f,t.frontUVs||null,t.backUVs||null)},E.CreateLathe=function(e,t,i){var r,n=t.arc?t.arc<=0||1<t.arc?1:t.arc:1,o=void 0===t.closed||t.closed,s=t.shape,a=t.radius||1,l=t.tessellation||64,c=t.clip||0,h=t.updatable,u=E.updateSideOrientation(t.sideOrientation),d=t.cap||mi.Mesh.NO_CAP,f=2*Math.PI,p=new Array,m=t.invertUV||!1,_=0,g=0,v=f/l*n,y=new Array;for(_=0;_<=l-c;_++){y=[];for(d!=mi.Mesh.CAP_START&&d!=mi.Mesh.CAP_ALL||(y.push(new mi.Vector3(0,s[0].y,0)),y.push(new mi.Vector3(Math.cos(_*v)*s[0].x*a,s[0].y,Math.sin(_*v)*s[0].x*a))),g=0;g<s.length;g++)r=new mi.Vector3(Math.cos(_*v)*s[g].x*a,s[g].y,Math.sin(_*v)*s[g].x*a),y.push(r);d!=mi.Mesh.CAP_END&&d!=mi.Mesh.CAP_ALL||(y.push(new mi.Vector3(Math.cos(_*v)*s[s.length-1].x*a,s[s.length-1].y,Math.sin(_*v)*s[s.length-1].x*a)),y.push(new mi.Vector3(0,s[s.length-1].y,0))),p.push(y)}return E.CreateRibbon(e,{pathArray:p,closeArray:o,sideOrientation:u,updatable:h,invertUV:m,frontUVs:t.frontUVs,backUVs:t.backUVs},i)},E.CreatePlane=function(e,t,i){var r=new mi.Mesh(e,i);if(t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreatePlane(t).applyToMesh(r,t.updatable),t.sourcePlane){r.translate(t.sourcePlane.normal,t.sourcePlane.d);var n=Math.acos(mi.Vector3.Dot(t.sourcePlane.normal,mi.Axis.Z)),o=mi.Vector3.Cross(mi.Axis.Z,t.sourcePlane.normal);o.lengthSquared()>mi.Epsilon&&r.rotate(o,n)}return r},E.CreateGround=function(e,t,i){var r=new mi.GroundMesh(e,i);return r._setReady(!1),r._subdivisionsX=t.subdivisionsX||t.subdivisions||1,r._subdivisionsY=t.subdivisionsY||t.subdivisions||1,r._width=t.width||1,r._height=t.height||1,r._maxX=r._width/2,r._maxZ=r._height/2,r._minX=-r._maxX,r._minZ=-r._maxZ,mi.VertexData.CreateGround(t).applyToMesh(r,t.updatable),r._setReady(!0),r},E.CreateTiledGround=function(e,t,i){var r=new mi.Mesh(e,i);return mi.VertexData.CreateTiledGround(t).applyToMesh(r,t.updatable),r},E.CreateGroundFromHeightMap=function(e,t,i,s){var a=i.width||10,l=i.height||10,c=i.subdivisions||1,h=i.minHeight||0,u=i.maxHeight||1,d=i.colorFilter||new mi.Color3(.3,.59,.11),f=i.alphaFilter||0,p=i.updatable,m=i.onReady,_=new mi.GroundMesh(e,s);_._subdivisionsX=c,_._subdivisionsY=c,_._width=a,_._height=l,_._maxX=_._width/2,_._maxZ=_._height/2,_._minX=-_._maxX,_._minZ=-_._maxZ,_._setReady(!1);return mi.Tools.LoadImage(t,(function(e){var t=document.createElement("canvas"),i=t.getContext("2d");if(!i)throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");if(!s.isDisposed){var r=e.width,n=e.height;t.width=r,t.height=n,i.drawImage(e,0,0);var o=i.getImageData(0,0,r,n).data;mi.VertexData.CreateGroundFromHeightMap({width:a,height:l,subdivisions:c,minHeight:h,maxHeight:u,colorFilter:d,buffer:o,bufferWidth:r,bufferHeight:n,alphaFilter:f}).applyToMesh(_,p),m&&m(_),_._setReady(!0)}}),(function(){}),s.database),_},E.CreatePolygon=function(e,t,i){t.sideOrientation=E.updateSideOrientation(t.sideOrientation);for(var r=t.shape,n=t.holes||[],o=t.depth||0,s=[],a=[],l=0;l<r.length;l++)s[l]=new mi.Vector2(r[l].x,r[l].z);s[0].equalsWithEpsilon(s[s.length-1],1e-8)&&s.pop();for(var c=new mi.PolygonMeshBuilder(e,s,i),h=0;h<n.length;h++){a=[];for(var u=0;u<n[h].length;u++)a.push(new mi.Vector2(n[h][u].x,n[h][u].z));c.addHole(a)}var d=c.build(t.updatable,o);return d._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreatePolygon(d,t.sideOrientation,t.faceUV,t.faceColors,t.frontUVs,t.backUVs).applyToMesh(d,t.updatable),d},E.ExtrudePolygon=function(e,t,i){return E.CreatePolygon(e,t,i)},E.CreateTube=function(e,t,i){var r=t.path,n=t.instance,o=1;void 0!==t.radius?o=t.radius:n&&(o=n._creationDataStorage.radius);var s=t.tessellation||64,a=t.radiusFunction||null,l=t.cap||mi.Mesh.NO_CAP,c=t.invertUV||!1,h=t.updatable,u=E.updateSideOrientation(t.sideOrientation);t.arc=t.arc&&(t.arc<=0||1<t.arc)?1:t.arc||1;var d,f,p=function(n,e,t,i,r,o,s,a){for(var l,c,h,u,d=e.getTangents(),f=e.getNormals(),p=e.getDistances(),m=2*Math.PI/r*a,_=o||function(){return i},g=mi.Tmp.Matrix[0],v=s===mi.Mesh.NO_CAP||s===mi.Mesh.CAP_END?0:2,y=0;y<n.length;y++){c=_(y,p[y]),l=Array(),h=f[y];for(var b=0;b<r;b++)mi.Matrix.RotationAxisToRef(d[y],m*b,g),u=l[b]?l[b]:mi.Vector3.Zero(),mi.Vector3.TransformCoordinatesToRef(h,g,u),u.scaleInPlace(c).addInPlace(n[y]),l[b]=u;t[v]=l,v++}var T=function(e,t){for(var i=Array(),r=0;r<e;r++)i.push(n[t]);return i};switch(s){case mi.Mesh.NO_CAP:break;case mi.Mesh.CAP_START:t[0]=T(r,0),t[1]=t[2].slice(0);break;case mi.Mesh.CAP_END:t[v]=t[v-1].slice(0),t[v+1]=T(r,n.length-1);break;case mi.Mesh.CAP_ALL:t[0]=T(r,0),t[1]=t[2].slice(0),t[v]=t[v-1].slice(0),t[v+1]=T(r,n.length-1)}return t};if(n){var m=n._creationDataStorage,_=t.arc||m.arc;return f=p(r,d=m.path3D.update(r),m.pathArray,o,m.tessellation,a,m.cap,_),n=E.CreateRibbon("",{pathArray:f,instance:n}),m.path3D=d,m.pathArray=f,m.arc=_,m.radius=o,n}f=p(r,d=new mi.Path3D(r),new Array,o,s,a,l=l<0||3<l?0:l,t.arc);var g=E.CreateRibbon(e,{pathArray:f,closePath:!0,closeArray:!1,updatable:h,sideOrientation:u,invertUV:c,frontUVs:t.frontUVs,backUVs:t.backUVs},i);return g._creationDataStorage.pathArray=f,g._creationDataStorage.path3D=d,g._creationDataStorage.tessellation=s,g._creationDataStorage.cap=l,g._creationDataStorage.arc=t.arc,g._creationDataStorage.radius=o,g},E.CreatePolyhedron=function(e,t,i){var r=new mi.Mesh(e,i);return t.sideOrientation=E.updateSideOrientation(t.sideOrientation),r._originalBuilderSideOrientation=t.sideOrientation,mi.VertexData.CreatePolyhedron(t).applyToMesh(r,t.updatable),r},E.CreateDecal=function(e,t,i){var r=t.getIndices(),n=t.getVerticesData(mi.VertexBuffer.PositionKind),o=t.getVerticesData(mi.VertexBuffer.NormalKind),s=i.position||mi.Vector3.Zero(),a=i.normal||mi.Vector3.Up(),f=i.size||mi.Vector3.One(),l=i.angle||0;if(!a){var c=new mi.Vector3(0,0,1),h=t.getScene().activeCamera,u=mi.Vector3.TransformCoordinates(c,h.getWorldMatrix());a=h.globalPosition.subtract(u)}var d=-Math.atan2(a.z,a.x)-Math.PI/2,p=Math.sqrt(a.x*a.x+a.z*a.z),m=Math.atan2(a.y,p),_=mi.Matrix.RotationYawPitchRoll(d,m,l).multiply(mi.Matrix.Translation(s.x,s.y,s.z)),g=mi.Matrix.Invert(_),v=t.getWorldMatrix().multiply(g),y=new mi.VertexData;y.indices=[],y.positions=[],y.normals=[],y.uvs=[];for(var b=0,T=function(e){var t=new mi.PositionNormalVertex;if(!r||!n||!o)return t;var i=r[e];return t.position=new mi.Vector3(n[3*i],n[3*i+1],n[3*i+2]),t.position=mi.Vector3.TransformCoordinates(t.position,v),t.normal=new mi.Vector3(o[3*i],o[3*i+1],o[3*i+2]),t.normal=mi.Vector3.TransformNormal(t.normal,v),t},x=function(e,r){if(0===e.length)return e;for(var n=.5*Math.abs(mi.Vector3.Dot(f,r)),t=function(e,t){var i=mi.Vector3.GetClipFactor(e.position,t.position,r,n);return new mi.PositionNormalVertex(mi.Vector3.Lerp(e.position,t.position,i),mi.Vector3.Lerp(e.normal,t.normal,i))},i=new Array,o=0;o<e.length;o+=3){var s,a,l,c=null,h=null,u=null,d=null;switch(((s=0<mi.Vector3.Dot(e[o].position,r)-n)?1:0)+((a=0<mi.Vector3.Dot(e[o+1].position,r)-n)?1:0)+((l=0<mi.Vector3.Dot(e[o+2].position,r)-n)?1:0)){case 0:i.push(e[o]),i.push(e[o+1]),i.push(e[o+2]);break;case 1:if(s&&(c=e[o+1],h=e[o+2],u=t(e[o],c),d=t(e[o],h)),a){c=e[o],h=e[o+2],u=t(e[o+1],c),d=t(e[o+1],h),i.push(u),i.push(h.clone()),i.push(c.clone()),i.push(h.clone()),i.push(u.clone()),i.push(d);break}l&&(c=e[o],h=e[o+1],u=t(e[o+2],c),d=t(e[o+2],h)),c&&h&&u&&d&&(i.push(c.clone()),i.push(h.clone()),i.push(u),i.push(d),i.push(u.clone()),i.push(h.clone()));break;case 2:s||(h=t(c=e[o].clone(),e[o+1]),u=t(c,e[o+2]),i.push(c),i.push(h),i.push(u)),a||(h=t(c=e[o+1].clone(),e[o+2]),u=t(c,e[o]),i.push(c),i.push(h),i.push(u)),l||(h=t(c=e[o+2].clone(),e[o]),u=t(c,e[o+1]),i.push(c),i.push(h),i.push(u))}}return i},E=0;E<r.length;E+=3){var A=new Array;if(A.push(T(E)),A.push(T(E+1)),A.push(T(E+2)),0!==(A=x(A=x(A=x(A=x(A=x(A=x(A,new mi.Vector3(1,0,0)),new mi.Vector3(-1,0,0)),new mi.Vector3(0,1,0)),new mi.Vector3(0,-1,0)),new mi.Vector3(0,0,1)),new mi.Vector3(0,0,-1))).length)for(var P=0;P<A.length;P++){var S=A[P];y.indices.push(b),S.position.toArray(y.positions,3*b),S.normal.toArray(y.normals,3*b),y.uvs.push(.5+S.position.x/f.x),y.uvs.push(.5+S.position.y/f.y),b++}}var R=new mi.Mesh(e,t.getScene());return y.applyToMesh(R),R.position=s.clone(),R.rotation=new mi.Vector3(m,d,l),R},E._ExtrudeShapeGeneric=function(e,t,i,r,n,o,s,a,l,c,h,u,d,f,p,m,_,g){var v,y,b=function(e,t,i,r,n,o,s,a,l,c){for(var h=i.getTangents(),u=i.getNormals(),d=i.getBinormals(),f=i.getDistances(),p=0,m=c&&a?a:function(){return null!==o?o:0},_=c&&s?s:function(){return null!==n?n:1},g=l===mi.Mesh.NO_CAP||l===mi.Mesh.CAP_END?0:2,v=mi.Tmp.Matrix[0],y=0;y<t.length;y++){for(var b=new Array,T=m(y,f[y]),x=_(y,f[y]),E=0;E<e.length;E++){mi.Matrix.RotationAxisToRef(h[y],p,v);var A=h[y].scale(e[E].z).add(u[y].scale(e[E].x)).add(d[y].scale(e[E].y)),P=b[E]?b[E]:mi.Vector3.Zero();mi.Vector3.TransformCoordinatesToRef(A,v,P),P.scaleInPlace(x).addInPlace(t[y]),b[E]=P}r[g]=b,p+=T,g++}var S=function(e){var t,i=Array(),r=mi.Vector3.Zero();for(t=0;t<e.length;t++)r.addInPlace(e[t]);for(r.scaleInPlace(1/e.length),t=0;t<e.length;t++)i.push(r);return i};switch(l){case mi.Mesh.NO_CAP:break;case mi.Mesh.CAP_START:r[0]=S(r[2]),r[1]=r[2];break;case mi.Mesh.CAP_END:r[g]=r[g-1],r[g+1]=S(r[g-1]);break;case mi.Mesh.CAP_ALL:r[0]=S(r[2]),r[1]=r[2],r[g]=r[g-1],r[g+1]=S(r[g-1])}return r};if(p){var T=p._creationDataStorage;return v=T.path3D.update(i),y=b(t,i,T.path3D,T.pathArray,r,n,o,s,T.cap,h),p=mi.Mesh.CreateRibbon("",y,!1,!1,0,u||void 0,!1,0,p)}y=b(t,i,v=new mi.Path3D(i),new Array,r,n,o,s,c=c<0||3<c?0:c,h);var x=E.CreateRibbon(e,{pathArray:y,closeArray:a,closePath:l,updatable:d,sideOrientation:f,invertUV:m,frontUVs:_||void 0,backUVs:g||void 0},u);return x._creationDataStorage.pathArray=y,x._creationDataStorage.path3D=v,x._creationDataStorage.cap=c,x},E})(),mi.MeshBuilder=_i,gi=$a||($a={}),vi=(function(){function r(){}return Object.defineProperty(r,"DecoderAvailable",{get:function(){if("undefined"!=typeof DracoDecoderModule)return!0;var e=r.Configuration.decoder;if(e){if(e.wasmUrl&&e.wasmBinaryUrl&&"object"==typeof WebAssembly)return!0;if(e.fallbackUrl)return!0}return!1},enumerable:!0,configurable:!0}),r.prototype.dispose=function(){},r.prototype.decodeMeshAsync=function(e,y){var b=e instanceof ArrayBuffer?new Uint8Array(e):e;return r._GetDecoderModule().then((function(e){var t=e.module,i=new gi.VertexData,r=new t.DecoderBuffer;r.Init(b,b.byteLength);var n,o,s=new t.Decoder;try{var a=s.GetEncodedGeometryType(r);switch(a){case t.TRIANGULAR_MESH:n=new t.Mesh,o=s.DecodeBufferToMesh(r,n);break;case t.POINT_CLOUD:n=new t.PointCloud,o=s.DecodeBufferToPointCloud(r,n);break;default:throw new Error("Invalid geometry type "+a)}if(!o.ok()||!n.ptr)throw new Error(o.error_msg());var l=n.num_points();if(a===t.TRIANGULAR_MESH){var c=n.num_faces(),h=new t.DracoInt32Array;try{for(var u=new Uint32Array(3*c),d=0;d<c;d++){s.GetFaceFromMesh(n,d,h);var f=3*d;u[f+0]=h.GetValue(0),u[f+1]=h.GetValue(1),u[f+2]=h.GetValue(2)}i.indices=u}finally{t.destroy(h)}}for(var p in y){var m=y[p],_=s.GetAttributeByUniqueId(n,m),g=new t.DracoFloat32Array;try{s.GetAttributeFloatForAllPoints(n,_,g);var v=new Float32Array(l*_.num_components());for(d=0;d<v.length;d++)v[d]=g.GetValue(d);i.set(v,p)}finally{t.destroy(g)}}}finally{n&&t.destroy(n),t.destroy(s),t.destroy(r)}return i}))},r._GetDecoderModule=function(){if(!r._DecoderModulePromise){var e=null,i={};if("undefined"!=typeof DracoDecoderModule)e=Promise.resolve();else{var t=r.Configuration.decoder;t&&(t.wasmUrl&&t.wasmBinaryUrl&&"object"==typeof WebAssembly?e=Promise.all([r._LoadScriptAsync(t.wasmUrl),r._LoadFileAsync(t.wasmBinaryUrl).then((function(e){i.wasmBinary=e}))]):t.fallbackUrl&&(e=r._LoadScriptAsync(t.fallbackUrl)))}if(!e)throw new Error("Draco decoder module is not available");r._DecoderModulePromise=e.then((function(){return new Promise(function(t){i.onModuleLoaded=function(e){t({module:e})},DracoDecoderModule(i)})}))}return r._DecoderModulePromise},r._LoadScriptAsync=function(i){return new Promise(function(e,t){gi.Tools.LoadScript(i,(function(){e()}),(function(e){t(new Error(e))}))})},r._LoadFileAsync=function(e){return new Promise(function(t,i){gi.Tools.LoadFile(e,(function(e){t(e)}),void 0,void 0,!0,(function(e,t){i(t)}))})},r.Configuration={decoder:{wasmUrl:"https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",wasmBinaryUrl:"https://preview.babylonjs.com/draco_decoder_gltf.wasm",fallbackUrl:"https://preview.babylonjs.com/draco_decoder_gltf.js"}},r})(),gi.DracoCompression=vi,(function(r){r.Engine.AudioEngineFactory=function(e){return new t(e)};var t=(function(){function e(e){void 0===e&&(e=null);var t=this;this._audioContext=null,this._audioContextInitialized=!1,this._muteButton=null,this.canUseWebAudio=!1,this.WarnedWebAudioUnsupported=!1,this.isMP3supported=!1,this.isOGGsupported=!1,this.unlocked=!0,this.useCustomUnlockedButton=!1,this.onAudioUnlockedObservable=new r.Observable,this.onAudioLockedObservable=new r.Observable,this._tryToRun=!1,this._onResize=function(){t._moveButtonToTopLeft()},void 0===window.AudioContext&&void 0===window.webkitAudioContext||(window.AudioContext=window.AudioContext||window.webkitAudioContext,this.canUseWebAudio=!0);var i=document.createElement("audio");this._hostElement=e;try{i&&i.canPlayType&&i.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/,"")&&(this.isMP3supported=!0)}catch(e){}try{i&&i.canPlayType&&i.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/,"")&&(this.isOGGsupported=!0)}catch(e){}}return Object.defineProperty(e.prototype,"audioContext",{get:function(){return this._audioContextInitialized?this.unlocked||this._muteButton||this._displayMuteButton():this._initializeAudioContext(),this._audioContext},enumerable:!0,configurable:!0}),e.prototype.lock=function(){this._triggerSuspendedState()},e.prototype.unlock=function(){this._triggerRunningState()},e.prototype._resumeAudioContext=function(){var e;return this._audioContext.resume&&(e=this._audioContext.resume()),e||Promise.resolve()},e.prototype._initializeAudioContext=function(){try{this.canUseWebAudio&&(this._audioContext=new AudioContext,this.masterGain=this._audioContext.createGain(),this.masterGain.gain.value=1,this.masterGain.connect(this._audioContext.destination),this._audioContextInitialized=!0,"running"===this._audioContext.state&&this._triggerRunningState())}catch(e){this.canUseWebAudio=!1,r.Tools.Error("Web Audio: "+e.message)}},e.prototype._triggerRunningState=function(){var e=this;this._tryToRun||(this._tryToRun=!0,this._resumeAudioContext().then((function(){e._tryToRun=!1,e._muteButton&&e._hideMuteButton()})).catch((function(){e._tryToRun=!1,e.unlocked=!1})),this.unlocked=!0,this.onAudioUnlockedObservable.notifyObservers(this))},e.prototype._triggerSuspendedState=function(){this.unlocked=!1,this.onAudioLockedObservable.notifyObservers(this),this._displayMuteButton()},e.prototype._displayMuteButton=function(){var e=this;if(!this.useCustomUnlockedButton){this._muteButton=document.createElement("BUTTON"),this._muteButton.className="babylonUnmuteIcon",this._muteButton.id="babylonUnmuteIconBtn",this._muteButton.title="Unmute";var t=document.createElement("style");t.appendChild(document.createTextNode(".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }")),document.getElementsByTagName("head")[0].appendChild(t),document.body.appendChild(this._muteButton),this._moveButtonToTopLeft(),this._muteButton.addEventListener("touchend",(function(){e._triggerRunningState()}),!0),this._muteButton.addEventListener("click",(function(){e._triggerRunningState()}),!0),window.addEventListener("resize",this._onResize)}},e.prototype._moveButtonToTopLeft=function(){this._hostElement&&this._muteButton&&(this._muteButton.style.top=this._hostElement.offsetTop+20+"px",this._muteButton.style.left=this._hostElement.offsetLeft+20+"px")},e.prototype._hideMuteButton=function(){this._muteButton&&(document.body.removeChild(this._muteButton),this._muteButton=null)},e.prototype.dispose=function(){this.canUseWebAudio&&this._audioContextInitialized&&(this._connectedAnalyser&&this._audioContext&&(this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser.dispose(),this.masterGain.disconnect(),this.masterGain.connect(this._audioContext.destination),this._connectedAnalyser=null),this.masterGain.gain.value=1),this.WarnedWebAudioUnsupported=!1,this._hideMuteButton(),window.removeEventListener("resize",this._onResize),this.onAudioUnlockedObservable.clear(),this.onAudioLockedObservable.clear()},e.prototype.getGlobalVolume=function(){return this.canUseWebAudio&&this._audioContextInitialized?this.masterGain.gain.value:-1},e.prototype.setGlobalVolume=function(e){this.canUseWebAudio&&this._audioContextInitialized&&(this.masterGain.gain.value=e)},e.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this.canUseWebAudio&&this._audioContextInitialized&&this._audioContext&&(this._connectedAnalyser=e,this.masterGain.disconnect(),this._connectedAnalyser.connectAudioNodes(this.masterGain,this._audioContext.destination))},e})();r.AudioEngine=t})($a||($a={})),yi=$a||($a={}),bi=(function(){function d(e,t,i,r,n){void 0===r&&(r=null);var o=this;this.autoplay=!1,this.loop=!1,this.useCustomAttenuation=!1,this.isPlaying=!1,this.isPaused=!1,this.spatialSound=!1,this.refDistance=1,this.rolloffFactor=1,this.maxDistance=100,this.distanceModel="linear",this.onEndedObservable=new yi.Observable,this._panningModel="equalpower",this._playbackRate=1,this._streaming=!1,this._startTime=0,this._startOffset=0,this._position=yi.Vector3.Zero(),this._positionInEmitterSpace=!1,this._localDirection=new yi.Vector3(1,0,0),this._volume=1,this._isReadyToPlay=!1,this._isDirectional=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._coneOuterGain=0,this._isOutputConnected=!1,this._urlType="Unknown",this.name=e;var s=(this._scene=i)._getComponent(yi.SceneComponentConstants.NAME_AUDIO);if(s||(s=new yi.AudioSceneComponent(i),i._addComponent(s)),this._readyToPlayCallback=r,this._customAttenuationFunction=function(e,t,i,r,n){return t<i?e*(1-t/i):0},n&&(this.autoplay=n.autoplay||!1,this.loop=n.loop||!1,void 0!==n.volume&&(this._volume=n.volume),this.spatialSound=n.spatialSound||!1,this.maxDistance=n.maxDistance||100,this.useCustomAttenuation=n.useCustomAttenuation||!1,this.rolloffFactor=n.rolloffFactor||1,this.refDistance=n.refDistance||1,this.distanceModel=n.distanceModel||"linear",this._playbackRate=n.playbackRate||1,this._streaming=n.streaming||!1),yi.Engine.audioEngine.canUseWebAudio&&yi.Engine.audioEngine.audioContext){this._soundGain=yi.Engine.audioEngine.audioContext.createGain(),this._soundGain.gain.value=this._volume,this._inputAudioNode=this._soundGain,this._outputAudioNode=this._soundGain,this.spatialSound&&this._createSpatialParameters(),this._scene.mainSoundTrack.AddSound(this);var a=!0;if(t)try{"string"==typeof t?this._urlType="String":t instanceof ArrayBuffer?this._urlType="ArrayBuffer":t instanceof MediaStream?this._urlType="MediaStream":Array.isArray(t)&&(this._urlType="Array");var l=[],c=!1;switch(this._urlType){case"MediaStream":this._streaming=!0,this._isReadyToPlay=!0,this._streamingSource=yi.Engine.audioEngine.audioContext.createMediaElementSource(t),this.autoplay&&this.play(),this._readyToPlayCallback&&this._readyToPlayCallback();break;case"ArrayBuffer":0<t.byteLength&&(c=!0,this._soundLoaded(t));break;case"String":l.push(t);case"Array":0===l.length&&(l=t);for(var h=0;h<l.length;h++){var u=l[h];if(-1!==u.indexOf(".mp3",u.length-4)&&yi.Engine.audioEngine.isMP3supported&&(c=!0),-1!==u.indexOf(".ogg",u.length-4)&&yi.Engine.audioEngine.isOGGsupported&&(c=!0),-1!==u.indexOf(".wav",u.length-4)&&(c=!0),-1!==u.indexOf("blob:")&&(c=!0),c){this._streaming?(this._htmlAudioElement=new Audio(u),this._htmlAudioElement.controls=!1,this._htmlAudioElement.loop=this.loop,yi.Tools.SetCorsBehavior(u,this._htmlAudioElement),this._htmlAudioElement.preload="auto",this._htmlAudioElement.addEventListener("canplaythrough",(function(){o._isReadyToPlay=!0,o.autoplay&&o.play(),o._readyToPlayCallback&&o._readyToPlayCallback()})),document.body.appendChild(this._htmlAudioElement),this._htmlAudioElement.load()):this._scene._loadFile(u,(function(e){o._soundLoaded(e)}),void 0,!0,!0,(function(e){e&&yi.Tools.Error("XHR "+e.status+" error on: "+u+"."),yi.Tools.Error("Sound creation aborted."),o._scene.mainSoundTrack.RemoveSound(o)}));break}}break;default:a=!1}a?c||(this._isReadyToPlay=!0,this._readyToPlayCallback&&window.setTimeout((function(){o._readyToPlayCallback&&o._readyToPlayCallback()}),1e3)):yi.Tools.Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.")}catch(e){yi.Tools.Error("Unexpected error. Sound creation aborted."),this._scene.mainSoundTrack.RemoveSound(this)}}else this._scene.mainSoundTrack.AddSound(this),yi.Engine.audioEngine.WarnedWebAudioUnsupported||(yi.Tools.Error("Web Audio is not supported by your browser."),yi.Engine.audioEngine.WarnedWebAudioUnsupported=!0),this._readyToPlayCallback&&window.setTimeout((function(){o._readyToPlayCallback&&o._readyToPlayCallback()}),1e3)}return d.prototype.dispose=function(){yi.Engine.audioEngine.canUseWebAudio&&(this.isPlaying&&this.stop(),this._isReadyToPlay=!1,-1===this.soundTrackId?this._scene.mainSoundTrack.RemoveSound(this):this._scene.soundTracks&&this._scene.soundTracks[this.soundTrackId].RemoveSound(this),this._soundGain&&(this._soundGain.disconnect(),this._soundGain=null),this._soundPanner&&(this._soundPanner.disconnect(),this._soundPanner=null),this._soundSource&&(this._soundSource.disconnect(),this._soundSource=null),this._audioBuffer=null,this._htmlAudioElement&&(this._htmlAudioElement.pause(),this._htmlAudioElement.src="",document.body.removeChild(this._htmlAudioElement)),this._streamingSource&&this._streamingSource.disconnect(),this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._connectedMesh=null))},d.prototype.isReady=function(){return this._isReadyToPlay},d.prototype._soundLoaded=function(e){var t=this;yi.Engine.audioEngine.audioContext&&yi.Engine.audioEngine.audioContext.decodeAudioData(e,(function(e){t._audioBuffer=e,t._isReadyToPlay=!0,t.autoplay&&t.play(),t._readyToPlayCallback&&t._readyToPlayCallback()}),(function(e){yi.Tools.Error("Error while decoding audio data for: "+t.name+" / Error: "+e)}))},d.prototype.setAudioBuffer=function(e){yi.Engine.audioEngine.canUseWebAudio&&(this._audioBuffer=e,this._isReadyToPlay=!0)},d.prototype.updateOptions=function(e){e&&(this.loop=e.loop||this.loop,this.maxDistance=e.maxDistance||this.maxDistance,this.useCustomAttenuation=e.useCustomAttenuation||this.useCustomAttenuation,this.rolloffFactor=e.rolloffFactor||this.rolloffFactor,this.refDistance=e.refDistance||this.refDistance,this.distanceModel=e.distanceModel||this.distanceModel,this._playbackRate=e.playbackRate||this._playbackRate,this._updateSpatialParameters(),this.isPlaying&&(this._streaming&&this._htmlAudioElement?this._htmlAudioElement.playbackRate=this._playbackRate:this._soundSource&&(this._soundSource.playbackRate.value=this._playbackRate)))},d.prototype._createSpatialParameters=function(){yi.Engine.audioEngine.canUseWebAudio&&yi.Engine.audioEngine.audioContext&&(this._scene.headphone&&(this._panningModel="HRTF"),this._soundPanner=yi.Engine.audioEngine.audioContext.createPanner(),this._updateSpatialParameters(),this._soundPanner.connect(this._outputAudioNode),this._inputAudioNode=this._soundPanner)},d.prototype._updateSpatialParameters=function(){this.spatialSound&&this._soundPanner&&(this.useCustomAttenuation?(this._soundPanner.distanceModel="linear",this._soundPanner.maxDistance=Number.MAX_VALUE,this._soundPanner.refDistance=1,this._soundPanner.rolloffFactor=1):(this._soundPanner.distanceModel=this.distanceModel,this._soundPanner.maxDistance=this.maxDistance,this._soundPanner.refDistance=this.refDistance,this._soundPanner.rolloffFactor=this.rolloffFactor),this._soundPanner.panningModel=this._panningModel)},d.prototype.switchPanningModelToHRTF=function(){this._panningModel="HRTF",this._switchPanningModel()},d.prototype.switchPanningModelToEqualPower=function(){this._panningModel="equalpower",this._switchPanningModel()},d.prototype._switchPanningModel=function(){yi.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.panningModel=this._panningModel)},d.prototype.connectToSoundTrackAudioNode=function(e){yi.Engine.audioEngine.canUseWebAudio&&(this._isOutputConnected&&this._outputAudioNode.disconnect(),this._outputAudioNode.connect(e),this._isOutputConnected=!0)},d.prototype.setDirectionalCone=function(e,t,i){t<e?yi.Tools.Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle."):(this._coneInnerAngle=e,this._coneOuterAngle=t,this._coneOuterGain=i,this._isDirectional=!0,this.isPlaying&&this.loop&&(this.stop(),this.play()))},Object.defineProperty(d.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(e){if(e!=this._coneInnerAngle){if(this._coneOuterAngle<e)return void yi.Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=e,yi.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle)}},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(e){if(e!=this._coneOuterAngle){if(e<this._coneInnerAngle)return void yi.Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=e,yi.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&(this._soundPanner.coneOuterAngle=this._coneOuterAngle)}},enumerable:!0,configurable:!0}),d.prototype.setPosition=function(e){this._position=e,yi.Engine.audioEngine.canUseWebAudio&&this.spatialSound&&this._soundPanner&&!isNaN(this._position.x)&&!isNaN(this._position.y)&&!isNaN(this._position.z)&&this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z)},d.prototype.setLocalDirectionToMesh=function(e){this._localDirection=e,yi.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.isPlaying&&this._updateDirection()},d.prototype._updateDirection=function(){if(this._connectedMesh&&this._soundPanner){var e=this._connectedMesh.getWorldMatrix(),t=yi.Vector3.TransformNormal(this._localDirection,e);t.normalize(),this._soundPanner.setOrientation(t.x,t.y,t.z)}},d.prototype.updateDistanceFromListener=function(){if(yi.Engine.audioEngine.canUseWebAudio&&this._connectedMesh&&this.useCustomAttenuation&&this._soundGain&&this._scene.activeCamera){var e=this._connectedMesh.getDistanceToCamera(this._scene.activeCamera);this._soundGain.gain.value=this._customAttenuationFunction(this._volume,e,this.maxDistance,this.refDistance,this.rolloffFactor)}},d.prototype.setAttenuationFunction=function(e){this._customAttenuationFunction=e},d.prototype.play=function(e,t){var i=this;if(this._isReadyToPlay&&this._scene.audioEnabled&&yi.Engine.audioEngine.audioContext)try{this._startOffset<0&&(e=-this._startOffset,this._startOffset=0);var r=e?yi.Engine.audioEngine.audioContext.currentTime+e:yi.Engine.audioEngine.audioContext.currentTime;if(this._soundSource&&this._streamingSource||this.spatialSound&&this._soundPanner&&(isNaN(this._position.x)||isNaN(this._position.y)||isNaN(this._position.z)||this._soundPanner.setPosition(this._position.x,this._position.y,this._position.z),this._isDirectional&&(this._soundPanner.coneInnerAngle=this._coneInnerAngle,this._soundPanner.coneOuterAngle=this._coneOuterAngle,this._soundPanner.coneOuterGain=this._coneOuterGain,this._connectedMesh?this._updateDirection():this._soundPanner.setOrientation(this._localDirection.x,this._localDirection.y,this._localDirection.z))),this._streaming){if(this._streamingSource||(this._streamingSource=yi.Engine.audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement),this._htmlAudioElement.onended=function(){i._onended()},this._htmlAudioElement.playbackRate=this._playbackRate),this._streamingSource.disconnect(),this._streamingSource.connect(this._inputAudioNode),this._htmlAudioElement){var n=function(){if(yi.Engine.audioEngine.unlocked){var e=i._htmlAudioElement.play();void 0!==e&&e.catch((function(e){yi.Engine.audioEngine.lock(),yi.Engine.audioEngine.onAudioUnlockedObservable.addOnce((function(){n()}))}))}else yi.Engine.audioEngine.onAudioUnlockedObservable.addOnce((function(){n()}))};n()}}else this._soundSource=yi.Engine.audioEngine.audioContext.createBufferSource(),this._soundSource.buffer=this._audioBuffer,this._soundSource.connect(this._inputAudioNode),this._soundSource.loop=this.loop,this._soundSource.playbackRate.value=this._playbackRate,this._soundSource.onended=function(){i._onended()},this._soundSource.buffer&&this._soundSource.start(r,this.isPaused?this._startOffset%this._soundSource.buffer.duration:t||0);this._startTime=r,this.isPlaying=!0,this.isPaused=!1}catch(e){yi.Tools.Error("Error while trying to play audio: "+this.name+", "+e.message)}},d.prototype._onended=function(){this.isPlaying=!1,this.onended&&this.onended(),this.onEndedObservable.notifyObservers(this)},d.prototype.stop=function(e){if(this.isPlaying){if(this._streaming)this._htmlAudioElement?(this._htmlAudioElement.pause(),0<this._htmlAudioElement.currentTime&&(this._htmlAudioElement.currentTime=0)):this._streamingSource.disconnect();else if(yi.Engine.audioEngine.audioContext&&this._soundSource){var t=e?yi.Engine.audioEngine.audioContext.currentTime+e:yi.Engine.audioEngine.audioContext.currentTime;this._soundSource.stop(t),this._soundSource.onended=function(){},this.isPaused||(this._startOffset=0)}this.isPlaying=!1}},d.prototype.pause=function(){this.isPlaying&&(this.isPaused=!0,this._streaming?this._htmlAudioElement?this._htmlAudioElement.pause():this._streamingSource.disconnect():yi.Engine.audioEngine.audioContext&&(this.stop(0),this._startOffset+=yi.Engine.audioEngine.audioContext.currentTime-this._startTime))},d.prototype.setVolume=function(e,t){yi.Engine.audioEngine.canUseWebAudio&&this._soundGain&&(t&&yi.Engine.audioEngine.audioContext?(this._soundGain.gain.cancelScheduledValues(yi.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.setValueAtTime(this._soundGain.gain.value,yi.Engine.audioEngine.audioContext.currentTime),this._soundGain.gain.linearRampToValueAtTime(e,yi.Engine.audioEngine.audioContext.currentTime+t)):this._soundGain.gain.value=e),this._volume=e},d.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))},d.prototype.getVolume=function(){return this._volume},d.prototype.attachToMesh=function(e){var t=this;this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null),this._connectedMesh=e,this.spatialSound||(this.spatialSound=!0,this._createSpatialParameters(),this.isPlaying&&this.loop&&(this.stop(),this.play())),this._onRegisterAfterWorldMatrixUpdate(this._connectedMesh),this._registerFunc=function(e){return t._onRegisterAfterWorldMatrixUpdate(e)},e.registerAfterWorldMatrixUpdate(this._registerFunc)},d.prototype.detachFromMesh=function(){this._connectedMesh&&this._registerFunc&&(this._connectedMesh.unregisterAfterWorldMatrixUpdate(this._registerFunc),this._registerFunc=null,this._connectedMesh=null)},d.prototype._onRegisterAfterWorldMatrixUpdate=function(e){if(e.getBoundingInfo){var t=e;if(this._positionInEmitterSpace)t.worldMatrixFromCache.invertToRef(yi.Tmp.Matrix[0]),this.setPosition(yi.Tmp.Matrix[0].getTranslation());else{var i=t.getBoundingInfo();this.setPosition(i.boundingSphere.centerWorld)}yi.Engine.audioEngine.canUseWebAudio&&this._isDirectional&&this.isPlaying&&this._updateDirection()}},d.prototype.clone=function(){var e=this;if(this._streaming)return null;var t=function(){e._isReadyToPlay?(r._audioBuffer=e.getAudioBuffer(),r._isReadyToPlay=!0,r.autoplay&&r.play()):window.setTimeout(t,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 d(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),t(),r},d.prototype.getAudioBuffer=function(){return this._audioBuffer},d.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._connectedMesh&&(e.connectedMeshId=this._connectedMesh.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},d.Parse=function(e,t,i,r){var n,o=e.name;n=e.url?i+e.url:i+o;var s,a={autoplay:e.autoplay,loop:e.loop,volume:e.volume,spatialSound:e.spatialSound,maxDistance:e.maxDistance,rolloffFactor:e.rolloffFactor,refDistance:e.refDistance,distanceModel:e.distanceModel,playbackRate:e.playbackRate};if(r){var l=function(){r._isReadyToPlay?(s._audioBuffer=r.getAudioBuffer(),s._isReadyToPlay=!0,s.autoplay&&s.play()):window.setTimeout(l,300)};s=new d(o,new ArrayBuffer(0),t,null,a),l()}else s=new d(o,n,t,function(){t._removePendingData(s)},a),t._addPendingData(s);if(e.position){var c=yi.Vector3.FromArray(e.position);s.setPosition(c)}if(e.isDirectional&&(s.setDirectionalCone(e.coneInnerAngle||360,e.coneOuterAngle||360,e.coneOuterGain||0),e.localDirectionToMesh)){var h=yi.Vector3.FromArray(e.localDirectionToMesh);s.setLocalDirectionToMesh(h)}if(e.connectedMeshId){var u=t.getMeshByID(e.connectedMeshId);u&&s.attachToMesh(u)}return s},d})(),yi.Sound=bi,Ti=$a||($a={}),xi=(function(){function e(e,t){void 0===t&&(t={}),this.id=-1,this._isMainTrack=!1,this._isInitialized=!1,this._scene=e,this.soundCollection=new Array,this._options=t,!this._isMainTrack&&this._scene.soundTracks&&(this._scene.soundTracks.push(this),this.id=this._scene.soundTracks.length-1)}return e.prototype._initializeSoundTrackAudioGraph=function(){Ti.Engine.audioEngine.canUseWebAudio&&Ti.Engine.audioEngine.audioContext&&(this._outputAudioNode=Ti.Engine.audioEngine.audioContext.createGain(),this._outputAudioNode.connect(Ti.Engine.audioEngine.masterGain),this._options&&(this._options.volume&&(this._outputAudioNode.gain.value=this._options.volume),this._options.mainTrack&&(this._isMainTrack=this._options.mainTrack)),this._isInitialized=!0)},e.prototype.dispose=function(){if(Ti.Engine.audioEngine&&Ti.Engine.audioEngine.canUseWebAudio){for(this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas();this.soundCollection.length;)this.soundCollection[0].dispose();this._outputAudioNode&&this._outputAudioNode.disconnect(),this._outputAudioNode=null}},e.prototype.AddSound=function(e){this._isInitialized||this._initializeSoundTrackAudioGraph(),Ti.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&e.connectToSoundTrackAudioNode(this._outputAudioNode),e.soundTrackId&&(-1===e.soundTrackId?this._scene.mainSoundTrack.RemoveSound(e):this._scene.soundTracks&&this._scene.soundTracks[e.soundTrackId].RemoveSound(e)),this.soundCollection.push(e),e.soundTrackId=this.id},e.prototype.RemoveSound=function(e){var t=this.soundCollection.indexOf(e);-1!==t&&this.soundCollection.splice(t,1)},e.prototype.setVolume=function(e){Ti.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.gain.value=e)},e.prototype.switchPanningModelToHRTF=function(){if(Ti.Engine.audioEngine.canUseWebAudio)for(var e=0;e<this.soundCollection.length;e++)this.soundCollection[e].switchPanningModelToHRTF()},e.prototype.switchPanningModelToEqualPower=function(){if(Ti.Engine.audioEngine.canUseWebAudio)for(var e=0;e<this.soundCollection.length;e++)this.soundCollection[e].switchPanningModelToEqualPower()},e.prototype.connectToAnalyser=function(e){this._connectedAnalyser&&this._connectedAnalyser.stopDebugCanvas(),this._connectedAnalyser=e,Ti.Engine.audioEngine.canUseWebAudio&&this._outputAudioNode&&(this._outputAudioNode.disconnect(),this._connectedAnalyser.connectAudioNodes(this._outputAudioNode,Ti.Engine.audioEngine.masterGain))},e})(),Ti.SoundTrack=xi,Ei=$a||($a={}),Ai=(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=Ei.Engine.audioEngine,this._audioEngine.canUseWebAudio&&this._audioEngine.audioContext&&(this._webAudioAnalyser=this._audioEngine.audioContext.createAnalyser(),this._webAudioAnalyser.minDecibels=-140,this._webAudioAnalyser.maxDecibels=0,this._byteFreqs=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._byteTime=new Uint8Array(this._webAudioAnalyser.frequencyBinCount),this._floatFreqs=new Float32Array(this._webAudioAnalyser.frequencyBinCount))}return e.prototype.getFrequencyBinCount=function(){return this._audioEngine.canUseWebAudio?this._webAudioAnalyser.frequencyBinCount:0},e.prototype.getByteFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs)),this._byteFreqs},e.prototype.getByteTimeDomainData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getByteTimeDomainData(this._byteTime)),this._byteTime},e.prototype.getFloatFrequencyData=function(){return this._audioEngine.canUseWebAudio&&(this._webAudioAnalyser.smoothingTimeConstant=this.SMOOTHING,this._webAudioAnalyser.fftSize=this.FFT_SIZE,this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs)),this._floatFreqs},e.prototype.drawDebugCanvas=function(){var e=this;if(this._audioEngine.canUseWebAudio&&(this._debugCanvas||(this._debugCanvas=document.createElement("canvas"),this._debugCanvas.width=this.DEBUGCANVASSIZE.width,this._debugCanvas.height=this.DEBUGCANVASSIZE.height,this._debugCanvas.style.position="absolute",this._debugCanvas.style.top=this.DEBUGCANVASPOS.y+"px",this._debugCanvas.style.left=this.DEBUGCANVASPOS.x+"px",this._debugCanvasContext=this._debugCanvas.getContext("2d"),document.body.appendChild(this._debugCanvas),this._registerFunc=function(){e.drawDebugCanvas()},this._scene.registerBeforeRender(this._registerFunc)),this._registerFunc&&this._debugCanvasContext)){var t=this.getByteFrequencyData();this._debugCanvasContext.fillStyle="rgb(0, 0, 0)",this._debugCanvasContext.fillRect(0,0,this.DEBUGCANVASSIZE.width,this.DEBUGCANVASSIZE.height);for(var i=0;i<this.getFrequencyBinCount();i++){var r=t[i]/this.BARGRAPHAMPLITUDE,n=this.DEBUGCANVASSIZE.height*r,o=this.DEBUGCANVASSIZE.height-n-1,s=this.DEBUGCANVASSIZE.width/this.getFrequencyBinCount(),a=i/this.getFrequencyBinCount()*360;this._debugCanvasContext.fillStyle="hsl("+a+", 100%, 50%)",this._debugCanvasContext.fillRect(i*s,o,s,n)}}},e.prototype.stopDebugCanvas=function(){this._debugCanvas&&(this._registerFunc&&(this._scene.unregisterBeforeRender(this._registerFunc),this._registerFunc=null),document.body.removeChild(this._debugCanvas),this._debugCanvas=null,this._debugCanvasContext=null)},e.prototype.connectAudioNodes=function(e,t){this._audioEngine.canUseWebAudio&&(e.connect(this._webAudioAnalyser),this._webAudioAnalyser.connect(t))},e.prototype.dispose=function(){this._audioEngine.canUseWebAudio&&this._webAudioAnalyser.disconnect()},e})(),Ei.Analyser=Ai,Pi=$a||($a={}),Si=(function(){function e(e,t,i){var r=this;if(this.loop=!1,this._coneInnerAngle=360,this._coneOuterAngle=360,this._volume=1,this.isPlaying=!1,this.isPaused=!1,this._sounds=[],this._weights=[],t.length!==i.length)throw new Error("Sounds length does not equal weights length");this.loop=e;for(var n=0,o=0,s=this._weights=i;o<s.length;o++){n+=s[o]}for(var a=0<n?1/n:0,l=0;l<this._weights.length;l++)this._weights[l]*=a;this._sounds=t;for(var c=0,h=this._sounds;c<h.length;c++){h[c].onEndedObservable.add((function(){r._onended()}))}}return Object.defineProperty(e.prototype,"directionalConeInnerAngle",{get:function(){return this._coneInnerAngle},set:function(e){if(e!==this._coneInnerAngle){if(this._coneOuterAngle<e)return void Pi.Tools.Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneInnerAngle=e;for(var t=0,i=this._sounds;t<i.length;t++){i[t].directionalConeInnerAngle=e}}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"directionalConeOuterAngle",{get:function(){return this._coneOuterAngle},set:function(e){if(e!==this._coneOuterAngle){if(e<this._coneInnerAngle)return void Pi.Tools.Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");this._coneOuterAngle=e;for(var t=0,i=this._sounds;t<i.length;t++){i[t].directionalConeOuterAngle=e}}},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"volume",{get:function(){return this._volume},set:function(e){if(e!==this._volume)for(var t=0,i=this._sounds;t<i.length;t++){i[t].setVolume(e)}},enumerable:!0,configurable:!0}),e.prototype._onended=function(){void 0!==this._currentIndex&&(this._sounds[this._currentIndex].autoplay=!1),this.loop&&this.isPlaying?this.play():this.isPlaying=!1},e.prototype.pause=function(){this.isPaused=!0,void 0!==this._currentIndex&&this._sounds[this._currentIndex].pause()},e.prototype.stop=function(){this.isPlaying=!1,void 0!==this._currentIndex&&this._sounds[this._currentIndex].stop()},e.prototype.play=function(e){if(!this.isPaused){this.stop();for(var t=Math.random(),i=0,r=0;r<this._weights.length;r++)if(t<=(i+=this._weights[r])){this._currentIndex=r;break}}var n=this._sounds[this._currentIndex];n.isReady()?n.play(0,this.isPaused?void 0:e):n.autoplay=!0,this.isPlaying=!0,this.isPaused=!1},e})(),Pi.WeightedSound=Si,(function(c){c.AbstractScene.AddParser(c.SceneComponentConstants.NAME_AUDIO,(function(e,t,i,r){var n,o=[];if(i.sounds=i.sounds||[],void 0!==e.sounds&&null!==e.sounds)for(var s=0,a=e.sounds.length;s<a;s++){var l=e.sounds[s];c.Engine.audioEngine.canUseWebAudio?(l.url||(l.url=l.name),o[l.url]?i.sounds.push(c.Sound.Parse(l,t,r,o[l.url])):(n=c.Sound.Parse(l,t,r),o[l.url]=n,i.sounds.push(n))):i.sounds.push(new c.Sound(l.name,null,t))}o=[]})),Object.defineProperty(c.Scene.prototype,"mainSoundTrack",{get:function(){var e=this._getComponent(c.SceneComponentConstants.NAME_AUDIO);return e||(e=new i(this),this._addComponent(e)),this._mainSoundTrack||(this._mainSoundTrack=new c.SoundTrack(this,{mainTrack:!0})),this._mainSoundTrack},enumerable:!0,configurable:!0}),c.Scene.prototype.getSoundByName=function(e){var t;for(t=0;t<this.mainSoundTrack.soundCollection.length;t++)if(this.mainSoundTrack.soundCollection[t].name===e)return this.mainSoundTrack.soundCollection[t];if(this.soundTracks)for(var i=0;i<this.soundTracks.length;i++)for(t=0;t<this.soundTracks[i].soundCollection.length;t++)if(this.soundTracks[i].soundCollection[t].name===e)return this.soundTracks[i].soundCollection[t];return null},Object.defineProperty(c.Scene.prototype,"audioEnabled",{get:function(){var e=this._getComponent(c.SceneComponentConstants.NAME_AUDIO);return e||(e=new i(this),this._addComponent(e)),e.audioEnabled},set:function(e){var t=this._getComponent(c.SceneComponentConstants.NAME_AUDIO);t||(t=new i(this),this._addComponent(t)),e?t.enableAudio():t.disableAudio()},enumerable:!0,configurable:!0}),Object.defineProperty(c.Scene.prototype,"headphone",{get:function(){var e=this._getComponent(c.SceneComponentConstants.NAME_AUDIO);return e||(e=new i(this),this._addComponent(e)),e.headphone},set:function(e){var t=this._getComponent(c.SceneComponentConstants.NAME_AUDIO);t||(t=new i(this),this._addComponent(t)),e?t.switchAudioModeForHeadphones():t.switchAudioModeForNormalSpeakers()},enumerable:!0,configurable:!0});var i=(function(){function e(e){this.name=c.SceneComponentConstants.NAME_AUDIO,this._audioEnabled=!0,this._headphone=!1,(this.scene=e).soundTracks=new Array,e.sounds=new Array}return Object.defineProperty(e.prototype,"audioEnabled",{get:function(){return this._audioEnabled},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"headphone",{get:function(){return this._headphone},enumerable:!0,configurable:!0}),e.prototype.register=function(){this.scene._afterRenderStage.registerStep(c.SceneComponentConstants.STEP_AFTERRENDER_AUDIO,this,this._afterRender)},e.prototype.rebuild=function(){},e.prototype.serialize=function(e){if(e.sounds=[],this.scene.soundTracks)for(var t=0;t<this.scene.soundTracks.length;t++)for(var i=this.scene.soundTracks[t],r=0;r<i.soundCollection.length;r++)e.sounds.push(i.soundCollection[r].serialize())},e.prototype.addFromContainer=function(e){var t=this;e.sounds&&e.sounds.forEach((function(e){e.play(),e.autoplay=!0,t.scene.mainSoundTrack.AddSound(e)}))},e.prototype.removeFromContainer=function(e){var t=this;e.sounds&&e.sounds.forEach((function(e){e.stop(),e.autoplay=!1,t.scene.mainSoundTrack.RemoveSound(e)}))},e.prototype.dispose=function(){var e=this.scene;if(e._mainSoundTrack&&e.mainSoundTrack.dispose(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].dispose()},e.prototype.disableAudio=function(){var e,t=this.scene;for(this._audioEnabled=!1,e=0;e<t.mainSoundTrack.soundCollection.length;e++)t.mainSoundTrack.soundCollection[e].pause();if(t.soundTracks)for(e=0;e<t.soundTracks.length;e++)for(var i=0;i<t.soundTracks[e].soundCollection.length;i++)t.soundTracks[e].soundCollection[i].pause()},e.prototype.enableAudio=function(){var e,t=this.scene;for(this._audioEnabled=!0,e=0;e<t.mainSoundTrack.soundCollection.length;e++)t.mainSoundTrack.soundCollection[e].isPaused&&t.mainSoundTrack.soundCollection[e].play();if(t.soundTracks)for(e=0;e<t.soundTracks.length;e++)for(var i=0;i<t.soundTracks[e].soundCollection.length;i++)t.soundTracks[e].soundCollection[i].isPaused&&t.soundTracks[e].soundCollection[i].play()},e.prototype.switchAudioModeForHeadphones=function(){var e=this.scene;if(this._headphone=!0,e.mainSoundTrack.switchPanningModelToHRTF(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].switchPanningModelToHRTF()},e.prototype.switchAudioModeForNormalSpeakers=function(){var e=this.scene;if(this._headphone=!1,e.mainSoundTrack.switchPanningModelToEqualPower(),e.soundTracks)for(var t=0;t<e.soundTracks.length;t++)e.soundTracks[t].switchPanningModelToEqualPower()},e.prototype._afterRender=function(){var e=this.scene;if(this._audioEnabled&&e._mainSoundTrack&&e.soundTracks&&(0!==e._mainSoundTrack.soundCollection.length||1!==e.soundTracks.length)){var t,i=c.Engine.audioEngine;if((t=0<e.activeCameras.length?e.activeCameras[0]:e.activeCamera)&&i.audioContext){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&0<t.rigCameras.length&&(t=t.rigCameras[0]);var r,n=c.Matrix.Invert(t.getViewMatrix()),o=c.Vector3.TransformNormal(new c.Vector3(0,0,-1),n);for(o.normalize(),isNaN(o.x)||isNaN(o.y)||isNaN(o.z)||i.audioContext.listener.setOrientation(o.x,o.y,o.z,0,1,0),r=0;r<e.mainSoundTrack.soundCollection.length;r++){var s=e.mainSoundTrack.soundCollection[r];s.useCustomAttenuation&&s.updateDistanceFromListener()}if(e.soundTracks)for(r=0;r<e.soundTracks.length;r++)for(var a=0;a<e.soundTracks[r].soundCollection.length;a++)(s=e.soundTracks[r].soundCollection[a]).useCustomAttenuation&&s.updateDistanceFromListener()}}},e})();c.AudioSceneComponent=i})($a||($a={})),(function(e){var t=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r._sound=t,r}return T(e,n),e.prototype._prepare=function(){},e.prototype.execute=function(){void 0!==this._sound&&this._sound.play()},e.prototype.serialize=function(e){return n.prototype._serialize.call(this,{name:"PlaySoundAction",properties:[{name:"sound",value:this._sound.name}]},e)},e})(e.Action);e.PlaySoundAction=t;var i=(function(n){function e(e,t,i){var r=n.call(this,e,i)||this;return r._sound=t,r}return T(e,n),e.prototype._prepare=function(){},e.prototype.execute=function(){void 0!==this._sound&&this._sound.stop()},e.prototype.serialize=function(e){return n.prototype._serialize.call(this,{name:"StopSoundAction",properties:[{name:"sound",value:this._sound.name}]},e)},e})(e.Action);e.StopSoundAction=i})($a||($a={})),Ri=$a||($a={}),Mi=(function(y){function s(e,t,i,r,n,o,s,a,l,c,h,u,d){void 0===i&&(i=null),void 0===r&&(r=!1),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=Ri.Engine.TEXTUREFORMAT_RGBA),void 0===l&&(l=!1),void 0===c&&(c=null),void 0===h&&(h=!1),void 0===u&&(u=.8),void 0===d&&(d=0);var f=y.call(this,t)||this;if(f.boundingBoxPosition=Ri.Vector3.Zero(),f._rotationY=0,f._prefiltered=!1,f.name=e,f.url=e,f._noMipmap=r,f.hasAlpha=!1,f._format=a,f.isCube=!0,f._textureMatrix=Ri.Matrix.Identity(),f._createPolynomials=h,f.coordinatesMode=Ri.Texture.CUBIC_MODE,!e&&!n)return f;var p=e.lastIndexOf("."),m=c||(-1<p?e.substring(p).toLowerCase():""),_=".dds"===m,g=".env"===m;if(g?(f.gammaSpace=!1,f._prefiltered=!1):(f._prefiltered=l)&&(f.gammaSpace=!1),f._texture=f._getFromCache(e,r),!n&&(g||_||i||(i=["_px.jpg","_py.jpg","_pz.jpg","_nx.jpg","_ny.jpg","_nz.jpg"]),n=[],i))for(var v=0;v<i.length;v++)n.push(e+i[v]);return f._files=n,f._texture?o&&(f._texture.isReady?Ri.Tools.SetImmediate((function(){return o()})):f._texture.onLoadedObservable.add(o)):t.useDelayedTextureLoading?f.delayLoadState=Ri.Engine.DELAYLOADSTATE_NOTLOADED:f._texture=l?t.getEngine().createPrefilteredCubeTexture(e,t,u,d,o,s,a,c,f._createPolynomials):t.getEngine().createCubeTexture(e,t,n,r,o,s,f._format,c,!1,u,d),f}return T(s,y),Object.defineProperty(s.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var t=this.getScene();t&&t.markAllMaterialsAsDirty(Ri.Material.TextureDirtyFlag)}},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(Ri.Matrix.RotationY(this._rotationY))},enumerable:!0,configurable:!0}),s.CreateFromImages=function(e,t,i){var r="";return e.forEach((function(e){return r+=e})),new s(r,t,null,i,e)},s.CreateFromPrefilteredData=function(e,t,i,r){return void 0===i&&(i=null),void 0===r&&(r=!0),new s(e,t,null,!1,null,null,null,void 0,!0,i,r)},s.prototype.delayLoad=function(){if(this.delayLoadState===Ri.Engine.DELAYLOADSTATE_NOTLOADED){var e=this.getScene();e&&(this.delayLoadState=Ri.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||(this._prefiltered?this._texture=e.getEngine().createPrefilteredCubeTexture(this.url,e,this.lodGenerationScale,this.lodGenerationOffset,void 0,void 0,this._format,void 0,this._createPolynomials):this._texture=e.getEngine().createCubeTexture(this.url,e,this._files,this._noMipmap,void 0,void 0,this._format)))}},s.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},s.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},s.Parse=function(t,i,r){var e=Ri.SerializationHelper.Parse((function(){var e=!1;return t.prefiltered&&(e=t.prefiltered),new s(r+t.name,i,t.extensions,!1,null,null,null,void 0,e)}),t,i);if(t.boundingBoxPosition&&(e.boundingBoxPosition=Ri.Vector3.FromArray(t.boundingBoxPosition)),t.boundingBoxSize&&(e.boundingBoxSize=Ri.Vector3.FromArray(t.boundingBoxSize)),t.animations)for(var n=0;n<t.animations.length;n++){var o=t.animations[n];e.animations.push(Ri.Animation.Parse(o))}return e},s.prototype.clone=function(){var t=this;return Ri.SerializationHelper.Clone((function(){var e=t.getScene();return e?new s(t.url,e,t._extensions,t._noMipmap,t._files):t}),this)},b([Ri.serialize("rotationY")],s.prototype,"rotationY",null),s})(Ri.BaseTexture),Ri.CubeTexture=Mi,Ci=$a||($a={}),Oi=(function(h){function n(e,t,i,r,n,o,s,a,l){void 0===r&&(r=Ci.Engine.TEXTUREFORMAT_RGBA),void 0===n&&(n=Ci.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=Ci.Texture.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null);var c=h.call(this,"",e)||this;return c._texture=e.getEngine().createRawCubeTexture(t,i,r,n,o,s,a,l),c}return T(n,h),n.prototype.update=function(e,t,i,r,n,o){void 0===n&&(n=null),void 0===o&&(o=0),this._texture.getEngine().updateRawCubeTexture(this._texture,e,t,i,r,n)},n.prototype.updateRGBDAsync=function(e,t,i,r){return void 0===t&&(t=null),void 0===i&&(i=.8),void 0===r&&(r=0),n._UpdateRGBDAsync(this._texture,e,t,i,r)},n.prototype.clone=function(){var r=this;return Ci.SerializationHelper.Clone((function(){var e=r.getScene(),t=r._texture,i=new n(e,t._bufferViewArray,t.width,t.format,t.type,t.generateMipMaps,t.invertY,t.samplingMode,t._compression);return t.dataSource===Ci.InternalTexture.DATASOURCE_CUBERAW_RGBD&&i.updateRGBDAsync(t._bufferViewArrayArray,t._sphericalPolynomial,t._lodGenerationScale,t._lodGenerationOffset),i}),this)},n._UpdateRGBDAsync=function(e,t,i,r,n){return e._dataSource=Ci.InternalTexture.DATASOURCE_CUBERAW_RGBD,e._bufferViewArrayArray=t,e._lodGenerationScale=r,e._lodGenerationOffset=n,e._sphericalPolynomial=i,Ci.EnvironmentTextureTools.UploadLevelsAsync(e,t).then((function(){e.isReady=!0}))},n})(Ci.CubeTexture),Ci.RawCubeTexture=Oi,Di=$a||($a={}),Ii=(function(f){function i(e,t,i,r,n,o,s,a,l,c,h,u){void 0===n&&(n=!0),void 0===o&&(o=Di.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===s&&(s=!1),void 0===a&&(a=Di.Texture.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=!0),void 0===c&&(c=!1),void 0===h&&(h=!1),void 0===u&&(u=Di.Engine.TEXTUREFORMAT_RGBA);var d=f.call(this,null,i,!r)||this;return d.isCube=s,d.renderParticles=!0,d.renderSprites=!1,d.coordinatesMode=Di.Texture.PROJECTION_MODE,d.ignoreCameraViewport=!1,d.onBeforeBindObservable=new Di.Observable,d.onAfterUnbindObservable=new Di.Observable,d.onBeforeRenderObservable=new Di.Observable,d.onAfterRenderObservable=new Di.Observable,d.onClearObservable=new Di.Observable,d._currentRefreshId=-1,d._refreshRate=1,d._samples=1,d.boundingBoxPosition=Di.Vector3.Zero(),(i=d.getScene())?(d.renderList=new Array,d._engine=i.getEngine(),d.name=e,d.isRenderTarget=!0,d._initialSizeParameter=t,d._processSizeParameter(t),d._resizeObserver=d.getScene().getEngine().onResizeObservable.add((function(){})),d._generateMipMaps=!!r,d._doNotChangeAspectRatio=n,d._renderingManager=new Di.RenderingManager(i),d._renderingManager._useSceneAutoClearSetup=!0,h||(d._renderTargetOptions={generateMipMaps:r,type:o,format:u,samplingMode:a,generateDepthBuffer:l,generateStencilBuffer:c},a===Di.Texture.NEAREST_SAMPLINGMODE&&(d.wrapU=Di.Texture.CLAMP_ADDRESSMODE,d.wrapV=Di.Texture.CLAMP_ADDRESSMODE),s?(d._texture=i.getEngine().createRenderTargetCubeTexture(d.getRenderSize(),d._renderTargetOptions),d.coordinatesMode=Di.Texture.INVCUBIC_MODE,d._textureMatrix=Di.Matrix.Identity()):d._texture=i.getEngine().createRenderTargetTexture(d._size,d._renderTargetOptions)),d):d}return T(i,f),Object.defineProperty(i.prototype,"renderList",{get:function(){return this._renderList},set:function(e){this._renderList=e,this._renderList&&this._hookArray(this._renderList)},enumerable:!0,configurable:!0}),i.prototype._hookArray=function(n){var o=this,s=n.push;n.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=0===n.length,r=s.apply(n,e);return i&&o.getScene().meshes.forEach((function(e){e._markSubMeshesAsLightDirty()})),r};var r=n.splice;n.splice=function(e,t){var i=r.apply(n,[e,t]);return 0===n.length&&o.getScene().meshes.forEach((function(e){e._markSubMeshesAsLightDirty()})),i}},Object.defineProperty(i.prototype,"onAfterUnbind",{set:function(e){this._onAfterUnbindObserver&&this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver),this._onAfterUnbindObserver=this.onAfterUnbindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onClear",{set:function(e){this._onClearObserver&&this.onClearObservable.remove(this._onClearObserver),this._onClearObserver=this.onClearObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"renderTargetOptions",{get:function(){return this._renderTargetOptions},enumerable:!0,configurable:!0}),i.prototype._onRatioRescale=function(){this._sizeRatio&&this.resize(this._initialSizeParameter)},Object.defineProperty(i.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var t=this.getScene();t&&t.markAllMaterialsAsDirty(Di.Material.TextureDirtyFlag)}},enumerable:!0,configurable:!0}),i.prototype.createDepthStencilTexture=function(e,t,i){if(void 0===e&&(e=0),void 0===t&&(t=!0),void 0===i&&(i=!1),this.getScene()){var r=this.getScene().getEngine();this.depthStencilTexture=r.createDepthStencilTexture(this._size,{bilinearFiltering:t,comparisonFunction:e,generateStencil:i,isCube:this.isCube}),r.setFrameBufferDepthStencilTexture(this)}},i.prototype._processSizeParameter=function(e){e.ratio?(this._sizeRatio=e.ratio,this._size={width:this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(),this._sizeRatio),height:this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(),this._sizeRatio)}):this._size=e},Object.defineProperty(i.prototype,"samples",{get:function(){return this._samples},set:function(e){if(this._samples!==e){var t=this.getScene();t&&(this._samples=t.getEngine().updateRenderTargetTextureSampleCount(this._texture,e))}},enumerable:!0,configurable:!0}),i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype.addPostProcess=function(e){if(!this._postProcessManager){var t=this.getScene();if(!t)return;this._postProcessManager=new Di.PostProcessManager(t),this._postProcesses=new Array}this._postProcesses.push(e),this._postProcesses[0].autoClear=!1},i.prototype.clearPostProcesses=function(e){if(void 0===e&&(e=!1),this._postProcesses){if(e)for(var t=0,i=this._postProcesses;t<i.length;t++){i[t].dispose()}this._postProcesses=[]}},i.prototype.removePostProcess=function(e){if(this._postProcesses){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses.splice(t,1),0<this._postProcesses.length&&(this._postProcesses[0].autoClear=!1))}},i.prototype._shouldRender=function(){return-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)},i.prototype.getRenderSize=function(){return this.getRenderWidth()},i.prototype.getRenderWidth=function(){return this._size.width?this._size.width:this._size},i.prototype.getRenderHeight=function(){return this._size.width?this._size.height:this._size},Object.defineProperty(i.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),i.prototype.scale=function(e){var t=this.getRenderSize()*e;this.resize(t)},i.prototype.getReflectionTextureMatrix=function(){return this.isCube?this._textureMatrix:f.prototype.getReflectionTextureMatrix.call(this)},i.prototype.resize=function(e){this.releaseInternalTexture();var t=this.getScene();t&&(this._processSizeParameter(e),this.isCube?this._texture=t.getEngine().createRenderTargetCubeTexture(this.getRenderSize(),this._renderTargetOptions):this._texture=t.getEngine().createRenderTargetTexture(this._size,this._renderTargetOptions))},i.prototype.render=function(e,t){if(void 0===e&&(e=!1),void 0===t&&(t=!1),a=this.getScene()){var i,r=a.getEngine();if(void 0!==this.useCameraPostProcesses&&(e=this.useCameraPostProcesses),this._waitingRenderList){this.renderList=[];for(var n=0;n<this._waitingRenderList.length;n++){var o=this._waitingRenderList[n],s=a.getMeshByID(o);s&&this.renderList.push(s)}delete this._waitingRenderList}if(this.renderListPredicate){var a;if(this.renderList?this.renderList.splice(0):this.renderList=[],!(a=this.getScene()))return;var l=a.meshes;for(n=0;n<l.length;n++){var c=l[n];this.renderListPredicate(c)&&this.renderList.push(c)}}this.onBeforeBindObservable.notifyObservers(this),this.activeCamera?(i=this.activeCamera,r.setViewport(this.activeCamera.viewport,this.getRenderWidth(),this.getRenderHeight()),this.activeCamera!==a.activeCamera&&a.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(!0))):(i=a.activeCamera)&&r.setViewport(i.viewport,this.getRenderWidth(),this.getRenderHeight()),this._renderingManager.reset();for(var h=this.renderList?this.renderList:a.getActiveMeshes().data,u=this.renderList?this.renderList.length:a.getActiveMeshes().length,d=a.getRenderId(),f=0;f<u;f++){if(c=h[f]){if(!c.isReady(0===this.refreshRate)){this.resetRefreshCounter();continue}c._preActivateForIntermediateRendering(d);var p=void 0;if(p=!(this.renderList||!i)&&0==(c.layerMask&i.layerMask),c.isEnabled()&&c.isVisible&&c.subMeshes&&!p){c._activate(d);for(var m=0;m<c.subMeshes.length;m++){var _=c.subMeshes[m];a._activeIndices.addCount(_.indexCount,!1),this._renderingManager.dispatch(_,c)}}}}for(var g=0;g<a.particleSystems.length;g++){var v=a.particleSystems[g],y=v.emitter;v.isStarted()&&y&&y.position&&y.isEnabled()&&(0<=h.indexOf(y)&&this._renderingManager.dispatchParticles(v))}if(this.isCube)for(var b=0;b<6;b++)this.renderToTarget(b,h,u,e,t),a.incrementRenderId(),a.resetCachedMaterial();else this.renderToTarget(0,h,u,e,t);this.onAfterUnbindObservable.notifyObservers(this),a.activeCamera&&(this.activeCamera&&this.activeCamera!==a.activeCamera&&a.setTransformMatrix(a.activeCamera.getViewMatrix(),a.activeCamera.getProjectionMatrix(!0)),r.setViewport(a.activeCamera.viewport)),a.resetCachedMaterial()}},i.prototype._bestReflectionRenderTargetDimension=function(e,t){var i=e*t,r=Di.Tools.NearestPOT(i+16384/(128+i));return Math.min(Di.Tools.FloorPOT(e),r)},i.prototype.unbindFrameBuffer=function(e,t){var i=this;this._texture&&e.unBindFramebuffer(this._texture,this.isCube,(function(){i.onAfterRenderObservable.notifyObservers(t)}))},i.prototype.renderToTarget=function(e,t,i,r,n){var o=this.getScene();if(o){var s=o.getEngine();this._texture&&(this._postProcessManager?this._postProcessManager._prepareFrame(this._texture,this._postProcesses):r&&o.postProcessManager._prepareFrame(this._texture)||this._texture&&s.bindFramebuffer(this._texture,this.isCube?e:void 0,void 0,void 0,this.ignoreCameraViewport,this.depthStencilTexture?this.depthStencilTexture:void 0),this.onBeforeRenderObservable.notifyObservers(e),this.onClearObservable.hasObservers()?this.onClearObservable.notifyObservers(s):s.clear(this.clearColor||o.clearColor,!0,!0,!0),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0),this._renderingManager.render(this.customRenderFunction,t,this.renderParticles,this.renderSprites),this._postProcessManager?this._postProcessManager._finalizeFrame(!1,this._texture,e,this._postProcesses,this.ignoreCameraViewport):r&&o.postProcessManager._finalizeFrame(!1,this._texture,e),this._doNotChangeAspectRatio||o.updateTransformMatrix(!0),n&&Di.Tools.DumpFramebuffer(this.getRenderWidth(),this.getRenderHeight(),s),this.isCube&&5!==e?this.onAfterRenderObservable.notifyObservers(e):(this.isCube&&5===e&&s.generateMipMapsForCubemap(this._texture),this.unbindFrameBuffer(s,e)))}},i.prototype.setRenderingOrder=function(e,t,i,r){void 0===t&&(t=null),void 0===i&&(i=null),void 0===r&&(r=null),this._renderingManager.setRenderingOrder(e,t,i,r)},i.prototype.setRenderingAutoClearDepthStencil=function(e,t){this._renderingManager.setRenderingAutoClearDepthStencil(e,t),this._renderingManager._useSceneAutoClearSetup=!1},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e,this.getScene(),this._renderTargetOptions.generateMipMaps,this._doNotChangeAspectRatio,this._renderTargetOptions.type,this.isCube,this._renderTargetOptions.samplingMode,this._renderTargetOptions.generateDepthBuffer,this._renderTargetOptions.generateStencilBuffer);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,this.renderList&&(t.renderList=this.renderList.slice(0)),t},i.prototype.serialize=function(){if(!this.name)return null;var e=f.prototype.serialize.call(this);if(e.renderTargetSize=this.getRenderSize(),e.renderList=[],this.renderList)for(var t=0;t<this.renderList.length;t++)e.renderList.push(this.renderList[t].id);return e},i.prototype.disposeFramebufferObjects=function(){var e=this.getInternalTexture(),t=this.getScene();e&&t&&t.getEngine()._releaseFramebufferObjects(e)},i.prototype.dispose=function(){this._postProcessManager&&(this._postProcessManager.dispose(),this._postProcessManager=null),this.clearPostProcesses(!0),this._resizeObserver&&(this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this.renderList=null;var e=this.getScene();if(e){var t=e.customRenderTargets.indexOf(this);0<=t&&e.customRenderTargets.splice(t,1);for(var i=0,r=e.cameras;i<r.length;i++){var n=r[i];0<=(t=n.customRenderTargets.indexOf(this))&&n.customRenderTargets.splice(t,1)}f.prototype.dispose.call(this)}},i.prototype._rebuild=function(){this.refreshRate===i.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=i.REFRESHRATE_RENDER_ONCE),this._postProcessManager&&this._postProcessManager._rebuild()},i.prototype.freeRenderingGroups=function(){this._renderingManager&&this._renderingManager.freeRenderingGroups()},i.REFRESHRATE_RENDER_ONCE=0,i.REFRESHRATE_RENDER_ONEVERYFRAME=1,i.REFRESHRATE_RENDER_ONEVERYTWOFRAMES=2,i})(Di.Texture),Di.RenderTargetTexture=Ii,wi=$a||($a={}),Li=(function(p){function e(e,t,i,r,n){var o=this,s=!(!n||!n.generateMipMaps)&&n.generateMipMaps,a=!(!n||!n.generateDepthTexture)&&n.generateDepthTexture,l=!n||void 0===n.doNotChangeAspectRatio||n.doNotChangeAspectRatio;if((o=p.call(this,e,t,r,s,l)||this)._engine=r.getEngine(),o.isSupported){for(var c=[],h=[],u=0;u<i;u++)n&&n.types&&void 0!==n.types[u]?c.push(n.types[u]):c.push(n&&n.defaultType?n.defaultType:wi.Engine.TEXTURETYPE_UNSIGNED_INT),n&&n.samplingModes&&void 0!==n.samplingModes[u]?h.push(n.samplingModes[u]):h.push(wi.Texture.BILINEAR_SAMPLINGMODE);var d=!n||void 0===n.generateDepthBuffer||n.generateDepthBuffer,f=!(!n||void 0===n.generateStencilBuffer)&&n.generateStencilBuffer;return o._size=t,o._multiRenderTargetOptions={samplingModes:h,generateMipMaps:s,generateDepthBuffer:d,generateStencilBuffer:f,generateDepthTexture:a,types:c,textureCount:i},o._createInternalTextures(),o._createTextures(),o}o.dispose()}return T(e,p),Object.defineProperty(e.prototype,"isSupported",{get:function(){return 1<this._engine.webGLVersion||this._engine.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textures",{get:function(){return this._textures},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthTexture",{get:function(){return this._textures[this._textures.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wrapU",{set:function(e){if(this._textures)for(var t=0;t<this._textures.length;t++)this._textures[t].wrapU=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"wrapV",{set:function(e){if(this._textures)for(var t=0;t<this._textures.length;t++)this._textures[t].wrapV=e},enumerable:!0,configurable:!0}),e.prototype._rebuild=function(){this.releaseInternalTextures(),this._createInternalTextures();for(var e=0;e<this._internalTextures.length;e++){this._textures[e]._texture=this._internalTextures[e]}this._texture=this._internalTextures[0]},e.prototype._createInternalTextures=function(){this._internalTextures=this._engine.createMultipleRenderTarget(this._size,this._multiRenderTargetOptions)},e.prototype._createTextures=function(){this._textures=[];for(var e=0;e<this._internalTextures.length;e++){var t=new wi.Texture(null,this.getScene());t._texture=this._internalTextures[e],this._textures.push(t)}this._texture=this._internalTextures[0]},Object.defineProperty(e.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures,e))},enumerable:!0,configurable:!0}),e.prototype.resize=function(e){this.releaseInternalTextures(),this._internalTextures=this._engine.createMultipleRenderTarget(e,this._multiRenderTargetOptions),this._createInternalTextures()},e.prototype.unbindFrameBuffer=function(e,t){var i=this;e.unBindMultiColorAttachmentFramebuffer(this._internalTextures,this.isCube,(function(){i.onAfterRenderObservable.notifyObservers(t)}))},e.prototype.dispose=function(){this.releaseInternalTextures(),p.prototype.dispose.call(this)},e.prototype.releaseInternalTextures=function(){if(this._internalTextures)for(var e=this._internalTextures.length-1;0<=e;e--)void 0!==this._internalTextures[e]&&(this._internalTextures[e].dispose(),this._internalTextures.splice(e,1))},e})(wi.RenderTargetTexture),wi.MultiRenderTarget=Li,Fi=$a||($a={}),Bi=(function(l){function r(e,t,i,r,n,o,s){void 0===n&&(n=Fi.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===o&&(o=Fi.Texture.BILINEAR_SAMPLINGMODE),void 0===s&&(s=!0);var a=l.call(this,e,t,i,r,!0,n,!1,o,s)||this;return a.scene=i,a.mirrorPlane=new Fi.Plane(0,1,0,1),a._transformMatrix=Fi.Matrix.Zero(),a._mirrorMatrix=Fi.Matrix.Zero(),a._adaptiveBlurKernel=0,a._blurKernelX=0,a._blurKernelY=0,a._blurRatio=1,a.ignoreCameraViewport=!0,a._updateGammaSpace(),a._imageProcessingConfigChangeObserver=i.imageProcessingConfiguration.onUpdateParameters.add((function(){a._updateGammaSpace})),a.onBeforeRenderObservable.add((function(){Fi.Matrix.ReflectionToRef(a.mirrorPlane,a._mirrorMatrix),a._savedViewMatrix=i.getViewMatrix(),a._mirrorMatrix.multiplyToRef(a._savedViewMatrix,a._transformMatrix),i.setTransformMatrix(a._transformMatrix,i.getProjectionMatrix()),i.clipPlane=a.mirrorPlane,i.getEngine().cullBackFaces=!1,i._mirroredCameraPosition=Fi.Vector3.TransformCoordinates(i.activeCamera.globalPosition,a._mirrorMatrix)})),a.onAfterRenderObservable.add((function(){i.setTransformMatrix(a._savedViewMatrix,i.getProjectionMatrix()),i.getEngine().cullBackFaces=!0,i._mirroredCameraPosition=null,delete i.clipPlane})),a}return T(r,l),Object.defineProperty(r.prototype,"blurRatio",{get:function(){return this._blurRatio},set:function(e){this._blurRatio!==e&&(this._blurRatio=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"adaptiveBlurKernel",{set:function(e){this._adaptiveBlurKernel=e,this._autoComputeBlurKernel()},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernel",{set:function(e){this.blurKernelX=e,this.blurKernelY=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelX",{get:function(){return this._blurKernelX},set:function(e){this._blurKernelX!==e&&(this._blurKernelX=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"blurKernelY",{get:function(){return this._blurKernelY},set:function(e){this._blurKernelY!==e&&(this._blurKernelY=e,this._preparePostProcesses())},enumerable:!0,configurable:!0}),r.prototype._autoComputeBlurKernel=function(){var e=this.getScene().getEngine(),t=this.getRenderWidth()/e.getRenderWidth(),i=this.getRenderHeight()/e.getRenderHeight();this.blurKernelX=this._adaptiveBlurKernel*t,this.blurKernelY=this._adaptiveBlurKernel*i},r.prototype._onRatioRescale=function(){this._sizeRatio&&(this.resize(this._initialSizeParameter),this._adaptiveBlurKernel||this._preparePostProcesses()),this._adaptiveBlurKernel&&this._autoComputeBlurKernel()},r.prototype._updateGammaSpace=function(){this.gammaSpace=!this.scene.imageProcessingConfiguration.isEnabled||!this.scene.imageProcessingConfiguration.applyByPostProcess},r.prototype._preparePostProcesses=function(){if(this.clearPostProcesses(!0),this._blurKernelX&&this._blurKernelY){var e=this.getScene().getEngine(),t=e.getCaps().textureFloatRender?Fi.Engine.TEXTURETYPE_FLOAT:Fi.Engine.TEXTURETYPE_HALF_FLOAT;this._blurX=new Fi.BlurPostProcess("horizontal blur",new Fi.Vector2(1,0),this._blurKernelX,this._blurRatio,null,Fi.Texture.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 Fi.BlurPostProcess("vertical blur",new Fi.Vector2(0,1),this._blurKernelY,this._blurRatio,null,Fi.Texture.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)},r.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),i=new r(this.name,t.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},r.prototype.serialize=function(){if(!this.name)return null;var e=l.prototype.serialize.call(this);return e.mirrorPlane=this.mirrorPlane.asArray(),e},r.prototype.dispose=function(){l.prototype.dispose.call(this),this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver)},r})(Fi.RenderTargetTexture),Fi.MirrorTexture=Bi,Ni=$a||($a={}),Vi=(function(o){function r(e,t,i,r){var n=o.call(this,e,t,i,r,!0)||this;return n.refractionPlane=new Ni.Plane(0,1,0,1),n.depth=2,n.onBeforeRenderObservable.add((function(){i.clipPlane=n.refractionPlane})),n.onAfterRenderObservable.add((function(){delete i.clipPlane})),n}return T(r,o),r.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),i=new r(this.name,t.width,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.refractionPlane=this.refractionPlane.clone(),this.renderList&&(i.renderList=this.renderList.slice(0)),i.depth=this.depth,i},r.prototype.serialize=function(){if(!this.name)return null;var e=o.prototype.serialize.call(this);return e.mirrorPlane=this.refractionPlane.asArray(),e.depth=this.depth,e},r})(Ni.RenderTargetTexture),Ni.RefractionTexture=Vi,Ui=$a||($a={}),zi=(function(l){function r(e,t,i,r,n,o){void 0===i&&(i=null),void 0===n&&(n=Ui.Texture.TRILINEAR_SAMPLINGMODE),void 0===o&&(o=Ui.Engine.TEXTUREFORMAT_RGBA);var s=l.call(this,null,i,!r,void 0,n,void 0,void 0,void 0,void 0,o)||this;s.name=e,s._engine=s.getScene().getEngine(),s.wrapU=Ui.Texture.CLAMP_ADDRESSMODE,s.wrapV=Ui.Texture.CLAMP_ADDRESSMODE,s._generateMipMaps=r,t.getContext?(s._canvas=t,s._texture=s._engine.createDynamicTexture(t.width,t.height,r,n)):(s._canvas=document.createElement("canvas"),t.width||0===t.width?s._texture=s._engine.createDynamicTexture(t.width,t.height,r,n):s._texture=s._engine.createDynamicTexture(t,t,r,n));var a=s.getSize();return s._canvas.width=a.width,s._canvas.height=a.height,s._context=s._canvas.getContext("2d"),s}return T(r,l),Object.defineProperty(r.prototype,"canRescale",{get:function(){return!0},enumerable:!0,configurable:!0}),r.prototype._recreate=function(e){this._canvas.width=e.width,this._canvas.height=e.height,this.releaseInternalTexture(),this._texture=this._engine.createDynamicTexture(e.width,e.height,this._generateMipMaps,this._samplingMode)},r.prototype.scale=function(e){var t=this.getSize();t.width*=e,t.height*=e,this._recreate(t)},r.prototype.scaleTo=function(e,t){var i=this.getSize();i.width=e,i.height=t,this._recreate(i)},r.prototype.getContext=function(){return this._context},r.prototype.clear=function(){var e=this.getSize();this._context.fillRect(0,0,e.width,e.height)},r.prototype.update=function(e,t){void 0===t&&(t=!1),this._engine.updateDynamicTexture(this._texture,this._canvas,void 0===e||e,t,this._format||void 0)},r.prototype.drawText=function(e,t,i,r,n,o,s,a){void 0===a&&(a=!0);var l=this.getSize();if(o&&(this._context.fillStyle=o,this._context.fillRect(0,0,l.width,l.height)),this._context.font=r,null==t){var c=this._context.measureText(e);t=(l.width-c.width)/2}if(null==i){var h=parseInt(r.replace(/\D/g,""));i=l.height/2+h/3.65}this._context.fillStyle=n,this._context.fillText(e,t,i),a&&this.update(s)},r.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=this.getSize(),i=new r(this.name,t,e,this._generateMipMaps);return i.hasAlpha=this.hasAlpha,i.level=this.level,i.wrapU=this.wrapU,i.wrapV=this.wrapV,i},r.prototype.serialize=function(){var e=this.getScene();e&&!e.isReady()&&Ui.Tools.Warn("The scene must be ready before serializing the dynamic texture");var t=l.prototype.serialize.call(this);return t.base64String=this._canvas.toDataURL(),t.invertY=this._invertY,t.samplingMode=this.samplingMode,t},r.prototype._rebuild=function(){this.update()},r})(Ui.Texture),Ui.DynamicTexture=zi,Gi=$a||($a={}),ki=(function(l){function o(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!1),void 0===o&&(o=Gi.Texture.TRILINEAR_SAMPLINGMODE),void 0===s&&(s={autoPlay:!0,loop:!0,autoUpdateTexture:!0});var a=l.call(this,null,i,!r,n)||this;return a._onUserActionRequestedObservable=null,a._stillImageCaptured=!1,a._poster=!1,a._createInternalTexture=function(){if(null!=a._texture){if(!a._poster)return;a._texture.dispose(),a._poster=!1}if(!a._engine.needPOTTextures||Gi.Tools.IsExponentOfTwo(a.video.videoWidth)&&Gi.Tools.IsExponentOfTwo(a.video.videoHeight)?(a.wrapU=Gi.Texture.WRAP_ADDRESSMODE,a.wrapV=Gi.Texture.WRAP_ADDRESSMODE):(a.wrapU=Gi.Texture.CLAMP_ADDRESSMODE,a.wrapV=Gi.Texture.CLAMP_ADDRESSMODE,a._generateMipMaps=!1),a._texture=a._engine.createDynamicTexture(a.video.videoWidth,a.video.videoHeight,a._generateMipMaps,a._samplingMode),a.video.autoplay)a._texture.isReady=!0,a._updateInternalTexture(),a.onLoadObservable.hasObservers()&&a.onLoadObservable.notifyObservers(a);else{var e=a.video.onplaying,t=!1;a.video.onplaying=function(){a.video.onplaying=e,a._texture.isReady=!0,a._updateInternalTexture(),t||a.video.pause(),a.onLoadObservable.hasObservers()&&a.onLoadObservable.notifyObservers(a)};var i=a.video.play();i?i.then((function(){})).catch((function(){t=!0,a._onUserActionRequestedObservable&&a._onUserActionRequestedObservable.hasObservers()&&a._onUserActionRequestedObservable.notifyObservers(a)})):(a.video.onplaying=e,a._texture.isReady=!0,a._updateInternalTexture(),a.onLoadObservable.hasObservers()&&a.onLoadObservable.notifyObservers(a))}},a.reset=function(){null!=a._texture&&(a._poster||(a._texture.dispose(),a._texture=null))},a._updateInternalTexture=function(e){null!=a._texture&&a._texture.isReady&&(a.video.readyState<a.video.HAVE_CURRENT_DATA||a._engine.updateVideoTexture(a._texture,a.video,a._invertY))},a._engine=a.getScene().getEngine(),a._generateMipMaps=r,a._samplingMode=o,a.autoUpdateTexture=s.autoUpdateTexture,a.name=e||a._getName(t),a.video=a._getVideo(t),s.poster&&(a.video.poster=s.poster),void 0!==s.autoPlay&&(a.video.autoplay=s.autoPlay),void 0!==s.loop&&(a.video.loop=s.loop),a.video.setAttribute("playsinline",""),a.video.addEventListener("canplay",a._createInternalTexture),a.video.addEventListener("paused",a._updateInternalTexture),a.video.addEventListener("seeked",a._updateInternalTexture),a.video.addEventListener("emptied",a.reset),a.video.readyState>=a.video.HAVE_CURRENT_DATA&&a._createInternalTexture(),s.poster&&(a._texture=a._engine.createTexture(s.poster,!1,!0,i),a._poster=!0),a}return T(o,l),Object.defineProperty(o.prototype,"onUserActionRequestedObservable",{get:function(){return this._onUserActionRequestedObservable||(this._onUserActionRequestedObservable=new Gi.Observable),this._onUserActionRequestedObservable},enumerable:!0,configurable:!0}),o.prototype._getName=function(e){return e instanceof HTMLVideoElement?e.currentSrc:"object"==typeof e?e.toString():e},o.prototype._getVideo=function(e){if(e instanceof HTMLVideoElement)return Gi.Tools.SetCorsBehavior(e.currentSrc,e),e;var i=document.createElement("video");return"string"==typeof e?(Gi.Tools.SetCorsBehavior(e,i),i.src=e):(Gi.Tools.SetCorsBehavior(e[0],i),e.forEach((function(e){var t=document.createElement("source");t.src=e,i.appendChild(t)}))),i},o.prototype._rebuild=function(){this.update()},o.prototype.update=function(){this.autoUpdateTexture&&this.updateTexture(!0)},o.prototype.updateTexture=function(e){e&&(this.video.paused&&this._stillImageCaptured||(this._stillImageCaptured=!0,this._updateInternalTexture()))},o.prototype.updateURL=function(e){this.video.src=e},o.prototype.dispose=function(){l.prototype.dispose.call(this),this._onUserActionRequestedObservable&&(this._onUserActionRequestedObservable.clear(),this._onUserActionRequestedObservable=null),this.video.removeEventListener("canplay",this._createInternalTexture),this.video.removeEventListener("paused",this._updateInternalTexture),this.video.removeEventListener("seeked",this._updateInternalTexture),this.video.removeEventListener("emptied",this.reset),this.video.pause()},o.CreateFromWebCam=function(i,r,e){var t,n=document.createElement("video");n.setAttribute("autoplay",""),n.setAttribute("muted",""),n.setAttribute("playsinline",""),e&&e.deviceId&&(t={exact:e.deviceId}),window.URL=window.URL||window.webkitURL||window.mozURL||window.msURL,navigator.mediaDevices?navigator.mediaDevices.getUserMedia({video:e}).then((function(e){void 0!==n.mozSrcObject?n.mozSrcObject=e:n.srcObject=e;var t=function(){r&&r(new o("video",n,i,!0,!0)),n.removeEventListener("playing",t)};n.addEventListener("playing",t),n.play()})).catch((function(e){Gi.Tools.Error(e.name)})):(navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({video:{deviceId:t,width:{min:e&&e.minWidth||256,max:e&&e.maxWidth||640},height:{min:e&&e.minHeight||256,max:e&&e.maxHeight||480}}},(function(e){void 0!==n.mozSrcObject?n.mozSrcObject=e:n.src=window.URL&&window.URL.createObjectURL(e)||e,n.play(),r&&r(new o("video",n,i,!0,!0))}),(function(e){Gi.Tools.Error(e.name)})))},o})(Gi.Texture),Gi.VideoTexture=ki,Wi=$a||($a={}),Hi=(function(h){function l(e,t,i,r,n,o,s,a,l){void 0===o&&(o=!0),void 0===s&&(s=!1),void 0===a&&(a=Wi.Texture.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=Wi.Engine.TEXTURETYPE_UNSIGNED_INT);var c=h.call(this,null,n,!o,s)||this;return c.format=r,c._engine=n.getEngine(),c._texture=n.getEngine().createRawTexture(e,t,i,r,o,s,a,null,l),c.wrapU=Wi.Texture.CLAMP_ADDRESSMODE,c.wrapV=Wi.Texture.CLAMP_ADDRESSMODE,c}return T(l,h),l.prototype.update=function(e){this._engine.updateRawTexture(this._texture,e,this._texture.format,this._texture.invertY,void 0,this._texture.type)},l.CreateLuminanceTexture=function(e,t,i,r,n,o,s){return void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=Wi.Texture.TRILINEAR_SAMPLINGMODE),new l(e,t,i,Wi.Engine.TEXTUREFORMAT_LUMINANCE,r,n,o,s)},l.CreateLuminanceAlphaTexture=function(e,t,i,r,n,o,s){return void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=Wi.Texture.TRILINEAR_SAMPLINGMODE),new l(e,t,i,Wi.Engine.TEXTUREFORMAT_LUMINANCE_ALPHA,r,n,o,s)},l.CreateAlphaTexture=function(e,t,i,r,n,o,s){return void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=Wi.Texture.TRILINEAR_SAMPLINGMODE),new l(e,t,i,Wi.Engine.TEXTUREFORMAT_ALPHA,r,n,o,s)},l.CreateRGBTexture=function(e,t,i,r,n,o,s,a){return void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=Wi.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=Wi.Engine.TEXTURETYPE_UNSIGNED_INT),new l(e,t,i,Wi.Engine.TEXTUREFORMAT_RGB,r,n,o,s,a)},l.CreateRGBATexture=function(e,t,i,r,n,o,s,a){return void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=Wi.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=Wi.Engine.TEXTURETYPE_UNSIGNED_INT),new l(e,t,i,Wi.Engine.TEXTUREFORMAT_RGBA,r,n,o,s,a)},l.CreateRTexture=function(e,t,i,r,n,o,s,a){return void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=Wi.Texture.TRILINEAR_SAMPLINGMODE),void 0===a&&(a=Wi.Engine.TEXTURETYPE_FLOAT),new l(e,t,i,Wi.Engine.TEXTUREFORMAT_R,r,n,o,s,a)},l})(Wi.Texture),Wi.RawTexture=Hi,Xi=$a||($a={}),ji=(function(u){function e(e,t,i,r,n,o,s,a,l,c){void 0===s&&(s=!0),void 0===a&&(a=!1),void 0===l&&(l=Xi.Texture.TRILINEAR_SAMPLINGMODE),void 0===c&&(c=Xi.Engine.TEXTURETYPE_UNSIGNED_INT);var h=u.call(this,null,o,!s,a)||this;return h.format=n,h._engine=o.getEngine(),h._texture=o.getEngine().createRawTexture3D(e,t,i,r,n,s,a,l,void 0,c),h.is3D=!0,h}return T(e,u),e.prototype.update=function(e){this._texture&&this._engine.updateRawTexture3D(this._texture,e,this._texture.format,this._texture.invertY,void 0,this._texture.type)},e})(Xi.Texture),Xi.RawTexture3D=ji,Yi=$a||($a={}),Ki=(function(){function e(e){this._vertexBuffers={},this._scene=e}return e.prototype._prepareBuffers=function(){if(!this._vertexBuffers[Yi.VertexBuffer.PositionKind]){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1),this._vertexBuffers[Yi.VertexBuffer.PositionKind]=new Yi.VertexBuffer(this._scene.getEngine(),e,Yi.VertexBuffer.PositionKind,!1,!1,2),this._buildIndexBuffer()}},e.prototype._buildIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},e.prototype._rebuild=function(){var e=this._vertexBuffers[Yi.VertexBuffer.PositionKind];e&&(e._rebuild(),this._buildIndexBuffer())},e.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;return!!i&&(!(!(t=t||i._postProcesses.filter((function(e){return null!=e})))||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!=t),!0))},e.prototype.directRender=function(e,t,i,r,n){void 0===t&&(t=null),void 0===i&&(i=!1),void 0===r&&(r=0),void 0===n&&(n=0);for(var o=this._scene.getEngine(),s=0;s<e.length;s++){s<e.length-1?e[s+1].activate(this._scene.activeCamera,t):t?o.bindFramebuffer(t,r,void 0,void 0,i,void 0,n):o.restoreDefaultFramebuffer();var a=e[s],l=a.apply();l&&(a.onBeforeRenderObservable.notifyObservers(l),this._prepareBuffers(),o.bindBuffers(this._vertexBuffers,this._indexBuffer,l),o.drawElementsType(Yi.Material.TriangleFillMode,0,6),a.onAfterRenderObservable.notifyObservers(l))}o.setDepthBuffer(!0),o.setDepthWrite(!0)},e.prototype._finalizeFrame=function(e,t,i,r,n){void 0===n&&(n=!1);var o=this._scene.activeCamera;if(o&&0!==(r=r||o._postProcesses.filter((function(e){return null!=e}))).length&&this._scene.postProcessesEnabled){for(var s=this._scene.getEngine(),a=0,l=r.length;a<l;a++){var c=r[a];if(a<l-1?c._outputTexture=r[a+1].activate(o,t):t?(s.bindFramebuffer(t,i,void 0,void 0,n),c._outputTexture=t):(s.restoreDefaultFramebuffer(),c._outputTexture=null),e)break;var h=c.apply();h&&(c.onBeforeRenderObservable.notifyObservers(h),this._prepareBuffers(),s.bindBuffers(this._vertexBuffers,this._indexBuffer,h),s.drawElementsType(Yi.Material.TriangleFillMode,0,6),c.onAfterRenderObservable.notifyObservers(h))}s.setDepthBuffer(!0),s.setDepthWrite(!0),s.setAlphaMode(Yi.Engine.ALPHA_DISABLE)}},e.prototype.dispose=function(){var e=this._vertexBuffers[Yi.VertexBuffer.PositionKind];e&&(e.dispose(),this._vertexBuffers[Yi.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},e})(),Yi.PostProcessManager=Ki,Qi=$a||($a={}),Zi=(function(){function e(e,t,i,r,n,o,s,a,l,c,h,u,d,f){void 0===s&&(s=Qi.Texture.NEAREST_SAMPLINGMODE),void 0===c&&(c=null),void 0===h&&(h=Qi.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===u&&(u="postprocess"),void 0===f&&(f=!1),this.name=e,this.width=-1,this.height=-1,this._outputTexture=null,this.autoClear=!0,this.alphaMode=Qi.Engine.ALPHA_DISABLE,this.animations=new Array,this.enablePixelPerfectMode=!1,this.forceFullscreenViewport=!0,this.scaleMode=Qi.Engine.SCALEMODE_FLOOR,this.alwaysForcePOT=!1,this._samples=1,this.adaptScaleToCurrentViewport=!1,this._reusable=!1,this._textures=new Qi.SmartArray(2),this._currentRenderTextureInd=0,this._scaleRatio=new Qi.Vector2(1,1),this._texelSize=Qi.Vector2.Zero(),this.onActivateObservable=new Qi.Observable,this.onSizeChangedObservable=new Qi.Observable,this.onApplyObservable=new Qi.Observable,this.onBeforeRenderObservable=new Qi.Observable,this.onAfterRenderObservable=new Qi.Observable,null!=o?(this._camera=o,this._scene=o.getScene(),o.attachPostProcess(this),this._engine=this._scene.getEngine(),this._scene.postProcesses.push(this)):a&&(this._engine=a,this._engine.postProcesses.push(this)),this._options=n,this.renderTargetSamplingMode=s||Qi.Texture.NEAREST_SAMPLINGMODE,this._reusable=l||!1,this._textureType=h,this._samplers=r||[],this._samplers.push("textureSampler"),this._fragmentUrl=t,this._vertexUrl=u,this._parameters=i||[],this._parameters.push("scale"),this._indexParameters=d,f||this.updateEffect(c)}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}),Object.defineProperty(e.prototype,"onActivate",{set:function(e){this._onActivateObserver&&this.onActivateObservable.remove(this._onActivateObserver),e&&(this._onActivateObserver=this.onActivateObservable.add(e))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onSizeChanged",{set:function(e){this._onSizeChangedObserver&&this.onSizeChangedObservable.remove(this._onSizeChangedObserver),this._onSizeChangedObserver=this.onSizeChangedObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onApply",{set:function(e){this._onApplyObserver&&this.onApplyObservable.remove(this._onApplyObserver),this._onApplyObserver=this.onApplyObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"inputTexture",{get:function(){return this._textures.data[this._currentRenderTextureInd]},set:function(e){this._forcedOutputTexture=e},enumerable:!0,configurable:!0}),e.prototype.getCamera=function(){return this._camera},Object.defineProperty(e.prototype,"texelSize",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.texelSize:(this._forcedOutputTexture&&this._texelSize.copyFromFloats(1/this._forcedOutputTexture.width,1/this._forcedOutputTexture.height),this._texelSize)},enumerable:!0,configurable:!0}),e.prototype.getEngine=function(){return this._engine},e.prototype.getEffect=function(){return this._effect},e.prototype.shareOutputWith=function(e){return this._disposeTextures(),this._shareOutputWithPostProcess=e,this},e.prototype.useOwnOutput=function(){0==this._textures.length&&(this._textures=new Qi.SmartArray(2)),this._shareOutputWithPostProcess=null},e.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._effect=this._engine.createEffect({vertex:this._vertexUrl,fragment:this._fragmentUrl},["position"],t||this._parameters,i||this._samplers,null!==e?e:"",void 0,n,o,r||this._indexParameters)},e.prototype.isReusable=function(){return this._reusable},e.prototype.markTextureDirty=function(){this.width=-1},e.prototype.activate=function(e,t,i){var r=this;void 0===t&&(t=null);var n=(e=e||this._camera).getScene(),o=n.getEngine(),s=o.getCaps().maxTextureSize,a=(t?t.width:this._engine.getRenderWidth(!0))*this._options|0,l=(t?t.height:this._engine.getRenderHeight(!0))*this._options|0,c=e.parent;!c||c.leftCamera!=e&&c.rightCamera!=e||(a/=2);var h,u=this._options.width||a,d=this._options.height||l;if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(this.adaptScaleToCurrentViewport){var f=o.currentViewport;f&&(u*=f.width,d*=f.height)}if((this.renderTargetSamplingMode===Qi.Texture.TRILINEAR_SAMPLINGMODE||this.alwaysForcePOT)&&(this._options.width||(u=o.needPOTTextures?Qi.Tools.GetExponentOfTwo(u,s,this.scaleMode):u),this._options.height||(d=o.needPOTTextures?Qi.Tools.GetExponentOfTwo(d,s,this.scaleMode):d)),this.width!==u||this.height!==d){if(0<this._textures.length){for(var p=0;p<this._textures.length;p++)this._engine._releaseTexture(this._textures.data[p]);this._textures.reset()}this.width=u,this.height=d;var m={width:this.width,height:this.height},_={generateMipMaps:!1,generateDepthBuffer:i||0===e._postProcesses.indexOf(this),generateStencilBuffer:(i||0===e._postProcesses.indexOf(this))&&this._engine.isStencilEnable,samplingMode:this.renderTargetSamplingMode,type:this._textureType};this._textures.push(this._engine.createRenderTargetTexture(m,_)),this._reusable&&this._textures.push(this._engine.createRenderTargetTexture(m,_)),this._texelSize.copyFromFloats(1/this.width,1/this.height),this.onSizeChangedObservable.notifyObservers(this)}this._textures.forEach((function(e){e.samples!==r.samples&&r._engine.updateRenderTargetTextureSampleCount(e,r.samples)}))}return this._shareOutputWithPostProcess?h=this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?(h=this._forcedOutputTexture,this.width=this._forcedOutputTexture.width,this.height=this._forcedOutputTexture.height):h=this.inputTexture,this.enablePixelPerfectMode?(this._scaleRatio.copyFromFloats(a/u,l/d),this._engine.bindFramebuffer(h,0,a,l,this.forceFullscreenViewport)):(this._scaleRatio.copyFromFloats(1,1),this._engine.bindFramebuffer(h,0,void 0,void 0,this.forceFullscreenViewport)),this.onActivateObservable.notifyObservers(e),this.autoClear&&this.alphaMode===Qi.Engine.ALPHA_DISABLE&&this._engine.clear(this.clearColor?this.clearColor:n.clearColor,n._allowPostProcessClearColor,!0,!0),this._reusable&&(this._currentRenderTextureInd=(this._currentRenderTextureInd+1)%2),h},Object.defineProperty(e.prototype,"isSupported",{get:function(){return this._effect.isSupported},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"aspectRatio",{get:function(){return this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.aspectRatio:this._forcedOutputTexture?this._forcedOutputTexture.width/this._forcedOutputTexture.height:this.width/this.height},enumerable:!0,configurable:!0}),e.prototype.isReady=function(){return this._effect&&this._effect.isReady()},e.prototype.apply=function(){return this._effect&&this._effect.isReady()?(this._engine.enableEffect(this._effect),this._engine.setState(!1),this._engine.setDepthBuffer(!1),this._engine.setDepthWrite(!1),this._engine.setAlphaMode(this.alphaMode),this.alphaConstants&&this.getEngine().setAlphaConstants(this.alphaConstants.r,this.alphaConstants.g,this.alphaConstants.b,this.alphaConstants.a),e=this._shareOutputWithPostProcess?this._shareOutputWithPostProcess.inputTexture:this._forcedOutputTexture?this._forcedOutputTexture:this.inputTexture,this._effect._bindTexture("textureSampler",e),this._effect.setVector2("scale",this._scaleRatio),this.onApplyObservable.notifyObservers(this._effect),this._effect):null;var e},e.prototype._disposeTextures=function(){if(!this._shareOutputWithPostProcess&&!this._forcedOutputTexture){if(0<this._textures.length)for(var e=0;e<this._textures.length;e++)this._engine._releaseTexture(this._textures.data[e]);this._textures.dispose()}},e.prototype.dispose=function(e){if(e=e||this._camera,this._disposeTextures(),this._scene){var t=this._scene.postProcesses.indexOf(this);-1!==t&&this._scene.postProcesses.splice(t,1)}else{var i=this._engine.postProcesses.indexOf(this);-1!==i&&this._engine.postProcesses.splice(i,1)}if(e){if(e.detachPostProcess(this),0===e._postProcesses.indexOf(this)&&0<e._postProcesses.length){var r=this._camera._getFirstPostProcess();r&&r.markTextureDirty()}this.onActivateObservable.clear(),this.onAfterRenderObservable.clear(),this.onApplyObservable.clear(),this.onBeforeRenderObservable.clear(),this.onSizeChangedObservable.clear()}},e})(),Qi.PostProcess=Zi,qi=$a||($a={}),Ji=(function(l){function e(e,t,i,r,n,o,s,a){return void 0===i&&(i=null),void 0===s&&(s=qi.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1),l.call(this,e,"pass",null,null,t,i,r,n,o,void 0,s,void 0,null,a)||this}return T(e,l),e})(qi.PostProcess),qi.PassPostProcess=Ji;var $i,er,tr,ir,rr,nr,or,sr,ar,lr,cr,hr,ur,dr,fr,pr,mr,_r,gr,vr,yr,br,Tr,xr,Er,Ar,Pr,Sr,Rr,Mr,Cr,Or,Dr,Ir,wr,Lr,Fr,Br,Nr,Vr,Ur,zr,Gr,kr,Wr,Hr,Xr,jr,Yr,Kr,Qr,Zr,qr,Jr,$r,en,tn,rn,nn,on,sn,an,ln,cn,hn,un,dn,fn,pn,mn,_n,gn,vn,yn,bn,Tn,xn,En,An,Pn,Sn,Rn,Mn,Cn,On,Dn,In,wn,Ln,Fn,Bn,Nn,Vn,Un,zn,Gn,kn,Wn,Hn,Xn,jn,Yn,Kn,Qn,Zn,qn,Jn,$n,eo,to,io,ro,no,oo,so,ao,lo,co,ho,uo,fo,po,mo,_o,go,vo,yo,bo,To,xo,Eo,Ao,Po,So,Ro,Mo,Co,Oo,Do,Io,wo,Lo,Fo,Bo,No,Vo,Uo,zo,Go,ko,Wo,Ho,Xo,jo,Yo,Ko,Qo,Zo,qo,Jo,$o,es,ts,is,rs,ns,os,ss,as,ls,cs,hs,us,ds,fs,ps,ms,_s,gs,vs,ys,bs,Ts,xs,Es,As,Ps,Ss,Rs,Ms,Cs,Os,Ds,Is,ws,Ls,Fs,Bs,Ns,Vs,Us,zs,Gs,ks,Ws,Hs,Xs,js,Ys,Ks,Qs,Zs,qs,Js,$s,ea,ta,ia,ra,na,oa,sa,aa;ae=this&&this.__assign||function(){return(ae=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};$i=$a||($a={}),er=(function(){function s(e,t,i){this._bias=5e-5,this._normalBias=0,this._blurBoxOffset=1,this._blurScale=2,this._blurKernel=1,this._useKernelBlur=!1,this._filter=s.FILTER_NONE,this._filteringQuality=s.QUALITY_HIGH,this._contactHardeningLightSizeUVRatio=.1,this._darkness=0,this._transparencyShadow=!1,this.frustumEdgeFalloff=0,this.forceBackFacesOnly=!1,this._lightDirection=$i.Vector3.Zero(),this._viewMatrix=$i.Matrix.Zero(),this._projectionMatrix=$i.Matrix.Zero(),this._transformMatrix=$i.Matrix.Zero(),this._cachedPosition=new $i.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cachedDirection=new $i.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._currentFaceIndex=0,this._currentFaceIndexCache=0,this._defaultTextureMatrix=$i.Matrix.Identity(),this._mapSize=e,this._light=t,this._scene=t.getScene();var r=(t._shadowGenerator=this)._scene._getComponent($i.SceneComponentConstants.NAME_SHADOWGENERATOR);r||(r=new $i.ShadowGeneratorSceneComponent(this._scene),this._scene._addComponent(r));var n=this._scene.getEngine().getCaps();i?n.textureFloatRender&&n.textureFloatLinearFiltering?this._textureType=$i.Engine.TEXTURETYPE_FLOAT:n.textureHalfFloatRender&&n.textureHalfFloatLinearFiltering?this._textureType=$i.Engine.TEXTURETYPE_HALF_FLOAT:this._textureType=$i.Engine.TEXTURETYPE_UNSIGNED_INT:n.textureHalfFloatRender&&n.textureHalfFloatLinearFiltering?this._textureType=$i.Engine.TEXTURETYPE_HALF_FLOAT:n.textureFloatRender&&n.textureFloatLinearFiltering?this._textureType=$i.Engine.TEXTURETYPE_FLOAT:this._textureType=$i.Engine.TEXTURETYPE_UNSIGNED_INT,this._initializeGenerator(),this._applyFilterValues()}return Object.defineProperty(s.prototype,"bias",{get:function(){return this._bias},set:function(e){this._bias=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"normalBias",{get:function(){return this._normalBias},set:function(e){this._normalBias=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"blurBoxOffset",{get:function(){return this._blurBoxOffset},set:function(e){this._blurBoxOffset!==e&&(this._blurBoxOffset=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"blurScale",{get:function(){return this._blurScale},set:function(e){this._blurScale!==e&&(this._blurScale=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"blurKernel",{get:function(){return this._blurKernel},set:function(e){this._blurKernel!==e&&(this._blurKernel=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useKernelBlur",{get:function(){return this._useKernelBlur},set:function(e){this._useKernelBlur!==e&&(this._useKernelBlur=e,this._disposeBlurPostProcesses())},enumerable:!0,configurable:!0}),Object.defineProperty(s.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(s.prototype,"filter",{get:function(){return this._filter},set:function(e){if(this._light.needCube()){if(e===s.FILTER_BLUREXPONENTIALSHADOWMAP)return void(this.useExponentialShadowMap=!0);if(e===s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)return void(this.useCloseExponentialShadowMap=!0);if(e===s.FILTER_PCF||e===s.FILTER_PCSS)return void(this.usePoissonSampling=!0)}e!==s.FILTER_PCF&&e!==s.FILTER_PCSS||1!==this._scene.getEngine().webGLVersion?this._filter!==e&&(this._filter=e,this._disposeBlurPostProcesses(),this._applyFilterValues(),this._light._markMeshesAsLightDirty()):this.usePoissonSampling=!0},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"usePoissonSampling",{get:function(){return this.filter===s.FILTER_POISSONSAMPLING},set:function(e){(e||this.filter===s.FILTER_POISSONSAMPLING)&&(this.filter=e?s.FILTER_POISSONSAMPLING:s.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useVarianceShadowMap",{get:function(){return $i.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap},set:function(e){$i.Tools.Warn("VSM are now replaced by ESM. Please use useExponentialShadowMap instead."),this.useExponentialShadowMap=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useBlurVarianceShadowMap",{get:function(){return $i.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap},set:function(e){$i.Tools.Warn("VSM are now replaced by ESM. Please use useBlurExponentialShadowMap instead."),this.useBlurExponentialShadowMap=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useExponentialShadowMap",{get:function(){return this.filter===s.FILTER_EXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===s.FILTER_EXPONENTIALSHADOWMAP)&&(this.filter=e?s.FILTER_EXPONENTIALSHADOWMAP:s.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useBlurExponentialShadowMap",{get:function(){return this.filter===s.FILTER_BLUREXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===s.FILTER_BLUREXPONENTIALSHADOWMAP)&&(this.filter=e?s.FILTER_BLUREXPONENTIALSHADOWMAP:s.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useCloseExponentialShadowMap",{get:function(){return this.filter===s.FILTER_CLOSEEXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===s.FILTER_CLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?s.FILTER_CLOSEEXPONENTIALSHADOWMAP:s.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useBlurCloseExponentialShadowMap",{get:function(){return this.filter===s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP},set:function(e){(e||this.filter===s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP)&&(this.filter=e?s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP:s.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"usePercentageCloserFiltering",{get:function(){return this.filter===s.FILTER_PCF},set:function(e){(e||this.filter===s.FILTER_PCF)&&(this.filter=e?s.FILTER_PCF:s.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"filteringQuality",{get:function(){return this._filteringQuality},set:function(e){this._filteringQuality=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"useContactHardeningShadow",{get:function(){return this.filter===s.FILTER_PCSS},set:function(e){(e||this.filter===s.FILTER_PCSS)&&(this.filter=e?s.FILTER_PCSS:s.FILTER_NONE)},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"contactHardeningLightSizeUVRatio",{get:function(){return this._contactHardeningLightSizeUVRatio},set:function(e){this._contactHardeningLightSizeUVRatio=e},enumerable:!0,configurable:!0}),s.prototype.getDarkness=function(){return this._darkness},s.prototype.setDarkness=function(e){return this._darkness=1<=e?1:e<=0?0:e,this},s.prototype.setTransparencyShadow=function(e){return this._transparencyShadow=e,this},s.prototype.getShadowMap=function(){return this._shadowMap},s.prototype.getShadowMapForRendering=function(){return this._shadowMap2?this._shadowMap2:this._shadowMap},s.prototype.addShadowCaster=function(e,t){var i;return void 0===t&&(t=!0),this._shadowMap&&(this._shadowMap.renderList||(this._shadowMap.renderList=[]),this._shadowMap.renderList.push(e),t&&(i=this._shadowMap.renderList).push.apply(i,e.getChildMeshes())),this},s.prototype.removeShadowCaster=function(e,t){if(void 0===t&&(t=!0),!this._shadowMap||!this._shadowMap.renderList)return this;var i=this._shadowMap.renderList.indexOf(e);if(-1!==i&&this._shadowMap.renderList.splice(i,1),t)for(var r=0,n=e.getChildren();r<n.length;r++){var o=n[r];this.removeShadowCaster(o)}return this},s.prototype.getLight=function(){return this._light},s.prototype._initializeGenerator=function(){this._light._markMeshesAsLightDirty(),this._initializeShadowMap()},s.prototype._initializeShadowMap=function(){var t=this,i=this._scene.getEngine();1<i.webGLVersion?(this._shadowMap=new $i.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube(),void 0,!1,!1),this._shadowMap.createDepthStencilTexture($i.Engine.LESS,!0)):this._shadowMap=new $i.RenderTargetTexture(this._light.name+"_shadowMap",this._mapSize,this._scene,!1,!0,this._textureType,this._light.needCube()),this._shadowMap.wrapU=$i.Texture.CLAMP_ADDRESSMODE,this._shadowMap.wrapV=$i.Texture.CLAMP_ADDRESSMODE,this._shadowMap.anisotropicFilteringLevel=1,this._shadowMap.updateSamplingMode($i.Texture.BILINEAR_SAMPLINGMODE),this._shadowMap.renderParticles=!1,this._shadowMap.ignoreCameraViewport=!0,this._shadowMap.onBeforeRenderObservable.add((function(e){t._currentFaceIndex=e,t._filter===s.FILTER_PCF&&i.setColorWrite(!1)})),this._shadowMap.customRenderFunction=this._renderForShadowMap.bind(this),this._shadowMap.onAfterUnbindObservable.add((function(){if(t._filter===s.FILTER_PCF&&i.setColorWrite(!0),t.useBlurExponentialShadowMap||t.useBlurCloseExponentialShadowMap){var e=t.getShadowMapForRendering();e&&t._scene.postProcessManager.directRender(t._blurPostProcesses,e.getInternalTexture(),!0)}}));var r=new $i.Color4(0,0,0,0),n=new $i.Color4(1,1,1,1);this._shadowMap.onClearObservable.add((function(e){t._filter===s.FILTER_PCF?e.clear(n,!1,!0,!1):t.useExponentialShadowMap||t.useBlurExponentialShadowMap?e.clear(r,!0,!0,!1):e.clear(n,!0,!0,!1)}))},s.prototype._initializeBlurRTTAndPostProcesses=function(){var t=this,e=this._scene.getEngine(),i=this._mapSize/this.blurScale;this.useKernelBlur&&1===this.blurScale||(this._shadowMap2=new $i.RenderTargetTexture(this._light.name+"_shadowMap2",i,this._scene,!1,!0,this._textureType),this._shadowMap2.wrapU=$i.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.wrapV=$i.Texture.CLAMP_ADDRESSMODE,this._shadowMap2.updateSamplingMode($i.Texture.BILINEAR_SAMPLINGMODE)),this.useKernelBlur?(this._kernelBlurXPostprocess=new $i.BlurPostProcess(this._light.name+"KernelBlurX",new $i.Vector2(1,0),this.blurKernel,1,null,$i.Texture.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.width=i,this._kernelBlurXPostprocess.height=i,this._kernelBlurXPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._shadowMap)})),this._kernelBlurYPostprocess=new $i.BlurPostProcess(this._light.name+"KernelBlurY",new $i.Vector2(0,1),this.blurKernel,1,null,$i.Texture.BILINEAR_SAMPLINGMODE,e,!1,this._textureType),this._kernelBlurXPostprocess.autoClear=!1,this._kernelBlurYPostprocess.autoClear=!1,this._textureType===$i.Engine.TEXTURETYPE_UNSIGNED_INT&&(this._kernelBlurXPostprocess.packedFloat=!0,this._kernelBlurYPostprocess.packedFloat=!0),this._blurPostProcesses=[this._kernelBlurXPostprocess,this._kernelBlurYPostprocess]):(this._boxBlurPostprocess=new $i.PostProcess(this._light.name+"DepthBoxBlur","depthBoxBlur",["screenSize","boxOffset"],[],1,null,$i.Texture.BILINEAR_SAMPLINGMODE,e,!1,"#define OFFSET "+this._blurBoxOffset,this._textureType),this._boxBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",i,i),e.setTexture("textureSampler",t._shadowMap)})),this._boxBlurPostprocess.autoClear=!1,this._blurPostProcesses=[this._boxBlurPostprocess])},s.prototype._renderForShadowMap=function(e,t,i,r){var n,o=this._scene.getEngine();if(r.length){for(o.setColorWrite(!1),n=0;n<r.length;n++)this._renderSubMeshForShadowMap(r.data[n]);o.setColorWrite(!0)}for(n=0;n<e.length;n++)this._renderSubMeshForShadowMap(e.data[n]);for(n=0;n<t.length;n++)this._renderSubMeshForShadowMap(t.data[n]);if(this._transparencyShadow)for(n=0;n<i.length;n++)this._renderSubMeshForShadowMap(i.data[n])},s.prototype._renderSubMeshForShadowMap=function(e){var i=this,t=e.getRenderingMesh(),r=this._scene,n=r.getEngine(),o=e.getMaterial();if(o){n.setState(o.backFaceCulling);var s=t._getInstancesRenderList(e._id);if(!s.mustReturn){var a=n.getCaps().instancedArrays&&null!==s.visibleInstances[e._id]&&void 0!==s.visibleInstances[e._id];if(this.isReady(e,a)){if(n.enableEffect(this._effect),t._bind(e,this._effect,$i.Material.TriangleFillMode),this._effect.setFloat3("biasAndScale",this.bias,this.normalBias,this.depthScale),this._effect.setMatrix("viewProjection",this.getTransformMatrix()),this.getLight().getTypeID()===$i.Light.LIGHTTYPEID_DIRECTIONALLIGHT?this._effect.setVector3("lightData",this._cachedDirection):this._effect.setVector3("lightData",this._cachedPosition),r.activeCamera&&this._effect.setFloat2("depthValues",this.getLight().getDepthMinZ(r.activeCamera),this.getLight().getDepthMinZ(r.activeCamera)+this.getLight().getDepthMaxZ(r.activeCamera)),o&&o.needAlphaTesting()){var l=o.getAlphaTestTexture();l&&(this._effect.setTexture("diffuseSampler",l),this._effect.setMatrix("diffuseMatrix",l.getTextureMatrix()||this._defaultTextureMatrix))}t.useBones&&t.computeBonesUsingShaders&&this._effect.setMatrices("mBones",t.skeleton.getTransformMatrices(t)),$i.MaterialHelper.BindMorphTargetParameters(t,this._effect),this.forceBackFacesOnly&&n.setState(!0,0,!1,!0),t._processRendering(e,this._effect,$i.Material.TriangleFillMode,s,a,(function(e,t){return i._effect.setMatrix("world",t)})),this.forceBackFacesOnly&&n.setState(!0,0,!1,!1)}else this._shadowMap&&this._shadowMap.resetRefreshCounter()}}},s.prototype._applyFilterValues=function(){this._shadowMap&&(this.filter===s.FILTER_NONE||this.filter===s.FILTER_PCSS?this._shadowMap.updateSamplingMode($i.Texture.NEAREST_SAMPLINGMODE):this._shadowMap.updateSamplingMode($i.Texture.BILINEAR_SAMPLINGMODE))},s.prototype.forceCompilation=function(e,t){var i=this,r=ae({useInstances:!1},t),n=this.getShadowMap();if(n){var o=n.renderList;if(o){for(var s=new Array,a=0,l=o;a<l.length;a++){var c=l[a];s.push.apply(s,c.subMeshes)}if(0!==s.length){var h=0,u=function(){if(i._scene&&i._scene.getEngine()){for(;i.isReady(s[h],r.useInstances);)if(++h>=s.length)return void(e&&e(i));setTimeout(u,16)}};u()}else e&&e(this)}else e&&e(this)}else e&&e(this)},s.prototype.forceCompilationAsync=function(t){var i=this;return new Promise(function(e){i.forceCompilation((function(){e()}),t)})},s.prototype.isReady=function(e,t){var i=[];this._textureType!==$i.Engine.TEXTURETYPE_UNSIGNED_INT&&i.push("#define FLOAT"),this.useExponentialShadowMap||this.useBlurExponentialShadowMap?i.push("#define ESM"):(this.usePercentageCloserFiltering||this.useContactHardeningShadow)&&i.push("#define DEPTHTEXTURE");var r=[$i.VertexBuffer.PositionKind],n=e.getMesh(),o=e.getMaterial();if(this.normalBias&&n.isVerticesDataPresent($i.VertexBuffer.NormalKind)&&(r.push($i.VertexBuffer.NormalKind),i.push("#define NORMAL"),n.nonUniformScaling&&i.push("#define NONUNIFORMSCALING"),this.getLight().getTypeID()===$i.Light.LIGHTTYPEID_DIRECTIONALLIGHT&&i.push("#define DIRECTIONINLIGHTDATA")),o&&o.needAlphaTesting()){var s=o.getAlphaTestTexture();s&&(i.push("#define ALPHATEST"),n.isVerticesDataPresent($i.VertexBuffer.UVKind)&&(r.push($i.VertexBuffer.UVKind),i.push("#define UV1")),n.isVerticesDataPresent($i.VertexBuffer.UV2Kind)&&1===s.coordinatesIndex&&(r.push($i.VertexBuffer.UV2Kind),i.push("#define UV2")))}n.useBones&&n.computeBonesUsingShaders?(r.push($i.VertexBuffer.MatricesIndicesKind),r.push($i.VertexBuffer.MatricesWeightsKind),4<n.numBoneInfluencers&&(r.push($i.VertexBuffer.MatricesIndicesExtraKind),r.push($i.VertexBuffer.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),i.push("#define BonesPerMesh "+(n.skeleton.bones.length+1))):i.push("#define NUM_BONE_INFLUENCERS 0");var a=n.morphTargetManager,l=0;a&&0<a.numInfluencers&&(i.push("#define MORPHTARGETS"),l=a.numInfluencers,i.push("#define NUM_MORPH_INFLUENCERS "+l),$i.MaterialHelper.PrepareAttributesForMorphTargets(r,n,{NUM_MORPH_INFLUENCERS:l})),t&&(i.push("#define INSTANCES"),r.push("world0"),r.push("world1"),r.push("world2"),r.push("world3"));var c=i.join("\n");return this._cachedDefines!==c&&(this._cachedDefines=c,this._effect=this._scene.getEngine().createEffect("shadowMap",r,["world","mBones","viewProjection","diffuseMatrix","lightData","depthValues","biasAndScale","morphTargetInfluences"],["diffuseSampler"],c,void 0,void 0,void 0,{maxSimultaneousMorphTargets:l})),!!this._effect.isReady()&&((this.useBlurExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(this._blurPostProcesses&&this._blurPostProcesses.length||this._initializeBlurRTTAndPostProcesses()),!(this._kernelBlurXPostprocess&&!this._kernelBlurXPostprocess.isReady())&&(!(this._kernelBlurYPostprocess&&!this._kernelBlurYPostprocess.isReady())&&!(this._boxBlurPostprocess&&!this._boxBlurPostprocess.isReady())))},s.prototype.prepareDefines=function(e,t){var i=this._scene,r=this._light;i.shadowsEnabled&&r.shadowEnabled&&(e["SHADOW"+t]=!0,this.useContactHardeningShadow&&(e["SHADOWPCSS"+t]=!0,this._filteringQuality===s.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===s.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)),this.usePercentageCloserFiltering?(e["SHADOWPCF"+t]=!0,this._filteringQuality===s.QUALITY_LOW?e["SHADOWLOWQUALITY"+t]=!0:this._filteringQuality===s.QUALITY_MEDIUM&&(e["SHADOWMEDIUMQUALITY"+t]=!0)):this.usePoissonSampling?e["SHADOWPOISSON"+t]=!0:this.useExponentialShadowMap||this.useBlurExponentialShadowMap?e["SHADOWESM"+t]=!0:(this.useCloseExponentialShadowMap||this.useBlurCloseExponentialShadowMap)&&(e["SHADOWCLOSEESM"+t]=!0),r.needCube()&&(e["SHADOWCUBE"+t]=!0))},s.prototype.bindShadowLight=function(e,t){var i=this._light,r=this._scene;if(r.shadowsEnabled&&i.shadowEnabled){var n=r.activeCamera;if(n){var o=this.getShadowMap();o&&(i.needCube()||t.setMatrix("lightMatrix"+e,this.getTransformMatrix()),this._filter===s.FILTER_PCF?(t.setDepthStencilTexture("shadowSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),o.getSize().width,1/o.getSize().width,this.frustumEdgeFalloff,e)):this._filter===s.FILTER_PCSS?(t.setDepthStencilTexture("shadowSampler"+e,this.getShadowMapForRendering()),t.setTexture("depthSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),1/o.getSize().width,this._contactHardeningLightSizeUVRatio*o.getSize().width,this.frustumEdgeFalloff,e)):(t.setTexture("shadowSampler"+e,this.getShadowMapForRendering()),i._uniformBuffer.updateFloat4("shadowsInfo",this.getDarkness(),this.blurScale/o.getSize().width,this.depthScale,this.frustumEdgeFalloff,e)),i._uniformBuffer.updateFloat2("depthValues",this.getLight().getDepthMinZ(n),this.getLight().getDepthMinZ(n)+this.getLight().getDepthMaxZ(n),e))}}},s.prototype.getTransformMatrix=function(){var e=this._scene;if(this._currentRenderID===e.getRenderId()&&this._currentFaceIndexCache===this._currentFaceIndex)return this._transformMatrix;this._currentRenderID=e.getRenderId(),this._currentFaceIndexCache=this._currentFaceIndex;var t=this._light.position;if(this._light.computeTransformedInformation()&&(t=this._light.transformedPosition),$i.Vector3.NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex),this._lightDirection),1===Math.abs($i.Vector3.Dot(this._lightDirection,$i.Vector3.Up()))&&(this._lightDirection.z=1e-13),this._light.needProjectionMatrixCompute()||!this._cachedPosition||!this._cachedDirection||!t.equals(this._cachedPosition)||!this._lightDirection.equals(this._cachedDirection)){this._cachedPosition.copyFrom(t),this._cachedDirection.copyFrom(this._lightDirection),$i.Matrix.LookAtLHToRef(t,t.add(this._lightDirection),$i.Vector3.Up(),this._viewMatrix);var i=this.getShadowMap();if(i){var r=i.renderList;r&&this._light.setShadowProjectionMatrix(this._projectionMatrix,this._viewMatrix,r)}this._viewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix)}return this._transformMatrix},s.prototype.recreateShadowMap=function(){var e=this._shadowMap;if(e){var t=e.renderList;this._disposeRTTandPostProcesses(),this._initializeGenerator(),this.filter=this.filter,this._applyFilterValues(),this._shadowMap.renderList=t}},s.prototype._disposeBlurPostProcesses=function(){this._shadowMap2&&(this._shadowMap2.dispose(),this._shadowMap2=null),this._boxBlurPostprocess&&(this._boxBlurPostprocess.dispose(),this._boxBlurPostprocess=null),this._kernelBlurXPostprocess&&(this._kernelBlurXPostprocess.dispose(),this._kernelBlurXPostprocess=null),this._kernelBlurYPostprocess&&(this._kernelBlurYPostprocess.dispose(),this._kernelBlurYPostprocess=null),this._blurPostProcesses=[]},s.prototype._disposeRTTandPostProcesses=function(){this._shadowMap&&(this._shadowMap.dispose(),this._shadowMap=null),this._disposeBlurPostProcesses()},s.prototype.dispose=function(){this._disposeRTTandPostProcesses(),this._light&&(this._light._shadowGenerator=null,this._light._markMeshesAsLightDirty())},s.prototype.serialize=function(){var e={},t=this.getShadowMap();if(!t)return e;if(e.lightId=this._light.id,e.mapSize=t.getRenderSize(),e.useExponentialShadowMap=this.useExponentialShadowMap,e.useBlurExponentialShadowMap=this.useBlurExponentialShadowMap,e.useCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.useBlurCloseExponentialShadowMap=this.useBlurExponentialShadowMap,e.usePoissonSampling=this.usePoissonSampling,e.forceBackFacesOnly=this.forceBackFacesOnly,e.depthScale=this.depthScale,e.darkness=this.getDarkness(),e.blurBoxOffset=this.blurBoxOffset,e.blurKernel=this.blurKernel,e.blurScale=this.blurScale,e.useKernelBlur=this.useKernelBlur,e.transparencyShadow=this._transparencyShadow,e.frustumEdgeFalloff=this.frustumEdgeFalloff,e.bias=this.bias,e.normalBias=this.normalBias,e.usePercentageCloserFiltering=this.usePercentageCloserFiltering,e.useContactHardeningShadow=this.useContactHardeningShadow,e.filteringQuality=this.filteringQuality,e.contactHardeningLightSizeUVRatio=this.contactHardeningLightSizeUVRatio,e.renderList=[],t.renderList)for(var i=0;i<t.renderList.length;i++){var r=t.renderList[i];e.renderList.push(r.id)}return e},s.Parse=function(e,t){for(var i=t.getLightByID(e.lightId),r=new s(e.mapSize,i),n=r.getShadowMap(),o=0;o<e.renderList.length;o++){t.getMeshesByID(e.renderList[o]).forEach((function(e){n&&(n.renderList||(n.renderList=[]),n.renderList.push(e))}))}return e.usePoissonSampling?r.usePoissonSampling=!0:e.useExponentialShadowMap?r.useExponentialShadowMap=!0:e.useBlurExponentialShadowMap?r.useBlurExponentialShadowMap=!0:e.useCloseExponentialShadowMap?r.useCloseExponentialShadowMap=!0:e.useBlurCloseExponentialShadowMap?r.useBlurCloseExponentialShadowMap=!0:e.usePercentageCloserFiltering?r.usePercentageCloserFiltering=!0:e.useContactHardeningShadow&&(r.useContactHardeningShadow=!0),e.filteringQuality&&(r.filteringQuality=e.filteringQuality),e.contactHardeningLightSizeUVRatio?r.contactHardeningLightSizeUVRatio=e.contactHardeningLightSizeUVRatio:e.useVarianceShadowMap?r.useExponentialShadowMap=!0:e.useBlurVarianceShadowMap&&(r.useBlurExponentialShadowMap=!0),e.depthScale&&(r.depthScale=e.depthScale),e.blurScale&&(r.blurScale=e.blurScale),e.blurBoxOffset&&(r.blurBoxOffset=e.blurBoxOffset),e.useKernelBlur&&(r.useKernelBlur=e.useKernelBlur),e.blurKernel&&(r.blurKernel=e.blurKernel),void 0!==e.bias&&(r.bias=e.bias),void 0!==e.normalBias&&(r.normalBias=e.normalBias),void 0!==e.frustumEdgeFalloff&&(r.frustumEdgeFalloff=e.frustumEdgeFalloff),e.darkness&&r.setDarkness(e.darkness),e.transparencyShadow&&r.setTransparencyShadow(!0),r.forceBackFacesOnly=e.forceBackFacesOnly,r},s.FILTER_NONE=0,s.FILTER_EXPONENTIALSHADOWMAP=1,s.FILTER_POISSONSAMPLING=2,s.FILTER_BLUREXPONENTIALSHADOWMAP=3,s.FILTER_CLOSEEXPONENTIALSHADOWMAP=4,s.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP=5,s.FILTER_PCF=6,s.FILTER_PCSS=7,s.QUALITY_HIGH=0,s.QUALITY_MEDIUM=1,s.QUALITY_LOW=2,s})(),$i.ShadowGenerator=er,(function(a){a.AbstractScene.AddParser(a.SceneComponentConstants.NAME_SHADOWGENERATOR,(function(e,t,i,r){if(void 0!==e.shadowGenerators&&null!==e.shadowGenerators)for(var n=0,o=e.shadowGenerators.length;n<o;n++){var s=e.shadowGenerators[n];a.ShadowGenerator.Parse(s,t)}}));var e=(function(){function e(e){this.name=a.SceneComponentConstants.NAME_SHADOWGENERATOR,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(a.SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){},e.prototype.serialize=function(e){e.shadowGenerators=[];for(var t=0,i=this.scene.lights;t<i.length;t++){var r=i[t].getShadowGenerator();r&&e.shadowGenerators.push(r.serialize())}},e.prototype.addFromContainer=function(e){},e.prototype.removeFromContainer=function(e){},e.prototype.dispose=function(){},e.prototype._gatherRenderTargets=function(e){var t=this.scene;if(this.scene.shadowsEnabled)for(var i=0;i<t.lights.length;i++){var r=t.lights[i],n=r.getShadowGenerator();if(r.isEnabled()&&r.shadowEnabled&&n){var o=n.getShadowMap();-1!==t.textures.indexOf(o)&&e.push(o)}}},e})();a.ShadowGeneratorSceneComponent=e})($a||($a={})),tr=$a||($a={}),ir=(function(){function e(e,t,i){void 0===t&&(t=""),void 0===i&&(i="black");var r=this;this._renderingCanvas=e,this._loadingText=t,this._loadingDivBackgroundColor=i,this._resizeLoadingUI=function(){var e=r._renderingCanvas.getBoundingClientRect(),t=window.getComputedStyle(r._renderingCanvas).position;r._loadingDiv&&(r._loadingDiv.style.position="fixed"===t?"fixed":"absolute",r._loadingDiv.style.left=e.left+"px",r._loadingDiv.style.top=e.top+"px",r._loadingDiv.style.width=e.width+"px",r._loadingDiv.style.height=e.height+"px")}}return e.prototype.displayLoadingUI=function(){if(!this._loadingDiv){this._loadingDiv=document.createElement("div"),this._loadingDiv.id="babylonjsLoadingDiv",this._loadingDiv.style.opacity="0",this._loadingDiv.style.transition="opacity 1.5s ease",this._loadingDiv.style.pointerEvents="none",this._loadingTextDiv=document.createElement("div"),this._loadingTextDiv.style.position="absolute",this._loadingTextDiv.style.left="0",this._loadingTextDiv.style.top="50%",this._loadingTextDiv.style.marginTop="80px",this._loadingTextDiv.style.width="100%",this._loadingTextDiv.style.height="20px",this._loadingTextDiv.style.fontFamily="Arial",this._loadingTextDiv.style.fontSize="14px",this._loadingTextDiv.style.color="white",this._loadingTextDiv.style.textAlign="center",this._loadingTextDiv.innerHTML="Loading",this._loadingDiv.appendChild(this._loadingTextDiv),this._loadingTextDiv.innerHTML=this._loadingText;var e=document.createElement("style");e.type="text/css";e.innerHTML="@-webkit-keyframes spin1 { 0% { -webkit-transform: rotate(0deg);}\n 100% { -webkit-transform: rotate(360deg);}\n } @keyframes spin1 { 0% { transform: rotate(0deg);}\n 100% { transform: rotate(360deg);}\n }",document.getElementsByTagName("head")[0].appendChild(e);var t=new Image;t.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAB4CAYAAAA5ZDbSAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAHBhaW50Lm5ldCA0LjAuMTZEaa/1AAAYq0lEQVR4Xu2dCZRcVZnHScAJUZSwjSOIbAJmEAZwQCCMoAInYRGIg8AwegQx7AFzUBBmzAFlE4EAwxz2GRk2w7AnAURZBiEOZgyEQDAQAjmEJqTpNd3V1V3Vmd+/6utKV7/1vnpVXd2p/zn3vOV+27vfu/fd/W3QQAPrBZqbm7fJZrN79vf3T+/r67uf4wO9vb37WXQDIwWtra0Tenp6voQTv5XP56/BkfcR3iLk1g6B7hEeI+zP5V+ZiAbqBZ2dnZ8lV+6Gg87CobfhpOc4byf0FjwYE9DneBkWcXrM2tmzNzTxDdQKJPyETCazI46YgiMuI9zJuXJltuChFIHsP/PSfIfTjU19A2mira1tcxy3ey6XO5vEnkV4kes11XBmENDVj97XOT2O03FmWgMuoNLzGRJva8IUnPkzjjcT/kLoKCZzfQB7XiX8M2G8md7AUJgzJ+Z6e88gZ1xGuj3HsY17PcVkrG9gp7CUF/F8PUvxqdZDrFq1ahNVfKjwTCYxZuDE2wjKlc2WViMePM+HPNsFPOdf22OPblD5OZQHvphnV65cjTMzxaQY3eA5V9OO/hmnm1lSjE7woFsQbiXki4++foHnXkW4mLC1JUl947333tsMY3emqfB9jtPJlXN5U0+bOXPmWCPxgOccSy4+AfqPio+9/oFnbyatbqVE28GSZfjQ1NT0KQzaHMcdyPfyaNoE12HcvdxT29K3Fkv8A2vWrPmcifAFZNtD91yRY+SBZ+9UsMtEgD+jTpeenp6JXI6xpKkuUDqRcA6Kr0Wpens+InQTnIpV6Fdi+BQT64ulS5eOIzefD62na7CeoGcnLCM8ykt5OWlzcPv772/BS/w3nP+K+xU11+DvQe5dcrQlTfWAwbNMb8XA8AyGX80xtLlA6TAJuteMbVhhia1v5VMcr+LWMeoZ4xiYw7q6urbhHbgG+paCkIRQehHu4pO3O5fVydEomF5Ulx548JfVD2wqfKE2I3R3ob/f2GoC1DWhdz7HG3i5j2pvb9+Z24m6HvVZQtYsZFWcowlzePEP4jJdR/OQhxTVpAs9NMXxmZxuZKo8IG4s+v8R2tUFphSBTBWzH+OAFwn/gS3TuN55xYoVqfc6dXd3fwHZ1xFaTX0iyGbwjJqXXAammxP00EXx6UMGEx7ram7+vKnzBZ/87Xiwp40tEdDTgYwlHG/CmadSjO7L+XiialOZAej7POFG2VK0Khngl6Pn8/LL0YEtlFh4n8oDAqvaAYH8tzH2iNDm1IIFn8Ax50G7xtgCAU07CfAG4RHOz+vLZL7e0dGxlYlKHaj8BHo25xgrsfV5wrYH4KmouxV+ZZDnCUdwmXxMGgFvFUVWD+jQuOot6rI0tb4gcfaG9v+MrcAn+wj38gL8C7cObmlp2ZRjOkWYD6ypuAf6zjFHLSJ0c/6YQ813DM/yZXgehreiVgP8cvSfsOeExYsXuzs6n8v9j8mqBRZQmdjXVPuira1NHSpn8UDf4Xu0vd2uCtDzacJOlDDf5ng94X8JTWarB8R1EK7ju7udiYgEz/v3pLFKm4oHUHhh3iZdfshpaEYpA4pvKLLXBujLYKRq71XLhUHg27z12rW9B6L/QhLrWWxRH7nzeDK8awi/5HRTEx0K6MZQ694LHk0DqrgfADkreIYz1q5c+UlTEQzesIuMryrggYQWjNL3RGO7p2tuFMeqjaOidgzyCz1yJMTJ6L6d66WEVCcHIO/dQkI75Chs2g97Hoc3jRz9Lge1ED5l4r0gckqRPB0gTw34t1B+h3IqxZkmrn2SULUa7ezZszdE5xfR9130Xsm5ilrnHrmkQOcKvrkncxqrIiY6wlewbw7BOUfDo/b84zzvj9C7J7eCS0NrUiRKCPjUE7ScMBdlF/B2HqBi0ERXBcuXL99YnQz9fX2ah3Up4UnsWGEmDRuUhoTn+Z5PfvbZZ2N/fuCZRJgnfhNVBu73EZoIKt7l0L2UBsYeDZg016nb5EUCWuXQewinUtTuyq2aTStF14a8SD+VDQVj6hDYxjuXf4Hjl83sSMCmTp8j4FtoMuRQ5dAZcii3kk/0s2bBhxIcBxjxUlib1hWInEDO/6qKV+y4geO5HAMntEE/pq+nZyo0ywsG1SmwL4Orf+0yqGCfmvR73LAn9lAeBjQTEhkA+1h49a08iRflcq4H5iuXFU9cz4lqihC/LXS/NZa6Bc+pz5gql5ub6VXD2tZWTSPeyS7XgeLhXrMnEhj6MSHSwaIhFGZH8oA/JzzFeexvJbRN2HW03moT6cEChx6w4QY2rurn85JWrxsiCy0FwjcIqos8w7GZNPulkawDEbFHlaBtjzODEDrVztuKXMmADPWA3RaljyJeNdKq98ilAez8iJdyGqfO31V4NoV/EvyaCqR54V2EshE5Lqcb+TrkstkTLD4WKB4PNNZQ8P05HAelMXNSPWChC8JsYvwthJo0jSoF6fIqjjqe08Aat+LIkd+AVjn09zxbZFqK3tjXAUbXUaWDjTUSyN4J45YZX2Igo4cEOVfFson2ALIxSjR0jog5YNgpfNHM90BxIjDyWIB8Z2NfB01HISJ20wPaw4w1FlavXq1v8aPGXhFw9JNRFTDItifU/RwwpfmKxYsDK180kU4x0lhAXvOSJUs+bezlIDL2N4xi4GpjK4MGCuzUA+SPxzn3m4iKgKyV2DCV08DeMWg0B+zHHOt2DpjS3Mz1BfFOM25C5ZH4LxldJBB0g7GVARkaXgv8VsKqZtIMPpN9RUnJgRzU5Wfp22vifcG3+2vQvmdsdQXsX2pm+oKX+GYjjQXkPWqsXshpRhcJ0RpbGShSHiSuheP37ZYHsGusVHOrU1lMxkO9od4eE+8LlSzQqfetpnPAooBN/2Um+gISp89MkF8K4G3RrMJYoOhbYGxlQEGhSOGogfoLwipExGtUZVVBYIVAluaAaUpuWA+YujlPF22Ra/iBLYEOsV6tV4w0FiitfmLsXiBMU0NiAVrfsp77Zd8MHPgbDoHtva6uLs1jiv1piAKy5tCG+4KJ9wVO/p6RDzvy+b5rzSwP9Okh/WKPERiCWzfk4K8bUSTiOljAyCdx5DZG4gE8W5Dov+NYUfsV/j50fUC4dmXIQDh0qQ6PVgJsOcLM8oA410Ggvo6Ojr81di+g2TKuQOiyJOKWxlpCJpM5zUjKAL3awTsamQfEbYhjtDGKa5tPsyn/wAuiURftlBO56h6aunEwCMxxvV1d+2Fr7Jce2vAu5LUtLeoGi/19gtbToCaR97BoD6BvUs+WkXqgbw6OuhC6wH5l4rRGaCFOvYnjYbyxnpcsCvDVhYOxo6+zszNwSNHVTtJEmSiwzlMAQmNPwIPW42Dds2hfEK/5WJo0Fth+5VNxFHSlkoTzFRh/N3wnq0OGWxXtdoO8enFwaI4jsyidYgNZTxhrMEjEJ4w+En65ESWRXZ7Q4K/COqDAPlhka87WedB8KawmngTIHREOJs5pMiRp+p/GGgxL1FiA9hxjK6G1tVVdhJGAV15+cPXq1f7dahVC20Wg4miCp0uTe3Xh4Hwu93rY1B7SR/t7xQbP5R1FGgpy8IlKe+MJhZ9Aa7u5jPm+pGLX2BMDOZ+hDXgQiXIJ5xoXHZg96anEEFcvOTi0SMUXS4w0FijSTzTWYEA3hkTSEtDI2qw6RoytDLA6jctCvzKqJ8oPFOO7kAhnYe9cZGiWiZ/N9ezguWaSL4h3TUfvKJIfoN0I4sjigYSdZyxlcDVMgEczEY41ER6oZFBOh2Yqegf2zYoziFC3DuZZrjSTPLDtMlxaNPmPP/54W2OPxksrVozP5fLPGr8vEOpbxJCr3jQSJyDvGRNRhv7iHh8vE5LMpKznHBz4zSTOaXwe+mXGGh9tbWvVQf+iyfCAON/ZlTj4v43ECfB94Le4CuMrWVpTtw7O9fZOM5M8oD7xVSOLBdLuNWN1g7bgJUF8+4qpBjf7Te9M6hD4tBDc0289Wh2MHbuaSR7gsHOMLBaQ9W/G6o5MJrNDPu9dcYdQ33Yc95I6OFV5hnp2cGCliDingX5KU+9MShd0dmqta/k8J4zwnV2JsuuNxAnI83VwNpO52kiSoC4djA255cuXBzYPycGzjTQWkPdNY00OfRcQVLafRnd39ySLLsG1i20AyPZ3cDb7AyNJgnp1cOhUHUhcFiL045v9jTUa8Gjlm29fsQQhb3DzJLUEhC+oiK7EISPOwapoEh+7JQJti5YfGXs0YNC62ouC1h9lsrlToClsjc/RM7uSe0kd3EmlzTO/Kqk8Q106mM/Yw2aOB9jnOg6sWTHxJ9FraSJMy6nGz7RbZUDYmN7e3BnQ5Gisez7u3J9c0JwA6Pb0aCFvNObgwKk6NoU59uJwaJ8y1viAT4vCtEFXYO8SFQGtCZpllyXQtNqL+4lmZ/BN/5qJKQFZozEHe9JtAGSaw4wsFnie4JmUQcjleh8yZq0Fnmq3y0D02IzPMgnonYqYIfA4pC+TcXrgIahLB+PEb5s5HrjaR0b7kbHGB0pK7TDO1/T39x1lUZGAPlUH0xTbz+KSoC4dDDx2DQCHzTCaWOB5zjbW+KCSpW0IS0BIJmy6zWCk7WDuxZ4r5oO6dHB7e/sBZo4H2OfUsYOv9jHW+ECJdkAtA/c6MpmMd+XaEKj7km9M4F5TEfBzSKovDLKG1cHobw+b6EDa3WOksYBPAhevBUJMxl8GJTRhFyMLBKSJFn5ls9nvmogS0DfaHOzb3h8AcUuNNBLQNiWa0gRv4MwMMyBwCqxAfCIH82JdYSJKQN+ocjA5NHD2I/e1aj/23iPyhbG6A+bAgXsZoUEII/UAkkQORu71JqIE7o22HBw4VaelpWU74mPPDc/39d1trO5Qb4vJ8QXxbwat06WofcTInMCzeToAtN4VXUn/l1AXDkan9tDSfmL6C81BZooHxDkN9CMveLFZFFAWWZtDwVta3G0sJcAbe3bmYEiniShBXabcL+wflQDD5mD0yKlvk0b/Tk33AG5F7idG+/ibRe54oEl1nLG6A+ZYe1jyAIuG/u2LB3MazxwAfL5vJFGJinxQUwcju6c/n3+FNPm5JhJyy2k/sQTp5nm+2HBJCGi1X1WpwzuBoQXAN+IcjDz8mdePKi/WhH1uxd7GcCjIVBcWpUYDfZ0VbclEJSr2akMBhVrdX6j+Jx3DpSh7vKB8CIiqKwcrcXGqdr05k3RKbU9ryTQVkUB3aHMrEshw7kGCXiv8xxG0h6Uzent6Fpn6MhA17A6GT/3yTxNO1coJbgWur3JFf1fXNuTes5AZe18xXobFHJKv04JZc3O7CtIcgGL9KW03u3QCfL4D4b292dhrpoYgsYOhEz4kaOuHqXKqiagYiN9QnUlyKgX84JUYsQFP9GKzMFRSe8XJb9upE9Dn62CK/KQT75wdTLz+NXgPNdrDuYzeUd0ByN4Wp07n+EdCRZuTY1/ymZQDwIjQye9pA32xdw6IiUgHc639mN8kzCLRjkxzQRzitUpkZ8LZBP1CILUd55EVvdgsCrzJl5i8mgCja+Zgjst4Pq3DUnMmtSWqyNIuQruRU3+CbO08n+pvBAZAjf1IU5kcGJc0YRMBfVV3MPd2RN4+YbvYukI/3sSpe+LUmbw0ryG/6ts1oSLeYrMw6C0xeaFAGc+Wq3hbfeRk582b55lrzf3UHJwWkD0Wp+6BQ3+BfXEXw6UCdHX4TVB0BoJi9Y1Cp59XbUWN8HW7lRjLli3zbINE+1hNiCRI1cGakIhT99ani/A6z1z1nDoUqNQfbO40kyqDfrCBwMg3E5rsCy+8sFlHR8dEnFzRTq/I8hQ9NFFOtGhXVOxgFeUqfknUK7Ctpjl1ANKJ/vmUkvrdwRZmWjpA4J9MTyja2toKY8TQa/ufxP/Whdd5c5cQJHIwfBsTvkKiaqd6/fRyOHKqavdL0H+V2sxmWvrQCAeKItfmQlNyDG/8SVwnetMHyxmA7lm0K2I7GFrlVBW/V6FPP9GqeU4V0Kt2+O2yhctUN6AJBEWD9ngMnessJxh5AfCoQe+8q+xQOYLuWbQrQh2MXP1XYh8S9DKC2sI1z6kCatW3/RCZ6Vj9fNPMqx2wQVNJQlcNEl/mGG5pv48bi7HxMVSOoHsW7QqPg5GlvnJtk6/B9+HMqYUfaXE6rampqWy4dVhgi8FfLprnBXEex+i/wCSkNiSNDSpUxxt7Ccj2nQQYAwUHc9yE3HEotuifDklnfFYMdGNC/lWCxotDf4PvB/jHZTs71c+f2n+ryqCPPcb5/pKdGrTvbH2MUjH4ByOLBDpON9YSFi5cuI1FOwFbbyTox5T6y+iwFL8CqvWvwVtolWgSv/N4sXbl5ZP3r8hRLT50d56KgYJDCYXVhYOhtqqReKDdZuGJtSQSOk8f67x581SspvH3lpoBe9Vefbg/lzveaXmnAf6tEDMNGRp3LnV3ch29o10lQIf+bOKZc+XnmMGARF2EK4vUwQiSw33n7ZlqDWwcaK9Ob29vd26vwj+OT8m3kKFxdd9tlILSJ1Wo8Y8RZT/YiKOY4le5P3SGZJAc7telg7FroL16Jc/n/a1cBBCxsSblwT8LOfofcCh4AQ4x1uoCXZtgVKnYDXLMUECnPSQD29VBcrhfVw7GHrVXb6WylGg0SvUZcrr+YPYuwWVfaE9ltmpA2Q6EQq2UY+yigzf2oqCH4v4MIysD94fdwdig9uqDnB4T5/d+gwHPGNVFcOopyJiPLOfmGTwa0Ek8qS8RKDKORLFWH95utwbDd94SRqqN/Cv4PDXbTFfXfUZWBvRUPJCRBJiIqfnnccy0Dz74wHkWoypY2D4ZGU8gK+kKjQKQ8RcTW1uQI2fmc7nH7LIMFEW+sw6xdyN4CgvNByNIDjp+ZyRVhzlV7dVLaZc7t1cRoW0w9of/No6ptbuRdZupqC3QPZY33HchMkbJiRPssgyaHkN82XaJXPtOJuN+JRuixQI6Cu1VXiZtJehcFGpeNPyXI6cqPWTIvsxU1R7o912akevre4OHfTHot3fEfRbD3y8+Qu0djO5Ce5UXNGl7dTt4z0RGqnOuhgLZgmcPk2FHrrd3jgwkAVQ58e1ioxjcHeMLPWQcq+5gZKm9+hJHjXo5z4xQBQsxxyDjEfir+nNq5GfQo/nYh6f9e4NUgGEFx3DEzvw1nPrOhSJ+kh6GUBUHw6//Kmls96dJ2qv6FxNF9z8g405kVLVXDfkaiFAd4JIkttYUGFpyDOf91Ch/YVEe8DA/gORpuywDfLNMjBOQt4qEupbTPTX4YeJig+/qrnoxkfMeIdH2UHGBfP0H6kFepElc1rY5lBQYXZbzuO7BWYH7b3V3d/+TX1FEG/JSExEJdOi7qsnrx3DuNM8Zdg2NqnN/BjK0EXlVhxORr56wP6Lv/DT+X1FzYLynaOWe2s1TjCQW4An9t6Jk4hBVdH6YpB9YNXoS+SRk/JaQZHd5J2CnesLuyGaze3KZ2hTemoNcpO+uB3pAQuzvC7SeJSfc0258Wo97aX9PT+TmMEMB73jsO0wJzXnVx4llL7pe5kWaFtSqGHHgu6rpPr5jsdx+hyI59G+hA4C25GDO1V69mbf/77h0+lZpzZX44B+Ye1X1cWKz92pKrYlcjtzc6gfN+ufhApd/ErcwTvuTRNI0m4c4Tg77u6gfbCHdTuQcrRFaRKiFU7Xl1O/RqX9RObevRxR43gmEBYUn9wEJIMeF/jk0yVKTta2tE0jg43kx1OatWifEYKDrHYKGDnfkMrU1xHUPaoh7k8i+030EvoV3c6i4aTCoc/9+9NVkFgh6BmZFaig08he3oxYkwBEkQGCzg7gfG6kzaDvuSyLfgIyqt1cF6SAspoS4iJf3c9xaf3JrGEgUzZcOGgvO4agzjTQUkI9V5z4851MuLhBvUUp1gR7tjXEHL+shXFZnduNIBomi6T73FVLLByQePu4N3CxMbVxyzfeQUTYZrdpA3yvoPVf/1jdTGggC6aXx0ieLSecFcWoj72vkhU4IcswU7gVORksb6FHnufbouJ4Xbv+gf1g0EADav9uSeO9YenpA3IfURFVZ0gqEms1rRg0qCzM4TuYy1T061jt0dXXpX0xJ96FMDXIqQXtJ3tSfze6OaY0KU1ogfTUgUJMK0lBIL06dS/F/LJeRe0k2kAAk7BgSWN2GVW/aCOjRuPCbBHVGBG6J3ECKIN3VlfjroguqA+RrMsFvCNqisf5mRox2qPlB4s8vuiMdIE/fVjVvLlRnhKlqYLig7QIpOiva40PAqR2E22neJFrN10AVgWMOIDgPuMOjmRFa+HVaR0fHliaugXoEOe80nBWrZg2dZkZoYffuaW5u1kCVkadmbT70AGdqJodWOhxHqP2eFg1UDvsLatnSFq41M+KKnp6eXbhsdB2OdGiCeX8+/2ecqgnmk/VXNYtqYLSAnNposzpjgw3+H/belpVa8J7TAAAAAElFTkSuQmCC",t.style.position="absolute",t.style.left="50%",t.style.top="50%",t.style.marginLeft="-60px",t.style.marginTop="-60px",t.style.animation="spin1 2s infinite ease-in-out",t.style.webkitAnimation="spin1 2s infinite ease-in-out",t.style.transformOrigin="50% 50%",t.style.webkitTransformOrigin="50% 50%",this._loadingDiv.appendChild(t),this._resizeLoadingUI(),window.addEventListener("resize",this._resizeLoadingUI),this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor,document.body.appendChild(this._loadingDiv),this._loadingDiv.style.opacity="1"}},e.prototype.hideLoadingUI=function(){var e=this;if(this._loadingDiv){this._loadingDiv.style.opacity="0",this._loadingDiv.addEventListener("transitionend",(function(){e._loadingDiv&&(document.body.removeChild(e._loadingDiv),window.removeEventListener("resize",e._resizeLoadingUI),e._loadingDiv=null)}))}},Object.defineProperty(e.prototype,"loadingUIText",{get:function(){return this._loadingText},set:function(e){this._loadingText=e,this._loadingTextDiv&&(this._loadingTextDiv.innerHTML=this._loadingText)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"loadingUIBackgroundColor",{get:function(){return this._loadingDivBackgroundColor},set:function(e){this._loadingDivBackgroundColor=e,this._loadingDiv&&(this._loadingDiv.style.backgroundColor=this._loadingDivBackgroundColor)},enumerable:!0,configurable:!0}),e})(),tr.DefaultLoadingScreen=ir,(function(A){var P=(function(){function t(e,t,i){this.lengthComputable=e,this.loaded=t,this.total=i}return t.FromProgressEvent=function(e){return new t(e.lengthComputable,e.loaded,e.total)},t})();A.SceneLoaderProgressEvent=P;var e=(function(){function E(){}return Object.defineProperty(E,"ForceFullSceneLoadingForIncremental",{get:function(){return E._ForceFullSceneLoadingForIncremental},set:function(e){E._ForceFullSceneLoadingForIncremental=e},enumerable:!0,configurable:!0}),Object.defineProperty(E,"ShowLoadingScreen",{get:function(){return E._ShowLoadingScreen},set:function(e){E._ShowLoadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(E,"loggingLevel",{get:function(){return E._loggingLevel},set:function(e){E._loggingLevel=e},enumerable:!0,configurable:!0}),Object.defineProperty(E,"CleanBoneMatrixWeights",{get:function(){return E._CleanBoneMatrixWeights},set:function(e){E._CleanBoneMatrixWeights=e},enumerable:!0,configurable:!0}),E._getDefaultPlugin=function(){return E._registeredPlugins[".babylon"]},E._getPluginForExtension=function(e){var t=E._registeredPlugins[e];return t||(A.Tools.Warn("Unable to find a plugin to load "+e+" files. Trying to use .babylon default plugin. To load from a specific filetype (eg. gltf) see: http://doc.babylonjs.com/how_to/load_from_any_file_type"),E._getDefaultPlugin())},E._getPluginForDirectLoad=function(e){for(var t in E._registeredPlugins){var i=E._registeredPlugins[t].plugin;if(i.canDirectLoad&&i.canDirectLoad(e))return E._registeredPlugins[t]}return E._getDefaultPlugin()},E._getPluginForFilename=function(e){var t=e.indexOf("?");-1!==t&&(e=e.substring(0,t));var i=e.lastIndexOf("."),r=e.substring(i,e.length).toLowerCase();return E._getPluginForExtension(r)},E._getDirectLoad=function(e){return"data:"===e.substr(0,5)?e.substr(5):null},E._loadData=function(e,i,r,t,n,o,s){var a,l=E._getDirectLoad(e.name),c=s?E._getPluginForExtension(s):l?E._getPluginForDirectLoad(e.name):E._getPluginForFilename(e.name);a=c.plugin.createPlugin?c.plugin.createPlugin():c.plugin;var h,u=c.isBinary;E.OnPluginActivatedObservable.notifyObservers(a);var d=function(e,t){i.isDisposed?n("Scene has been disposed"):(i.database=h,r(a,e,t))},f=null,p=!1,m=a.onDisposeObservable;m&&m.add((function(){p=!0,f&&(f.abort(),f=null),o()}));var _=function(){p||(f=A.Tools.LoadFile(e.url,d,t?function(e){t(P.FromProgressEvent(e))}:void 0,h,u,(function(e,t){n("Failed to load scene."+(t?" "+t.message:""),t)})))};if(l)return d(l),a;if(-1===e.rootUrl.indexOf("file:")){var g=i.getEngine(),v=g.enableOfflineSupport;if(v){for(var y=!1,b=0,T=i.disableOfflineSupportExceptionRules;b<T.length;b++){if(T[b].test(e.url)){y=!0;break}}v=!y}v?h=new A.Database(e.url,_,g.disableManifestCheck):_()}else{var x=A.FilesInput.FilesToLoad[e.name.toLowerCase()];x?f=A.Tools.ReadFile(x,d,t,u):n("Unable to find file named "+e.name)}return a},E._getFileInfo=function(e,t){var i,r;if(t){if("/"===t.substr(0,1))return A.Tools.Error("Wrong sceneFilename parameter"),null;i=e+t,r=t}else i=e,r=A.Tools.GetFilename(e),e=A.Tools.GetFolderPath(e);return{url:i,rootUrl:e,name:r}},E.GetPluginForExtension=function(e){return E._getPluginForExtension(e).plugin},E.IsPluginForExtensionAvailable=function(e){return!!E._registeredPlugins[e]},E.RegisterPlugin=function(t){if("string"==typeof t.extensions){var e=t.extensions;E._registeredPlugins[e.toLowerCase()]={plugin:t,isBinary:!1}}else{var i=t.extensions;Object.keys(i).forEach((function(e){E._registeredPlugins[e.toLowerCase()]={plugin:t,isBinary:i[e].isBinary}}))}},E.ImportMesh=function(a,e,t,l,n,i,r,o){if(void 0===t&&(t=""),void 0===l&&(l=A.Engine.LastCreatedScene),void 0===n&&(n=null),void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=null),!l)return A.Tools.Error("No scene available to import mesh to"),null;var c=E._getFileInfo(e,t);if(!c)return null;var s={};l._addPendingData(s);var h=function(){l._removePendingData(s)},u=function(e,t){var i="Unable to import meshes from "+c.url+": "+e;r?r(l,i,t):A.Tools.Error(i),h()},d=i?function(e){try{i(e)}catch(e){u("Error in onProgress callback",e)}}:void 0,f=function(e,t,i,r){if(l.importedMeshesFiles.push(c.url),n)try{n(e,t,i,r)}catch(e){u("Error in onSuccess callback",e)}l._removePendingData(s)};return E._loadData(c,l,(function(t,e,i){if(t.rewriteRootURL&&(c.rootUrl=t.rewriteRootURL(c.rootUrl,i)),t.importMesh){var r=t,n=new Array,o=new Array,s=new Array;if(!r.importMesh(a,l,e,c.rootUrl,n,o,s,u))return;l.loadingPluginName=t.name,f(n,o,s,[])}else{t.importMeshAsync(a,l,e,c.rootUrl,d,c.name).then((function(e){l.loadingPluginName=t.name,f(e.meshes,e.particleSystems,e.skeletons,e.animationGroups)})).catch((function(e){u(e.message,e)}))}}),d,u,h,o)},E.ImportMeshAsync=function(e,t,i,o,s,a){return void 0===i&&(i=""),void 0===o&&(o=A.Engine.LastCreatedScene),void 0===s&&(s=null),void 0===a&&(a=null),new Promise(function(n,r){E.ImportMesh(e,t,i,o,(function(e,t,i,r){n({meshes:e,particleSystems:t,skeletons:i,animationGroups:r})}),s,(function(e,t,i){r(i||new Error(t))}),a)})},E.Load=function(e,t,i,r,n,o,s){return void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),E.Append(e,t,new A.Scene(i),r,n,o,s)},E.LoadAsync=function(e,i,n,o,s){return void 0===o&&(o=null),void 0===s&&(s=null),new Promise(function(t,r){E.Load(e,i,n,(function(e){t(e)}),o,(function(e,t,i){r(i||new Error(t))}),s)})},E.Append=function(e,t,r,i,n,o,s){if(void 0===t&&(t=""),void 0===r&&(r=A.Engine.LastCreatedScene),void 0===i&&(i=null),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),!r)return A.Tools.Error("No scene available to append to"),null;var a=E._getFileInfo(e,t);if(!a)return null;E.ShowLoadingScreen&&r.getEngine().displayLoadingUI();var l={};r._addPendingData(l);var c=function(){r._removePendingData(l),r.getEngine().hideLoadingUI()},h=function(e,t){var i="Unable to load from "+a.url+(e?": "+e:"");o?o(r,i,t):A.Tools.Error(i),c()},u=n?function(e){try{n(e)}catch(e){h("Error in onProgress callback",e)}}:void 0,d=function(){if(i)try{i(r)}catch(e){h("Error in onSuccess callback",e)}r._removePendingData(l)};return E._loadData(a,r,(function(e,t,i){if(e.load){if(!e.load(r,t,a.rootUrl,h))return;r.loadingPluginName=e.name,d()}else{e.loadAsync(r,t,a.rootUrl,u,a.name).then((function(){r.loadingPluginName=e.name,d()})).catch((function(e){h(e.message,e)}))}E.ShowLoadingScreen&&r.executeWhenReady((function(){r.getEngine().hideLoadingUI()}))}),u,h,c,s)},E.AppendAsync=function(e,i,n,o,s){return void 0===i&&(i=""),void 0===n&&(n=A.Engine.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),new Promise(function(t,r){E.Append(e,i,n,(function(e){t(e)}),o,(function(e,t,i){r(i||new Error(t))}),s)})},E.LoadAssetContainer=function(e,t,n,i,r,o,s){if(void 0===t&&(t=""),void 0===n&&(n=A.Engine.LastCreatedScene),void 0===i&&(i=null),void 0===r&&(r=null),void 0===o&&(o=null),void 0===s&&(s=null),!n)return A.Tools.Error("No scene available to load asset container to"),null;var a=E._getFileInfo(e,t);if(!a)return null;var l={};n._addPendingData(l);var c=function(){n._removePendingData(l)},h=function(e,t){var i="Unable to load assets from "+a.url+(e?": "+e:"");o?o(n,i,t):A.Tools.Error(i),c()},u=r?function(e){try{r(e)}catch(e){h("Error in onProgress callback",e)}}:void 0,d=function(e){if(i)try{i(e)}catch(e){h("Error in onSuccess callback",e)}n._removePendingData(l)};return E._loadData(a,n,(function(t,e,i){if(t.loadAssetContainer){var r=t.loadAssetContainer(n,e,a.rootUrl,h);if(!r)return;n.loadingPluginName=t.name,d(r)}else if(t.loadAssetContainerAsync){t.loadAssetContainerAsync(n,e,a.rootUrl,u,a.name).then((function(e){n.loadingPluginName=t.name,d(e)})).catch((function(e){h(e.message,e)}))}else h("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");E.ShowLoadingScreen&&n.executeWhenReady((function(){n.getEngine().hideLoadingUI()}))}),u,h,c,s)},E.LoadAssetContainerAsync=function(e,i,n,o,s){return void 0===i&&(i=""),void 0===n&&(n=A.Engine.LastCreatedScene),void 0===o&&(o=null),void 0===s&&(s=null),new Promise(function(t,r){E.LoadAssetContainer(e,i,n,(function(e){t(e)}),o,(function(e,t,i){r(i||new Error(t))}),s)})},E._ForceFullSceneLoadingForIncremental=!1,E._ShowLoadingScreen=!0,E._CleanBoneMatrixWeights=!1,E.NO_LOGGING=0,E.MINIMAL_LOGGING=1,E.SUMMARY_LOGGING=2,E.DETAILED_LOGGING=3,E._loggingLevel=E.NO_LOGGING,E.OnPluginActivatedObservable=new A.Observable,E._registeredPlugins={},E})();A.SceneLoader=e})($a||($a={})),rr=$a||($a={}),nr=function(e,t,i,r){for(var n=0,o=t.materials.length;n<o;n++){var s=t.materials[n];if(s.id===e)return rr.Material.Parse(s,i,r)}return null},or=function(e,t,i){for(var r in t)if(e.name===t[r])return i.push(e.id),!0;return!(!e.parentId||-1===i.indexOf(e.parentId))&&(i.push(e.id),!0)},sr=function(e,t){return e+" of "+(t?t.file+" from "+t.name+" version: "+t.version+", exporter version: "+t.exporter_version:"unknown")},ar=function(e,t,i,r,n){void 0===n&&(n=!1);var o=new rr.AssetContainer(e),s="importScene has failed JSON parse";try{var a=JSON.parse(t);s="";var l,c,h=rr.SceneLoader.loggingLevel===rr.SceneLoader.DETAILED_LOGGING;if(void 0!==a.lights&&null!==a.lights)for(l=0,c=a.lights.length;l<c;l++){var u=a.lights[l],d=rr.Light.Parse(u,e);d&&(o.lights.push(d),s+=0===l?"\n\tLights:":"",s+="\n\t\t"+d.toString(h))}if(void 0!==a.animations&&null!==a.animations)for(l=0,c=a.animations.length;l<c;l++){var f=a.animations[l],p=rr.Animation.Parse(f);e.animations.push(p),o.animations.push(p),s+=0===l?"\n\tAnimations:":"",s+="\n\t\t"+p.toString(h)}if(void 0!==a.materials&&null!==a.materials)for(l=0,c=a.materials.length;l<c;l++){var m=a.materials[l],_=rr.Material.Parse(m,e,i);o.materials.push(_),s+=0===l?"\n\tMaterials:":"",s+="\n\t\t"+_.toString(h)}if(void 0!==a.multiMaterials&&null!==a.multiMaterials)for(l=0,c=a.multiMaterials.length;l<c;l++){var g=a.multiMaterials[l],v=rr.Material.ParseMultiMaterial(g,e);o.multiMaterials.push(v),s+=0===l?"\n\tMultiMaterials:":"",s+="\n\t\t"+v.toString(h)}if(void 0!==a.morphTargetManagers&&null!==a.morphTargetManagers)for(var y=0,b=a.morphTargetManagers;y<b.length;y++){var T=b[y];o.morphTargetManagers.push(rr.MorphTargetManager.Parse(T,e))}if(void 0!==a.skeletons&&null!==a.skeletons)for(l=0,c=a.skeletons.length;l<c;l++){var x=a.skeletons[l],E=rr.Skeleton.Parse(x,e);o.skeletons.push(E),s+=0===l?"\n\tSkeletons:":"",s+="\n\t\t"+E.toString(h)}var A=a.geometries;if(null!=A){var P=new Array,S=A.boxes;if(null!=S)for(l=0,c=S.length;l<c;l++){var R=S[l];P.push(rr.BoxGeometry.Parse(R,e))}var M=A.spheres;if(null!=M)for(l=0,c=M.length;l<c;l++){var C=M[l];P.push(rr.SphereGeometry.Parse(C,e))}var O=A.cylinders;if(null!=O)for(l=0,c=O.length;l<c;l++){var D=O[l];P.push(rr.CylinderGeometry.Parse(D,e))}var I=A.toruses;if(null!=I)for(l=0,c=I.length;l<c;l++){var w=I[l];P.push(rr.TorusGeometry.Parse(w,e))}var L=A.grounds;if(null!=L)for(l=0,c=L.length;l<c;l++){var F=L[l];P.push(rr.GroundGeometry.Parse(F,e))}var B=A.planes;if(null!=B)for(l=0,c=B.length;l<c;l++){var N=B[l];P.push(rr.PlaneGeometry.Parse(N,e))}var V=A.torusKnots;if(null!=V)for(l=0,c=V.length;l<c;l++){var U=V[l];P.push(rr.TorusKnotGeometry.Parse(U,e))}var z=A.vertexData;if(null!=z)for(l=0,c=z.length;l<c;l++){var G=z[l];P.push(rr.Geometry.Parse(G,e,i))}P.forEach((function(e){e&&o.geometries.push(e)}))}if(void 0!==a.transformNodes&&null!==a.transformNodes)for(l=0,c=a.transformNodes.length;l<c;l++){var k=a.transformNodes[l],W=rr.TransformNode.Parse(k,e,i);o.transformNodes.push(W)}if(void 0!==a.meshes&&null!==a.meshes)for(l=0,c=a.meshes.length;l<c;l++){var H=a.meshes[l],X=rr.Mesh.Parse(H,e,i);o.meshes.push(X),s+=0===l?"\n\tMeshes:":"",s+="\n\t\t"+X.toString(h)}if(void 0!==a.cameras&&null!==a.cameras)for(l=0,c=a.cameras.length;l<c;l++){var j=a.cameras[l],Y=rr.Camera.Parse(j,e);o.cameras.push(Y),s+=0===l?"\n\tCameras:":"",s+="\n\t\t"+Y.toString(h)}if(void 0!==a.animationGroups&&null!==a.animationGroups)for(l=0,c=a.animationGroups.length;l<c;l++){var K=a.animationGroups[l],Q=rr.AnimationGroup.Parse(K,e);o.animationGroups.push(Q),s+=0===l?"\n\tAnimationGroups:":"",s+="\n\t\t"+Q.toString(h)}for(l=0,c=e.cameras.length;l<c;l++){(Y=e.cameras[l])._waitingParentId&&(Y.parent=e.getLastEntryByID(Y._waitingParentId),Y._waitingParentId=null)}for(l=0,c=e.lights.length;l<c;l++){var Z=e.lights[l];Z&&Z._waitingParentId&&(Z.parent=e.getLastEntryByID(Z._waitingParentId),Z._waitingParentId=null)}for(l=0,c=e.transformNodes.length;l<c;l++){var q=e.transformNodes[l];q._waitingParentId&&(q.parent=e.getLastEntryByID(q._waitingParentId),q._waitingParentId=null)}for(l=0,c=e.meshes.length;l<c;l++){(X=e.meshes[l])._waitingParentId&&(X.parent=e.getLastEntryByID(X._waitingParentId),X._waitingParentId=null)}for(l=0,c=e.meshes.length;l<c;l++){var J=e.meshes[l];J._waitingFreezeWorldMatrix?(J.freezeWorldMatrix(),J._waitingFreezeWorldMatrix=null):J.computeWorldMatrix(!0)}for(l=0,c=e.lights.length;l<c;l++){var $=e.lights[l];if(0<$._excludedMeshesIds.length){for(var ee=0;ee<$._excludedMeshesIds.length;ee++){var te=e.getMeshByID($._excludedMeshesIds[ee]);te&&$.excludedMeshes.push(te)}$._excludedMeshesIds=[]}if(0<$._includedOnlyMeshesIds.length){for(var ie=0;ie<$._includedOnlyMeshesIds.length;ie++){var re=e.getMeshByID($._includedOnlyMeshesIds[ie]);re&&$.includedOnlyMeshes.push(re)}$._includedOnlyMeshesIds=[]}}for(rr.AbstractScene.Parse(a,e,o,i),l=0,c=e.meshes.length;l<c;l++){(X=e.meshes[l])._waitingActions&&(rr.ActionManager.Parse(X._waitingActions,X,e),X._waitingActions=null)}void 0!==a.actions&&null!==a.actions&&rr.ActionManager.Parse(a.actions,null,e),n||o.removeAllFromScene()}catch(e){var ne=sr("loadAssets",a?a.producer:"Unknown")+s;if(!r)throw rr.Tools.Log(ne),e;r(ne,e)}finally{null!==s&&rr.SceneLoader.loggingLevel!==rr.SceneLoader.NO_LOGGING&&rr.Tools.Log(sr("loadAssets",a?a.producer:"Unknown")+(rr.SceneLoader.loggingLevel!==rr.SceneLoader.MINIMAL_LOGGING?s:""))}return o},rr.SceneLoader.RegisterPlugin({name:"babylon.js",extensions:".babylon",canDirectLoad:function(e){return-1!==e.indexOf("babylon")},importMesh:function(e,i,t,r,n,o,s,a){var l="importMesh has failed JSON parse";try{var c=JSON.parse(t);l="";var h=rr.SceneLoader.loggingLevel===rr.SceneLoader.DETAILED_LOGGING;e?Array.isArray(e)||(e=[e]):e=null;var u=new Array;if(void 0!==c.meshes&&null!==c.meshes){var d,f,p,m=[],_=[];for(d=0,f=c.meshes.length;d<f;d++){var g=c.meshes[d];if(null===e||or(g,e,u)){if(null!==e&&delete e[e.indexOf(g.name)],void 0!==g.geometryId&&null!==g.geometryId&&void 0!==c.geometries&&null!==c.geometries){var v=!1;["boxes","spheres","cylinders","toruses","grounds","planes","torusKnots","vertexData"].forEach((function(t){!0!==v&&c.geometries[t]&&Array.isArray(c.geometries[t])&&c.geometries[t].forEach((function(e){if(e.id===g.geometryId){switch(t){case"boxes":rr.BoxGeometry.Parse(e,i);break;case"spheres":rr.SphereGeometry.Parse(e,i);break;case"cylinders":rr.CylinderGeometry.Parse(e,i);break;case"toruses":rr.TorusGeometry.Parse(e,i);break;case"grounds":rr.GroundGeometry.Parse(e,i);break;case"planes":rr.PlaneGeometry.Parse(e,i);break;case"torusKnots":rr.TorusKnotGeometry.Parse(e,i);break;case"vertexData":rr.Geometry.Parse(e,i,r)}v=!0}}))})),!1===v&&rr.Tools.Warn("Geometry not found for mesh "+g.id)}if(g.materialId){var y=-1!==_.indexOf(g.materialId);if(!1===y&&void 0!==c.multiMaterials&&null!==c.multiMaterials)for(var b=0,T=c.multiMaterials.length;b<T;b++){var x=c.multiMaterials[b];if(x.id===g.materialId){for(var E=0,A=x.materials.length;E<A;E++){var P,S=x.materials[E];_.push(S),(P=nr(S,c,i,r))&&(l+="\n\tMaterial "+P.toString(h))}_.push(x.id);var R=rr.Material.ParseMultiMaterial(x,i);R&&(y=!0,l+="\n\tMulti-Material "+R.toString(h));break}}!1===y&&(_.push(g.materialId),(P=nr(g.materialId,c,i,r))?l+="\n\tMaterial "+P.toString(h):rr.Tools.Warn("Material not found for mesh "+g.id))}if(-1<g.skeletonId&&void 0!==c.skeletons&&null!==c.skeletons&&!1==-1<m.indexOf(g.skeletonId))for(var M=0,C=c.skeletons.length;M<C;M++){var O=c.skeletons[M];if(O.id===g.skeletonId){var D=rr.Skeleton.Parse(O,i);s.push(D),m.push(O.id),l+="\n\tSkeleton "+D.toString(h)}}if(void 0!==c.morphTargetManagers&&null!==c.morphTargetManagers)for(var I=0,w=c.morphTargetManagers;I<w.length;I++){var L=w[I];rr.MorphTargetManager.Parse(L,i)}var F=rr.Mesh.Parse(g,i,r);n.push(F),l+="\n\tMesh "+F.toString(h)}}for(d=0,f=i.meshes.length;d<f;d++)(p=i.meshes[d])._waitingParentId&&(p.parent=i.getLastEntryByID(p._waitingParentId),p._waitingParentId=null);for(d=0,f=i.meshes.length;d<f;d++)(p=i.meshes[d])._waitingFreezeWorldMatrix?(p.freezeWorldMatrix(),p._waitingFreezeWorldMatrix=null):p.computeWorldMatrix(!0)}if(void 0!==c.particleSystems&&null!==c.particleSystems){var B=rr.AbstractScene.GetIndividualParser(rr.SceneComponentConstants.NAME_PARTICLESYSTEM);if(B)for(d=0,f=c.particleSystems.length;d<f;d++){var N=c.particleSystems[d];-1!==u.indexOf(N.emitterId)&&o.push(B(N,i,r))}}return!0}catch(e){var V=sr("importMesh",c?c.producer:"Unknown")+l;if(!a)throw rr.Tools.Log(V),e;a(V,e)}finally{null!==l&&rr.SceneLoader.loggingLevel!==rr.SceneLoader.NO_LOGGING&&rr.Tools.Log(sr("importMesh",c?c.producer:"Unknown")+(rr.SceneLoader.loggingLevel!==rr.SceneLoader.MINIMAL_LOGGING?l:""))}return!1},load:function(e,t,i,r){var n="importScene has failed JSON parse";try{var o=JSON.parse(t);if(n="",void 0!==o.useDelayedTextureLoading&&null!==o.useDelayedTextureLoading&&(e.useDelayedTextureLoading=o.useDelayedTextureLoading&&!rr.SceneLoader.ForceFullSceneLoadingForIncremental),void 0!==o.autoClear&&null!==o.autoClear&&(e.autoClear=o.autoClear),void 0!==o.clearColor&&null!==o.clearColor&&(e.clearColor=rr.Color4.FromArray(o.clearColor)),void 0!==o.ambientColor&&null!==o.ambientColor&&(e.ambientColor=rr.Color3.FromArray(o.ambientColor)),void 0!==o.gravity&&null!==o.gravity&&(e.gravity=rr.Vector3.FromArray(o.gravity)),o.fogMode&&0!==o.fogMode)switch(e.fogMode=o.fogMode,e.fogColor=rr.Color3.FromArray(o.fogColor),e.fogStart=o.fogStart,e.fogEnd=o.fogEnd,e.fogDensity=o.fogDensity,n+="\tFog mode for scene: ",e.fogMode){case 1:n+="exp\n";break;case 2:n+="exp2\n";break;case 3:n+="linear\n"}if(o.physicsEnabled){var s;"cannon"===o.physicsEngine?s=new rr.CannonJSPlugin:"oimo"===o.physicsEngine&&(s=new rr.OimoJSPlugin),n="\tPhysics engine "+(o.physicsEngine?o.physicsEngine:"oimo")+" enabled\n";var a=o.physicsGravity?rr.Vector3.FromArray(o.physicsGravity):null;e.enablePhysics(a,s)}if(void 0!==o.metadata&&null!==o.metadata&&(e.metadata=o.metadata),void 0!==o.collisionsEnabled&&null!==o.collisionsEnabled&&(e.collisionsEnabled=o.collisionsEnabled),e.workerCollisions=!!o.workerCollisions,!ar(e,t,i,r,!0))return!1;if(o.autoAnimate&&e.beginAnimation(e,o.autoAnimateFrom,o.autoAnimateTo,o.autoAnimateLoop,o.autoAnimateSpeed||1),void 0!==o.activeCameraID&&null!==o.activeCameraID&&e.setActiveCameraByID(o.activeCameraID),void 0!==o.environmentTexture&&null!==o.environmentTexture){if(o.environmentTextureType&&"BABYLON.HDRCubeTexture"===o.environmentTextureType){var l=o.environmentTextureSize?o.environmentTextureSize:128,c=new rr.HDRCubeTexture(i+o.environmentTexture,e,l);o.environmentTextureRotationY&&(c.rotationY=o.environmentTextureRotationY),e.environmentTexture=c}else{var h=rr.CubeTexture.CreateFromPrefilteredData(i+o.environmentTexture,e);o.environmentTextureRotationY&&(h.rotationY=o.environmentTextureRotationY),e.environmentTexture=h}if(!0===o.createDefaultSkybox){var u=void 0!==e.activeCamera&&null!==e.activeCamera?(e.activeCamera.maxZ-e.activeCamera.minZ)/2:1e3,d=o.skyboxBlurLevel||0;e.createDefaultSkybox(void 0,!0,u,d)}}return!0}catch(e){var f=sr("importScene",o?o.producer:"Unknown")+n;if(!r)throw rr.Tools.Log(f),e;r(f,e)}finally{null!==n&&rr.SceneLoader.loggingLevel!==rr.SceneLoader.NO_LOGGING&&rr.Tools.Log(sr("importScene",o?o.producer:"Unknown")+(rr.SceneLoader.loggingLevel!==rr.SceneLoader.MINIMAL_LOGGING?n:""))}return!1},loadAssetContainer:function(e,t,i,r){return ar(e,t,i,r)}}),lr=$a||($a={}),cr=(function(){function n(e,t,i,r,n,o,s,a,l){this.onProcessFileCallback=function(){return!0},this._engine=e,this._currentScene=t,this._sceneLoadedCallback=i,this._progressCallback=r,this._additionalRenderLoopLogicCallback=n,this._textureLoadingCallback=o,this._startingProcessingFilesCallback=s,this._onReloadCallback=a,this._errorCallback=l}return n.prototype.monitorElementForDragNDrop=function(e){var t=this;e&&(this._elementToMonitor=e,this._dragEnterHandler=function(e){t.drag(e)},this._dragOverHandler=function(e){t.drag(e)},this._dropHandler=function(e){t.drop(e)},this._elementToMonitor.addEventListener("dragenter",this._dragEnterHandler,!1),this._elementToMonitor.addEventListener("dragover",this._dragOverHandler,!1),this._elementToMonitor.addEventListener("drop",this._dropHandler,!1))},n.prototype.dispose=function(){this._elementToMonitor&&(this._elementToMonitor.removeEventListener("dragenter",this._dragEnterHandler),this._elementToMonitor.removeEventListener("dragover",this._dragOverHandler),this._elementToMonitor.removeEventListener("drop",this._dropHandler))},n.prototype.renderFunction=function(){if(this._additionalRenderLoopLogicCallback&&this._additionalRenderLoopLogicCallback(),this._currentScene){if(this._textureLoadingCallback){var e=this._currentScene.getWaitingItemsCount();0<e&&this._textureLoadingCallback(e)}this._currentScene.render()}},n.prototype.drag=function(e){e.stopPropagation(),e.preventDefault()},n.prototype.drop=function(e){e.stopPropagation(),e.preventDefault(),this.loadFiles(e)},n.prototype._traverseFolder=function(e,n,o,s){var a=this,t=e.createReader(),l=e.fullPath.replace(/^\//,"").replace(/(.+?)\/?$/,"$1/");t.readEntries((function(e){o.count+=e.length;for(var t=0,i=e;t<i.length;t++){var r=i[t];r.isFile?r.file((function(e){e.correctName=l+e.name,n.push(e),0==--o.count&&s()})):r.isDirectory&&a._traverseFolder(r,n,o,s)}--o.count&&s()}))},n.prototype._processFiles=function(e){for(var t=0;t<e.length;t++){var i=e[t].correctName.toLowerCase(),r=i.split(".").pop();this.onProcessFileCallback(e[t],i,r)&&("babylon"!==r&&"stl"!==r&&"obj"!==r&&"gltf"!==r&&"glb"!==r||-1!==i.indexOf(".binary.babylon")||-1!==i.indexOf(".incremental.babylon")||(this._sceneFileToLoad=e[t]),n.FilesToLoad[i]=e[t])}},n.prototype.loadFiles=function(e){var t=this;if(e&&e.dataTransfer&&e.dataTransfer.files&&(this._filesToLoad=e.dataTransfer.files),e&&e.target&&e.target.files&&(this._filesToLoad=e.target.files),this._filesToLoad&&0!==this._filesToLoad.length&&(this._startingProcessingFilesCallback&&this._startingProcessingFilesCallback(this._filesToLoad),this._filesToLoad&&0<this._filesToLoad.length)){for(var i=new Array,r=[],n=e.dataTransfer?e.dataTransfer.items:null,o=0;o<this._filesToLoad.length;o++){var s=this._filesToLoad[o],a=s.name.toLowerCase(),l=void 0;if(s.correctName=a,n){var c=n[o];c.getAsEntry?l=c.getAsEntry():c.webkitGetAsEntry&&(l=c.webkitGetAsEntry())}l&&l.isDirectory?r.push(l):i.push(s)}if(0===r.length)this._processFiles(i),this._processReload();else for(var h={count:r.length},u=0,d=r;u<d.length;u++){var f=d[u];this._traverseFolder(f,i,h,(function(){t._processFiles(i),0===h.count&&t._processReload()}))}}},n.prototype._processReload=function(){this._onReloadCallback?this._onReloadCallback(this._sceneFileToLoad):this.reload()},n.prototype.reload=function(){var t=this;this._sceneFileToLoad?(this._currentScene&&(0<lr.Tools.errorsCount&&lr.Tools.ClearLogCache(),this._engine.stopRenderLoop()),lr.SceneLoader.LoadAsync("file:",this._sceneFileToLoad.name,this._engine,(function(e){t._progressCallback&&t._progressCallback(e)})).then((function(e){t._currentScene&&t._currentScene.dispose(),t._currentScene=e,t._sceneLoadedCallback&&t._sceneLoadedCallback(t._sceneFileToLoad,t._currentScene),t._currentScene.executeWhenReady((function(){t._engine.runRenderLoop((function(){t.renderFunction()}))}))})).catch((function(e){t._errorCallback&&t._errorCallback(t._sceneFileToLoad,t._currentScene,e.message)}))):lr.Tools.Error("Please provide a valid .babylon file.")},n.FilesToLoad={},n})(),lr.FilesInput=cr,hr=$a||($a={}),ur=(function(){function n(){}return n.EnableFor=function(t){t._tags=t._tags||{},t.hasTags=function(){return n.HasTags(t)},t.addTags=function(e){return n.AddTagsTo(t,e)},t.removeTags=function(e){return n.RemoveTagsFrom(t,e)},t.matchesTagsQuery=function(e){return n.MatchesQuery(t,e)}},n.DisableFor=function(e){delete e._tags,delete e.hasTags,delete e.addTags,delete e.removeTags,delete e.matchesTagsQuery},n.HasTags=function(e){return!!e._tags&&!hr.Tools.IsEmpty(e._tags)},n.GetTags=function(e,t){if(void 0===t&&(t=!0),!e._tags)return null;if(t){var i=[];for(var r in e._tags)e._tags.hasOwnProperty(r)&&!0===e._tags[r]&&i.push(r);return i.join(" ")}return e._tags},n.AddTagsTo=function(r,e){e&&("string"==typeof e&&e.split(" ").forEach((function(e,t,i){n._AddTagTo(r,e)})))},n._AddTagTo=function(e,t){""!==(t=t.trim())&&"true"!==t&&"false"!==t&&(t.match(/[\s]/)||t.match(/^([!]|([|]|[&]){2})/)||(n.EnableFor(e),e._tags[t]=!0))},n.RemoveTagsFrom=function(e,t){if(n.HasTags(e)){var i=t.split(" ");for(var r in i)n._RemoveTagFrom(e,i[r])}},n._RemoveTagFrom=function(e,t){delete e._tags[t]},n.MatchesQuery=function(t,e){return void 0===e||(""===e?n.HasTags(t):hr.AndOrNotEvaluator.Eval(e,(function(e){return n.HasTags(t)&&t._tags[e]})))},n})(),hr.Tags=ur,dr=$a||($a={}),fr=(function(){function c(){}return c.Eval=function(e,t){return"true"===(e=e.match(/\([^\(\)]*\)/g)?e.replace(/\([^\(\)]*\)/g,(function(e){return e=e.slice(1,e.length-1),c._HandleParenthesisContent(e,t)})):c._HandleParenthesisContent(e,t))||"false"!==e&&c.Eval(e,t)},c._HandleParenthesisContent=function(e,t){var i;t=t||function(e){return"true"===e};var r=e.split("||");for(var n in r)if(r.hasOwnProperty(n)){var o=c._SimplifyNegation(r[n].trim()),s=o.split("&&");if(1<s.length)for(var a=0;a<s.length;++a){var l=c._SimplifyNegation(s[a].trim());if(!(i="true"!==l&&"false"!==l?"!"===l[0]?!t(l.substring(1)):t(l):"true"===l)){o="false";break}}if(i||"true"===o){i=!0;break}i="true"!==o&&"false"!==o?"!"===o[0]?!t(o.substring(1)):t(o):"true"===o}return i?"true":"false"},c._SimplifyNegation=function(e){return"!true"===(e=(e=e.replace(/^[\s!]+/,(function(e){return(e=e.replace(/[\s]/g,(function(){return""}))).length%2?"!":""}))).trim())?e="false":"!false"===e&&(e="true"),e},c})(),dr.AndOrNotEvaluator=fr,pr=$a||($a={}),mr=(function(){function c(e,t,i){void 0===i&&(i=!1);var r=this;this.idbFactory=window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,this.callbackManifestChecked=t,this.currentSceneUrl=c._ReturnFullUrlLocation(e),this.db=null,this._enableSceneOffline=!1,this._enableTexturesOffline=!1,this.manifestVersionFound=0,this.mustUpdateRessources=!1,this.hasReachedQuota=!1,c.IDBStorageEnabled?i?(this._enableSceneOffline=!0,this._enableTexturesOffline=!0,this.manifestVersionFound=1,pr.Tools.SetImmediate((function(){r.callbackManifestChecked(!0)}))):this._checkManifestFile():this.callbackManifestChecked(!0)}return Object.defineProperty(c.prototype,"enableSceneOffline",{get:function(){return this._enableSceneOffline},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"enableTexturesOffline",{get:function(){return this._enableTexturesOffline},enumerable:!0,configurable:!0}),c.prototype._checkManifestFile=function(){var i=this,r=function(){i._enableSceneOffline=!1,i._enableTexturesOffline=!1,i.callbackManifestChecked(!1)},n=!1,e=this.currentSceneUrl+".manifest",o=new XMLHttpRequest;navigator.onLine&&(n=!0,e=e+(null==e.match(/\?/)?"?":"&")+Date.now()),o.open("GET",e,!0),o.addEventListener("load",(function(){if(200===o.status||pr.Tools.ValidateXHRData(o,1))try{var e=JSON.parse(o.response);i._enableSceneOffline=e.enableSceneOffline,i._enableTexturesOffline=e.enableTexturesOffline,e.version&&!isNaN(parseInt(e.version))&&(i.manifestVersionFound=e.version),i.callbackManifestChecked&&i.callbackManifestChecked(!0)}catch(e){r()}else r()}),!1),o.addEventListener("error",(function(e){if(n){n=!1;var t=i.currentSceneUrl+".manifest";o.open("GET",t,!0),o.send()}else r()}),!1);try{o.send()}catch(e){pr.Tools.Error("Error on XHR send request."),this.callbackManifestChecked(!1)}},c.prototype.openAsync=function(t,e){var i=this,r=function(){i.isSupported=!1,e&&e()};if(this.idbFactory&&(this._enableSceneOffline||this._enableTexturesOffline))if(this.db)t&&t();else{this.hasReachedQuota=!1,this.isSupported=!0;var n=this.idbFactory.open("babylonjs",1);n.onerror=function(e){r()},n.onblocked=function(e){pr.Tools.Error("IDB request blocked. Please reload the page."),r()},n.onsuccess=function(e){i.db=n.result,t()},n.onupgradeneeded=function(e){if(i.db=e.target.result,i.db)try{i.db.createObjectStore("scenes",{keyPath:"sceneUrl"}),i.db.createObjectStore("versions",{keyPath:"sceneUrl"}),i.db.createObjectStore("textures",{keyPath:"textureUrl"})}catch(e){pr.Tools.Error("Error while creating object stores. Exception: "+e.message),r()}}}else this.isSupported=!1,e&&e()},c.prototype.loadImageFromDB=function(e,t){var i=this,r=c._ReturnFullUrlLocation(e),n=function(){i.hasReachedQuota||null===i.db?t.src=e:i._saveImageIntoDBAsync(r,t)};this.mustUpdateRessources?n():this._loadImageFromDBAsync(r,t,n)},c.prototype._loadImageFromDBAsync=function(r,n,o){if(this.isSupported&&null!==this.db){var s,e=this.db.transaction(["textures"]);e.onabort=function(e){n.src=r},e.oncomplete=function(e){var t;if(s){var i=window.URL||window.webkitURL;t=i.createObjectURL(s.data),n.onerror=function(){pr.Tools.Error("Error loading image from blob URL: "+t+" switching back to web url: "+r),n.src=r},n.src=t}else o()};var t=e.objectStore("textures").get(r);t.onsuccess=function(e){s=e.target.result},t.onerror=function(e){pr.Tools.Error("Error loading texture "+r+" from DB."),n.src=r}}else pr.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),n.src=r},c.prototype._saveImageIntoDBAsync=function(r,n){var o=this;if(this.isSupported){var s=function(){var t;if(a){var i=window.URL||window.webkitURL;try{t=i.createObjectURL(a)}catch(e){t=i.createObjectURL(a)}}t&&(n.src=t)};if(c.IsUASupportingBlobStorage){var a,l=new XMLHttpRequest;l.open("GET",r,!0),l.responseType="blob",l.addEventListener("load",(function(){if(200===l.status&&o.db){a=l.response;var e=o.db.transaction(["textures"],"readwrite");e.onabort=function(e){try{var t=(e.srcElement||e.target).error;t&&"QuotaExceededError"===t.name&&(o.hasReachedQuota=!0)}catch(e){}s()},e.oncomplete=function(e){s()};var t={textureUrl:r,data:a};try{var i=e.objectStore("textures").put(t);i.onsuccess=function(e){},i.onerror=function(e){s()}}catch(e){25===e.code&&(c.IsUASupportingBlobStorage=!1),n.src=r}}else n.src=r}),!1),l.addEventListener("error",(function(e){pr.Tools.Error("Error in XHR request in BABYLON.Database."),n.src=r}),!1),l.send()}else n.src=r}else pr.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),n.src=r},c.prototype._checkVersionFromDB=function(e,t){var i=this;this._loadVersionFromDBAsync(e,t,(function(){i._saveVersionIntoDBAsync(e,t)}))},c.prototype._loadVersionFromDBAsync=function(t,i,r){var n,o=this;if(this.isSupported&&this.db)try{var e=this.db.transaction(["versions"]);e.oncomplete=function(e){n?o.manifestVersionFound!==n.data?(o.mustUpdateRessources=!0,r()):i(n.data):(o.mustUpdateRessources=!0,r())},e.onabort=function(e){i(-1)};var s=e.objectStore("versions").get(t);s.onsuccess=function(e){n=e.target.result},s.onerror=function(e){pr.Tools.Error("Error loading version for scene "+t+" from DB."),i(-1)}}catch(e){pr.Tools.Error("Error while accessing 'versions' object store (READ OP). Exception: "+e.message),i(-1)}else pr.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i(-1)},c.prototype._saveVersionIntoDBAsync=function(e,i){var r=this;if(this.isSupported&&!this.hasReachedQuota&&this.db)try{var t=this.db.transaction(["versions"],"readwrite");t.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(r.hasReachedQuota=!0)}catch(e){}i(-1)},t.oncomplete=function(e){i(r.manifestVersionFound)};var n={sceneUrl:e,data:this.manifestVersionFound},o=t.objectStore("versions").put(n);o.onsuccess=function(e){},o.onerror=function(e){pr.Tools.Error("Error in DB add version request in BABYLON.Database.")}}catch(e){pr.Tools.Error("Error while accessing 'versions' object store (WRITE OP). Exception: "+e.message),i(-1)}else i(-1)},c.prototype.loadFileFromDB=function(e,t,i,r,n){var o=this,s=c._ReturnFullUrlLocation(e),a=function(){o._saveFileIntoDBAsync(s,t,i,n,r)};this._checkVersionFromDB(s,(function(e){-1!==e?o.mustUpdateRessources?o._saveFileIntoDBAsync(s,t,i,n,r):o._loadFileFromDBAsync(s,t,a,n):r&&r()}))},c.prototype._loadFileFromDBAsync=function(t,i,r,e){if(this.isSupported&&this.db){var n,o;n=-1!==t.indexOf(".babylon")?"scenes":"textures";var s=this.db.transaction([n]);s.oncomplete=function(e){o?i(o.data):r()},s.onabort=function(e){r()};var a=s.objectStore(n).get(t);a.onsuccess=function(e){o=e.target.result},a.onerror=function(e){pr.Tools.Error("Error loading file "+t+" from DB."),r()}}else pr.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),i()},c.prototype._saveFileIntoDBAsync=function(r,n,e,o,s){var a=this;if(this.isSupported){var l;l=-1!==r.indexOf(".babylon")?"scenes":"textures";var c,h=new XMLHttpRequest;h.open("GET",r+"?"+Date.now(),!0),o&&(h.responseType="arraybuffer"),e&&(h.onprogress=e),h.addEventListener("load",(function(){if(200===h.status||h.status<400&&pr.Tools.ValidateXHRData(h,o?6:1))if(c=o?h.response:h.responseText,!a.hasReachedQuota&&a.db){var e,t=a.db.transaction([l],"readwrite");t.onabort=function(e){try{var t=e.srcElement.error;t&&"QuotaExceededError"===t.name&&(a.hasReachedQuota=!0)}catch(e){}n(c)},t.oncomplete=function(e){n(c)},e="scenes"===l?{sceneUrl:r,data:c,version:a.manifestVersionFound}:{textureUrl:r,data:c};try{var i=t.objectStore(l).put(e);i.onsuccess=function(e){},i.onerror=function(e){pr.Tools.Error("Error in DB add file request in BABYLON.Database.")}}catch(e){n(c)}}else n(c);else 400<=h.status&&s?s(h):n()}),!1),h.addEventListener("error",(function(e){pr.Tools.Error("error on XHR request."),n()}),!1),h.send()}else pr.Tools.Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open."),n()},c.IsUASupportingBlobStorage=!0,c.IDBStorageEnabled=!0,c._ParseURL=function(e){var t=(document.createElement("a").href=e).substring(0,e.lastIndexOf("#")),i=e.substring(t.lastIndexOf("/")+1,e.length);return e.substring(0,e.indexOf(i,0))},c._ReturnFullUrlLocation=function(e){return-1===e.indexOf("http:/")&&-1===e.indexOf("https:/")?c._ParseURL(window.location.href)+e:e},c})(),pr.Database=mr,_r=$a||($a={}),gr=(function(){function i(){this._isEnabled=!0,this.leftColor=_r.Color3.White(),this.rightColor=_r.Color3.Black(),this.bias=0,this.power=1}return Object.defineProperty(i.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,_r.Engine.MarkAllMaterialsAsDirty(_r.Material.FresnelDirtyFlag|_r.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),i.prototype.clone=function(){var e=new i;return _r.Tools.DeepCopy(this,e),e},i.prototype.serialize=function(){var e={};return e.isEnabled=this.isEnabled,e.leftColor=this.leftColor.asArray(),e.rightColor=this.rightColor.asArray(),e.bias=this.bias,e.power=this.power,e},i.Parse=function(e){var t=new i;return t.isEnabled=e.isEnabled,t.leftColor=_r.Color3.FromArray(e.leftColor),t.rightColor=_r.Color3.FromArray(e.rightColor),t.bias=e.bias,t.power=e.power||1,t},i})(),_r.FresnelParameters=gr,vr=$a||($a={}),yr=(function(n){function s(e,t){var i=n.call(this,e,t,!0)||this;return t.multiMaterials.push(i),i.subMaterials=new Array,i.storeEffectOnSubMeshes=!0,i}return T(s,n),Object.defineProperty(s.prototype,"subMaterials",{get:function(){return this._subMaterials},set:function(e){this._subMaterials=e,this._hookArray(e)},enumerable:!0,configurable:!0}),s.prototype._hookArray=function(r){var n=this,o=r.push;r.push=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var i=o.apply(r,e);return n._markAllSubMeshesAsTexturesDirty(),i};var s=r.splice;r.splice=function(e,t){var i=s.apply(r,[e,t]);return n._markAllSubMeshesAsTexturesDirty(),i}},s.prototype.getSubMaterial=function(e){return e<0||e>=this.subMaterials.length?this.getScene().defaultMaterial:this.subMaterials[e]},s.prototype.getActiveTextures=function(){var e;return(e=n.prototype.getActiveTextures.call(this)).concat.apply(e,this.subMaterials.map((function(e){return e?e.getActiveTextures():[]})))},s.prototype.getClassName=function(){return"MultiMaterial"},s.prototype.isReadyForSubMesh=function(e,t,i){for(var r=0;r<this.subMaterials.length;r++){var n=this.subMaterials[r];if(n){if(n.storeEffectOnSubMeshes){if(!n.isReadyForSubMesh(e,t,i))return!1;continue}if(!n.isReady(e))return!1}}return!0},s.prototype.clone=function(e,t){for(var i=new s(e,this.getScene()),r=0;r<this.subMaterials.length;r++){var n=null,o=this.subMaterials[r];n=t&&o?o.clone(e+"-"+o.name):this.subMaterials[r],i.subMaterials.push(n)}return i},s.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,vr.Tags&&(e.tags=vr.Tags.GetTags(this)),e.materials=[];for(var t=0;t<this.subMaterials.length;t++){var i=this.subMaterials[t];i?e.materials.push(i.id):e.materials.push(null)}return e},s.prototype.dispose=function(e,t){var i=this.getScene();if(i){var r=i.multiMaterials.indexOf(this);0<=r&&i.multiMaterials.splice(r,1),n.prototype.dispose.call(this,e,t)}},s})(vr.Material),vr.MultiMaterial=yr,br=$a||($a={}),Tr=(function(){function e(){this.touchAngularSensibility=2e5,this.touchMoveSensibility=250,this._offsetX=null,this._offsetY=null,this._pointerPressed=new Array}return e.prototype.attachControl=function(e,n){var o=this,s=null;void 0===this._pointerInput&&(this._onLostFocus=function(e){o._offsetX=null,o._offsetY=null},this._pointerInput=function(e,t){var i=e.event;if("mouse"!==i.pointerType)if(e.type===br.PointerEventTypes.POINTERDOWN){if(n||i.preventDefault(),o._pointerPressed.push(i.pointerId),1!==o._pointerPressed.length)return;s={x:i.clientX,y:i.clientY}}else if(e.type===br.PointerEventTypes.POINTERUP){if(n||i.preventDefault(),-1===(r=o._pointerPressed.indexOf(i.pointerId)))return;if(o._pointerPressed.splice(r,1),0!=r)return;s=null,o._offsetX=null,o._offsetY=null}else if(e.type===br.PointerEventTypes.POINTERMOVE){if(n||i.preventDefault(),!s)return;var r;if(0!=(r=o._pointerPressed.indexOf(i.pointerId)))return;o._offsetX=i.clientX-s.x,o._offsetY=-(i.clientY-s.y)}}),this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,br.PointerEventTypes.POINTERDOWN|br.PointerEventTypes.POINTERUP|br.PointerEventTypes.POINTERMOVE),this._onLostFocus&&e.addEventListener("blur",this._onLostFocus)},e.prototype.detachControl=function(e){this._pointerInput&&e&&(this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null),this._onLostFocus&&(e.removeEventListener("blur",this._onLostFocus),this._onLostFocus=null),this._pointerPressed=[],this._offsetX=null,this._offsetY=null)},e.prototype.checkInputs=function(){if(this._offsetX&&this._offsetY){var e=this.camera;if(e.cameraRotation.y+=this._offsetX/this.touchAngularSensibility,1<this._pointerPressed.length)e.cameraRotation.x+=-this._offsetY/this.touchAngularSensibility;else{var t=e._computeLocalCameraSpeed(),i=new br.Vector3(0,0,t*this._offsetY/this.touchMoveSensibility);br.Matrix.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,e._cameraRotationMatrix),e.cameraDirection.addInPlace(br.Vector3.TransformCoordinates(i,e._cameraRotationMatrix))}}},e.prototype.getClassName=function(){return"FreeCameraTouchInput"},e.prototype.getSimpleName=function(){return"touch"},b([br.serialize()],e.prototype,"touchAngularSensibility",void 0),b([br.serialize()],e.prototype,"touchMoveSensibility",void 0),e})(),br.FreeCameraTouchInput=Tr,br.CameraInputTypes.FreeCameraTouchInput=Tr,(function(i){i.Node.AddNodeConstructor("TouchCamera",(function(e,t){return function(){return new r(e,i.Vector3.Zero(),t)}}));var r=(function(n){function e(e,t,i){var r=n.call(this,e,t,i)||this;return r.inputs.addTouch(),r._setupInputs(),r}return T(e,n),Object.defineProperty(e.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(e.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}),e.prototype.getClassName=function(){return"TouchCamera"},e.prototype._setupInputs=function(){var e=this.inputs.attached.mouse;e&&(e.touchEnabled=!1)},e})(i.FreeCamera);i.TouchCamera=r})($a||($a={})),xr=$a||($a={}),Er=(function(h){function i(e,t,i,r,n,o,s){void 0===n&&(n=null),void 0===o&&(o=!0),void 0===s&&(s=!1);var a=h.call(this,null,r,!o)||this;a.isCube=s,a.isEnabled=!0,a.autoClear=!0,a.onGeneratedObservable=new xr.Observable,a._textures={},a._currentRefreshId=-1,a._refreshRate=1,a._vertexBuffers={},a._uniforms=new Array,a._samplers=new Array,a._floats={},a._ints={},a._floatsArrays={},a._colors3={},a._colors4={},a._vectors2={},a._vectors3={},a._matrices={},a._fallbackTextureUsed=!1,a._cachedDefines="",a._contentUpdateId=-1;var l=(r=a.getScene())._getComponent(xr.SceneComponentConstants.NAME_PROCEDURALTEXTURE);l||(l=new xr.ProceduralTextureSceneComponent(r),r._addComponent(l)),r.proceduralTextures.push(a),a._engine=r.getEngine(),a.name=e,a.isRenderTarget=!0,a._size=t,a._generateMipMaps=o,a.setFragment(i),a._fallbackTexture=n,s?(a._texture=a._engine.createRenderTargetCubeTexture(t,{generateMipMaps:o,generateDepthBuffer:!1,generateStencilBuffer:!1}),a.setFloat("face",0)):a._texture=a._engine.createRenderTargetTexture(t,{generateMipMaps:o,generateDepthBuffer:!1,generateStencilBuffer:!1});var c=[];return c.push(1,1),c.push(-1,1),c.push(-1,-1),c.push(1,-1),a._vertexBuffers[xr.VertexBuffer.PositionKind]=new xr.VertexBuffer(a._engine,c,xr.VertexBuffer.PositionKind,!1,!1,2),a._createIndexBuffer(),a}return T(i,h),i.prototype.getContent=function(){return this._contentData&&this._currentRefreshId==this._contentUpdateId||(this._contentData=this.readPixels(0,0,this._contentData),this._contentUpdateId=this._currentRefreshId),this._contentData},i.prototype._createIndexBuffer=function(){var e=this._engine,t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},i.prototype._rebuild=function(){var e=this._vertexBuffers[xr.VertexBuffer.PositionKind];e&&e._rebuild(),this._createIndexBuffer(),this.refreshRate===xr.RenderTargetTexture.REFRESHRATE_RENDER_ONCE&&(this.refreshRate=xr.RenderTargetTexture.REFRESHRATE_RENDER_ONCE)},i.prototype.reset=function(){void 0!==this._effect&&this._engine._releaseEffect(this._effect)},i.prototype._getDefines=function(){return""},i.prototype.isReady=function(){var e,t=this,i=this._engine;if(!this._fragment)return!1;if(this._fallbackTextureUsed)return!0;var r=this._getDefines();return!(!this._effect||r!==this._cachedDefines||!this._effect.isReady())||(e=void 0!==this._fragment.fragmentElement?{vertex:"procedural",fragmentElement:this._fragment.fragmentElement}:{vertex:"procedural",fragment:this._fragment},this._cachedDefines=r,this._effect=i.createEffect(e,[xr.VertexBuffer.PositionKind],this._uniforms,this._samplers,r,void 0,void 0,(function(){t.releaseInternalTexture(),t._fallbackTexture&&(t._texture=t._fallbackTexture._texture,t._texture&&t._texture.incrementReferences()),t._fallbackTextureUsed=!0})),this._effect.isReady())},i.prototype.resetRefreshCounter=function(){this._currentRefreshId=-1},i.prototype.setFragment=function(e){this._fragment=e},Object.defineProperty(i.prototype,"refreshRate",{get:function(){return this._refreshRate},set:function(e){this._refreshRate=e,this.resetRefreshCounter()},enumerable:!0,configurable:!0}),i.prototype._shouldRender=function(){return this.isEnabled&&this.isReady()&&this._texture?!this._fallbackTextureUsed&&(-1===this._currentRefreshId?(this._currentRefreshId=1,!0):this.refreshRate===this._currentRefreshId?(this._currentRefreshId=1,!0):(this._currentRefreshId++,!1)):(this._texture&&(this._texture.isReady=!1),!1)},i.prototype.getRenderSize=function(){return this._size},i.prototype.resize=function(e,t){this._fallbackTextureUsed||(this.releaseInternalTexture(),this._texture=this._engine.createRenderTargetTexture(e,t),this._size=e,this._generateMipMaps=t)},i.prototype._checkUniform=function(e){-1===this._uniforms.indexOf(e)&&this._uniforms.push(e)},i.prototype.setTexture=function(e,t){return-1===this._samplers.indexOf(e)&&this._samplers.push(e),this._textures[e]=t,this},i.prototype.setFloat=function(e,t){return this._checkUniform(e),this._floats[e]=t,this},i.prototype.setInt=function(e,t){return this._checkUniform(e),this._ints[e]=t,this},i.prototype.setFloats=function(e,t){return this._checkUniform(e),this._floatsArrays[e]=t,this},i.prototype.setColor3=function(e,t){return this._checkUniform(e),this._colors3[e]=t,this},i.prototype.setColor4=function(e,t){return this._checkUniform(e),this._colors4[e]=t,this},i.prototype.setVector2=function(e,t){return this._checkUniform(e),this._vectors2[e]=t,this},i.prototype.setVector3=function(e,t){return this._checkUniform(e),this._vectors3[e]=t,this},i.prototype.setMatrix=function(e,t){return this._checkUniform(e),this._matrices[e]=t,this},i.prototype.render=function(e){var t=this.getScene();if(t){var i=this._engine;for(var r in i.enableEffect(this._effect),i.setState(!1),this._textures)this._effect.setTexture(r,this._textures[r]);for(r in this._ints)this._effect.setInt(r,this._ints[r]);for(r in this._floats)this._effect.setFloat(r,this._floats[r]);for(r in this._floatsArrays)this._effect.setArray(r,this._floatsArrays[r]);for(r in this._colors3)this._effect.setColor3(r,this._colors3[r]);for(r in this._colors4){var n=this._colors4[r];this._effect.setFloat4(r,n.r,n.g,n.b,n.a)}for(r in this._vectors2)this._effect.setVector2(r,this._vectors2[r]);for(r in this._vectors3)this._effect.setVector3(r,this._vectors3[r]);for(r in this._matrices)this._effect.setMatrix(r,this._matrices[r]);if(this._texture){if(this.isCube)for(var o=0;o<6;o++)i.bindFramebuffer(this._texture,o,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this._effect.setFloat("face",o),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(xr.Material.TriangleFillMode,0,6),5===o&&i.generateMipMapsForCubemap(this._texture);else i.bindFramebuffer(this._texture,0,void 0,void 0,!0),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect),this.autoClear&&i.clear(t.clearColor,!0,!1,!1),i.drawElementsType(xr.Material.TriangleFillMode,0,6);i.unBindFramebuffer(this._texture,this.isCube),this.onGenerated&&this.onGenerated(),this.onGeneratedObservable.notifyObservers(this)}}},i.prototype.clone=function(){var e=this.getSize(),t=new i(this.name,e.width,this._fragment,this.getScene(),this._fallbackTexture,this._generateMipMaps);return t.hasAlpha=this.hasAlpha,t.level=this.level,t.coordinatesMode=this.coordinatesMode,t},i.prototype.dispose=function(){var e=this.getScene();if(e){var t=e.proceduralTextures.indexOf(this);0<=t&&e.proceduralTextures.splice(t,1);var i=this._vertexBuffers[xr.VertexBuffer.PositionKind];i&&(i.dispose(),this._vertexBuffers[xr.VertexBuffer.PositionKind]=null),this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer)&&(this._indexBuffer=null),h.prototype.dispose.call(this)}},b([xr.serialize()],i.prototype,"isEnabled",void 0),b([xr.serialize()],i.prototype,"autoClear",void 0),b([xr.serialize()],i.prototype,"_generateMipMaps",void 0),b([xr.serialize()],i.prototype,"_size",void 0),b([xr.serialize()],i.prototype,"refreshRate",null),i})(xr.Texture),xr.ProceduralTexture=Er,Ar=$a||($a={}),Pr=(function(){function e(e){this.name=Ar.SceneComponentConstants.NAME_PROCEDURALTEXTURE,this.scene=e,this.scene.proceduralTextures=new Array,e.layers=new Array}return e.prototype.register=function(){this.scene._beforeClearStage.registerStep(Ar.SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE,this,this._beforeClear)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeClear=function(){if(this.scene.proceduralTexturesEnabled){Ar.Tools.StartPerformanceCounter("Procedural textures",0<this.scene.proceduralTextures.length);for(var e=0;e<this.scene.proceduralTextures.length;e++){var t=this.scene.proceduralTextures[e];t._shouldRender()&&t.render()}Ar.Tools.EndPerformanceCounter("Procedural textures",0<this.scene.proceduralTextures.length)}},e})(),Ar.ProceduralTextureSceneComponent=Pr,Sr=$a||($a={}),Rr=(function(a){function e(e,t,i,r,n,o){var s=a.call(this,e,i,null,r,n,o)||this;return s._animate=!0,s._time=0,s._texturePath=t,s._loadJson(t),s.refreshRate=1,s}return T(e,a),e.prototype._loadJson=function(e){var t=this,i=function(){Sr.Tools.Log("No config file found in "+e+" trying to use ShadersStore or DOM element");try{t.setFragment(t._texturePath)}catch(e){Sr.Tools.Error("No json or ShaderStore or DOM element found for CustomProceduralTexture")}},r=e+"/config.json",n=new XMLHttpRequest;n.open("GET",r,!0),n.addEventListener("load",(function(){if(200===n.status||Sr.Tools.ValidateXHRData(n,1))try{t._config=JSON.parse(n.response),t.updateShaderUniforms(),t.updateTextures(),t.setFragment(t._texturePath+"/custom"),t._animate=t._config.animate,t.refreshRate=t._config.refreshrate}catch(e){i()}else i()}),!1),n.addEventListener("error",(function(){i()}),!1);try{n.send()}catch(e){Sr.Tools.Error("CustomProceduralTexture: Error on XHR send request.")}},e.prototype.isReady=function(){if(!a.prototype.isReady.call(this))return!1;for(var e in this._textures){if(!this._textures[e].isReady())return!1}return!0},e.prototype.render=function(e){var t=this.getScene();this._animate&&t&&(this._time+=.03*t.getAnimationRatio(),this.updateShaderUniforms()),a.prototype.render.call(this,e)},e.prototype.updateTextures=function(){for(var e=0;e<this._config.sampler2Ds.length;e++)this.setTexture(this._config.sampler2Ds[e].sample2Dname,new Sr.Texture(this._texturePath+"/"+this._config.sampler2Ds[e].textureRelativeUrl,this.getScene()))},e.prototype.updateShaderUniforms=function(){if(this._config)for(var e=0;e<this._config.uniforms.length;e++){var t=this._config.uniforms[e];switch(t.type){case"float":this.setFloat(t.name,t.value);break;case"color3":this.setColor3(t.name,new Sr.Color3(t.r,t.g,t.b));break;case"color4":this.setColor4(t.name,new Sr.Color4(t.r,t.g,t.b,t.a));break;case"vector2":this.setVector2(t.name,new Sr.Vector2(t.x,t.y));break;case"vector3":this.setVector3(t.name,new Sr.Vector3(t.x,t.y,t.z))}}this.setFloat("time",this._time)},Object.defineProperty(e.prototype,"animate",{get:function(){return this._animate},set:function(e){this._animate=e},enumerable:!0,configurable:!0}),e})(Sr.ProceduralTexture),Sr.CustomProceduralTexture=Rr,Mr=$a||($a={}),Cr=(function(){function e(){this.gamepadAngularSensibility=200,this.gamepadMoveSensibility=40,this._cameraTransform=Mr.Matrix.Identity(),this._deltaTransform=Mr.Vector3.Zero(),this._vector3=Mr.Vector3.Zero(),this._vector2=Mr.Vector2.Zero()}return e.prototype.attachControl=function(e,t){var i=this,r=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=r.onGamepadConnectedObservable.add((function(e){e.type!==Mr.Gamepad.POSE_ENABLED&&(i.gamepad&&e.type!==Mr.Gamepad.XBOX||(i.gamepad=e))})),this._onGamepadDisconnectedObserver=r.onGamepadDisconnectedObservable.add((function(e){i.gamepad===e&&(i.gamepad=null)})),this.gamepad=r.getGamepadByType(Mr.Gamepad.XBOX)},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad&&this.gamepad.leftStick){var e=this.camera,t=this.gamepad.leftStick,i=t.x/this.gamepadMoveSensibility,r=t.y/this.gamepadMoveSensibility;t.x=.005<Math.abs(i)?0+i:0,t.y=.005<Math.abs(r)?0+r:0;var n=this.gamepad.rightStick;if(n){var o=n.x/this.gamepadAngularSensibility,s=n.y/this.gamepadAngularSensibility;n.x=.001<Math.abs(o)?0+o:0,n.y=.001<Math.abs(s)?0+s:0}else n={x:0,y:0};e.rotationQuaternion?e.rotationQuaternion.toRotationMatrix(this._cameraTransform):Mr.Matrix.RotationYawPitchRollToRef(e.rotation.y,e.rotation.x,0,this._cameraTransform);var a=50*e._computeLocalCameraSpeed();this._vector3.copyFromFloats(t.x*a,0,-t.y*a),Mr.Vector3.TransformCoordinatesToRef(this._vector3,this._cameraTransform,this._deltaTransform),e.cameraDirection.addInPlace(this._deltaTransform),this._vector2.copyFromFloats(n.y,n.x),e.cameraRotation.addInPlace(this._vector2)}},e.prototype.getClassName=function(){return"FreeCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},b([Mr.serialize()],e.prototype,"gamepadAngularSensibility",void 0),b([Mr.serialize()],e.prototype,"gamepadMoveSensibility",void 0),e})(),Mr.FreeCameraGamepadInput=Cr,Mr.CameraInputTypes.FreeCameraGamepadInput=Cr,Or=$a||($a={}),Dr=(function(){function e(){this.gamepadRotationSensibility=80,this.gamepadMoveSensibility=40}return e.prototype.attachControl=function(e,t){var i=this,r=this.camera.getScene().gamepadManager;this._onGamepadConnectedObserver=r.onGamepadConnectedObservable.add((function(e){e.type!==Or.Gamepad.POSE_ENABLED&&(i.gamepad&&e.type!==Or.Gamepad.XBOX||(i.gamepad=e))})),this._onGamepadDisconnectedObserver=r.onGamepadDisconnectedObservable.add((function(e){i.gamepad===e&&(i.gamepad=null)})),this.gamepad=r.getGamepadByType(Or.Gamepad.XBOX)},e.prototype.detachControl=function(e){this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),this.gamepad=null},e.prototype.checkInputs=function(){if(this.gamepad){var e=this.camera,t=this.gamepad.rightStick;if(t){if(0!=t.x){var i=t.x/this.gamepadRotationSensibility;0!=i&&.005<Math.abs(i)&&(e.inertialAlphaOffset+=i)}if(0!=t.y){var r=t.y/this.gamepadRotationSensibility;0!=r&&.005<Math.abs(r)&&(e.inertialBetaOffset+=r)}}var n=this.gamepad.leftStick;if(n&&0!=n.y){var o=n.y/this.gamepadMoveSensibility;0!=o&&.005<Math.abs(o)&&(this.camera.inertialRadiusOffset-=o)}}},e.prototype.getClassName=function(){return"ArcRotateCameraGamepadInput"},e.prototype.getSimpleName=function(){return"gamepad"},b([Or.serialize()],e.prototype,"gamepadRotationSensibility",void 0),b([Or.serialize()],e.prototype,"gamepadMoveSensibility",void 0),e})(),Or.ArcRotateCameraGamepadInput=Dr,Or.CameraInputTypes.ArcRotateCameraGamepadInput=Dr,Ir=$a||($a={}),wr=(function(){function e(e){var n=this;this._scene=e,this._babylonGamepads=[],this._oneGamepadConnected=!1,this._isMonitoring=!1,this.onGamepadDisconnectedObservable=new Ir.Observable,Ir.Tools.IsWindowObjectExist()?(this._gamepadEventSupported="GamepadEvent"in window,this._gamepadSupport=navigator.getGamepads||navigator.webkitGetGamepads||navigator.msGetGamepads||navigator.webkitGamepads):this._gamepadEventSupported=!1,this.onGamepadConnectedObservable=new Ir.Observable(function(e){for(var t in n._babylonGamepads){var i=n._babylonGamepads[t];i&&i._isConnected&&n.onGamepadConnectedObservable.notifyObserver(e,i)}}),this._onGamepadConnectedEvent=function(e){var t,i=e.gamepad;i.index in n._babylonGamepads&&n._babylonGamepads[i.index].isConnected||(n._babylonGamepads[i.index]?((t=n._babylonGamepads[i.index]).browserGamepad=i,t._isConnected=!0):t=n._addNewGamepad(i),n.onGamepadConnectedObservable.notifyObservers(t),n._startMonitoringGamepads())},this._onGamepadDisconnectedEvent=function(e){var t=e.gamepad;for(var i in n._babylonGamepads)if(n._babylonGamepads[i].index===t.index){var r=n._babylonGamepads[i];r._isConnected=!1,n.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=Ir.Gamepad.XBOX);for(var t=0,i=this._babylonGamepads;t<i.length;t++){var r=i[t];if(r&&r.type===e)return r}return null},e.prototype.dispose=function(){this._gamepadEventSupported&&(this._onGamepadConnectedEvent&&window.removeEventListener("gamepadconnected",this._onGamepadConnectedEvent),this._onGamepadDisconnectedEvent&&window.removeEventListener("gamepaddisconnected",this._onGamepadDisconnectedEvent),this._onGamepadConnectedEvent=null,this._onGamepadDisconnectedEvent=null),this._babylonGamepads.forEach((function(e){e.dispose()})),this.onGamepadConnectedObservable.clear(),this.onGamepadDisconnectedObservable.clear(),this._oneGamepadConnected=!1,this._stopMonitoringGamepads(),this._babylonGamepads=[]},e.prototype._addNewGamepad=function(e){var t;this._oneGamepadConnected||(this._oneGamepadConnected=!0);var i=-1!==e.id.search("Xbox One");return t=i||-1!==e.id.search("Xbox 360")||-1!==e.id.search("xinput")?new Ir.Xbox360Pad(e.id,e.index,e,i):e.pose?Ir.PoseEnabledControllerHelper.InitiateController(e):new Ir.GenericPad(e.id,e.index,e),this._babylonGamepads[t.index]=t},e.prototype._startMonitoringGamepads=function(){this._isMonitoring||(this._isMonitoring=!0,this._scene||this._checkGamepadsStatus())},e.prototype._stopMonitoringGamepads=function(){this._isMonitoring=!1},e.prototype._checkGamepadsStatus=function(){var e=this;for(var t in this._updateGamepadObjects(),this._babylonGamepads){var i=this._babylonGamepads[t];i&&i.isConnected&&i.update()}this._isMonitoring&&!this._scene&&Ir.Tools.QueueNewFrame((function(){e._checkGamepadsStatus()}))},e.prototype._updateGamepadObjects=function(){for(var e=navigator.getGamepads?navigator.getGamepads():navigator.webkitGetGamepads?navigator.webkitGetGamepads():[],t=0;t<e.length;t++){var i=e[t];if(i)if(this._babylonGamepads[i.index])this._babylonGamepads[t].browserGamepad=i,this._babylonGamepads[t].isConnected||(this._babylonGamepads[t]._isConnected=!0,this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[t]));else{var r=this._addNewGamepad(i);this.onGamepadConnectedObservable.notifyObservers(r)}}},e})(),Ir.GamepadManager=wr,(function(o){var e=function(e,t){this.x=e,this.y=t};o.StickValues=e;var s=(function(){function a(e,t,i,r,n,o,s){void 0===r&&(r=0),void 0===n&&(n=1),void 0===o&&(o=2),void 0===s&&(s=3),this.id=e,this.index=t,this.browserGamepad=i,this._leftStick={x:0,y:0},this._rightStick={x:0,y:0},this._isConnected=!0,this._invertLeftStickY=!1,this.type=a.GAMEPAD,this._leftStickAxisX=r,this._leftStickAxisY=n,this._rightStickAxisX=o,this._rightStickAxisY=s,2<=this.browserGamepad.axes.length&&(this._leftStick={x:this.browserGamepad.axes[this._leftStickAxisX],y:this.browserGamepad.axes[this._leftStickAxisY]}),4<=this.browserGamepad.axes.length&&(this._rightStick={x:this.browserGamepad.axes[this._rightStickAxisX],y:this.browserGamepad.axes[this._rightStickAxisY]})}return Object.defineProperty(a.prototype,"isConnected",{get:function(){return this._isConnected},enumerable:!0,configurable:!0}),a.prototype.onleftstickchanged=function(e){this._onleftstickchanged=e},a.prototype.onrightstickchanged=function(e){this._onrightstickchanged=e},Object.defineProperty(a.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(a.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}),a.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]})},a.prototype.dispose=function(){},a.GAMEPAD=0,a.GENERIC=1,a.XBOX=2,a.POSE_ENABLED=3,a})(),t=(function(n){function e(e,t,i){var r=n.call(this,e,t,i)||this;return r.onButtonDownObservable=new o.Observable,r.onButtonUpObservable=new o.Observable,r.type=s.GENERIC,r._buttons=new Array(i.buttons.length),r}return T(e,n),e.prototype.onbuttondown=function(e){this._onbuttondown=e},e.prototype.onbuttonup=function(e){this._onbuttonup=e},e.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},e.prototype.update=function(){n.prototype.update.call(this);for(var e=0;e<this._buttons.length;e++)this._buttons[e]=this._setButtonValue(this.browserGamepad.buttons[e].value,this._buttons[e],e)},e.prototype.dispose=function(){n.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear()},e})(o.Gamepad=s);o.GenericPad=t})($a||($a={})),(function(s){var t,e,i,r;(e=t=s.Xbox360Button||(s.Xbox360Button={}))[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",(r=i=s.Xbox360Dpad||(s.Xbox360Dpad={}))[r.Up=0]="Up",r[r.Down=1]="Down",r[r.Left=2]="Left",r[r.Right=3]="Right";var n=(function(o){function e(e,t,i,r){void 0===r&&(r=!1);var n=o.call(this,e,t,i,0,1,2,3)||this;return n._leftTrigger=0,n._rightTrigger=0,n.onButtonDownObservable=new s.Observable,n.onButtonUpObservable=new s.Observable,n.onPadDownObservable=new s.Observable,n.onPadUpObservable=new s.Observable,n._buttonA=0,n._buttonB=0,n._buttonX=0,n._buttonY=0,n._buttonBack=0,n._buttonStart=0,n._buttonLB=0,n._buttonRB=0,n._buttonLeftStick=0,n._buttonRightStick=0,n._dPadUp=0,n._dPadDown=0,n._dPadLeft=0,n._dPadRight=0,n._isXboxOnePad=!1,n.type=s.Gamepad.XBOX,n._isXboxOnePad=r,n}return T(e,o),e.prototype.onlefttriggerchanged=function(e){this._onlefttriggerchanged=e},e.prototype.onrighttriggerchanged=function(e){this._onrighttriggerchanged=e},Object.defineProperty(e.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(e.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}),e.prototype.onbuttondown=function(e){this._onbuttondown=e},e.prototype.onbuttonup=function(e){this._onbuttonup=e},e.prototype.ondpaddown=function(e){this._ondpaddown=e},e.prototype.ondpadup=function(e){this._ondpadup=e},e.prototype._setButtonValue=function(e,t,i){return e!==t&&(1===e&&(this._onbuttondown&&this._onbuttondown(i),this.onButtonDownObservable.notifyObservers(i)),0===e&&(this._onbuttonup&&this._onbuttonup(i),this.onButtonUpObservable.notifyObservers(i))),e},e.prototype._setDPadValue=function(e,t,i){return e!==t&&(1===e&&(this._ondpaddown&&this._ondpaddown(i),this.onPadDownObservable.notifyObservers(i)),0===e&&(this._ondpadup&&this._ondpadup(i),this.onPadUpObservable.notifyObservers(i))),e},Object.defineProperty(e.prototype,"buttonA",{get:function(){return this._buttonA},set:function(e){this._buttonA=this._setButtonValue(e,this._buttonA,t.A)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonB",{get:function(){return this._buttonB},set:function(e){this._buttonB=this._setButtonValue(e,this._buttonB,t.B)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonX",{get:function(){return this._buttonX},set:function(e){this._buttonX=this._setButtonValue(e,this._buttonX,t.X)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonY",{get:function(){return this._buttonY},set:function(e){this._buttonY=this._setButtonValue(e,this._buttonY,t.Y)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonStart",{get:function(){return this._buttonStart},set:function(e){this._buttonStart=this._setButtonValue(e,this._buttonStart,t.Start)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonBack",{get:function(){return this._buttonBack},set:function(e){this._buttonBack=this._setButtonValue(e,this._buttonBack,t.Back)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonLB",{get:function(){return this._buttonLB},set:function(e){this._buttonLB=this._setButtonValue(e,this._buttonLB,t.LB)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonRB",{get:function(){return this._buttonRB},set:function(e){this._buttonRB=this._setButtonValue(e,this._buttonRB,t.RB)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonLeftStick",{get:function(){return this._buttonLeftStick},set:function(e){this._buttonLeftStick=this._setButtonValue(e,this._buttonLeftStick,t.LeftStick)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"buttonRightStick",{get:function(){return this._buttonRightStick},set:function(e){this._buttonRightStick=this._setButtonValue(e,this._buttonRightStick,t.RightStick)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dPadUp",{get:function(){return this._dPadUp},set:function(e){this._dPadUp=this._setDPadValue(e,this._dPadUp,i.Up)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dPadDown",{get:function(){return this._dPadDown},set:function(e){this._dPadDown=this._setDPadValue(e,this._dPadDown,i.Down)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dPadLeft",{get:function(){return this._dPadLeft},set:function(e){this._dPadLeft=this._setDPadValue(e,this._dPadLeft,i.Left)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"dPadRight",{get:function(){return this._dPadRight},set:function(e){this._dPadRight=this._setDPadValue(e,this._dPadRight,i.Right)},enumerable:!0,configurable:!0}),e.prototype.update=function(){o.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)},e.prototype.dispose=function(){o.prototype.dispose.call(this),this.onButtonDownObservable.clear(),this.onButtonUpObservable.clear(),this.onPadDownObservable.clear(),this.onPadUpObservable.clear()},e})(s.Gamepad);s.Xbox360Pad=n})($a||($a={})),(function(s){var r,e;(e=r=s.PoseEnabledControllerType||(s.PoseEnabledControllerType={}))[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";var t=(function(){function e(){}return e.InitiateController=function(e){return-1!==e.id.indexOf("Oculus Touch")?new s.OculusTouchController(e):0===e.id.indexOf(s.WindowsMotionController.GAMEPAD_ID_PREFIX)?new s.WindowsMotionController(e):-1!==e.id.toLowerCase().indexOf("openvr")?new s.ViveController(e):0===e.id.indexOf(s.GearVRController.GAMEPAD_ID_PREFIX)||-1!==e.id.indexOf("Oculus Go")?new s.GearVRController(e):0===e.id.indexOf(s.DaydreamController.GAMEPAD_ID_PREFIX)?new s.DaydreamController(e):new s.GenericController(e)},e})();s.PoseEnabledControllerHelper=t;var i=(function(i){function e(e){var t=i.call(this,e.id,e.index,e)||this;return t._deviceRoomPosition=s.Vector3.Zero(),t._deviceRoomRotationQuaternion=new s.Quaternion,t.devicePosition=s.Vector3.Zero(),t.deviceRotationQuaternion=new s.Quaternion,t.deviceScaleFactor=1,t._trackPosition=!0,t._maxRotationDistFromHeadset=Math.PI/5,t._draggedRoomRotation=0,t._leftHandSystemQuaternion=new s.Quaternion,t._deviceToWorld=s.Matrix.Identity(),t._pointingPoseNode=null,t._workingMatrix=s.Matrix.Identity(),t._meshAttachedObservable=new s.Observable,t.type=s.Gamepad.POSE_ENABLED,t.controllerType=r.GENERIC,t.position=s.Vector3.Zero(),t.rotationQuaternion=new s.Quaternion,t._calculatedPosition=s.Vector3.Zero(),t._calculatedRotation=new s.Quaternion,s.Quaternion.RotationYawPitchRollToRef(Math.PI,0,0,t._leftHandSystemQuaternion),t}return T(e,i),e.prototype._disableTrackPosition=function(e){this._trackPosition&&(this._calculatedPosition.copyFrom(e),this._trackPosition=!1)},e.prototype.update=function(){i.prototype.update.call(this),this._updatePoseAndMesh()},e.prototype._updatePoseAndMesh=function(){var e=this.browserGamepad.pose;if((this.updateFromDevice(e),!this._trackPosition&&s.Engine.LastCreatedScene&&s.Engine.LastCreatedScene.activeCamera&&s.Engine.LastCreatedScene.activeCamera.devicePosition)&&((t=s.Engine.LastCreatedScene.activeCamera)._computeDevicePosition(),this._deviceToWorld.setTranslation(t.devicePosition),t.deviceRotationQuaternion)){var t;(t=t)._deviceRoomRotationQuaternion.toEulerAnglesToRef(s.Tmp.Vector3[0]);var i=Math.atan2(Math.sin(s.Tmp.Vector3[0].y-this._draggedRoomRotation),Math.cos(s.Tmp.Vector3[0].y-this._draggedRoomRotation));if(Math.abs(i)>this._maxRotationDistFromHeadset){var r=i-(i<0?-this._maxRotationDistFromHeadset:this._maxRotationDistFromHeadset);this._draggedRoomRotation+=r;var n=Math.sin(-r),o=Math.cos(-r);this._calculatedPosition.x=this._calculatedPosition.x*o-this._calculatedPosition.z*n,this._calculatedPosition.z=this._calculatedPosition.x*n+this._calculatedPosition.z*o}}s.Vector3.TransformCoordinatesToRef(this._calculatedPosition,this._deviceToWorld,this.devicePosition),this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix),s.Quaternion.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))},e.prototype.updateFromDevice=function(e){if(e){(this.rawPose=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))}},e.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 s.Quaternion),this._updatePoseAndMesh(),this._pointingPoseNode){for(var t=[],i=this._pointingPoseNode;i.parent;)t.push(i.parent),i=i.parent;t.reverse().forEach((function(e){e.computeWorldMatrix(!0)}))}this._meshAttachedObservable.notifyObservers(e)},e.prototype.attachToPoseControlledCamera=function(e){this._poseControlledCamera=e,this._mesh&&(this._mesh.parent=this._poseControlledCamera)},e.prototype.dispose=function(){this._mesh&&this._mesh.dispose(),this._mesh=null,i.prototype.dispose.call(this)},Object.defineProperty(e.prototype,"mesh",{get:function(){return this._mesh},enumerable:!0,configurable:!0}),e.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this.mesh)return new s.Ray(s.Vector3.Zero(),new s.Vector3(0,0,1),e);var t=this._pointingPoseNode?this._pointingPoseNode.getWorldMatrix():this.mesh.getWorldMatrix(),i=t.getTranslation(),r=new s.Vector3(0,0,-1),n=s.Vector3.TransformNormal(r,t),o=s.Vector3.Normalize(n);return new s.Ray(i,o,e)},e.POINTING_POSE="POINTING_POSE",e})(s.Gamepad);s.PoseEnabledController=i})($a||($a={})),Lr=$a||($a={}),Fr=(function(i){function e(e){var t=i.call(this,e)||this;return t.onTriggerStateChangedObservable=new Lr.Observable,t.onMainButtonStateChangedObservable=new Lr.Observable,t.onSecondaryButtonStateChangedObservable=new Lr.Observable,t.onPadStateChangedObservable=new Lr.Observable,t.onPadValuesChangedObservable=new Lr.Observable,t.pad={x:0,y:0},t._changes={pressChanged:!1,touchChanged:!1,valueChanged:!1,changed:!1},t._buttons=new Array(e.buttons.length),t.hand=e.hand,t}return T(e,i),e.prototype.onButtonStateChange=function(e){this._onButtonStateChange=e},Object.defineProperty(e.prototype,"defaultModel",{get:function(){return this._defaultModel},enumerable:!0,configurable:!0}),e.prototype.update=function(){i.prototype.update.call(this);for(var e=0;e<this._buttons.length;e++)this._setButtonValue(this.browserGamepad.buttons[e],this._buttons[e],e);this.leftStick.x===this.pad.x&&this.leftStick.y===this.pad.y||(this.pad.x=this.leftStick.x,this.pad.y=this.leftStick.y,this.onPadValuesChangedObservable.notifyObservers(this.pad))},e.prototype._setButtonValue=function(e,t,i){e||(e={pressed:!1,touched:!1,value:0}),t?(this._checkChanges(e,t),this._changes.changed&&(this._onButtonStateChange&&this._onButtonStateChange(this.index,i,e),this._handleButtonChange(i,e,this._changes)),this._buttons[i].pressed=e.pressed,this._buttons[i].touched=e.touched,this._buttons[i].value=e.value<1e-8?0:e.value):this._buttons[i]={pressed:e.pressed,touched:e.touched,value:e.value}},e.prototype._checkChanges=function(e,t){return this._changes.pressChanged=e.pressed!==t.pressed,this._changes.touchChanged=e.touched!==t.touched,this._changes.valueChanged=e.value!==t.value,this._changes.changed=this._changes.pressChanged||this._changes.touchChanged||this._changes.valueChanged,this._changes},e.prototype.dispose=function(){i.prototype.dispose.call(this),this.onTriggerStateChangedObservable.clear(),this.onMainButtonStateChangedObservable.clear(),this.onSecondaryButtonStateChangedObservable.clear(),this.onPadStateChangedObservable.clear(),this.onPadValuesChangedObservable.clear()},e})(Lr.PoseEnabledController),Lr.WebVRController=Fr,Br=$a||($a={}),Nr=(function(i){function n(e){var t=i.call(this,e)||this;return t.onSecondaryTriggerStateChangedObservable=new Br.Observable,t.onThumbRestChangedObservable=new Br.Observable,t.controllerType=Br.PoseEnabledControllerType.OCULUS,t}return T(n,i),n.prototype.initControllerMesh=function(e,t){var i,r=this;i="left"===this.hand?n.MODEL_LEFT_FILENAME:n.MODEL_RIGHT_FILENAME,Br.SceneLoader.ImportMesh("",n.MODEL_BASE_URL,i,e,(function(e){r._defaultModel=e[1],r.attachToMesh(r._defaultModel),t&&t(r._defaultModel)}))},Object.defineProperty(n.prototype,"onAButtonStateChangedObservable",{get:function(){if("right"===this.hand)return this.onMainButtonStateChangedObservable;throw new Error("No A button on left hand")},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onBButtonStateChangedObservable",{get:function(){if("right"===this.hand)return this.onSecondaryButtonStateChangedObservable;throw new Error("No B button on left hand")},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onXButtonStateChangedObservable",{get:function(){if("left"===this.hand)return this.onMainButtonStateChangedObservable;throw new Error("No X button on right hand")},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"onYButtonStateChangedObservable",{get:function(){if("left"===this.hand)return this.onSecondaryButtonStateChangedObservable;throw new Error("No Y button on right hand")},enumerable:!0,configurable:!0}),n.prototype._handleButtonChange=function(e,t,i){var r=t,n="right"===this.hand?-1:1;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(r);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[3].rotation.x=.2*-r.value,this._defaultModel.getChildren()[3].position.y=.005*-r.value,this._defaultModel.getChildren()[3].position.z=.005*-r.value),void this.onTriggerStateChangedObservable.notifyObservers(r);case 2:return this._defaultModel&&(this._defaultModel.getChildren()[4].position.x=n*r.value*.0035),void this.onSecondaryTriggerStateChangedObservable.notifyObservers(r);case 3:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[1].position.y=-.001:this._defaultModel.getChildren()[1].position.y=0),void this.onMainButtonStateChangedObservable.notifyObservers(r);case 4:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(r);case 5:return void this.onThumbRestChangedObservable.notifyObservers(r)}},n.MODEL_BASE_URL="https://controllers.babylonjs.com/oculus/",n.MODEL_LEFT_FILENAME="left.babylon",n.MODEL_RIGHT_FILENAME="right.babylon",n})(Br.WebVRController),Br.OculusTouchController=Nr,Vr=$a||($a={}),Ur=(function(i){function r(e){var t=i.call(this,e)||this;return t.controllerType=Vr.PoseEnabledControllerType.VIVE,t._invertLeftStickY=!0,t}return T(r,i),r.prototype.initControllerMesh=function(e,t){var i=this;Vr.SceneLoader.ImportMesh("",r.MODEL_BASE_URL,r.MODEL_FILENAME,e,(function(e){i._defaultModel=e[1],i.attachToMesh(i._defaultModel),t&&t(i._defaultModel)}))},Object.defineProperty(r.prototype,"onLeftButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onRightButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!0,configurable:!0}),r.prototype._handleButtonChange=function(e,t,i){var r=t;switch(e){case 0:return void this.onPadStateChangedObservable.notifyObservers(r);case 1:return this._defaultModel&&(this._defaultModel.getChildren()[6].rotation.x=.15*-r.value),void this.onTriggerStateChangedObservable.notifyObservers(r);case 2:return void this.onMainButtonStateChangedObservable.notifyObservers(r);case 3:return this._defaultModel&&(r.pressed?this._defaultModel.getChildren()[2].position.y=-.001:this._defaultModel.getChildren()[2].position.y=0),void this.onSecondaryButtonStateChangedObservable.notifyObservers(r)}},r.MODEL_BASE_URL="https://controllers.babylonjs.com/vive/",r.MODEL_FILENAME="wand.babylon",r})(Vr.WebVRController),Vr.ViveController=Ur,zr=$a||($a={}),Gr=(function(t){function r(e){return t.call(this,e)||this}return T(r,t),r.prototype.initControllerMesh=function(e,t){var i=this;zr.SceneLoader.ImportMesh("",r.MODEL_BASE_URL,r.MODEL_FILENAME,e,(function(e){i._defaultModel=e[1],i.attachToMesh(i._defaultModel),t&&t(i._defaultModel)}))},r.prototype._handleButtonChange=function(e,t,i){console.log("Button id: "+e+"state: "),console.dir(t)},r.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",r.MODEL_FILENAME="generic.babylon",r})(zr.WebVRController),zr.GenericController=Gr,kr=$a||($a={}),Wr=function(){this.buttonMeshes={},this.axisMeshes={}},Hr=(function(s){function l(e){var t=s.call(this,e)||this;return t._mapping={buttons:["thumbstick","trigger","grip","menu","trackpad"],buttonMeshNames:{trigger:"SELECT",menu:"MENU",grip:"GRASP",thumbstick:"THUMBSTICK_PRESS",trackpad:"TOUCHPAD_PRESS"},buttonObservableNames:{trigger:"onTriggerStateChangedObservable",menu:"onSecondaryButtonStateChangedObservable",grip:"onMainButtonStateChangedObservable",thumbstick:"onPadStateChangedObservable",trackpad:"onTrackpadChangedObservable"},axisMeshNames:["THUMBSTICK_X","THUMBSTICK_Y","TOUCHPAD_TOUCH_X","TOUCHPAD_TOUCH_Y"],pointingPoseMeshName:kr.PoseEnabledController.POINTING_POSE},t.onTrackpadChangedObservable=new kr.Observable,t.onTrackpadValuesChangedObservable=new kr.Observable,t.trackpad={x:0,y:0},t.controllerType=kr.PoseEnabledControllerType.WINDOWS,t._loadedMeshInfo=null,t}return T(l,s),Object.defineProperty(l.prototype,"onTriggerButtonStateChangedObservable",{get:function(){return this.onTriggerStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"onMenuButtonStateChangedObservable",{get:function(){return this.onSecondaryButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"onGripButtonStateChangedObservable",{get:function(){return this.onMainButtonStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"onThumbstickButtonStateChangedObservable",{get:function(){return this.onPadStateChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"onTouchpadButtonStateChangedObservable",{get:function(){return this.onTrackpadChangedObservable},enumerable:!0,configurable:!0}),Object.defineProperty(l.prototype,"onTouchpadValuesChangedObservable",{get:function(){return this.onTrackpadValuesChangedObservable},enumerable:!0,configurable:!0}),l.prototype._updateTrackpad=function(){!this.browserGamepad.axes||this.browserGamepad.axes[2]==this.trackpad.x&&this.browserGamepad.axes[3]==this.trackpad.y||(this.trackpad.x=this.browserGamepad.axes[2],this.trackpad.y=this.browserGamepad.axes[3],this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad))},l.prototype.update=function(){if(s.prototype.update.call(this),this.browserGamepad.axes&&(this._updateTrackpad(),this._loadedMeshInfo))for(var e=0;e<this._mapping.axisMeshNames.length;e++)this._lerpAxisTransform(e,this.browserGamepad.axes[e])},l.prototype._handleButtonChange=function(e,t,i){var r=this._mapping.buttons[e];if(r){this._updateTrackpad();var n=this[this._mapping.buttonObservableNames[r]];n&&n.notifyObservers(t),this._lerpButtonTransform(r,t.value)}},l.prototype._lerpButtonTransform=function(e,t){if(this._loadedMeshInfo){var i=this._loadedMeshInfo.buttonMeshes[e];i.unpressed.rotationQuaternion&&i.pressed.rotationQuaternion&&i.value.rotationQuaternion&&(kr.Quaternion.SlerpToRef(i.unpressed.rotationQuaternion,i.pressed.rotationQuaternion,t,i.value.rotationQuaternion),kr.Vector3.LerpToRef(i.unpressed.position,i.pressed.position,t,i.value.position))}},l.prototype._lerpAxisTransform=function(e,t){if(this._loadedMeshInfo){var i=this._loadedMeshInfo.axisMeshes[e];if(i&&i.min.rotationQuaternion&&i.max.rotationQuaternion&&i.value.rotationQuaternion){var r=.5*t+.5;kr.Quaternion.SlerpToRef(i.min.rotationQuaternion,i.max.rotationQuaternion,r,i.value.rotationQuaternion),kr.Vector3.LerpToRef(i.min.position,i.max.position,r,i.value.position)}}},l.prototype.initControllerMesh=function(t,i,r){var n,o,s=this;if(void 0===r&&(r=!1),kr.SceneLoader.IsPluginForExtensionAvailable(".glb")){var e="default";if(this.id&&!r){var a=this.id.match(l.GAMEPAD_ID_PATTERN);e=a&&a[0]||e}o="left"===this.hand?l.MODEL_LEFT_FILENAME:l.MODEL_RIGHT_FILENAME,n=l.MODEL_BASE_URL+e+"/"}else kr.Tools.Warn("You need to reference GLTF loader to load Windows Motion Controllers model. Falling back to generic models"),n=kr.GenericController.MODEL_BASE_URL,o=kr.GenericController.MODEL_FILENAME;kr.SceneLoader.ImportMesh("",n,o,t,(function(e){s._loadedMeshInfo=s.processModel(t,e),s._loadedMeshInfo&&(s._defaultModel=s._loadedMeshInfo.rootNode,s.attachToMesh(s._defaultModel),i&&i(s._defaultModel))}),null,(function(e,t){kr.Tools.Log(t),kr.Tools.Warn("Failed to retrieve controller model from the remote server: "+n+o),r||s.initControllerMesh(e,i,!0)}))},l.prototype.processModel=function(e,t){for(var i=null,r=new kr.Mesh(this.id+" "+this.hand,e),n=null,o=0;o<t.length;o++){var s=t[o];if(!s.parent){s.isPickable=!1,n=s;break}}return n?(n.setParent(r),i=this.createMeshInfo(r)):kr.Tools.Warn("Could not find root node in model file."),i},l.prototype.createMeshInfo=function(e){var t,i=new Wr;for(i.rootNode=e,i.buttonMeshes={},i.axisMeshes={},t=0;t<this._mapping.buttons.length;t++){var r=this._mapping.buttonMeshNames[this._mapping.buttons[t]];if(r){var n=c(e,r);if(n){var o={index:t,value:h(n,"VALUE"),pressed:h(n,"PRESSED"),unpressed:h(n,"UNPRESSED")};o.value&&o.pressed&&o.unpressed?i.buttonMeshes[this._mapping.buttons[t]]=o:kr.Tools.Warn("Missing button submesh under mesh with name: "+r+"(VALUE: "+!!o.value+", PRESSED: "+!!o.pressed+", UNPRESSED:"+!!o.unpressed+")")}else kr.Tools.Warn("Missing button mesh with name: "+r)}else kr.Tools.Log("Skipping unknown button at index: "+t+" with mapped name: "+this._mapping.buttons[t])}for(t=0;t<this._mapping.axisMeshNames.length;t++){var s=this._mapping.axisMeshNames[t];if(s){var a=c(e,s);if(a){var l={index:t,value:h(a,"VALUE"),min:h(a,"MIN"),max:h(a,"MAX")};l.value&&l.min&&l.max?i.axisMeshes[t]=l:kr.Tools.Warn("Missing axis submesh under mesh with name: "+s+"(VALUE: "+!!l.value+", MIN: "+!!l.min+", MAX:"+!!l.max+")")}else kr.Tools.Warn("Missing axis mesh with name: "+s)}else kr.Tools.Log("Skipping unknown axis at index: "+t)}return i.pointingPoseNode=c(e,this._mapping.pointingPoseMeshName),i.pointingPoseNode?this._pointingPoseNode=i.pointingPoseNode:kr.Tools.Warn("Missing pointing pose mesh with name: "+this._mapping.pointingPoseMeshName),i;function c(e,t){return e.getChildMeshes(!1,(function(e){return e.name===t}))[0]}function h(e,t){return e.getChildMeshes(!0,(function(e){return e.name==t}))[0]}},l.prototype.getForwardRay=function(e){if(void 0===e&&(e=100),!this._loadedMeshInfo||!this._loadedMeshInfo.pointingPoseNode)return s.prototype.getForwardRay.call(this,e);var t=this._loadedMeshInfo.pointingPoseNode.getWorldMatrix(),i=t.getTranslation(),r=new kr.Vector3(0,0,-1),n=kr.Vector3.TransformNormal(r,t),o=kr.Vector3.Normalize(n);return new kr.Ray(i,o,e)},l.prototype.dispose=function(){s.prototype.dispose.call(this),this.onTrackpadChangedObservable.clear()},l.MODEL_BASE_URL="https://controllers.babylonjs.com/microsoft/",l.MODEL_LEFT_FILENAME="left.glb",l.MODEL_RIGHT_FILENAME="right.glb",l.GAMEPAD_ID_PREFIX="Spatial Controller (Spatial Interaction Source) ",l.GAMEPAD_ID_PATTERN=/([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/,l})(kr.WebVRController),kr.WindowsMotionController=Hr,Xr=$a||($a={}),jr=(function(i){function e(e){var t=i.call(this,e)||this;return t._buttonIndexToObservableNameMap=["onTrackpadChangedObservable","onTriggerStateChangedObservable"],t.controllerType=Xr.PoseEnabledControllerType.GEAR_VR,t._calculatedPosition=new Xr.Vector3("left"==t.hand?-.15:.15,-.5,.25),t._disableTrackPosition(t._calculatedPosition),t}return T(e,i),e.prototype.initControllerMesh=function(i,r){var n=this;Xr.SceneLoader.ImportMesh("",e.MODEL_BASE_URL,e.MODEL_FILENAME,i,(function(e){var t=new Xr.Mesh("",i);e[1].parent=t,e[1].position.z=-.15,n._defaultModel=t,n.attachToMesh(n._defaultModel),r&&r(n._defaultModel)}))},e.prototype._handleButtonChange=function(e,t,i){if(e<this._buttonIndexToObservableNameMap.length){var r=this[this._buttonIndexToObservableNameMap[e]];r&&r.notifyObservers(t)}},e.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",e.MODEL_FILENAME="generic.babylon",e.GAMEPAD_ID_PREFIX="Gear VR",e})(Xr.WebVRController),Xr.GearVRController=jr,Yr=$a||($a={}),Kr=(function(i){function r(e){var t=i.call(this,e)||this;return t.controllerType=Yr.PoseEnabledControllerType.DAYDREAM,t}return T(r,i),r.prototype.initControllerMesh=function(e,t){var i=this;Yr.SceneLoader.ImportMesh("",r.MODEL_BASE_URL,r.MODEL_FILENAME,e,(function(e){i._defaultModel=e[1],i.attachToMesh(i._defaultModel),t&&t(i._defaultModel)}))},r.prototype._handleButtonChange=function(e,t,i){if(0===e){var r=this.onTriggerStateChangedObservable;r&&r.notifyObservers(t)}else Yr.Tools.Warn("Unrecognized Daydream button index: "+e)},r.MODEL_BASE_URL="https://controllers.babylonjs.com/generic/",r.MODEL_FILENAME="generic.babylon",r.GAMEPAD_ID_PREFIX="Daydream",r})(Yr.WebVRController),Yr.DaydreamController=Kr,(function(t){Object.defineProperty(t.Scene.prototype,"gamepadManager",{get:function(){if(!this._gamepadManager){this._gamepadManager=new t.GamepadManager(this);var e=this._getComponent(t.SceneComponentConstants.NAME_GAMEPAD);e||(e=new i(this),this._addComponent(e))}return this._gamepadManager},enumerable:!0,configurable:!0}),t.FreeCameraInputsManager.prototype.addGamepad=function(){return this.add(new t.FreeCameraGamepadInput),this},t.ArcRotateCameraInputsManager.prototype.addGamepad=function(){return this.add(new t.ArcRotateCameraGamepadInput),this};var i=(function(){function e(e){this.name=t.SceneComponentConstants.NAME_GAMEPAD,this.scene=e}return e.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(t.SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD,this,this._beforeCameraUpdate)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){var e=this.scene._gamepadManager;e&&(e.dispose(),this.scene._gamepadManager=null)},e.prototype._beforeCameraUpdate=function(){var e=this.scene._gamepadManager;e&&e._isMonitoring&&e._checkGamepadsStatus()},e})();t.GamepadSystemSceneComponent=i})($a||($a={})),(function(f){f.Node.AddNodeConstructor("FollowCamera",(function(e,t){return function(){return new i(e,f.Vector3.Zero(),t)}})),f.Node.AddNodeConstructor("ArcFollowCamera",(function(e,t){return function(){return new r(e,0,0,1,null,t)}}));var i=(function(o){function e(e,t,i,r){void 0===r&&(r=null);var n=o.call(this,e,t,i)||this;return n.radius=12,n.rotationOffset=0,n.heightOffset=4,n.cameraAcceleration=.05,n.maxCameraSpeed=20,n.lockedTarget=r,n}return T(e,o),e.prototype._follow=function(e){if(e){var t;if(e.rotationQuaternion){var i=new f.Matrix;e.rotationQuaternion.toRotationMatrix(i),t=Math.atan2(i.m[8],i.m[10])}else t=e.rotation.y;var r=f.Tools.ToRadians(this.rotationOffset)+t,n=e.getAbsolutePosition(),o=n.x+Math.sin(r)*this.radius,s=n.z+Math.cos(r)*this.radius,a=o-this.position.x,l=n.y+this.heightOffset-this.position.y,c=s-this.position.z,h=a*this.cameraAcceleration*2,u=l*this.cameraAcceleration,d=c*this.cameraAcceleration*2;(h>this.maxCameraSpeed||h<-this.maxCameraSpeed)&&(h=h<1?-this.maxCameraSpeed:this.maxCameraSpeed),(u>this.maxCameraSpeed||u<-this.maxCameraSpeed)&&(u=u<1?-this.maxCameraSpeed:this.maxCameraSpeed),(d>this.maxCameraSpeed||d<-this.maxCameraSpeed)&&(d=d<1?-this.maxCameraSpeed:this.maxCameraSpeed),this.position=new f.Vector3(this.position.x+h,this.position.y+u,this.position.z+d),this.setTarget(n)}},e.prototype._checkInputs=function(){o.prototype._checkInputs.call(this),this.lockedTarget&&this._follow(this.lockedTarget)},e.prototype.getClassName=function(){return"FollowCamera"},b([f.serialize()],e.prototype,"radius",void 0),b([f.serialize()],e.prototype,"rotationOffset",void 0),b([f.serialize()],e.prototype,"heightOffset",void 0),b([f.serialize()],e.prototype,"cameraAcceleration",void 0),b([f.serialize()],e.prototype,"maxCameraSpeed",void 0),b([f.serializeAsMeshReference("lockedTargetId")],e.prototype,"lockedTarget",void 0),e})(f.TargetCamera);f.FollowCamera=i;var r=(function(a){function e(e,t,i,r,n,o){var s=a.call(this,e,f.Vector3.Zero(),o)||this;return s.alpha=t,s.beta=i,s.radius=r,s.target=n,s._cartesianCoordinates=f.Vector3.Zero(),s._follow(),s}return T(e,a),e.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)}},e.prototype._checkInputs=function(){a.prototype._checkInputs.call(this),this._follow()},e.prototype.getClassName=function(){return"ArcFollowCamera"},e})(f.TargetCamera);f.ArcFollowCamera=r})($a||($a={})),Qr=$a||($a={}),Zr=(function(n){function e(e,t,i){var r=n.call(this,e,t,i)||this;return r.inputs.addGamepad(),r}return T(e,n),Object.defineProperty(e.prototype,"gamepadAngularSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadAngularSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadAngularSensibility=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"gamepadMoveSensibility",{get:function(){var e=this.inputs.attached.gamepad;return e?e.gamepadMoveSensibility:0},set:function(e){var t=this.inputs.attached.gamepad;t&&(t.gamepadMoveSensibility=e)},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"UniversalCamera"},e})(Qr.TouchCamera),Qr.UniversalCamera=Zr,(function(i){i.Node.AddNodeConstructor("GamepadCamera",(function(e,t){return function(){return new r(e,i.Vector3.Zero(),t)}}));var r=(function(r){function e(e,t,i){return r.call(this,e,t,i)||this}return T(e,r),e.prototype.getClassName=function(){return"GamepadCamera"},e})(i.UniversalCamera);i.GamepadCamera=r})($a||($a={})),qr=$a||($a={}),Jr=(function(){function e(){this._renderPipelines={}}return e.prototype.addPipeline=function(e){this._renderPipelines[e._name]=e},e.prototype.attachCamerasToRenderPipeline=function(e,t,i){void 0===i&&(i=!1);var r=this._renderPipelines[e];r&&r._attachCameras(t,i)},e.prototype.detachCamerasFromRenderPipeline=function(e,t){var i=this._renderPipelines[e];i&&i._detachCameras(t)},e.prototype.enableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._enableEffect(t,i)},e.prototype.disableEffectInPipeline=function(e,t,i){var r=this._renderPipelines[e];r&&r._disableEffect(t,i)},e.prototype.update=function(){for(var e in this._renderPipelines)if(this._renderPipelines.hasOwnProperty(e)){var t=this._renderPipelines[e];t.isSupported?t._update():(t.dispose(),delete this._renderPipelines[e])}},e.prototype._rebuild=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e]._rebuild()}},e.prototype.dispose=function(){for(var e in this._renderPipelines){if(this._renderPipelines.hasOwnProperty(e))this._renderPipelines[e].dispose()}},e})(),qr.PostProcessRenderPipelineManager=Jr,(function(t){Object.defineProperty(t.Scene.prototype,"postProcessRenderPipelineManager",{get:function(){if(!this._postProcessRenderPipelineManager){var e=this._getComponent(t.SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER);e||(e=new i(this),this._addComponent(e)),this._postProcessRenderPipelineManager=new t.PostProcessRenderPipelineManager}return this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0});var i=(function(){function e(e){this.name=t.SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(t.SceneComponentConstants.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(e){this.scene._postProcessRenderPipelineManager&&this.scene._postProcessRenderPipelineManager.update()},e})();t.PostProcessRenderPipelineManagerSceneComponent=i})($a||($a={})),$r=$a||($a={}),en=(function(){function e(e,t,i,r){this._name=t,this._singleInstance=r||!0,this._getPostProcesses=i,this._cameras={},this._indicesForCamera={},this._postProcesses={}}return Object.defineProperty(e.prototype,"isSupported",{get:function(){for(var e in this._postProcesses)if(this._postProcesses.hasOwnProperty(e))for(var t=this._postProcesses[e],i=0;i<t.length;i++)if(!t[i].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),e.prototype._update=function(){},e.prototype._attachCameras=function(e){var t,i=this,r=$r.Tools.MakeArray(e||this._cameras);if(r)for(var n=0;n<r.length;n++){var o=r[n],s=o.name;if(t=this._singleInstance?0:s,!this._postProcesses[t]){var a=this._getPostProcesses();a&&(this._postProcesses[t]=Array.isArray(a)?a:[a])}this._indicesForCamera[s]||(this._indicesForCamera[s]=[]),this._postProcesses[t].forEach((function(e){var t=o.attachPostProcess(e);i._indicesForCamera[s].push(t)})),this._cameras[s]||(this._cameras[s]=o)}},e.prototype._detachCameras=function(e){var t=$r.Tools.MakeArray(e||this._cameras);if(t)for(var i=0;i<t.length;i++){var r=t[i],n=r.name;this._postProcesses[this._singleInstance?0:n].forEach((function(e){r.detachPostProcess(e)})),this._cameras[n]&&(this._cameras[n]=null)}},e.prototype._enable=function(e){var t=this,i=$r.Tools.MakeArray(e||this._cameras);if(i)for(var r=0;r<i.length;r++)for(var n=i[r],o=n.name,s=0;s<this._indicesForCamera[o].length;s++)void 0!==n._postProcesses[this._indicesForCamera[o][s]]&&null!==n._postProcesses[this._indicesForCamera[o][s]]||this._postProcesses[this._singleInstance?0:o].forEach((function(e){i[r].attachPostProcess(e,t._indicesForCamera[o][s])}))},e.prototype._disable=function(e){var t=$r.Tools.MakeArray(e||this._cameras);if(t)for(var i=0;i<t.length;i++){var r=t[i],n=r.name;this._postProcesses[this._singleInstance?0:n].forEach((function(e){r.detachPostProcess(e)}))}},e.prototype.getPostProcesses=function(e){return this._singleInstance?this._postProcesses[0]:e?this._postProcesses[e.name]:null},e})(),$r.PostProcessRenderEffect=en,tn=$a||($a={}),rn=(function(){function e(e,t){this.engine=e,this._name=t,this._renderEffects={},this._renderEffectsForIsolatedPass=new Array,this._cameras=[]}return e.prototype.getClassName=function(){return"PostProcessRenderPipeline"},Object.defineProperty(e.prototype,"isSupported",{get:function(){for(var e in this._renderEffects)if(this._renderEffects.hasOwnProperty(e)&&!this._renderEffects[e].isSupported)return!1;return!0},enumerable:!0,configurable:!0}),e.prototype.addEffect=function(e){this._renderEffects[e._name]=e},e.prototype._rebuild=function(){},e.prototype._enableEffect=function(e,t){var i=this._renderEffects[e];i&&i._enable(tn.Tools.MakeArray(t||this._cameras))},e.prototype._disableEffect=function(e,t){var i=this._renderEffects[e];i&&i._disable(tn.Tools.MakeArray(t||this._cameras))},e.prototype._attachCameras=function(e,t){var i=tn.Tools.MakeArray(e||this._cameras);if(i){var r,n=[];for(r=0;r<i.length;r++){var o=i[r],s=o.name;-1===this._cameras.indexOf(o)?this._cameras[s]=o:t&&n.push(r)}for(r=0;r<n.length;r++)e.splice(n[r],1);for(var a in this._renderEffects)this._renderEffects.hasOwnProperty(a)&&this._renderEffects[a]._attachCameras(i)}},e.prototype._detachCameras=function(e){var t=tn.Tools.MakeArray(e||this._cameras);if(t){for(var i in this._renderEffects)this._renderEffects.hasOwnProperty(i)&&this._renderEffects[i]._detachCameras(t);for(var r=0;r<t.length;r++)this._cameras.splice(this._cameras.indexOf(t[r]),1)}},e.prototype._update=function(){for(var e in this._renderEffects)this._renderEffects.hasOwnProperty(e)&&this._renderEffects[e]._update();for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t].name;this._renderEffectsForIsolatedPass[i]&&this._renderEffectsForIsolatedPass[i]._update()}},e.prototype._reset=function(){this._renderEffects={},this._renderEffectsForIsolatedPass=new Array},e.prototype._enableMSAAOnFirstPostProcess=function(e){var t=Object.keys(this._renderEffects);if(2<=this.engine.webGLVersion&&0<t.length){var i=this._renderEffects[t[0]].getPostProcesses();if(i)return i[0].samples=e,!0}return!1},e.prototype.dispose=function(){},b([tn.serialize()],e.prototype,"_name",void 0),e})(),tn.PostProcessRenderPipeline=rn,nn=$a||($a={}),on=(function(){function e(e,t,i){void 0===t&&(t=nn.Engine.TEXTURETYPE_FLOAT),void 0===i&&(i=null);var c=this;this.useOnlyInActiveCamera=!1;var r=(this._scene=e)._getComponent(nn.SceneComponentConstants.NAME_DEPTHRENDERER);r||(r=new nn.DepthRendererSceneComponent(e),e._addComponent(r)),this._camera=i;var o=e.getEngine();this._depthMap=new nn.RenderTargetTexture("depthMap",{width:o.getRenderWidth(),height:o.getRenderHeight()},this._scene,!1,!0,t),this._depthMap.wrapU=nn.Texture.CLAMP_ADDRESSMODE,this._depthMap.wrapV=nn.Texture.CLAMP_ADDRESSMODE,this._depthMap.refreshRate=1,this._depthMap.renderParticles=!1,this._depthMap.renderList=null,this._depthMap.activeCamera=this._camera,this._depthMap.ignoreCameraViewport=!0,this._depthMap.useCameraPostProcesses=!1,this._depthMap.onClearObservable.add((function(e){e.clear(new nn.Color4(1,1,1,1),!0,!0,!0)}));var s=function(e){var t=e.getRenderingMesh(),i=c._scene,r=i.getEngine(),n=e.getMaterial();if(n){r.setState(n.backFaceCulling,0,!1,i.useRightHandedSystem);var o=t._getInstancesRenderList(e._id);if(!o.mustReturn){var s=r.getCaps().instancedArrays&&null!==o.visibleInstances[e._id],a=c._camera||i.activeCamera;if(c.isReady(e,s)&&a){if(r.enableEffect(c._effect),t._bind(e,c._effect,nn.Material.TriangleFillMode),c._effect.setMatrix("viewProjection",i.getTransformMatrix()),c._effect.setFloat2("depthValues",a.minZ,a.minZ+a.maxZ),n&&n.needAlphaTesting()){var l=n.getAlphaTestTexture();l&&(c._effect.setTexture("diffuseSampler",l),c._effect.setMatrix("diffuseMatrix",l.getTextureMatrix()))}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&c._effect.setMatrices("mBones",t.skeleton.getTransformMatrices(t)),t._processRendering(e,c._effect,nn.Material.TriangleFillMode,o,s,(function(e,t){return c._effect.setMatrix("world",t)}))}}}};this._depthMap.customRenderFunction=function(e,t,i,r){var n;if(r.length){for(o.setColorWrite(!1),n=0;n<r.length;n++)s(r.data[n]);o.setColorWrite(!0)}for(n=0;n<e.length;n++)s(e.data[n]);for(n=0;n<t.length;n++)s(t.data[n])}}return e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i.disableDepthWrite)return!1;var r=[],n=[nn.VertexBuffer.PositionKind],o=e.getMesh();i&&i.needAlphaTesting()&&i.getAlphaTestTexture()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(nn.VertexBuffer.UVKind)&&(n.push(nn.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(nn.VertexBuffer.UV2Kind)&&(n.push(nn.VertexBuffer.UV2Kind),r.push("#define UV2"))),o.useBones&&o.computeBonesUsingShaders?(n.push(nn.VertexBuffer.MatricesIndicesKind),n.push(nn.VertexBuffer.MatricesWeightsKind),4<o.numBoneInfluencers&&(n.push(nn.VertexBuffer.MatricesIndicesExtraKind),n.push(nn.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),t&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var s=r.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._effect=this._scene.getEngine().createEffect("depth",n,["world","mBones","viewProjection","diffuseMatrix","depthValues"],["diffuseSampler"],s)),this._effect.isReady()},e.prototype.getDepthMap=function(){return this._depthMap},e.prototype.dispose=function(){this._depthMap.dispose()},e})(),nn.DepthRenderer=on,(function(i){i.Scene.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=i.Engine.TEXTURETYPE_HALF_FLOAT;else{if(!this.getEngine().getCaps().textureFloatRender)throw"Depth renderer does not support int texture type";t=i.Engine.TEXTURETYPE_FLOAT}this._depthRenderer[e.id]=new i.DepthRenderer(this,t,e)}return this._depthRenderer[e.id]},i.Scene.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 e=(function(){function e(e){this.name=i.SceneComponentConstants.NAME_DEPTHRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(i.SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER,this,this._gatherRenderTargets),this.scene._gatherActiveCameraRenderTargetsStage.registerStep(i.SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER,this,this._gatherActiveCameraRenderTargets)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){for(var e in this.scene._depthRenderer)this.scene._depthRenderer[e].dispose()},e.prototype._gatherRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var i=this.scene._depthRenderer[t];i.useOnlyInActiveCamera||e.push(i.getDepthMap())}},e.prototype._gatherActiveCameraRenderTargets=function(e){if(this.scene._depthRenderer)for(var t in this.scene._depthRenderer){var i=this.scene._depthRenderer[t];i.useOnlyInActiveCamera&&this.scene.activeCamera.id===t&&e.push(i.getDepthMap())}},e})();i.DepthRendererSceneComponent=e})($a||($a={})),sn=$a||($a={}),an=(function(){function e(e,t){void 0===t&&(t=1),this._enablePosition=!1,this._scene=e,this._ratio=t;var i=e._getComponent(sn.SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER);i||(i=new sn.GeometryBufferRendererSceneComponent(e),e._addComponent(i)),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}),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,"scene",{get:function(){return this._scene},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ratio",{get:function(){return this._ratio},enumerable:!0,configurable:!0}),e.prototype.isReady=function(e,t){var i=e.getMaterial();if(i&&i.disableDepthWrite)return!1;var r=[],n=[sn.VertexBuffer.PositionKind,sn.VertexBuffer.NormalKind],o=e.getMesh();i&&i.needAlphaTesting()&&(r.push("#define ALPHATEST"),o.isVerticesDataPresent(sn.VertexBuffer.UVKind)&&(n.push(sn.VertexBuffer.UVKind),r.push("#define UV1")),o.isVerticesDataPresent(sn.VertexBuffer.UV2Kind)&&(n.push(sn.VertexBuffer.UV2Kind),r.push("#define UV2"))),this._enablePosition&&r.push("#define POSITION"),o.useBones&&o.computeBonesUsingShaders?(n.push(sn.VertexBuffer.MatricesIndicesKind),n.push(sn.VertexBuffer.MatricesWeightsKind),4<o.numBoneInfluencers&&(n.push(sn.VertexBuffer.MatricesIndicesExtraKind),n.push(sn.VertexBuffer.MatricesWeightsExtraKind)),r.push("#define NUM_BONE_INFLUENCERS "+o.numBoneInfluencers),r.push("#define BonesPerMesh "+(o.skeleton?o.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),t&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var s=r.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._effect=this._scene.getEngine().createEffect("geometry",n,["world","mBones","viewProjection","diffuseMatrix","view"],["diffuseSampler"],s,void 0,void 0,void 0,{buffersCount:this._enablePosition?3:2})),this._effect.isReady()},e.prototype.getGBuffer=function(){return this._multiRenderTarget},Object.defineProperty(e.prototype,"samples",{get:function(){return this._multiRenderTarget.samples},set:function(e){this._multiRenderTarget.samples=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.getGBuffer().dispose()},e.prototype._createRenderTargets=function(){var l=this,o=this._scene.getEngine(),e=this._enablePosition?3:2;if(this._multiRenderTarget=new sn.MultiRenderTarget("gBuffer",{width:o.getRenderWidth()*this._ratio,height:o.getRenderHeight()*this._ratio},e,this._scene,{generateMipMaps:!1,generateDepthTexture:!0,defaultType:sn.Engine.TEXTURETYPE_FLOAT}),this.isSupported){this._multiRenderTarget.wrapU=sn.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.wrapV=sn.Texture.CLAMP_ADDRESSMODE,this._multiRenderTarget.refreshRate=1,this._multiRenderTarget.renderParticles=!1,this._multiRenderTarget.renderList=null,this._multiRenderTarget.onClearObservable.add((function(e){e.clear(new sn.Color4(0,0,0,1),!0,!0,!0)}));var s=function(e){var t=e.getRenderingMesh(),i=l._scene,r=i.getEngine(),n=e.getMaterial();if(n){r.setState(n.backFaceCulling,0,!1,i.useRightHandedSystem);var o=t._getInstancesRenderList(e._id);if(!o.mustReturn){var s=r.getCaps().instancedArrays&&null!==o.visibleInstances[e._id];if(l.isReady(e,s)){if(r.enableEffect(l._effect),t._bind(e,l._effect,sn.Material.TriangleFillMode),l._effect.setMatrix("viewProjection",i.getTransformMatrix()),l._effect.setMatrix("view",i.getViewMatrix()),n&&n.needAlphaTesting()){var a=n.getAlphaTestTexture();a&&(l._effect.setTexture("diffuseSampler",a),l._effect.setMatrix("diffuseMatrix",a.getTextureMatrix()))}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&l._effect.setMatrices("mBones",t.skeleton.getTransformMatrices(t)),t._processRendering(e,l._effect,sn.Material.TriangleFillMode,o,s,(function(e,t){return l._effect.setMatrix("world",t)}))}}}};this._multiRenderTarget.customRenderFunction=function(e,t,i,r){var n;if(r.length){for(o.setColorWrite(!1),n=0;n<r.length;n++)s(r.data[n]);o.setColorWrite(!0)}for(n=0;n<e.length;n++)s(e.data[n]);for(n=0;n<t.length;n++)s(t.data[n])}}},e})(),sn.GeometryBufferRenderer=an,(function(t){Object.defineProperty(t.Scene.prototype,"geometryBufferRenderer",{get:function(){this._geometryBufferRenderer},set:function(e){e&&e.isSupported&&(this._geometryBufferRenderer=e)},enumerable:!0,configurable:!0}),t.Scene.prototype.enableGeometryBufferRenderer=function(e){return void 0===e&&(e=1),this._geometryBufferRenderer||(this._geometryBufferRenderer=new t.GeometryBufferRenderer(this,e),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null)),this._geometryBufferRenderer},t.Scene.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)};var e=(function(){function e(e){this.name=t.SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER,this.scene=e}return e.prototype.register=function(){this.scene._gatherRenderTargetsStage.registerStep(t.SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER,this,this._gatherRenderTargets)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._gatherRenderTargets=function(e){this.scene._geometryBufferRenderer&&e.push(this.scene._geometryBufferRenderer.getGBuffer())},e})();t.GeometryBufferRendererSceneComponent=e})($a||($a={})),ln=$a||($a={}),cn=(function(a){function e(e,t,i,r){var n=a.call(this,t.getEngine(),e)||this;n.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",n.SSAORenderEffect="SSAORenderEffect",n.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",n.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",n.SSAOCombineRenderEffect="SSAOCombineRenderEffect",n.totalStrength=1,n.radius=1e-4,n.area=.0075,n.fallOff=1e-6,n.base=.5,n._firstUpdate=!0,n._scene=t,n._createRandomTexture(),n._depthTexture=t.enableDepthRenderer().getDepthMap();var o=i.ssaoRatio||i,s=i.combineRatio||i;return n._originalColorPostProcess=new ln.PassPostProcess("SSAOOriginalSceneColor",s,null,ln.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),n._createSSAOPostProcess(o),n._createBlurPostProcess(o),n._createSSAOCombinePostProcess(s),n.addEffect(new ln.PostProcessRenderEffect(t.getEngine(),n.SSAOOriginalSceneColorEffect,function(){return n._originalColorPostProcess},!0)),n.addEffect(new ln.PostProcessRenderEffect(t.getEngine(),n.SSAORenderEffect,function(){return n._ssaoPostProcess},!0)),n.addEffect(new ln.PostProcessRenderEffect(t.getEngine(),n.SSAOBlurHRenderEffect,function(){return n._blurHPostProcess},!0)),n.addEffect(new ln.PostProcessRenderEffect(t.getEngine(),n.SSAOBlurVRenderEffect,function(){return n._blurVPostProcess},!0)),n.addEffect(new ln.PostProcessRenderEffect(t.getEngine(),n.SSAOCombineRenderEffect,function(){return n._ssaoCombinePostProcess},!0)),t.postProcessRenderPipelineManager.addPipeline(n),r&&t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,r),n}return T(e,a),e.prototype.dispose=function(e){void 0===e&&(e=!1);for(var t=0;t<this._scene.cameras.length;t++){var i=this._scene.cameras[t];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableDepthRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),a.prototype.dispose.call(this)},e.prototype._createBlurPostProcess=function(e){var t=this;this._blurHPostProcess=new ln.BlurPostProcess("BlurH",new ln.Vector2(1,0),16,e,null,ln.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,ln.Engine.TEXTURETYPE_UNSIGNED_INT),this._blurVPostProcess=new ln.BlurPostProcess("BlurV",new ln.Vector2(0,1),16,e,null,ln.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,ln.Engine.TEXTURETYPE_UNSIGNED_INT),this._blurHPostProcess.onActivateObservable.add((function(){var e=t._blurHPostProcess.width/t._scene.getEngine().getRenderWidth();t._blurHPostProcess.kernel=16*e})),this._blurVPostProcess.onActivateObservable.add((function(){var e=t._blurVPostProcess.height/t._scene.getEngine().getRenderHeight();t._blurVPostProcess.kernel=16*e}))},e.prototype._rebuild=function(){this._firstUpdate=!0,a.prototype._rebuild.call(this)},e.prototype._createSSAOPostProcess=function(e){var t=this,i=[.5381,.1856,-.4319,.1379,.2486,.443,.3371,.5679,-.0057,-.6999,-.0451,-.0019,.0689,-.1598,-.8547,.056,.0069,-.1843,-.0146,.1402,.0762,.01,-.1924,-.0344,-.3577,-.5301,-.4358,-.3169,.1063,.0158,.0103,-.5869,.0046,-.0897,-.494,.3287,.7119,-.0154,-.0918,-.0533,.0596,-.5411,.0352,-.0631,.546,-.4776,.2847,-.0271];this._ssaoPostProcess=new ln.PostProcess("ssao","ssao",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","area","fallOff","base","range","viewport"],["randomSampler"],e,null,ln.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES 16\n#define SSAO"),this._ssaoPostProcess.onApply=function(e){t._firstUpdate&&(e.setArray3("sampleSphere",i),e.setFloat("samplesFactor",1/16),e.setFloat("randTextureTiles",4)),e.setFloat("totalStrength",t.totalStrength),e.setFloat("radius",t.radius),e.setFloat("area",t.area),e.setFloat("fallOff",t.fallOff),e.setFloat("base",t.base),e.setTexture("textureSampler",t._depthTexture),e.setTexture("randomSampler",t._randomTexture)}},e.prototype._createSSAOCombinePostProcess=function(e){var t=this;this._ssaoCombinePostProcess=new ln.PostProcess("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,ln.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){e.setVector4("viewport",ln.Tmp.Vector4[0].copyFromFloats(0,0,1,1)),e.setTextureFromPostProcess("originalColor",t._originalColorPostProcess)}},e.prototype._createRandomTexture=function(){this._randomTexture=new ln.DynamicTexture("SSAORandomTexture",512,this._scene,!1,ln.Texture.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=ln.Texture.WRAP_ADDRESSMODE,this._randomTexture.wrapV=ln.Texture.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),t=function(e,t){return Math.random()*(t-e)+e},i=ln.Vector3.Zero(),r=0;r<512;r++)for(var n=0;n<512;n++)i.x=Math.floor(255*t(-1,1)),i.y=Math.floor(255*t(-1,1)),i.z=Math.floor(255*t(-1,1)),e.fillStyle="rgb("+i.x+", "+i.y+", "+i.z+")",e.fillRect(r,n,1,1);this._randomTexture.update(!1)},b([ln.serialize()],e.prototype,"totalStrength",void 0),b([ln.serialize()],e.prototype,"radius",void 0),b([ln.serialize()],e.prototype,"area",void 0),b([ln.serialize()],e.prototype,"fallOff",void 0),b([ln.serialize()],e.prototype,"base",void 0),e})(ln.PostProcessRenderPipeline),ln.SSAORenderingPipeline=cn,hn=$a||($a={}),un=(function(l){function r(e,t,i,r){var n=l.call(this,t.getEngine(),e)||this;if(n.SSAOOriginalSceneColorEffect="SSAOOriginalSceneColorEffect",n.SSAORenderEffect="SSAORenderEffect",n.SSAOBlurHRenderEffect="SSAOBlurHRenderEffect",n.SSAOBlurVRenderEffect="SSAOBlurVRenderEffect",n.SSAOCombineRenderEffect="SSAOCombineRenderEffect",n.totalStrength=1,n.maxZ=100,n.minZAspect=.2,n._samples=8,n._textureSamples=1,n._expensiveBlur=!0,n.radius=2,n.base=0,n._firstUpdate=!0,n._bits=new Uint32Array(1),n._scene=t,n._ratio=i,!n.isSupported)return hn.Tools.Error("SSAO 2 needs WebGL 2 support."),n;var o=n._ratio.ssaoRatio||i,s=n._ratio.blurRatio||i,a=t.enableGeometryBufferRenderer();return n._createRandomTexture(),n._depthTexture=a.getGBuffer().textures[0],n._normalTexture=a.getGBuffer().textures[1],n._originalColorPostProcess=new hn.PassPostProcess("SSAOOriginalSceneColor",1,null,hn.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1),n._originalColorPostProcess.samples=n.textureSamples,n._createSSAOPostProcess(1),n._createBlurPostProcess(o,s),n._createSSAOCombinePostProcess(s),n.addEffect(new hn.PostProcessRenderEffect(t.getEngine(),n.SSAOOriginalSceneColorEffect,function(){return n._originalColorPostProcess},!0)),n.addEffect(new hn.PostProcessRenderEffect(t.getEngine(),n.SSAORenderEffect,function(){return n._ssaoPostProcess},!0)),n.addEffect(new hn.PostProcessRenderEffect(t.getEngine(),n.SSAOBlurHRenderEffect,function(){return n._blurHPostProcess},!0)),n.addEffect(new hn.PostProcessRenderEffect(t.getEngine(),n.SSAOBlurVRenderEffect,function(){return n._blurVPostProcess},!0)),n.addEffect(new hn.PostProcessRenderEffect(t.getEngine(),n.SSAOCombineRenderEffect,function(){return n._ssaoCombinePostProcess},!0)),t.postProcessRenderPipelineManager.addPipeline(n),r&&t.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,r),n}return T(r,l),Object.defineProperty(r.prototype,"samples",{get:function(){return this._samples},set:function(e){this._ssaoPostProcess.updateEffect("#define SAMPLES "+e+"\n#define SSAO"),this._samples=e,this._sampleSphere=this._generateHemisphere(),this._firstUpdate=!0},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"textureSamples",{get:function(){return this._textureSamples},set:function(e){this._textureSamples=e,this._originalColorPostProcess.samples=e,this._blurHPostProcess.samples=e,this._blurVPostProcess.samples=e,this._ssaoPostProcess.samples=e,this._ssaoCombinePostProcess.samples=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"expensiveBlur",{get:function(){return this._expensiveBlur},set:function(e){this._blurHPostProcess.updateEffect("#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE "+(e?"1":"0")+"\n",null,["textureSampler","depthSampler"]),this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE "+(e?"1":"0")+"\n",null,["textureSampler","depthSampler"]),this._expensiveBlur=e,this._firstUpdate=!0},enumerable:!0,configurable:!0}),Object.defineProperty(r,"IsSupported",{get:function(){var e=hn.Engine.LastCreatedEngine;return!!e&&e.getCaps().drawBuffersExtension},enumerable:!0,configurable:!0}),r.prototype.dispose=function(e){void 0===e&&(e=!1);for(var t=0;t<this._scene.cameras.length;t++){var i=this._scene.cameras[t];this._originalColorPostProcess.dispose(i),this._ssaoPostProcess.dispose(i),this._blurHPostProcess.dispose(i),this._blurVPostProcess.dispose(i),this._ssaoCombinePostProcess.dispose(i)}this._randomTexture.dispose(),e&&this._scene.disableGeometryBufferRenderer(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),l.prototype.dispose.call(this)},r.prototype._createBlurPostProcess=function(e,t){var i=this;this._samplerOffsets=[];for(var r=this.expensiveBlur,n=-8;n<8;n++)this._samplerOffsets.push(2*n+.5);this._blurHPostProcess=new hn.PostProcess("BlurH","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],e,null,hn.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_H\n#define SAMPLES 16\n#define EXPENSIVE "+(r?"1":"0")+"\n"),this._blurHPostProcess.onApply=function(e){i._scene.activeCamera&&(e.setFloat("outSize",0<i._ssaoCombinePostProcess.width?i._ssaoCombinePostProcess.width:i._originalColorPostProcess.width),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ),e.setFloat("radius",i.radius),e.setTexture("depthSampler",i._depthTexture),i._firstUpdate&&e.setArray("samplerOffsets",i._samplerOffsets))},this._blurVPostProcess=new hn.PostProcess("BlurV","ssao2",["outSize","samplerOffsets","near","far","radius"],["depthSampler"],t,null,hn.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define BILATERAL_BLUR\n#define BILATERAL_BLUR_V\n#define SAMPLES 16\n#define EXPENSIVE "+(r?"1":"0")+"\n"),this._blurVPostProcess.onApply=function(e){i._scene.activeCamera&&(e.setFloat("outSize",0<i._ssaoCombinePostProcess.height?i._ssaoCombinePostProcess.height:i._originalColorPostProcess.height),e.setFloat("near",i._scene.activeCamera.minZ),e.setFloat("far",i._scene.activeCamera.maxZ),e.setFloat("radius",i.radius),e.setTexture("depthSampler",i._depthTexture),i._firstUpdate&&(e.setArray("samplerOffsets",i._samplerOffsets),i._firstUpdate=!1))},this._blurHPostProcess.samples=this.textureSamples,this._blurVPostProcess.samples=this.textureSamples},r.prototype._rebuild=function(){this._firstUpdate=!0,l.prototype._rebuild.call(this)},r.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]},r.prototype._hammersley=function(e,t){return[e/t,this._radicalInverse_VdC(e)]},r.prototype._hemisphereSample_uniform=function(e,t){var i=2*t*Math.PI,r=1-(.85*e+.15),n=Math.sqrt(1-r*r);return new hn.Vector3(Math.cos(i)*n,Math.sin(i)*n,r)},r.prototype._generateHemisphere=function(){for(var e,t=this.samples,i=[],r=0;r<t;){if(t<16)e=this._hemisphereSample_uniform(Math.random(),Math.random());else{var n=this._hammersley(r,t);e=this._hemisphereSample_uniform(n[0],n[1])}i.push(e.x,e.y,e.z),r++}return i},r.prototype._createSSAOPostProcess=function(e){var t=this,i=this.samples;this._sampleSphere=this._generateHemisphere(),this._ssaoPostProcess=new hn.PostProcess("ssao2","ssao2",["sampleSphere","samplesFactor","randTextureTiles","totalStrength","radius","base","range","projection","near","far","texelSize","xViewport","yViewport","maxZ","minZAspect"],["randomSampler","normalSampler"],e,null,hn.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,"#define SAMPLES "+i+"\n#define SSAO"),this._ssaoPostProcess.onApply=function(e){t._firstUpdate&&(e.setArray3("sampleSphere",t._sampleSphere),e.setFloat("randTextureTiles",32)),t._scene.activeCamera&&(e.setFloat("samplesFactor",1/t.samples),e.setFloat("totalStrength",t.totalStrength),e.setFloat2("texelSize",1/t._ssaoPostProcess.width,1/t._ssaoPostProcess.height),e.setFloat("radius",t.radius),e.setFloat("maxZ",t.maxZ),e.setFloat("minZAspect",t.minZAspect),e.setFloat("base",t.base),e.setFloat("near",t._scene.activeCamera.minZ),e.setFloat("far",t._scene.activeCamera.maxZ),e.setFloat("xViewport",Math.tan(t._scene.activeCamera.fov/2)*t._scene.getEngine().getAspectRatio(t._scene.activeCamera,!0)),e.setFloat("yViewport",Math.tan(t._scene.activeCamera.fov/2)),e.setMatrix("projection",t._scene.getProjectionMatrix()),e.setTexture("textureSampler",t._depthTexture),e.setTexture("normalSampler",t._normalTexture),e.setTexture("randomSampler",t._randomTexture))},this._ssaoPostProcess.samples=this.textureSamples},r.prototype._createSSAOCombinePostProcess=function(e){var i=this;this._ssaoCombinePostProcess=new hn.PostProcess("ssaoCombine","ssaoCombine",[],["originalColor","viewport"],e,null,hn.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._ssaoCombinePostProcess.onApply=function(e){var t=i._scene.activeCamera.viewport;e.setVector4("viewport",hn.Tmp.Vector4[0].copyFromFloats(t.x,t.y,t.width,t.height)),e.setTextureFromPostProcess("originalColor",i._originalColorPostProcess)},this._ssaoCombinePostProcess.samples=this.textureSamples},r.prototype._createRandomTexture=function(){this._randomTexture=new hn.DynamicTexture("SSAORandomTexture",128,this._scene,!1,hn.Texture.TRILINEAR_SAMPLINGMODE),this._randomTexture.wrapU=hn.Texture.WRAP_ADDRESSMODE,this._randomTexture.wrapV=hn.Texture.WRAP_ADDRESSMODE;for(var e=this._randomTexture.getContext(),t=function(e,t){return Math.random()*(t-e)+e},i=hn.Vector3.Zero(),r=0;r<128;r++)for(var n=0;n<128;n++)i.x=t(0,1),i.y=t(0,1),i.z=0,i.normalize(),i.scaleInPlace(255),i.x=Math.floor(i.x),i.y=Math.floor(i.y),e.fillStyle="rgb("+i.x+", "+i.y+", "+i.z+")",e.fillRect(r,n,1,1);this._randomTexture.update(!1)},r.prototype.serialize=function(){var e=hn.SerializationHelper.Serialize(this);return e.customType="SSAO2RenderingPipeline",e},r.Parse=function(e,t,i){return hn.SerializationHelper.Parse((function(){return new r(e._name,t,e._ratio)}),e,t,i)},b([hn.serialize()],r.prototype,"totalStrength",void 0),b([hn.serialize()],r.prototype,"maxZ",void 0),b([hn.serialize()],r.prototype,"minZAspect",void 0),b([hn.serialize("samples")],r.prototype,"_samples",void 0),b([hn.serialize("textureSamples")],r.prototype,"_textureSamples",void 0),b([hn.serialize()],r.prototype,"_ratio",void 0),b([hn.serialize("expensiveBlur")],r.prototype,"_expensiveBlur",void 0),b([hn.serialize()],r.prototype,"radius",void 0),b([hn.serialize()],r.prototype,"base",void 0),r})(hn.PostProcessRenderPipeline),hn.SSAO2RenderingPipeline=un,dn=$a||($a={}),fn=(function(s){function e(e,t,i,r,n){void 0===r&&(r=1);var o=s.call(this,i.getEngine(),e)||this;return o.LensChromaticAberrationEffect="LensChromaticAberrationEffect",o.HighlightsEnhancingEffect="HighlightsEnhancingEffect",o.LensDepthOfFieldEffect="LensDepthOfFieldEffect",o._scene=i,o._depthTexture=i.enableDepthRenderer().getDepthMap(),t.grain_texture?o._grainTexture=t.grain_texture:o._createGrainTexture(),o._edgeBlur=t.edge_blur?t.edge_blur:0,o._grainAmount=t.grain_amount?t.grain_amount:0,o._chromaticAberration=t.chromatic_aberration?t.chromatic_aberration:0,o._distortion=t.distortion?t.distortion:0,o._highlightsGain=void 0!==t.dof_gain?t.dof_gain:-1,o._highlightsThreshold=t.dof_threshold?t.dof_threshold:1,o._dofDistance=void 0!==t.dof_focus_distance?t.dof_focus_distance:-1,o._dofAperture=t.dof_aperture?t.dof_aperture:1,o._dofDarken=t.dof_darken?t.dof_darken:0,o._dofPentagon=void 0===t.dof_pentagon||t.dof_pentagon,o._blurNoise=void 0===t.blur_noise||t.blur_noise,o._createChromaticAberrationPostProcess(r),o._createHighlightsPostProcess(r),o._createDepthOfFieldPostProcess(r/4),o.addEffect(new dn.PostProcessRenderEffect(i.getEngine(),o.LensChromaticAberrationEffect,function(){return o._chromaticAberrationPostProcess},!0)),o.addEffect(new dn.PostProcessRenderEffect(i.getEngine(),o.HighlightsEnhancingEffect,function(){return o._highlightsPostProcess},!0)),o.addEffect(new dn.PostProcessRenderEffect(i.getEngine(),o.LensDepthOfFieldEffect,function(){return o._depthOfFieldPostProcess},!0)),-1===o._highlightsGain&&o._disableEffect(o.HighlightsEnhancingEffect,null),i.postProcessRenderPipelineManager.addPipeline(o),n&&i.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(e,n),o}return T(e,s),e.prototype.setEdgeBlur=function(e){this._edgeBlur=e},e.prototype.disableEdgeBlur=function(){this._edgeBlur=0},e.prototype.setGrainAmount=function(e){this._grainAmount=e},e.prototype.disableGrain=function(){this._grainAmount=0},e.prototype.setChromaticAberration=function(e){this._chromaticAberration=e},e.prototype.disableChromaticAberration=function(){this._chromaticAberration=0},e.prototype.setEdgeDistortion=function(e){this._distortion=e},e.prototype.disableEdgeDistortion=function(){this._distortion=0},e.prototype.setFocusDistance=function(e){this._dofDistance=e},e.prototype.disableDepthOfField=function(){this._dofDistance=-1},e.prototype.setAperture=function(e){this._dofAperture=e},e.prototype.setDarkenOutOfFocus=function(e){this._dofDarken=e},e.prototype.enablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect("#define PENTAGON\n")},e.prototype.disablePentagonBokeh=function(){this._highlightsPostProcess.updateEffect()},e.prototype.enableNoiseBlur=function(){this._blurNoise=!0},e.prototype.disableNoiseBlur=function(){this._blurNoise=!1},e.prototype.setHighlightsGain=function(e){this._highlightsGain=e},e.prototype.setHighlightsThreshold=function(e){-1===this._highlightsGain&&(this._highlightsGain=1),this._highlightsThreshold=e},e.prototype.disableHighlights=function(){this._highlightsGain=-1},e.prototype.dispose=function(e){void 0===e&&(e=!1),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._scene.cameras),this._chromaticAberrationPostProcess=null,this._highlightsPostProcess=null,this._depthOfFieldPostProcess=null,this._grainTexture.dispose(),e&&this._scene.disableDepthRenderer()},e.prototype._createChromaticAberrationPostProcess=function(e){var t=this;this._chromaticAberrationPostProcess=new dn.PostProcess("LensChromaticAberration","chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],e,null,dn.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._chromaticAberrationPostProcess.onApply=function(e){e.setFloat("chromatic_aberration",t._chromaticAberration),e.setFloat("screen_width",t._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",t._scene.getEngine().getRenderHeight()),e.setFloat("radialIntensity",1),e.setFloat2("direction",17,17),e.setFloat2("centerPosition",.5,.5)}},e.prototype._createHighlightsPostProcess=function(e){var t=this;this._highlightsPostProcess=new dn.PostProcess("LensHighlights","lensHighlights",["gain","threshold","screen_width","screen_height"],[],e,null,dn.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,this._dofPentagon?"#define PENTAGON\n":""),this._highlightsPostProcess.onApply=function(e){e.setFloat("gain",t._highlightsGain),e.setFloat("threshold",t._highlightsThreshold),e.setTextureFromPostProcess("textureSampler",t._chromaticAberrationPostProcess),e.setFloat("screen_width",t._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",t._scene.getEngine().getRenderHeight())}},e.prototype._createDepthOfFieldPostProcess=function(e){var t=this;this._depthOfFieldPostProcess=new dn.PostProcess("LensDepthOfField","depthOfField",["grain_amount","blur_noise","screen_width","screen_height","distortion","dof_enabled","screen_distance","aperture","darken","edge_blur","highlights","near","far"],["depthSampler","grainSampler","highlightsSampler"],e,null,dn.Texture.TRILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1),this._depthOfFieldPostProcess.onApply=function(e){e.setTexture("depthSampler",t._depthTexture),e.setTexture("grainSampler",t._grainTexture),e.setTextureFromPostProcess("textureSampler",t._highlightsPostProcess),e.setTextureFromPostProcess("highlightsSampler",t._depthOfFieldPostProcess),e.setFloat("grain_amount",t._grainAmount),e.setBool("blur_noise",t._blurNoise),e.setFloat("screen_width",t._scene.getEngine().getRenderWidth()),e.setFloat("screen_height",t._scene.getEngine().getRenderHeight()),e.setFloat("distortion",t._distortion),e.setBool("dof_enabled",-1!==t._dofDistance),e.setFloat("screen_distance",1/(.1-1/t._dofDistance)),e.setFloat("aperture",t._dofAperture),e.setFloat("darken",t._dofDarken),e.setFloat("edge_blur",t._edgeBlur),e.setBool("highlights",-1!==t._highlightsGain),t._scene.activeCamera&&(e.setFloat("near",t._scene.activeCamera.minZ),e.setFloat("far",t._scene.activeCamera.maxZ))}},e.prototype._createGrainTexture=function(){this._grainTexture=new dn.DynamicTexture("LensNoiseTexture",512,this._scene,!1,dn.Texture.BILINEAR_SAMPLINGMODE),this._grainTexture.wrapU=dn.Texture.WRAP_ADDRESSMODE,this._grainTexture.wrapV=dn.Texture.WRAP_ADDRESSMODE;for(var e,t,i,r=this._grainTexture.getContext(),n=0;n<512;n++)for(var o=0;o<512;o++)e=Math.floor(255*(t=.42,i=.58,Math.random()*(i-t)+t)),r.fillStyle="rgb("+e+", "+e+", "+e+")",r.fillRect(n,o,1,1);this._grainTexture.update(!1)},e})(dn.PostProcessRenderPipeline),dn.LensRenderingPipeline=fn,pn=$a||($a={}),mn=(function(s){function c(e,t,i,r,n){void 0===r&&(r=null);var o=s.call(this,t.getEngine(),e)||this;return o.downSampleX4PostProcess=null,o.brightPassPostProcess=null,o.blurHPostProcesses=[],o.blurVPostProcesses=[],o.textureAdderPostProcess=null,o.volumetricLightPostProcess=null,o.volumetricLightSmoothXPostProcess=null,o.volumetricLightSmoothYPostProcess=null,o.volumetricLightMergePostProces=null,o.volumetricLightFinalPostProcess=null,o.luminancePostProcess=null,o.luminanceDownSamplePostProcesses=[],o.hdrPostProcess=null,o.textureAdderFinalPostProcess=null,o.lensFlareFinalPostProcess=null,o.hdrFinalPostProcess=null,o.lensFlarePostProcess=null,o.lensFlareComposePostProcess=null,o.motionBlurPostProcess=null,o.depthOfFieldPostProcess=null,o.fxaaPostProcess=null,o.brightThreshold=1,o.blurWidth=512,o.horizontalBlur=!1,o.exposure=1,o.lensTexture=null,o.volumetricLightCoefficient=.2,o.volumetricLightPower=4,o.volumetricLightBlurScale=64,o.sourceLight=null,o.hdrMinimumLuminance=1,o.hdrDecreaseRate=.5,o.hdrIncreaseRate=.5,o.lensColorTexture=null,o.lensFlareStrength=20,o.lensFlareGhostDispersal=1.4,o.lensFlareHaloWidth=.7,o.lensFlareDistortionStrength=16,o.lensStarTexture=null,o.lensFlareDirtTexture=null,o.depthOfFieldDistance=10,o.depthOfFieldBlurWidth=64,o.motionStrength=1,o.animations=[],o._currentDepthOfFieldSource=null,o._hdrCurrentLuminance=1,o._bloomEnabled=!1,o._depthOfFieldEnabled=!1,o._vlsEnabled=!1,o._lensFlareEnabled=!1,o._hdrEnabled=!1,o._motionBlurEnabled=!1,o._fxaaEnabled=!1,o._motionBlurSamples=64,o._volumetricLightStepsCount=50,o._samples=1,o._cameras=n||[],o._scene=t,o._basePostProcess=r,o._ratio=i,o._floatTextureType=t.getEngine().getCaps().textureFloatRender?pn.Engine.TEXTURETYPE_FLOAT:pn.Engine.TEXTURETYPE_HALF_FLOAT,t.postProcessRenderPipelineManager.addPipeline(o),o._buildPipeline(),o}return T(c,s),Object.defineProperty(c.prototype,"BloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"DepthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"LensFlareEnabled",{get:function(){return this._lensFlareEnabled},set:function(e){this._lensFlareEnabled!==e&&(this._lensFlareEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"HDREnabled",{get:function(){return this._hdrEnabled},set:function(e){this._hdrEnabled!==e&&(this._hdrEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"VLSEnabled",{get:function(){return this._vlsEnabled},set:function(e){if(this._vlsEnabled!==e){if(e)if(!this._scene.enableGeometryBufferRenderer())return void pn.Tools.Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");this._vlsEnabled=e,this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"MotionBlurEnabled",{get:function(){return this._motionBlurEnabled},set:function(e){this._motionBlurEnabled!==e&&(this._motionBlurEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"volumetricLightStepsCount",{get:function(){return this._volumetricLightStepsCount},set:function(e){this.volumetricLightPostProcess&&this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS "+e.toFixed(1)),this._volumetricLightStepsCount=e},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"motionBlurSamples",{get:function(){return this._motionBlurSamples},set:function(e){this.motionBlurPostProcess&&this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+e.toFixed(1)),this._motionBlurSamples=e},enumerable:!0,configurable:!0}),Object.defineProperty(c.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),c.prototype._buildPipeline=function(){var t=this,e=this._ratio,i=this._scene;this._disposePostProcesses(),this._reset(),this._basePostProcess?this.originalPostProcess=this._basePostProcess:(this.originalPostProcess=new pn.PostProcess("HDRPass","standard",[],[],e,null,pn.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",this._floatTextureType),this.originalPostProcess.onApply=function(e){t._currentDepthOfFieldSource=t.originalPostProcess}),(this._bloomEnabled||this._vlsEnabled||this._lensFlareEnabled||this._depthOfFieldEnabled||this._motionBlurEnabled)&&this.addEffect(new pn.PostProcessRenderEffect(i.getEngine(),"HDRPassPostProcess",function(){return t.originalPostProcess},!0)),this._currentDepthOfFieldSource=this.originalPostProcess,this._bloomEnabled&&(this._createDownSampleX4PostProcess(i,e/2),this._createBrightPassPostProcess(i,e/2),this._createBlurPostProcesses(i,e/4,1),this._createTextureAdderPostProcess(i,e),this.textureAdderFinalPostProcess=new pn.PostProcess("HDRDepthOfFieldSource","standard",[],[],e,null,pn.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new pn.PostProcessRenderEffect(i.getEngine(),"HDRBaseDepthOfFieldSource",function(){return t.textureAdderFinalPostProcess},!0))),this._vlsEnabled&&(this._createVolumetricLightPostProcess(i,e),this.volumetricLightFinalPostProcess=new pn.PostProcess("HDRVLSFinal","standard",[],[],e,null,pn.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new pn.PostProcessRenderEffect(i.getEngine(),"HDRVLSFinal",function(){return t.volumetricLightFinalPostProcess},!0))),this._lensFlareEnabled&&(this._createLensFlarePostProcess(i,e),this.lensFlareFinalPostProcess=new pn.PostProcess("HDRPostLensFlareDepthOfFieldSource","standard",[],[],e,null,pn.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new pn.PostProcessRenderEffect(i.getEngine(),"HDRPostLensFlareDepthOfFieldSource",function(){return t.lensFlareFinalPostProcess},!0))),this._hdrEnabled&&(this._createLuminancePostProcesses(i,this._floatTextureType),this._createHdrPostProcess(i,e),this.hdrFinalPostProcess=new pn.PostProcess("HDRPostHDReDepthOfFieldSource","standard",[],[],e,null,pn.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define PASS_POST_PROCESS",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new pn.PostProcessRenderEffect(i.getEngine(),"HDRPostHDReDepthOfFieldSource",function(){return t.hdrFinalPostProcess},!0))),this._depthOfFieldEnabled&&(this._createBlurPostProcesses(i,e/2,3,"depthOfFieldBlurWidth"),this._createDepthOfFieldPostProcess(i,e)),this._motionBlurEnabled&&this._createMotionBlurPostProcess(i,e),this._fxaaEnabled&&(this.fxaaPostProcess=new pn.FxaaPostProcess("fxaa",1,null,pn.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new pn.PostProcessRenderEffect(i.getEngine(),"HDRFxaa",function(){return t.fxaaPostProcess},!0))),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this._samples)&&1<this._samples&&pn.Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")},c.prototype._createDownSampleX4PostProcess=function(e,t){var s=this,a=new Array(32);this.downSampleX4PostProcess=new pn.PostProcess("HDRDownSampleX4","standard",["dsOffsets"],[],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DOWN_SAMPLE_X4",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.downSampleX4PostProcess.onApply=function(e){for(var t=0,i=s.downSampleX4PostProcess.width,r=s.downSampleX4PostProcess.height,n=-2;n<2;n++)for(var o=-2;o<2;o++)a[t]=(n+.5)*(1/i),a[t+1]=(o+.5)*(1/r),t+=2;e.setArray2("dsOffsets",a)},this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRDownSampleX4",function(){return s.downSampleX4PostProcess},!0))},c.prototype._createBrightPassPostProcess=function(e,t){var r=this,n=new Array(8);this.brightPassPostProcess=new pn.PostProcess("HDRBrightPass","standard",["dsOffsets","brightThreshold"],[],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define BRIGHT_PASS",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.brightPassPostProcess.onApply=function(e){var t=1/r.brightPassPostProcess.width,i=1/r.brightPassPostProcess.height;n[0]=-.5*t,n[1]=.5*i,n[2]=.5*t,n[3]=.5*i,n[4]=-.5*t,n[5]=-.5*i,n[6]=.5*t,n[7]=-.5*i,e.setArray2("dsOffsets",n),e.setFloat("brightThreshold",r.brightThreshold)},this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRBrightPass",function(){return r.brightPassPostProcess},!0))},c.prototype._createBlurPostProcesses=function(e,t,i,r){var n=this;void 0===r&&(r="blurWidth");var o=e.getEngine(),s=new pn.BlurPostProcess("HDRBlurH_"+i,new pn.Vector2(1,0),this[r],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,pn.Engine.TEXTURETYPE_UNSIGNED_INT),a=new pn.BlurPostProcess("HDRBlurV_"+i,new pn.Vector2(0,1),this[r],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,pn.Engine.TEXTURETYPE_UNSIGNED_INT);s.onActivateObservable.add((function(){var e=s.width/o.getRenderWidth();s.kernel=n[r]*e})),a.onActivateObservable.add((function(){var e=a.height/o.getRenderHeight();a.kernel=n.horizontalBlur?64*e:n[r]*e})),this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRBlurH"+i,function(){return s},!0)),this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRBlurV"+i,function(){return a},!0)),this.blurHPostProcesses.push(s),this.blurVPostProcesses.push(a)},c.prototype._createTextureAdderPostProcess=function(e,t){var i=this;this.textureAdderPostProcess=new pn.PostProcess("HDRTextureAdder","standard",["exposure"],["otherSampler","lensSampler"],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define TEXTURE_ADDER",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.textureAdderPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._vlsEnabled?i._currentDepthOfFieldSource:i.originalPostProcess),e.setTexture("lensSampler",i.lensTexture),e.setFloat("exposure",i.exposure),i._currentDepthOfFieldSource=i.textureAdderFinalPostProcess},this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRTextureAdder",function(){return i.textureAdderPostProcess},!0))},c.prototype._createVolumetricLightPostProcess=function(e,t){var i=this,r=e.enableGeometryBufferRenderer();r.enablePosition=!0;var n=r.getGBuffer();this.volumetricLightPostProcess=new pn.PostProcess("HDRVLS","standard",["shadowViewProjection","cameraPosition","sunDirection","sunColor","scatteringCoefficient","scatteringPower","depthValues"],["shadowMapSampler","positionSampler"],t/8,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLS\n#define NB_STEPS "+this._volumetricLightStepsCount.toFixed(1));var o=pn.Vector2.Zero();this.volumetricLightPostProcess.onApply=function(e){if(i.sourceLight&&i.sourceLight.getShadowGenerator()&&i._scene.activeCamera){var t=i.sourceLight.getShadowGenerator();e.setTexture("shadowMapSampler",t.getShadowMap()),e.setTexture("positionSampler",n.textures[2]),e.setColor3("sunColor",i.sourceLight.diffuse),e.setVector3("sunDirection",i.sourceLight.getShadowDirection()),e.setVector3("cameraPosition",i._scene.activeCamera.globalPosition),e.setMatrix("shadowViewProjection",t.getTransformMatrix()),e.setFloat("scatteringCoefficient",i.volumetricLightCoefficient),e.setFloat("scatteringPower",i.volumetricLightPower),o.x=i.sourceLight.getDepthMinZ(i._scene.activeCamera),o.y=i.sourceLight.getDepthMaxZ(i._scene.activeCamera),e.setVector2("depthValues",o)}},this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRVLS",function(){return i.volumetricLightPostProcess},!0)),this._createBlurPostProcesses(e,t/4,0,"volumetricLightBlurScale"),this.volumetricLightMergePostProces=new pn.PostProcess("HDRVLSMerge","standard",[],["originalSampler"],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define VLSMERGE"),this.volumetricLightMergePostProces.onApply=function(e){e.setTextureFromPostProcess("originalSampler",i._bloomEnabled?i.textureAdderFinalPostProcess:i.originalPostProcess),i._currentDepthOfFieldSource=i.volumetricLightFinalPostProcess},this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRVLSMerge",function(){return i.volumetricLightMergePostProces},!0))},c.prototype._createLuminancePostProcesses=function(r,e){var a=this,t=Math.pow(3,c.LuminanceSteps);this.luminancePostProcess=new pn.PostProcess("HDRLuminance","standard",["lumOffsets"],[],{width:t,height:t},null,pn.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,"#define LUMINANCE",e);var n=[];this.luminancePostProcess.onApply=function(e){var t=1/a.luminancePostProcess.width,i=1/a.luminancePostProcess.height;n[0]=-.5*t,n[1]=.5*i,n[2]=.5*t,n[3]=.5*i,n[4]=-.5*t,n[5]=-.5*i,n[6]=.5*t,n[7]=-.5*i,e.setArray2("lumOffsets",n)},this.addEffect(new pn.PostProcessRenderEffect(r.getEngine(),"HDRLuminance",function(){return a.luminancePostProcess},!0));for(var i=c.LuminanceSteps-1;0<=i;i--){t=Math.pow(3,i);var o="#define LUMINANCE_DOWN_SAMPLE\n";0===i&&(o+="#define FINAL_DOWN_SAMPLER");var s=new pn.PostProcess("HDRLuminanceDownSample"+i,"standard",["dsOffsets","halfDestPixelSize"],[],{width:t,height:t},null,pn.Texture.BILINEAR_SAMPLINGMODE,r.getEngine(),!1,o,e);this.luminanceDownSamplePostProcesses.push(s)}var l=this.luminancePostProcess;this.luminanceDownSamplePostProcesses.forEach((function(n,o){var s=new Array(18);n.onApply=function(e){if(l){for(var t=0,i=-1;i<2;i++)for(var r=-1;r<2;r++)s[t]=i/l.width,s[t+1]=r/l.height,t+=2;e.setArray2("dsOffsets",s),e.setFloat("halfDestPixelSize",.5/l.width),l=o===a.luminanceDownSamplePostProcesses.length-1?a.luminancePostProcess:n}},o===a.luminanceDownSamplePostProcesses.length-1&&(n.onAfterRender=function(e){var t=r.getEngine().readPixels(0,0,1,1),i=new pn.Vector4(1/16581375,1/65025,1/255,1);a._hdrCurrentLuminance=(t[0]*i.x+t[1]*i.y+t[2]*i.z+t[3]*i.w)/100}),a.addEffect(new pn.PostProcessRenderEffect(r.getEngine(),"HDRLuminanceDownSample"+o,function(){return n},!0))}))},c.prototype._createHdrPostProcess=function(i,e){var r=this;this.hdrPostProcess=new pn.PostProcess("HDR","standard",["averageLuminance"],["textureAdderSampler"],e,null,pn.Texture.BILINEAR_SAMPLINGMODE,i.getEngine(),!1,"#define HDR",pn.Engine.TEXTURETYPE_UNSIGNED_INT);var n=1,o=0,s=0;this.hdrPostProcess.onApply=function(e){if(e.setTextureFromPostProcess("textureAdderSampler",r._currentDepthOfFieldSource),o+=i.getEngine().getDeltaTime(),n<0)n=r._hdrCurrentLuminance;else{var t=(s-o)/1e3;r._hdrCurrentLuminance<n+r.hdrDecreaseRate*t?n+=r.hdrDecreaseRate*t:r._hdrCurrentLuminance>n-r.hdrIncreaseRate*t?n-=r.hdrIncreaseRate*t:n=r._hdrCurrentLuminance}n=pn.Scalar.Clamp(n,r.hdrMinimumLuminance,1e20),e.setFloat("averageLuminance",n),s=o,r._currentDepthOfFieldSource=r.hdrFinalPostProcess},this.addEffect(new pn.PostProcessRenderEffect(i.getEngine(),"HDR",function(){return r.hdrPostProcess},!0))},c.prototype._createLensFlarePostProcess=function(e,t){var s=this;this.lensFlarePostProcess=new pn.PostProcess("HDRLensFlare","standard",["strength","ghostDispersal","haloWidth","resolution","distortionStrength"],["lensColorSampler"],t/2,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRLensFlare",function(){return s.lensFlarePostProcess},!0)),this._createBlurPostProcesses(e,t/4,2),this.lensFlareComposePostProcess=new pn.PostProcess("HDRLensFlareCompose","standard",["lensStarMatrix"],["otherSampler","lensDirtSampler","lensStarSampler"],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define LENS_FLARE_COMPOSE",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRLensFlareCompose",function(){return s.lensFlareComposePostProcess},!0));var i=new pn.Vector2(0,0);this.lensFlarePostProcess.onApply=function(e){e.setTextureFromPostProcess("textureSampler",s._bloomEnabled?s.blurHPostProcesses[0]:s.originalPostProcess),e.setTexture("lensColorSampler",s.lensColorTexture),e.setFloat("strength",s.lensFlareStrength),e.setFloat("ghostDispersal",s.lensFlareGhostDispersal),e.setFloat("haloWidth",s.lensFlareHaloWidth),i.x=s.lensFlarePostProcess.width,i.y=s.lensFlarePostProcess.height,e.setVector2("resolution",i),e.setFloat("distortionStrength",s.lensFlareDistortionStrength)};var a=pn.Matrix.FromValues(2,0,-1,0,0,2,-1,0,0,0,1,0,0,0,0,1),l=pn.Matrix.FromValues(.5,0,.5,0,0,.5,.5,0,0,0,1,0,0,0,0,1);this.lensFlareComposePostProcess.onApply=function(e){if(s._scene.activeCamera){e.setTextureFromPostProcess("otherSampler",s._currentDepthOfFieldSource),e.setTexture("lensDirtSampler",s.lensFlareDirtTexture),e.setTexture("lensStarSampler",s.lensStarTexture);var t=s._scene.activeCamera.getViewMatrix().getRow(0),i=s._scene.activeCamera.getViewMatrix().getRow(2),r=pn.Vector3.Dot(t.toVector3(),new pn.Vector3(1,0,0))+pn.Vector3.Dot(i.toVector3(),new pn.Vector3(0,0,1));r*=4;var n=pn.Matrix.FromValues(.5*Math.cos(r),-Math.sin(r),0,0,Math.sin(r),.5*Math.cos(r),0,0,0,0,1,0,0,0,0,1),o=l.multiply(n).multiply(a);e.setMatrix("lensStarMatrix",o),s._currentDepthOfFieldSource=s.lensFlareFinalPostProcess}}},c.prototype._createDepthOfFieldPostProcess=function(e,t){var i=this;this.depthOfFieldPostProcess=new pn.PostProcess("HDRDepthOfField","standard",["distance"],["otherSampler","depthSampler"],t,null,pn.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,"#define DEPTH_OF_FIELD",pn.Engine.TEXTURETYPE_UNSIGNED_INT),this.depthOfFieldPostProcess.onApply=function(e){e.setTextureFromPostProcess("otherSampler",i._currentDepthOfFieldSource),e.setTexture("depthSampler",i._getDepthTexture()),e.setFloat("distance",i.depthOfFieldDistance)},this.addEffect(new pn.PostProcessRenderEffect(e.getEngine(),"HDRDepthOfField",function(){return i.depthOfFieldPostProcess},!0))},c.prototype._createMotionBlurPostProcess=function(t,e){var i=this;this.motionBlurPostProcess=new pn.PostProcess("HDRMotionBlur","standard",["inverseViewProjection","prevViewProjection","screenSize","motionScale","motionStrength"],["depthSampler"],e,null,pn.Texture.BILINEAR_SAMPLINGMODE,t.getEngine(),!1,"#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES "+this.motionBlurSamples.toFixed(1),pn.Engine.TEXTURETYPE_UNSIGNED_INT);var r=0,n=pn.Matrix.Identity(),o=pn.Matrix.Identity(),s=pn.Matrix.Identity(),a=pn.Vector2.Zero();this.motionBlurPostProcess.onApply=function(e){(s=t.getProjectionMatrix().multiply(t.getViewMatrix())).invertToRef(o),e.setMatrix("inverseViewProjection",o),e.setMatrix("prevViewProjection",n),n=s,a.x=i.motionBlurPostProcess.width,a.y=i.motionBlurPostProcess.height,e.setVector2("screenSize",a),r=t.getEngine().getFps()/60,e.setFloat("motionScale",r),e.setFloat("motionStrength",i.motionStrength),e.setTexture("depthSampler",i._getDepthTexture())},this.addEffect(new pn.PostProcessRenderEffect(t.getEngine(),"HDRMotionBlur",function(){return i.motionBlurPostProcess},!0))},c.prototype._getDepthTexture=function(){return this._scene.getEngine().getCaps().drawBuffersExtension?this._scene.enableGeometryBufferRenderer().getGBuffer().textures[0]:this._scene.enableDepthRenderer().getDepthMap()},c.prototype._disposePostProcesses=function(){for(var e=0;e<this._cameras.length;e++){var t=this._cameras[e];this.originalPostProcess&&this.originalPostProcess.dispose(t),this.downSampleX4PostProcess&&this.downSampleX4PostProcess.dispose(t),this.brightPassPostProcess&&this.brightPassPostProcess.dispose(t),this.textureAdderPostProcess&&this.textureAdderPostProcess.dispose(t),this.textureAdderFinalPostProcess&&this.textureAdderFinalPostProcess.dispose(t),this.volumetricLightPostProcess&&this.volumetricLightPostProcess.dispose(t),this.volumetricLightSmoothXPostProcess&&this.volumetricLightSmoothXPostProcess.dispose(t),this.volumetricLightSmoothYPostProcess&&this.volumetricLightSmoothYPostProcess.dispose(t),this.volumetricLightMergePostProces&&this.volumetricLightMergePostProces.dispose(t),this.volumetricLightFinalPostProcess&&this.volumetricLightFinalPostProcess.dispose(t),this.lensFlarePostProcess&&this.lensFlarePostProcess.dispose(t),this.lensFlareComposePostProcess&&this.lensFlareComposePostProcess.dispose(t);for(var i=0;i<this.luminanceDownSamplePostProcesses.length;i++)this.luminanceDownSamplePostProcesses[i].dispose(t);this.luminancePostProcess&&this.luminancePostProcess.dispose(t),this.hdrPostProcess&&this.hdrPostProcess.dispose(t),this.hdrFinalPostProcess&&this.hdrFinalPostProcess.dispose(t),this.depthOfFieldPostProcess&&this.depthOfFieldPostProcess.dispose(t),this.motionBlurPostProcess&&this.motionBlurPostProcess.dispose(t),this.fxaaPostProcess&&this.fxaaPostProcess.dispose(t);for(i=0;i<this.blurHPostProcesses.length;i++)this.blurHPostProcesses[i].dispose(t);for(i=0;i<this.blurVPostProcesses.length;i++)this.blurVPostProcesses[i].dispose(t)}this.originalPostProcess=null,this.downSampleX4PostProcess=null,this.brightPassPostProcess=null,this.textureAdderPostProcess=null,this.textureAdderFinalPostProcess=null,this.volumetricLightPostProcess=null,this.volumetricLightSmoothXPostProcess=null,this.volumetricLightSmoothYPostProcess=null,this.volumetricLightMergePostProces=null,this.volumetricLightFinalPostProcess=null,this.lensFlarePostProcess=null,this.lensFlareComposePostProcess=null,this.luminancePostProcess=null,this.hdrPostProcess=null,this.hdrFinalPostProcess=null,this.depthOfFieldPostProcess=null,this.motionBlurPostProcess=null,this.fxaaPostProcess=null,this.luminanceDownSamplePostProcesses=[],this.blurHPostProcesses=[],this.blurVPostProcesses=[]},c.prototype.dispose=function(){this._disposePostProcesses(),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),s.prototype.dispose.call(this)},c.prototype.serialize=function(){var e=pn.SerializationHelper.Serialize(this);return this.sourceLight&&(e.sourceLightId=this.sourceLight.id),e.customType="StandardRenderingPipeline",e},c.Parse=function(e,t,i){var r=pn.SerializationHelper.Parse((function(){return new c(e._name,t,e._ratio)}),e,t,i);return e.sourceLightId&&(r.sourceLight=t.getLightByID(e.sourceLightId)),r},c.LuminanceSteps=6,b([pn.serialize()],c.prototype,"brightThreshold",void 0),b([pn.serialize()],c.prototype,"blurWidth",void 0),b([pn.serialize()],c.prototype,"horizontalBlur",void 0),b([pn.serialize()],c.prototype,"exposure",void 0),b([pn.serializeAsTexture("lensTexture")],c.prototype,"lensTexture",void 0),b([pn.serialize()],c.prototype,"volumetricLightCoefficient",void 0),b([pn.serialize()],c.prototype,"volumetricLightPower",void 0),b([pn.serialize()],c.prototype,"volumetricLightBlurScale",void 0),b([pn.serialize()],c.prototype,"hdrMinimumLuminance",void 0),b([pn.serialize()],c.prototype,"hdrDecreaseRate",void 0),b([pn.serialize()],c.prototype,"hdrIncreaseRate",void 0),b([pn.serializeAsTexture("lensColorTexture")],c.prototype,"lensColorTexture",void 0),b([pn.serialize()],c.prototype,"lensFlareStrength",void 0),b([pn.serialize()],c.prototype,"lensFlareGhostDispersal",void 0),b([pn.serialize()],c.prototype,"lensFlareHaloWidth",void 0),b([pn.serialize()],c.prototype,"lensFlareDistortionStrength",void 0),b([pn.serializeAsTexture("lensStarTexture")],c.prototype,"lensStarTexture",void 0),b([pn.serializeAsTexture("lensFlareDirtTexture")],c.prototype,"lensFlareDirtTexture",void 0),b([pn.serialize()],c.prototype,"depthOfFieldDistance",void 0),b([pn.serialize()],c.prototype,"depthOfFieldBlurWidth",void 0),b([pn.serialize()],c.prototype,"motionStrength",void 0),b([pn.serialize()],c.prototype,"_ratio",void 0),b([pn.serialize()],c.prototype,"BloomEnabled",null),b([pn.serialize()],c.prototype,"DepthOfFieldEnabled",null),b([pn.serialize()],c.prototype,"LensFlareEnabled",null),b([pn.serialize()],c.prototype,"HDREnabled",null),b([pn.serialize()],c.prototype,"VLSEnabled",null),b([pn.serialize()],c.prototype,"MotionBlurEnabled",null),b([pn.serialize()],c.prototype,"fxaaEnabled",null),b([pn.serialize()],c.prototype,"volumetricLightStepsCount",null),b([pn.serialize()],c.prototype,"motionBlurSamples",null),b([pn.serialize()],c.prototype,"samples",null),c})(pn.PostProcessRenderPipeline),pn.StandardRenderingPipeline=mn,_n=$a||($a={}),gn=(function(c){function e(e,t,i,r,n,o,s){void 0===i&&(i=null),void 0===s&&(s=_n.Engine.TEXTURETYPE_UNSIGNED_INT);var a=c.call(this,e,"fxaa",["texelSize"],null,t,i,r||_n.Texture.BILINEAR_SAMPLINGMODE,n,o,null,s,"fxaa",void 0,!0)||this,l=a._getDefines();return a.updateEffect(l),a.onApplyObservable.add((function(e){var t=a.texelSize;e.setFloat2("texelSize",t.x,t.y)})),a}return T(e,c),e.prototype._getDefines=function(){var e=this.getEngine();if(!e)return null;var t=e.getGlInfo();return t&&t.renderer&&-1<t.renderer.toLowerCase().indexOf("mali")?"#define MALI 1\n":null},e})(_n.PostProcess),_n.FxaaPostProcess=gn,vn=$a||($a={}),yn=(function(u){function e(e,t,i,r,n,o,s,a,l,c){void 0===l&&(l=vn.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=!1);var h=u.call(this,e,"chromaticAberration",["chromatic_aberration","screen_width","screen_height","direction","radialIntensity","centerPosition"],[],r,n,o,s,a,null,l,void 0,null,c)||this;return h.aberrationAmount=30,h.radialIntensity=0,h.direction=new vn.Vector2(.707,.707),h.centerPosition=new vn.Vector2(.5,.5),h.onApplyObservable.add((function(e){e.setFloat("chromatic_aberration",h.aberrationAmount),e.setFloat("screen_width",t),e.setFloat("screen_height",i),e.setFloat("radialIntensity",h.radialIntensity),e.setFloat2("direction",h.direction.x,h.direction.y),e.setFloat2("centerPosition",h.centerPosition.x,h.centerPosition.y)})),h}return T(e,u),e})(vn.PostProcess),vn.ChromaticAberrationPostProcess=yn,bn=$a||($a={}),Tn=(function(c){function e(e,t,i,r,n,o,s,a){void 0===s&&(s=bn.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1);var l=c.call(this,e,"grain",["intensity","animatedSeed"],[],t,i,r,n,o,null,s,void 0,null,a)||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 T(e,c),e})(bn.PostProcess),bn.GrainPostProcess=Tn,xn=$a||($a={}),En=(function(c){function e(e,t,i,r,n,o,s,a){void 0===s&&(s=xn.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1);var l=c.call(this,e,"sharpen",["sharpnessAmounts","screenSize"],null,t,i,r,n,o,null,s,void 0,null,a)||this;return l.colorAmount=1,l.edgeAmount=.3,l.onApply=function(e){e.setFloat2("screenSize",l.width,l.height),e.setFloat2("sharpnessAmounts",l.edgeAmount,l.colorAmount)},l}return T(e,c),e})(xn.PostProcess),xn.SharpenPostProcess=En,An=$a||($a={}),Pn=(function(x){function e(e,t,i,r,n,o,s,a,l,c,h){void 0===o&&(o=An.Texture.BILINEAR_SAMPLINGMODE),void 0===l&&(l=An.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===c&&(c=""),void 0===h&&(h=!1);var u=x.call(this,e,"kernelBlur",["delta","direction","cameraMinMaxZ"],["circleOfConfusionSampler"],r,n,o,s,a,null,l,"kernelBlur",{varyingCount:0,depCount:0},!0)||this;return u.direction=t,u.blockCompilation=h,u._packedFloat=!1,u._staticDefines="",u._staticDefines=c,u.onApplyObservable.add((function(e){u._outputTexture?e.setFloat2("delta",1/u._outputTexture.width*u.direction.x,1/u._outputTexture.height*u.direction.y):e.setFloat2("delta",1/u.width*u.direction.x,1/u.height*u.direction.y)})),u.kernel=i,u}return T(e,x),Object.defineProperty(e.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(e.prototype,"packedFloat",{get:function(){return this._packedFloat},set:function(e){this._packedFloat!==e&&(this._packedFloat=e,this.blockCompilation||this._updateParameters())},enumerable:!0,configurable:!0}),e.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),this._updateParameters(n,o)},e.prototype._updateParameters=function(e,t){for(var i=this._kernel,r=(i-1)/2,n=[],o=[],s=0,a=0;a<i;a++){var l=a/(i-1),c=this._gaussianWeight(2*l-1);n[a]=a-r,s+=o[a]=c}for(a=0;a<o.length;a++)o[a]/=s;var h=[],u=[],d=[];for(a=0;a<=r;a+=2){var f=Math.min(a+1,Math.floor(r));if(a===f)d.push({o:n[a],w:o[a]});else{var p=f===r,m=o[a]+o[f]*(p?.5:1),_=n[a]+1/(1+o[a]/o[f]);0===_?(d.push({o:n[a],w:o[a]}),d.push({o:n[a+1],w:o[a+1]})):(d.push({o:_,w:m}),d.push({o:-_,w:m}))}}for(a=0;a<d.length;a++)u[a]=d[a].o,h[a]=d[a].w;n=u,o=h;var g=this.getEngine().getCaps().maxVaryingVectors,v=Math.max(g,0)-1,y=Math.min(n.length,v),b="";b+=this._staticDefines,-1!=this._staticDefines.indexOf("DOF")&&(b+="#define CENTER_WEIGHT "+this._glslFloat(o[y-1])+"\r\n",y--);for(a=0;a<y;a++)b+="#define KERNEL_OFFSET"+a+" "+this._glslFloat(n[a])+"\r\n",b+="#define KERNEL_WEIGHT"+a+" "+this._glslFloat(o[a])+"\r\n";var T=0;for(a=v;a<n.length;a++)b+="#define KERNEL_DEP_OFFSET"+T+" "+this._glslFloat(n[a])+"\r\n",b+="#define KERNEL_DEP_WEIGHT"+T+" "+this._glslFloat(o[a])+"\r\n",T++;this.packedFloat&&(b+="#define PACKEDFLOAT 1"),this.blockCompilation=!1,x.prototype.updateEffect.call(this,b,null,null,{varyingCount:y,depCount:T},e,t)},e.prototype._nearestBestKernel=function(e){for(var t=Math.round(e),i=0,r=[t,t-1,t+1,t-2,t+2];i<r.length;i++){var n=r[i];if(n%2!=0&&Math.floor(n/2)%2==0&&0<n)return Math.max(n,3)}return Math.max(t,3)},e.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)},e.prototype._glslFloat=function(e,t){return void 0===t&&(t=8),e.toFixed(t).replace(/0+$/,"")},e})(An.PostProcess),An.BlurPostProcess=Pn,Sn=$a||($a={}),Rn=(function(p){function e(e,t,i,r,n,o,s,a,l,c,h,u,d){void 0===a&&(a=null),void 0===l&&(l=Sn.Texture.BILINEAR_SAMPLINGMODE),void 0===u&&(u=Sn.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===d&&(d=!1);var f=p.call(this,e,i,r,n,o,l=Sn.Texture.BILINEAR_SAMPLINGMODE,c,h,u=Sn.Engine.TEXTURETYPE_UNSIGNED_INT,"#define DOF 1\r\n",d)||this;return f.direction=i,f.onApplyObservable.add((function(e){null!=a&&e.setTextureFromPostProcess("textureSampler",a),e.setTextureFromPostProcessOutput("circleOfConfusionSampler",s),t.activeCamera&&e.setFloat2("cameraMinMaxZ",t.activeCamera.minZ,t.activeCamera.maxZ)})),f}return T(e,p),e})(Sn.BlurPostProcess),Sn.DepthOfFieldBlurPostProcess=Rn,(function(f){var e=function(){};f.DepthOfFieldMergePostProcessOptions=e;var t=(function(d){function e(e,t,r,n,i,o,s,a,l,c,h){void 0===c&&(c=f.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var u=d.call(this,e,"depthOfFieldMerge",[],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2"],i,o,s,a,l,null,c,void 0,null,!0)||this;return u.blurSteps=n,u.onApplyObservable.add((function(i){i.setTextureFromPostProcess("textureSampler",t),i.setTextureFromPostProcessOutput("circleOfConfusionSampler",r),n.forEach((function(e,t){i.setTextureFromPostProcessOutput("blurStep"+(n.length-t-1),e)}))})),h||u.updateEffect(),u}return T(e,d),e.prototype.updateEffect=function(e,t,i,r,n,o){void 0===e&&(e=null),void 0===t&&(t=null),void 0===i&&(i=null),e||(e="",e+="#define BLUR_LEVEL "+(this.blurSteps.length-1)+"\n"),d.prototype.updateEffect.call(this,e,t,i,r,n,o)},e})(f.PostProcess);f.DepthOfFieldMergePostProcess=t})($a||($a={})),Mn=$a||($a={}),Cn=(function(h){function e(e,t,i,r,n,o,s,a,l){void 0===a&&(a=Mn.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===l&&(l=!1);var c=h.call(this,e,"circleOfConfusion",["cameraMinMaxZ","focusDistance","cocPrecalculation"],["depthSampler"],i,r,n,o,s,null,a,void 0,null,l)||this;return c.lensSize=50,c.fStop=1.4,c.focusDistance=2e3,c.focalLength=50,c._depthTexture=null,c._depthTexture=t,c.onApplyObservable.add((function(e){if(c._depthTexture){e.setTexture("depthSampler",c._depthTexture);var t=c.lensSize/c.fStop*c.focalLength/(c.focusDistance-c.focalLength);e.setFloat("focusDistance",c.focusDistance),e.setFloat("cocPrecalculation",t),e.setFloat2("cameraMinMaxZ",c._depthTexture.activeCamera.minZ,c._depthTexture.activeCamera.maxZ)}else Mn.Tools.Warn("No depth texture set on CircleOfConfusionPostProcess")})),c}return T(e,h),Object.defineProperty(e.prototype,"depthTexture",{set:function(e){this._depthTexture=e},enumerable:!0,configurable:!0}),e})(Mn.PostProcess),Mn.CircleOfConfusionPostProcess=Cn,(function(p){var m,e;(e=m=p.DepthOfFieldEffectBlurLevel||(p.DepthOfFieldEffectBlurLevel={}))[e.Low=0]="Low",e[e.Medium=1]="Medium",e[e.High=2]="High";var t=(function(f){function e(e,t,i,r,n){void 0===i&&(i=m.Low),void 0===r&&(r=0),void 0===n&&(n=!1);var o=f.call(this,e.getEngine(),"depth of field",(function(){return o._effects}),!0)||this;o._effects=[],o._circleOfConfusion=new p.CircleOfConfusionPostProcess("circleOfConfusion",t,1,null,p.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n),o._depthOfFieldBlurY=[],o._depthOfFieldBlurX=[];var s=1,a=15;switch(i){case m.High:s=3,a=51;break;case m.Medium:s=2,a=31;break;default:a=15,s=1}for(var l=a/Math.pow(2,s-1),c=1,h=0;h<s;h++){var u=new p.DepthOfFieldBlurPostProcess("verticle blur",e,new p.Vector2(0,1),l,c,null,o._circleOfConfusion,0==h?o._circleOfConfusion:null,p.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n);u.autoClear=!1,c=.75/Math.pow(2,h);var d=new p.DepthOfFieldBlurPostProcess("horizontal blur",e,new p.Vector2(1,0),l,c,null,o._circleOfConfusion,null,p.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n);d.autoClear=!1,o._depthOfFieldBlurY.push(u),o._depthOfFieldBlurX.push(d)}o._effects=[o._circleOfConfusion];for(h=0;h<o._depthOfFieldBlurX.length;h++)o._effects.push(o._depthOfFieldBlurY[h]),o._effects.push(o._depthOfFieldBlurX[h]);return o._dofMerge=new p.DepthOfFieldMergePostProcess("dofMerge",o._circleOfConfusion,o._circleOfConfusion,o._depthOfFieldBlurX,c,null,p.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,r,n),o._dofMerge.autoClear=!1,o._effects.push(o._dofMerge),o}return T(e,f),Object.defineProperty(e.prototype,"focalLength",{get:function(){return this._circleOfConfusion.focalLength},set:function(e){this._circleOfConfusion.focalLength=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fStop",{get:function(){return this._circleOfConfusion.fStop},set:function(e){this._circleOfConfusion.fStop=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"focusDistance",{get:function(){return this._circleOfConfusion.focusDistance},set:function(e){this._circleOfConfusion.focusDistance=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lensSize",{get:function(){return this._circleOfConfusion.lensSize},set:function(e){this._circleOfConfusion.lensSize=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"depthTexture",{set:function(e){this._circleOfConfusion.depthTexture=e},enumerable:!0,configurable:!0}),e.prototype.disposeEffects=function(e){for(var t=0;t<this._effects.length;t++)this._effects[t].dispose(e)},e.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},e.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},e})(p.PostProcessRenderEffect);p.DepthOfFieldEffect=t})($a||($a={})),On=$a||($a={}),Dn=(function(d){function e(e,t,i,r,n,o,s,a,l,c,h){void 0===c&&(c=On.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===h&&(h=!1);var u=d.call(this,e,"bloomMerge",["bloomWeight"],["circleOfConfusionSampler","blurStep0","blurStep1","blurStep2","bloomBlur"],n,o,s,a,l,null,c,void 0,null,!0)||this;return u.weight=r,u.onApplyObservable.add((function(e){e.setTextureFromPostProcess("textureSampler",t),e.setTextureFromPostProcessOutput("bloomBlur",i),e.setFloat("bloomWeight",u.weight)})),h||u.updateEffect(),u}return T(e,d),e})(On.PostProcess),On.BloomMergePostProcess=Dn,In=$a||($a={}),wn=(function(c){function e(e,t,i,r,n,o,s,a){void 0===s&&(s=In.Engine.TEXTURETYPE_UNSIGNED_INT),void 0===a&&(a=!1);var l=c.call(this,e,"extractHighlights",["threshold","exposure"],null,t,i,r,n,o,null,s,void 0,null,a)||this;return l.threshold=.9,l._exposure=1,l._inputPostProcess=null,l.onApplyObservable.add((function(e){l._inputPostProcess&&e.setTextureFromPostProcess("textureSampler",l._inputPostProcess),e.setFloat("threshold",Math.pow(l.threshold,In.ToGammaSpace)),e.setFloat("exposure",l._exposure)})),l}return T(e,c),e})(In.PostProcess),In.ExtractHighlightsPostProcess=wn,Ln=$a||($a={}),Fn=(function(a){function e(e,t,i,r,n,o){void 0===n&&(n=0),void 0===o&&(o=!1);var s=a.call(this,e.getEngine(),"bloom",(function(){return s._effects}),!0)||this;return s.bloomScale=t,s._effects=[],s._downscale=new Ln.ExtractHighlightsPostProcess("highlights",1,null,Ln.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n,o),s._blurX=new Ln.BlurPostProcess("horizontal blur",new Ln.Vector2(1,0),10,t,null,Ln.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n,void 0,o),s._blurX.alwaysForcePOT=!0,s._blurX.autoClear=!1,s._blurY=new Ln.BlurPostProcess("vertical blur",new Ln.Vector2(0,1),10,t,null,Ln.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n,void 0,o),s._blurY.alwaysForcePOT=!0,s._blurY.autoClear=!1,s.kernel=r,s._effects=[s._downscale,s._blurX,s._blurY],s._merge=new Ln.BloomMergePostProcess("bloomMerge",s._downscale,s._blurY,i,t,null,Ln.Texture.BILINEAR_SAMPLINGMODE,e.getEngine(),!1,n,o),s._merge.autoClear=!1,s._effects.push(s._merge),s}return T(e,a),Object.defineProperty(e.prototype,"threshold",{get:function(){return this._downscale.threshold},set:function(e){this._downscale.threshold=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"weight",{get:function(){return this._merge.weight},set:function(e){this._merge.weight=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"kernel",{get:function(){return this._blurX.kernel/this.bloomScale},set:function(e){this._blurX.kernel=e*this.bloomScale,this._blurY.kernel=e*this.bloomScale},enumerable:!0,configurable:!0}),e.prototype.disposeEffects=function(e){for(var t=0;t<this._effects.length;t++)this._effects[t].dispose(e)},e.prototype._updateEffects=function(){for(var e=0;e<this._effects.length;e++)this._effects[e].updateEffect()},e.prototype._isReady=function(){for(var e=0;e<this._effects.length;e++)if(!this._effects[e].isReady())return!1;return!0},e})(Ln.PostProcessRenderEffect),Ln.BloomEffect=Fn,Bn=$a||($a={}),Nn=(function(l){function r(e,t,i,r,n){void 0===e&&(e=""),void 0===t&&(t=!0),void 0===i&&(i=Bn.Engine.LastCreatedScene),void 0===n&&(n=!0);var o=l.call(this,i.getEngine(),e)||this;o._camerasToBeAttached=[],o.SharpenPostProcessId="SharpenPostProcessEffect",o.ImageProcessingPostProcessId="ImageProcessingPostProcessEffect",o.FxaaPostProcessId="FxaaPostProcessEffect",o.ChromaticAberrationPostProcessId="ChromaticAberrationPostProcessEffect",o.GrainPostProcessId="GrainPostProcessEffect",o._glowLayer=null,o.animations=[],o._imageProcessingConfigurationObserver=null,o._sharpenEnabled=!1,o._bloomEnabled=!1,o._depthOfFieldEnabled=!1,o._depthOfFieldBlurLevel=Bn.DepthOfFieldEffectBlurLevel.Low,o._fxaaEnabled=!1,o._imageProcessingEnabled=!0,o._bloomScale=.5,o._chromaticAberrationEnabled=!1,o._grainEnabled=!1,o._buildAllowed=!0,o._resizeObserver=null,o._hardwareScaleLevel=1,o._bloomKernel=64,o._bloomWeight=.15,o._bloomThreshold=.9,o._samples=1,o._hasCleared=!1,o._prevPostProcess=null,o._prevPrevPostProcess=null,o._depthOfFieldSceneObserver=null,o._cameras=r||i.cameras,o._cameras=o._cameras.slice(),o._camerasToBeAttached=o._cameras.slice(),o._buildAllowed=n,o._scene=i;var s=o._scene.getEngine().getCaps();o._hdr=t&&(s.textureHalfFloatRender||s.textureFloatRender),o._hdr?s.textureHalfFloatRender?o._defaultPipelineTextureType=Bn.Engine.TEXTURETYPE_HALF_FLOAT:s.textureFloatRender&&(o._defaultPipelineTextureType=Bn.Engine.TEXTURETYPE_FLOAT):o._defaultPipelineTextureType=Bn.Engine.TEXTURETYPE_UNSIGNED_INT,i.postProcessRenderPipelineManager.addPipeline(o);var a=o._scene.getEngine();return o.sharpen=new Bn.SharpenPostProcess("sharpen",1,null,Bn.Texture.BILINEAR_SAMPLINGMODE,a,!1,o._defaultPipelineTextureType,!0),o._sharpenEffect=new Bn.PostProcessRenderEffect(a,o.SharpenPostProcessId,function(){return o.sharpen},!0),o.depthOfField=new Bn.DepthOfFieldEffect(o._scene,null,o._depthOfFieldBlurLevel,o._defaultPipelineTextureType,!0),o.bloom=new Bn.BloomEffect(o._scene,o._bloomScale,o._bloomWeight,o.bloomKernel,o._defaultPipelineTextureType,!0),o.chromaticAberration=new Bn.ChromaticAberrationPostProcess("ChromaticAberration",a.getRenderWidth(),a.getRenderHeight(),1,null,Bn.Texture.BILINEAR_SAMPLINGMODE,a,!1,o._defaultPipelineTextureType,!0),o._chromaticAberrationEffect=new Bn.PostProcessRenderEffect(a,o.ChromaticAberrationPostProcessId,function(){return o.chromaticAberration},!0),o.grain=new Bn.GrainPostProcess("Grain",1,null,Bn.Texture.BILINEAR_SAMPLINGMODE,a,!1,o._defaultPipelineTextureType,!0),o._grainEffect=new Bn.PostProcessRenderEffect(a,o.GrainPostProcessId,function(){return o.grain},!0),o._resizeObserver=a.onResizeObservable.add((function(){o._hardwareScaleLevel=a.getHardwareScalingLevel(),o.bloomKernel=o.bloomKernel})),o._imageProcessingConfigurationObserver=o._scene.imageProcessingConfiguration.onUpdateParameters.add((function(){o.bloom._downscale._exposure=o._scene.imageProcessingConfiguration.exposure})),o._buildPipeline(),o}return T(r,l),Object.defineProperty(r.prototype,"sharpenEnabled",{get:function(){return this._sharpenEnabled},set:function(e){this._sharpenEnabled!==e&&(this._sharpenEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.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(r.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(r.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(r.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(r.prototype,"bloomEnabled",{get:function(){return this._bloomEnabled},set:function(e){this._bloomEnabled!==e&&(this._bloomEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),r.prototype._rebuildBloom=function(){var e=this.bloom;this.bloom=new Bn.BloomEffect(this._scene,this.bloomScale,this._bloomWeight,this.bloomKernel,this._defaultPipelineTextureType,!1),this.bloom.threshold=e.threshold;for(var t=0;t<this._cameras.length;t++)e.disposeEffects(this._cameras[t])},Object.defineProperty(r.prototype,"depthOfFieldEnabled",{get:function(){return this._depthOfFieldEnabled},set:function(e){this._depthOfFieldEnabled!==e&&(this._depthOfFieldEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"depthOfFieldBlurLevel",{get:function(){return this._depthOfFieldBlurLevel},set:function(e){if(this._depthOfFieldBlurLevel!==e){this._depthOfFieldBlurLevel=e;var t=this.depthOfField;this.depthOfField=new Bn.DepthOfFieldEffect(this._scene,null,this._depthOfFieldBlurLevel,this._defaultPipelineTextureType,!1),this.depthOfField.focalLength=t.focalLength,this.depthOfField.focusDistance=t.focusDistance,this.depthOfField.fStop=t.fStop,this.depthOfField.lensSize=t.lensSize;for(var i=0;i<this._cameras.length;i++)t.disposeEffects(this._cameras[i]);this._buildPipeline()}},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"fxaaEnabled",{get:function(){return this._fxaaEnabled},set:function(e){this._fxaaEnabled!==e&&(this._fxaaEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"samples",{get:function(){return this._samples},set:function(e){this._samples!==e&&(this._samples=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"imageProcessingEnabled",{get:function(){return this._imageProcessingEnabled},set:function(e){this._imageProcessingEnabled!==e&&(this._imageProcessingEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"glowLayerEnabled",{get:function(){return null==this._glowLayer},set:function(e){e&&!this._glowLayer?this._glowLayer=new Bn.GlowLayer("",this._scene):!e&&this._glowLayer&&(this._glowLayer.dispose(),this._glowLayer=null)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"chromaticAberrationEnabled",{get:function(){return this._chromaticAberrationEnabled},set:function(e){this._chromaticAberrationEnabled!==e&&(this._chromaticAberrationEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"grainEnabled",{get:function(){return this._grainEnabled},set:function(e){this._grainEnabled!==e&&(this._grainEnabled=e,this._buildPipeline())},enumerable:!0,configurable:!0}),r.prototype.prepare=function(){var e=this._buildAllowed;this._buildAllowed=!0,this._buildPipeline(),this._buildAllowed=e},r.prototype._setAutoClearAndTextureSharing=function(e,t){void 0===t&&(t=!1),this._hasCleared?e.autoClear=!1:(e.autoClear=!0,this._scene.autoClear=!1,this._hasCleared=!0),t||(this._prevPrevPostProcess?e.shareOutputWith(this._prevPrevPostProcess):e.useOwnOutput(),this._prevPostProcess&&(this._prevPrevPostProcess=this._prevPostProcess),this._prevPostProcess=e)},r.prototype._buildPipeline=function(){var t=this;if(this._buildAllowed){this._scene.autoClear=!0;var e=this._scene.getEngine();if(this._disposePostProcesses(),null!==this._cameras&&(this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._cameras=this._camerasToBeAttached.slice()),this._reset(),this._prevPostProcess=null,this._prevPrevPostProcess=null,this._hasCleared=!1,this.depthOfFieldEnabled){if(1<this._cameras.length){for(var i=0,r=this._cameras;i<r.length;i++){var n=r[i];(o=this._scene.enableDepthRenderer(n)).useOnlyInActiveCamera=!0}this._depthOfFieldSceneObserver=this._scene.onAfterRenderTargetsRenderObservable.add((function(e){-1<t._cameras.indexOf(e.activeCamera)&&(t.depthOfField.depthTexture=e.enableDepthRenderer(e.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 Bn.ImageProcessingPostProcess("imageProcessing",1,null,Bn.Texture.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType),this._hdr?(this.addEffect(new Bn.PostProcessRenderEffect(e,this.ImageProcessingPostProcessId,function(){return t.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 Bn.FxaaPostProcess("fxaa",1,null,Bn.Texture.BILINEAR_SAMPLINGMODE,e,!1,this._defaultPipelineTextureType),this.addEffect(new Bn.PostProcessRenderEffect(e,this.FxaaPostProcessId,function(){return t.fxaa},!0)),this._setAutoClearAndTextureSharing(this.fxaa,!0)),null!==this._cameras&&this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name,this._cameras),!this._enableMSAAOnFirstPostProcess(this.samples)&&1<this.samples&&Bn.Tools.Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0")}},r.prototype._disposePostProcesses=function(e){void 0===e&&(e=!1);for(var t=0;t<this._cameras.length;t++){var i=this._cameras[t];this.imageProcessing&&this.imageProcessing.dispose(i),this.fxaa&&this.fxaa.dispose(i),e&&(this.sharpen&&this.sharpen.dispose(i),this.depthOfField&&(this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver),this.depthOfField.disposeEffects(i)),this.bloom&&this.bloom.disposeEffects(i),this.chromaticAberration&&this.chromaticAberration.dispose(i),this.grain&&this.grain.dispose(i),this._glowLayer&&this._glowLayer.dispose())}this.imageProcessing=null,this.fxaa=null,e&&(this.sharpen=null,this._sharpenEffect=null,this.depthOfField=null,this.bloom=null,this.chromaticAberration=null,this._chromaticAberrationEffect=null,this.grain=null,this._grainEffect=null,this._glowLayer=null)},r.prototype.addCamera=function(e){this._camerasToBeAttached.push(e),this._buildPipeline()},r.prototype.removeCamera=function(e){var t=this._camerasToBeAttached.indexOf(e);this._camerasToBeAttached.splice(t,1),this._buildPipeline()},r.prototype.dispose=function(){this._disposePostProcesses(!0),this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name,this._cameras),this._scene.autoClear=!0,this._resizeObserver&&(this._scene.getEngine().onResizeObservable.remove(this._resizeObserver),this._resizeObserver=null),this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver),l.prototype.dispose.call(this)},r.prototype.serialize=function(){var e=Bn.SerializationHelper.Serialize(this);return e.customType="DefaultRenderingPipeline",e},r.Parse=function(e,t,i){return Bn.SerializationHelper.Parse((function(){return new r(e._name,e._name._hdr,t)}),e,t,i)},b([Bn.serialize()],r.prototype,"sharpenEnabled",null),b([Bn.serialize()],r.prototype,"bloomKernel",null),b([Bn.serialize()],r.prototype,"_bloomWeight",void 0),b([Bn.serialize()],r.prototype,"_bloomThreshold",void 0),b([Bn.serialize()],r.prototype,"_hdr",void 0),b([Bn.serialize()],r.prototype,"bloomWeight",null),b([Bn.serialize()],r.prototype,"bloomThreshold",null),b([Bn.serialize()],r.prototype,"bloomScale",null),b([Bn.serialize()],r.prototype,"bloomEnabled",null),b([Bn.serialize()],r.prototype,"depthOfFieldEnabled",null),b([Bn.serialize()],r.prototype,"depthOfFieldBlurLevel",null),b([Bn.serialize()],r.prototype,"fxaaEnabled",null),b([Bn.serialize()],r.prototype,"samples",null),b([Bn.serialize()],r.prototype,"imageProcessingEnabled",null),b([Bn.serialize()],r.prototype,"glowLayerEnabled",null),b([Bn.serialize()],r.prototype,"chromaticAberrationEnabled",null),b([Bn.serialize()],r.prototype,"grainEnabled",null),r})(Bn.PostProcessRenderPipeline),Bn.DefaultRenderingPipeline=Nn,(function(c){var e=(function(t){function e(){var e=t.call(this)||this;return e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.EXPOSURE=!1,e.rebuild(),e}return T(e,t),e})(c.MaterialDefines);c.ImageProcessingConfigurationDefines=e;var t=(function(){function i(){this.colorCurves=new c.ColorCurves,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._toneMappingType=i.TONEMAPPING_STANDARD,this._contrast=1,this.vignetteStretch=0,this.vignetteCentreX=0,this.vignetteCentreY=0,this.vignetteWeight=1.5,this.vignetteColor=new c.Color4(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=i.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new c.Observable}return Object.defineProperty(i.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"colorGradingTexture",{get:function(){return this._colorGradingTexture},set:function(e){this._colorGradingTexture!==e&&(this._colorGradingTexture=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"toneMappingType",{get:function(){return this._toneMappingType},set:function(e){this._toneMappingType!==e&&(this._toneMappingType=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"contrast",{get:function(){return this._contrast},set:function(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),i.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},i.prototype.getClassName=function(){return"ImageProcessingConfiguration"},i.PrepareUniforms=function(e,t){t.EXPOSURE&&e.push("exposureLinear"),t.CONTRAST&&e.push("contrast"),t.COLORGRADING&&e.push("colorTransformSettings"),t.VIGNETTE&&(e.push("vInverseScreenSize"),e.push("vignetteSettings1"),e.push("vignetteSettings2")),t.COLORCURVES&&c.ColorCurves.PrepareUniforms(e)},i.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},i.prototype.prepareDefines=function(e,t){if(void 0===t&&(t=!1),t!==this.applyByPostProcess||!this._isEnabled)return e.VIGNETTE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.EXPOSURE=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.IMAGEPROCESSING=!1,void(e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess&&this._isEnabled);switch(e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===i._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,e.TONEMAPPING=this.toneMappingEnabled,this._toneMappingType){case i.TONEMAPPING_ACES:e.TONEMAPPING_ACES=!0}e.CONTRAST=1!==this.contrast,e.EXPOSURE=1!==this.exposure,e.COLORCURVES=this.colorCurvesEnabled&&!!this.colorCurves,e.COLORGRADING=this.colorGradingEnabled&&!!this.colorGradingTexture,e.COLORGRADING?e.COLORGRADING3D=this.colorGradingTexture.is3D:e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=this.colorGradingWithGreenDepth,e.SAMPLER3DBGRMAP=this.colorGradingBGR,e.IMAGEPROCESSINGPOSTPROCESS=this.applyByPostProcess,e.IMAGEPROCESSING=e.VIGNETTE||e.TONEMAPPING||e.CONTRAST||e.EXPOSURE||e.COLORCURVES||e.COLORGRADING},i.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},i.prototype.bind=function(e,t){if(void 0===t&&(t=1),this._colorCurvesEnabled&&this.colorCurves&&c.ColorCurves.Bind(this.colorCurves,e),this._vignetteEnabled){var i=1/e.getEngine().getRenderWidth(),r=1/e.getEngine().getRenderHeight();e.setFloat2("vInverseScreenSize",i,r);var n=Math.tan(.5*this.vignetteCameraFov),o=n*t,s=Math.sqrt(o*n);o=c.Tools.Mix(o,s,this.vignetteStretch),n=c.Tools.Mix(n,s,this.vignetteStretch),e.setFloat4("vignetteSettings1",o,n,-o*this.vignetteCentreX,-n*this.vignetteCentreY);var a=-2*this.vignetteWeight;e.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,a)}if(e.setFloat("exposureLinear",this.exposure),e.setFloat("contrast",this.contrast),this.colorGradingTexture){e.setTexture("txColorTransform",this.colorGradingTexture);var l=this.colorGradingTexture.getSize().height;e.setFloat4("colorTransformSettings",(l-1)/l,.5/l,l,this.colorGradingTexture.level)}},i.prototype.clone=function(){return c.SerializationHelper.Clone((function(){return new i}),this)},i.prototype.serialize=function(){return c.SerializationHelper.Serialize(this)},i.Parse=function(e){return c.SerializationHelper.Parse((function(){return new i}),e,null,null)},Object.defineProperty(i,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(i,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!0,configurable:!0}),i.TONEMAPPING_STANDARD=0,i.TONEMAPPING_ACES=1,i._VIGNETTEMODE_MULTIPLY=0,i._VIGNETTEMODE_OPAQUE=1,b([c.serializeAsColorCurves()],i.prototype,"colorCurves",void 0),b([c.serialize()],i.prototype,"_colorCurvesEnabled",void 0),b([c.serializeAsTexture("colorGradingTexture")],i.prototype,"_colorGradingTexture",void 0),b([c.serialize()],i.prototype,"_colorGradingEnabled",void 0),b([c.serialize()],i.prototype,"_colorGradingWithGreenDepth",void 0),b([c.serialize()],i.prototype,"_colorGradingBGR",void 0),b([c.serialize()],i.prototype,"_exposure",void 0),b([c.serialize()],i.prototype,"_toneMappingEnabled",void 0),b([c.serialize()],i.prototype,"_toneMappingType",void 0),b([c.serialize()],i.prototype,"_contrast",void 0),b([c.serialize()],i.prototype,"vignetteStretch",void 0),b([c.serialize()],i.prototype,"vignetteCentreX",void 0),b([c.serialize()],i.prototype,"vignetteCentreY",void 0),b([c.serialize()],i.prototype,"vignetteWeight",void 0),b([c.serializeAsColor4()],i.prototype,"vignetteColor",void 0),b([c.serialize()],i.prototype,"vignetteCameraFov",void 0),b([c.serialize()],i.prototype,"_vignetteBlendMode",void 0),b([c.serialize()],i.prototype,"_vignetteEnabled",void 0),b([c.serialize()],i.prototype,"_applyByPostProcess",void 0),b([c.serialize()],i.prototype,"_isEnabled",void 0),i})();c.ImageProcessingConfiguration=t})($a||($a={})),Vn=$a||($a={}),Un=(function(r){function y(e,t){var i=r.call(this,t)||this;return e&&(i._engine=t.getEngine(),i._textureMatrix=Vn.Matrix.Identity(),i.name=e,i.url=e,i.hasAlpha=!1,i.isCube=!1,i.is3D=1<i._engine.webGLVersion,i.wrapU=Vn.Texture.CLAMP_ADDRESSMODE,i.wrapV=Vn.Texture.CLAMP_ADDRESSMODE,i.wrapR=Vn.Texture.CLAMP_ADDRESSMODE,i.anisotropicFilteringLevel=1,i._texture=i._getFromCache(e,!0),i._texture||(t.useDelayedTextureLoading?i.delayLoadState=Vn.Engine.DELAYLOADSTATE_NOTLOADED:i.loadTexture())),i}return T(y,r),y.prototype.getTextureMatrix=function(){return this._textureMatrix},y.prototype.load3dlTexture=function(){var g,v=this._engine;g=1===v.webGLVersion?v.createRawTexture(null,1,1,Vn.Engine.TEXTUREFORMAT_RGBA,!1,!1,Vn.Texture.BILINEAR_SAMPLINGMODE):v.createRawTexture3D(null,1,1,1,Vn.Engine.TEXTUREFORMAT_RGBA,!1,!1,Vn.Texture.BILINEAR_SAMPLINGMODE),this._texture=g;var e=function(e){if("string"==typeof e){for(var t,i=null,r=null,n=e.split("\n"),o=0,s=0,a=0,l=0,c=0,h=0;h<n.length;h++)if(t=n[h],y._noneEmptyLineRegex.test(t)&&0!==t.indexOf("#")){var u=t.split(" ");if(0!==o){if(0!=o){var d=Math.max(parseInt(u[0]),0),f=Math.max(parseInt(u[1]),0),p=Math.max(parseInt(u[2]),0);c=Math.max(d,c),c=Math.max(f,c),c=Math.max(p,c);var m=4*(s+l*o+a*o*o);r&&(r[m+0]=d,r[m+1]=f,r[m+2]=p),++a%o==0&&++l%o==(a=0)&&(s++,l=0)}}else o=u.length,i=new Uint8Array(o*o*o*4),r=new Float32Array(o*o*o*4)}if(r&&i)for(h=0;h<r.length;h++)if(0<h&&(h+1)%4==0)i[h]=255;else{var _=r[h];i[h]=_/c*255}g.is3D?(g.updateSize(o,o,o),v.updateRawTexture3D(g,i,Vn.Engine.TEXTUREFORMAT_RGBA,!1)):(g.updateSize(o*o,o),v.updateRawTexture(g,i,Vn.Engine.TEXTUREFORMAT_RGBA,!1))}},t=this.getScene();return t?t._loadFile(this.url,e):this._engine._loadFile(this.url,e),this._texture},y.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},y.prototype.clone=function(){var e=new y(this.url,this.getScene());return e.level=this.level,e},y.prototype.delayLoad=function(){this.delayLoadState===Vn.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=Vn.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},y.Parse=function(e,t,i){var r=null;return e.name&&!e.isRenderTarget&&((r=new y(e.name,t)).name=e.name,r.level=e.level),r},y.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},y._noneEmptyLineRegex=/\S+/,y})(Vn.BaseTexture),Vn.ColorGradingTexture=Un,zn=$a||($a={}),Gn=(function(){function d(){this._dirty=!0,this._tempColor=new zn.Color4(0,0,0,0),this._globalCurve=new zn.Color4(0,0,0,0),this._highlightsCurve=new zn.Color4(0,0,0,0),this._midtonesCurve=new zn.Color4(0,0,0,0),this._shadowsCurve=new zn.Color4(0,0,0,0),this._positiveCurve=new zn.Color4(0,0,0,0),this._negativeCurve=new zn.Color4(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(d.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"globalExposure",{get:function(){return this._globalExposure},set:function(e){this._globalExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),d.prototype.getClassName=function(){return"ColorCurves"},d.Bind=function(e,t,i,r,n){void 0===i&&(i="vCameraColorCurvePositive"),void 0===r&&(r="vCameraColorCurveNeutral"),void 0===n&&(n="vCameraColorCurveNegative"),e._dirty&&(e._dirty=!1,e.getColorGradingDataToRef(e._globalHue,e._globalDensity,e._globalSaturation,e._globalExposure,e._globalCurve),e.getColorGradingDataToRef(e._highlightsHue,e._highlightsDensity,e._highlightsSaturation,e._highlightsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._highlightsCurve),e.getColorGradingDataToRef(e._midtonesHue,e._midtonesDensity,e._midtonesSaturation,e._midtonesExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._midtonesCurve),e.getColorGradingDataToRef(e._shadowsHue,e._shadowsDensity,e._shadowsSaturation,e._shadowsExposure,e._tempColor),e._tempColor.multiplyToRef(e._globalCurve,e._shadowsCurve),e._highlightsCurve.subtractToRef(e._midtonesCurve,e._positiveCurve),e._midtonesCurve.subtractToRef(e._shadowsCurve,e._negativeCurve)),t&&(t.setFloat4(i,e._positiveCurve.r,e._positiveCurve.g,e._positiveCurve.b,e._positiveCurve.a),t.setFloat4(r,e._midtonesCurve.r,e._midtonesCurve.g,e._midtonesCurve.b,e._midtonesCurve.a),t.setFloat4(n,e._negativeCurve.r,e._negativeCurve.g,e._negativeCurve.b,e._negativeCurve.a))},d.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},d.prototype.getColorGradingDataToRef=function(e,t,i,r,n){null!=e&&(e=d.clamp(e,0,360),t=d.clamp(t,-100,100),i=d.clamp(i,-100,100),r=d.clamp(r,-100,100),t=d.applyColorGradingSliderNonlinear(t),t*=.5,r=d.applyColorGradingSliderNonlinear(r),t<0&&(t*=-1,e=(e+180)%360),d.fromHSBToRef(e,t,50+.25*r,n),n.scaleToRef(2,n),n.a=1+.01*i)},d.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},d.fromHSBToRef=function(e,t,i,r){var n=d.clamp(e,0,360),o=d.clamp(t/100,0,1),s=d.clamp(i/100,0,1);if(0===o)r.r=s,r.g=s,r.b=s;else{n/=60;var a=Math.floor(n),l=n-a,c=s*(1-o),h=s*(1-o*l),u=s*(1-o*(1-l));switch(a){case 0:r.r=s,r.g=u,r.b=c;break;case 1:r.r=h,r.g=s,r.b=c;break;case 2:r.r=c,r.g=s,r.b=u;break;case 3:r.r=c,r.g=h,r.b=s;break;case 4:r.r=u,r.g=c,r.b=s;break;default:r.r=s,r.g=c,r.b=h}}r.a=1},d.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},d.prototype.clone=function(){return zn.SerializationHelper.Clone((function(){return new d}),this)},d.prototype.serialize=function(){return zn.SerializationHelper.Serialize(this)},d.Parse=function(e){return zn.SerializationHelper.Parse((function(){return new d}),e,null,null)},b([zn.serialize()],d.prototype,"_globalHue",void 0),b([zn.serialize()],d.prototype,"_globalDensity",void 0),b([zn.serialize()],d.prototype,"_globalSaturation",void 0),b([zn.serialize()],d.prototype,"_globalExposure",void 0),b([zn.serialize()],d.prototype,"_highlightsHue",void 0),b([zn.serialize()],d.prototype,"_highlightsDensity",void 0),b([zn.serialize()],d.prototype,"_highlightsSaturation",void 0),b([zn.serialize()],d.prototype,"_highlightsExposure",void 0),b([zn.serialize()],d.prototype,"_midtonesHue",void 0),b([zn.serialize()],d.prototype,"_midtonesDensity",void 0),b([zn.serialize()],d.prototype,"_midtonesSaturation",void 0),b([zn.serialize()],d.prototype,"_midtonesExposure",void 0),d})(),zn.ColorCurves=Gn,kn=$a||($a={}),Wn=(function(u){function e(e,t,i,r,n,o,s,a,l,c){var h=u.call(this,e,"refraction",["baseColor","depth","colorLevel"],["refractionSampler"],o,s,a,l,c)||this;return h.color=i,h.depth=r,h.colorLevel=n,h._ownRefractionTexture=!0,h.onActivateObservable.add((function(e){h._refTexture=h._refTexture||new kn.Texture(t,e.getScene())})),h.onApplyObservable.add((function(e){e.setColor3("baseColor",h.color),e.setFloat("depth",h.depth),e.setFloat("colorLevel",h.colorLevel),e.setTexture("refractionSampler",h._refTexture)})),h}return T(e,u),Object.defineProperty(e.prototype,"refractionTexture",{get:function(){return this._refTexture},set:function(e){this._refTexture&&this._ownRefractionTexture&&this._refTexture.dispose(),this._refTexture=e,this._ownRefractionTexture=!1},enumerable:!0,configurable:!0}),e.prototype.dispose=function(e){this._refTexture&&this._ownRefractionTexture&&(this._refTexture.dispose(),this._refTexture=null),u.prototype.dispose.call(this,e)},e})(kn.PostProcess),kn.RefractionPostProcess=Wn,Hn=$a||($a={}),Xn=(function(a){function e(e,t,i,r,n,o){var s=a.call(this,e,"blackAndWhite",["degree"],null,t,i,r,n,o)||this;return s.degree=1,s.onApplyObservable.add((function(e){e.setFloat("degree",s.degree)})),s}return T(e,a),e})(Hn.PostProcess),Hn.BlackAndWhitePostProcess=Xn,jn=$a||($a={}),Yn=(function(c){function e(e,t,i,r,n,o,s,a){void 0===a&&(a=jn.Engine.TEXTURETYPE_UNSIGNED_INT);var l=c.call(this,e,"convolution",["kernel","screenSize"],null,i,r,n,o,s,null,a)||this;return l.kernel=t,l.onApply=function(e){e.setFloat2("screenSize",l.width,l.height),e.setArray("kernel",l.kernel)},l}return T(e,c),e.EdgeDetect0Kernel=[1,0,-1,0,0,0,-1,0,1],e.EdgeDetect1Kernel=[0,1,0,1,-4,1,0,1,0],e.EdgeDetect2Kernel=[-1,-1,-1,-1,8,-1,-1,-1,-1],e.SharpenKernel=[0,-1,0,-1,5,-1,0,-1,0],e.EmbossKernel=[-2,-1,0,-1,1,1,0,1,2],e.GaussianKernel=[0,1,0,1,1,1,0,1,0],e})(jn.PostProcess),jn.ConvolutionPostProcess=Yn,Kn=$a||($a={}),Qn=(function(l){function e(e,t,i,r,n,o,s){var a=l.call(this,e,"filter",["kernelMatrix"],null,i,r,n,o,s)||this;return a.kernelMatrix=t,a.onApply=function(e){e.setMatrix("kernelMatrix",a.kernelMatrix)},a}return T(e,l),e})(Kn.PostProcess),Kn.FilterPostProcess=Qn,Zn=$a||($a={}),qn=(function(h){function u(e,t,i,r,n,o,s,a,l){void 0===n&&(n=100),void 0===o&&(o=Zn.Texture.BILINEAR_SAMPLINGMODE);var c=h.call(this,e,"volumetricLightScattering",["decay","exposure","weight","meshPositionOnScreen","density"],["lightScatteringSampler"],t.postProcessRatio||t,i,o,s,a,"#define NUM_SAMPLES "+n)||this;return c._screenCoordinates=Zn.Vector2.Zero(),c.customMeshPosition=Zn.Vector3.Zero(),c.useCustomMeshPosition=!1,c.invert=!0,c.excludedMeshes=new Array,c.exposure=.3,c.decay=.96815,c.weight=.58767,c.density=.926,s=(l=null===i?l:i.getScene()).getEngine(),c._viewPort=new Zn.Viewport(0,0,1,1).toGlobal(s.getRenderWidth(),s.getRenderHeight()),c.mesh=null!==r?r:u.CreateDefaultMesh("VolumetricLightScatteringMesh",l),c._createPass(l,t.passRatio||t),c.onActivate=function(e){c.isSupported||c.dispose(e),c.onActivate=null},c.onApplyObservable.add((function(e){c._updateMeshScreenCoordinates(l),e.setTexture("lightScatteringSampler",c._volumetricLightScatteringRTT),e.setFloat("exposure",c.exposure),e.setFloat("decay",c.decay),e.setFloat("weight",c.weight),e.setFloat("density",c.density),e.setVector2("meshPositionOnScreen",c._screenCoordinates)})),c}return T(u,h),Object.defineProperty(u.prototype,"useDiffuseColor",{get:function(){return Zn.Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead"),!1},set:function(e){Zn.Tools.Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead")},enumerable:!0,configurable:!0}),u.prototype.getClassName=function(){return"VolumetricLightScatteringPostProcess"},u.prototype._isReady=function(e,t){var i=e.getMesh();if(i===this.mesh&&i.material)return i.material.isReady(i);var r=[],n=[Zn.VertexBuffer.PositionKind],o=e.getMaterial();o&&(o.needAlphaTesting()&&r.push("#define ALPHATEST"),i.isVerticesDataPresent(Zn.VertexBuffer.UVKind)&&(n.push(Zn.VertexBuffer.UVKind),r.push("#define UV1")),i.isVerticesDataPresent(Zn.VertexBuffer.UV2Kind)&&(n.push(Zn.VertexBuffer.UV2Kind),r.push("#define UV2"))),i.useBones&&i.computeBonesUsingShaders?(n.push(Zn.VertexBuffer.MatricesIndicesKind),n.push(Zn.VertexBuffer.MatricesWeightsKind),r.push("#define NUM_BONE_INFLUENCERS "+i.numBoneInfluencers),r.push("#define BonesPerMesh "+(i.skeleton?i.skeleton.bones.length+1:0))):r.push("#define NUM_BONE_INFLUENCERS 0"),t&&(r.push("#define INSTANCES"),n.push("world0"),n.push("world1"),n.push("world2"),n.push("world3"));var s=r.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._volumetricLightScatteringPass=i.getScene().getEngine().createEffect({vertexElement:"depth",fragmentElement:"volumetricLightScatteringPass"},n,["world","mBones","viewProjection","diffuseMatrix"],["diffuseSampler"],s)),this._volumetricLightScatteringPass.isReady()},u.prototype.setCustomMeshPosition=function(e){this.customMeshPosition=e},u.prototype.getCustomMeshPosition=function(){return this.customMeshPosition},u.prototype.dispose=function(e){var t=e.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);-1!==t&&e.getScene().customRenderTargets.splice(t,1),this._volumetricLightScatteringRTT.dispose(),h.prototype.dispose.call(this,e)},u.prototype.getPass=function(){return this._volumetricLightScatteringRTT},u.prototype._meshExcluded=function(e){return 0<this.excludedMeshes.length&&-1!==this.excludedMeshes.indexOf(e)},u.prototype._createPass=function(c,e){var h=this,t=c.getEngine();this._volumetricLightScatteringRTT=new Zn.RenderTargetTexture("volumetricLightScatteringMap",{width:t.getRenderWidth()*e,height:t.getRenderHeight()*e},c,!1,!0,Zn.Engine.TEXTURETYPE_UNSIGNED_INT),this._volumetricLightScatteringRTT.wrapU=Zn.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.wrapV=Zn.Texture.CLAMP_ADDRESSMODE,this._volumetricLightScatteringRTT.renderList=null,this._volumetricLightScatteringRTT.renderParticles=!1,this._volumetricLightScatteringRTT.ignoreCameraViewport=!0;var i=this.getCamera();i?i.customRenderTargets.push(this._volumetricLightScatteringRTT):c.customRenderTargets.push(this._volumetricLightScatteringRTT);var r,u=function(e){var t=e.getRenderingMesh();if(!h._meshExcluded(t)){var i=e.getMaterial();if(i){var r=t.getScene(),n=r.getEngine();n.setState(i.backFaceCulling);var o=t._getInstancesRenderList(e._id);if(!o.mustReturn){var s=n.getCaps().instancedArrays&&null!==o.visibleInstances[e._id];if(h._isReady(e,s)){var a=h._volumetricLightScatteringPass;if(t===h.mesh&&(a=e.effect?e.effect:i.getEffect()),n.enableEffect(a),t._bind(e,a,Zn.Material.TriangleFillMode),t===h.mesh)i.bind(t.getWorldMatrix(),t);else{if(h._volumetricLightScatteringPass.setMatrix("viewProjection",r.getTransformMatrix()),i&&i.needAlphaTesting()){var l=i.getAlphaTestTexture();h._volumetricLightScatteringPass.setTexture("diffuseSampler",l),l&&h._volumetricLightScatteringPass.setMatrix("diffuseMatrix",l.getTextureMatrix())}t.useBones&&t.computeBonesUsingShaders&&t.skeleton&&h._volumetricLightScatteringPass.setMatrices("mBones",t.skeleton.getTransformMatrices(t))}t._processRendering(e,h._volumetricLightScatteringPass,Zn.Material.TriangleFillMode,o,s,(function(e,t){return a.setMatrix("world",t)}))}}}}},n=new Zn.Color4(0,0,0,1);this._volumetricLightScatteringRTT.onBeforeRenderObservable.add((function(){r=c.clearColor,c.clearColor=n})),this._volumetricLightScatteringRTT.onAfterRenderObservable.add((function(){c.clearColor=r})),this._volumetricLightScatteringRTT.customRenderFunction=function(e,t,i,r){var n,o=c.getEngine();if(r.length){for(o.setColorWrite(!1),n=0;n<r.length;n++)u(r.data[n]);o.setColorWrite(!0)}for(n=0;n<e.length;n++)u(e.data[n]);for(n=0;n<t.length;n++)u(t.data[n]);if(i.length){for(n=0;n<i.length;n++){var s=i.data[n],a=s.getBoundingInfo();a&&c.activeCamera&&(s._alphaIndex=s.getMesh().alphaIndex,s._distanceToCamera=a.boundingSphere.centerWorld.subtract(c.activeCamera.position).length())}var l=i.data.slice(0,i.length);for(l.sort((function(e,t){return e._alphaIndex>t._alphaIndex?1:e._alphaIndex<t._alphaIndex?-1:e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0})),o.setAlphaMode(Zn.Engine.ALPHA_COMBINE),n=0;n<l.length;n++)u(l[n]);o.setAlphaMode(Zn.Engine.ALPHA_DISABLE)}}},u.prototype._updateMeshScreenCoordinates=function(e){var t,i=e.getTransformMatrix();t=this.useCustomMeshPosition?this.customMeshPosition:this.attachedNode?this.attachedNode.position:this.mesh.parent?this.mesh.getAbsolutePosition():this.mesh.position;var r=Zn.Vector3.Project(t,Zn.Matrix.Identity(),i,this._viewPort);this._screenCoordinates.x=r.x/this._viewPort.width,this._screenCoordinates.y=r.y/this._viewPort.height,this.invert&&(this._screenCoordinates.y=1-this._screenCoordinates.y)},u.CreateDefaultMesh=function(e,t){var i=Zn.Mesh.CreatePlane(e,1,t);i.billboardMode=Zn.AbstractMesh.BILLBOARDMODE_ALL;var r=new Zn.StandardMaterial(e+"Material",t);return r.emissiveColor=new Zn.Color3(1,1,1),i.material=r,i},b([Zn.serializeAsVector3()],u.prototype,"customMeshPosition",void 0),b([Zn.serialize()],u.prototype,"useCustomMeshPosition",void 0),b([Zn.serialize()],u.prototype,"invert",void 0),b([Zn.serializeAsMeshReference()],u.prototype,"mesh",void 0),b([Zn.serialize()],u.prototype,"excludedMeshes",void 0),b([Zn.serialize()],u.prototype,"exposure",void 0),b([Zn.serialize()],u.prototype,"decay",void 0),b([Zn.serialize()],u.prototype,"weight",void 0),b([Zn.serialize()],u.prototype,"density",void 0),u})(Zn.PostProcess),Zn.VolumetricLightScatteringPostProcess=qn,Jn=$a||($a={}),$n=(function(l){function e(e,t,i,r,n,o,s){var a=l.call(this,e,"colorCorrection",null,["colorTable"],i,r,n,o,s)||this;return a._colorTableTexture=new Jn.Texture(t,r.getScene(),!0,!1,Jn.Texture.TRILINEAR_SAMPLINGMODE),a._colorTableTexture.anisotropicFilteringLevel=1,a._colorTableTexture.wrapU=Jn.Texture.CLAMP_ADDRESSMODE,a._colorTableTexture.wrapV=Jn.Texture.CLAMP_ADDRESSMODE,a.onApply=function(e){e.setTexture("colorTable",a._colorTableTexture)},a}return T(e,l),e})(Jn.PostProcess),Jn.ColorCorrectionPostProcess=$n,(function(h){var u,e;(e=u=h.TonemappingOperator||(h.TonemappingOperator={}))[e.Hable=0]="Hable",e[e.Reinhard=1]="Reinhard",e[e.HejiDawson=2]="HejiDawson",e[e.Photographic=3]="Photographic";var t=(function(c){function e(e,t,i,r,n,o,s){void 0===n&&(n=h.Texture.BILINEAR_SAMPLINGMODE),void 0===s&&(s=h.Engine.TEXTURETYPE_UNSIGNED_INT);var a=c.call(this,e,"tonemap",["_ExposureAdjustment"],null,1,r,n,o,!0,null,s)||this;a._operator=t,a.exposureAdjustment=i;var l="#define ";return a._operator===u.Hable?l+="HABLE_TONEMAPPING":a._operator===u.Reinhard?l+="REINHARD_TONEMAPPING":a._operator===u.HejiDawson?l+="OPTIMIZED_HEJIDAWSON_TONEMAPPING":a._operator===u.Photographic&&(l+="PHOTOGRAPHIC_TONEMAPPING"),a.updateEffect(l),a.onApply=function(e){e.setFloat("_ExposureAdjustment",a.exposureAdjustment)},a}return T(e,c),e})(h.PostProcess);h.TonemapPostProcess=t})($a||($a={})),eo=$a||($a={}),to=(function(s){function e(e,t,i,r,n,o){return s.call(this,e,"displayPass",["passSampler"],["passSampler"],t,i,r,n,o)||this}return T(e,s),e})(eo.PostProcess),eo.DisplayPassPostProcess=to,io=$a||($a={}),ro=(function(a){function e(e,t,i,r,n,o,s){return void 0===s&&(s=io.Engine.TEXTURETYPE_UNSIGNED_INT),a.call(this,e,"highlights",null,null,t,i,r,n,o,null,s)||this}return T(e,a),e})(io.PostProcess),io.HighlightsPostProcess=ro,no=$a||($a={}),oo=(function(c){function e(e,t,i,r,n,o,s,a){void 0===i&&(i=null),void 0===s&&(s=no.Engine.TEXTURETYPE_UNSIGNED_INT);var l=c.call(this,e,"imageProcessing",[],[],t,i,r,n,o,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},a?(a.applyByPostProcess=!0,l._attachImageProcessingConfiguration(a,!0),l.fromLinearSpace=!1):(l._attachImageProcessingConfiguration(null,!0),l.imageProcessingConfiguration.applyByPostProcess=!0),l.onApply=function(e){l.imageProcessingConfiguration.bind(e,l.aspectRatio)},l}return T(e,c),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,t){var i=this;if(void 0===t&&(t=!1),e!==this._imageProcessingConfiguration){if(this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),e)this._imageProcessingConfiguration=e;else{var r=null,n=this.getEngine(),o=this.getCamera();if(o)r=o.getScene();else if(n&&n.scenes){var s=n.scenes;r=s[s.length-1]}else r=no.Engine.LastCreatedScene;this._imageProcessingConfiguration=r.imageProcessingConfiguration}this._imageProcessingConfiguration&&(this._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){i._updateParameters()}))),t||this._updateParameters()}},Object.defineProperty(e.prototype,"colorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingTexture",{get:function(){return this.imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"colorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"exposure",{get:function(){return this.imageProcessingConfiguration.exposure},set:function(e){this.imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"toneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"contrast",{get:function(){return this.imageProcessingConfiguration.contrast},set:function(e){this.imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteStretch",{get:function(){return this.imageProcessingConfiguration.vignetteStretch},set:function(e){this.imageProcessingConfiguration.vignetteStretch=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteCentreX",{get:function(){return this.imageProcessingConfiguration.vignetteCentreX},set:function(e){this.imageProcessingConfiguration.vignetteCentreX=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteCentreY",{get:function(){return this.imageProcessingConfiguration.vignetteCentreY},set:function(e){this.imageProcessingConfiguration.vignetteCentreY=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteWeight",{get:function(){return this.imageProcessingConfiguration.vignetteWeight},set:function(e){this.imageProcessingConfiguration.vignetteWeight=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteColor",{get:function(){return this.imageProcessingConfiguration.vignetteColor},set:function(e){this.imageProcessingConfiguration.vignetteColor=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteCameraFov",{get:function(){return this.imageProcessingConfiguration.vignetteCameraFov},set:function(e){this.imageProcessingConfiguration.vignetteCameraFov=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteBlendMode",{get:function(){return this.imageProcessingConfiguration.vignetteBlendMode},set:function(e){this.imageProcessingConfiguration.vignetteBlendMode=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"vignetteEnabled",{get:function(){return this.imageProcessingConfiguration.vignetteEnabled},set:function(e){this.imageProcessingConfiguration.vignetteEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fromLinearSpace",{get:function(){return this._fromLinearSpace},set:function(e){this._fromLinearSpace!==e&&(this._fromLinearSpace=e,this._updateParameters())},enumerable:!0,configurable:!0}),e.prototype.getClassName=function(){return"ImageProcessingPostProcess"},e.prototype._updateParameters=function(){this._defines.FROMLINEARSPACE=this._fromLinearSpace,this.imageProcessingConfiguration.prepareDefines(this._defines,!0);var e="";for(var t in this._defines)this._defines[t]&&(e+="#define "+t+";\r\n");var i=["textureSampler"],r=["scale"];no.ImageProcessingConfiguration&&(no.ImageProcessingConfiguration.PrepareSamplers(i,this._defines),no.ImageProcessingConfiguration.PrepareUniforms(r,this._defines)),this.updateEffect(e,r,i)},e.prototype.dispose=function(e){c.prototype.dispose.call(this,e),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),this._imageProcessingConfiguration&&(this.imageProcessingConfiguration.applyByPostProcess=!1)},b([no.serialize()],e.prototype,"_fromLinearSpace",void 0),e})(no.PostProcess),no.ImageProcessingPostProcess=oo,so=$a||($a={}),ao=(function(l){function d(e,t,i,r,n,o,s){void 0===i&&(i=null),void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null);var a=l.call(this,e,t.getScene())||this;return a.name=e,a.children=new Array,a.animations=new Array,a._index=null,a._absoluteTransform=new so.Matrix,a._invertedAbsoluteTransform=new so.Matrix,a._scalingDeterminant=1,a._worldTransform=new so.Matrix,a._needToDecompose=!0,a._needToCompose=!1,a._skeleton=t,a._localMatrix=r?r.clone():so.Matrix.Identity(),a._restPose=n||a._localMatrix.clone(),a._baseMatrix=o||a._localMatrix.clone(),a._index=s,t.bones.push(a),a.setParent(i,!1),(o||r)&&a._updateDifferenceMatrix(),a}return T(d,l),Object.defineProperty(d.prototype,"_matrix",{get:function(){return this._compose(),this._localMatrix},set:function(e){this._localMatrix.copyFrom(e),this._needToDecompose=!0},enumerable:!0,configurable:!0}),d.prototype.getSkeleton=function(){return this._skeleton},d.prototype.getParent=function(){return this._parent},d.prototype.setParent=function(e,t){if(void 0===t&&(t=!0),this._parent!==e){if(this._parent){var i=this._parent.children.indexOf(this);-1!==i&&this._parent.children.splice(i,1)}this._parent=e,this._parent&&this._parent.children.push(this),t&&this._updateDifferenceMatrix(),this.markAsDirty()}},d.prototype.getLocalMatrix=function(){return this._compose(),this._localMatrix},d.prototype.getBaseMatrix=function(){return this._baseMatrix},d.prototype.getRestPose=function(){return this._restPose},d.prototype.getWorldMatrix=function(){return this._worldTransform},d.prototype.returnToRest=function(){this.updateMatrix(this._restPose.clone())},d.prototype.getInvertedAbsoluteTransform=function(){return this._invertedAbsoluteTransform},d.prototype.getAbsoluteTransform=function(){return this._absoluteTransform},Object.defineProperty(d.prototype,"position",{get:function(){return this._decompose(),this._localPosition},set:function(e){this._decompose(),this._localPosition.copyFrom(e),this._markAsDirtyAndCompose()},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"rotation",{get:function(){return this.getRotation()},set:function(e){this.setRotation(e)},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"rotationQuaternion",{get:function(){return this._decompose(),this._localRotation},set:function(e){this.setRotationQuaternion(e)},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"scaling",{get:function(){return this.getScale()},set:function(e){this.setScale(e)},enumerable:!0,configurable:!0}),Object.defineProperty(d.prototype,"animationPropertiesOverride",{get:function(){return this._skeleton.animationPropertiesOverride},enumerable:!0,configurable:!0}),d.prototype._decompose=function(){this._needToDecompose&&(this._needToDecompose=!1,this._localScaling||(this._localScaling=so.Vector3.Zero(),this._localRotation=so.Quaternion.Zero(),this._localPosition=so.Vector3.Zero()),this._localMatrix.decompose(this._localScaling,this._localRotation,this._localPosition))},d.prototype._compose=function(){this._needToCompose&&(this._needToCompose=!1,so.Matrix.ComposeToRef(this._localScaling,this._localRotation,this._localPosition,this._localMatrix))},d.prototype.updateMatrix=function(e,t,i){void 0===t&&(t=!0),void 0===i&&(i=!0),this._baseMatrix.copyFrom(e),t&&this._updateDifferenceMatrix(),i?(this._localMatrix.copyFrom(e),this._markAsDirtyAndDecompose()):this.markAsDirty()},d.prototype._updateDifferenceMatrix=function(e,t){if(void 0===t&&(t=!0),e||(e=this._baseMatrix),this._parent?e.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform):this._absoluteTransform.copyFrom(e),this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform),t)for(var i=0;i<this.children.length;i++)this.children[i]._updateDifferenceMatrix();this._scalingDeterminant=this._absoluteTransform.determinant()<0?-1:1},d.prototype.markAsDirty=function(){this._currentRenderId++,this._childRenderId++,this._skeleton._markAsDirty()},d.prototype._markAsDirtyAndCompose=function(){this.markAsDirty(),this._needToCompose=!0},d.prototype._markAsDirtyAndDecompose=function(){this.markAsDirty(),this._needToDecompose=!0},d.prototype.copyAnimationRange=function(e,t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null),0===this.animations.length&&(this.animations.push(new so.Animation(this.name,"_matrix",e.animations[0].framePerSecond,so.Animation.ANIMATIONTYPE_MATRIX,0)),this.animations[0].setKeys([]));var o=e.animations[0].getRange(t);if(!o)return!1;for(var s,a,l,c=o.from,h=o.to,u=e.animations[0].getKeys(),d=e.length,f=e.getParent(),p=this.getParent(),m=r&&f&&d&&this.length&&d!==this.length,_=m&&p&&f?p.length/f.length:1,g=r&&!p&&n&&(1!==n.x||1!==n.y||1!==n.z),v=this.animations[0].getKeys(),y=0,b=u.length;y<b;y++)(s=u[y]).frame>=c&&s.frame<=h&&(r?(l=s.value.clone(),m?(a=l.getTranslation(),l.setTranslation(a.scaleInPlace(_))):g&&n?(a=l.getTranslation(),l.setTranslation(a.multiplyInPlace(n))):l=s.value):l=s.value,v.push({frame:s.frame+i,value:l}));return this.animations[0].createRange(t,c+i,h+i),!0},d.prototype.translate=function(e,t,i){void 0===t&&(t=so.Space.LOCAL);var r=this.getLocalMatrix();if(t==so.Space.LOCAL)r.m[12]+=e.x,r.m[13]+=e.y,r.m[14]+=e.z;else{var n=null;i&&(n=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var o=d._tmpMats[0],s=d._tmpVecs[0];this._parent&&(i&&n?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(n,o)):o.copyFrom(this._parent.getAbsoluteTransform())),o.m[12]=0,o.m[13]=0,o.m[14]=0,o.invert(),so.Vector3.TransformCoordinatesToRef(e,o,s),r.m[12]+=s.x,r.m[13]+=s.y,r.m[14]+=s.z}this._markAsDirtyAndDecompose()},d.prototype.setPosition=function(e,t,i){void 0===t&&(t=so.Space.LOCAL);var r=this.getLocalMatrix();if(t==so.Space.LOCAL)r.m[12]=e.x,r.m[13]=e.y,r.m[14]=e.z;else{var n=null;i&&(n=i.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var o=d._tmpMats[0],s=d._tmpVecs[0];this._parent&&(i&&n?(o.copyFrom(this._parent.getAbsoluteTransform()),o.multiplyToRef(n,o)):o.copyFrom(this._parent.getAbsoluteTransform())),o.invert(),so.Vector3.TransformCoordinatesToRef(e,o,s),r.m[12]=s.x,r.m[13]=s.y,r.m[14]=s.z}this._markAsDirtyAndDecompose()},d.prototype.setAbsolutePosition=function(e,t){this.setPosition(e,so.Space.WORLD,t)},d.prototype.scale=function(e,t,i,r){void 0===r&&(r=!1);var n=this.getLocalMatrix(),o=d._tmpMats[0];so.Matrix.ScalingToRef(e,t,i,o),o.multiplyToRef(n,n),o.invert();for(var s=0,a=this.children;s<a.length;s++){var l=(u=a[s]).getLocalMatrix();l.multiplyToRef(o,l),l.m[12]*=e,l.m[13]*=t,l.m[14]*=i,u._markAsDirtyAndDecompose()}if(this._markAsDirtyAndDecompose(),r)for(var c=0,h=this.children;c<h.length;c++){var u;(u=h[c]).scale(e,t,i,r)}},d.prototype.setScale=function(e){this._decompose(),this._localScaling.copyFrom(e),this._markAsDirtyAndCompose()},d.prototype.getScale=function(){return this._decompose(),this._localScaling},d.prototype.getScaleToRef=function(e){this._decompose(),e.copyFrom(this._localScaling)},d.prototype.setYawPitchRoll=function(e,t,i,r,n){if(void 0===r&&(r=so.Space.LOCAL),r===so.Space.LOCAL){var o=d._tmpQuat;return so.Quaternion.RotationYawPitchRollToRef(e,t,i,o),void this.setRotationQuaternion(o,r,n)}var s=d._tmpMats[0];if(this._getNegativeRotationToRef(s,n)){var a=d._tmpMats[1];so.Matrix.RotationYawPitchRollToRef(e,t,i,a),s.multiplyToRef(a,a),this._rotateWithMatrix(a,r,n)}},d.prototype.rotate=function(e,t,i,r){void 0===i&&(i=so.Space.LOCAL);var n=d._tmpMats[0];n.m[12]=0,n.m[13]=0,n.m[14]=0,so.Matrix.RotationAxisToRef(e,t,n),this._rotateWithMatrix(n,i,r)},d.prototype.setAxisAngle=function(e,t,i,r){if(void 0===i&&(i=so.Space.LOCAL),i===so.Space.LOCAL){var n=d._tmpQuat;return so.Quaternion.RotationAxisToRef(e,t,n),void this.setRotationQuaternion(n,i,r)}var o=d._tmpMats[0];if(this._getNegativeRotationToRef(o,r)){var s=d._tmpMats[1];so.Matrix.RotationAxisToRef(e,t,s),o.multiplyToRef(s,s),this._rotateWithMatrix(s,i,r)}},d.prototype.setRotation=function(e,t,i){void 0===t&&(t=so.Space.LOCAL),this.setYawPitchRoll(e.y,e.x,e.z,t,i)},d.prototype.setRotationQuaternion=function(e,t,i){if(void 0===t&&(t=so.Space.LOCAL),t===so.Space.LOCAL)return this._decompose(),this._localRotation.copyFrom(e),void this._markAsDirtyAndCompose();var r=d._tmpMats[0];if(this._getNegativeRotationToRef(r,i)){var n=d._tmpMats[1];so.Matrix.FromQuaternionToRef(e,n),r.multiplyToRef(n,n),this._rotateWithMatrix(n,t,i)}},d.prototype.setRotationMatrix=function(e,t,i){if(void 0===t&&(t=so.Space.LOCAL),t===so.Space.LOCAL){var r=d._tmpQuat;return so.Quaternion.FromRotationMatrixToRef(e,r),void this.setRotationQuaternion(r,t,i)}var n=d._tmpMats[0];if(this._getNegativeRotationToRef(n,i)){var o=d._tmpMats[1];o.copyFrom(e),n.multiplyToRef(e,o),this._rotateWithMatrix(o,t,i)}},d.prototype._rotateWithMatrix=function(e,t,i){void 0===t&&(t=so.Space.LOCAL);var r=this.getLocalMatrix(),n=r.m[12],o=r.m[13],s=r.m[14],a=this.getParent(),l=d._tmpMats[3],c=d._tmpMats[4];a&&t==so.Space.WORLD?(i?(l.copyFrom(i.getWorldMatrix()),a.getAbsoluteTransform().multiplyToRef(l,l)):l.copyFrom(a.getAbsoluteTransform()),c.copyFrom(l),c.invert(),r.multiplyToRef(l,r),r.multiplyToRef(e,r),r.multiplyToRef(c,r)):t==so.Space.WORLD&&i?(l.copyFrom(i.getWorldMatrix()),c.copyFrom(l),c.invert(),r.multiplyToRef(l,r),r.multiplyToRef(e,r),r.multiplyToRef(c,r)):r.multiplyToRef(e,r),r.m[12]=n,r.m[13]=o,r.m[14]=s,this.computeAbsoluteTransforms(),this._markAsDirtyAndDecompose()},d.prototype._getNegativeRotationToRef=function(e,t){var i=d._tmpMats[2];return e.copyFrom(this.getAbsoluteTransform()),t&&(e.multiplyToRef(t.getWorldMatrix(),e),so.Matrix.ScalingToRef(t.scaling.x,t.scaling.y,t.scaling.z,i)),e.invert(),!isNaN(e.m[0])&&(i.m[0]*=this._scalingDeterminant,e.multiplyToRef(i,e),!0)},d.prototype.getPosition=function(e,t){void 0===e&&(e=so.Space.LOCAL),void 0===t&&(t=null);var i=so.Vector3.Zero();return this.getPositionToRef(e,t,i),i},d.prototype.getPositionToRef=function(e,t,i){if(void 0===e&&(e=so.Space.LOCAL),e==so.Space.LOCAL){var r=this.getLocalMatrix();i.x=r.m[12],i.y=r.m[13],i.z=r.m[14]}else{var n=null;t&&(n=t.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var o=d._tmpMats[0];t&&n?(o.copyFrom(this.getAbsoluteTransform()),o.multiplyToRef(n,o)):o=this.getAbsoluteTransform(),i.x=o.m[12],i.y=o.m[13],i.z=o.m[14]}},d.prototype.getAbsolutePosition=function(e){void 0===e&&(e=null);var t=so.Vector3.Zero();return this.getPositionToRef(so.Space.WORLD,e,t),t},d.prototype.getAbsolutePositionToRef=function(e,t){this.getPositionToRef(so.Space.WORLD,e,t)},d.prototype.computeAbsoluteTransforms=function(){if(this._compose(),this._parent)this._localMatrix.multiplyToRef(this._parent._absoluteTransform,this._absoluteTransform);else{this._absoluteTransform.copyFrom(this._localMatrix);var e=this._skeleton.getPoseMatrix();e&&this._absoluteTransform.multiplyToRef(e,this._absoluteTransform)}for(var t=this.children,i=t.length,r=0;r<i;r++)t[r].computeAbsoluteTransforms()},d.prototype.getDirection=function(e,t){void 0===t&&(t=null);var i=so.Vector3.Zero();return this.getDirectionToRef(e,t,i),i},d.prototype.getDirectionToRef=function(e,t,i){void 0===t&&(t=null);var r=null;t&&(r=t.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var n=d._tmpMats[0];n.copyFrom(this.getAbsoluteTransform()),t&&r&&n.multiplyToRef(r,n),so.Vector3.TransformNormalToRef(e,n,i),i.normalize()},d.prototype.getRotation=function(e,t){void 0===e&&(e=so.Space.LOCAL),void 0===t&&(t=null);var i=so.Vector3.Zero();return this.getRotationToRef(e,t,i),i},d.prototype.getRotationToRef=function(e,t,i){void 0===e&&(e=so.Space.LOCAL),void 0===t&&(t=null);var r=d._tmpQuat;this.getRotationQuaternionToRef(e,t,r),r.toEulerAnglesToRef(i)},d.prototype.getRotationQuaternion=function(e,t){void 0===e&&(e=so.Space.LOCAL),void 0===t&&(t=null);var i=so.Quaternion.Identity();return this.getRotationQuaternionToRef(e,t,i),i},d.prototype.getRotationQuaternionToRef=function(e,t,i){if(void 0===e&&(e=so.Space.LOCAL),void 0===t&&(t=null),e==so.Space.LOCAL)this._decompose(),i.copyFrom(this._localRotation);else{var r=d._tmpMats[0],n=this.getAbsoluteTransform();t?n.multiplyToRef(t.getWorldMatrix(),r):r.copyFrom(n),r.m[0]*=this._scalingDeterminant,r.m[1]*=this._scalingDeterminant,r.m[2]*=this._scalingDeterminant,r.decompose(void 0,i,void 0)}},d.prototype.getRotationMatrix=function(e,t){void 0===e&&(e=so.Space.LOCAL);var i=so.Matrix.Identity();return this.getRotationMatrixToRef(e,t,i),i},d.prototype.getRotationMatrixToRef=function(e,t,i){if(void 0===e&&(e=so.Space.LOCAL),e==so.Space.LOCAL)this.getLocalMatrix().getRotationMatrixToRef(i);else{var r=d._tmpMats[0],n=this.getAbsoluteTransform();t?n.multiplyToRef(t.getWorldMatrix(),r):r.copyFrom(n),r.m[0]*=this._scalingDeterminant,r.m[1]*=this._scalingDeterminant,r.m[2]*=this._scalingDeterminant,r.getRotationMatrixToRef(i)}},d.prototype.getAbsolutePositionFromLocal=function(e,t){void 0===t&&(t=null);var i=so.Vector3.Zero();return this.getAbsolutePositionFromLocalToRef(e,t,i),i},d.prototype.getAbsolutePositionFromLocalToRef=function(e,t,i){void 0===t&&(t=null);var r=null;t&&(r=t.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var n=d._tmpMats[0];t&&r?(n.copyFrom(this.getAbsoluteTransform()),n.multiplyToRef(r,n)):n=this.getAbsoluteTransform(),so.Vector3.TransformCoordinatesToRef(e,n,i)},d.prototype.getLocalPositionFromAbsolute=function(e,t){void 0===t&&(t=null);var i=so.Vector3.Zero();return this.getLocalPositionFromAbsoluteToRef(e,t,i),i},d.prototype.getLocalPositionFromAbsoluteToRef=function(e,t,i){void 0===t&&(t=null);var r=null;t&&(r=t.getWorldMatrix()),this._skeleton.computeAbsoluteTransforms();var n=d._tmpMats[0];n.copyFrom(this.getAbsoluteTransform()),t&&r&&n.multiplyToRef(r,n),n.invert(),so.Vector3.TransformCoordinatesToRef(e,n,i)},d._tmpVecs=[so.Vector3.Zero(),so.Vector3.Zero()],d._tmpQuat=so.Quaternion.Identity(),d._tmpMats=[so.Matrix.Identity(),so.Matrix.Identity(),so.Matrix.Identity(),so.Matrix.Identity(),so.Matrix.Identity()],d})(so.Node),so.Bone=ao,lo=$a||($a={}),co=(function(){function b(e,t,i){if(this.targetPosition=lo.Vector3.Zero(),this.poleTargetPosition=lo.Vector3.Zero(),this.poleTargetLocalOffset=lo.Vector3.Zero(),this.poleAngle=0,this.slerpAmount=1,this._bone1Quat=lo.Quaternion.Identity(),this._bone1Mat=lo.Matrix.Identity(),this._bone2Ang=Math.PI,this._maxAngle=Math.PI,this._rightHandedSystem=!1,this._bendAxis=lo.Vector3.Right(),this._slerping=!1,this._adjustRoll=0,this._bone2=t,this._bone1=t.getParent(),this._bone1){this.mesh=e;var r=t.getPosition();if(0<t.getAbsoluteTransform().determinant()&&(this._rightHandedSystem=!0,this._bendAxis.x=0,this._bendAxis.y=0,this._bendAxis.z=-1,r.x>r.y&&r.x>r.z&&(this._adjustRoll=.5*Math.PI,this._bendAxis.z=1)),this._bone1.length){var n=this._bone1.getScale(),o=this._bone2.getScale();this._bone1Length=this._bone1.length*n.y*this.mesh.scaling.y,this._bone2Length=this._bone2.length*o.y*this.mesh.scaling.y}else if(this._bone1.children[0]){e.computeWorldMatrix(!0);var s=this._bone2.children[0].getAbsolutePosition(e),a=this._bone2.getAbsolutePosition(e),l=this._bone1.getAbsolutePosition(e);this._bone1Length=lo.Vector3.Distance(s,a),this._bone2Length=lo.Vector3.Distance(a,l)}this._bone1.getRotationMatrixToRef(lo.Space.WORLD,e,this._bone1Mat),this.maxAngle=Math.PI,i&&(i.targetMesh&&(this.targetMesh=i.targetMesh,this.targetMesh.computeWorldMatrix(!0)),i.poleTargetMesh?(this.poleTargetMesh=i.poleTargetMesh,this.poleTargetMesh.computeWorldMatrix(!0)):i.poleTargetBone?this.poleTargetBone=i.poleTargetBone:this._bone1.getParent()&&(this.poleTargetBone=this._bone1.getParent()),i.poleTargetLocalOffset&&this.poleTargetLocalOffset.copyFrom(i.poleTargetLocalOffset),i.poleAngle&&(this.poleAngle=i.poleAngle),i.bendAxis&&this._bendAxis.copyFrom(i.bendAxis),i.maxAngle&&(this.maxAngle=i.maxAngle),i.slerpAmount&&(this.slerpAmount=i.slerpAmount))}}return Object.defineProperty(b.prototype,"maxAngle",{get:function(){return this._maxAngle},set:function(e){this._setMaxAngle(e)},enumerable:!0,configurable:!0}),b.prototype._setMaxAngle=function(e){e<0&&(e=0),(e>Math.PI||null==e)&&(e=Math.PI),this._maxAngle=e;var t=this._bone1Length,i=this._bone2Length;this._maxReach=Math.sqrt(t*t+i*i-2*t*i*Math.cos(e))},b.prototype.update=function(){var e=this._bone1;if(e){var t=this.targetPosition,i=this.poleTargetPosition,r=b._tmpMats[0],n=b._tmpMats[1];this.targetMesh&&t.copyFrom(this.targetMesh.getAbsolutePosition()),this.poleTargetBone?this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset,this.mesh,i):this.poleTargetMesh&&lo.Vector3.TransformCoordinatesToRef(this.poleTargetLocalOffset,this.poleTargetMesh.getWorldMatrix(),i);var o=b._tmpVecs[0],s=b._tmpVecs[1],a=b._tmpVecs[2],l=b._tmpVecs[3],c=b._tmpVecs[4],h=b._tmpQuat;e.getAbsolutePositionToRef(this.mesh,o),i.subtractToRef(o,c),0==c.x&&0==c.y&&0==c.z?c.y=1:c.normalize(),t.subtractToRef(o,l),l.normalize(),lo.Vector3.CrossToRef(l,c,s),s.normalize(),lo.Vector3.CrossToRef(l,s,a),a.normalize(),lo.Matrix.FromXYZAxesToRef(a,l,s,r);var u=this._bone1Length,d=this._bone2Length,f=lo.Vector3.Distance(o,t);0<this._maxReach&&(f=Math.min(this._maxReach,f));var p=(d*d+f*f-u*u)/(2*d*f),m=(f*f+u*u-d*d)/(2*f*u);1<p&&(p=1),1<m&&(m=1),p<-1&&(p=-1),m<-1&&(m=-1);var _=Math.acos(p),g=Math.acos(m),v=-_-g;if(this._rightHandedSystem)lo.Matrix.RotationYawPitchRollToRef(0,0,this._adjustRoll,n),n.multiplyToRef(r,r),lo.Matrix.RotationAxisToRef(this._bendAxis,g,n),n.multiplyToRef(r,r);else{var y=b._tmpVecs[5];y.copyFrom(this._bendAxis),y.x*=-1,lo.Matrix.RotationAxisToRef(y,-g,n),n.multiplyToRef(r,r)}this.poleAngle&&(lo.Matrix.RotationAxisToRef(l,this.poleAngle,n),r.multiplyToRef(n,r)),this._bone1&&(this.slerpAmount<1?(this._slerping||lo.Quaternion.FromRotationMatrixToRef(this._bone1Mat,this._bone1Quat),lo.Quaternion.FromRotationMatrixToRef(r,h),lo.Quaternion.SlerpToRef(this._bone1Quat,h,this.slerpAmount,this._bone1Quat),v=this._bone2Ang*(1-this.slerpAmount)+v*this.slerpAmount,this._bone1.setRotationQuaternion(this._bone1Quat,lo.Space.WORLD,this.mesh),this._slerping=!0):(this._bone1.setRotationMatrix(r,lo.Space.WORLD,this.mesh),this._bone1Mat.copyFrom(r),this._slerping=!1)),this._bone2.setAxisAngle(this._bendAxis,v,lo.Space.LOCAL),this._bone2Ang=v}},b._tmpVecs=[lo.Vector3.Zero(),lo.Vector3.Zero(),lo.Vector3.Zero(),lo.Vector3.Zero(),lo.Vector3.Zero(),lo.Vector3.Zero()],b._tmpQuat=lo.Quaternion.Identity(),b._tmpMats=[lo.Matrix.Identity(),lo.Matrix.Identity()],b})(),lo.BoneIKController=co,ho=$a||($a={}),uo=(function(){function C(e,t,i,r){if(this.upAxis=ho.Vector3.Up(),this.upAxisSpace=ho.Space.LOCAL,this.adjustYaw=0,this.adjustPitch=0,this.adjustRoll=0,this.slerpAmount=1,this._boneQuat=ho.Quaternion.Identity(),this._slerping=!1,this._firstFrameSkipped=!1,this._fowardAxis=ho.Vector3.Forward(),this.mesh=e,this.bone=t,this.target=i,r&&(r.adjustYaw&&(this.adjustYaw=r.adjustYaw),r.adjustPitch&&(this.adjustPitch=r.adjustPitch),r.adjustRoll&&(this.adjustRoll=r.adjustRoll),null!=r.maxYaw?this.maxYaw=r.maxYaw:this.maxYaw=Math.PI,null!=r.minYaw?this.minYaw=r.minYaw:this.minYaw=-Math.PI,null!=r.maxPitch?this.maxPitch=r.maxPitch:this.maxPitch=Math.PI,null!=r.minPitch?this.minPitch=r.minPitch:this.minPitch=-Math.PI,null!=r.slerpAmount&&(this.slerpAmount=r.slerpAmount),null!=r.upAxis&&(this.upAxis=r.upAxis),null!=r.upAxisSpace&&(this.upAxisSpace=r.upAxisSpace),null!=r.yawAxis||null!=r.pitchAxis)){var n=ho.Axis.Y,o=ho.Axis.X;null!=r.yawAxis&&(n=r.yawAxis.clone()).normalize(),null!=r.pitchAxis&&(o=r.pitchAxis.clone()).normalize();var s=ho.Vector3.Cross(o,n);this._transformYawPitch=ho.Matrix.Identity(),ho.Matrix.FromXYZAxesToRef(o,n,s,this._transformYawPitch),this._transformYawPitchInv=this._transformYawPitch.clone(),this._transformYawPitch.invert()}t.getParent()||this.upAxisSpace!=ho.Space.BONE||(this.upAxisSpace=ho.Space.LOCAL)}return Object.defineProperty(C.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(C.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(C.prototype,"minPitch",{get:function(){return this._minPitch},set:function(e){this._minPitch=e,this._minPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),Object.defineProperty(C.prototype,"maxPitch",{get:function(){return this._maxPitch},set:function(e){this._maxPitch=e,this._maxPitchTan=Math.tan(e)},enumerable:!0,configurable:!0}),C.prototype.update=function(){if(this.slerpAmount<1&&!this._firstFrameSkipped)this._firstFrameSkipped=!0;else{var e=this.bone,t=C._tmpVecs[0];e.getAbsolutePositionToRef(this.mesh,t);var i=this.target,r=C._tmpMats[0],n=C._tmpMats[1],o=this.mesh,s=e.getParent(),a=C._tmpVecs[1];a.copyFrom(this.upAxis),this.upAxisSpace==ho.Space.BONE&&s?(this._transformYawPitch&&ho.Vector3.TransformCoordinatesToRef(a,this._transformYawPitchInv,a),s.getDirectionToRef(a,this.mesh,a)):this.upAxisSpace==ho.Space.LOCAL&&(o.getDirectionToRef(a,a),1==o.scaling.x&&1==o.scaling.y&&1==o.scaling.z||a.normalize());var l=!1,c=!1;if(this._maxYaw==Math.PI&&this._minYaw==-Math.PI||(l=!0),this._maxPitch==Math.PI&&this._minPitch==-Math.PI||(c=!0),l||c){var h=C._tmpMats[2],u=C._tmpMats[3];if(this.upAxisSpace==ho.Space.BONE&&1==a.y&&s)s.getRotationMatrixToRef(ho.Space.WORLD,this.mesh,h);else if(this.upAxisSpace!=ho.Space.LOCAL||1!=a.y||s){(f=C._tmpVecs[2]).copyFrom(this._fowardAxis),this._transformYawPitch&&ho.Vector3.TransformCoordinatesToRef(f,this._transformYawPitchInv,f),s?s.getDirectionToRef(f,this.mesh,f):o.getDirectionToRef(f,f);var d=ho.Vector3.Cross(a,f);d.normalize();var f=ho.Vector3.Cross(d,a);ho.Matrix.FromXYZAxesToRef(d,a,f,h)}else h.copyFrom(o.getWorldMatrix());h.invertToRef(u);var p=null;if(c){var m=C._tmpVecs[3];i.subtractToRef(t,m),ho.Vector3.TransformCoordinatesToRef(m,u,m),p=Math.sqrt(m.x*m.x+m.z*m.z);var _=Math.atan2(m.y,p),g=_;_>this._maxPitch?(m.y=this._maxPitchTan*p,g=this._maxPitch):_<this._minPitch&&(m.y=this._minPitchTan*p,g=this._minPitch),_!=g&&(ho.Vector3.TransformCoordinatesToRef(m,h,m),m.addInPlace(t),i=m)}if(l){m=C._tmpVecs[4];i.subtractToRef(t,m),ho.Vector3.TransformCoordinatesToRef(m,u,m);var v=Math.atan2(m.x,m.z),y=v;if((v>this._maxYaw||v<this._minYaw)&&(null==p&&(p=Math.sqrt(m.x*m.x+m.z*m.z)),this._yawRange>Math.PI?this._isAngleBetween(v,this._maxYaw,this._midYawConstraint)?(m.z=this._maxYawCos*p,m.x=this._maxYawSin*p,y=this._maxYaw):this._isAngleBetween(v,this._midYawConstraint,this._minYaw)&&(m.z=this._minYawCos*p,m.x=this._minYawSin*p,y=this._minYaw):v>this._maxYaw?(m.z=this._maxYawCos*p,m.x=this._maxYawSin*p,y=this._maxYaw):v<this._minYaw&&(m.z=this._minYawCos*p,m.x=this._minYawSin*p,y=this._minYaw)),this._slerping&&this._yawRange>Math.PI){var b=C._tmpVecs[8];b.copyFrom(ho.Axis.Z),this._transformYawPitch&&ho.Vector3.TransformCoordinatesToRef(b,this._transformYawPitchInv,b);var T=C._tmpMats[4];this._boneQuat.toRotationMatrix(T),this.mesh.getWorldMatrix().multiplyToRef(T,T),ho.Vector3.TransformCoordinatesToRef(b,T,b),ho.Vector3.TransformCoordinatesToRef(b,u,b);var x=Math.atan2(b.x,b.z),E=this._getAngleBetween(x,v);if(this._getAngleBetween(x,this._midYawConstraint)<E){null==p&&(p=Math.sqrt(m.x*m.x+m.z*m.z));var A=this._getAngleBetween(x,this._maxYaw);y=this._getAngleBetween(x,this._minYaw)<A?x+.75*Math.PI:x-.75*Math.PI,m.z=Math.cos(y)*p,m.x=Math.sin(y)*p}}v!=y&&(ho.Vector3.TransformCoordinatesToRef(m,h,m),m.addInPlace(t),i=m)}}var P=C._tmpVecs[5],S=C._tmpVecs[6],R=C._tmpVecs[7],M=C._tmpQuat;i.subtractToRef(t,P),P.normalize(),ho.Vector3.CrossToRef(a,P,S),S.normalize(),ho.Vector3.CrossToRef(P,S,R),R.normalize(),ho.Matrix.FromXYZAxesToRef(S,R,P,r),0===S.x&&0===S.y&&0===S.z||0===R.x&&0===R.y&&0===R.z||0===P.x&&0===P.y&&0===P.z||((this.adjustYaw||this.adjustPitch||this.adjustRoll)&&(ho.Matrix.RotationYawPitchRollToRef(this.adjustYaw,this.adjustPitch,this.adjustRoll,n),n.multiplyToRef(r,r)),this.slerpAmount<1?(this._slerping||this.bone.getRotationQuaternionToRef(ho.Space.WORLD,this.mesh,this._boneQuat),this._transformYawPitch&&this._transformYawPitch.multiplyToRef(r,r),ho.Quaternion.FromRotationMatrixToRef(r,M),ho.Quaternion.SlerpToRef(this._boneQuat,M,this.slerpAmount,this._boneQuat),this.bone.setRotationQuaternion(this._boneQuat,ho.Space.WORLD,this.mesh),this._slerping=!0):(this._transformYawPitch&&this._transformYawPitch.multiplyToRef(r,r),this.bone.setRotationMatrix(r,ho.Space.WORLD,this.mesh),this._slerping=!1))}},C.prototype._getAngleDiff=function(e,t){var i=t-e;return(i%=2*Math.PI)>Math.PI?i-=2*Math.PI:i<-Math.PI&&(i+=2*Math.PI),i},C.prototype._getAngleBetween=function(e,t){var i=0;return(i=(e=(e%=2*Math.PI)<0?e+2*Math.PI:e)<(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)?t-e:e-t)>Math.PI&&(i=2*Math.PI-i),i},C.prototype._isAngleBetween=function(e,t,i){if(e=(e%=2*Math.PI)<0?e+2*Math.PI:e,(t=(t%=2*Math.PI)<0?t+2*Math.PI:t)<(i=(i%=2*Math.PI)<0?i+2*Math.PI:i)){if(t<e&&e<i)return!0}else if(i<e&&e<t)return!0;return!1},C._tmpVecs=[ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero(),ho.Vector3.Zero()],C._tmpQuat=ho.Quaternion.Identity(),C._tmpMats=[ho.Matrix.Identity(),ho.Matrix.Identity(),ho.Matrix.Identity(),ho.Matrix.Identity(),ho.Matrix.Identity()],C})(),ho.BoneLookController=uo,fo=$a||($a={}),po=(function(){function u(e,t,i){this.name=e,this.id=t,this.bones=new Array,this.needInitialSkinMatrix=!1,this._isDirty=!0,this._meshesWithPoseMatrix=new Array,this._identity=fo.Matrix.Identity(),this._ranges={},this._lastAbsoluteTransformsUpdateId=-1,this.doNotSerialize=!1,this._animationPropertiesOverride=null,this.onBeforeComputeObservable=new fo.Observable,this.bones=[],this._scene=i||fo.Engine.LastCreatedScene,i.skeletons.push(this),this._isDirty=!0}return Object.defineProperty(u.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),u.prototype.getTransformMatrices=function(e){return this.needInitialSkinMatrix&&e._bonesTransformMatrices?e._bonesTransformMatrices:(this._transformMatrices||this.prepare(),this._transformMatrices)},u.prototype.getScene=function(){return this._scene},u.prototype.toString=function(e){var t="Name: "+this.name+", nBones: "+this.bones.length;if(t+=", nAnimationRanges: "+(this._ranges?Object.keys(this._ranges).length:"none"),e){t+=", Ranges: {";var i=!0;for(var r in this._ranges)i&&(t+=", ",i=!1),t+=r;t+="}"}return t},u.prototype.getBoneIndexByName=function(e){for(var t=0,i=this.bones.length;t<i;t++)if(this.bones[t].name===e)return t;return-1},u.prototype.createAnimationRange=function(e,t,i){if(!this._ranges[e]){this._ranges[e]=new fo.AnimationRange(e,t,i);for(var r=0,n=this.bones.length;r<n;r++)this.bones[r].animations[0]&&this.bones[r].animations[0].createRange(e,t,i)}},u.prototype.deleteAnimationRange=function(e,t){void 0===t&&(t=!0);for(var i=0,r=this.bones.length;i<r;i++)this.bones[i].animations[0]&&this.bones[i].animations[0].deleteRange(e,t);this._ranges[e]=null},u.prototype.getAnimationRange=function(e){return this._ranges[e]},u.prototype.getAnimationRanges=function(){var e,t=[],i=0;for(e in this._ranges)t[i]=this._ranges[e],i++;return t},u.prototype.copyAnimationRange=function(e,t,i){if(void 0===i&&(i=!1),this._ranges[t]||!e.getAnimationRange(t))return!1;var r,n,o=!0,s=this._getHighestAnimationFrame()+1,a={},l=e.bones;for(n=0,r=l.length;n<r;n++)a[l[n].name]=l[n];this.bones.length!==l.length&&(fo.Tools.Warn("copyAnimationRange: this rig has "+this.bones.length+" bones, while source as "+l.length),o=!1);var c=i&&this.dimensionsAtRest&&e.dimensionsAtRest?this.dimensionsAtRest.divide(e.dimensionsAtRest):null;for(n=0,r=this.bones.length;n<r;n++){var h=this.bones[n].name,u=a[h];u?o=o&&this.bones[n].copyAnimationRange(u,t,s,i,c):(fo.Tools.Warn("copyAnimationRange: not same rig, missing source bone "+h),o=!1)}var d=e.getAnimationRange(t);return d&&(this._ranges[t]=new fo.AnimationRange(t,d.from+s,d.to+s)),o},u.prototype.returnToRest=function(){for(var e=0;e<this.bones.length;e++)this.bones[e].returnToRest()},u.prototype._getHighestAnimationFrame=function(){for(var e=0,t=0,i=this.bones.length;t<i;t++)if(this.bones[t].animations[0]){var r=this.bones[t].animations[0].getHighestFrame();e<r&&(e=r)}return e},u.prototype.beginAnimation=function(e,t,i,r){var n=this.getAnimationRange(e);return n?this._scene.beginAnimation(this,n.from,n.to,t,i,r):null},u.prototype._markAsDirty=function(){this._isDirty=!0},u.prototype._registerMeshWithPoseMatrix=function(e){this._meshesWithPoseMatrix.push(e)},u.prototype._unregisterMeshWithPoseMatrix=function(e){var t=this._meshesWithPoseMatrix.indexOf(e);-1<t&&this._meshesWithPoseMatrix.splice(t,1)},u.prototype._computeTransformMatrices=function(e,t){this.onBeforeComputeObservable.notifyObservers(this);for(var i=0;i<this.bones.length;i++){var r=this.bones[i],n=r.getParent();if(n?r.getLocalMatrix().multiplyToRef(n.getWorldMatrix(),r.getWorldMatrix()):t?r.getLocalMatrix().multiplyToRef(t,r.getWorldMatrix()):r.getWorldMatrix().copyFrom(r.getLocalMatrix()),-1!==r._index){var o=null===r._index?i:r._index;r.getInvertedAbsoluteTransform().multiplyToArray(r.getWorldMatrix(),e,16*o)}}this._identity.copyToArray(e,16*this.bones.length)},u.prototype.prepare=function(){if(this._isDirty){if(this.needInitialSkinMatrix)for(var e=0;e<this._meshesWithPoseMatrix.length;e++){var t=this._meshesWithPoseMatrix[e],i=t.getPoseMatrix();if(t._bonesTransformMatrices&&t._bonesTransformMatrices.length===16*(this.bones.length+1)||(t._bonesTransformMatrices=new Float32Array(16*(this.bones.length+1))),this._synchronizedWithMesh!==t){this._synchronizedWithMesh=t;for(var r=0;r<this.bones.length;r++){var n=this.bones[r];if(!n.getParent())n.getBaseMatrix().multiplyToRef(i,fo.Tmp.Matrix[1]),n._updateDifferenceMatrix(fo.Tmp.Matrix[1])}}this._computeTransformMatrices(t._bonesTransformMatrices,i)}else this._transformMatrices&&this._transformMatrices.length===16*(this.bones.length+1)||(this._transformMatrices=new Float32Array(16*(this.bones.length+1))),this._computeTransformMatrices(this._transformMatrices,null);this._isDirty=!1,this._scene._activeBones.addCount(this.bones.length,!1)}},u.prototype.getAnimatables=function(){if(!this._animatables||this._animatables.length!==this.bones.length){this._animatables=[];for(var e=0;e<this.bones.length;e++)this._animatables.push(this.bones[e])}return this._animatables},u.prototype.clone=function(e,t){var i=new u(e,t||e,this._scene);i.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var r=0;r<this.bones.length;r++){var n=this.bones[r],o=null,s=n.getParent();if(s){var a=this.bones.indexOf(s);o=i.bones[a]}var l=new fo.Bone(n.name,i,o,n.getBaseMatrix().clone(),n.getRestPose().clone());fo.Tools.DeepCopy(n.animations,l.animations)}if(this._ranges)for(var c in i._ranges={},this._ranges){var h=this._ranges[c];h&&(i._ranges[c]=h.clone())}return this._isDirty=!0,i},u.prototype.enableBlending=function(t){void 0===t&&(t=.01),this.bones.forEach((function(e){e.animations.forEach((function(e){e.enableBlending=!0,e.blendingSpeed=t}))}))},u.prototype.dispose=function(){this._meshesWithPoseMatrix=[],this.getScene().stopAnimation(this),this.getScene().removeSkeleton(this)},u.prototype.serialize=function(){var e={};e.name=this.name,e.id=this.id,this.dimensionsAtRest&&(e.dimensionsAtRest=this.dimensionsAtRest.asArray()),e.bones=[],e.needInitialSkinMatrix=this.needInitialSkinMatrix;for(var t=0;t<this.bones.length;t++){var i=this.bones[t],r=i.getParent(),n={parentBoneIndex:r?this.bones.indexOf(r):-1,name:i.name,matrix:i.getBaseMatrix().toArray(),rest:i.getRestPose().toArray()};for(var o in e.bones.push(n),i.length&&(n.length=i.length),i.metadata&&(n.metadata=i.metadata),i.animations&&0<i.animations.length&&(n.animation=i.animations[0].serialize()),e.ranges=[],this._ranges){var s=this._ranges[o];if(s){var a={};a.name=o,a.from=s.from,a.to=s.to,e.ranges.push(a)}}}return e},u.Parse=function(e,t){var i,r=new u(e.name,e.id,t);for(e.dimensionsAtRest&&(r.dimensionsAtRest=fo.Vector3.FromArray(e.dimensionsAtRest)),r.needInitialSkinMatrix=e.needInitialSkinMatrix,i=0;i<e.bones.length;i++){var n=e.bones[i],o=null;-1<n.parentBoneIndex&&(o=r.bones[n.parentBoneIndex]);var s=n.rest?fo.Matrix.FromArray(n.rest):null,a=new fo.Bone(n.name,r,o,fo.Matrix.FromArray(n.matrix),s);void 0!==n.id&&null!==n.id&&(a.id=n.id),n.length&&(a.length=n.length),n.metadata&&(a.metadata=n.metadata),n.animation&&a.animations.push(fo.Animation.Parse(n.animation))}if(e.ranges)for(i=0;i<e.ranges.length;i++){var l=e.ranges[i];r.createAnimationRange(l.name,l.from,l.to)}return r},u.prototype.computeAbsoluteTransforms=function(e){void 0===e&&(e=!1);var t=this._scene.getRenderId();(this._lastAbsoluteTransformsUpdateId!=t||e)&&(this.bones[0].computeAbsoluteTransforms(),this._lastAbsoluteTransformsUpdateId=t)},u.prototype.getPoseMatrix=function(){var e=null;return 0<this._meshesWithPoseMatrix.length&&(e=this._meshesWithPoseMatrix[0].getPoseMatrix()),e},u.prototype.sortBones=function(){for(var e=new Array,t=new Array(this.bones.length),i=0;i<this.bones.length;i++)this._sortBones(i,e,t);this.bones=e},u.prototype._sortBones=function(e,t,i){if(!i[e]){i[e]=!0;var r=this.bones[e];void 0===r._index&&(r._index=e);var n=r.getParent();n&&this._sortBones(this.bones.indexOf(n),t,i),t.push(r)}},u})(),fo.Skeleton=po,mo=$a||($a={}),_o=(function(){function e(){}return e.Ldexp=function(e,t){return 1023<t?e*Math.pow(2,1023)*Math.pow(2,t-1023):t<-1074?e*Math.pow(2,-1074)*Math.pow(2,t+1074):e*Math.pow(2,t)},e.Rgbe2float=function(e,t,i,r,n,o){0<n?(n=this.Ldexp(1,n-136),e[o+0]=t*n,e[o+1]=i*n,e[o+2]=r*n):(e[o+0]=0,e[o+1]=0,e[o+2]=0)},e.readStringLine=function(e,t){for(var i="",r="",n=t;n<e.length-t&&"\n"!=(r=String.fromCharCode(e[n]));n++)i+=r;return i},e.RGBE_ReadHeader=function(e){var t,i,r=this.readStringLine(e,0);if("#"!=r[0]||"?"!=r[1])throw"Bad HDR Format.";for(var n=!1,o=!1,s=0;s+=r.length+1,"FORMAT=32-bit_rle_rgbe"==(r=this.readStringLine(e,s))?o=!0:0==r.length&&(n=!0),!n;);if(!o)throw"HDR Bad header format, unsupported FORMAT";s+=r.length+1,r=this.readStringLine(e,s);var a=/^\-Y (.*) \+X (.*)$/g.exec(r);if(!a||a.length<3)throw"HDR Bad header format, no size";if(i=parseInt(a[2]),t=parseInt(a[1]),i<8||32767<i)throw"HDR Bad header format, unsupported size";return{height:t,width:i,dataPosition:s+=r.length+1}},e.GetCubeMapTextureData=function(e,t){var i=new Uint8Array(e),r=this.RGBE_ReadHeader(i),n=this.RGBE_ReadPixels_RLE(i,r);return mo.PanoramaToCubeMapTools.ConvertPanoramaToCubemap(n,r.width,r.height,t)},e.RGBE_ReadPixels=function(e,t){return this.RGBE_ReadPixels_RLE(e,t)},e.RGBE_ReadPixels_RLE=function(e,t){for(var i,r,n,o,s,a=t.height,l=t.width,c=t.dataPosition,h=0,u=0,d=0,f=new ArrayBuffer(4*l),p=new Uint8Array(f),m=new ArrayBuffer(t.width*t.height*4*3),_=new Float32Array(m);0<a;){if(i=e[c++],r=e[c++],n=e[c++],o=e[c++],2!=i||2!=r||128&n)throw"HDR Bad header format, not RLE";if((n<<8|o)!=l)throw"HDR Bad header format, wrong scan line width";for(d=h=0;d<4;d++)for(u=(d+1)*l;h<u;)if(i=e[c++],r=e[c++],128<i){if(0==(s=i-128)||u-h<s)throw"HDR Bad Format, bad scanline data (run)";for(;0<s--;)p[h++]=r}else{if(0==(s=i)||u-h<s)throw"HDR Bad Format, bad scanline data (non-run)";if(p[h++]=r,0<--s)for(var g=0;g<s;g++)p[h++]=e[c++]}for(d=0;d<l;d++)i=p[d],r=p[d+l],n=p[d+2*l],o=p[d+3*l],this.Rgbe2float(_,i,r,n,o,(t.height-a)*l*3+3*d);a--}return _},e})(),mo.HDRTools=_o,go=$a||($a={}),vo=(function(h){function _(e,t,i,r,n,o,s,a,l){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=null),void 0===l&&(l=null);var c=h.call(this,t)||this;return c._generateHarmonics=!0,c._onLoad=null,c._onError=null,c.coordinatesMode=go.Texture.CUBIC_MODE,c._isBlocking=!0,c._rotationY=0,c.boundingBoxPosition=go.Vector3.Zero(),e&&(c.name=e,c.url=e,c.hasAlpha=!1,c.isCube=!0,c._textureMatrix=go.Matrix.Identity(),c._onLoad=a,c._onError=l,c.gammaSpace=o,c._noMipmap=r,c._size=i,c._texture=c._getFromCache(e,c._noMipmap),c._texture||(t.useDelayedTextureLoading?c.delayLoadState=go.Engine.DELAYLOADSTATE_NOTLOADED:c.loadTexture())),c}return T(_,h),Object.defineProperty(_.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(_.prototype,"rotationY",{get:function(){return this._rotationY},set:function(e){this._rotationY=e,this.setReflectionTextureMatrix(go.Matrix.RotationY(this._rotationY))},enumerable:!0,configurable:!0}),Object.defineProperty(_.prototype,"boundingBoxSize",{get:function(){return this._boundingBoxSize},set:function(e){if(!this._boundingBoxSize||!this._boundingBoxSize.equals(e)){this._boundingBoxSize=e;var t=this.getScene();t&&t.markAllMaterialsAsDirty(go.Material.TextureDirtyFlag)}},enumerable:!0,configurable:!0}),_.prototype.loadTexture=function(){var m=this,e=this.getScene();e&&(this._texture=e.getEngine().createRawCubeTextureFromUrl(this.url,e,this._size,go.Engine.TEXTUREFORMAT_RGB,e.getEngine().getCaps().textureFloat?go.Engine.TEXTURETYPE_FLOAT:go.Engine.TEXTURETYPE_UNSIGNED_INT,this._noMipmap,(function(e){m.lodGenerationOffset=0,m.lodGenerationScale=.8;var t=m.getScene();if(!t)return null;var i=go.HDRTools.GetCubeMapTextureData(e,m._size);if(m._generateHarmonics){var r=go.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial(i);m.sphericalPolynomial=r}for(var n=[],o=null,s=0;s<6;s++){if(!t.getEngine().getCaps().textureFloat){var a=new ArrayBuffer(m._size*m._size*3);o=new Uint8Array(a)}var l=i[_._facesMapping[s]];if(m.gammaSpace||o)for(var c=0;c<m._size*m._size;c++)if(m.gammaSpace&&(l[3*c+0]=Math.pow(l[3*c+0],go.ToGammaSpace),l[3*c+1]=Math.pow(l[3*c+1],go.ToGammaSpace),l[3*c+2]=Math.pow(l[3*c+2],go.ToGammaSpace)),o){var h=Math.max(255*l[3*c+0],0),u=Math.max(255*l[3*c+1],0),d=Math.max(255*l[3*c+2],0),f=Math.max(Math.max(h,u),d);if(255<f){var p=255/f;h*=p,u*=p,d*=p}o[3*c+0]=h,o[3*c+1]=u,o[3*c+2]=d}o?n.push(o):n.push(l)}return n}),null,this._onLoad,this._onError))},_.prototype.clone=function(){var e=this.getScene();if(!e)return this;var t=new _(this.url,e,this._size,this._noMipmap,this._generateHarmonics,this.gammaSpace);return t.level=this.level,t.wrapU=this.wrapU,t.wrapV=this.wrapV,t.coordinatesIndex=this.coordinatesIndex,t.coordinatesMode=this.coordinatesMode,t},_.prototype.delayLoad=function(){this.delayLoadState===go.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=go.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap),this._texture||this.loadTexture())},_.prototype.getReflectionTextureMatrix=function(){return this._textureMatrix},_.prototype.setReflectionTextureMatrix=function(e){this._textureMatrix=e},_.Parse=function(e,t,i){var r=null;return e.name&&!e.isRenderTarget&&((r=new _(i+e.name,t,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=go.Vector3.FromArray(e.boundingBoxPosition)),e.boundingBoxSize&&(r.boundingBoxSize=go.Vector3.FromArray(e.boundingBoxSize)),e.rotationY&&(r.rotationY=e.rotationY)),r},_.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},_._facesMapping=["right","left","up","down","front","back"],_})(go.BaseTexture),go.HDRCubeTexture=vo,yo=$a||($a={}),bo=(function(){function e(){}return e.ConvertPanoramaToCubemap=function(e,t,i,r){if(!e)throw"ConvertPanoramaToCubemap: input cannot be null";if(e.length!=t*i*3)throw"ConvertPanoramaToCubemap: input size is wrong";return{front:this.CreateCubemapTexture(r,this.FACE_FRONT,e,t,i),back:this.CreateCubemapTexture(r,this.FACE_BACK,e,t,i),left:this.CreateCubemapTexture(r,this.FACE_LEFT,e,t,i),right:this.CreateCubemapTexture(r,this.FACE_RIGHT,e,t,i),up:this.CreateCubemapTexture(r,this.FACE_UP,e,t,i),down:this.CreateCubemapTexture(r,this.FACE_DOWN,e,t,i),size:r,type:yo.Engine.TEXTURETYPE_FLOAT,format:yo.Engine.TEXTUREFORMAT_RGB,gammaSpace:!1}},e.CreateCubemapTexture=function(e,t,i,r,n){for(var o=new ArrayBuffer(e*e*4*3),s=new Float32Array(o),a=t[1].subtract(t[0]).scale(1/e),l=t[3].subtract(t[2]).scale(1/e),c=1/e,h=0,u=0;u<e;u++){for(var d=t[0],f=t[2],p=0;p<e;p++){var m=f.subtract(d).scale(h).add(d);m.normalize();var _=this.CalcProjectionSpherical(m,i,r,n);s[u*e*3+3*p+0]=_.r,s[u*e*3+3*p+1]=_.g,s[u*e*3+3*p+2]=_.b,d=d.add(a),f=f.add(l)}h+=c}return s},e.CalcProjectionSpherical=function(e,t,i,r){for(var n=Math.atan2(e.z,e.x),o=Math.acos(e.y);n<-Math.PI;)n+=2*Math.PI;for(;n>Math.PI;)n-=2*Math.PI;var s=n/Math.PI,a=o/Math.PI;s=.5*s+.5;var l=Math.round(s*i);l<0?l=0:i<=l&&(l=i-1);var c=Math.round(a*r);c<0?c=0:r<=c&&(c=r-1);var h=r-c-1;return{r:t[h*i*3+3*l+0],g:t[h*i*3+3*l+1],b:t[h*i*3+3*l+2]}},e.FACE_FRONT=[new yo.Vector3(-1,-1,-1),new yo.Vector3(1,-1,-1),new yo.Vector3(-1,1,-1),new yo.Vector3(1,1,-1)],e.FACE_BACK=[new yo.Vector3(1,-1,1),new yo.Vector3(-1,-1,1),new yo.Vector3(1,1,1),new yo.Vector3(-1,1,1)],e.FACE_RIGHT=[new yo.Vector3(1,-1,-1),new yo.Vector3(1,-1,1),new yo.Vector3(1,1,-1),new yo.Vector3(1,1,1)],e.FACE_LEFT=[new yo.Vector3(-1,-1,1),new yo.Vector3(-1,-1,-1),new yo.Vector3(-1,1,1),new yo.Vector3(-1,1,-1)],e.FACE_DOWN=[new yo.Vector3(-1,1,-1),new yo.Vector3(1,1,-1),new yo.Vector3(-1,1,1),new yo.Vector3(1,1,1)],e.FACE_UP=[new yo.Vector3(-1,-1,1),new yo.Vector3(1,-1,1),new yo.Vector3(-1,-1,-1),new yo.Vector3(1,-1,-1)],e})(),yo.PanoramaToCubeMapTools=bo,(function(g){var n=(function(r){function e(e,t){var i=r.call(this,e.x,e.y)||this;return i.index=t,i}return T(e,r),e})(g.Vector2),o=(function(){function e(){this.elements=new Array}return e.prototype.add=function(e){var i=this,r=new Array;return e.forEach((function(e){if(0===r.length||!e.equalsWithEpsilon(r[0])){var t=new n(e,i.elements.length);r.push(t),i.elements.push(t)}})),r},e.prototype.computeBounds=function(){var t=new g.Vector2(this.elements[0].x,this.elements[0].y),i=new g.Vector2(this.elements[0].x,this.elements[0].y);return this.elements.forEach((function(e){e.x<t.x?t.x=e.x:e.x>i.x&&(i.x=e.x),e.y<t.y?t.y=e.y:e.y>i.y&&(i.y=e.y)})),{min:t,max:i,width:i.x-t.x,height:i.y-t.y}},e})(),e=(function(){function e(){}return e.Rectangle=function(e,t,i,r){return[new g.Vector2(e,t),new g.Vector2(i,t),new g.Vector2(i,r),new g.Vector2(e,r)]},e.Circle=function(e,t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=32);for(var n=new Array,o=0,s=2*Math.PI/r,a=0;a<r;a++)n.push(new g.Vector2(t+Math.cos(o)*e,i+Math.sin(o)*e)),o-=s;return n},e.Parse=function(e){var t,i=e.split(/[^-+eE\.\d]+/).map(parseFloat).filter((function(e){return!isNaN(e)})),r=[];for(t=0;t<(2147483646&i.length);t+=2)r.push(new g.Vector2(i[t],i[t+1]));return r},e.StartingAt=function(e,t){return g.Path2.StartingAt(e,t)},e})();g.Polygon=e;var t=(function(){function e(e,t,i){var r;this._points=new o,this._outlinepoints=new o,this._holes=new Array,this._epoints=new Array,this._eholes=new Array,this._name=e,this._scene=i,r=t instanceof g.Path2?t.getPoints():t,this._addToepoint(r),this._points.add(r),this._outlinepoints.add(r),void 0===_&&g.Tools.Warn("Earcut was not found, the polygon will not be built.")}return e.prototype._addToepoint=function(e){for(var t=0,i=e;t<i.length;t++){var r=i[t];this._epoints.push(r.x,r.y)}},e.prototype.addHole=function(e){this._points.add(e);var t=new o;return t.add(e),this._holes.push(t),this._eholes.push(this._epoints.length/2),this._addToepoint(e),this},e.prototype.build=function(e,t){var i=this;void 0===e&&(e=!1),void 0===t&&(t=0);var r=new g.Mesh(this._name,this._scene),n=new Array,o=new Array,s=new Array,a=this._points.computeBounds();this._points.elements.forEach((function(e){n.push(0,1,0),o.push(e.x,0,e.y),s.push((e.x-a.min.x)/a.width,(e.y-a.min.y)/a.height)}));for(var l=new Array,c=_(this._epoints,this._eholes,2),h=0;h<c.length;h++)l.push(c[h]);if(0<t){var u=o.length/3;this._points.elements.forEach((function(e){n.push(0,-1,0),o.push(e.x,-t,e.y),s.push(1-(e.x-a.min.x)/a.width,1-(e.y-a.min.y)/a.height)}));var d=l.length;for(h=0;h<d;h+=3){var f=l[h+0],p=l[h+1],m=l[h+2];l.push(m+u),l.push(p+u),l.push(f+u)}this.addSide(o,n,s,l,a,this._outlinepoints,t,!1),this._holes.forEach((function(e){i.addSide(o,n,s,l,a,e,t,!0)}))}return r.setVerticesData(g.VertexBuffer.PositionKind,o,e),r.setVerticesData(g.VertexBuffer.NormalKind,n,e),r.setVerticesData(g.VertexBuffer.UVKind,s,e),r.setIndices(l),r},e.prototype.addSide=function(e,t,i,r,n,o,s,a){for(var l=e.length/3,c=0,h=0;h<o.elements.length;h++){var u,d=o.elements[h];u=h+1>o.elements.length-1?o.elements[0]:o.elements[h+1],e.push(d.x,0,d.y),e.push(d.x,-s,d.y),e.push(u.x,0,u.y),e.push(u.x,-s,u.y);var f=new g.Vector3(d.x,0,d.y),p=new g.Vector3(u.x,0,u.y).subtract(f),m=new g.Vector3(0,1,0),_=g.Vector3.Cross(p,m);_=_.normalize(),i.push(c/n.width,0),i.push(c/n.width,1),c+=p.length(),i.push(c/n.width,0),i.push(c/n.width,1),a?(t.push(_.x,_.y,_.z),t.push(_.x,_.y,_.z),t.push(_.x,_.y,_.z),t.push(_.x,_.y,_.z),r.push(l),r.push(l+2),r.push(l+1),r.push(l+1),r.push(l+2),r.push(l+3)):(t.push(-_.x,-_.y,-_.z),t.push(-_.x,-_.y,-_.z),t.push(-_.x,-_.y,-_.z),t.push(-_.x,-_.y,-_.z),r.push(l),r.push(l+1),r.push(l+2),r.push(l+1),r.push(l+3),r.push(l+2)),l+=4}},e})();g.PolygonMeshBuilder=t})($a||($a={})),To=$a||($a={}),xo=0,Eo=(function(){function i(e,t,i){this.pos=e,this.normal=t,this.uv=i}return i.prototype.clone=function(){return new i(this.pos.clone(),this.normal.clone(),this.uv.clone())},i.prototype.flip=function(){this.normal=this.normal.scale(-1)},i.prototype.interpolate=function(e,t){return new i(To.Vector3.Lerp(this.pos,e.pos,t),To.Vector3.Lerp(this.normal,e.normal,t),To.Vector2.Lerp(this.uv,e.uv,t))},i})(),Ao=(function(){function y(e,t){this.normal=e,this.w=t}return y.FromPoints=function(e,t,i){var r=i.subtract(e),n=t.subtract(e);if(0===r.lengthSquared()||0===n.lengthSquared())return null;var o=To.Vector3.Normalize(To.Vector3.Cross(r,n));return new y(o,To.Vector3.Dot(o,e))},y.prototype.clone=function(){return new y(this.normal.clone(),this.w)},y.prototype.flip=function(){this.normal.scaleInPlace(-1),this.w=-this.w},y.prototype.splitPolygon=function(e,t,i,r,n){var o,s,a=0,l=[];for(o=0;o<e.vertices.length;o++){var c=(s=To.Vector3.Dot(this.normal,e.vertices[o].pos)-this.w)<-y.EPSILON?2:y.EPSILON<s?1:0;a|=c,l.push(c)}switch(a){case 0:(0<To.Vector3.Dot(this.normal,e.plane.normal)?t:i).push(e);break;case 1:r.push(e);break;case 2:n.push(e);break;case 3:var h,u=[],d=[];for(o=0;o<e.vertices.length;o++){var f=(o+1)%e.vertices.length,p=l[o],m=l[f],_=e.vertices[o],g=e.vertices[f];if(2!==p&&u.push(_),1!==p&&d.push(2!==p?_.clone():_),3==(p|m)){s=(this.w-To.Vector3.Dot(this.normal,_.pos))/To.Vector3.Dot(this.normal,g.pos.subtract(_.pos));var v=_.interpolate(g,s);u.push(v),d.push(v.clone())}}3<=u.length&&(h=new Po(u,e.shared)).plane&&r.push(h),3<=d.length&&(h=new Po(d,e.shared)).plane&&n.push(h)}},y.EPSILON=1e-5,y})(),Po=(function(){function e(e,t){this.vertices=e,this.shared=t,this.plane=Ao.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})(),So=(function(){function n(e){this.plane=null,this.front=null,this.back=null,this.polygons=new Array,e&&this.build(e)}return n.prototype.clone=function(){var e=new n;return e.plane=this.plane&&this.plane.clone(),e.front=this.front&&this.front.clone(),e.back=this.back&&this.back.clone(),e.polygons=this.polygons.map((function(e){return e.clone()})),e},n.prototype.invert=function(){for(var e=0;e<this.polygons.length;e++)this.polygons[e].flip();this.plane&&this.plane.flip(),this.front&&this.front.invert(),this.back&&this.back.invert();var t=this.front;this.front=this.back,this.back=t},n.prototype.clipPolygons=function(e){if(!this.plane)return e.slice();for(var t=new Array,i=new Array,r=0;r<e.length;r++)this.plane.splitPolygon(e[r],t,i,t,i);return this.front&&(t=this.front.clipPolygons(t)),i=this.back?this.back.clipPolygons(i):[],t.concat(i)},n.prototype.clipTo=function(e){this.polygons=e.clipPolygons(this.polygons),this.front&&this.front.clipTo(e),this.back&&this.back.clipTo(e)},n.prototype.allPolygons=function(){var e=this.polygons.slice();return this.front&&(e=e.concat(this.front.allPolygons())),this.back&&(e=e.concat(this.back.allPolygons())),e},n.prototype.build=function(e){if(e.length){this.plane||(this.plane=e[0].plane.clone());for(var t=new Array,i=new Array,r=0;r<e.length;r++)this.plane.splitPolygon(e[r],this.polygons,this.polygons,t,i);t.length&&(this.front||(this.front=new n),this.front.build(t)),i.length&&(this.back||(this.back=new n),this.back.build(i))}},n})(),Ro=(function(){function S(){this.polygons=new Array}return S.FromMesh=function(e){var t,i,r,n,o,s,a,l,c,h,u=new Array,d=null;if(!(e instanceof To.Mesh))throw"BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh";e.computeWorldMatrix(!0),a=e.getWorldMatrix(),l=e.position.clone(),c=e.rotation.clone(),e.rotationQuaternion&&(d=e.rotationQuaternion.clone()),h=e.scaling.clone();for(var f=e.getIndices(),p=e.getVerticesData(To.VertexBuffer.PositionKind),m=e.getVerticesData(To.VertexBuffer.NormalKind),_=e.getVerticesData(To.VertexBuffer.UVKind),g=e.subMeshes,v=0,y=g.length;v<y;v++)for(var b=g[v].indexStart,T=g[v].indexCount+g[v].indexStart;b<T;b+=3){s=[];for(var x=0;x<3;x++){var E=new To.Vector3(m[3*f[b+x]],m[3*f[b+x]+1],m[3*f[b+x]+2]);r=new To.Vector2(_[2*f[b+x]],_[2*f[b+x]+1]);var A=new To.Vector3(p[3*f[b+x]],p[3*f[b+x]+1],p[3*f[b+x]+2]);n=To.Vector3.TransformCoordinates(A,a),i=To.Vector3.TransformNormal(E,a),t=new Eo(n,i,r),s.push(t)}(o=new Po(s,{subMeshId:v,meshId:xo,materialIndex:g[v].materialIndex})).plane&&u.push(o)}var P=S.FromPolygons(u);return P.matrix=a,P.position=l,P.rotation=c,P.scaling=h,P.rotationQuaternion=d,xo++,P},S.FromPolygons=function(e){var t=new S;return t.polygons=e,t},S.prototype.clone=function(){var e=new S;return e.polygons=this.polygons.map((function(e){return e.clone()})),e.copyTransformAttributes(this),e},S.prototype.union=function(e){var t=new So(this.clone().polygons),i=new So(e.clone().polygons);return t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),S.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},S.prototype.unionInPlace=function(e){var t=new So(this.polygons),i=new So(e.polygons);t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),this.polygons=t.allPolygons()},S.prototype.subtract=function(e){var t=new So(this.clone().polygons),i=new So(e.clone().polygons);return t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),S.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},S.prototype.subtractInPlace=function(e){var t=new So(this.polygons),i=new So(e.polygons);t.invert(),t.clipTo(i),i.clipTo(t),i.invert(),i.clipTo(t),i.invert(),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},S.prototype.intersect=function(e){var t=new So(this.clone().polygons),i=new So(e.clone().polygons);return t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),S.FromPolygons(t.allPolygons()).copyTransformAttributes(this)},S.prototype.intersectInPlace=function(e){var t=new So(this.polygons),i=new So(e.polygons);t.invert(),i.clipTo(t),i.invert(),t.clipTo(i),i.clipTo(t),t.build(i.allPolygons()),t.invert(),this.polygons=t.allPolygons()},S.prototype.inverse=function(){var e=this.clone();return e.inverseInPlace(),e},S.prototype.inverseInPlace=function(){this.polygons.map((function(e){e.flip()}))},S.prototype.copyTransformAttributes=function(e){return this.matrix=e.matrix,this.position=e.position,this.rotation=e.rotation,this.scaling=e.scaling,this.rotationQuaternion=e.rotationQuaternion,this},S.prototype.buildMeshGeometry=function(e,t,i){var r=this.matrix.clone();r.invert();var n,o,s,a=new To.Mesh(e,t),l=[],c=[],h=[],u=[],d=To.Vector3.Zero(),f=To.Vector3.Zero(),p=To.Vector2.Zero(),m=this.polygons,_=[0,0,0],g={},v=0,y={};i&&m.sort((function(e,t){return e.shared.meshId===t.shared.meshId?e.shared.subMeshId-t.shared.subMeshId:e.shared.meshId-t.shared.meshId}));for(var b=0,T=m.length;b<T;b++){y[(n=m[b]).shared.meshId]||(y[n.shared.meshId]={}),y[n.shared.meshId][n.shared.subMeshId]||(y[n.shared.meshId][n.shared.subMeshId]={indexStart:1/0,indexEnd:-1/0,materialIndex:n.shared.materialIndex}),s=y[n.shared.meshId][n.shared.subMeshId];for(var x=2,E=n.vertices.length;x<E;x++){_[0]=0,_[1]=x-1,_[2]=x;for(var A=0;A<3;A++){d.copyFrom(n.vertices[_[A]].pos),f.copyFrom(n.vertices[_[A]].normal),p.copyFrom(n.vertices[_[A]].uv);var P=To.Vector3.TransformCoordinates(d,r),S=To.Vector3.TransformNormal(f,r);void 0!==(o=g[P.x+","+P.y+","+P.z])&&h[3*o]===S.x&&h[3*o+1]===S.y&&h[3*o+2]===S.z&&u[2*o]===p.x&&u[2*o+1]===p.y||(l.push(P.x,P.y,P.z),u.push(p.x,p.y),h.push(f.x,f.y,f.z),o=g[P.x+","+P.y+","+P.z]=l.length/3-1),c.push(o),s.indexStart=Math.min(v,s.indexStart),s.indexEnd=Math.max(v,s.indexEnd),v++}}}if(a.setVerticesData(To.VertexBuffer.PositionKind,l),a.setVerticesData(To.VertexBuffer.NormalKind,h),a.setVerticesData(To.VertexBuffer.UVKind,u),a.setIndices(c,null),i){var R,M=0;for(var C in a.subMeshes=new Array,y){for(var O in R=-1,y[C])s=y[C][O],To.SubMesh.CreateFromIndices(s.materialIndex+M,s.indexStart,s.indexEnd-s.indexStart+1,a),R=Math.max(s.materialIndex,R);M+=++R}}return a},S.prototype.toMesh=function(e,t,i,r){var n=this.buildMeshGeometry(e,i,r);return n.material=t,n.position.copyFrom(this.position),n.rotation.copyFrom(this.rotation),this.rotationQuaternion&&(n.rotationQuaternion=this.rotationQuaternion.clone()),n.scaling.copyFrom(this.scaling),n.computeWorldMatrix(!0),n},S})(),To.CSG=Ro,Mo=$a||($a={}),Co=(function(){function o(e,t,i,r,n){this.size=e,this.position=t,this.alphaMode=Mo.Engine.ALPHA_ONEONE,this.color=i||new Mo.Color3(1,1,1),this.texture=r?new Mo.Texture(r,n.getScene(),!0):null,(this._system=n).lensFlares.push(this)}return o.AddFlare=function(e,t,i,r,n){return new o(e,t,i,r,n)},o.prototype.dispose=function(){this.texture&&this.texture.dispose();var e=this._system.lensFlares.indexOf(this);this._system.lensFlares.splice(e,1)},o})(),Mo.LensFlare=Co,(function(l){l.AbstractScene.AddParser(l.SceneComponentConstants.NAME_LENSFLARESYSTEM,(function(e,t,i,r){if(void 0!==e.lensFlareSystems&&null!==e.lensFlareSystems){i.lensFlareSystems||(i.lensFlareSystems=new Array);for(var n=0,o=e.lensFlareSystems.length;n<o;n++){var s=e.lensFlareSystems[n],a=l.LensFlareSystem.Parse(s,t,r);i.lensFlareSystems.push(a)}}})),l.AbstractScene.prototype.getLensFlareSystemByName=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].name===e)return this.lensFlareSystems[t];return null},l.AbstractScene.prototype.getLensFlareSystemByID=function(e){for(var t=0;t<this.lensFlareSystems.length;t++)if(this.lensFlareSystems[t].id===e)return this.lensFlareSystems[t];return null},l.AbstractScene.prototype.removeLensFlareSystem=function(e){var t=this.lensFlareSystems.indexOf(e);return-1!==t&&this.lensFlareSystems.splice(t,1),t},l.AbstractScene.prototype.addLensFlareSystem=function(e){this.lensFlareSystems.push(e)};var e=(function(){function e(e){this.name=l.SceneComponentConstants.NAME_LENSFLARESYSTEM,(this.scene=e).lensFlareSystems=new Array}return e.prototype.register=function(){this.scene._afterCameraDrawStage.registerStep(l.SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM,this,this._draw)},e.prototype.rebuild=function(){},e.prototype.addFromContainer=function(e){var t=this;e.lensFlareSystems&&e.lensFlareSystems.forEach((function(e){t.scene.addLensFlareSystem(e)}))},e.prototype.removeFromContainer=function(e){var t=this;e.lensFlareSystems&&e.lensFlareSystems.forEach((function(e){t.scene.removeLensFlareSystem(e)}))},e.prototype.serialize=function(e){e.lensFlareSystems=[];for(var t=0,i=this.scene.lensFlareSystems;t<i.length;t++){var r=i[t];e.lensFlareSystems.push(r.serialize())}},e.prototype.dispose=function(){for(var e=this.scene.lensFlareSystems;e.length;)e[0].dispose()},e.prototype._draw=function(e){if(this.scene.lensFlaresEnabled){var t=this.scene.lensFlareSystems;l.Tools.StartPerformanceCounter("Lens flares",0<t.length);for(var i=0,r=t;i<r.length;i++){var n=r[i];0!=(e.layerMask&n.layerMask)&&n.render()}l.Tools.EndPerformanceCounter("Lens flares",0<t.length)}},e})();l.LensFlareSystemSceneComponent=e})($a||($a={})),Oo=$a||($a={}),Do=(function(){function l(e,t,i){this.name=e,this.lensFlares=new Array,this.borderLimit=300,this.viewportBorder=0,this.layerMask=268435455,this._vertexBuffers={},this._isEnabled=!0,this._scene=i||Oo.Engine.LastCreatedScene;var r=this._scene._getComponent(Oo.SceneComponentConstants.NAME_LENSFLARESYSTEM);r||(r=new Oo.LensFlareSystemSceneComponent(this._scene),i._addComponent(r)),this._emitter=t,this.id=e,i.lensFlareSystems.push(this),this.meshesSelectionPredicate=function(e){return i.activeCamera&&e.material&&e.isVisible&&e.isEnabled()&&e.isBlocker&&0!=(e.layerMask&i.activeCamera.layerMask)};var n=i.getEngine(),o=[];o.push(1,1),o.push(-1,1),o.push(-1,-1),o.push(1,-1),this._vertexBuffers[Oo.VertexBuffer.PositionKind]=new Oo.VertexBuffer(n,o,Oo.VertexBuffer.PositionKind,!1,!1,2);var s=[];s.push(0),s.push(1),s.push(2),s.push(0),s.push(2),s.push(3),this._indexBuffer=n.createIndexBuffer(s),this._effect=n.createEffect("lensFlare",[Oo.VertexBuffer.PositionKind],["color","viewportMatrix"],["textureSampler"],"")}return Object.defineProperty(l.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled=e},enumerable:!0,configurable:!0}),l.prototype.getScene=function(){return this._scene},l.prototype.getEmitter=function(){return this._emitter},l.prototype.setEmitter=function(e){this._emitter=e},l.prototype.getEmitterPosition=function(){return this._emitter.getAbsolutePosition?this._emitter.getAbsolutePosition():this._emitter.position},l.prototype.computeEffectivePosition=function(e){var t=this.getEmitterPosition();return t=Oo.Vector3.Project(t,Oo.Matrix.Identity(),this._scene.getTransformMatrix(),e),this._positionX=t.x,this._positionY=t.y,t=Oo.Vector3.TransformCoordinates(this.getEmitterPosition(),this._scene.getViewMatrix()),0<this.viewportBorder&&(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),0<t.z&&(this._positionX>e.x&&this._positionX<e.x+e.width&&this._positionY>e.y&&(this._positionY,e.y,e.height),!0)},l.prototype._isVisible=function(){if(!this._isEnabled||!this._scene.activeCamera)return!1;var e=this.getEmitterPosition().subtract(this._scene.activeCamera.globalPosition),t=e.length();e.normalize();var i=new Oo.Ray(this._scene.activeCamera.globalPosition,e),r=this._scene.pickWithRay(i,this.meshesSelectionPredicate,!0);return!r||!r.hit||r.distance>t},l.prototype.render=function(){if(!this._effect.isReady()||!this._scene.activeCamera)return!1;var e,t,i=this._scene.getEngine(),r=this._scene.activeCamera.viewport.toGlobal(i.getRenderWidth(!0),i.getRenderHeight(!0));if(!this.computeEffectivePosition(r))return!1;if(!this._isVisible())return!1;e=this._positionX<this.borderLimit+r.x?this.borderLimit+r.x-this._positionX:this._positionX>r.x+r.width-this.borderLimit?this._positionX-r.x-r.width+this.borderLimit:0;var n=(t=this._positionY<this.borderLimit+r.y?this.borderLimit+r.y-this._positionY:this._positionY>r.y+r.height-this.borderLimit?this._positionY-r.y-r.height+this.borderLimit:0)<e?e:t;(n-=this.viewportBorder)>this.borderLimit&&(n=this.borderLimit);var o=1-Oo.Scalar.Clamp(n/this.borderLimit,0,1);if(o<0)return!1;1<o&&(o=1),0<this.viewportBorder&&(r.x+=this.viewportBorder,r.y+=this.viewportBorder,r.width-=2*this.viewportBorder,r.height-=2*this.viewportBorder,this._positionX-=this.viewportBorder,this._positionY-=this.viewportBorder);var s=r.x+r.width/2,a=r.y+r.height/2,l=s-this._positionX,c=a-this._positionY;i.enableEffect(this._effect),i.setState(!1),i.setDepthBuffer(!1),i.bindBuffers(this._vertexBuffers,this._indexBuffer,this._effect);for(var h=0;h<this.lensFlares.length;h++){var u=this.lensFlares[h];i.setAlphaMode(u.alphaMode);var d=s-l*u.position,f=a-c*u.position,p=u.size,m=u.size*i.getAspectRatio(this._scene.activeCamera,!0),_=d/(r.width+2*r.x)*2-1,g=1-f/(r.height+2*r.y)*2,v=Oo.Matrix.FromValues(p/2,0,0,0,0,m/2,0,0,0,0,1,0,_,g,0,1);this._effect.setMatrix("viewportMatrix",v),this._effect.setTexture("textureSampler",u.texture),this._effect.setFloat4("color",u.color.r*o,u.color.g*o,u.color.b*o,1),i.drawElementsType(Oo.Material.TriangleFillMode,0,6)}return i.setDepthBuffer(!0),i.setAlphaMode(Oo.Engine.ALPHA_DISABLE),!0},l.prototype.dispose=function(){var e=this._vertexBuffers[Oo.VertexBuffer.PositionKind];for(e&&(e.dispose(),this._vertexBuffers[Oo.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null);this.lensFlares.length;)this.lensFlares[0].dispose();var t=this._scene.lensFlareSystems.indexOf(this);this._scene.lensFlareSystems.splice(t,1)},l.Parse=function(e,t,i){var r=t.getLastEntryByID(e.emitterId),n=e.name||"lensFlareSystem#"+e.emitterId,o=new l(n,r,t);o.id=e.id||n,o.borderLimit=e.borderLimit;for(var s=0;s<e.flares.length;s++){var a=e.flares[s];Oo.LensFlare.AddFlare(a.size,a.position,Oo.Color3.FromArray(a.color),a.textureName?i+a.textureName:"",o)}return o},l.prototype.serialize=function(){var e={};e.id=this.id,e.name=this.name,e.emitterId=this.getEmitter().id,e.borderLimit=this.borderLimit,e.flares=[];for(var t=0;t<this.lensFlares.length;t++){var i=this.lensFlares[t];e.flares.push({size:i.size,position:i.position,color:i.color.asArray(),textureName:Oo.Tools.GetFilename(i.texture?i.texture.name:"")})}return e},l})(),Oo.LensFlareSystem=Do,(function(e){var i=(function(){function e(e,t){this.type=e,(this.jointData=t).nativeParams=t.nativeParams||{}}return Object.defineProperty(e.prototype,"physicsJoint",{get:function(){return this._physicsJoint},set:function(e){this._physicsJoint,this._physicsJoint=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"physicsPlugin",{set:function(e){this._physicsPlugin=e},enumerable:!0,configurable:!0}),e.prototype.executeNativeFunction=function(e){e(this._physicsPlugin.world,this._physicsJoint)},e.DistanceJoint=0,e.HingeJoint=1,e.BallAndSocketJoint=2,e.WheelJoint=3,e.SliderJoint=4,e.PrismaticJoint=5,e.UniversalJoint=6,e.Hinge2Joint=e.WheelJoint,e.PointToPointJoint=8,e.SpringJoint=9,e.LockJoint=10,e})(),t=(function(t){function e(e){return t.call(this,i.DistanceJoint,e)||this}return T(e,t),e.prototype.updateDistance=function(e,t){this._physicsPlugin.updateDistanceJoint(this,e,t)},e})(e.PhysicsJoint=i);e.DistanceJoint=t;var r=(function(i){function e(e,t){return i.call(this,e,t)||this}return T(e,i),e.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e||0,t)},e.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},e})(i),n=(function(t){function e(e){return t.call(this,i.HingeJoint,e)||this}return T(e,t),e.prototype.setMotor=function(e,t){this._physicsPlugin.setMotor(this,e||0,t)},e.prototype.setLimit=function(e,t){this._physicsPlugin.setLimit(this,e,t)},e})(e.MotorEnabledJoint=r);e.HingeJoint=n;var o=(function(t){function e(e){return t.call(this,i.Hinge2Joint,e)||this}return T(e,t),e.prototype.setMotor=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setMotor(this,e||0,t,i)},e.prototype.setLimit=function(e,t,i){void 0===i&&(i=0),this._physicsPlugin.setLimit(this,e,t,i)},e})(r);e.Hinge2Joint=o})($a||($a={})),Io=$a||($a={}),wo=(function(){function h(e,t,i,r){void 0===i&&(i={mass:0});var n=this;this.object=e,this.type=t,this._options=i,this._scene=r,this._bodyUpdateRequired=!1,this._onBeforePhysicsStepCallbacks=new Array,this._onAfterPhysicsStepCallbacks=new Array,this._onPhysicsCollideCallbacks=[],this._deltaPosition=Io.Vector3.Zero(),this._isDisposed=!1,this._tmpQuat=new Io.Quaternion,this._tmpQuat2=new Io.Quaternion,this.beforeStep=function(){n._physicsEngine&&(n.object.translate(n._deltaPosition,-1),n._deltaRotationConjugated&&n.object.rotationQuaternion&&n.object.rotationQuaternion.multiplyToRef(n._deltaRotationConjugated,n.object.rotationQuaternion),n.object.computeWorldMatrix(!1),n.object.parent&&n.object.rotationQuaternion?(n.getParentsRotation(),n._tmpQuat.multiplyToRef(n.object.rotationQuaternion,n._tmpQuat)):n._tmpQuat.copyFrom(n.object.rotationQuaternion||new Io.Quaternion),n._options.disableBidirectionalTransformation||n.object.rotationQuaternion&&n._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(n,n.object.getAbsolutePivotPoint(),n._tmpQuat),n._onBeforePhysicsStepCallbacks.forEach((function(e){e(n)})))},this.afterStep=function(){n._physicsEngine&&(n._onAfterPhysicsStepCallbacks.forEach((function(e){e(n)})),n._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(n),n.object.parent&&n.object.rotationQuaternion&&(n.getParentsRotation(),n._tmpQuat.conjugateInPlace(),n._tmpQuat.multiplyToRef(n.object.rotationQuaternion,n.object.rotationQuaternion)),n.object.setAbsolutePosition(n.object.position),n._deltaRotation&&n.object.rotationQuaternion&&n.object.rotationQuaternion.multiplyToRef(n._deltaRotation,n.object.rotationQuaternion),n.object.translate(n._deltaPosition,1))},this.onCollideEvent=null,this.onCollide=function(e){if((n._onPhysicsCollideCallbacks.length||n.onCollideEvent)&&n._physicsEngine){var t=n._physicsEngine.getImpostorWithPhysicsBody(e.body);t&&(n.onCollideEvent&&n.onCollideEvent(n,t),n._onPhysicsCollideCallbacks.filter((function(e){return-1!==e.otherImpostors.indexOf(t)})).forEach((function(e){e.callback(n,t)})))}},this.object?(!this._scene&&e.getScene&&(this._scene=e.getScene()),this._scene&&(this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine?(this.object.rotationQuaternion||(this.object.rotation?this.object.rotationQuaternion=Io.Quaternion.RotationYawPitchRoll(this.object.rotation.y,this.object.rotation.x,this.object.rotation.z):this.object.rotationQuaternion=new Io.Quaternion),this._options.mass=void 0===i.mass?0:i.mass,this._options.friction=void 0===i.friction?.2:i.friction,this._options.restitution=void 0===i.restitution?.2:i.restitution,this._joints=[],!this.object.parent||this._options.ignoreParent?this._init():this.object.parent.physicsImpostor&&Io.Tools.Warn("You must affect impostors to children before affecting impostor to parent.")):Io.Tools.Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors."))):Io.Tools.Error("No object was provided. A physics object is obligatory")}return Object.defineProperty(h.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),Object.defineProperty(h.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(h.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(h.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}),h.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))},h.prototype._getPhysicsParent=function(){return this.object.parent instanceof Io.AbstractMesh?this.object.parent.physicsImpostor:null},h.prototype.isBodyInitRequired=function(){return this._bodyUpdateRequired||!this._physicsBody&&!this._parent},h.prototype.setScalingUpdated=function(e){this.forceUpdate()},h.prototype.forceUpdate=function(){this._init(),this.parent&&!this._options.ignoreParent&&this.parent.forceUpdate()},Object.defineProperty(h.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(h.prototype,"parent",{get:function(){return!this._options.ignoreParent&&this._parent?this._parent:null},set:function(e){this._parent=e},enumerable:!0,configurable:!0}),h.prototype.resetUpdateFlags=function(){this._bodyUpdateRequired=!1},h.prototype.getObjectExtendSize=function(){if(this.object.getBoundingInfo){var e=this.object.rotationQuaternion;this.object.rotationQuaternion=h.IDENTITY_QUATERNION,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0);var t=this.object.getBoundingInfo().boundingBox.extendSizeWorld.scale(2);return this.object.rotationQuaternion=e,this.object.computeWorldMatrix&&this.object.computeWorldMatrix(!0),t}return h.DEFAULT_OBJECT_SIZE},h.prototype.getObjectCenter=function(){return this.object.getBoundingInfo?this.object.getBoundingInfo().boundingBox.centerWorld:this.object.position},h.prototype.getParam=function(e){return this._options[e]},h.prototype.setParam=function(e,t){this._options[e]=t,this._bodyUpdateRequired=!0},h.prototype.setMass=function(e){this.getParam("mass")!==e&&this.setParam("mass",e),this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setBodyMass(this,e)},h.prototype.getLinearVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this):Io.Vector3.Zero()},h.prototype.setLinearVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this,e)},h.prototype.getAngularVelocity=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this):Io.Vector3.Zero()},h.prototype.setAngularVelocity=function(e){this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this,e)},h.prototype.executeNativeFunction=function(e){this._physicsEngine&&e(this._physicsEngine.getPhysicsPlugin().world,this.physicsBody)},h.prototype.registerBeforePhysicsStep=function(e){this._onBeforePhysicsStepCallbacks.push(e)},h.prototype.unregisterBeforePhysicsStep=function(e){var t=this._onBeforePhysicsStepCallbacks.indexOf(e);-1<t?this._onBeforePhysicsStepCallbacks.splice(t,1):Io.Tools.Warn("Function to remove was not found")},h.prototype.registerAfterPhysicsStep=function(e){this._onAfterPhysicsStepCallbacks.push(e)},h.prototype.unregisterAfterPhysicsStep=function(e){var t=this._onAfterPhysicsStepCallbacks.indexOf(e);-1<t?this._onAfterPhysicsStepCallbacks.splice(t,1):Io.Tools.Warn("Function to remove was not found")},h.prototype.registerOnPhysicsCollide=function(e,t){var i=e instanceof Array?e:[e];this._onPhysicsCollideCallbacks.push({callback:t,otherImpostors:i})},h.prototype.unregisterOnPhysicsCollide=function(e,r){var n=e instanceof Array?e:[e],o=-1;this._onPhysicsCollideCallbacks.some((function(e,t){if(e.callback===r&&e.otherImpostors.length===n.length){var i=e.otherImpostors.every((function(e){return-1<n.indexOf(e)}));return i&&(o=t),i}return!1}))?this._onPhysicsCollideCallbacks.splice(o,1):Io.Tools.Warn("Function to remove was not found")},h.prototype.getParentsRotation=function(){var e=this.object.parent;for(this._tmpQuat.copyFromFloats(0,0,0,1);e;)e.rotationQuaternion?this._tmpQuat2.copyFrom(e.rotationQuaternion):Io.Quaternion.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},h.prototype.applyForce=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyForce(this,e,t),this},h.prototype.applyImpulse=function(e,t){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().applyImpulse(this,e,t),this},h.prototype.createJoint=function(e,t,i){var r=new Io.PhysicsJoint(t,i);return this.addJoint(e,r),this},h.prototype.addJoint=function(e,t){return this._joints.push({otherImpostor:e,joint:t}),this._physicsEngine&&this._physicsEngine.addJoint(this,e,t),this},h.prototype.sleep=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().sleepBody(this),this},h.prototype.wakeUp=function(){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().wakeUpBody(this),this},h.prototype.clone=function(e){return e?new h(e,this.type,this._options,this._scene):null},h.prototype.dispose=function(){var t=this;this._physicsEngine&&(this._joints.forEach((function(e){t._physicsEngine&&t._physicsEngine.removeJoint(t,e.otherImpostor,e.joint)})),this._physicsEngine.removeImpostor(this),this.parent&&this.parent.forceUpdate(),this._isDisposed=!0)},h.prototype.setDeltaPosition=function(e){this._deltaPosition.copyFrom(e)},h.prototype.setDeltaRotation=function(e){this._deltaRotation||(this._deltaRotation=new Io.Quaternion),this._deltaRotation.copyFrom(e),this._deltaRotationConjugated=this._deltaRotation.conjugate()},h.prototype.getBoxSizeToRef=function(e){return this._physicsEngine&&this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this,e),this},h.prototype.getRadius=function(){return this._physicsEngine?this._physicsEngine.getPhysicsPlugin().getRadius(this):0},h.prototype.syncBoneWithImpostor=function(e,t,i,r,n){var o=h._tmpVecs[0],s=this.object;if(s.rotationQuaternion)if(n){var a=h._tmpQuat;s.rotationQuaternion.multiplyToRef(n,a),e.setRotationQuaternion(a,Io.Space.WORLD,t)}else e.setRotationQuaternion(s.rotationQuaternion,Io.Space.WORLD,t);o.x=0,o.y=0,o.z=0,i&&(o.x=i.x,o.y=i.y,o.z=i.z,e.getDirectionToRef(o,t,o),null==r&&(r=i.length()),o.x*=r,o.y*=r,o.z*=r),e.getParent()?(o.addInPlace(s.getAbsolutePosition()),e.setAbsolutePosition(o,t)):(t.setAbsolutePosition(s.getAbsolutePosition()),t.position.x-=o.x,t.position.y-=o.y,t.position.z-=o.z)},h.prototype.syncImpostorWithBone=function(e,t,i,r,n,o){var s=this.object;if(s.rotationQuaternion)if(n){var a=h._tmpQuat;e.getRotationQuaternionToRef(Io.Space.WORLD,t,a),a.multiplyToRef(n,s.rotationQuaternion)}else e.getRotationQuaternionToRef(Io.Space.WORLD,t,s.rotationQuaternion);var l=h._tmpVecs[0],c=h._tmpVecs[1];o||((o=h._tmpVecs[2]).x=0,o.y=1,o.z=0),e.getDirectionToRef(o,t,c),e.getAbsolutePositionToRef(t,l),null==r&&i&&(r=i.length()),null!=r&&(l.x+=c.x*r,l.y+=c.y*r,l.z+=c.z*r),s.setAbsolutePosition(l)},h.DEFAULT_OBJECT_SIZE=new Io.Vector3(1,1,1),h.IDENTITY_QUATERNION=Io.Quaternion.Identity(),h._tmpVecs=[Io.Vector3.Zero(),Io.Vector3.Zero(),Io.Vector3.Zero()],h._tmpQuat=Io.Quaternion.Identity(),h.NoImpostor=0,h.SphereImpostor=1,h.BoxImpostor=2,h.PlaneImpostor=3,h.MeshImpostor=4,h.CylinderImpostor=7,h.ParticleImpostor=8,h.HeightmapImpostor=9,h})(),Io.PhysicsImpostor=wo,Lo=$a||($a={}),Fo=(function(){function e(e,t){if(void 0===t&&(t=new Lo.CannonJSPlugin),this._physicsPlugin=t,this._impostors=[],this._joints=[],!this._physicsPlugin.isSupported())throw new Error("Physics Engine "+this._physicsPlugin.name+" cannot be found. Please make sure it is included.");e=e||new Lo.Vector3(0,-9.807,0),this.setGravity(e),this.setTimeStep()}return e.prototype.setGravity=function(e){this.gravity=e,this._physicsPlugin.setGravity(this.gravity)},e.prototype.setTimeStep=function(e){void 0===e&&(e=1/60),this._physicsPlugin.setTimeStep(e)},e.prototype.getTimeStep=function(){return this._physicsPlugin.getTimeStep()},e.prototype.dispose=function(){this._impostors.forEach((function(e){e.dispose()})),this._physicsPlugin.dispose()},e.prototype.getPhysicsPluginName=function(){return this._physicsPlugin.name},e.prototype.addImpostor=function(e){e.uniqueId=this._impostors.push(e),e.parent||this._physicsPlugin.generatePhysicsBody(e)},e.prototype.removeImpostor=function(e){var t=this._impostors.indexOf(e);if(-1<t){var i=this._impostors.splice(t,1);i.length&&(i[0].physicsBody=null)}},e.prototype.addJoint=function(e,t,i){var r={mainImpostor:e,connectedImpostor:t,joint:i};i.physicsPlugin=this._physicsPlugin,this._joints.push(r),this._physicsPlugin.generateJoint(r)},e.prototype.removeJoint=function(t,i,r){var e=this._joints.filter((function(e){return e.connectedImpostor===i&&e.joint===r&&e.mainImpostor===t}));e.length&&this._physicsPlugin.removeJoint(e[0])},e.prototype._step=function(e){var t=this;this._impostors.forEach((function(e){e.isBodyInitRequired()&&t._physicsPlugin.generatePhysicsBody(e)})),.1<e?e=.1:e<=0&&(e=1/60),this._physicsPlugin.executeStep(e,this._impostors)},e.prototype.getPhysicsPlugin=function(){return this._physicsPlugin},e.prototype.getImpostors=function(){return this._impostors},e.prototype.getImpostorForPhysicsObject=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].object===e)return this._impostors[t];return null},e.prototype.getImpostorWithPhysicsBody=function(e){for(var t=0;t<this._impostors.length;++t)if(this._impostors[t].physicsBody===e)return this._impostors[t];return null},e.Epsilon=.001,e})(),Lo.PhysicsEngine=Fo,(function(f){var e=(function(){function e(e){this._scene=e,this._physicsEngine=this._scene.getPhysicsEngine(),this._physicsEngine||f.Tools.Warn("Physics engine not enabled. Please enable the physics before you can use the methods.")}return e.prototype.applyRadialExplosionImpulse=function(i,r,n,o){if(void 0===o&&(o=h.Constant),!this._physicsEngine)return f.Tools.Warn("Physics engine not enabled. Please enable the physics before you call this method."),null;var e=this._physicsEngine.getImpostors();if(0===e.length)return null;var s=new t(this._scene);return e.forEach((function(e){var t=s.getImpostorForceAndContactPoint(e,i,r,n,o);t&&e.applyImpulse(t.force,t.contactPoint)})),s.dispose(!1),s},e.prototype.applyRadialExplosionForce=function(i,r,n,o){if(void 0===o&&(o=h.Constant),!this._physicsEngine)return f.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;var e=this._physicsEngine.getImpostors();if(0===e.length)return null;var s=new t(this._scene);return e.forEach((function(e){var t=s.getImpostorForceAndContactPoint(e,i,r,n,o);t&&e.applyForce(t.force,t.contactPoint)})),s.dispose(!1),s},e.prototype.gravitationalField=function(e,t,i,r){if(void 0===r&&(r=h.Constant),!this._physicsEngine)return f.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var n=new o(this,this._scene,e,t,i,r);return n.dispose(!1),n},e.prototype.updraft=function(e,t,i,r,n){if(void 0===n&&(n=a.Center),!this._physicsEngine)return f.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var o=new s(this._scene,e,t,i,r,n);return o.dispose(!1),o},e.prototype.vortex=function(e,t,i,r){if(!this._physicsEngine)return f.Tools.Warn("Physics engine not enabled. Please enable the physics before you call the PhysicsHelper."),null;if(0===this._physicsEngine.getImpostors().length)return null;var n=new l(this._scene,e,t,i,r);return n.dispose(!1),n},e})();f.PhysicsHelper=e;var t=(function(){function e(e){this._sphereOptions={segments:32,diameter:1},this._rays=[],this._dataFetched=!1,this._scene=e}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere,rays:this._rays}},e.prototype.getImpostorForceAndContactPoint=function(e,t,i,r,n){if(0===e.mass)return null;if(!this._intersectsWithSphere(e,t,i))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var o=e.getObjectCenter().subtract(t),s=new f.Ray(t,o,i);this._rays.push(s);var a=s.intersectsMesh(e.object).pickedPoint;if(!a)return null;var l=f.Vector3.Distance(t,a);if(i<l)return null;var c=n===h.Constant?r:r*(1-l/i);return{force:o.multiplyByFloats(c,c,c),contactPoint:a}},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=f.MeshBuilder.CreateSphere("radialExplosionEventSphere",this._sphereOptions,this._scene),this._sphere.isVisible=!1)},e.prototype._intersectsWithSphere=function(e,t,i){var r=e.object;return this._prepareSphere(),this._sphere.position=t,this._sphere.scaling=new f.Vector3(2*i,2*i,2*i),this._sphere._updateBoundingInfo(),this._sphere.computeWorldMatrix(!0),this._sphere.intersectsMesh(r,!0)},e})();f.PhysicsRadialExplosionEvent=t;var o=(function(){function e(e,t,i,r,n,o){void 0===o&&(o=h.Constant),this._dataFetched=!1,this._physicsHelper=e,this._scene=t,this._origin=i,this._radius=r,this._strength=n,this._falloff=o,this._tickCallback=this._tick.bind(this)}return e.prototype.getData=function(){return this._dataFetched=!0,{sphere:this._sphere}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._sphere.dispose():setTimeout((function(){t._dataFetched||t._sphere.dispose()}),0)},e.prototype._tick=function(){if(this._sphere)this._physicsHelper.applyRadialExplosionForce(this._origin,this._radius,-1*this._strength,this._falloff);else{var e=this._physicsHelper.applyRadialExplosionForce(this._origin,this._radius,-1*this._strength,this._falloff);e&&(this._sphere=e.getData().sphere.clone("radialExplosionEventSphereClone"))}},e})();f.PhysicsGravitationalFieldEvent=o;var s=(function(){function e(e,t,i,r,n,o){this._scene=e,this._origin=t,this._radius=i,this._strength=r,this._height=n,this._updraftMode=o,this._originTop=f.Vector3.Zero(),this._originDirection=f.Vector3.Zero(),this._cylinderPosition=f.Vector3.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._origin.addToRef(new f.Vector3(0,this._height/2,0),this._cylinderPosition),this._origin.addToRef(new f.Vector3(0,this._height,0),this._originTop),this._updraftMode===a.Perpendicular&&(this._originDirection=this._origin.subtract(this._originTop).normalize()),this._tickCallback=this._tick.bind(this)}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0)},e.prototype.getImpostorForceAndContactPoint=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;var t=e.getObjectCenter();if(this._updraftMode===a.Perpendicular)var i=this._originDirection;else i=t.subtract(this._originTop);var r=-1*this._strength;return{force:i.multiplyByFloats(r,r,r),contactPoint:t}},e.prototype._tick=function(){var i=this;this._physicsEngine.getImpostors().forEach((function(e){var t=i.getImpostorForceAndContactPoint(e);t&&e.applyForce(t.force,t.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=f.MeshBuilder.CreateCylinder("updraftEventCylinder",{height:this._height,diameter:2*this._radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._prepareCylinder(),this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e})();f.PhysicsUpdraftEvent=s;var h,i,a,r,l=(function(){function e(e,t,i,r,n){this._scene=e,this._origin=t,this._radius=i,this._strength=r,this._height=n,this._originTop=f.Vector3.Zero(),this._centripetalForceThreshold=.7,this._updraftMultiplier=.02,this._cylinderPosition=f.Vector3.Zero(),this._dataFetched=!1,this._physicsEngine=this._scene.getPhysicsEngine(),this._origin.addToRef(new f.Vector3(0,this._height/2,0),this._cylinderPosition),this._origin.addToRef(new f.Vector3(0,this._height,0),this._originTop),this._tickCallback=this._tick.bind(this)}return e.prototype.getData=function(){return this._dataFetched=!0,{cylinder:this._cylinder}},e.prototype.enable=function(){this._tickCallback.call(this),this._scene.registerBeforeRender(this._tickCallback)},e.prototype.disable=function(){this._scene.unregisterBeforeRender(this._tickCallback)},e.prototype.dispose=function(e){var t=this;void 0===e&&(e=!0),e?this._cylinder.dispose():setTimeout((function(){t._dataFetched||t._cylinder.dispose()}),0)},e.prototype.getImpostorForceAndContactPoint=function(e){if(0===e.mass)return null;if(!this._intersectsWithCylinder(e))return null;if("Mesh"!==e.object.getClassName()&&"InstancedMesh"!==e.object.getClassName())return null;var t=e.getObjectCenter(),i=new f.Vector3(this._origin.x,t.y,this._origin.z),r=t.subtract(i),n=new f.Ray(i,r,this._radius).intersectsMesh(e.object),o=n.pickedPoint;if(!o)return null;var s=n.distance/this._radius,a=f.Vector3.Cross(i,t).normalize(),l=o.normalize();if(s>this._centripetalForceThreshold&&(l=l.negate()),s>this._centripetalForceThreshold)var c=l.x*this._strength/8,h=l.y*this._updraftMultiplier,u=l.z*this._strength/8;else c=(a.x+l.x)/2,h=this._originTop.y*this._updraftMultiplier,u=(a.z+l.z)/2;var d=new f.Vector3(c,h,u);return{force:d=d.multiplyByFloats(this._strength,this._strength,this._strength),contactPoint:t}},e.prototype._tick=function(){var i=this;this._physicsEngine.getImpostors().forEach((function(e){var t=i.getImpostorForceAndContactPoint(e);t&&e.applyForce(t.force,t.contactPoint)}))},e.prototype._prepareCylinder=function(){this._cylinder||(this._cylinder=f.MeshBuilder.CreateCylinder("vortexEventCylinder",{height:this._height,diameter:2*this._radius},this._scene),this._cylinder.isVisible=!1)},e.prototype._intersectsWithCylinder=function(e){var t=e.object;return this._prepareCylinder(),this._cylinder.position=this._cylinderPosition,this._cylinder.intersectsMesh(t,!0)},e})();f.PhysicsVortexEvent=l,(i=h=f.PhysicsRadialImpulseFalloff||(f.PhysicsRadialImpulseFalloff={}))[i.Constant=0]="Constant",i[i.Linear=1]="Linear",(r=a=f.PhysicsUpdraftMode||(f.PhysicsUpdraftMode={}))[r.Center=0]="Center",r[r.Perpendicular=1]="Perpendicular"})($a||($a={})),Bo=$a||($a={}),No=(function(){function e(e,t){void 0===e&&(e=!0),void 0===t&&(t=10),this._useDeltaForWorldStep=e,this.name="CannonJSPlugin",this._physicsMaterials=new Array,this._fixedTimeStep=1/60,this.BJSCANNON=i,this._minus90X=new Bo.Quaternion(-.7071067811865475,0,0,.7071067811865475),this._plus90X=new Bo.Quaternion(.7071067811865475,0,0,.7071067811865475),this._tmpPosition=Bo.Vector3.Zero(),this._tmpDeltaPosition=Bo.Vector3.Zero(),this._tmpUnityRotation=new Bo.Quaternion,this.isSupported()?(this._extendNamespace(),this.world=new this.BJSCANNON.World,this.world.broadphase=new this.BJSCANNON.NaiveBroadphase,this.world.solver.iterations=t):Bo.Tools.Error("CannonJS is not available. Please make sure you included the js file.")}return e.prototype.setGravity=function(e){this.world.gravity.copy(e)},e.prototype.setTimeStep=function(e){this._fixedTimeStep=e},e.prototype.getTimeStep=function(){return this._fixedTimeStep},e.prototype.executeStep=function(e,t){this.world.step(this._fixedTimeStep,this._useDeltaForWorldStep?e:0,3)},e.prototype.applyImpulse=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyImpulse(n,r)},e.prototype.applyForce=function(e,t,i){var r=new this.BJSCANNON.Vec3(i.x,i.y,i.z),n=new this.BJSCANNON.Vec3(t.x,t.y,t.z);e.physicsBody.applyForce(n,r)},e.prototype.generatePhysicsBody=function(t){if(t.parent)t.physicsBody&&(this.removePhysicsBody(t),t.forceUpdate());else{if(t.isBodyInitRequired()){var e=this._createShape(t),i=t.physicsBody;i&&this.removePhysicsBody(t);var r=this._addMaterial("mat-"+t.uniqueId,t.getParam("friction"),t.getParam("restitution")),n={mass:t.getParam("mass"),material:r},o=t.getParam("nativeOptions");for(var s in o)o.hasOwnProperty(s)&&(n[s]=o[s]);t.physicsBody=new this.BJSCANNON.Body(n),t.physicsBody.addEventListener("collide",t.onCollide),this.world.addEventListener("preStep",t.beforeStep),this.world.addEventListener("postStep",t.afterStep),t.physicsBody.addShape(e),this.world.add(t.physicsBody),i&&["force","torque","velocity","angularVelocity"].forEach((function(e){t.physicsBody[e].copy(i[e])})),this._processChildMeshes(t)}this._updatePhysicsBodyTransformation(t)}},e.prototype._processChildMeshes=function(o){var s=this,e=o.object.getChildMeshes?o.object.getChildMeshes(!0):[],a=o.object.rotationQuaternion;if(e.length){var l=function(e,t){if(a&&t.rotationQuaternion){var i=t.getPhysicsImpostor();if(i)if(i.parent!==o){var r=t.getAbsolutePosition().subtract(o.object.getAbsolutePosition()),n=t.rotationQuaternion.multiply(Bo.Quaternion.Inverse(a));i.physicsBody&&(s.removePhysicsBody(i),i.physicsBody=null),i.parent=o,i.resetUpdateFlags(),o.physicsBody.addShape(s._createShape(i),new s.BJSCANNON.Vec3(r.x,r.y,r.z),new s.BJSCANNON.Quaternion(n.x,n.y,n.z,n.w)),o.physicsBody.mass+=i.getParam("mass")}a.multiplyInPlace(t.rotationQuaternion),t.getChildMeshes(!0).filter((function(e){return!!e.physicsImpostor})).forEach(l.bind(s,t.getAbsolutePosition()))}};e.filter((function(e){return!!e.physicsImpostor})).forEach(l.bind(this,o.object.getAbsolutePosition()))}},e.prototype.removePhysicsBody=function(e){e.physicsBody.removeEventListener("collide",e.onCollide),this.world.removeEventListener("preStep",e.beforeStep),this.world.removeEventListener("postStep",e.afterStep),this.world.remove(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var r,n=e.joint.jointData,o={pivotA:n.mainPivot?(new this.BJSCANNON.Vec3).copy(n.mainPivot):null,pivotB:n.connectedPivot?(new this.BJSCANNON.Vec3).copy(n.connectedPivot):null,axisA:n.mainAxis?(new this.BJSCANNON.Vec3).copy(n.mainAxis):null,axisB:n.connectedAxis?(new this.BJSCANNON.Vec3).copy(n.connectedAxis):null,maxForce:n.nativeParams.maxForce,collideConnected:!!n.collision};switch(e.joint.type){case Bo.PhysicsJoint.HingeJoint:case Bo.PhysicsJoint.Hinge2Joint:r=new this.BJSCANNON.HingeConstraint(t,i,o);break;case Bo.PhysicsJoint.DistanceJoint:r=new this.BJSCANNON.DistanceConstraint(t,i,n.maxDistance||2);break;case Bo.PhysicsJoint.SpringJoint:var s=n;r=new this.BJSCANNON.Spring(t,i,{restLength:s.length,stiffness:s.stiffness,damping:s.damping,localAnchorA:o.pivotA,localAnchorB:o.pivotB});break;case Bo.PhysicsJoint.LockJoint:r=new this.BJSCANNON.LockConstraint(t,i,o);break;case Bo.PhysicsJoint.PointToPointJoint:case Bo.PhysicsJoint.BallAndSocketJoint:default:r=new this.BJSCANNON.PointToPointConstraint(t,o.pivotA,i,o.pivotA,o.maxForce)}r.collideConnected=!!n.collision,e.joint.physicsJoint=r,e.joint.type!==Bo.PhysicsJoint.SpringJoint?this.world.addConstraint(r):(e.joint.jointData.forceApplicationCallback=e.joint.jointData.forceApplicationCallback||function(){r.applyForce()},e.mainImpostor.registerAfterPhysicsStep(e.joint.jointData.forceApplicationCallback))}},e.prototype.removeJoint=function(e){e.joint.type!==Bo.PhysicsJoint.SpringJoint?this.world.removeConstraint(e.joint.physicsJoint):e.mainImpostor.unregisterAfterPhysicsStep(e.joint.jointData.forceApplicationCallback)},e.prototype._addMaterial=function(e,t,i){var r,n;for(r=0;r<this._physicsMaterials.length;r++)if((n=this._physicsMaterials[r]).friction===t&&n.restitution===i)return n;var o=new this.BJSCANNON.Material(e);return o.friction=t,o.restitution=i,this._physicsMaterials.push(o),o},e.prototype._checkWithEpsilon=function(e){return e<Bo.PhysicsEngine.Epsilon?Bo.PhysicsEngine.Epsilon:e},e.prototype._createShape=function(e){var t,i=e.object,r=e.getObjectExtendSize();switch(e.type){case Bo.PhysicsImpostor.SphereImpostor:var n=r.x,o=r.y,s=r.z;t=new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(n),this._checkWithEpsilon(o),this._checkWithEpsilon(s))/2);break;case Bo.PhysicsImpostor.CylinderImpostor:t=new this.BJSCANNON.Cylinder(this._checkWithEpsilon(r.x)/2,this._checkWithEpsilon(r.x)/2,this._checkWithEpsilon(r.y),16);break;case Bo.PhysicsImpostor.BoxImpostor:var a=r.scale(.5);t=new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(a.x),this._checkWithEpsilon(a.y),this._checkWithEpsilon(a.z)));break;case Bo.PhysicsImpostor.PlaneImpostor:Bo.Tools.Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead"),t=new this.BJSCANNON.Plane;break;case Bo.PhysicsImpostor.MeshImpostor:var l=i.getVerticesData?i.getVerticesData(Bo.VertexBuffer.PositionKind):[],c=i.getIndices?i.getIndices():[];if(!l)return;var h=i.position.clone(),u=i.rotation&&i.rotation.clone(),d=i.rotationQuaternion&&i.rotationQuaternion.clone();i.position.copyFromFloats(0,0,0),i.rotation&&i.rotation.copyFromFloats(0,0,0),i.rotationQuaternion&&i.rotationQuaternion.copyFrom(e.getParentsRotation()),i.rotationQuaternion&&i.parent&&i.rotationQuaternion.conjugateInPlace();var f,p=i.computeWorldMatrix(!0),m=new Array;for(f=0;f<l.length;f+=3)Bo.Vector3.TransformCoordinates(Bo.Vector3.FromArray(l,f),p).toArray(m,f);Bo.Tools.Warn("MeshImpostor only collides against spheres."),t=new this.BJSCANNON.Trimesh(m,c),i.position.copyFrom(h),u&&i.rotation&&i.rotation.copyFrom(u),d&&i.rotationQuaternion&&i.rotationQuaternion.copyFrom(d);break;case Bo.PhysicsImpostor.HeightmapImpostor:var _=i.position.clone(),g=i.rotation&&i.rotation.clone(),v=i.rotationQuaternion&&i.rotationQuaternion.clone();i.position.copyFromFloats(0,0,0),i.rotation&&i.rotation.copyFromFloats(0,0,0),i.rotationQuaternion&&i.rotationQuaternion.copyFrom(e.getParentsRotation()),i.rotationQuaternion&&i.parent&&i.rotationQuaternion.conjugateInPlace(),i.rotationQuaternion&&i.rotationQuaternion.multiplyInPlace(this._minus90X),t=this._createHeightmap(i),i.position.copyFrom(_),g&&i.rotation&&i.rotation.copyFrom(g),v&&i.rotationQuaternion&&i.rotationQuaternion.copyFrom(v),i.computeWorldMatrix(!0);break;case Bo.PhysicsImpostor.ParticleImpostor:t=new this.BJSCANNON.Particle}return t},e.prototype._createHeightmap=function(e,t){var i,r=e.getVerticesData(Bo.VertexBuffer.PositionKind),n=e.computeWorldMatrix(!0),o=new Array;for(i=0;i<r.length;i+=3)Bo.Vector3.TransformCoordinates(Bo.Vector3.FromArray(r,i),n).toArray(o,i);r=o;for(var s=new Array,a=t||~~(Math.sqrt(r.length/3)-1),l=e.getBoundingInfo(),c=Math.min(l.boundingBox.extendSizeWorld.x,l.boundingBox.extendSizeWorld.y),h=l.boundingBox.extendSizeWorld.z,u=2*c/a,d=0;d<r.length;d+=3){var f=Math.round(r[d+0]/u+a/2),p=Math.round(-1*(r[d+1]/u-a/2)),m=-r[d+2]+h;s[f]||(s[f]=[]),s[f][p]||(s[f][p]=m),s[f][p]=Math.max(m,s[f][p])}for(f=0;f<=a;++f){if(!s[f]){for(var _=1;!s[(f+_)%a];)_++;s[f]=s[(f+_)%a].slice()}for(p=0;p<=a;++p)if(!s[f][p]){var g;for(_=1;void 0===g;)g=s[f][(p+_++)%a];s[f][p]=g}}var v=new this.BJSCANNON.Heightfield(s,{elementSize:u});return v.minY=h,v},e.prototype._updatePhysicsBodyTransformation=function(e){var t=e.object;if(t.computeWorldMatrix&&t.computeWorldMatrix(!0),t.getBoundingInfo()){var i=e.getObjectCenter();this._tmpDeltaPosition.copyFrom(t.getAbsolutePivotPoint().subtract(i)),this._tmpDeltaPosition.divideInPlace(e.object.scaling),this._tmpPosition.copyFrom(i);var r=t.rotationQuaternion;if(r){if(e.type!==Bo.PhysicsImpostor.PlaneImpostor&&e.type!==Bo.PhysicsImpostor.HeightmapImpostor&&e.type!==Bo.PhysicsImpostor.CylinderImpostor||(r=r.multiply(this._minus90X),e.setDeltaRotation(this._plus90X)),e.type===Bo.PhysicsImpostor.HeightmapImpostor){var n=t,o=n.getBoundingInfo(),s=n.rotationQuaternion;n.rotationQuaternion=this._tmpUnityRotation,n.computeWorldMatrix(!0);var a=i.clone(),l=n.getPivotMatrix()||Bo.Matrix.Translation(0,0,0),c=Bo.Matrix.Translation(o.boundingBox.extendSizeWorld.x,0,-o.boundingBox.extendSizeWorld.z);n.setPreTransformMatrix(c),n.computeWorldMatrix(!0);var h=o.boundingBox.centerWorld.subtract(i).subtract(n.position).negate();this._tmpPosition.copyFromFloats(h.x,h.y-o.boundingBox.extendSizeWorld.y,h.z),this._tmpDeltaPosition.copyFrom(o.boundingBox.centerWorld.subtract(a)),this._tmpDeltaPosition.y+=o.boundingBox.extendSizeWorld.y,n.rotationQuaternion=s,n.setPreTransformMatrix(l),n.computeWorldMatrix(!0)}else e.type===Bo.PhysicsImpostor.MeshImpostor&&this._tmpDeltaPosition.copyFromFloats(0,0,0);e.setDeltaPosition(this._tmpDeltaPosition),e.physicsBody.position.copy(this._tmpPosition),e.physicsBody.quaternion.copy(r)}}},e.prototype.setTransformationFromPhysicsBody=function(e){e.object.position.copyFrom(e.physicsBody.position),e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.quaternion)},e.prototype.setPhysicsBodyTransformation=function(e,t,i){e.physicsBody.position.copy(t),e.physicsBody.quaternion.copy(i)},e.prototype.isSupported=function(){return void 0!==this.BJSCANNON},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.velocity.copy(t)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.velocity;return t?new Bo.Vector3(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new Bo.Vector3(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){e.physicsBody.mass=t,e.physicsBody.updateMassProperties()},e.prototype.getBodyMass=function(e){return e.physicsBody.mass},e.prototype.getBodyFriction=function(e){return e.physicsBody.material.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.material.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.material.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.material.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.wakeUp()},e.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.distance=t},e.prototype.setMotor=function(e,t,i,r){r||(e.physicsJoint.enableMotor(),e.physicsJoint.setMotorSpeed(t),i&&this.setLimit(e,i))},e.prototype.setLimit=function(e,t,i){e.physicsJoint.motorEquation.maxForce=t,e.physicsJoint.motorEquation.minForce=void 0===i?-t:i},e.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.quaternion.x,e.rotationQuaternion.y=i.quaternion.y,e.rotationQuaternion.z=i.quaternion.z,e.rotationQuaternion.w=i.quaternion.w)},e.prototype.getRadius=function(e){return e.physicsBody.shapes[0].boundingSphereRadius},e.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes[0];t.x=2*i.halfExtents.x,t.y=2*i.halfExtents.y,t.z=2*i.halfExtents.z},e.prototype.dispose=function(){},e.prototype._extendNamespace=function(){var u=new this.BJSCANNON.Vec3,d=this.BJSCANNON;this.BJSCANNON.World.prototype.step=function(e,t,i){if(i=i||10,0===(t=t||0))this.internalStep(e),this.time+=e;else{var r=Math.floor((this.time+t)/e)-Math.floor(this.time/e);r=Math.min(r,i)||1;for(var n=performance.now(),o=0;o!==r&&(this.internalStep(e),!(performance.now()-n>1e3*e));o++);this.time+=t;for(var s=this.time%e/e,a=u,l=this.bodies,c=0;c!==l.length;c++){var h=l[c];h.type!==d.Body.STATIC&&h.sleepState!==d.Body.SLEEPING?(h.position.vsub(h.previousPosition,a),a.scale(s,a),h.position.vadd(a,h.interpolatedPosition)):(h.interpolatedPosition.copy(h.position),h.interpolatedQuaternion.copy(h.quaternion))}}}},e})(),Bo.CannonJSPlugin=No,Vo=$a||($a={}),Uo=(function(){function e(e){this.name="OimoJSPlugin",this._tmpImpostorsArray=[],this._tmpPositionVector=Vo.Vector3.Zero(),this.BJSOIMO=t,this.world=new this.BJSOIMO.World({iterations:e}),this.world.clear()}return e.prototype.setGravity=function(e){this.world.gravity.copy(e)},e.prototype.setTimeStep=function(e){this.world.timeStep=e},e.prototype.getTimeStep=function(){return this.world.timeStep},e.prototype.executeStep=function(e,t){var i=this;t.forEach((function(e){e.beforeStep()})),this.world.step(),t.forEach((function(e){e.afterStep(),i._tmpImpostorsArray[e.uniqueId]=e}));for(var r=this.world.contacts;null!==r;)if(!r.touching||r.body1.sleeping||r.body2.sleeping){var n=this._tmpImpostorsArray[+r.body1.name],o=this._tmpImpostorsArray[+r.body2.name];n&&o&&(n.onCollide({body:o.physicsBody}),o.onCollide({body:n.physicsBody})),r=r.next}else r=r.next},e.prototype.applyImpulse=function(e,t,i){var r=e.physicsBody.mass;e.physicsBody.applyImpulse(i.scale(this.world.invScale),t.scale(this.world.invScale*r))},e.prototype.applyForce=function(e,t,i){Vo.Tools.Warn("Oimo doesn't support applying force. Using impule instead."),this.applyImpulse(e,t,i)},e.prototype.generatePhysicsBody=function(p){var m=this;if(p.parent)p.physicsBody&&(this.removePhysicsBody(p),p.forceUpdate());else{if(p.isBodyInitRequired()){var _={name:p.uniqueId,config:[p.getParam("mass")||1,p.getParam("friction"),p.getParam("restitution")],size:[],type:[],pos:[],posShape:[],rot:[],rotShape:[],move:0!==p.getParam("mass"),density:p.getParam("mass"),friction:p.getParam("friction"),restitution:p.getParam("restitution"),world:this.world},t=[p];(e=p.object).getChildMeshes&&e.getChildMeshes().forEach((function(e){e.physicsImpostor&&t.push(e.physicsImpostor)}));var g=function(e){return Math.max(e,Vo.PhysicsEngine.Epsilon)},v=new Vo.Quaternion;t.forEach((function(e){if(e.object.rotationQuaternion){var t=e.object.rotationQuaternion;v=t.clone();var i=t.toEulerAngles(),r=e.getObjectExtendSize(),n=57.29577951308232;if(e===p){var o=p.getObjectCenter();p.object.getAbsolutePivotPoint().subtractToRef(o,m._tmpPositionVector),m._tmpPositionVector.divideInPlace(p.object.scaling),_.pos.push(o.x),_.pos.push(o.y),_.pos.push(o.z),_.posShape.push(0,0,0),_.rot.push(0),_.rot.push(0),_.rot.push(0),_.rotShape.push(0,0,0)}else{var s=e.object.getAbsolutePosition().subtract(p.object.getAbsolutePosition());_.posShape.push(s.x),_.posShape.push(s.y),_.posShape.push(s.z),_.pos.push(0,0,0),_.rot.push(0),_.rot.push(0),_.rot.push(0),_.rotShape.push(i.x*n),_.rotShape.push(i.y*n),_.rotShape.push(i.z*n)}switch(e.type){case Vo.PhysicsImpostor.ParticleImpostor:Vo.Tools.Warn("No Particle support in OIMO.js. using SphereImpostor instead");case Vo.PhysicsImpostor.SphereImpostor:var a=r.x,l=r.y,c=r.z,h=Math.max(g(a),g(l),g(c))/2;_.type.push("sphere"),_.size.push(h),_.size.push(h),_.size.push(h);break;case Vo.PhysicsImpostor.CylinderImpostor:var u=g(r.x)/2,d=g(r.y);_.type.push("cylinder"),_.size.push(u),_.size.push(d),_.size.push(d);break;case Vo.PhysicsImpostor.PlaneImpostor:case Vo.PhysicsImpostor.BoxImpostor:default:u=g(r.x),d=g(r.y);var f=g(r.z);_.type.push("box"),_.size.push(u),_.size.push(d),_.size.push(f)}e.object.rotationQuaternion=t}})),p.physicsBody=this.world.add(_),p.physicsBody.resetQuaternion(v),p.physicsBody.updatePosition(0)}else this._tmpPositionVector.copyFromFloats(0,0,0);var e;p.setDeltaPosition(this._tmpPositionVector)}},e.prototype.removePhysicsBody=function(e){this.world.removeRigidBody(e.physicsBody)},e.prototype.generateJoint=function(e){var t=e.mainImpostor.physicsBody,i=e.connectedImpostor.physicsBody;if(t&&i){var r,n=e.joint.jointData,o=n.nativeParams||{},s={body1:t,body2:i,axe1:o.axe1||(n.mainAxis?n.mainAxis.asArray():null),axe2:o.axe2||(n.connectedAxis?n.connectedAxis.asArray():null),pos1:o.pos1||(n.mainPivot?n.mainPivot.asArray():null),pos2:o.pos2||(n.connectedPivot?n.connectedPivot.asArray():null),min:o.min,max:o.max,collision:o.collision||n.collision,spring:o.spring,world:this.world};switch(e.joint.type){case Vo.PhysicsJoint.BallAndSocketJoint:r="jointBall";break;case Vo.PhysicsJoint.SpringJoint:Vo.Tools.Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");var a=n;s.min=a.length||s.min,s.max=Math.max(s.min,s.max);case Vo.PhysicsJoint.DistanceJoint:r="jointDistance",s.max=n.maxDistance;break;case Vo.PhysicsJoint.PrismaticJoint:r="jointPrisme";break;case Vo.PhysicsJoint.SliderJoint:r="jointSlide";break;case Vo.PhysicsJoint.WheelJoint:r="jointWheel";break;case Vo.PhysicsJoint.HingeJoint:default:r="jointHinge"}s.type=r,e.joint.physicsJoint=this.world.add(s)}},e.prototype.removeJoint=function(e){try{this.world.removeJoint(e.joint.physicsJoint)}catch(e){Vo.Tools.Warn(e)}},e.prototype.isSupported=function(){return void 0!==this.BJSOIMO},e.prototype.setTransformationFromPhysicsBody=function(e){e.physicsBody.sleeping||(e.object.position.copyFrom(e.physicsBody.getPosition()),e.object.rotationQuaternion&&e.object.rotationQuaternion.copyFrom(e.physicsBody.getQuaternion()))},e.prototype.setPhysicsBodyTransformation=function(e,t,i){var r=e.physicsBody;r.position.copy(t),r.orientation.copy(i),r.syncShapes(),r.awake()},e.prototype.setLinearVelocity=function(e,t){e.physicsBody.linearVelocity.copy(t)},e.prototype.setAngularVelocity=function(e,t){e.physicsBody.angularVelocity.copy(t)},e.prototype.getLinearVelocity=function(e){var t=e.physicsBody.linearVelocity;return t?new Vo.Vector3(t.x,t.y,t.z):null},e.prototype.getAngularVelocity=function(e){var t=e.physicsBody.angularVelocity;return t?new Vo.Vector3(t.x,t.y,t.z):null},e.prototype.setBodyMass=function(e,t){var i=0===t;e.physicsBody.shapes.density=i?1:t,e.physicsBody.setupMass(i?2:1)},e.prototype.getBodyMass=function(e){return e.physicsBody.shapes.density},e.prototype.getBodyFriction=function(e){return e.physicsBody.shapes.friction},e.prototype.setBodyFriction=function(e,t){e.physicsBody.shapes.friction=t},e.prototype.getBodyRestitution=function(e){return e.physicsBody.shapes.restitution},e.prototype.setBodyRestitution=function(e,t){e.physicsBody.shapes.restitution=t},e.prototype.sleepBody=function(e){e.physicsBody.sleep()},e.prototype.wakeUpBody=function(e){e.physicsBody.awake()},e.prototype.updateDistanceJoint=function(e,t,i){e.physicsJoint.limitMotor.upperLimit=t,void 0!==i&&(e.physicsJoint.limitMotor.lowerLimit=i)},e.prototype.setMotor=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setMotor(t,i)},e.prototype.setLimit=function(e,t,i,r){var n=r?e.physicsJoint.rotationalLimitMotor2:e.physicsJoint.rotationalLimitMotor1||e.physicsJoint.rotationalLimitMotor||e.physicsJoint.limitMotor;n&&n.setLimit(t,void 0===i?-t:i)},e.prototype.syncMeshWithImpostor=function(e,t){var i=t.physicsBody;e.position.x=i.position.x,e.position.y=i.position.y,e.position.z=i.position.z,e.rotationQuaternion&&(e.rotationQuaternion.x=i.orientation.x,e.rotationQuaternion.y=i.orientation.y,e.rotationQuaternion.z=i.orientation.z,e.rotationQuaternion.w=i.orientation.s)},e.prototype.getRadius=function(e){return e.physicsBody.shapes.radius},e.prototype.getBoxSizeToRef=function(e,t){var i=e.physicsBody.shapes;t.x=2*i.halfWidth,t.y=2*i.halfHeight,t.z=2*i.halfDepth},e.prototype.dispose=function(){this.world.clear()},e})(),Vo.OimoJSPlugin=Uo,(function(n){n.Scene.prototype.getPhysicsEngine=function(){return this._physicsEngine},n.Scene.prototype.enablePhysics=function(e,t){if(void 0===e&&(e=null),this._physicsEngine)return!0;var i=this._getComponent(n.SceneComponentConstants.NAME_PHYSICSENGINE);i||(i=new r(this),this._addComponent(i));try{return this._physicsEngine=new n.PhysicsEngine(e,t),!0}catch(e){return n.Tools.Error(e.message),!1}},n.Scene.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},n.Scene.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},n.Scene.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},n.Scene.prototype._advancePhysicsEngineStep=function(e){this._physicsEngine&&(this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(e/1e3),this.onAfterPhysicsObservable.notifyObservers(this))},Object.defineProperty(n.AbstractMesh.prototype,"physicsImpostor",{get:function(){return this._physicsImpostor},set:function(e){var t=this;this._physicsImpostor!==e&&(this._disposePhysicsObserver&&this.onDisposeObservable.remove(this._disposePhysicsObserver),(this._physicsImpostor=e)&&(this._disposePhysicsObserver=this.onDisposeObservable.add((function(){t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)}))))},enumerable:!0,configurable:!0}),n.AbstractMesh.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},n.AbstractMesh.prototype.applyImpulse=function(e,t){return this.physicsImpostor&&this.physicsImpostor.applyImpulse(e,t),this},n.AbstractMesh.prototype.setPhysicsLinkWith=function(e,t,i,r){return this.physicsImpostor&&e.physicsImpostor&&this.physicsImpostor.createJoint(e.physicsImpostor,n.PhysicsJoint.HingeJoint,{mainPivot:t,connectedPivot:i,nativeParams:r}),this};var r=(function(){function e(e){var t=this;this.name=n.SceneComponentConstants.NAME_PHYSICSENGINE,this.scene=e,this.scene.onBeforePhysicsObservable=new n.Observable,this.scene.onAfterPhysicsObservable=new n.Observable,this.scene.getDeterministicFrameTime=function(){return t.scene._physicsEngine?1e3*t.scene._physicsEngine.getTimeStep():1e3/60}}return e.prototype.register=function(){},e.prototype.rebuild=function(){},e.prototype.dispose=function(){this.scene.onBeforePhysicsObservable.clear(),this.scene.onAfterPhysicsObservable.clear(),this.scene._physicsEngine&&this.scene.disablePhysicsEngine()},e})();n.PhysicsEngineSceneComponent=r})($a||($a={})),(function(B){function e(e){return e.charCodeAt(0)+(e.charCodeAt(1)<<8)+(e.charCodeAt(2)<<16)+(e.charCodeAt(3)<<24)}var N=e("DXT1"),V=e("DXT3"),U=e("DXT5"),z=e("DX10"),t=(function(){function F(){}return F.GetDDSInfo=function(e){var t=new Int32Array(e,0,31),i=new Int32Array(e,0,35),r=1;131072&t[2]&&(r=Math.max(1,t[7]));var n=t[21],o=n===z?i[32]:0,s=B.Engine.TEXTURETYPE_UNSIGNED_INT;switch(n){case 113:s=B.Engine.TEXTURETYPE_HALF_FLOAT;break;case 116:s=B.Engine.TEXTURETYPE_FLOAT;break;case z:if(10===o){s=B.Engine.TEXTURETYPE_HALF_FLOAT;break}}return{width:t[4],height:t[3],mipmapCount:r,isFourCC:4==(4&t[20]),isRGB:64==(64&t[20]),isLuminance:131072==(131072&t[20]),isCube:512==(512&t[28]),isCompressed:n===N||n===V||n===U,dxgiFormat:o,textureType:s}},F._ToHalfFloat=function(e){F._FloatView||(F._FloatView=new Float32Array(1),F._Int32View=new Int32Array(F._FloatView.buffer)),F._FloatView[0]=e;var t=F._Int32View[0],i=t>>16&32768,r=t>>12&2047,n=t>>23&255;return n<103?i:142<n?(i|=31744,i|=(255==n?0:1)&&8388607&t):n<113?i|=((r|=2048)>>114-n)+(r>>113-n&1):(i|=n-112<<10|r>>1,i+=1&r)},F._FromHalfFloat=function(e){var t=(32768&e)>>15,i=(31744&e)>>10,r=1023&e;return 0===i?(t?-1:1)*Math.pow(2,-14)*(r/Math.pow(2,10)):31==i?r?NaN:1/0*(t?-1:1):(t?-1:1)*Math.pow(2,i-15)*(1+r/Math.pow(2,10))},F._GetHalfFloatAsFloatRGBAArrayBuffer=function(e,t,i,r,n,o){for(var s=new Float32Array(r),a=new Uint16Array(n,i),l=0,c=0;c<t;c++)for(var h=0;h<e;h++){var u=4*(h+c*e);s[l]=F._FromHalfFloat(a[u]),s[l+1]=F._FromHalfFloat(a[u+1]),s[l+2]=F._FromHalfFloat(a[u+2]),s[l+3]=F.StoreLODInAlphaChannel?o:F._FromHalfFloat(a[u+3]),l+=4}return s},F._GetHalfFloatRGBAArrayBuffer=function(e,t,i,r,n,o){if(F.StoreLODInAlphaChannel){for(var s=new Uint16Array(r),a=new Uint16Array(n,i),l=0,c=0;c<t;c++)for(var h=0;h<e;h++){var u=4*(h+c*e);s[l]=a[u],s[l+1]=a[u+1],s[l+2]=a[u+2],s[l+3]=F._ToHalfFloat(o),l+=4}return s}return new Uint16Array(n,i,r)},F._GetFloatRGBAArrayBuffer=function(e,t,i,r,n,o){if(F.StoreLODInAlphaChannel){for(var s=new Float32Array(r),a=new Float32Array(n,i),l=0,c=0;c<t;c++)for(var h=0;h<e;h++){var u=4*(h+c*e);s[l]=a[u],s[l+1]=a[u+1],s[l+2]=a[u+2],s[l+3]=o,l+=4}return s}return new Float32Array(n,i,r)},F._GetFloatAsUIntRGBAArrayBuffer=function(e,t,i,r,n,o){for(var s=new Uint8Array(r),a=new Float32Array(n,i),l=0,c=0;c<t;c++)for(var h=0;h<e;h++){var u=4*(h+c*e);s[l]=255*B.Scalar.Clamp(a[u]),s[l+1]=255*B.Scalar.Clamp(a[u+1]),s[l+2]=255*B.Scalar.Clamp(a[u+2]),s[l+3]=F.StoreLODInAlphaChannel?o:255*B.Scalar.Clamp(a[u+3]),l+=4}return s},F._GetHalfFloatAsUIntRGBAArrayBuffer=function(e,t,i,r,n,o){for(var s=new Uint8Array(r),a=new Uint16Array(n,i),l=0,c=0;c<t;c++)for(var h=0;h<e;h++){var u=4*(h+c*e);s[l]=255*B.Scalar.Clamp(F._FromHalfFloat(a[u])),s[l+1]=255*B.Scalar.Clamp(F._FromHalfFloat(a[u+1])),s[l+2]=255*B.Scalar.Clamp(F._FromHalfFloat(a[u+2])),s[l+3]=F.StoreLODInAlphaChannel?o:255*B.Scalar.Clamp(F._FromHalfFloat(a[u+3])),l+=4}return s},F._GetRGBAArrayBuffer=function(e,t,i,r,n,o,s,a,l){for(var c=new Uint8Array(r),h=new Uint8Array(n,i),u=0,d=0;d<t;d++)for(var f=0;f<e;f++){var p=4*(f+d*e);c[u]=h[p+o],c[u+1]=h[p+s],c[u+2]=h[p+a],c[u+3]=h[p+l],u+=4}return c},F._ExtractLongWordOrder=function(e){return 0===e||255===e||-16777216===e?0:1+F._ExtractLongWordOrder(e>>8)},F._GetRGBArrayBuffer=function(e,t,i,r,n,o,s,a){for(var l=new Uint8Array(r),c=new Uint8Array(n,i),h=0,u=0;u<t;u++)for(var d=0;d<e;d++){var f=3*(d+u*e);l[h]=c[f+o],l[h+1]=c[f+s],l[h+2]=c[f+a],h+=3}return l},F._GetLuminanceArrayBuffer=function(e,t,i,r,n){for(var o=new Uint8Array(r),s=new Uint8Array(n,i),a=0,l=0;l<t;l++)for(var c=0;c<e;c++){var h=c+l*e;o[a]=s[h],a++}return o},F.UploadDDSLevels=function(e,t,i,r,n,o,s,a){void 0===s&&(s=-1);var l=null;r.sphericalPolynomial&&(l=new Array);var c,h,u,d,f,p,m,_=e.getCaps().s3tc,g=new Int32Array(i,0,31),v=0,y=0,b=1;if(542327876===g[0])if(r.isFourCC||r.isRGB||r.isLuminance)if(!r.isCompressed||_){var T=g[22];d=g[1]+4;var x,E=!1;if(r.isFourCC)switch(c=g[21]){case N:b=8,y=_.COMPRESSED_RGBA_S3TC_DXT1_EXT;break;case V:b=16,y=_.COMPRESSED_RGBA_S3TC_DXT3_EXT;break;case U:b=16,y=_.COMPRESSED_RGBA_S3TC_DXT5_EXT;break;case 113:case 116:E=!0;break;case z:d+=20;var A=!1;switch(r.dxgiFormat){case 10:A=E=!0;break;case 88:r.isRGB=!0,T=32,A=!(r.isFourCC=!1)}if(A)break;default:return void console.error("Unsupported FourCC code:",(x=c,String.fromCharCode(255&x,x>>8&255,x>>16&255,x>>24&255)))}var P=F._ExtractLongWordOrder(g[23]),S=F._ExtractLongWordOrder(g[24]),R=F._ExtractLongWordOrder(g[25]),M=F._ExtractLongWordOrder(g[26]);E&&(y=e._getRGBABufferInternalSizedFormat(r.textureType)),p=1,131072&g[2]&&!1!==n&&(p=Math.max(1,g[7]));for(var C=0;C<o;C++){for(h=g[4],u=g[3],m=0;m<p;++m){if(-1===s||s===m){var O=-1===s?m:0;if(!r.isCompressed&&r.isFourCC){t.format=B.Engine.TEXTUREFORMAT_RGBA,v=h*u*4;var D=null;e._badOS||e._badDesktopOS||!e.getCaps().textureHalfFloat&&!e.getCaps().textureFloat?(128===T?(D=F._GetFloatAsUIntRGBAArrayBuffer(h,u,d,v,i,O),l&&0==O&&l.push(F._GetFloatRGBAArrayBuffer(h,u,d,v,i,O))):64===T&&(D=F._GetHalfFloatAsUIntRGBAArrayBuffer(h,u,d,v,i,O),l&&0==O&&l.push(F._GetHalfFloatAsFloatRGBAArrayBuffer(h,u,d,v,i,O))),t.type=B.Engine.TEXTURETYPE_UNSIGNED_INT):128===T?(t.type=B.Engine.TEXTURETYPE_FLOAT,D=F._GetFloatRGBAArrayBuffer(h,u,d,v,i,O),l&&0==O&&l.push(D)):64!==T||e.getCaps().textureHalfFloat?(t.type=B.Engine.TEXTURETYPE_HALF_FLOAT,D=F._GetHalfFloatRGBAArrayBuffer(h,u,d,v,i,O),l&&0==O&&l.push(F._GetHalfFloatAsFloatRGBAArrayBuffer(h,u,d,v,i,O))):(t.type=B.Engine.TEXTURETYPE_FLOAT,D=F._GetHalfFloatAsFloatRGBAArrayBuffer(h,u,d,v,i,O),l&&0==O&&l.push(D)),D&&e._uploadDataToTextureDirectly(t,D,C,O)}else if(r.isRGB)t.type=B.Engine.TEXTURETYPE_UNSIGNED_INT,24===T?(t.format=B.Engine.TEXTUREFORMAT_RGB,f=F._GetRGBArrayBuffer(h,u,d,v=h*u*3,i,P,S,R)):(t.format=B.Engine.TEXTUREFORMAT_RGBA,f=F._GetRGBAArrayBuffer(h,u,d,v=h*u*4,i,P,S,R,M)),e._uploadDataToTextureDirectly(t,f,C,O);else if(r.isLuminance){var I=e._getUnpackAlignement(),w=h,L=Math.floor((h+I-1)/I)*I;f=F._GetLuminanceArrayBuffer(h,u,d,v=L*(u-1)+w,i),t.format=B.Engine.TEXTUREFORMAT_LUMINANCE,t.type=B.Engine.TEXTURETYPE_UNSIGNED_INT,e._uploadDataToTextureDirectly(t,f,C,O)}else v=Math.max(4,h)/4*Math.max(4,u)/4*b,f=new Uint8Array(i,d,v),t.type=B.Engine.TEXTURETYPE_UNSIGNED_INT,e._uploadCompressedDataToTextureDirectly(t,y,h,u,f,C,O)}d+=T?h*u*(T/8):v,h*=.5,u*=.5,h=Math.max(1,h),u=Math.max(1,u)}if(void 0!==a)break}l&&0<l.length?r.sphericalPolynomial=B.CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial({size:g[4],right:l[0],left:l[1],up:l[2],down:l[3],front:l[4],back:l[5],format:B.Engine.TEXTUREFORMAT_RGBA,type:B.Engine.TEXTURETYPE_FLOAT,gammaSpace:!1}):r.sphericalPolynomial=void 0}else B.Tools.Error("Compressed textures are not supported on this platform.");else B.Tools.Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");else B.Tools.Error("Invalid magic number in DDS header")},F.StoreLODInAlphaChannel=!1,F})();B.DDSTools=t})($a||($a={})),zo=$a||($a={}),Go=(function(){function e(){this.supportCascades=!0}return e.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".dds")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,i,r,n){var o,s=t.getEngine(),a=!1;if(Array.isArray(e))for(var l=0;l<e.length;l++){var c=e[l];o=zo.DDSTools.GetDDSInfo(c),t.width=o.width,t.height=o.height,a=(o.isRGB||o.isLuminance||1<o.mipmapCount)&&t.generateMipMaps,s._unpackFlipY(o.isCompressed),zo.DDSTools.UploadDDSLevels(s,t,c,o,a,6,-1,l),o.isFourCC||1!==o.mipmapCount||s.generateMipMapsForCubemap(t)}else{var h=e;o=zo.DDSTools.GetDDSInfo(h),t.width=o.width,t.height=o.height,i&&(o.sphericalPolynomial=new zo.SphericalPolynomial),a=(o.isRGB||o.isLuminance||1<o.mipmapCount)&&t.generateMipMaps,s._unpackFlipY(o.isCompressed),zo.DDSTools.UploadDDSLevels(s,t,h,o,a,6),o.isFourCC||1!==o.mipmapCount||s.generateMipMapsForCubemap(t)}s._setCubeMapTextureParams(a),t.isReady=!0,r&&r({isDDS:!0,width:t.width,info:o,data:e,texture:t})},e.prototype.loadData=function(e,t,i){var r=zo.DDSTools.GetDDSInfo(e),n=(r.isRGB||r.isLuminance||1<r.mipmapCount)&&t.generateMipMaps&&r.width>>r.mipmapCount-1==1;i(r.width,r.height,n,r.isFourCC,(function(){zo.DDSTools.UploadDDSLevels(t.getEngine(),t,e,r,n,1)}))},e})(),zo.Engine._TextureLoaders.push(new Go),ko=$a||($a={}),Wo=(function(){function E(){}return E.GetTGAHeader=function(e){var t=0;return{id_length:e[t++],colormap_type:e[t++],image_type:e[t++],colormap_index:e[t++]|e[t++]<<8,colormap_length:e[t++]|e[t++]<<8,colormap_size:e[t++],origin:[e[t++]|e[t++]<<8,e[t++]|e[t++]<<8],width:e[t++]|e[t++]<<8,height:e[t++]|e[t++]<<8,pixel_size:e[t++],flags:e[t++]}},E.UploadContent=function(e,t){if(t.length<19)ko.Tools.Error("Unable to load TGA file - Not enough data to contain header");else{var i=18,r=E.GetTGAHeader(t);if(r.id_length+i>t.length)ko.Tools.Error("Unable to load TGA file - Not enough data");else{i+=r.id_length;var n,o=!1,s=!1,a=!1;switch(r.image_type){case E._TYPE_RLE_INDEXED:o=!0;case E._TYPE_INDEXED:s=!0;break;case E._TYPE_RLE_RGB:o=!0;case E._TYPE_RGB:break;case E._TYPE_RLE_GREY:o=!0;case E._TYPE_GREY:a=!0}var l,c,h,u,d,f,p,m=r.pixel_size>>3,_=r.width*r.height*m;if(s&&(l=t.subarray(i,i+=r.colormap_length*(r.colormap_size>>3))),o){var g,v,y;n=new Uint8Array(_);for(var b=0,T=new Uint8Array(m);i<_&&b<_;)if(v=1+(127&(g=t[i++])),128&g){for(y=0;y<m;++y)T[y]=t[i++];for(y=0;y<v;++y)n.set(T,b+y*m);b+=m*v}else{for(v*=m,y=0;y<v;++y)n[b+y]=t[i++];b+=v}}else n=t.subarray(i,i+=s?r.width*r.height:_);switch((r.flags&E._ORIGIN_MASK)>>E._ORIGIN_SHIFT){default:case E._ORIGIN_UL:c=0,u=1,p=r.width,h=0,d=1,f=r.height;break;case E._ORIGIN_BL:c=0,u=1,p=r.width,h=r.height-1,f=d=-1;break;case E._ORIGIN_UR:c=r.width-1,p=u=-1,h=0,d=1,f=r.height;break;case E._ORIGIN_BR:c=r.width-1,p=u=-1,h=r.height-1,f=d=-1}var x=E["_getImageData"+(a?"Grey":"")+r.pixel_size+"bits"](r,l,n,h,d,f,c,u,p);e.getEngine()._uploadDataToTextureDirectly(e,x)}}},E._getImageData8bits=function(e,t,i,r,n,o,s,a,l){var c,h,u,d=i,f=t,p=e.width,m=e.height,_=0,g=new Uint8Array(p*m*4);for(u=r;u!==o;u+=n)for(h=s;h!==l;h+=a,_++)c=d[_],g[4*(h+p*u)+3]=255,g[4*(h+p*u)+2]=f[3*c+0],g[4*(h+p*u)+1]=f[3*c+1],g[4*(h+p*u)+0]=f[3*c+2];return g},E._getImageData16bits=function(e,t,i,r,n,o,s,a,l){var c,h,u,d=i,f=e.width,p=e.height,m=0,_=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(h=s;h!==l;h+=a,m+=2){var g=255*((31744&(c=d[m+0]+(d[m+1]<<8)))>>10)/31|0,v=255*((992&c)>>5)/31|0,y=255*(31&c)/31|0;_[4*(h+f*u)+0]=g,_[4*(h+f*u)+1]=v,_[4*(h+f*u)+2]=y,_[4*(h+f*u)+3]=32768&c?0:255}return _},E._getImageData24bits=function(e,t,i,r,n,o,s,a,l){var c,h,u=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(h=r;h!==o;h+=n)for(c=s;c!==l;c+=a,p+=3)m[4*(c+d*h)+3]=255,m[4*(c+d*h)+2]=u[p+0],m[4*(c+d*h)+1]=u[p+1],m[4*(c+d*h)+0]=u[p+2];return m},E._getImageData32bits=function(e,t,i,r,n,o,s,a,l){var c,h,u=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(h=r;h!==o;h+=n)for(c=s;c!==l;c+=a,p+=4)m[4*(c+d*h)+2]=u[p+0],m[4*(c+d*h)+1]=u[p+1],m[4*(c+d*h)+0]=u[p+2],m[4*(c+d*h)+3]=u[p+3];return m},E._getImageDataGrey8bits=function(e,t,i,r,n,o,s,a,l){var c,h,u,d=i,f=e.width,p=e.height,m=0,_=new Uint8Array(f*p*4);for(u=r;u!==o;u+=n)for(h=s;h!==l;h+=a,m++)c=d[m],_[4*(h+f*u)+0]=c,_[4*(h+f*u)+1]=c,_[4*(h+f*u)+2]=c,_[4*(h+f*u)+3]=255;return _},E._getImageDataGrey16bits=function(e,t,i,r,n,o,s,a,l){var c,h,u=i,d=e.width,f=e.height,p=0,m=new Uint8Array(d*f*4);for(h=r;h!==o;h+=n)for(c=s;c!==l;c+=a,p+=2)m[4*(c+d*h)+0]=u[p+0],m[4*(c+d*h)+1]=u[p+0],m[4*(c+d*h)+2]=u[p+0],m[4*(c+d*h)+3]=u[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})(),ko.TGATools=Wo,Ho=$a||($a={}),Xo=(function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".tga")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,i,r,n){throw".env not supported in Cube."},e.prototype.loadData=function(e,t,i){var r=new Uint8Array(e),n=Ho.TGATools.GetTGAHeader(r);i(n.width,n.height,t.generateMipMaps,!1,(function(){Ho.TGATools.UploadContent(t,r)}))},e})(),Ho.Engine._TextureLoaders.push(new Xo),jo=$a||($a={}),Yo=(function(){function h(e,t,i,r){this.arrayBuffer=e;var n=new Uint8Array(this.arrayBuffer,0,12);if(171===n[0]&&75===n[1]&&84===n[2]&&88===n[3]&&32===n[4]&&49===n[5]&&49===n[6]&&187===n[7]&&13===n[8]&&10===n[9]&&26===n[10]&&10===n[11]){var o=new Int32Array(this.arrayBuffer,12,13),s=16909060===o[0];this.glType=s?this.switchEndianness(o[1]):o[1],this.glTypeSize=s?this.switchEndianness(o[2]):o[2],this.glFormat=s?this.switchEndianness(o[3]):o[3],this.glInternalFormat=s?this.switchEndianness(o[4]):o[4],this.glBaseInternalFormat=s?this.switchEndianness(o[5]):o[5],this.pixelWidth=s?this.switchEndianness(o[6]):o[6],this.pixelHeight=s?this.switchEndianness(o[7]):o[7],this.pixelDepth=s?this.switchEndianness(o[8]):o[8],this.numberOfArrayElements=s?this.switchEndianness(o[9]):o[9],this.numberOfFaces=s?this.switchEndianness(o[10]):o[10],this.numberOfMipmapLevels=s?this.switchEndianness(o[11]):o[11],this.bytesOfKeyValueData=s?this.switchEndianness(o[12]):o[12],0===this.glType?(this.numberOfMipmapLevels=Math.max(1,this.numberOfMipmapLevels),0!==this.pixelHeight&&0===this.pixelDepth?0===this.numberOfArrayElements?this.numberOfFaces===t?this.loadType=h.COMPRESSED_2D:jo.Tools.Error("number of faces expected"+t+", but found "+this.numberOfFaces):jo.Tools.Error("texture arrays not currently supported"):jo.Tools.Error("only 2D textures currently supported")):jo.Tools.Error("only compressed formats currently supported")}else jo.Tools.Error("texture missing KTX identifier")}return h.prototype.switchEndianness=function(e){return(255&e)<<24|(65280&e)<<8|e>>8&65280|e>>24&255},h.prototype.uploadLevels=function(e,t){switch(this.loadType){case h.COMPRESSED_2D:this._upload2DCompressedLevels(e,t)}},h.prototype._upload2DCompressedLevels=function(e,t){for(var i=h.HEADER_LEN+this.bytesOfKeyValueData,r=this.pixelWidth,n=this.pixelHeight,o=t?this.numberOfMipmapLevels:1,s=0;s<o;s++){var a=new Int32Array(this.arrayBuffer,i,1)[0];i+=4;for(var l=0;l<this.numberOfFaces;l++){var c=new Uint8Array(this.arrayBuffer,i,a);e.getEngine()._uploadCompressedDataToTextureDirectly(e,this.glInternalFormat,r,n,c,l,s),i+=a,i+=3-(a+3)%4}r=Math.max(1,.5*r),n=Math.max(1,.5*n)}},h.HEADER_LEN=64,h.COMPRESSED_2D=0,h.COMPRESSED_3D=1,h.TEX_2D=2,h.TEX_3D=3,h})(),jo.KhronosTextureContainer=Yo,Ko=$a||($a={}),Qo=(function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,i,r,n){return!(!t||r||i||n)},e.prototype.transformUrl=function(e,t){var i=e.lastIndexOf(".");return(-1<i?e.substring(0,i):e)+t},e.prototype.getFallbackTextureUrl=function(e,t){var i=new RegExp(t+"$");return e.replace(i,"")},e.prototype.loadCubeData=function(e,t,i,r,n){if(!Array.isArray(e)){var o=t.getEngine(),s=new Ko.KhronosTextureContainer(e,6),a=1<s.numberOfMipmapLevels&&t.generateMipMaps;o._unpackFlipY(!0),s.uploadLevels(t,t.generateMipMaps),t.width=s.pixelWidth,t.height=s.pixelHeight,o._setCubeMapTextureParams(a),t.isReady=!0}},e.prototype.loadData=function(e,t,i){var r=new Ko.KhronosTextureContainer(e,1);i(r.pixelWidth,r.pixelHeight,!1,!0,(function(){r.uploadLevels(t,t.generateMipMaps)}))},e})(),Ko.Engine._TextureLoaders.unshift(new Qo),Zo=$a||($a={}),qo=(function(){function T(){}return T.GetEnvInfo=function(e){for(var t=new DataView(e),i=0,r=0;r<T._MagicBytes.length;r++)if(t.getUint8(i++)!==T._MagicBytes[r])return Zo.Tools.Error("Not a babylon environment map"),null;for(var n="",o=0;o=t.getUint8(i++);)n+=String.fromCharCode(o);var s=JSON.parse(n);return s.specular&&(s.specular.specularDataPosition=i,s.specular.lodGenerationScale=s.specular.lodGenerationScale||.8),s},T.CreateEnvTextureAsync=function(m){var _=this,e=m.getInternalTexture();if(!e)return Promise.reject("The cube texture is invalid.");if(!m._prefiltered)return Promise.reject("The cube texture is invalid (not prefiltered).");var l=e.getEngine();if(l&&l.premultipliedAlpha)return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");if(m.textureType===Zo.Engine.TEXTURETYPE_UNSIGNED_INT)return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");var c=l.getRenderingCanvas();if(!c)return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");var i=Zo.Engine.TEXTURETYPE_FLOAT;if(!l.getCaps().textureFloatRender&&(i=Zo.Engine.TEXTURETYPE_HALF_FLOAT,!l.getCaps().textureHalfFloatRender))return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");var g=e.width,v=new Zo.Scene(l),y={},r=[],b=Zo.Scalar.Log2(e.width);b=Math.round(b);for(var t=function(s){for(var a=Math.pow(2,b-s),e=function(n){var e=m.readPixels(n,s),o=l.createRawTexture(e,a,a,Zo.Engine.TEXTUREFORMAT_RGBA,!1,!1,Zo.Texture.NEAREST_SAMPLINGMODE,null,i),t=new Promise(function(i,e){var r=new Zo.PostProcess("rgbdEncode","rgbdEncode",null,null,1,null,Zo.Texture.NEAREST_SAMPLINGMODE,l,!1,void 0,Zo.Engine.TEXTURETYPE_UNSIGNED_INT,void 0,null,!1);r.getEffect().executeWhenCompiled((function(){r.onApply=function(e){e._bindTexture("textureSampler",o)};var e=l.getRenderWidth(),t=l.getRenderHeight();l.setSize(a,a),v.postProcessManager.directRender([r],null),Zo.Tools.ToBlob(c,(function(e){var t=new FileReader;t.onload=function(e){var t=e.target.result;y[6*s+n]=t,i()},t.readAsArrayBuffer(e)})),l.setSize(e,t)}))});r.push(t)},t=0;t<6;t++)e(t)},n=0;n<=b;n++)t(n);return Promise.all(r).then((function(){v.dispose();for(var e={version:1,width:g,irradiance:_._CreateEnvTextureIrradiance(m),specular:{mipmaps:[],lodGenerationScale:m.lodGenerationScale}},t=0,i=0;i<=b;i++)for(var r=0;r<6;r++){var n=y[6*i+r].byteLength;e.specular.mipmaps.push({length:n,position:t}),t+=n}for(var o=JSON.stringify(e),s=new ArrayBuffer(o.length+1),a=new Uint8Array(s),l=(i=0,o.length);i<l;i++)a[i]=o.charCodeAt(i);a[o.length]=0;var c=T._MagicBytes.length+t+s.byteLength,h=new ArrayBuffer(c),u=new Uint8Array(h),d=new DataView(h),f=0;for(i=0;i<T._MagicBytes.length;i++)d.setUint8(f++,T._MagicBytes[i]);u.set(new Uint8Array(s),f),f+=s.byteLength;for(i=0;i<=b;i++)for(r=0;r<6;r++){var p=y[6*i+r];u.set(new Uint8Array(p),f),f+=p.byteLength}return h}))},T._CreateEnvTextureIrradiance=function(e){var t=e.sphericalPolynomial;return null==t?null:{x:[t.x.x,t.x.y,t.x.z],y:[t.y.x,t.y.y,t.y.z],z:[t.z.x,t.z.y,t.z.z],xx:[t.xx.x,t.xx.y,t.xx.z],yy:[t.yy.x,t.yy.y,t.yy.z],zz:[t.zz.x,t.zz.y,t.zz.z],yz:[t.yz.x,t.yz.y,t.yz.z],zx:[t.zx.x,t.zx.y,t.zx.z],xy:[t.xy.x,t.xy.y,t.xy.z]}},T.UploadEnvLevelsAsync=function(e,t,i){if(1!==i.version)throw new Error('Unsupported babylon environment map version "'+i.version+'"');var r=i.specular;if(!r)return Promise.resolve();var n=Zo.Scalar.Log2(i.width);if(n=Math.round(n)+1,r.mipmaps.length!==6*n)throw new Error('Unsupported specular mipmaps number "'+r.mipmaps.length+'"');e._lodGenerationScale=r.lodGenerationScale;for(var o=new Array(n),s=0;s<n;s++){o[s]=new Array(6);for(var a=0;a<6;a++){var l=r.mipmaps[6*s+a];o[s][a]=new Uint8Array(t,r.specularDataPosition+l.position,l.length)}}return T.UploadLevelsAsync(e,o)},T.UploadLevelsAsync=function(l,r){if(!Zo.Tools.IsExponentOfTwo(l.width))throw new Error("Texture size must be a power of two");var e=Math.round(Zo.Scalar.Log2(l.width))+1,c=l.getEngine(),h=!1,u=!1,d=null,f=null,p=null,t=c.getCaps();if(l.format=Zo.Engine.TEXTUREFORMAT_RGBA,l.type=Zo.Engine.TEXTURETYPE_UNSIGNED_INT,l.generateMipMaps=!0,c.updateTextureSamplingMode(Zo.Texture.TRILINEAR_SAMPLINGMODE,l),t.textureLOD?c.webGLVersion<2?h=!1:t.textureHalfFloatRender&&t.textureHalfFloatLinearFiltering?(h=!0,l.type=Zo.Engine.TEXTURETYPE_HALF_FLOAT):t.textureFloatRender&&t.textureFloatLinearFiltering&&(h=!0,l.type=Zo.Engine.TEXTURETYPE_FLOAT):(u=!(h=!1),p={}),h)d=new Zo.PostProcess("rgbdDecode","rgbdDecode",null,null,1,null,Zo.Texture.TRILINEAR_SAMPLINGMODE,c,!1,void 0,l.type,void 0,null,!1),l._isRGBD=!1,l.invertY=!1,f=c.createRenderTargetCubeTexture(l.width,{generateDepthBuffer:!1,generateMipMaps:!0,generateStencilBuffer:!1,samplingMode:Zo.Texture.TRILINEAR_SAMPLINGMODE,type:l.type,format:Zo.Engine.TEXTUREFORMAT_RGBA});else if(l._isRGBD=!0,l.invertY=!0,u)for(var i=l._lodGenerationScale,n=l._lodGenerationOffset,o=0;o<3;o++){var s=(e-1)*i+n,a=n+(s-n)*(1-o/2),m=Math.round(Math.min(Math.max(a,0),s)),_=new Zo.InternalTexture(c,Zo.InternalTexture.DATASOURCE_TEMP);_.isCube=!0,_.invertY=!0,_.generateMipMaps=!1,c.updateTextureSamplingMode(Zo.Texture.LINEAR_LINEAR,_);var g=new Zo.BaseTexture(null);switch(g.isCube=!0,g._texture=_,p[m]=g,o){case 0:l._lodTextureLow=g;break;case 1:l._lodTextureMid=g;break;case 2:l._lodTextureHigh=g}}var v=[],y=function(a){for(var e=function(n){var e=r[a][n],t=new Blob([e],{type:"image/png"}),o=URL.createObjectURL(t),s=new Image;s.src=o;var i=new Promise(function(i,r){s.onload=function(){if(h){var t=c.createTexture(null,!0,!0,null,Zo.Texture.NEAREST_SAMPLINGMODE,null,(function(e){r(e)}),s);d.getEffect().executeWhenCompiled((function(){d.onApply=function(e){e._bindTexture("textureSampler",t),e.setFloat2("scale",1,1)},c.scenes[0].postProcessManager.directRender([d],f,!0,n,a),c.restoreDefaultFramebuffer(),t.dispose(),window.URL.revokeObjectURL(o),i()}))}else{if(c._uploadImageToTexture(l,s,n,a),u){var e=p[a];e&&c._uploadImageToTexture(e._texture,s,n,0)}i()}},s.onerror=function(e){r(e)}});v.push(i)},t=0;t<6;t++)e(t)};for(o=0;o<r.length;o++)y(o);if(r.length<e){var b=void 0,T=Math.pow(2,e-1-r.length),x=T*T*4;switch(l.type){case Zo.Engine.TEXTURETYPE_UNSIGNED_INT:b=new Uint8Array(x);break;case Zo.Engine.TEXTURETYPE_HALF_FLOAT:b=new Uint16Array(x);break;case Zo.Engine.TEXTURETYPE_FLOAT:b=new Float32Array(x)}for(o=r.length;o<e;o++)for(var E=0;E<6;E++)c._uploadArrayBufferViewToTexture(l,b,E,o)}return Promise.all(v).then((function(){f&&(c._releaseFramebufferObjects(f),f._swapAndDie(l)),d&&d.dispose(),u&&(l._lodTextureHigh&&l._lodTextureHigh._texture&&(l._lodTextureHigh._texture.isReady=!0),l._lodTextureMid&&l._lodTextureMid._texture&&(l._lodTextureMid._texture.isReady=!0),l._lodTextureLow&&l._lodTextureLow._texture&&(l._lodTextureLow._texture.isReady=!0))}))},T.UploadEnvSpherical=function(e,t){1!==t.version&&Zo.Tools.Warn('Unsupported babylon environment map version "'+t.version+'"');var i=t.irradiance;if(i){var r=new Zo.SphericalPolynomial;Zo.Vector3.FromArrayToRef(i.x,0,r.x),Zo.Vector3.FromArrayToRef(i.y,0,r.y),Zo.Vector3.FromArrayToRef(i.z,0,r.z),Zo.Vector3.FromArrayToRef(i.xx,0,r.xx),Zo.Vector3.FromArrayToRef(i.yy,0,r.yy),Zo.Vector3.FromArrayToRef(i.zz,0,r.zz),Zo.Vector3.FromArrayToRef(i.yz,0,r.yz),Zo.Vector3.FromArrayToRef(i.zx,0,r.zx),Zo.Vector3.FromArrayToRef(i.xy,0,r.xy),e._sphericalPolynomial=r}},T._MagicBytes=[134,22,135,150,246,214,150,54],T})(),Zo.EnvironmentTextureTools=qo,Jo=$a||($a={}),$o=(function(){function e(){this.supportCascades=!1}return e.prototype.canLoad=function(e,t,i,r,n){return 0===e.indexOf(".env")},e.prototype.transformUrl=function(e,t){return e},e.prototype.getFallbackTextureUrl=function(e,t){return null},e.prototype.loadCubeData=function(e,t,i,r,n){if(!Array.isArray(e)){e=e;var o=Jo.EnvironmentTextureTools.GetEnvInfo(e);o?(t.width=o.width,t.height=o.width,Jo.EnvironmentTextureTools.UploadEnvSpherical(t,o),Jo.EnvironmentTextureTools.UploadEnvLevelsAsync(t,e,o).then((function(){t.isReady=!0,r&&r()}))):n&&n("Can not parse the environment file",null)}},e.prototype.loadData=function(e,t,i){throw".env not supported in 2d."},e})(),Jo.Engine._TextureLoaders.push(new $o),es=$a||($a={}),ts=(function(){function e(s){var a=this;this.originalScene=s,this._pointerCaptures={},this._lastPointerEvents={},this.shouldRender=!0,this.onlyCheckPointerDownEvents=!0,this.processAllEvents=!1,this.onPointerOutObservable=new es.Observable,this.utilityLayerScene=new es.Scene(s.getEngine()),this.utilityLayerScene.useRightHandedSystem=s.useRightHandedSystem,this.utilityLayerScene._allowPostProcessClearColor=!1,s.getEngine().scenes.pop(),this.utilityLayerScene.detachControl(),this._originalPointerObserver=s.onPrePointerObservable.add((function(e,t){if(a.processAllEvents||e.type===es.PointerEventTypes.POINTERMOVE||e.type===es.PointerEventTypes.POINTERUP||e.type===es.PointerEventTypes.POINTERDOWN){var i=e.event;if(s.isPointerCaptured(i.pointerId))a._pointerCaptures[i.pointerId]=!1;else{var r=e.ray?a.utilityLayerScene.pickWithRay(e.ray):a.utilityLayerScene.pick(s.pointerX,s.pointerY);if(!e.ray&&r&&(e.ray=r.ray),a.utilityLayerScene.onPrePointerObservable.notifyObservers(e),a.onlyCheckPointerDownEvents&&e.type!=es.PointerEventTypes.POINTERDOWN)return e.skipOnPointerObservable||a.utilityLayerScene.onPointerObservable.notifyObservers(new es.PointerInfo(e.type,e.event,r)),void(e.type===es.PointerEventTypes.POINTERUP&&a._pointerCaptures[i.pointerId]&&(a._pointerCaptures[i.pointerId]=!1));if(a.utilityLayerScene.autoClearDepthAndStencil)r&&r.hit&&(e.skipOnPointerObservable||a.utilityLayerScene.onPointerObservable.notifyObservers(new es.PointerInfo(e.type,e.event,r)),e.skipOnPointerObservable=!0);else{var n=e.ray?s.pickWithRay(e.ray):s.pick(s.pointerX,s.pointerY),o=e.event;n&&r&&(0===r.distance&&n.pickedMesh?a.mainSceneTrackerPredicate&&a.mainSceneTrackerPredicate(n.pickedMesh)?(a._notifyObservers(e,n,o),e.skipOnPointerObservable=!0):e.type===es.PointerEventTypes.POINTERDOWN?a._pointerCaptures[o.pointerId]=!0:a._lastPointerEvents[o.pointerId]&&(a.onPointerOutObservable.notifyObservers(o.pointerId),delete a._lastPointerEvents[o.pointerId]):!a._pointerCaptures[o.pointerId]&&(r.distance<n.distance||0===n.distance)?(a._notifyObservers(e,r,o),e.skipOnPointerObservable||(e.skipOnPointerObservable=0<r.distance)):!a._pointerCaptures[o.pointerId]&&r.distance>n.distance&&(a.mainSceneTrackerPredicate&&a.mainSceneTrackerPredicate(n.pickedMesh)?(a._notifyObservers(e,n,o),e.skipOnPointerObservable=!0):a._lastPointerEvents[o.pointerId]&&(a.onPointerOutObservable.notifyObservers(o.pointerId),delete a._lastPointerEvents[o.pointerId])),e.type===es.PointerEventTypes.POINTERUP&&a._pointerCaptures[o.pointerId]&&(a._pointerCaptures[o.pointerId]=!1))}}}})),this.utilityLayerScene.autoClear=!1,this._afterRenderObserver=this.originalScene.onAfterRenderObservable.add((function(){a.shouldRender&&a.render()})),this._sceneDisposeObserver=this.originalScene.onDisposeObservable.add((function(){a.dispose()})),this._updateCamera()}return Object.defineProperty(e,"DefaultUtilityLayer",{get:function(){return null==e._DefaultUtilityLayer&&(e._DefaultUtilityLayer=new e(es.Engine.LastCreatedScene)).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(es.Engine.LastCreatedScene)).utilityLayerScene.autoClearDepthAndStencil=!1,e._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce((function(){e._DefaultKeepDepthUtilityLayer=null}))),e._DefaultKeepDepthUtilityLayer},enumerable:!0,configurable:!0}),e.prototype._notifyObservers=function(e,t,i){e.skipOnPointerObservable||(this.utilityLayerScene.onPointerObservable.notifyObservers(new es.PointerInfo(e.type,e.event,t)),this._lastPointerEvents[i.pointerId]=!0)},e.prototype.render=function(){if(this._updateCamera(),this.utilityLayerScene.activeCamera){var e=this.utilityLayerScene.activeCamera.getScene(),t=this.utilityLayerScene.activeCamera;t._scene=this.utilityLayerScene,t.leftCamera&&(t.leftCamera._scene=this.utilityLayerScene),t.rightCamera&&(t.rightCamera._scene=this.utilityLayerScene),this.utilityLayerScene.render(!1),t._scene=e,t.leftCamera&&(t.leftCamera._scene=e),t.rightCamera&&(t.rightCamera._scene=e)}},e.prototype.dispose=function(){this.onPointerOutObservable.clear(),this._afterRenderObserver&&this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver),this._sceneDisposeObserver&&this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver),this._originalPointerObserver&&this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver),this.utilityLayerScene.dispose()},e.prototype._updateCamera=function(){this.utilityLayerScene.activeCamera=this.originalScene.activeCamera},e._DefaultUtilityLayer=null,e._DefaultKeepDepthUtilityLayer=null,e})(),es.UtilityLayerRenderer=ts,is=$a||($a={}),rs=(function(){function o(e){this.maxDragAngle=0,this._useAlternatePickedPointAboveMaxDragAngle=!1,this.currentDraggingPointerID=-1,this.dragging=!1,this.dragDeltaRatio=.2,this.updateDragPlane=!0,this._debugMode=!1,this._moving=!1,this.onDragObservable=new is.Observable,this.onDragStartObservable=new is.Observable,this.onDragEndObservable=new is.Observable,this.moveAttached=!0,this.enabled=!0,this.detachCameraControls=!0,this.useObjectOrienationForDragging=!0,this._tmpVector=new is.Vector3(0,0,0),this._alternatePickedPoint=new is.Vector3(0,0,0),this._worldDragAxis=new is.Vector3(0,0,0),this._targetPosition=new is.Vector3(0,0,0),this._attachedElement=null,this._startDragRay=new is.Ray(new is.Vector3,new is.Vector3),this._lastPointerRay={},this._dragDelta=new is.Vector3,this._pointA=new is.Vector3(0,0,0),this._pointB=new is.Vector3(0,0,0),this._pointC=new is.Vector3(0,0,0),this._lineA=new is.Vector3(0,0,0),this._lineB=new is.Vector3(0,0,0),this._localAxis=new is.Vector3(0,0,0),this._lookAt=new is.Vector3(0,0,0),this._options=e||{};var t=0;if(this._options.dragAxis&&t++,this._options.dragPlaneNormal&&t++,1<t)throw"Multiple drag modes specified in dragBehavior options. Only one expected"}return Object.defineProperty(o.prototype,"name",{get:function(){return"PointerDrag"},enumerable:!0,configurable:!0}),o.prototype.init=function(){},o.prototype.attach=function(e){var n=this;this._scene=e.getScene(),this._attachedNode=e,o._planeScene||(this._debugMode?o._planeScene=this._scene:((o._planeScene=new is.Scene(this._scene.getEngine())).detachControl(),this._scene.getEngine().scenes.pop(),this._scene.onDisposeObservable.addOnce((function(){o._planeScene.dispose(),o._planeScene=null})))),this._dragPlane=is.Mesh.CreatePlane("pointerDragPlane",this._debugMode?1:1e4,o._planeScene,!1,is.Mesh.DOUBLESIDE),this.lastDragPosition=new is.Vector3(0,0,0);this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){var i;if(n.enabled)if(e.type==is.PointerEventTypes.POINTERDOWN)!n.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.pickedPoint&&e.pickInfo.ray&&(i=e.pickInfo.pickedMesh,n._attachedNode==i||i.isDescendantOf(n._attachedNode))&&n._startDrag(e.event.pointerId,e.pickInfo.ray,e.pickInfo.pickedPoint);else if(e.type==is.PointerEventTypes.POINTERUP)n.currentDraggingPointerID==e.event.pointerId&&n.releaseDrag();else if(e.type==is.PointerEventTypes.POINTERMOVE){var r=e.event.pointerId;n.currentDraggingPointerID===o._AnyMouseID&&r!==o._AnyMouseID&&"mouse"==e.event.pointerType&&(n._lastPointerRay[n.currentDraggingPointerID]&&(n._lastPointerRay[r]=n._lastPointerRay[n.currentDraggingPointerID],delete n._lastPointerRay[n.currentDraggingPointerID]),n.currentDraggingPointerID=r),n._lastPointerRay[r]||(n._lastPointerRay[r]=new is.Ray(new is.Vector3,new is.Vector3)),e.pickInfo&&e.pickInfo.ray&&(n._lastPointerRay[r].origin.copyFrom(e.pickInfo.ray.origin),n._lastPointerRay[r].direction.copyFrom(e.pickInfo.ray.direction),n.currentDraggingPointerID==r&&n.dragging&&n._moveDrag(e.pickInfo.ray))}})),this._beforeRenderObserver=this._scene.onBeforeRenderObservable.add((function(){n._moving&&n.moveAttached&&(is.BoundingBoxGizmo._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._attachedNode.setAbsolutePosition(n._tmpVector),is.BoundingBoxGizmo._RestorePivotPoint(n._attachedNode))}))},o.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)},o.prototype.startDrag=function(e,t,i){void 0===e&&(e=o._AnyMouseID),this._startDrag(e,t,i);var r=this._lastPointerRay[e];e===o._AnyMouseID&&(r=this._lastPointerRay[Object.keys(this._lastPointerRay)[0]]),r&&this._moveDrag(r)},o.prototype._startDrag=function(e,t,i){if(this._scene.activeCamera&&!this.dragging&&this._attachedNode){is.BoundingBoxGizmo._RemoveAndStorePivotPoint(this._attachedNode),t?(this._startDragRay.direction.copyFrom(t.direction),this._startDragRay.origin.copyFrom(t.origin)):(this._startDragRay.origin.copyFrom(this._scene.activeCamera.position),this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector),this._tmpVector.subtractToRef(this._scene.activeCamera.position,this._startDragRay.direction)),this._updateDragPlanePosition(this._startDragRay,i||this._tmpVector);var r=this._pickWithRayOnDragPlane(this._startDragRay);r&&(this.dragging=!0,this.currentDraggingPointerID=e,this.lastDragPosition.copyFrom(r),this.onDragStartObservable.notifyObservers({dragPlanePoint:r,pointerId:this.currentDraggingPointerID}),this._targetPosition.copyFrom(this._attachedNode.absolutePosition),this.detachCameraControls&&this._scene.activeCamera&&!this._scene.activeCamera.leftCamera&&(this._scene.activeCamera.inputs.attachedElement?(this._attachedElement=this._scene.activeCamera.inputs.attachedElement,this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement)):this._attachedElement=null)),is.BoundingBoxGizmo._RestorePivotPoint(this._attachedNode)}},o.prototype._moveDrag=function(e){this._moving=!0;var t=this._pickWithRayOnDragPlane(e);if(t){this.updateDragPlane&&this._updateDragPlanePosition(e,t);var i=0;this._options.dragAxis?(is.Vector3.TransformCoordinatesToRef(this._options.dragAxis,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._worldDragAxis),t.subtractToRef(this.lastDragPosition,this._tmpVector),i=is.Vector3.Dot(this._tmpVector,this._worldDragAxis),this._worldDragAxis.scaleToRef(i,this._dragDelta)):(i=this._dragDelta.length(),t.subtractToRef(this.lastDragPosition,this._dragDelta)),this._targetPosition.addInPlace(this._dragDelta),this.onDragObservable.notifyObservers({dragDistance:i,delta:this._dragDelta,dragPlanePoint:t,dragPlaneNormal:this._dragPlane.forward,pointerId:this.currentDraggingPointerID}),this.lastDragPosition.copyFrom(t)}},o.prototype._pickWithRayOnDragPlane=function(e){var t=this;if(!e)return null;var i=Math.acos(is.Vector3.Dot(this._dragPlane.forward,e.direction));if(i>Math.PI/2&&(i=Math.PI-i),0<this.maxDragAngle&&i>this.maxDragAngle){if(this._useAlternatePickedPointAboveMaxDragAngle){this._tmpVector.copyFrom(e.direction),this._attachedNode.absolutePosition.subtractToRef(e.origin,this._alternatePickedPoint),this._alternatePickedPoint.normalize(),this._alternatePickedPoint.scaleInPlace(-2*is.Vector3.Dot(this._alternatePickedPoint,this._tmpVector)),this._tmpVector.addInPlace(this._alternatePickedPoint);var r=is.Vector3.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 n=o._planeScene.pickWithRay(e,(function(e){return e==t._dragPlane}));return n&&n.hit&&n.pickedMesh&&n.pickedPoint?n.pickedPoint:null},o.prototype._updateDragPlanePosition=function(e,t){this._pointA.copyFrom(t),this._options.dragAxis?(this.useObjectOrienationForDragging?is.Vector3.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),is.Vector3.CrossToRef(this._lineA,this._lineB,this._lookAt),is.Vector3.CrossToRef(this._lineA,this._lookAt,this._lookAt),this._lookAt.normalize(),this._dragPlane.position.copyFrom(this._pointA),this._pointA.subtractToRef(this._lookAt,this._lookAt),this._dragPlane.lookAt(this._lookAt)):this._options.dragPlaneNormal?(this.useObjectOrienationForDragging?is.Vector3.TransformCoordinatesToRef(this._options.dragPlaneNormal,this._attachedNode.getWorldMatrix().getRotationMatrix(),this._localAxis):this._localAxis.copyFrom(this._options.dragPlaneNormal),this._dragPlane.position.copyFrom(this._pointA),this._pointA.subtractToRef(this._localAxis,this._lookAt),this._dragPlane.lookAt(this._lookAt)):(this._dragPlane.position.copyFrom(this._pointA),this._dragPlane.lookAt(e.origin)),this._dragPlane.computeWorldMatrix(!0)},o.prototype.detach=function(){this._pointerObserver&&this._scene.onPointerObservable.remove(this._pointerObserver),this._beforeRenderObserver&&this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},o._AnyMouseID=-2,o})(),is.PointerDragBehavior=rs,ns=$a||($a={}),os=(function(){function e(){this._startDistance=0,this._initialScale=new ns.Vector3(0,0,0),this._targetScale=new ns.Vector3(0,0,0),this._sceneRenderObserver=null,this._dragBehaviorA=new ns.PointerDragBehavior({}),this._dragBehaviorA.moveAttached=!1,this._dragBehaviorB=new ns.PointerDragBehavior({}),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(t){var i=this;this._ownerNode=t,this._dragBehaviorA.onDragStartObservable.add((function(e){i._dragBehaviorA.dragging&&i._dragBehaviorB.dragging&&(i._dragBehaviorA.currentDraggingPointerID==i._dragBehaviorB.currentDraggingPointerID?i._dragBehaviorA.releaseDrag():(i._initialScale.copyFrom(t.scaling),i._startDistance=i._getCurrentDistance()))})),this._dragBehaviorB.onDragStartObservable.add((function(e){i._dragBehaviorA.dragging&&i._dragBehaviorB.dragging&&(i._dragBehaviorA.currentDraggingPointerID==i._dragBehaviorB.currentDraggingPointerID?i._dragBehaviorB.releaseDrag():(i._initialScale.copyFrom(t.scaling),i._startDistance=i._getCurrentDistance()))})),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(e){e.onDragObservable.add((function(){if(i._dragBehaviorA.dragging&&i._dragBehaviorB.dragging){var e=i._getCurrentDistance()/i._startDistance;i._initialScale.scaleToRef(e,i._targetScale)}}))})),t.addBehavior(this._dragBehaviorA),t.addBehavior(this._dragBehaviorB),this._sceneRenderObserver=t.getScene().onBeforeRenderObservable.add((function(){if(i._dragBehaviorA.dragging&&i._dragBehaviorB.dragging){var e=i._targetScale.subtract(t.scaling).scaleInPlace(.1);.01<e.length()&&t.scaling.addInPlace(e)}}))},e.prototype.detach=function(){var t=this;this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver),[this._dragBehaviorA,this._dragBehaviorB].forEach((function(e){e.onDragStartObservable.clear(),e.onDragObservable.clear(),t._ownerNode.removeBehavior(e)}))},e})(),ns.MultiPointerScaleBehavior=os,ss=$a||($a={}),as=(function(){function i(){this._sceneRenderObserver=null,this._targetPosition=new ss.Vector3(0,0,0),this._moving=!1,this._startingOrientation=new ss.Quaternion,this.zDragFactor=3,this.dragging=!1,this.dragDeltaRatio=.2,this.currentDraggingPointerID=-1,this.detachCameraControls=!0,this.onDragStartObservable=new ss.Observable,this.onDragEndObservable=new ss.Observable}return Object.defineProperty(i.prototype,"name",{get:function(){return"SixDofDrag"},enumerable:!0,configurable:!0}),i.prototype.init=function(){},i.prototype.attach=function(e){var a=this;this._ownerNode=e,this._scene=this._ownerNode.getScene(),i._virtualScene||((i._virtualScene=new ss.Scene(this._scene.getEngine())).detachControl(),this._scene.getEngine().scenes.pop());var l=null,c=new ss.Vector3(0,0,0);this._virtualOriginMesh=new ss.AbstractMesh("",i._virtualScene),this._virtualOriginMesh.rotationQuaternion=new ss.Quaternion,this._virtualDragMesh=new ss.AbstractMesh("",i._virtualScene),this._virtualDragMesh.rotationQuaternion=new ss.Quaternion;var h=null;this._pointerObserver=this._scene.onPointerObservable.add((function(e,t){if(e.type==ss.PointerEventTypes.POINTERDOWN){if(!a.dragging&&e.pickInfo&&e.pickInfo.hit&&e.pickInfo.pickedMesh&&e.pickInfo.ray&&(s=e.pickInfo.pickedMesh,a._ownerNode==s||s.isDescendantOf(a._ownerNode))){a._scene.activeCamera&&a._scene.activeCamera.cameraRigMode==ss.Camera.RIG_MODE_NONE&&e.pickInfo.ray.origin.copyFrom(a._scene.activeCamera.position),l=a._ownerNode,ss.BoundingBoxGizmo._RemoveAndStorePivotPoint(l),c.copyFrom(e.pickInfo.ray.origin),a._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),a._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.subtract(e.pickInfo.ray.direction)),a._virtualOriginMesh.removeChild(a._virtualDragMesh),l.computeWorldMatrix(),a._virtualDragMesh.position.copyFrom(l.absolutePosition),l.rotationQuaternion||(l.rotationQuaternion=ss.Quaternion.RotationYawPitchRoll(l.rotation.y,l.rotation.x,l.rotation.z));var i=l.parent;l.setParent(null),a._virtualDragMesh.rotationQuaternion.copyFrom(l.rotationQuaternion),l.setParent(i),a._virtualOriginMesh.addChild(a._virtualDragMesh),a._targetPosition.copyFrom(a._virtualDragMesh.absolutePosition),a.dragging=!0,a.currentDraggingPointerID=e.event.pointerId,a.detachCameraControls&&a._scene.activeCamera&&!a._scene.activeCamera.leftCamera&&(a._scene.activeCamera.inputs.attachedElement?(h=a._scene.activeCamera.inputs.attachedElement,a._scene.activeCamera.detachControl(a._scene.activeCamera.inputs.attachedElement)):h=null),ss.BoundingBoxGizmo._RestorePivotPoint(l),a.onDragStartObservable.notifyObservers({})}}else if(e.type==ss.PointerEventTypes.POINTERUP)a.currentDraggingPointerID==e.event.pointerId&&(a.dragging=!1,a._moving=!1,a.currentDraggingPointerID=-1,l=null,a._virtualOriginMesh.removeChild(a._virtualDragMesh),a.detachCameraControls&&h&&a._scene.activeCamera&&!a._scene.activeCamera.leftCamera&&a._scene.activeCamera.attachControl(h,!0),a.onDragEndObservable.notifyObservers({}));else if(e.type==ss.PointerEventTypes.POINTERMOVE&&a.currentDraggingPointerID==e.event.pointerId&&a.dragging&&e.pickInfo&&e.pickInfo.ray&&l){var r=a.zDragFactor;a._scene.activeCamera&&a._scene.activeCamera.cameraRigMode==ss.Camera.RIG_MODE_NONE&&(e.pickInfo.ray.origin.copyFrom(a._scene.activeCamera.position),r=0);var n=e.pickInfo.ray.origin.subtract(c);c.copyFrom(e.pickInfo.ray.origin);var o=-ss.Vector3.Dot(n,e.pickInfo.ray.direction);a._virtualOriginMesh.addChild(a._virtualDragMesh),a._virtualDragMesh.position.z-=a._virtualDragMesh.position.z<1?o*a.zDragFactor:o*r*a._virtualDragMesh.position.z,a._virtualDragMesh.position.z<0&&(a._virtualDragMesh.position.z=0),a._virtualOriginMesh.position.copyFrom(e.pickInfo.ray.origin),a._virtualOriginMesh.lookAt(e.pickInfo.ray.origin.subtract(e.pickInfo.ray.direction)),a._virtualOriginMesh.removeChild(a._virtualDragMesh),a._targetPosition.copyFrom(a._virtualDragMesh.absolutePosition),l.parent&&ss.Vector3.TransformCoordinatesToRef(a._targetPosition,ss.Matrix.Invert(l.parent.getWorldMatrix()),a._targetPosition),a._moving||a._startingOrientation.copyFrom(a._virtualDragMesh.rotationQuaternion),a._moving=!0}var s}));var t=new ss.Quaternion;this._sceneRenderObserver=e.getScene().onBeforeRenderObservable.add((function(){if(a.dragging&&a._moving&&l){ss.BoundingBoxGizmo._RemoveAndStorePivotPoint(l),l.position.addInPlace(a._targetPosition.subtract(l.position).scale(a.dragDeltaRatio)),t.copyFrom(a._startingOrientation),t.x=-t.x,t.y=-t.y,t.z=-t.z,a._virtualDragMesh.rotationQuaternion.multiplyToRef(t,t),ss.Quaternion.RotationYawPitchRollToRef(t.toEulerAngles("xyz").y,0,0,t),t.multiplyToRef(a._startingOrientation,t);var e=l.parent;l.setParent(null),ss.Quaternion.SlerpToRef(l.rotationQuaternion,t,a.dragDeltaRatio,l.rotationQuaternion),l.setParent(e),ss.BoundingBoxGizmo._RestorePivotPoint(l)}}))},i.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()},i})(),ss.SixDofDragBehavior=as,ls=$a||($a={}),cs=function(e,t,i,r){void 0===t&&(t=new ls.Vector3),void 0===i&&(i=0),void 0===r&&(r=!1),this.direction=e,this.rotatedDirection=t,this.diff=i,this.ignore=r},hs=(function(){function e(e){this.ui=e,this.name="AttachToBoxBehavior",this.distanceAwayFromFace=.15,this.distanceAwayFromBottomOfFace=.15,this._faceVectors=[new cs(ls.Vector3.Up()),new cs(ls.Vector3.Down()),new cs(ls.Vector3.Left()),new cs(ls.Vector3.Right()),new cs(ls.Vector3.Forward()),new cs(ls.Vector3.Forward().scaleInPlace(-1))],this._tmpMatrix=new ls.Matrix,this._tmpVector=new ls.Vector3,this._zeroVector=ls.Vector3.Zero(),this._lookAtTmpMatrix=new ls.Matrix}return e.prototype.init=function(){},e.prototype._closestFace=function(t){var i=this;return this._faceVectors.forEach((function(e){i._target.rotationQuaternion||(i._target.rotationQuaternion=ls.Quaternion.RotationYawPitchRoll(i._target.rotation.y,i._target.rotation.x,i._target.rotation.z)),i._target.rotationQuaternion.toRotationMatrix(i._tmpMatrix),ls.Vector3.TransformCoordinatesToRef(e.direction,i._tmpMatrix,e.rotatedDirection),e.diff=ls.Vector3.GetAngleBetweenVectors(e.rotatedDirection,t,ls.Vector3.Cross(e.rotatedDirection,t))})),this._faceVectors.reduce((function(e,t){return e.ignore?t:t.ignore?e:e.diff<t.diff?e:t}),this._faceVectors[0])},e.prototype._lookAtToRef=function(e,t,i){void 0===t&&(t=new ls.Vector3(0,1,0)),ls.Matrix.LookAtLHToRef(this._zeroVector,e,t,this._lookAtTmpMatrix),this._lookAtTmpMatrix.invert(),ls.Quaternion.FromRotationMatrixToRef(this._lookAtTmpMatrix,i)},e.prototype.attach=function(r){var n=this;this._target=r,this._scene=this._target.getScene(),this._onRenderObserver=this._scene.onBeforeRenderObservable.add((function(){if(n._scene.activeCamera){var e=n._scene.activeCamera.position;n._scene.activeCamera.devicePosition&&(e=n._scene.activeCamera.devicePosition);var t=n._closestFace(e.subtract(r.position));n._scene.activeCamera.leftCamera?n._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(n._tmpMatrix):n._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(n._tmpMatrix),ls.Vector3.TransformCoordinatesToRef(ls.Vector3.Up(),n._tmpMatrix,n._tmpVector),n._faceVectors.forEach((function(e){t.direction.x&&e.direction.x&&(e.ignore=!0),t.direction.y&&e.direction.y&&(e.ignore=!0),t.direction.z&&e.direction.z&&(e.ignore=!0)}));var i=n._closestFace(n._tmpVector);n._faceVectors.forEach((function(e){e.ignore=!1})),n.ui.position.copyFrom(r.position),t.direction.x&&(t.rotatedDirection.scaleToRef(r.scaling.x/2+n.distanceAwayFromFace,n._tmpVector),n.ui.position.addInPlace(n._tmpVector)),t.direction.y&&(t.rotatedDirection.scaleToRef(r.scaling.y/2+n.distanceAwayFromFace,n._tmpVector),n.ui.position.addInPlace(n._tmpVector)),t.direction.z&&(t.rotatedDirection.scaleToRef(r.scaling.z/2+n.distanceAwayFromFace,n._tmpVector),n.ui.position.addInPlace(n._tmpVector)),n.ui.rotationQuaternion||(n.ui.rotationQuaternion=ls.Quaternion.RotationYawPitchRoll(n.ui.rotation.y,n.ui.rotation.x,n.ui.rotation.z)),t.rotatedDirection.scaleToRef(-1,n._tmpVector),n._lookAtToRef(n._tmpVector,i.rotatedDirection,n.ui.rotationQuaternion),i.direction.x&&n.ui.up.scaleToRef(n.distanceAwayFromBottomOfFace-r.scaling.x/2,n._tmpVector),i.direction.y&&n.ui.up.scaleToRef(n.distanceAwayFromBottomOfFace-r.scaling.y/2,n._tmpVector),i.direction.z&&n.ui.up.scaleToRef(n.distanceAwayFromBottomOfFace-r.scaling.z/2,n._tmpVector),n.ui.position.addInPlace(n._tmpVector)}}))},e.prototype.detach=function(){this._scene.onBeforeRenderObservable.remove(this._onRenderObserver)},e})(),ls.AttachToBoxBehavior=hs,us=$a||($a={}),ds=(function(){function e(){var e=this;this.delay=0,this.fadeInTime=300,this._millisecondsPerFrame=1e3/60,this._hovered=!1,this._hoverValue=0,this._ownerNode=null,this._update=function(){if(e._ownerNode){if(e._hoverValue+=e._hovered?e._millisecondsPerFrame:-e._millisecondsPerFrame,e._setAllVisibility(e._ownerNode,(e._hoverValue-e.delay)/e.fadeInTime),1<e._ownerNode.visibility)return e._setAllVisibility(e._ownerNode,1),void(e._hoverValue=e.fadeInTime+e.delay);if(e._ownerNode.visibility<0&&(e._setAllVisibility(e._ownerNode,0),e._hoverValue<0))return void(e._hoverValue=0);setTimeout(e._update,e._millisecondsPerFrame)}}}return Object.defineProperty(e.prototype,"name",{get:function(){return"FadeInOut"},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){this._ownerNode=e,this._setAllVisibility(this._ownerNode,0)},e.prototype.detach=function(){this._ownerNode=null},e.prototype.fadeIn=function(e){this._hovered=e,this._update()},e.prototype._setAllVisibility=function(e,t){var i=this;e.visibility=t,e.getChildMeshes().forEach((function(e){i._setAllVisibility(e,t)}))},e})(),us.FadeInOutBehavior=ds,fs=$a||($a={}),ps=(function(){function e(e){void 0===e&&(e=fs.UtilityLayerRenderer.DefaultUtilityLayer);var t=this;this.gizmoLayer=e,this.scaleRatio=1,this._tmpMatrix=new fs.Matrix,this._customMeshSet=!1,this.updateGizmoRotationToMatchAttachedMesh=!0,this.updateGizmoPositionToMatchAttachedMesh=!0,this._updateScale=!0,this._interactionsEnabled=!0,this._tempVector=new fs.Vector3,this._rootMesh=new fs.Mesh("gizmoRootNode",e.utilityLayerScene),this._beforeRenderObserver=this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add((function(){t._update()})),this.attachedMesh=null}return Object.defineProperty(e.prototype,"attachedMesh",{get:function(){return this._attachedMesh},set:function(e){this._attachedMesh=e,this._rootMesh.setEnabled(!!e),this._attachedMeshChanged(e)},enumerable:!0,configurable:!0}),e.prototype.setCustomMesh=function(e){if(e.getScene()!=this.gizmoLayer.utilityLayerScene)throw"When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";this._rootMesh.getChildMeshes().forEach((function(e){e.dispose()})),e.parent=this._rootMesh,this._customMeshSet=!0},e.prototype._attachedMeshChanged=function(e){},e.prototype._update=function(){if(this.attachedMesh&&(this.updateGizmoRotationToMatchAttachedMesh?(this._rootMesh.rotationQuaternion||(this._rootMesh.rotationQuaternion=fs.Quaternion.RotationYawPitchRoll(this._rootMesh.rotation.y,this._rootMesh.rotation.x,this._rootMesh.rotation.z)),this._tempVector.copyFrom(this.attachedMesh.scaling),this.attachedMesh.scaling.x<0&&(this.attachedMesh.scaling.x*=-1),this.attachedMesh.scaling.y<0&&(this.attachedMesh.scaling.y*=-1),this.attachedMesh.scaling.z<0&&(this.attachedMesh.scaling.z*=-1),this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix),this.attachedMesh.scaling.copyFrom(this._tempVector),this.attachedMesh.computeWorldMatrix(),fs.Quaternion.FromRotationMatrixToRef(this._tmpMatrix,this._rootMesh.rotationQuaternion)):this._rootMesh.rotationQuaternion&&this._rootMesh.rotationQuaternion.set(0,0,0,1),this.updateGizmoPositionToMatchAttachedMesh&&this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition),this._updateScale&&this.gizmoLayer.utilityLayerScene.activeCamera&&this.attachedMesh)){var e=this.gizmoLayer.utilityLayerScene.activeCamera.position;this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition&&(e=this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition),this._rootMesh.position.subtractToRef(e,this._tempVector);var t=this._tempVector.length()*this.scaleRatio;this._rootMesh.scaling.set(t,t,t)}},e.prototype.dispose=function(){this._rootMesh.dispose(),this._beforeRenderObserver&&this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver)},e})(),fs.Gizmo=ps,ms=$a||($a={}),_s=(function(p){function e(e,t,i){void 0===t&&(t=ms.Color3.Gray()),void 0===i&&(i=ms.UtilityLayerRenderer.DefaultUtilityLayer);var r=p.call(this,i)||this;r._pointerObserver=null,r.snapDistance=0,r.onSnapObservable=new ms.Observable;var n=new ms.StandardMaterial("",i.utilityLayerScene);n.disableLighting=!0,n.emissiveColor=t;var o=new ms.StandardMaterial("",i.utilityLayerScene);o.disableLighting=!0,o.emissiveColor=t.add(new ms.Color3(.3,.3,.3));var s=new ms.AbstractMesh("",i.utilityLayerScene),a=ms.MeshBuilder.CreateCylinder("yPosMesh",{diameterTop:0,height:1.5,diameterBottom:.75,tessellation:96},i.utilityLayerScene),l=ms.MeshBuilder.CreateLines("yPosMesh",{points:[new ms.Vector3(0,0,0),new ms.Vector3(0,1.1,0)]},i.utilityLayerScene);l.color=n.emissiveColor,s.addChild(a),s.addChild(l),a.scaling.scaleInPlace(.05),a.material=n,a.rotation.x=Math.PI/2,a.position.z+=.3,l.scaling.scaleInPlace(.26),l.rotation.x=Math.PI/2,l.material=n,s.lookAt(r._rootMesh.position.subtract(e)),s.scaling.scaleInPlace(1/3),r._rootMesh.addChild(s);var c=0,h=new ms.Vector3,u={snapDistance:0};r.dragBehavior=new ms.PointerDragBehavior({dragAxis:e}),r.dragBehavior.moveAttached=!1,r._rootMesh.addBehavior(r.dragBehavior);var d=new ms.Vector3,f=new ms.Matrix;return r.dragBehavior.onDragObservable.add((function(e){if(r.attachedMesh)if(r.attachedMesh.parent?(r.attachedMesh.parent.computeWorldMatrix().invertToRef(f),f.setTranslationFromFloats(0,0,0),ms.Vector3.TransformCoordinatesToRef(e.delta,f,d)):d.copyFrom(e.delta),0==r.snapDistance)r.attachedMesh.position.addInPlace(d);else if(c+=e.dragDistance,Math.abs(c)>r.snapDistance){var t=Math.floor(Math.abs(c)/r.snapDistance);c%=r.snapDistance,d.normalizeToRef(h),h.scaleInPlace(r.snapDistance*t),r.attachedMesh.position.addInPlace(h),u.snapDistance=r.snapDistance*t,r.onSnapObservable.notifyObservers(u)}})),r._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(e,t){if(!r._customMeshSet){var i=e.pickInfo&&-1!=r._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?o:n;r._rootMesh.getChildMeshes().forEach((function(e){e.material=i,e.color&&(e.color=i.emissiveColor)}))}})),r}return T(e,p),e.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},e.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),p.prototype.dispose.call(this)},e})(ms.Gizmo),ms.AxisDragGizmo=_s,gs=$a||($a={}),vs=(function(u){function e(r,e,t){void 0===e&&(e=gs.Color3.Gray()),void 0===t&&(t=gs.UtilityLayerRenderer.DefaultUtilityLayer);var n=u.call(this,t)||this;n._pointerObserver=null,n.snapDistance=0,n.onSnapObservable=new gs.Observable,n.uniformScaling=!1,n._coloredMaterial=new gs.StandardMaterial("",t.utilityLayerScene),n._coloredMaterial.disableLighting=!0,n._coloredMaterial.emissiveColor=e;var o=new gs.StandardMaterial("",t.utilityLayerScene);o.disableLighting=!0,o.emissiveColor=e.add(new gs.Color3(.3,.3,.3));var i=new gs.AbstractMesh("",t.utilityLayerScene),s=gs.MeshBuilder.CreateBox("yPosMesh",{size:.4},t.utilityLayerScene),a=gs.MeshBuilder.CreateLines("yPosMesh",{points:[new gs.Vector3(0,0,0),new gs.Vector3(0,1.1,0)]},t.utilityLayerScene);a.color=n._coloredMaterial.emissiveColor,i.addChild(s),i.addChild(a),s.scaling.scaleInPlace(.1),s.material=n._coloredMaterial,s.rotation.x=Math.PI/2,s.position.z+=.3,a.scaling.scaleInPlace(.26),a.rotation.x=Math.PI/2,a.material=n._coloredMaterial,i.lookAt(n._rootMesh.position.subtract(r)),n._rootMesh.addChild(i),i.scaling.scaleInPlace(1/3),n.dragBehavior=new gs.PointerDragBehavior({dragAxis:r}),n.dragBehavior.moveAttached=!1,n._rootMesh.addBehavior(n.dragBehavior);var l=0,c=new gs.Vector3,h={snapDistance:0};return n.dragBehavior.onDragObservable.add((function(e){if(n.attachedMesh){var t=!1,i=0;n.uniformScaling?(n.attachedMesh.scaling.normalizeToRef(c),c.y<0&&c.scaleInPlace(-1)):c.copyFrom(r),0==n.snapDistance?c.scaleToRef(e.dragDistance,c):(l+=e.dragDistance,Math.abs(l)>n.snapDistance?(i=Math.floor(l/n.snapDistance),l%=n.snapDistance,c.scaleToRef(n.snapDistance*i,c),t=!0):c.scaleInPlace(0)),n.attachedMesh.scaling.addInPlace(c),t&&(h.snapDistance=n.snapDistance*i,n.onSnapObservable.notifyObservers(h))}})),n._pointerObserver=t.utilityLayerScene.onPointerObservable.add((function(e,t){if(!n._customMeshSet){var i=e.pickInfo&&-1!=n._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?o:n._coloredMaterial;n._rootMesh.getChildMeshes().forEach((function(e){e.material=i,e.color&&(e.color=i.emissiveColor)}))}})),n}return T(e,u),e.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},e.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),u.prototype.dispose.call(this)},e.prototype.setCustomMesh=function(e,t){var i=this;void 0===t&&(t=!1),u.prototype.setCustomMesh.call(this,e),t&&(this._rootMesh.getChildMeshes().forEach((function(e){e.material=i._coloredMaterial,e.color&&(e.color=i._coloredMaterial.emissiveColor)})),this._customMeshSet=!1)},e})(gs.Gizmo),gs.AxisScaleGizmo=vs,ys=$a||($a={}),bs=(function(c){function e(h,e,u,t){void 0===e&&(e=ys.Color3.Gray()),void 0===u&&(u=ys.UtilityLayerRenderer.DefaultUtilityLayer),void 0===t&&(t=32);var d=c.call(this,u)||this;d._pointerObserver=null,d.snapDistance=0,d.onSnapObservable=new ys.Observable;var r=new ys.StandardMaterial("",u.utilityLayerScene);r.disableLighting=!0,r.emissiveColor=e;var n=new ys.StandardMaterial("",u.utilityLayerScene);n.disableLighting=!0,n.emissiveColor=e.add(new ys.Color3(.3,.3,.3));for(var i=new ys.AbstractMesh("",u.utilityLayerScene),o=new Array,s=0;s<t;s++){var a=2*Math.PI*(s/(t-1));o.push(new ys.Vector3(.8*Math.sin(a),0,.8*Math.cos(a)))}var l=ys.Mesh.CreateLines("",o,u.utilityLayerScene);l.color=r.emissiveColor,l.scaling.scaleInPlace(.26),l.material=r,l.rotation.x=Math.PI/2,i.addChild(l),i.lookAt(d._rootMesh.position.subtract(h)),d._rootMesh.addChild(i),i.scaling.scaleInPlace(1/3),d.dragBehavior=new ys.PointerDragBehavior({dragPlaneNormal:h}),d.dragBehavior.moveAttached=!1,d.dragBehavior.maxDragAngle=9*Math.PI/20,d.dragBehavior._useAlternatePickedPointAboveMaxDragAngle=!0,d._rootMesh.addBehavior(d.dragBehavior);var f=new ys.Vector3;d.dragBehavior.onDragStartObservable.add((function(e){d.attachedMesh&&f.copyFrom(e.dragPlanePoint)}));var p=new ys.Matrix,m=new ys.Vector3,_=new ys.Vector3,g={snapDistance:0},v=0,y=new ys.Matrix,b=new ys.Vector3,T=new ys.Quaternion;return d.dragBehavior.onDragObservable.add((function(e){if(d.attachedMesh){d.attachedMesh.rotationQuaternion||(d.attachedMesh.rotationQuaternion=ys.Quaternion.RotationYawPitchRoll(d.attachedMesh.rotation.y,d.attachedMesh.rotation.x,d.attachedMesh.rotation.z));var t=e.dragPlanePoint.subtract(d.attachedMesh.absolutePosition).normalize(),i=f.subtract(d.attachedMesh.absolutePosition).normalize(),r=ys.Vector3.Cross(t,i),n=ys.Vector3.Dot(t,i),o=Math.atan2(r.length(),n);if(m.copyFrom(h),_.copyFrom(h),d.updateGizmoRotationToMatchAttachedMesh&&(d.attachedMesh.rotationQuaternion.toRotationMatrix(p),_=ys.Vector3.TransformCoordinates(m,p)),u.utilityLayerScene.activeCamera){var s=u.utilityLayerScene.activeCamera.position.subtract(d.attachedMesh.position);0<ys.Vector3.Dot(s,_)&&(m.scaleInPlace(-1),_.scaleInPlace(-1))}0<ys.Vector3.Dot(_,r)&&(o=-o);var a=!1;if(0!=d.snapDistance)if(v+=o,Math.abs(v)>d.snapDistance){var l=Math.floor(v/d.snapDistance);v%=d.snapDistance,o=d.snapDistance*l,a=!0}else o=0;y.reset(),d.attachedMesh.parent&&(d.attachedMesh.parent.computeWorldMatrix().invertToRef(y),y.getRotationMatrixToRef(y),ys.Vector3.TransformCoordinatesToRef(m,y,m));var c=Math.sin(o/2);T.set(m.x*c,m.y*c,m.z*c,Math.cos(o/2)),0<y.determinant()&&(T.toEulerAnglesToRef(b),ys.Quaternion.RotationYawPitchRollToRef(b.y,-b.x,-b.z,T)),d.updateGizmoRotationToMatchAttachedMesh?d.attachedMesh.rotationQuaternion.multiplyToRef(T,d.attachedMesh.rotationQuaternion):T.multiplyToRef(d.attachedMesh.rotationQuaternion,d.attachedMesh.rotationQuaternion),f.copyFrom(e.dragPlanePoint),a&&(g.snapDistance=o,d.onSnapObservable.notifyObservers(g))}})),d._pointerObserver=u.utilityLayerScene.onPointerObservable.add((function(e,t){if(!d._customMeshSet){var i=e.pickInfo&&-1!=d._rootMesh.getChildMeshes().indexOf(e.pickInfo.pickedMesh)?n:r;d._rootMesh.getChildMeshes().forEach((function(e){e.material=i,e.color&&(e.color=i.emissiveColor)}))}})),d}return T(e,c),e.prototype._attachedMeshChanged=function(e){this.dragBehavior&&(this.dragBehavior.enabled=!!e)},e.prototype.dispose=function(){this.onSnapObservable.clear(),this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver),this.dragBehavior.detach(),c.prototype.dispose.call(this)},e})(ys.Gizmo),ys.PlaneRotationGizmo=bs,Ts=$a||($a={}),xs=(function(i){function e(e){void 0===e&&(e=Ts.UtilityLayerRenderer.DefaultUtilityLayer);var t=i.call(this,e)||this;return t.onDragStartObservable=new Ts.Observable,t.onDragEndObservable=new Ts.Observable,t.xGizmo=new Ts.AxisDragGizmo(new Ts.Vector3(1,0,0),Ts.Color3.Red().scale(.5),e),t.yGizmo=new Ts.AxisDragGizmo(new Ts.Vector3(0,1,0),Ts.Color3.Green().scale(.5),e),t.zGizmo=new Ts.AxisDragGizmo(new Ts.Vector3(0,0,1),Ts.Color3.Blue().scale(.5),e),[t.xGizmo,t.yGizmo,t.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){t.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){t.onDragEndObservable.notifyObservers({})}))})),t.attachedMesh=null,t}return T(e,i),Object.defineProperty(e.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.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(e.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}),e.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},e.prototype.setCustomMesh=function(e){Ts.Tools.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)")},e})(Ts.Gizmo),Ts.PositionGizmo=xs,Es=$a||($a={}),As=(function(r){function e(e,t){void 0===e&&(e=Es.UtilityLayerRenderer.DefaultUtilityLayer),void 0===t&&(t=32);var i=r.call(this,e)||this;return i.onDragStartObservable=new Es.Observable,i.onDragEndObservable=new Es.Observable,i.xGizmo=new Es.PlaneRotationGizmo(new Es.Vector3(1,0,0),Es.Color3.Red().scale(.5),e,t),i.yGizmo=new Es.PlaneRotationGizmo(new Es.Vector3(0,1,0),Es.Color3.Green().scale(.5),e,t),i.zGizmo=new Es.PlaneRotationGizmo(new Es.Vector3(0,0,1),Es.Color3.Blue().scale(.5),e,t),[i.xGizmo,i.yGizmo,i.zGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){i.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){i.onDragEndObservable.notifyObservers({})}))})),i.attachedMesh=null,i}return T(e,r),Object.defineProperty(e.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.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(e.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(e.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}),e.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},e.prototype.setCustomMesh=function(e){Es.Tools.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)")},e})(Es.Gizmo),Es.RotationGizmo=As,Ps=$a||($a={}),Ss=(function(n){function e(e){void 0===e&&(e=Ps.UtilityLayerRenderer.DefaultUtilityLayer);var t=n.call(this,e)||this;t.onDragStartObservable=new Ps.Observable,t.onDragEndObservable=new Ps.Observable,t.xGizmo=new Ps.AxisScaleGizmo(new Ps.Vector3(1,0,0),Ps.Color3.Red().scale(.5),e),t.yGizmo=new Ps.AxisScaleGizmo(new Ps.Vector3(0,1,0),Ps.Color3.Green().scale(.5),e),t.zGizmo=new Ps.AxisScaleGizmo(new Ps.Vector3(0,0,1),Ps.Color3.Blue().scale(.5),e),t.uniformScaleGizmo=new Ps.AxisScaleGizmo(new Ps.Vector3(0,1,0),Ps.Color3.Yellow().scale(.5),e),t.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh=!1,t.uniformScaleGizmo.uniformScaling=!0;var i=Ps.Mesh.CreatePolyhedron("",{type:1},t.uniformScaleGizmo.gizmoLayer.utilityLayerScene);i.scaling.scaleInPlace(.02),i.visibility=0;var r=Ps.Mesh.CreatePolyhedron("",{type:1},t.uniformScaleGizmo.gizmoLayer.utilityLayerScene);return r.scaling.scaleInPlace(.007),i.addChild(r),t.uniformScaleGizmo.setCustomMesh(i,!0),[t.xGizmo,t.yGizmo,t.zGizmo,t.uniformScaleGizmo].forEach((function(e){e.dragBehavior.onDragStartObservable.add((function(){t.onDragStartObservable.notifyObservers({})})),e.dragBehavior.onDragEndObservable.add((function(){t.onDragEndObservable.notifyObservers({})}))})),t.attachedMesh=null,t}return T(e,n),Object.defineProperty(e.prototype,"attachedMesh",{set:function(e){this.xGizmo&&(this.xGizmo.attachedMesh=e,this.yGizmo.attachedMesh=e,this.zGizmo.attachedMesh=e,this.uniformScaleGizmo.attachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"updateGizmoRotationToMatchAttachedMesh",{get:function(){return this.xGizmo.updateGizmoRotationToMatchAttachedMesh},set:function(e){e||Ps.Tools.Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported."),this.xGizmo&&(this.xGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.yGizmo.updateGizmoRotationToMatchAttachedMesh=e,this.zGizmo.updateGizmoRotationToMatchAttachedMesh=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"snapDistance",{get:function(){return this.xGizmo.snapDistance},set:function(e){this.xGizmo&&(this.xGizmo.snapDistance=e,this.yGizmo.snapDistance=e,this.zGizmo.snapDistance=e,this.uniformScaleGizmo.snapDistance=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleRatio",{get:function(){return this.xGizmo.scaleRatio},set:function(e){this.xGizmo&&(this.xGizmo.scaleRatio=e,this.yGizmo.scaleRatio=e,this.zGizmo.scaleRatio=e,this.uniformScaleGizmo.scaleRatio=e)},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.xGizmo.dispose(),this.yGizmo.dispose(),this.zGizmo.dispose(),this.uniformScaleGizmo.dispose(),this.onDragStartObservable.clear(),this.onDragEndObservable.clear()},e})(Ps.Gizmo),Ps.ScaleGizmo=Ss,Rs=$a||($a={}),Ms=(function(_){function g(t,i){void 0===t&&(t=Rs.Color3.Gray()),void 0===i&&(i=Rs.UtilityLayerRenderer.DefaultKeepDepthUtilityLayer);var l=_.call(this,i)||this;l._boundingDimensions=new Rs.Vector3(1,1,1),l._renderObserver=null,l._pointerObserver=null,l._scaleDragSpeed=.2,l._tmpQuaternion=new Rs.Quaternion,l._tmpVector=new Rs.Vector3(0,0,0),l._tmpRotationMatrix=new Rs.Matrix,l.ignoreChildren=!1,l.includeChildPredicate=null,l.rotationSphereSize=.1,l.scaleBoxSize=.1,l.fixedDragMeshScreenSize=!1,l.fixedDragMeshScreenSizeDistanceFactor=10,l.onDragStartObservable=new Rs.Observable,l.onScaleBoxDragObservable=new Rs.Observable,l.onScaleBoxDragEndObservable=new Rs.Observable,l.onRotationSphereDragObservable=new Rs.Observable,l.onRotationSphereDragEndObservable=new Rs.Observable,l.scalePivot=null,l._existingMeshScale=new Rs.Vector3,l._updateScale=!1,l._anchorMesh=new Rs.AbstractMesh("anchor",i.utilityLayerScene);var n=new Rs.StandardMaterial("",i.utilityLayerScene);n.disableLighting=!0,n.emissiveColor=t;var r=new Rs.StandardMaterial("",i.utilityLayerScene);r.disableLighting=!0,r.emissiveColor=t.clone().add(new Rs.Color3(.3,.3,.3)),l._lineBoundingBox=new Rs.AbstractMesh("",i.utilityLayerScene),l._lineBoundingBox.rotationQuaternion=new Rs.Quaternion;var e=[];e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(0,0,0),new Rs.Vector3(l._boundingDimensions.x,0,0)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(0,0,0),new Rs.Vector3(0,l._boundingDimensions.y,0)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(0,0,0),new Rs.Vector3(0,0,l._boundingDimensions.z)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(l._boundingDimensions.x,0,0),new Rs.Vector3(l._boundingDimensions.x,l._boundingDimensions.y,0)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(l._boundingDimensions.x,0,0),new Rs.Vector3(l._boundingDimensions.x,0,l._boundingDimensions.z)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(0,l._boundingDimensions.y,0),new Rs.Vector3(l._boundingDimensions.x,l._boundingDimensions.y,0)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(0,l._boundingDimensions.y,0),new Rs.Vector3(0,l._boundingDimensions.y,l._boundingDimensions.z)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(0,0,l._boundingDimensions.z),new Rs.Vector3(l._boundingDimensions.x,0,l._boundingDimensions.z)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(0,0,l._boundingDimensions.z),new Rs.Vector3(0,l._boundingDimensions.y,l._boundingDimensions.z)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(l._boundingDimensions.x,l._boundingDimensions.y,l._boundingDimensions.z),new Rs.Vector3(0,l._boundingDimensions.y,l._boundingDimensions.z)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(l._boundingDimensions.x,l._boundingDimensions.y,l._boundingDimensions.z),new Rs.Vector3(l._boundingDimensions.x,0,l._boundingDimensions.z)]},i.utilityLayerScene)),e.push(Rs.MeshBuilder.CreateLines("lines",{points:[new Rs.Vector3(l._boundingDimensions.x,l._boundingDimensions.y,l._boundingDimensions.z),new Rs.Vector3(l._boundingDimensions.x,l._boundingDimensions.y,0)]},i.utilityLayerScene)),e.forEach((function(e){e.color=t,e.position.addInPlace(new Rs.Vector3(-l._boundingDimensions.x/2,-l._boundingDimensions.y/2,-l._boundingDimensions.z/2)),e.isPickable=!1,l._lineBoundingBox.addChild(e)})),l._rootMesh.addChild(l._lineBoundingBox),l._rotateSpheresParent=new Rs.AbstractMesh("",i.utilityLayerScene),l._rotateSpheresParent.rotationQuaternion=new Rs.Quaternion;for(var o=function(o){var t=Rs.MeshBuilder.CreateSphere("",{diameter:1},i.utilityLayerScene);t.rotationQuaternion=new Rs.Quaternion,t.material=n,(u=new Rs.PointerDragBehavior({})).moveAttached=!1,u.updateDragPlane=!1,t.addBehavior(u);var s=new Rs.Vector3(1,0,0),a=0;u.onDragStartObservable.add((function(e){s.copyFrom(t.forward),a=0})),u.onDragObservable.add((function(e){if(l.onRotationSphereDragObservable.notifyObservers({}),l.attachedMesh){g._RemoveAndStorePivotPoint(l.attachedMesh);var t=s,i=e.dragPlaneNormal.scale(Rs.Vector3.Dot(e.dragPlaneNormal,t)),r=t.subtract(i).normalizeToNew(),n=-Rs.Vector3.Dot(r,e.delta);n=n/l._boundingDimensions.length()*l._anchorMesh.scaling.length(),l.attachedMesh.rotationQuaternion||(l.attachedMesh.rotationQuaternion=Rs.Quaternion.RotationYawPitchRoll(l.attachedMesh.rotation.y,l.attachedMesh.rotation.x,l.attachedMesh.rotation.z)),l._anchorMesh.rotationQuaternion||(l._anchorMesh.rotationQuaternion=Rs.Quaternion.RotationYawPitchRoll(l._anchorMesh.rotation.y,l._anchorMesh.rotation.x,l._anchorMesh.rotation.z)),a+=n,Math.abs(a)<=2*Math.PI&&(8<=o?Rs.Quaternion.RotationYawPitchRollToRef(0,0,n,l._tmpQuaternion):4<=o?Rs.Quaternion.RotationYawPitchRollToRef(n,0,0,l._tmpQuaternion):Rs.Quaternion.RotationYawPitchRollToRef(0,n,0,l._tmpQuaternion),l._anchorMesh.addChild(l.attachedMesh),l._anchorMesh.rotationQuaternion.multiplyToRef(l._tmpQuaternion,l._anchorMesh.rotationQuaternion),l._anchorMesh.removeChild(l.attachedMesh)),l.updateBoundingBox(),g._RestorePivotPoint(l.attachedMesh)}})),u.onDragStartObservable.add((function(){l.onDragStartObservable.notifyObservers({}),l._selectNode(t)})),u.onDragEndObservable.add((function(){l.onRotationSphereDragEndObservable.notifyObservers({}),l._selectNode(null)})),c._rotateSpheresParent.addChild(t)},c=this,s=0;s<12;s++)o(s);l._rootMesh.addChild(l._rotateSpheresParent),l._scaleBoxesParent=new Rs.AbstractMesh("",i.utilityLayerScene),l._scaleBoxesParent.rotationQuaternion=new Rs.Quaternion;for(var a=0;a<2;a++)for(var h=0;h<2;h++)for(var u,d=function(){var r=Rs.MeshBuilder.CreateBox("",{size:1},i.utilityLayerScene);r.material=n;var e=new Rs.Vector3(0==a?-1:1,0==h?-1:1,0==p?-1:1);(u=new Rs.PointerDragBehavior({dragAxis:e})).moveAttached=!1,r.addBehavior(u),u.onDragObservable.add((function(e){if(l.onScaleBoxDragObservable.notifyObservers({}),l.attachedMesh){g._RemoveAndStorePivotPoint(l.attachedMesh);var t=e.dragDistance/l._boundingDimensions.length()*l._anchorMesh.scaling.length(),i=new Rs.Vector3(t,t,t);i.scaleInPlace(l._scaleDragSpeed),l.updateBoundingBox(),l.scalePivot?(l.attachedMesh.getWorldMatrix().getRotationMatrixToRef(l._tmpRotationMatrix),l._boundingDimensions.scaleToRef(.5,l._tmpVector),Rs.Vector3.TransformCoordinatesToRef(l._tmpVector,l._tmpRotationMatrix,l._tmpVector),l._anchorMesh.position.subtractInPlace(l._tmpVector),l._boundingDimensions.multiplyToRef(l.scalePivot,l._tmpVector),Rs.Vector3.TransformCoordinatesToRef(l._tmpVector,l._tmpRotationMatrix,l._tmpVector),l._anchorMesh.position.addInPlace(l._tmpVector)):(r.absolutePosition.subtractToRef(l._anchorMesh.position,l._tmpVector),l._anchorMesh.position.subtractInPlace(l._tmpVector)),l._anchorMesh.addChild(l.attachedMesh),l._anchorMesh.scaling.addInPlace(i),(l._anchorMesh.scaling.x<0||l._anchorMesh.scaling.y<0||l._anchorMesh.scaling.z<0)&&l._anchorMesh.scaling.subtractInPlace(i),l._anchorMesh.removeChild(l.attachedMesh),g._RestorePivotPoint(l.attachedMesh)}})),u.onDragStartObservable.add((function(){l.onDragStartObservable.notifyObservers({}),l._selectNode(r)})),u.onDragEndObservable.add((function(){l.onScaleBoxDragEndObservable.notifyObservers({}),l._selectNode(null)})),f._scaleBoxesParent.addChild(r)},f=this,p=0;p<2;p++)d();l._rootMesh.addChild(l._scaleBoxesParent);var m=new Array;return l._pointerObserver=i.utilityLayerScene.onPointerObservable.add((function(t,e){m[t.event.pointerId]?t.pickInfo&&t.pickInfo.pickedMesh!=m[t.event.pointerId]&&(m[t.event.pointerId].material=n,delete m[t.event.pointerId]):l._rotateSpheresParent.getChildMeshes().concat(l._scaleBoxesParent.getChildMeshes()).forEach((function(e){t.pickInfo&&t.pickInfo.pickedMesh==e&&((m[t.event.pointerId]=e).material=r)}))})),l._renderObserver=l.gizmoLayer.originalScene.onBeforeRenderObservable.add((function(){l.attachedMesh&&!l._existingMeshScale.equals(l.attachedMesh.scaling)&&l.updateBoundingBox()})),l.updateBoundingBox(),l}return T(g,_),g._RemoveAndStorePivotPoint=function(e){e&&0===g._PivotCached&&(e.getPivotPointToRef(g._OldPivotPoint),g._OldPivotPoint.equalsToFloats(0,0,0)||(e.setPivotMatrix(Rs.Matrix.IdentityReadOnly),g._OldPivotPoint.subtractToRef(e.getPivotPoint(),g._PivotTranslation),g._PivotTmpVector.copyFromFloats(1,1,1),g._PivotTmpVector.subtractInPlace(e.scaling),g._PivotTmpVector.multiplyInPlace(g._PivotTranslation),e.position.addInPlace(g._PivotTmpVector))),g._PivotCached++},g._RestorePivotPoint=function(e){e&&!g._OldPivotPoint.equalsToFloats(0,0,0)&&1===g._PivotCached&&(e.setPivotPoint(g._OldPivotPoint),g._PivotTmpVector.copyFromFloats(1,1,1),g._PivotTmpVector.subtractInPlace(e.scaling),g._PivotTmpVector.multiplyInPlace(g._PivotTranslation),e.position.subtractInPlace(g._PivotTmpVector)),this._PivotCached--},g.prototype._attachedMeshChanged=function(e){e&&(g._RemoveAndStorePivotPoint(e),this._anchorMesh.addChild(e),this._anchorMesh.removeChild(e),g._RestorePivotPoint(e),this.updateBoundingBox())},g.prototype._selectNode=function(i){this._rotateSpheresParent.getChildMeshes().concat(this._scaleBoxesParent.getChildMeshes()).forEach((function(e,t){e.isVisible=!i||e==i}))},g.prototype.updateBoundingBox=function(){if(this.attachedMesh){g._RemoveAndStorePivotPoint(this.attachedMesh),this._update(),this.attachedMesh.rotationQuaternion||(this.attachedMesh.rotationQuaternion=Rs.Quaternion.RotationYawPitchRoll(this.attachedMesh.rotation.y,this.attachedMesh.rotation.x,this.attachedMesh.rotation.z)),this._anchorMesh.rotationQuaternion||(this._anchorMesh.rotationQuaternion=Rs.Quaternion.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 e=this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren,this.includeChildPredicate);e.max.subtractToRef(e.min,this._boundingDimensions),this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions),this._lineBoundingBox.position.set((e.max.x+e.min.x)/2,(e.max.y+e.min.y)/2,(e.max.z+e.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)}for(var t=this._rotateSpheresParent.getChildMeshes(),i=0;i<3;i++)for(var r=0;r<2;r++)for(var n=0;n<2;n++){var o=4*i+2*r+n;if(0==i&&(t[o].position.set(this._boundingDimensions.x/2,this._boundingDimensions.y*r,this._boundingDimensions.z*n),t[o].position.addInPlace(new Rs.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),t[o].lookAt(Rs.Vector3.Cross(Rs.Vector3.Right(),t[o].position.normalizeToNew()).normalizeToNew().add(t[o].position))),1==i&&(t[o].position.set(this._boundingDimensions.x*r,this._boundingDimensions.y/2,this._boundingDimensions.z*n),t[o].position.addInPlace(new Rs.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),t[o].lookAt(Rs.Vector3.Cross(Rs.Vector3.Up(),t[o].position.normalizeToNew()).normalizeToNew().add(t[o].position))),2==i&&(t[o].position.set(this._boundingDimensions.x*r,this._boundingDimensions.y*n,this._boundingDimensions.z/2),t[o].position.addInPlace(new Rs.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),t[o].lookAt(Rs.Vector3.Cross(Rs.Vector3.Forward(),t[o].position.normalizeToNew()).normalizeToNew().add(t[o].position))),this.fixedDragMeshScreenSize){this._rootMesh.computeWorldMatrix(),this._rotateSpheresParent.computeWorldMatrix(),t[o].computeWorldMatrix(),t[o].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);var s=this.rotationSphereSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;t[o].scaling.set(s,s,s)}else t[o].scaling.set(this.rotationSphereSize,this.rotationSphereSize,this.rotationSphereSize)}var a=this._scaleBoxesParent.getChildMeshes();for(i=0;i<2;i++)for(r=0;r<2;r++)for(n=0;n<2;n++){if(a[o=4*i+2*r+n])if(a[o].position.set(this._boundingDimensions.x*i,this._boundingDimensions.y*r,this._boundingDimensions.z*n),a[o].position.addInPlace(new Rs.Vector3(-this._boundingDimensions.x/2,-this._boundingDimensions.y/2,-this._boundingDimensions.z/2)),this.fixedDragMeshScreenSize){this._rootMesh.computeWorldMatrix(),this._scaleBoxesParent.computeWorldMatrix(),a[o].computeWorldMatrix(),a[o].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position,this._tmpVector);s=this.scaleBoxSize*this._tmpVector.length()/this.fixedDragMeshScreenSizeDistanceFactor;a[o].scaling.set(s,s,s)}else a[o].scaling.set(this.scaleBoxSize,this.scaleBoxSize,this.scaleBoxSize)}this.attachedMesh&&(this._existingMeshScale.copyFrom(this.attachedMesh.scaling),g._RestorePivotPoint(this.attachedMesh))},g.prototype.setEnabledRotationAxis=function(i){this._rotateSpheresParent.getChildMeshes().forEach((function(e,t){t<4?e.setEnabled(-1!=i.indexOf("x")):t<8?e.setEnabled(-1!=i.indexOf("y")):e.setEnabled(-1!=i.indexOf("z"))}))},g.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(),_.prototype.dispose.call(this)},g.MakeNotPickableAndWrapInBoundingBox=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e),e.rotationQuaternion||(e.rotationQuaternion=Rs.Quaternion.RotationYawPitchRoll(e.rotation.y,e.rotation.x,e.rotation.z));var i=e.position.clone(),r=e.rotationQuaternion.clone();e.rotationQuaternion.set(0,0,0,1),e.position.set(0,0,0);var n=Rs.MeshBuilder.CreateBox("box",{size:1},e.getScene()),o=e.getHierarchyBoundingVectors();return o.max.subtractToRef(o.min,n.scaling),n.position.set((o.max.x+o.min.x)/2,(o.max.y+o.min.y)/2,(o.max.z+o.min.z)/2),e.addChild(n),e.rotationQuaternion.copyFrom(r),e.position.copyFrom(i),e.removeChild(n),n.addChild(e),n.visibility=0,n},g.prototype.setCustomMesh=function(e){Rs.Tools.Error("Custom meshes are not supported on this gizmo")},g._PivotCached=0,g._OldPivotPoint=new Rs.Vector3,g._PivotTranslation=new Rs.Vector3,g._PivotTmpVector=new Rs.Vector3,g})(Rs.Gizmo),Rs.BoundingBoxGizmo=Ms,Cs=$a||($a={}),Os=(function(){function e(e){var n=this;this.scene=e,this._gizmosEnabled={positionGizmo:!1,rotationGizmo:!1,scaleGizmo:!1,boundingBoxGizmo:!1},this._pointerObserver=null,this._attachedMesh=null,this._boundingBoxColor=Cs.Color3.FromHexString("#0984e3"),this.boundingBoxDragBehavior=new Cs.SixDofDragBehavior,this.attachableMeshes=null,this.usePointerToAttachGizmos=!0,this._defaultKeepDepthUtilityLayer=new Cs.UtilityLayerRenderer(e),this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil=!1,this._defaultUtilityLayer=new Cs.UtilityLayerRenderer(e),this.gizmos={positionGizmo:null,rotationGizmo:null,scaleGizmo:null,boundingBoxGizmo:null},this._pointerObserver=e.onPointerObservable.add((function(e,t){if(n.usePointerToAttachGizmos&&e.type==Cs.PointerEventTypes.POINTERDOWN)if(e.pickInfo&&e.pickInfo.pickedMesh){var i=e.pickInfo.pickedMesh;if(null==n.attachableMeshes)for(;i&&null!=i.parent;)i=i.parent;else{var r=!1;n.attachableMeshes.forEach((function(e){i&&(i==e||i.isDescendantOf(e))&&(i=e,r=!0)})),r||(i=null)}i instanceof Cs.AbstractMesh?n._attachedMesh!=i&&n.attachToMesh(i):n.attachToMesh(null)}else n.attachToMesh(null)}))}return e.prototype.attachToMesh=function(e){for(var t in this._attachedMesh&&this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh=e,this.gizmos){var i=this.gizmos[t];i&&this._gizmosEnabled[t]&&(i.attachedMesh=e)}this.boundingBoxGizmoEnabled&&this._attachedMesh&&this._attachedMesh.addBehavior(this.boundingBoxDragBehavior)},Object.defineProperty(e.prototype,"positionGizmoEnabled",{get:function(){return this._gizmosEnabled.positionGizmo},set:function(e){e?(this.gizmos.positionGizmo||(this.gizmos.positionGizmo=new Cs.PositionGizmo(this._defaultUtilityLayer)),this.gizmos.positionGizmo.attachedMesh=this._attachedMesh):this.gizmos.positionGizmo&&(this.gizmos.positionGizmo.attachedMesh=null),this._gizmosEnabled.positionGizmo=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationGizmoEnabled",{get:function(){return this._gizmosEnabled.rotationGizmo},set:function(e){e?(this.gizmos.rotationGizmo||(this.gizmos.rotationGizmo=new Cs.RotationGizmo(this._defaultUtilityLayer)),this.gizmos.rotationGizmo.attachedMesh=this._attachedMesh):this.gizmos.rotationGizmo&&(this.gizmos.rotationGizmo.attachedMesh=null),this._gizmosEnabled.rotationGizmo=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"scaleGizmoEnabled",{get:function(){return this._gizmosEnabled.scaleGizmo},set:function(e){e?(this.gizmos.scaleGizmo=this.gizmos.scaleGizmo||new Cs.ScaleGizmo(this._defaultUtilityLayer),this.gizmos.scaleGizmo.attachedMesh=this._attachedMesh):this.gizmos.scaleGizmo&&(this.gizmos.scaleGizmo.attachedMesh=null),this._gizmosEnabled.scaleGizmo=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"boundingBoxGizmoEnabled",{get:function(){return this._gizmosEnabled.boundingBoxGizmo},set:function(e){e?(this.gizmos.boundingBoxGizmo=this.gizmos.boundingBoxGizmo||new Cs.BoundingBoxGizmo(this._boundingBoxColor,this._defaultKeepDepthUtilityLayer),this.gizmos.boundingBoxGizmo.attachedMesh=this._attachedMesh,this._attachedMesh&&(this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior),this._attachedMesh.addBehavior(this.boundingBoxDragBehavior))):this.gizmos.boundingBoxGizmo&&(this.gizmos.boundingBoxGizmo.attachedMesh=null),this._gizmosEnabled.boundingBoxGizmo=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){for(var e in this.scene.onPointerObservable.remove(this._pointerObserver),this.gizmos){var t=this.gizmos[e];t&&t.dispose()}this._defaultKeepDepthUtilityLayer.dispose(),this._defaultUtilityLayer.dispose(),this.boundingBoxDragBehavior.detach()},e})(),Cs.GizmoManager=Os,Ds=$a||($a={}),Is=(function(){function n(e,t,i){void 0===t&&(t=0),void 0===i&&(i=null),this.name=e,this.animations=new Array,this._positions=null,this._normals=null,this._tangents=null,this.onInfluenceChanged=new Ds.Observable,this._onDataLayoutChanged=new Ds.Observable,this._animationPropertiesOverride=null,this._scene=i||Ds.Engine.LastCreatedScene,this.influence=t}return Object.defineProperty(n.prototype,"influence",{get:function(){return this._influence},set:function(e){if(this._influence!==e){var t=this._influence;this._influence=e,this.onInfluenceChanged.hasObservers&&this.onInfluenceChanged.notifyObservers(0===t||0===e)}},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"animationPropertiesOverride",{get:function(){return!this._animationPropertiesOverride&&this._scene?this._scene.animationPropertiesOverride:this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"hasPositions",{get:function(){return!!this._positions},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"hasNormals",{get:function(){return!!this._normals},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"hasTangents",{get:function(){return!!this._tangents},enumerable:!0,configurable:!0}),n.prototype.setPositions=function(e){var t=this.hasPositions;this._positions=e,t!==this.hasPositions&&this._onDataLayoutChanged.notifyObservers(void 0)},n.prototype.getPositions=function(){return this._positions},n.prototype.setNormals=function(e){var t=this.hasNormals;this._normals=e,t!==this.hasNormals&&this._onDataLayoutChanged.notifyObservers(void 0)},n.prototype.getNormals=function(){return this._normals},n.prototype.setTangents=function(e){var t=this.hasTangents;this._tangents=e,t!==this.hasTangents&&this._onDataLayoutChanged.notifyObservers(void 0)},n.prototype.getTangents=function(){return this._tangents},n.prototype.serialize=function(){var e={};return e.name=this.name,e.influence=this.influence,e.positions=Array.prototype.slice.call(this.getPositions()),this.hasNormals&&(e.normals=Array.prototype.slice.call(this.getNormals())),this.hasTangents&&(e.tangents=Array.prototype.slice.call(this.getTangents())),Ds.Animation.AppendSerializedAnimations(this,e),e},n.Parse=function(e){var t=new n(e.name,e.influence);if(t.setPositions(e.positions),e.normals&&t.setNormals(e.normals),e.tangents&&t.setTangents(e.tangents),e.animations)for(var i=0;i<e.animations.length;i++){var r=e.animations[i];t.animations.push(Ds.Animation.Parse(r))}return t},n.FromMesh=function(e,t,i){t||(t=e.name);var r=new n(t,i,e.getScene());return r.setPositions(e.getVerticesData(Ds.VertexBuffer.PositionKind)),e.isVerticesDataPresent(Ds.VertexBuffer.NormalKind)&&r.setNormals(e.getVerticesData(Ds.VertexBuffer.NormalKind)),e.isVerticesDataPresent(Ds.VertexBuffer.TangentKind)&&r.setTangents(e.getVerticesData(Ds.VertexBuffer.TangentKind)),r},n})(),Ds.MorphTarget=Is,ws=$a||($a={}),Ls=(function(){function s(e){void 0===e&&(e=null),this._targets=new Array,this._targetInfluenceChangedObservers=new Array,this._targetDataLayoutChangedObservers=new Array,this._activeTargets=new ws.SmartArray(16),this._supportsNormals=!1,this._supportsTangents=!1,this._vertexCount=0,this._uniqueId=0,this._tempInfluences=new Array,e||(e=ws.Engine.LastCreatedScene),this._scene=e,this._scene&&(this._scene.morphTargetManagers.push(this),this._uniqueId=this._scene.getUniqueId())}return Object.defineProperty(s.prototype,"uniqueId",{get:function(){return this._uniqueId},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"vertexCount",{get:function(){return this._vertexCount},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"supportsNormals",{get:function(){return this._supportsNormals},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"supportsTangents",{get:function(){return this._supportsTangents},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"numTargets",{get:function(){return this._targets.length},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"numInfluencers",{get:function(){return this._activeTargets.length},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"influences",{get:function(){return this._influences},enumerable:!0,configurable:!0}),s.prototype.getActiveTarget=function(e){return this._activeTargets.data[e]},s.prototype.getTarget=function(e){return this._targets[e]},s.prototype.addTarget=function(e){var t=this;this._targets.push(e),this._targetInfluenceChangedObservers.push(e.onInfluenceChanged.add((function(e){t._syncActiveTargets(e)}))),this._targetDataLayoutChangedObservers.push(e._onDataLayoutChanged.add((function(){t._syncActiveTargets(!0)}))),this._syncActiveTargets(!0)},s.prototype.removeTarget=function(e){var t=this._targets.indexOf(e);0<=t&&(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))},s.prototype.serialize=function(){var e={};e.id=this.uniqueId,e.targets=[];for(var t=0,i=this._targets;t<i.length;t++){var r=i[t];e.targets.push(r.serialize())}return e},s.prototype._syncActiveTargets=function(e){var t=0;this._activeTargets.reset(),this._supportsNormals=!0,this._supportsTangents=!0;for(var i=this._vertexCount=0,r=this._targets;i<r.length;i++){var n=r[i];if(0!==n.influence){this._activeTargets.push(n),this._tempInfluences[t++]=n.influence,this._supportsNormals=this._supportsNormals&&n.hasNormals,this._supportsTangents=this._supportsTangents&&n.hasTangents;var o=n.getPositions();if(o){var s=o.length/3;if(0===this._vertexCount)this._vertexCount=s;else if(this._vertexCount!==s)return void ws.Tools.Error("Incompatible target. Targets must all have the same vertices count.")}}}this._influences&&this._influences.length===t||(this._influences=new Float32Array(t));for(var a=0;a<t;a++)this._influences[a]=this._tempInfluences[a];e&&this.synchronize()},s.prototype.synchronize=function(){if(this._scene)for(var e=0,t=this._scene.meshes;e<t.length;e++){var i=t[e];i.morphTargetManager===this&&i._syncGeometryWithMorphTargetManager()}},s.Parse=function(e,t){var i=new s(t);i._uniqueId=e.id;for(var r=0,n=e.targets;r<n.length;r++){var o=n[r];i.addTarget(ws.MorphTarget.Parse(o))}return i},s})(),ws.MorphTargetManager=Ls,Fs=$a||($a={}),Bs=(function(){function r(e,t,i){void 0===i&&(i=2),this.maxDepth=i,this.dynamicContent=new Array,this._maxBlockCapacity=t||64,this._selectionContent=new Fs.SmartArrayNoDuplicate(1024),this._creationFunc=e}return r.prototype.update=function(e,t,i){r._CreateBlocks(e,t,i,this._maxBlockCapacity,0,this.maxDepth,this,this._creationFunc)},r.prototype.addMesh=function(e){for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}},r.prototype.select=function(e,t){this._selectionContent.reset();for(var i=0;i<this.blocks.length;i++){this.blocks[i].select(e,this._selectionContent,t)}return t?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.prototype.intersects=function(e,t,i){this._selectionContent.reset();for(var r=0;r<this.blocks.length;r++){this.blocks[r].intersects(e,t,this._selectionContent,i)}return i?this._selectionContent.concat(this.dynamicContent):this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r.prototype.intersectsRay=function(e){this._selectionContent.reset();for(var t=0;t<this.blocks.length;t++){this.blocks[t].intersectsRay(e,this._selectionContent)}return this._selectionContent.concatWithNoDuplicate(this.dynamicContent),this._selectionContent},r._CreateBlocks=function(e,t,i,r,n,o,s,a){s.blocks=new Array;for(var l=new Fs.Vector3((t.x-e.x)/2,(t.y-e.y)/2,(t.z-e.z)/2),c=0;c<2;c++)for(var h=0;h<2;h++)for(var u=0;u<2;u++){var d=e.add(l.multiplyByFloats(c,h,u)),f=e.add(l.multiplyByFloats(c+1,h+1,u+1)),p=new Fs.OctreeBlock(d,f,r,n+1,o,a);p.addEntries(i),s.blocks.push(p)}},r.CreationFuncForMeshes=function(e,t){var i=e.getBoundingInfo();!e.isBlocked&&i.boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},r.CreationFuncForSubMeshes=function(e,t){e.getBoundingInfo().boundingBox.intersectsMinMax(t.minPoint,t.maxPoint)&&t.entries.push(e)},r})(),Fs.Octree=Bs,Ns=$a||($a={}),Vs=(function(){function e(e,t,i,r,n,o){this.entries=new Array,this._boundingVectors=new Array,this._capacity=i,this._depth=r,this._maxDepth=n,this._creationFunc=o,this._minPoint=e,this._maxPoint=t,this._boundingVectors.push(e.clone()),this._boundingVectors.push(t.clone()),this._boundingVectors.push(e.clone()),this._boundingVectors[2].x=t.x,this._boundingVectors.push(e.clone()),this._boundingVectors[3].y=t.y,this._boundingVectors.push(e.clone()),this._boundingVectors[4].z=t.z,this._boundingVectors.push(t.clone()),this._boundingVectors[5].z=e.z,this._boundingVectors.push(t.clone()),this._boundingVectors[6].x=e.x,this._boundingVectors.push(t.clone()),this._boundingVectors[7].y=e.y}return Object.defineProperty(e.prototype,"capacity",{get:function(){return this._capacity},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"minPoint",{get:function(){return this._minPoint},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"maxPoint",{get:function(){return this._maxPoint},enumerable:!0,configurable:!0}),e.prototype.addEntry=function(e){if(this.blocks)for(var t=0;t<this.blocks.length;t++){this.blocks[t].addEntry(e)}else this._creationFunc(e,this),this.entries.length>this.capacity&&this._depth<this._maxDepth&&this.createInnerBlocks()},e.prototype.addEntries=function(e){for(var t=0;t<e.length;t++){var i=e[t];this.addEntry(i)}},e.prototype.select=function(e,t,i){if(Ns.BoundingBox.IsInFrustum(this._boundingVectors,e)){if(this.blocks){for(var r=0;r<this.blocks.length;r++){this.blocks[r].select(e,t,i)}return}i?t.concat(this.entries):t.concatWithNoDuplicate(this.entries)}},e.prototype.intersects=function(e,t,i,r){if(Ns.BoundingBox.IntersectsSphere(this._minPoint,this._maxPoint,e,t)){if(this.blocks){for(var n=0;n<this.blocks.length;n++){this.blocks[n].intersects(e,t,i,r)}return}r?i.concat(this.entries):i.concatWithNoDuplicate(this.entries)}},e.prototype.intersectsRay=function(e,t){if(e.intersectsBoxMinMax(this._minPoint,this._maxPoint)){if(this.blocks){for(var i=0;i<this.blocks.length;i++){this.blocks[i].intersectsRay(e,t)}return}t.concatWithNoDuplicate(this.entries)}},e.prototype.createInnerBlocks=function(){Ns.Octree._CreateBlocks(this._minPoint,this._maxPoint,this.entries,this._capacity,this._depth,this._maxDepth,this,this._creationFunc)},e})(),Ns.OctreeBlock=Vs,(function(o){o.Scene.prototype.createOrUpdateSelectionOctree=function(e,t){void 0===e&&(e=64),void 0===t&&(t=2);var i=this._getComponent(o.SceneComponentConstants.NAME_OCTREE);i||(i=new s(this),this._addComponent(i)),this._selectionOctree||(this._selectionOctree=new o.Octree(o.Octree.CreationFuncForMeshes,e,t));var r=this.getWorldExtends();return this._selectionOctree.update(r.min,r.max,this.meshes),this._selectionOctree},Object.defineProperty(o.Scene.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),o.AbstractMesh.prototype.createOrUpdateSubmeshesOctree=function(e,t){void 0===e&&(e=64),void 0===t&&(t=2);var i=this.getScene(),r=i._getComponent(o.SceneComponentConstants.NAME_OCTREE);r||(r=new s(i),i._addComponent(r)),this._submeshesOctree||(this._submeshesOctree=new o.Octree(o.Octree.CreationFuncForSubMeshes,e,t)),this.computeWorldMatrix(!0);var n=this.getBoundingInfo().boundingBox;return this._submeshesOctree.update(n.minimumWorld,n.maximumWorld,this.subMeshes),this._submeshesOctree};var s=(function(){function e(e){this.name=o.SceneComponentConstants.NAME_OCTREE,this.checksIsEnabled=!0,this._tempRay=new o.Ray(o.Vector3.Zero(),new o.Vector3(1,1,1)),this.scene=e,this.scene.getActiveMeshCandidates=this.getActiveMeshCandidates.bind(this),this.scene.getActiveSubMeshCandidates=this.getActiveSubMeshCandidates.bind(this),this.scene.getCollidingSubMeshCandidates=this.getCollidingSubMeshCandidates.bind(this),this.scene.getIntersectingSubMeshCandidates=this.getIntersectingSubMeshCandidates.bind(this)}return e.prototype.register=function(){var r=this;this.scene.onMeshRemovedObservable.add((function(e){var t=r.scene.selectionOctree;if(null!=t){var i=t.dynamicContent.indexOf(e);-1!==i&&t.dynamicContent.splice(i,1)}})),this.scene.onMeshImportedObservable.add((function(e){var t=r.scene.selectionOctree;null!=t&&t.addMesh(e)}))},e.prototype.getActiveMeshCandidates=function(){return this.scene._selectionOctree?this.scene._selectionOctree.select(this.scene.frustumPlanes):this.scene._getDefaultMeshCandidates()},e.prototype.getActiveSubMeshCandidates=function(e){return e._submeshesOctree&&e.useOctreeForRenderingSelection?e._submeshesOctree.select(this.scene.frustumPlanes):this.scene._getDefaultSubMeshCandidates(e)},e.prototype.getIntersectingSubMeshCandidates=function(e,t){return e._submeshesOctree&&e.useOctreeForPicking?(o.Ray.TransformToRef(t,e.getWorldMatrix(),this._tempRay),e._submeshesOctree.intersectsRay(this._tempRay)):this.scene._getDefaultSubMeshCandidates(e)},e.prototype.getCollidingSubMeshCandidates=function(e,t){if(e._submeshesOctree&&e.useOctreeForCollisions){var i=t._velocityWorldLength+Math.max(t._radius.x,t._radius.y,t._radius.z);return e._submeshesOctree.intersects(t._basePointWorld,i)}return this.scene._getDefaultSubMeshCandidates(e)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e})();o.OctreeSceneComponent=s})($a||($a={})),Us=$a||($a={}),zs=(function(a){function e(e,t,i,r,n,o){var s=a.call(this,e,"anaglyph",null,["leftSampler"],t,i[1],r,n,o)||this;return s._passedProcess=i[0]._rigPostProcess,s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("leftSampler",s._passedProcess)})),s}return T(e,a),e})(Us.PostProcess),Us.AnaglyphPostProcess=zs,(function(c){c.Node.AddNodeConstructor("AnaglyphArcRotateCamera",(function(e,t,i){return function(){return new r(e,0,0,1,c.Vector3.Zero(),i.interaxial_distance,t)}}));var r=(function(l){function e(e,t,i,r,n,o,s){var a=l.call(this,e,t,i,r,n,s)||this;return a.interaxialDistance=o,a.setCameraRigMode(c.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:o}),a}return T(e,l),e.prototype.getClassName=function(){return"AnaglyphArcRotateCamera"},e})(c.ArcRotateCamera);c.AnaglyphArcRotateCamera=r})($a||($a={})),(function(s){s.Node.AddNodeConstructor("AnaglyphFreeCamera",(function(e,t,i){return function(){return new r(e,s.Vector3.Zero(),i.interaxial_distance,t)}}));var r=(function(o){function e(e,t,i,r){var n=o.call(this,e,t,r)||this;return n.interaxialDistance=i,n.setCameraRigMode(s.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),n}return T(e,o),e.prototype.getClassName=function(){return"AnaglyphFreeCamera"},e})(s.FreeCamera);s.AnaglyphFreeCamera=r})($a||($a={})),(function(s){s.Node.AddNodeConstructor("AnaglyphGamepadCamera",(function(e,t,i){return function(){return new r(e,s.Vector3.Zero(),i.interaxial_distance,t)}}));var r=(function(o){function e(e,t,i,r){var n=o.call(this,e,t,r)||this;return n.interaxialDistance=i,n.setCameraRigMode(s.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),n}return T(e,o),e.prototype.getClassName=function(){return"AnaglyphGamepadCamera"},e})(s.GamepadCamera);s.AnaglyphGamepadCamera=r})($a||($a={})),(function(s){s.Node.AddNodeConstructor("AnaglyphUniversalCamera",(function(e,t,i){return function(){return new r(e,s.Vector3.Zero(),i.interaxial_distance,t)}}));var r=(function(o){function e(e,t,i,r){var n=o.call(this,e,t,r)||this;return n.interaxialDistance=i,n.setCameraRigMode(s.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH,{interaxialDistance:i}),n}return T(e,o),e.prototype.getClassName=function(){return"AnaglyphUniversalCamera"},e})(s.UniversalCamera);s.AnaglyphUniversalCamera=r})($a||($a={})),Gs=$a||($a={}),ks=(function(a){function e(e,t,i,r,n,o){var s=a.call(this,e,"stereoscopicInterlace",["stepSize"],["camASampler"],1,t[1],r,n,o,i?"#define IS_STEREOSCOPIC_HORIZ 1":void 0)||this;return s._passedProcess=t[0]._rigPostProcess,s._stepSize=new Gs.Vector2(1/s.width,1/s.height),s.onSizeChangedObservable.add((function(){s._stepSize=new Gs.Vector2(1/s.width,1/s.height)})),s.onApplyObservable.add((function(e){e.setTextureFromPostProcess("camASampler",s._passedProcess),e.setFloat2("stepSize",s._stepSize.x,s._stepSize.y)})),s}return T(e,a),e})(Gs.PostProcess),Gs.StereoscopicInterlacePostProcess=ks,(function(h){h.Node.AddNodeConstructor("StereoscopicArcRotateCamera",(function(e,t,i){return function(){return new r(e,0,0,1,h.Vector3.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var r=(function(c){function e(e,t,i,r,n,o,s,a){var l=c.call(this,e,t,i,r,n,a)||this;return l.interaxialDistance=o,l.isStereoscopicSideBySide=s,l.setCameraRigMode(s?h.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:h.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:o}),l}return T(e,c),e.prototype.getClassName=function(){return"StereoscopicArcRotateCamera"},e})(h.ArcRotateCamera);h.StereoscopicArcRotateCamera=r})($a||($a={})),(function(a){a.Node.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new r(e,a.Vector3.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var r=(function(s){function e(e,t,i,r,n){var o=s.call(this,e,t,n)||this;return o.interaxialDistance=i,o.isStereoscopicSideBySide=r,o.setCameraRigMode(r?a.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:a.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),o}return T(e,s),e.prototype.getClassName=function(){return"StereoscopicFreeCamera"},e})(a.FreeCamera);a.StereoscopicFreeCamera=r})($a||($a={})),(function(a){a.Node.AddNodeConstructor("StereoscopicGamepadCamera",(function(e,t,i){return function(){return new r(e,a.Vector3.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var r=(function(s){function e(e,t,i,r,n){var o=s.call(this,e,t,n)||this;return o.interaxialDistance=i,o.isStereoscopicSideBySide=r,o.setCameraRigMode(r?a.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:a.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),o}return T(e,s),e.prototype.getClassName=function(){return"StereoscopicGamepadCamera"},e})(a.GamepadCamera);a.StereoscopicGamepadCamera=r})($a||($a={})),(function(a){a.Node.AddNodeConstructor("StereoscopicFreeCamera",(function(e,t,i){return function(){return new r(e,a.Vector3.Zero(),i.interaxial_distance,i.isStereoscopicSideBySide,t)}}));var r=(function(s){function e(e,t,i,r,n){var o=s.call(this,e,t,n)||this;return o.interaxialDistance=i,o.isStereoscopicSideBySide=r,o.setCameraRigMode(r?a.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:a.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER,{interaxialDistance:i}),o}return T(e,s),e.prototype.getClassName=function(){return"StereoscopicUniversalCamera"},e})(a.UniversalCamera);a.StereoscopicUniversalCamera=r})($a||($a={})),Ws=$a||($a={}),Hs=(function(o){function e(e,t,i,r){var n=o.call(this,e,"vrDistortionCorrection",["LensCenter","Scale","ScaleIn","HmdWarpParam"],null,r.postProcessScaleFactor,t,Ws.Texture.BILINEAR_SAMPLINGMODE)||this;return n._isRightEye=i,n._distortionFactors=r.distortionK,n._postProcessScaleFactor=r.postProcessScaleFactor,n._lensCenterOffset=r.lensCenterOffset,n.adaptScaleToCurrentViewport=!0,n.onSizeChangedObservable.add((function(){n._scaleIn=new Ws.Vector2(2,2/n.aspectRatio),n._scaleFactor=new Ws.Vector2(1/n._postProcessScaleFactor*.5,1/n._postProcessScaleFactor*.5*n.aspectRatio),n._lensCenter=new Ws.Vector2(n._isRightEye?.5-.5*n._lensCenterOffset:.5+.5*n._lensCenterOffset,.5)})),n.onApplyObservable.add((function(e){e.setFloat2("LensCenter",n._lensCenter.x,n._lensCenter.y),e.setFloat2("Scale",n._scaleFactor.x,n._scaleFactor.y),e.setFloat2("ScaleIn",n._scaleIn.x,n._scaleIn.y),e.setFloat4("HmdWarpParam",n._distortionFactors[0],n._distortionFactors[1],n._distortionFactors[2],n._distortionFactors[3])})),n}return T(e,o),e})(Ws.PostProcess),Ws.VRDistortionCorrectionPostProcess=Hs,Xs=$a||($a={}),js=(function(){function e(){var t=this;this._screenOrientationAngle=0,this._screenQuaternion=new Xs.Quaternion,this._alpha=0,this._beta=0,this._gamma=0,this._orientationChanged=function(){t._screenOrientationAngle=void 0!==window.orientation?+window.orientation:window.screen.orientation&&window.screen.orientation.angle?window.screen.orientation.angle:0,t._screenOrientationAngle=-Xs.Tools.ToRadians(t._screenOrientationAngle/2),t._screenQuaternion.copyFromFloats(0,Math.sin(t._screenOrientationAngle),0,Math.cos(t._screenOrientationAngle))},this._deviceOrientation=function(e){t._alpha=null!==e.alpha?e.alpha:0,t._beta=null!==e.beta?e.beta:0,t._gamma=null!==e.gamma?e.gamma:0},this._constantTranform=new Xs.Quaternion(-Math.sqrt(.5),0,0,Math.sqrt(.5)),this._orientationChanged()}return Object.defineProperty(e.prototype,"camera",{get:function(){return this._camera},set:function(e){this._camera=e,null==this._camera||this._camera.rotationQuaternion||(this._camera.rotationQuaternion=new Xs.Quaternion)},enumerable:!0,configurable:!0}),e.prototype.attachControl=function(e,t){window.addEventListener("orientationchange",this._orientationChanged),window.addEventListener("deviceorientation",this._deviceOrientation),this._orientationChanged()},e.prototype.detachControl=function(e){window.removeEventListener("orientationchange",this._orientationChanged),window.removeEventListener("deviceorientation",this._deviceOrientation)},e.prototype.checkInputs=function(){this._alpha&&(Xs.Quaternion.RotationYawPitchRollToRef(Xs.Tools.ToRadians(this._alpha),Xs.Tools.ToRadians(this._beta),-Xs.Tools.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})(),Xs.FreeCameraDeviceOrientationInput=js,Xs.CameraInputTypes.FreeCameraDeviceOrientationInput=js,Ys=$a||($a={}),Ks=(function(){function e(){this.alphaCorrection=1,this.betaCorrection=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),null!==e.gamma&&(this._gamma=0|+e.gamma),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})(),Ys.ArcRotateCameraVRDeviceOrientationInput=Ks,Ys.CameraInputTypes.ArcRotateCameraVRDeviceOrientationInput=Ks,Qs=$a||($a={}),Zs=(function(){function t(){this.compensateDistortion=!0}return Object.defineProperty(t.prototype,"aspectRatio",{get:function(){return this.hResolution/(2*this.vResolution)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"aspectRatioFov",{get:function(){return 2*Math.atan(this.postProcessScaleFactor*this.vScreenSize/(2*this.eyeToScreenDistance))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return Qs.Matrix.Translation(e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightHMatrix",{get:function(){var e=4*(this.hScreenSize/4-this.lensSeparationDistance/2)/this.hScreenSize;return Qs.Matrix.Translation(-e,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"leftPreViewMatrix",{get:function(){return Qs.Matrix.Translation(.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rightPreViewMatrix",{get:function(){return Qs.Matrix.Translation(-.5*this.interpupillaryDistance,0,0)},enumerable:!0,configurable:!0}),t.GetDefault=function(){var e=new t;return e.hResolution=1280,e.vResolution=800,e.hScreenSize=.149759993,e.vScreenSize=.0935999975,e.vScreenCenter=.0467999987,e.eyeToScreenDistance=.0410000011,e.lensSeparationDistance=.063500002,e.interpupillaryDistance=.064000003,e.distortionK=[1,.219999999,.239999995,0],e.chromaAbCorrection=[.995999992,-.00400000019,1.01400006,0],e.postProcessScaleFactor=1.714605507808412,e.lensCenterOffset=.151976421,e},t})(),Qs.VRCameraMetrics=Zs,(function(a){a.Node.AddNodeConstructor("WebVRFreeCamera",(function(e,t){return function(){return new i(e,a.Vector3.Zero(),t)}})),a.Node.AddNodeConstructor("WebVRGamepadCamera",(function(e,t){return function(){return new i(e,a.Vector3.Zero(),t)}}));var i=(function(s){function e(e,t,i,r){void 0===r&&(r={});var n=s.call(this,e,t,i)||this;n.webVROptions=r,n._vrDevice=null,n.rawPose=null,n._specsVersion="1.1",n._attached=!1,n._descendants=[],n._deviceRoomPosition=a.Vector3.Zero(),n._deviceRoomRotationQuaternion=a.Quaternion.Identity(),n._standingMatrix=null,n.devicePosition=a.Vector3.Zero(),n.deviceRotationQuaternion=a.Quaternion.Identity(),n.deviceScaleFactor=1,n._deviceToWorld=a.Matrix.Identity(),n._worldToDevice=a.Matrix.Identity(),n.controllers=[],n.onControllersAttachedObservable=new a.Observable,n.onControllerMeshLoadedObservable=new a.Observable,n.onPoseUpdatedFromDeviceObservable=new a.Observable,n._poseSet=!1,n.rigParenting=!0,n._defaultHeight=void 0,n._htmlElementAttached=null,n._detachIfAttached=function(){var e=n.getEngine().getVRDevice();e&&!e.isPresenting&&n._htmlElementAttached&&n.detachControl(n._htmlElementAttached)},n._workingVector=a.Vector3.Zero(),n._oneVector=a.Vector3.One(),n._workingMatrix=a.Matrix.Identity(),n._tmpMatrix=new a.Matrix,n._cache.position=a.Vector3.Zero(),r.defaultHeight&&(n._defaultHeight=r.defaultHeight,n.position.y=n._defaultHeight),n.minZ=.1,5===arguments.length&&(n.webVROptions=arguments[4]),null==n.webVROptions.trackPosition&&(n.webVROptions.trackPosition=!0),null==n.webVROptions.controllerMeshes&&(n.webVROptions.controllerMeshes=!0),null==n.webVROptions.defaultLightingOnControllers&&(n.webVROptions.defaultLightingOnControllers=!0),n.rotationQuaternion=new a.Quaternion,n.webVROptions&&n.webVROptions.positionScale&&(n.deviceScaleFactor=n.webVROptions.positionScale);var o=n.getEngine();return n._onVREnabled=function(e){e&&n.initControllers()},o.onVRRequestPresentComplete.add(n._onVREnabled),o.initWebVR().add((function(e){e.vrDisplay&&n._vrDevice!==e.vrDisplay&&(n._vrDevice=e.vrDisplay,n.setCameraRigMode(a.Camera.RIG_MODE_WEBVR,{parentCamera:n,vrDisplay:n._vrDevice,frameData:n._frameData,specs:n._specsVersion}),n._attached&&n.getEngine().enableVR())})),"undefined"!=typeof VRFrameData&&(n._frameData=new VRFrameData),i.onBeforeCameraRenderObservable.add((function(t){t.parent===n&&n.rigParenting&&(n._descendants=n.getDescendants(!0,(function(t){var e=n.controllers.some((function(e){return e._mesh===t})),i=-1!==n._rigCameras.indexOf(t);return!e&&!i})),n._descendants.forEach((function(e){e.parent=t})))})),i.onAfterCameraRenderObservable.add((function(e){e.parent===n&&n.rigParenting&&n._descendants.forEach((function(e){e.parent=n}))})),n}return T(e,s),e.prototype.deviceDistanceToRoomGround=function(){return this._standingMatrix?(this._standingMatrix.getTranslationToRef(this._workingVector),this._deviceRoomPosition.y+this._workingVector.y):this._defaultHeight||0},e.prototype.useStandingMatrix=function(t){var i=this;void 0===t&&(t=function(e){}),this.getEngine().initWebVRAsync().then((function(e){e.vrDisplay&&e.vrDisplay.stageParameters&&e.vrDisplay.stageParameters.sittingToStandingTransform&&i.webVROptions.trackPosition?(i._standingMatrix=new a.Matrix,a.Matrix.FromFloat32ArrayToRefScaled(e.vrDisplay.stageParameters.sittingToStandingTransform,0,1,i._standingMatrix),i.getScene().useRightHandedSystem||[2,6,8,9,14].forEach((function(e){i._standingMatrix&&(i._standingMatrix.m[e]*=-1)})),t(!0)):t(!1)}))},e.prototype.useStandingMatrixAsync=function(){var i=this;return new Promise(function(t,e){i.useStandingMatrix((function(e){t(e)}))})},e.prototype.dispose=function(){this._detachIfAttached(),this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled),this._updateCacheWhenTrackingDisabledObserver&&this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver),s.prototype.dispose.call(this)},e.prototype.getControllerByName=function(e){for(var t=0,i=this.controllers;t<i.length;t++){var r=i[t];if(r.hand===e)return r}return null},Object.defineProperty(e.prototype,"leftController",{get:function(){return this._leftController||(this._leftController=this.getControllerByName("left")),this._leftController},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rightController",{get:function(){return this._rightController||(this._rightController=this.getControllerByName("right")),this._rightController},enumerable:!0,configurable:!0}),e.prototype.getForwardRay=function(e){return void 0===e&&(e=100),this.leftCamera?s.prototype.getForwardRay.call(this,e,this.leftCamera.getWorldMatrix(),this.leftCamera.globalPosition):s.prototype.getForwardRay.call(this,e)},e.prototype._checkInputs=function(){this._vrDevice&&this._vrDevice.isPresenting&&(this._vrDevice.getFrameData(this._frameData),this.updateFromDevice(this._frameData.pose)),s.prototype._checkInputs.call(this)},e.prototype.updateFromDevice=function(e){e&&e.orientation&&(this.rawPose=e,this._deviceRoomRotationQuaternion.copyFromFloats(e.orientation[0],e.orientation[1],-e.orientation[2],-e.orientation[3]),this.getScene().useRightHandedSystem&&(this._deviceRoomRotationQuaternion.z*=-1,this._deviceRoomRotationQuaternion.w*=-1),this.webVROptions.trackPosition&&this.rawPose.position&&(this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2]),this.getScene().useRightHandedSystem&&(this._deviceRoomPosition.z*=-1)),this._poseSet=!0)},e.prototype.attachControl=function(e,t){s.prototype.attachControl.call(this,e,t),this._attached=!0,this._htmlElementAttached=e,t=!a.Camera.ForceAttachControlToAlwaysPreventDefault&&t,this._vrDevice&&this.getEngine().enableVR(),window.addEventListener("vrdisplaypresentchange",this._detachIfAttached)},e.prototype.detachControl=function(e){this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver),this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver),s.prototype.detachControl.call(this,e),this._attached=!1,this.getEngine().disableVR(),window.removeEventListener("vrdisplaypresentchange",this._detachIfAttached)},e.prototype.getClassName=function(){return"WebVRFreeCamera"},e.prototype.resetToCurrentRotation=function(){this._vrDevice.resetPose()},e.prototype._updateRigCameras=function(){var e=this._rigCameras[0],t=this._rigCameras[1];e.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),t.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion),e.position.copyFrom(this._deviceRoomPosition),t.position.copyFrom(this._deviceRoomPosition)},e.prototype._correctPositionIfNotTrackPosition=function(e,t){void 0===t&&(t=!1),this.rawPose&&this.rawPose.position&&!this.webVROptions.trackPosition&&(a.Matrix.TranslationToRef(this.rawPose.position[0],this.rawPose.position[1],-this.rawPose.position[2],this._tmpMatrix),t||this._tmpMatrix.invert(),this._tmpMatrix.multiplyToRef(e,e))},e.prototype._updateCache=function(e){var t=this;this.rotationQuaternion.equals(this._cache.rotationQuaternion)&&this.position.equals(this._cache.position)||(this.updateCacheCalled||(this.updateCacheCalled=!0,this.update()),this.rotationQuaternion.toRotationMatrix(this._workingMatrix),a.Vector3.TransformCoordinatesToRef(this._deviceRoomPosition,this._workingMatrix,this._workingVector),this.devicePosition.subtractToRef(this._workingVector,this._workingVector),a.Matrix.ComposeToRef(this._oneVector,this.rotationQuaternion,this._workingVector,this._deviceToWorld),this._deviceToWorld.getTranslationToRef(this._workingVector),this._workingVector.addInPlace(this.position),this._workingVector.subtractInPlace(this._cache.position),this._deviceToWorld.setTranslation(this._workingVector),this._deviceToWorld.invertToRef(this._worldToDevice),this.controllers.forEach((function(e){e._deviceToWorld.copyFrom(t._deviceToWorld),t._correctPositionIfNotTrackPosition(e._deviceToWorld),e.update()}))),e||s.prototype._updateCache.call(this),this.updateCacheCalled=!1},e.prototype._computeDevicePosition=function(){a.Vector3.TransformCoordinatesToRef(this._deviceRoomPosition,this._deviceToWorld,this.devicePosition)},e.prototype.update=function(){this._computeDevicePosition(),a.Matrix.FromQuaternionToRef(this._deviceRoomRotationQuaternion,this._workingMatrix),this._workingMatrix.multiplyToRef(this._deviceToWorld,this._workingMatrix),a.Quaternion.FromRotationMatrixToRef(this._workingMatrix,this.deviceRotationQuaternion),this._poseSet&&this.onPoseUpdatedFromDeviceObservable.notifyObservers(null),s.prototype.update.call(this)},e.prototype._getViewMatrix=function(){return a.Matrix.Identity()},e.prototype._getWebVRViewMatrix=function(){var t=this,e=this._cameraRigParams.parentCamera;e._updateCache();var i=this._cameraRigParams.left?this._cameraRigParams.frameData.leftViewMatrix:this._cameraRigParams.frameData.rightViewMatrix;return a.Matrix.FromArrayToRef(i,0,this._webvrViewMatrix),this.getScene().useRightHandedSystem||[2,6,8,9,14].forEach((function(e){t._webvrViewMatrix.m[e]*=-1})),this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix),a.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),1!==e.deviceScaleFactor&&(this._webvrViewMatrix.invert(),e.deviceScaleFactor&&(this._webvrViewMatrix.m[12]*=e.deviceScaleFactor,this._webvrViewMatrix.m[13]*=e.deviceScaleFactor,this._webvrViewMatrix.m[14]*=e.deviceScaleFactor),this._webvrViewMatrix.invert()),e._correctPositionIfNotTrackPosition(this._webvrViewMatrix,!0),e._worldToDevice.multiplyToRef(this._webvrViewMatrix,this._webvrViewMatrix),this._workingMatrix=this._workingMatrix||a.Matrix.Identity(),this._webvrViewMatrix.invertToRef(this._workingMatrix),this._workingMatrix.multiplyToRef(e.getWorldMatrix(),this._workingMatrix),this._workingMatrix.getTranslationToRef(this._globalPosition),this._markSyncedWithParent(),this._webvrViewMatrix},e.prototype._getWebVRProjectionMatrix=function(){var t=this,e=this.parent;e._vrDevice.depthNear=e.minZ,e._vrDevice.depthFar=e.maxZ;var i=this._cameraRigParams.left?this._cameraRigParams.frameData.leftProjectionMatrix:this._cameraRigParams.frameData.rightProjectionMatrix;return a.Matrix.FromArrayToRef(i,0,this._projectionMatrix),this.getScene().useRightHandedSystem||[8,9,10,11].forEach((function(e){t._projectionMatrix.m[e]*=-1})),this._projectionMatrix},e.prototype.initControllers=function(){var n=this;this.controllers=[];var e=this.getScene().gamepadManager;this._onGamepadDisconnectedObserver=e.onGamepadDisconnectedObservable.add((function(e){if(e.type===a.Gamepad.POSE_ENABLED){var t=e;t.defaultModel&&t.defaultModel.setEnabled(!1),"right"===t.hand&&(n._rightController=null),"left"===t.hand&&(n._leftController=null);var i=n.controllers.indexOf(t);-1!==i&&n.controllers.splice(i,1)}})),this._onGamepadConnectedObserver=e.onGamepadConnectedObservable.add((function(e){if(e.type===a.Gamepad.POSE_ENABLED){var t=e;if(n.webVROptions.trackPosition||(t._disableTrackPosition(new a.Vector3("left"==t.hand?-.15:.15,-.5,.25)),n._updateCacheWhenTrackingDisabledObserver||(n._updateCacheWhenTrackingDisabledObserver=n._scene.onBeforeRenderObservable.add((function(){n._updateCache()})))),t.deviceScaleFactor=n.deviceScaleFactor,t._deviceToWorld.copyFrom(n._deviceToWorld),n._correctPositionIfNotTrackPosition(t._deviceToWorld),n.webVROptions.controllerMeshes&&(t.defaultModel?t.defaultModel.setEnabled(!0):t.initControllerMesh(n.getScene(),(function(e){if(e.scaling.scaleInPlace(n.deviceScaleFactor),n.onControllerMeshLoadedObservable.notifyObservers(t),n.webVROptions.defaultLightingOnControllers){n._lightOnControllers||(n._lightOnControllers=new a.HemisphericLight("vrControllersLight",new a.Vector3(0,1,0),n.getScene()));var r=function(e,t){var i=e.getChildren();i&&0!==i.length&&i.forEach((function(e){t.includedOnlyMeshes.push(e),r(e,t)}))};n._lightOnControllers.includedOnlyMeshes.push(e),r(e,n._lightOnControllers)}}))),t.attachToPoseControlledCamera(n),-1===n.controllers.indexOf(t)){n.controllers.push(t);for(var i=!1,r=0;r<n.controllers.length;r++)n.controllers[r].controllerType===a.PoseEnabledControllerType.VIVE&&(i?n.controllers[r].hand="right":(i=!0,n.controllers[r].hand="left"));2<=n.controllers.length&&n.onControllersAttachedObservable.notifyObservers(n.controllers)}}}))},e})(a.FreeCamera);a.WebVRFreeCamera=i})($a||($a={})),(function(o){o.Node.AddNodeConstructor("DeviceOrientationCamera",(function(e,t){return function(){return new i(e,o.Vector3.Zero(),t)}}));var i=(function(n){function e(e,t,i){var r=n.call(this,e,t,i)||this;return r._quaternionCache=new o.Quaternion,r.inputs.addDeviceOrientation(),r}return T(e,n),e.prototype.getClassName=function(){return"DeviceOrientationCamera"},e.prototype._checkInputs=function(){n.prototype._checkInputs.call(this),this._quaternionCache.copyFrom(this.rotationQuaternion),this._initialQuaternion&&this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)},e.prototype.resetToCurrentRotation=function(t){var i=this;void 0===t&&(t=o.Axis.Y),this.rotationQuaternion&&(this._initialQuaternion||(this._initialQuaternion=new o.Quaternion),this._initialQuaternion.copyFrom(this._quaternionCache||this.rotationQuaternion),["x","y","z"].forEach((function(e){t[e]?i._initialQuaternion[e]*=-1:i._initialQuaternion[e]=0})),this._initialQuaternion.normalize(),this._initialQuaternion.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion))},e})(o.FreeCamera);o.DeviceOrientationCamera=i})($a||($a={})),(function(a){a.Node.AddNodeConstructor("VRDeviceOrientationFreeCamera",(function(e,t){return function(){return new i(e,a.Vector3.Zero(),t)}}));var i=(function(s){function e(e,t,i,r,n){void 0===r&&(r=!0),void 0===n&&(n=a.VRCameraMetrics.GetDefault());var o=s.call(this,e,t,i)||this;return n.compensateDistortion=r,o.setCameraRigMode(a.Camera.RIG_MODE_VR,{vrCameraMetrics:n}),o}return T(e,s),e.prototype.getClassName=function(){return"VRDeviceOrientationFreeCamera"},e})(a.DeviceOrientationCamera);a.VRDeviceOrientationFreeCamera=i})($a||($a={})),(function(h){h.Node.AddNodeConstructor("VRDeviceOrientationFreeCamera",(function(e,t){return function(){return new i(e,0,0,1,h.Vector3.Zero(),t)}}));var i=(function(c){function e(e,t,i,r,n,o,s,a){void 0===s&&(s=!0),void 0===a&&(a=h.VRCameraMetrics.GetDefault());var l=c.call(this,e,t,i,r,n,o)||this;return a.compensateDistortion=s,l.setCameraRigMode(h.Camera.RIG_MODE_VR,{vrCameraMetrics:a}),l.inputs.addVRDeviceOrientation(),l}return T(e,c),e.prototype.getClassName=function(){return"VRDeviceOrientationArcRotateCamera"},e})(h.ArcRotateCamera);h.VRDeviceOrientationArcRotateCamera=i})($a||($a={})),(function(a){a.Node.AddNodeConstructor("VRDeviceOrientationGamepadCamera",(function(e,t){return function(){return new i(e,a.Vector3.Zero(),t)}}));var i=(function(s){function e(e,t,i,r,n){void 0===r&&(r=!0),void 0===n&&(n=a.VRCameraMetrics.GetDefault());var o=s.call(this,e,t,i,r,n)||this;return o.inputs.addGamepad(),o}return T(e,s),e.prototype.getClassName=function(){return"VRDeviceOrientationGamepadCamera"},e})(a.VRDeviceOrientationFreeCamera);a.VRDeviceOrientationGamepadCamera=i})($a||($a={})),qs=$a||($a={}),Js=(function(){function r(e,t){if(void 0===t&&(t=null),this.scene=e,this._pointerDownOnMeshAsked=!1,this._isActionableMesh=!1,this._teleportationRequestInitiated=!1,this._teleportationBackRequestInitiated=!1,this._rotationRightAsked=!1,this._rotationLeftAsked=!1,this._dpadPressed=!0,this._activePointer=!1,this._id=r._idCounter++,t)this._gazeTracker=t.clone("gazeTracker");else{this._gazeTracker=qs.Mesh.CreateTorus("gazeTracker",.0035,.0025,20,e,!1),this._gazeTracker.bakeCurrentTransformIntoVertices(),this._gazeTracker.isPickable=!1,this._gazeTracker.isVisible=!1;var i=new qs.StandardMaterial("targetMat",e);i.specularColor=qs.Color3.Black(),i.emissiveColor=new qs.Color3(.7,.7,.7),i.backFaceCulling=!1,this._gazeTracker.material=i}}return r.prototype._getForwardRay=function(e){return new qs.Ray(qs.Vector3.Zero(),new qs.Vector3(0,0,e))},r.prototype._selectionPointerDown=function(){this._pointerDownOnMeshAsked=!0,this._currentHit&&this.scene.simulatePointerDown(this._currentHit,{pointerId:this._id})},r.prototype._selectionPointerUp=function(){this._currentHit&&this.scene.simulatePointerUp(this._currentHit,{pointerId:this._id}),this._pointerDownOnMeshAsked=!1},r.prototype._activatePointer=function(){this._activePointer=!0},r.prototype._deactivatePointer=function(){this._activePointer=!1},r.prototype._updatePointerDistance=function(e){void 0===e&&(e=100)},r.prototype.dispose=function(){this._interactionsEnabled=!1,this._teleportationEnabled=!1,this._gazeTracker&&this._gazeTracker.dispose()},r._idCounter=0,r})(),$s=(function(a){function e(e,t,i){var r=a.call(this,t,i)||this;r.webVRController=e,r._laserPointer=qs.Mesh.CreateCylinder("laserPointer",1,.004,2e-4,20,1,t,!1);var n=new qs.StandardMaterial("laserPointerMat",t);if(n.emissiveColor=new qs.Color3(.7,.7,.7),n.alpha=.6,r._laserPointer.material=n,r._laserPointer.rotation.x=Math.PI/2,r._laserPointer.position.z=-.5,r._laserPointer.isVisible=!1,r._laserPointer.isPickable=!1,!e.mesh){var o=new qs.Mesh("preloadControllerMesh",t),s=new qs.Mesh(qs.PoseEnabledController.POINTING_POSE,t);s.rotation.x=-.7,o.addChild(s),e.attachToMesh(o)}return r._setLaserPointerParent(e.mesh),r._meshAttachedObserver=e._meshAttachedObservable.add((function(e){r._setLaserPointerParent(e)})),r}return T(e,a),e.prototype._getForwardRay=function(e){return this.webVRController.getForwardRay(e)},e.prototype._activatePointer=function(){a.prototype._activatePointer.call(this),this._laserPointer.isVisible=!0},e.prototype._deactivatePointer=function(){a.prototype._deactivatePointer.call(this),this._laserPointer.isVisible=!1},e.prototype._setLaserPointerColor=function(e){this._laserPointer.material.emissiveColor=e},e.prototype._setLaserPointerParent=function(e){var t=function(e){e.isPickable=!1,e.getChildMeshes().forEach((function(e){t(e)}))};t(e);var i=e.getChildMeshes();this.webVRController._pointingPoseNode=null;for(var r=0;r<i.length;r++)if(i[r].name&&0<=i[r].name.indexOf(qs.PoseEnabledController.POINTING_POSE)){e=i[r],this.webVRController._pointingPoseNode=e;break}this._laserPointer.parent=e},e.prototype._updatePointerDistance=function(e){void 0===e&&(e=100),this._laserPointer.scaling.y=e,this._laserPointer.position.z=-e/2},e.prototype.dispose=function(){a.prototype.dispose.call(this),this._laserPointer.dispose(),this._meshAttachedObserver&&this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver)},e})(Js),ea=(function(r){function e(e,t){var i=r.call(this,t)||this;return i.getCamera=e,i}return T(e,r),e.prototype._getForwardRay=function(e){var t=this.getCamera();return t?t.getForwardRay(e):new qs.Ray(qs.Vector3.Zero(),qs.Vector3.Forward())},e})(Js),ta=(function(){function e(e,t){void 0===t&&(t={});var r=this;if(this.webVROptions=t,this._webVRsupported=!1,this._webVRready=!1,this._webVRrequesting=!1,this._webVRpresenting=!1,this._fullscreenVRpresenting=!1,this.onEnteringVRObservable=new qs.Observable,this.onExitingVRObservable=new qs.Observable,this.onControllerMeshLoadedObservable=new qs.Observable,this._useCustomVRButton=!1,this._teleportationRequested=!1,this._teleportActive=!1,this._floorMeshesCollection=[],this._rotationAllowed=!0,this._teleportBackwardsVector=new qs.Vector3(0,-1,-1),this._isDefaultTeleportationTarget=!0,this._teleportationFillColor="#444444",this._teleportationBorderColor="#FFFFFF",this._rotationAngle=0,this._haloCenter=new qs.Vector3(0,0,0),this._padSensibilityUp=.65,this._padSensibilityDown=.35,this._leftController=null,this._rightController=null,this.onNewMeshSelected=new qs.Observable,this.onNewMeshPicked=new qs.Observable,this.onBeforeCameraTeleport=new qs.Observable,this.onAfterCameraTeleport=new qs.Observable,this.onSelectedMeshUnselected=new qs.Observable,this.teleportationEnabled=!0,this._teleportationInitialized=!1,this._interactionsEnabled=!1,this._interactionsRequested=!1,this._displayGaze=!0,this._displayLaserPointer=!0,this.updateGazeTrackerScale=!0,this._onResize=function(){r.moveButtonToBottomRight(),r._fullscreenVRpresenting&&r._webVRready&&r.exitVR()},this._onFullscreenChange=function(){void 0!==document.fullscreen?r._fullscreenVRpresenting=document.fullscreen:void 0!==document.mozFullScreen?r._fullscreenVRpresenting=document.mozFullScreen:void 0!==document.webkitIsFullScreen?r._fullscreenVRpresenting=document.webkitIsFullScreen:void 0!==document.msIsFullScreen?r._fullscreenVRpresenting=document.msIsFullScreen:void 0!==document.msFullscreenElement&&(r._fullscreenVRpresenting=document.msFullscreenElement),!r._fullscreenVRpresenting&&r._canvas&&(r.exitVR(),r._useCustomVRButton||(r._btnVR.style.top=r._canvas.offsetTop+r._canvas.offsetHeight-70+"px",r._btnVR.style.left=r._canvas.offsetLeft+r._canvas.offsetWidth-100+"px"))},this.beforeRender=function(){r._leftController&&r._leftController._activePointer&&r._castRayAndSelectObject(r._leftController),r._rightController&&r._rightController._activePointer&&r._castRayAndSelectObject(r._rightController),r._noControllerIsActive?r._castRayAndSelectObject(r._cameraGazer):r._cameraGazer._gazeTracker.isVisible=!1},this._onNewGamepadConnected=function(e){if(e.type!==qs.Gamepad.POSE_ENABLED)e.leftStick&&e.onleftstickchanged((function(e){r._teleportationInitialized&&r.teleportationEnabled&&(!r._leftController&&!r._rightController||r._leftController&&!r._leftController._activePointer&&r._rightController&&!r._rightController._activePointer)&&(r._checkTeleportWithRay(e,r._cameraGazer),r._checkTeleportBackwards(e,r._cameraGazer))})),e.rightStick&&e.onrightstickchanged((function(e){r._teleportationInitialized&&r._checkRotate(e,r._cameraGazer)})),e.type===qs.Gamepad.XBOX&&(e.onbuttondown((function(e){r._interactionsEnabled&&e===qs.Xbox360Button.A&&r._cameraGazer._selectionPointerDown()})),e.onbuttonup((function(e){r._interactionsEnabled&&e===qs.Xbox360Button.A&&r._cameraGazer._selectionPointerUp()})));else{var t=e,i=new $s(t,r._scene,r._cameraGazer._gazeTracker);"right"===t.hand||r._leftController&&r._leftController.webVRController!=t?r._rightController=i:r._leftController=i,r._tryEnableInteractionOnController(i)}},this._tryEnableInteractionOnController=function(e){r._interactionsRequested&&!e._interactionsEnabled&&r._enableInteractionOnController(e),r._teleportationRequested&&!e._teleportationEnabled&&r._enableTeleportationOnController(e)},this._onNewGamepadDisconnected=function(e){e instanceof qs.WebVRController&&("left"===e.hand&&null!=r._leftController&&(r._leftController.dispose(),r._leftController=null),"right"===e.hand&&null!=r._rightController&&(r._rightController.dispose(),r._rightController=null))},this._workingVector=qs.Vector3.Zero(),this._workingQuaternion=qs.Quaternion.Identity(),this._workingMatrix=qs.Matrix.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 qs.Vector3(0,this._defaultHeight,0),t.createDeviceOrientationCamera||!this._scene.activeCamera){if(this._deviceOrientationCamera=new qs.DeviceOrientationCamera("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 qs.TargetCamera&&this._scene.activeCamera.rotation)){var i=this._scene.activeCamera;i.rotationQuaternion?this._deviceOrientationCamera.rotationQuaternion.copyFrom(i.rotationQuaternion):this._deviceOrientationCamera.rotationQuaternion.copyFrom(qs.Quaternion.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&&(this._vrDeviceOrientationCamera=new qs.VRDeviceOrientationFreeCamera("VRDeviceOrientationVRHelper",this._position,this._scene)),this._webVRCamera=new qs.WebVRFreeCamera("WebVRHelper",this._position,this._scene,t),this._webVRCamera.useStandingMatrix(),this._cameraGazer=new ea(function(){return r.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 n=document.createElement("style");n.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(n),this.moveButtonToBottomRight()}this._btnVR&&this._btnVR.addEventListener("click",(function(){r.isInVRMode?r.exitVR():r.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&&r.displayVRButton()})),this._onKeyDown=function(e){27===e.keyCode&&r.isInVRMode&&r.exitVR()},document.addEventListener("keydown",this._onKeyDown),this._scene.onPrePointerObservable.add((function(e,t){r.isInVRMode&&(r.exitVR(),r._fullscreenVRpresenting&&r._scene.getEngine().switchFullscreen(!0))}),qs.PointerEventTypes.POINTERDOUBLETAP,!1),this._onVRDisplayChanged=function(e){return r.onVRDisplayChanged(e)},this._onVrDisplayPresentChange=function(){return r.onVrDisplayPresentChange()},this._onVRRequestPresentStart=function(){r._webVRrequesting=!0,r.updateButtonVisibility()},this._onVRRequestPresentComplete=function(e){r._webVRrequesting=!1,r.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(){r.dispose()})),this._webVRCamera.onControllerMeshLoadedObservable.add((function(e){return r._onDefaultMeshLoaded(e)})),this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected),this.updateButtonVisibility(),this._circleEase=new qs.CircleEase,this._circleEase.setEasingMode(qs.EasingFunction.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)||(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)?(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){qs.Tools.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 qs.Tools.Warn("Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?");this.updateButtonVisibility()},e.prototype.onVRDisplayChanged=function(e){this._webVRsupported=e.vrSupported,this._webVRready=!!e.vrDisplay,this._webVRpresenting=e.vrDisplay&&e.vrDisplay.isPresenting,this.updateButtonVisibility()},e.prototype.moveButtonToBottomRight=function(){this._canvas&&!this._useCustomVRButton&&(this._btnVR.style.top=this._canvas.offsetTop+this._canvas.offsetHeight-70+"px",this._btnVR.style.left=this._canvas.offsetLeft+this._canvas.offsetWidth-100+"px")},e.prototype.displayVRButton=function(){this._useCustomVRButton||this._btnVRDisplayed||(document.body.appendChild(this._btnVR),this._btnVRDisplayed=!0)},e.prototype.updateButtonVisibility=function(){this._btnVR&&!this._useCustomVRButton&&(this._btnVR.className="babylonVRicon",this.isInVRMode?this._btnVR.className+=" vrdisplaypresenting":(this._webVRready&&(this._btnVR.className+=" vrdisplayready"),this._webVRsupported&&(this._btnVR.className+=" vrdisplaysupported"),this._webVRrequesting&&(this._btnVR.className+=" vrdisplayrequesting")))},e.prototype.enterVR=function(){if(this.onEnteringVRObservable)try{this.onEnteringVRObservable.notifyObservers(this)}catch(e){qs.Tools.Warn("Error in your custom logic onEnteringVR: "+e)}this._scene.activeCamera&&(this._position=this._scene.activeCamera.position.clone(),this._existingCamera=this._scene.activeCamera),this._webVRrequesting||(this._webVRready?this._webVRpresenting||(this._webVRCamera.position=this._position,this._scene.activeCamera=this._webVRCamera):this._vrDeviceOrientationCamera&&(this._vrDeviceOrientationCamera.position=this._position,this._scene.activeCamera&&(this._vrDeviceOrientationCamera.minZ=this._scene.activeCamera.minZ),this._scene.activeCamera=this._vrDeviceOrientationCamera,this._scene.getEngine().switchFullscreen(!0),this.updateButtonVisibility()),this._scene.activeCamera&&this._canvas&&this._scene.activeCamera.attachControl(this._canvas),this._interactionsEnabled&&this._scene.registerBeforeRender(this.beforeRender),this._hasEnteredVR=!0)},e.prototype.exitVR=function(){if(this._hasEnteredVR){if(this.onExitingVRObservable)try{this.onExitingVRObservable.notifyObservers(this)}catch(e){qs.Tools.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._deviceOrientationCamera?(this._deviceOrientationCamera.position=this._position,this._scene.activeCamera=this._deviceOrientationCamera,this._canvas&&this._scene.activeCamera.attachControl(this._canvas)):this._existingCamera&&(this._existingCamera.position=this._position,this._scene.activeCamera=this._existingCamera),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._hasEnteredVR=!1}},Object.defineProperty(e.prototype,"position",{get:function(){return this._position},set:function(e){this._position=e,this._scene.activeCamera&&(this._scene.activeCamera.position=e)},enumerable:!0,configurable:!0}),e.prototype.enableInteractions=function(){var t=this;this._interactionsEnabled||(this._interactionsRequested=!0,this._leftController&&this._enableInteractionOnController(this._leftController),this._rightController&&this._enableInteractionOnController(this._rightController),this.raySelectionPredicate=function(e){return e.isVisible&&(e.isPickable||e.name===t._floorMeshName)},this.meshSelectionPredicate=function(e){return!0},this._raySelectionPredicate=function(e){return!!(t._isTeleportationFloor(e)||-1===e.name.indexOf("gazeTracker")&&-1===e.name.indexOf("teleportationTarget")&&-1===e.name.indexOf("torusTeleportation"))&&t.raySelectionPredicate(e)},this._interactionsEnabled=!0)},Object.defineProperty(e.prototype,"_noControllerIsActive",{get:function(){return!(this._leftController&&this._leftController._activePointer||this._rightController&&this._rightController._activePointer)},enumerable:!0,configurable:!0}),e.prototype._isTeleportationFloor=function(e){for(var t=0;t<this._floorMeshesCollection.length;t++)if(this._floorMeshesCollection[t].id===e.id)return!0;return!(!this._floorMeshName||e.name!==this._floorMeshName)},e.prototype.addFloorMesh=function(e){this._floorMeshesCollection&&(-1<this._floorMeshesCollection.indexOf(e)||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 qs.ImageProcessingConfiguration;t.vignetteColor=new qs.Color4(0,0,0,0),t.vignetteEnabled=!0,this._postProcessMove=new qs.ImageProcessingPostProcess("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(i){var r=this;i.webVRController.mesh&&(i._interactionsEnabled=!0,i._activatePointer(),this.webVROptions.laserToggle&&i.webVRController.onMainButtonStateChangedObservable.add((function(e){r._displayLaserPointer&&1===e.value&&(i._activePointer?i._deactivatePointer():i._activatePointer(),r.displayGaze&&(i._gazeTracker.isVisible=i._activePointer))})),i.webVRController.onTriggerStateChangedObservable.add((function(e){var t=i;r._noControllerIsActive&&(t=r._cameraGazer),t._pointerDownOnMeshAsked?e.value<r._padSensibilityDown&&t._selectionPointerUp():e.value>r._padSensibilityUp&&t._selectionPointerDown()})))},e.prototype._checkTeleportWithRay=function(e,t){this._teleportationRequestInitiated&&!t._teleportationRequestInitiated||(t._teleportationRequestInitiated?Math.sqrt(e.y*e.y+e.x*e.x)<this._padSensibilityDown&&(this._teleportActive&&this.teleportCamera(this._haloCenter),t._teleportationRequestInitiated=!1):e.y<-this._padSensibilityUp&&t._dpadPressed&&(t._activatePointer(),t._teleportationRequestInitiated=!0))},e.prototype._checkRotate=function(e,t){t._teleportationRequestInitiated||(t._rotationLeftAsked?e.x>-this._padSensibilityDown&&(t._rotationLeftAsked=!1):e.x<-this._padSensibilityUp&&t._dpadPressed&&(t._rotationLeftAsked=!0,this._rotationAllowed&&this._rotateCamera(!1)),t._rotationRightAsked?e.x<this._padSensibilityDown&&(t._rotationRightAsked=!1):e.x>this._padSensibilityUp&&t._dpadPressed&&(t._rotationRightAsked=!0,this._rotationAllowed&&this._rotateCamera(!0)))},e.prototype._checkTeleportBackwards=function(e,t){if(!t._teleportationRequestInitiated)if(e.y>this._padSensibilityUp&&t._dpadPressed){if(!t._teleportationBackRequestInitiated){if(!this.currentVRCamera)return;var i=qs.Quaternion.FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix()),r=this.currentVRCamera.position;this.currentVRCamera.devicePosition&&this.currentVRCamera.deviceRotationQuaternion&&(i=this.currentVRCamera.deviceRotationQuaternion,r=this.currentVRCamera.devicePosition),i.toEulerAnglesToRef(this._workingVector),this._workingVector.z=0,this._workingVector.x=0,qs.Quaternion.RotationYawPitchRollToRef(this._workingVector.y,this._workingVector.x,this._workingVector.z,this._workingQuaternion),this._workingQuaternion.toRotationMatrix(this._workingMatrix),qs.Vector3.TransformCoordinatesToRef(this._teleportBackwardsVector,this._workingMatrix,this._workingVector);var n=new qs.Ray(r,this._workingVector),o=this._scene.pickWithRay(n,this._raySelectionPredicate);o&&o.pickedPoint&&o.pickedMesh&&this._isTeleportationFloor(o.pickedMesh)&&o.distance<5&&this.teleportCamera(o.pickedPoint),t._teleportationBackRequestInitiated=!0}}else t._teleportationBackRequestInitiated=!1},e.prototype._enableTeleportationOnController=function(t){var i=this;t.webVRController.mesh&&(t._interactionsEnabled||this._enableInteractionOnController(t),t._interactionsEnabled=!0,t._teleportationEnabled=!0,t.webVRController.controllerType===qs.PoseEnabledControllerType.VIVE&&(t._dpadPressed=!1,t.webVRController.onPadStateChangedObservable.add((function(e){t._dpadPressed=e.pressed,t._dpadPressed||(t._rotationLeftAsked=!1,t._rotationRightAsked=!1,t._teleportationBackRequestInitiated=!1)}))),t.webVRController.onPadValuesChangedObservable.add((function(e){i.teleportationEnabled&&(i._checkTeleportBackwards(e,t),i._checkTeleportWithRay(e,t)),i._checkRotate(e,t)})))},e.prototype._createTeleportationCircles=function(){this._teleportationTarget=qs.Mesh.CreateGround("teleportationTarget",2,2,2,this._scene),this._teleportationTarget.isPickable=!1;var e=new qs.DynamicTexture("DynamicTexture",512,this._scene,!0);e.hasAlpha=!0;var t=e.getContext();t.beginPath(),t.arc(256,256,200,0,2*Math.PI,!1),t.fillStyle=this._teleportationFillColor,t.fill(),t.lineWidth=10,t.strokeStyle=this._teleportationBorderColor,t.stroke(),t.closePath(),e.update();var i=new qs.StandardMaterial("TextPlaneMaterial",this._scene);i.diffuseTexture=e,this._teleportationTarget.material=i;var r=qs.Mesh.CreateTorus("torusTeleportation",.75,.1,25,this._scene,!1);r.isPickable=!1,r.parent=this._teleportationTarget;var n=new qs.Animation("animationInnerCircle","position.y",30,qs.Animation.ANIMATIONTYPE_FLOAT,qs.Animation.ANIMATIONLOOPMODE_CYCLE),o=[];o.push({frame:0,value:0}),o.push({frame:30,value:.4}),o.push({frame:60,value:0}),n.setKeys(o);var s=new qs.SineEase;s.setEasingMode(qs.EasingFunction.EASINGMODE_EASEINOUT),n.setEasingFunction(s),r.animations=[],r.animations.push(n),this._scene.beginAnimation(r,0,60,!0),this._hideTeleportationTarget()},e.prototype._displayTeleportationTarget=function(){this._teleportActive=!0,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!0,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!0))},e.prototype._hideTeleportationTarget=function(){this._teleportActive=!1,this._teleportationInitialized&&(this._teleportationTarget.isVisible=!1,this._isDefaultTeleportationTarget&&(this._teleportationTarget.getChildren()[0].isVisible=!1))},e.prototype._rotateCamera=function(e){var t=this;if(this.currentVRCamera instanceof qs.FreeCamera){e?this._rotationAngle++:this._rotationAngle--,this.currentVRCamera.animations=[];var i=qs.Quaternion.FromRotationMatrix(qs.Matrix.RotationY(Math.PI/4*this._rotationAngle)),r=new qs.Animation("animationRotation","rotationQuaternion",90,qs.Animation.ANIMATIONTYPE_QUATERNION,qs.Animation.ANIMATIONLOOPMODE_CONSTANT),n=[];n.push({frame:0,value:this.currentVRCamera.rotationQuaternion}),n.push({frame:6,value:i}),r.setKeys(n),r.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(r),this._postProcessMove.animations=[];var o=new qs.Animation("animationPP","vignetteWeight",90,qs.Animation.ANIMATIONTYPE_FLOAT,qs.Animation.ANIMATIONLOOPMODE_CONSTANT),s=[];s.push({frame:0,value:0}),s.push({frame:3,value:4}),s.push({frame:6,value:0}),o.setKeys(s),o.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(o);var a=new qs.Animation("animationPP2","vignetteStretch",90,qs.Animation.ANIMATIONTYPE_FLOAT,qs.Animation.ANIMATIONLOOPMODE_CONSTANT),l=[];l.push({frame:0,value:0}),l.push({frame:3,value:10}),l.push({frame:6,value:0}),a.setKeys(l),a.setEasingFunction(this._circleEase),this._postProcessMove.animations.push(a),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._postProcessMove.samples=4,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,6,!1,1,(function(){t._webVRCamera.detachPostProcess(t._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,6,!1,1)}},e.prototype._moveTeleportationSelectorTo=function(e,t,i){if(e.pickedPoint){t._teleportationRequestInitiated&&(this._displayTeleportationTarget(),this._haloCenter.copyFrom(e.pickedPoint),this._teleportationTarget.position.copyFrom(e.pickedPoint));var r=this._convertNormalToDirectionOfRay(e.getNormal(!0,!1),i);if(r){var n=qs.Vector3.Cross(qs.Axis.Y,r),o=qs.Vector3.Cross(r,n);qs.Vector3.RotationFromAxisToRef(o,r,n,this._teleportationTarget.rotation)}this._teleportationTarget.position.y+=.1}},e.prototype.teleportCamera=function(e){var t=this;if(this.currentVRCamera instanceof qs.FreeCamera){this.webVRCamera.leftCamera?(this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition),this._workingVector.subtractInPlace(this.webVRCamera.position),e.subtractToRef(this._workingVector,this._workingVector)):this._workingVector.copyFrom(e),this.isInVRMode?this._workingVector.y+=this.webVRCamera.deviceDistanceToRoomGround()*this._webVRCamera.deviceScaleFactor:this._workingVector.y+=this._defaultHeight,this.onBeforeCameraTeleport.notifyObservers(this._workingVector),this.currentVRCamera.animations=[];var i=new qs.Animation("animationCameraTeleportation","position",90,qs.Animation.ANIMATIONTYPE_VECTOR3,qs.Animation.ANIMATIONLOOPMODE_CONSTANT),r=[{frame:0,value:this.currentVRCamera.position},{frame:11,value:this._workingVector}];i.setKeys(r),i.setEasingFunction(this._circleEase),this.currentVRCamera.animations.push(i),this._postProcessMove.animations=[];var n=new qs.Animation("animationPP","vignetteWeight",90,qs.Animation.ANIMATIONTYPE_FLOAT,qs.Animation.ANIMATIONLOOPMODE_CONSTANT),o=[];o.push({frame:0,value:0}),o.push({frame:5,value:8}),o.push({frame:11,value:0}),n.setKeys(o),this._postProcessMove.animations.push(n);var s=new qs.Animation("animationPP2","vignetteStretch",90,qs.Animation.ANIMATIONTYPE_FLOAT,qs.Animation.ANIMATIONLOOPMODE_CONSTANT),a=[];a.push({frame:0,value:0}),a.push({frame:5,value:10}),a.push({frame:11,value:0}),s.setKeys(a),this._postProcessMove.animations.push(s),this._postProcessMove.imageProcessingConfiguration.vignetteWeight=0,this._postProcessMove.imageProcessingConfiguration.vignetteStretch=0,this._webVRCamera.attachPostProcess(this._postProcessMove),this._scene.beginAnimation(this._postProcessMove,0,11,!1,1,(function(){t._webVRCamera.detachPostProcess(t._postProcessMove)})),this._scene.beginAnimation(this.currentVRCamera,0,11,!1,1,(function(){t.onAfterCameraTeleport.notifyObservers(t._workingVector)})),this._hideTeleportationTarget()}},e.prototype._convertNormalToDirectionOfRay=function(e,t){e&&(Math.acos(qs.Vector3.Dot(e,t.direction))<Math.PI/2&&e.scaleInPlace(-1));return e},e.prototype._castRayAndSelectObject=function(e){if(this.currentVRCamera instanceof qs.FreeCamera){var t=e._getForwardRay(this._rayLength),i=this._scene.pickWithRay(t,this._raySelectionPredicate);if(i&&(e._laserPointer&&(i.originMesh=e._laserPointer.parent),this._scene.simulatePointerMove(i,{pointerId:e._id})),(e._currentHit=i)&&i.pickedPoint){if(this._displayGaze){var r=1;e._gazeTracker.isVisible=!0,e._isActionableMesh&&(r=3),this.updateGazeTrackerScale&&(e._gazeTracker.scaling.x=i.distance*r,e._gazeTracker.scaling.y=i.distance*r,e._gazeTracker.scaling.z=i.distance*r);var n=this._convertNormalToDirectionOfRay(i.getNormal(),t);if(n){var o=qs.Vector3.Cross(qs.Axis.Y,n),s=qs.Vector3.Cross(n,o);qs.Vector3.RotationFromAxisToRef(s,n,o,e._gazeTracker.rotation)}e._gazeTracker.position.copyFrom(i.pickedPoint),e._gazeTracker.position.x<0?e._gazeTracker.position.x+=.002:e._gazeTracker.position.x-=.002,e._gazeTracker.position.y<0?e._gazeTracker.position.y+=.002:e._gazeTracker.position.y-=.002,e._gazeTracker.position.z<0?e._gazeTracker.position.z+=.002:e._gazeTracker.position.z-=.002}e._updatePointerDistance(i.distance)}else e._updatePointerDistance(),e._gazeTracker.isVisible=!1;if(i&&i.pickedMesh){if(this._teleportationInitialized&&this._isTeleportationFloor(i.pickedMesh)&&i.pickedPoint)return e._currentMeshSelected&&!this._isTeleportationFloor(e._currentMeshSelected)&&this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,void(e._teleportationRequestInitiated&&this._moveTeleportationSelectorTo(i,e,t));if(i.pickedMesh!==e._currentMeshSelected)if(this.meshSelectionPredicate(i.pickedMesh)){this.onNewMeshPicked.notifyObservers(i),e._currentMeshSelected=i.pickedMesh,i.pickedMesh.isPickable&&i.pickedMesh.actionManager?(this.changeGazeColor(new qs.Color3(0,0,1)),this.changeLaserColor(new qs.Color3(.2,.2,1)),e._isActionableMesh=!0):(this.changeGazeColor(new qs.Color3(.7,.7,.7)),this.changeLaserColor(new qs.Color3(.7,.7,.7)),e._isActionableMesh=!1);try{this.onNewMeshSelected.notifyObservers(i.pickedMesh)}catch(e){qs.Tools.Warn("Error in your custom logic onNewMeshSelected: "+e)}}else this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,this.changeGazeColor(new qs.Color3(.7,.7,.7)),this.changeLaserColor(new qs.Color3(.7,.7,.7))}else this._notifySelectedMeshUnselected(e._currentMeshSelected),e._currentMeshSelected=null,this.changeGazeColor(new qs.Color3(.7,.7,.7)),this.changeLaserColor(new qs.Color3(.7,.7,.7))}},e.prototype._notifySelectedMeshUnselected=function(e){e&&this.onSelectedMeshUnselected.notifyObservers(e)},e.prototype.changeLaserColor=function(e){this._leftController&&this._leftController._setLaserPointerColor(e),this._rightController&&this._rightController._setLaserPointerColor(e)},e.prototype.changeGazeColor=function(e){this._cameraGazer._gazeTracker.material&&(this._cameraGazer._gazeTracker.material.emissiveColor=e,this._leftController&&(this._leftController._gazeTracker.material.emissiveColor=e),this._rightController&&(this._rightController._gazeTracker.material.emissiveColor=e))},e.prototype.dispose=function(){this.isInVRMode&&this.exitVR(),this._postProcessMove&&this._postProcessMove.dispose(),this._webVRCamera&&this._webVRCamera.dispose(),this._vrDeviceOrientationCamera&&this._vrDeviceOrientationCamera.dispose(),!this._useCustomVRButton&&this._btnVR.parentNode&&document.body.removeChild(this._btnVR),this._deviceOrientationCamera&&this._scene.activeCamera!=this._deviceOrientationCamera&&this._deviceOrientationCamera.dispose(),this._cameraGazer&&this._cameraGazer.dispose(),this._leftController&&this._leftController.dispose(),this._rightController&&this._rightController.dispose(),this._teleportationTarget&&this._teleportationTarget.dispose(),this._floorMeshesCollection=[],document.removeEventListener("keydown",this._onKeyDown),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),window.removeEventListener("resize",this._onResize),document.removeEventListener("fullscreenchange",this._onFullscreenChange),document.removeEventListener("mozfullscreenchange",this._onFullscreenChange),document.removeEventListener("webkitfullscreenchange",this._onFullscreenChange),document.removeEventListener("msfullscreenchange",this._onFullscreenChange),document.onmsfullscreenchange=null,this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged),this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart),this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete),window.removeEventListener("vrdisplaypresentchange",this._onVrDisplayPresentChange),this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected),this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected),this._scene.unregisterBeforeRender(this.beforeRender)},e.prototype.getClassName=function(){return"VRExperienceHelper"},e})(),qs.VRExperienceHelper=ta,(function(n){var o,e;(e=o=n.JoystickAxis||(n.JoystickAxis={}))[e.X=0]="X",e[e.Y=1]="Y",e[e.Z=2]="Z";var t=(function(){function r(e){var t=this;if(this._leftJoystick=!!e,r._globalJoystickIndex++,this._axisTargetedByLeftAndRight=o.X,this._axisTargetedByUpAndDown=o.Y,this.reverseLeftRight=!1,this.reverseUpDown=!1,this._touches=new n.StringDictionary,this.deltaPosition=n.Vector3.Zero(),this._joystickSensibility=25,this._inversedSensibility=1/(this._joystickSensibility/1e3),this._onResize=function(e){r.vjCanvasWidth=window.innerWidth,r.vjCanvasHeight=window.innerHeight,r.vjCanvas&&(r.vjCanvas.width=r.vjCanvasWidth,r.vjCanvas.height=r.vjCanvasHeight),r.halfWidth=r.vjCanvasWidth/2},!r.vjCanvas){window.addEventListener("resize",this._onResize,!1),r.vjCanvas=document.createElement("canvas"),r.vjCanvasWidth=window.innerWidth,r.vjCanvasHeight=window.innerHeight,r.vjCanvas.width=window.innerWidth,r.vjCanvas.height=window.innerHeight,r.vjCanvas.style.width="100%",r.vjCanvas.style.height="100%",r.vjCanvas.style.position="absolute",r.vjCanvas.style.backgroundColor="transparent",r.vjCanvas.style.top="0px",r.vjCanvas.style.left="0px",r.vjCanvas.style.zIndex="5",r.vjCanvas.style.msTouchAction="none",r.vjCanvas.setAttribute("touch-action","none");var i=r.vjCanvas.getContext("2d");if(!i)throw new Error("Unable to create canvas for virtual joystick");(r.vjCanvasContext=i).strokeStyle="#ffffff",r.vjCanvasContext.lineWidth=2,document.body.appendChild(r.vjCanvas)}r.halfWidth=r.vjCanvas.width/2,this.pressed=!1,this._joystickColor="cyan",this._joystickPointerID=-1,this._joystickPointerPos=new n.Vector2(0,0),this._joystickPreviousPointerPos=new n.Vector2(0,0),this._joystickPointerStartPos=new n.Vector2(0,0),this._deltaJoystickVector=new n.Vector2(0,0),this._onPointerDownHandlerRef=function(e){t._onPointerDown(e)},this._onPointerMoveHandlerRef=function(e){t._onPointerMove(e)},this._onPointerUpHandlerRef=function(e){t._onPointerUp(e)},r.vjCanvas.addEventListener("pointerdown",this._onPointerDownHandlerRef,!1),r.vjCanvas.addEventListener("pointermove",this._onPointerMoveHandlerRef,!1),r.vjCanvas.addEventListener("pointerup",this._onPointerUpHandlerRef,!1),r.vjCanvas.addEventListener("pointerout",this._onPointerUpHandlerRef,!1),r.vjCanvas.addEventListener("contextmenu",(function(e){e.preventDefault()}),!1),requestAnimationFrame((function(){t._drawVirtualJoystick()}))}return r.prototype.setJoystickSensibility=function(e){this._joystickSensibility=e,this._inversedSensibility=1/(this._joystickSensibility/1e3)},r.prototype._onPointerDown=function(e){e.preventDefault(),(!0===this._leftJoystick?e.clientX<r.halfWidth:e.clientX>r.halfWidth)&&this._joystickPointerID<0?(this._joystickPointerID=e.pointerId,this._joystickPointerStartPos.x=e.clientX,this._joystickPointerStartPos.y=e.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(e.pointerId.toString(),e)):r._globalJoystickIndex<2&&this._action&&(this._action(),this._touches.add(e.pointerId.toString(),{x:e.clientX,y:e.clientY,prevX:e.clientX,prevY:e.clientY}))},r.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 o.X:this.deltaPosition.x=Math.min(1,Math.max(-1,t));break;case o.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,t));break;case o.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,t))}var i=(this.reverseUpDown?1:-1)*this._deltaJoystickVector.y/this._inversedSensibility;switch(this._axisTargetedByUpAndDown){case o.X:this.deltaPosition.x=Math.min(1,Math.max(-1,i));break;case o.Y:this.deltaPosition.y=Math.min(1,Math.max(-1,i));break;case o.Z:this.deltaPosition.z=Math.min(1,Math.max(-1,i))}}else{var r=this._touches.get(e.pointerId.toString());r&&(r.x=e.clientX,r.y=e.clientY)}},r.prototype._onPointerUp=function(e){if(this._joystickPointerID==e.pointerId)r.vjCanvasContext.clearRect(this._joystickPointerStartPos.x-64,this._joystickPointerStartPos.y-64,128,128),r.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x-42,this._joystickPreviousPointerPos.y-42,84,84),this._joystickPointerID=-1,this.pressed=!1;else{var t=this._touches.get(e.pointerId.toString());t&&r.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88)}this._deltaJoystickVector.x=0,this._deltaJoystickVector.y=0,this._touches.remove(e.pointerId.toString())},r.prototype.setJoystickColor=function(e){this._joystickColor=e},r.prototype.setActionOnTouch=function(e){this._action=e},r.prototype.setAxisForLeftRight=function(e){switch(e){case o.X:case o.Y:case o.Z:this._axisTargetedByLeftAndRight=e;break;default:this._axisTargetedByLeftAndRight=o.X}},r.prototype.setAxisForUpDown=function(e){switch(e){case o.X:case o.Y:case o.Z:this._axisTargetedByUpAndDown=e;break;default:this._axisTargetedByUpAndDown=o.Y}},r.prototype._drawVirtualJoystick=function(){var i=this;this.pressed&&this._touches.forEach((function(e,t){t.pointerId===i._joystickPointerID?(r.vjCanvasContext.clearRect(i._joystickPointerStartPos.x-64,i._joystickPointerStartPos.y-64,128,128),r.vjCanvasContext.clearRect(i._joystickPreviousPointerPos.x-42,i._joystickPreviousPointerPos.y-42,84,84),r.vjCanvasContext.beginPath(),r.vjCanvasContext.lineWidth=6,r.vjCanvasContext.strokeStyle=i._joystickColor,r.vjCanvasContext.arc(i._joystickPointerStartPos.x,i._joystickPointerStartPos.y,40,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath(),r.vjCanvasContext.beginPath(),r.vjCanvasContext.strokeStyle=i._joystickColor,r.vjCanvasContext.lineWidth=2,r.vjCanvasContext.arc(i._joystickPointerStartPos.x,i._joystickPointerStartPos.y,60,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath(),r.vjCanvasContext.beginPath(),r.vjCanvasContext.strokeStyle=i._joystickColor,r.vjCanvasContext.arc(i._joystickPointerPos.x,i._joystickPointerPos.y,40,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath(),i._joystickPreviousPointerPos=i._joystickPointerPos.clone()):(r.vjCanvasContext.clearRect(t.prevX-44,t.prevY-44,88,88),r.vjCanvasContext.beginPath(),r.vjCanvasContext.fillStyle="white",r.vjCanvasContext.beginPath(),r.vjCanvasContext.strokeStyle="red",r.vjCanvasContext.lineWidth=6,r.vjCanvasContext.arc(t.x,t.y,40,0,2*Math.PI,!0),r.vjCanvasContext.stroke(),r.vjCanvasContext.closePath(),t.prevX=t.x,t.prevY=t.y)})),requestAnimationFrame((function(){i._drawVirtualJoystick()}))},r.prototype.releaseCanvas=function(){r.vjCanvas&&(r.vjCanvas.removeEventListener("pointerdown",this._onPointerDownHandlerRef),r.vjCanvas.removeEventListener("pointermove",this._onPointerMoveHandlerRef),r.vjCanvas.removeEventListener("pointerup",this._onPointerUpHandlerRef),r.vjCanvas.removeEventListener("pointerout",this._onPointerUpHandlerRef),window.removeEventListener("resize",this._onResize),document.body.removeChild(r.vjCanvas),r.vjCanvas=null)},r._globalJoystickIndex=0,r})();n.VirtualJoystick=t})($a||($a={})),(function(i){i.Node.AddNodeConstructor("VirtualJoysticksCamera",(function(e,t){return function(){return new r(e,i.Vector3.Zero(),t)}}));var r=(function(n){function e(e,t,i){var r=n.call(this,e,t,i)||this;return r.inputs.addVirtualJoystick(),r}return T(e,n),e.prototype.getClassName=function(){return"VirtualJoysticksCamera"},e})(i.FreeCamera);i.VirtualJoysticksCamera=r})($a||($a={})),ia=$a||($a={}),ra=(function(){function e(){}return e.prototype.getLeftJoystick=function(){return this._leftjoystick},e.prototype.getRightJoystick=function(){return this._rightjoystick},e.prototype.checkInputs=function(){if(this._leftjoystick){var e=this.camera,t=50*e._computeLocalCameraSpeed(),i=ia.Matrix.RotationYawPitchRoll(e.rotation.y,e.rotation.x,0),r=ia.Vector3.TransformCoordinates(new ia.Vector3(this._leftjoystick.deltaPosition.x*t,this._leftjoystick.deltaPosition.y*t,this._leftjoystick.deltaPosition.z*t),i);e.cameraDirection=e.cameraDirection.add(r),e.cameraRotation=e.cameraRotation.addVector3(this._rightjoystick.deltaPosition),this._leftjoystick.pressed||(this._leftjoystick.deltaPosition=this._leftjoystick.deltaPosition.scale(.9)),this._rightjoystick.pressed||(this._rightjoystick.deltaPosition=this._rightjoystick.deltaPosition.scale(.9))}},e.prototype.attachControl=function(e,t){this._leftjoystick=new ia.VirtualJoystick(!0),this._leftjoystick.setAxisForUpDown(ia.JoystickAxis.Z),this._leftjoystick.setAxisForLeftRight(ia.JoystickAxis.X),this._leftjoystick.setJoystickSensibility(.15),this._rightjoystick=new ia.VirtualJoystick(!1),this._rightjoystick.setAxisForUpDown(ia.JoystickAxis.X),this._rightjoystick.setAxisForLeftRight(ia.JoystickAxis.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})(),ia.FreeCameraVirtualJoystickInput=ra,ia.CameraInputTypes.FreeCameraVirtualJoystickInput=ra,(function(b){var e=function(e,t,i){this.quality=e,this.distance=t,this.optimizeMesh=i};b.SimplificationSettings=e;var t,i,r=(function(){function e(){this.running=!1,this._simplificationArray=[]}return e.prototype.addTask=function(e){this._simplificationArray.push(e)},e.prototype.executeNext=function(){var e=this._simplificationArray.pop();e?(this.running=!0,this.runSimplification(e)):this.running=!1},e.prototype.runSimplification=function(r){var i=this;if(r.parallelProcessing)r.settings.forEach((function(t){i.getSimplifier(r).simplify(t,(function(e){r.mesh.addLODLevel(t.distance,e),e.isVisible=!0,t.quality===r.settings[r.settings.length-1].quality&&r.successCallback&&r.successCallback(),i.executeNext()}))}));else{var n=this.getSimplifier(r);b.AsyncLoop.Run(r.settings.length,(function(e){var t,i;t=r.settings[e.index],i=function(){e.executeNext()},n.simplify(t,(function(e){r.mesh.addLODLevel(t.distance,e),e.isVisible=!0,i()}))}),(function(){r.successCallback&&r.successCallback(),i.executeNext()}))}},e.prototype.getSimplifier=function(e){switch(e.simplificationType){case t.QUADRATIC:default:return new o(e.mesh)}},e})();b.SimplificationQueue=r,(i=t=b.SimplificationType||(b.SimplificationType={}))[i.QUADRATIC=0]="QUADRATIC";var f=function(e){this.vertices=e,this.error=new Array(4),this.deleted=!1,this.isDirty=!1,this.deletePending=!1,this.borderFactor=0},s=(function(){function e(e,t){this.position=e,this.id=t,this.isBorder=!0,this.q=new n,this.triangleCount=0,this.triangleStart=0,this.originalOffsets=[]}return e.prototype.updatePosition=function(e){this.position.copyFrom(e)},e})(),n=(function(){function n(e){this.data=new Array(10);for(var t=0;t<10;++t)e&&e[t]?this.data[t]=e[t]:this.data[t]=0}return n.prototype.det=function(e,t,i,r,n,o,s,a,l){return this.data[e]*this.data[n]*this.data[l]+this.data[i]*this.data[r]*this.data[a]+this.data[t]*this.data[o]*this.data[s]-this.data[i]*this.data[n]*this.data[s]-this.data[e]*this.data[o]*this.data[a]-this.data[t]*this.data[r]*this.data[l]},n.prototype.addInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e.data[t]},n.prototype.addArrayInPlace=function(e){for(var t=0;t<10;++t)this.data[t]+=e[t]},n.prototype.add=function(e){for(var t=new n,i=0;i<10;++i)t.data[i]=this.data[i]+e.data[i];return t},n.FromData=function(e,t,i,r){return new n(n.DataFromNumbers(e,t,i,r))},n.DataFromNumbers=function(e,t,i,r){return[e*e,e*t,e*i,e*r,t*t,t*i,t*r,i*i,i*r,r*r]},n})(),l=function(e,t){this.vertexId=e,this.triangleId=t},o=(function(){function e(e){this._mesh=e,this.syncIterations=5e3,this.aggressiveness=7,this.decimationIterations=100,this.boundingBoxEpsilon=b.Epsilon}return e.prototype.simplify=function(t,e){var i=this;this.initDecimatedMesh(),b.AsyncLoop.Run(this._mesh.subMeshes.length,(function(e){i.initWithMesh(e.index,(function(){i.runDecimation(t,e.index,(function(){e.executeNext()}))}),t.optimizeMesh)}),(function(){setTimeout((function(){e(i._reconstructedMesh)}),0)}))},e.prototype.runDecimation=function(e,t,i){var v=this,r=~~(this.triangles.length*e.quality),y=0,n=this.triangles.length;b.AsyncLoop.Run(this.decimationIterations,(function(e){var t,i;n-y<=r?e.breakLoop():(t=e.index,i=function(){e.executeNext()},setTimeout((function(){t%5==0&&v.updateMesh(0===t);for(var e=0;e<v.triangles.length;++e)v.triangles[e].isDirty=!1;var g=1e-9*Math.pow(t+3,v.aggressiveness);b.AsyncLoop.SyncAsyncForLoop(v.triangles.length,v.syncIterations,(function(e){var t=~~((v.triangles.length/2+e)%v.triangles.length),i=v.triangles[t];if(i&&!(i.error[3]>g||i.deleted||i.isDirty))for(var r=0;r<3;++r)if(i.error[r]<g){var n=[],o=[],s=i.vertices[r],a=i.vertices[(r+1)%3];if(s.isBorder||a.isBorder)continue;var l=b.Vector3.Zero(),c=b.Vector3.Zero(),h=b.Vector2.Zero(),u=new b.Color4(0,0,0,1);v.calculateError(s,a,l,c,h,u);var d=new Array;if(v.isFlipped(s,a,l,n,i.borderFactor,d))continue;if(v.isFlipped(a,s,l,o,i.borderFactor,d))continue;if(n.indexOf(!0)<0||o.indexOf(!0)<0)continue;var f=new Array;if(d.forEach((function(e){-1===f.indexOf(e)&&(e.deletePending=!0,f.push(e))})),f.length%2!=0)continue;s.q=a.q.add(s.q),s.updatePosition(l);var p=v.references.length;y=v.updateTriangles(s,s,n,y),y=v.updateTriangles(s,a,o,y);var m=v.references.length-p;if(m<=s.triangleCount){if(m)for(var _=0;_<m;_++)v.references[s.triangleStart+_]=v.references[p+_]}else s.triangleStart=p;s.triangleCount=m;break}}),i,(function(){return n-y<=r}))}),0))}),(function(){setTimeout((function(){v.reconstructMesh(t),i()}),0)}))},e.prototype.initWithMesh=function(e,t,n){var c=this;this.vertices=[],this.triangles=[];var o=this._mesh.getVerticesData(b.VertexBuffer.PositionKind),h=this._mesh.getIndices(),u=this._mesh.subMeshes[e],d=[],i=u.verticesCount;b.AsyncLoop.SyncAsyncForLoop(i,this.syncIterations/4>>0,(function(e){if(o){var t=e+u.verticesStart,i=b.Vector3.FromArray(o,3*t),r=(function(e){if(n)for(var t=0;t<c.vertices.length;++t)if(c.vertices[t].position.equals(e))return c.vertices[t];return null})(i)||new s(i,c.vertices.length);r.originalOffsets.push(t),r.id===c.vertices.length&&c.vertices.push(r),d.push(r.id)}}),(function(){b.AsyncLoop.SyncAsyncForLoop(u.indexCount/3,c.syncIterations,(function(e){if(h){var t=3*(u.indexStart/3+e),i=h[t+0],r=h[t+1],n=h[t+2],o=c.vertices[d[i-u.verticesStart]],s=c.vertices[d[r-u.verticesStart]],a=c.vertices[d[n-u.verticesStart]],l=new f([o,s,a]);l.originalOffset=t,c.triangles.push(l)}}),(function(){c.init(t)}))}))},e.prototype.init=function(e){var r=this;b.AsyncLoop.SyncAsyncForLoop(this.triangles.length,this.syncIterations,(function(e){var t=r.triangles[e];t.normal=b.Vector3.Cross(t.vertices[1].position.subtract(t.vertices[0].position),t.vertices[2].position.subtract(t.vertices[0].position)).normalize();for(var i=0;i<3;i++)t.vertices[i].q.addArrayInPlace(n.DataFromNumbers(t.normal.x,t.normal.y,t.normal.z,-b.Vector3.Dot(t.normal,t.vertices[0].position)))}),(function(){b.AsyncLoop.SyncAsyncForLoop(r.triangles.length,r.syncIterations,(function(e){for(var t=r.triangles[e],i=0;i<3;++i)t.error[i]=r.calculateError(t.vertices[i],t.vertices[(i+1)%3]);t.error[3]=Math.min(t.error[0],t.error[1],t.error[2])}),(function(){e()}))}))},e.prototype.reconstructMesh=function(e){var t,r,i,n=[];for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleCount=0;for(t=0;t<this.triangles.length;++t)if(!this.triangles[t].deleted){for(r=this.triangles[t],i=0;i<3;++i)r.vertices[i].triangleCount=1;n.push(r)}var o=this._reconstructedMesh.getVerticesData(b.VertexBuffer.PositionKind)||[],s=this._reconstructedMesh.getVerticesData(b.VertexBuffer.NormalKind)||[],a=this._reconstructedMesh.getVerticesData(b.VertexBuffer.UVKind)||[],l=this._reconstructedMesh.getVerticesData(b.VertexBuffer.ColorKind)||[],c=this._mesh.getVerticesData(b.VertexBuffer.NormalKind),h=this._mesh.getVerticesData(b.VertexBuffer.UVKind),u=this._mesh.getVerticesData(b.VertexBuffer.ColorKind),d=0;for(t=0;t<this.vertices.length;++t){var f=this.vertices[t];f.id=d,f.triangleCount&&f.originalOffsets.forEach((function(e){c&&(o.push(f.position.x),o.push(f.position.y),o.push(f.position.z),s.push(c[3*e]),s.push(c[3*e+1]),s.push(c[3*e+2]),h&&h.length?(a.push(h[2*e]),a.push(h[2*e+1])):u&&u.length&&(l.push(u[4*e]),l.push(u[4*e+1]),l.push(u[4*e+2]),l.push(u[4*e+3])),++d)}))}var p=this._reconstructedMesh.getTotalIndices(),m=this._reconstructedMesh.getTotalVertices(),_=this._reconstructedMesh.subMeshes;this._reconstructedMesh.subMeshes=[];var g=this._reconstructedMesh.getIndices(),v=this._mesh.getIndices();for(t=0;t<n.length;++t)r=n[t],[0,1,2].forEach((function(e){var t=v[r.originalOffset+e],i=r.vertices[e].originalOffsets.indexOf(t);i<0&&(i=0),g.push(r.vertices[e].id+i+m)}));this._reconstructedMesh.setIndices(g),this._reconstructedMesh.setVerticesData(b.VertexBuffer.PositionKind,o),this._reconstructedMesh.setVerticesData(b.VertexBuffer.NormalKind,s),0<a.length&&this._reconstructedMesh.setVerticesData(b.VertexBuffer.UVKind,a),0<l.length&&this._reconstructedMesh.setVerticesData(b.VertexBuffer.ColorKind,l);var y=this._mesh.subMeshes[e];0<e&&(this._reconstructedMesh.subMeshes=[],_.forEach((function(e){b.SubMesh.AddToMesh(e.materialIndex,e.verticesStart,e.verticesCount,e.indexStart,e.indexCount,e.getMesh())})),b.SubMesh.AddToMesh(y.materialIndex,m,d,p,3*n.length,this._reconstructedMesh))},e.prototype.initDecimatedMesh=function(){this._reconstructedMesh=new b.Mesh(this._mesh.name+"Decimated",this._mesh.getScene()),this._reconstructedMesh.material=this._mesh.material,this._reconstructedMesh.parent=this._mesh.parent,this._reconstructedMesh.isVisible=!1,this._reconstructedMesh.renderingGroupId=this._mesh.renderingGroupId},e.prototype.isFlipped=function(e,t,i,r,n,o){for(var s=0;s<e.triangleCount;++s){var a=this.triangles[this.references[e.triangleStart+s].triangleId];if(!a.deleted){var l=this.references[e.triangleStart+s].vertexId,c=a.vertices[(l+1)%3],h=a.vertices[(l+2)%3];if(c!==t&&h!==t){var u=c.position.subtract(i);u=u.normalize();var d=h.position.subtract(i);if(d=d.normalize(),.999<Math.abs(b.Vector3.Dot(u,d)))return!0;var f=b.Vector3.Cross(u,d).normalize();if(r[s]=!1,b.Vector3.Dot(f,a.normal)<.2)return!0}else r[s]=!0,o.push(a)}}return!1},e.prototype.updateTriangles=function(e,t,i,r){for(var n=r,o=0;o<t.triangleCount;++o){var s=this.references[t.triangleStart+o],a=this.triangles[s.triangleId];a.deleted||(i[o]&&a.deletePending?(a.deleted=!0,n++):(a.vertices[s.vertexId]=e,a.isDirty=!0,a.error[0]=this.calculateError(a.vertices[0],a.vertices[1])+a.borderFactor/2,a.error[1]=this.calculateError(a.vertices[1],a.vertices[2])+a.borderFactor/2,a.error[2]=this.calculateError(a.vertices[2],a.vertices[0])+a.borderFactor/2,a.error[3]=Math.min(a.error[0],a.error[1],a.error[2]),this.references.push(s)))}return n},e.prototype.identifyBorder=function(){for(var e=0;e<this.vertices.length;++e){var t,i=[],r=[],n=this.vertices[e];for(t=0;t<n.triangleCount;++t)for(var o=this.triangles[this.references[n.triangleStart+t].triangleId],s=0;s<3;s++){for(var a=0,l=o.vertices[s];a<i.length&&r[a]!==l.id;)++a;a===i.length?(i.push(1),r.push(l.id)):i[a]++}for(t=0;t<i.length;++t)1===i[t]?this.vertices[r[t]].isBorder=!0:this.vertices[r[t]].isBorder=!1}},e.prototype.updateMesh=function(e){var t,i,r,n;if(void 0===e&&(e=!1),!e){var o=[];for(t=0;t<this.triangles.length;++t)this.triangles[t].deleted||o.push(this.triangles[t]);this.triangles=o}for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleCount=0,this.vertices[t].triangleStart=0;for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;r<3;++r)(n=i.vertices[r]).triangleCount++;var s=0;for(t=0;t<this.vertices.length;++t)this.vertices[t].triangleStart=s,s+=this.vertices[t].triangleCount,this.vertices[t].triangleCount=0;var a=new Array(3*this.triangles.length);for(t=0;t<this.triangles.length;++t)for(i=this.triangles[t],r=0;r<3;++r)a[(n=i.vertices[r]).triangleStart+n.triangleCount]=new l(r,t),n.triangleCount++;this.references=a,e&&this.identifyBorder()},e.prototype.vertexError=function(e,t){var i=t.x,r=t.y,n=t.z;return e.data[0]*i*i+2*e.data[1]*i*r+2*e.data[2]*i*n+2*e.data[3]*i+e.data[4]*r*r+2*e.data[5]*r*n+2*e.data[6]*r+e.data[7]*n*n+2*e.data[8]*n+e.data[9]},e.prototype.calculateError=function(e,t,i,r,n,o){var s=e.q.add(t.q),a=e.isBorder&&t.isBorder,l=0,c=s.det(0,1,2,1,4,5,2,5,7);if(0===c||a){var h=e.position.add(t.position).divide(new b.Vector3(2,2,2)),u=this.vertexError(s,e.position),d=this.vertexError(s,t.position),f=this.vertexError(s,h);(l=Math.min(u,d,f))===u?i&&i.copyFrom(e.position):l===d?i&&i.copyFrom(t.position):i&&i.copyFrom(h)}else i||(i=b.Vector3.Zero()),i.x=-1/c*s.det(1,2,3,4,5,6,5,7,8),i.y=1/c*s.det(0,2,3,1,5,6,2,7,8),i.z=-1/c*s.det(0,1,3,1,4,6,2,5,8),l=this.vertexError(s,i);return l},e})()})($a||($a={})),(function(n){Object.defineProperty(n.Scene.prototype,"simplificationQueue",{get:function(){if(!this._simplificationQueue){this._simplificationQueue=new n.SimplificationQueue;var e=this._getComponent(n.SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE);e||(e=new t(this),this._addComponent(e))}return this._simplificationQueue},set:function(e){this._simplificationQueue=e},enumerable:!0,configurable:!0}),n.Mesh.prototype.simplify=function(e,t,i,r){return void 0===t&&(t=!0),void 0===i&&(i=n.SimplificationType.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:e,parallelProcessing:t,mesh:this,simplificationType:i,successCallback:r}),this};var t=(function(){function e(e){this.name=n.SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE,this.scene=e}return e.prototype.register=function(){this.scene._beforeCameraUpdateStage.registerStep(n.SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE,this,this._beforeCameraUpdate)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype._beforeCameraUpdate=function(){this.scene._simplificationQueue&&!this.scene._simplificationQueue.running&&this.scene._simplificationQueue.executeNext()},e})();n.SimplicationQueueSceneComponent=t})($a||($a={})),na=function(e,t){this.distance=e,this.mesh=t},($a||($a={})).MeshLODLevel=na,(function(d){var e=(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})(),n=(function(n){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=1024),void 0===i&&(i=.5);var r=n.call(this,e)||this;return r.priority=e,r.maximumSize=t,r.step=i,r}return T(e,n),e.prototype.getDescription=function(){return"Reducing render target texture size to "+this.maximumSize},e.prototype.apply=function(e,t){for(var i=!0,r=0;r<e.textures.length;r++){var n=e.textures[r];if(n.canRescale&&!n.getContext){var o=n.getSize();Math.max(o.width,o.height)>this.maximumSize&&(n.scale(this.step),i=!1)}}return i},e})(d.SceneOptimization=e);d.TextureOptimization=n;var o=(function(n){function e(e,t,i){void 0===e&&(e=0),void 0===t&&(t=2),void 0===i&&(i=.25);var r=n.call(this,e)||this;return r.priority=e,r.maximumScale=t,r.step=i,r._currentScale=-1,r._directionOffset=1,r}return T(e,n),e.prototype.getDescription=function(){return"Setting hardware scaling level to "+this._currentScale},e.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},e})(e);d.HardwareScalingOptimization=o;var s=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.getDescription=function(){return"Turning shadows on/off"},t.prototype.apply=function(e,t){return e.shadowsEnabled=t.isInImprovementMode,!0},t})(e);d.ShadowsOptimization=s;var a=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(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})(e);d.PostProcessesOptimization=a;var l=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(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})(e);d.LensFlaresOptimization=l;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(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})(e);d.CustomOptimization=c;var h=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.getDescription=function(){return"Turning particles on/off"},t.prototype.apply=function(e,t){return e.particlesEnabled=t.isInImprovementMode,!0},t})(e);d.ParticlesOptimization=h;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return T(t,e),t.prototype.getDescription=function(){return"Turning render targets off"},t.prototype.apply=function(e,t){return e.renderTargetsEnabled=t.isInImprovementMode,!0},t})(e);d.RenderTargetsOptimization=u;var f=(function(t){function u(){var e=null!==t&&t.apply(this,arguments)||this;return e._canBeMerged=function(e){if(!(e instanceof d.Mesh))return!1;var t=e;return!t.isDisposed()&&(!(!t.isVisible||!t.isEnabled())&&(!(0<t.instances.length)&&(!t.skeleton&&!t.hasLODLevels)))},e}return T(u,t),Object.defineProperty(u,"UpdateSelectionTree",{get:function(){return u._UpdateSelectionTree},set:function(e){u._UpdateSelectionTree=e},enumerable:!0,configurable:!0}),u.prototype.getDescription=function(){return"Merging similar meshes together"},u.prototype.apply=function(e,t,i){for(var r=e.meshes.slice(0),n=r.length,o=0;o<n;o++){var s=new Array,a=r[o];if(this._canBeMerged(a)){s.push(a);for(var l=o+1;l<n;l++){var c=r[l];this._canBeMerged(c)&&(c.material===a.material&&c.checkCollisions===a.checkCollisions&&(s.push(c),n--,r.splice(l,1),l--))}s.length<2||d.Mesh.MergeMeshes(s,void 0,!0)}}var h=e;return h.createOrUpdateSelectionOctree&&(null!=i?i&&h.createOrUpdateSelectionOctree():u.UpdateSelectionTree&&h.createOrUpdateSelectionOctree()),!0},u._UpdateSelectionTree=!1,u})(e);d.MergeMeshesOptimization=f;var p=(function(){function r(e,t){void 0===e&&(e=60),void 0===t&&(t=2e3),this.targetFrameRate=e,this.trackerDuration=t,this.optimizations=new Array}return r.prototype.addOptimization=function(e){return this.optimizations.push(e),this},r.prototype.addCustomOptimization=function(e,t,i){void 0===i&&(i=0);var r=new c(i);return r.onApply=e,r.onGetDescription=t,this.optimizations.push(r),this},r.LowDegradationAllowed=function(e){var t=new r(e),i=0;return t.addOptimization(new f(i)),t.addOptimization(new s(i)),t.addOptimization(new l(i)),i++,t.addOptimization(new a(i)),t.addOptimization(new h(i)),i++,t.addOptimization(new n(i,1024)),t},r.ModerateDegradationAllowed=function(e){var t=new r(e),i=0;return t.addOptimization(new f(i)),t.addOptimization(new s(i)),t.addOptimization(new l(i)),i++,t.addOptimization(new a(i)),t.addOptimization(new h(i)),i++,t.addOptimization(new n(i,512)),i++,t.addOptimization(new u(i)),i++,t.addOptimization(new o(i,2)),t},r.HighDegradationAllowed=function(e){var t=new r(e),i=0;return t.addOptimization(new f(i)),t.addOptimization(new s(i)),t.addOptimization(new l(i)),i++,t.addOptimization(new a(i)),t.addOptimization(new h(i)),i++,t.addOptimization(new n(i,256)),i++,t.addOptimization(new u(i)),i++,t.addOptimization(new o(i,4)),t},r})();d.SceneOptimizerOptions=p;var t=(function(){function o(e,t,i,r){void 0===i&&(i=!0),void 0===r&&(r=!1);var n=this;if(this._isRunning=!1,this._currentPriorityLevel=0,this._targetFrameRate=60,this._trackerDuration=2e3,this._currentFrameRate=0,this._improvementMode=!1,this.onSuccessObservable=new d.Observable,this.onNewOptimizationAppliedObservable=new d.Observable,this.onFailureObservable=new d.Observable,this._options=t||new p,this._options.targetFrameRate&&(this._targetFrameRate=this._options.targetFrameRate),this._options.trackerDuration&&(this._trackerDuration=this._options.trackerDuration),i)for(var o=0,s=0,a=this._options.optimizations;s<a.length;s++){a[s].priority=o++}this._improvementMode=r,this._scene=e||d.Engine.LastCreatedScene,this._sceneDisposeObserver=this._scene.onDisposeObservable.add((function(){n._sceneDisposeObserver=null,n.dispose()}))}return Object.defineProperty(o.prototype,"isInImprovementMode",{get:function(){return this._improvementMode},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"currentPriorityLevel",{get:function(){return this._currentPriorityLevel},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"currentFrameRate",{get:function(){return this._currentFrameRate},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"targetFrameRate",{get:function(){return this._targetFrameRate},set:function(e){this._targetFrameRate=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"trackerDuration",{get:function(){return this._trackerDuration},set:function(e){this._trackerDuration=e},enumerable:!0,configurable:!0}),Object.defineProperty(o.prototype,"optimizations",{get:function(){return this._options.optimizations},enumerable:!0,configurable:!0}),o.prototype.stop=function(){this._isRunning=!1},o.prototype.reset=function(){this._currentPriorityLevel=0},o.prototype.start=function(){var e=this;this._isRunning||(this._isRunning=!0,this._scene.executeWhenReady((function(){setTimeout((function(){e._checkCurrentState()}),e._trackerDuration)})))},o.prototype._checkCurrentState=function(){var e=this;if(this._isRunning){var t=this._scene,i=this._options;if(this._currentFrameRate=Math.round(t.getEngine().getFps()),this._improvementMode&&this._currentFrameRate<=this._targetFrameRate||!this._improvementMode&&this._currentFrameRate>=this._targetFrameRate)return this._isRunning=!1,void this.onSuccessObservable.notifyObservers(this);for(var r=!0,n=!0,o=0;o<i.optimizations.length;o++){var s=i.optimizations[o];s.priority===this._currentPriorityLevel&&(n=!1,r=r&&s.apply(t,this),this.onNewOptimizationAppliedObservable.notifyObservers(s))}if(n)return this._isRunning=!1,void this.onFailureObservable.notifyObservers(this);r&&this._currentPriorityLevel++,t.executeWhenReady((function(){setTimeout((function(){e._checkCurrentState()}),e._trackerDuration)}))}},o.prototype.dispose=function(){this.stop(),this.onSuccessObservable.clear(),this.onFailureObservable.clear(),this.onNewOptimizationAppliedObservable.clear(),this._sceneDisposeObserver&&this._scene.onDisposeObservable.remove(this._sceneDisposeObserver)},o.OptimizeAsync=function(e,t,i,r){var n=new o(e,t||p.ModerateDegradationAllowed(),!1);return i&&n.onSuccessObservable.add((function(){i()})),r&&n.onFailureObservable.add((function(){r()})),n.start(),n},o})();d.SceneOptimizer=t})($a||($a={})),(function(h){h.Scene.prototype.getOutlineRenderer=function(){return this._outlineRenderer||(this._outlineRenderer=new e(this)),this._outlineRenderer},Object.defineProperty(h.AbstractMesh.prototype,"renderOutline",{get:function(){return this._renderOutline},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOutline=e},enumerable:!0,configurable:!0}),Object.defineProperty(h.AbstractMesh.prototype,"renderOverlay",{get:function(){return this._renderOverlay},set:function(e){e&&this.getScene().getOutlineRenderer(),this._renderOverlay=e},enumerable:!0,configurable:!0});var e=(function(){function e(e){this.name=h.SceneComponentConstants.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(h.SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE,this,this._beforeRenderingMesh),this.scene._afterRenderingMeshStage.registerStep(h.SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE,this,this._afterRenderingMesh)},e.prototype.rebuild=function(){},e.prototype.dispose=function(){},e.prototype.render=function(e,t,i){var r=this;void 0===i&&(i=!1);var n=this.scene,o=n.getEngine(),s=o.getCaps().instancedArrays&&null!==t.visibleInstances[e._id]&&void 0!==t.visibleInstances[e._id];if(this.isReady(e,s)){var a=e.getRenderingMesh(),l=e.getMaterial();if(l&&n.activeCamera){if(o.enableEffect(this._effect),l.useLogarithmicDepth&&this._effect.setFloat("logarithmicDepthConstant",2/(Math.log(n.activeCamera.maxZ+1)/Math.LN2)),this._effect.setFloat("offset",i?0:a.outlineWidth),this._effect.setColor4("color",i?a.overlayColor:a.outlineColor,i?a.overlayAlpha:l.alpha),this._effect.setMatrix("viewProjection",n.getTransformMatrix()),a.useBones&&a.computeBonesUsingShaders&&a.skeleton&&this._effect.setMatrices("mBones",a.skeleton.getTransformMatrices(a)),a._bind(e,this._effect,h.Material.TriangleFillMode),l&&l.needAlphaTesting()){var c=l.getAlphaTestTexture();c&&(this._effect.setTexture("diffuseSampler",c),this._effect.setMatrix("diffuseMatrix",c.getTextureMatrix()))}o.setZOffset(-this.zOffset),a._processRendering(e,this._effect,h.Material.TriangleFillMode,t,s,(function(e,t){r._effect.setMatrix("world",t)})),o.setZOffset(0)}}},e.prototype.isReady=function(e,t){var i=[],r=[h.VertexBuffer.PositionKind,h.VertexBuffer.NormalKind],n=e.getMesh(),o=e.getMaterial();o&&(o.needAlphaTesting()&&(i.push("#define ALPHATEST"),n.isVerticesDataPresent(h.VertexBuffer.UVKind)&&(r.push(h.VertexBuffer.UVKind),i.push("#define UV1")),n.isVerticesDataPresent(h.VertexBuffer.UV2Kind)&&(r.push(h.VertexBuffer.UV2Kind),i.push("#define UV2"))),o.useLogarithmicDepth&&i.push("#define LOGARITHMICDEPTH")),n.useBones&&n.computeBonesUsingShaders?(r.push(h.VertexBuffer.MatricesIndicesKind),r.push(h.VertexBuffer.MatricesWeightsKind),4<n.numBoneInfluencers&&(r.push(h.VertexBuffer.MatricesIndicesExtraKind),r.push(h.VertexBuffer.MatricesWeightsExtraKind)),i.push("#define NUM_BONE_INFLUENCERS "+n.numBoneInfluencers),i.push("#define BonesPerMesh "+(n.skeleton?n.skeleton.bones.length+1:0))):i.push("#define NUM_BONE_INFLUENCERS 0"),t&&(i.push("#define INSTANCES"),r.push("world0"),r.push("world1"),r.push("world2"),r.push("world3"));var s=i.join("\n");return this._cachedDefines!==s&&(this._cachedDefines=s,this._effect=this.scene.getEngine().createEffect("outline",r,["world","mBones","viewProjection","diffuseMatrix","offset","color","logarithmicDepthConstant"],["diffuseSampler"],s)),this._effect.isReady()},e.prototype._beforeRenderingMesh=function(e,t,i){this._savedDepthWrite=this._engine.getDepthWrite(),e.renderOutline&&(this._engine.setDepthWrite(!1),this.render(t,i),this._engine.setDepthWrite(this._savedDepthWrite))},e.prototype._afterRenderingMesh=function(e,t,i){if(e.renderOutline&&this._savedDepthWrite&&(this._engine.setDepthWrite(!0),this._engine.setColorWrite(!1),this.render(t,i),this._engine.setColorWrite(!0)),e.renderOverlay){var r=this._engine.getAlphaMode();this._engine.setAlphaMode(h.Engine.ALPHA_COMBINE),this.render(t,i,!0),this._engine.setAlphaMode(r)}},e})();h.OutlineRenderer=e})($a||($a={})),(function(y){y.AbstractMesh.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},y.AbstractMesh.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new i(this,e,t),this},Object.defineProperty(y.AbstractMesh.prototype,"edgesRenderer",{get:function(){return this._edgesRenderer},enumerable:!0,configurable:!0}),y.LinesMesh.prototype.enableEdgesRendering=function(e,t){return void 0===e&&(e=.95),void 0===t&&(t=!1),this.disableEdgesRendering(),this._edgesRenderer=new y.LineEdgesRenderer(this,e,t),this};var b=function(){this.edges=new Array,this.edgesConnectedCount=0},i=(function(){function e(e,t,i,r){void 0===t&&(t=.95),void 0===i&&(i=!1),void 0===r&&(r=!0);var n=this;this.edgesWidthScalerForOrthographic=1e3,this.edgesWidthScalerForPerspective=50,this._linesPositions=new Array,this._linesNormals=new Array,this._linesIndices=new Array,this._buffers={},this._checkVerticesInsteadOfIndices=!1,this.isEnabled=!0,this._source=e,this._checkVerticesInsteadOfIndices=i,this._epsilon=t,this._prepareRessources(),r&&this._generateEdgesLines(),this._meshRebuildObserver=this._source.onRebuildObservable.add((function(){n._rebuild()})),this._meshDisposeObserver=this._source.onDisposeObservable.add((function(){n.dispose()}))}return e.prototype._prepareRessources=function(){this._lineShader||(this._lineShader=new y.ShaderMaterial("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[y.VertexBuffer.PositionKind];e&&e._rebuild(),(e=this._buffers[y.VertexBuffer.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[y.VertexBuffer.PositionKind];e&&(e.dispose(),this._buffers[y.VertexBuffer.PositionKind]=null),(e=this._buffers[y.VertexBuffer.NormalKind])&&(e.dispose(),this._buffers[y.VertexBuffer.NormalKind]=null),this._source.getScene().getEngine()._releaseBuffer(this._ib),this._lineShader.dispose()},e.prototype._processEdgeForAdjacencies=function(e,t,i,r,n){return e===i&&t===r||e===r&&t===i?0:e===r&&t===n||e===n&&t===r?1:e===n&&t===i||e===i&&t===n?2:-1},e.prototype._processEdgeForAdjacenciesWithVertices=function(e,t,i,r,n){return e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(r)||e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(i)?0:e.equalsWithEpsilon(r)&&t.equalsWithEpsilon(n)||e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(r)?1:e.equalsWithEpsilon(n)&&t.equalsWithEpsilon(i)||e.equalsWithEpsilon(i)&&t.equalsWithEpsilon(n)?2:-1},e.prototype._checkEdge=function(e,t,i,r,n){var o;void 0===t?o=!0:o=y.Vector3.Dot(i[e],i[t])<this._epsilon;if(o){var s=this._linesPositions.length/3;r.subtract(n).normalize(),this._linesPositions.push(r.x),this._linesPositions.push(r.y),this._linesPositions.push(r.z),this._linesPositions.push(r.x),this._linesPositions.push(r.y),this._linesPositions.push(r.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(-1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(1),this._linesNormals.push(r.x),this._linesNormals.push(r.y),this._linesNormals.push(r.z),this._linesNormals.push(-1),this._linesNormals.push(r.x),this._linesNormals.push(r.y),this._linesNormals.push(r.z),this._linesNormals.push(1),this._linesIndices.push(s),this._linesIndices.push(s+1),this._linesIndices.push(s+2),this._linesIndices.push(s),this._linesIndices.push(s+2),this._linesIndices.push(s+3)}},e.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(y.VertexBuffer.PositionKind),t=this._source.getIndices();if(t&&e){var i,r,n=new Array,o=new Array;for(i=0;i<t.length;i+=3){r=new b;var s=t[i],a=t[i+1],l=t[i+2];r.p0=new y.Vector3(e[3*s],e[3*s+1],e[3*s+2]),r.p1=new y.Vector3(e[3*a],e[3*a+1],e[3*a+2]),r.p2=new y.Vector3(e[3*l],e[3*l+1],e[3*l+2]);var c=y.Vector3.Cross(r.p1.subtract(r.p0),r.p2.subtract(r.p1));c.normalize(),o.push(c),n.push(r)}for(i=0;i<n.length;i++){r=n[i];for(var h=i+1;h<n.length;h++){var u=n[h];if(3===r.edgesConnectedCount)break;if(3!==u.edgesConnectedCount)for(var d=t[3*h],f=t[3*h+1],p=t[3*h+2],m=0;m<3;m++){var _=0;if(void 0===r.edges[m]){switch(m){case 0:_=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p0,r.p1,u.p0,u.p1,u.p2):this._processEdgeForAdjacencies(t[3*i],t[3*i+1],d,f,p);break;case 1:_=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p1,r.p2,u.p0,u.p1,u.p2):this._processEdgeForAdjacencies(t[3*i+1],t[3*i+2],d,f,p);break;case 2:_=this._checkVerticesInsteadOfIndices?this._processEdgeForAdjacenciesWithVertices(r.p2,r.p0,u.p0,u.p1,u.p2):this._processEdgeForAdjacencies(t[3*i+2],t[3*i],d,f,p)}if(-1!==_&&(r.edges[m]=h,u.edges[_]=i,r.edgesConnectedCount++,u.edgesConnectedCount++,3===r.edgesConnectedCount))break}}}}for(i=0;i<n.length;i++){var g=n[i];this._checkEdge(i,g.edges[0],o,g.p0,g.p1),this._checkEdge(i,g.edges[1],o,g.p1,g.p2),this._checkEdge(i,g.edges[2],o,g.p2,g.p0)}var v=this._source.getScene().getEngine();this._buffers[y.VertexBuffer.PositionKind]=new y.VertexBuffer(v,this._linesPositions,y.VertexBuffer.PositionKind,!1),this._buffers[y.VertexBuffer.NormalKind]=new y.VertexBuffer(v,this._linesNormals,y.VertexBuffer.NormalKind,!1,!1,4),this._ib=v.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},e.prototype.isReady=function(){return this._lineShader.isReady()},e.prototype.render=function(){var e=this._source.getScene();if(this.isReady()&&e.activeCamera){var t=e.getEngine();this._lineShader._preBind(),1!==this._source.edgesColor.a?t.setAlphaMode(y.Engine.ALPHA_COMBINE):t.setAlphaMode(y.Engine.ALPHA_DISABLE),t.bindBuffers(this._buffers,this._ib,this._lineShader.getEffect()),e.resetCachedMaterial(),this._lineShader.setColor4("color",this._source.edgesColor),e.activeCamera.mode===y.Camera.ORTHOGRAPHIC_CAMERA?this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForOrthographic):this._lineShader.setFloat("width",this._source.edgesWidth/this.edgesWidthScalerForPerspective),this._lineShader.setFloat("aspectRatio",t.getAspectRatio(e.activeCamera)),this._lineShader.bind(this._source.getWorldMatrix()),t.drawElementsType(y.Material.TriangleFillMode,0,this._indicesCount),this._lineShader.unbind()}},e})();y.EdgesRenderer=i})($a||($a={})),oa=$a||($a={}),sa=function(){this.edges=new Array,this.edgesConnectedCount=0},aa=(function(n){function e(e,t,i){void 0===t&&(t=.95),void 0===i&&(i=!1);var r=n.call(this,e,t,i,!1)||this;return r._generateEdgesLines(),r}return T(e,n),e.prototype._checkEdge=function(e,t,i,r,n){var o=this._linesPositions.length/3;r.subtract(n).normalize(),this._linesPositions.push(r.x),this._linesPositions.push(r.y),this._linesPositions.push(r.z),this._linesPositions.push(r.x),this._linesPositions.push(r.y),this._linesPositions.push(r.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesPositions.push(n.x),this._linesPositions.push(n.y),this._linesPositions.push(n.z),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(-1),this._linesNormals.push(n.x),this._linesNormals.push(n.y),this._linesNormals.push(n.z),this._linesNormals.push(1),this._linesNormals.push(r.x),this._linesNormals.push(r.y),this._linesNormals.push(r.z),this._linesNormals.push(-1),this._linesNormals.push(r.x),this._linesNormals.push(r.y),this._linesNormals.push(r.z),this._linesNormals.push(1),this._linesIndices.push(o),this._linesIndices.push(o+1),this._linesIndices.push(o+2),this._linesIndices.push(o),this._linesIndices.push(o+2),this._linesIndices.push(o+3)},e.prototype._generateEdgesLines=function(){var e=this._source.getVerticesData(oa.VertexBuffer.PositionKind);if(this._source.getIndices()&&e){for(var t,i=new Array,r=new Array,n=0;n<e.length/3-1;n++){var o=new sa;o.p0=new oa.Vector3(e[3*n],e[3*n+1],e[3*n+2]),o.p1=new oa.Vector3(e[3*(n+1)],e[3*(n+1)+1],e[3*(n+1)+2]),i.push(o)}for(t=0;t<i.length;t++){var s=i[t];this._checkEdge(t,s.edges[0],r,s.p0,s.p1)}var a=this._source.getScene().getEngine();this._buffers[oa.VertexBuffer.PositionKind]=new oa.VertexBuffer(a,this._linesPositions,oa.VertexBuffer.PositionKind,!1),this._buffers[oa.VertexBuffer.NormalKind]=new oa.VertexBuffer(a,this._linesNormals,oa.VertexBuffer.NormalKind,!1,!1,4),this._ib=a.createIndexBuffer(this._linesIndices),this._indicesCount=this._linesIndices.length}},e})(oa.EdgesRenderer),oa.LineEdgesRenderer=aa,(function(s){s.AbstractScene.AddParser(s.SceneComponentConstants.NAME_EFFECTLAYER,(function(e,t,i,r){if(e.effectLayers){i.effectLayers||(i.effectLayers=new Array);for(var n=0;n<e.effectLayers.length;n++){var o=s.EffectLayer.Parse(e.effectLayers[n],t,r);i.effectLayers.push(o)}}})),s.AbstractScene.prototype.removeEffectLayer=function(e){var t=this.effectLayers.indexOf(e);return-1!==t&&this.effectLayers.splice(t,1),t},s.AbstractScene.prototype.addEffectLayer=function(e){this.effectLayers.push(e)};var e=(function(){function e(e){this.name=s.SceneComponentConstants.NAME_EFFECTLAYER,this._renderEffects=!1,this._needStencil=!1,this._previousStencilState=!1,this.scene=e,this._engine=e.getEngine(),e.effectLayers=new Array}return e.prototype.register=function(){this.scene._isReadyForMeshStage.registerStep(s.SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER,this,this._isReadyForMesh),this.scene._cameraDrawRenderTargetStage.registerStep(s.SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER,this,this._renderMainTexture),this.scene._beforeCameraDrawStage.registerStep(s.SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER,this,this._setStencil),this.scene._afterRenderingGroupDrawStage.registerStep(s.SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW,this,this._drawRenderingGroup),this.scene._afterCameraDrawStage.registerStep(s.SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER,this,this._setStencilBack),this.scene._afterCameraDrawStage.registerStep(s.SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW,this,this._drawCamera)},e.prototype.rebuild=function(){for(var e=0,t=this.scene.effectLayers;e<t.length;e++){t[e]._rebuild()}},e.prototype.serialize=function(e){e.effectLayers=[];for(var t=0,i=this.scene.effectLayers;t<i.length;t++){var r=i[t];r.serialize&&e.effectLayers.push(r.serialize())}},e.prototype.addFromContainer=function(e){var t=this;e.effectLayers&&e.effectLayers.forEach((function(e){t.scene.addEffectLayer(e)}))},e.prototype.removeFromContainer=function(e){var t=this;e.effectLayers&&e.effectLayers.forEach((function(e){t.scene.removeEffectLayer(e)}))},e.prototype.dispose=function(){for(var e=this.scene.effectLayers;e.length;)e[0].dispose()},e.prototype._isReadyForMesh=function(e,t){for(var i=0,r=this.scene.effectLayers;i<r.length;i++){var n=r[i];if(n.hasMesh(e))for(var o=0,s=e.subMeshes;o<s.length;o++){var a=s[o];if(!n.isReady(a,t))return!1}}return!0},e.prototype._renderMainTexture=function(e){this._renderEffects=!1,this._needStencil=!1;var t=this.scene.effectLayers;if(t&&0<t.length){this._previousStencilState=this._engine.getStencilBuffer();for(var i=0,r=t;i<r.length;i++){var n=r[i];if(n.shouldRender()&&(!n.camera||n.camera.cameraRigMode===s.Camera.RIG_MODE_NONE&&e===n.camera||n.camera.cameraRigMode!==s.Camera.RIG_MODE_NONE&&-1<n.camera._rigCameras.indexOf(e))){this._renderEffects=!0,this._needStencil=this._needStencil||n.needStencil();var o=n._mainTexture;o._shouldRender()&&(this.scene.incrementRenderId(),o.render(!1,!1))}}this.scene.incrementRenderId()}},e.prototype._setStencil=function(e){this._needStencil&&this._engine.setStencilBuffer(!0)},e.prototype._setStencilBack=function(e){this._needStencil&&this._engine.setStencilBuffer(this._previousStencilState)},e.prototype._draw=function(e){if(this._renderEffects){this._engine.setDepthBuffer(!1);for(var t=this.scene.effectLayers,i=0;i<t.length;i++){var r=t[i];r.renderingGroupId===e&&r.shouldRender()&&r.render()}this._engine.setDepthBuffer(!0)}},e.prototype._drawCamera=function(e){this._renderEffects&&this._draw(-1)},e.prototype._drawRenderingGroup=function(e){!this.scene._isInIntermediateRendering()&&this._renderEffects&&this._draw(e)},e})();s.EffectLayerSceneComponent=e})($a||($a={}));var la,ca,ha,ua,da,fa,pa,ma,_a,ga,va,ya,ba,Ta,xa,Ea,Aa,Pa,Sa,Ra,Ma,Ca,Oa,Da,Ia,wa,La,Fa,Ba;ae=this&&this.__assign||function(){return(ae=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};la=$a||($a={}),ca=(function(){function e(e,t){this._vertexBuffers={},this._maxSize=0,this._mainTextureDesiredSize={width:0,height:0},this._shouldRender=!0,this._postProcesses=[],this._textures=[],this._emissiveTextureAndColor={texture:null,color:new la.Color4},this.neutralColor=new la.Color4,this.isEnabled=!0,this.onDisposeObservable=new la.Observable,this.onBeforeRenderMainTextureObservable=new la.Observable,this.onBeforeComposeObservable=new la.Observable,this.onAfterComposeObservable=new la.Observable,this.onSizeChangedObservable=new la.Observable,this.name=e,this._scene=t||la.Engine.LastCreatedScene;var i=this._scene._getComponent(la.SceneComponentConstants.NAME_EFFECTLAYER);i||(i=new la.EffectLayerSceneComponent(this._scene),this._scene._addComponent(i)),this._engine=this._scene.getEngine(),this._maxSize=this._engine.getCaps().maxTextureSize,this._scene.effectLayers.push(this),this._generateIndexBuffer(),this._genrateVertexBuffer()}return Object.defineProperty(e.prototype,"camera",{get:function(){return this._effectLayerOptions.camera},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"renderingGroupId",{get:function(){return this._effectLayerOptions.renderingGroupId},enumerable:!0,configurable:!0}),e.prototype._init=function(e){this._effectLayerOptions=ae({mainTextureRatio:.5,alphaBlendingMode:la.Engine.ALPHA_COMBINE,camera:null,renderingGroupId:-1},e),this._setMainTextureSize(),this._createMainTexture(),this._createTextureAndPostProcesses(),this._mergeEffect=this._createMergeEffect()},e.prototype._generateIndexBuffer=function(){var e=[];e.push(0),e.push(1),e.push(2),e.push(0),e.push(2),e.push(3),this._indexBuffer=this._engine.createIndexBuffer(e)},e.prototype._genrateVertexBuffer=function(){var e=[];e.push(1,1),e.push(-1,1),e.push(-1,-1),e.push(1,-1);var t=new la.VertexBuffer(this._engine,e,la.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[la.VertexBuffer.PositionKind]=t},e.prototype._setMainTextureSize=function(){this._effectLayerOptions.mainTextureFixedSize?(this._mainTextureDesiredSize.width=this._effectLayerOptions.mainTextureFixedSize,this._mainTextureDesiredSize.height=this._effectLayerOptions.mainTextureFixedSize):(this._mainTextureDesiredSize.width=this._engine.getRenderWidth()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.height=this._engine.getRenderHeight()*this._effectLayerOptions.mainTextureRatio,this._mainTextureDesiredSize.width=this._engine.needPOTTextures?la.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.width,this._maxSize):this._mainTextureDesiredSize.width,this._mainTextureDesiredSize.height=this._engine.needPOTTextures?la.Tools.GetExponentOfTwo(this._mainTextureDesiredSize.height,this._maxSize):this._mainTextureDesiredSize.height),this._mainTextureDesiredSize.width=Math.floor(this._mainTextureDesiredSize.width),this._mainTextureDesiredSize.height=Math.floor(this._mainTextureDesiredSize.height)},e.prototype._createMainTexture=function(){var s=this;this._mainTexture=new la.RenderTargetTexture("HighlightLayerMainRTT",{width:this._mainTextureDesiredSize.width,height:this._mainTextureDesiredSize.height},this._scene,!1,!0,la.Engine.TEXTURETYPE_UNSIGNED_INT),this._mainTexture.activeCamera=this._effectLayerOptions.camera,this._mainTexture.wrapU=la.Texture.CLAMP_ADDRESSMODE,this._mainTexture.wrapV=la.Texture.CLAMP_ADDRESSMODE,this._mainTexture.anisotropicFilteringLevel=1,this._mainTexture.updateSamplingMode(la.Texture.BILINEAR_SAMPLINGMODE),this._mainTexture.renderParticles=!1,this._mainTexture.renderList=null,this._mainTexture.ignoreCameraViewport=!0,this._mainTexture.customRenderFunction=function(e,t,i,r){var n;s.onBeforeRenderMainTextureObservable.notifyObservers(s);var o=s._scene.getEngine();if(r.length){for(o.setColorWrite(!1),n=0;n<r.length;n++)s._renderSubMesh(r.data[n]);o.setColorWrite(!0)}for(n=0;n<e.length;n++)s._renderSubMesh(e.data[n]);for(n=0;n<t.length;n++)s._renderSubMesh(t.data[n]);for(n=0;n<i.length;n++)s._renderSubMesh(i.data[n])},this._mainTexture.onClearObservable.add((function(e){e.clear(s.neutralColor,!0,!0,!0)}))},e.prototype._isReady=function(e,t,i){var r=e.getMaterial();if(!r)return!1;if(!r.isReady(e.getMesh(),t))return!1;var n=[],o=[la.VertexBuffer.PositionKind],s=e.getMesh(),a=!1,l=!1;if(r&&r.needAlphaTesting()){var c=r.getAlphaTestTexture();c&&(n.push("#define ALPHATEST"),s.isVerticesDataPresent(la.VertexBuffer.UV2Kind)&&1===c.coordinatesIndex?(n.push("#define DIFFUSEUV2"),l=!0):s.isVerticesDataPresent(la.VertexBuffer.UVKind)&&(n.push("#define DIFFUSEUV1"),a=!0))}i&&(n.push("#define EMISSIVE"),s.isVerticesDataPresent(la.VertexBuffer.UV2Kind)&&1===i.coordinatesIndex?(n.push("#define EMISSIVEUV2"),l=!0):s.isVerticesDataPresent(la.VertexBuffer.UVKind)&&(n.push("#define EMISSIVEUV1"),a=!0)),a&&(o.push(la.VertexBuffer.UVKind),n.push("#define UV1")),l&&(o.push(la.VertexBuffer.UV2Kind),n.push("#define UV2")),s.useBones&&s.computeBonesUsingShaders?(o.push(la.VertexBuffer.MatricesIndicesKind),o.push(la.VertexBuffer.MatricesWeightsKind),4<s.numBoneInfluencers&&(o.push(la.VertexBuffer.MatricesIndicesExtraKind),o.push(la.VertexBuffer.MatricesWeightsExtraKind)),n.push("#define NUM_BONE_INFLUENCERS "+s.numBoneInfluencers),n.push("#define BonesPerMesh "+(s.skeleton?s.skeleton.bones.length+1:0))):n.push("#define NUM_BONE_INFLUENCERS 0");var h=s.morphTargetManager,u=0;h&&0<h.numInfluencers&&(n.push("#define MORPHTARGETS"),u=h.numInfluencers,n.push("#define NUM_MORPH_INFLUENCERS "+u),la.MaterialHelper.PrepareAttributesForMorphTargets(o,s,{NUM_MORPH_INFLUENCERS:u})),t&&(n.push("#define INSTANCES"),o.push("world0"),o.push("world1"),o.push("world2"),o.push("world3"));var d=n.join("\n");return this._cachedDefines!==d&&(this._cachedDefines=d,this._effectLayerMapGenerationEffect=this._scene.getEngine().createEffect("glowMapGeneration",o,["world","mBones","viewProjection","diffuseMatrix","color","emissiveMatrix","morphTargetInfluences"],["diffuseSampler","emissiveSampler"],d,void 0,void 0,void 0,{maxSimultaneousMorphTargets:u})),this._effectLayerMapGenerationEffect.isReady()},e.prototype.render=function(){var e=this._mergeEffect;if(e.isReady()){for(var t=0;t<this._postProcesses.length;t++)if(!this._postProcesses[t].isReady())return;var i=this._scene.getEngine();this.onBeforeComposeObservable.notifyObservers(this),i.enableEffect(e),i.setState(!1),i.bindBuffers(this._vertexBuffers,this._indexBuffer,e);var r=i.getAlphaMode();i.setAlphaMode(this._effectLayerOptions.alphaBlendingMode),this._internalRender(e),i.setAlphaMode(r),this.onAfterComposeObservable.notifyObservers(this);var n=this._mainTexture.getSize();this._setMainTextureSize(),n.width===this._mainTextureDesiredSize.width&&n.height===this._mainTextureDesiredSize.height||(this.onSizeChangedObservable.notifyObservers(this),this._disposeTextureAndPostProcesses(),this._createMainTexture(),this._createTextureAndPostProcesses())}},e.prototype.hasMesh=function(e){return-1===this.renderingGroupId||e.renderingGroupId===this.renderingGroupId},e.prototype.shouldRender=function(){return this.isEnabled&&this._shouldRender},e.prototype._shouldRenderMesh=function(e){return!0},e.prototype._shouldRenderEmissiveTextureForMesh=function(e){return!0},e.prototype._renderSubMesh=function(e){var i=this;if(this.shouldRender()){var t=e.getMaterial(),r=e.getRenderingMesh(),n=this._scene,o=n.getEngine();if(t&&!t.needAlphaBlendingForMesh(r)){o.setState(t.backFaceCulling);var s=r._getInstancesRenderList(e._id);if(!s.mustReturn&&this._shouldRenderMesh(r)){var a=o.getCaps().instancedArrays&&null!==s.visibleInstances[e._id]&&void 0!==s.visibleInstances[e._id];if(this._setEmissiveTextureAndColor(r,e,t),this._isReady(e,a,this._emissiveTextureAndColor.texture)){if(o.enableEffect(this._effectLayerMapGenerationEffect),r._bind(e,this._effectLayerMapGenerationEffect,la.Material.TriangleFillMode),this._effectLayerMapGenerationEffect.setMatrix("viewProjection",n.getTransformMatrix()),this._effectLayerMapGenerationEffect.setFloat4("color",this._emissiveTextureAndColor.color.r,this._emissiveTextureAndColor.color.g,this._emissiveTextureAndColor.color.b,this._emissiveTextureAndColor.color.a),t&&t.needAlphaTesting()){var l=t.getAlphaTestTexture();if(l){this._effectLayerMapGenerationEffect.setTexture("diffuseSampler",l);var c=l.getTextureMatrix();c&&this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix",c)}}this._emissiveTextureAndColor.texture&&(this._effectLayerMapGenerationEffect.setTexture("emissiveSampler",this._emissiveTextureAndColor.texture),this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix",this._emissiveTextureAndColor.texture.getTextureMatrix())),r.useBones&&r.computeBonesUsingShaders&&r.skeleton&&this._effectLayerMapGenerationEffect.setMatrices("mBones",r.skeleton.getTransformMatrices(r)),la.MaterialHelper.BindMorphTargetParameters(r,this._effectLayerMapGenerationEffect),r._processRendering(e,this._effectLayerMapGenerationEffect,la.Material.TriangleFillMode,s,a,(function(e,t){return i._effectLayerMapGenerationEffect.setMatrix("world",t)}))}else this._mainTexture.resetRefreshCounter()}}}},e.prototype._rebuild=function(){var e=this._vertexBuffers[la.VertexBuffer.PositionKind];e&&e._rebuild(),this._generateIndexBuffer()},e.prototype._disposeTextureAndPostProcesses=function(){this._mainTexture.dispose();for(var e=0;e<this._postProcesses.length;e++)this._postProcesses[e]&&this._postProcesses[e].dispose();this._postProcesses=[];for(e=0;e<this._textures.length;e++)this._textures[e]&&this._textures[e].dispose();this._textures=[]},e.prototype.dispose=function(){var e=this._vertexBuffers[la.VertexBuffer.PositionKind];e&&(e.dispose(),this._vertexBuffers[la.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this._disposeTextureAndPostProcesses();var t=this._scene.effectLayers.indexOf(this,0);-1<t&&this._scene.effectLayers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onBeforeRenderMainTextureObservable.clear(),this.onBeforeComposeObservable.clear(),this.onAfterComposeObservable.clear(),this.onSizeChangedObservable.clear()},e.prototype.getClassName=function(){return"EffectLayer"},e.Parse=function(e,t,i){return la.Tools.Instantiate(e.customType).Parse(e,t,i)},b([la.serialize()],e.prototype,"name",void 0),b([la.serializeAsColor4()],e.prototype,"neutralColor",void 0),b([la.serialize()],e.prototype,"isEnabled",void 0),b([la.serializeAsCameraReference()],e.prototype,"camera",null),b([la.serialize()],e.prototype,"renderingGroupId",null),e})(),la.EffectLayer=ca,(function(h){h.AbstractScene.prototype.getHighlightLayerByName=function(e){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===e&&this.effectLayers[t].getEffectName()===i.EffectName)return this.effectLayers[t];return null};var n=(function(c){function e(e,t,i,r,n,o,s,a){void 0===o&&(o=h.Texture.BILINEAR_SAMPLINGMODE);var l=c.call(this,e,"glowBlurPostProcess",["screenSize","direction","blurWidth"],null,r,n,o,s,a)||this;return l.direction=t,l.kernel=i,l.onApplyObservable.add((function(e){e.setFloat2("screenSize",l.width,l.height),e.setVector2("direction",l.direction),e.setFloat("blurWidth",l.kernel)})),l}return T(e,c),e})(h.PostProcess),i=(function(s){function a(e,t,i){var r=s.call(this,e,t)||this;return r.name=e,r.innerGlow=!0,r.outerGlow=!0,r.onBeforeBlurObservable=new h.Observable,r.onAfterBlurObservable=new h.Observable,r._instanceGlowingMeshStencilReference=a.GlowingMeshStencilReference++,r._meshes={},r._excludedMeshes={},r.neutralColor=a.NeutralColor,r._engine.isStencilEnable||h.Tools.Warn("Rendering the Highlight Layer requires the stencil to be active on the canvas. var engine = new BABYLON.Engine(canvas, antialias, { stencil: true }"),r._options=ae({mainTextureRatio:.5,blurTextureSizeRatio:.5,blurHorizontalSize:1,blurVerticalSize:1,alphaBlendingMode:h.Engine.ALPHA_COMBINE,camera:null,renderingGroupId:-1},i),r._init({alphaBlendingMode:r._options.alphaBlendingMode,camera:r._options.camera,mainTextureFixedSize:r._options.mainTextureFixedSize,mainTextureRatio:r._options.mainTextureRatio,renderingGroupId:r._options.renderingGroupId}),r._shouldRender=!1,r}return T(a,s),Object.defineProperty(a.prototype,"blurHorizontalSize",{get:function(){return this._horizontalBlurPostprocess.kernel},set:function(e){this._horizontalBlurPostprocess.kernel=e},enumerable:!0,configurable:!0}),Object.defineProperty(a.prototype,"blurVerticalSize",{get:function(){return this._verticalBlurPostprocess.kernel},set:function(e){this._verticalBlurPostprocess.kernel=e},enumerable:!0,configurable:!0}),a.prototype.getEffectName=function(){return a.EffectName},a.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[h.VertexBuffer.PositionKind],["offset"],["textureSampler"],this._options.isStroke?"#define STROKE \n":void 0)},a.prototype._createTextureAndPostProcesses=function(){var t=this,i=this._mainTextureDesiredSize.width*this._options.blurTextureSizeRatio,r=this._mainTextureDesiredSize.height*this._options.blurTextureSizeRatio;i=this._engine.needPOTTextures?h.Tools.GetExponentOfTwo(i,this._maxSize):i,r=this._engine.needPOTTextures?h.Tools.GetExponentOfTwo(r,this._maxSize):r;var e=0;e=this._engine.getCaps().textureHalfFloatRender?h.Engine.TEXTURETYPE_HALF_FLOAT:h.Engine.TEXTURETYPE_UNSIGNED_INT,this._blurTexture=new h.RenderTargetTexture("HighlightLayerBlurRTT",{width:i,height:r},this._scene,!1,!0,e),this._blurTexture.wrapU=h.Texture.CLAMP_ADDRESSMODE,this._blurTexture.wrapV=h.Texture.CLAMP_ADDRESSMODE,this._blurTexture.anisotropicFilteringLevel=16,this._blurTexture.updateSamplingMode(h.Texture.TRILINEAR_SAMPLINGMODE),this._blurTexture.renderParticles=!1,this._blurTexture.ignoreCameraViewport=!0,this._textures=[this._blurTexture],this._options.alphaBlendingMode===h.Engine.ALPHA_COMBINE?(this._downSamplePostprocess=new h.PassPostProcess("HighlightLayerPPP",this._options.blurTextureSizeRatio,null,h.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._downSamplePostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._mainTexture)})),this._horizontalBlurPostprocess=new n("HighlightLayerHBP",new h.Vector2(1,0),this._options.blurHorizontalSize,1,null,h.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._horizontalBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",i,r)})),this._verticalBlurPostprocess=new n("HighlightLayerVBP",new h.Vector2(0,1),this._options.blurVerticalSize,1,null,h.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine()),this._verticalBlurPostprocess.onApplyObservable.add((function(e){e.setFloat2("screenSize",i,r)})),this._postProcesses=[this._downSamplePostprocess,this._horizontalBlurPostprocess,this._verticalBlurPostprocess]):(this._horizontalBlurPostprocess=new h.BlurPostProcess("HighlightLayerHBP",new h.Vector2(1,0),this._options.blurHorizontalSize/2,{width:i,height:r},null,h.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,e),this._horizontalBlurPostprocess.width=i,this._horizontalBlurPostprocess.height=r,this._horizontalBlurPostprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._mainTexture)})),this._verticalBlurPostprocess=new h.BlurPostProcess("HighlightLayerVBP",new h.Vector2(0,1),this._options.blurVerticalSize/2,{width:i,height:r},null,h.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,e),this._postProcesses=[this._horizontalBlurPostprocess,this._verticalBlurPostprocess]),this._mainTexture.onAfterUnbindObservable.add((function(){t.onBeforeBlurObservable.notifyObservers(t);var e=t._blurTexture.getInternalTexture();e&&t._scene.postProcessManager.directRender(t._postProcesses,e,!0),t.onAfterBlurObservable.notifyObservers(t)})),this._postProcesses.map((function(e){e.autoClear=!1}))},a.prototype.needStencil=function(){return!0},a.prototype.isReady=function(e,t){var i=e.getMaterial(),r=e.getRenderingMesh();if(!i||!r||!this._meshes)return!1;var n=null,o=this._meshes[r.uniqueId];return o&&o.glowEmissiveOnly&&i&&(n=i.emissiveTexture),s.prototype._isReady.call(this,e,t,n)},a.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture);var t=this._engine,i=t.getStencilBuffer(),r=t.getStencilFunction(),n=t.getStencilMask(),o=t.getStencilOperationPass(),s=t.getStencilOperationFail(),a=t.getStencilOperationDepthFail(),l=t.getStencilFunctionReference();t.setStencilOperationPass(h.Engine.REPLACE),t.setStencilOperationFail(h.Engine.KEEP),t.setStencilOperationDepthFail(h.Engine.KEEP),t.setStencilMask(0),t.setStencilBuffer(!0),t.setStencilFunctionReference(this._instanceGlowingMeshStencilReference),this.outerGlow&&(e.setFloat("offset",0),t.setStencilFunction(h.Engine.NOTEQUAL),t.drawElementsType(h.Material.TriangleFillMode,0,6)),this.innerGlow&&(e.setFloat("offset",1),t.setStencilFunction(h.Engine.EQUAL),t.drawElementsType(h.Material.TriangleFillMode,0,6)),t.setStencilFunction(r),t.setStencilMask(n),t.setStencilBuffer(i),t.setStencilOperationPass(o),t.setStencilOperationFail(s),t.setStencilOperationDepthFail(a),t.setStencilFunctionReference(l)},a.prototype.shouldRender=function(){return!!s.prototype.shouldRender.call(this)&&!!this._meshes},a.prototype._shouldRenderMesh=function(e){return(!this._excludedMeshes||!this._excludedMeshes[e.uniqueId])&&!!s.prototype.hasMesh.call(this,e)},a.prototype._setEmissiveTextureAndColor=function(e,t,i){var r=this._meshes[e.uniqueId];r?this._emissiveTextureAndColor.color.set(r.color.r,r.color.g,r.color.b,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a),r&&r.glowEmissiveOnly&&i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.color.set(1,1,1,1)):this._emissiveTextureAndColor.texture=null},a.prototype.addExcludedMesh=function(e){this._excludedMeshes&&(this._excludedMeshes[e.uniqueId]||(this._excludedMeshes[e.uniqueId]={mesh:e,beforeRender:e.onBeforeRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!1)})),afterRender:e.onAfterRenderObservable.add((function(e){e.getEngine().setStencilBuffer(!0)}))}))},a.prototype.removeExcludedMesh=function(e){if(this._excludedMeshes){var t=this._excludedMeshes[e.uniqueId];t&&(t.beforeRender&&e.onBeforeRenderObservable.remove(t.beforeRender),t.afterRender&&e.onAfterRenderObservable.remove(t.afterRender)),this._excludedMeshes[e.uniqueId]=null}},a.prototype.hasMesh=function(e){return!!this._meshes&&(!!s.prototype.hasMesh.call(this,e)&&(void 0!==this._meshes[e.uniqueId]&&null!==this._meshes[e.uniqueId]))},a.prototype.addMesh=function(e,t,i){var r=this;if(void 0===i&&(i=!1),this._meshes){var n=this._meshes[e.uniqueId];n?n.color=t:(this._meshes[e.uniqueId]={mesh:e,color:t,observerHighlight:e.onBeforeRenderObservable.add((function(e){r._excludedMeshes&&r._excludedMeshes[e.uniqueId]?r._defaultStencilReference(e):e.getScene().getEngine().setStencilFunctionReference(r._instanceGlowingMeshStencilReference)})),observerDefault:e.onAfterRenderObservable.add(this._defaultStencilReference),glowEmissiveOnly:i},e.onDisposeObservable.add((function(){r._disposeMesh(e)}))),this._shouldRender=!0}},a.prototype.removeMesh=function(e){if(this._meshes){var t=this._meshes[e.uniqueId];for(var i in t&&(t.observerHighlight&&e.onBeforeRenderObservable.remove(t.observerHighlight),t.observerDefault&&e.onAfterRenderObservable.remove(t.observerDefault),delete this._meshes[e.uniqueId]),this._shouldRender=!1,this._meshes)if(this._meshes[i]){this._shouldRender=!0;break}}},a.prototype._defaultStencilReference=function(e){e.getScene().getEngine().setStencilFunctionReference(a.NormalMeshStencilReference)},a.prototype._disposeMesh=function(e){this.removeMesh(e),this.removeExcludedMesh(e)},a.prototype.dispose=function(){if(this._meshes){for(var e in this._meshes){(t=this._meshes[e])&&t.mesh&&(t.observerHighlight&&t.mesh.onBeforeRenderObservable.remove(t.observerHighlight),t.observerDefault&&t.mesh.onAfterRenderObservable.remove(t.observerDefault))}this._meshes=null}if(this._excludedMeshes){for(var e in this._excludedMeshes){var t;(t=this._excludedMeshes[e])&&(t.beforeRender&&t.mesh.onBeforeRenderObservable.remove(t.beforeRender),t.afterRender&&t.mesh.onAfterRenderObservable.remove(t.afterRender))}this._excludedMeshes=null}s.prototype.dispose.call(this)},a.prototype.getClassName=function(){return"HighlightLayer"},a.prototype.serialize=function(){var e=h.SerializationHelper.Serialize(this);if(e.customType="BABYLON.HighlightLayer",e.meshes=[],this._meshes)for(var t in this._meshes){var i=this._meshes[t];i&&e.meshes.push({glowEmissiveOnly:i.glowEmissiveOnly,color:i.color.asArray(),meshId:i.mesh.id})}if(e.excludedMeshes=[],this._excludedMeshes)for(var r in this._excludedMeshes){var n=this._excludedMeshes[r];n&&e.excludedMeshes.push(n.mesh.id)}return e},a.Parse=function(e,t,i){var r,n=h.SerializationHelper.Parse((function(){return new a(e.name,t,e.options)}),e,t,i);for(r=0;r<e.excludedMeshes.length;r++){(o=t.getMeshByID(e.excludedMeshes[r]))&&n.addExcludedMesh(o)}for(r=0;r<e.meshes.length;r++){var o,s=e.meshes[r];(o=t.getMeshByID(s.meshId))&&n.addMesh(o,h.Color3.FromArray(s.color),s.glowEmissiveOnly)}return n},a.EffectName="HighlightLayer",a.NeutralColor=new h.Color4(0,0,0,0),a.GlowingMeshStencilReference=2,a.NormalMeshStencilReference=1,b([h.serialize()],a.prototype,"innerGlow",void 0),b([h.serialize()],a.prototype,"outerGlow",void 0),b([h.serialize()],a.prototype,"blurHorizontalSize",null),b([h.serialize()],a.prototype,"blurVerticalSize",null),b([h.serialize("options")],a.prototype,"_options",void 0),a})(h.EffectLayer);h.HighlightLayer=i})($a||($a={})),(function(a){a.AbstractScene.prototype.getGlowLayerByName=function(e){for(var t=0;t<this.effectLayers.length;t++)if(this.effectLayers[t].name===e&&this.effectLayers[t].getEffectName()===i.EffectName)return this.effectLayers[t];return null};var i=(function(o){function s(e,t,i){var r=o.call(this,e,t)||this;return r._intensity=1,r._includedOnlyMeshes=[],r._excludedMeshes=[],r.neutralColor=new a.Color4(0,0,0,1),r._options=ae({mainTextureRatio:s.DefaultTextureRatio,blurKernelSize:32,mainTextureFixedSize:void 0,camera:null,mainTextureSamples:1,renderingGroupId:-1},i),r._init({alphaBlendingMode:a.Engine.ALPHA_ADD,camera:r._options.camera,mainTextureFixedSize:r._options.mainTextureFixedSize,mainTextureRatio:r._options.mainTextureRatio,renderingGroupId:r._options.renderingGroupId}),r}return T(s,o),Object.defineProperty(s.prototype,"blurKernelSize",{get:function(){return this._horizontalBlurPostprocess1.kernel},set:function(e){this._horizontalBlurPostprocess1.kernel=e,this._verticalBlurPostprocess1.kernel=e,this._horizontalBlurPostprocess2.kernel=e,this._verticalBlurPostprocess2.kernel=e},enumerable:!0,configurable:!0}),Object.defineProperty(s.prototype,"intensity",{get:function(){return this._intensity},set:function(e){this._intensity=e},enumerable:!0,configurable:!0}),s.prototype.getEffectName=function(){return s.EffectName},s.prototype._createMergeEffect=function(){return this._engine.createEffect("glowMapMerge",[a.VertexBuffer.PositionKind],["offset"],["textureSampler","textureSampler2"],"#define EMISSIVE \n")},s.prototype._createTextureAndPostProcesses=function(){var t=this,e=this._mainTextureDesiredSize.width,i=this._mainTextureDesiredSize.height;e=this._engine.needPOTTextures?a.Tools.GetExponentOfTwo(e,this._maxSize):e,i=this._engine.needPOTTextures?a.Tools.GetExponentOfTwo(i,this._maxSize):i;var r=0;r=this._engine.getCaps().textureHalfFloatRender?a.Engine.TEXTURETYPE_HALF_FLOAT:a.Engine.TEXTURETYPE_UNSIGNED_INT,this._blurTexture1=new a.RenderTargetTexture("GlowLayerBlurRTT",{width:e,height:i},this._scene,!1,!0,r),this._blurTexture1.wrapU=a.Texture.CLAMP_ADDRESSMODE,this._blurTexture1.wrapV=a.Texture.CLAMP_ADDRESSMODE,this._blurTexture1.updateSamplingMode(a.Texture.BILINEAR_SAMPLINGMODE),this._blurTexture1.renderParticles=!1,this._blurTexture1.ignoreCameraViewport=!0;var n=Math.floor(e/2),o=Math.floor(i/2);this._blurTexture2=new a.RenderTargetTexture("GlowLayerBlurRTT2",{width:n,height:o},this._scene,!1,!0,r),this._blurTexture2.wrapU=a.Texture.CLAMP_ADDRESSMODE,this._blurTexture2.wrapV=a.Texture.CLAMP_ADDRESSMODE,this._blurTexture2.updateSamplingMode(a.Texture.BILINEAR_SAMPLINGMODE),this._blurTexture2.renderParticles=!1,this._blurTexture2.ignoreCameraViewport=!0,this._textures=[this._blurTexture1,this._blurTexture2],this._horizontalBlurPostprocess1=new a.BlurPostProcess("GlowLayerHBP1",new a.Vector2(1,0),this._options.blurKernelSize/2,{width:e,height:i},null,a.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._horizontalBlurPostprocess1.width=e,this._horizontalBlurPostprocess1.height=i,this._horizontalBlurPostprocess1.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._mainTexture)})),this._verticalBlurPostprocess1=new a.BlurPostProcess("GlowLayerVBP1",new a.Vector2(0,1),this._options.blurKernelSize/2,{width:e,height:i},null,a.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._horizontalBlurPostprocess2=new a.BlurPostProcess("GlowLayerHBP2",new a.Vector2(1,0),this._options.blurKernelSize/2,{width:n,height:o},null,a.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._horizontalBlurPostprocess2.width=n,this._horizontalBlurPostprocess2.height=o,this._horizontalBlurPostprocess2.onApplyObservable.add((function(e){e.setTexture("textureSampler",t._blurTexture1)})),this._verticalBlurPostprocess2=new a.BlurPostProcess("GlowLayerVBP2",new a.Vector2(0,1),this._options.blurKernelSize/2,{width:n,height:o},null,a.Texture.BILINEAR_SAMPLINGMODE,this._scene.getEngine(),!1,r),this._postProcesses=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1,this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._postProcesses1=[this._horizontalBlurPostprocess1,this._verticalBlurPostprocess1],this._postProcesses2=[this._horizontalBlurPostprocess2,this._verticalBlurPostprocess2],this._mainTexture.samples=this._options.mainTextureSamples,this._mainTexture.onAfterUnbindObservable.add((function(){var e=t._blurTexture1.getInternalTexture();e&&(t._scene.postProcessManager.directRender(t._postProcesses1,e,!0),(e=t._blurTexture2.getInternalTexture())&&t._scene.postProcessManager.directRender(t._postProcesses2,e,!0))})),this._postProcesses.map((function(e){e.autoClear=!1}))},s.prototype.isReady=function(e,t){var i=e.getMaterial(),r=e.getRenderingMesh();if(!i||!r)return!1;var n=i.emissiveTexture;return o.prototype._isReady.call(this,e,t,n)},s.prototype.needStencil=function(){return!1},s.prototype._internalRender=function(e){e.setTexture("textureSampler",this._blurTexture1),e.setTexture("textureSampler2",this._blurTexture2),e.setFloat("offset",this._intensity);var t=this._engine,i=t.getStencilBuffer();t.setStencilBuffer(!1),t.drawElementsType(a.Material.TriangleFillMode,0,6),t.setStencilBuffer(i)},s.prototype._setEmissiveTextureAndColor=function(e,t,i){var r=1;this.customEmissiveTextureSelector?this._emissiveTextureAndColor.texture=this.customEmissiveTextureSelector(e,t,i):i?(this._emissiveTextureAndColor.texture=i.emissiveTexture,this._emissiveTextureAndColor.texture&&(r=this._emissiveTextureAndColor.texture.level)):this._emissiveTextureAndColor.texture=null,this.customEmissiveColorSelector?this.customEmissiveColorSelector(e,t,i,this._emissiveTextureAndColor.color):i.emissiveColor?this._emissiveTextureAndColor.color.set(i.emissiveColor.r*r,i.emissiveColor.g*r,i.emissiveColor.b*r,1):this._emissiveTextureAndColor.color.set(this.neutralColor.r,this.neutralColor.g,this.neutralColor.b,this.neutralColor.a)},s.prototype._shouldRenderMesh=function(e){return this.hasMesh(e)},s.prototype.addExcludedMesh=function(e){-1===this._excludedMeshes.indexOf(e.uniqueId)&&this._excludedMeshes.push(e.uniqueId)},s.prototype.removeExcludedMesh=function(e){var t=this._excludedMeshes.indexOf(e.uniqueId);-1!==t&&this._excludedMeshes.splice(t,1)},s.prototype.addIncludedOnlyMesh=function(e){-1===this._includedOnlyMeshes.indexOf(e.uniqueId)&&this._includedOnlyMeshes.push(e.uniqueId)},s.prototype.removeIncludedOnlyMesh=function(e){var t=this._includedOnlyMeshes.indexOf(e.uniqueId);-1!==t&&this._includedOnlyMeshes.splice(t,1)},s.prototype.hasMesh=function(e){return!!o.prototype.hasMesh.call(this,e)&&(this._includedOnlyMeshes.length?-1!==this._includedOnlyMeshes.indexOf(e.uniqueId):!this._excludedMeshes.length||-1===this._excludedMeshes.indexOf(e.uniqueId))},s.prototype._disposeMesh=function(e){this.removeIncludedOnlyMesh(e),this.removeExcludedMesh(e)},s.prototype.getClassName=function(){return"GlowLayer"},s.prototype.serialize=function(){var e,t=a.SerializationHelper.Serialize(this);if(t.customType="BABYLON.GlowLayer",t.includedMeshes=[],this._includedOnlyMeshes.length)for(e=0;e<this._includedOnlyMeshes.length;e++){(i=this._scene.getMeshByUniqueID(this._includedOnlyMeshes[e]))&&t.includedMeshes.push(i.id)}if(t.excludedMeshes=[],this._excludedMeshes.length)for(e=0;e<this._excludedMeshes.length;e++){var i;(i=this._scene.getMeshByUniqueID(this._excludedMeshes[e]))&&t.excludedMeshes.push(i.id)}return t},s.Parse=function(e,t,i){var r,n=a.SerializationHelper.Parse((function(){return new s(e.name,t,e.options)}),e,t,i);for(r=0;r<e.excludedMeshes.length;r++){(o=t.getMeshByID(e.excludedMeshes[r]))&&n.addExcludedMesh(o)}for(r=0;r<e.includedMeshes.length;r++){var o;(o=t.getMeshByID(e.includedMeshes[r]))&&n.addIncludedOnlyMesh(o)}return n},s.EffectName="GlowLayer",s.DefaultBlurKernelSize=32,s.DefaultTextureRatio=.5,b([a.serialize()],s.prototype,"blurKernelSize",null),b([a.serialize()],s.prototype,"intensity",null),b([a.serialize("options")],s.prototype,"_options",void 0),s})(a.EffectLayer);a.GlowLayer=i})($a||($a={})),(function(a){var o,e;(e=o=a.AssetTaskState||(a.AssetTaskState={}))[e.INIT=0]="INIT",e[e.RUNNING=1]="RUNNING",e[e.DONE=2]="DONE",e[e.ERROR=3]="ERROR";var t=(function(){function e(e){this.name=e,this._isCompleted=!1,this._taskState=o.INIT}return Object.defineProperty(e.prototype,"isCompleted",{get:function(){return this._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"taskState",{get:function(){return this._taskState},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"errorObject",{get:function(){return this._errorObject},enumerable:!0,configurable:!0}),e.prototype._setErrorObject=function(e,t){this._errorObject||(this._errorObject={message:e,exception:t})},e.prototype.run=function(e,t,i){var r=this;this._taskState=o.RUNNING,this.runTask(e,(function(){r.onDoneCallback(t,i)}),(function(e,t){r.onErrorCallback(i,e,t)}))},e.prototype.runTask=function(e,t,i){throw new Error("runTask is not implemented")},e.prototype.reset=function(){this._taskState=o.INIT},e.prototype.onErrorCallback=function(e,t,i){this._taskState=o.ERROR,this._errorObject={message:t,exception:i},this.onError&&this.onError(this,t,i),e()},e.prototype.onDoneCallback=function(e,t){try{this._taskState=o.DONE,this._isCompleted=!0,this.onSuccess&&this.onSuccess(this),e()}catch(e){this.onErrorCallback(t,"Task is done, error executing success callback(s)",e)}},e})();a.AbstractAssetTask=t;var s=function(e,t,i){this.remainingCount=e,this.totalCount=t,this.task=i};a.AssetsProgressEvent=s;var l=(function(o){function e(e,t,i,r){var n=o.call(this,e)||this;return n.name=e,n.meshesNames=t,n.rootUrl=i,n.sceneFilename=r,n}return T(e,o),e.prototype.runTask=function(e,r,n){var o=this;a.SceneLoader.ImportMesh(this.meshesNames,this.rootUrl,this.sceneFilename,e,(function(e,t,i){o.loadedMeshes=e,o.loadedParticleSystems=t,o.loadedSkeletons=i,r()}),null,(function(e,t,i){n(t,i)}))},e})(t);a.MeshAssetTask=l;var r=(function(r){function e(e,t){var i=r.call(this,e)||this;return i.name=e,i.url=t,i}return T(e,r),e.prototype.runTask=function(e,t,i){var r=this;e._loadFile(this.url,(function(e){r.text=e,t()}),void 0,!1,!1,(function(e,t){e&&i(e.status+" "+e.statusText,t)}))},e})(t);a.TextFileAssetTask=r;var n=(function(r){function e(e,t){var i=r.call(this,e)||this;return i.name=e,i.url=t,i}return T(e,r),e.prototype.runTask=function(e,t,i){var r=this;e._loadFile(this.url,(function(e){r.data=e,t()}),void 0,!0,!0,(function(e,t){e&&i(e.status+" "+e.statusText,t)}))},e})(t);a.BinaryFileAssetTask=n;var c=(function(r){function e(e,t){var i=r.call(this,e)||this;return i.name=e,i.url=t,i}return T(e,r),e.prototype.runTask=function(e,t,i){var r=this,n=new Image;a.Tools.SetCorsBehavior(this.url,n),n.onload=function(){r.image=n,t()},n.onerror=function(e){i("Error loading image",e)},n.src=this.url},e})(t);a.ImageAssetTask=c;var h=(function(s){function e(e,t,i,r,n){void 0===n&&(n=a.Texture.TRILINEAR_SAMPLINGMODE);var o=s.call(this,e)||this;return o.name=e,o.url=t,o.noMipmap=i,o.invertY=r,o.samplingMode=n,o}return T(e,s),e.prototype.runTask=function(e,t,i){this.texture=new a.Texture(this.url,e,this.noMipmap,this.invertY,this.samplingMode,function(){t()},function(e,t){i(e,t)})},e})(t);a.TextureAssetTask=h;var u=(function(s){function e(e,t,i,r,n){var o=s.call(this,e)||this;return o.name=e,o.url=t,o.extensions=i,o.noMipmap=r,o.files=n,o}return T(e,s),e.prototype.runTask=function(e,t,i){this.texture=new a.CubeTexture(this.url,e,this.extensions,this.noMipmap,this.files,function(){t()},function(e,t){i(e,t)})},e})(t);a.CubeTextureAssetTask=u;var d=(function(l){function e(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var a=l.call(this,e)||this;return a.name=e,a.url=t,a.size=i,a.noMipmap=r,a.generateHarmonics=n,a.gammaSpace=o,a.reserved=s,a}return T(e,l),e.prototype.run=function(e,t,i){this.texture=new a.HDRCubeTexture(this.url,e,this.size,this.noMipmap,this.generateHarmonics,this.gammaSpace,this.reserved,function(){t()},function(e,t){i(e,t)})},e})(t);a.HDRCubeTextureAssetTask=d;var i=(function(){function e(e){this._isLoading=!1,this._tasks=new Array,this._waitingTasksCount=0,this._totalTasksCount=0,this.onTaskSuccessObservable=new a.Observable,this.onTaskErrorObservable=new a.Observable,this.onTasksDoneObservable=new a.Observable,this.onProgressObservable=new a.Observable,this.useDefaultLoadingScreen=!0,this._scene=e}return e.prototype.addMeshTask=function(e,t,i,r){var n=new l(e,t,i,r);return this._tasks.push(n),n},e.prototype.addTextFileTask=function(e,t){var i=new r(e,t);return this._tasks.push(i),i},e.prototype.addBinaryFileTask=function(e,t){var i=new n(e,t);return this._tasks.push(i),i},e.prototype.addImageTask=function(e,t){var i=new c(e,t);return this._tasks.push(i),i},e.prototype.addTextureTask=function(e,t,i,r,n){void 0===n&&(n=a.Texture.TRILINEAR_SAMPLINGMODE);var o=new h(e,t,i,r,n);return this._tasks.push(o),o},e.prototype.addCubeTextureTask=function(e,t,i,r,n){var o=new u(e,t,i,r,n);return this._tasks.push(o),o},e.prototype.addHDRCubeTextureTask=function(e,t,i,r,n,o,s){void 0===r&&(r=!1),void 0===n&&(n=!0),void 0===o&&(o=!1),void 0===s&&(s=!1);var a=new d(e,t,i,r,n,o,s);return this._tasks.push(a),a},e.prototype.removeTask=function(e){var t=this._tasks.indexOf(e);-1<t&&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 s(this._waitingTasksCount,this._totalTasksCount,e))}catch(e){a.Tools.Error("Error running progress callbacks."),console.log(e)}if(0===this._waitingTasksCount){try{this.onFinish&&this.onFinish(this._tasks);for(var t=this._tasks.slice(),i=0,r=t;i<r.length;i++){if((e=r[i]).taskState===o.DONE){var n=this._tasks.indexOf(e);-1<n&&this._tasks.splice(n,1)}}this.onTasksDoneObservable.notifyObservers(this._tasks)}catch(e){a.Tools.Error("Error running tasks-done callbacks."),console.log(e)}this._isLoading=!1,this._scene.getEngine().hideLoadingUI()}},e.prototype._runTask=function(i){var r=this,t=function(e,t){i._setErrorObject(e,t),r.onTaskError&&r.onTaskError(i),r.onTaskErrorObservable.notifyObservers(i),r._decreaseWaitingTasksCount(i)};i.run(this._scene,(function(){try{r.onTaskSuccess&&r.onTaskSuccess(i),r.onTaskSuccessObservable.notifyObservers(i),r._decreaseWaitingTasksCount(i)}catch(e){t("Error executing task success callbacks",e)}}),t)},e.prototype.reset=function(){return this._isLoading=!1,this._tasks=new Array,this},e.prototype.load=function(){if(this._isLoading)return this;if(this._isLoading=!0,this._waitingTasksCount=this._tasks.length,this._totalTasksCount=this._tasks.length,0===this._waitingTasksCount)return this._isLoading=!1,this.onFinish&&this.onFinish(this._tasks),this.onTasksDoneObservable.notifyObservers(this._tasks),this;this.useDefaultLoadingScreen&&this._scene.getEngine().displayLoadingUI();for(var e=0;e<this._tasks.length;e++){var t=this._tasks[e];t.taskState===o.INIT&&this._runTask(t)}return this},e})();a.AssetsManager=i})($a||($a={})),ha=$a||($a={}),ua=[],da=function(e,t){if(!ua[e.id]&&!e.doNotSerialize){if(e instanceof ha.BoxGeometry)t.boxes.push(e.serialize());else if(e instanceof ha.SphereGeometry)t.spheres.push(e.serialize());else if(e instanceof ha.CylinderGeometry)t.cylinders.push(e.serialize());else if(e instanceof ha.TorusGeometry)t.toruses.push(e.serialize());else if(e instanceof ha.GroundGeometry)t.grounds.push(e.serialize());else if(e instanceof ha.Plane)t.planes.push(e.serialize());else if(e instanceof ha.TorusKnotGeometry)t.torusKnots.push(e.serialize());else{if(e instanceof ha._PrimitiveGeometry)throw new Error("Unknown primitive type");t.vertexData.push(e.serializeVerticeData())}ua[e.id]=!0}},fa=function(e,t){var i={},r=e._geometry;return r&&(e.getScene().getGeometryByID(r.id)||da(r,t.geometries)),e.serialize&&e.serialize(i),i},pa=(function(){function v(){}return v.ClearCache=function(){ua=[]},v.Serialize=function(e){var t,i,r,n={};if(v.ClearCache(),n.useDelayedTextureLoading=e.useDelayedTextureLoading,n.autoClear=e.autoClear,n.clearColor=e.clearColor.asArray(),n.ambientColor=e.ambientColor.asArray(),n.gravity=e.gravity.asArray(),n.collisionsEnabled=e.collisionsEnabled,n.workerCollisions=e.workerCollisions,e.fogMode&&0!==e.fogMode&&(n.fogMode=e.fogMode,n.fogColor=e.fogColor.asArray(),n.fogStart=e.fogStart,n.fogEnd=e.fogEnd,n.fogDensity=e.fogDensity),e.isPhysicsEnabled()){var o=e.getPhysicsEngine();o&&(n.physicsEnabled=!0,n.physicsGravity=o.gravity.asArray(),n.physicsEngine=o.getPhysicsPluginName())}e.metadata&&(n.metadata=e.metadata),n.morphTargetManagers=[];for(var s=0,a=e.meshes;s<a.length;s++){var l=(p=a[s]).morphTargetManager;l&&n.morphTargetManagers.push(l.serialize())}for(n.lights=[],t=0;t<e.lights.length;t++)(i=e.lights[t]).doNotSerialize||n.lights.push(i.serialize());for(n.cameras=[],t=0;t<e.cameras.length;t++){var c=e.cameras[t];c.doNotSerialize||n.cameras.push(c.serialize())}for(e.activeCamera&&(n.activeCameraID=e.activeCamera.id),ha.Animation.AppendSerializedAnimations(e,n),n.materials=[],n.multiMaterials=[],t=0;t<e.materials.length;t++)(r=e.materials[t]).doNotSerialize||n.materials.push(r.serialize());for(n.multiMaterials=[],t=0;t<e.multiMaterials.length;t++){var h=e.multiMaterials[t];n.multiMaterials.push(h.serialize())}for(e.environmentTexture&&(n.environmentTexture=e.environmentTexture.name),n.skeletons=[],t=0;t<e.skeletons.length;t++){var u=e.skeletons[t];u.doNotSerialize||n.skeletons.push(u.serialize())}for(n.transformNodes=[],t=0;t<e.transformNodes.length;t++)n.transformNodes.push(e.transformNodes[t].serialize());n.geometries={},n.geometries.boxes=[],n.geometries.spheres=[],n.geometries.cylinders=[],n.geometries.toruses=[],n.geometries.grounds=[],n.geometries.planes=[],n.geometries.torusKnots=[],n.geometries.vertexData=[],ua=[];var d=e.getGeometries();for(t=0;t<d.length;t++){var f=d[t];f.isReady()&&da(f,n.geometries)}for(n.meshes=[],t=0;t<e.meshes.length;t++){var p;if((p=e.meshes[t])instanceof ha.Mesh){var m=p;m.doNotSerialize||m.delayLoadState!==ha.Engine.DELAYLOADSTATE_LOADED&&m.delayLoadState!==ha.Engine.DELAYLOADSTATE_NONE||n.meshes.push(fa(m,n))}}for(n.particleSystems=[],t=0;t<e.particleSystems.length;t++)n.particleSystems.push(e.particleSystems[t].serialize());e.actionManager&&(n.actions=e.actionManager.serialize("scene"));for(var _=0,g=e._serializableComponents;_<g.length;_++){g[_].serialize(n)}return n},v.SerializeMesh=function(t,e,i){void 0===e&&(e=!1),void 0===i&&(i=!1);var r={};if(v.ClearCache(),t=t instanceof Array?t:[t],e||i)for(var n=0;n<t.length;++n)i&&t[n].getDescendants().forEach((function(e){e instanceof ha.Mesh&&t.indexOf(e)<0&&t.push(e)})),e&&t[n].parent&&t.indexOf(t[n].parent)<0&&t.push(t[n].parent);return t.forEach((function(e){!(function(t,e){if(t.delayLoadState===ha.Engine.DELAYLOADSTATE_LOADED||t.delayLoadState===ha.Engine.DELAYLOADSTATE_NONE){if(t.material)if(t.material instanceof ha.MultiMaterial){if(e.multiMaterials=e.multiMaterials||[],e.materials=e.materials||[],!e.multiMaterials.some((function(e){return e.id===t.material.id}))){e.multiMaterials.push(t.material.serialize());for(var i=function(t){t&&(e.materials.some((function(e){return e.id===t.id}))||e.materials.push(t.serialize()))},r=0,n=t.material.subMaterials;r<n.length;r++)i(n[r])}}else e.materials=e.materials||[],e.materials.some((function(e){return e.id===t.material.id}))||e.materials.push(t.material.serialize());var o=t._geometry;o&&(e.geometries||(e.geometries={},e.geometries.boxes=[],e.geometries.spheres=[],e.geometries.cylinders=[],e.geometries.toruses=[],e.geometries.grounds=[],e.geometries.planes=[],e.geometries.torusKnots=[],e.geometries.vertexData=[]),da(o,e.geometries)),t.skeleton&&(e.skeletons=e.skeletons||[],e.skeletons.push(t.skeleton.serialize())),e.meshes=e.meshes||[],e.meshes.push(fa(t,e))}})(e,r)})),r},v})(),ha.SceneSerializer=pa,ma=$a||($a={}),_a=(function(){function e(e,t,i,r,n){void 0===r&&(r=!0),void 0===n&&(n=!1);var o=this;this.name=e,this._viewMatrix=ma.Matrix.Identity(),this._target=ma.Vector3.Zero(),this._add=ma.Vector3.Zero(),this._invertYAxis=!1,this.position=ma.Vector3.Zero(),this._scene=i,this._scene.reflectionProbes||(this._scene.reflectionProbes=new Array),this._scene.reflectionProbes.push(this),this._renderTargetTexture=new ma.RenderTargetTexture(e,t,i,r,!0,n?ma.Engine.TEXTURETYPE_FLOAT:ma.Engine.TEXTURETYPE_UNSIGNED_INT,!0),this._renderTargetTexture.onBeforeRenderObservable.add((function(e){switch(e){case 0:o._add.copyFromFloats(1,0,0);break;case 1:o._add.copyFromFloats(-1,0,0);break;case 2:o._add.copyFromFloats(0,o._invertYAxis?1:-1,0);break;case 3:o._add.copyFromFloats(0,o._invertYAxis?-1:1,0);break;case 4:o._add.copyFromFloats(0,0,1);break;case 5:o._add.copyFromFloats(0,0,-1)}o._attachedMesh&&o.position.copyFrom(o._attachedMesh.getAbsolutePosition()),o.position.addToRef(o._add,o._target),ma.Matrix.LookAtLHToRef(o.position,o._target,ma.Vector3.Up(),o._viewMatrix),i.setTransformMatrix(o._viewMatrix,o._projectionMatrix),i._forcedViewPosition=o.position})),this._renderTargetTexture.onAfterUnbindObservable.add((function(){i._forcedViewPosition=null,i.updateTransformMatrix(!0)})),i.activeCamera&&(this._projectionMatrix=ma.Matrix.PerspectiveFovLH(Math.PI/2,1,i.activeCamera.minZ,i.activeCamera.maxZ))}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})(),ma.ReflectionProbe=_a,ga=$a||($a={}),va=(function(){function e(e){this.name=ga.SceneComponentConstants.NAME_LAYER,this.scene=e,this._engine=e.getEngine(),e.layers=new Array}return e.prototype.register=function(){this.scene._beforeCameraDrawStage.registerStep(ga.SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER,this,this._drawBackground),this.scene._afterCameraDrawStage.registerStep(ga.SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER,this,this._drawForeground)},e.prototype.rebuild=function(){for(var e=0,t=this.scene.layers;e<t.length;e++){t[e]._rebuild()}},e.prototype.dispose=function(){for(var e=this.scene.layers;e.length;)e[0].dispose()},e.prototype._draw=function(e,t){var i=this.scene.layers;if(i.length){this._engine.setDepthBuffer(!1);for(var r=e.layerMask,n=0,o=i;n<o.length;n++){var s=o[n];s.isBackground===t&&0!=(s.layerMask&r)&&s.render()}this._engine.setDepthBuffer(!0)}},e.prototype._drawBackground=function(e){this._draw(e,!0)},e.prototype._drawForeground=function(e){this._draw(e,!1)},e})(),ga.LayerSceneComponent=va,ya=$a||($a={}),ba=(function(){function e(e,t,i,r,n){this.name=e,this.scale=new ya.Vector2(1,1),this.offset=new ya.Vector2(0,0),this.alphaBlendingMode=ya.Engine.ALPHA_COMBINE,this.layerMask=268435455,this._vertexBuffers={},this.onDisposeObservable=new ya.Observable,this.onBeforeRenderObservable=new ya.Observable,this.onAfterRenderObservable=new ya.Observable,this.texture=t?new ya.Texture(t,i,!0):null,this.isBackground=void 0===r||r,this.color=void 0===n?new ya.Color4(1,1,1,1):n,this._scene=i||ya.Engine.LastCreatedScene;var o=this._scene._getComponent(ya.SceneComponentConstants.NAME_LAYER);o||(o=new ya.LayerSceneComponent(this._scene),this._scene._addComponent(o)),this._scene.layers.push(this);var s=this._scene.getEngine(),a=[];a.push(1,1),a.push(-1,1),a.push(-1,-1),a.push(1,-1);var l=new ya.VertexBuffer(s,a,ya.VertexBuffer.PositionKind,!1,!1,2);this._vertexBuffers[ya.VertexBuffer.PositionKind]=l,this._createIndexBuffer(),this._effect=s.createEffect("layer",[ya.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],""),this._alphaTestEffect=s.createEffect("layer",[ya.VertexBuffer.PositionKind],["textureMatrix","color","scale","offset"],["textureSampler"],"#define ALPHATEST")}return Object.defineProperty(e.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onBeforeRender",{set:function(e){this._onBeforeRenderObserver&&this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver),this._onBeforeRenderObserver=this.onBeforeRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"onAfterRender",{set:function(e){this._onAfterRenderObserver&&this.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=this.onAfterRenderObservable.add(e)},enumerable:!0,configurable:!0}),e.prototype._createIndexBuffer=function(){var e=this._scene.getEngine(),t=[];t.push(0),t.push(1),t.push(2),t.push(0),t.push(2),t.push(3),this._indexBuffer=e.createIndexBuffer(t)},e.prototype._rebuild=function(){var e=this._vertexBuffers[ya.VertexBuffer.PositionKind];e&&e._rebuild(),this._createIndexBuffer()},e.prototype.render=function(){var e=this.alphaTest?this._alphaTestEffect:this._effect;if(e.isReady()&&this.texture&&this.texture.isReady()){var t=this._scene.getEngine();this.onBeforeRenderObservable.notifyObservers(this),t.enableEffect(e),t.setState(!1),e.setTexture("textureSampler",this.texture),e.setMatrix("textureMatrix",this.texture.getTextureMatrix()),e.setFloat4("color",this.color.r,this.color.g,this.color.b,this.color.a),e.setVector2("offset",this.offset),e.setVector2("scale",this.scale),t.bindBuffers(this._vertexBuffers,this._indexBuffer,e),this.alphaTest?t.drawElementsType(ya.Material.TriangleFillMode,0,6):(t.setAlphaMode(this.alphaBlendingMode),t.drawElementsType(ya.Material.TriangleFillMode,0,6),t.setAlphaMode(ya.Engine.ALPHA_DISABLE)),this.onAfterRenderObservable.notifyObservers(this)}},e.prototype.dispose=function(){var e=this._vertexBuffers[ya.VertexBuffer.PositionKind];e&&(e.dispose(),this._vertexBuffers[ya.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),this.texture&&(this.texture.dispose(),this.texture=null);var t=this._scene.layers.indexOf(this);this._scene.layers.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear(),this.onAfterRenderObservable.clear(),this.onBeforeRenderObservable.clear()},e})(),ya.Layer=ba,Ta=$a||($a={}),xa=(function(){function e(){}return e.CreateResizedCopy=function(t,e,i,r){void 0===r&&(r=!0);var n=t.getScene(),o=n.getEngine(),s=new Ta.RenderTargetTexture("resized"+t.name,{width:e,height:i},n,!t.noMipmap,!0,t._texture.type,!1,t._samplingMode,!1);s.wrapU=t.wrapU,s.wrapV=t.wrapV,s.uOffset=t.uOffset,s.vOffset=t.vOffset,s.uScale=t.uScale,s.vScale=t.vScale,s.uAng=t.uAng,s.vAng=t.vAng,s.wAng=t.wAng,s.coordinatesIndex=t.coordinatesIndex,s.level=t.level,s.anisotropicFilteringLevel=t.anisotropicFilteringLevel,s._texture.isReady=!1,t.wrapU=Ta.Texture.CLAMP_ADDRESSMODE,t.wrapV=Ta.Texture.CLAMP_ADDRESSMODE;var a=new Ta.PassPostProcess("pass",1,null,r?Ta.Texture.BILINEAR_SAMPLINGMODE:Ta.Texture.NEAREST_SAMPLINGMODE,o,!1,Ta.Engine.TEXTURETYPE_UNSIGNED_INT);return a.getEffect().executeWhenCompiled((function(){a.onApply=function(e){e.setTexture("textureSampler",t)};var e=s.getInternalTexture();e&&(n.postProcessManager.directRender([a],e),o.unBindFramebuffer(e),s.disposeFramebufferObjects(),a.dispose(),e.isReady=!0)})),s},e.GetEnvironmentBRDFTexture=function(e){if(!e._environmentBRDFTexture){var t=Ta.Texture.CreateFromBase64String(this._environmentBRDFBase64Texture,"EnvironmentBRDFTexture",e,!0,!1,Ta.Texture.BILINEAR_SAMPLINGMODE);t.wrapU=Ta.Texture.CLAMP_ADDRESSMODE,t.wrapV=Ta.Texture.CLAMP_ADDRESSMODE,e._environmentBRDFTexture=t}return e._environmentBRDFTexture},e._environmentBRDFBase64Texture="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=",e})(),Ta.TextureTools=xa,Ea=$a||($a={}),Aa=(function(){function p(){this._mode=p.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(p.prototype,"name",{get:function(){return"Framing"},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"mode",{get:function(){return this._mode},set:function(e){this._mode=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"radiusScale",{get:function(){return this._radiusScale},set:function(e){this._radiusScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"positionScale",{get:function(){return this._positionScale},set:function(e){this._positionScale=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"defaultElevation",{get:function(){return this._defaultElevation},set:function(e){this._defaultElevation=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"elevationReturnTime",{get:function(){return this._elevationReturnTime},set:function(e){this._elevationReturnTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"elevationReturnWaitTime",{get:function(){return this._elevationReturnWaitTime},set:function(e){this._elevationReturnWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(p.prototype,"framingTime",{get:function(){return this._framingTime},set:function(e){this._framingTime=e},enumerable:!0,configurable:!0}),p.prototype.init=function(){},p.prototype.attach=function(e){var t=this;this._attachedCamera=e;var i=this._attachedCamera.getScene();p.EasingFunction.setEasingMode(p.EasingMode),this._onPrePointerObservableObserver=i.onPrePointerObservable.add((function(e){e.type!==Ea.PointerEventTypes.POINTERDOWN?e.type===Ea.PointerEventTypes.POINTERUP&&(t._isPointerDown=!1):t._isPointerDown=!0})),this._onMeshTargetChangedObserver=e.onMeshTargetChangedObservable.add((function(e){e&&t.zoomOnMesh(e)})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){t._applyUserInteraction(),t._maintainCameraAboveGround()}))},p.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}},p.prototype.zoomOnMesh=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getBoundingInfo().boundingBox;this.zoomOnBoundingInfo(r.minimumWorld,r.maximumWorld,t,i)},p.prototype.zoomOnMeshHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null),e.computeWorldMatrix(!0);var r=e.getHierarchyBoundingVectors(!0);this.zoomOnBoundingInfo(r.min,r.max,t,i)},p.prototype.zoomOnMeshesHierarchy=function(e,t,i){void 0===t&&(t=!1),void 0===i&&(i=null);for(var r=new Ea.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),n=new Ea.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),o=0;o<e.length;o++){var s=e[o].getHierarchyBoundingVectors(!0);Ea.Tools.CheckExtends(s.min,r,n),Ea.Tools.CheckExtends(s.max,r,n)}this.zoomOnBoundingInfo(r,n,t,i)},p.prototype.zoomOnBoundingInfo=function(e,t,i,r){var n,o=this;if(void 0===i&&(i=!1),void 0===r&&(r=null),this._attachedCamera){var s=e.y,a=s+(t.y-s)*this._positionScale,l=t.subtract(e).scale(.5);if(i)n=new Ea.Vector3(0,a,0);else{var c=e.add(l);n=new Ea.Vector3(c.x,a,c.z)}this._vectorTransition||(this._vectorTransition=Ea.Animation.CreateAnimation("target",Ea.Animation.ANIMATIONTYPE_VECTOR3,60,p.EasingFunction)),this._betaIsAnimating=!0;var h=Ea.Animation.TransitionTo("target",n,this._attachedCamera,this._attachedCamera.getScene(),60,this._vectorTransition,this._framingTime);h&&this._animatables.push(h);var u=0;if(this._mode===p.FitFrustumSidesMode){var d=this._calculateLowerRadiusFromModelBoundingSphere(e,t);this.autoCorrectCameraLimitsAndSensibility&&(this._attachedCamera.lowerRadiusLimit=l.length()+this._attachedCamera.minZ),u=d}else this._mode===p.IgnoreBoundsSizeMode&&(u=this._calculateLowerRadiusFromModelBoundingSphere(e,t),this.autoCorrectCameraLimitsAndSensibility&&null===this._attachedCamera.lowerRadiusLimit&&(this._attachedCamera.lowerRadiusLimit=this._attachedCamera.minZ));if(this.autoCorrectCameraLimitsAndSensibility){var f=t.subtract(e).length();this._attachedCamera.panningSensibility=5e3/f,this._attachedCamera.wheelPrecision=100/u}this._radiusTransition||(this._radiusTransition=Ea.Animation.CreateAnimation("radius",Ea.Animation.ANIMATIONTYPE_FLOAT,60,p.EasingFunction)),(h=Ea.Animation.TransitionTo("radius",u,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusTransition,this._framingTime,(function(){o.stopAllAnimations(),r&&r(),o._attachedCamera&&o._attachedCamera.useInputToRestoreState&&o._attachedCamera.storeState()})))&&this._animatables.push(h)}},p.prototype._calculateLowerRadiusFromModelBoundingSphere=function(e,t){var i=t.subtract(e).length(),r=this._getFrustumSlope(),n=.5*i*this._radiusScale,o=n*Math.sqrt(1+1/(r.x*r.x)),s=n*Math.sqrt(1+1/(r.y*r.y)),a=Math.max(o,s),l=this._attachedCamera;return l?(l.lowerRadiusLimit&&this._mode===p.IgnoreBoundsSizeMode&&(a=a<l.lowerRadiusLimit?l.lowerRadiusLimit:a),l.upperRadiusLimit&&(a=a>l.upperRadiusLimit?l.upperRadiusLimit:a),a):0},p.prototype._maintainCameraAboveGround=function(){var e=this;if(!(this._elevationReturnTime<0)){var t=Ea.Tools.Now-this._lastInteractionTime,i=.5*Math.PI-this._defaultElevation,r=.5*Math.PI;if(this._attachedCamera&&!this._betaIsAnimating&&this._attachedCamera.beta>r&&t>=this._elevationReturnWaitTime){this._betaIsAnimating=!0,this.stopAllAnimations(),this._betaTransition||(this._betaTransition=Ea.Animation.CreateAnimation("beta",Ea.Animation.ANIMATIONTYPE_FLOAT,60,p.EasingFunction));var n=Ea.Animation.TransitionTo("beta",i,this._attachedCamera,this._attachedCamera.getScene(),60,this._betaTransition,this._elevationReturnTime,(function(){e._clearAnimationLocks(),e.stopAllAnimations()}));n&&this._animatables.push(n)}}},p.prototype._getFrustumSlope=function(){var e=this._attachedCamera;if(!e)return Ea.Vector2.Zero();var t=e.getScene().getEngine().getAspectRatio(e),i=Math.tan(e.fov/2),r=i*t;return new Ea.Vector2(r,i)},p.prototype._clearAnimationLocks=function(){this._betaIsAnimating=!1},p.prototype._applyUserInteraction=function(){this.isUserIsMoving&&(this._lastInteractionTime=Ea.Tools.Now,this.stopAllAnimations(),this._clearAnimationLocks())},p.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(p.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}),p.EasingFunction=new Ea.ExponentialEase,p.EasingMode=Ea.EasingFunction.EASINGMODE_EASEINOUT,p.IgnoreBoundsSizeMode=0,p.FitFrustumSidesMode=1,p})(),Ea.FramingBehavior=Aa,Pa=$a||($a={}),Sa=(function(){function r(){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(r.prototype,"name",{get:function(){return"Bouncing"},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"autoTransitionRange",{get:function(){return this._autoTransitionRange},set:function(e){var i=this;if(this._autoTransitionRange!==e){this._autoTransitionRange=e;var t=this._attachedCamera;t&&(e?this._onMeshTargetChangedObserver=t.onMeshTargetChangedObservable.add((function(e){if(e){e.computeWorldMatrix(!0);var t=e.getBoundingInfo().diagonalLength;i.lowerRadiusTransitionRange=.05*t,i.upperRadiusTransitionRange=.05*t}})):this._onMeshTargetChangedObserver&&t.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver))}},enumerable:!0,configurable:!0}),r.prototype.init=function(){},r.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))}))},r.prototype.detach=function(){this._attachedCamera&&(this._onAfterCheckInputsObserver&&this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver),this._onMeshTargetChangedObserver&&this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver),this._attachedCamera=null)},r.prototype._isRadiusAtLimit=function(e){return!!this._attachedCamera&&(this._attachedCamera.radius===e&&!this._radiusIsAnimating)},r.prototype._applyBoundRadiusAnimation=function(e){var t=this;if(this._attachedCamera){this._radiusBounceTransition||(r.EasingFunction.setEasingMode(r.EasingMode),this._radiusBounceTransition=Pa.Animation.CreateAnimation("radius",Pa.Animation.ANIMATIONTYPE_FLOAT,60,r.EasingFunction)),this._cachedWheelPrecision=this._attachedCamera.wheelPrecision,this._attachedCamera.wheelPrecision=1/0,this._attachedCamera.inertialRadiusOffset=0,this.stopAllAnimations(),this._radiusIsAnimating=!0;var i=Pa.Animation.TransitionTo("radius",this._attachedCamera.radius+e,this._attachedCamera,this._attachedCamera.getScene(),60,this._radiusBounceTransition,this.transitionDuration,(function(){return t._clearAnimationLocks()}));i&&this._animatables.push(i)}},r.prototype._clearAnimationLocks=function(){this._radiusIsAnimating=!1,this._attachedCamera&&(this._attachedCamera.wheelPrecision=this._cachedWheelPrecision)},r.prototype.stopAllAnimations=function(){for(this._attachedCamera&&(this._attachedCamera.animations=[]);this._animatables.length;)this._animatables[0].onAnimationEnd=null,this._animatables[0].stop(),this._animatables.shift()},r.EasingFunction=new Pa.BackEase(.3),r.EasingMode=Pa.EasingFunction.EASINGMODE_EASEOUT,r})(),Pa.BouncingBehavior=Sa,Ra=$a||($a={}),Ma=(function(){function e(){this._zoomStopsAnimation=!1,this._idleRotationSpeed=.05,this._idleRotationWaitTime=2e3,this._idleRotationSpinupTime=2e3,this._isPointerDown=!1,this._lastFrameTime=null,this._lastInteractionTime=-1/0,this._cameraRotationSpeed=0,this._lastFrameRadius=0}return Object.defineProperty(e.prototype,"name",{get:function(){return"AutoRotation"},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"zoomStopsAnimation",{get:function(){return this._zoomStopsAnimation},set:function(e){this._zoomStopsAnimation=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpeed",{get:function(){return this._idleRotationSpeed},set:function(e){this._idleRotationSpeed=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationWaitTime",{get:function(){return this._idleRotationWaitTime},set:function(e){this._idleRotationWaitTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"idleRotationSpinupTime",{get:function(){return this._idleRotationSpinupTime},set:function(e){this._idleRotationSpinupTime=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"rotationInProgress",{get:function(){return 0<Math.abs(this._cameraRotationSpeed)},enumerable:!0,configurable:!0}),e.prototype.init=function(){},e.prototype.attach=function(e){var n=this;this._attachedCamera=e;var t=this._attachedCamera.getScene();this._onPrePointerObservableObserver=t.onPrePointerObservable.add((function(e){e.type!==Ra.PointerEventTypes.POINTERDOWN?e.type===Ra.PointerEventTypes.POINTERUP&&(n._isPointerDown=!1):n._isPointerDown=!0})),this._onAfterCheckInputsObserver=e.onAfterCheckInputsObservable.add((function(){var e=Ra.Tools.Now,t=0;null!=n._lastFrameTime&&(t=e-n._lastFrameTime),n._lastFrameTime=e,n._applyUserInteraction();var i=e-n._lastInteractionTime-n._idleRotationWaitTime,r=Math.max(Math.min(i/n._idleRotationSpinupTime,1),0);n._cameraRotationSpeed=n._idleRotationSpeed*r,n._attachedCamera&&(n._attachedCamera.alpha-=n._cameraRotationSpeed*(t/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=Ra.Tools.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})(),Ra.AutoRotationBehavior=Ma,(function(d){var r=function(){this.renderWidth=512,this.renderHeight=256,this.textureSize=512,this.deterministicLockstep=!1,this.lockstepMaxSteps=4};d.NullEngineOptions=r;var e=(function(i){function e(e){void 0===e&&(e=new r);var t=i.call(this,null)||this;return void 0===e.deterministicLockstep&&(e.deterministicLockstep=!1),void 0===e.lockstepMaxSteps&&(e.lockstepMaxSteps=4),t._options=e,t._caps=new d.EngineCapabilities,t._caps.maxTexturesImageUnits=16,t._caps.maxVertexTextureImageUnits=16,t._caps.maxTextureSize=512,t._caps.maxCubemapTextureSize=512,t._caps.maxRenderTextureSize=512,t._caps.maxVertexAttribs=16,t._caps.maxVaryingVectors=16,t._caps.maxFragmentUniformVectors=16,t._caps.maxVertexUniformVectors=16,t._caps.standardDerivatives=!1,t._caps.astc=null,t._caps.s3tc=null,t._caps.pvrtc=null,t._caps.etc1=null,t._caps.etc2=null,t._caps.textureAnisotropicFilterExtension=null,t._caps.maxAnisotropy=0,t._caps.uintIndices=!1,t._caps.fragmentDepthSupported=!1,t._caps.highPrecisionShaderSupported=!0,t._caps.colorBufferFloat=!1,t._caps.textureFloat=!1,t._caps.textureFloatLinearFiltering=!1,t._caps.textureFloatRender=!1,t._caps.textureHalfFloat=!1,t._caps.textureHalfFloatLinearFiltering=!1,t._caps.textureHalfFloatRender=!1,t._caps.textureLOD=!1,t._caps.drawBuffersExtension=!1,t._caps.depthTextureExtension=!1,t._caps.vertexArrayObject=!1,t._caps.instancedArrays=!1,d.Tools.Log("Babylon.js null engine (v"+d.Engine.Version+") launched"),"undefined"==typeof URL&&(URL={createObjectURL:function(){},revokeObjectURL:function(){}}),"undefined"==typeof Blob&&(Blob=function(){}),t}return T(e,i),e.prototype.isDeterministicLockStep=function(){return this._options.deterministicLockstep},e.prototype.getLockstepMaxSteps=function(){return this._options.lockstepMaxSteps},e.prototype.getHardwareScalingLevel=function(){return 1},e.prototype.createVertexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},e.prototype.createIndexBuffer=function(e){return{capacity:0,references:1,is32Bits:!1}},e.prototype.clear=function(e,t,i,r){void 0===r&&(r=!1)},e.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._options.renderWidth},e.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._options.renderHeight},e.prototype.setViewport=function(e,t,i){this._cachedViewport=e},e.prototype.createShaderProgram=function(e,t,i,r){return{transformFeedback:null,__SPECTOR_rebuildProgram:null}},e.prototype.getUniforms=function(e,t){return[]},e.prototype.getAttributes=function(e,t){return[]},e.prototype.bindSamplers=function(e){this._currentEffect=null},e.prototype.enableEffect=function(e){(this._currentEffect=e).onBind&&e.onBind(e),e._onBindObservable&&e._onBindObservable.notifyObservers(e)},e.prototype.setState=function(e,t,i,r){void 0===t&&(t=0),void 0===r&&(r=!1)},e.prototype.setIntArray=function(e,t){},e.prototype.setIntArray2=function(e,t){},e.prototype.setIntArray3=function(e,t){},e.prototype.setIntArray4=function(e,t){},e.prototype.setFloatArray=function(e,t){},e.prototype.setFloatArray2=function(e,t){},e.prototype.setFloatArray3=function(e,t){},e.prototype.setFloatArray4=function(e,t){},e.prototype.setArray=function(e,t){},e.prototype.setArray2=function(e,t){},e.prototype.setArray3=function(e,t){},e.prototype.setArray4=function(e,t){},e.prototype.setMatrices=function(e,t){},e.prototype.setMatrix=function(e,t){},e.prototype.setMatrix3x3=function(e,t){},e.prototype.setMatrix2x2=function(e,t){},e.prototype.setFloat=function(e,t){},e.prototype.setFloat2=function(e,t,i){},e.prototype.setFloat3=function(e,t,i,r){},e.prototype.setBool=function(e,t){},e.prototype.setFloat4=function(e,t,i,r,n){},e.prototype.setColor3=function(e,t){},e.prototype.setColor4=function(e,t,i){},e.prototype.setAlphaMode=function(e,t){void 0===t&&(t=!1),this._alphaMode!==e&&(this._alphaState.alphaBlend=e!==d.Engine.ALPHA_DISABLE,t||this.setDepthWrite(e===d.Engine.ALPHA_DISABLE),this._alphaMode=e)},e.prototype.bindBuffers=function(e,t,i){},e.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)},e.prototype.draw=function(e,t,i,r){},e.prototype.drawElementsType=function(e,t,i,r){},e.prototype.drawArraysType=function(e,t,i,r){},e.prototype._createTexture=function(){return{}},e.prototype._releaseTexture=function(e){},e.prototype.createTexture=function(e,t,i,r,n,o,s,a,l,c){void 0===n&&(n=d.Texture.TRILINEAR_SAMPLINGMODE),void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null);var h=new d.InternalTexture(this,d.InternalTexture.DATASOURCE_URL),u=String(e);return h.url=u,h.generateMipMaps=!t,h.samplingMode=n,h.invertY=i,h.baseWidth=this._options.textureSize,h.baseHeight=this._options.textureSize,h.width=this._options.textureSize,h.height=this._options.textureSize,c&&(h.format=c),h.isReady=!0,o&&o(),this._internalTexturesCache.push(h),h},e.prototype.createRenderTargetTexture=function(e,t){var i=new d.RenderTargetCreationOptions;void 0!==t&&"object"==typeof t?(i.generateMipMaps=t.generateMipMaps,i.generateDepthBuffer=void 0===t.generateDepthBuffer||t.generateDepthBuffer,i.generateStencilBuffer=i.generateDepthBuffer&&t.generateStencilBuffer,i.type=void 0===t.type?d.Engine.TEXTURETYPE_UNSIGNED_INT:t.type,i.samplingMode=void 0===t.samplingMode?d.Texture.TRILINEAR_SAMPLINGMODE:t.samplingMode):(i.generateMipMaps=t,i.generateDepthBuffer=!0,i.generateStencilBuffer=!1,i.type=d.Engine.TEXTURETYPE_UNSIGNED_INT,i.samplingMode=d.Texture.TRILINEAR_SAMPLINGMODE);var r=new d.InternalTexture(this,d.InternalTexture.DATASOURCE_RENDERTARGET),n=e.width||e,o=e.height||e;return r._depthStencilBuffer={},r._framebuffer={},r.baseWidth=n,r.baseHeight=o,r.width=n,r.height=o,r.isReady=!0,r.samples=1,r.generateMipMaps=!!i.generateMipMaps,r.samplingMode=i.samplingMode,r.type=i.type,r._generateDepthBuffer=i.generateDepthBuffer,r._generateStencilBuffer=!!i.generateStencilBuffer,this._internalTexturesCache.push(r),r},e.prototype.updateTextureSamplingMode=function(e,t){t.samplingMode=e},e.prototype.bindFramebuffer=function(e,t,i,r,n){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this._currentFramebuffer=e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer,this._cachedViewport&&!n&&this.setViewport(this._cachedViewport,i,r)},e.prototype.unBindFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null,i&&(e._MSAAFramebuffer&&(this._currentFramebuffer=e._framebuffer),i()),this._currentFramebuffer=null},e.prototype.createDynamicVertexBuffer=function(e){return{capacity:1,references:1,is32Bits:!1}},e.prototype.updateDynamicTexture=function(e,t,i,r,n){void 0===r&&(r=!1)},e.prototype.getError=function(){return 0},e.prototype._getUnpackAlignement=function(){return 1},e.prototype._unpackFlipY=function(e){},e.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0)},e.prototype.updateDynamicVertexBuffer=function(e,t,i,r){},e.prototype._bindTextureDirectly=function(e,t){return this._boundTexturesCache[this._activeChannel]!==t&&(this._boundTexturesCache[this._activeChannel]=t,!0)},e.prototype._bindTexture=function(e,t){e<0||this._bindTextureDirectly(0,t)},e.prototype._releaseBuffer=function(e){return e.references--,0===e.references},e.prototype.releaseEffects=function(){},e.prototype.displayLoadingUI=function(){},e.prototype.hideLoadingUI=function(){},e.prototype._uploadCompressedDataToTextureDirectly=function(e,t,i,r,n,o,s){void 0===o&&(o=0),void 0===s&&(s=0)},e.prototype._uploadDataToTextureDirectly=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},e.prototype._uploadArrayBufferViewToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},e.prototype._uploadImageToTexture=function(e,t,i,r){void 0===i&&(i=0),void 0===r&&(r=0)},e})(d.Engine);d.NullEngine=e})($a||($a={})),Ca=$a||($a={}),Oa=(function(){function e(e){this.engine=e,this._captureGPUFrameTime=!1,this._gpuFrameTime=new Ca.PerfCounter,this._captureShaderCompilationTime=!1,this._shaderCompilationTime=new Ca.PerfCounter,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)?(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);-1<e&&(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)?(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})(),Ca.EngineInstrumentation=Oa,Da=$a||($a={}),Ia=(function(){function e(e){var t=this;this.scene=e,this._captureActiveMeshesEvaluationTime=!1,this._activeMeshesEvaluationTime=new Da.PerfCounter,this._captureRenderTargetsRenderTime=!1,this._renderTargetsRenderTime=new Da.PerfCounter,this._captureFrameTime=!1,this._frameTime=new Da.PerfCounter,this._captureRenderTime=!1,this._renderTime=new Da.PerfCounter,this._captureInterFrameTime=!1,this._interFrameTime=new Da.PerfCounter,this._captureParticlesRenderTime=!1,this._particlesRenderTime=new Da.PerfCounter,this._captureSpritesRenderTime=!1,this._spritesRenderTime=new Da.PerfCounter,this._capturePhysicsTime=!1,this._physicsTime=new Da.PerfCounter,this._captureAnimationsTime=!1,this._animationsTime=new Da.PerfCounter,this._captureCameraRenderTime=!1,this._cameraRenderTime=new Da.PerfCounter,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&&(Da.Tools.StartPerformanceCounter("Scene rendering"),t._frameTime.beginMonitoring()),t._captureInterFrameTime&&t._interFrameTime.endMonitoring(),t._captureParticlesRenderTime&&t._particlesRenderTime.fetchNewFrame(),t._captureSpritesRenderTime&&t._spritesRenderTime.fetchNewFrame(),t._captureAnimationsTime&&t._animationsTime.beginMonitoring(),t.scene.getEngine()._drawCalls.fetchNewFrame(),t.scene.getEngine()._textureCollisions.fetchNewFrame()})),this._onAfterRenderObserver=e.onAfterRenderObservable.add((function(){t._captureFrameTime&&(Da.Tools.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)?(this._onBeforeActiveMeshesEvaluationObserver=this.scene.onBeforeActiveMeshesEvaluationObservable.add((function(){Da.Tools.StartPerformanceCounter("Active meshes evaluation"),t._activeMeshesEvaluationTime.beginMonitoring()})),this._onAfterActiveMeshesEvaluationObserver=this.scene.onAfterActiveMeshesEvaluationObservable.add((function(){Da.Tools.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)?(this._onBeforeRenderTargetsRenderObserver=this.scene.onBeforeRenderTargetsRenderObservable.add((function(){Da.Tools.StartPerformanceCounter("Render targets rendering"),t._renderTargetsRenderTime.beginMonitoring()})),this._onAfterRenderTargetsRenderObserver=this.scene.onAfterRenderTargetsRenderObservable.add((function(){Da.Tools.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)?(this._onBeforeParticlesRenderingObserver=this.scene.onBeforeParticlesRenderingObservable.add((function(){Da.Tools.StartPerformanceCounter("Particles"),t._particlesRenderTime.beginMonitoring()})),this._onAfterParticlesRenderingObserver=this.scene.onAfterParticlesRenderingObservable.add((function(){Da.Tools.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(){Da.Tools.StartPerformanceCounter("Sprites"),t._spritesRenderTime.beginMonitoring()})),this._onAfterSpritesRenderingObserver=this.scene.onAfterSpritesRenderingObservable.add((function(){Da.Tools.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)?(this._onBeforePhysicsObserver=this.scene.onBeforePhysicsObservable.add((function(){Da.Tools.StartPerformanceCounter("Physics"),t._physicsTime.beginMonitoring()})),this._onAfterPhysicsObserver=this.scene.onAfterPhysicsObservable.add((function(){Da.Tools.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)?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)?(this._onBeforeDrawPhaseObserver=this.scene.onBeforeDrawPhaseObservable.add((function(){t._renderTime.beginMonitoring(),Da.Tools.StartPerformanceCounter("Main render")})),this._onAfterDrawPhaseObserver=this.scene.onAfterDrawPhaseObservable.add((function(){t._renderTime.endMonitoring(!1),Da.Tools.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)?(this._onBeforeCameraRenderObserver=this.scene.onBeforeCameraRenderObservable.add((function(e){t._cameraRenderTime.beginMonitoring(),Da.Tools.StartPerformanceCounter("Rendering camera "+e.name)})),this._onAfterCameraRenderObserver=this.scene.onAfterCameraRenderObservable.add((function(e){t._cameraRenderTime.endMonitoring(!1),Da.Tools.EndPerformanceCounter("Rendering camera "+e.name)}))):(this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"drawCallsCounter",{get:function(){return this.scene.getEngine()._drawCalls},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"textureCollisionsCounter",{get:function(){return this.scene.getEngine()._textureCollisions},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver),this._onAfterRenderObserver=null,this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver),this._onBeforeActiveMeshesEvaluationObserver=null,this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver),this._onAfterActiveMeshesEvaluationObserver=null,this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver),this._onBeforeRenderTargetsRenderObserver=null,this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver),this._onAfterRenderTargetsRenderObserver=null,this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver),this._onBeforeAnimationsObserver=null,this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver),this._onBeforeParticlesRenderingObserver=null,this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver),this._onAfterParticlesRenderingObserver=null,this._onBeforeSpritesRenderingObserver&&(this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver),this._onBeforeSpritesRenderingObserver=null),this._onAfterSpritesRenderingObserver&&(this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver),this._onAfterSpritesRenderingObserver=null),this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver),this._onBeforeDrawPhaseObserver=null,this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver),this._onAfterDrawPhaseObserver=null,this._onBeforePhysicsObserver&&(this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver),this._onBeforePhysicsObserver=null),this._onAfterPhysicsObserver&&(this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver),this._onAfterPhysicsObserver=null),this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver),this._onAfterAnimationsObserver=null,this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=null,this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=null,this.scene=null},e})(),Da.SceneInstrumentation=Ia,wa=function(){this._timeElapsedQueryEnded=!1},($a||($a={}))._TimeToken=wa,La=$a||($a={}),Fa=(function(t){function e(){var e=t.call(this)||this;return e.DIFFUSE=!1,e.DIFFUSEDIRECTUV=0,e.GAMMADIFFUSE=!1,e.DIFFUSEHASALPHA=!1,e.OPACITYFRESNEL=!1,e.REFLECTIONBLUR=!1,e.REFLECTIONFRESNEL=!1,e.REFLECTIONFALLOFF=!1,e.TEXTURELODSUPPORT=!1,e.PREMULTIPLYALPHA=!1,e.USERGBCOLOR=!1,e.USEHIGHLIGHTANDSHADOWCOLORS=!1,e.NOISE=!1,e.REFLECTIONBGR=!1,e.IMAGEPROCESSING=!1,e.VIGNETTE=!1,e.VIGNETTEBLENDMODEMULTIPLY=!1,e.VIGNETTEBLENDMODEOPAQUE=!1,e.TONEMAPPING=!1,e.TONEMAPPING_ACES=!1,e.CONTRAST=!1,e.COLORCURVES=!1,e.COLORGRADING=!1,e.COLORGRADING3D=!1,e.SAMPLER3DGREENDEPTH=!1,e.SAMPLER3DBGRMAP=!1,e.IMAGEPROCESSINGPOSTPROCESS=!1,e.EXPOSURE=!1,e.REFLECTION=!1,e.REFLECTIONMAP_3D=!1,e.REFLECTIONMAP_SPHERICAL=!1,e.REFLECTIONMAP_PLANAR=!1,e.REFLECTIONMAP_CUBIC=!1,e.REFLECTIONMAP_PROJECTION=!1,e.REFLECTIONMAP_SKYBOX=!1,e.REFLECTIONMAP_SKYBOX_TRANSFORMED=!1,e.REFLECTIONMAP_EXPLICIT=!1,e.REFLECTIONMAP_EQUIRECTANGULAR=!1,e.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,e.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,e.INVERTCUBICMAP=!1,e.REFLECTIONMAP_OPPOSITEZ=!1,e.LODINREFLECTIONALPHA=!1,e.GAMMAREFLECTION=!1,e.RGBDREFLECTION=!1,e.EQUIRECTANGULAR_RELFECTION_FOV=!1,e.MAINUV1=!1,e.MAINUV2=!1,e.UV1=!1,e.UV2=!1,e.CLIPPLANE=!1,e.CLIPPLANE2=!1,e.CLIPPLANE3=!1,e.CLIPPLANE4=!1,e.POINTSIZE=!1,e.FOG=!1,e.NORMAL=!1,e.NUM_BONE_INFLUENCERS=0,e.BonesPerMesh=0,e.INSTANCES=!1,e.SHADOWFLOAT=!1,e.rebuild(),e}return T(e,t),e})(La.MaterialDefines),Ba=(function(r){function n(e,t){var i=r.call(this,e,t)||this;return i.primaryColor=La.Color3.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=La.Vector3.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 La.SmartArray(16),i._reflectionControls=La.Vector4.Zero(),i._white=La.Color3.White(),i._primaryShadowColor=La.Color3.Black(),i._primaryHighlightColor=La.Color3.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 T(n,r),Object.defineProperty(n.prototype,"_perceptualColor",{get:function(){return this.__perceptualColor},set:function(e){this.__perceptualColor=e,this._computePrimaryColorFromPerceptualColor(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"primaryColorShadowLevel",{get:function(){return this._primaryColorShadowLevel},set:function(e){this._primaryColorShadowLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"primaryColorHighlightLevel",{get:function(){return this._primaryColorHighlightLevel},set:function(e){this._primaryColorHighlightLevel=e,this._computePrimaryColors(),this._markAllSubMeshesAsLightsDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"reflectionStandardFresnelWeight",{set:function(e){var t=e;t<.5?(t*=2,this.reflectionReflectance0=n.StandardReflectance0*t,this.reflectionReflectance90=n.StandardReflectance90*t):(t=2*t-1,this.reflectionReflectance0=n.StandardReflectance0+(1-n.StandardReflectance0)*t,this.reflectionReflectance90=n.StandardReflectance90+(1-n.StandardReflectance90)*t)},enumerable:!0,configurable:!0}),Object.defineProperty(n.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}),n.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(e){t._computePrimaryColorFromPerceptualColor(),t._markAllSubMeshesAsImageProcessingDirty()}))))},Object.defineProperty(n.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this.imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"cameraColorCurves",{get:function(){return this.imageProcessingConfiguration.colorCurves},set:function(e){this.imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"hasRenderTargetTextures",{get:function(){return!(!this._diffuseTexture||!this._diffuseTexture.isRenderTarget)||!(!this._reflectionTexture||!this._reflectionTexture.isRenderTarget)},enumerable:!0,configurable:!0}),n.prototype.needAlphaTesting=function(){return!0},n.prototype.needAlphaBlending=function(){return this.alpha<0||null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},n.prototype.isReadyForSubMesh=function(e,t,i){var r=this;if(void 0===i&&(i=!1),t.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;t._materialDefines||(t._materialDefines=new Fa);var n=this.getScene(),o=t._materialDefines;if(!this.checkReadyOnEveryCall&&t.effect&&o._renderId===n.getRenderId())return!0;var s=n.getEngine();if(La.MaterialHelper.PrepareDefinesForLights(n,e,o,!1,this._maxSimultaneousLights),o._needNormals=!0,o._areTexturesDirty){if(o._needUVs=!1,n.texturesEnabled){if(n.getEngine().getCaps().textureLOD&&(o.TEXTURELODSUPPORT=!0),this._diffuseTexture&&La.StandardMaterial.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;La.MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture,o,"DIFFUSE"),o.DIFFUSEHASALPHA=this._diffuseTexture.hasAlpha,o.GAMMADIFFUSE=this._diffuseTexture.gammaSpace,o.OPACITYFRESNEL=this._opacityFresnel}else o.DIFFUSE=!1,o.DIFFUSEHASALPHA=!1,o.GAMMADIFFUSE=!1,o.OPACITYFRESNEL=!1;var a=this._reflectionTexture;if(a&&La.StandardMaterial.ReflectionTextureEnabled){if(!a.isReadyOrNotBlocking())return!1;switch(o.REFLECTION=!0,o.GAMMAREFLECTION=a.gammaSpace,o.RGBDREFLECTION=a.isRGBD,o.REFLECTIONBLUR=0<this._reflectionBlur,o.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!a.invertZ:a.invertZ,o.LODINREFLECTIONALPHA=a.lodLevelInAlpha,o.EQUIRECTANGULAR_RELFECTION_FOV=this.useEquirectangularFOV,o.REFLECTIONBGR=this.switchToBGR,a.coordinatesMode===La.Texture.INVCUBIC_MODE&&(o.INVERTCUBICMAP=!0),o.REFLECTIONMAP_3D=a.isCube,a.coordinatesMode){case La.Texture.EXPLICIT_MODE:o.REFLECTIONMAP_EXPLICIT=!0;break;case La.Texture.PLANAR_MODE:o.REFLECTIONMAP_PLANAR=!0;break;case La.Texture.PROJECTION_MODE:o.REFLECTIONMAP_PROJECTION=!0;break;case La.Texture.SKYBOX_MODE:o.REFLECTIONMAP_SKYBOX=!0,o.REFLECTIONMAP_SKYBOX_TRANSFORMED=!a.getReflectionTextureMatrix().isIdentity();break;case La.Texture.SPHERICAL_MODE:o.REFLECTIONMAP_SPHERICAL=!0;break;case La.Texture.EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case La.Texture.FIXED_EQUIRECTANGULAR_MODE:o.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case La.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:o.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case La.Texture.CUBIC_MODE:case La.Texture.INVCUBIC_MODE:default:o.REFLECTIONMAP_CUBIC=!0}this.reflectionFresnel?(o.REFLECTIONFRESNEL=!0,o.REFLECTIONFALLOFF=0<this.reflectionFalloffDistance,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===La.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===La.Engine.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(La.MaterialHelper.PrepareDefinesForMisc(e,n,!1,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(e),o),La.MaterialHelper.PrepareDefinesForFrameBoundValues(n,s,o,i),La.MaterialHelper.PrepareDefinesForAttributes(e,o,!1,!0,!1)&&e&&(n.getEngine().getCaps().standardDerivatives||e.isVerticesDataPresent(La.VertexBuffer.NormalKind)||(e.createNormals(!0),La.Tools.Warn("BackgroundMaterial: Normals have been created for the mesh: "+e.name))),o.isDirty){o.markAsProcessed(),n.resetCachedMaterial();var l=new La.EffectFallbacks;o.FOG&&l.addFallback(0,"FOG"),o.POINTSIZE&&l.addFallback(1,"POINTSIZE"),La.MaterialHelper.HandleFallbacksForShadows(o,l,this._maxSimultaneousLights),0<o.NUM_BONE_INFLUENCERS&&l.addCPUSkinningFallback(0,e);var c=[La.VertexBuffer.PositionKind];o.NORMAL&&c.push(La.VertexBuffer.NormalKind),o.UV1&&c.push(La.VertexBuffer.UVKind),o.UV2&&c.push(La.VertexBuffer.UV2Kind),La.MaterialHelper.PrepareAttributesForBones(c,e,o,l),La.MaterialHelper.PrepareAttributesForInstances(c,o);var h=["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"],u=["diffuseSampler","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh"],d=["Material","Scene"];La.ImageProcessingConfiguration&&(La.ImageProcessingConfiguration.PrepareUniforms(h,o),La.ImageProcessingConfiguration.PrepareSamplers(u,o)),La.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:h,uniformBuffersNames:d,samplers:u,defines:o,maxSimultaneousLights:this._maxSimultaneousLights});var f=o.toString();t.setEffect(n.getEngine().createEffect("background",{attributes:c,uniformsNames:h,uniformBuffersNames:d,samplers:u,defines:f,fallbacks:l,onCompiled:function(e){r.onCompiled&&r.onCompiled(e),r.bindSceneUniformBuffer(e,n.getSceneUniformBuffer())},onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights}},s),o),this.buildUniformLayout()}return!(!t.effect||!t.effect.isReady())&&(o._renderId=n.getRenderId(),this._wasPreviouslyReady=!0)},n.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())},n.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))},n.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()},n.prototype.unbind=function(){this._diffuseTexture&&this._diffuseTexture.isRenderTarget&&this._uniformBuffer.setTexture("diffuseSampler",null),this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),r.prototype.unbind.call(this)},n.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},n.prototype.bindForSubMesh=function(e,t,i){var r=this.getScene(),n=i._materialDefines;if(n){var o=i.effect;if(o){this._activeEffect=o,this.bindOnlyWorldMatrix(e),La.MaterialHelper.BindBonesParameters(t,this._activeEffect);var s=this._mustRebind(r,o,t.visibility);if(s){this._uniformBuffer.bindToEffect(o,"Material"),this.bindViewProjection(o);var a=this._reflectionTexture;this._uniformBuffer.useUbo&&this.isFrozen&&this._uniformBuffer.isSync||(r.texturesEnabled&&(this._diffuseTexture&&La.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),La.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse")),a&&La.StandardMaterial.ReflectionTextureEnabled&&(this._uniformBuffer.updateMatrix("reflectionMatrix",a.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",a.level,this._reflectionBlur),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",a.getSize().width,a.lodGenerationScale,a.lodGenerationOffset))),0<this.shadowLevel&&this._uniformBuffer.updateFloat("shadowLevel",this.shadowLevel),this._uniformBuffer.updateFloat("alpha",this.alpha),this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),n.USEHIGHLIGHTANDSHADOWCOLORS?(this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryHighlightColor,1),this._uniformBuffer.updateColor4("vPrimaryColorShadow",this._primaryShadowColor,1)):this._uniformBuffer.updateColor4("vPrimaryColor",this._primaryColor,1)),this._uniformBuffer.updateFloat("fFovMultiplier",this._fovMultiplier),r.texturesEnabled&&(this._diffuseTexture&&La.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("diffuseSampler",this._diffuseTexture),a&&La.StandardMaterial.ReflectionTextureEnabled&&(n.REFLECTIONBLUR&&n.TEXTURELODSUPPORT?this._uniformBuffer.setTexture("reflectionSampler",a):n.REFLECTIONBLUR?(this._uniformBuffer.setTexture("reflectionSampler",a._lodTextureMid||a),this._uniformBuffer.setTexture("reflectionSamplerLow",a._lodTextureLow||a),this._uniformBuffer.setTexture("reflectionSamplerHigh",a._lodTextureHigh||a)):this._uniformBuffer.setTexture("reflectionSampler",a),n.REFLECTIONFRESNEL&&(this._uniformBuffer.updateFloat3("vBackgroundCenter",this.sceneCenter.x,this.sceneCenter.y,this.sceneCenter.z),this._uniformBuffer.updateFloat4("vReflectionControl",this._reflectionControls.x,this._reflectionControls.y,this._reflectionControls.z,this._reflectionControls.w)))),La.MaterialHelper.BindClipPlane(this._activeEffect,r),La.MaterialHelper.BindEyePosition(o,r)}!s&&this.isFrozen||(r.lightsEnabled&&La.MaterialHelper.BindLights(r,t,this._activeEffect,n,this._maxSimultaneousLights,!1),this.bindView(o),La.MaterialHelper.BindFogParameters(r,t,this._activeEffect,!0),this._imageProcessingConfiguration&&this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(t,this._activeEffect)}}},n.prototype.dispose=function(e,t){void 0===e&&(e=!1),void 0===t&&(t=!1),t&&(this.diffuseTexture&&this.diffuseTexture.dispose(),this.reflectionTexture&&this.reflectionTexture.dispose()),this._renderTargets.dispose(),this._imageProcessingConfiguration&&this._imageProcessingObserver&&this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver),r.prototype.dispose.call(this,e)},n.prototype.clone=function(e){var t=this;return La.SerializationHelper.Clone((function(){return new n(e,t.getScene())}),this)},n.prototype.serialize=function(){var e=La.SerializationHelper.Serialize(this);return e.customType="BABYLON.BackgroundMaterial",e},n.prototype.getClassName=function(){return"BackgroundMaterial"},n.Parse=function(e,t,i){return La.SerializationHelper.Parse((function(){return new n(e.name,t)}),e,t,i)},n.StandardReflectance0=.05,n.StandardReflectance90=.5,b([La.serializeAsColor3()],n.prototype,"_primaryColor",void 0),b([La.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"primaryColor",void 0),b([La.serializeAsColor3()],n.prototype,"__perceptualColor",void 0),b([La.serialize()],n.prototype,"_primaryColorShadowLevel",void 0),b([La.serialize()],n.prototype,"_primaryColorHighlightLevel",void 0),b([La.expandToProperty("_markAllSubMeshesAsLightsDirty")],n.prototype,"primaryColorHighlightLevel",null),b([La.serializeAsTexture()],n.prototype,"_reflectionTexture",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionTexture",void 0),b([La.serialize()],n.prototype,"_reflectionBlur",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionBlur",void 0),b([La.serializeAsTexture()],n.prototype,"_diffuseTexture",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"diffuseTexture",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"shadowLights",void 0),b([La.serialize()],n.prototype,"_shadowLevel",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"shadowLevel",void 0),b([La.serializeAsVector3()],n.prototype,"_sceneCenter",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"sceneCenter",void 0),b([La.serialize()],n.prototype,"_opacityFresnel",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"opacityFresnel",void 0),b([La.serialize()],n.prototype,"_reflectionFresnel",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionFresnel",void 0),b([La.serialize()],n.prototype,"_reflectionFalloffDistance",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionFalloffDistance",void 0),b([La.serialize()],n.prototype,"_reflectionAmount",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionAmount",void 0),b([La.serialize()],n.prototype,"_reflectionReflectance0",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionReflectance0",void 0),b([La.serialize()],n.prototype,"_reflectionReflectance90",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"reflectionReflectance90",void 0),b([La.serialize()],n.prototype,"_useRGBColor",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"useRGBColor",void 0),b([La.serialize()],n.prototype,"_enableNoise",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"enableNoise",void 0),b([La.serialize()],n.prototype,"_maxSimultaneousLights",void 0),b([La.expandToProperty("_markAllSubMeshesAsTexturesDirty")],n.prototype,"maxSimultaneousLights",void 0),b([La.serializeAsImageProcessingConfiguration()],n.prototype,"_imageProcessingConfiguration",void 0),n})(La.PushMaterial),La.BackgroundMaterial=Ba;var Na,Va,Ua,za,Ga,ka,Wa,Ha,Xa,ja,Ya,Ka,Qa,Za;ae=this&&this.__assign||function(){return(ae=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};Na=$a||($a={}),Va=(function(){function r(e,t){var i=this;this._errorHandler=function(e,t){i.onErrorObservable.notifyObservers({message:e,exception:t})},this._options=ae({},r._getDefaultOptions(),e),this._scene=t,this.onErrorObservable=new Na.Observable,this._setupBackground(),this._setupImageProcessing()}return r._getDefaultOptions=function(){return{createGround:!0,groundSize:15,groundTexture:this._groundTextureCDNUrl,groundColor:new Na.Color3(.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:Na.Engine.TEXTURETYPE_UNSIGNED_INT,groundYBias:1e-5,createSkybox:!0,skyboxSize:20,skyboxTexture:this._skyboxTextureCDNUrl,skyboxColor:new Na.Color3(.2,.2,.3).toLinearSpace().scale(3),backgroundYRotation:0,sizeAuto:!0,rootPosition:Na.Vector3.Zero(),setupImageProcessing:!0,environmentTexture:this._environmentTextureCDNUrl,cameraExposure:.8,cameraContrast:1.2,toneMappingEnabled:!0}},Object.defineProperty(r.prototype,"rootMesh",{get:function(){return this._rootMesh},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"skybox",{get:function(){return this._skybox},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"skyboxTexture",{get:function(){return this._skyboxTexture},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"skyboxMaterial",{get:function(){return this._skyboxMaterial},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"ground",{get:function(){return this._ground},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"groundTexture",{get:function(){return this._groundTexture},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"groundMirror",{get:function(){return this._groundMirror},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"groundMirrorRenderList",{get:function(){return this._groundMirror?this._groundMirror.renderList:null},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"groundMaterial",{get:function(){return this._groundMaterial},enumerable:!0,configurable:!0}),r.prototype.updateOptions=function(e){var t=ae({},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()},r.prototype.setMainColor=function(e){this.groundMaterial&&(this.groundMaterial.primaryColor=e),this.skyboxMaterial&&(this.skyboxMaterial.primaryColor=e),this.groundMirror&&(this.groundMirror.clearColor=new Na.Color4(e.r,e.g,e.b,1))},r.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())},r.prototype._setupEnvironmentTexture=function(){if(!this._scene.environmentTexture)if(this._options.environmentTexture instanceof Na.BaseTexture)this._scene.environmentTexture=this._options.environmentTexture;else{var e=Na.CubeTexture.CreateFromPrefilteredData(this._options.environmentTexture,this._scene);this._scene.environmentTexture=e}},r.prototype._setupBackground=function(){this._rootMesh||(this._rootMesh=new Na.Mesh("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},r.prototype._getSceneSize=function(){var t=this,e=this._options.groundSize,i=this._options.skyboxSize,r=this._options.rootPosition;if(!this._scene.meshes||1===this._scene.meshes.length)return{groundSize:e,skyboxSize:i,rootPosition:r};var n=this._scene.getWorldExtends((function(e){return e!==t._ground&&e!==t._rootMesh&&e!==t._skybox})),o=n.max.subtract(n.min);if(this._options.sizeAuto){this._scene.activeCamera instanceof Na.ArcRotateCamera&&this._scene.activeCamera.upperRadiusLimit&&(i=e=2*this._scene.activeCamera.upperRadiusLimit);var s=o.length();e<s&&(i=e=2*s),e*=1.1,i*=1.5,(r=n.min.add(o.scale(.5))).y=n.min.y-this._options.groundYBias}return{groundSize:e,skyboxSize:i,rootPosition:r}},r.prototype._setupGround=function(e){var t=this;this._ground&&!this._ground.isDisposed()||(this._ground=Na.Mesh.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},r.prototype._setupGroundMaterial=function(){this._groundMaterial||(this._groundMaterial=new Na.BackgroundMaterial("BackgroundPlaneMaterial",this._scene)),this._groundMaterial.alpha=this._options.groundOpacity,this._groundMaterial.alphaMode=Na.Engine.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)},r.prototype._setupGroundDiffuseTexture=function(){if(this._groundMaterial&&!this._groundTexture)if(this._options.groundTexture instanceof Na.BaseTexture)this._groundMaterial.diffuseTexture=this._options.groundTexture;else{var e=new Na.Texture(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}},r.prototype._setupGroundMirrorTexture=function(e){var t=Na.Texture.CLAMP_ADDRESSMODE;if(!this._groundMirror&&(this._groundMirror=new Na.MirrorTexture("BackgroundPlaneMirrorTexture",{ratio:this._options.groundMirrorSizeRatio},this._scene,!1,this._options.groundMirrorTextureType,Na.Texture.BILINEAR_SAMPLINGMODE,!0),this._groundMirror.mirrorPlane=new Na.Plane(0,-1,0,e.rootPosition.y),this._groundMirror.anisotropicFilteringLevel=1,this._groundMirror.wrapU=t,this._groundMirror.wrapV=t,this._groundMirror.gammaSpace=!1,this._groundMirror.renderList))for(var i=0;i<this._scene.meshes.length;i++){var r=this._scene.meshes[i];r!==this._ground&&r!==this._skybox&&r!==this._rootMesh&&this._groundMirror.renderList.push(r)}this._groundMirror.clearColor=new Na.Color4(this._options.groundColor.r,this._options.groundColor.g,this._options.groundColor.b,1),this._groundMirror.adaptiveBlurKernel=this._options.groundMirrorBlurKernel},r.prototype._setupMirrorInGroundMaterial=function(){this._groundMaterial&&(this._groundMaterial.reflectionTexture=this._groundMirror,this._groundMaterial.reflectionFresnel=!0,this._groundMaterial.reflectionAmount=this._options.groundMirrorAmount,this._groundMaterial.reflectionStandardFresnelWeight=this._options.groundMirrorFresnelWeight,this._groundMaterial.reflectionFalloffDistance=this._options.groundMirrorFallOffDistance)},r.prototype._setupSkybox=function(e){var t=this;this._skybox&&!this._skybox.isDisposed()||(this._skybox=Na.Mesh.CreateBox("BackgroundSkybox",e.skyboxSize,this._scene,void 0,Na.Mesh.BACKSIDE),this._skybox.onDisposeObservable.add((function(){t._skybox=null}))),this._skybox.parent=this._rootMesh},r.prototype._setupSkyboxMaterial=function(){this._skybox&&(this._skyboxMaterial||(this._skyboxMaterial=new Na.BackgroundMaterial("BackgroundSkyboxMaterial",this._scene)),this._skyboxMaterial.useRGBColor=!1,this._skyboxMaterial.primaryColor=this._options.skyboxColor,this._skyboxMaterial.enableNoise=!0,this._skybox.material=this._skyboxMaterial)},r.prototype._setupSkyboxReflectionTexture=function(){this._skyboxMaterial&&(this._skyboxTexture||(this._options.skyboxTexture instanceof Na.BaseTexture?this._skyboxMaterial.reflectionTexture=this._options.skyboxTexture:(this._skyboxTexture=new Na.CubeTexture(this._options.skyboxTexture,this._scene,void 0,void 0,void 0,void 0,this._errorHandler),this._skyboxTexture.coordinatesMode=Na.Texture.SKYBOX_MODE,this._skyboxTexture.gammaSpace=!1,this._skyboxMaterial.reflectionTexture=this._skyboxTexture)))},r.prototype.dispose=function(){this._groundMaterial&&this._groundMaterial.dispose(!0,!0),this._skyboxMaterial&&this._skyboxMaterial.dispose(!0,!0),this._rootMesh.dispose(!1)},r._groundTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundGround.png",r._skyboxTextureCDNUrl="https://assets.babylonjs.com/environments/backgroundSkybox.dds",r._environmentTextureCDNUrl="https://assets.babylonjs.com/environments/environmentSpecular.env",r})(),Na.EnvironmentHelper=Va,Ua=$a||($a={}),za=(function(){function c(){this.systems=new Array}return Object.defineProperty(c.prototype,"emitterNode",{get:function(){return this._emitterNode},enumerable:!0,configurable:!0}),c.prototype.setEmitterAsSphere=function(e,t,i){this._emitterNode&&this._emitterNode.dispose(),this._emitterCreationOptions={kind:"Sphere",options:e,renderingGroupId:t};var r=Ua.MeshBuilder.CreateSphere("emitterSphere",{diameter:e.diameter,segments:e.segments},i);r.renderingGroupId=t;var n=new Ua.StandardMaterial("emitterSphereMaterial",i);n.emissiveColor=e.color,r.material=n;for(var o=0,s=this.systems;o<s.length;o++){s[o].emitter=r}this._emitterNode=r},c.prototype.start=function(e){for(var t=0,i=this.systems;t<i.length;t++){var r=i[t];e&&(r.emitter=e),r.start()}},c.prototype.dispose=function(){for(var e=0,t=this.systems;e<t.length;e++){t[e].dispose()}this.systems=[],this._emitterNode&&(this._emitterNode.dispose(),this._emitterNode=null)},c.prototype.serialize=function(){for(var e={systems:[]},t=0,i=this.systems;t<i.length;t++){var r=i[t];e.systems.push(r.serialize())}return this._emitterNode&&(e.emitter=this._emitterCreationOptions),e},c.Parse=function(e,t,i){void 0===i&&(i=!1);var r=new c,n=Ua.ParticleHelper.BaseAssetsUrl+"/textures/";t=t||Ua.Engine.LastCreatedScene;for(var o=0,s=e.systems;o<s.length;o++){var a=s[o];r.systems.push(i?Ua.GPUParticleSystem.Parse(a,t,n,!0):Ua.ParticleSystem.Parse(a,t,n,!0))}if(e.emitter){var l=e.emitter.options;switch(e.emitter.kind){case"Sphere":r.setEmitterAsSphere({diameter:l.diameter,segments:l.segments,color:Ua.Color3.FromArray(l.color)},e.emitter.renderingGroupId,t)}}return r},c})(),Ua.ParticleSystemSet=za,Ga=$a||($a={}),ka=(function(){function e(){}return e.CreateDefault=function(e,t,i,r){var n;return void 0===t&&(t=500),void 0===r&&(r=!1),(n=r?new Ga.GPUParticleSystem("default system",{capacity:t},i):new Ga.ParticleSystem("default system",t,i)).emitter=e,n.particleTexture=new Ga.Texture("https://www.babylonjs.com/assets/Flare.png",n.getScene()),n.createConeEmitter(.1,Math.PI/4),n.color1=new Ga.Color4(1,1,1,1),n.color2=new Ga.Color4(1,1,1,1),n.colorDead=new Ga.Color4(1,1,1,0),n.minSize=.1,n.maxSize=.1,n.minEmitPower=2,n.maxEmitPower=2,n.updateSpeed=1/60,n.emitRate=30,n},e.CreateAsync=function(n,o,s){void 0===s&&(s=!1),o||(o=Ga.Engine.LastCreatedScene);var a={};return o._addPendingData(a),new Promise(function(r,i){if(s&&!Ga.GPUParticleSystem.IsSupported)return o._removePendingData(a),i("Particle system with GPU is not supported.");Ga.Tools.LoadFile(e.BaseAssetsUrl+"/systems/"+n+".json",(function(e,t){o._removePendingData(a);var i=JSON.parse(e.toString());return r(Ga.ParticleSystemSet.Parse(i,o,s))}),void 0,void 0,void 0,(function(e,t){return o._removePendingData(a),i("An error occured while the creation of your particle system. Check if your type '"+n+"' exists.")}))})},e.ExportSet=function(e){for(var t=new Ga.ParticleSystemSet,i=0,r=e;i<r.length;i++){var n=r[i];t.systems.push(n)}return t},e.BaseAssetsUrl="https://assets.babylonjs.com/particles",e})(),Ga.ParticleHelper=ka,Wa=$a||($a={}),Ha=(function(l){function e(e,t,i,r){var n=l.call(this,e,r)||this;n._useDirectMapping=!1,e=e||"videoDome",i.resolution=0|Math.abs(i.resolution)||32,i.clickToPlay=Boolean(i.clickToPlay),i.autoPlay=void 0===i.autoPlay||Boolean(i.autoPlay),i.loop=void 0===i.loop||Boolean(i.loop),i.size=Math.abs(i.size)||(r.activeCamera?.48*r.activeCamera.maxZ:1e3),void 0===i.useDirectMapping?n._useDirectMapping=!0:n._useDirectMapping=i.useDirectMapping,n._setReady(!1);var o={loop:i.loop,autoPlay:i.autoPlay,autoUpdateTexture:!0,poster:i.poster},s=n._material=new Wa.BackgroundMaterial(e+"_material",r),a=n._videoTexture=new Wa.VideoTexture(e+"_texture",t,r,!1,n._useDirectMapping,Wa.Texture.TRILINEAR_SAMPLINGMODE,o);return n._mesh=Wa.Mesh.CreateSphere(e+"_mesh",i.resolution,i.size,r,!1,Wa.Mesh.BACKSIDE),a.onLoadObservable.addOnce((function(){n._setReady(!0)})),s.useEquirectangularFOV=!0,s.fovMultiplier=1,s.opacityFresnel=!1,n._useDirectMapping?(a.wrapU=Wa.Texture.CLAMP_ADDRESSMODE,a.wrapV=Wa.Texture.CLAMP_ADDRESSMODE,s.diffuseTexture=a):(a.coordinatesMode=Wa.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,a.wrapV=Wa.Texture.CLAMP_ADDRESSMODE,s.reflectionTexture=a),n._mesh.material=s,n._mesh.parent=n,i.clickToPlay&&(r.onPointerUp=function(){n._videoTexture.video.play()}),n}return T(e,l),Object.defineProperty(e.prototype,"videoTexture",{get:function(){return this._videoTexture},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(e,t){void 0===t&&(t=!1),this._videoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),l.prototype.dispose.call(this,e,t)},e})(Wa.TransformNode),Wa.VideoDome=Ha,Xa=$a||($a={}),ja=(function(a){function e(e,t,i,r,n){void 0===n&&(n=null);var o=a.call(this,e,r)||this;o._useDirectMapping=!1,o.onLoadErrorObservable=new Xa.Observable,e=e||"photoDome",i.resolution=0|Math.abs(i.resolution)||32,i.size=Math.abs(i.size)||(r.activeCamera?.48*r.activeCamera.maxZ:1e3),void 0===i.useDirectMapping?o._useDirectMapping=!0:o._useDirectMapping=i.useDirectMapping,o._setReady(!1);var s=o._material=new Xa.BackgroundMaterial(e+"_material",r);return o._mesh=Xa.Mesh.CreateSphere(e+"_mesh",i.resolution,i.size,r,!1,Xa.Mesh.BACKSIDE),s.opacityFresnel=!1,s.useEquirectangularFOV=!0,s.fovMultiplier=1,o.photoTexture=new Xa.Texture(t,r,!0,!o._useDirectMapping,void 0,void 0,function(e,t){o.onLoadErrorObservable.notifyObservers(e||"Unknown error occured"),n&&n(e,t)}),o.photoTexture.onLoadObservable.addOnce((function(){o._setReady(!0)})),o._mesh.material=s,o._mesh.parent=o}return T(e,a),Object.defineProperty(e.prototype,"photoTexture",{get:function(){return this._photoTexture},set:function(e){this._photoTexture!==e&&(this._photoTexture=e,this._useDirectMapping?(this._photoTexture.wrapU=Xa.Texture.CLAMP_ADDRESSMODE,this._photoTexture.wrapV=Xa.Texture.CLAMP_ADDRESSMODE,this._material.diffuseTexture=this._photoTexture):(this._photoTexture.coordinatesMode=Xa.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE,this._photoTexture.wrapV=Xa.Texture.CLAMP_ADDRESSMODE,this._material.reflectionTexture=this._photoTexture))},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"fovMultiplier",{get:function(){return this._material.fovMultiplier},set:function(e){this._material.fovMultiplier=e},enumerable:!0,configurable:!0}),e.prototype.dispose=function(e,t){void 0===t&&(t=!1),this._photoTexture.dispose(),this._mesh.dispose(),this._material.dispose(),this.onLoadErrorObservable.clear(),a.prototype.dispose.call(this,e,t)},e})(Xa.TransformNode),Xa.PhotoDome=ja,Ya=$a||($a={}),Ka=function(){this.occlusionInternalRetryCounter=0,this.isOcclusionQueryInProgress=!1,this.isOccluded=!1,this.occlusionRetryCount=-1,this.occlusionType=Ya.AbstractMesh.OCCLUSION_TYPE_NONE,this.occlusionQueryAlgorithmType=Ya.AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE},Ya.Engine.prototype.createQuery=function(){return this._gl.createQuery()},Ya.Engine.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},Ya.Engine.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},Ya.Engine.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},Ya.Engine.prototype.beginOcclusionQuery=function(e,t){var i=this._getGlAlgorithmType(e);return this._gl.beginQuery(i,t),this},Ya.Engine.prototype.endOcclusionQuery=function(e){var t=this._getGlAlgorithmType(e);return this._gl.endQuery(t),this},Ya.Engine.prototype._createTimeQuery=function(){var e=this.getCaps().timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},Ya.Engine.prototype._deleteTimeQuery=function(e){var t=this.getCaps().timerQuery;t.deleteQueryEXT?t.deleteQueryEXT(e):this.deleteQuery(e)},Ya.Engine.prototype._getTimeQueryResult=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},Ya.Engine.prototype._getTimeQueryAvailability=function(e){var t=this.getCaps().timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},Ya.Engine.prototype.startTimeQuery=function(){var e=this.getCaps(),t=e.timerQuery;if(!t)return null;var i=new Ya._TimeToken;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),e.canUseTimestampForTimerQuery)i._startTimeQuery=this._createTimeQuery(),t.queryCounterEXT(i._startTimeQuery,t.TIMESTAMP_EXT);else{if(this._currentNonTimestampToken)return this._currentNonTimestampToken;i._timeElapsedQuery=this._createTimeQuery(),t.beginQueryEXT?t.beginQueryEXT(t.TIME_ELAPSED_EXT,i._timeElapsedQuery):this._gl.beginQuery(t.TIME_ELAPSED_EXT,i._timeElapsedQuery),this._currentNonTimestampToken=i}return i},Ya.Engine.prototype.endTimeQuery=function(e){var t=this.getCaps(),i=t.timerQuery;if(!i||!e)return-1;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),i.queryCounterEXT(e._endTimeQuery,i.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;i.endQueryEXT?i.endQueryEXT(i.TIME_ELAPSED_EXT):this._gl.endQuery(i.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var r=this._gl.getParameter(i.GPU_DISJOINT_EXT),n=!1;if(e._endTimeQuery?n=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(n=this._getTimeQueryAvailability(e._timeElapsedQuery)),n&&!r){var o=0;if(t.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var s=this._getTimeQueryResult(e._startTimeQuery);o=this._getTimeQueryResult(e._endTimeQuery)-s,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;o=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return o}return-1},Ya.Engine.prototype._getGlAlgorithmType=function(e){return e===Ya.AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},Object.defineProperty(Ya.AbstractMesh.prototype,"isOcclusionQueryInProgress",{get:function(){return this._occlusionDataStorage.isOcclusionQueryInProgress},enumerable:!1,configurable:!0}),Object.defineProperty(Ya.AbstractMesh.prototype,"_occlusionDataStorage",{get:function(){return this.__occlusionDataStorage||(this.__occlusionDataStorage=new Ka),this.__occlusionDataStorage},enumerable:!1,configurable:!0}),Object.defineProperty(Ya.AbstractMesh.prototype,"isOccluded",{get:function(){return this._occlusionDataStorage.isOccluded},set:function(e){this._occlusionDataStorage.isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(Ya.AbstractMesh.prototype,"occlusionQueryAlgorithmType",{get:function(){return this._occlusionDataStorage.occlusionQueryAlgorithmType},set:function(e){this._occlusionDataStorage.occlusionQueryAlgorithmType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Ya.AbstractMesh.prototype,"occlusionType",{get:function(){return this._occlusionDataStorage.occlusionType},set:function(e){this._occlusionDataStorage.occlusionType=e},enumerable:!0,configurable:!0}),Object.defineProperty(Ya.AbstractMesh.prototype,"occlusionRetryCount",{get:function(){return this._occlusionDataStorage.occlusionRetryCount},set:function(e){this._occlusionDataStorage.occlusionRetryCount=e},enumerable:!0,configurable:!0}),Ya.AbstractMesh.prototype._checkOcclusionQuery=function(){var e=this._occlusionDataStorage;if(e.occlusionType===Ya.AbstractMesh.OCCLUSION_TYPE_NONE)return e.isOccluded=!1;var t=this.getEngine();if(t.webGLVersion<2)return e.isOccluded=!1;if(!t.isQueryResultAvailable)return e.isOccluded=!1;if(this.isOcclusionQueryInProgress&&this._occlusionQuery)if(t.isQueryResultAvailable(this._occlusionQuery)){var i=t.getQueryResult(this._occlusionQuery);e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=1!==i}else{if(e.occlusionInternalRetryCounter++,!(-1!==e.occlusionRetryCount&&e.occlusionInternalRetryCounter>e.occlusionRetryCount))return!1;e.isOcclusionQueryInProgress=!1,e.occlusionInternalRetryCounter=0,e.isOccluded=e.occlusionType!==Ya.AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC&&e.isOccluded}var r=this.getScene();if(r.getBoundingBoxRenderer){var n=r.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=t.createQuery()),t.beginOcclusionQuery(e.occlusionQueryAlgorithmType,this._occlusionQuery),n.renderOcclusionBoundingBox(this),t.endOcclusionQuery(e.occlusionQueryAlgorithmType),this._occlusionDataStorage.isOcclusionQueryInProgress=!0}return e.isOccluded},Qa=$a||($a={}),Za=(function(s){function n(e,t,i,r,n){void 0===t&&(t=256),void 0===i&&(i=Qa.Engine.LastCreatedScene);var o=s.call(this,e,t,"noise",i,r,n)||this;return o._time=0,o.brightness=.2,o.octaves=3,o.persistence=.8,o.animationSpeedFactor=1,o.autoClear=!1,o._updateShaderUniforms(),o}return T(n,s),n.prototype._updateShaderUniforms=function(){var e=this.getScene();e&&(this._time+=e.getAnimationRatio()*this.animationSpeedFactor*.01,this.setFloat("brightness",this.brightness),this.setFloat("persistence",this.persistence),this.setFloat("timeScale",this._time))},n.prototype._getDefines=function(){return"#define OCTAVES "+(0|this.octaves)},n.prototype.render=function(e){this._updateShaderUniforms(),s.prototype.render.call(this,e)},n.prototype.serialize=function(){var e={customType:"BABYLON.NoiseProceduralTexture"};return e.brightness=this.brightness,e.octaves=this.octaves,e.persistence=this.persistence,e.animationSpeedFactor=this.animationSpeedFactor,e.size=this.getSize().width,e.generateMipMaps=this._generateMipMaps,e},n.Parse=function(e,t,i){var r=new n(e.name,e.size,t,void 0,e.generateMipMaps);return r.brightness=e.brightness,r.octaves=e.octaves,r.persistence=e.persistence,r.animationSpeedFactor=e.animationSpeedFactor,r},n})(Qa.ProceduralTexture),Qa.NoiseProceduralTexture=Za;var qa,Ja,$a,el;ae=this&&this.__assign||function(){return(ae=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var n in t=arguments[i])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e}).apply(this,arguments)};qa=$a||($a={}),Ja=(function(){function n(e,t){if(void 0===t&&(t=null),!n.IsSupported(e))throw"Your browser does not support recording so far.";var i=e.getRenderingCanvas();if(!i)throw"The babylon engine must have a canvas to be recorded";this._canvas=i,this._canvas.isRecording=!1,this._options=ae({},n._defaultOptions,t);var r=this._canvas.captureStream(this._options.fps);this._mediaRecorder=new MediaRecorder(r,{mimeType:this._options.mimeType}),this._mediaRecorder.ondataavailable=this._handleDataAvailable.bind(this),this._mediaRecorder.onerror=this._handleError.bind(this),this._mediaRecorder.onstop=this._handleStop.bind(this)}return n.IsSupported=function(e){var t=e.getRenderingCanvas();return!!t&&"function"==typeof t.captureStream},Object.defineProperty(n.prototype,"isRecording",{get:function(){return!!this._canvas&&this._canvas.isRecording},enumerable:!0,configurable:!0}),n.prototype.stopRecording=function(){this._canvas&&this._mediaRecorder&&this.isRecording&&(this._canvas.isRecording=!1,this._mediaRecorder.stop())},n.prototype.startRecording=function(e,t){var i=this;if(void 0===e&&(e="babylonjs.webm"),void 0===t&&(t=7),!this._canvas||!this._mediaRecorder)throw"Recorder has already been disposed";if(this.isRecording)throw"Recording already in progress";return 0<t&&setTimeout((function(){i.stopRecording()}),1e3*t),this._fileName=e,this._recordedChunks=[],this._resolve=null,this._reject=null,this._canvas.isRecording=!0,this._mediaRecorder.start(this._options.recordChunckSize),new Promise(function(e,t){i._resolve=e,i._reject=t})},n.prototype.dispose=function(){this._canvas=null,this._mediaRecorder=null,this._recordedChunks=[],this._fileName=null,this._resolve=null,this._reject=null},n.prototype._handleDataAvailable=function(e){0<e.data.size&&this._recordedChunks.push(e.data)},n.prototype._handleError=function(e){if(this.stopRecording(),!this._reject)throw new e.error;this._reject(e.error)},n.prototype._handleStop=function(){this.stopRecording();var e=new Blob(this._recordedChunks);this._resolve&&this._resolve(e),window.URL.createObjectURL(e),this._fileName&&qa.Tools.Download(e,this._fileName)},n._defaultOptions={mimeType:"video/webm",fps:25,recordChunckSize:3e3},n})(),qa.VideoRecorder=Ja,(el=$a||($a={})).Scene.prototype.createDefaultLight=function(e){if(void 0===e&&(e=!1),e&&this.lights)for(var t=0;t<this.lights.length;t++)this.lights[t].dispose();0===this.lights.length&&new el.HemisphericLight("default light",el.Vector3.Up(),this)},el.Scene.prototype.createDefaultCamera=function(e,t,i){if(void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),t&&this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),!this.activeCamera){var r,n=this.getWorldExtends(),o=n.max.subtract(n.min),s=n.min.add(o.scale(.5)),a=1.5*o.length();if(isFinite(a)||(a=1,s.copyFromFloats(0,0,0)),e){var l=new el.ArcRotateCamera("default camera",-Math.PI/2,Math.PI/2,a,s,this);l.lowerRadiusLimit=.01*a,l.wheelPrecision=100/a,r=l}else{var c=new el.FreeCamera("default camera",new el.Vector3(s.x,s.y,-a),this);c.setTarget(s),r=c}r.minZ=.01*a,r.maxZ=1e3*a,r.speed=.2*a,this.activeCamera=r;var h=this.getEngine().getRenderingCanvas();i&&h&&r.attachControl(h)}},el.Scene.prototype.createDefaultCameraOrLight=function(e,t,i){void 0===e&&(e=!1),void 0===t&&(t=!1),void 0===i&&(i=!1),this.createDefaultLight(t),this.createDefaultCamera(e,t,i)},el.Scene.prototype.createDefaultSkybox=function(e,t,i,r,n){if(void 0===t&&(t=!1),void 0===i&&(i=1e3),void 0===r&&(r=0),void 0===n&&(n=!0),!e)return el.Tools.Warn("Can not create default skybox without environment texture."),null;n&&e&&(this.environmentTexture=e);var o=el.Mesh.CreateBox("hdrSkyBox",i,this);if(t){var s=new el.PBRMaterial("skyBox",this);s.backFaceCulling=!1,s.reflectionTexture=e.clone(),s.reflectionTexture&&(s.reflectionTexture.coordinatesMode=el.Texture.SKYBOX_MODE),s.microSurface=1-r,s.disableLighting=!0,s.twoSidedLighting=!0,o.infiniteDistance=!0,o.material=s}else{var a=new el.StandardMaterial("skyBox",this);a.backFaceCulling=!1,a.reflectionTexture=e.clone(),a.reflectionTexture&&(a.reflectionTexture.coordinatesMode=el.Texture.SKYBOX_MODE),a.disableLighting=!0,o.infiniteDistance=!0,o.material=a}return o},el.Scene.prototype.createDefaultEnvironment=function(e){return el.EnvironmentHelper?new el.EnvironmentHelper(e,this):null},el.Scene.prototype.createDefaultVRExperience=function(e){return void 0===e&&(e={}),new el.VRExperienceHelper(this,e)},$a.Effect.ShadersStore={defaultVertexShader:"#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL \nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif \n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n",defaultPixelShader:"#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY \n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n",pbrVertexShader:"precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif \n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif \n#if defined(ALBEDO) && ALBEDODIRECTUV == 0 \nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0 \nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0 \nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0 \nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0 \nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0 \nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0 \nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0 \nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<bumpVertex>\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n\n#include<logDepthVertex>\n}",pbrPixelShader:"#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2;\n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrLightFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#include<bumpFragment>\n#ifdef SPECULARAA\nvec3 nDfdx=dFdx(normalW.xyz);\nvec3 nDfdy=dFdy(normalW.xyz);\nfloat slopeSquare=max(dot(nDfdx,nDfdx),dot(nDfdy,nDfdy));\n\nfloat geometricRoughnessFactor=pow(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n#else\nfloat geometricRoughnessFactor=0.;\n#endif\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\n#ifdef SPECULARAA\n\n\nalphaG+=(0.75*geometricAlphaGFactor);\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#if defined(LODINREFLECTIONALPHA) && !defined(REFLECTIONMAP_SKYBOX)\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat reflectionLOD=getLodFromAlphaG(vReflectionMicrosurfaceInfos.x,alphaG,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\nvec3 irradianceVector=vec3(reflectionMatrix*vec4(normalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nirradianceVector.z*=-1.0;\n#endif\nenvironmentIrradiance=environmentIrradianceJones(irradianceVector);\n#endif\n#endif\n\nenvironmentRadiance.rgb*=vReflectionInfos.x;\nenvironmentRadiance.rgb*=vReflectionColor.rgb;\nenvironmentIrradiance*=vReflectionColor.rgb;\n#endif\n\n\n\nfloat reflectance=max(max(surfaceReflectivityColor.r,surfaceReflectivityColor.g),surfaceReflectivityColor.b);\nfloat reflectance90=fresnelGrazingReflectance(reflectance);\nvec3 specularEnvironmentR0=surfaceReflectivityColor.rgb;\nvec3 specularEnvironmentR90=vec3(1.0,1.0,1.0)*reflectance90;\n\nvec3 diffuseBase=vec3(0.,0.,0.);\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb;\n#ifdef GAMMALIGHTMAP\nlightmapColor=toLinearSpace(lightmapColor);\n#endif\nlightmapColor*=vLightmapInfos.y;\n#endif\nlightingInfo info;\npointLightingInfo pointInfo;\nspotLightingInfo spotInfo;\nfloat shadow=1.; \nfloat NdotL=-1.;\n#include<lightFragment>[0..maxSimultaneousLights]\n\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef ALPHABLEND\nfloat luminanceOverAlpha=0.0;\n#if defined(REFLECTION) && defined(RADIANCEOVERALPHA)\nluminanceOverAlpha+=getLuminance(finalRadianceScaled);\n#endif\n#if defined(SPECULARTERM) && defined(SPECULAROVERALPHA)\nluminanceOverAlpha+=getLuminance(finalSpecularScaled);\n#endif\n#if defined(RADIANCEOVERALPHA) || defined(SPECULAROVERALPHA)\nalpha=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse.rgb+=vAmbientColor;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}",rgbdEncodePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void) \n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}",rgbdDecodePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void) \n{\ngl_FragColor=vec4(fromRGBD(texture2D(textureSampler,vUV)),1.0);\n}",spritesVertexShader:"\nattribute vec4 position;\nattribute vec4 options;\nattribute vec4 cellInfo;\nattribute vec4 color;\n\nuniform vec2 textureInfos;\nuniform mat4 view;\nuniform mat4 projection;\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#include<fogVertexDeclaration>\nvoid main(void) { \nvec3 viewPos=(view*vec4(position.xyz,1.0)).xyz; \nvec2 cornerPos;\nfloat angle=position.w;\nvec2 size=vec2(options.x,options.y);\nvec2 offset=options.zw;\nvec2 uvScale=textureInfos.xy;\ncornerPos=vec2(offset.x-0.5,offset.y-0.5)*size;\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nviewPos+=rotatedCorner;\ngl_Position=projection*vec4(viewPos,1.0); \n\nvColor=color;\n\nvec2 uvOffset=vec2(abs(offset.x-cellInfo.x),1.0-abs(offset.y-cellInfo.y));\nvUV=(uvOffset+cellInfo.zw)*uvScale;\n\n#ifdef FOG\nvFogDistance=viewPos;\n#endif\n}",spritesPixelShader:"uniform bool alphaTest;\nvarying vec4 vColor;\n\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\nvec4 color=texture2D(diffuseSampler,vUV);\nif (alphaTest) \n{\nif (color.a<0.95)\ndiscard;\n}\ncolor*=vColor;\n#include<fogFragment>\ngl_FragColor=color;\n}",particlesVertexShader:"\nattribute vec3 position;\nattribute vec4 color;\nattribute float angle;\nattribute vec2 size;\n#ifdef ANIMATESHEET \nattribute float cellIndex;\n#endif\n#ifndef BILLBOARD \nattribute vec3 direction;\n#endif\n#ifdef BILLBOARDSTRETCHED\nattribute vec3 direction; \n#endif\n#ifdef RAMPGRADIENT\nattribute vec4 remapData;\n#endif\nattribute vec2 offset;\n\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n#ifdef ANIMATESHEET \nuniform vec3 particlesInfos; \n#endif\n\nvarying vec2 vUV;\nvarying vec4 vColor;\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\n#endif\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration>\n#ifdef BILLBOARD\nuniform vec3 eyePosition; \n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner; \n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner; \n}\n#endif\nvoid main(void) { \nvec2 cornerPos;\ncornerPos=(vec2(offset.x-0.5,offset.y-0.5)-translationPivot)*size+translationPivot;\n#ifdef BILLBOARD \n\nvec3 rotatedCorner;\n#ifdef BILLBOARDY \nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz; \n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition; \nvec3 worldPos=rotateAlign(toCamera,rotatedCorner);\nvec3 viewPos=(view*vec4(worldPos,1.0)).xyz; \n#else\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 viewPos=(view*vec4(position,1.0)).xyz+rotatedCorner; \n#endif\n#ifdef RAMPGRADIENT\nremapRanges=remapData;\n#endif\n\ngl_Position=projection*vec4(viewPos,1.0); \n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=normalize(direction);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\ngl_Position=projection*view*vec4(worldPos,1.0); \n#endif \nvColor=color;\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/particlesInfos.z);\nfloat columnOffset=cellIndex-rowOffset*particlesInfos.z;\nvec2 uvScale=particlesInfos.xy;\nvec2 uvOffset=vec2(offset.x ,1.0-offset.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=offset;\n#endif\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*vec4(viewPos,1.0);\n#endif\n#include<clipPlaneVertex>\n}",particlesPixelShader:"\nvarying vec2 vUV;\nvarying vec4 vColor;\nuniform vec4 textureMask;\nuniform sampler2D diffuseSampler;\n#include<clipPlaneFragmentDeclaration>\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n#ifdef RAMPGRADIENT\nvarying vec4 remapRanges;\nuniform sampler2D rampSampler;\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec4 textureColor=texture2D(diffuseSampler,vUV);\nvec4 baseColor=(textureColor*textureMask+(vec4(1.,1.,1.,1.)-textureMask))*vColor;\n#ifdef RAMPGRADIENT\nfloat alpha=baseColor.a;\nfloat remappedColorIndex=clamp((alpha-remapRanges.x)/remapRanges.y,0.0,1.0);\nvec4 rampColor=texture2D(rampSampler,vec2(1.0-remappedColorIndex,0.));\nbaseColor.rgb*=rampColor.rgb;\n\nfloat finalAlpha=baseColor.a;\nbaseColor.a=clamp((alpha*rampColor.a-remapRanges.z)/remapRanges.w,0.0,1.0);\n#endif\n#ifdef BLENDMULTIPLYMODE\nfloat sourceAlpha=vColor.a*textureColor.a;\nbaseColor.rgb=baseColor.rgb*sourceAlpha+vec3(1.0)*(1.0-sourceAlpha);\n#endif\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\nbaseColor.rgb=toLinearSpace(baseColor.rgb);\nbaseColor=applyImageProcessing(baseColor);\n#endif\n#endif\ngl_FragColor=baseColor;\n}",colorVertexShader:"\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}",colorPixelShader:"#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}",gpuRenderParticlesVertexShader:"#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition; \n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner; \n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else \nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY \nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0)); \n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition; \nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0)); \n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4(position,1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0); \n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif \n#include<clipPlaneVertex>\n}",gpuRenderParticlesPixelShader:"#version 300 es\nuniform sampler2D textureSampler;\nin vec2 vUV;\nin vec4 vColor;\nout vec4 outFragColor;\n#include<clipPlaneFragmentDeclaration2> \n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main() {\n#include<clipPlaneFragment> \nvec4 textureColor=texture(textureSampler,vUV);\noutFragColor=textureColor*vColor;\n#ifdef BLENDMULTIPLYMODE\nfloat alpha=vColor.a*textureColor.a;\noutFragColor.rgb=outFragColor.rgb*alpha+vec3(1.0)*(1.0-alpha); \n#endif \n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\n#else\n#ifdef IMAGEPROCESSING\noutFragColor.rgb=toLinearSpace(outFragColor.rgb);\noutFragColor=applyImageProcessing(outFragColor);\n#endif\n#endif\n}\n",gpuUpdateParticlesVertexShader:"#version 300 es\n#define PI 3.14159\nuniform float currentCount;\nuniform float timeDelta;\nuniform float stopFactor;\nuniform mat4 emitterWM;\nuniform vec2 lifeTime;\nuniform vec2 emitPower;\nuniform vec2 sizeRange;\nuniform vec4 scaleRange;\n#ifndef COLORGRADIENTS\nuniform vec4 color1;\nuniform vec4 color2;\n#endif\nuniform vec3 gravity;\nuniform sampler2D randomSampler;\nuniform sampler2D randomSampler2;\nuniform vec4 angleRange;\n#ifdef BOXEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\nuniform vec3 minEmitBox;\nuniform vec3 maxEmitBox;\n#endif\n#ifdef POINTEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#endif\n#ifdef HEMISPHERICEMITTER\nuniform float radius;\nuniform float radiusRange;\nuniform float directionRandomizer;\n#endif\n#ifdef SPHEREEMITTER\nuniform float radius;\nuniform float radiusRange;\n#ifdef DIRECTEDSPHEREEMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CYLINDEREMITTER\nuniform float radius;\nuniform float height;\nuniform float radiusRange;\n#ifdef DIRECTEDCYLINDEREMITTER\nuniform vec3 direction1;\nuniform vec3 direction2;\n#else\nuniform float directionRandomizer;\n#endif\n#endif\n#ifdef CONEEMITTER\nuniform vec2 radius;\nuniform float coneAngle;\nuniform vec2 height;\nuniform float directionRandomizer;\n#endif\n\nin vec3 position;\nin float age;\nin float life;\nin vec4 seed;\nin vec3 size;\n#ifndef COLORGRADIENTS\nin vec4 color;\n#endif\nin vec3 direction;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nin float angle;\n#else\nin vec2 angle;\n#endif\n#ifdef ANIMATESHEET\nin float cellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nin float cellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nin vec3 noiseCoordinates1;\nin vec3 noiseCoordinates2;\n#endif\n\nout vec3 outPosition;\nout float outAge;\nout float outLife;\nout vec4 outSeed;\nout vec3 outSize;\n#ifndef COLORGRADIENTS\nout vec4 outColor;\n#endif\nout vec3 outDirection;\n#ifndef BILLBOARD\nout vec3 outInitialDirection;\n#endif\n#ifdef ANGULARSPEEDGRADIENTS\nout float outAngle;\n#else\nout vec2 outAngle;\n#endif\n#ifdef ANIMATESHEET\nout float outCellIndex;\n#ifdef ANIMATESHEETRANDOMSTART\nout float outCellStartOffset;\n#endif\n#endif\n#ifdef NOISE\nout vec3 outNoiseCoordinates1;\nout vec3 outNoiseCoordinates2;\n#endif\n#ifdef SIZEGRADIENTS\nuniform sampler2D sizeGradientSampler;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nuniform sampler2D angularSpeedGradientSampler;\n#endif \n#ifdef VELOCITYGRADIENTS\nuniform sampler2D velocityGradientSampler;\n#endif\n#ifdef LIMITVELOCITYGRADIENTS\nuniform sampler2D limitVelocityGradientSampler;\nuniform float limitVelocityDamping;\n#endif\n#ifdef DRAGGRADIENTS\nuniform sampler2D dragGradientSampler;\n#endif\n#ifdef NOISE\nuniform vec3 noiseStrength;\nuniform sampler2D noiseSampler;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 cellInfos;\n#endif\nvec3 getRandomVec3(float offset) {\nreturn texture(randomSampler2,vec2(float(gl_VertexID)*offset/currentCount,0)).rgb;\n}\nvec4 getRandomVec4(float offset) {\nreturn texture(randomSampler,vec2(float(gl_VertexID)*offset/currentCount,0));\n}\nvoid main() {\nfloat newAge=age+timeDelta; \n\nif (newAge>=life && stopFactor != 0.) {\nvec3 position;\nvec3 direction;\n\nvec4 randoms=getRandomVec4(seed.x);\n\noutLife=lifeTime.x+(lifeTime.y-lifeTime.x)*randoms.r;\noutAge=mod(newAge,outLife);\n\noutSeed=seed;\n\n#ifdef SIZEGRADIENTS \noutSize.x=texture(sizeGradientSampler,vec2(0,0)).r;\n#else\noutSize.x=sizeRange.x+(sizeRange.y-sizeRange.x)*randoms.g;\n#endif\noutSize.y=scaleRange.x+(scaleRange.y-scaleRange.x)*randoms.b;\noutSize.z=scaleRange.z+(scaleRange.w-scaleRange.z)*randoms.a; \n#ifndef COLORGRADIENTS\n\noutColor=color1+(color2-color1)*randoms.b;\n#endif\n\n#ifndef ANGULARSPEEDGRADIENTS \noutAngle.y=angleRange.x+(angleRange.y-angleRange.x)*randoms.a;\noutAngle.x=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#else\noutAngle=angleRange.z+(angleRange.w-angleRange.z)*randoms.r;\n#endif \n\n#ifdef POINTEMITTER\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=vec3(0,0,0);\ndirection=direction1+(direction2-direction1)*randoms3;\n#elif defined(BOXEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\nposition=minEmitBox+(maxEmitBox-minEmitBox)*randoms2;\ndirection=direction1+(direction2-direction1)*randoms3; \n#elif defined(HEMISPHERICEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,abs(randY),randZ);\ndirection=position+directionRandomizer*randoms3; \n#elif defined(SPHEREEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat phi=2.0*PI*randoms2.x;\nfloat theta=acos(2.0*randoms2.y-1.0);\nfloat randX=cos(phi)*sin(theta);\nfloat randY=cos(theta);\nfloat randZ=sin(phi)*sin(theta);\nposition=(radius-(radius*radiusRange*randoms2.z))*vec3(randX,randY,randZ);\n#ifdef DIRECTEDSPHEREEMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\ndirection=position+directionRandomizer*randoms3;\n#endif\n#elif defined(CYLINDEREMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nvec3 randoms3=getRandomVec3(seed.z);\n\nfloat yPos=(randoms2.x-0.5)*height;\nfloat angle=randoms2.y*PI*2.;\nfloat inverseRadiusRangeSquared=((1.-radiusRange)*(1.-radiusRange));\nfloat positionRadius=radius*sqrt(inverseRadiusRangeSquared+(randoms2.z*(1.-inverseRadiusRangeSquared)));\nfloat xPos=positionRadius*cos(angle);\nfloat zPos=positionRadius*sin(angle);\nposition=vec3(xPos,yPos,zPos);\n#ifdef DIRECTEDCYLINDEREMITTER\ndirection=direction1+(direction2-direction1)*randoms3;\n#else\n\nangle=angle+((randoms3.x-0.5)*PI);\ndirection=vec3(cos(angle),randoms3.y-0.5,sin(angle));\ndirection=normalize(direction);\n#endif\n#elif defined(CONEEMITTER)\nvec3 randoms2=getRandomVec3(seed.y);\nfloat s=2.0*PI*randoms2.x;\n#ifdef CONEEMITTERSPAWNPOINT\nfloat h=0.00001;\n#else\nfloat h=randoms2.y*height.y;\n\nh=1.-h*h; \n#endif\nfloat lRadius=radius.x-radius.x*randoms2.z*radius.y;\nlRadius=lRadius*h;\nfloat randX=lRadius*sin(s);\nfloat randZ=lRadius*cos(s);\nfloat randY=h*height.x;\nposition=vec3(randX,randY,randZ); \n\nif (abs(cos(coneAngle)) == 1.0) {\ndirection=vec3(0.,1.0,0.);\n} else {\nvec3 randoms3=getRandomVec3(seed.z);\ndirection=position+directionRandomizer*randoms3;\n}\n#else \n\nposition=vec3(0.,0.,0.);\n\ndirection=2.0*(getRandomVec3(seed.w)-vec3(0.5,0.5,0.5));\n#endif\nfloat power=emitPower.x+(emitPower.y-emitPower.x)*randoms.a;\noutPosition=(emitterWM*vec4(position,1.)).xyz;\nvec3 initial=(emitterWM*vec4(direction,0.)).xyz;\noutDirection=initial*power;\n#ifndef BILLBOARD \noutInitialDirection=initial;\n#endif\n#ifdef ANIMATESHEET \noutCellIndex=cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=randoms.a*outLife;\n#endif \n#endif\n#ifdef NOISE\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif\n} else {\nfloat directionScale=timeDelta;\noutAge=newAge;\nfloat ageGradient=newAge/life;\n#ifdef VELOCITYGRADIENTS\ndirectionScale*=texture(velocityGradientSampler,vec2(ageGradient,0)).r;\n#endif\n#ifdef DRAGGRADIENTS\ndirectionScale*=1.0-texture(dragGradientSampler,vec2(ageGradient,0)).r;\n#endif\noutPosition=position+direction*directionScale;\noutLife=life;\noutSeed=seed;\n#ifndef COLORGRADIENTS \noutColor=color;\n#endif\n#ifdef SIZEGRADIENTS\noutSize.x=texture(sizeGradientSampler,vec2(ageGradient,0)).r;\noutSize.yz=size.yz;\n#else\noutSize=size;\n#endif \n#ifndef BILLBOARD \noutInitialDirection=initialDirection;\n#endif\nvec3 updatedDirection=direction+gravity*timeDelta;\n#ifdef LIMITVELOCITYGRADIENTS\nfloat limitVelocity=texture(limitVelocityGradientSampler,vec2(ageGradient,0)).r;\nfloat currentVelocity=length(updatedDirection);\nif (currentVelocity>limitVelocity) {\nupdatedDirection=updatedDirection*limitVelocityDamping;\n}\n#endif\noutDirection=updatedDirection;\n#ifdef NOISE\nvec3 localPosition=outPosition-emitterWM[3].xyz;\nfloat fetchedR=texture(noiseSampler,vec2(noiseCoordinates1.x,noiseCoordinates1.y)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedG=texture(noiseSampler,vec2(noiseCoordinates1.z,noiseCoordinates2.x)*vec2(0.5)+vec2(0.5)).r;\nfloat fetchedB=texture(noiseSampler,vec2(noiseCoordinates2.y,noiseCoordinates2.z)*vec2(0.5)+vec2(0.5)).r;\nvec3 force=vec3(2.*fetchedR-1.,2.*fetchedG-1.,2.*fetchedB-1.)*noiseStrength;\noutDirection=outDirection+force*timeDelta;\noutNoiseCoordinates1=noiseCoordinates1;\noutNoiseCoordinates2=noiseCoordinates2;\n#endif \n#ifdef ANGULARSPEEDGRADIENTS\nfloat angularSpeed=texture(angularSpeedGradientSampler,vec2(ageGradient,0)).r;\noutAngle=angle+angularSpeed*timeDelta;\n#else\noutAngle=vec2(angle.x+angle.y*timeDelta,angle.y);\n#endif\n#ifdef ANIMATESHEET \nfloat offsetAge=outAge;\nfloat dist=cellInfos.y-cellInfos.x;\n#ifdef ANIMATESHEETRANDOMSTART\noutCellStartOffset=cellStartOffset;\noffsetAge+=cellStartOffset;\n#endif \nfloat ratio=clamp(mod(offsetAge*cellInfos.z,life)/life,0.,1.0);\noutCellIndex=float(int(cellInfos.x+ratio*dist));\n#endif\n}\n}",gpuUpdateParticlesPixelShader:"#version 300 es\nvoid main() {\ndiscard;\n}\n",postprocessVertexShader:"\nattribute vec2 position;\nuniform vec2 scale;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd)*scale;\ngl_Position=vec4(position,0.0,1.0);\n}",passPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}",shadowMapVertexShader:"\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\nuniform vec3 lightData;\n#endif\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\n#include<helperFunctions>\nuniform mat4 viewProjection;\nuniform vec3 biasAndScale;\nuniform vec2 depthValues;\nvarying float vDepthMetric;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\n\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvec3 worldNor=normalize(normalWorld*normal);\n#ifdef DIRECTIONINLIGHTDATA\nvec3 worldLightDir=normalize(-lightData.xyz);\n#else\nvec3 directionToLight=lightData.xyz-worldPos.xyz;\nvec3 worldLightDir=normalize(directionToLight);\n#endif\nfloat ndl=dot(worldNor,worldLightDir);\nfloat sinNL=sqrt(1.0-ndl*ndl);\nfloat normalBias=biasAndScale.y*sinNL;\nworldPos.xyz-=worldNor*normalBias;\n#endif\n\ngl_Position=viewProjection*worldPos;\n#ifdef DEPTHTEXTURE\n\ngl_Position.z+=biasAndScale.x*gl_Position.w;\n#endif\n\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y))+biasAndScale.x;\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",shadowMapPixelShader:"#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}",depthBoxBlurPixelShader:"\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}",proceduralVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vPosition;\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvPosition=position;\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",depthVertexShader:"\nattribute vec3 position;\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nuniform vec2 depthValues;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvDepthMetric=((gl_Position.z+depthValues.x)/(depthValues.y));\n#if defined(ALPHATEST) || defined(BASIC_RENDER)\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",depthPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\nvarying float vDepthMetric;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(vDepthMetric,vDepthMetric*vDepthMetric,0.0,1.0);\n}",geometryVertexShader:"precision highp float;\nprecision highp int;\n#include<bonesDeclaration>\n#include<instancesDeclaration>\nattribute vec3 position;\nattribute vec3 normal;\n#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nvarying vec2 uv;\n#endif\n#ifdef UV2\nvarying 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\nvoid main(void)\n{\n#include<instancesVertex>\n#include<bonesVertex>\nvec4 pos=vec4(finalWorld*vec4(position,1.0));\nvNormalV=normalize(vec3((view*finalWorld)*vec4(normal,0.0)));\nvViewPos=view*pos;\n#ifdef POSITION\nvPosition=pos.xyz/pos.w;\n#endif\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}",geometryPixelShader:"#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 ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef POSITION\n#include<mrtFragmentDeclaration>[3]\n#else\n#include<mrtFragmentDeclaration>[2]\n#endif\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[2]=vec4(vPosition,1.0);\n#endif\n}",ssaoPixelShader:"\nuniform sampler2D textureSampler;\nvarying vec2 vUV;\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float radius;\nuniform float area;\nuniform float fallOff;\nuniform float base;\nvec3 normalFromDepth(float depth,vec2 coords)\n{\nvec2 offset1=vec2(0.0,radius);\nvec2 offset2=vec2(radius,0.0);\nfloat depth1=texture2D(textureSampler,coords+offset1).r;\nfloat depth2=texture2D(textureSampler,coords+offset2).r;\nvec3 p1=vec3(offset1,depth1-depth);\nvec3 p2=vec3(offset2,depth2-depth);\nvec3 normal=cross(p1,p2);\nnormal.z=-normal.z;\nreturn normalize(normal);\n}\nvoid main()\n{\nvec3 random=normalize(texture2D(randomSampler,vUV*randTextureTiles).rgb);\nfloat depth=texture2D(textureSampler,vUV).r;\nvec3 position=vec3(vUV,depth);\nvec3 normal=normalFromDepth(depth,vUV);\nfloat radiusDepth=radius/depth;\nfloat occlusion=0.0;\nvec3 ray;\nvec3 hemiRay;\nfloat occlusionDepth;\nfloat difference;\nfor (int i=0; i<SAMPLES; i++)\n{\nray=radiusDepth*reflect(sampleSphere[i],random);\nhemiRay=position+sign(dot(ray,normal))*ray;\nocclusionDepth=texture2D(textureSampler,clamp(hemiRay.xy,vec2(0.001,0.001),vec2(0.999,0.999))).r;\ndifference=depth-occlusionDepth;\nocclusion+=step(fallOff,difference)*(1.0-smoothstep(fallOff,area,difference));\n}\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor.r=result;\ngl_FragColor.g=result;\ngl_FragColor.b=result;\ngl_FragColor.a=1.0;\n}\n#endif\n",ssao2PixelShader:"\nprecision highp float;\nuniform sampler2D textureSampler;\nuniform float near;\nuniform float far;\nuniform float radius;\nfloat scales[16]=float[16](\n0.1,\n0.11406250000000001,\n0.131640625,\n0.15625,\n0.187890625,\n0.2265625,\n0.272265625,\n0.325,\n0.384765625,\n0.4515625,\n0.525390625,\n0.60625,\n0.694140625,\n0.7890625,\n0.891015625,\n1.0\n);\nvarying vec2 vUV;\nfloat perspectiveDepthToViewZ( const in float invClipZ,const in float near,const in float far ) {\nreturn ( near*far )/( ( far-near )*invClipZ-far );\n}\nfloat viewZToPerspectiveDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( near*far/viewZ+far)/( far-near );\n}\nfloat viewZToOrthographicDepth( const in float viewZ,const in float near,const in float far ) {\nreturn ( viewZ+near )/( near-far );\n}\n#ifdef SSAO\nuniform sampler2D randomSampler;\nuniform sampler2D normalSampler;\nuniform float randTextureTiles;\nuniform float samplesFactor;\nuniform vec3 sampleSphere[SAMPLES];\nuniform float totalStrength;\nuniform float base;\nuniform float xViewport;\nuniform float yViewport;\nuniform float maxZ;\nuniform float minZAspect;\nuniform vec2 texelSize;\nuniform mat4 projection;\nvoid main()\n{\nvec3 random=texture2D(randomSampler,vUV*randTextureTiles).rgb;\nfloat depth=texture2D(textureSampler,vUV).r;\nfloat depthSign=depth/abs(depth);\ndepth=depth*depthSign;\nvec3 normal=texture2D(normalSampler,vUV).rgb; \nfloat occlusion=0.0;\nfloat correctedRadius=min(radius,minZAspect*depth/near);\nvec3 vViewRay=vec3((vUV.x*2.0-1.0)*xViewport,(vUV.y*2.0-1.0)*yViewport,depthSign);\nvec3 origin=vViewRay*depth;\nvec3 rvec=random*2.0-1.0;\nrvec.z=0.0;\n\nfloat dotProduct=dot(rvec,normal);\nrvec=1.0-abs(dotProduct)>1e-2 ? rvec : vec3(-rvec.y,0.0,rvec.x);\nvec3 tangent=normalize(rvec-normal*dot(rvec,normal));\nvec3 bitangent=cross(normal,tangent);\nmat3 tbn=mat3(tangent,bitangent,normal);\nfloat difference;\nfor (int i=0; i<SAMPLES; ++i) {\n\nvec3 samplePosition=scales[(i+int(random.x*16.0)) % 16]*tbn*sampleSphere[(i+int(random.y*16.0)) % 16];\nsamplePosition=samplePosition*correctedRadius+origin;\n\nvec4 offset=vec4(samplePosition,1.0);\noffset=projection*offset;\noffset.xyz/=offset.w;\noffset.xy=offset.xy*0.5+0.5;\nif (offset.x<0.0 || offset.y<0.0 || offset.x>1.0 || offset.y>1.0) {\ncontinue;\n}\n\nfloat sampleDepth=abs(texture2D(textureSampler,offset.xy).r);\n\ndifference=depthSign*samplePosition.z-sampleDepth;\nfloat rangeCheck=1.0-smoothstep(correctedRadius*0.5,correctedRadius,difference);\nocclusion+=(difference>=0.0 ? 1.0 : 0.0)*rangeCheck;\n}\nocclusion=occlusion*(1.0-smoothstep(maxZ*0.75,maxZ,depth));\nfloat ao=1.0-totalStrength*occlusion*samplesFactor;\nfloat result=clamp(ao+base,0.0,1.0);\ngl_FragColor=vec4(vec3(result),1.0);\n}\n#endif\n#ifdef BILATERAL_BLUR\nuniform sampler2D depthSampler;\nuniform float outSize;\nuniform float samplerOffsets[SAMPLES];\nvec4 blur9(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.3846153846)*direction;\nvec2 off2=vec2(3.2307692308)*direction;\ncolor+=texture2D(image,uv)*0.2270270270;\ncolor+=texture2D(image,uv+(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv-(off1/resolution))*0.3162162162;\ncolor+=texture2D(image,uv+(off2/resolution))*0.0702702703;\ncolor+=texture2D(image,uv-(off2/resolution))*0.0702702703;\nreturn color;\n}\nvec4 blur13(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\ncolor+=texture2D(image,uv)*0.1964825501511404;\ncolor+=texture2D(image,uv+(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv-(off1/resolution))*0.2969069646728344;\ncolor+=texture2D(image,uv+(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv-(off2/resolution))*0.09447039785044732;\ncolor+=texture2D(image,uv+(off3/resolution))*0.010381362401148057;\ncolor+=texture2D(image,uv-(off3/resolution))*0.010381362401148057;\nreturn color;\n}\nvec4 blur13Bilateral(sampler2D image,vec2 uv,float resolution,vec2 direction) {\nvec4 color=vec4(0.0);\nvec2 off1=vec2(1.411764705882353)*direction;\nvec2 off2=vec2(3.2941176470588234)*direction;\nvec2 off3=vec2(5.176470588235294)*direction;\nfloat compareDepth=abs(texture2D(depthSampler,uv).r);\nfloat sampleDepth;\nfloat weight;\nfloat weightSum=30.0;\ncolor+=texture2D(image,uv)*30.0;\nsampleDepth=abs(texture2D(depthSampler,uv+(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off1/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off1/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off2/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off2/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv+(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv+(off3/resolution))*weight;\nsampleDepth=abs(texture2D(depthSampler,uv-(off3/resolution)).r);\nweight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30.0);\nweightSum+=weight;\ncolor+=texture2D(image,uv-(off3/resolution))*weight;\nreturn color/weightSum;\n}\nvoid main()\n{\n#if EXPENSIVE\nfloat compareDepth=abs(texture2D(depthSampler,vUV).r);\nfloat texelsize=1.0/outSize;\nfloat result=0.0;\nfloat weightSum=0.0;\nfor (int i=0; i<SAMPLES; ++i)\n{\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\nvec2 sampleOffset=vec2(texelsize*samplerOffsets[i],0.0);\n#else\nvec2 direction=vec2(0.0,1.0);\nvec2 sampleOffset=vec2(0.0,texelsize*samplerOffsets[i]);\n#endif\nvec2 samplePos=vUV+sampleOffset;\nfloat sampleDepth=abs(texture2D(depthSampler,samplePos).r);\nfloat weight=clamp(1.0/( 0.003+abs(compareDepth-sampleDepth)),0.0,30000.0);\nresult+=texture2D(textureSampler,samplePos).r*weight;\nweightSum+=weight;\n}\nresult/=weightSum;\ngl_FragColor.rgb=vec3(result);\ngl_FragColor.a=1.0;\n#else\nvec4 color;\n#ifdef BILATERAL_BLUR_H\nvec2 direction=vec2(1.0,0.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#else\nvec2 direction=vec2(0.0,1.0);\ncolor=blur13Bilateral(textureSampler,vUV,outSize,direction);\n#endif\ngl_FragColor.rgb=vec3(color.r);\ngl_FragColor.a=1.0;\n#endif\n}\n#endif\n",ssaoCombinePixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D originalColor;\nuniform vec4 viewport;\nvarying vec2 vUV;\nvoid main(void) {\nvec4 ssaoColor=texture2D(textureSampler,viewport.xy+vUV*viewport.zw);\nvec4 sceneColor=texture2D(originalColor,vUV);\ngl_FragColor=sceneColor*ssaoColor;\n}\n",lensHighlightsPixelShader:"\nuniform sampler2D textureSampler; \n\nuniform float gain;\nuniform float threshold;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\n\nvec4 highlightColor(vec4 color) {\nvec4 highlight=color;\nfloat luminance=dot(highlight.rgb,vec3(0.2125,0.7154,0.0721));\nfloat lum_threshold;\nif (threshold>1.0) { lum_threshold=0.94+0.01*threshold; }\nelse { lum_threshold=0.5+0.44*threshold; }\nluminance=clamp((luminance-lum_threshold)*(1.0/(1.0-lum_threshold)),0.0,1.0);\nhighlight*=luminance*gain;\nhighlight.a=1.0;\nreturn highlight;\n}\nvoid main(void)\n{\nvec4 original=texture2D(textureSampler,vUV);\n\nif (gain == -1.0) {\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\nreturn;\n}\nfloat w=2.0/screen_width;\nfloat h=2.0/screen_height;\nfloat weight=1.0;\n\nvec4 blurred=vec4(0.0,0.0,0.0,0.0);\n#ifdef PENTAGON\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.84*w,0.43*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.48*w,-1.29*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.61*w,1.51*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.55*w,-0.74*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.71*w,-0.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.94*w,1.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.40*w,-1.87*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.62*w,1.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.09*w,0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.46*w,-1.71*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.08*w,2.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.85*w,-1.89*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.89*w,0.16*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.29*w,1.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.40*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.54*w,2.26*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.60*w,-0.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.31*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.83*w,2.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.12*w,-2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.60*w,1.11*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.99*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.50*w,-2.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.85*w,3.33*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.94*w,-1.92*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.27*w,-0.53*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.95*w,2.48*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.23*w,-3.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.17*w,2.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.97*w,-0.04*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.25*w,-2.00*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.31*w,3.08*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.94*w,-2.59*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.37*w,0.64*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.13*w,1.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.03*w,-3.65*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.60*w,3.17*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.14*w,-1.19*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.00*w,-1.19*h)));\n#else\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.85*w,0.36*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.52*w,-1.14*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.46*w,1.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.46*w,-0.83*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.79*w,-0.42*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.11*w,1.62*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.29*w,-2.07*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.69*w,1.39*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.28*w,0.12*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.65*w,-1.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.08*w,2.44*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.63*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.55*w,0.31*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.13*w,1.52*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.56*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.38*w,2.34*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.64*w,-0.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.53*w,-1.21*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.06*w,2.63*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.00*w,-2.69*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.59*w,1.32*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.82*w,0.78*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.57*w,-2.50*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(0.54*w,2.93*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.39*w,-1.81*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,-0.28*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.04*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.02*w,-3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.09*w,2.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-3.07*w,-0.25*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.44*w,-1.90*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-0.52*w,3.05*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-1.68*w,-2.61*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(3.01*w,0.79*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.76*w,1.46*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.05*w,-2.94*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(1.21*w,2.88*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(-2.84*w,-1.30*h)));\nblurred+=highlightColor(texture2D(textureSampler,vUV+vec2(2.98*w,-0.96*h)));\n#endif\nblurred/=39.0;\ngl_FragColor=blurred;\n\n}",depthOfFieldPixelShader:"\n\n\n\n\nuniform sampler2D textureSampler;\nuniform sampler2D highlightsSampler;\nuniform sampler2D depthSampler;\nuniform sampler2D grainSampler;\n\nuniform float grain_amount;\nuniform bool blur_noise;\nuniform float screen_width;\nuniform float screen_height;\nuniform float distortion;\nuniform bool dof_enabled;\n\nuniform float screen_distance; \nuniform float aperture;\nuniform float darken;\nuniform float edge_blur;\nuniform bool highlights;\n\nuniform float near;\nuniform float far;\n\nvarying vec2 vUV;\n\n#define PI 3.14159265\n#define TWOPI 6.28318530\n#define inverse_focal_length 0.1 \n\nvec2 centered_screen_pos;\nvec2 distorted_coords;\nfloat radius2;\nfloat radius;\n\nvec2 rand(vec2 co)\n{\nfloat noise1=(fract(sin(dot(co,vec2(12.9898,78.233)))*43758.5453));\nfloat noise2=(fract(sin(dot(co,vec2(12.9898,78.233)*2.0))*43758.5453));\nreturn clamp(vec2(noise1,noise2),0.0,1.0);\n}\n\nvec2 getDistortedCoords(vec2 coords) {\nif (distortion == 0.0) { return coords; }\nvec2 direction=1.0*normalize(centered_screen_pos);\nvec2 dist_coords=vec2(0.5,0.5);\ndist_coords.x=0.5+direction.x*radius2*1.0;\ndist_coords.y=0.5+direction.y*radius2*1.0;\nfloat dist_amount=clamp(distortion*0.23,0.0,1.0);\ndist_coords=mix(coords,dist_coords,dist_amount);\nreturn dist_coords;\n}\n\nfloat sampleScreen(inout vec4 color,const in vec2 offset,const in float weight) {\n\nvec2 coords=distorted_coords;\nfloat angle=rand(coords*100.0).x*TWOPI;\ncoords+=vec2(offset.x*cos(angle)-offset.y*sin(angle),offset.x*sin(angle)+offset.y*cos(angle));\ncolor+=texture2D(textureSampler,coords)*weight;\nreturn weight;\n}\n\nfloat getBlurLevel(float size) {\nreturn min(3.0,ceil(size/1.0));\n}\n\nvec4 getBlurColor(float size) {\nvec4 col=texture2D(textureSampler,distorted_coords);\nif (size == 0.0) { return col; }\n\n\nfloat blur_level=getBlurLevel(size);\nfloat w=(size/screen_width);\nfloat h=(size/screen_height);\nfloat total_weight=1.0;\nvec2 sample_coords;\ntotal_weight+=sampleScreen(col,vec2(-0.50*w,0.24*h),0.93);\ntotal_weight+=sampleScreen(col,vec2(0.30*w,-0.75*h),0.90);\ntotal_weight+=sampleScreen(col,vec2(0.36*w,0.96*h),0.87);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,-0.55*h),0.85);\ntotal_weight+=sampleScreen(col,vec2(1.33*w,-0.37*h),0.83);\ntotal_weight+=sampleScreen(col,vec2(-0.82*w,1.31*h),0.80);\ntotal_weight+=sampleScreen(col,vec2(-0.31*w,-1.67*h),0.78);\ntotal_weight+=sampleScreen(col,vec2(1.47*w,1.11*h),0.76);\ntotal_weight+=sampleScreen(col,vec2(-1.97*w,0.19*h),0.74);\ntotal_weight+=sampleScreen(col,vec2(1.42*w,-1.57*h),0.72);\nif (blur_level>1.0) {\ntotal_weight+=sampleScreen(col,vec2(0.01*w,2.25*h),0.70);\ntotal_weight+=sampleScreen(col,vec2(-1.62*w,-1.74*h),0.67);\ntotal_weight+=sampleScreen(col,vec2(2.49*w,0.20*h),0.65);\ntotal_weight+=sampleScreen(col,vec2(-2.07*w,1.61*h),0.63);\ntotal_weight+=sampleScreen(col,vec2(0.46*w,-2.70*h),0.61);\ntotal_weight+=sampleScreen(col,vec2(1.55*w,2.40*h),0.59);\ntotal_weight+=sampleScreen(col,vec2(-2.88*w,-0.75*h),0.56);\ntotal_weight+=sampleScreen(col,vec2(2.73*w,-1.44*h),0.54);\ntotal_weight+=sampleScreen(col,vec2(-1.08*w,3.02*h),0.52);\ntotal_weight+=sampleScreen(col,vec2(-1.28*w,-3.05*h),0.49);\n}\nif (blur_level>2.0) {\ntotal_weight+=sampleScreen(col,vec2(3.11*w,1.43*h),0.46);\ntotal_weight+=sampleScreen(col,vec2(-3.36*w,1.08*h),0.44);\ntotal_weight+=sampleScreen(col,vec2(1.80*w,-3.16*h),0.41);\ntotal_weight+=sampleScreen(col,vec2(0.83*w,3.65*h),0.38);\ntotal_weight+=sampleScreen(col,vec2(-3.16*w,-2.19*h),0.34);\ntotal_weight+=sampleScreen(col,vec2(3.92*w,-0.53*h),0.31);\ntotal_weight+=sampleScreen(col,vec2(-2.59*w,3.12*h),0.26);\ntotal_weight+=sampleScreen(col,vec2(-0.20*w,-4.15*h),0.22);\ntotal_weight+=sampleScreen(col,vec2(3.02*w,3.00*h),0.15);\n}\ncol/=total_weight; \n\nif (darken>0.0) {\ncol.rgb*=clamp(0.3,1.0,1.05-size*0.5*darken);\n}\n\n\n\n\nreturn col;\n}\nvoid main(void)\n{\n\ncentered_screen_pos=vec2(vUV.x-0.5,vUV.y-0.5);\nradius2=centered_screen_pos.x*centered_screen_pos.x+centered_screen_pos.y*centered_screen_pos.y;\nradius=sqrt(radius2);\ndistorted_coords=getDistortedCoords(vUV); \nvec2 texels_coords=vec2(vUV.x*screen_width,vUV.y*screen_height); \nfloat depth=texture2D(depthSampler,distorted_coords).r; \nfloat distance=near+(far-near)*depth; \nvec4 color=texture2D(textureSampler,vUV); \n\n\nfloat coc=abs(aperture*(screen_distance*(inverse_focal_length-1.0/distance)-1.0));\n\nif (dof_enabled == false || coc<0.07) { coc=0.0; }\n\nfloat edge_blur_amount=0.0;\nif (edge_blur>0.0) {\nedge_blur_amount=clamp((radius*2.0-1.0+0.15*edge_blur)*1.5,0.0,1.0)*1.3;\n}\n\nfloat blur_amount=max(edge_blur_amount,coc);\n\nif (blur_amount == 0.0) {\ngl_FragColor=texture2D(textureSampler,distorted_coords);\n}\nelse {\n\ngl_FragColor=getBlurColor(blur_amount*1.7);\n\nif (highlights) {\ngl_FragColor.rgb+=clamp(coc,0.0,1.0)*texture2D(highlightsSampler,distorted_coords).rgb;\n}\nif (blur_noise) {\n\nvec2 noise=rand(distorted_coords)*0.01*blur_amount;\nvec2 blurred_coord=vec2(distorted_coords.x+noise.x,distorted_coords.y+noise.y);\ngl_FragColor=0.04*texture2D(textureSampler,blurred_coord)+0.96*gl_FragColor;\n}\n}\n\nif (grain_amount>0.0) {\nvec4 grain_color=texture2D(grainSampler,texels_coords*0.003);\ngl_FragColor.rgb+=(-0.5+grain_color.rgb)*0.30*grain_amount;\n}\n}\n",standardPixelShader:"uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\n\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n",fxaaVertexShader:"\nattribute vec2 position;\nuniform vec2 texelSize;\n\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=(position*madd+madd);\nsampleCoordS=vUV+vec2( 0.0,1.0)*texelSize;\nsampleCoordE=vUV+vec2( 1.0,0.0)*texelSize;\nsampleCoordN=vUV+vec2( 0.0,-1.0)*texelSize;\nsampleCoordW=vUV+vec2(-1.0,0.0)*texelSize;\nsampleCoordNW=vUV+vec2(-1.0,-1.0)*texelSize;\nsampleCoordSE=vUV+vec2( 1.0,1.0)*texelSize;\nsampleCoordNE=vUV+vec2( 1.0,-1.0)*texelSize;\nsampleCoordSW=vUV+vec2(-1.0,1.0)*texelSize;\ngl_Position=vec4(position,0.0,1.0);\n}",fxaaPixelShader:"uniform sampler2D textureSampler;\nuniform vec2 texelSize;\nvarying vec2 vUV;\nvarying vec2 sampleCoordS;\nvarying vec2 sampleCoordE;\nvarying vec2 sampleCoordN;\nvarying vec2 sampleCoordW;\nvarying vec2 sampleCoordNW;\nvarying vec2 sampleCoordSE;\nvarying vec2 sampleCoordNE;\nvarying vec2 sampleCoordSW;\nconst float fxaaQualitySubpix=1.0;\nconst float fxaaQualityEdgeThreshold=0.166;\nconst float fxaaQualityEdgeThresholdMin=0.0833;\nconst vec3 kLumaCoefficients=vec3(0.2126,0.7152,0.0722);\n#define FxaaLuma(rgba) dot(rgba.rgb,kLumaCoefficients)\nvoid main(){\nvec2 posM;\nposM.x=vUV.x;\nposM.y=vUV.y;\nvec4 rgbyM=texture2D(textureSampler,vUV,0.0);\nfloat lumaM=FxaaLuma(rgbyM);\nfloat lumaS=FxaaLuma(texture2D(textureSampler,sampleCoordS,0.0));\nfloat lumaE=FxaaLuma(texture2D(textureSampler,sampleCoordE,0.0));\nfloat lumaN=FxaaLuma(texture2D(textureSampler,sampleCoordN,0.0));\nfloat lumaW=FxaaLuma(texture2D(textureSampler,sampleCoordW,0.0));\nfloat maxSM=max(lumaS,lumaM);\nfloat minSM=min(lumaS,lumaM);\nfloat maxESM=max(lumaE,maxSM);\nfloat minESM=min(lumaE,minSM);\nfloat maxWN=max(lumaN,lumaW);\nfloat minWN=min(lumaN,lumaW);\nfloat rangeMax=max(maxWN,maxESM);\nfloat rangeMin=min(minWN,minESM);\nfloat rangeMaxScaled=rangeMax*fxaaQualityEdgeThreshold;\nfloat range=rangeMax-rangeMin;\nfloat rangeMaxClamped=max(fxaaQualityEdgeThresholdMin,rangeMaxScaled);\n#ifndef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\nreturn;\n}\n#endif\nfloat lumaNW=FxaaLuma(texture2D(textureSampler,sampleCoordNW,0.0));\nfloat lumaSE=FxaaLuma(texture2D(textureSampler,sampleCoordSE,0.0));\nfloat lumaNE=FxaaLuma(texture2D(textureSampler,sampleCoordNE,0.0));\nfloat lumaSW=FxaaLuma(texture2D(textureSampler,sampleCoordSW,0.0));\nfloat lumaNS=lumaN+lumaS;\nfloat lumaWE=lumaW+lumaE;\nfloat subpixRcpRange=1.0/range;\nfloat subpixNSWE=lumaNS+lumaWE;\nfloat edgeHorz1=(-2.0*lumaM)+lumaNS;\nfloat edgeVert1=(-2.0*lumaM)+lumaWE;\nfloat lumaNESE=lumaNE+lumaSE;\nfloat lumaNWNE=lumaNW+lumaNE;\nfloat edgeHorz2=(-2.0*lumaE)+lumaNESE;\nfloat edgeVert2=(-2.0*lumaN)+lumaNWNE;\nfloat lumaNWSW=lumaNW+lumaSW;\nfloat lumaSWSE=lumaSW+lumaSE;\nfloat edgeHorz4=(abs(edgeHorz1)*2.0)+abs(edgeHorz2);\nfloat edgeVert4=(abs(edgeVert1)*2.0)+abs(edgeVert2);\nfloat edgeHorz3=(-2.0*lumaW)+lumaNWSW;\nfloat edgeVert3=(-2.0*lumaS)+lumaSWSE;\nfloat edgeHorz=abs(edgeHorz3)+edgeHorz4;\nfloat edgeVert=abs(edgeVert3)+edgeVert4;\nfloat subpixNWSWNESE=lumaNWSW+lumaNESE;\nfloat lengthSign=texelSize.x;\nbool horzSpan=edgeHorz>=edgeVert;\nfloat subpixA=subpixNSWE*2.0+subpixNWSWNESE;\nif (!horzSpan)\n{\nlumaN=lumaW;\n}\nif (!horzSpan) \n{\nlumaS=lumaE;\n}\nif (horzSpan) \n{\nlengthSign=texelSize.y;\n}\nfloat subpixB=(subpixA*(1.0/12.0))-lumaM;\nfloat gradientN=lumaN-lumaM;\nfloat gradientS=lumaS-lumaM;\nfloat lumaNN=lumaN+lumaM;\nfloat lumaSS=lumaS+lumaM;\nbool pairN=abs(gradientN)>=abs(gradientS);\nfloat gradient=max(abs(gradientN),abs(gradientS));\nif (pairN)\n{\nlengthSign=-lengthSign;\n}\nfloat subpixC=clamp(abs(subpixB)*subpixRcpRange,0.0,1.0);\nvec2 posB;\nposB.x=posM.x;\nposB.y=posM.y;\nvec2 offNP;\noffNP.x=(!horzSpan) ? 0.0 : texelSize.x;\noffNP.y=(horzSpan) ? 0.0 : texelSize.y;\nif (!horzSpan) \n{\nposB.x+=lengthSign*0.5;\n}\nif (horzSpan)\n{\nposB.y+=lengthSign*0.5;\n}\nvec2 posN;\nposN.x=posB.x-offNP.x*1.5;\nposN.y=posB.y-offNP.y*1.5;\nvec2 posP;\nposP.x=posB.x+offNP.x*1.5;\nposP.y=posB.y+offNP.y*1.5;\nfloat subpixD=((-2.0)*subpixC)+3.0;\nfloat lumaEndN=FxaaLuma(texture2D(textureSampler,posN,0.0));\nfloat subpixE=subpixC*subpixC;\nfloat lumaEndP=FxaaLuma(texture2D(textureSampler,posP,0.0));\nif (!pairN) \n{\nlumaNN=lumaSS;\n}\nfloat gradientScaled=gradient*1.0/4.0;\nfloat lumaMM=lumaM-lumaNN*0.5;\nfloat subpixF=subpixD*subpixE;\nbool lumaMLTZero=lumaMM<0.0;\nlumaEndN-=lumaNN*0.5;\nlumaEndP-=lumaNN*0.5;\nbool doneN=abs(lumaEndN)>=gradientScaled;\nbool doneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) \n{\nposN.x-=offNP.x*3.0;\n}\nif (!doneN) \n{\nposN.y-=offNP.y*3.0;\n}\nbool doneNP=(!doneN) || (!doneP);\nif (!doneP) \n{\nposP.x+=offNP.x*3.0;\n}\nif (!doneP)\n{\nposP.y+=offNP.y*3.0;\n}\nif (doneNP)\n{\nif (!doneN) lumaEndN=FxaaLuma(texture2D(textureSampler,posN.xy,0.0));\nif (!doneP) lumaEndP=FxaaLuma(texture2D(textureSampler,posP.xy,0.0));\nif (!doneN) lumaEndN=lumaEndN-lumaNN*0.5;\nif (!doneP) lumaEndP=lumaEndP-lumaNN*0.5;\ndoneN=abs(lumaEndN)>=gradientScaled;\ndoneP=abs(lumaEndP)>=gradientScaled;\nif (!doneN) posN.x-=offNP.x*12.0;\nif (!doneN) posN.y-=offNP.y*12.0;\ndoneNP=(!doneN) || (!doneP);\nif (!doneP) posP.x+=offNP.x*12.0;\nif (!doneP) posP.y+=offNP.y*12.0;\n}\nfloat dstN=posM.x-posN.x;\nfloat dstP=posP.x-posM.x;\nif (!horzSpan)\n{\ndstN=posM.y-posN.y;\n}\nif (!horzSpan) \n{\ndstP=posP.y-posM.y;\n}\nbool goodSpanN=(lumaEndN<0.0) != lumaMLTZero;\nfloat spanLength=(dstP+dstN);\nbool goodSpanP=(lumaEndP<0.0) != lumaMLTZero;\nfloat spanLengthRcp=1.0/spanLength;\nbool directionN=dstN<dstP;\nfloat dst=min(dstN,dstP);\nbool goodSpan=directionN ? goodSpanN : goodSpanP;\nfloat subpixG=subpixF*subpixF;\nfloat pixelOffset=(dst*(-spanLengthRcp))+0.5;\nfloat subpixH=subpixG*fxaaQualitySubpix;\nfloat pixelOffsetGood=goodSpan ? pixelOffset : 0.0;\nfloat pixelOffsetSubpix=max(pixelOffsetGood,subpixH);\nif (!horzSpan)\n{\nposM.x+=pixelOffsetSubpix*lengthSign;\n}\nif (horzSpan)\n{\nposM.y+=pixelOffsetSubpix*lengthSign;\n}\n#ifdef MALI\nif(range<rangeMaxClamped) \n{\ngl_FragColor=rgbyM;\n}\nelse\n{\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n}\n#else\ngl_FragColor=texture2D(textureSampler,posM,0.0);\n#endif\n}",chromaticAberrationPixelShader:"\nuniform sampler2D textureSampler; \n\nuniform float chromatic_aberration;\nuniform float radialIntensity;\nuniform vec2 direction;\nuniform vec2 centerPosition;\nuniform float screen_width;\nuniform float screen_height;\n\nvarying vec2 vUV;\nvoid main(void)\n{\nvec2 centered_screen_pos=vec2(vUV.x-centerPosition.x,vUV.y-centerPosition.y);\nvec2 directionOfEffect=direction;\nif(directionOfEffect.x == 0. && directionOfEffect.y == 0.){\ndirectionOfEffect=normalize(centered_screen_pos);\n}\nfloat radius2=centered_screen_pos.x*centered_screen_pos.x\n+centered_screen_pos.y*centered_screen_pos.y;\nfloat radius=sqrt(radius2);\nvec4 original=texture2D(textureSampler,vUV);\n\nvec3 ref_indices=vec3(-0.3,0.0,0.3);\nfloat ref_shiftX=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.x/screen_width;\nfloat ref_shiftY=chromatic_aberration*pow(radius,radialIntensity)*directionOfEffect.y/screen_height;\n\nvec2 ref_coords_r=vec2(vUV.x+ref_indices.r*ref_shiftX,vUV.y+ref_indices.r*ref_shiftY*0.5);\nvec2 ref_coords_g=vec2(vUV.x+ref_indices.g*ref_shiftX,vUV.y+ref_indices.g*ref_shiftY*0.5);\nvec2 ref_coords_b=vec2(vUV.x+ref_indices.b*ref_shiftX,vUV.y+ref_indices.b*ref_shiftY*0.5);\noriginal.r=texture2D(textureSampler,ref_coords_r).r;\noriginal.g=texture2D(textureSampler,ref_coords_g).g;\noriginal.b=texture2D(textureSampler,ref_coords_b).b;\noriginal.a=clamp(texture2D(textureSampler,ref_coords_r).a+texture2D(textureSampler,ref_coords_g).a+texture2D(textureSampler,ref_coords_b).a,0.,1.);\ngl_FragColor=original;\n}",grainPixelShader:"#include<helperFunctions>\n\nuniform sampler2D textureSampler; \n\nuniform float intensity;\nuniform float animatedSeed;\n\nvarying vec2 vUV;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec2 seed=vUV*(animatedSeed);\nfloat grain=dither(seed,intensity);\n\nfloat lum=getLuminance(gl_FragColor.rgb);\nfloat grainAmount=(cos(-PI+(lum*PI*2.))+1.)/2.;\ngl_FragColor.rgb+=grain*grainAmount;\ngl_FragColor.rgb=max(gl_FragColor.rgb,0.0);\n}",sharpenPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform vec2 sharpnessAmounts;\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 color=texture2D(textureSampler,vUV);\nvec4 edgeDetection=texture2D(textureSampler,vUV+onePixel*vec2(0,-1)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0)) +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1)) -\ncolor*4.0;\ngl_FragColor=max(vec4(color.rgb*sharpnessAmounts.y,color.a)-(sharpnessAmounts.x*vec4(edgeDetection.rgb,0)),0.);\n}",kernelBlurVertexShader:"\nattribute vec2 position;\n\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nsampleCenter=(position*madd+madd);\n#include<kernelBlurVertex>[0..varyingCount]\ngl_Position=vec4(position,0.0,1.0);\n}",kernelBlurPixelShader:"\nuniform sampler2D textureSampler;\nuniform vec2 delta;\n\nvarying vec2 sampleCenter;\n#ifdef DOF\nuniform sampler2D circleOfConfusionSampler;\nuniform vec2 cameraMinMaxZ;\nfloat sampleDistance(const in vec2 offset) {\nfloat depth=texture2D(circleOfConfusionSampler,offset).g; \nreturn cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth; \n}\nfloat sampleCoC(const in vec2 offset) {\nfloat coc=texture2D(circleOfConfusionSampler,offset).r; \nreturn coc; \n}\n#endif\n#include<kernelBlurVaryingDeclaration>[0..varyingCount]\n#ifdef PACKEDFLOAT\nvec4 pack(float depth)\n{\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(depth*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nvoid main(void)\n{\nfloat computedWeight=0.0;\n#ifdef PACKEDFLOAT \nfloat blend=0.;\n#else\nvec4 blend=vec4(0.);\n#endif\n#ifdef DOF\nfloat sumOfWeights=CENTER_WEIGHT; \nfloat factor=0.0;\n\n#ifdef PACKEDFLOAT\nblend+=unpack(texture2D(textureSampler,sampleCenter))*CENTER_WEIGHT;\n#else\nblend+=texture2D(textureSampler,sampleCenter)*CENTER_WEIGHT;\n#endif\n#endif\n#include<kernelBlurFragment>[0..varyingCount]\n#include<kernelBlurFragment2>[0..depCount]\n#ifdef PACKEDFLOAT\ngl_FragColor=pack(blend);\n#else\ngl_FragColor=blend;\n#endif\n#ifdef DOF\ngl_FragColor/=sumOfWeights;\n#endif\n}",depthOfFieldMergePixelShader:"uniform sampler2D textureSampler;\nvarying vec2 vUV;\nuniform sampler2D circleOfConfusionSampler;\nuniform sampler2D blurStep0;\n#if BLUR_LEVEL>0\nuniform sampler2D blurStep1;\n#endif\n#if BLUR_LEVEL>1\nuniform sampler2D blurStep2;\n#endif\nvoid main(void)\n{\nfloat coc=texture2D(circleOfConfusionSampler,vUV).r;\n#if BLUR_LEVEL == 0\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred0=texture2D(blurStep0,vUV);\ngl_FragColor=mix(original,blurred0,coc);\n#endif\n#if BLUR_LEVEL == 1\nif(coc<0.5){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(original,blurred1,coc/0.5);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV); \nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.5)/0.5);\n}\n#endif\n#if BLUR_LEVEL == 2\nif(coc<0.33){\nvec4 original=texture2D(textureSampler,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(original,blurred2,coc/0.33);\n}else if(coc<0.66){\nvec4 blurred1=texture2D(blurStep1,vUV);\nvec4 blurred2=texture2D(blurStep2,vUV);\ngl_FragColor=mix(blurred2,blurred1,(coc-0.33)/0.33);\n}else{\nvec4 blurred0=texture2D(blurStep0,vUV);\nvec4 blurred1=texture2D(blurStep1,vUV);\ngl_FragColor=mix(blurred1,blurred0,(coc-0.66)/0.34);\n}\n#endif\n}\n",circleOfConfusionPixelShader:"\nuniform sampler2D depthSampler;\n\nvarying vec2 vUV;\n\nuniform vec2 cameraMinMaxZ;\n\nuniform float focusDistance;\nuniform float cocPrecalculation;\nvoid main(void)\n{\nfloat depth=texture2D(depthSampler,vUV).r;\nfloat pixelDistance=(cameraMinMaxZ.x+(cameraMinMaxZ.y-cameraMinMaxZ.x)*depth)*1000.0; \nfloat coc=abs(cocPrecalculation* ((focusDistance-pixelDistance)/pixelDistance));\ncoc=clamp(coc,0.0,1.0);\ngl_FragColor=vec4(coc,depth,coc,1.0);\n}\n",bloomMergePixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D bloomBlur;\nvarying vec2 vUV;\nuniform float bloomWeight;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\nvec3 blurred=texture2D(bloomBlur,vUV).rgb;\ngl_FragColor.rgb=gl_FragColor.rgb+(blurred.rgb*bloomWeight); \n}\n",extractHighlightsPixelShader:"#include<helperFunctions>\n\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform float threshold;\nuniform float exposure;\nvoid main(void) \n{\ngl_FragColor=texture2D(textureSampler,vUV);\nfloat luma=getLuminance(gl_FragColor.rgb*exposure);\ngl_FragColor.rgb=step(threshold,luma)*gl_FragColor.rgb;\n}",refractionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D refractionSampler;\n\nuniform vec3 baseColor;\nuniform float depth;\nuniform float colorLevel;\nvoid main() {\nfloat ref=1.0-texture2D(refractionSampler,vUV).r;\nvec2 uv=vUV-vec2(0.5);\nvec2 offset=uv*depth*ref;\nvec3 sourceColor=texture2D(textureSampler,vUV-offset).rgb;\ngl_FragColor=vec4(sourceColor+sourceColor*ref*colorLevel,1.0);\n}",blackAndWhitePixelShader:"\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}",convolutionPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform vec2 screenSize;\nuniform float kernel[9];\nvoid main(void)\n{\nvec2 onePixel=vec2(1.0,1.0)/screenSize;\nvec4 colorSum =\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,-1))*kernel[0] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,-1))*kernel[1] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,-1))*kernel[2] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,0))*kernel[3] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,0))*kernel[4] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,0))*kernel[5] +\ntexture2D(textureSampler,vUV+onePixel*vec2(-1,1))*kernel[6] +\ntexture2D(textureSampler,vUV+onePixel*vec2(0,1))*kernel[7] +\ntexture2D(textureSampler,vUV+onePixel*vec2(1,1))*kernel[8];\nfloat kernelWeight =\nkernel[0] +\nkernel[1] +\nkernel[2] +\nkernel[3] +\nkernel[4] +\nkernel[5] +\nkernel[6] +\nkernel[7] +\nkernel[8];\nif (kernelWeight<=0.0) {\nkernelWeight=1.0;\n}\ngl_FragColor=vec4((colorSum/kernelWeight).rgb,1);\n}",filterPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform mat4 kernelMatrix;\nvoid main(void)\n{\nvec3 baseColor=texture2D(textureSampler,vUV).rgb;\nvec3 updatedColor=(kernelMatrix*vec4(baseColor,1.0)).rgb;\ngl_FragColor=vec4(updatedColor,1.0);\n}",volumetricLightScatteringPixelShader:"uniform sampler2D textureSampler;\nuniform sampler2D lightScatteringSampler;\nuniform float decay;\nuniform float exposure;\nuniform float weight;\nuniform float density;\nuniform vec2 meshPositionOnScreen;\nvarying vec2 vUV;\nvoid main(void) {\nvec2 tc=vUV;\nvec2 deltaTexCoord=(tc-meshPositionOnScreen.xy);\ndeltaTexCoord*=1.0/float(NUM_SAMPLES)*density;\nfloat illuminationDecay=1.0;\nvec4 color=texture2D(lightScatteringSampler,tc)*0.4;\nfor(int i=0; i<NUM_SAMPLES; i++) {\ntc-=deltaTexCoord;\nvec4 dataSample=texture2D(lightScatteringSampler,tc)*0.4;\ndataSample*=illuminationDecay*weight;\ncolor+=dataSample;\nilluminationDecay*=decay;\n}\nvec4 realColor=texture2D(textureSampler,vUV);\ngl_FragColor=((vec4((vec3(color.r,color.g,color.b)*exposure),1))+(realColor*(1.5-0.4)));\n}\n",volumetricLightScatteringPassPixelShader:"#if defined(ALPHATEST) || defined(NEED_UV)\nvarying vec2 vUV;\n#endif\n#if defined(ALPHATEST)\nuniform sampler2D diffuseSampler;\n#endif\nvoid main(void)\n{\n#if defined(ALPHATEST)\nvec4 diffuseColor=texture2D(diffuseSampler,vUV);\nif (diffuseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=vec4(0.0,0.0,0.0,1.0);\n}\n",colorCorrectionPixelShader:"\nuniform sampler2D textureSampler; \nuniform sampler2D colorTable; \n\nvarying vec2 vUV;\n\nconst float SLICE_COUNT=16.0; \n\nvec4 sampleAs3DTexture(sampler2D textureSampler,vec3 uv,float width) {\nfloat sliceSize=1.0/width; \nfloat slicePixelSize=sliceSize/width; \nfloat sliceInnerSize=slicePixelSize*(width-1.0); \nfloat zSlice0=min(floor(uv.z*width),width-1.0);\nfloat zSlice1=min(zSlice0+1.0,width-1.0);\nfloat xOffset=slicePixelSize*0.5+uv.x*sliceInnerSize;\nfloat s0=xOffset+(zSlice0*sliceSize);\nfloat s1=xOffset+(zSlice1*sliceSize);\nvec4 slice0Color=texture2D(textureSampler,vec2(s0,uv.y));\nvec4 slice1Color=texture2D(textureSampler,vec2(s1,uv.y));\nfloat zOffset=mod(uv.z*width,1.0);\nvec4 result=mix(slice0Color,slice1Color,zOffset);\nreturn result;\n}\nvoid main(void)\n{\nvec4 screen_color=texture2D(textureSampler,vUV);\ngl_FragColor=sampleAs3DTexture(colorTable,screen_color.rgb,SLICE_COUNT);\n}",tonemapPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform float _ExposureAdjustment;\n#if defined(HABLE_TONEMAPPING)\nconst float A=0.15;\nconst float B=0.50;\nconst float C=0.10;\nconst float D=0.20;\nconst float E=0.02;\nconst float F=0.30;\nconst float W=11.2;\n#endif\nfloat Luminance(vec3 c)\n{\nreturn dot(c,vec3(0.22,0.707,0.071));\n}\nvoid main(void) \n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\n#if defined(REINHARD_TONEMAPPING)\nfloat lum=Luminance(colour.rgb); \nfloat lumTm=lum*_ExposureAdjustment;\nfloat scale=lumTm/(1.0+lumTm); \ncolour*=scale/lum;\n#elif defined(HABLE_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nconst float ExposureBias=2.0;\nvec3 x=ExposureBias*colour;\nvec3 curr=((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F;\nx=vec3(W,W,W);\nvec3 whiteScale=1.0/(((x*(A*x+C*B)+D*E)/(x*(A*x+B)+D*F))-E/F);\ncolour=curr*whiteScale;\n#elif defined(OPTIMIZED_HEJIDAWSON_TONEMAPPING)\ncolour*=_ExposureAdjustment;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\n#elif defined(PHOTOGRAPHIC_TONEMAPPING)\ncolour=vec3(1.0,1.0,1.0)-exp2(-_ExposureAdjustment*colour);\n#endif\ngl_FragColor=vec4(colour.rgb,1.0);\n}",displayPassPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}",highlightsPixelShader:"\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}",imageProcessingPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\nvoid main(void)\n{\nvec4 result=texture2D(textureSampler,vUV);\n#ifdef IMAGEPROCESSING\n#ifndef FROMLINEARSPACE\n\nresult.rgb=toLinearSpace(result.rgb);\n#endif\nresult=applyImageProcessing(result);\n#else\n\n#ifdef FROMLINEARSPACE\nresult=applyImageProcessing(result);\n#endif\n#endif\ngl_FragColor=result;\n}",lensFlareVertexShader:"\nattribute vec2 position;\n\nuniform mat4 viewportMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvUV=position*madd+madd;\ngl_Position=viewportMatrix*vec4(position,0.0,1.0);\n}",lensFlarePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\ngl_FragColor=baseColor*color;\n}",anaglyphPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D leftSampler;\nvoid main(void)\n{\nvec4 leftFrag=texture2D(leftSampler,vUV);\nleftFrag=vec4(1.0,leftFrag.g,leftFrag.b,1.0);\nvec4 rightFrag=texture2D(textureSampler,vUV);\nrightFrag=vec4(rightFrag.r,1.0,1.0,1.0);\ngl_FragColor=vec4(rightFrag.rgb*leftFrag.rgb,1.0);\n}",stereoscopicInterlacePixelShader:"const vec3 TWO=vec3(2.0,2.0,2.0);\nvarying vec2 vUV;\nuniform sampler2D camASampler;\nuniform sampler2D textureSampler;\nuniform vec2 stepSize;\nvoid main(void)\n{\nbool useCamB;\nvec2 texCoord1;\nvec2 texCoord2;\nvec3 frag1;\nvec3 frag2;\n#ifdef IS_STEREOSCOPIC_HORIZ\nuseCamB=vUV.x>0.5;\ntexCoord1=vec2(useCamB ? (vUV.x-0.5)*2.0 : vUV.x*2.0,vUV.y);\ntexCoord2=vec2(texCoord1.x+stepSize.x,vUV.y);\n#else\nuseCamB=vUV.y>0.5;\ntexCoord1=vec2(vUV.x,useCamB ? (vUV.y-0.5)*2.0 : vUV.y*2.0);\ntexCoord2=vec2(vUV.x,texCoord1.y+stepSize.y);\n#endif\n\nif (useCamB){\nfrag1=texture2D(textureSampler,texCoord1).rgb;\nfrag2=texture2D(textureSampler,texCoord2).rgb;\n}else{\nfrag1=texture2D(camASampler ,texCoord1).rgb;\nfrag2=texture2D(camASampler ,texCoord2).rgb;\n}\ngl_FragColor=vec4((frag1+frag2)/TWO,1.0);\n}",vrDistortionCorrectionPixelShader:"\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}",glowBlurPostProcessPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec2 screenSize;\nuniform vec2 direction;\nuniform float blurWidth;\n\nfloat getLuminance(vec3 color)\n{\nreturn dot(color,vec3(0.2126,0.7152,0.0722));\n}\nvoid main(void)\n{\nfloat weights[7];\nweights[0]=0.05;\nweights[1]=0.1;\nweights[2]=0.2;\nweights[3]=0.3;\nweights[4]=0.2;\nweights[5]=0.1;\nweights[6]=0.05;\nvec2 texelSize=vec2(1.0/screenSize.x,1.0/screenSize.y);\nvec2 texelStep=texelSize*direction*blurWidth;\nvec2 start=vUV-3.0*texelStep;\nvec4 baseColor=vec4(0.,0.,0.,0.);\nvec2 texelOffset=vec2(0.,0.);\nfor (int i=0; i<7; i++)\n{\n\nvec4 texel=texture2D(textureSampler,start+texelOffset);\nbaseColor.a+=texel.a*weights[i];\n\nfloat luminance=getLuminance(baseColor.rgb);\nfloat luminanceTexel=getLuminance(texel.rgb);\nfloat choice=step(luminanceTexel,luminance);\nbaseColor.rgb=choice*baseColor.rgb+(1.0-choice)*texel.rgb;\ntexelOffset+=texelStep;\n}\ngl_FragColor=baseColor;\n}",glowMapGenerationPixelShader:"#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform sampler2D emissiveSampler;\n#endif\nuniform vec4 color;\nvoid main(void)\n{\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUVDiffuse).a<0.4)\ndiscard;\n#endif\n#ifdef EMISSIVE\ngl_FragColor=texture2D(emissiveSampler,vUVEmissive)*color;\n#else\ngl_FragColor=color;\n#endif\n}",glowMapGenerationVertexShader:"\nattribute vec3 position;\n#include<bonesDeclaration>\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\nvarying vec4 vPosition;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef ALPHATEST\nvarying vec2 vUVDiffuse;\nuniform mat4 diffuseMatrix;\n#endif\n#ifdef EMISSIVE\nvarying vec2 vUVEmissive;\nuniform mat4 emissiveMatrix;\n#endif\nvoid main(void)\n{\nvec3 positionUpdated=position;\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#include<instancesVertex>\n#include<bonesVertex>\n#ifdef CUBEMAP\nvPosition=finalWorld*vec4(positionUpdated,1.0);\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#else\nvPosition=viewProjection*finalWorld*vec4(positionUpdated,1.0);\ngl_Position=vPosition;\n#endif\n#ifdef ALPHATEST\n#ifdef DIFFUSEUV1\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef DIFFUSEUV2\nvUVDiffuse=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#ifdef EMISSIVE\n#ifdef EMISSIVEUV1\nvUVEmissive=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef EMISSIVEUV2\nvUVEmissive=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n}",glowMapMergePixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#ifdef EMISSIVE\nuniform sampler2D textureSampler2;\n#endif\n\nuniform float offset;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef EMISSIVE\nbaseColor+=texture2D(textureSampler2,vUV);\nbaseColor*=offset;\n#else\nbaseColor.a=abs(offset-baseColor.a);\n#ifdef STROKE\nfloat alpha=smoothstep(.0,.1,baseColor.a);\nbaseColor.a=alpha;\nbaseColor.rgb=baseColor.rgb*alpha;\n#endif\n#endif\ngl_FragColor=baseColor;\n}",glowMapMergeVertexShader:"\nattribute vec2 position;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) {\nvUV=position*madd+madd;\ngl_Position=vec4(position,0.0,1.0);\n}",lineVertexShader:"\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}",linePixelShader:"uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}",outlineVertexShader:"\nattribute vec3 position;\nattribute vec3 normal;\n#include<bonesDeclaration>\n\nuniform float offset;\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform mat4 diffuseMatrix;\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#endif\n#include<logDepthDeclaration>\nvoid main(void)\n{\nvec3 offsetPosition=position+normal*offset;\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(offsetPosition,1.0);\n#ifdef ALPHATEST\n#ifdef UV1\nvUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n#endif\n#ifdef UV2\nvUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n#endif\n#endif\n#include<logDepthVertex>\n}\n",outlinePixelShader:"#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nuniform vec4 color;\n#ifdef ALPHATEST\nvarying vec2 vUV;\nuniform sampler2D diffuseSampler;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\n#ifdef ALPHATEST\nif (texture2D(diffuseSampler,vUV).a<0.4)\ndiscard;\n#endif\n#include<logDepthFragment>\ngl_FragColor=color;\n}",layerVertexShader:"\nattribute vec2 position;\n\nuniform vec2 scale;\nuniform vec2 offset;\nuniform mat4 textureMatrix;\n\nvarying vec2 vUV;\nconst vec2 madd=vec2(0.5,0.5);\nvoid main(void) { \nvec2 shiftedPosition=position*scale+offset;\nvUV=vec2(textureMatrix*vec4(shiftedPosition*madd+madd,1.0,0.0));\ngl_Position=vec4(shiftedPosition,0.0,1.0);\n}",layerPixelShader:"\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n\nuniform vec4 color;\nvoid main(void) {\nvec4 baseColor=texture2D(textureSampler,vUV);\n#ifdef ALPHATEST\nif (baseColor.a<0.4)\ndiscard;\n#endif\ngl_FragColor=baseColor*color;\n}",backgroundVertexShader:"precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2; \n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif \n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif \n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0 \nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n",backgroundPixelShader:"#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif \n#ifdef MAINUV2 \nvarying vec2 vMainUV2; \n#endif \n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n",noisePixelShader:"\n\nuniform float brightness;\nuniform float persistence;\nuniform float timeScale;\n\nvarying vec2 vUV;\n\nvec2 hash22(vec2 p)\n{\np=p*mat2(127.1,311.7,269.5,183.3);\np=-1.0+2.0*fract(sin(p)*43758.5453123);\nreturn sin(p*6.283+timeScale);\n}\nfloat interpolationNoise(vec2 p)\n{\nvec2 pi=floor(p);\nvec2 pf=p-pi;\nvec2 w=pf*pf*(3.-2.*pf);\nfloat f00=dot(hash22(pi+vec2(.0,.0)),pf-vec2(.0,.0));\nfloat f01=dot(hash22(pi+vec2(.0,1.)),pf-vec2(.0,1.));\nfloat f10=dot(hash22(pi+vec2(1.0,0.)),pf-vec2(1.0,0.));\nfloat f11=dot(hash22(pi+vec2(1.0,1.)),pf-vec2(1.0,1.));\nfloat xm1=mix(f00,f10,w.x);\nfloat xm2=mix(f01,f11,w.x);\nfloat ym=mix(xm1,xm2,w.y); \nreturn ym;\n}\nfloat perlinNoise2D(float x,float y)\n{\nfloat sum=0.0;\nfloat frequency=0.0;\nfloat amplitude=0.0;\nfor(int i=0; i<OCTAVES; i++)\n{\nfrequency=pow(2.0,float(i));\namplitude=pow(persistence,float(i));\nsum=sum+interpolationNoise(vec2(x*frequency,y*frequency))*amplitude;\n}\nreturn sum;\n}\n\nvoid main(void)\n{\nfloat x=abs(vUV.x);\nfloat y=abs(vUV.y);\nfloat noise=brightness+(1.0-brightness)*perlinNoise2D(x,y);\ngl_FragColor=vec4(noise,noise,noise,1.0);\n}\n"},$a.Effect.IncludesShadersStore={depthPrePass:"#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif",bonesDeclaration:"#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nattribute vec4 matricesIndices;\nattribute vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nattribute vec4 matricesIndicesExtra;\nattribute vec4 matricesWeightsExtra;\n#endif\n#endif",instancesDeclaration:"#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif",pointCloudVertexDeclaration:"#ifdef POINTSIZE\nuniform float pointSize;\n#endif",bumpVertexDeclaration:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#endif\n",clipPlaneVertexDeclaration:"#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nvarying float fClipDistance;\n#endif\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",fogVertexDeclaration:"#ifdef FOG\nvarying vec3 vFogDistance;\n#endif",morphTargetsVertexGlobalDeclaration:"#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif",morphTargetsVertexDeclaration:"#ifdef MORPHTARGETS\nattribute vec3 position{X};\n#ifdef MORPHTARGETS_NORMAL\nattribute vec3 normal{X};\n#endif\n#ifdef MORPHTARGETS_TANGENT\nattribute vec3 tangent{X};\n#endif\n#endif",logDepthDeclaration:"#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif",morphTargetsVertex:"#ifdef MORPHTARGETS\npositionUpdated+=(position{X}-position)*morphTargetInfluences[{X}];\n#ifdef MORPHTARGETS_NORMAL\nnormalUpdated+=(normal{X}-normal)*morphTargetInfluences[{X}];\n#endif\n#ifdef MORPHTARGETS_TANGENT\ntangentUpdated.xyz+=(tangent{X}-tangent.xyz)*morphTargetInfluences[{X}];\n#endif\n#endif",instancesVertex:"#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif",bonesVertex:"#if NUM_BONE_INFLUENCERS>0\nmat4 influence;\ninfluence=mBones[int(matricesIndices[0])]*matricesWeights[0];\n#if NUM_BONE_INFLUENCERS>1\ninfluence+=mBones[int(matricesIndices[1])]*matricesWeights[1];\n#endif \n#if NUM_BONE_INFLUENCERS>2\ninfluence+=mBones[int(matricesIndices[2])]*matricesWeights[2];\n#endif \n#if NUM_BONE_INFLUENCERS>3\ninfluence+=mBones[int(matricesIndices[3])]*matricesWeights[3];\n#endif \n#if NUM_BONE_INFLUENCERS>4\ninfluence+=mBones[int(matricesIndicesExtra[0])]*matricesWeightsExtra[0];\n#endif \n#if NUM_BONE_INFLUENCERS>5\ninfluence+=mBones[int(matricesIndicesExtra[1])]*matricesWeightsExtra[1];\n#endif \n#if NUM_BONE_INFLUENCERS>6\ninfluence+=mBones[int(matricesIndicesExtra[2])]*matricesWeightsExtra[2];\n#endif \n#if NUM_BONE_INFLUENCERS>7\ninfluence+=mBones[int(matricesIndicesExtra[3])]*matricesWeightsExtra[3];\n#endif \nfinalWorld=finalWorld*influence;\n#endif",bumpVertex:"#if defined(BUMP) || defined(PARALLAX)\n#if defined(TANGENT) && defined(NORMAL)\nvec3 tbnNormal=normalize(normalUpdated);\nvec3 tbnTangent=normalize(tangentUpdated.xyz);\nvec3 tbnBitangent=cross(tbnNormal,tbnTangent)*tangentUpdated.w;\nvTBN=mat3(finalWorld)*mat3(tbnTangent,tbnBitangent,tbnNormal);\n#endif\n#endif",clipPlaneVertex:"#ifdef CLIPPLANE\nfClipDistance=dot(worldPos,vClipPlane);\n#endif\n#ifdef CLIPPLANE2\nfClipDistance2=dot(worldPos,vClipPlane2);\n#endif\n#ifdef CLIPPLANE3\nfClipDistance3=dot(worldPos,vClipPlane3);\n#endif\n#ifdef CLIPPLANE4\nfClipDistance4=dot(worldPos,vClipPlane4);\n#endif",fogVertex:"#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif",shadowsVertex:"#ifdef SHADOWS\n#if defined(SHADOW{X}) && !defined(SHADOWCUBE{X})\nvPositionFromLight{X}=lightMatrix{X}*worldPos;\nvDepthMetric{X}=((vPositionFromLight{X}.z+light{X}.depthValues.x)/(light{X}.depthValues.y));\n#endif\n#endif",pointCloudVertex:"#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif",logDepthVertex:"#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif",helperFunctions:"const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=max(0.0000001,max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D); \n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}",lightFragmentDeclaration:"#ifdef LIGHT{X}\nuniform vec4 vLightData{X};\nuniform vec4 vLightDiffuse{X};\n#ifdef SPECULARTERM\nuniform vec3 vLightSpecular{X};\n#else\nvec3 vLightSpecular{X}=vec3(0.);\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X};\n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\nuniform vec4 shadowsInfo{X};\nuniform vec2 depthValues{X};\n#endif\n#ifdef SPOTLIGHT{X}\nuniform vec4 vLightDirection{X};\nuniform vec4 vLightFalloff{X};\n#elif defined(POINTLIGHT{X})\nuniform vec4 vLightFalloff{X};\n#elif defined(HEMILIGHT{X})\nuniform vec3 vLightGround{X};\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#endif",lightsFragmentFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef NDOTL\nfloat ndl;\n#endif\n};\nlightingInfo computeLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 lightVectorW;\nfloat attenuation=1.0;\nif (lightData.w == 0.)\n{\nvec3 direction=lightData.xyz-vPositionW;\nattenuation=max(0.,1.0-length(direction)/range);\nlightVectorW=normalize(direction);\n}\nelse\n{\nlightVectorW=normalize(-lightData.xyz);\n}\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec4 lightDirection,vec3 diffuseColor,vec3 specularColor,float range,float glossiness) {\nlightingInfo result;\nvec3 direction=lightData.xyz-vPositionW;\nvec3 lightVectorW=normalize(direction);\nfloat attenuation=max(0.,1.0-length(direction)/range);\n\nfloat cosAngle=max(0.,dot(lightDirection.xyz,-lightVectorW));\nif (cosAngle>=lightDirection.w)\n{\ncosAngle=max(0.,pow(cosAngle,lightData.w));\nattenuation*=cosAngle;\n\nfloat ndl=max(0.,dot(vNormal,lightVectorW));\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=ndl*diffuseColor*attenuation;\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightVectorW);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor*attenuation;\n#endif\nreturn result;\n}\nresult.diffuse=vec3(0.);\n#ifdef SPECULARTERM\nresult.specular=vec3(0.);\n#endif\n#ifdef NDOTL\nresult.ndl=0.;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float glossiness) {\nlightingInfo result;\n\nfloat ndl=dot(vNormal,lightData.xyz)*0.5+0.5;\n#ifdef NDOTL\nresult.ndl=ndl;\n#endif\nresult.diffuse=mix(groundColor,diffuseColor,ndl);\n#ifdef SPECULARTERM\n\nvec3 angleW=normalize(viewDirectionW+lightData.xyz);\nfloat specComp=max(0.,dot(vNormal,angleW));\nspecComp=pow(specComp,max(1.,glossiness));\nresult.specular=specComp*specularColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn textureColor;\n}",lightUboDeclaration:"#ifdef LIGHT{X}\nuniform Light{X}\n{\nvec4 vLightData;\nvec4 vLightDiffuse;\nvec3 vLightSpecular;\n#ifdef SPOTLIGHT{X}\nvec4 vLightDirection;\nvec4 vLightFalloff;\n#elif defined(POINTLIGHT{X})\nvec4 vLightFalloff;\n#elif defined(HEMILIGHT{X})\nvec3 vLightGround;\n#endif\nvec4 shadowsInfo;\nvec2 depthValues;\n} light{X};\n#ifdef PROJECTEDLIGHTTEXTURE{X}\nuniform mat4 textureProjectionMatrix{X};\nuniform sampler2D projectionLightSampler{X};\n#endif\n#ifdef SHADOW{X}\n#if defined(SHADOWCUBE{X})\nuniform samplerCube shadowSampler{X}; \n#else\nvarying vec4 vPositionFromLight{X};\nvarying float vDepthMetric{X};\n#if defined(SHADOWPCSS{X})\nuniform highp sampler2DShadow shadowSampler{X};\nuniform highp sampler2D depthSampler{X};\n#elif defined(SHADOWPCF{X})\nuniform highp sampler2DShadow shadowSampler{X};\n#else\nuniform sampler2D shadowSampler{X};\n#endif\nuniform mat4 lightMatrix{X};\n#endif\n#endif\n#endif",defaultVertexDeclaration:"\nuniform mat4 viewProjection;\nuniform mat4 view;\n#ifdef DIFFUSE\nuniform mat4 diffuseMatrix;\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\nuniform mat4 specularMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef REFLECTION\nuniform mat4 reflectionMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n",defaultFragmentDeclaration:"uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif",defaultUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor; \nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix; \nvec4 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize; \n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",shadowsFragmentFunctions:"#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness); \nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0); \n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x; \nuv+=0.5; \nvec2 st=fract(uv); \nvec2 base_uv=floor(uv)-0.5; \nbase_uv*=shadowMapSizeAndInverse.y; \n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n",fresnelFunction:"#ifdef FRESNEL\nfloat computeFresnelTerm(vec3 viewDirection,vec3 worldNormal,float bias,float power)\n{\nfloat fresnelTerm=pow(bias+abs(dot(viewDirection,worldNormal)),power);\nreturn clamp(fresnelTerm,0.,1.);\n}\n#endif",reflectionFunction:"#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\nvec3 parallaxCorrectNormal( vec3 vertexPos,vec3 origVec,vec3 cubeSize,vec3 cubePos ) {\n\nvec3 invOrigVec=vec3(1.0,1.0,1.0)/origVec;\nvec3 halfSize=cubeSize*0.5;\nvec3 intersecAtMaxPlane=(cubePos+halfSize-vertexPos)*invOrigVec;\nvec3 intersecAtMinPlane=(cubePos-halfSize-vertexPos)*invOrigVec;\n\nvec3 largestIntersec=max(intersecAtMaxPlane,intersecAtMinPlane);\n\nfloat distance=min(min(largestIntersec.x,largestIntersec.y),largestIntersec.z);\n\nvec3 intersectPositionWS=vertexPos+origVec*distance;\n\nreturn intersectPositionWS-cubePos;\n}\n#endif\nvec3 computeReflectionCoords(vec4 worldPos,vec3 worldNormal)\n{\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvec3 direction=normalize(vDirectionW);\nfloat lon=atan(direction.z,direction.x);\nfloat lat=acos(direction.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y; \n#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED\nreturn vec3(1.0-s,t,0);\n#else\nreturn vec3(s,t,0);\n#endif\n#endif\n#ifdef REFLECTIONMAP_EQUIRECTANGULAR\nvec3 cameraToVertex=normalize(worldPos.xyz-vEyePosition.xyz);\nvec3 r=normalize(reflect(cameraToVertex,worldNormal));\nfloat lon=atan(r.z,r.x);\nfloat lat=acos(r.y);\nvec2 sphereCoords=vec2(lon,lat)*RECIPROCAL_PI2*2.0;\nfloat s=sphereCoords.x*0.5+0.5;\nfloat t=sphereCoords.y; \nreturn vec3(s,t,0);\n#endif\n#ifdef REFLECTIONMAP_SPHERICAL\nvec3 viewDir=normalize(vec3(view*worldPos));\nvec3 viewNormal=normalize(vec3(view*vec4(worldNormal,0.0)));\nvec3 r=reflect(viewDir,viewNormal);\nr.z=r.z-1.0;\nfloat m=2.0*length(r);\nreturn vec3(r.x/m+0.5,1.0-r.y/m-0.5,0);\n#endif\n#ifdef REFLECTIONMAP_PLANAR\nvec3 viewDir=worldPos.xyz-vEyePosition.xyz;\nvec3 coords=normalize(reflect(viewDir,worldNormal));\nreturn vec3(reflectionMatrix*vec4(coords,1));\n#endif\n#ifdef REFLECTIONMAP_CUBIC\nvec3 viewDir=normalize(worldPos.xyz-vEyePosition.xyz);\n\nvec3 coords=reflect(viewDir,worldNormal);\n#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\ncoords=parallaxCorrectNormal(worldPos.xyz,coords,vReflectionSize,vReflectionPosition);\n#endif\ncoords=vec3(reflectionMatrix*vec4(coords,0));\n#ifdef INVERTCUBICMAP\ncoords.y*=-1.0;\n#endif\nreturn coords;\n#endif\n#ifdef REFLECTIONMAP_PROJECTION\nreturn vec3(reflectionMatrix*(view*worldPos));\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nreturn vPositionUVW;\n#endif\n#ifdef REFLECTIONMAP_EXPLICIT\nreturn vec3(0,0,0);\n#endif\n}",imageProcessingDeclaration:"#ifdef EXPOSURE\nuniform float exposureLinear;\n#endif\n#ifdef CONTRAST\nuniform float contrast;\n#endif\n#ifdef VIGNETTE\nuniform vec2 vInverseScreenSize;\nuniform vec4 vignetteSettings1;\nuniform vec4 vignetteSettings2;\n#endif\n#ifdef COLORCURVES\nuniform vec4 vCameraColorCurveNegative;\nuniform vec4 vCameraColorCurveNeutral;\nuniform vec4 vCameraColorCurvePositive;\n#endif\n#ifdef COLORGRADING\n#ifdef COLORGRADING3D\nuniform highp sampler3D txColorTransform;\n#else\nuniform sampler2D txColorTransform;\n#endif\nuniform vec4 colorTransformSettings;\n#endif",imageProcessingFunctions:"#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x; \n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=clamp(color,0.0,1.0);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}",bumpFragmentFunctions:"#ifdef BUMP\n#if BUMPDIRECTUV == 1\n#define vBumpUV vMainUV1\n#elif BUMPDIRECTUV == 2\n#define vBumpUV vMainUV2\n#else\nvarying vec2 vBumpUV;\n#endif\nuniform sampler2D bumpSampler;\n#if defined(TANGENT) && defined(NORMAL) \nvarying mat3 vTBN;\n#endif\n#ifdef OBJECTSPACE_NORMALMAP\nuniform mat4 normalMatrix;\n#endif\n\nmat3 cotangent_frame(vec3 normal,vec3 p,vec2 uv)\n{\n\nuv=gl_FrontFacing ? uv : -uv;\n\nvec3 dp1=dFdx(p);\nvec3 dp2=dFdy(p);\nvec2 duv1=dFdx(uv);\nvec2 duv2=dFdy(uv);\n\nvec3 dp2perp=cross(dp2,normal);\nvec3 dp1perp=cross(normal,dp1);\nvec3 tangent=dp2perp*duv1.x+dp1perp*duv2.x;\nvec3 bitangent=dp2perp*duv1.y+dp1perp*duv2.y;\n\ntangent*=vTangentSpaceParams.x;\nbitangent*=vTangentSpaceParams.y;\n\nfloat invmax=inversesqrt(max(dot(tangent,tangent),dot(bitangent,bitangent)));\nreturn mat3(tangent*invmax,bitangent*invmax,normal);\n}\nvec3 perturbNormal(mat3 cotangentFrame,vec2 uv)\n{\nvec3 map=texture2D(bumpSampler,uv).xyz;\nmap=map*2.0-1.0;\n#ifdef NORMALXYSCALE\nmap=normalize(map*vec3(vBumpInfos.y,vBumpInfos.y,1.0));\n#endif\nreturn normalize(cotangentFrame*map);\n}\n#ifdef PARALLAX\nconst float minSamples=4.;\nconst float maxSamples=15.;\nconst int iMaxSamples=15;\n\nvec2 parallaxOcclusion(vec3 vViewDirCoT,vec3 vNormalCoT,vec2 texCoord,float parallaxScale) {\nfloat parallaxLimit=length(vViewDirCoT.xy)/vViewDirCoT.z;\nparallaxLimit*=parallaxScale;\nvec2 vOffsetDir=normalize(vViewDirCoT.xy);\nvec2 vMaxOffset=vOffsetDir*parallaxLimit;\nfloat numSamples=maxSamples+(dot(vViewDirCoT,vNormalCoT)*(minSamples-maxSamples));\nfloat stepSize=1.0/numSamples;\n\nfloat currRayHeight=1.0;\nvec2 vCurrOffset=vec2(0,0);\nvec2 vLastOffset=vec2(0,0);\nfloat lastSampledHeight=1.0;\nfloat currSampledHeight=1.0;\nfor (int i=0; i<iMaxSamples; i++)\n{\ncurrSampledHeight=texture2D(bumpSampler,vBumpUV+vCurrOffset).w;\n\nif (currSampledHeight>currRayHeight)\n{\nfloat delta1=currSampledHeight-currRayHeight;\nfloat delta2=(currRayHeight+stepSize)-lastSampledHeight;\nfloat ratio=delta1/(delta1+delta2);\nvCurrOffset=(ratio)* vLastOffset+(1.0-ratio)*vCurrOffset;\n\nbreak;\n}\nelse\n{\ncurrRayHeight-=stepSize;\nvLastOffset=vCurrOffset;\nvCurrOffset+=stepSize*vMaxOffset;\nlastSampledHeight=currSampledHeight;\n}\n}\nreturn vCurrOffset;\n}\nvec2 parallaxOffset(vec3 viewDir,float heightScale)\n{\n\nfloat height=texture2D(bumpSampler,vBumpUV).w;\nvec2 texCoordOffset=heightScale*viewDir.xy*height;\nreturn -texCoordOffset;\n}\n#endif\n#endif",clipPlaneFragmentDeclaration:"#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",fogFragmentDeclaration:"#ifdef FOG\n#define FOGMODE_NONE 0.\n#define FOGMODE_EXP 1.\n#define FOGMODE_EXP2 2.\n#define FOGMODE_LINEAR 3.\n#define E 2.71828\nuniform vec4 vFogInfos;\nuniform vec3 vFogColor;\nvarying vec3 vFogDistance;\nfloat CalcFogFactor()\n{\nfloat fogCoeff=1.0;\nfloat fogStart=vFogInfos.y;\nfloat fogEnd=vFogInfos.z;\nfloat fogDensity=vFogInfos.w;\nfloat fogDistance=length(vFogDistance);\nif (FOGMODE_LINEAR == vFogInfos.x)\n{\nfogCoeff=(fogEnd-fogDistance)/(fogEnd-fogStart);\n}\nelse if (FOGMODE_EXP == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDensity);\n}\nelse if (FOGMODE_EXP2 == vFogInfos.x)\n{\nfogCoeff=1.0/pow(E,fogDistance*fogDistance*fogDensity*fogDensity);\n}\nreturn clamp(fogCoeff,0.0,1.0);\n}\n#endif",clipPlaneFragment:"#ifdef CLIPPLANE\nif (fClipDistance>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE2\nif (fClipDistance2>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE3\nif (fClipDistance3>0.0)\n{\ndiscard;\n}\n#endif\n#ifdef CLIPPLANE4\nif (fClipDistance4>0.0)\n{\ndiscard;\n}\n#endif",bumpFragment:"vec2 uvOffset=vec2(0.0,0.0);\n#if defined(BUMP) || defined(PARALLAX)\n#ifdef NORMALXYSCALE\nfloat normalScale=1.0;\n#else \nfloat normalScale=vBumpInfos.y;\n#endif\n#if defined(TANGENT) && defined(NORMAL)\nmat3 TBN=vTBN;\n#else\nmat3 TBN=cotangent_frame(normalW*normalScale,vPositionW,vBumpUV);\n#endif\n#endif\n#ifdef PARALLAX\nmat3 invTBN=transposeMat3(TBN);\n#ifdef PARALLAXOCCLUSION\nuvOffset=parallaxOcclusion(invTBN*-viewDirectionW,invTBN*normalW,vBumpUV,vBumpInfos.z);\n#else\nuvOffset=parallaxOffset(invTBN*viewDirectionW,vBumpInfos.z);\n#endif\n#endif\n#ifdef BUMP\n#ifdef OBJECTSPACE_NORMALMAP\nnormalW=normalize(texture2D(bumpSampler,vBumpUV).xyz*2.0-1.0);\nnormalW=normalize(mat3(normalMatrix)*normalW); \n#else\nnormalW=perturbNormal(TBN,vBumpUV+uvOffset);\n#endif\n#endif",lightFragment:"#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n#ifdef SPOTLIGHT{X}\nspotInfo=computeSpotLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\nspotInfo.attenuation=computeDistanceLightFalloff_GLTF(spotInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Physical(spotInfo.lightDistanceSquared);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\nspotInfo.attenuation=computeDistanceLightFalloff_Standard(spotInfo.lightOffset,light{X}.vLightFalloff.x);\nspotInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\nspotInfo.attenuation=computeDistanceLightFalloff(spotInfo.lightOffset,spotInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\nspotInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,spotInfo.directionToLightCenterW,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\ninfo=computeSpotLighting(spotInfo,viewDirectionW,normalW,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(POINTLIGHT{X})\npointInfo=computePointLightingInfo(light{X}.vLightData);\n#ifdef LIGHT_FALLOFF_GLTF{X}\npointInfo.attenuation=computeDistanceLightFalloff_GLTF(pointInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npointInfo.attenuation=computeDistanceLightFalloff_Physical(pointInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npointInfo.attenuation=computeDistanceLightFalloff_Standard(pointInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npointInfo.attenuation=computeDistanceLightFalloff(pointInfo.lightOffset,pointInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\ninfo=computePointLighting(pointInfo,viewDirectionW,normalW,light{X}.vLightDiffuse.rgb,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#elif defined(DIRLIGHT{X})\ninfo=computeDirectionalLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,roughness,NdotV,specularEnvironmentR0,specularEnvironmentR90,geometricRoughnessFactor,NdotL);\n#endif\n#else\n#ifdef SPOTLIGHT{X}\ninfo=computeSpotLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDirection,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#elif defined(HEMILIGHT{X})\ninfo=computeHemisphericLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightGround,glossiness);\n#elif defined(POINTLIGHT{X}) || defined(DIRLIGHT{X})\ninfo=computeLighting(viewDirectionW,normalW,light{X}.vLightData,light{X}.vLightDiffuse.rgb,light{X}.vLightSpecular,light{X}.vLightDiffuse.a,glossiness);\n#endif\n#endif\n#ifdef PROJECTEDLIGHTTEXTURE{X}\ninfo.diffuse*=computeProjectionTextureDiffuseLighting(projectionLightSampler{X},textureProjectionMatrix{X});\n#endif\n#endif\n#ifdef SHADOW{X}\n#ifdef SHADOWCLOSEESM{X}\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithCloseESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithCloseESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWESM{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithESMCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.depthValues);\n#else\nshadow=computeShadowWithESM(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.z,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPOISSON{X})\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowWithPoissonSamplingCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadowWithPoissonSampling(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCF{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCF1(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCF3(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCF5(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.yz,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#elif defined(SHADOWPCSS{X})\n#if defined(SHADOWLOWQUALITY{X})\nshadow=computeShadowWithPCSS16(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#elif defined(SHADOWMEDIUMQUALITY{X})\nshadow=computeShadowWithPCSS32(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#else\nshadow=computeShadowWithPCSS64(vPositionFromLight{X},vDepthMetric{X},depthSampler{X},shadowSampler{X},light{X}.shadowsInfo.y,light{X}.shadowsInfo.z,light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#else\n#if defined(SHADOWCUBE{X})\nshadow=computeShadowCube(light{X}.vLightData.xyz,shadowSampler{X},light{X}.shadowsInfo.x,light{X}.depthValues);\n#else\nshadow=computeShadow(vPositionFromLight{X},vDepthMetric{X},shadowSampler{X},light{X}.shadowsInfo.x,light{X}.shadowsInfo.w);\n#endif\n#endif\n#ifdef SHADOWONLY\n#ifndef SHADOWINUSE\n#define SHADOWINUSE\n#endif\nglobalShadow+=shadow;\nshadowLightCount+=1.0;\n#endif\n#else\nshadow=1.;\n#endif\n#ifndef SHADOWONLY\n#ifdef CUSTOMUSERLIGHTING\ndiffuseBase+=computeCustomDiffuseLighting(info,diffuseBase,shadow);\n#ifdef SPECULARTERM\nspecularBase+=computeCustomSpecularLighting(info,specularBase,shadow);\n#endif\n#elif defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X})\ndiffuseBase+=lightmapColor*shadow;\n#ifdef SPECULARTERM\n#ifndef LIGHTMAPNOSPECULAR{X}\nspecularBase+=info.specular*shadow*lightmapColor;\n#endif\n#endif\n#else\ndiffuseBase+=info.diffuse*shadow;\n#ifdef SPECULARTERM\nspecularBase+=info.specular*shadow;\n#endif\n#endif\n#endif\n#endif",logDepthFragment:"#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif",fogFragment:"#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif",pbrVertexDeclaration:"uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY \nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n",pbrFragmentDeclaration:"uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY \nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \n#endif\n#endif",pbrUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize; \nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};",pbrFunctions:"\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\nconst float kRougnhessToAlphaScale=0.1;\nconst float kRougnhessToAlphaOffset=0.29248125;\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nconst float kMinimumVariance=0.0005;\nfloat alphaG=square(roughness)+kMinimumVariance;\nreturn alphaG;\n}\n\nfloat smithVisibilityG1_TrowbridgeReitzGGX(float dot,float alphaG)\n{\nfloat tanSquared=(1.0-dot*dot)/(dot*dot);\nreturn 2.0/(1.0+sqrt(1.0+alphaG*alphaG*tanSquared));\n}\nfloat smithVisibilityG_TrowbridgeReitzGGX_Walter(float NdotL,float NdotV,float alphaG)\n{\nreturn smithVisibilityG1_TrowbridgeReitzGGX(NdotL,alphaG)*smithVisibilityG1_TrowbridgeReitzGGX(NdotV,alphaG);\n}\n\n\nfloat normalDistributionFunction_TrowbridgeReitzGGX(float NdotH,float alphaG)\n{\n\n\n\nfloat a2=square(alphaG);\nfloat d=NdotH*NdotH*(a2-1.0)+1.0;\nreturn a2/(PI*d*d);\n}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(clamp(1.0-VdotH,0.,1.),5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor)\n{\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibilityG_TrowbridgeReitzGGX_Walter(NdotL,NdotV,alphaG);\nvisibility/=(4.0*NdotL*NdotV); \nfloat specTerm=max(0.,visibility*distribution)*NdotL;\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel*NdotL/PI;\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}",harmonicsFunctions:"#ifdef USESPHERICALFROMREFLECTIONMAP\nuniform vec3 vSphericalX;\nuniform vec3 vSphericalY;\nuniform vec3 vSphericalZ;\nuniform vec3 vSphericalXX_ZZ;\nuniform vec3 vSphericalYY_ZZ;\nuniform vec3 vSphericalZZ;\nuniform vec3 vSphericalXY;\nuniform vec3 vSphericalYZ;\nuniform vec3 vSphericalZX;\nvec3 quaternionVectorRotation_ScaledSqrtTwo(vec4 Q,vec3 V){\nvec3 T=cross(Q.xyz,V);\nT+=Q.www*V;\nreturn cross(Q.xyz,T)+V;\n}\nvec3 environmentIrradianceJones(vec3 normal)\n{\n\n\n\n\n\n\n\n\n\nfloat Nx=normal.x;\nfloat Ny=normal.y;\nfloat Nz=normal.z;\nvec3 C1=vSphericalZZ.rgb;\nvec3 Cx=vSphericalX.rgb;\nvec3 Cy=vSphericalY.rgb;\nvec3 Cz=vSphericalZ.rgb;\nvec3 Cxx_zz=vSphericalXX_ZZ.rgb;\nvec3 Cyy_zz=vSphericalYY_ZZ.rgb;\nvec3 Cxy=vSphericalXY.rgb;\nvec3 Cyz=vSphericalYZ.rgb;\nvec3 Czx=vSphericalZX.rgb;\nvec3 a1=Cyy_zz*Ny+Cy;\nvec3 a2=Cyz*Nz+a1;\nvec3 b1=Czx*Nz+Cx;\nvec3 b2=Cxy*Ny+b1;\nvec3 b3=Cxx_zz*Nx+b2;\nvec3 t1=Cz*Nz+C1;\nvec3 t2=a2*Ny+t1;\nvec3 t3=b3*Nx+t2;\nreturn t3;\n}\n#endif",pbrLightFunctions:"\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n};\nstruct pointLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat attenuation;\n};\nstruct spotLightingInfo\n{\nvec3 lightOffset;\nfloat lightDistanceSquared;\nvec3 directionToLightCenterW;\nfloat attenuation;\n};\nfloat computeDistanceLightFalloff_Standard(vec3 lightOffset,float range)\n{\nreturn max(0.,1.0-length(lightOffset)/range);\n}\nfloat computeDistanceLightFalloff_Physical(float lightDistanceSquared)\n{\nreturn 1.0/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{ \n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977; \n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}\npointLightingInfo computePointLightingInfo(vec4 lightData) {\npointLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nspotLightingInfo computeSpotLightingInfo(vec4 lightData) {\nspotLightingInfo result;\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.directionToLightCenterW=normalize(result.lightOffset);\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\nreturn result;\n}\nlightingInfo computePointLighting(pointLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nvec3 lightDirection=normalize(info.lightOffset);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeSpotLighting(spotLightingInfo info,vec3 viewDirectionW,vec3 vNormal,vec4 lightDirection,vec3 diffuseColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\nfloat lightDistance=sqrt(info.lightDistanceSquared);\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+info.directionToLightCenterW);\nNdotL=clamp(dot(vNormal,info.directionToLightCenterW),0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor*info.attenuation;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor*info.attenuation;\n#endif\nreturn result;\n}\nlightingInfo computeDirectionalLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,float lightRadius,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\nfloat lightDistance=length(-lightData.xyz);\nvec3 lightDirection=normalize(-lightData.xyz);\n\nroughness=adjustRoughnessFromLightProperties(roughness,lightRadius,lightDistance);\n\nvec3 H=normalize(viewDirectionW+lightDirection);\nNdotL=clamp(dot(vNormal,lightDirection),0.00000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nfloat diffuseTerm=computeDiffuseTerm(NdotL,NdotV,VdotH,roughness);\nresult.diffuse=diffuseTerm*diffuseColor;\n#ifdef SPECULARTERM\n\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nlightingInfo computeHemisphericLighting(vec3 viewDirectionW,vec3 vNormal,vec4 lightData,vec3 diffuseColor,vec3 specularColor,vec3 groundColor,float roughness,float NdotV,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,out float NdotL) {\nlightingInfo result;\n\n\n\nNdotL=dot(vNormal,lightData.xyz)*0.5+0.5;\nresult.diffuse=mix(groundColor,diffuseColor,NdotL);\n#ifdef SPECULARTERM\n\nvec3 lightVectorW=normalize(lightData.xyz);\nvec3 H=normalize(viewDirectionW+lightVectorW);\nfloat NdotH=clamp(dot(vNormal,H),0.000000000001,1.0);\nNdotL=clamp(NdotL,0.000000000001,1.0);\nfloat VdotH=clamp(dot(viewDirectionW,H),0.0,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,NdotL,NdotV,VdotH,roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nresult.specular=specTerm*diffuseColor;\n#endif\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}",clipPlaneVertexDeclaration2:"#ifdef CLIPPLANE\nuniform vec4 vClipPlane;\nout float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nuniform vec4 vClipPlane2;\nout float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nuniform vec4 vClipPlane3;\nout float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nuniform vec4 vClipPlane4;\nout float fClipDistance4;\n#endif",clipPlaneFragmentDeclaration2:"#ifdef CLIPPLANE\nin float fClipDistance;\n#endif\n#ifdef CLIPPLANE2\nin float fClipDistance2;\n#endif\n#ifdef CLIPPLANE3\nin float fClipDistance3;\n#endif\n#ifdef CLIPPLANE4\nin float fClipDistance4;\n#endif",mrtFragmentDeclaration:"#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n",bones300Declaration:"#if NUM_BONE_INFLUENCERS>0\nuniform mat4 mBones[BonesPerMesh];\nin vec4 matricesIndices;\nin vec4 matricesWeights;\n#if NUM_BONE_INFLUENCERS>4\nin vec4 matricesIndicesExtra;\nin vec4 matricesWeightsExtra;\n#endif\n#endif",instances300Declaration:"#ifdef INSTANCES\nin vec4 world0;\nin vec4 world1;\nin vec4 world2;\nin vec4 world3;\n#else\nuniform mat4 world;\n#endif",kernelBlurFragment:"#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",kernelBlurFragment2:"#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",kernelBlurVaryingDeclaration:"varying vec2 sampleCoord{X};",kernelBlurVertex:"sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};",backgroundVertexDeclaration:"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",backgroundFragmentDeclaration:" 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",backgroundUboDeclaration:"layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};"},$a.CollisionWorker='var BABYLON;!function(D){var a,x=(a={root:0,found:!1},function(t,e,o,i){a.root=0,a.found=!1;var s=e*e-4*t*o;if(s<0)return a;var r=Math.sqrt(s),n=(-e-r)/(2*t),c=(-e+r)/(2*t);if(c<n){var h=c;c=n,n=h}return 0<n&&n<i?(a.root=n,a.found=!0):0<c&&c<i&&(a.root=c,a.found=!0),a}),t=function(){function t(){this._collisionPoint=D.Vector3.Zero(),this._planeIntersectionPoint=D.Vector3.Zero(),this._tempVector=D.Vector3.Zero(),this._tempVector2=D.Vector3.Zero(),this._tempVector3=D.Vector3.Zero(),this._tempVector4=D.Vector3.Zero(),this._edge=D.Vector3.Zero(),this._baseToVertex=D.Vector3.Zero(),this._destinationPoint=D.Vector3.Zero(),this._slidePlaneNormal=D.Vector3.Zero(),this._displacementVector=D.Vector3.Zero(),this._radius=D.Vector3.One(),this._retry=0,this._basePointWorld=D.Vector3.Zero(),this._velocityWorld=D.Vector3.Zero(),this._normalizedVelocity=D.Vector3.Zero(),this._collisionMask=-1}return Object.defineProperty(t.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(t){this._collisionMask=isNaN(t)?-1:t},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!0,configurable:!0}),t.prototype._initialize=function(t,e,o){this._velocity=e,D.Vector3.NormalizeToRef(e,this._normalizedVelocity),(this._basePoint=t).multiplyToRef(this._radius,this._basePointWorld),e.multiplyToRef(this._radius,this._velocityWorld),this._velocityWorldLength=this._velocityWorld.length(),this._epsilon=o,this.collisionFound=!1},t.prototype._checkPointInTriangle=function(t,e,o,i,s){e.subtractToRef(t,this._tempVector),o.subtractToRef(t,this._tempVector2),D.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var r=D.Vector3.Dot(this._tempVector4,s);return!(r<0)&&(i.subtractToRef(t,this._tempVector3),D.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((r=D.Vector3.Dot(this._tempVector4,s))<0)&&(D.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),0<=(r=D.Vector3.Dot(this._tempVector4,s))))},t.prototype._canDoCollision=function(t,e,o,i){var s,r,n,c,h=D.Vector3.Distance(this._basePointWorld,t),a=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(h>this._velocityWorldLength+a+e)&&(s=o,r=i,n=this._basePointWorld,c=this._velocityWorldLength+a,!(s.x>n.x+c||n.x-c>r.x||s.y>n.y+c||n.y-c>r.y||s.z>n.z+c||n.z-c>r.z))},t.prototype._testTriangle=function(t,e,o,i,s,r){var n,c=!1;e||(e=[]),e[t]||(e[t]=new D.Plane(0,0,0,0),e[t].copyFromPoints(o,i,s));var h=e[t];if(r||h.isFrontFacingTo(this._normalizedVelocity,0)){var a=h.signedDistanceTo(this._basePoint),l=D.Vector3.Dot(h.normal,this._velocity);if(0==l){if(1<=Math.abs(a))return;c=!0,n=0}else{var _=(1-a)/l;if(_<(n=(-1-a)/l)){var d=_;_=n,n=d}if(1<n||_<0)return;n<0&&(n=0),1<n&&(n=1)}this._collisionPoint.copyFromFloats(0,0,0);var V=!1,u=1;if(c||(this._basePoint.subtractToRef(h.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(n,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,o,i,s,h.normal)&&(V=!0,u=n,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!V){var p=this._velocity.lengthSquared(),P=p;this._basePoint.subtractToRef(o,this._tempVector);var f=2*D.Vector3.Dot(this._velocity,this._tempVector),m=this._tempVector.lengthSquared()-1,b=x(P,f,m,u);b.found&&(u=b.root,V=!0,this._collisionPoint.copyFrom(o)),this._basePoint.subtractToRef(i,this._tempVector),f=2*D.Vector3.Dot(this._velocity,this._tempVector),m=this._tempVector.lengthSquared()-1,(b=x(P,f,m,u)).found&&(u=b.root,V=!0,this._collisionPoint.copyFrom(i)),this._basePoint.subtractToRef(s,this._tempVector),f=2*D.Vector3.Dot(this._velocity,this._tempVector),m=this._tempVector.lengthSquared()-1,(b=x(P,f,m,u)).found&&(u=b.root,V=!0,this._collisionPoint.copyFrom(s)),i.subtractToRef(o,this._edge),o.subtractToRef(this._basePoint,this._baseToVertex);var y=this._edge.lengthSquared(),T=D.Vector3.Dot(this._edge,this._velocity),g=D.Vector3.Dot(this._edge,this._baseToVertex);if(P=y*-p+T*T,f=y*(2*D.Vector3.Dot(this._velocity,this._baseToVertex))-2*T*g,m=y*(1-this._baseToVertex.lengthSquared())+g*g,(b=x(P,f,m,u)).found){var v=(T*b.root-g)/y;0<=v&&v<=1&&(u=b.root,V=!0,this._edge.scaleInPlace(v),o.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(i,this._edge),i.subtractToRef(this._basePoint,this._baseToVertex),y=this._edge.lengthSquared(),T=D.Vector3.Dot(this._edge,this._velocity),g=D.Vector3.Dot(this._edge,this._baseToVertex),P=y*-p+T*T,f=y*(2*D.Vector3.Dot(this._velocity,this._baseToVertex))-2*T*g,m=y*(1-this._baseToVertex.lengthSquared())+g*g,(b=x(P,f,m,u)).found&&0<=(v=(T*b.root-g)/y)&&v<=1&&(u=b.root,V=!0,this._edge.scaleInPlace(v),i.addToRef(this._edge,this._collisionPoint)),o.subtractToRef(s,this._edge),s.subtractToRef(this._basePoint,this._baseToVertex),y=this._edge.lengthSquared(),T=D.Vector3.Dot(this._edge,this._velocity),g=D.Vector3.Dot(this._edge,this._baseToVertex),P=y*-p+T*T,f=y*(2*D.Vector3.Dot(this._velocity,this._baseToVertex))-2*T*g,m=y*(1-this._baseToVertex.lengthSquared())+g*g,(b=x(P,f,m,u)).found&&0<=(v=(T*b.root-g)/y)&&v<=1&&(u=b.root,V=!0,this._edge.scaleInPlace(v),s.addToRef(this._edge,this._collisionPoint))}if(V){var R=u*this._velocity.length();(!this.collisionFound||R<this._nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this._nearestDistance=R,this.collisionFound=!0)}}},t.prototype._collide=function(t,e,o,i,s,r,n){for(var c=i;c<s;c+=3){var h=e[o[c]-r],a=e[o[c+1]-r],l=e[o[c+2]-r];this._testTriangle(c,t,l,a,h,n)}},t.prototype._getResponse=function(t,e){t.addToRef(e,this._destinationPoint),e.scaleInPlace(this._nearestDistance/e.length()),this._basePoint.addToRef(e,t),t.subtractToRef(this.intersectionPoint,this._slidePlaneNormal),this._slidePlaneNormal.normalize(),this._slidePlaneNormal.scaleToRef(this._epsilon,this._displacementVector),t.addInPlace(this._displacementVector),this.intersectionPoint.addInPlace(this._displacementVector),this._slidePlaneNormal.scaleInPlace(D.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,e)},t}();D.Collider=t}(BABYLON||(BABYLON={}));var BABYLON,safePostMessage=self.postMessage;!function(a){a.WorkerIncluded=!0;var i=function(){function e(){this._meshes={},this._geometries={}}return e.prototype.getMeshes=function(){return this._meshes},e.prototype.getGeometries=function(){return this._geometries},e.prototype.getMesh=function(e){return this._meshes[e]},e.prototype.addMesh=function(e){this._meshes[e.uniqueId]=e},e.prototype.removeMesh=function(e){delete this._meshes[e]},e.prototype.getGeometry=function(e){return this._geometries[e]},e.prototype.addGeometry=function(e){this._geometries[e.id]=e},e.prototype.removeGeometry=function(e){delete this._geometries[e]},e}();a.CollisionCache=i;var s=function(){function e(e,o,i){this.collider=e,this._collisionCache=o,this.finalPosition=i,this.collisionsScalingMatrix=a.Matrix.Zero(),this.collisionTranformationMatrix=a.Matrix.Zero()}return e.prototype.collideWithWorld=function(e,o,i,r){if(this.collider._retry>=i)this.finalPosition.copyFrom(e);else{this.collider._initialize(e,o,.01);for(var t,s=this._collisionCache.getMeshes(),l=Object.keys(s),n=l.length,a=0;a<n;++a)if(t=l[a],parseInt(t)!=r){var c=s[t];c.checkCollisions&&this.checkCollision(c)}this.collider.collisionFound?(0===o.x&&0===o.y&&0===o.z||this.collider._getResponse(e,o),o.length()<=.01?this.finalPosition.copyFrom(e):(this.collider._retry++,this.collideWithWorld(e,o,i,r))):e.addToRef(o,this.finalPosition)}},e.prototype.checkCollision=function(e){this.collider._canDoCollision(a.Vector3.FromArray(e.sphereCenter),e.sphereRadius,a.Vector3.FromArray(e.boxMinimum),a.Vector3.FromArray(e.boxMaximum))&&(a.Matrix.ScalingToRef(1/this.collider._radius.x,1/this.collider._radius.y,1/this.collider._radius.z,this.collisionsScalingMatrix),a.Matrix.FromArray(e.worldMatrixFromCache).multiplyToRef(this.collisionsScalingMatrix,this.collisionTranformationMatrix),this.processCollisionsForSubMeshes(this.collisionTranformationMatrix,e))},e.prototype.processCollisionsForSubMeshes=function(e,o){var i=o.subMeshes,r=i.length;if(o.geometryId){var t=this._collisionCache.getGeometry(o.geometryId);if(t)for(var s=0;s<r;s++){var l=i[s];1<r&&!this.checkSubmeshCollision(l)||(this.collideForSubMesh(l,e,t),this.collider.collisionFound&&(this.collider.collidedMesh=o.uniqueId))}else console.log("couldn\'t find geometry",o.geometryId)}else console.log("no mesh geometry id")},e.prototype.collideForSubMesh=function(e,o,i){if(!i.positionsArray){i.positionsArray=[];for(var r=0,t=i.positions.length;r<t;r+=3){var s=a.Vector3.FromArray([i.positions[r],i.positions[r+1],i.positions[r+2]]);i.positionsArray.push(s)}}if(!e._lastColliderWorldVertices||!e._lastColliderTransformMatrix.equals(o)){e._lastColliderTransformMatrix=o.clone(),e._lastColliderWorldVertices=[],e._trianglePlanes=[];var l=e.verticesStart,n=e.verticesStart+e.verticesCount;for(r=l;r<n;r++)e._lastColliderWorldVertices.push(a.Vector3.TransformCoordinates(i.positionsArray[r],o))}this.collider._collide(e._trianglePlanes,e._lastColliderWorldVertices,i.indices,e.indexStart,e.indexStart+e.indexCount,e.verticesStart,e.hasMaterial)},e.prototype.checkSubmeshCollision=function(e){return this.collider._canDoCollision(a.Vector3.FromArray(e.sphereCenter),e.sphereRadius,a.Vector3.FromArray(e.boxMinimum),a.Vector3.FromArray(e.boxMaximum))},e}();a.CollideWorker=s;var e=function(){function e(){}return e.prototype.onInit=function(e){this._collisionCache=new i;var o={error:a.WorkerReplyType.SUCCESS,taskType:a.WorkerTaskType.INIT};safePostMessage(o)},e.prototype.onUpdate=function(e){var o=this,i={error:a.WorkerReplyType.SUCCESS,taskType:a.WorkerTaskType.UPDATE};try{for(var r in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(r)&&this._collisionCache.addGeometry(e.updatedGeometries[r]);for(var t in e.updatedMeshes)e.updatedMeshes.hasOwnProperty(t)&&this._collisionCache.addMesh(e.updatedMeshes[t]);e.removedGeometries.forEach(function(e){o._collisionCache.removeGeometry(e)}),e.removedMeshes.forEach(function(e){o._collisionCache.removeMesh(e)})}catch(e){i.error=a.WorkerReplyType.UNKNOWN_ERROR}safePostMessage(i)},e.prototype.onCollision=function(e){var o=a.Vector3.Zero(),i=new a.Collider;i._radius=a.Vector3.FromArray(e.collider.radius),new s(i,this._collisionCache,o).collideWithWorld(a.Vector3.FromArray(e.collider.position),a.Vector3.FromArray(e.collider.velocity),e.maximumRetry,e.excludedMeshUniqueId);var r={collidedMeshUniqueId:i.collidedMesh,collisionId:e.collisionId,newPosition:o.asArray()},t={error:a.WorkerReplyType.SUCCESS,taskType:a.WorkerTaskType.COLLIDE,payload:r};safePostMessage(t)},e}();a.CollisionDetectorTransferable=e;try{if(self&&self instanceof WorkerGlobalScope){window={},a.Collider||(importScripts("./babylon.collisionCoordinator.js"),importScripts("./babylon.collider.js"),importScripts("../Math/babylon.math.js"));var r=new e;self.onmessage=function(e){var o=e.data;switch(o.taskType){case a.WorkerTaskType.INIT:r.onInit(o.payload);break;case a.WorkerTaskType.COLLIDE:r.onCollision(o.payload);break;case a.WorkerTaskType.UPDATE:r.onUpdate(o.payload)}}}}catch(e){console.log("single worker init")}}(BABYLON||(BABYLON={}));var BABYLON;!function(c){var d,e,n,o;c.CollisionWorker="",(e=d=c.WorkerTaskType||(c.WorkerTaskType={}))[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE",(o=n=c.WorkerReplyType||(c.WorkerReplyType={}))[o.SUCCESS=0]="SUCCESS",o[o.UNKNOWN_ERROR=1]="UNKNOWN_ERROR";var i=function(){function o(){var s=this;this._scaledPosition=c.Vector3.Zero(),this._scaledVelocity=c.Vector3.Zero(),this.onMeshUpdated=function(e){s._addUpdateMeshesList[e.uniqueId]=o.SerializeMesh(e)},this.onGeometryUpdated=function(e){s._addUpdateGeometriesList[e.id]=o.SerializeGeometry(e)},this._afterRender=function(){if(s._init&&!(0==s._toRemoveGeometryArray.length&&0==s._toRemoveMeshesArray.length&&0==Object.keys(s._addUpdateGeometriesList).length&&0==Object.keys(s._addUpdateMeshesList).length||4<s._runningUpdated)){++s._runningUpdated;var e={updatedMeshes:s._addUpdateMeshesList,updatedGeometries:s._addUpdateGeometriesList,removedGeometries:s._toRemoveGeometryArray,removedMeshes:s._toRemoveMeshesArray},o={payload:e,taskType:d.UPDATE},i=[];for(var t in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(t)&&(i.push(o.payload.updatedGeometries[t].indices.buffer),i.push(o.payload.updatedGeometries[t].normals.buffer),i.push(o.payload.updatedGeometries[t].positions.buffer));s._worker.postMessage(o,i),s._addUpdateMeshesList={},s._addUpdateGeometriesList={},s._toRemoveGeometryArray=[],s._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(e){var o=e.data;if(o.error==n.SUCCESS)switch(o.taskType){case d.INIT:s._init=!0,s._scene.meshes.forEach(function(e){s.onMeshAdded(e)}),s._scene.getGeometries().forEach(function(e){s.onGeometryAdded(e)});break;case d.UPDATE:s._runningUpdated--;break;case d.COLLIDE:var i=o.payload;if(!s._collisionsCallbackArray[i.collisionId])return;var t=s._collisionsCallbackArray[i.collisionId];if(t){var r=s._scene.getMeshByUniqueID(i.collidedMeshUniqueId);r&&t(i.collisionId,c.Vector3.FromArray(i.newPosition),r)}s._collisionsCallbackArray[i.collisionId]=null}else c.Tools.Warn("error returned from worker!")},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return o.prototype.getNewPosition=function(e,o,i,t,r,s,n){if(this._init&&!this._collisionsCallbackArray[n]&&!this._collisionsCallbackArray[n+1e5]){e.divideToRef(i._radius,this._scaledPosition),o.divideToRef(i._radius,this._scaledVelocity),this._collisionsCallbackArray[n]=s;var a={payload:{collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:i._radius.asArray()},collisionId:n,excludedMeshUniqueId:r?r.uniqueId:null,maximumRetry:t},taskType:d.COLLIDE};this._worker.postMessage(a)}},o.prototype.init=function(e){this._scene=e,this._scene.registerAfterRender(this._afterRender);var o=c.WorkerIncluded?c.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([c.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(o),this._worker.onmessage=this._onMessageFromWorker;var i={payload:{},taskType:d.INIT};this._worker.postMessage(i)},o.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},o.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},o.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},o.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},o.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},o.SerializeMesh=function(e){var o=[];e.subMeshes&&(o=e.subMeshes.map(function(e,o){var i=e.getBoundingInfo();return{position:o,verticesStart:e.verticesStart,verticesCount:e.verticesCount,indexStart:e.indexStart,indexCount:e.indexCount,hasMaterial:!!e.getMaterial(),sphereCenter:i.boundingSphere.centerWorld.asArray(),sphereRadius:i.boundingSphere.radiusWorld,boxMinimum:i.boundingBox.minimumWorld.asArray(),boxMaximum:i.boundingBox.maximumWorld.asArray()}}));var i=null;if(e instanceof c.Mesh)i=(t=e.geometry)?t.id:null;else if(e instanceof c.InstancedMesh){var t;i=(t=e.sourceMesh&&e.sourceMesh.geometry)?t.id:null}var r=e.getBoundingInfo();return{uniqueId:e.uniqueId,id:e.id,name:e.name,geometryId:i,sphereCenter:r.boundingSphere.centerWorld.asArray(),sphereRadius:r.boundingSphere.radiusWorld,boxMinimum:r.boundingBox.minimumWorld.asArray(),boxMaximum:r.boundingBox.maximumWorld.asArray(),worldMatrixFromCache:e.worldMatrixFromCache.asArray(),subMeshes:o,checkCollisions:e.checkCollisions}},o.SerializeGeometry=function(e){return{id:e.id,positions:new Float32Array(e.getVerticesData(c.VertexBuffer.PositionKind)||[]),normals:new Float32Array(e.getVerticesData(c.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(e.getIndices()||[])}},o}();c.CollisionCoordinatorWorker=i;var t=function(){function e(){this._scaledPosition=c.Vector3.Zero(),this._scaledVelocity=c.Vector3.Zero(),this._finalPosition=c.Vector3.Zero()}return e.prototype.getNewPosition=function(e,o,i,t,r,s,n){e.divideToRef(i._radius,this._scaledPosition),o.divideToRef(i._radius,this._scaledVelocity),i.collidedMesh=null,i._retry=0,i._initialVelocity=this._scaledVelocity,i._initialPosition=this._scaledPosition,this._collideWithWorld(this._scaledPosition,this._scaledVelocity,i,t,this._finalPosition,r),this._finalPosition.multiplyInPlace(i._radius),s(n,this._finalPosition,i.collidedMesh)},e.prototype.init=function(e){this._scene=e},e.prototype.destroy=function(){},e.prototype.onMeshAdded=function(e){},e.prototype.onMeshUpdated=function(e){},e.prototype.onMeshRemoved=function(e){},e.prototype.onGeometryAdded=function(e){},e.prototype.onGeometryUpdated=function(e){},e.prototype.onGeometryDeleted=function(e){},e.prototype._collideWithWorld=function(e,o,i,t,r,s){void 0===s&&(s=null);var n=10*c.Engine.CollisionsEpsilon;if(i._retry>=t)r.copyFrom(e);else{var a=s?s.collisionMask:i.collisionMask;i._initialize(e,o,n);for(var d=0;d<this._scene.meshes.length;d++){var l=this._scene.meshes[d];l.isEnabled()&&l.checkCollisions&&l.subMeshes&&l!==s&&0!=(a&l.collisionGroup)&&l._checkCollision(i)}i.collisionFound?(0===o.x&&0===o.y&&0===o.z||i._getResponse(e,o),o.length()<=n?r.copyFrom(e):(i._retry++,this._collideWithWorld(e,o,i,t,r,s))):e.addToRef(o,r)}},e}();c.CollisionCoordinatorLegacy=t}(BABYLON||(BABYLON={}));var BABYLON;!function(p){p.ToGammaSpace=1/2.2,p.ToLinearSpace=2.2,p.Epsilon=.001;var i=function(){function n(t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),this.r=t,this.g=i,this.b=r}return n.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},n.prototype.getClassName=function(){return"Color3"},n.prototype.getHashCode=function(){var t=this.r||0;return t=397*(t=397*t^(this.g||0))^(this.b||0)},n.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,this},n.prototype.toColor4=function(t){return void 0===t&&(t=1),new r(this.r,this.g,this.b,t)},n.prototype.asArray=function(){var t=new Array;return this.toArray(t,0),t},n.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},n.prototype.multiply=function(t){return new n(this.r*t.r,this.g*t.g,this.b*t.b)},n.prototype.multiplyToRef=function(t,i){return i.r=this.r*t.r,i.g=this.g*t.g,i.b=this.b*t.b,this},n.prototype.equals=function(t){return t&&this.r===t.r&&this.g===t.g&&this.b===t.b},n.prototype.equalsFloats=function(t,i,r){return this.r===t&&this.g===i&&this.b===r},n.prototype.scale=function(t){return new n(this.r*t,this.g*t,this.b*t)},n.prototype.scaleToRef=function(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,this},n.prototype.scaleAndAddToRef=function(t,i){return i.r+=this.r*t,i.g+=this.g*t,i.b+=this.b*t,this},n.prototype.clampToRef=function(t,i,r){return void 0===t&&(t=0),void 0===i&&(i=1),r.r=p.Scalar.Clamp(this.r,t,i),r.g=p.Scalar.Clamp(this.g,t,i),r.b=p.Scalar.Clamp(this.b,t,i),this},n.prototype.add=function(t){return new n(this.r+t.r,this.g+t.g,this.b+t.b)},n.prototype.addToRef=function(t,i){return i.r=this.r+t.r,i.g=this.g+t.g,i.b=this.b+t.b,this},n.prototype.subtract=function(t){return new n(this.r-t.r,this.g-t.g,this.b-t.b)},n.prototype.subtractToRef=function(t,i){return i.r=this.r-t.r,i.g=this.g-t.g,i.b=this.b-t.b,this},n.prototype.clone=function(){return new n(this.r,this.g,this.b)},n.prototype.copyFrom=function(t){return this.r=t.r,this.g=t.g,this.b=t.b,this},n.prototype.copyFromFloats=function(t,i,r){return this.r=t,this.g=i,this.b=r,this},n.prototype.set=function(t,i,r){return this.copyFromFloats(t,i,r)},n.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;return"#"+p.Scalar.ToHex(t)+p.Scalar.ToHex(i)+p.Scalar.ToHex(r)},n.prototype.toLinearSpace=function(){var t=new n;return this.toLinearSpaceToRef(t),t},n.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,p.ToLinearSpace),t.g=Math.pow(this.g,p.ToLinearSpace),t.b=Math.pow(this.b,p.ToLinearSpace),this},n.prototype.toGammaSpace=function(){var t=new n;return this.toGammaSpaceToRef(t),t},n.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,p.ToGammaSpace),t.g=Math.pow(this.g,p.ToGammaSpace),t.b=Math.pow(this.b,p.ToGammaSpace),this},n.FromHexString=function(t){if("#"!==t.substring(0,1)||7!==t.length)return new n(0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),o=parseInt(t.substring(5,7),16);return n.FromInts(i,r,o)},n.FromArray=function(t,i){return void 0===i&&(i=0),new n(t[i],t[i+1],t[i+2])},n.FromInts=function(t,i,r){return new n(t/255,i/255,r/255)},n.Lerp=function(t,i,r){var o=new n(0,0,0);return n.LerpToRef(t,i,r,o),o},n.LerpToRef=function(t,i,r,o){o.r=t.r+(i.r-t.r)*r,o.g=t.g+(i.g-t.g)*r,o.b=t.b+(i.b-t.b)*r},n.Red=function(){return new n(1,0,0)},n.Green=function(){return new n(0,1,0)},n.Blue=function(){return new n(0,0,1)},n.Black=function(){return new n(0,0,0)},n.White=function(){return new n(1,1,1)},n.Purple=function(){return new n(.5,0,.5)},n.Magenta=function(){return new n(1,0,1)},n.Yellow=function(){return new n(1,1,0)},n.Gray=function(){return new n(.5,.5,.5)},n.Teal=function(){return new n(0,1,1)},n.Random=function(){return new n(Math.random(),Math.random(),Math.random())},n}();p.Color3=i;var r=function(){function e(t,i,r,o){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=1),this.r=t,this.g=i,this.b=r,this.a=o}return e.prototype.addInPlace=function(t){return this.r+=t.r,this.g+=t.g,this.b+=t.b,this.a+=t.a,this},e.prototype.asArray=function(){var t=new Array;return this.toArray(t,0),t},e.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.r,t[i+1]=this.g,t[i+2]=this.b,t[i+3]=this.a,this},e.prototype.add=function(t){return new e(this.r+t.r,this.g+t.g,this.b+t.b,this.a+t.a)},e.prototype.subtract=function(t){return new e(this.r-t.r,this.g-t.g,this.b-t.b,this.a-t.a)},e.prototype.subtractToRef=function(t,i){return i.r=this.r-t.r,i.g=this.g-t.g,i.b=this.b-t.b,i.a=this.a-t.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(t,i){return i.r=this.r*t,i.g=this.g*t,i.b=this.b*t,i.a=this.a*t,this},e.prototype.scaleAndAddToRef=function(t,i){return i.r+=this.r*t,i.g+=this.g*t,i.b+=this.b*t,i.a+=this.a*t,this},e.prototype.clampToRef=function(t,i,r){return void 0===t&&(t=0),void 0===i&&(i=1),r.r=p.Scalar.Clamp(this.r,t,i),r.g=p.Scalar.Clamp(this.g,t,i),r.b=p.Scalar.Clamp(this.b,t,i),r.a=p.Scalar.Clamp(this.a,t,i),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(t,i){return i.r=this.r*t.r,i.g=this.g*t.g,i.b=this.b*t.b,i.a=this.a*t.a,i},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 t=this.r||0;return t=397*(t=397*(t=397*t^(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(t){return this.r=t.r,this.g=t.g,this.b=t.b,this.a=t.a,this},e.prototype.copyFromFloats=function(t,i,r,o){return this.r=t,this.g=i,this.b=r,this.a=o,this},e.prototype.set=function(t,i,r,o){return this.copyFromFloats(t,i,r,o)},e.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0,o=255*this.a|0;return"#"+p.Scalar.ToHex(t)+p.Scalar.ToHex(i)+p.Scalar.ToHex(r)+p.Scalar.ToHex(o)},e.prototype.toLinearSpace=function(){var t=new e;return this.toLinearSpaceToRef(t),t},e.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,p.ToLinearSpace),t.g=Math.pow(this.g,p.ToLinearSpace),t.b=Math.pow(this.b,p.ToLinearSpace),t.a=this.a,this},e.prototype.toGammaSpace=function(){var t=new e;return this.toGammaSpaceToRef(t),t},e.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,p.ToGammaSpace),t.g=Math.pow(this.g,p.ToGammaSpace),t.b=Math.pow(this.b,p.ToGammaSpace),t.a=this.a,this},e.FromHexString=function(t){if("#"!==t.substring(0,1)||9!==t.length)return new e(0,0,0,0);var i=parseInt(t.substring(1,3),16),r=parseInt(t.substring(3,5),16),o=parseInt(t.substring(5,7),16),n=parseInt(t.substring(7,9),16);return e.FromInts(i,r,o,n)},e.Lerp=function(t,i,r){var o=new e(0,0,0,0);return e.LerpToRef(t,i,r,o),o},e.LerpToRef=function(t,i,r,o){o.r=t.r+(i.r-t.r)*r,o.g=t.g+(i.g-t.g)*r,o.b=t.b+(i.b-t.b)*r,o.a=t.a+(i.a-t.a)*r},e.FromColor3=function(t,i){return void 0===i&&(i=1),new e(t.r,t.g,t.b,i)},e.FromArray=function(t,i){return void 0===i&&(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.FromInts=function(t,i,r,o){return new e(t/255,i/255,r/255,o/255)},e.CheckColors4=function(t,i){if(t.length===3*i){for(var r=[],o=0;o<t.length;o+=3){var n=o/3*4;r[n]=t[o],r[n+1]=t[o+1],r[n+2]=t[o+2],r[n+3]=1}return r}return t},e}();p.Color4=r;var f=function(){function y(t,i){void 0===t&&(t=0),void 0===i&&(i=0),this.x=t,this.y=i}return y.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},y.prototype.getClassName=function(){return"Vector2"},y.prototype.getHashCode=function(){var t=this.x||0;return t=397*t^(this.y||0)},y.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,this},y.prototype.asArray=function(){var t=new Array;return this.toArray(t,0),t},y.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this},y.prototype.copyFromFloats=function(t,i){return this.x=t,this.y=i,this},y.prototype.set=function(t,i){return this.copyFromFloats(t,i)},y.prototype.add=function(t){return new y(this.x+t.x,this.y+t.y)},y.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,this},y.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this},y.prototype.addVector3=function(t){return new y(this.x+t.x,this.y+t.y)},y.prototype.subtract=function(t){return new y(this.x-t.x,this.y-t.y)},y.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,this},y.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this},y.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this},y.prototype.multiply=function(t){return new y(this.x*t.x,this.y*t.y)},y.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,this},y.prototype.multiplyByFloats=function(t,i){return new y(this.x*t,this.y*i)},y.prototype.divide=function(t){return new y(this.x/t.x,this.y/t.y)},y.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,this},y.prototype.divideInPlace=function(t){return this.divideToRef(t,this)},y.prototype.negate=function(){return new y(-this.x,-this.y)},y.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this},y.prototype.scale=function(t){var i=new y(0,0);return this.scaleToRef(t,i),i},y.prototype.scaleToRef=function(t,i){return i.x=this.x*t,i.y=this.y*t,this},y.prototype.scaleAndAddToRef=function(t,i){return i.x+=this.x*t,i.y+=this.y*t,this},y.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y},y.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=p.Epsilon),t&&p.Scalar.WithinEpsilon(this.x,t.x,i)&&p.Scalar.WithinEpsilon(this.y,t.y,i)},y.prototype.floor=function(){return new y(Math.floor(this.x),Math.floor(this.y))},y.prototype.fract=function(){return new y(this.x-Math.floor(this.x),this.y-Math.floor(this.y))},y.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},y.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},y.prototype.normalize=function(){var t=this.length();if(0===t)return this;var i=1/t;return this.x*=i,this.y*=i,this},y.prototype.clone=function(){return new y(this.x,this.y)},y.Zero=function(){return new y(0,0)},y.One=function(){return new y(1,1)},y.FromArray=function(t,i){return void 0===i&&(i=0),new y(t[i],t[i+1])},y.FromArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1]},y.CatmullRom=function(t,i,r,o,n){var e=n*n,s=n*e;return new y(.5*(2*i.x+(-t.x+r.x)*n+(2*t.x-5*i.x+4*r.x-o.x)*e+(-t.x+3*i.x-3*r.x+o.x)*s),.5*(2*i.y+(-t.y+r.y)*n+(2*t.y-5*i.y+4*r.y-o.y)*e+(-t.y+3*i.y-3*r.y+o.y)*s))},y.Clamp=function(t,i,r){var o=t.x;o=(o=o>r.x?r.x:o)<i.x?i.x:o;var n=t.y;return new y(o,n=(n=n>r.y?r.y:n)<i.y?i.y:n)},y.Hermite=function(t,i,r,o,n){var e=n*n,s=n*e,h=2*s-3*e+1,a=-2*s+3*e,u=s-2*e+n,m=s-e;return new y(t.x*h+r.x*a+i.x*u+o.x*m,t.y*h+r.y*a+i.y*u+o.y*m)},y.Lerp=function(t,i,r){return new y(t.x+(i.x-t.x)*r,t.y+(i.y-t.y)*r)},y.Dot=function(t,i){return t.x*i.x+t.y*i.y},y.Normalize=function(t){var i=t.clone();return i.normalize(),i},y.Minimize=function(t,i){return new y(t.x<i.x?t.x:i.x,t.y<i.y?t.y:i.y)},y.Maximize=function(t,i){return new y(t.x>i.x?t.x:i.x,t.y>i.y?t.y:i.y)},y.Transform=function(t,i){var r=y.Zero();return y.TransformToRef(t,i,r),r},y.TransformToRef=function(t,i,r){var o=t.x*i.m[0]+t.y*i.m[4]+i.m[12],n=t.x*i.m[1]+t.y*i.m[5]+i.m[13];r.x=o,r.y=n},y.PointInTriangle=function(t,i,r,o){var n=.5*(-r.y*o.x+i.y*(-r.x+o.x)+i.x*(r.y-o.y)+r.x*o.y),e=n<0?-1:1,s=(i.y*o.x-i.x*o.y+(o.y-i.y)*t.x+(i.x-o.x)*t.y)*e,h=(i.x*r.y-i.y*r.x+(i.y-r.y)*t.x+(r.x-i.x)*t.y)*e;return 0<s&&0<h&&s+h<2*n*e},y.Distance=function(t,i){return Math.sqrt(y.DistanceSquared(t,i))},y.DistanceSquared=function(t,i){var r=t.x-i.x,o=t.y-i.y;return r*r+o*o},y.Center=function(t,i){var r=t.add(i);return r.scaleInPlace(.5),r},y.DistanceOfPointFromSegment=function(t,i,r){var o=y.DistanceSquared(i,r);if(0===o)return y.Distance(t,i);var n=r.subtract(i),e=Math.max(0,Math.min(1,y.Dot(t.subtract(i),n)/o)),s=i.add(n.multiplyByFloats(e,e));return y.Distance(t,s)},y}();p.Vector2=f;var l=function(){function c(t,i,r){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),this.x=t,this.y=i,this.z=r}return c.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},c.prototype.getClassName=function(){return"Vector3"},c.prototype.getHashCode=function(){var t=this.x||0;return t=397*(t=397*t^(this.y||0))^(this.z||0)},c.prototype.asArray=function(){var t=[];return this.toArray(t,0),t},c.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,this},c.prototype.toQuaternion=function(){return p.Quaternion.RotationYawPitchRoll(this.x,this.y,this.z)},c.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this},c.prototype.add=function(t){return new c(this.x+t.x,this.y+t.y,this.z+t.z)},c.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,i.z=this.z+t.z,this},c.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this},c.prototype.subtract=function(t){return new c(this.x-t.x,this.y-t.y,this.z-t.z)},c.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,i.z=this.z-t.z,this},c.prototype.subtractFromFloats=function(t,i,r){return new c(this.x-t,this.y-i,this.z-r)},c.prototype.subtractFromFloatsToRef=function(t,i,r,o){return o.x=this.x-t,o.y=this.y-i,o.z=this.z-r,this},c.prototype.negate=function(){return new c(-this.x,-this.y,-this.z)},c.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this},c.prototype.scale=function(t){return new c(this.x*t,this.y*t,this.z*t)},c.prototype.scaleToRef=function(t,i){return i.x=this.x*t,i.y=this.y*t,i.z=this.z*t,this},c.prototype.scaleAndAddToRef=function(t,i){return i.x+=this.x*t,i.y+=this.y*t,i.z+=this.z*t,this},c.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z},c.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=p.Epsilon),t&&p.Scalar.WithinEpsilon(this.x,t.x,i)&&p.Scalar.WithinEpsilon(this.y,t.y,i)&&p.Scalar.WithinEpsilon(this.z,t.z,i)},c.prototype.equalsToFloats=function(t,i,r){return this.x===t&&this.y===i&&this.z===r},c.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this},c.prototype.multiply=function(t){return new c(this.x*t.x,this.y*t.y,this.z*t.z)},c.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,i.z=this.z*t.z,this},c.prototype.multiplyByFloats=function(t,i,r){return new c(this.x*t,this.y*i,this.z*r)},c.prototype.divide=function(t){return new c(this.x/t.x,this.y/t.y,this.z/t.z)},c.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,i.z=this.z/t.z,this},c.prototype.divideInPlace=function(t){return this.divideToRef(t,this)},c.prototype.minimizeInPlace=function(t){return this.minimizeInPlaceFromFloats(t.x,t.y,t.z)},c.prototype.maximizeInPlace=function(t){return this.maximizeInPlaceFromFloats(t.x,t.y,t.z)},c.prototype.minimizeInPlaceFromFloats=function(t,i,r){return t<this.x&&(this.x=t),i<this.y&&(this.y=i),r<this.z&&(this.z=r),this},c.prototype.maximizeInPlaceFromFloats=function(t,i,r){return t>this.x&&(this.x=t),i>this.y&&(this.y=i),r>this.z&&(this.z=r),this},Object.defineProperty(c.prototype,"isNonUniform",{get:function(){var t=Math.abs(this.x),i=Math.abs(this.y);if(t!==i)return!0;var r=Math.abs(this.z);return t!==r||i!==r},enumerable:!0,configurable:!0}),c.prototype.floor=function(){return new c(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z))},c.prototype.fract=function(){return new c(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z))},c.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},c.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},c.prototype.normalize=function(){var t=this.length();if(0===t||1===t)return this;var i=1/t;return this.x*=i,this.y*=i,this.z*=i,this},c.prototype.normalizeToNew=function(){var t=new c(0,0,0);return this.normalizeToRef(t),t},c.prototype.normalizeToRef=function(t){var i=this.length();if(0===i||1===i)return t.set(this.x,this.y,this.z),t;var r=1/i;return this.scaleToRef(r,t),t},c.prototype.clone=function(){return new c(this.x,this.y,this.z)},c.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this},c.prototype.copyFromFloats=function(t,i,r){return this.x=t,this.y=i,this.z=r,this},c.prototype.set=function(t,i,r){return this.copyFromFloats(t,i,r)},c.GetClipFactor=function(t,i,r,o){var n=c.Dot(t,r)-o;return n/(n-(c.Dot(i,r)-o))},c.GetAngleBetweenVectors=function(t,i,r){var o=_.Vector3[1].copyFrom(t).normalize(),n=_.Vector3[2].copyFrom(i).normalize(),e=c.Dot(o,n),s=_.Vector3[3];return c.CrossToRef(o,n,s),0<c.Dot(s,r)?Math.acos(e):-Math.acos(e)},c.FromArray=function(t,i){return i||(i=0),new c(t[i],t[i+1],t[i+2])},c.FromFloatArray=function(t,i){return c.FromArray(t,i)},c.FromArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2]},c.FromFloatArrayToRef=function(t,i,r){return c.FromArrayToRef(t,i,r)},c.FromFloatsToRef=function(t,i,r,o){o.x=t,o.y=i,o.z=r},c.Zero=function(){return new c(0,0,0)},c.One=function(){return new c(1,1,1)},c.Up=function(){return new c(0,1,0)},c.Down=function(){return new c(0,-1,0)},c.Forward=function(){return new c(0,0,1)},c.Backward=function(){return new c(0,0,-1)},c.Right=function(){return new c(1,0,0)},c.Left=function(){return new c(-1,0,0)},c.TransformCoordinates=function(t,i){var r=c.Zero();return c.TransformCoordinatesToRef(t,i,r),r},c.TransformCoordinatesToRef=function(t,i,r){var o=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8]+i.m[12],n=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9]+i.m[13],e=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10]+i.m[14],s=t.x*i.m[3]+t.y*i.m[7]+t.z*i.m[11]+i.m[15];r.x=o/s,r.y=n/s,r.z=e/s},c.TransformCoordinatesFromFloatsToRef=function(t,i,r,o,n){var e=t*o.m[0]+i*o.m[4]+r*o.m[8]+o.m[12],s=t*o.m[1]+i*o.m[5]+r*o.m[9]+o.m[13],h=t*o.m[2]+i*o.m[6]+r*o.m[10]+o.m[14],a=t*o.m[3]+i*o.m[7]+r*o.m[11]+o.m[15];n.x=e/a,n.y=s/a,n.z=h/a},c.TransformNormal=function(t,i){var r=c.Zero();return c.TransformNormalToRef(t,i,r),r},c.TransformNormalToRef=function(t,i,r){var o=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8],n=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9],e=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10];r.x=o,r.y=n,r.z=e},c.TransformNormalFromFloatsToRef=function(t,i,r,o,n){n.x=t*o.m[0]+i*o.m[4]+r*o.m[8],n.y=t*o.m[1]+i*o.m[5]+r*o.m[9],n.z=t*o.m[2]+i*o.m[6]+r*o.m[10]},c.CatmullRom=function(t,i,r,o,n){var e=n*n,s=n*e;return new c(.5*(2*i.x+(-t.x+r.x)*n+(2*t.x-5*i.x+4*r.x-o.x)*e+(-t.x+3*i.x-3*r.x+o.x)*s),.5*(2*i.y+(-t.y+r.y)*n+(2*t.y-5*i.y+4*r.y-o.y)*e+(-t.y+3*i.y-3*r.y+o.y)*s),.5*(2*i.z+(-t.z+r.z)*n+(2*t.z-5*i.z+4*r.z-o.z)*e+(-t.z+3*i.z-3*r.z+o.z)*s))},c.Clamp=function(t,i,r){var o=t.x;o=(o=o>r.x?r.x:o)<i.x?i.x:o;var n=t.y;n=(n=n>r.y?r.y:n)<i.y?i.y:n;var e=t.z;return new c(o,n,e=(e=e>r.z?r.z:e)<i.z?i.z:e)},c.Hermite=function(t,i,r,o,n){var e=n*n,s=n*e,h=2*s-3*e+1,a=-2*s+3*e,u=s-2*e+n,m=s-e;return new c(t.x*h+r.x*a+i.x*u+o.x*m,t.y*h+r.y*a+i.y*u+o.y*m,t.z*h+r.z*a+i.z*u+o.z*m)},c.Lerp=function(t,i,r){var o=new c(0,0,0);return c.LerpToRef(t,i,r,o),o},c.LerpToRef=function(t,i,r,o){o.x=t.x+(i.x-t.x)*r,o.y=t.y+(i.y-t.y)*r,o.z=t.z+(i.z-t.z)*r},c.Dot=function(t,i){return t.x*i.x+t.y*i.y+t.z*i.z},c.Cross=function(t,i){var r=c.Zero();return c.CrossToRef(t,i,r),r},c.CrossToRef=function(t,i,r){_.Vector3[0].x=t.y*i.z-t.z*i.y,_.Vector3[0].y=t.z*i.x-t.x*i.z,_.Vector3[0].z=t.x*i.y-t.y*i.x,r.copyFrom(_.Vector3[0])},c.Normalize=function(t){var i=c.Zero();return c.NormalizeToRef(t,i),i},c.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},c.Project=function(t,i,r,o){var n=o.width,e=o.height,s=o.x,h=o.y,a=c._viewportMatrixCache?c._viewportMatrixCache:c._viewportMatrixCache=new m;m.FromValuesToRef(n/2,0,0,0,0,-e/2,0,0,0,0,.5,0,s+n/2,e/2+h,.5,1,a);var u=_.Matrix[0];return i.multiplyToRef(r,u),u.multiplyToRef(a,u),c.TransformCoordinates(t,u)},c.UnprojectFromTransform=function(t,i,r,o,n){var e=_.Matrix[0];o.multiplyToRef(n,e),e.invert(),t.x=t.x/i*2-1,t.y=-(t.y/r*2-1);var s=c.TransformCoordinates(t,e),h=t.x*e.m[3]+t.y*e.m[7]+t.z*e.m[11]+e.m[15];return p.Scalar.WithinEpsilon(h,1)&&(s=s.scale(1/h)),s},c.Unproject=function(t,i,r,o,n,e){var s=c.Zero();return c.UnprojectToRef(t,i,r,o,n,e,s),s},c.UnprojectToRef=function(t,i,r,o,n,e,s){c.UnprojectFloatsToRef(t.x,t.y,t.z,i,r,o,n,e,s)},c.UnprojectFloatsToRef=function(t,i,r,o,n,e,s,h,a){var u=_.Matrix[0];e.multiplyToRef(s,u),u.multiplyToRef(h,u),u.invert();var m=_.Vector3[0];m.x=t/o*2-1,m.y=-(i/n*2-1),m.z=2*r-1,c.TransformCoordinatesToRef(m,u,a);var y=m.x*u.m[3]+m.y*u.m[7]+m.z*u.m[11]+u.m[15];p.Scalar.WithinEpsilon(y,1)&&a.scaleInPlace(1/y)},c.Minimize=function(t,i){var r=t.clone();return r.minimizeInPlace(i),r},c.Maximize=function(t,i){var r=t.clone();return r.maximizeInPlace(i),r},c.Distance=function(t,i){return Math.sqrt(c.DistanceSquared(t,i))},c.DistanceSquared=function(t,i){var r=t.x-i.x,o=t.y-i.y,n=t.z-i.z;return r*r+o*o+n*n},c.Center=function(t,i){var r=t.add(i);return r.scaleInPlace(.5),r},c.RotationFromAxis=function(t,i,r){var o=c.Zero();return c.RotationFromAxisToRef(t,i,r,o),o},c.RotationFromAxisToRef=function(t,i,r,o){var n=_.Quaternion[0];x.RotationQuaternionFromAxisToRef(t,i,r,n),n.toEulerAnglesToRef(o)},c}();p.Vector3=l;var o=function(){function n(t,i,r,o){this.x=t,this.y=i,this.z=r,this.w=o}return n.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},n.prototype.getClassName=function(){return"Vector4"},n.prototype.getHashCode=function(){var t=this.x||0;return t=397*(t=397*(t=397*t^(this.y||0))^(this.z||0))^(this.w||0)},n.prototype.asArray=function(){var t=new Array;return this.toArray(t,0),t},n.prototype.toArray=function(t,i){return void 0===i&&(i=0),t[i]=this.x,t[i+1]=this.y,t[i+2]=this.z,t[i+3]=this.w,this},n.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},n.prototype.add=function(t){return new n(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},n.prototype.addToRef=function(t,i){return i.x=this.x+t.x,i.y=this.y+t.y,i.z=this.z+t.z,i.w=this.w+t.w,this},n.prototype.subtractInPlace=function(t){return this.x-=t.x,this.y-=t.y,this.z-=t.z,this.w-=t.w,this},n.prototype.subtract=function(t){return new n(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},n.prototype.subtractToRef=function(t,i){return i.x=this.x-t.x,i.y=this.y-t.y,i.z=this.z-t.z,i.w=this.w-t.w,this},n.prototype.subtractFromFloats=function(t,i,r,o){return new n(this.x-t,this.y-i,this.z-r,this.w-o)},n.prototype.subtractFromFloatsToRef=function(t,i,r,o,n){return n.x=this.x-t,n.y=this.y-i,n.z=this.z-r,n.w=this.w-o,this},n.prototype.negate=function(){return new n(-this.x,-this.y,-this.z,-this.w)},n.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},n.prototype.scale=function(t){return new n(this.x*t,this.y*t,this.z*t,this.w*t)},n.prototype.scaleToRef=function(t,i){return i.x=this.x*t,i.y=this.y*t,i.z=this.z*t,i.w=this.w*t,this},n.prototype.scaleAndAddToRef=function(t,i){return i.x+=this.x*t,i.y+=this.y*t,i.z+=this.z*t,i.w+=this.w*t,this},n.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},n.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=p.Epsilon),t&&p.Scalar.WithinEpsilon(this.x,t.x,i)&&p.Scalar.WithinEpsilon(this.y,t.y,i)&&p.Scalar.WithinEpsilon(this.z,t.z,i)&&p.Scalar.WithinEpsilon(this.w,t.w,i)},n.prototype.equalsToFloats=function(t,i,r,o){return this.x===t&&this.y===i&&this.z===r&&this.w===o},n.prototype.multiplyInPlace=function(t){return this.x*=t.x,this.y*=t.y,this.z*=t.z,this.w*=t.w,this},n.prototype.multiply=function(t){return new n(this.x*t.x,this.y*t.y,this.z*t.z,this.w*t.w)},n.prototype.multiplyToRef=function(t,i){return i.x=this.x*t.x,i.y=this.y*t.y,i.z=this.z*t.z,i.w=this.w*t.w,this},n.prototype.multiplyByFloats=function(t,i,r,o){return new n(this.x*t,this.y*i,this.z*r,this.w*o)},n.prototype.divide=function(t){return new n(this.x/t.x,this.y/t.y,this.z/t.z,this.w/t.w)},n.prototype.divideToRef=function(t,i){return i.x=this.x/t.x,i.y=this.y/t.y,i.z=this.z/t.z,i.w=this.w/t.w,this},n.prototype.divideInPlace=function(t){return this.divideToRef(t,this)},n.prototype.minimizeInPlace=function(t){return t.x<this.x&&(this.x=t.x),t.y<this.y&&(this.y=t.y),t.z<this.z&&(this.z=t.z),t.w<this.w&&(this.w=t.w),this},n.prototype.maximizeInPlace=function(t){return t.x>this.x&&(this.x=t.x),t.y>this.y&&(this.y=t.y),t.z>this.z&&(this.z=t.z),t.w>this.w&&(this.w=t.w),this},n.prototype.floor=function(){return new n(Math.floor(this.x),Math.floor(this.y),Math.floor(this.z),Math.floor(this.w))},n.prototype.fract=function(){return new n(this.x-Math.floor(this.x),this.y-Math.floor(this.y),this.z-Math.floor(this.z),this.w-Math.floor(this.w))},n.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},n.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},n.prototype.normalize=function(){var t=this.length();if(0===t)return this;var i=1/t;return this.x*=i,this.y*=i,this.z*=i,this.w*=i,this},n.prototype.toVector3=function(){return new l(this.x,this.y,this.z)},n.prototype.clone=function(){return new n(this.x,this.y,this.z,this.w)},n.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},n.prototype.copyFromFloats=function(t,i,r,o){return this.x=t,this.y=i,this.z=r,this.w=o,this},n.prototype.set=function(t,i,r,o){return this.copyFromFloats(t,i,r,o)},n.FromArray=function(t,i){return i||(i=0),new n(t[i],t[i+1],t[i+2],t[i+3])},n.FromArrayToRef=function(t,i,r){r.x=t[i],r.y=t[i+1],r.z=t[i+2],r.w=t[i+3]},n.FromFloatArrayToRef=function(t,i,r){n.FromArrayToRef(t,i,r)},n.FromFloatsToRef=function(t,i,r,o,n){n.x=t,n.y=i,n.z=r,n.w=o},n.Zero=function(){return new n(0,0,0,0)},n.One=function(){return new n(1,1,1,1)},n.Normalize=function(t){var i=n.Zero();return n.NormalizeToRef(t,i),i},n.NormalizeToRef=function(t,i){i.copyFrom(t),i.normalize()},n.Minimize=function(t,i){var r=t.clone();return r.minimizeInPlace(i),r},n.Maximize=function(t,i){var r=t.clone();return r.maximizeInPlace(i),r},n.Distance=function(t,i){return Math.sqrt(n.DistanceSquared(t,i))},n.DistanceSquared=function(t,i){var r=t.x-i.x,o=t.y-i.y,n=t.z-i.z,e=t.w-i.w;return r*r+o*o+n*n+e*e},n.Center=function(t,i){var r=t.add(i);return r.scaleInPlace(.5),r},n.TransformNormal=function(t,i){var r=n.Zero();return n.TransformNormalToRef(t,i,r),r},n.TransformNormalToRef=function(t,i,r){var o=t.x*i.m[0]+t.y*i.m[4]+t.z*i.m[8],n=t.x*i.m[1]+t.y*i.m[5]+t.z*i.m[9],e=t.x*i.m[2]+t.y*i.m[6]+t.z*i.m[10];r.x=o,r.y=n,r.z=e,r.w=t.w},n.TransformNormalFromFloatsToRef=function(t,i,r,o,n,e){e.x=t*n.m[0]+i*n.m[4]+r*n.m[8],e.y=t*n.m[1]+i*n.m[5]+r*n.m[9],e.z=t*n.m[2]+i*n.m[6]+r*n.m[10],e.w=o},n}();p.Vector4=o;var t=function(){function o(t,i){this.width=t,this.height=i}return o.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},o.prototype.getClassName=function(){return"Size"},o.prototype.getHashCode=function(){var t=this.width||0;return t=397*t^(this.height||0)},o.prototype.copyFrom=function(t){this.width=t.width,this.height=t.height},o.prototype.copyFromFloats=function(t,i){return this.width=t,this.height=i,this},o.prototype.set=function(t,i){return this.copyFromFloats(t,i)},o.prototype.multiplyByFloats=function(t,i){return new o(this.width*t,this.height*i)},o.prototype.clone=function(){return new o(this.width,this.height)},o.prototype.equals=function(t){return!!t&&(this.width===t.width&&this.height===t.height)},Object.defineProperty(o.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),o.Zero=function(){return new o(0,0)},o.prototype.add=function(t){return new o(this.width+t.width,this.height+t.height)},o.prototype.subtract=function(t){return new o(this.width-t.width,this.height-t.height)},o.Lerp=function(t,i,r){return new o(t.width+(i.width-t.width)*r,t.height+(i.height-t.height)*r)},o}();p.Size=t;var x=function(){function y(t,i,r,o){void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=0),void 0===o&&(o=1),this.x=t,this.y=i,this.z=r,this.w=o}return y.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},y.prototype.getClassName=function(){return"Quaternion"},y.prototype.getHashCode=function(){var t=this.x||0;return t=397*(t=397*(t=397*t^(this.y||0))^(this.z||0))^(this.w||0)},y.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},y.prototype.equals=function(t){return t&&this.x===t.x&&this.y===t.y&&this.z===t.z&&this.w===t.w},y.prototype.clone=function(){return new y(this.x,this.y,this.z,this.w)},y.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.z=t.z,this.w=t.w,this},y.prototype.copyFromFloats=function(t,i,r,o){return this.x=t,this.y=i,this.z=r,this.w=o,this},y.prototype.set=function(t,i,r,o){return this.copyFromFloats(t,i,r,o)},y.prototype.add=function(t){return new y(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},y.prototype.addInPlace=function(t){return this.x+=t.x,this.y+=t.y,this.z+=t.z,this.w+=t.w,this},y.prototype.subtract=function(t){return new y(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},y.prototype.scale=function(t){return new y(this.x*t,this.y*t,this.z*t,this.w*t)},y.prototype.scaleToRef=function(t,i){return i.x=this.x*t,i.y=this.y*t,i.z=this.z*t,i.w=this.w*t,this},y.prototype.scaleInPlace=function(t){return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},y.prototype.scaleAndAddToRef=function(t,i){return i.x+=this.x*t,i.y+=this.y*t,i.z+=this.z*t,i.w+=this.w*t,this},y.prototype.multiply=function(t){var i=new y(0,0,0,1);return this.multiplyToRef(t,i),i},y.prototype.multiplyToRef=function(t,i){var r=this.x*t.w+this.y*t.z-this.z*t.y+this.w*t.x,o=-this.x*t.z+this.y*t.w+this.z*t.x+this.w*t.y,n=this.x*t.y-this.y*t.x+this.z*t.w+this.w*t.z,e=-this.x*t.x-this.y*t.y-this.z*t.z+this.w*t.w;return i.copyFromFloats(r,o,n,e),this},y.prototype.multiplyInPlace=function(t){return this.multiplyToRef(t,this),this},y.prototype.conjugateToRef=function(t){return t.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},y.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},y.prototype.conjugate=function(){return new y(-this.x,-this.y,-this.z,this.w)},y.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},y.prototype.normalize=function(){var t=1/this.length();return this.x*=t,this.y*=t,this.z*=t,this.w*=t,this},y.prototype.toEulerAngles=function(t){void 0===t&&(t="YZX");var i=l.Zero();return this.toEulerAnglesToRef(i,t),i},y.prototype.toEulerAnglesToRef=function(t,i){void 0===i&&(i="YZX");var r=this.z,o=this.x,n=this.y,e=this.w,s=e*e,h=r*r,a=o*o,u=n*n,m=n*r-o*e;return m<-.4999999?(t.y=2*Math.atan2(n,e),t.x=Math.PI/2,t.z=0):.4999999<m?(t.y=2*Math.atan2(n,e),t.x=-Math.PI/2,t.z=0):(t.z=Math.atan2(2*(o*n+r*e),-h-a+u+s),t.x=Math.asin(-2*(r*n-o*e)),t.y=Math.atan2(2*(r*o+n*e),h-a-u+s)),this},y.prototype.toRotationMatrix=function(t){var i=this.x*this.x,r=this.y*this.y,o=this.z*this.z,n=this.x*this.y,e=this.z*this.w,s=this.z*this.x,h=this.y*this.w,a=this.y*this.z,u=this.x*this.w;return t.m[0]=1-2*(r+o),t.m[1]=2*(n+e),t.m[2]=2*(s-h),t.m[3]=0,t.m[4]=2*(n-e),t.m[5]=1-2*(o+i),t.m[6]=2*(a+u),t.m[7]=0,t.m[8]=2*(s+h),t.m[9]=2*(a-u),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,t._markAsUpdated(),this},y.prototype.fromRotationMatrix=function(t){return y.FromRotationMatrixToRef(t,this),this},y.FromRotationMatrix=function(t){var i=new y;return y.FromRotationMatrixToRef(t,i),i},y.FromRotationMatrixToRef=function(t,i){var r,o=t.m,n=o[0],e=o[4],s=o[8],h=o[1],a=o[5],u=o[9],m=o[2],y=o[6],c=o[10],p=n+a+c;0<p?(r=.5/Math.sqrt(p+1),i.w=.25/r,i.x=(y-u)*r,i.y=(s-m)*r,i.z=(h-e)*r):a<n&&c<n?(r=2*Math.sqrt(1+n-a-c),i.w=(y-u)/r,i.x=.25*r,i.y=(e+h)/r,i.z=(s+m)/r):c<a?(r=2*Math.sqrt(1+a-n-c),i.w=(s-m)/r,i.x=(e+h)/r,i.y=.25*r,i.z=(u+y)/r):(r=2*Math.sqrt(1+c-n-a),i.w=(h-e)/r,i.x=(s+m)/r,i.y=(u+y)/r,i.z=.25*r)},y.Dot=function(t,i){return t.x*i.x+t.y*i.y+t.z*i.z+t.w*i.w},y.AreClose=function(t,i){return 0<=y.Dot(t,i)},y.Zero=function(){return new y(0,0,0,0)},y.Inverse=function(t){return new y(-t.x,-t.y,-t.z,t.w)},y.Identity=function(){return new y(0,0,0,1)},y.IsIdentity=function(t){return t&&0===t.x&&0===t.y&&0===t.z&&1===t.w},y.RotationAxis=function(t,i){return y.RotationAxisToRef(t,i,new y)},y.RotationAxisToRef=function(t,i,r){var o=Math.sin(i/2);return t.normalize(),r.w=Math.cos(i/2),r.x=t.x*o,r.y=t.y*o,r.z=t.z*o,r},y.FromArray=function(t,i){return i||(i=0),new y(t[i],t[i+1],t[i+2],t[i+3])},y.RotationYawPitchRoll=function(t,i,r){var o=new y;return y.RotationYawPitchRollToRef(t,i,r,o),o},y.RotationYawPitchRollToRef=function(t,i,r,o){var n=.5*r,e=.5*i,s=.5*t,h=Math.sin(n),a=Math.cos(n),u=Math.sin(e),m=Math.cos(e),y=Math.sin(s),c=Math.cos(s);o.x=c*u*a+y*m*h,o.y=y*m*a-c*u*h,o.z=c*m*h-y*u*a,o.w=c*m*a+y*u*h},y.RotationAlphaBetaGamma=function(t,i,r){var o=new y;return y.RotationAlphaBetaGammaToRef(t,i,r,o),o},y.RotationAlphaBetaGammaToRef=function(t,i,r,o){var n=.5*(r+t),e=.5*(r-t),s=.5*i;o.x=Math.cos(e)*Math.sin(s),o.y=Math.sin(e)*Math.sin(s),o.z=Math.sin(n)*Math.cos(s),o.w=Math.cos(n)*Math.cos(s)},y.RotationQuaternionFromAxis=function(t,i,r){var o=new y(0,0,0,0);return y.RotationQuaternionFromAxisToRef(t,i,r,o),o},y.RotationQuaternionFromAxisToRef=function(t,i,r,o){var n=_.Matrix[0];m.FromXYZAxesToRef(t.normalize(),i.normalize(),r.normalize(),n),y.FromRotationMatrixToRef(n,o)},y.Slerp=function(t,i,r){var o=y.Identity();return y.SlerpToRef(t,i,r,o),o},y.SlerpToRef=function(t,i,r,o){var n,e,s=t.x*i.x+t.y*i.y+t.z*i.z+t.w*i.w,h=!1;if(s<0&&(h=!0,s=-s),.999999<s)e=1-r,n=h?-r:r;else{var a=Math.acos(s),u=1/Math.sin(a);e=Math.sin((1-r)*a)*u,n=h?-Math.sin(r*a)*u:Math.sin(r*a)*u}o.x=e*t.x+n*i.x,o.y=e*t.y+n*i.y,o.z=e*t.z+n*i.z,o.w=e*t.w+n*i.w},y.Hermite=function(t,i,r,o,n){var e=n*n,s=n*e,h=2*s-3*e+1,a=-2*s+3*e,u=s-2*e+n,m=s-e;return new y(t.x*h+r.x*a+i.x*u+o.x*m,t.y*h+r.y*a+i.y*u+o.y*m,t.z*h+r.z*a+i.z*u+o.z*m,t.w*h+r.w*a+i.w*u+o.w*m)},y}();p.Quaternion=x;var m=function(){function z(){this._isIdentity=!1,this._isIdentityDirty=!0,this.m=new Float32Array(16),this._markAsUpdated()}return z.prototype._markAsUpdated=function(){this.updateFlag=z._updateFlagSeed++,this._isIdentityDirty=!0},z.prototype.isIdentity=function(t){return void 0===t&&(t=!1),this._isIdentityDirty&&(this._isIdentityDirty=!1,1!==this.m[0]||1!==this.m[5]||1!==this.m[15]?this._isIdentity=!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[11]||0!==this.m[12]||0!==this.m[13]||0!==this.m[14]?this._isIdentity=!1:this._isIdentity=!0,t||1===this.m[10]||(this._isIdentity=!1)),this._isIdentity},z.prototype.determinant=function(){var t=this.m[10]*this.m[15]-this.m[11]*this.m[14],i=this.m[9]*this.m[15]-this.m[11]*this.m[13],r=this.m[9]*this.m[14]-this.m[10]*this.m[13],o=this.m[8]*this.m[15]-this.m[11]*this.m[12],n=this.m[8]*this.m[14]-this.m[10]*this.m[12],e=this.m[8]*this.m[13]-this.m[9]*this.m[12];return this.m[0]*(this.m[5]*t-this.m[6]*i+this.m[7]*r)-this.m[1]*(this.m[4]*t-this.m[6]*o+this.m[7]*n)+this.m[2]*(this.m[4]*i-this.m[5]*o+this.m[7]*e)-this.m[3]*(this.m[4]*r-this.m[5]*n+this.m[6]*e)},z.prototype.toArray=function(){return this.m},z.prototype.asArray=function(){return this.toArray()},z.prototype.invert=function(){return this.invertToRef(this),this},z.prototype.reset=function(){for(var t=0;t<16;t++)this.m[t]=0;return this._markAsUpdated(),this},z.prototype.add=function(t){var i=new z;return this.addToRef(t,i),i},z.prototype.addToRef=function(t,i){for(var r=0;r<16;r++)i.m[r]=this.m[r]+t.m[r];return i._markAsUpdated(),this},z.prototype.addToSelf=function(t){for(var i=0;i<16;i++)this.m[i]+=t.m[i];return this._markAsUpdated(),this},z.prototype.invertToRef=function(t){var i=this.m[0],r=this.m[1],o=this.m[2],n=this.m[3],e=this.m[4],s=this.m[5],h=this.m[6],a=this.m[7],u=this.m[8],m=this.m[9],y=this.m[10],c=this.m[11],p=this.m[12],f=this.m[13],l=this.m[14],x=this.m[15],z=y*x-c*l,w=m*x-c*f,d=m*l-y*f,v=u*x-c*p,R=u*l-y*p,T=u*f-m*p,g=s*z-h*w+a*d,A=-(e*z-h*v+a*R),_=e*w-s*v+a*T,F=-(e*d-s*R+h*T),M=1/(i*g+r*A+o*_+n*F),b=h*x-a*l,P=s*x-a*f,C=s*l-h*f,S=e*x-a*p,Z=e*l-h*p,I=e*f-s*p,L=h*c-a*y,V=s*c-a*m,D=s*y-h*m,H=e*c-a*u,N=e*y-h*u,q=e*m-s*u;return t.m[0]=g*M,t.m[4]=A*M,t.m[8]=_*M,t.m[12]=F*M,t.m[1]=-(r*z-o*w+n*d)*M,t.m[5]=(i*z-o*v+n*R)*M,t.m[9]=-(i*w-r*v+n*T)*M,t.m[13]=(i*d-r*R+o*T)*M,t.m[2]=(r*b-o*P+n*C)*M,t.m[6]=-(i*b-o*S+n*Z)*M,t.m[10]=(i*P-r*S+n*I)*M,t.m[14]=-(i*C-r*Z+o*I)*M,t.m[3]=-(r*L-o*V+n*D)*M,t.m[7]=(i*L-o*H+n*N)*M,t.m[11]=-(i*V-r*H+n*q)*M,t.m[15]=(i*D-r*N+o*q)*M,t._markAsUpdated(),this},z.prototype.setTranslationFromFloats=function(t,i,r){return this.m[12]=t,this.m[13]=i,this.m[14]=r,this._markAsUpdated(),this},z.prototype.setTranslation=function(t){return this.m[12]=t.x,this.m[13]=t.y,this.m[14]=t.z,this._markAsUpdated(),this},z.prototype.getTranslation=function(){return new l(this.m[12],this.m[13],this.m[14])},z.prototype.getTranslationToRef=function(t){return t.x=this.m[12],t.y=this.m[13],t.z=this.m[14],this},z.prototype.removeRotationAndScaling=function(){return this.setRowFromFloats(0,1,0,0,0),this.setRowFromFloats(1,0,1,0,0),this.setRowFromFloats(2,0,0,1,0),this},z.prototype.multiply=function(t){var i=new z;return this.multiplyToRef(t,i),i},z.prototype.copyFrom=function(t){for(var i=0;i<16;i++)this.m[i]=t.m[i];return this._markAsUpdated(),this},z.prototype.copyToArray=function(t,i){void 0===i&&(i=0);for(var r=0;r<16;r++)t[i+r]=this.m[r];return this},z.prototype.multiplyToRef=function(t,i){return this.multiplyToArray(t,i.m,0),i._markAsUpdated(),this},z.prototype.multiplyToArray=function(t,i,r){var o=this.m[0],n=this.m[1],e=this.m[2],s=this.m[3],h=this.m[4],a=this.m[5],u=this.m[6],m=this.m[7],y=this.m[8],c=this.m[9],p=this.m[10],f=this.m[11],l=this.m[12],x=this.m[13],z=this.m[14],w=this.m[15],d=t.m[0],v=t.m[1],R=t.m[2],T=t.m[3],g=t.m[4],A=t.m[5],_=t.m[6],F=t.m[7],M=t.m[8],b=t.m[9],P=t.m[10],C=t.m[11],S=t.m[12],Z=t.m[13],I=t.m[14],L=t.m[15];return i[r]=o*d+n*g+e*M+s*S,i[r+1]=o*v+n*A+e*b+s*Z,i[r+2]=o*R+n*_+e*P+s*I,i[r+3]=o*T+n*F+e*C+s*L,i[r+4]=h*d+a*g+u*M+m*S,i[r+5]=h*v+a*A+u*b+m*Z,i[r+6]=h*R+a*_+u*P+m*I,i[r+7]=h*T+a*F+u*C+m*L,i[r+8]=y*d+c*g+p*M+f*S,i[r+9]=y*v+c*A+p*b+f*Z,i[r+10]=y*R+c*_+p*P+f*I,i[r+11]=y*T+c*F+p*C+f*L,i[r+12]=l*d+x*g+z*M+w*S,i[r+13]=l*v+x*A+z*b+w*Z,i[r+14]=l*R+x*_+z*P+w*I,i[r+15]=l*T+x*F+z*C+w*L,this},z.prototype.equals=function(t){return t&&this.m[0]===t.m[0]&&this.m[1]===t.m[1]&&this.m[2]===t.m[2]&&this.m[3]===t.m[3]&&this.m[4]===t.m[4]&&this.m[5]===t.m[5]&&this.m[6]===t.m[6]&&this.m[7]===t.m[7]&&this.m[8]===t.m[8]&&this.m[9]===t.m[9]&&this.m[10]===t.m[10]&&this.m[11]===t.m[11]&&this.m[12]===t.m[12]&&this.m[13]===t.m[13]&&this.m[14]===t.m[14]&&this.m[15]===t.m[15]},z.prototype.clone=function(){return z.FromValues(this.m[0],this.m[1],this.m[2],this.m[3],this.m[4],this.m[5],this.m[6],this.m[7],this.m[8],this.m[9],this.m[10],this.m[11],this.m[12],this.m[13],this.m[14],this.m[15])},z.prototype.getClassName=function(){return"Matrix"},z.prototype.getHashCode=function(){for(var t=this.m[0]||0,i=1;i<16;i++)t=397*t^(this.m[i]||0);return t},z.prototype.decompose=function(t,i,r){return r&&(r.x=this.m[12],r.y=this.m[13],r.z=this.m[14]),(t=t||_.Vector3[0]).x=Math.sqrt(this.m[0]*this.m[0]+this.m[1]*this.m[1]+this.m[2]*this.m[2]),t.y=Math.sqrt(this.m[4]*this.m[4]+this.m[5]*this.m[5]+this.m[6]*this.m[6]),t.z=Math.sqrt(this.m[8]*this.m[8]+this.m[9]*this.m[9]+this.m[10]*this.m[10]),this.determinant()<=0&&(t.y*=-1),0===t.x||0===t.y||0===t.z?(i&&(i.x=0,i.y=0,i.z=0,i.w=1),!1):(i&&(z.FromValuesToRef(this.m[0]/t.x,this.m[1]/t.x,this.m[2]/t.x,0,this.m[4]/t.y,this.m[5]/t.y,this.m[6]/t.y,0,this.m[8]/t.z,this.m[9]/t.z,this.m[10]/t.z,0,0,0,0,1,_.Matrix[0]),x.FromRotationMatrixToRef(_.Matrix[0],i)),!0)},z.prototype.getRow=function(t){if(t<0||3<t)return null;var i=4*t;return new o(this.m[i+0],this.m[i+1],this.m[i+2],this.m[i+3])},z.prototype.setRow=function(t,i){if(t<0||3<t)return this;var r=4*t;return this.m[r+0]=i.x,this.m[r+1]=i.y,this.m[r+2]=i.z,this.m[r+3]=i.w,this._markAsUpdated(),this},z.prototype.transpose=function(){return z.Transpose(this)},z.prototype.transposeToRef=function(t){return z.TransposeToRef(this,t),this},z.prototype.setRowFromFloats=function(t,i,r,o,n){if(t<0||3<t)return this;var e=4*t;return this.m[e+0]=i,this.m[e+1]=r,this.m[e+2]=o,this.m[e+3]=n,this._markAsUpdated(),this},z.prototype.scale=function(t){var i=new z;return this.scaleToRef(t,i),i},z.prototype.scaleToRef=function(t,i){for(var r=0;r<16;r++)i.m[r]=this.m[r]*t;return i._markAsUpdated(),this},z.prototype.scaleAndAddToRef=function(t,i){for(var r=0;r<16;r++)i.m[r]+=this.m[r]*t;return i._markAsUpdated(),this},z.prototype.toNormalMatrix=function(t){this.invertToRef(t),t.transpose();var i=t.m;z.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)},z.prototype.getRotationMatrix=function(){var t=z.Identity();return this.getRotationMatrixToRef(t),t},z.prototype.getRotationMatrixToRef=function(t){var i=this.m,r=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),o=Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),n=Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]);return this.determinant()<=0&&(o*=-1),0===r||0===o||0===n?z.IdentityToRef(t):z.FromValuesToRef(i[0]/r,i[1]/r,i[2]/r,0,i[4]/o,i[5]/o,i[6]/o,0,i[8]/n,i[9]/n,i[10]/n,0,0,0,0,1,t),this},z.FromArray=function(t,i){var r=new z;return i||(i=0),z.FromArrayToRef(t,i,r),r},z.FromArrayToRef=function(t,i,r){for(var o=0;o<16;o++)r.m[o]=t[o+i];r._markAsUpdated()},z.FromFloat32ArrayToRefScaled=function(t,i,r,o){for(var n=0;n<16;n++)o.m[n]=t[n+i]*r;o._markAsUpdated()},z.FromValuesToRef=function(t,i,r,o,n,e,s,h,a,u,m,y,c,p,f,l,x){x.m[0]=t,x.m[1]=i,x.m[2]=r,x.m[3]=o,x.m[4]=n,x.m[5]=e,x.m[6]=s,x.m[7]=h,x.m[8]=a,x.m[9]=u,x.m[10]=m,x.m[11]=y,x.m[12]=c,x.m[13]=p,x.m[14]=f,x.m[15]=l,x._markAsUpdated()},Object.defineProperty(z,"IdentityReadOnly",{get:function(){return z._identityReadOnly},enumerable:!0,configurable:!0}),z.FromValues=function(t,i,r,o,n,e,s,h,a,u,m,y,c,p,f,l){var x=new z;return x.m[0]=t,x.m[1]=i,x.m[2]=r,x.m[3]=o,x.m[4]=n,x.m[5]=e,x.m[6]=s,x.m[7]=h,x.m[8]=a,x.m[9]=u,x.m[10]=m,x.m[11]=y,x.m[12]=c,x.m[13]=p,x.m[14]=f,x.m[15]=l,x},z.Compose=function(t,i,r){var o=z.Identity();return z.ComposeToRef(t,i,r,o),o},z.ComposeToRef=function(t,i,r,o){z.FromValuesToRef(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1,_.Matrix[1]),i.toRotationMatrix(_.Matrix[0]),_.Matrix[1].multiplyToRef(_.Matrix[0],o),o.setTranslation(r)},z.Identity=function(){return z.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},z.IdentityToRef=function(t){z.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t)},z.Zero=function(){return z.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},z.RotationX=function(t){var i=new z;return z.RotationXToRef(t,i),i},z.Invert=function(t){var i=new z;return t.invertToRef(i),i},z.RotationXToRef=function(t,i){var r=Math.sin(t),o=Math.cos(t);i.m[0]=1,i.m[15]=1,i.m[5]=o,i.m[10]=o,i.m[9]=-r,i.m[6]=r,i.m[1]=0,i.m[2]=0,i.m[3]=0,i.m[4]=0,i.m[7]=0,i.m[8]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i._markAsUpdated()},z.RotationY=function(t){var i=new z;return z.RotationYToRef(t,i),i},z.RotationYToRef=function(t,i){var r=Math.sin(t),o=Math.cos(t);i.m[5]=1,i.m[15]=1,i.m[0]=o,i.m[2]=-r,i.m[8]=r,i.m[10]=o,i.m[1]=0,i.m[3]=0,i.m[4]=0,i.m[6]=0,i.m[7]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i._markAsUpdated()},z.RotationZ=function(t){var i=new z;return z.RotationZToRef(t,i),i},z.RotationZToRef=function(t,i){var r=Math.sin(t),o=Math.cos(t);i.m[10]=1,i.m[15]=1,i.m[0]=o,i.m[1]=r,i.m[4]=-r,i.m[5]=o,i.m[2]=0,i.m[3]=0,i.m[6]=0,i.m[7]=0,i.m[8]=0,i.m[9]=0,i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i._markAsUpdated()},z.RotationAxis=function(t,i){var r=z.Zero();return z.RotationAxisToRef(t,i,r),r},z.RotationAxisToRef=function(t,i,r){var o=Math.sin(-i),n=Math.cos(-i),e=1-n;t.normalize(),r.m[0]=t.x*t.x*e+n,r.m[1]=t.x*t.y*e-t.z*o,r.m[2]=t.x*t.z*e+t.y*o,r.m[3]=0,r.m[4]=t.y*t.x*e+t.z*o,r.m[5]=t.y*t.y*e+n,r.m[6]=t.y*t.z*e-t.x*o,r.m[7]=0,r.m[8]=t.z*t.x*e-t.y*o,r.m[9]=t.z*t.y*e+t.x*o,r.m[10]=t.z*t.z*e+n,r.m[11]=0,r.m[15]=1,r._markAsUpdated()},z.RotationYawPitchRoll=function(t,i,r){var o=new z;return z.RotationYawPitchRollToRef(t,i,r,o),o},z.RotationYawPitchRollToRef=function(t,i,r,o){x.RotationYawPitchRollToRef(t,i,r,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(o)},z.Scaling=function(t,i,r){var o=z.Zero();return z.ScalingToRef(t,i,r,o),o},z.ScalingToRef=function(t,i,r,o){o.m[0]=t,o.m[1]=0,o.m[2]=0,o.m[3]=0,o.m[4]=0,o.m[5]=i,o.m[6]=0,o.m[7]=0,o.m[8]=0,o.m[9]=0,o.m[10]=r,o.m[11]=0,o.m[12]=0,o.m[13]=0,o.m[14]=0,o.m[15]=1,o._markAsUpdated()},z.Translation=function(t,i,r){var o=z.Identity();return z.TranslationToRef(t,i,r,o),o},z.TranslationToRef=function(t,i,r,o){z.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1,o)},z.Lerp=function(t,i,r){var o=z.Zero();return z.LerpToRef(t,i,r,o),o},z.LerpToRef=function(t,i,r,o){for(var n=0;n<16;n++)o.m[n]=t.m[n]*(1-r)+i.m[n]*r;o._markAsUpdated()},z.DecomposeLerp=function(t,i,r){var o=z.Zero();return z.DecomposeLerpToRef(t,i,r,o),o},z.DecomposeLerpToRef=function(t,i,r,o){var n=_.Vector3[0],e=_.Quaternion[0],s=_.Vector3[1];t.decompose(n,e,s);var h=_.Vector3[2],a=_.Quaternion[1],u=_.Vector3[3];i.decompose(h,a,u);var m=_.Vector3[4];l.LerpToRef(n,h,r,m);var y=_.Quaternion[2];x.SlerpToRef(e,a,r,y);var c=_.Vector3[5];l.LerpToRef(s,u,r,c),z.ComposeToRef(m,y,c,o)},z.LookAtLH=function(t,i,r){var o=z.Zero();return z.LookAtLHToRef(t,i,r,o),o},z.LookAtLHToRef=function(t,i,r,o){i.subtractToRef(t,this._zAxis),this._zAxis.normalize(),l.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),l.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var n=-l.Dot(this._xAxis,t),e=-l.Dot(this._yAxis,t),s=-l.Dot(this._zAxis,t);return z.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,n,e,s,1,o)},z.LookAtRH=function(t,i,r){var o=z.Zero();return z.LookAtRHToRef(t,i,r,o),o},z.LookAtRHToRef=function(t,i,r,o){t.subtractToRef(i,this._zAxis),this._zAxis.normalize(),l.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),l.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var n=-l.Dot(this._xAxis,t),e=-l.Dot(this._yAxis,t),s=-l.Dot(this._zAxis,t);return z.FromValuesToRef(this._xAxis.x,this._yAxis.x,this._zAxis.x,0,this._xAxis.y,this._yAxis.y,this._zAxis.y,0,this._xAxis.z,this._yAxis.z,this._zAxis.z,0,n,e,s,1,o)},z.OrthoLH=function(t,i,r,o){var n=z.Zero();return z.OrthoLHToRef(t,i,r,o,n),n},z.OrthoLHToRef=function(t,i,r,o,n){z.FromValuesToRef(2/t,0,0,0,0,2/i,0,0,0,0,2/(o-r),0,0,0,-(o+r)/(o-r),1,n)},z.OrthoOffCenterLH=function(t,i,r,o,n,e){var s=z.Zero();return z.OrthoOffCenterLHToRef(t,i,r,o,n,e,s),s},z.OrthoOffCenterLHToRef=function(t,i,r,o,n,e,s){z.FromValuesToRef(2/(i-t),0,0,0,0,2/(o-r),0,0,0,0,2/(e-n),0,(t+i)/(t-i),(o+r)/(r-o),-(e+n)/(e-n),1,s)},z.OrthoOffCenterRH=function(t,i,r,o,n,e){var s=z.Zero();return z.OrthoOffCenterRHToRef(t,i,r,o,n,e,s),s},z.OrthoOffCenterRHToRef=function(t,i,r,o,n,e,s){z.OrthoOffCenterLHToRef(t,i,r,o,n,e,s),s.m[10]*=-1},z.PerspectiveLH=function(t,i,r,o){var n=z.Zero();return z.FromValuesToRef(2*r/t,0,0,0,0,2*r/i,0,0,0,0,(o+r)/(o-r),1,0,0,-2*o*r/(o-r),0,n),n},z.PerspectiveFovLH=function(t,i,r,o){var n=z.Zero();return z.PerspectiveFovLHToRef(t,i,r,o,n),n},z.PerspectiveFovLHToRef=function(t,i,r,o,n,e){void 0===e&&(e=!0);var s=r,h=o,a=1/Math.tan(.5*t);z.FromValuesToRef(e?a/i:a,0,0,0,0,e?a:a*i,0,0,0,0,(h+s)/(h-s),1,0,0,-2*h*s/(h-s),0,n)},z.PerspectiveFovRH=function(t,i,r,o){var n=z.Zero();return z.PerspectiveFovRHToRef(t,i,r,o,n),n},z.PerspectiveFovRHToRef=function(t,i,r,o,n,e){void 0===e&&(e=!0);var s=r,h=o,a=1/Math.tan(.5*t);z.FromValuesToRef(e?a/i:a,0,0,0,0,e?a:a*i,0,0,0,0,-(h+s)/(h-s),-1,0,0,-2*h*s/(h-s),0,n)},z.PerspectiveFovWebVRToRef=function(t,i,r,o,n){void 0===n&&(n=!1);var e=n?-1:1,s=Math.tan(t.upDegrees*Math.PI/180),h=Math.tan(t.downDegrees*Math.PI/180),a=Math.tan(t.leftDegrees*Math.PI/180),u=Math.tan(t.rightDegrees*Math.PI/180),m=2/(a+u),y=2/(s+h);o.m[0]=m,o.m[1]=o.m[2]=o.m[3]=o.m[4]=0,o.m[5]=y,o.m[6]=o.m[7]=0,o.m[8]=(a-u)*m*.5,o.m[9]=-(s-h)*y*.5,o.m[10]=-r/(i-r),o.m[11]=1*e,o.m[12]=o.m[13]=o.m[15]=0,o.m[14]=-2*r*i/(r-i),o._markAsUpdated()},z.GetFinalMatrix=function(t,i,r,o,n,e){var s=t.width,h=t.height,a=t.x,u=t.y,m=z.FromValues(s/2,0,0,0,0,-h/2,0,0,0,0,e-n,0,a+s/2,h/2+u,n,1);return i.multiply(r).multiply(o).multiply(m)},z.GetAsMatrix2x2=function(t){return new Float32Array([t.m[0],t.m[1],t.m[4],t.m[5]])},z.GetAsMatrix3x3=function(t){return new Float32Array([t.m[0],t.m[1],t.m[2],t.m[4],t.m[5],t.m[6],t.m[8],t.m[9],t.m[10]])},z.Transpose=function(t){var i=new z;return z.TransposeToRef(t,i),i},z.TransposeToRef=function(t,i){i.m[0]=t.m[0],i.m[1]=t.m[4],i.m[2]=t.m[8],i.m[3]=t.m[12],i.m[4]=t.m[1],i.m[5]=t.m[5],i.m[6]=t.m[9],i.m[7]=t.m[13],i.m[8]=t.m[2],i.m[9]=t.m[6],i.m[10]=t.m[10],i.m[11]=t.m[14],i.m[12]=t.m[3],i.m[13]=t.m[7],i.m[14]=t.m[11],i.m[15]=t.m[15]},z.Reflection=function(t){var i=new z;return z.ReflectionToRef(t,i),i},z.ReflectionToRef=function(t,i){t.normalize();var r=t.normal.x,o=t.normal.y,n=t.normal.z,e=-2*r,s=-2*o,h=-2*n;i.m[0]=e*r+1,i.m[1]=s*r,i.m[2]=h*r,i.m[3]=0,i.m[4]=e*o,i.m[5]=s*o+1,i.m[6]=h*o,i.m[7]=0,i.m[8]=e*n,i.m[9]=s*n,i.m[10]=h*n+1,i.m[11]=0,i.m[12]=e*t.d,i.m[13]=s*t.d,i.m[14]=h*t.d,i.m[15]=1,i._markAsUpdated()},z.FromXYZAxesToRef=function(t,i,r,o){o.m[0]=t.x,o.m[1]=t.y,o.m[2]=t.z,o.m[3]=0,o.m[4]=i.x,o.m[5]=i.y,o.m[6]=i.z,o.m[7]=0,o.m[8]=r.x,o.m[9]=r.y,o.m[10]=r.z,o.m[11]=0,o.m[12]=0,o.m[13]=0,o.m[14]=0,o.m[15]=1,o._markAsUpdated()},z.FromQuaternionToRef=function(t,i){var r=t.x*t.x,o=t.y*t.y,n=t.z*t.z,e=t.x*t.y,s=t.z*t.w,h=t.z*t.x,a=t.y*t.w,u=t.y*t.z,m=t.x*t.w;i.m[0]=1-2*(o+n),i.m[1]=2*(e+s),i.m[2]=2*(h-a),i.m[3]=0,i.m[4]=2*(e-s),i.m[5]=1-2*(n+r),i.m[6]=2*(u+m),i.m[7]=0,i.m[8]=2*(h+a),i.m[9]=2*(u-m),i.m[10]=1-2*(o+r),i.m[11]=0,i.m[12]=0,i.m[13]=0,i.m[14]=0,i.m[15]=1,i._markAsUpdated()},z._tempQuaternion=new x,z._xAxis=l.Zero(),z._yAxis=l.Zero(),z._zAxis=l.Zero(),z._updateFlagSeed=0,z._identityReadOnly=z.Identity(),z}();p.Matrix=m;var n=function(){function s(t,i,r,o){this.normal=new l(t,i,r),this.d=o}return s.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},s.prototype.clone=function(){return new s(this.normal.x,this.normal.y,this.normal.z,this.d)},s.prototype.getClassName=function(){return"Plane"},s.prototype.getHashCode=function(){var t=this.normal.getHashCode();return t=397*t^(this.d||0)},s.prototype.normalize=function(){var t=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),i=0;return 0!==t&&(i=1/t),this.normal.x*=i,this.normal.y*=i,this.normal.z*=i,this.d*=i,this},s.prototype.transform=function(t){var i=m.Transpose(t),r=this.normal.x,o=this.normal.y,n=this.normal.z,e=this.d;return new s(r*i.m[0]+o*i.m[1]+n*i.m[2]+e*i.m[3],r*i.m[4]+o*i.m[5]+n*i.m[6]+e*i.m[7],r*i.m[8]+o*i.m[9]+n*i.m[10]+e*i.m[11],r*i.m[12]+o*i.m[13]+n*i.m[14]+e*i.m[15])},s.prototype.dotCoordinate=function(t){return this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z+this.d},s.prototype.copyFromPoints=function(t,i,r){var o,n=i.x-t.x,e=i.y-t.y,s=i.z-t.z,h=r.x-t.x,a=r.y-t.y,u=r.z-t.z,m=e*u-s*a,y=s*h-n*u,c=n*a-e*h,p=Math.sqrt(m*m+y*y+c*c);return o=0!==p?1/p:0,this.normal.x=m*o,this.normal.y=y*o,this.normal.z=c*o,this.d=-(this.normal.x*t.x+this.normal.y*t.y+this.normal.z*t.z),this},s.prototype.isFrontFacingTo=function(t,i){return l.Dot(this.normal,t)<=i},s.prototype.signedDistanceTo=function(t){return l.Dot(t,this.normal)+this.d},s.FromArray=function(t){return new s(t[0],t[1],t[2],t[3])},s.FromPoints=function(t,i,r){var o=new s(0,0,0,0);return o.copyFromPoints(t,i,r),o},s.FromPositionAndNormal=function(t,i){var r=new s(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},s.SignedDistanceToPlaneFromPositionAndNormal=function(t,i,r){var o=-(i.x*t.x+i.y*t.y+i.z*t.z);return l.Dot(r,i)+o},s}();p.Plane=n;var e=function(){function n(t,i,r,o){this.x=t,this.y=i,this.width=r,this.height=o}return n.prototype.toGlobal=function(t,i){if(t.getRenderWidth){var r=t;return this.toGlobal(r.getRenderWidth(),r.getRenderHeight())}var o=t;return new n(this.x*o,this.y*i,this.width*o,this.height*i)},n.prototype.clone=function(){return new n(this.x,this.y,this.width,this.height)},n}();p.Viewport=e;var s,h=function(){function o(){}return o.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new n(0,0,0,0));return o.GetPlanesToRef(t,i),i},o.GetNearPlaneToRef=function(t,i){i.normal.x=t.m[3]+t.m[2],i.normal.y=t.m[7]+t.m[6],i.normal.z=t.m[11]+t.m[10],i.d=t.m[15]+t.m[14],i.normalize()},o.GetFarPlaneToRef=function(t,i){i.normal.x=t.m[3]-t.m[2],i.normal.y=t.m[7]-t.m[6],i.normal.z=t.m[11]-t.m[10],i.d=t.m[15]-t.m[14],i.normalize()},o.GetLeftPlaneToRef=function(t,i){i.normal.x=t.m[3]+t.m[0],i.normal.y=t.m[7]+t.m[4],i.normal.z=t.m[11]+t.m[8],i.d=t.m[15]+t.m[12],i.normalize()},o.GetRightPlaneToRef=function(t,i){i.normal.x=t.m[3]-t.m[0],i.normal.y=t.m[7]-t.m[4],i.normal.z=t.m[11]-t.m[8],i.d=t.m[15]-t.m[12],i.normalize()},o.GetTopPlaneToRef=function(t,i){i.normal.x=t.m[3]-t.m[1],i.normal.y=t.m[7]-t.m[5],i.normal.z=t.m[11]-t.m[9],i.d=t.m[15]-t.m[13],i.normalize()},o.GetBottomPlaneToRef=function(t,i){i.normal.x=t.m[3]+t.m[1],i.normal.y=t.m[7]+t.m[5],i.normal.z=t.m[11]+t.m[9],i.d=t.m[15]+t.m[13],i.normalize()},o.GetPlanesToRef=function(t,i){o.GetNearPlaneToRef(t,i[0]),o.GetFarPlaneToRef(t,i[1]),o.GetLeftPlaneToRef(t,i[2]),o.GetRightPlaneToRef(t,i[3]),o.GetTopPlaneToRef(t,i[4]),o.GetBottomPlaneToRef(t,i[5])},o}();p.Frustum=h,(s=p.Space||(p.Space={}))[s.LOCAL=0]="LOCAL",s[s.WORLD=1]="WORLD",s[s.BONE=2]="BONE";var a=function(){function t(){}return t.X=new l(1,0,0),t.Y=new l(0,1,0),t.Z=new l(0,0,1),t}();p.Axis=a;var z,u,y=function(){function t(){}return t.Interpolate=function(t,i,r,o,n){for(var e=1-3*o+3*i,s=3*o-6*i,h=3*i,a=t,u=0;u<5;u++){var m=a*a;a-=(e*(m*a)+s*m+h*a-t)*(1/(3*e*m+2*s*a+h)),a=Math.min(1,Math.max(0,a))}return 3*Math.pow(1-a,2)*a*r+3*(1-a)*Math.pow(a,2)*n+Math.pow(a,3)},t}();p.BezierCurve=y,(u=z=p.Orientation||(p.Orientation={}))[u.CW=0]="CW",u[u.CCW=1]="CCW";var c=function(){function o(t){this._radians=t,this._radians<0&&(this._radians+=2*Math.PI)}return o.prototype.degrees=function(){return 180*this._radians/Math.PI},o.prototype.radians=function(){return this._radians},o.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new o(Math.atan2(r.y,r.x))},o.FromRadians=function(t){return new o(t)},o.FromDegrees=function(t){return new o(t*Math.PI/180)},o}();p.Angle=c;var w=function(t,i,r){this.startPoint=t,this.midPoint=i,this.endPoint=r;var o=Math.pow(i.x,2)+Math.pow(i.y,2),n=(Math.pow(t.x,2)+Math.pow(t.y,2)-o)/2,e=(o-Math.pow(r.x,2)-Math.pow(r.y,2))/2,s=(t.x-i.x)*(i.y-r.y)-(i.x-r.x)*(t.y-i.y);this.centerPoint=new f((n*(i.y-r.y)-e*(t.y-i.y))/s,((t.x-i.x)*e-(i.x-r.x)*n)/s),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=c.BetweenTwoPoints(this.centerPoint,this.startPoint);var h=this.startAngle.degrees(),a=c.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),u=c.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();180<a-h&&(a-=360),a-h<-180&&(a+=360),180<u-a&&(u-=360),u-a<-180&&(u+=360),this.orientation=a-h<0?z.CW:z.CCW,this.angle=c.FromDegrees(this.orientation===z.CW?h-u:u-h)};p.Arc2=w;var d=function(){function r(t,i){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new f(t,i))}return r.prototype.addLineTo=function(t,i){if(this.closed)return this;var r=new f(t,i),o=this._points[this._points.length-1];return this._points.push(r),this._length+=r.subtract(o).length(),this},r.prototype.addArcTo=function(t,i,r,o,n){if(void 0===n&&(n=36),this.closed)return this;var e=this._points[this._points.length-1],s=new f(t,i),h=new f(r,o),a=new w(e,s,h),u=a.angle.radians()/n;a.orientation===z.CW&&(u*=-1);for(var m=a.startAngle.radians()+u,y=0;y<n;y++){var c=Math.cos(m)*a.radius+a.centerPoint.x,p=Math.sin(m)*a.radius+a.centerPoint.y;this.addLineTo(c,p),m+=u}return this},r.prototype.close=function(){return this.closed=!0,this},r.prototype.length=function(){var t=this._length;if(!this.closed){var i=this._points[this._points.length-1];t+=this._points[0].subtract(i).length()}return t},r.prototype.getPoints=function(){return this._points},r.prototype.getPointAtLengthPosition=function(t){if(t<0||1<t)return f.Zero();for(var i=t*this.length(),r=0,o=0;o<this._points.length;o++){var n=(o+1)%this._points.length,e=this._points[o],s=this._points[n].subtract(e),h=s.length()+r;if(r<=i&&i<=h){var a=s.normalize(),u=i-r;return new f(e.x+a.x*u,e.y+a.y*u)}r=h}return f.Zero()},r.StartingAt=function(t,i){return new r(t,i)},r}();p.Path2=d;var v=function(){function t(t,i,r){void 0===i&&(i=null),this.path=t,this._curve=new Array,this._distances=new Array,this._tangents=new Array,this._normals=new Array,this._binormals=new Array;for(var o=0;o<t.length;o++)this._curve[o]=t[o].clone();this._raw=r||!1,this._compute(i)}return t.prototype.getCurve=function(){return this._curve},t.prototype.getTangents=function(){return this._tangents},t.prototype.getNormals=function(){return this._normals},t.prototype.getBinormals=function(){return this._binormals},t.prototype.getDistances=function(){return this._distances},t.prototype.update=function(t,i){void 0===i&&(i=null);for(var r=0;r<t.length;r++)this._curve[r].x=t[r].x,this._curve[r].y=t[r].y,this._curve[r].z=t[r].z;return this._compute(i),this},t.prototype._compute=function(t){var i=this._curve.length;this._tangents[0]=this._getFirstNonNullVector(0),this._raw||this._tangents[0].normalize(),this._tangents[i-1]=this._curve[i-1].subtract(this._curve[i-2]),this._raw||this._tangents[i-1].normalize();var r,o,n,e,s=this._tangents[0],h=this._normalVector(this._curve[0],s,t);this._normals[0]=h,this._raw||this._normals[0].normalize(),this._binormals[0]=l.Cross(s,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var a=1;a<i;a++)r=this._getLastNonNullVector(a),a<i-1&&(o=this._getFirstNonNullVector(a),this._tangents[a]=r.add(o),this._tangents[a].normalize()),this._distances[a]=this._distances[a-1]+r.length(),n=this._tangents[a],e=this._binormals[a-1],this._normals[a]=l.Cross(e,n),this._raw||this._normals[a].normalize(),this._binormals[a]=l.Cross(n,this._normals[a]),this._raw||this._binormals[a].normalize()},t.prototype._getFirstNonNullVector=function(t){for(var i=1,r=this._curve[t+i].subtract(this._curve[t]);0===r.length()&&t+i+1<this._curve.length;)i++,r=this._curve[t+i].subtract(this._curve[t]);return r},t.prototype._getLastNonNullVector=function(t){for(var i=1,r=this._curve[t].subtract(this._curve[t-i]);0===r.length()&&i+1<t;)i++,r=this._curve[t].subtract(this._curve[t-i]);return r},t.prototype._normalVector=function(t,i,r){var o,n,e=i.length();(0===e&&(e=1),null==r)?(n=p.Scalar.WithinEpsilon(Math.abs(i.y)/e,1,p.Epsilon)?p.Scalar.WithinEpsilon(Math.abs(i.x)/e,1,p.Epsilon)?p.Scalar.WithinEpsilon(Math.abs(i.z)/e,1,p.Epsilon)?l.Zero():new l(0,0,1):new l(1,0,0):new l(0,-1,0),o=l.Cross(i,n)):(o=l.Cross(i,r),l.CrossToRef(o,i,o));return o.normalize(),o},t}();p.Path3D=v;var R=function(){function m(t){this._length=0,this._points=t,this._length=this._computeLength(t)}return m.CreateQuadraticBezier=function(t,i,r,o){o=2<o?o:3;for(var n=new Array,e=function(t,i,r,o){return(1-t)*(1-t)*i+2*t*(1-t)*r+t*t*o},s=0;s<=o;s++)n.push(new l(e(s/o,t.x,i.x,r.x),e(s/o,t.y,i.y,r.y),e(s/o,t.z,i.z,r.z)));return new m(n)},m.CreateCubicBezier=function(t,i,r,o,n){n=3<n?n:4;for(var e=new Array,s=function(t,i,r,o,n){return(1-t)*(1-t)*(1-t)*i+3*t*(1-t)*(1-t)*r+3*t*t*(1-t)*o+t*t*t*n},h=0;h<=n;h++)e.push(new l(s(h/n,t.x,i.x,r.x,o.x),s(h/n,t.y,i.y,r.y,o.y),s(h/n,t.z,i.z,r.z,o.z)));return new m(e)},m.CreateHermiteSpline=function(t,i,r,o,n){for(var e=new Array,s=1/n,h=0;h<=n;h++)e.push(l.Hermite(t,i,r,o,h*s));return new m(e)},m.CreateCatmullRomSpline=function(t,i,r){var o=new Array,n=1/i,e=0;if(r){for(var s=t.length,h=0;h<s;h++)for(var a=e=0;a<i;a++)o.push(l.CatmullRom(t[h%s],t[(h+1)%s],t[(h+2)%s],t[(h+3)%s],e)),e+=n;o.push(o[0])}else{var u=new Array;u.push(t[0].clone()),Array.prototype.push.apply(u,t),u.push(t[t.length-1].clone());for(h=0;h<u.length-3;h++)for(a=e=0;a<i;a++)o.push(l.CatmullRom(u[h],u[h+1],u[h+2],u[h+3],e)),e+=n;h--,o.push(l.CatmullRom(u[h],u[h+1],u[h+2],u[h+3],e))}return new m(o)},m.prototype.getPoints=function(){return this._points},m.prototype.length=function(){return this._length},m.prototype.continue=function(t){for(var i=this._points[this._points.length-1],r=this._points.slice(),o=t.getPoints(),n=1;n<o.length;n++)r.push(o[n].subtract(o[0]).add(i));return new m(r)},m.prototype._computeLength=function(t){for(var i=0,r=1;r<t.length;r++)i+=t[r].subtract(t[r-1]).length();return i},m}();p.Curve3=R;var T=function(){function t(t,i){void 0===t&&(t=l.Zero()),void 0===i&&(i=l.Up()),this.position=t,this.normal=i}return t.prototype.clone=function(){return new t(this.position.clone(),this.normal.clone())},t}();p.PositionNormalVertex=T;var g=function(){function t(t,i,r){void 0===t&&(t=l.Zero()),void 0===i&&(i=l.Up()),void 0===r&&(r=f.Zero()),this.position=t,this.normal=i,this.uv=r}return t.prototype.clone=function(){return new t(this.position.clone(),this.normal.clone(),this.uv.clone())},t}();p.PositionNormalTextureVertex=g;var A=function(){function t(){}return t.Color3=[i.Black(),i.Black(),i.Black()],t.Color4=[new r(0,0,0,0),new r(0,0,0,0)],t.Vector2=[f.Zero(),f.Zero(),f.Zero()],t.Vector3=[l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero()],t.Vector4=[o.Zero(),o.Zero(),o.Zero()],t.Quaternion=[x.Zero(),x.Zero()],t.Matrix=[m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero(),m.Zero()],t}();p.Tmp=A;var _=function(){function t(){}return t.Vector3=[l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero()],t.Matrix=[m.Zero(),m.Zero()],t.Quaternion=[x.Zero(),x.Zero(),x.Zero()],t}()}(BABYLON||(BABYLON={}));';var tl="undefined"!=typeof global?global:"undefined"!=typeof window?window:this;return tl.BABYLON=$a,void 0!==_&&(tl.Earcut={earcut:_}),$a}));