Skip to content

Instantly share code, notes, and snippets.

@blondegeek
Created September 21, 2018 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save blondegeek/f6e5ca0fb42765a073de831b8808729f to your computer and use it in GitHub Desktop.
Save blondegeek/f6e5ca0fb42765a073de831b8808729f to your computer and use it in GitHub Desktop.
parametric CreateTube for SpringJoint -- ok for babylon 3.2, broken for babylon 3.3
This file has been truncated, but you can view the full file.
!(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(e,t,i){e=e||this.CANNON,t=t||this.OIMO,i=i||this.earcut;var r,n=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;a>=0;a--)(n=e[a])&&(s=(o<3?n(s):o>3?n(t,i,s):n(t,i))||s);return o>3&&s&&Object.defineProperty(t,i,s),s},o=this&&this.__extends||(function(){var e=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])};return function(t,i){function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}})();!(function(e){var t=(function(){function e(){this._defines={},this._currentRank=32,this._maxRank=-1}return e.prototype.unBindMesh=function(){this._mesh=null},e.prototype.addFallback=function(e,t){this._defines[e]||(e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e),this._defines[e]=new Array),this._defines[e].push(t)},e.prototype.addCPUSkinningFallback=function(e,t){this._mesh=t,e<this._currentRank&&(this._currentRank=e),e>this._maxRank&&(this._maxRank=e)},Object.defineProperty(e.prototype,"isMoreFallbacks",{get:function(){return this._currentRank<=this._maxRank},enumerable:!0,configurable:!0}),e.prototype.reduce=function(e,t){if(this._mesh&&this._mesh.computeBonesUsingShaders&&this._mesh.numBoneInfluencers>0&&this._mesh.material){this._mesh.computeBonesUsingShaders=!1,e=e.replace("#define NUM_BONE_INFLUENCERS "+this._mesh.numBoneInfluencers,"#define NUM_BONE_INFLUENCERS 0"),t._bonesComputationForcedToCPU=!0;for(var i=this._mesh.getScene(),r=0;r<i.meshes.length;r++){var n=i.meshes[r];if(n.material&&(n.computeBonesUsingShaders&&0!==n.numBoneInfluencers))if(n.material.getEffect()===t)n.computeBonesUsingShaders=!1;else if(n.subMeshes)for(var o=0,s=n.subMeshes;o<s.length;o++){var a=s[o],l=a.effect;if(l===t){n.computeBonesUsingShaders=!1;break}}}}else{var h=this._defines[this._currentRank];if(h)for(var r=0;r<h.length;r++)e=e.replace("#define "+h[r],"");this._currentRank++}return e},e})();e.EffectFallbacks=t;var i=(function(){function e(){}return e})();e.EffectCreationOptions=i;var r=(function(){function t(i,r,n,o,s,a,l,h,c,u){void 0===o&&(o=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===h&&(h=null),void 0===c&&(c=null);var f=this;if(this.uniqueId=0,this.onCompileObservable=new e.Observable,this.onErrorObservable=new e.Observable,this.onBindObservable=new e.Observable,this._bonesComputationForcedToCPU=!1,this._uniformBuffersNames={},this._isReady=!1,this._compilationError="",this.name=i,r.attributes){var p=r;if(this._engine=n,this._attributesNames=p.attributes,this._uniformsNames=p.uniformsNames.concat(p.samplers),this._samplers=p.samplers.slice(),this.defines=p.defines,this.onError=p.onError,this.onCompiled=p.onCompiled,this._fallbacks=p.fallbacks,this._indexParameters=p.indexParameters,this._transformFeedbackVaryings=p.transformFeedbackVaryings,p.uniformBuffersNames)for(var d=0;d<p.uniformBuffersNames.length;d++)this._uniformBuffersNames[p.uniformBuffersNames[d]]=d}else this._engine=s,this.defines=a,this._uniformsNames=n.concat(o),this._samplers=o?o.slice():[],this._attributesNames=r,this.onError=c,this.onCompiled=h,this._indexParameters=u,this._fallbacks=l;this.uniqueId=t._uniqueIdSeed++;var m,_;i.vertexElement?(m=document.getElementById(i.vertexElement))||(m=i.vertexElement):m=i.vertex||i,i.fragmentElement?(_=document.getElementById(i.fragmentElement))||(_=i.fragmentElement):_=i.fragment||i,this._loadVertexShader(m,(function(e){f._processIncludes(e,(function(e){f._processShaderConversion(e,!1,(function(e){f._loadFragmentShader(_,(function(t){f._processIncludes(t,(function(t){f._processShaderConversion(t,!0,(function(t){if(i){var r=i.vertexElement||i.vertex||i,n=i.fragmentElement||i.fragment||i;f._vertexSourceCode="#define SHADER_NAME vertex:"+r+"\n"+e,f._fragmentSourceCode="#define SHADER_NAME fragment:"+n+"\n"+t}else f._vertexSourceCode=e,f._fragmentSourceCode=t;f._prepareEffect()}))}))}))}))}))}))}return Object.defineProperty(t.prototype,"key",{get:function(){return this._key},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._isReady},t.prototype.getEngine=function(){return this._engine},t.prototype.getProgram=function(){return this._program},t.prototype.getAttributesNames=function(){return this._attributesNames},t.prototype.getAttributeLocation=function(e){return this._attributes[e]},t.prototype.getAttributeLocationByName=function(e){var t=this._attributesNames.indexOf(e);return this._attributes[t]},t.prototype.getAttributesCount=function(){return this._attributes.length},t.prototype.getUniformIndex=function(e){return this._uniformsNames.indexOf(e)},t.prototype.getUniform=function(e){return this._uniforms[this._uniformsNames.indexOf(e)]},t.prototype.getSamplers=function(){return this._samplers},t.prototype.getCompilationError=function(){return this._compilationError},t.prototype.executeWhenCompiled=function(e){if(this.isReady())return void e(this);this.onCompileObservable.add((function(t){e(t)}))},t.prototype._loadVertexShader=function(i,r){if(e.Tools.IsWindowObjectExist()&&i instanceof HTMLElement){return void r(e.Tools.GetDOMTextContent(i))}if("base64:"===i.substr(0,7)){return void r(window.atob(i.substr(7)))}if(t.ShadersStore[i+"VertexShader"])return void r(t.ShadersStore[i+"VertexShader"]);var n;n="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,this._engine._loadFile(n+".vertex.fx",r)},t.prototype._loadFragmentShader=function(i,r){if(e.Tools.IsWindowObjectExist()&&i instanceof HTMLElement){return void r(e.Tools.GetDOMTextContent(i))}if("base64:"===i.substr(0,7)){return void r(window.atob(i.substr(7)))}if(t.ShadersStore[i+"PixelShader"])return void r(t.ShadersStore[i+"PixelShader"]);if(t.ShadersStore[i+"FragmentShader"])return void r(t.ShadersStore[i+"FragmentShader"]);var n;n="."===i[0]||"/"===i[0]||i.indexOf("http")>-1?i:e.Engine.ShadersRepository+i,this._engine._loadFile(n+".fragment.fx",r)},t.prototype._dumpShadersSource=function(t,i,r){var n=this._engine.webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"",o=n+(r?r+"\n":"");t=o+t,i=o+i;var s=2,a=/\n/gm,l="\n1\t"+t.replace(a,(function(){return"\n"+s+++"\t"}));s=2;var h="\n1\t"+i.replace(a,(function(){return"\n"+s+++"\t"}));this.name.vertexElement?(e.Tools.Error("Vertex shader: "+this.name.vertexElement+l),e.Tools.Error("Fragment shader: "+this.name.fragmentElement+h)):this.name.vertex?(e.Tools.Error("Vertex shader: "+this.name.vertex+l),e.Tools.Error("Fragment shader: "+this.name.fragment+h)):(e.Tools.Error("Vertex shader: "+this.name+l),e.Tools.Error("Fragment shader: "+this.name+h))},t.prototype._processShaderConversion=function(e,t,i){var r=this._processPrecision(e);if(1==this._engine.webGLVersion)return void i(r);if(-1!==r.indexOf("#version 3"))return void i(r.replace("#version 300 es",""));var n=-1!==r.search(/#extension.+GL_EXT_draw_buffers.+require/),o=/#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g,s=r.replace(o,"");s=s.replace(/varying(?![\n\r])\s/g,t?"in ":"out "),s=s.replace(/attribute[ \t]/g,"in "),s=s.replace(/[ \t]attribute/g," in"),t&&(s=s.replace(/texture2DLodEXT\s*\(/g,"textureLod("),s=s.replace(/textureCubeLodEXT\s*\(/g,"textureLod("),s=s.replace(/texture2D\s*\(/g,"texture("),s=s.replace(/textureCube\s*\(/g,"texture("),s=s.replace(/gl_FragDepthEXT/g,"gl_FragDepth"),s=s.replace(/gl_FragColor/g,"glFragColor"),s=s.replace(/gl_FragData/g,"glFragData"),s=s.replace(/void\s+?main\s*\(/g,(n?"":"out vec4 glFragColor;\n")+"void main(")),i(s)},t.prototype._processIncludes=function(i,r){for(var n=this,o=/#include<(.+)>(\((.*)\))*(\[(.*)\])*/g,s=o.exec(i),a=new String(i);null!=s;){var l=s[1];if(-1!==l.indexOf("__decl__")&&(l=l.replace(/__decl__/,""),this._engine.supportsUniformBuffers&&(l=l.replace(/Vertex/,"Ubo"),l=l.replace(/Fragment/,"Ubo")),l+="Declaration"),!t.IncludesShadersStore[l]){var h=e.Engine.ShadersRepository+"ShadersInclude/"+l+".fx";return void this._engine._loadFile(h,(function(e){t.IncludesShadersStore[l]=e,n._processIncludes(a,r)}))}var c=t.IncludesShadersStore[l];if(s[2])for(var u=s[3].split(","),f=0;f<u.length;f+=2){var p=new RegExp(u[f],"g"),d=u[f+1];c=c.replace(p,d)}if(s[4]){var m=s[5];if(-1!==m.indexOf("..")){var _=m.split(".."),g=parseInt(_[0]),v=parseInt(_[1]),y=c.slice(0);c="",isNaN(v)&&(v=this._indexParameters[_[1]]);for(var b=g;b<v;b++)this._engine.supportsUniformBuffers||(y=y.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),c+=y.replace(/\{X\}/g,b.toString())+"\n"}else this._engine.supportsUniformBuffers||(c=c.replace(/light\{X\}.(\w*)/g,(function(e,t){return t+"{X}"}))),c=c.replace(/\{X\}/g,m)}a=a.replace(s[0],c),s=o.exec(i)}r(a)},t.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},t.prototype._rebuildProgram=function(t,i,r,n){var o=this;this._isReady=!1,this._vertexSourceCodeOverride=t,this._fragmentSourceCodeOverride=i,this.onError=function(e,t){n&&n(t)},this.onCompiled=function(){for(var t=o.getEngine().scenes,i=0;i<t.length;i++)t[i].markAllMaterialsAsDirty(e.Material.TextureDirtyFlag);r&&r(o._program)},this._fallbacks=null,this._prepareEffect()},t.prototype.getSpecificUniformLocations=function(e){return this._engine.getUniforms(this._program,e)},t.prototype._prepareEffect=function(){var t=this._attributesNames,i=this.defines,r=this._fallbacks;this._valueCache={};var n=this._program;try{var 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,i,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]);this._uniforms=o.getUniforms(this._program,this._uniformsNames),this._attributes=o.getAttributes(this._program,t);var a;for(a=0;a<this._samplers.length;a++){null==this.getUniform(this._samplers[a])&&(this._samplers.splice(a,1),a--)}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(),n&&this.getEngine()._deleteProgram(n)}catch(o){this._compilationError=o.message,e.Tools.Error("Unable to compile effect:"),e.Tools.Error("Uniforms: "+this._uniformsNames.map((function(e){return" "+e}))),e.Tools.Error("Attributes: "+t.map((function(e){return" "+e}))),this._dumpShadersSource(this._vertexSourceCode,this._fragmentSourceCode,i),e.Tools.Error("Error: "+this._compilationError),n&&(this._program=n,this._isReady=!0,this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this)),r&&r.isMoreFallbacks?(e.Tools.Error("Trying next fallback."),this.defines=r.reduce(this.defines,this),this._prepareEffect()):(this.onError&&this.onError(this,this._compilationError),this.onErrorObservable.notifyObservers(this),this.onErrorObservable.clear(),this._fallbacks&&this._fallbacks.unBindMesh())}},Object.defineProperty(t.prototype,"isSupported",{get:function(){return""===this._compilationError},enumerable:!0,configurable:!0}),t.prototype._bindTexture=function(e,t){this._engine._bindTexture(this._samplers.indexOf(e),t)},t.prototype.setTexture=function(e,t){this._engine.setTexture(this._samplers.indexOf(e),this.getUniform(e),t)},t.prototype.setDepthStencilTexture=function(e,t){this._engine.setDepthStencilTexture(this._samplers.indexOf(e),this.getUniform(e),t)},t.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)},t.prototype.setTextureFromPostProcess=function(e,t){this._engine.setTextureFromPostProcess(this._samplers.indexOf(e),t)},t.prototype.setTextureFromPostProcessOutput=function(e,t){this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(e),t)},t.prototype._cacheMatrix=function(e,t){var i=this._valueCache[e],r=t.updateFlag;return(void 0===i||i!==r)&&(this._valueCache[e]=r,!0)},t.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},t.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},t.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},t.prototype.bindUniformBuffer=function(e,i){var r=this._uniformBuffersNames[i];void 0!==r&&t._baseCache[r]!==e&&(t._baseCache[r]=e,this._engine.bindUniformBufferBase(e,r))},t.prototype.bindUniformBlock=function(e,t){this._engine.bindUniformBlock(this._program,e,t)},t.prototype.setInt=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t?this:(this._valueCache[e]=t,this._engine.setInt(this.getUniform(e),t),this)},t.prototype.setIntArray=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray(this.getUniform(e),t),this},t.prototype.setIntArray2=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray2(this.getUniform(e),t),this},t.prototype.setIntArray3=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray3(this.getUniform(e),t),this},t.prototype.setIntArray4=function(e,t){return this._valueCache[e]=null,this._engine.setIntArray4(this.getUniform(e),t),this},t.prototype.setFloatArray=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray(this.getUniform(e),t),this},t.prototype.setFloatArray2=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray2(this.getUniform(e),t),this},t.prototype.setFloatArray3=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray3(this.getUniform(e),t),this},t.prototype.setFloatArray4=function(e,t){return this._valueCache[e]=null,this._engine.setFloatArray4(this.getUniform(e),t),this},t.prototype.setArray=function(e,t){return this._valueCache[e]=null,this._engine.setArray(this.getUniform(e),t),this},t.prototype.setArray2=function(e,t){return this._valueCache[e]=null,this._engine.setArray2(this.getUniform(e),t),this},t.prototype.setArray3=function(e,t){return this._valueCache[e]=null,this._engine.setArray3(this.getUniform(e),t),this},t.prototype.setArray4=function(e,t){return this._valueCache[e]=null,this._engine.setArray4(this.getUniform(e),t),this},t.prototype.setMatrices=function(e,t){return t?(this._valueCache[e]=null,this._engine.setMatrices(this.getUniform(e),t),this):this},t.prototype.setMatrix=function(e,t){return this._cacheMatrix(e,t)&&this._engine.setMatrix(this.getUniform(e),t),this},t.prototype.setMatrix3x3=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix3x3(this.getUniform(e),t),this},t.prototype.setMatrix2x2=function(e,t){return this._valueCache[e]=null,this._engine.setMatrix2x2(this.getUniform(e),t),this},t.prototype.setFloat=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t?this:(this._valueCache[e]=t,this._engine.setFloat(this.getUniform(e),t),this)},t.prototype.setBool=function(e,t){var i=this._valueCache[e];return void 0!==i&&i===t?this:(this._valueCache[e]=t,this._engine.setBool(this.getUniform(e),t?1:0),this)},t.prototype.setVector2=function(e,t){return this._cacheFloat2(e,t.x,t.y)&&this._engine.setFloat2(this.getUniform(e),t.x,t.y),this},t.prototype.setFloat2=function(e,t,i){return this._cacheFloat2(e,t,i)&&this._engine.setFloat2(this.getUniform(e),t,i),this},t.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},t.prototype.setFloat3=function(e,t,i,r){return this._cacheFloat3(e,t,i,r)&&this._engine.setFloat3(this.getUniform(e),t,i,r),this},t.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},t.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},t.prototype.setColor3=function(e,t){return this._cacheFloat3(e,t.r,t.g,t.b)&&this._engine.setColor3(this.getUniform(e),t),this},t.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},t.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},t.ResetCache=function(){t._baseCache={}},t._uniqueIdSeed=0,t._baseCache={},t.ShadersStore={},t.IncludesShadersStore={},t})();e.Effect=r})(r||(r={}));var r;!(function(e){var t=(function(){function e(){}return Object.defineProperty(e,"KEYDOWN",{get:function(){return e._KEYDOWN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"KEYUP",{get:function(){return e._KEYUP},enumerable:!0,configurable:!0}),e._KEYDOWN=1,e._KEYUP=2,e})();e.KeyboardEventTypes=t;var i=(function(){function e(e,t){this.type=e,this.event=t}return e})();e.KeyboardInfo=i;var r=(function(e){function t(t,i){var r=e.call(this,t,i)||this;return r.skipOnPointerObservable=!1,r}return o(t,e),t})(i);e.KeyboardInfoPre=r})(r||(r={}));var r;!(function(e){var t=(function(){function e(){}return Object.defineProperty(e,"POINTERDOWN",{get:function(){return e._POINTERDOWN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERUP",{get:function(){return e._POINTERUP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERMOVE",{get:function(){return e._POINTERMOVE},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERWHEEL",{get:function(){return e._POINTERWHEEL},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERPICK",{get:function(){return e._POINTERPICK},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERTAP",{get:function(){return e._POINTERTAP},enumerable:!0,configurable:!0}),Object.defineProperty(e,"POINTERDOUBLETAP",{get:function(){return e._POINTERDOUBLETAP},enumerable:!0,configurable:!0}),e._POINTERDOWN=1,e._POINTERUP=2,e._POINTERMOVE=4,e._POINTERWHEEL=8,e._POINTERPICK=16,e._POINTERTAP=32,e._POINTERDOUBLETAP=64,e})();e.PointerEventTypes=t;var i=(function(){function e(e,t){this.type=e,this.event=t}return e})();e.PointerInfoBase=i;var r=(function(t){function i(i,r,n,o){var s=t.call(this,i,r)||this;return s.skipOnPointerObservable=!1,s.localPosition=new e.Vector2(n,o),s}return o(i,t),i})(i);e.PointerInfoPre=r;var n=(function(e){function t(t,i,r){var n=e.call(this,t,i)||this;return n.pickInfo=r,n}return o(t,e),t})(i);e.PointerInfo=n})(r||(r={}));var r;!(function(e){e.ToGammaSpace=1/2.2,e.ToLinearSpace=2.2,e.Epsilon=.001;var t=(function(){function t(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 t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+"}"},t.prototype.getClassName=function(){return"Color3"},t.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0)},t.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},t.prototype.toColor4=function(e){return void 0===e&&(e=1),new i(this.r,this.g,this.b,e)},t.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},t.prototype.toLuminance=function(){return.3*this.r+.59*this.g+.11*this.b},t.prototype.multiply=function(e){return new t(this.r*e.r,this.g*e.g,this.b*e.b)},t.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},t.prototype.equals=function(e){return e&&this.r===e.r&&this.g===e.g&&this.b===e.b},t.prototype.equalsFloats=function(e,t,i){return this.r===e&&this.g===t&&this.b===i},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e)},t.prototype.scaleToRef=function(e,t){return t.r=this.r*e,t.g=this.g*e,t.b=this.b*e,this},t.prototype.scaleAndAddToRef=function(e,t){return t.r+=this.r*e,t.g+=this.g*e,t.b+=this.b*e,this},t.prototype.clampToRef=function(t,i,r){return void 0===t&&(t=0),void 0===i&&(i=1),r.r=e.Scalar.Clamp(this.r,t,i),r.g=e.Scalar.Clamp(this.g,t,i),r.b=e.Scalar.Clamp(this.b,t,i),this},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b)},t.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},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b)},t.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},t.prototype.clone=function(){return new t(this.r,this.g,this.b)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this},t.prototype.copyFromFloats=function(e,t,i){return this.r=e,this.g=t,this.b=i,this},t.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},t.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0;return"#"+e.Scalar.ToHex(t)+e.Scalar.ToHex(i)+e.Scalar.ToHex(r)},t.prototype.toLinearSpace=function(){var e=new t;return this.toLinearSpaceToRef(e),e},t.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToLinearSpace),t.g=Math.pow(this.g,e.ToLinearSpace),t.b=Math.pow(this.b,e.ToLinearSpace),this},t.prototype.toGammaSpace=function(){var e=new t;return this.toGammaSpaceToRef(e),e},t.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToGammaSpace),t.g=Math.pow(this.g,e.ToGammaSpace),t.b=Math.pow(this.b,e.ToGammaSpace),this},t.FromHexString=function(e){if("#"!==e.substring(0,1)||7!==e.length)return new t(0,0,0);var i=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16);return t.FromInts(i,r,n)},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1],e[i+2])},t.FromInts=function(e,i,r){return new t(e/255,i/255,r/255)},t.Lerp=function(e,i,r){return new t(e.r+(i.r-e.r)*r,e.g+(i.g-e.g)*r,e.b+(i.b-e.b)*r)},t.Red=function(){return new t(1,0,0)},t.Green=function(){return new t(0,1,0)},t.Blue=function(){return new t(0,0,1)},t.Black=function(){return new t(0,0,0)},t.White=function(){return new t(1,1,1)},t.Purple=function(){return new t(.5,0,.5)},t.Magenta=function(){return new t(1,0,1)},t.Yellow=function(){return new t(1,1,0)},t.Gray=function(){return new t(.5,.5,.5)},t.Teal=function(){return new t(0,1,1)},t.Random=function(){return new t(Math.random(),Math.random(),Math.random())},t})();e.Color3=t;var i=(function(){function t(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 t.prototype.addInPlace=function(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this.a+=e.a,this},t.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},t.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},t.prototype.add=function(e){return new t(this.r+e.r,this.g+e.g,this.b+e.b,this.a+e.a)},t.prototype.subtract=function(e){return new t(this.r-e.r,this.g-e.g,this.b-e.b,this.a-e.a)},t.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},t.prototype.scale=function(e){return new t(this.r*e,this.g*e,this.b*e,this.a*e)},t.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},t.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},t.prototype.clampToRef=function(t,i,r){return void 0===t&&(t=0),void 0===i&&(i=1),r.r=e.Scalar.Clamp(this.r,t,i),r.g=e.Scalar.Clamp(this.g,t,i),r.b=e.Scalar.Clamp(this.b,t,i),r.a=e.Scalar.Clamp(this.a,t,i),this},t.prototype.multiply=function(e){return new t(this.r*e.r,this.g*e.g,this.b*e.b,this.a*e.a)},t.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},t.prototype.toString=function(){return"{R: "+this.r+" G:"+this.g+" B:"+this.b+" A:"+this.a+"}"},t.prototype.getClassName=function(){return"Color4"},t.prototype.getHashCode=function(){var e=this.r||0;return e=397*e^(this.g||0),e=397*e^(this.b||0),e=397*e^(this.a||0)},t.prototype.clone=function(){return new t(this.r,this.g,this.b,this.a)},t.prototype.copyFrom=function(e){return this.r=e.r,this.g=e.g,this.b=e.b,this.a=e.a,this},t.prototype.copyFromFloats=function(e,t,i,r){return this.r=e,this.g=t,this.b=i,this.a=r,this},t.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},t.prototype.toHexString=function(){var t=255*this.r|0,i=255*this.g|0,r=255*this.b|0,n=255*this.a|0;return"#"+e.Scalar.ToHex(t)+e.Scalar.ToHex(i)+e.Scalar.ToHex(r)+e.Scalar.ToHex(n)},t.prototype.toLinearSpace=function(){var e=new t;return this.toLinearSpaceToRef(e),e},t.prototype.toLinearSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToLinearSpace),t.g=Math.pow(this.g,e.ToLinearSpace),t.b=Math.pow(this.b,e.ToLinearSpace),t.a=this.a,this},t.prototype.toGammaSpace=function(){var e=new t;return this.toGammaSpaceToRef(e),e},t.prototype.toGammaSpaceToRef=function(t){return t.r=Math.pow(this.r,e.ToGammaSpace),t.g=Math.pow(this.g,e.ToGammaSpace),t.b=Math.pow(this.b,e.ToGammaSpace),t.a=this.a,this},t.FromHexString=function(e){if("#"!==e.substring(0,1)||9!==e.length)return new t(0,0,0,0);var i=parseInt(e.substring(1,3),16),r=parseInt(e.substring(3,5),16),n=parseInt(e.substring(5,7),16),o=parseInt(e.substring(7,9),16);return t.FromInts(i,r,n,o)},t.Lerp=function(e,i,r){var n=new t(0,0,0,0);return t.LerpToRef(e,i,r,n),n},t.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},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.FromInts=function(e,i,r,n){return new t(e/255,i/255,r/255,n/255)},t.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},t})();e.Color4=i;var r=(function(){function t(e,t){this.x=e,this.y=t}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+"}"},t.prototype.getClassName=function(){return"Vector2"},t.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0)},t.prototype.toArray=function(e,t){return void 0===t&&(t=0),e[t]=this.x,e[t+1]=this.y,this},t.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this},t.prototype.copyFromFloats=function(e,t){return this.x=e,this.y=t,this},t.prototype.set=function(e,t){return this.copyFromFloats(e,t)},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.addToRef=function(e,t){return t.x=this.x+e.x,t.y=this.y+e.y,this},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this},t.prototype.addVector3=function(e){return new t(this.x+e.x,this.y+e.y)},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y)},t.prototype.subtractToRef=function(e,t){return t.x=this.x-e.x,t.y=this.y-e.y,this},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y)},t.prototype.multiplyToRef=function(e,t){return t.x=this.x*e.x,t.y=this.y*e.y,this},t.prototype.multiplyByFloats=function(e,i){return new t(this.x*e,this.y*i)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y)},t.prototype.divideToRef=function(e,t){return t.x=this.x/e.x,t.y=this.y/e.y,this},t.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},t.prototype.negate=function(){return new t(-this.x,-this.y)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this},t.prototype.scale=function(e){var i=new t(0,0);return this.scaleToRef(e,i),i},t.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,this},t.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,this},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y},t.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=e.Epsilon),t&&e.Scalar.WithinEpsilon(this.x,t.x,i)&&e.Scalar.WithinEpsilon(this.y,t.y,i)},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y},t.prototype.normalize=function(){var e=this.length();if(0===e)return this;var t=1/e;return this.x*=t,this.y*=t,this},t.prototype.clone=function(){return new t(this.x,this.y)},t.Zero=function(){return new t(0,0)},t.One=function(){return new t(1,1)},t.FromArray=function(e,i){return void 0===i&&(i=0),new t(e[i],e[i+1])},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1]},t.CatmullRom=function(e,i,r,n,o){var s=o*o,a=o*s;return new t(.5*(2*i.x+(-e.x+r.x)*o+(2*e.x-5*i.x+4*r.x-n.x)*s+(-e.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-e.y+r.y)*o+(2*e.y-5*i.y+4*r.y-n.y)*s+(-e.y+3*i.y-3*r.y+n.y)*a))},t.Clamp=function(e,i,r){var n=e.x;n=n>r.x?r.x:n,n=n<i.x?i.x:n;var o=e.y;return o=o>r.y?r.y:o,o=o<i.y?i.y:o,new t(n,o)},t.Hermite=function(e,i,r,n,o){var s=o*o,a=o*s,l=2*a-3*s+1,h=-2*a+3*s,c=a-2*s+o,u=a-s;return new t(e.x*l+r.x*h+i.x*c+n.x*u,e.y*l+r.y*h+i.y*c+n.y*u)},t.Lerp=function(e,i,r){return new t(e.x+(i.x-e.x)*r,e.y+(i.y-e.y)*r)},t.Dot=function(e,t){return e.x*t.x+e.y*t.y},t.Normalize=function(e){var t=e.clone();return t.normalize(),t},t.Minimize=function(e,i){return new t(e.x<i.x?e.x:i.x,e.y<i.y?e.y:i.y)},t.Maximize=function(e,i){return new t(e.x>i.x?e.x:i.x,e.y>i.y?e.y:i.y)},t.Transform=function(e,i){var r=t.Zero();return t.TransformToRef(e,i,r),r},t.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},t.PointInTriangle=function(e,t,i,r){var n=.5*(-i.y*r.x+t.y*(-i.x+r.x)+t.x*(i.y-r.y)+i.x*r.y),o=n<0?-1:1,s=(t.y*r.x-t.x*r.y+(r.y-t.y)*e.x+(t.x-r.x)*e.y)*o,a=(t.x*i.y-t.y*i.x+(t.y-i.y)*e.x+(i.x-t.x)*e.y)*o;return s>0&&a>0&&s+a<2*n*o},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.DistanceSquared=function(e,t){var i=e.x-t.x,r=e.y-t.y;return i*i+r*r},t.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},t.DistanceOfPointFromSegment=function(e,i,r){var n=t.DistanceSquared(i,r);if(0===n)return t.Distance(e,i);var o=r.subtract(i),s=Math.max(0,Math.min(1,t.Dot(e.subtract(i),o)/n)),a=i.add(o.multiplyByFloats(s,s));return t.Distance(e,a)},t})();e.Vector2=r;var n=(function(){function t(e,t,i){this.x=e,this.y=t,this.z=i}
return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+"}"},t.prototype.getClassName=function(){return"Vector3"},t.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0)},t.prototype.asArray=function(){var e=[];return this.toArray(e,0),e},t.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},t.prototype.toQuaternion=function(){return e.Quaternion.RotationYawPitchRoll(this.x,this.y,this.z)},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z)},t.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},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z)},t.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},t.prototype.subtractFromFloats=function(e,i,r){return new t(this.x-e,this.y-i,this.z-r)},t.prototype.subtractFromFloatsToRef=function(e,t,i,r){return r.x=this.x-e,r.y=this.y-t,r.z=this.z-i,this},t.prototype.negate=function(){return new t(-this.x,-this.y,-this.z)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e)},t.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,this},t.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,t.z+=this.z*e,this},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z},t.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=e.Epsilon),t&&e.Scalar.WithinEpsilon(this.x,t.x,i)&&e.Scalar.WithinEpsilon(this.y,t.y,i)&&e.Scalar.WithinEpsilon(this.z,t.z,i)},t.prototype.equalsToFloats=function(e,t,i){return this.x===e&&this.y===t&&this.z===i},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z)},t.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},t.prototype.multiplyByFloats=function(e,i,r){return new t(this.x*e,this.y*i,this.z*r)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y,this.z/e.z)},t.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},t.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},t.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),this},t.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),this},Object.defineProperty(t.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}),t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z},t.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},t.prototype.normalizeToNew=function(){var e=new t(0,0,0);return this.normalizeToRef(e),e},t.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},t.prototype.clone=function(){return new t(this.x,this.y,this.z)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this},t.prototype.copyFromFloats=function(e,t,i){return this.x=e,this.y=t,this.z=i,this},t.prototype.set=function(e,t,i){return this.copyFromFloats(e,t,i)},t.GetClipFactor=function(e,i,r,n){var o=t.Dot(e,r)-n;return o/(o-(t.Dot(i,r)-n))},t.GetAngleBetweenVectors=function(e,i,r){var n=e.clone().normalize(),o=i.clone().normalize(),s=t.Dot(n,o),a=t.Cross(n,o);return t.Dot(a,r)>0?Math.acos(s):-Math.acos(s)},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2])},t.FromFloatArray=function(e,i){return t.FromArray(e,i)},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2]},t.FromFloatArrayToRef=function(e,i,r){return t.FromArrayToRef(e,i,r)},t.FromFloatsToRef=function(e,t,i,r){r.x=e,r.y=t,r.z=i},t.Zero=function(){return new t(0,0,0)},t.One=function(){return new t(1,1,1)},t.Up=function(){return new t(0,1,0)},t.Forward=function(){return new t(0,0,1)},t.Right=function(){return new t(1,0,0)},t.Left=function(){return new t(-1,0,0)},t.TransformCoordinates=function(e,i){var r=t.Zero();return t.TransformCoordinatesToRef(e,i,r),r},t.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},t.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},t.TransformNormal=function(e,i){var r=t.Zero();return t.TransformNormalToRef(e,i,r),r},t.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},t.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]},t.CatmullRom=function(e,i,r,n,o){var s=o*o,a=o*s;return new t(.5*(2*i.x+(-e.x+r.x)*o+(2*e.x-5*i.x+4*r.x-n.x)*s+(-e.x+3*i.x-3*r.x+n.x)*a),.5*(2*i.y+(-e.y+r.y)*o+(2*e.y-5*i.y+4*r.y-n.y)*s+(-e.y+3*i.y-3*r.y+n.y)*a),.5*(2*i.z+(-e.z+r.z)*o+(2*e.z-5*i.z+4*r.z-n.z)*s+(-e.z+3*i.z-3*r.z+n.z)*a))},t.Clamp=function(e,i,r){var n=e.x;n=n>r.x?r.x:n,n=n<i.x?i.x:n;var o=e.y;o=o>r.y?r.y:o,o=o<i.y?i.y:o;var s=e.z;return s=s>r.z?r.z:s,s=s<i.z?i.z:s,new t(n,o,s)},t.Hermite=function(e,i,r,n,o){var s=o*o,a=o*s,l=2*a-3*s+1,h=-2*a+3*s,c=a-2*s+o,u=a-s;return new t(e.x*l+r.x*h+i.x*c+n.x*u,e.y*l+r.y*h+i.y*c+n.y*u,e.z*l+r.z*h+i.z*c+n.z*u)},t.Lerp=function(e,i,r){var n=new t(0,0,0);return t.LerpToRef(e,i,r,n),n},t.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},t.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z},t.Cross=function(e,i){var r=t.Zero();return t.CrossToRef(e,i,r),r},t.CrossToRef=function(e,t,i){E.Vector3[0].x=e.y*t.z-e.z*t.y,E.Vector3[0].y=e.z*t.x-e.x*t.z,E.Vector3[0].z=e.x*t.y-e.y*t.x,i.copyFrom(E.Vector3[0])},t.Normalize=function(e){var i=t.Zero();return t.NormalizeToRef(e,i),i},t.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},t.Project=function(e,i,r,n){var o=n.width,s=n.height,a=n.x,h=n.y,c=t._viewportMatrixCache?t._viewportMatrixCache:t._viewportMatrixCache=new l;l.FromValuesToRef(o/2,0,0,0,0,-s/2,0,0,0,0,.5,0,a+o/2,s/2+h,.5,1,c);var u=E.Matrix[0];return i.multiplyToRef(r,u),u.multiplyToRef(c,u),t.TransformCoordinates(e,u)},t.UnprojectFromTransform=function(i,r,n,o,s){var a=E.Matrix[0];o.multiplyToRef(s,a),a.invert(),i.x=i.x/r*2-1,i.y=-(i.y/n*2-1);var l=t.TransformCoordinates(i,a),h=i.x*a.m[3]+i.y*a.m[7]+i.z*a.m[11]+a.m[15];return e.Scalar.WithinEpsilon(h,1)&&(l=l.scale(1/h)),l},t.Unproject=function(e,i,r,n,o,s){var a=t.Zero();return t.UnprojectToRef(e,i,r,n,o,s,a),a},t.UnprojectToRef=function(e,i,r,n,o,s,a){t.UnprojectFloatsToRef(e.x,e.y,e.z,i,r,n,o,s,a)},t.UnprojectFloatsToRef=function(i,r,n,o,s,a,l,h,c){var u=E.Matrix[0];a.multiplyToRef(l,u),u.multiplyToRef(h,u),u.invert();var f=E.Vector3[0];f.x=i/o*2-1,f.y=-(r/s*2-1),f.z=2*n-1,t.TransformCoordinatesToRef(f,u,c);var p=f.x*u.m[3]+f.y*u.m[7]+f.z*u.m[11]+u.m[15];e.Scalar.WithinEpsilon(p,1)&&c.scaleInPlace(1/p)},t.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},t.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.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},t.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},t.RotationFromAxis=function(e,i,r){var n=t.Zero();return t.RotationFromAxisToRef(e,i,r,n),n},t.RotationFromAxisToRef=function(e,t,i,r){var n=E.Quaternion[0];a.RotationQuaternionFromAxisToRef(e,t,i,n),n.toEulerAnglesToRef(r)},t})();e.Vector3=n;var o=(function(){function t(e,t,i,r){this.x=e,this.y=t,this.z=i,this.w=r}return t.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},t.prototype.getClassName=function(){return"Vector4"},t.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0),e=397*e^(this.w||0)},t.prototype.asArray=function(){var e=new Array;return this.toArray(e,0),e},t.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},t.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},t.prototype.add=function(e){return new t(this.x+e.x,this.y+e.y,this.z+e.z,this.w+e.w)},t.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},t.prototype.subtractInPlace=function(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this.w-=e.w,this},t.prototype.subtract=function(e){return new t(this.x-e.x,this.y-e.y,this.z-e.z,this.w-e.w)},t.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},t.prototype.subtractFromFloats=function(e,i,r,n){return new t(this.x-e,this.y-i,this.z-r,this.w-n)},t.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},t.prototype.negate=function(){return new t(-this.x,-this.y,-this.z,-this.w)},t.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},t.prototype.scale=function(e){return new t(this.x*e,this.y*e,this.z*e,this.w*e)},t.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},t.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},t.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},t.prototype.equalsWithEpsilon=function(t,i){return void 0===i&&(i=e.Epsilon),t&&e.Scalar.WithinEpsilon(this.x,t.x,i)&&e.Scalar.WithinEpsilon(this.y,t.y,i)&&e.Scalar.WithinEpsilon(this.z,t.z,i)&&e.Scalar.WithinEpsilon(this.w,t.w,i)},t.prototype.equalsToFloats=function(e,t,i,r){return this.x===e&&this.y===t&&this.z===i&&this.w===r},t.prototype.multiplyInPlace=function(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this.w*=e.w,this},t.prototype.multiply=function(e){return new t(this.x*e.x,this.y*e.y,this.z*e.z,this.w*e.w)},t.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},t.prototype.multiplyByFloats=function(e,i,r,n){return new t(this.x*e,this.y*i,this.z*r,this.w*n)},t.prototype.divide=function(e){return new t(this.x/e.x,this.y/e.y,this.z/e.z,this.w/e.w)},t.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},t.prototype.divideInPlace=function(e){return this.divideToRef(e,this)},t.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},t.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},t.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},t.prototype.lengthSquared=function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},t.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},t.prototype.toVector3=function(){return new n(this.x,this.y,this.z)},t.prototype.clone=function(){return new t(this.x,this.y,this.z,this.w)},t.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},t.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},t.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},t.FromArray=function(e,i){return i||(i=0),new t(e[i],e[i+1],e[i+2],e[i+3])},t.FromArrayToRef=function(e,t,i){i.x=e[t],i.y=e[t+1],i.z=e[t+2],i.w=e[t+3]},t.FromFloatArrayToRef=function(e,i,r){t.FromArrayToRef(e,i,r)},t.FromFloatsToRef=function(e,t,i,r,n){n.x=e,n.y=t,n.z=i,n.w=r},t.Zero=function(){return new t(0,0,0,0)},t.One=function(){return new t(1,1,1,1)},t.Normalize=function(e){var i=t.Zero();return t.NormalizeToRef(e,i),i},t.NormalizeToRef=function(e,t){t.copyFrom(e),t.normalize()},t.Minimize=function(e,t){var i=e.clone();return i.minimizeInPlace(t),i},t.Maximize=function(e,t){var i=e.clone();return i.maximizeInPlace(t),i},t.Distance=function(e,i){return Math.sqrt(t.DistanceSquared(e,i))},t.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},t.Center=function(e,t){var i=e.add(t);return i.scaleInPlace(.5),i},t.TransformNormal=function(e,i){var r=t.Zero();return t.TransformNormalToRef(e,i,r),r},t.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},t.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},t})();e.Vector4=o;var s=(function(){function e(e,t){this.width=e,this.height=t}return e.prototype.toString=function(){return"{W: "+this.width+", H: "+this.height+"}"},e.prototype.getClassName=function(){return"Size"},e.prototype.getHashCode=function(){var e=this.width||0;return e=397*e^(this.height||0)},e.prototype.copyFrom=function(e){this.width=e.width,this.height=e.height},e.prototype.copyFromFloats=function(e,t){return this.width=e,this.height=t,this},e.prototype.set=function(e,t){return this.copyFromFloats(e,t)},e.prototype.multiplyByFloats=function(t,i){return new e(this.width*t,this.height*i)},e.prototype.clone=function(){return new e(this.width,this.height)},e.prototype.equals=function(e){return!!e&&(this.width===e.width&&this.height===e.height)},Object.defineProperty(e.prototype,"surface",{get:function(){return this.width*this.height},enumerable:!0,configurable:!0}),e.Zero=function(){return new e(0,0)},e.prototype.add=function(t){return new e(this.width+t.width,this.height+t.height)},e.prototype.subtract=function(t){return new e(this.width-t.width,this.height-t.height)},e.Lerp=function(t,i,r){return new e(t.width+(i.width-t.width)*r,t.height+(i.height-t.height)*r)},e})();e.Size=s;var a=(function(){function e(e,t,i,r){void 0===e&&(e=0),void 0===t&&(t=0),void 0===i&&(i=0),void 0===r&&(r=1),this.x=e,this.y=t,this.z=i,this.w=r}return e.prototype.toString=function(){return"{X: "+this.x+" Y:"+this.y+" Z:"+this.z+" W:"+this.w+"}"},e.prototype.getClassName=function(){return"Quaternion"},e.prototype.getHashCode=function(){var e=this.x||0;return e=397*e^(this.y||0),e=397*e^(this.z||0),e=397*e^(this.w||0)},e.prototype.asArray=function(){return[this.x,this.y,this.z,this.w]},e.prototype.equals=function(e){return e&&this.x===e.x&&this.y===e.y&&this.z===e.z&&this.w===e.w},e.prototype.clone=function(){return new e(this.x,this.y,this.z,this.w)},e.prototype.copyFrom=function(e){return this.x=e.x,this.y=e.y,this.z=e.z,this.w=e.w,this},e.prototype.copyFromFloats=function(e,t,i,r){return this.x=e,this.y=t,this.z=i,this.w=r,this},e.prototype.set=function(e,t,i,r){return this.copyFromFloats(e,t,i,r)},e.prototype.add=function(t){return new e(this.x+t.x,this.y+t.y,this.z+t.z,this.w+t.w)},e.prototype.addInPlace=function(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this.w+=e.w,this},e.prototype.subtract=function(t){return new e(this.x-t.x,this.y-t.y,this.z-t.z,this.w-t.w)},e.prototype.scale=function(t){return new e(this.x*t,this.y*t,this.z*t,this.w*t)},e.prototype.scaleToRef=function(e,t){return t.x=this.x*e,t.y=this.y*e,t.z=this.z*e,t.w=this.w*e,this},e.prototype.scaleInPlace=function(e){return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.scaleAndAddToRef=function(e,t){return t.x+=this.x*e,t.y+=this.y*e,t.z+=this.z*e,t.w+=this.w*e,this},e.prototype.multiply=function(t){var i=new e(0,0,0,1);return this.multiplyToRef(t,i),i},e.prototype.multiplyToRef=function(e,t){var i=this.x*e.w+this.y*e.z-this.z*e.y+this.w*e.x,r=-this.x*e.z+this.y*e.w+this.z*e.x+this.w*e.y,n=this.x*e.y-this.y*e.x+this.z*e.w+this.w*e.z,o=-this.x*e.x-this.y*e.y-this.z*e.z+this.w*e.w;return t.copyFromFloats(i,r,n,o),this},e.prototype.multiplyInPlace=function(e){return this.multiplyToRef(e,this),this},e.prototype.conjugateToRef=function(e){return e.copyFromFloats(-this.x,-this.y,-this.z,this.w),this},e.prototype.conjugateInPlace=function(){return this.x*=-1,this.y*=-1,this.z*=-1,this},e.prototype.conjugate=function(){return new e(-this.x,-this.y,-this.z,this.w)},e.prototype.length=function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w)},e.prototype.normalize=function(){var e=1/this.length();return this.x*=e,this.y*=e,this.z*=e,this.w*=e,this},e.prototype.toEulerAngles=function(e){void 0===e&&(e="YZX");var t=n.Zero();return this.toEulerAnglesToRef(t,e),t},e.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,h=n*n,c=n*i-r*o;return c<-.4999999?(e.y=2*Math.atan2(n,o),e.x=Math.PI/2,e.z=0):c>.4999999?(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+h+s),e.x=Math.asin(-2*(i*n-r*o)),e.y=Math.atan2(2*(i*r+n*o),a-l-h+s)),this},e.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,h=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+h),e.m[7]=0,e.m[8]=2*(s+a),e.m[9]=2*(l-h),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},e.prototype.fromRotationMatrix=function(t){return e.FromRotationMatrixToRef(t,this),this},e.FromRotationMatrix=function(t){var i=new e;return e.FromRotationMatrixToRef(t,i),i},e.FromRotationMatrixToRef=function(e,t){var i,r=e.m,n=r[0],o=r[4],s=r[8],a=r[1],l=r[5],h=r[9],c=r[2],u=r[6],f=r[10],p=n+l+f;p>0?(i=.5/Math.sqrt(p+1),t.w=.25/i,t.x=(u-h)*i,t.y=(s-c)*i,t.z=(a-o)*i):n>l&&n>f?(i=2*Math.sqrt(1+n-l-f),t.w=(u-h)/i,t.x=.25*i,t.y=(o+a)/i,t.z=(s+c)/i):l>f?(i=2*Math.sqrt(1+l-n-f),t.w=(s-c)/i,t.x=(o+a)/i,t.y=.25*i,t.z=(h+u)/i):(i=2*Math.sqrt(1+f-n-l),t.w=(a-o)/i,t.x=(s+c)/i,t.y=(h+u)/i,t.z=.25*i)},e.Dot=function(e,t){return e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w},e.AreClose=function(t,i){return e.Dot(t,i)>=0},e.Zero=function(){return new e(0,0,0,0)},e.Inverse=function(t){return new e(-t.x,-t.y,-t.z,t.w)},e.Identity=function(){return new e(0,0,0,1)},e.IsIdentity=function(e){return e&&0===e.x&&0===e.y&&0===e.z&&1===e.w},e.RotationAxis=function(t,i){return e.RotationAxisToRef(t,i,new e)},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(t/2);return e.normalize(),i.w=Math.cos(t/2),i.x=e.x*r,i.y=e.y*r,i.z=e.z*r,i},e.FromArray=function(t,i){return i||(i=0),new e(t[i],t[i+1],t[i+2],t[i+3])},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){var n=.5*i,o=.5*t,s=.5*e,a=Math.sin(n),l=Math.cos(n),h=Math.sin(o),c=Math.cos(o),u=Math.sin(s),f=Math.cos(s);r.x=f*h*l+u*c*a,r.y=u*c*l-f*h*a,r.z=f*c*a-u*h*l,r.w=f*c*l+u*h*a},e.RotationAlphaBetaGamma=function(t,i,r){var n=new e;return e.RotationAlphaBetaGammaToRef(t,i,r,n),n},e.RotationAlphaBetaGammaToRef=function(e,t,i,r){var n=.5*(i+e),o=.5*(i-e),s=.5*t;r.x=Math.cos(o)*Math.sin(s),r.y=Math.sin(o)*Math.sin(s),r.z=Math.sin(n)*Math.cos(s),r.w=Math.cos(n)*Math.cos(s)},e.RotationQuaternionFromAxis=function(t,i,r){var n=new e(0,0,0,0);return e.RotationQuaternionFromAxisToRef(t,i,r,n),n},e.RotationQuaternionFromAxisToRef=function(t,i,r,n){var o=E.Matrix[0];l.FromXYZAxesToRef(t.normalize(),i.normalize(),r.normalize(),o),e.FromRotationMatrixToRef(o,n)},e.Slerp=function(t,i,r){var n=e.Identity();return e.SlerpToRef(t,i,r,n),n},e.SlerpToRef=function(e,t,i,r){var n,o,s=e.x*t.x+e.y*t.y+e.z*t.z+e.w*t.w,a=!1;if(s<0&&(a=!0,s=-s),s>.999999)o=1-i,n=a?-i:i;else{var l=Math.acos(s),h=1/Math.sin(l);o=Math.sin((1-i)*l)*h,n=a?-Math.sin(i*l)*h:Math.sin(i*l)*h}r.x=o*e.x+n*t.x,r.y=o*e.y+n*t.y,r.z=o*e.z+n*t.z,r.w=o*e.w+n*t.w},e.Hermite=function(t,i,r,n,o){var s=o*o,a=o*s,l=2*a-3*s+1,h=-2*a+3*s,c=a-2*s+o,u=a-s;return new e(t.x*l+r.x*h+i.x*c+n.x*u,t.y*l+r.y*h+i.y*c+n.y*u,t.z*l+r.z*h+i.z*c+n.z*u,t.w*l+r.w*h+i.w*c+n.w*u)},e})();e.Quaternion=a;var l=(function(){function e(){this._isIdentity=!1,this._isIdentityDirty=!0,this.m=new Float32Array(16),this._markAsUpdated()}return e.prototype._markAsUpdated=function(){this.updateFlag=e._updateFlagSeed++,this._isIdentityDirty=!0},e.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},e.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)},e.prototype.toArray=function(){return this.m},e.prototype.asArray=function(){return this.toArray()},e.prototype.invert=function(){return this.invertToRef(this),this},e.prototype.reset=function(){for(var e=0;e<16;e++)this.m[e]=0;return this._markAsUpdated(),this},e.prototype.add=function(t){var i=new e;return this.addToRef(t,i),i},e.prototype.addToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]+e.m[i];return t._markAsUpdated(),this},e.prototype.addToSelf=function(e){for(var t=0;t<16;t++)this.m[t]+=e.m[t];return this._markAsUpdated(),this},e.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],h=this.m[8],c=this.m[9],u=this.m[10],f=this.m[11],p=this.m[12],d=this.m[13],m=this.m[14],_=this.m[15],g=u*_-f*m,v=c*_-f*d,y=c*m-u*d,b=h*_-f*p,x=h*m-u*p,T=h*d-c*p,E=s*g-a*v+l*y,P=-(o*g-a*b+l*x),A=o*v-s*b+l*T,M=-(o*y-s*x+a*T),S=1/(t*E+i*P+r*A+n*M),C=a*_-l*m,R=s*_-l*d,O=s*m-a*d,I=o*_-l*p,D=o*m-a*p,w=o*d-s*p,L=a*f-l*u,F=s*f-l*c,B=s*u-a*c,V=o*f-l*h,N=o*u-a*h,U=o*c-s*h;return e.m[0]=E*S,e.m[4]=P*S,e.m[8]=A*S,e.m[12]=M*S,e.m[1]=-(i*g-r*v+n*y)*S,e.m[5]=(t*g-r*b+n*x)*S,e.m[9]=-(t*v-i*b+n*T)*S,e.m[13]=(t*y-i*x+r*T)*S,e.m[2]=(i*C-r*R+n*O)*S,e.m[6]=-(t*C-r*I+n*D)*S,e.m[10]=(t*R-i*I+n*w)*S,e.m[14]=-(t*O-i*D+r*w)*S,e.m[3]=-(i*L-r*F+n*B)*S,e.m[7]=(t*L-r*V+n*N)*S,e.m[11]=-(t*F-i*V+n*U)*S,e.m[15]=(t*B-i*N+r*U)*S,e._markAsUpdated(),this},e.prototype.setTranslationFromFloats=function(e,t,i){return this.m[12]=e,this.m[13]=t,this.m[14]=i,this._markAsUpdated(),this},e.prototype.setTranslation=function(e){return this.m[12]=e.x,this.m[13]=e.y,this.m[14]=e.z,this._markAsUpdated(),this},e.prototype.getTranslation=function(){return new n(this.m[12],this.m[13],this.m[14])},e.prototype.getTranslationToRef=function(e){return e.x=this.m[12],e.y=this.m[13],e.z=this.m[14],this},e.prototype.removeRotationAndScaling=function(){return this.setRowFromFloats(0,1,0,0,0),this.setRowFromFloats(1,0,1,0,0),this.setRowFromFloats(2,0,0,1,0),this},e.prototype.multiply=function(t){var i=new e;return this.multiplyToRef(t,i),i},e.prototype.copyFrom=function(e){for(var t=0;t<16;t++)this.m[t]=e.m[t];return this._markAsUpdated(),this},e.prototype.copyToArray=function(e,t){void 0===t&&(t=0);for(var i=0;i<16;i++)e[t+i]=this.m[i];return this},e.prototype.multiplyToRef=function(e,t){return this.multiplyToArray(e,t.m,0),t._markAsUpdated(),this},e.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],h=this.m[6],c=this.m[7],u=this.m[8],f=this.m[9],p=this.m[10],d=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],x=e.m[2],T=e.m[3],E=e.m[4],P=e.m[5],A=e.m[6],M=e.m[7],S=e.m[8],C=e.m[9],R=e.m[10],O=e.m[11],I=e.m[12],D=e.m[13],w=e.m[14],L=e.m[15];return t[i]=r*y+n*E+o*S+s*I,t[i+1]=r*b+n*P+o*C+s*D,t[i+2]=r*x+n*A+o*R+s*w,t[i+3]=r*T+n*M+o*O+s*L,t[i+4]=a*y+l*E+h*S+c*I,t[i+5]=a*b+l*P+h*C+c*D,t[i+6]=a*x+l*A+h*R+c*w,t[i+7]=a*T+l*M+h*O+c*L,t[i+8]=u*y+f*E+p*S+d*I,t[i+9]=u*b+f*P+p*C+d*D,t[i+10]=u*x+f*A+p*R+d*w,t[i+11]=u*T+f*M+p*O+d*L,t[i+12]=m*y+_*E+g*S+v*I,t[i+13]=m*b+_*P+g*C+v*D,t[i+14]=m*x+_*A+g*R+v*w,t[i+15]=m*T+_*M+g*O+v*L,this},e.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]},e.prototype.clone=function(){return e.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])},e.prototype.getClassName=function(){return"Matrix"},e.prototype.getHashCode=function(){for(var e=this.m[0]||0,t=1;t<16;t++)e=397*e^(this.m[t]||0);return e},e.prototype.decompose=function(t,i,r){return r&&(r.x=this.m[12],r.y=this.m[13],r.z=this.m[14]),t=t||E.Vector3[0],t.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&&(e.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,E.Matrix[0]),a.FromRotationMatrixToRef(E.Matrix[0],i)),!0)},e.prototype.getRow=function(e){if(e<0||e>3)return null;var t=4*e;return new o(this.m[t+0],this.m[t+1],this.m[t+2],this.m[t+3])},e.prototype.setRow=function(e,t){if(e<0||e>3)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},e.prototype.transpose=function(){return e.Transpose(this)},e.prototype.transposeToRef=function(t){return e.TransposeToRef(this,t),this},e.prototype.setRowFromFloats=function(e,t,i,r,n){if(e<0||e>3)return this;var o=4*e;return this.m[o+0]=t,this.m[o+1]=i,this.m[o+2]=r,this.m[o+3]=n,this._markAsUpdated(),this},e.prototype.scale=function(t){var i=new e;return this.scaleToRef(t,i),i},e.prototype.scaleToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]=this.m[i]*e;return t._markAsUpdated(),this},e.prototype.scaleAndAddToRef=function(e,t){for(var i=0;i<16;i++)t.m[i]+=this.m[i]*e;return t._markAsUpdated(),this},e.prototype.toNormalMatrix=function(t){this.invertToRef(t),t.transpose();var i=t.m;e.FromValuesToRef(i[0],i[1],i[2],0,i[4],i[5],i[6],0,i[8],i[9],i[10],0,0,0,0,1,t)},e.prototype.getRotationMatrix=function(){var t=e.Identity();return this.getRotationMatrixToRef(t),t},e.prototype.getRotationMatrixToRef=function(t){var i=this.m,r=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]),n=Math.sqrt(i[4]*i[4]+i[5]*i[5]+i[6]*i[6]),o=Math.sqrt(i[8]*i[8]+i[9]*i[9]+i[10]*i[10]);return this.determinant()<=0&&(n*=-1),0===r||0===n||0===o?e.IdentityToRef(t):e.FromValuesToRef(i[0]/r,i[1]/r,i[2]/r,0,i[4]/n,i[5]/n,i[6]/n,0,i[8]/o,i[9]/o,i[10]/o,0,0,0,0,1,t),this},e.FromArray=function(t,i){var r=new e;return i||(i=0),e.FromArrayToRef(t,i,r),r},e.FromArrayToRef=function(e,t,i){for(var r=0;r<16;r++)i.m[r]=e[r+t];i._markAsUpdated()},e.FromFloat32ArrayToRefScaled=function(e,t,i,r){for(var n=0;n<16;n++)r.m[n]=e[n+t]*i;r._markAsUpdated()},e.FromValuesToRef=function(e,t,i,r,n,o,s,a,l,h,c,u,f,p,d,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]=h,_.m[10]=c,_.m[11]=u,_.m[12]=f,_.m[13]=p,_.m[14]=d,_.m[15]=m,_._markAsUpdated()},Object.defineProperty(e,"IdentityReadOnly",{get:function(){return e._identityReadOnly},enumerable:!0,configurable:!0}),e.FromValues=function(t,i,r,n,o,s,a,l,h,c,u,f,p,d,m,_){var g=new e;return g.m[0]=t,g.m[1]=i,g.m[2]=r,g.m[3]=n,g.m[4]=o,g.m[5]=s,g.m[6]=a,g.m[7]=l,g.m[8]=h,g.m[9]=c,g.m[10]=u,g.m[11]=f,g.m[12]=p,g.m[13]=d,g.m[14]=m,g.m[15]=_,g},e.Compose=function(t,i,r){var n=e.Identity();return e.ComposeToRef(t,i,r,n),n},e.ComposeToRef=function(t,i,r,n){e.FromValuesToRef(t.x,0,0,0,0,t.y,0,0,0,0,t.z,0,0,0,0,1,E.Matrix[1]),i.toRotationMatrix(E.Matrix[0]),E.Matrix[1].multiplyToRef(E.Matrix[0],n),n.setTranslation(r)},e.Identity=function(){return e.FromValues(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1)},e.IdentityToRef=function(t){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,t)},e.Zero=function(){return e.FromValues(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)},e.RotationX=function(t){var i=new e;return e.RotationXToRef(t,i),i},e.Invert=function(t){var i=new e;return t.invertToRef(i),i},e.RotationXToRef=function(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()},e.RotationY=function(t){var i=new e;return e.RotationYToRef(t,i),i},e.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()},e.RotationZ=function(t){var i=new e;return e.RotationZToRef(t,i),i},e.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()},e.RotationAxis=function(t,i){var r=e.Zero();return e.RotationAxisToRef(t,i,r),r},e.RotationAxisToRef=function(e,t,i){var r=Math.sin(-t),n=Math.cos(-t),o=1-n;e.normalize(),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()},e.RotationYawPitchRoll=function(t,i,r){var n=new e;return e.RotationYawPitchRollToRef(t,i,r,n),n},e.RotationYawPitchRollToRef=function(e,t,i,r){a.RotationYawPitchRollToRef(e,t,i,this._tempQuaternion),this._tempQuaternion.toRotationMatrix(r)},e.Scaling=function(t,i,r){var n=e.Zero();return e.ScalingToRef(t,i,r,n),n},e.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()},e.Translation=function(t,i,r){var n=e.Identity();return e.TranslationToRef(t,i,r,n),n},e.TranslationToRef=function(t,i,r,n){e.FromValuesToRef(1,0,0,0,0,1,0,0,0,0,1,0,t,i,r,1,n)},e.Lerp=function(t,i,r){var n=e.Zero();return e.LerpToRef(t,i,r,n),n},e.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()},e.DecomposeLerp=function(t,i,r){var n=e.Zero();return e.DecomposeLerpToRef(t,i,r,n),n},e.DecomposeLerpToRef=function(t,i,r,o){var s=E.Vector3[0],l=E.Quaternion[0],h=E.Vector3[1];t.decompose(s,l,h);var c=E.Vector3[2],u=E.Quaternion[1],f=E.Vector3[3];i.decompose(c,u,f);var p=E.Vector3[4];n.LerpToRef(s,c,r,p);var d=E.Quaternion[2];a.SlerpToRef(l,u,r,d);var m=E.Vector3[5];n.LerpToRef(h,f,r,m),e.ComposeToRef(p,d,m,o)},e.LookAtLH=function(t,i,r){var n=e.Zero();return e.LookAtLHToRef(t,i,r,n),n},e.LookAtLHToRef=function(t,i,r,o){i.subtractToRef(t,this._zAxis),this._zAxis.normalize(),n.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),n.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-n.Dot(this._xAxis,t),a=-n.Dot(this._yAxis,t),l=-n.Dot(this._zAxis,t);return e.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,s,a,l,1,o)},e.LookAtRH=function(t,i,r){var n=e.Zero();return e.LookAtRHToRef(t,i,r,n),n},e.LookAtRHToRef=function(t,i,r,o){t.subtractToRef(i,this._zAxis),this._zAxis.normalize(),n.CrossToRef(r,this._zAxis,this._xAxis),0===this._xAxis.lengthSquared()?this._xAxis.x=1:this._xAxis.normalize(),n.CrossToRef(this._zAxis,this._xAxis,this._yAxis),this._yAxis.normalize();var s=-n.Dot(this._xAxis,t),a=-n.Dot(this._yAxis,t),l=-n.Dot(this._zAxis,t);return e.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,s,a,l,1,o)},e.OrthoLH=function(t,i,r,n){var o=e.Zero();return e.OrthoLHToRef(t,i,r,n,o),o},e.OrthoLHToRef=function(t,i,r,n,o){var s=r,a=n,l=2/t,h=2/i,c=2/(a-s),u=-(a+s)/(a-s);e.FromValuesToRef(l,0,0,0,0,h,0,0,0,0,c,0,0,0,u,1,o)},e.OrthoOffCenterLH=function(t,i,r,n,o,s){var a=e.Zero();return e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterLHToRef=function(t,i,r,n,o,s,a){var l=o,h=s,c=2/(i-t),u=2/(n-r),f=2/(h-l),p=-(h+l)/(h-l),d=(t+i)/(t-i),m=(n+r)/(r-n);e.FromValuesToRef(c,0,0,0,0,u,0,0,0,0,f,0,d,m,p,1,a)},e.OrthoOffCenterRH=function(t,i,r,n,o,s){var a=e.Zero();return e.OrthoOffCenterRHToRef(t,i,r,n,o,s,a),a},e.OrthoOffCenterRHToRef=function(t,i,r,n,o,s,a){e.OrthoOffCenterLHToRef(t,i,r,n,o,s,a),a.m[10]*=-1},e.PerspectiveLH=function(t,i,r,n){var o=e.Zero(),s=r,a=n,l=2*s/t,h=2*s/i,c=(a+s)/(a-s),u=-2*a*s/(a-s);return e.FromValuesToRef(l,0,0,0,0,h,0,0,0,0,c,1,0,0,u,0,o),o},e.PerspectiveFovLH=function(t,i,r,n){var o=e.Zero();return e.PerspectiveFovLHToRef(t,i,r,n,o),o},e.PerspectiveFovLHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,l=n,h=1/Math.tan(.5*t),c=s?h/i:h,u=s?h:h*i,f=(l+a)/(l-a),p=-2*l*a/(l-a);e.FromValuesToRef(c,0,0,0,0,u,0,0,0,0,f,1,0,0,p,0,o)},e.PerspectiveFovRH=function(t,i,r,n){var o=e.Zero();return e.PerspectiveFovRHToRef(t,i,r,n,o),o},e.PerspectiveFovRHToRef=function(t,i,r,n,o,s){void 0===s&&(s=!0);var a=r,l=n,h=1/Math.tan(.5*t),c=s?h/i:h,u=s?h:h*i,f=-(l+a)/(l-a),p=-2*l*a/(l-a);e.FromValuesToRef(c,0,0,0,0,u,0,0,0,0,f,-1,0,0,p,0,o)},e.PerspectiveFovWebVRToRef=function(e,t,i,r,n){void 0===n&&(n=!1);var o=n?-1:1,s=Math.tan(e.upDegrees*Math.PI/180),a=Math.tan(e.downDegrees*Math.PI/180),l=Math.tan(e.leftDegrees*Math.PI/180),h=Math.tan(e.rightDegrees*Math.PI/180),c=2/(l+h),u=2/(s+a);r.m[0]=c,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-h)*c*.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()},e.GetFinalMatrix=function(t,i,r,n,o,s){var a=t.width,l=t.height,h=t.x,c=t.y,u=e.FromValues(a/2,0,0,0,0,-l/2,0,0,0,0,s-o,0,h+a/2,l/2+c,o,1);return i.multiply(r).multiply(n).multiply(u)},e.GetAsMatrix2x2=function(e){return new Float32Array([e.m[0],e.m[1],e.m[4],e.m[5]])},e.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]])},e.Transpose=function(t){var i=new e;return e.TransposeToRef(t,i),i},e.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]},e.Reflection=function(t){var i=new e;return e.ReflectionToRef(t,i),i},e.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()},e.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()},e.FromQuaternionToRef=function(e,t){var i=e.x*e.x,r=e.y*e.y,n=e.z*e.z,o=e.x*e.y,s=e.z*e.w,a=e.z*e.x,l=e.y*e.w,h=e.y*e.z,c=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*(h+c),t.m[7]=0,t.m[8]=2*(a+l),t.m[9]=2*(h-c),t.m[10]=1-2*(r+i),t.m[11]=0,t.m[12]=0,t.m[13]=0,t.m[14]=0,t.m[15]=1,t._markAsUpdated()},e._tempQuaternion=new a,e._xAxis=n.Zero(),e._yAxis=n.Zero(),e._zAxis=n.Zero(),e._updateFlagSeed=0,e._identityReadOnly=e.Identity(),e})();e.Matrix=l;var h=(function(){function e(e,t,i,r){this.normal=new n(e,t,i),this.d=r}return e.prototype.asArray=function(){return[this.normal.x,this.normal.y,this.normal.z,this.d]},e.prototype.clone=function(){return new e(this.normal.x,this.normal.y,this.normal.z,this.d)},e.prototype.getClassName=function(){return"Plane"},e.prototype.getHashCode=function(){var e=this.normal.getHashCode();return e=397*e^(this.d||0)},e.prototype.normalize=function(){var e=Math.sqrt(this.normal.x*this.normal.x+this.normal.y*this.normal.y+this.normal.z*this.normal.z),t=0;return 0!==e&&(t=1/e),this.normal.x*=t,this.normal.y*=t,this.normal.z*=t,this.d*=t,this},e.prototype.transform=function(t){var i=l.Transpose(t),r=this.normal.x,n=this.normal.y,o=this.normal.z,s=this.d;return new e(r*i.m[0]+n*i.m[1]+o*i.m[2]+s*i.m[3],r*i.m[4]+n*i.m[5]+o*i.m[6]+s*i.m[7],r*i.m[8]+n*i.m[9]+o*i.m[10]+s*i.m[11],r*i.m[12]+n*i.m[13]+o*i.m[14]+s*i.m[15])},e.prototype.dotCoordinate=function(e){return this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z+this.d},e.prototype.copyFromPoints=function(e,t,i){var r,n=t.x-e.x,o=t.y-e.y,s=t.z-e.z,a=i.x-e.x,l=i.y-e.y,h=i.z-e.z,c=o*h-s*l,u=s*a-n*h,f=n*l-o*a,p=Math.sqrt(c*c+u*u+f*f);return r=0!==p?1/p:0,this.normal.x=c*r,this.normal.y=u*r,this.normal.z=f*r,this.d=-(this.normal.x*e.x+this.normal.y*e.y+this.normal.z*e.z),this},e.prototype.isFrontFacingTo=function(e,t){return n.Dot(this.normal,e)<=t},e.prototype.signedDistanceTo=function(e){return n.Dot(e,this.normal)+this.d},e.FromArray=function(t){return new e(t[0],t[1],t[2],t[3])},e.FromPoints=function(t,i,r){var n=new e(0,0,0,0);return n.copyFromPoints(t,i,r),n},e.FromPositionAndNormal=function(t,i){var r=new e(0,0,0,0);return i.normalize(),r.normal=i,r.d=-(i.x*t.x+i.y*t.y+i.z*t.z),r},e.SignedDistanceToPlaneFromPositionAndNormal=function(e,t,i){var r=-(t.x*e.x+t.y*e.y+t.z*e.z);return n.Dot(i,t)+r},e})();e.Plane=h;var c=(function(){function e(e,t,i,r){this.x=e,this.y=t,this.width=i,this.height=r}return e.prototype.toGlobal=function(t,i){if(t.getRenderWidth){var r=t;return this.toGlobal(r.getRenderWidth(),r.getRenderHeight())}var n=t;return new e(this.x*n,this.y*i,this.width*n,this.height*i)},e.prototype.clone=function(){return new e(this.x,this.y,this.width,this.height)},e})();e.Viewport=c;var u=(function(){function e(){}return e.GetPlanes=function(t){for(var i=[],r=0;r<6;r++)i.push(new h(0,0,0,0));return e.GetPlanesToRef(t,i),i},e.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()},e.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()},e.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()},e.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()},e.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()},e.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()},e.GetPlanesToRef=function(t,i){e.GetNearPlaneToRef(t,i[0]),e.GetFarPlaneToRef(t,i[1]),e.GetLeftPlaneToRef(t,i[2]),e.GetRightPlaneToRef(t,i[3]),e.GetTopPlaneToRef(t,i[4]),e.GetBottomPlaneToRef(t,i[5])},e})();e.Frustum=u;!(function(e){e[e.LOCAL=0]="LOCAL",e[e.WORLD=1]="WORLD",e[e.BONE=2]="BONE"})(e.Space||(e.Space={}));var f=(function(){function e(){}return e.X=new n(1,0,0),e.Y=new n(0,1,0),e.Z=new n(0,0,1),e})();e.Axis=f;var p=(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,h=0;h<5;h++){var c=l*l;l-=(o*(c*l)+s*c+a*l-e)*(1/(3*o*c+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})();e.BezierCurve=p;var d;!(function(e){e[e.CW=0]="CW",e[e.CCW=1]="CCW"})(d=e.Orientation||(e.Orientation={}));var m=(function(){function e(e){this._radians=e,this._radians<0&&(this._radians+=2*Math.PI)}return e.prototype.degrees=function(){return 180*this._radians/Math.PI},e.prototype.radians=function(){return this._radians},e.BetweenTwoPoints=function(t,i){var r=i.subtract(t);return new e(Math.atan2(r.y,r.x))},e.FromRadians=function(t){return new e(t)},e.FromDegrees=function(t){return new e(t*Math.PI/180)},e})();e.Angle=m;var _=(function(){function e(e,t,i){this.startPoint=e,this.midPoint=t,this.endPoint=i;var n=Math.pow(t.x,2)+Math.pow(t.y,2),o=(Math.pow(e.x,2)+Math.pow(e.y,2)-n)/2,s=(n-Math.pow(i.x,2)-Math.pow(i.y,2))/2,a=(e.x-t.x)*(t.y-i.y)-(t.x-i.x)*(e.y-t.y);this.centerPoint=new r((o*(t.y-i.y)-s*(e.y-t.y))/a,((e.x-t.x)*s-(t.x-i.x)*o)/a),this.radius=this.centerPoint.subtract(this.startPoint).length(),this.startAngle=m.BetweenTwoPoints(this.centerPoint,this.startPoint);var l=this.startAngle.degrees(),h=m.BetweenTwoPoints(this.centerPoint,this.midPoint).degrees(),c=m.BetweenTwoPoints(this.centerPoint,this.endPoint).degrees();h-l>180&&(h-=360),h-l<-180&&(h+=360),c-h>180&&(c-=360),c-h<-180&&(c+=360),this.orientation=h-l<0?d.CW:d.CCW,this.angle=m.FromDegrees(this.orientation===d.CW?l-c:c-l)}return e})();e.Arc2=_;var g=(function(){function e(e,t){this._points=new Array,this._length=0,this.closed=!1,this._points.push(new r(e,t))}return e.prototype.addLineTo=function(e,t){if(this.closed)return this;var i=new r(e,t),n=this._points[this._points.length-1];return this._points.push(i),this._length+=i.subtract(n).length(),this},e.prototype.addArcTo=function(e,t,i,n,o){if(void 0===o&&(o=36),this.closed)return this;var s=this._points[this._points.length-1],a=new r(e,t),l=new r(i,n),h=new _(s,a,l),c=h.angle.radians()/o;h.orientation===d.CW&&(c*=-1);for(var u=h.startAngle.radians()+c,f=0;f<o;f++){var p=Math.cos(u)*h.radius+h.centerPoint.x,m=Math.sin(u)*h.radius+h.centerPoint.y;this.addLineTo(p,m),u+=c}return this},e.prototype.close=function(){return this.closed=!0,this},e.prototype.length=function(){var e=this._length;if(!this.closed){var t=this._points[this._points.length-1];e+=this._points[0].subtract(t).length()}return e},e.prototype.getPoints=function(){return this._points},e.prototype.getPointAtLengthPosition=function(e){if(e<0||e>1)return r.Zero();for(var t=e*this.length(),i=0,n=0;n<this._points.length;n++){var o=(n+1)%this._points.length,s=this._points[n],a=this._points[o],l=a.subtract(s),h=l.length()+i;if(t>=i&&t<=h){var c=l.normalize(),u=t-i;return new r(s.x+c.x*u,s.y+c.y*u)}i=h}return r.Zero()},e.StartingAt=function(t,i){return new e(t,i)},e})();e.Path2=g;var v=(function(){function t(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 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(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},t.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=this._tangents[0],r=this._normalVector(this._curve[0],i,e);this._normals[0]=r,this._raw||this._normals[0].normalize(),this._binormals[0]=n.Cross(i,this._normals[0]),this._raw||this._binormals[0].normalize(),this._distances[0]=0;for(var o,s,a,l,h=1;h<t;h++)o=this._getLastNonNullVector(h),h<t-1&&(s=this._getFirstNonNullVector(h),this._tangents[h]=o.add(s),this._tangents[h].normalize()),this._distances[h]=this._distances[h-1]+o.length(),a=this._tangents[h],l=this._binormals[h-1],this._normals[h]=n.Cross(l,a),this._raw||this._normals[h].normalize(),this._binormals[h]=n.Cross(a,this._normals[h]),this._raw||this._binormals[h].normalize()},t.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},t.prototype._getLastNonNullVector=function(e){for(var t=1,i=this._curve[e].subtract(this._curve[e-t]);0===i.length()&&e>t+1;)t++,i=this._curve[e].subtract(this._curve[e-t]);return i},t.prototype._normalVector=function(t,i,r){var o,s=i.length();if(0===s&&(s=1),void 0===r||null===r){var a;a=e.Scalar.WithinEpsilon(Math.abs(i.y)/s,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(i.x)/s,1,e.Epsilon)?e.Scalar.WithinEpsilon(Math.abs(i.z)/s,1,e.Epsilon)?n.Zero():new n(0,0,1):new n(1,0,0):new n(0,-1,0),o=n.Cross(i,a)}else o=n.Cross(i,r),n.CrossToRef(o,i,o);return o.normalize(),o},t})();e.Path3D=v;var y=(function(){function e(e){this._length=0,this._points=e,this._length=this._computeLength(e)}return e.CreateQuadraticBezier=function(t,i,r,o){o=o>2?o:3;for(var s=new Array,a=function(e,t,i,r){return(1-e)*(1-e)*t+2*e*(1-e)*i+e*e*r},l=0;l<=o;l++)s.push(new n(a(l/o,t.x,i.x,r.x),a(l/o,t.y,i.y,r.y),a(l/o,t.z,i.z,r.z)));return new e(s)},e.CreateCubicBezier=function(t,i,r,o,s){s=s>3?s:4;for(var a=new Array,l=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},h=0;h<=s;h++)a.push(new n(l(h/s,t.x,i.x,r.x,o.x),l(h/s,t.y,i.y,r.y,o.y),l(h/s,t.z,i.z,r.z,o.z)));return new e(a)},e.CreateHermiteSpline=function(t,i,r,o,s){for(var a=new Array,l=1/s,h=0;h<=s;h++)a.push(n.Hermite(t,i,r,o,h*l));return new e(a)},e.CreateCatmullRomSpline=function(t,i){var r=new Array;r.push(t[0].clone()),Array.prototype.push.apply(r,t),r.push(t[t.length-1].clone());for(var o=new Array,s=1/i,a=0,l=0;l<r.length-3;l++){a=0;for(var h=0;h<i;h++)o.push(n.CatmullRom(r[l],r[l+1],r[l+2],r[l+3],a)),a+=s}return l--,o.push(n.CatmullRom(r[l],r[l+1],r[l+2],r[l+3],a)),new e(o)},e.prototype.getPoints=function(){return this._points},e.prototype.length=function(){return this._length},e.prototype.continue=function(t){for(var i=this._points[this._points.length-1],r=this._points.slice(),n=t.getPoints(),o=1;o<n.length;o++)r.push(n[o].subtract(n[0]).add(i));return new e(r)},e.prototype._computeLength=function(e){for(var t=0,i=1;i<e.length;i++)t+=e[i].subtract(e[i-1]).length();return t},e})();e.Curve3=y;var b=(function(){function e(e,t){void 0===e&&(e=n.Zero()),void 0===t&&(t=n.Up()),this.position=e,this.normal=t}return e.prototype.clone=function(){return new e(this.position.clone(),this.normal.clone())},e})();e.PositionNormalVertex=b;var x=(function(){function e(e,t,i){void 0===e&&(e=n.Zero()),void 0===t&&(t=n.Up()),void 0===i&&(i=r.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})();e.PositionNormalTextureVertex=x;var T=(function(){function e(){}return e.Color3=[t.Black(),t.Black(),t.Black()],e.Vector2=[r.Zero(),r.Zero(),r.Zero()],e.Vector3=[n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero()],e.Vector4=[o.Zero(),o.Zero(),o.Zero()],e.Quaternion=[a.Zero(),a.Zero()],e.Matrix=[l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero(),l.Zero()],e})();e.Tmp=T;var E=(function(){function e(){}return e.Vector3=[n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero(),n.Zero()],e.Matrix=[l.Zero(),l.Zero()],e.Quaternion=[a.Zero(),a.Zero(),a.Zero()],e})()})(r||(r={}));var r;!(function(e){var t=(function(){function e(){}return e.WithinEpsilon=function(e,t,i){void 0===i&&(i=1.401298e-45);var r=e-t;return-i<=r&&r<=i},e.ToHex=function(e){var t=e.toString(16);return e<=15?("0"+t).toUpperCase():t.toUpperCase()},e.Sign=function(e){return e=+e,0===e||isNaN(e)?e:e>0?1:-1},e.Clamp=function(e,t,i){return void 0===t&&(t=0),void 0===i&&(i=1),Math.min(i,Math.max(t,e))},e.Log2=function(e){return Math.log(e)*Math.LOG2E},e.Repeat=function(e,t){return e-Math.floor(e/t)*t},e.Normalize=function(e,t,i){return(e-t)/(i-t)},e.Denormalize=function(e,t,i){return e*(i-t)+t},e.DeltaAngle=function(t,i){var r=e.Repeat(i-t,360);return r>180&&(r-=360),r},e.PingPong=function(t,i){var r=e.Repeat(t,2*i);return i-Math.abs(r-i)},e.SmoothStep=function(t,i,r){var n=e.Clamp(r);return n=-2*n*n*n+3*n*n,i*n+t*(1-n)},e.MoveTowards=function(t,i,r){return Math.abs(i-t)<=r?i:t+e.Sign(i-t)*r},e.MoveTowardsAngle=function(t,i,r){var n=e.DeltaAngle(t,i),o=0;return-r<n&&n<r?o=i:(i=t+n,o=e.MoveTowards(t,i,r)),o},e.Lerp=function(e,t,i){return e+(t-e)*i},e.LerpAngle=function(t,i,r){var n=e.Repeat(i-t,360);return n>180&&(n-=360),t+n*e.Clamp(r)},e.InverseLerp=function(t,i,r){return t!=i?e.Clamp((r-t)/(i-t)):0},e.Hermite=function(e,t,i,r,n){var o=n*n,s=n*o;return e*(2*s-3*o+1)+i*(-2*s+3*o)+t*(s-2*o+n)+r*(s-o)},e.RandomRange=function(e,t){return e===t?e:Math.random()*(t-e)+e},e.RangeToPercent=function(e,t,i){return(e-t)/(i-t)},e.PercentToRange=function(e,t,i){return(i-t)*e+t},e.NormalizeRadians=function(t){return t-=e.TwoPi*Math.floor((t+Math.PI)/e.TwoPi)},e.TwoPi=2*Math.PI,e})();e.Scalar=t})(r||(r={}));var r;!(function(e){function t(e){var t=e.getClassName();return v[t]||(v[t]={}),v[t]}function i(e){var t=e.getClassName();if(y[t])return y[t];y[t]={};for(var i=y[t],r=e,n=t;n;){var o=v[n];for(var s in o)i[s]=o[s];var a=void 0,l=!1;do{if(a=Object.getPrototypeOf(r),!a.getClassName){l=!0;break}if(a.getClassName()!==n)break;r=a}while(a);if(l)break;n=a.getClassName(),r=a}return i}function r(e,i){return function(r,n){var o=t(r);o[n]||(o[n]={type:e,sourceName:i})}}function n(e,t){return void 0===t&&(t=null),function(i,r){var n=t||"_"+r;Object.defineProperty(i,r,{get:function(){return this[n]},set:function(t){this[n]!==t&&(this[n]=t,i[e].apply(this))},enumerable:!0,configurable:!0})}}function o(e,t){return void 0===t&&(t=null),n(e,t)}function s(e){return r(0,e)}function a(e){return r(1,e)}function l(e){return r(2,e)}function h(e){return r(3,e)}function c(e){return r(4,e)}function u(e){return r(5,e)}function f(e){return r(6,e)}function p(e){return r(7,e)}function d(e){return r(8,e)}function m(e){return r(9,e)}function _(e){return r(10,e)}function g(e){return r(11,e)}var v={},y={},b=function(t,r,n){var o=t();e.Tags&&e.Tags.AddTagsTo(o,r.tags);var s=i(o);for(var a in s){var l=s[a],h=r[a],c=l.type;if(void 0!==h&&null!==h)switch(c){case 0:case 6:case 11:o[a]=h;break;case 1:o[a]=n||h.isRenderTarget?h:h.clone();break;case 2:case 3:case 4:case 5:case 7:case 10:o[a]=n?h:h.clone()}}return o};e.expandToProperty=o,e.serialize=s,e.serializeAsTexture=a,e.serializeAsColor3=l,e.serializeAsFresnelParameters=h,e.serializeAsVector2=c,e.serializeAsVector3=u,e.serializeAsMeshReference=f,e.serializeAsColorCurves=p,e.serializeAsColor4=d,e.serializeAsImageProcessingConfiguration=m,e.serializeAsQuaternion=_,e.serializeAsCameraReference=g;var x=(function(){function t(){}return t.Serialize=function(t,r){r||(r={}),e.Tags&&(r.tags=e.Tags.GetTags(t));var n=i(t);for(var o in n){var s=n[o],a=s.sourceName||o,l=s.type,h=t[o];if(void 0!==h&&null!==h)switch(l){case 0:r[a]=h;break;case 1:r[a]=h.serialize();break;case 2:r[a]=h.asArray();break;case 3:r[a]=h.serialize();break;case 4:case 5:r[a]=h.asArray();break;case 6:r[a]=h.id;break;case 7:r[a]=h.serialize();break;case 8:r[a]=h.asArray();break;case 9:r[a]=h.serialize();break;case 10:r[a]=h.asArray();break;case 11:r[a]=h.id}}return r},t.Parse=function(t,r,n,o){void 0===o&&(o=null);var s=t();o||(o=""),e.Tags&&e.Tags.AddTagsTo(s,r.tags);var a=i(s);for(var l in a){var h=a[l],c=r[h.sourceName||l],u=h.type;if(void 0!==c&&null!==c){var f=s;switch(u){case 0:f[l]=c;break;case 1:n&&(f[l]=e.Texture.Parse(c,n,o));break;case 2:f[l]=e.Color3.FromArray(c);break;case 3:f[l]=e.FresnelParameters.Parse(c);break;case 4:f[l]=e.Vector2.FromArray(c);break;case 5:f[l]=e.Vector3.FromArray(c);break;case 6:n&&(f[l]=n.getLastMeshByID(c));break;case 7:f[l]=e.ColorCurves.Parse(c);break;case 8:f[l]=e.Color4.FromArray(c);break;case 9:f[l]=e.ImageProcessingConfiguration.Parse(c);break;case 10:f[l]=e.Quaternion.FromArray(c);break;case 11:n&&(f[l]=n.getCameraByID(c))}}}return s},t.Clone=function(e,t){return b(e,t,!1)},t.Instanciate=function(e,t){return b(e,t,!0)},t})();e.SerializationHelper=x})(r||(r={}));var r;!(function(e){var t=(function(){function e(){var e=this;this.promise=new Promise(function(t,i){e._resolve=t,e._reject=i})}return Object.defineProperty(e.prototype,"resolve",{get:function(){return this._resolve},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"reject",{get:function(){return this._reject},enumerable:!0,configurable:!0}),e})();e.Deferred=t})(r||(r={}));var r;!(function(e){var t=(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})();e.EventState=t;var i=(function(){function e(e,t,i){void 0===i&&(i=null),this.callback=e,this.mask=t,this.scope=i,this._willBeUnregistered=!1,this.unregisterOnNextCall=!1}return e})();e.Observer=i;var r=(function(){function e(){}return e.prototype.dispose=function(){if(this._observers&&this._observables)for(var e=0;e<this._observers.length;e++)this._observables[e].remove(this._observers[e]);this._observers=null,this._observables=null},e.Watch=function(t,i,r,n){void 0===r&&(r=-1),void 0===n&&(n=null);var o=new e;o._observers=new Array,o._observables=t;for(var s=0,a=t;s<a.length;s++){var l=a[s],h=l.add(i,r,!1,n);h&&o._observers.push(h)}return o},e})();e.MultiObserver=r;var n=(function(){function r(e){this._observers=new Array,this._eventState=new t(0),e&&(this._onObserverAdded=e)}return r.prototype.add=function(e,t,r,n,o){if(void 0===t&&(t=-1),void 0===r&&(r=!1),void 0===n&&(n=null),void 0===o&&(o=!1),!e)return null;var s=new i(e,t,n);return s.unregisterOnNextCall=o,r?this._observers.unshift(s):this._observers.push(s),this._onObserverAdded&&this._onObserverAdded(s),s},r.prototype.remove=function(e){if(!e)return!1;var t=this._observers.indexOf(e);return-1!==t&&(this._observers.splice(t,1),!0)},r.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._observers.splice(i,1),!0;return!1},r.prototype._deferUnregister=function(t){var i=this;t.unregisterOnNextCall=!1,t._willBeUnregistered=!0,e.Tools.SetImmediate((function(){i.remove(t)}))},r.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},r.prototype.notifyObserversWithPromise=function(e,t,i,r){var n=this;void 0===t&&(t=-1);var o=Promise.resolve(e);if(!this._observers.length)return o;var s=this._eventState;return s.mask=t,s.target=i,s.currentTarget=r,s.skipNextObservers=!1,this._observers.forEach((function(i){s.skipNextObservers||i._willBeUnregistered||i.mask&t&&(o=i.scope?o.then((function(t){return s.lastReturnValue=t,i.callback.apply(i.scope,[e,s])})):o.then((function(t){return s.lastReturnValue=t,i.callback(e,s)})),i.unregisterOnNextCall&&n._deferUnregister(i))})),o.then((function(){return e}))},r.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)},r.prototype.hasObservers=function(){return this._observers.length>0},r.prototype.clear=function(){this._observers=new Array,this._onObserverAdded=null},r.prototype.clone=function(){var e=new r;return e._observers=this._observers.slice(0),e},r.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},r})();e.Observable=n})(r||(r={}));var r;!(function(e){var t=(function(){function e(t){this.length=0,this.data=new Array(t),this._id=e._GlobalId++}return e.prototype.push=function(e){this.data[this.length++]=e,this.length>this.data.length&&(this.data.length*=2)},e.prototype.forEach=function(e){for(var t=0;t<this.length;t++)e(this.data[t])},e.prototype.sort=function(e){this.data.sort(e)},e.prototype.reset=function(){this.length=0},e.prototype.dispose=function(){this.reset(),this.data&&(this.data.length=0,this.data=[])},e.prototype.concat=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++)this.data[this.length++]=(e.data||e)[t]}},e.prototype.indexOf=function(e){var t=this.data.indexOf(e);return t>=this.length?-1:t},e.prototype.contains=function(e){return-1!==this.data.indexOf(e)},e._GlobalId=0,e})();e.SmartArray=t;var i=(function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t._duplicateId=0,t}return o(t,e),t.prototype.push=function(t){e.prototype.push.call(this,t),t.__smartArrayFlags||(t.__smartArrayFlags={}),t.__smartArrayFlags[this._id]=this._duplicateId},t.prototype.pushNoDuplicate=function(e){return(!e.__smartArrayFlags||e.__smartArrayFlags[this._id]!==this._duplicateId)&&(this.push(e),!0)},t.prototype.reset=function(){e.prototype.reset.call(this),this._duplicateId++},t.prototype.concatWithNoDuplicate=function(e){if(0!==e.length){this.length+e.length>this.data.length&&(this.data.length=2*(this.length+e.length));for(var t=0;t<e.length;t++){var i=(e.data||e)[t];this.pushNoDuplicate(i)}}},t})(t);e.SmartArrayNoDuplicate=i})(r||(r={}));var r;!(function(e){function t(e,t){return function(i){i.__bjsclassName__=e,i.__bjsmoduleName__=null!=t?t:null}}var i=(function(e){function t(i,r){var n=e.call(this,i)||this;return n.request=r,n.name="LoadFileError",t._setPrototypeOf(n,t.prototype),n}return o(t,e),t._setPrototypeOf=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},t})(Error);e.LoadFileError=i;var r=(function(){function e(){}return e.ExponentialBackoff=function(e,t){return void 0===e&&(e=3),void 0===t&&(t=500),function(i,r,n){return 0!==r.status||n>=e||-1!==i.indexOf("file:")?-1:Math.pow(2,n)*t}},e})();e.RetryStrategy=r;var n,s=function(t,i){return t?t instanceof e.Mesh?null:t instanceof e.SubMesh?t.clone(i):t.clone?t.clone():null:null},a=(function(){function t(){}return t.Mix=function(e,t,i){return e*(1-i)+t*i},t.Instantiate=function(e){if(t.RegisteredExternalClasses&&t.RegisteredExternalClasses[e])return t.RegisteredExternalClasses[e];for(var i=e.split("."),r=window||this,n=0,o=i.length;n<o;n++)r=r[i[n]];return"function"!=typeof r?null:r},t.Slice=function(e,t,i){return e.slice?e.slice(t,i):Array.prototype.slice.call(e,t,i)},t.SetImmediate=function(e){window.setImmediate?window.setImmediate(e):setTimeout(e,1)},t.IsExponentOfTwo=function(e){var t=1;do{t*=2}while(t<e);return t===e},t.FloatRound=function(e){return Math.fround?Math.fround(e):t._tmpFloatArray[0]=e},t.CeilingPOT=function(e){return e--,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,++e},t.FloorPOT=function(e){return e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,(e|=e>>16)-(e>>1)},t.NearestPOT=function(e){var i=t.CeilingPOT(e),r=t.FloorPOT(e);return i-e>e-r?r:i},t.GetExponentOfTwo=function(i,r,n){void 0===n&&(n=e.Engine.SCALEMODE_NEAREST);var o;switch(n){case e.Engine.SCALEMODE_FLOOR:o=t.FloorPOT(i);break;case e.Engine.SCALEMODE_NEAREST:o=t.NearestPOT(i);break;case e.Engine.SCALEMODE_CEILING:default:o=t.CeilingPOT(i)}return Math.min(o,r)},t.GetFilename=function(e){var t=e.lastIndexOf("/");return t<0?e:e.substring(t+1)},t.GetFolderPath=function(e,t){void 0===t&&(t=!1);var i=e.lastIndexOf("/");return i<0?t?e:"":e.substring(0,i+1)},t.GetDOMTextContent=function(e){for(var t="",i=e.firstChild;i;)3===i.nodeType&&(t+=i.textContent),i=i.nextSibling;return t},t.ToDegrees=function(e){return 180*e/Math.PI},t.ToRadians=function(e){return e*Math.PI/180},t.EncodeArrayBufferTobase64=function(e){for(var t,i,r,n,o,s,a,l="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h="",c=0,u=new Uint8Array(e);c<u.length;)t=u[c++],i=c<u.length?u[c++]:Number.NaN,r=c<u.length?u[c++]:Number.NaN,n=t>>2,o=(3&t)<<4|i>>4,s=(15&i)<<2|r>>6,a=63&r,isNaN(i)?s=a=64:isNaN(r)&&(a=64),h+=l.charAt(n)+l.charAt(o)+l.charAt(s)+l.charAt(a);return"data:image/png;base64,"+h},t.ExtractMinAndMaxIndexed=function(t,i,r,n,o){void 0===o&&(o=null);for(var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE),l=r;l<r+n;l++){var h=new e.Vector3(t[3*i[l]],t[3*i[l]+1],t[3*i[l]+2]);s=e.Vector3.Minimize(h,s),a=e.Vector3.Maximize(h,a)}return o&&(s.x-=s.x*o.x+o.y,s.y-=s.y*o.x+o.y,s.z-=s.z*o.x+o.y,a.x+=a.x*o.x+o.y,a.y+=a.y*o.x+o.y,a.z+=a.z*o.x+o.y),{minimum:s,maximum:a}},t.ExtractMinAndMax=function(t,i,r,n,o){void 0===n&&(n=null);var s=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),a=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);o||(o=3);for(var l=i;l<i+r;l++){var h=new e.Vector3(t[l*o],t[l*o+1],t[l*o+2]);s=e.Vector3.Minimize(h,s),a=e.Vector3.Maximize(h,a)}return n&&(s.x-=s.x*n.x+n.y,s.y-=s.y*n.x+n.y,s.z-=s.z*n.x+n.y,a.x+=a.x*n.x+n.y,a.y+=a.y*n.x+n.y,a.z+=a.z*n.x+n.y),{minimum:s,maximum:a}},t.Vector2ArrayFeeder=function(t){return function(i){var r=void 0!==t.BYTES_PER_ELEMENT;if(i>=(r?t.length/2:t.length))return null;if(r){var n=t;return new e.Vector2(n[2*i+0],n[2*i+1])}return t[i]}},t.ExtractMinAndMaxVector2=function(t,i){void 0===i&&(i=null);for(var r=new e.Vector2(Number.MAX_VALUE,Number.MAX_VALUE),n=new e.Vector2(-Number.MAX_VALUE,-Number.MAX_VALUE),o=0,s=t(o++);s;)r=e.Vector2.Minimize(s,r),n=e.Vector2.Maximize(s,n),s=t(o++);return i&&(r.x-=r.x*i.x+i.y,r.y-=r.y*i.x+i.y,n.x+=n.x*i.x+i.y,n.y+=n.y*i.x+i.y),{minimum:r,maximum:n}},t.MakeArray=function(e,t){return!0===t||void 0!==e&&null!=e?Array.isArray(e)?e:[e]:null},t.GetPointerPrefix=function(){var e="pointer";return!t.IsWindowObjectExist()||window.PointerEvent||navigator.pointerEnabled||(e="mouse"),e},t.QueueNewFrame=function(e,i){return t.IsWindowObjectExist()?(i||(i=window),
i.requestAnimationFrame?i.requestAnimationFrame(e):i.msRequestAnimationFrame?i.msRequestAnimationFrame(e):i.webkitRequestAnimationFrame?i.webkitRequestAnimationFrame(e):i.mozRequestAnimationFrame?i.mozRequestAnimationFrame(e):i.oRequestAnimationFrame?i.oRequestAnimationFrame(e):window.setTimeout(e,16)):setTimeout(e,16)},t.RequestFullscreen=function(e){var t=e.requestFullscreen||e.msRequestFullscreen||e.webkitRequestFullscreen||e.mozRequestFullScreen;t&&t.call(e)},t.ExitFullscreen=function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msCancelFullScreen&&document.msCancelFullScreen()},t.SetCorsBehavior=function(e,i){if((!e||0!==e.indexOf("data:"))&&t.CorsBehavior)if("string"==typeof t.CorsBehavior||t.CorsBehavior instanceof String)i.crossOrigin=t.CorsBehavior;else{var r=t.CorsBehavior(e);r&&(i.crossOrigin=r)}},t.CleanUrl=function(e){return e=e.replace(/#/gm,"%23")},t.LoadImage=function(i,r,n,o){i instanceof ArrayBuffer&&(i=t.EncodeArrayBufferTobase64(i)),i=t.CleanUrl(i),i=t.PreprocessUrl(i);var s=new Image;t.SetCorsBehavior(i,s);var a=function(){s.removeEventListener("load",a),s.removeEventListener("error",l),r(s)},l=function(e){s.removeEventListener("load",a),s.removeEventListener("error",l),t.Error("Error while trying to load image: "+i),n&&n("Error while trying to load image: "+i,e)};s.addEventListener("load",a),s.addEventListener("error",l);var h=function(){s.src=i},c=function(){o&&o.loadImageFromDB(i,s)};if("data:"!==i.substr(0,5)&&o&&o.enableTexturesOffline&&e.Database.IsUASupportingBlobStorage)o.openAsync(c,h);else{if(-1!==i.indexOf("file:")){var u=decodeURIComponent(i.substring(5).toLowerCase());if(e.FilesInput.FilesToLoad[u]){try{var f;try{f=URL.createObjectURL(e.FilesInput.FilesToLoad[u],{oneTimeOnly:!0})}catch(t){f=URL.createObjectURL(e.FilesInput.FilesToLoad[u])}s.src=f}catch(e){s.src=""}return s}}h()}return s},t.LoadFile=function(r,n,o,s,a,l){if(r=t.CleanUrl(r),r=t.PreprocessUrl(r),-1!==r.indexOf("file:")){var h=decodeURIComponent(r.substring(5).toLowerCase());if(e.FilesInput.FilesToLoad[h])return t.ReadFile(e.FilesInput.FilesToLoad[h],n,o,a)}var c=t.BaseUrl+r,u=!1,f={onCompleteObservable:new e.Observable,abort:function(){return u=!0}},p=function(){var e=new XMLHttpRequest,r=null;f.abort=function(){u=!0,e.readyState!==(XMLHttpRequest.DONE||4)&&e.abort(),null!==r&&(clearTimeout(r),r=null)};var s=function(h){e.open("GET",c,!0),a&&(e.responseType="arraybuffer"),o&&e.addEventListener("progress",o);var p=function(){e.removeEventListener("loadend",p),f.onCompleteObservable.notifyObservers(f),f.onCompleteObservable.clear()};e.addEventListener("loadend",p);var d=function(){if(!u&&e.readyState===(XMLHttpRequest.DONE||4)){if(e.removeEventListener("readystatechange",d),e.status>=200&&e.status<300||!t.IsWindowObjectExist()&&0===e.status)return void n(a?e.response:e.responseText,e.responseURL);var o=t.DefaultRetryStrategy;if(o){var f=o(c,e,h);if(-1!==f)return e.removeEventListener("loadend",p),e=new XMLHttpRequest,void(r=setTimeout((function(){return s(h+1)}),f))}var m=new i("Error status: "+e.status+" "+e.statusText+" - Unable to load "+c,e);if(!l)throw m;l(e,m)}};e.addEventListener("readystatechange",d),e.send()};s(0)};if(s&&s.enableSceneOffline){var d=function(){u||p()},m=function(){u||s&&s.loadFileFromDB(r,(function(e){u||n(e),f.onCompleteObservable.notifyObservers(f)}),o?function(e){u||o(e)}:void 0,d,a)};s.openAsync(m,d)}else p();return f},t.LoadScript=function(e,t,i){var r=document.getElementsByTagName("head")[0],n=document.createElement("script");n.type="text/javascript",n.src=e,n.onload=function(){t&&t()},n.onerror=function(t){i&&i("Unable to load script '"+e+"'",t)},r.appendChild(n)},t.ReadFileAsDataURL=function(t,i,r){var n=new FileReader,o={onCompleteObservable:new e.Observable,abort:function(){return n.abort()}};return n.onloadend=function(e){o.onCompleteObservable.notifyObservers(o)},n.onload=function(e){i(e.target.result)},n.onprogress=r,n.readAsDataURL(t),o},t.ReadFile=function(i,r,n,o){var s=new FileReader,a={onCompleteObservable:new e.Observable,abort:function(){return s.abort()}};return s.onloadend=function(e){return a.onCompleteObservable.notifyObservers(a)},s.onerror=function(e){t.Log("Error while reading file: "+i.name),r(JSON.stringify({autoClear:!0,clearColor:[1,0,0],ambientColor:[0,0,0],gravity:[0,-9.807,0],meshes:[],cameras:[],lights:[]}))},s.onload=function(e){r(e.target.result)},n&&(s.onprogress=n),o?s.readAsArrayBuffer(i):s.readAsText(i),a},t.FileAsURL=function(e){var t=new Blob([e]);return(window.URL||window.webkitURL).createObjectURL(t)},t.Format=function(e,t){return void 0===t&&(t=2),e.toFixed(t)},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)},t.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],a=typeof o;if("function"!==a)try{if("object"===a)if(o instanceof Array){if(t[n]=[],o.length>0)if("object"==typeof o[0])for(var l=0;l<o.length;l++){var h=s(o[l],t);-1===t[n].indexOf(h)&&t[n].push(h)}else t[n]=o.slice(0)}else t[n]=s(o,t);else t[n]=o}catch(e){}}},t.IsEmpty=function(e){for(var t in e)if(e.hasOwnProperty(t))return!1;return!0},t.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){}}},t.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){}}},t.DumpFramebuffer=function(e,i,r,o,s,a){void 0===s&&(s="image/png");for(var l=4*e,h=i/2,c=r.readPixels(0,0,e,i),u=0;u<h;u++)for(var f=0;f<l;f++){var p=f+u*l,d=i-u-1,m=f+d*l,_=c[p];c[p]=c[m],c[m]=_}n||(n=document.createElement("canvas")),n.width=e,n.height=i;var g=n.getContext("2d");if(g){var v=g.createImageData(e,i);v.data.set(c),g.putImageData(v,0,0),t.EncodeScreenshotCanvasData(o,s,a)}},t.EncodeScreenshotCanvasData=function(e,t,i){void 0===t&&(t="image/png");var r=n.toDataURL(t);e?e(r):(n.toBlob||(n.toBlob=function(e,t,i){var r=this;setTimeout((function(){for(var n=atob(r.toDataURL(t,i).split(",")[1]),o=n.length,s=new Uint8Array(o),a=0;a<o;a++)s[a]=n.charCodeAt(a);e(new Blob([s],{type:t||"image/png"}))}))}),n.toBlob((function(e){var t=URL.createObjectURL(e);if("download"in document.createElement("a")){var r=window.document.createElement("a");if(r.href=t,i)r.setAttribute("download",i);else{var n=new Date,o=(n.getFullYear()+"-"+(n.getMonth()+1)).slice(-2)+"-"+n.getDate()+"_"+n.getHours()+"-"+("0"+n.getMinutes()).slice(-2);r.setAttribute("download","screenshot_"+o+".png")}window.document.body.appendChild(r),r.addEventListener("click",(function(){r.parentElement&&r.parentElement.removeChild(r)})),r.click()}else{var s=window.open("");if(!s)return;var a=s.document.createElement("img");a.onload=function(){URL.revokeObjectURL(t)},a.src=t,s.document.body.appendChild(a)}})))},t.CreateScreenshot=function(e,i,r,o,s){void 0===s&&(s="image/png");var a,l;if(r.precision)a=Math.round(e.getRenderWidth()*r.precision),l=Math.round(a/e.getAspectRatio(i));else if(r.width&&r.height)a=r.width,l=r.height;else if(r.width&&!r.height)a=r.width,l=Math.round(a/e.getAspectRatio(i));else if(r.height&&!r.width)l=r.height,a=Math.round(l*e.getAspectRatio(i));else{if(isNaN(r))return void t.Error("Invalid 'size' parameter !");l=r,a=r}n||(n=document.createElement("canvas")),n.width=a,n.height=l;var h=n.getContext("2d"),c=e.getRenderWidth()/e.getRenderHeight(),u=a,f=u/c;f>l&&(f=l,u=f*c);var p=Math.max(0,a-u)/2,d=Math.max(0,l-f)/2,m=e.getRenderingCanvas();h&&m&&h.drawImage(m,p,d,u,f),t.EncodeScreenshotCanvasData(o,s)},t.CreateScreenshotUsingRenderTarget=function(i,r,n,o,s,a,l,h){void 0===s&&(s="image/png"),void 0===a&&(a=1),void 0===l&&(l=!1);var c,u;if(n.precision)c=Math.round(i.getRenderWidth()*n.precision),u=Math.round(c/i.getAspectRatio(r)),n={width:c,height:u};else if(n.width&&n.height)c=n.width,u=n.height;else if(n.width&&!n.height)c=n.width,u=Math.round(c/i.getAspectRatio(r)),n={width:c,height:u};else if(n.height&&!n.width)u=n.height,c=Math.round(u*i.getAspectRatio(r)),n={width:c,height:u};else{if(isNaN(n))return void t.Error("Invalid 'size' parameter !");u=n,c=n}var f=r.getScene(),p=null;f.activeCamera!==r&&(p=f.activeCamera,f.activeCamera=r);var d=new e.RenderTargetTexture("screenShot",n,f,!1,!1,e.Engine.TEXTURETYPE_UNSIGNED_INT,!1,e.Texture.NEAREST_SAMPLINGMODE);d.renderList=null,d.samples=a,l&&d.addPostProcess(new e.FxaaPostProcess("antialiasing",1,f.activeCamera)),d.onAfterRenderObservable.add((function(){t.DumpFramebuffer(c,u,i,o,s,h)})),f.incrementRenderId(),f.resetCachedMaterial(),d.render(!0),d.dispose(),p&&(f.activeCamera=p),r.getProjectionMatrix(!0)},t.ValidateXHRData=function(t,i){void 0===i&&(i=7);try{if(1&i){if(t.responseText&&t.responseText.length>0)return!0;if(1===i)return!1}if(2&i){var r=e.TGATools.GetTGAHeader(t.response);if(r.width&&r.height&&r.width>0&&r.height>0)return!0;if(2===i)return!1}if(4&i){var n=new Uint8Array(t.response,0,3);return 68===n[0]&&68===n[1]&&83===n[2]}}catch(e){}return!1},t.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)}))},t.IsBase64=function(e){return!(e.length<5)&&"data:"===e.substr(0,5)},t.DecodeBase64=function(e){for(var t=atob(e.split(",")[1]),i=t.length,r=new Uint8Array(new ArrayBuffer(i)),n=0;n<i;n++)r[n]=t.charCodeAt(n);return r.buffer},Object.defineProperty(t,"NoneLogLevel",{get:function(){return t._NoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MessageLogLevel",{get:function(){return t._MessageLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WarningLogLevel",{get:function(){return t._WarningLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ErrorLogLevel",{get:function(){return t._ErrorLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AllLogLevel",{get:function(){return t._MessageLogLevel|t._WarningLogLevel|t._ErrorLogLevel},enumerable:!0,configurable:!0}),t._AddLogEntry=function(e){t._LogCache=e+t._LogCache,t.OnNewCacheEntry&&t.OnNewCacheEntry(e)},t._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},t._LogDisabled=function(e){},t._LogEnabled=function(e){var i=t._FormatMessage(e);console.log("BJS - "+i);var r="<div style='color:white'>"+i+"</div><br>";t._AddLogEntry(r)},t._WarnDisabled=function(e){},t._WarnEnabled=function(e){var i=t._FormatMessage(e);console.warn("BJS - "+i);var r="<div style='color:orange'>"+i+"</div><br>";t._AddLogEntry(r)},t._ErrorDisabled=function(e){},t._ErrorEnabled=function(e){t.errorsCount++;var i=t._FormatMessage(e);console.error("BJS - "+i);var r="<div style='color:red'>"+i+"</div><br>";t._AddLogEntry(r)},Object.defineProperty(t,"LogCache",{get:function(){return t._LogCache},enumerable:!0,configurable:!0}),t.ClearLogCache=function(){t._LogCache="",t.errorsCount=0},Object.defineProperty(t,"LogLevels",{set:function(e){(e&t.MessageLogLevel)===t.MessageLogLevel?t.Log=t._LogEnabled:t.Log=t._LogDisabled,(e&t.WarningLogLevel)===t.WarningLogLevel?t.Warn=t._WarnEnabled:t.Warn=t._WarnDisabled,(e&t.ErrorLogLevel)===t.ErrorLogLevel?t.Error=t._ErrorEnabled:t.Error=t._ErrorDisabled},enumerable:!0,configurable:!0}),t.IsWindowObjectExist=function(){return"undefined"!=typeof window},Object.defineProperty(t,"PerformanceNoneLogLevel",{get:function(){return t._PerformanceNoneLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceUserMarkLogLevel",{get:function(){return t._PerformanceUserMarkLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceConsoleLogLevel",{get:function(){return t._PerformanceConsoleLogLevel},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PerformanceLogLevel",{set:function(e){return(e&t.PerformanceUserMarkLogLevel)===t.PerformanceUserMarkLogLevel?(t.StartPerformanceCounter=t._StartUserMark,void(t.EndPerformanceCounter=t._EndUserMark)):(e&t.PerformanceConsoleLogLevel)===t.PerformanceConsoleLogLevel?(t.StartPerformanceCounter=t._StartPerformanceConsole,void(t.EndPerformanceCounter=t._EndPerformanceConsole)):(t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,void(t.EndPerformanceCounter=t._EndPerformanceCounterDisabled))},enumerable:!0,configurable:!0}),t._StartPerformanceCounterDisabled=function(e,t){},t._EndPerformanceCounterDisabled=function(e,t){},t._StartUserMark=function(e,i){if(void 0===i&&(i=!0),!t._performance){if(!t.IsWindowObjectExist())return;t._performance=window.performance}i&&t._performance.mark&&t._performance.mark(e+"-Begin")},t._EndUserMark=function(e,i){void 0===i&&(i=!0),i&&t._performance.mark&&(t._performance.mark(e+"-End"),t._performance.measure(e,e+"-Begin",e+"-End"))},t._StartPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._StartUserMark(e,i),console.time&&console.time(e))},t._EndPerformanceConsole=function(e,i){void 0===i&&(i=!0),i&&(t._EndUserMark(e,i),console.time&&console.timeEnd(e))},Object.defineProperty(t,"Now",{get:function(){return t.IsWindowObjectExist()&&window.performance&&window.performance.now?window.performance.now():Date.now()},enumerable:!0,configurable:!0}),t.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},t.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},t.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},t.arrayOrStringFeeder=function(e){return function(i){if(i>=e.length)return null;var r=e.charCodeAt?e.charCodeAt(i):e[i];return r&&r.getHashCode&&(r=r.getHashCode()),"string"==typeof r?t.hashCodeFromStream(t.arrayOrStringFeeder(r)):r}},t.hashCodeFromStream=function(e){for(var t=0,i=0,r=e(i++);null!=r;)t=(t<<5)-t+r,t|=0,r=e(i++);return t},t.DelayAsync=function(e){return new Promise(function(t){setTimeout((function(){t()}),e)})},t.BaseUrl="",t.DefaultRetryStrategy=r.ExponentialBackoff(),t.CorsBehavior="anonymous",t.UseFallbackTexture=!0,t.RegisteredExternalClasses={},t.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",t._tmpFloatArray=new Float32Array(1),t.PreprocessUrl=function(e){return e},t._NoneLogLevel=0,t._MessageLogLevel=1,t._WarningLogLevel=2,t._ErrorLogLevel=4,t._LogCache="",t.errorsCount=0,t.Log=t._LogEnabled,t.Warn=t._WarnEnabled,t.Error=t._ErrorEnabled,t._PerformanceNoneLogLevel=0,t._PerformanceUserMarkLogLevel=1,t._PerformanceConsoleLogLevel=2,t.StartPerformanceCounter=t._StartPerformanceCounterDisabled,t.EndPerformanceCounter=t._EndPerformanceCounterDisabled,t})();e.Tools=a;var l=(function(){function e(){this._startMonitoringTime=0,this._min=0,this._max=0,this._average=0,this._lastSecAverage=0,this._current=0,this._totalValueCount=0,this._totalAccumulated=0,this._lastSecAccumulated=0,this._lastSecTime=0,this._lastSecValueCount=0}return Object.defineProperty(e.prototype,"min",{get:function(){return this._min},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"max",{get:function(){return this._max},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"average",{get:function(){return this._average},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"lastSecAverage",{get:function(){return this._lastSecAverage},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"current",{get:function(){return this._current},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"total",{get:function(){return this._totalAccumulated},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"count",{get:function(){return this._totalValueCount},enumerable:!0,configurable:!0}),e.prototype.fetchNewFrame=function(){this._totalValueCount++,this._current=0,this._lastSecValueCount++},e.prototype.addCount=function(t,i){e.Enabled&&(this._current+=t,i&&this._fetchResult())},e.prototype.beginMonitoring=function(){e.Enabled&&(this._startMonitoringTime=a.Now)},e.prototype.endMonitoring=function(t){if(void 0===t&&(t=!0),e.Enabled){t&&this.fetchNewFrame();var i=a.Now;this._current=i-this._startMonitoringTime,t&&this._fetchResult()}},e.prototype._fetchResult=function(){this._totalAccumulated+=this._current,this._lastSecAccumulated+=this._current,this._min=Math.min(this._min,this._current),this._max=Math.max(this._max,this._current),this._average=this._totalAccumulated/this._totalValueCount;var e=a.Now;e-this._lastSecTime>1e3&&(this._lastSecAverage=this._lastSecAccumulated/this._lastSecValueCount,this._lastSecTime=e,this._lastSecAccumulated=0,this._lastSecValueCount=0)},e.Enabled=!0,e})();e.PerfCounter=l,e.className=t;var h=(function(){function e(e,t,i,r){void 0===r&&(r=0),this.iterations=e,this._fn=t,this._successCallback=i,this.index=r-1,this._done=!1}return e.prototype.executeNext=function(){this._done||(this.index+1<this.iterations?(++this.index,this._fn(this)):this.breakLoop())},e.prototype.breakLoop=function(){this._done=!0,this._successCallback()},e.Run=function(t,i,r,n){void 0===n&&(n=0);var o=new e(t,i,r,n);return o.executeNext(),o},e.SyncAsyncForLoop=function(t,i,r,n,o,s){void 0===s&&(s=0),e.Run(Math.ceil(t/i),(function(e){o&&o()?e.breakLoop():setTimeout((function(){for(var n=0;n<i;++n){var s=e.index*i+n;if(s>=t)break;if(r(s),o&&o()){e.breakLoop();break}}e.executeNext()}),s)}),n)},e})();e.AsyncLoop=h})(r||(r={}));var r;!(function(e){var t;!(function(e){e[e.Pending=0]="Pending",e[e.Fulfilled=1]="Fulfilled",e[e.Rejected=2]="Rejected"})(t||(t={}));var i=(function(){function e(){this.count=0,this.target=0,this.results=[]}return e})(),r=(function(){function r(e){var i=this;if(this._state=t.Pending,this._children=new Array,this._rejectWasConsumed=!1,e)try{e((function(e){i._resolve(e)}),(function(e){i._reject(e)}))}catch(e){this._reject(e)}}return Object.defineProperty(r.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}),r.prototype.catch=function(e){return this.then(void 0,e)},r.prototype.then=function(i,n){var o=this,s=new r;return s._onFulfilled=i,s._onRejected=n,this._children.push(s),s._parent=this,this._state!==t.Pending&&e.Tools.SetImmediate((function(){if(o._state===t.Fulfilled||o._rejectWasConsumed){var e=s._resolve(o._result);if(void 0!==e&&null!==e)if(void 0!==e._state){var i=e;s._children.push(i),i._parent=s,s=i}else s._result=e}else s._reject(o._reason)})),s},r.prototype._moveChildren=function(e){var i=this;if((l=this._children).push.apply(l,e.splice(0,e.length)),this._children.forEach((function(e){e._parent=i})),this._state===t.Fulfilled)for(var r=0,n=this._children;r<n.length;r++){var o=n[r];o._resolve(this._result)}else if(this._state===t.Rejected)for(var s=0,a=this._children;s<a.length;s++){var o=a[s];o._reject(this._reason)}var l},r.prototype._resolve=function(e){try{this._state=t.Fulfilled;var i=null;if(this._onFulfilled&&(i=this._onFulfilled(e)),void 0!==i&&null!==i)if(void 0!==i._state){var r=i;r._parent=this,r._moveChildren(this._children),e=r._result}else e=i;this._result=e;for(var n=0,o=this._children;n<o.length;n++){o[n]._resolve(e)}this._children.length=0,delete this._onFulfilled,delete this._onRejected}catch(e){this._reject(e,!0)}},r.prototype._reject=function(e,i){if(void 0===i&&(i=!1),this._state=t.Rejected,this._reason=e,this._onRejected&&!i)try{this._onRejected(e),this._rejectWasConsumed=!0}catch(t){e=t}for(var r=0,n=this._children;r<n.length;r++){var o=n[r];this._rejectWasConsumed?o._resolve(null):o._reject(e)}this._children.length=0,delete this._onFulfilled,delete this._onRejected},r.resolve=function(e){var t=new r;return t._resolve(e),t},r._RegisterForFulfillment=function(e,i,r){e.then((function(e){return i.results[r]=e,i.count++,i.count===i.target&&i.rootPromise._resolve(i.results),null}),(function(e){i.rootPromise._state!==t.Rejected&&i.rootPromise._reject(e)}))},r.all=function(e){var t=new r,n=new i;if(n.target=e.length,n.rootPromise=t,e.length)for(var o=0;o<e.length;o++)r._RegisterForFulfillment(e[o],n,o);else t._resolve([]);return t},r.race=function(e){var t=new r;if(e.length)for(var i=0,n=e;i<n.length;i++){var o=n[i];o.then((function(e){return t&&(t._resolve(e),t=null),null}),(function(e){t&&(t._reject(e),t=null)}))}return t},r})(),n=(function(){function e(){}return e.Apply=function(e){if(void 0===e&&(e=!1),e||"undefined"==typeof Promise){window.Promise=r}},e})();e.PromisePolyfill=n})(r||(r={}));var r;!(function(e){var t=(function(){function e(e){this._pendingActions=new Array,this._workerInfos=e.map((function(e){return{worker:e,active:!1}}))}return e.prototype.dispose=function(){for(var e=0,t=this._workerInfos;e<t.length;e++){t[e].worker.terminate()}delete this._workerInfos,delete this._pendingActions},e.prototype.push=function(e){for(var t=0,i=this._workerInfos;t<i.length;t++){var r=i[t];if(!r.active)return void this._execute(r,e)}this._pendingActions.push(e)},e.prototype._execute=function(e,t){var i=this;e.active=!0,t(e.worker,(function(){e.active=!1;var t=i._pendingActions.shift();t&&i._execute(e,t)}))},e})();e.WorkerPool=t})(r||(r={}));var r;!(function(e){var t=(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._isBlendEquationParametersDirty[0],this._isBlendEquationParametersDirty[1]),this._isBlendEquationParametersDirty=!1),this._isBlendConstantsDirty&&(e.blendColor(this._blendConstants[0],this._blendConstants[1],this._blendConstants[2],this._blendConstants[3]),this._isBlendConstantsDirty=!1))},e})();e._AlphaState=t})(r||(r={}));var r;!(function(e){var t=(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})();e._DepthCullingState=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this._isStencilTestDirty=!1,this._isStencilMaskDirty=!1,this._isStencilFuncDirty=!1,this._isStencilOpDirty=!1,this.reset()}return Object.defineProperty(t.prototype,"isDirty",{get:function(){return this._isStencilTestDirty||this._isStencilMaskDirty||this._isStencilFuncDirty||this._isStencilOpDirty},enumerable:!0,configurable:!0}),Object.defineProperty(t.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(t.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(t.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(t.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(t.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(t.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(t.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(t.prototype,"stencilTest",{get:function(){return this._stencilTest},set:function(e){this._stencilTest!==e&&(this._stencilTest=e,this._isStencilTestDirty=!0)},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._stencilTest=!1,this._stencilMask=255,this._stencilFunc=e.Engine.ALWAYS,this._stencilFuncRef=1,this._stencilFuncMask=255,this._stencilOpStencilFail=e.Engine.KEEP,this._stencilOpDepthFail=e.Engine.KEEP,this._stencilOpStencilDepthPass=e.Engine.REPLACE,this._isStencilTestDirty=!0,this._isStencilMaskDirty=!0,this._isStencilFuncDirty=!0,this._isStencilOpDirty=!0},t.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))},t})();e._StencilState=t})(r||(r={}));var r,s=this&&this.__assign||Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e};!(function(e){var t=function(e,t,r,n,o){return i(e,o+(n?n+"\n":"")+t,r)},i=function(e,t,i){var r=e.createShader("vertex"===i?e.VERTEX_SHADER:e.FRAGMENT_SHADER);if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){var n=e.getShaderInfoLog(r);if(n)throw new Error(n)}if(!r)throw new Error("Something went wrong while compile the shader.");return r},r=function(t,i,r){var n=r.NEAREST,o=r.NEAREST;switch(t){case e.Texture.BILINEAR_SAMPLINGMODE:n=r.LINEAR,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case e.Texture.TRILINEAR_SAMPLINGMODE:n=r.LINEAR,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case e.Texture.NEAREST_SAMPLINGMODE:n=r.NEAREST,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case e.Texture.NEAREST_NEAREST_MIPNEAREST:n=r.NEAREST,o=i?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case e.Texture.NEAREST_LINEAR_MIPNEAREST:n=r.NEAREST,o=i?r.LINEAR_MIPMAP_NEAREST:r.LINEAR;break;case e.Texture.NEAREST_LINEAR_MIPLINEAR:n=r.NEAREST,o=i?r.LINEAR_MIPMAP_LINEAR:r.LINEAR;break;case e.Texture.NEAREST_LINEAR:n=r.NEAREST,o=r.LINEAR;break;case e.Texture.NEAREST_NEAREST:n=r.NEAREST,o=r.NEAREST;break;case e.Texture.LINEAR_NEAREST_MIPNEAREST:n=r.LINEAR,o=i?r.NEAREST_MIPMAP_NEAREST:r.NEAREST;break;case e.Texture.LINEAR_NEAREST_MIPLINEAR:n=r.LINEAR,o=i?r.NEAREST_MIPMAP_LINEAR:r.NEAREST;break;case e.Texture.LINEAR_LINEAR:n=r.LINEAR,o=r.LINEAR;break;case e.Texture.LINEAR_NEAREST:n=r.LINEAR,o=r.NEAREST}return{min:o,mag:n}},n=function(t,i,r,n,o,s){void 0===s&&(s=null);var a,l=function(){r[i]=a,r._internalCount++,n&&n._removePendingData(a),6===r._internalCount&&o(r)},h=function(e,t){n&&n._removePendingData(a),s&&s(e,t)};a=e.Tools.LoadImage(t,l,h,n?n.database:null),n&&n._addPendingData(a)},o=function(e,t,i,r,o){void 0===o&&(o=null);var s=[];s._internalCount=0;for(var a=0;a<6;a++)n(r[a],a,s,t,i,o)},a=(function(){function e(){}return e})(),l=(function(){function e(){}return e})();e.InstancingAttributeInfo=l;var h=(function(){function e(){}return e})();e.RenderTargetCreationOptions=h;var c=(function(){function e(){}return e})();e.DepthTextureCreationOptions=c;var u=(function(){function e(){}return e})();e.EngineCapabilities=u;var f=(function(){function n(t,i,r,o){void 0===o&&(o=!1);var s=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.onResizeObservable=new e.Observable,this.onCanvasBlurObservable=new e.Observable,this.onCanvasFocusObservable=new e.Observable,this.onCanvasPointerOutObservable=new e.Observable,this.onBeforeTextureInitObservable=new e.Observable,this._vrDisplay=void 0,this._vrSupported=!1,this._vrExclusivePointerMode=!1,this.disableUniformBuffers=!1,this._uniformBuffers=new Array,this.onBeginFrameObservable=new e.Observable,this.onEndFrameObservable=new e.Observable,this.onBeforeShaderCompilationObservable=new e.Observable,this.onAfterShaderCompilationObservable=new e.Observable,this._windowIsBackground=!1,this._webGLVersion=1,this._badOS=!1,this._badDesktopOS=!1,this.disableTextureBindingOptimization=!1,this.onVRDisplayChangedObservable=new e.Observable,this.onVRRequestPresentComplete=new e.Observable,this.onVRRequestPresentStart=new e.Observable,this._colorWrite=!0,this._drawCalls=new e.PerfCounter,this._textureCollisions=new e.PerfCounter,this._renderingQueueLaunched=!1,this._activeRenderLoops=new Array,this._deterministicLockstep=!1,this._lockstepMaxSteps=4,this.onContextLostObservable=new e.Observable,this.onContextRestoredObservable=new e.Observable,this._contextWasLost=!1,this._doNotHandleContextLost=!1,this._performanceMonitor=new e.PerformanceMonitor,this._fps=60,this._deltaTime=0,this.disablePerformanceMonitorInBackground=!1,this._depthCullingState=new e._DepthCullingState,this._stencilState=new e._StencilState,this._alphaState=new e._AlphaState,this._alphaMode=n.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._currentBufferPointers=new Array,this._currentInstanceLocations=new Array,this._currentInstanceBuffers=new Array,this._firstBoundInternalTextureTracker=new e.DummyInternalTextureTracker,this._lastBoundInternalTextureTracker=new e.DummyInternalTextureTracker,this._vaoRecordInProgress=!1,this._mustWipeVertexAttributes=!1,this._nextFreeTextureSlots=new Array,this._maxSimultaneousTextures=0,this._activeRequests=new Array,this._texturesSupported=new Array,this._onVRFullScreenTriggered=function(){if(s._vrDisplay&&s._vrDisplay.isPresenting){s._oldSize=new e.Size(s.getRenderWidth(),s.getRenderHeight()),s._oldHardwareScaleFactor=s.getHardwareScalingLevel();var t=s._vrDisplay.getEyeParameters("left");s.setHardwareScalingLevel(1),s.setSize(2*t.renderWidth,t.renderHeight)}else s.setHardwareScalingLevel(s._oldHardwareScaleFactor),s.setSize(s._oldSize.width,s._oldSize.height)},this._boundUniforms={},e.PromisePolyfill.Apply();var l=null;if(n.Instances.push(this),t){if(r=r||{},t.getContext){if(l=t,this._renderingCanvas=l,null!=i&&(r.antialias=i),void 0===r.deterministicLockstep&&(r.deterministicLockstep=!1),void 0===r.lockstepMaxSteps&&(r.lockstepMaxSteps=4),void 0===r.preserveDrawingBuffer&&(r.preserveDrawingBuffer=!1),void 0===r.audioEngine&&(r.audioEngine=!0),void 0===r.stencil&&(r.stencil=!0),this._deterministicLockstep=r.deterministicLockstep,this._lockstepMaxSteps=r.lockstepMaxSteps,this._doNotHandleContextLost=!!r.doNotHandleContextLost,navigator&&navigator.userAgent)for(var h=navigator.userAgent,c=0,u=n.ExceptionList;c<u.length;c++){var f=u[c],p=f.key,d=f.targets;if(h.indexOf(p)>-1){if(f.capture&&f.captureConstraint){var m=f.capture,_=f.captureConstraint,g=new RegExp(m),v=g.exec(h);if(v&&v.length>0){var y=parseInt(v[v.length-1]);if(y>=_)continue}}for(var b=0,x=d;b<x.length;b++){var T=x[b];switch(T){case"uniformBuffer":this.disableUniformBuffers=!0;break;case"textureBindingOptimization":this.disableTextureBindingOptimization=!0}}}}if(!r.disableWebGL2Support)try{this._gl=l.getContext("webgl2",r)||l.getContext("experimental-webgl2",r),this._gl&&(this._webGLVersion=2)}catch(e){}if(!this._gl){if(!l)throw new Error("The provided canvas is null or undefined.");try{this._gl=l.getContext("webgl",r)||l.getContext("experimental-webgl",r)}catch(e){throw new Error("WebGL not supported")}}if(!this._gl)throw new Error("WebGL not supported");this._onCanvasFocus=function(){s.onCanvasFocusObservable.notifyObservers(s)},this._onCanvasBlur=function(){s.onCanvasBlurObservable.notifyObservers(s)},l.addEventListener("focus",this._onCanvasFocus),l.addEventListener("blur",this._onCanvasBlur),this._onBlur=function(){s.disablePerformanceMonitorInBackground&&s._performanceMonitor.disable(),s._windowIsBackground=!0},this._onFocus=function(){s.disablePerformanceMonitorInBackground&&s._performanceMonitor.enable(),s._windowIsBackground=!1},this._onCanvasPointerOut=function(e){s.onCanvasPointerOutObservable.notifyObservers(e)},window.addEventListener("blur",this._onBlur),window.addEventListener("focus",this._onFocus),l.addEventListener("pointerout",this._onCanvasPointerOut),this._doNotHandleContextLost||(this._onContextLost=function(t){t.preventDefault(),s._contextWasLost=!0,e.Tools.Warn("WebGL context lost."),s.onContextLostObservable.notifyObservers(s)},this._onContextRestored=function(t){setTimeout((function(){s._initGLContext(),s._rebuildEffects(),s._rebuildInternalTextures(),s._rebuildBuffers(),s.wipeCaches(!0),e.Tools.Warn("WebGL context successfully restored."),s.onContextRestoredObservable.notifyObservers(s),s._contextWasLost=!1}),0)},l.addEventListener("webglcontextlost",this._onContextLost,!1),l.addEventListener("webglcontextrestored",this._onContextRestored,!1))}else this._gl=t,this._renderingCanvas=this._gl.canvas,this._gl.renderbufferStorageMultisample&&(this._webGLVersion=2),r.stencil=this._gl.getContextAttributes().stencil;var E=r.limitDeviceRatio||window.devicePixelRatio||1;this._hardwareScalingLevel=o?1/Math.min(E,window.devicePixelRatio||1):1,this.resize(),this._isStencilEnable=!!r.stencil,this._initGLContext(),l&&(this._onFullscreenChange=function(){void 0!==document.fullscreen?s.isFullscreen=document.fullscreen:void 0!==document.mozFullScreen?s.isFullscreen=document.mozFullScreen:void 0!==document.webkitIsFullScreen?s.isFullscreen=document.webkitIsFullScreen:void 0!==document.msIsFullScreen&&(s.isFullscreen=document.msIsFullScreen),s.isFullscreen&&s._pointerLockRequested&&l&&(l.requestPointerLock=l.requestPointerLock||l.msRequestPointerLock||l.mozRequestPointerLock||l.webkitRequestPointerLock,l.requestPointerLock&&l.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(){s.isPointerLock=document.mozPointerLockElement===l||document.webkitPointerLockElement===l||document.msPointerLockElement===l||document.pointerLockElement===l},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(){l&&l.requestPointerLock()},this._onVRDisplayPointerUnrestricted=function(){document.exitPointerLock()},window.addEventListener("vrdisplaypointerrestricted",this._onVRDisplayPointerRestricted,!1),window.addEventListener("vrdisplaypointerunrestricted",this._onVRDisplayPointerUnrestricted,!1)),r.audioEngine&&e.AudioEngine&&!n.audioEngine&&(n.audioEngine=new e.AudioEngine);for(var P=0;P<this._caps.maxVertexAttribs;P++)this._currentBufferPointers[P]=new a;this._linkTrackers(this._firstBoundInternalTextureTracker,this._lastBoundInternalTextureTracker),r.autoEnableWebVR&&this.initWebVR(),this._badOS=/iPad/i.test(navigator.userAgent)||/iPhone/i.test(navigator.userAgent),this._badDesktopOS=/^((?!chrome|android).)*safari/i.test(navigator.userAgent),console.log("Babylon.js engine (v"+n.Version+") launched"),this.enableOfflineSupport=void 0!==e.Database}}return Object.defineProperty(n,"LastCreatedEngine",{get:function(){return 0===n.Instances.length?null:n.Instances[n.Instances.length-1]},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LastCreatedScene",{get:function(){var e=n.LastCreatedEngine;return e?0===e.scenes.length?null:e.scenes[e.scenes.length-1]:null},enumerable:!0,configurable:!0}),n.MarkAllMaterialsAsDirty=function(e,t){for(var i=0;i<n.Instances.length;i++)for(var r=n.Instances[i],o=0;o<r.scenes.length;o++)r.scenes[o].markAllMaterialsAsDirty(e,t)},Object.defineProperty(n,"NEVER",{get:function(){return n._NEVER},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALWAYS",{get:function(){return n._ALWAYS},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LESS",{get:function(){return n._LESS},enumerable:!0,configurable:!0}),Object.defineProperty(n,"EQUAL",{get:function(){return n._EQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"LEQUAL",{get:function(){return n._LEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"GREATER",{get:function(){return n._GREATER},enumerable:!0,configurable:!0}),Object.defineProperty(n,"GEQUAL",{get:function(){return n._GEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"NOTEQUAL",{get:function(){return n._NOTEQUAL},enumerable:!0,configurable:!0}),Object.defineProperty(n,"KEEP",{get:function(){return n._KEEP},enumerable:!0,configurable:!0}),Object.defineProperty(n,"REPLACE",{get:function(){return n._REPLACE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"INCR",{get:function(){return n._INCR},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DECR",{get:function(){return n._DECR},enumerable:!0,configurable:!0}),Object.defineProperty(n,"INVERT",{get:function(){return n._INVERT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"INCR_WRAP",{get:function(){return n._INCR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DECR_WRAP",{get:function(){return n._DECR_WRAP},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_DISABLE",{get:function(){return n._ALPHA_DISABLE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_ONEONE",{get:function(){return n._ALPHA_ONEONE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_ADD",{get:function(){return n._ALPHA_ADD},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_COMBINE",{get:function(){return n._ALPHA_COMBINE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_SUBTRACT",{get:function(){return n._ALPHA_SUBTRACT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_MULTIPLY",{get:function(){return n._ALPHA_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_MAXIMIZED",{get:function(){return n._ALPHA_MAXIMIZED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_PREMULTIPLIED",{get:function(){return n._ALPHA_PREMULTIPLIED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_PREMULTIPLIED_PORTERDUFF",{get:function(){return n._ALPHA_PREMULTIPLIED_PORTERDUFF},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_INTERPOLATE",{get:function(){return n._ALPHA_INTERPOLATE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"ALPHA_SCREENMODE",{get:function(){return n._ALPHA_SCREENMODE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_NONE",{get:function(){return n._DELAYLOADSTATE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_LOADED",{get:function(){return n._DELAYLOADSTATE_LOADED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_LOADING",{get:function(){return n._DELAYLOADSTATE_LOADING},enumerable:!0,configurable:!0}),Object.defineProperty(n,"DELAYLOADSTATE_NOTLOADED",{get:function(){return n._DELAYLOADSTATE_NOTLOADED},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_ALPHA",{get:function(){return n._TEXTUREFORMAT_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_LUMINANCE",{get:function(){return n._TEXTUREFORMAT_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_R32F",{get:function(){return n._TEXTUREFORMAT_R32F},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_RG32F",{get:function(){return n._TEXTUREFORMAT_RG32F},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_RGB32F",{get:function(){return n._TEXTUREFORMAT_RGB32F},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_RGBA32F",{get:function(){return n._TEXTUREFORMAT_RGBA32F},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_LUMINANCE_ALPHA",{get:function(){return n._TEXTUREFORMAT_LUMINANCE_ALPHA},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_RGB",{get:function(){return n._TEXTUREFORMAT_RGB},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTUREFORMAT_RGBA",{get:function(){return n._TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTURETYPE_UNSIGNED_INT",{get:function(){return n._TEXTURETYPE_UNSIGNED_INT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTURETYPE_FLOAT",{get:function(){return n._TEXTURETYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"TEXTURETYPE_HALF_FLOAT",{get:function(){return n._TEXTURETYPE_HALF_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SCALEMODE_FLOOR",{get:function(){return n._SCALEMODE_FLOOR},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SCALEMODE_NEAREST",{get:function(){return n._SCALEMODE_NEAREST},enumerable:!0,configurable:!0}),Object.defineProperty(n,"SCALEMODE_CEILING",{get:function(){return n._SCALEMODE_CEILING},enumerable:!0,configurable:!0}),Object.defineProperty(n,"Version",{get:function(){return"3.2.0"},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isInVRExclusivePointerMode",{get:function(){return this._vrExclusivePointerMode},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"supportsUniformBuffers",{get:function(){return this.webGLVersion>1&&!this.disableUniformBuffers},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"needPOTTextures",{get:function(){return this._webGLVersion<2||this.forcePOTTextures},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"performanceMonitor",{get:function(){return this._performanceMonitor},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"texturesSupported",{get:function(){return this._texturesSupported},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"textureFormatInUse",{get:function(){return this._textureFormatInUse},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"currentViewport",{get:function(){return this._cachedViewport},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"emptyTexture",{get:function(){return this._emptyTexture||(this._emptyTexture=this.createRawTexture(new Uint8Array(4),1,1,n.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)),this._emptyTexture},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"emptyTexture3D",{get:function(){return this._emptyTexture3D||(this._emptyTexture3D=this.createRawTexture3D(new Uint8Array(4),1,1,1,n.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)),this._emptyTexture3D},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"emptyCubeTexture",{get:function(){if(!this._emptyCubeTexture){var t=new Uint8Array(4),i=[t,t,t,t,t,t];this._emptyCubeTexture=this.createRawCubeTexture(i,1,n.TEXTUREFORMAT_RGBA,n.TEXTURETYPE_UNSIGNED_INT,!1,!1,e.Texture.NEAREST_SAMPLINGMODE)}return this._emptyCubeTexture},enumerable:!0,configurable:!0}),n.prototype._rebuildInternalTextures=function(){for(var e=this._internalTexturesCache.slice(),t=0,i=e;t<i.length;t++){i[t]._rebuild()}},n.prototype._rebuildEffects=function(){for(var t in this._compiledEffects){this._compiledEffects[t]._prepareEffect()}e.Effect.ResetCache()},n.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()}},n.prototype._initGLContext=function(){this._caps=new u,this._caps.maxTexturesImageUnits=this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS),this._caps.maxCombinedTexturesImageUnits=this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),this._caps.maxVertexTextureImageUnits=this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),this._caps.maxTextureSize=this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),this._caps.maxCubemapTextureSize=this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),this._caps.maxRenderTextureSize=this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),this._caps.maxVertexAttribs=this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),this._caps.maxVaryingVectors=this._gl.getParameter(this._gl.MAX_VARYING_VECTORS),this._caps.maxFragmentUniformVectors=this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS),this._caps.maxVertexUniformVectors=this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS),this._glVersion=this._gl.getParameter(this._gl.VERSION);var e=this._gl.getExtension("WEBGL_debug_renderer_info");if(null!=e&&(this._glRenderer=this._gl.getParameter(e.UNMASKED_RENDERER_WEBGL),this._glVendor=this._gl.getParameter(e.UNMASKED_VENDOR_WEBGL)),this._glVendor||(this._glVendor="Unknown vendor"),this._glRenderer||(this._glRenderer="Unknown renderer"),this._gl.HALF_FLOAT_OES=36193,34842!==this._gl.RGBA16F&&(this._gl.RGBA16F=34842),34836!==this._gl.RGBA32F&&(this._gl.RGBA32F=34836),35056!==this._gl.DEPTH24_STENCIL8&&(this._gl.DEPTH24_STENCIL8=35056),this._caps.standardDerivatives=this._webGLVersion>1||null!==this._gl.getExtension("OES_standard_derivatives"),this._caps.astc=this._gl.getExtension("WEBGL_compressed_texture_astc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_astc"),this._caps.s3tc=this._gl.getExtension("WEBGL_compressed_texture_s3tc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc"),this._caps.pvrtc=this._gl.getExtension("WEBGL_compressed_texture_pvrtc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),this._caps.etc1=this._gl.getExtension("WEBGL_compressed_texture_etc1")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc1"),this._caps.etc2=this._gl.getExtension("WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBKIT_WEBGL_compressed_texture_etc")||this._gl.getExtension("WEBGL_compressed_texture_es3_0"),this._caps.textureAnisotropicFilterExtension=this._gl.getExtension("EXT_texture_filter_anisotropic")||this._gl.getExtension("WEBKIT_EXT_texture_filter_anisotropic")||this._gl.getExtension("MOZ_EXT_texture_filter_anisotropic"),this._caps.maxAnisotropy=this._caps.textureAnisotropicFilterExtension?this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0,this._caps.uintIndices=this._webGLVersion>1||null!==this._gl.getExtension("OES_element_index_uint"),this._caps.fragmentDepthSupported=this._webGLVersion>1||null!==this._gl.getExtension("EXT_frag_depth"),this._caps.highPrecisionShaderSupported=!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=this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT,this._caps.timerQuery.QUERY_COUNTER_BITS_EXT)>0),this._caps.colorBufferFloat=this._webGLVersion>1&&this._gl.getExtension("EXT_color_buffer_float"),this._caps.textureFloat=!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_float")),this._caps.textureFloatLinearFiltering=!(!this._caps.textureFloat||!this._gl.getExtension("OES_texture_float_linear")),this._caps.textureFloatRender=!(!this._caps.textureFloat||!this._canRenderToFloatFramebuffer()),this._caps.textureHalfFloat=!!(this._webGLVersion>1||this._gl.getExtension("OES_texture_half_float")),this._caps.textureHalfFloatLinearFiltering=!!(this._webGLVersion>1||this._caps.textureHalfFloat&&this._gl.getExtension("OES_texture_half_float_linear")),this._webGLVersion>1&&(this._gl.HALF_FLOAT_OES=5131),this._caps.textureHalfFloatRender=this._caps.textureHalfFloat&&this._canRenderToHalfFloatFramebuffer(),this._caps.textureLOD=!!(this._webGLVersion>1||this._gl.getExtension("EXT_shader_texture_lod")),this._webGLVersion>1)this._caps.drawBuffersExtension=!0;else{var t=this._gl.getExtension("WEBGL_draw_buffers");if(null!==t){this._caps.drawBuffersExtension=!0,this._gl.drawBuffers=t.drawBuffersWEBGL.bind(t),this._gl.DRAW_FRAMEBUFFER=this._gl.FRAMEBUFFER;for(var i=0;i<16;i++)this._gl["COLOR_ATTACHMENT"+i+"_WEBGL"]=t["COLOR_ATTACHMENT"+i+"_WEBGL"]}else this._caps.drawBuffersExtension=!1}if(this._webGLVersion>1)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(this._webGLVersion>1)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(this._webGLVersion>1)this._caps.instancedArrays=!0;else{var o=this._gl.getExtension("ANGLE_instanced_arrays");null!=o?(this._caps.instancedArrays=!0,this._gl.drawArraysInstanced=o.drawArraysInstancedANGLE.bind(o),this._gl.drawElementsInstanced=o.drawElementsInstancedANGLE.bind(o),this._gl.vertexAttribDivisor=o.vertexAttribDivisorANGLE.bind(o)):this._caps.instancedArrays=!1}if(this._caps.astc&&this.texturesSupported.push("-astc.ktx"),this._caps.s3tc&&this.texturesSupported.push("-dxt.ktx"),this._caps.pvrtc&&this.texturesSupported.push("-pvrtc.ktx"),this._caps.etc2&&this.texturesSupported.push("-etc2.ktx"),this._caps.etc1&&this.texturesSupported.push("-etc1.ktx"),this._gl.getShaderPrecisionFormat){var 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(n.prototype,"webGLVersion",{get:function(){return this._webGLVersion},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"isStencilEnable",{get:function(){return this._isStencilEnable},enumerable:!0,configurable:!0}),n.prototype._prepareWorkingCanvas=function(){if(!this._workingCanvas){this._workingCanvas=document.createElement("canvas");var e=this._workingCanvas.getContext("2d");e&&(this._workingContext=e)}},n.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},n.prototype.isDeterministicLockStep=function(){return this._deterministicLockstep},n.prototype.getLockstepMaxSteps=function(){return this._lockstepMaxSteps},n.prototype.getGlInfo=function(){return{vendor:this._glVendor,renderer:this._glRenderer,version:this._glVersion}},n.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)},n.prototype.getRenderWidth=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.width:this._gl.drawingBufferWidth},n.prototype.getRenderHeight=function(e){return void 0===e&&(e=!1),!e&&this._currentRenderTarget?this._currentRenderTarget.height:this._gl.drawingBufferHeight},n.prototype.getRenderingCanvas=function(){return this._renderingCanvas},n.prototype.getRenderingCanvasClientRect=function(){return this._renderingCanvas?this._renderingCanvas.getBoundingClientRect():null},n.prototype.setHardwareScalingLevel=function(e){this._hardwareScalingLevel=e,this.resize()},n.prototype.getHardwareScalingLevel=function(){return this._hardwareScalingLevel},n.prototype.getLoadedTexturesCache=function(){return this._internalTexturesCache},n.prototype.getCaps=function(){return this._caps},Object.defineProperty(n.prototype,"drawCalls",{get:function(){return e.Tools.Warn("drawCalls is deprecated. Please use SceneInstrumentation class"),0},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"drawCallsPerfCounter",{get:function(){return e.Tools.Warn("drawCallsPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),n.prototype.getDepthFunction=function(){return this._depthCullingState.depthFunc},n.prototype.setDepthFunction=function(e){this._depthCullingState.depthFunc=e},n.prototype.setDepthFunctionToGreater=function(){this._depthCullingState.depthFunc=this._gl.GREATER},n.prototype.setDepthFunctionToGreaterOrEqual=function(){this._depthCullingState.depthFunc=this._gl.GEQUAL},n.prototype.setDepthFunctionToLess=function(){this._depthCullingState.depthFunc=this._gl.LESS},n.prototype.setDepthFunctionToLessOrEqual=function(){this._depthCullingState.depthFunc=this._gl.LEQUAL},n.prototype.getStencilBuffer=function(){return this._stencilState.stencilTest},n.prototype.setStencilBuffer=function(e){this._stencilState.stencilTest=e},n.prototype.getStencilMask=function(){return this._stencilState.stencilMask},n.prototype.setStencilMask=function(e){this._stencilState.stencilMask=e},n.prototype.getStencilFunction=function(){return this._stencilState.stencilFunc},n.prototype.getStencilFunctionReference=function(){return this._stencilState.stencilFuncRef},n.prototype.getStencilFunctionMask=function(){return this._stencilState.stencilFuncMask},n.prototype.setStencilFunction=function(e){this._stencilState.stencilFunc=e},n.prototype.setStencilFunctionReference=function(e){this._stencilState.stencilFuncRef=e},n.prototype.setStencilFunctionMask=function(e){this._stencilState.stencilFuncMask=e},n.prototype.getStencilOperationFail=function(){return this._stencilState.stencilOpStencilFail},n.prototype.getStencilOperationDepthFail=function(){
return this._stencilState.stencilOpDepthFail},n.prototype.getStencilOperationPass=function(){return this._stencilState.stencilOpStencilDepthPass},n.prototype.setStencilOperationFail=function(e){this._stencilState.stencilOpStencilFail=e},n.prototype.setStencilOperationDepthFail=function(e){this._stencilState.stencilOpDepthFail=e},n.prototype.setStencilOperationPass=function(e){this._stencilState.stencilOpStencilDepthPass=e},n.prototype.setDitheringState=function(e){e?this._gl.enable(this._gl.DITHER):this._gl.disable(this._gl.DITHER)},n.prototype.setRasterizerState=function(e){e?this._gl.disable(this._gl.RASTERIZER_DISCARD):this._gl.enable(this._gl.RASTERIZER_DISCARD)},n.prototype.stopRenderLoop=function(e){if(!e)return void(this._activeRenderLoops=[]);var t=this._activeRenderLoops.indexOf(e);t>=0&&this._activeRenderLoops.splice(t,1)},n.prototype._renderLoop=function(){if(!this._contextWasLost){var t=!0;if(!this.renderEvenInBackground&&this._windowIsBackground&&(t=!1),t){this.beginFrame();for(var i=0;i<this._activeRenderLoops.length;i++){(0,this._activeRenderLoops[i])()}this.endFrame()}}if(this._activeRenderLoops.length>0){var r=null;this._vrDisplay&&this._vrDisplay.isPresenting&&(r=this._vrDisplay),this._frameHandler=e.Tools.QueueNewFrame(this._bindedRenderFunction,r)}else this._renderingQueueLaunched=!1},n.prototype.runRenderLoop=function(t){-1===this._activeRenderLoops.indexOf(t)&&(this._activeRenderLoops.push(t),this._renderingQueueLaunched||(this._renderingQueueLaunched=!0,this._bindedRenderFunction=this._renderLoop.bind(this),this._frameHandler=e.Tools.QueueNewFrame(this._bindedRenderFunction)))},n.prototype.switchFullscreen=function(t){this.isFullscreen?e.Tools.ExitFullscreen():(this._pointerLockRequested=t,this._renderingCanvas&&e.Tools.RequestFullscreen(this._renderingCanvas))},n.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)},n.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)},n.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._gl.viewport(o*r,s*n,r*e.width,n*e.height)},n.prototype.setDirectViewport=function(e,t,i,r){var n=this._cachedViewport;return this._cachedViewport=null,this._gl.viewport(e,t,i,r),n},n.prototype.beginFrame=function(){this.onBeginFrameObservable.notifyObservers(this),this._measureFps()},n.prototype.endFrame=function(){this._badOS&&this.flushFramebuffer(),this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.submitFrame(),this.onEndFrameObservable.notifyObservers(this)},n.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)}},n.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++){var o=r.cameras[n];o._currentRenderId=0}this.onResizeObservable.hasObservers&&this.onResizeObservable.notifyObservers(this)}},n.prototype.isVRDevicePresent=function(){return!!this._vrDisplay},n.prototype.getVRDevice=function(){return this._vrDisplay},n.prototype.initWebVR=function(){return this.initWebVRAsync(),this.onVRDisplayChangedObservable},n.prototype.initWebVRAsync=function(){var t=this,i=function(){var e={vrDisplay:t._vrDisplay,vrSupported:t._vrSupported};t.onVRDisplayChangedObservable.notifyObservers(e),t._webVRInitPromise=new Promise(function(t){t(e)})};return this._onVrDisplayConnect||(this._onVrDisplayConnect=function(e){t._vrDisplay=e.display,i()},this._onVrDisplayDisconnect=function(){t._vrDisplay.cancelAnimationFrame(t._frameHandler),t._vrDisplay=void 0,t._frameHandler=e.Tools.QueueNewFrame(t._bindedRenderFunction),i()},this._onVrDisplayPresentChange=function(){t._vrExclusivePointerMode=t._vrDisplay&&t._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(i),this._webVRInitPromise},n.prototype.enableVR=function(){var e=this;if(this._vrDisplay&&!this._vrDisplay.isPresenting){var t=function(){e.onVRRequestPresentComplete.notifyObservers(!0),e._onVRFullScreenTriggered()},i=function(){e.onVRRequestPresentComplete.notifyObservers(!1)};this.onVRRequestPresentStart.notifyObservers(this),this._vrDisplay.requestPresent([{source:this.getRenderingCanvas()}]).then(t).catch(i)}},n.prototype.disableVR=function(){this._vrDisplay&&this._vrDisplay.isPresenting&&this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered)},n.prototype._getVRDisplaysAsync=function(){var e=this;return new Promise(function(t,i){navigator.getVRDisplays?navigator.getVRDisplays().then((function(i){e._vrSupported=!0,e._vrDisplay=i[0],t({vrDisplay:e._vrDisplay,vrSupported:e._vrSupported})})):(e._vrDisplay=void 0,e._vrSupported=!1,t({vrDisplay:e._vrDisplay,vrSupported:e._vrSupported}))})},n.prototype.bindFramebuffer=function(e,t,i,r,n,o){this._currentRenderTarget&&this.unBindFramebuffer(this._currentRenderTarget),this._currentRenderTarget=e,this.bindUnboundFramebuffer(e._MSAAFramebuffer?e._MSAAFramebuffer:e._framebuffer);var s=this._gl;e.isCube&&(void 0===t&&(t=0),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,e._webGLTexture,0),o&&(o._generateStencilBuffer?s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,0):s.framebufferTexture2D(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.TEXTURE_CUBE_MAP_POSITIVE_X+t,o._webGLTexture,0))),this._cachedViewport&&!n?this.setViewport(this._cachedViewport,i,r):s.viewport(0,0,i||e.width,r||e.height),this.wipeCaches()},n.prototype.bindUnboundFramebuffer=function(e){this._currentFramebuffer!==e&&(this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,e),this._currentFramebuffer=e)},n.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)},n.prototype.unBindMultiColorAttachmentFramebuffer=function(e,t,i){void 0===t&&(t=!1),this._currentRenderTarget=null;var r=this._gl;if(e[0]._MSAAFramebuffer){r.bindFramebuffer(r.READ_FRAMEBUFFER,e[0]._MSAAFramebuffer),r.bindFramebuffer(r.DRAW_FRAMEBUFFER,e[0]._framebuffer);var n=e[0]._attachments;n||(n=new Array(e.length),e[0]._attachments=n);for(var o=0;o<e.length;o++){for(var s=e[o],a=0;a<n.length;a++)n[a]=r.NONE;n[o]=r[this.webGLVersion>1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"],r.readBuffer(n[o]),r.drawBuffers(n),r.blitFramebuffer(0,0,s.width,s.height,0,0,s.width,s.height,r.COLOR_BUFFER_BIT,r.NEAREST)}for(var o=0;o<n.length;o++)n[o]=r[this.webGLVersion>1?"COLOR_ATTACHMENT"+o:"COLOR_ATTACHMENT"+o+"_WEBGL"];r.drawBuffers(n)}for(var o=0;o<e.length;o++){var s=e[o];!s.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)},n.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)}},n.prototype.flushFramebuffer=function(){this._gl.flush()},n.prototype.restoreDefaultFramebuffer=function(){this._currentRenderTarget?this.unBindFramebuffer(this._currentRenderTarget):this.bindUnboundFramebuffer(null),this._cachedViewport&&this.setViewport(this._cachedViewport),this.wipeCaches()},n.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},n.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},n.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)},n.prototype._resetVertexBufferBinding=function(){this.bindArrayBuffer(null),this._cachedVertexBuffers=null},n.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},n.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},n.prototype.updateDynamicIndexBuffer=function(e,t,i){void 0===i&&(i=0),this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER]=null,this.bindIndexBuffer(e);var r;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()},n.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()},n.prototype._resetIndexBufferBinding=function(){this.bindIndexBuffer(null),this._cachedIndexBuffer=null},n.prototype.createIndexBuffer=function(e,t){var i=this._gl.createBuffer();if(!i)throw new Error("Unable to create index buffer");this.bindIndexBuffer(i);var r,n=!1;if(e instanceof Uint16Array)r=e;else if(this._caps.uintIndices)if(e instanceof Uint32Array)r=e,n=!0;else{for(var o=0;o<e.length;o++)if(e[o]>65535){n=!0;break}r=n?new Uint32Array(e):new Uint16Array(e)}else r=new Uint16Array(e);return this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER,r,t?this._gl.DYNAMIC_DRAW:this._gl.STATIC_DRAW),this._resetIndexBufferBinding(),i.references=1,i.is32Bits=n,i},n.prototype.bindArrayBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ARRAY_BUFFER)},n.prototype.bindUniformBuffer=function(e){this._gl.bindBuffer(this._gl.UNIFORM_BUFFER,e)},n.prototype.bindUniformBufferBase=function(e,t){this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,t,e)},n.prototype.bindUniformBlock=function(e,t,i){var r=this._gl.getUniformBlockIndex(e,t);this._gl.uniformBlockBinding(e,r,i)},n.prototype.bindIndexBuffer=function(e){this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.bindBuffer(e,this._gl.ELEMENT_ARRAY_BUFFER)},n.prototype.bindBuffer=function(e,t){(this._vaoRecordInProgress||this._currentBoundBuffer[t]!==e)&&(this._gl.bindBuffer(t,e),this._currentBoundBuffer[t]=e)},n.prototype.updateArrayBuffer=function(e){this._gl.bufferSubData(this._gl.ARRAY_BUFFER,0,e)},n.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))},n.prototype._bindIndexBufferWithCache=function(e){null!=e&&this._cachedIndexBuffer!==e&&(this._cachedIndexBuffer=e,this.bindIndexBuffer(e),this._uintIndicesCurrentlySet=e.is32Bits)},n.prototype._bindVertexBuffersAttributes=function(e,t){var i=t.getAttributesNames();this._vaoRecordInProgress||this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var r=0;r<i.length;r++){var n=t.getAttributeLocation(r);if(n>=0){var o=e[i[r]];if(!o)continue;this._gl.enableVertexAttribArray(n),this._vaoRecordInProgress||(this._vertexAttribArraysEnabled[n]=!0);var s=o.getBuffer();s&&(this._vertexAttribPointer(s,n,o.getSize(),o.type,o.normalized,o.byteStride,o.byteOffset),o.getIsInstanced()&&(this._gl.vertexAttribDivisor(n,o.getInstanceDivisor()),this._vaoRecordInProgress||(this._currentInstanceLocations.push(n),this._currentInstanceBuffers.push(s))))}}},n.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},n.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)},n.prototype.bindBuffersDirectly=function(e,t,i,r,n){if(this._cachedVertexBuffers!==e||this._cachedEffectForVertexBuffers!==n){this._cachedVertexBuffers=e,this._cachedEffectForVertexBuffers=n;var o=n.getAttributesCount();this._unbindVertexArrayObject(),this.unbindAllAttributes();for(var s=0,a=0;a<o;a++)if(a<i.length){var l=n.getAttributeLocation(a);l>=0&&(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)},n.prototype._unbindVertexArrayObject=function(){this._cachedVertexArrayObject&&(this._cachedVertexArrayObject=null,this._gl.bindVertexArray(null))},n.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)},n.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},n.prototype.releaseVertexArrayObject=function(e){this._gl.deleteVertexArray(e)},n.prototype._releaseBuffer=function(e){return 0===--e.references&&(this._gl.deleteBuffer(e),!0)},n.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},n.prototype.deleteInstancesBuffer=function(e){this._gl.deleteBuffer(e)},n.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++){var o=i[n];r+=4*o.attributeSize}for(var 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)}},n.prototype.applyStates=function(){this._depthCullingState.apply(this._gl),this._stencilState.apply(this._gl),this._alphaState.apply(this._gl)},n.prototype.draw=function(t,i,r,n){this.drawElementsType(t?e.Material.TriangleFillMode:e.Material.WireFrameFillMode,i,r,n)},n.prototype.drawPointClouds=function(t,i,r){this.drawArraysType(e.Material.PointFillMode,t,i,r)},n.prototype.drawUnIndexed=function(t,i,r,n){this.drawArraysType(t?e.Material.TriangleFillMode:e.Material.WireFrameFillMode,i,r,n)},n.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)},n.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)},n.prototype._drawMode=function(t){switch(t){case e.Material.TriangleFillMode:return this._gl.TRIANGLES;case e.Material.PointFillMode:return this._gl.POINTS;case e.Material.WireFrameFillMode:return this._gl.LINES;case e.Material.PointListDrawMode:return this._gl.POINTS;case e.Material.LineListDrawMode:return this._gl.LINES;case e.Material.LineLoopDrawMode:return this._gl.LINE_LOOP;case e.Material.LineStripDrawMode:return this._gl.LINE_STRIP;case e.Material.TriangleStripDrawMode:return this._gl.TRIANGLE_STRIP;case e.Material.TriangleFanDrawMode:return this._gl.TRIANGLE_FAN;default:return this._gl.TRIANGLES}},n.prototype._releaseEffect=function(e){this._compiledEffects[e._key]&&(delete this._compiledEffects[e._key],this._deleteProgram(e.getProgram()))},n.prototype._deleteProgram=function(e){e&&(e.__SPECTOR_rebuildProgram=null,e.transformFeedback&&(this.deleteTransformFeedback(e.transformFeedback),e.transformFeedback=null),this._gl.deleteProgram(e))},n.prototype.createEffect=function(t,i,r,n,o,s,a,l,h){var c=t.vertexElement||t.vertex||t,u=t.fragmentElement||t.fragment||t,f=c+"+"+u+"@"+(o||i.defines);if(this._compiledEffects[f]){var p=this._compiledEffects[f];return a&&p.isReady()&&a(p),p}var d=new e.Effect(t,i,r,n,this,o,s,a,l,h);return d._key=f,this._compiledEffects[f]=d,d},n.prototype.createEffectForParticles=function(e,t,i,r,n,o,s){return void 0===t&&(t=[]),void 0===i&&(i=[]),void 0===r&&(r=""),this.createEffect({vertex:"particles",fragmentElement:e},["position","color","options"],["view","projection"].concat(t),["diffuseSampler"].concat(i),r,n,o,s)},n.prototype.createRawShaderProgram=function(e,t,r,n){void 0===n&&(n=null),r=r||this._gl;var o=i(r,e,"vertex"),s=i(r,t,"fragment");return this._createShaderProgram(o,s,r,n)},n.prototype.createShaderProgram=function(e,i,r,n,o){void 0===o&&(o=null),n=n||this._gl,this.onBeforeShaderCompilationObservable.notifyObservers(this);var s=this._webGLVersion>1?"#version 300 es\n#define WEBGL2 \n":"",a=t(n,e,"vertex",r,s),l=t(n,i,"fragment",r,s),h=this._createShaderProgram(a,l,n,o);return this.onAfterShaderCompilationObservable.notifyObservers(this),h},n.prototype._createShaderProgram=function(e,t,i,r){void 0===r&&(r=null);var n=i.createProgram();if(!n)throw new Error("Unable to create program");if(i.attachShader(n,e),i.attachShader(n,t),this.webGLVersion>1&&r){var o=this.createTransformFeedback();this.bindTransformFeedback(o),this.setTranformFeedbackVaryings(n,r),n.transformFeedback=o}if(i.linkProgram(n),this.webGLVersion>1&&r&&this.bindTransformFeedback(null),!i.getProgramParameter(n,i.LINK_STATUS)){i.validateProgram(n);var s=i.getProgramInfoLog(n);if(s)throw new Error(s)}return i.deleteShader(e),i.deleteShader(t),n},n.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},n.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},n.prototype.enableEffect=function(e){e&&(this.bindSamplers(e),this._currentEffect=e,e.onBind&&e.onBind(e),e.onBindObservable.notifyObservers(e))},n.prototype.setIntArray=function(e,t){e&&this._gl.uniform1iv(e,t)},n.prototype.setIntArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2iv(e,t)},n.prototype.setIntArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3iv(e,t)},n.prototype.setIntArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4iv(e,t)},n.prototype.setFloatArray=function(e,t){e&&this._gl.uniform1fv(e,t)},n.prototype.setFloatArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},n.prototype.setFloatArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},n.prototype.setFloatArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},n.prototype.setArray=function(e,t){e&&this._gl.uniform1fv(e,t)},n.prototype.setArray2=function(e,t){e&&t.length%2==0&&this._gl.uniform2fv(e,t)},n.prototype.setArray3=function(e,t){e&&t.length%3==0&&this._gl.uniform3fv(e,t)},n.prototype.setArray4=function(e,t){e&&t.length%4==0&&this._gl.uniform4fv(e,t)},n.prototype.setMatrices=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t)},n.prototype.setMatrix=function(e,t){e&&this._gl.uniformMatrix4fv(e,!1,t.toArray())},n.prototype.setMatrix3x3=function(e,t){e&&this._gl.uniformMatrix3fv(e,!1,t)},n.prototype.setMatrix2x2=function(e,t){e&&this._gl.uniformMatrix2fv(e,!1,t)},n.prototype.setInt=function(e,t){e&&this._gl.uniform1i(e,t)},n.prototype.setFloat=function(e,t){e&&this._gl.uniform1f(e,t)},n.prototype.setFloat2=function(e,t,i){e&&this._gl.uniform2f(e,t,i)},n.prototype.setFloat3=function(e,t,i,r){e&&this._gl.uniform3f(e,t,i,r)},n.prototype.setBool=function(e,t){e&&this._gl.uniform1i(e,t)},n.prototype.setFloat4=function(e,t,i,r,n){e&&this._gl.uniform4f(e,t,i,r,n)},n.prototype.setColor3=function(e,t){e&&this._gl.uniform3f(e,t.r,t.g,t.b)},n.prototype.setColor4=function(e,t,i){e&&this._gl.uniform4f(e,t.r,t.g,t.b,i)},n.prototype.setDirectColor4=function(e,t){e&&this._gl.uniform4f(e,t.r,t.g,t.b,t.a)},n.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)},n.prototype.setZOffset=function(e){this._depthCullingState.zOffset=e},n.prototype.getZOffset=function(){return this._depthCullingState.zOffset},n.prototype.setDepthBuffer=function(e){this._depthCullingState.depthTest=e},n.prototype.getDepthWrite=function(){return this._depthCullingState.depthMask},n.prototype.setDepthWrite=function(e){this._depthCullingState.depthMask=e},n.prototype.setColorWrite=function(e){this._gl.colorMask(e,e,e,e),this._colorWrite=e},n.prototype.getColorWrite=function(){return this._colorWrite},n.prototype.setAlphaConstants=function(e,t,i,r){this._alphaState.setAlphaBlendConstants(e,t,i,r)},n.prototype.setAlphaMode=function(e,t){if(void 0===t&&(t=!1),this._alphaMode!==e){switch(e){case n.ALPHA_DISABLE:this._alphaState.alphaBlend=!1;break;case n.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 n.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 n.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 n.ALPHA_ONEONE:this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case n.ALPHA_ADD:this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA,this._gl.ONE,this._gl.ZERO,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case n.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 n.ALPHA_MULTIPLY:this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR,this._gl.ZERO,this._gl.ONE,this._gl.ONE),this._alphaState.alphaBlend=!0;break;case n.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 n.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 n.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===n.ALPHA_DISABLE),this._alphaMode=e}},n.prototype.getAlphaMode=function(){return this._alphaMode},n.prototype.wipeCaches=function(e){this.preventCacheWipeBetweenFrames&&!e||(this._currentEffect=null,e&&(this.resetTextureCache(),this._currentProgram=null,this._stencilState.reset(),this._depthCullingState.reset(),this.setDepthFunctionToLessOrEqual(),this._alphaState.reset()),this._resetVertexBufferBinding(),this._cachedIndexBuffer=null,this._cachedEffectForVertexBuffers=null,this._unbindVertexArrayObject(),this.bindIndexBuffer(null))},n.prototype.setTextureFormatToUse=function(e){for(var t=0,i=this.texturesSupported.length;t<i;t++)for(var r=0,n=e.length;r<n;r++)if(this._texturesSupported[t]===e[r].toLowerCase())return this._textureFormatInUse=this._texturesSupported[t];return this._textureFormatInUse=null,null},n.prototype._createTexture=function(){var e=this._gl.createTexture();if(!e)throw new Error("Unable to create texture");return e},n.prototype.createTexture=function(t,i,r,n,o,s,a,l,h,c){var u=this;void 0===o&&(o=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===s&&(s=null),void 0===a&&(a=null),void 0===l&&(l=null),void 0===h&&(h=null),void 0===c&&(c=null);var f=String(t),p="data:"===f.substr(0,5),d="blob:"===f.substr(0,5),m=p&&-1!==f.indexOf("base64"),_=h||new e.InternalTexture(this,e.InternalTexture.DATASOURCE_URL),g=f.lastIndexOf("."),v=g>0?f.substring(g).toLowerCase():"",y=this.getCaps().s3tc&&0===v.indexOf(".dds"),b=0===v.indexOf(".tga"),x=!1;!this._textureFormatInUse||m||h||(f=f.substring(0,g)+this._textureFormatInUse,x=!0),n&&n._addPendingData(_),_.url=f,_.generateMipMaps=!i,_.samplingMode=o,_.invertY=r,this._doNotHandleContextLost||(_._buffer=l);var T=null;s&&!h&&(T=_.onLoadedObservable.add(s)),h||this._internalTexturesCache.push(_);var E=function(s,h){n&&n._removePendingData(_),T&&_.onLoadedObservable.remove(T),x?u.createTexture(t,i,r,n,o,null,a,l,_):e.Tools.UseFallbackTexture&&u.createTexture(e.Tools.fallbackTexture,i,r,n,o,null,a,l,_),a&&a(s||"Unknown error",h)},P=null;if(x||b||y)x?P=function(t){var s=new e.KhronosTextureContainer(t,1);u._prepareWebGLTexture(_,n,s.pixelWidth,s.pixelHeight,r,!1,!0,(function(){return s.uploadLevels(u._gl,!i),!1}),o)}:b?P=function(t){var s=new Uint8Array(t),a=e.TGATools.GetTGAHeader(s);u._prepareWebGLTexture(_,n,a.width,a.height,r,i,!1,(function(){return e.TGATools.UploadContent(u._gl,s),!1}),o)}:y&&(P=function(t){var s=e.DDSTools.GetDDSInfo(t),a=(s.isRGB||s.isLuminance||s.mipmapCount>1)&&!i&&s.width>>s.mipmapCount-1==1;u._prepareWebGLTexture(_,n,s.width,s.height,r,!a,s.isFourCC,(function(){return e.DDSTools.UploadDDSLevels(u,u._gl,t,s,a,1),!1}),o)}),l?P&&P(l):this._loadFile(f,(function(e){P&&P(e)}),void 0,n?n.database:void 0,!0,(function(e,t){E("Unable to load "+(e&&e.responseURL,t))}));else{var A=function(t){d&&!u._doNotHandleContextLost&&(_._buffer=t),u._prepareWebGLTexture(_,n,t.width,t.height,r,i,!1,(function(i,r,o){var s=u._gl,a=t.width===i&&t.height===r,l=c?u._getInternalFormat(c):".jpg"===v?s.RGB:s.RGBA;if(a)return s.texImage2D(s.TEXTURE_2D,0,l,l,s.UNSIGNED_BYTE,t),!1;var h=new e.InternalTexture(u,e.InternalTexture.DATASOURCE_TEMP);return u._bindTextureDirectly(s.TEXTURE_2D,h,!0),s.texImage2D(s.TEXTURE_2D,0,l,l,s.UNSIGNED_BYTE,t),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),u._rescaleTexture(h,_,n,l,(function(){u._releaseTexture(h),u._bindTextureDirectly(s.TEXTURE_2D,_,!0),o()})),!0}),o)};!p||m?l instanceof HTMLImageElement?A(l):e.Tools.LoadImage(f,A,E,n?n.database:null):l instanceof Array||"string"==typeof l||l instanceof ArrayBuffer?e.Tools.LoadImage(l,A,E,n?n.database:null):A(l)}return _},n.prototype._rescaleTexture=function(t,i,r,o,s){var a=this,l=this.createRenderTargetTexture({width:i.width,height:i.height},{generateMipMaps:!1,type:n.TEXTURETYPE_UNSIGNED_INT,samplingMode:e.Texture.BILINEAR_SAMPLINGMODE,generateDepthBuffer:!1,generateStencilBuffer:!1});this._rescalePostProcess||(this._rescalePostProcess=new e.PassPostProcess("rescale",1,null,e.Texture.BILINEAR_SAMPLINGMODE,this,!1,n.TEXTURETYPE_UNSIGNED_INT)),this._rescalePostProcess.getEffect().executeWhenCompiled((function(){a._rescalePostProcess.onApply=function(e){e._bindTexture("textureSampler",t)};var e=r;e||(e=a.scenes[a.scenes.length-1]),e.postProcessManager.directRender([a._rescalePostProcess],l,!0),a._bindTextureDirectly(a._gl.TEXTURE_2D,i,!0),a._gl.copyTexImage2D(a._gl.TEXTURE_2D,0,o,0,0,i.width,i.height,0),a.unBindFramebuffer(l),a._releaseTexture(l),s&&s()}))},n.prototype.updateRawTexture=function(e,t,i,r,o,s){if(void 0===o&&(o=null),
void 0===s&&(s=n.TEXTURETYPE_UNSIGNED_INT),e){var a=this._getRGBABufferInternalSizedFormat(s,i),l=this._getInternalFormat(i),h=this._getWebGLTextureType(s);this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),this._doNotHandleContextLost||(e._bufferView=t,e.format=i,e.type=s,e.invertY=r,e._compression=o),e.width%4!=0&&this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT,1),o&&t?this._gl.compressedTexImage2D(this._gl.TEXTURE_2D,0,this.getCaps().s3tc[o],e.width,e.height,0,t):this._gl.texImage2D(this._gl.TEXTURE_2D,0,a,e.width,e.height,0,l,h,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}},n.prototype.createRawTexture=function(t,i,o,s,a,l,h,c,u){void 0===c&&(c=null),void 0===u&&(u=n.TEXTURETYPE_UNSIGNED_INT);var f=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RAW);f.baseWidth=i,f.baseHeight=o,f.width=i,f.height=o,f.format=s,f.generateMipMaps=a,f.samplingMode=h,f.invertY=l,f._compression=c,f.type=u,this._doNotHandleContextLost||(f._bufferView=t),this.updateRawTexture(f,t,s,l,c,u),this._bindTextureDirectly(this._gl.TEXTURE_2D,f,!0);var p=r(h,a,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MAG_FILTER,p.mag),this._gl.texParameteri(this._gl.TEXTURE_2D,this._gl.TEXTURE_MIN_FILTER,p.min),a&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._internalTexturesCache.push(f),f},n.prototype.createDynamicTexture=function(t,i,r,n){var o=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_DYNAMIC);return o.baseWidth=t,o.baseHeight=i,r&&(t=this.needPOTTextures?e.Tools.GetExponentOfTwo(t,this._caps.maxTextureSize):t,i=this.needPOTTextures?e.Tools.GetExponentOfTwo(i,this._caps.maxTextureSize):i),o.width=t,o.height=i,o.isReady=!1,o.generateMipMaps=r,o.samplingMode=n,this.updateTextureSamplingMode(n,o),this._internalTexturesCache.push(o),o},n.prototype.updateTextureSamplingMode=function(e,t){var i=r(e,t.generateMipMaps,this._gl);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},n.prototype.updateDynamicTexture=function(e,t,i,r,n){if(void 0===r&&(r=!1),e){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?1:0),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}},n.prototype.updateVideoTexture=function(e,t,i){if(e&&!e._isDisabled){this._bindTextureDirectly(this._gl.TEXTURE_2D,e,!0),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,i?0:1);try{if(void 0===this._videoTextureSupported&&(this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t),0!==this._gl.getError()?this._videoTextureSupported=!1:this._videoTextureSupported=!0),this._videoTextureSupported)this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,t);else{if(!e._workingCanvas){e._workingCanvas=document.createElement("canvas");var r=e._workingCanvas.getContext("2d");if(!r)throw new Error("Unable to get 2d context");e._workingContext=r,e._workingCanvas.width=e.width,e._workingCanvas.height=e.height}e._workingContext.drawImage(t,0,0,t.videoWidth,t.videoHeight,0,0,e.width,e.height),this._gl.texImage2D(this._gl.TEXTURE_2D,0,this._gl.RGBA,this._gl.RGBA,this._gl.UNSIGNED_BYTE,e._workingCanvas)}e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(this._gl.TEXTURE_2D,null),e.isReady=!0}catch(t){e._isDisabled=!0}}},n.prototype.updateTextureComparisonFunction=function(t,i){if(1===this.webGLVersion)return void e.Tools.Error("WebGL 1 does not support texture comparison.");var r=this._gl;t.isCube?(this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,t,!0),0===i?(r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_FUNC,n.LEQUAL),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_MODE,r.NONE)):(r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_FUNC,i),r.texParameteri(r.TEXTURE_CUBE_MAP,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null)):(this._bindTextureDirectly(this._gl.TEXTURE_2D,t,!0),0===i?(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_FUNC,n.LEQUAL),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_MODE,r.NONE)):(r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_FUNC,i),r.texParameteri(r.TEXTURE_2D,r.TEXTURE_COMPARE_MODE,r.COMPARE_REF_TO_TEXTURE)),this._bindTextureDirectly(this._gl.TEXTURE_2D,null)),t._comparisonFunction=i},n.prototype._setupDepthStencilTexture=function(t,i,o,s,a){var l=i.width||i,h=i.height||i;t.baseWidth=l,t.baseHeight=h,t.width=l,t.height=h,t.isReady=!0,t.samples=1,t.generateMipMaps=!1,t._generateDepthBuffer=!0,t._generateStencilBuffer=o,t.samplingMode=s?e.Texture.BILINEAR_SAMPLINGMODE:e.Texture.NEAREST_SAMPLINGMODE,t.type=n.TEXTURETYPE_UNSIGNED_INT,t._comparisonFunction=a;var c=this._gl,u=t.isCube?c.TEXTURE_CUBE_MAP:c.TEXTURE_2D,f=r(t.samplingMode,!1,c);c.texParameteri(u,c.TEXTURE_MAG_FILTER,f.mag),c.texParameteri(u,c.TEXTURE_MIN_FILTER,f.min),c.texParameteri(u,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(u,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),0===a?(c.texParameteri(u,c.TEXTURE_COMPARE_FUNC,n.LEQUAL),c.texParameteri(u,c.TEXTURE_COMPARE_MODE,c.NONE)):(c.texParameteri(u,c.TEXTURE_COMPARE_FUNC,a),c.texParameteri(u,c.TEXTURE_COMPARE_MODE,c.COMPARE_REF_TO_TEXTURE))},n.prototype.createDepthStencilTexture=function(e,t){if(t.isCube){var i=e.width||e;return this._createDepthStencilCubeTexture(i,t)}return this._createDepthStencilTexture(e,t)},n.prototype._createDepthStencilTexture=function(t,i){var r=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_DEPTHTEXTURE);if(!this._caps.depthTextureExtension)return e.Tools.Error("Depth texture is not supported by your browser or hardware."),r;var n=s({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},i),o=this._gl;return this._bindTextureDirectly(o.TEXTURE_2D,r,!0),this._setupDepthStencilTexture(r,t,n.generateStencil,n.bilinearFiltering,n.comparisonFunction),this.webGLVersion>1?n.generateStencil?o.texImage2D(o.TEXTURE_2D,0,o.DEPTH24_STENCIL8,r.width,r.height,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_COMPONENT24,r.width,r.height,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null):n.generateStencil?o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_STENCIL,r.width,r.height,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_2D,0,o.DEPTH_COMPONENT,r.width,r.height,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null),this._bindTextureDirectly(o.TEXTURE_2D,null),r},n.prototype._createDepthStencilCubeTexture=function(t,i){var r=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_UNKNOWN);if(r.isCube=!0,1===this.webGLVersion)return e.Tools.Error("Depth cube texture is not supported by WebGL 1."),r;var n=s({bilinearFiltering:!1,comparisonFunction:0,generateStencil:!1},i),o=this._gl;this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,r,!0),this._setupDepthStencilTexture(r,t,n.generateStencil,n.bilinearFiltering,n.comparisonFunction);for(var a=0;a<6;a++)n.generateStencil?o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,o.DEPTH24_STENCIL8,t,t,0,o.DEPTH_STENCIL,o.UNSIGNED_INT_24_8,null):o.texImage2D(o.TEXTURE_CUBE_MAP_POSITIVE_X+a,0,o.DEPTH_COMPONENT24,t,t,0,o.DEPTH_COMPONENT,o.UNSIGNED_INT,null);return this._bindTextureDirectly(o.TEXTURE_CUBE_MAP,null),r},n.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)}},n.prototype.createRenderTargetTexture=function(t,i){var o=new h;void 0!==i&&"object"==typeof i?(o.generateMipMaps=i.generateMipMaps,o.generateDepthBuffer=void 0===i.generateDepthBuffer||i.generateDepthBuffer,o.generateStencilBuffer=o.generateDepthBuffer&&i.generateStencilBuffer,o.type=void 0===i.type?n.TEXTURETYPE_UNSIGNED_INT:i.type,o.samplingMode=void 0===i.samplingMode?e.Texture.TRILINEAR_SAMPLINGMODE:i.samplingMode,o.format=void 0===i.format?n.TEXTUREFORMAT_RGBA:i.format):(o.generateMipMaps=i,o.generateDepthBuffer=!0,o.generateStencilBuffer=!1,o.type=n.TEXTURETYPE_UNSIGNED_INT,o.samplingMode=e.Texture.TRILINEAR_SAMPLINGMODE,o.format=n.TEXTUREFORMAT_RGBA),o.type!==n.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?o.type!==n.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(o.samplingMode=e.Texture.NEAREST_SAMPLINGMODE):o.samplingMode=e.Texture.NEAREST_SAMPLINGMODE;var s=this._gl,a=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(s.TEXTURE_2D,a,!0);var l=t.width||t,c=t.height||t,u=r(o.samplingMode,!!o.generateMipMaps,s);o.type!==n.TEXTURETYPE_FLOAT||this._caps.textureFloat||(o.type=n.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type")),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,u.mag),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,u.min),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texImage2D(s.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(o.type,o.format),l,c,0,this._getInternalFormat(o.format),this._getWebGLTextureType(o.type),null);var f=s.createFramebuffer();return this.bindUnboundFramebuffer(f),s.framebufferTexture2D(s.FRAMEBUFFER,s.COLOR_ATTACHMENT0,s.TEXTURE_2D,a._webGLTexture,0),a._depthStencilBuffer=this._setupFramebufferDepthAttachments(!!o.generateStencilBuffer,o.generateDepthBuffer,l,c),o.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(s.TEXTURE_2D,null),s.bindRenderbuffer(s.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),a._framebuffer=f,a.baseWidth=l,a.baseHeight=c,a.width=l,a.height=c,a.isReady=!0,a.samples=1,a.generateMipMaps=!!o.generateMipMaps,a.samplingMode=o.samplingMode,a.type=o.type,a._generateDepthBuffer=o.generateDepthBuffer,a._generateStencilBuffer=!!o.generateStencilBuffer,this._internalTexturesCache.push(a),a},n.prototype.createMultipleRenderTarget=function(t,i){var o=!1,s=!0,a=!1,l=!1,h=1,c=n.TEXTURETYPE_UNSIGNED_INT,u=e.Texture.TRILINEAR_SAMPLINGMODE,f=new Array,p=new Array;void 0!==i&&(o=void 0!==i.generateMipMaps&&i.generateMipMaps,s=void 0===i.generateDepthBuffer||i.generateDepthBuffer,a=void 0!==i.generateStencilBuffer&&i.generateStencilBuffer,l=void 0!==i.generateDepthTexture&&i.generateDepthTexture,h=i.textureCount||1,i.types&&(f=i.types),i.samplingModes&&(p=i.samplingModes));var d=this._gl,m=d.createFramebuffer();this.bindUnboundFramebuffer(m);for(var _=t.width||t,g=t.height||t,v=[],y=[],b=this._setupFramebufferDepthAttachments(a,s,_,g),x=0;x<h;x++){var T=p[x]||u,E=f[x]||c;E!==n.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?E!==n.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(T=e.Texture.NEAREST_SAMPLINGMODE):T=e.Texture.NEAREST_SAMPLINGMODE;var P=r(T,o,d);E!==n.TEXTURETYPE_FLOAT||this._caps.textureFloat||(E=n.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type"));var A=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_MULTIRENDERTARGET),M=d[this.webGLVersion>1?"COLOR_ATTACHMENT"+x:"COLOR_ATTACHMENT"+x+"_WEBGL"];v.push(A),y.push(M),d.activeTexture(d["TEXTURE"+x]),d.bindTexture(d.TEXTURE_2D,A._webGLTexture),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,P.mag),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,P.min),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texImage2D(d.TEXTURE_2D,0,this._getRGBABufferInternalSizedFormat(E),_,g,0,d.RGBA,this._getWebGLTextureType(E),null),d.framebufferTexture2D(d.DRAW_FRAMEBUFFER,M,d.TEXTURE_2D,A._webGLTexture,0),o&&this._gl.generateMipmap(this._gl.TEXTURE_2D),this._bindTextureDirectly(d.TEXTURE_2D,null),A._framebuffer=m,A._depthStencilBuffer=b,A.baseWidth=_,A.baseHeight=g,A.width=_,A.height=g,A.isReady=!0,A.samples=1,A.generateMipMaps=o,A.samplingMode=T,A.type=E,A._generateDepthBuffer=s,A._generateStencilBuffer=a,A._attachments=y,this._internalTexturesCache.push(A)}if(l&&this._caps.depthTextureExtension){var S=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_MULTIRENDERTARGET);d.activeTexture(d.TEXTURE0),d.bindTexture(d.TEXTURE_2D,S._webGLTexture),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MAG_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_MIN_FILTER,d.NEAREST),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_S,d.CLAMP_TO_EDGE),d.texParameteri(d.TEXTURE_2D,d.TEXTURE_WRAP_T,d.CLAMP_TO_EDGE),d.texImage2D(d.TEXTURE_2D,0,this.webGLVersion<2?d.DEPTH_COMPONENT:d.DEPTH_COMPONENT16,_,g,0,d.DEPTH_COMPONENT,d.UNSIGNED_SHORT,null),d.framebufferTexture2D(d.FRAMEBUFFER,d.DEPTH_ATTACHMENT,d.TEXTURE_2D,S._webGLTexture,0),S._framebuffer=m,S.baseWidth=_,S.baseHeight=g,S.width=_,S.height=g,S.isReady=!0,S.samples=1,S.generateMipMaps=o,S.samplingMode=d.NEAREST,S._generateDepthBuffer=s,S._generateStencilBuffer=a,v.push(S),this._internalTexturesCache.push(S)}return d.drawBuffers(y),d.bindRenderbuffer(d.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),this.resetTextureCache(),v},n.prototype._setupFramebufferDepthAttachments=function(e,t,i,r,n){void 0===n&&(n=1);var o=null,s=this._gl;return e?(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH24_STENCIL8,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_STENCIL,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_STENCIL_ATTACHMENT,s.RENDERBUFFER,o)):t&&(o=s.createRenderbuffer(),s.bindRenderbuffer(s.RENDERBUFFER,o),n>1?s.renderbufferStorageMultisample(s.RENDERBUFFER,n,s.DEPTH_COMPONENT16,i,r):s.renderbufferStorage(s.RENDERBUFFER,s.DEPTH_COMPONENT16,i,r),s.framebufferRenderbuffer(s.FRAMEBUFFER,s.DEPTH_ATTACHMENT,s.RENDERBUFFER,o)),o},n.prototype.updateRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e)return 1;if(e.samples===t)return t;var i=this._gl;if(t=Math.min(t,i.getParameter(i.MAX_SAMPLES)),e._depthStencilBuffer&&(i.deleteRenderbuffer(e._depthStencilBuffer),e._depthStencilBuffer=null),e._MSAAFramebuffer&&(i.deleteFramebuffer(e._MSAAFramebuffer),e._MSAAFramebuffer=null),e._MSAARenderBuffer&&(i.deleteRenderbuffer(e._MSAARenderBuffer),e._MSAARenderBuffer=null),t>1){var r=i.createFramebuffer();if(!r)throw new Error("Unable to create multi sampled framebuffer");e._MSAAFramebuffer=r,this.bindUnboundFramebuffer(e._MSAAFramebuffer);var n=i.createRenderbuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,n),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(e.type),e.width,e.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.RENDERBUFFER,n),e._MSAARenderBuffer=n}else this.bindUnboundFramebuffer(e._framebuffer);return e.samples=t,e._depthStencilBuffer=this._setupFramebufferDepthAttachments(e._generateStencilBuffer,e._generateDepthBuffer,e.width,e.height,t),i.bindRenderbuffer(i.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),t},n.prototype.updateMultipleRenderTargetTextureSampleCount=function(e,t){if(this.webGLVersion<2||!e||0==e.length)return 1;if(e[0].samples===t)return t;var i=this._gl;t=Math.min(t,i.getParameter(i.MAX_SAMPLES)),e[0]._depthStencilBuffer&&(i.deleteRenderbuffer(e[0]._depthStencilBuffer),e[0]._depthStencilBuffer=null),e[0]._MSAAFramebuffer&&(i.deleteFramebuffer(e[0]._MSAAFramebuffer),e[0]._MSAAFramebuffer=null);for(var r=0;r<e.length;r++)e[r]._MSAARenderBuffer&&(i.deleteRenderbuffer(e[r]._MSAARenderBuffer),e[r]._MSAARenderBuffer=null);if(t>1){var n=i.createFramebuffer();if(!n)throw new Error("Unable to create multi sampled framebuffer");this.bindUnboundFramebuffer(n);for(var o=this._setupFramebufferDepthAttachments(e[0]._generateStencilBuffer,e[0]._generateDepthBuffer,e[0].width,e[0].height,t),s=[],r=0;r<e.length;r++){var a=e[r],l=i[this.webGLVersion>1?"COLOR_ATTACHMENT"+r:"COLOR_ATTACHMENT"+r+"_WEBGL"],h=i.createRenderbuffer();if(!h)throw new Error("Unable to create multi sampled framebuffer");i.bindRenderbuffer(i.RENDERBUFFER,h),i.renderbufferStorageMultisample(i.RENDERBUFFER,t,this._getRGBAMultiSampleBufferFormat(a.type),a.width,a.height),i.framebufferRenderbuffer(i.FRAMEBUFFER,l,i.RENDERBUFFER,h),a._MSAAFramebuffer=n,a._MSAARenderBuffer=h,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},n.prototype._uploadDataToTexture=function(e,t,i,r,n,o,s,a){this._gl.texImage2D(e,t,i,r,n,0,o,s,a)},n.prototype._uploadCompressedDataToTexture=function(e,t,i,r,n,o){this._gl.compressedTexImage2D(e,t,i,r,n,0,o)},n.prototype.createRenderTargetCubeTexture=function(t,i){var o=s({generateMipMaps:!0,generateDepthBuffer:!0,generateStencilBuffer:!1,type:n.TEXTURETYPE_UNSIGNED_INT,samplingMode:e.Texture.TRILINEAR_SAMPLINGMODE,format:n.TEXTUREFORMAT_RGBA},i);o.generateStencilBuffer=o.generateDepthBuffer&&o.generateStencilBuffer,o.type!==n.TEXTURETYPE_FLOAT||this._caps.textureFloatLinearFiltering?o.type!==n.TEXTURETYPE_HALF_FLOAT||this._caps.textureHalfFloatLinearFiltering||(o.samplingMode=e.Texture.NEAREST_SAMPLINGMODE):o.samplingMode=e.Texture.NEAREST_SAMPLINGMODE;var a=this._gl,l=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RENDERTARGET);this._bindTextureDirectly(a.TEXTURE_CUBE_MAP,l,!0);var h=r(o.samplingMode,o.generateMipMaps,a);o.type!==n.TEXTURETYPE_FLOAT||this._caps.textureFloat||(o.type=n.TEXTURETYPE_UNSIGNED_INT,e.Tools.Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type")),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,h.mag),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,h.min),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE);for(var c=0;c<6;c++)a.texImage2D(a.TEXTURE_CUBE_MAP_POSITIVE_X+c,0,this._getRGBABufferInternalSizedFormat(o.type,o.format),t,t,0,this._getInternalFormat(o.format),this._getWebGLTextureType(o.type),null);var u=a.createFramebuffer();return this.bindUnboundFramebuffer(u),l._depthStencilBuffer=this._setupFramebufferDepthAttachments(o.generateStencilBuffer,o.generateDepthBuffer,t,t),o.generateMipMaps&&a.generateMipmap(a.TEXTURE_CUBE_MAP),this._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null),a.bindRenderbuffer(a.RENDERBUFFER,null),this.bindUnboundFramebuffer(null),l._framebuffer=u,l.width=t,l.height=t,l.isReady=!0,l.isCube=!0,l.samples=1,l.generateMipMaps=o.generateMipMaps,l.samplingMode=o.samplingMode,l.type=o.type,l._generateDepthBuffer=o.generateDepthBuffer,l._generateStencilBuffer=o.generateStencilBuffer,this._internalTexturesCache.push(l),l},n.prototype.createPrefilteredCubeTexture=function(t,i,r,n,o,s,a,l){var h=this;void 0===o&&(o=null),void 0===s&&(s=null),void 0===l&&(l=null);var c=function(t){if(!t)return void(o&&o(null));var s=t.texture;if(t.info.sphericalPolynomial&&(s._sphericalPolynomial=t.info.sphericalPolynomial),s._dataSource=e.InternalTexture.DATASOURCE_CUBEPREFILTERED,s._lodGenerationScale=r,s._lodGenerationOffset=n,h._caps.textureLOD)return void(o&&o(s));var a=h._gl,l=t.width;if(l){for(var c=[],u=0;u<3;u++){var f=u/2,p=1-f,d=n,m=e.Scalar.Log2(l)*r+n,_=d+(m-d)*p,g=Math.round(Math.min(Math.max(_,0),m)),v=new e.InternalTexture(h,e.InternalTexture.DATASOURCE_TEMP);if(v.isCube=!0,h._bindTextureDirectly(a.TEXTURE_CUBE_MAP,v,!0),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MAG_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_MIN_FILTER,a.LINEAR),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_S,a.CLAMP_TO_EDGE),a.texParameteri(a.TEXTURE_CUBE_MAP,a.TEXTURE_WRAP_T,a.CLAMP_TO_EDGE),t.isDDS){var y=t.info,b=t.data;a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL,y.isCompressed?1:0),e.DDSTools.UploadDDSLevels(h,h._gl,b,y,!0,6,g)}else e.Tools.Warn("DDS is the only prefiltered cube map supported so far.");h._bindTextureDirectly(a.TEXTURE_CUBE_MAP,null);var x=new e.BaseTexture(i);x.isCube=!0,x._texture=v,v.isReady=!0,c.push(x)}s._lodTextureHigh=c[2],s._lodTextureMid=c[1],s._lodTextureLow=c[0],o&&o(s)}};return this.createCubeTexture(t,i,null,!1,c,s,a,l,!0)},n.prototype.createCubeTexture=function(t,i,r,n,s,a,l,h,c){var u=this;void 0===s&&(s=null),void 0===a&&(a=null),void 0===h&&(h=null),void 0===c&&(c=!1);var f=this._gl,p=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_CUBE);p.isCube=!0,p.url=t,p.generateMipMaps=!n,this._doNotHandleContextLost||(p._extension=h,p._files=r);var d=!1,m=!1,_=t.lastIndexOf("."),g=h||(_>-1?t.substring(_).toLowerCase():"");this._textureFormatInUse?(g=this._textureFormatInUse,t=(_>-1?t.substring(0,_):t)+this._textureFormatInUse,d=!0):m=".dds"===g;var v=function(e,t){a&&e&&a(e.status+" "+e.statusText,t)};if(d)this._loadFile(t,(function(t){var i=new e.KhronosTextureContainer(t,6),r=i.numberOfMipmapLevels>1&&!n;u._bindTextureDirectly(f.TEXTURE_CUBE_MAP,p,!0),f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,1),i.uploadLevels(u._gl,!n),u.setCubeMapTextureParams(f,r),p.width=i.pixelWidth,p.height=i.pixelHeight,p.isReady=!0}),void 0,void 0,!0,v);else if(m)r&&6===r.length?this._cascadeLoadFiles(i,(function(t){for(var i,r=!1,o=0,a=0;a<t.length;a++){var l=t[a];i=e.DDSTools.GetDDSInfo(l),r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n,u._bindTextureDirectly(f.TEXTURE_CUBE_MAP,p,!0),f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,i.isCompressed?1:0),e.DDSTools.UploadDDSLevels(u,u._gl,l,i,r,6,-1,a),n||i.isFourCC||1!==i.mipmapCount||f.generateMipmap(f.TEXTURE_CUBE_MAP),p.width=i.width,p.height=i.height,p.type=i.textureType,o=i.width}u.setCubeMapTextureParams(f,r),p.isReady=!0,s&&s({isDDS:!0,width:o,info:i,imgs:t,texture:p})}),r,a):this._loadFile(t,(function(t){var i=e.DDSTools.GetDDSInfo(t);c&&(i.sphericalPolynomial=new e.SphericalPolynomial);var r=(i.isRGB||i.isLuminance||i.mipmapCount>1)&&!n;u._bindTextureDirectly(f.TEXTURE_CUBE_MAP,p,!0),f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,i.isCompressed?1:0),e.DDSTools.UploadDDSLevels(u,u._gl,t,i,r,6),n||i.isFourCC||1!==i.mipmapCount||f.generateMipmap(f.TEXTURE_CUBE_MAP),u.setCubeMapTextureParams(f,r),p.width=i.width,p.height=i.height,p.isReady=!0,p.type=i.textureType,s&&s({isDDS:!0,width:i.width,info:i,data:t,texture:p})}),void 0,void 0,!0,v);else{if(!r)throw new Error("Cannot load cubemap because files were not defined");o(0,i,(function(t){var i=u.needPOTTextures?e.Tools.GetExponentOfTwo(t[0].width,u._caps.maxCubemapTextureSize):t[0].width,r=i;if(u._prepareWorkingCanvas(),u._workingCanvas&&u._workingContext){u._workingCanvas.width=i,u._workingCanvas.height=r;var o=[f.TEXTURE_CUBE_MAP_POSITIVE_X,f.TEXTURE_CUBE_MAP_POSITIVE_Y,f.TEXTURE_CUBE_MAP_POSITIVE_Z,f.TEXTURE_CUBE_MAP_NEGATIVE_X,f.TEXTURE_CUBE_MAP_NEGATIVE_Y,f.TEXTURE_CUBE_MAP_NEGATIVE_Z];u._bindTextureDirectly(f.TEXTURE_CUBE_MAP,p,!0),f.pixelStorei(f.UNPACK_FLIP_Y_WEBGL,0);for(var a=l?u._getInternalFormat(l):u._gl.RGBA,h=0;h<o.length;h++)u._workingContext.drawImage(t[h],0,0,t[h].width,t[h].height,0,0,i,r),f.texImage2D(o[h],0,a,a,f.UNSIGNED_BYTE,u._workingCanvas);n||f.generateMipmap(f.TEXTURE_CUBE_MAP),u.setCubeMapTextureParams(f,!n),p.width=i,p.height=r,p.isReady=!0,l&&(p.format=l),p.onLoadedObservable.notifyObservers(p),p.onLoadedObservable.clear(),s&&s()}}),r,a)}return this._internalTexturesCache.push(p),p},n.prototype.setCubeMapTextureParams=function(e,t){e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_MIN_FILTER,t?e.LINEAR_MIPMAP_LINEAR:e.LINEAR),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_CUBE_MAP,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),this._bindTextureDirectly(e.TEXTURE_CUBE_MAP,null)},n.prototype.updateRawCubeTexture=function(t,i,r,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=0),t._bufferViewArray=i,t.format=r,t.type=n,t.invertY=o,t._compression=s;var l=this._gl,h=this._getWebGLTextureType(n),c=this._getInternalFormat(r),u=this._getRGBABufferInternalSizedFormat(n),f=!1;c===l.RGB&&(c=l.RGBA,f=!0),this._bindTextureDirectly(l.TEXTURE_CUBE_MAP,t,!0),l.pixelStorei(l.UNPACK_FLIP_Y_WEBGL,void 0===o?1:o?1:0),t.width%4!=0&&l.pixelStorei(l.UNPACK_ALIGNMENT,1);for(var p=0;p<6;p++){var d=i[p];s?l.compressedTexImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+p,a,this.getCaps().s3tc[s],t.width,t.height,0,d):(f&&(d=this._convertRGBtoRGBATextureData(d,t.width,t.height,n)),l.texImage2D(l.TEXTURE_CUBE_MAP_POSITIVE_X+p,a,u,t.width,t.height,0,c,h,d))}(!this.needPOTTextures||e.Tools.IsExponentOfTwo(t.width)&&e.Tools.IsExponentOfTwo(t.height))&&t.generateMipMaps&&0===a&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),t.isReady=!0},n.prototype.createRawCubeTexture=function(t,i,n,o,s,a,l,h){void 0===h&&(h=null);var c=this._gl,u=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_CUBERAW);u.isCube=!0,u.generateMipMaps=s,u.format=n,u.type=o,this._doNotHandleContextLost||(u._bufferViewArray=t);var f=this._getWebGLTextureType(o),p=this._getInternalFormat(n);p===c.RGB&&(p=c.RGBA);var d=i,m=d;if(u.width=d,u.height=m,!this.needPOTTextures||e.Tools.IsExponentOfTwo(u.width)&&e.Tools.IsExponentOfTwo(u.height)||(s=!1),t&&this.updateRawCubeTexture(u,t,n,o,a,h),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,u,!0),t&&s&&this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP),f!==c.FLOAT||this._caps.textureFloatLinearFiltering)if(f!==this._gl.HALF_FLOAT_OES||this._caps.textureHalfFloatLinearFiltering){var _=r(l,s,c);c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,_.mag),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,_.min)}else c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.NEAREST);else c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MAG_FILTER,c.NEAREST),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_MIN_FILTER,c.NEAREST);return c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_S,c.CLAMP_TO_EDGE),c.texParameteri(c.TEXTURE_CUBE_MAP,c.TEXTURE_WRAP_T,c.CLAMP_TO_EDGE),this._bindTextureDirectly(c.TEXTURE_CUBE_MAP,null),u},n.prototype.createRawCubeTextureFromUrl=function(t,i,r,n,o,s,a,l,h,c,u,f){var p=this;void 0===h&&(h=null),void 0===c&&(c=null),void 0===u&&(u=e.Texture.TRILINEAR_SAMPLINGMODE),void 0===f&&(f=!1);var d=this._gl,m=this.createRawCubeTexture(null,r,n,o,!s,f,u);i._addPendingData(m),m.url=t,this._internalTexturesCache.push(m);var _=function(e,t){i._removePendingData(m),c&&e&&c(e.status+" "+e.statusText,t)},g=function(e){var t=m.width,r=a(e);if(r){if(l){var c=p._getWebGLTextureType(o),u=p._getInternalFormat(n),_=p._getRGBABufferInternalSizedFormat(o),g=!1;u===d.RGB&&(u=d.RGBA,g=!0),p._bindTextureDirectly(d.TEXTURE_CUBE_MAP,m,!0),d.pixelStorei(d.UNPACK_FLIP_Y_WEBGL,0);for(var v=l(r),y=0;y<v.length;y++)for(var b=t>>y,x=0;x<6;x++){var T=v[y][x];g&&(T=p._convertRGBtoRGBATextureData(T,b,b,o)),d.texImage2D(x,y,_,b,b,0,u,c,T)}p._bindTextureDirectly(d.TEXTURE_CUBE_MAP,null)}else m.generateMipMaps=!s,p.updateRawCubeTexture(m,r,n,o,f);m.isReady=!0,i._removePendingData(m),h&&h()}};return this._loadFile(t,(function(e){g(e)}),void 0,i.database,!0,_),m},n.prototype.updateRawTexture3D=function(e,t,i,r,n){void 0===n&&(n=null);var o=this._getInternalFormat(i);this._bindTextureDirectly(this._gl.TEXTURE_3D,e,!0),this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL,void 0===r?1:r?1:0),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,o,e.width,e.height,e.depth,0,o,this._gl.UNSIGNED_BYTE,t),e.generateMipMaps&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),e.isReady=!0},n.prototype.createRawTexture3D=function(t,i,n,o,s,a,l,h,c){void 0===c&&(c=null);var u=new e.InternalTexture(this,e.InternalTexture.DATASOURCE_RAW3D);u.baseWidth=i,u.baseHeight=n,u.baseDepth=o,u.width=i,u.height=n,u.depth=o,u.format=s,u.generateMipMaps=a,u.samplingMode=h,u.is3D=!0,this._doNotHandleContextLost||(u._bufferView=t),this.updateRawTexture3D(u,t,s,l,c),this._bindTextureDirectly(this._gl.TEXTURE_3D,u,!0);var f=r(h,a,this._gl);return this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MAG_FILTER,f.mag),this._gl.texParameteri(this._gl.TEXTURE_3D,this._gl.TEXTURE_MIN_FILTER,f.min),a&&this._gl.generateMipmap(this._gl.TEXTURE_3D),this._bindTextureDirectly(this._gl.TEXTURE_3D,null),this._internalTexturesCache.push(u),u},n.prototype._prepareWebGLTextureContinuation=function(e,t,i,n,o){var s=this._gl;if(s){var a=r(o,!i,s);s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,a.mag),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,a.min),i||n||s.generateMipmap(s.TEXTURE_2D),this._bindTextureDirectly(s.TEXTURE_2D,null),t&&t._removePendingData(e),e.onLoadedObservable.notifyObservers(e),e.onLoadedObservable.clear()}},n.prototype._prepareWebGLTexture=function(t,i,r,n,o,s,a,l,h){var c=this;void 0===h&&(h=e.Texture.TRILINEAR_SAMPLINGMODE);var u=this.needPOTTextures?e.Tools.GetExponentOfTwo(r,this.getCaps().maxTextureSize):r,f=this.needPOTTextures?e.Tools.GetExponentOfTwo(n,this.getCaps().maxTextureSize):n,p=this._gl;if(p){if(!t._webGLTexture)return void(i&&i._removePendingData(t));this._bindTextureDirectly(p.TEXTURE_2D,t,!0),p.pixelStorei(p.UNPACK_FLIP_Y_WEBGL,void 0===o?1:o?1:0),t.baseWidth=r,t.baseHeight=n,t.width=u,t.height=f,t.isReady=!0,l(u,f,(function(){c._prepareWebGLTextureContinuation(t,i,s,a,h)}))||this._prepareWebGLTextureContinuation(t,i,s,a,h)}},n.prototype._convertRGBtoRGBATextureData=function(e,t,i,r){var o;o=r===n.TEXTURETYPE_FLOAT?new Float32Array(t*i*4):new Uint32Array(t*i*4);for(var s=0;s<t;s++)for(var a=0;a<i;a++){var l=3*(a*t+s),h=4*(a*t+s);o[h+0]=e[l+0],o[h+1]=e[l+1],o[h+2]=e[l+2],o[h+3]=1}return o},n.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)},n.prototype._releaseTexture=function(e){var t=this._gl
;this._releaseFramebufferObjects(e),t.deleteTexture(e._webGLTexture),this.unbindAllTextures();var i=this._internalTexturesCache.indexOf(e);-1!==i&&this._internalTexturesCache.splice(i,1),e._lodTextureHigh&&e._lodTextureHigh.dispose(),e._lodTextureMid&&e._lodTextureMid.dispose(),e._lodTextureLow&&e._lodTextureLow.dispose(),this.scenes.forEach((function(t){t.postProcesses.forEach((function(t){t._outputTexture==e&&(t._outputTexture=null)})),t.cameras.forEach((function(t){t._postProcesses.forEach((function(t){t&&t._outputTexture==e&&(t._outputTexture=null)}))}))}))},n.prototype.setProgram=function(e){this._currentProgram!==e&&(this._gl.useProgram(e),this._currentProgram=e)},n.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},n.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))},n.prototype._getCorrectTextureChannel=function(e,t){if(!t)return-1;if(t._initialSlot=e,this.disableTextureBindingOptimization)e!==t._designatedSlot&&this._textureCollisions.addCount(1,!1);else if(e!==t._designatedSlot)return t._designatedSlot>-1?t._designatedSlot:this._nextFreeTextureSlots.length?this._nextFreeTextureSlots[0]:(this._textureCollisions.addCount(1,!1),this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next));return e},n.prototype._linkTrackers=function(e,t){e.next=t,t.previous=e},n.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))},n.prototype._activateCurrentTexture=function(){this._currentTextureChannel!==this._activeChannel&&(this._gl.activeTexture(this._gl.TEXTURE0+this._activeChannel),this._currentTextureChannel=this._activeChannel)},n.prototype._bindTextureDirectly=function(e,t,i,r){void 0===i&&(i=!1),void 0===r&&(r=!1),i&&t&&t._designatedSlot>-1&&(this._activeChannel=t._designatedSlot);var n=this._boundTexturesCache[this._activeChannel],o=t&&t._initialSlot>-1;if(n!==t||r){if(n&&this._removeDesignatedSlot(n),this._activateCurrentTexture(),this._gl.bindTexture(e,t?t._webGLTexture:null),this._boundTexturesCache[this._activeChannel]=t,t){if(!this.disableTextureBindingOptimization){var s=this._nextFreeTextureSlots.indexOf(this._activeChannel);s>-1&&this._nextFreeTextureSlots.splice(s,1),this._linkTrackers(this._lastBoundInternalTextureTracker.previous,t),this._linkTrackers(t,this._lastBoundInternalTextureTracker)}t._designatedSlot=this._activeChannel}}else i&&this._activateCurrentTexture();o&&!i&&this._bindSamplerUniformToChannel(t._initialSlot,this._activeChannel)},n.prototype._bindTexture=function(e,t){e<0||(t&&(e=this._getCorrectTextureChannel(e,t)),this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,t))},n.prototype.setTextureFromPostProcess=function(e,t){this._bindTexture(e,t?t._textures.data[t._currentRenderTextureInd]:null)},n.prototype.setTextureFromPostProcessOutput=function(e,t){this._bindTexture(e,t?t._outputTexture:null)},n.prototype.unbindAllTextures=function(){for(var e=0;e<this._maxSimultaneousTextures;e++)this._activeChannel=e,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)},n.prototype.setTexture=function(e,t,i){e<0||(t&&(this._boundUniforms[e]=t),this._setTexture(e,i))},n.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))},n.prototype._bindSamplerUniformToChannel=function(e,t){var i=this._boundUniforms[e];i._currentState!==t&&(this._gl.uniform1i(i,t),i._currentState=t)},n.prototype._getTextureWrapMode=function(t){switch(t){case e.Texture.WRAP_ADDRESSMODE:return this._gl.REPEAT;case e.Texture.CLAMP_ADDRESSMODE:return this._gl.CLAMP_TO_EDGE;case e.Texture.MIRROR_ADDRESSMODE:return this._gl.MIRRORED_REPEAT}return this._gl.REPEAT},n.prototype._setTexture=function(t,i,r,o){if(void 0===r&&(r=!1),void 0===o&&(o=!1),!i)return null!=this._boundTexturesCache[t]&&(this._activeChannel=t,this._bindTextureDirectly(this._gl.TEXTURE_2D,null),this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,null),this.webGLVersion>1&&this._bindTextureDirectly(this._gl.TEXTURE_3D,null)),!1;if(i.video)this._activeChannel=t,i.update();else if(i.delayLoadState===n.DELAYLOADSTATE_NOTLOADED)return i.delayLoad(),!1;var s;s=o?i.depthStencilTexture:i.isReady()?i.getInternalTexture():i.isCube?this.emptyCubeTexture:i.is3D?this.emptyTexture3D:this.emptyTexture,r||(t=this._getCorrectTextureChannel(t,s));var a=!0;if(this._boundTexturesCache[t]===s&&(this._moveBoundTextureOnTop(s),r||this._bindSamplerUniformToChannel(s._initialSlot,t),a=!1),this._activeChannel=t,s&&s.is3D)a&&this._bindTextureDirectly(this._gl.TEXTURE_3D,s,r),s&&s._cachedWrapU!==i.wrapU&&(s._cachedWrapU=i.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(i.wrapU),s)),s&&s._cachedWrapV!==i.wrapV&&(s._cachedWrapV=i.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i.wrapV),s)),s&&s._cachedWrapR!==i.wrapR&&(s._cachedWrapR=i.wrapR,this._setTextureParameterInteger(this._gl.TEXTURE_3D,this._gl.TEXTURE_WRAP_R,this._getTextureWrapMode(i.wrapR),s)),this._setAnisotropicLevel(this._gl.TEXTURE_3D,i);else if(s&&s.isCube){if(a&&this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP,s,r),s._cachedCoordinatesMode!==i.coordinatesMode){s._cachedCoordinatesMode=i.coordinatesMode;var l=i.coordinatesMode!==e.Texture.CUBIC_MODE&&i.coordinatesMode!==e.Texture.SKYBOX_MODE?this._gl.REPEAT:this._gl.CLAMP_TO_EDGE;this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_S,l,s),this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP,this._gl.TEXTURE_WRAP_T,l)}this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP,i)}else a&&this._bindTextureDirectly(this._gl.TEXTURE_2D,s,r),s&&s._cachedWrapU!==i.wrapU&&(s._cachedWrapU=i.wrapU,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_S,this._getTextureWrapMode(i.wrapU),s)),s&&s._cachedWrapV!==i.wrapV&&(s._cachedWrapV=i.wrapV,this._setTextureParameterInteger(this._gl.TEXTURE_2D,this._gl.TEXTURE_WRAP_T,this._getTextureWrapMode(i.wrapV),s)),this._setAnisotropicLevel(this._gl.TEXTURE_2D,i);return!0},n.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)}},n.prototype._setAnisotropicLevel=function(t,i){var r=i.getInternalTexture();if(r){var n=this._caps.textureAnisotropicFilterExtension,o=i.anisotropicFilteringLevel;r.samplingMode!==e.Texture.LINEAR_LINEAR_MIPNEAREST&&r.samplingMode!==e.Texture.LINEAR_LINEAR_MIPLINEAR&&r.samplingMode!==e.Texture.LINEAR_LINEAR&&(o=1),n&&r._cachedAnisotropicFilteringLevel!==o&&(this._setTextureParameterFloat(t,n.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(o,this._caps.maxAnisotropy),r),r._cachedAnisotropicFilteringLevel=o)}},n.prototype._setTextureParameterFloat=function(e,t,i,r){this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameterf(e,t,i)},n.prototype._setTextureParameterInteger=function(e,t,i,r){r&&this._bindTextureDirectly(e,r,!0,!0),this._gl.texParameteri(e,t,i)},n.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},n.prototype.addExternalData=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,i)},n.prototype.getExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.get(t)},n.prototype.getOrAddExternalDataWithFactory=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,i)},n.prototype.removeExternalData=function(t){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.remove(t)},n.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 for(var e=0,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)},n.prototype.releaseEffects=function(){for(var e in this._compiledEffects)this._deleteProgram(this._compiledEffects[e]._program);this._compiledEffects={}},n.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();n.audioEngine&&n.audioEngine.dispose(),this.releaseEffects(),this.unbindAllAttributes(),this._boundUniforms=[],this._dummyFramebuffer&&this._gl.deleteFramebuffer(this._dummyFramebuffer),this.disableVR(),e.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 t=n.Instances.indexOf(this);t>=0&&n.Instances.splice(t,1),this._workingCanvas=null,this._workingContext=null,this._currentBufferPointers=[],this._renderingCanvas=null,this._currentProgram=null,this._bindedRenderFunction=null,this.onResizeObservable.clear(),this.onCanvasBlurObservable.clear(),this.onCanvasFocusObservable.clear(),this.onCanvasPointerOutObservable.clear(),this.onBeginFrameObservable.clear(),this.onEndFrameObservable.clear(),e.Effect.ResetCache();for(var i=0,r=this._activeRequests;i<r.length;i++){r[i].abort()}},n.prototype.displayLoadingUI=function(){if(e.Tools.IsWindowObjectExist()){var t=this.loadingScreen;t&&t.displayLoadingUI()}},n.prototype.hideLoadingUI=function(){if(e.Tools.IsWindowObjectExist()){var t=this.loadingScreen;t&&t.hideLoadingUI()}},Object.defineProperty(n.prototype,"loadingScreen",{get:function(){return!this._loadingScreen&&e.DefaultLoadingScreen&&this._renderingCanvas&&(this._loadingScreen=new e.DefaultLoadingScreen(this._renderingCanvas)),this._loadingScreen},set:function(e){this._loadingScreen=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"loadingUIText",{set:function(e){this.loadingScreen.loadingUIText=e},enumerable:!0,configurable:!0}),Object.defineProperty(n.prototype,"loadingUIBackgroundColor",{set:function(e){this.loadingScreen.loadingUIBackgroundColor=e},enumerable:!0,configurable:!0}),n.prototype.attachContextLostEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextlost",e,!1)},n.prototype.attachContextRestoredEvent=function(e){this._renderingCanvas&&this._renderingCanvas.addEventListener("webglcontextrestored",e,!1)},n.prototype.getVertexShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[0]):null},n.prototype.getFragmentShaderSource=function(e){var t=this._gl.getAttachedShaders(e);return t?this._gl.getShaderSource(t[1]):null},n.prototype.getError=function(){return this._gl.getError()},n.prototype.getFps=function(){return this._fps},n.prototype.getDeltaTime=function(){return this._deltaTime},n.prototype._measureFps=function(){this._performanceMonitor.sampleFrame(),this._fps=this._performanceMonitor.averageFPS,this._deltaTime=this._performanceMonitor.instantaneousFrameTime||0},n.prototype._readTexturePixels=function(e,t,i,r){void 0===r&&(r=-1);var n=this._gl;if(!this._dummyFramebuffer){var o=n.createFramebuffer();if(!o)throw new Error("Unable to create dummy framebuffer");this._dummyFramebuffer=o}n.bindFramebuffer(n.FRAMEBUFFER,this._dummyFramebuffer),r>-1?n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_CUBE_MAP_POSITIVE_X+r,e._webGLTexture,0):n.framebufferTexture2D(n.FRAMEBUFFER,n.COLOR_ATTACHMENT0,n.TEXTURE_2D,e._webGLTexture,0);var s,a=void 0!==e.type?this._getWebGLTextureType(e.type):n.UNSIGNED_BYTE;switch(a){case n.UNSIGNED_BYTE:s=new Uint8Array(4*t*i),a=n.UNSIGNED_BYTE;break;default:s=new Float32Array(4*t*i),a=n.FLOAT}return n.readPixels(0,0,t,i,n.RGBA,a,s),n.bindFramebuffer(n.FRAMEBUFFER,this._currentFramebuffer),s},n.prototype._canRenderToFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(n.TEXTURETYPE_FLOAT)},n.prototype._canRenderToHalfFloatFramebuffer=function(){return this._webGLVersion>1?this._caps.colorBufferFloat:this._canRenderToFramebuffer(n.TEXTURETYPE_HALF_FLOAT)},n.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&&o===t.FRAMEBUFFER_COMPLETE,i=i&&t.getError()===t.NO_ERROR,i&&(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},n.prototype._getWebGLTextureType=function(e){return e===n.TEXTURETYPE_FLOAT?this._gl.FLOAT:e===n.TEXTURETYPE_HALF_FLOAT?this._gl.HALF_FLOAT_OES:this._gl.UNSIGNED_BYTE},n.prototype._getInternalFormat=function(e){var t=this._gl.RGBA;switch(e){case n.TEXTUREFORMAT_ALPHA:t=this._gl.ALPHA;break;case n.TEXTUREFORMAT_LUMINANCE:t=this._gl.LUMINANCE;break;case n.TEXTUREFORMAT_LUMINANCE_ALPHA:t=this._gl.LUMINANCE_ALPHA;break;case n.TEXTUREFORMAT_RGB:case n.TEXTUREFORMAT_RGB32F:t=this._gl.RGB;break;case n.TEXTUREFORMAT_RGBA:case n.TEXTUREFORMAT_RGBA32F:t=this._gl.RGBA;break;case n.TEXTUREFORMAT_R32F:t=this._gl.RED;break;case n.TEXTUREFORMAT_RG32F:t=this._gl.RG}return t},n.prototype._getRGBABufferInternalSizedFormat=function(e,t){if(1===this._webGLVersion){if(t)switch(t){case n.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE}return this._gl.RGBA}if(e===n.TEXTURETYPE_FLOAT){if(t)switch(t){case n.TEXTUREFORMAT_R32F:return this._gl.R32F;case n.TEXTUREFORMAT_RG32F:return this._gl.RG32F;case n.TEXTUREFORMAT_RGB32F:return this._gl.RGB32F}return this._gl.RGBA32F}if(e===n.TEXTURETYPE_HALF_FLOAT)return this._gl.RGBA16F;if(t)switch(t){case n.TEXTUREFORMAT_LUMINANCE:return this._gl.LUMINANCE;case n.TEXTUREFORMAT_RGB:return this._gl.RGB}return this._gl.RGBA},n.prototype._getRGBAMultiSampleBufferFormat=function(e){return e===n.TEXTURETYPE_FLOAT?this._gl.RGBA32F:e===n.TEXTURETYPE_HALF_FLOAT?this._gl.RGBA16F:this._gl.RGBA8},n.prototype.createQuery=function(){return this._gl.createQuery()},n.prototype.deleteQuery=function(e){return this._gl.deleteQuery(e),this},n.prototype.isQueryResultAvailable=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT_AVAILABLE)},n.prototype.getQueryResult=function(e){return this._gl.getQueryParameter(e,this._gl.QUERY_RESULT)},n.prototype.beginOcclusionQuery=function(e,t){var i=this.getGlAlgorithmType(e);return this._gl.beginQuery(i,t),this},n.prototype.endOcclusionQuery=function(e){var t=this.getGlAlgorithmType(e);return this._gl.endQuery(t),this},n.prototype._createTimeQuery=function(){var e=this._caps.timerQuery;return e.createQueryEXT?e.createQueryEXT():this.createQuery()},n.prototype._deleteTimeQuery=function(e){var t=this._caps.timerQuery;if(t.deleteQueryEXT)return void t.deleteQueryEXT(e);this.deleteQuery(e)},n.prototype._getTimeQueryResult=function(e){var t=this._caps.timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT):this.getQueryResult(e)},n.prototype._getTimeQueryAvailability=function(e){var t=this._caps.timerQuery;return t.getQueryObjectEXT?t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT):this.isQueryResultAvailable(e)},n.prototype.startTimeQuery=function(){var t=this._caps.timerQuery;if(!t)return null;var i=new e._TimeToken;if(this._gl.getParameter(t.GPU_DISJOINT_EXT),this._caps.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},n.prototype.endTimeQuery=function(e){var t=this._caps.timerQuery;if(!t||!e)return-1;if(this._caps.canUseTimestampForTimerQuery){if(!e._startTimeQuery)return-1;e._endTimeQuery||(e._endTimeQuery=this._createTimeQuery(),t.queryCounterEXT(e._endTimeQuery,t.TIMESTAMP_EXT))}else if(!e._timeElapsedQueryEnded){if(!e._timeElapsedQuery)return-1;t.endQueryEXT?t.endQueryEXT(t.TIME_ELAPSED_EXT):this._gl.endQuery(t.TIME_ELAPSED_EXT),e._timeElapsedQueryEnded=!0}var i=this._gl.getParameter(t.GPU_DISJOINT_EXT),r=!1;if(e._endTimeQuery?r=this._getTimeQueryAvailability(e._endTimeQuery):e._timeElapsedQuery&&(r=this._getTimeQueryAvailability(e._timeElapsedQuery)),r&&!i){var n=0;if(this._caps.canUseTimestampForTimerQuery){if(!e._startTimeQuery||!e._endTimeQuery)return-1;var o=this._getTimeQueryResult(e._startTimeQuery);n=this._getTimeQueryResult(e._endTimeQuery)-o,this._deleteTimeQuery(e._startTimeQuery),this._deleteTimeQuery(e._endTimeQuery),e._startTimeQuery=null,e._endTimeQuery=null}else{if(!e._timeElapsedQuery)return-1;n=this._getTimeQueryResult(e._timeElapsedQuery),this._deleteTimeQuery(e._timeElapsedQuery),e._timeElapsedQuery=null,e._timeElapsedQueryEnded=!1,this._currentNonTimestampToken=null}return n}return-1},n.prototype.getGlAlgorithmType=function(t){return t===e.AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE?this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE:this._gl.ANY_SAMPLES_PASSED},n.prototype.createTransformFeedback=function(){return this._gl.createTransformFeedback()},n.prototype.deleteTransformFeedback=function(e){this._gl.deleteTransformFeedback(e)},n.prototype.bindTransformFeedback=function(e){this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK,e)},n.prototype.beginTransformFeedback=function(e){void 0===e&&(e=!0),this._gl.beginTransformFeedback(e?this._gl.POINTS:this._gl.TRIANGLES)},n.prototype.endTransformFeedback=function(){this._gl.endTransformFeedback()},n.prototype.setTranformFeedbackVaryings=function(e,t){this._gl.transformFeedbackVaryings(e,t,this._gl.INTERLEAVED_ATTRIBS)},n.prototype.bindTransformFeedbackBuffer=function(e){this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER,0,e)},n.prototype._loadFile=function(t,i,r,n,o,s){var a=this,l=e.Tools.LoadFile(t,i,r,n,o,s);return this._activeRequests.push(l),l.onCompleteObservable.add((function(e){a._activeRequests.splice(a._activeRequests.indexOf(e),1)})),l},n.prototype._loadFileAsync=function(e,t,i){var r=this;return new Promise(function(n,o){r._loadFile(e,(function(e){n(e)}),void 0,t,i,(function(e,t){o(t)}))})},n.prototype._partialLoadFile=function(e,t,i,r,n,o){void 0===o&&(o=null);var s=function(e){i[t]=e,6===++i._internalCount&&n(i)},a=function(e,t){o&&e&&o(e.status+" "+e.statusText,t)};this._loadFile(e,s,void 0,void 0,!0,a)},n.prototype._cascadeLoadFiles=function(e,t,i,r){void 0===r&&(r=null);var n=[];n._internalCount=0;for(var o=0;o<6;o++)this._partialLoadFile(i[o],o,n,e,t,r)},n.isSupported=function(){try{var e=document.createElement("canvas");return null!=(e.getContext("webgl")||e.getContext("experimental-webgl"))&&!!window.WebGLRenderingContext}catch(e){return!1}},n.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"]}],n.Instances=new Array,n._ALPHA_DISABLE=0,n._ALPHA_ADD=1,n._ALPHA_COMBINE=2,n._ALPHA_SUBTRACT=3,n._ALPHA_MULTIPLY=4,n._ALPHA_MAXIMIZED=5,n._ALPHA_ONEONE=6,n._ALPHA_PREMULTIPLIED=7,n._ALPHA_PREMULTIPLIED_PORTERDUFF=8,n._ALPHA_INTERPOLATE=9,n._ALPHA_SCREENMODE=10,n._DELAYLOADSTATE_NONE=0,n._DELAYLOADSTATE_LOADED=1,n._DELAYLOADSTATE_LOADING=2,n._DELAYLOADSTATE_NOTLOADED=4,n._TEXTUREFORMAT_ALPHA=0,n._TEXTUREFORMAT_LUMINANCE=1,n._TEXTUREFORMAT_LUMINANCE_ALPHA=2,n._TEXTUREFORMAT_RGB=4,n._TEXTUREFORMAT_RGBA=5,n._TEXTUREFORMAT_R32F=6,n._TEXTUREFORMAT_RG32F=7,n._TEXTUREFORMAT_RGB32F=8,n._TEXTUREFORMAT_RGBA32F=9,n._TEXTURETYPE_UNSIGNED_INT=0,n._TEXTURETYPE_FLOAT=1,n._TEXTURETYPE_HALF_FLOAT=2,n._NEVER=512,n._ALWAYS=519,n._LESS=513,n._EQUAL=514,n._LEQUAL=515,n._GREATER=516,n._GEQUAL=518,n._NOTEQUAL=517,n._KEEP=7680,n._REPLACE=7681,n._INCR=7682,n._DECR=7683,n._INVERT=5386,n._INCR_WRAP=34055,n._DECR_WRAP=34056,n._SCALEMODE_FLOOR=1,n._SCALEMODE_NEAREST=2,n._SCALEMODE_CEILING=3,n.CollisionsEpsilon=.001,n.CodeRepository="src/",n.ShadersRepository="src/Shaders/",n})();e.Engine=f})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i){void 0===i&&(i=null),this.state="",this.metadata=null,this.doNotSerialize=!1,this._isDisposed=!1,this.animations=new Array,this._ranges={},this._isEnabled=!0,this._isReady=!0,this._currentRenderId=-1,this._parentRenderId=-1,this._childRenderId=-1,this._animationPropertiesOverride=null,this.onDisposeObservable=new e.Observable,this._behaviors=new Array,this.name=t,this.id=t,this._scene=i||e.Engine.LastCreatedScene,this.uniqueId=this._scene.getUniqueId(),this._initCache()}return t.prototype.isDisposed=function(){return this._isDisposed},Object.defineProperty(t.prototype,"parent",{get:function(){return this._parentNode},set:function(e){if(this._parentNode!==e){if(this._parentNode&&void 0!==this._parentNode._children&&null!==this._parentNode._children){var t=this._parentNode._children.indexOf(this);-1!==t&&this._parentNode._children.splice(t,1)}this._parentNode=e,this._parentNode&&(void 0!==this._parentNode._children&&null!==this._parentNode._children||(this._parentNode._children=new Array),this._parentNode._children.push(this))}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride?this._animationPropertiesOverride:this._scene.animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"Node"},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}),t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._scene.getEngine()},t.prototype.addBehavior=function(e){var t=this;if(-1!==this._behaviors.indexOf(e))return this;if(e.init(),this._scene.isLoading)var i=this._scene.onDataLoadedObservable.add((function(){e.attach(t),setTimeout((function(){t._scene.onDataLoadedObservable.remove(i)}),0)}));else e.attach(this);return this._behaviors.push(e),this},t.prototype.removeBehavior=function(e){var t=this._behaviors.indexOf(e);return-1===t?this:(this._behaviors[t].detach(),this._behaviors.splice(t,1),this)},Object.defineProperty(t.prototype,"behaviors",{get:function(){return this._behaviors},enumerable:!0,configurable:!0}),t.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},t.prototype.getWorldMatrix=function(){return e.Matrix.Identity()},t.prototype._getWorldMatrixDeterminant=function(){return 1},t.prototype._initCache=function(){this._cache={},this._cache.parent=void 0},t.prototype.updateCache=function(e){!e&&this.isSynchronized()||(this._cache.parent=this.parent,this._updateCache())},t.prototype._updateCache=function(e){},t.prototype._isSynchronized=function(){return!0},t.prototype._markSyncedWithParent=function(){this.parent&&(this._parentRenderId=this.parent._childRenderId)},t.prototype.isSynchronizedWithParent=function(){return!this.parent||this._parentRenderId===this.parent._childRenderId&&this.parent.isSynchronized()},t.prototype.isSynchronized=function(e){var t=this.hasNewParent();return t=t||!this.isSynchronizedWithParent(),t=t||!this._isSynchronized(),e&&this.updateCache(!0),!t},t.prototype.hasNewParent=function(e){return this._cache.parent!==this.parent&&(e&&(this._cache.parent=this.parent),!0)},t.prototype.isReady=function(e){return void 0===e&&(e=!1),this._isReady},t.prototype.isEnabled=function(e){return void 0===e&&(e=!0),!1===e?this._isEnabled:!1!==this._isEnabled&&(void 0===this.parent||null===this.parent||this.parent.isEnabled(e))},t.prototype.setEnabled=function(e){this._isEnabled=e},t.prototype.isDescendantOf=function(e){return!!this.parent&&(this.parent===e||this.parent.isDescendantOf(e))},t.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)}},t.prototype.getDescendants=function(e,t){var i=new Array;return this._getDescendants(i,e,t),i},t.prototype.getChildMeshes=function(t,i){var r=[];return this._getDescendants(r,t,(function(t){return(!i||i(t))&&t instanceof e.AbstractMesh})),r},t.prototype.getChildTransformNodes=function(t,i){var r=[];return this._getDescendants(r,t,(function(t){return(!i||i(t))&&t instanceof e.TransformNode})),r},t.prototype.getChildren=function(e){return this.getDescendants(!0,e)},t.prototype._setReady=function(e){if(e!==this._isReady){if(!e)return void(this._isReady=!1);this.onReady&&this.onReady(this),this._isReady=!0}},t.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},t.prototype.createAnimationRange=function(t,i,r){if(!this._ranges[t]){this._ranges[t]=new e.AnimationRange(t,i,r);for(var n=0,o=this.animations.length;n<o;n++)this.animations[n]&&this.animations[n].createRange(t,i,r)}},t.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},t.prototype.getAnimationRange=function(e){return this._ranges[e]},t.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},t.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},t.prototype.computeWorldMatrix=function(t){return e.Matrix.Identity()},t.prototype.dispose=function(e,t){if(void 0===t&&(t=!1),e)for(var i=this.getChildTransformNodes(!0),r=0,n=i;r<n.length;r++){var o=n[r];o.parent=null,o.computeWorldMatrix(!0)}else for(var s=this.getDescendants(!0),a=0,l=s;a<l.length;a++){var h=l[a];h.dispose(e,t)}this.parent=null,this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear();for(var c=0,u=this._behaviors;c<u.length;c++){u[c].detach()}this._behaviors=[],this._isDisposed=!0},t.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)}},n([e.serialize()],t.prototype,"name",void 0),n([e.serialize()],t.prototype,"id",void 0),n([e.serialize()],t.prototype,"uniqueId",void 0),n([e.serialize()],t.prototype,"state",void 0),n([e.serialize()],t.prototype,"metadata",void 0),t})();e.Node=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i){this._tempRadiusVector=e.Vector3.Zero(),this.reConstruct(t,i)}return t.prototype.reConstruct=function(t,i){this.minimum=t.clone(),this.maximum=i.clone();var r=e.Vector3.Distance(t,i);this.center=e.Vector3.Lerp(t,i,.5),this.radius=.5*r,this.centerWorld=e.Vector3.Zero(),this._update(e.Matrix.Identity())},t.prototype._update=function(t){e.Vector3.TransformCoordinatesToRef(this.center,t,this.centerWorld),e.Vector3.TransformNormalFromFloatsToRef(1,1,1,t,this._tempRadiusVector),this.radiusWorld=Math.max(Math.abs(this._tempRadiusVector.x),Math.abs(this._tempRadiusVector.y),Math.abs(this._tempRadiusVector.z))*this.radius},t.prototype.isInFrustum=function(e){for(var t=0;t<6;t++)if(e[t].dotCoordinate(this.centerWorld)<=-this.radiusWorld)return!1;return!0},t.prototype.intersectsPoint=function(t){var i=this.centerWorld.x-t.x,r=this.centerWorld.y-t.y,n=this.centerWorld.z-t.z,o=Math.sqrt(i*i+r*r+n*n);return!(Math.abs(this.radiusWorld-o)<e.Epsilon)},t.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)},t})();e.BoundingSphere=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(e,t){this.vectorsWorld=new Array,this.reConstruct(e,t)}
return t.prototype.reConstruct=function(t,i){this.minimum=t.clone(),this.maximum=i.clone(),this.vectors=new Array,this.vectors.push(this.minimum.clone()),this.vectors.push(this.maximum.clone()),this.vectors.push(this.minimum.clone()),this.vectors[2].x=this.maximum.x,this.vectors.push(this.minimum.clone()),this.vectors[3].y=this.maximum.y,this.vectors.push(this.minimum.clone()),this.vectors[4].z=this.maximum.z,this.vectors.push(this.maximum.clone()),this.vectors[5].z=this.minimum.z,this.vectors.push(this.maximum.clone()),this.vectors[6].x=this.minimum.x,this.vectors.push(this.maximum.clone()),this.vectors[7].y=this.minimum.y,this.center=this.maximum.add(this.minimum).scale(.5),this.extendSize=this.maximum.subtract(this.minimum).scale(.5),this.directions=[e.Vector3.Zero(),e.Vector3.Zero(),e.Vector3.Zero()];for(var r=0;r<this.vectors.length;r++)this.vectorsWorld[r]=e.Vector3.Zero();this.minimumWorld=e.Vector3.Zero(),this.maximumWorld=e.Vector3.Zero(),this.centerWorld=e.Vector3.Zero(),this.extendSizeWorld=e.Vector3.Zero(),this._update(this._worldMatrix||e.Matrix.Identity())},t.prototype.getWorldMatrix=function(){return this._worldMatrix},t.prototype.setWorldMatrix=function(e){return this._worldMatrix.copyFrom(e),this},t.prototype._update=function(t){e.Vector3.FromFloatsToRef(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,this.minimumWorld),e.Vector3.FromFloatsToRef(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE,this.maximumWorld);for(var i=0;i<this.vectors.length;i++){var r=this.vectorsWorld[i];e.Vector3.TransformCoordinatesToRef(this.vectors[i],t,r),r.x<this.minimumWorld.x&&(this.minimumWorld.x=r.x),r.y<this.minimumWorld.y&&(this.minimumWorld.y=r.y),r.z<this.minimumWorld.z&&(this.minimumWorld.z=r.z),r.x>this.maximumWorld.x&&(this.maximumWorld.x=r.x),r.y>this.maximumWorld.y&&(this.maximumWorld.y=r.y),r.z>this.maximumWorld.z&&(this.maximumWorld.z=r.z)}this.maximumWorld.subtractToRef(this.minimumWorld,this.extendSizeWorld),this.extendSizeWorld.scaleInPlace(.5),this.maximumWorld.addToRef(this.minimumWorld,this.centerWorld),this.centerWorld.scaleInPlace(.5),e.Vector3.FromFloatArrayToRef(t.m,0,this.directions[0]),e.Vector3.FromFloatArrayToRef(t.m,4,this.directions[1]),e.Vector3.FromFloatArrayToRef(t.m,8,this.directions[2]),this._worldMatrix=t},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(t){var i=-e.Epsilon;return!(this.maximumWorld.x-t.x<i||i>t.x-this.minimumWorld.x)&&(!(this.maximumWorld.y-t.y<i||i>t.y-this.minimumWorld.y)&&!(this.maximumWorld.z-t.z<i||i>t.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(t,i,r,n){var o=e.Vector3.Clamp(r,t,i);return e.Vector3.DistanceSquared(r,o)<=n*n},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})();e.BoundingBox=t})(r||(r={}));var r;!(function(e){var t=function(t,i){var r=e.Vector3.Dot(i.centerWorld,t),n=Math.abs(e.Vector3.Dot(i.directions[0],t))*i.extendSize.x,o=Math.abs(e.Vector3.Dot(i.directions[1],t))*i.extendSize.y,s=Math.abs(e.Vector3.Dot(i.directions[2],t))*i.extendSize.z,a=n+o+s;return{min:r-a,max:r+a}},i=function(e,t,i,r){return!(e>r||i>t)},r=function(e,r,n){var o=t(e,r),s=t(e,n);return i(o.min,o.max,s.min,s.max)},n=(function(){function t(t,i){this.minimum=t,this.maximum=i,this._isLocked=!1,this.boundingBox=new e.BoundingBox(t,i),this.boundingSphere=new e.BoundingSphere(t,i)}return Object.defineProperty(t.prototype,"isLocked",{get:function(){return this._isLocked},set:function(e){this._isLocked=e},enumerable:!0,configurable:!0}),t.prototype.update=function(e){this._isLocked||(this.boundingBox._update(e),this.boundingSphere._update(e))},t.prototype.centerOn=function(t,i){return this.minimum=t.subtract(i),this.maximum=t.add(i),this.boundingBox=new e.BoundingBox(this.minimum,this.maximum),this.boundingSphere=new e.BoundingSphere(this.minimum,this.maximum),this},t.prototype.isInFrustum=function(e){return!!this.boundingSphere.isInFrustum(e)&&this.boundingBox.isInFrustum(e)},Object.defineProperty(t.prototype,"diagonalLength",{get:function(){var e=this.boundingBox;return e.maximumWorld.subtract(e.minimumWorld).length()},enumerable:!0,configurable:!0}),t.prototype.isCompletelyInFrustum=function(e){return this.boundingBox.isCompletelyInFrustum(e)},t.prototype._checkCollision=function(e){return e._canDoCollision(this.boundingSphere.centerWorld,this.boundingSphere.radiusWorld,this.boundingBox.minimumWorld,this.boundingBox.maximumWorld)},t.prototype.intersectsPoint=function(e){return!!this.boundingSphere.centerWorld&&(!!this.boundingSphere.intersectsPoint(e)&&!!this.boundingBox.intersectsPoint(e))},t.prototype.intersects=function(t,i){if(!this.boundingSphere.centerWorld||!t.boundingSphere.centerWorld)return!1;if(!e.BoundingSphere.Intersects(this.boundingSphere,t.boundingSphere))return!1;if(!e.BoundingBox.Intersects(this.boundingBox,t.boundingBox))return!1;if(!i)return!0;var n=this.boundingBox,o=t.boundingBox;return!!r(n.directions[0],n,o)&&(!!r(n.directions[1],n,o)&&(!!r(n.directions[2],n,o)&&(!!r(o.directions[0],n,o)&&(!!r(o.directions[1],n,o)&&(!!r(o.directions[2],n,o)&&(!!r(e.Vector3.Cross(n.directions[0],o.directions[0]),n,o)&&(!!r(e.Vector3.Cross(n.directions[0],o.directions[1]),n,o)&&(!!r(e.Vector3.Cross(n.directions[0],o.directions[2]),n,o)&&(!!r(e.Vector3.Cross(n.directions[1],o.directions[0]),n,o)&&(!!r(e.Vector3.Cross(n.directions[1],o.directions[1]),n,o)&&(!!r(e.Vector3.Cross(n.directions[1],o.directions[2]),n,o)&&(!!r(e.Vector3.Cross(n.directions[2],o.directions[0]),n,o)&&(!!r(e.Vector3.Cross(n.directions[2],o.directions[1]),n,o)&&!!r(e.Vector3.Cross(n.directions[2],o.directions[2]),n,o))))))))))))))},t})();e.BoundingInfo=n})(r||(r={}));var r;!(function(e){var t=(function(t){function i(r,n,o){void 0===n&&(n=null),void 0===o&&(o=!0);var s=t.call(this,r,n)||this;return s._forward=new e.Vector3(0,0,1),s._forwardInverted=new e.Vector3(0,0,-1),s._up=new e.Vector3(0,1,0),s._right=new e.Vector3(1,0,0),s._rightInverted=new e.Vector3(-1,0,0),s._rotation=e.Vector3.Zero(),s._scaling=e.Vector3.One(),s._isDirty=!1,s.billboardMode=i.BILLBOARDMODE_NONE,s.scalingDeterminant=1,s.infiniteDistance=!1,s.position=e.Vector3.Zero(),s._localWorld=e.Matrix.Zero(),s._worldMatrix=e.Matrix.Zero(),s._worldMatrixDeterminant=0,s._absolutePosition=e.Vector3.Zero(),s._pivotMatrix=e.Matrix.Identity(),s._postMultiplyPivotMatrix=!1,s._isWorldMatrixFrozen=!1,s.onAfterWorldMatrixUpdateObservable=new e.Observable,s._nonUniformScaling=!1,o&&s.getScene().addTransformNode(s),s}return o(i,t),i.prototype.getClassName=function(){return"TransformNode"},Object.defineProperty(i.prototype,"rotation",{get:function(){return this._rotation},set:function(e){this._rotation=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"scaling",{get:function(){return this._scaling},set:function(e){this._scaling=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rotationQuaternion",{get:function(){return this._rotationQuaternion},set:function(e){this._rotationQuaternion=e,e&&this.rotation.length()&&this.rotation.copyFromFloats(0,0,0)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"forward",{get:function(){return e.Vector3.Normalize(e.Vector3.TransformNormal(this.getScene().useRightHandedSystem?this._forwardInverted:this._forward,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"up",{get:function(){return e.Vector3.Normalize(e.Vector3.TransformNormal(this._up,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"right",{get:function(){return e.Vector3.Normalize(e.Vector3.TransformNormal(this.getScene().useRightHandedSystem?this._rightInverted:this._right,this.getWorldMatrix()))},enumerable:!0,configurable:!0}),i.prototype.getWorldMatrix=function(){return this._currentRenderId!==this.getScene().getRenderId()&&this.computeWorldMatrix(),this._worldMatrix},i.prototype._getWorldMatrixDeterminant=function(){return this._worldMatrixDeterminant},Object.defineProperty(i.prototype,"worldMatrixFromCache",{get:function(){return this._worldMatrix},enumerable:!0,configurable:!0}),i.prototype.updatePoseMatrix=function(e){return this._poseMatrix.copyFrom(e),this},i.prototype.getPoseMatrix=function(){return this._poseMatrix},i.prototype._isSynchronized=function(){return!this._isDirty&&(this.billboardMode===this._cache.billboardMode&&this.billboardMode===i.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)))))))},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.localMatrixUpdated=!1,this._cache.position=e.Vector3.Zero(),this._cache.scaling=e.Vector3.Zero(),this._cache.rotation=e.Vector3.Zero(),this._cache.rotationQuaternion=new e.Quaternion(0,0,0,0),this._cache.billboardMode=-1},i.prototype.markAsDirty=function(e){return"rotation"===e&&(this.rotationQuaternion=null),this._currentRenderId=Number.MAX_VALUE,this._isDirty=!0,this},Object.defineProperty(i.prototype,"absolutePosition",{get:function(){return this._absolutePosition},enumerable:!0,configurable:!0}),i.prototype.setPreTransformMatrix=function(e){return this.setPivotMatrix(e,!1)},i.prototype.setPivotMatrix=function(t,i){return void 0===i&&(i=!0),this._pivotMatrix=t.clone(),this._cache.pivotMatrixUpdated=!0,this._postMultiplyPivotMatrix=i,this._postMultiplyPivotMatrix&&(this._pivotMatrixInverse?this._pivotMatrix.invertToRef(this._pivotMatrixInverse):this._pivotMatrixInverse=e.Matrix.Invert(this._pivotMatrix)),this},i.prototype.getPivotMatrix=function(){return this._pivotMatrix},i.prototype.freezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this._isWorldMatrixFrozen=!0,this},i.prototype.unfreezeWorldMatrix=function(){return this._isWorldMatrixFrozen=!1,this.computeWorldMatrix(!0),this},Object.defineProperty(i.prototype,"isWorldMatrixFrozen",{get:function(){return this._isWorldMatrixFrozen},enumerable:!0,configurable:!0}),i.prototype.getAbsolutePosition=function(){return this.computeWorldMatrix(),this._absolutePosition},i.prototype.setAbsolutePosition=function(t){if(!t)return this;var i,r,n;if(void 0===t.x){if(arguments.length<3)return this;i=arguments[0],r=arguments[1],n=arguments[2]}else i=t.x,r=t.y,n=t.z;if(this.parent){var o=this.parent.getWorldMatrix().clone();o.invert();var s=new e.Vector3(i,r,n);this.position=e.Vector3.TransformCoordinates(s,o)}else this.position.x=i,this.position.y=r,this.position.z=n;return this},i.prototype.setPositionWithLocalVector=function(t){return this.computeWorldMatrix(),this.position=e.Vector3.TransformNormal(t,this._localWorld),this},i.prototype.getPositionExpressedInLocalSpace=function(){this.computeWorldMatrix();var t=this._localWorld.clone();return t.invert(),e.Vector3.TransformNormal(this.position,t)},i.prototype.locallyTranslate=function(t){return this.computeWorldMatrix(!0),this.position=e.Vector3.TransformCoordinates(t,this._localWorld),this},i.prototype.lookAt=function(t,r,n,o,s){void 0===r&&(r=0),void 0===n&&(n=0),void 0===o&&(o=0),void 0===s&&(s=e.Space.LOCAL);var a=i._lookAtVectorCache,l=s===e.Space.LOCAL?this.position:this.getAbsolutePosition();t.subtractToRef(l,a);var h=-Math.atan2(a.z,a.x)-Math.PI/2,c=Math.sqrt(a.x*a.x+a.z*a.z),u=Math.atan2(a.y,c);return this.rotationQuaternion?e.Quaternion.RotationYawPitchRollToRef(h+r,u+n,o,this.rotationQuaternion):(this.rotation.x=u+n,this.rotation.y=h+r,this.rotation.z=o),this},i.prototype.getDirection=function(t){var i=e.Vector3.Zero();return this.getDirectionToRef(t,i),i},i.prototype.getDirectionToRef=function(t,i){return e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),i),this},i.prototype.setPivotPoint=function(t,i){void 0===i&&(i=e.Space.LOCAL),0==this.getScene().getRenderId()&&this.computeWorldMatrix(!0);var r=this.getWorldMatrix();if(i==e.Space.WORLD){var n=e.Tmp.Matrix[0];r.invertToRef(n),t=e.Vector3.TransformCoordinates(t,n)}return this.setPivotMatrix(e.Matrix.Translation(-t.x,-t.y,-t.z),!0)},i.prototype.getPivotPoint=function(){var t=e.Vector3.Zero();return this.getPivotPointToRef(t),t},i.prototype.getPivotPointToRef=function(e){return e.x=-this._pivotMatrix.m[12],e.y=-this._pivotMatrix.m[13],e.z=-this._pivotMatrix.m[14],this},i.prototype.getAbsolutePivotPoint=function(){var t=e.Vector3.Zero();return this.getAbsolutePivotPointToRef(t),t},i.prototype.getAbsolutePivotPointToRef=function(t){return t.x=this._pivotMatrix.m[12],t.y=this._pivotMatrix.m[13],t.z=this._pivotMatrix.m[14],this.getPivotPointToRef(t),e.Vector3.TransformCoordinatesToRef(t,this.getWorldMatrix(),t),this},i.prototype.setParent=function(t){if(null===t){var i=e.Tmp.Quaternion[0],r=e.Tmp.Vector3[0],n=e.Tmp.Vector3[1];this.parent&&this.parent.computeWorldMatrix&&this.parent.computeWorldMatrix(!0),this.computeWorldMatrix(!0),this.getWorldMatrix().decompose(n,i,r),this.rotationQuaternion?this.rotationQuaternion.copyFrom(i):i.toEulerAnglesToRef(this.rotation),this.scaling.x=n.x,this.scaling.y=n.y,this.scaling.z=n.z,this.position.x=r.x,this.position.y=r.y,this.position.z=r.z}else{var i=e.Tmp.Quaternion[0],r=e.Tmp.Vector3[0],n=e.Tmp.Vector3[1],o=e.Tmp.Matrix[0],s=e.Tmp.Matrix[1];this.computeWorldMatrix(!0),t.computeWorldMatrix(!0),t.getWorldMatrix().invertToRef(s),this.getWorldMatrix().multiplyToRef(s,o),o.decompose(n,i,r),this.rotationQuaternion?this.rotationQuaternion.copyFrom(i):i.toEulerAnglesToRef(this.rotation),this.position.x=r.x,this.position.y=r.y,this.position.z=r.z,this.scaling.x=n.x,this.scaling.y=n.y,this.scaling.z=n.z}return this.parent=t,this},Object.defineProperty(i.prototype,"nonUniformScaling",{get:function(){return this._nonUniformScaling},enumerable:!0,configurable:!0}),i.prototype._updateNonUniformScalingState=function(e){return this._nonUniformScaling!==e&&(this._nonUniformScaling=!0,!0)},i.prototype.attachToBone=function(e,t){return this._transformToBoneReferal=t,this.parent=e,e.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this},i.prototype.detachFromBone=function(){return this.parent?(this.parent.getWorldMatrix().determinant()<0&&(this.scalingDeterminant*=-1),this._transformToBoneReferal=null,this.parent=null,this):this},i.prototype.rotate=function(t,r,n){t.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation=e.Vector3.Zero());var o;if(n&&n!==e.Space.LOCAL){if(this.parent){var s=this.parent.getWorldMatrix().clone();s.invert(),t=e.Vector3.TransformNormal(t,s)}o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),o.multiplyToRef(this.rotationQuaternion,this.rotationQuaternion)}else o=e.Quaternion.RotationAxisToRef(t,r,i._rotationAxisCache),this.rotationQuaternion.multiplyToRef(o,this.rotationQuaternion);return this},i.prototype.rotateAround=function(t,i,r){return i.normalize(),this.rotationQuaternion||(this.rotationQuaternion=e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z),this.rotation.copyFromFloats(0,0,0)),t.subtractToRef(this.position,e.Tmp.Vector3[0]),e.Matrix.TranslationToRef(e.Tmp.Vector3[0].x,e.Tmp.Vector3[0].y,e.Tmp.Vector3[0].z,e.Tmp.Matrix[0]),e.Tmp.Matrix[0].invertToRef(e.Tmp.Matrix[2]),e.Matrix.RotationAxisToRef(i,r,e.Tmp.Matrix[1]),e.Tmp.Matrix[2].multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[2]),e.Tmp.Matrix[2].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[2]),e.Tmp.Matrix[2].decompose(e.Tmp.Vector3[0],e.Tmp.Quaternion[0],e.Tmp.Vector3[1]),this.position.addInPlace(e.Tmp.Vector3[1]),e.Tmp.Quaternion[0].multiplyToRef(this.rotationQuaternion,this.rotationQuaternion),this},i.prototype.translate=function(t,i,r){var n=t.scale(i);if(r&&r!==e.Space.LOCAL)this.setAbsolutePosition(this.getAbsolutePosition().add(n));else{var o=this.getPositionExpressedInLocalSpace().add(n);this.setPositionWithLocalVector(o)}return this},i.prototype.addRotation=function(t,i,r){var n;this.rotationQuaternion?n=this.rotationQuaternion:(n=e.Tmp.Quaternion[1],e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,n));var o=e.Tmp.Quaternion[0];return e.Quaternion.RotationYawPitchRollToRef(i,t,r,o),n.multiplyInPlace(o),this.rotationQuaternion||n.toEulerAnglesToRef(this.rotation),this},i.prototype.computeWorldMatrix=function(t){if(this._isWorldMatrixFrozen)return this._worldMatrix;if(!t&&this.isSynchronized(!0))return this._currentRenderId=this.getScene().getRenderId(),this._worldMatrix;if(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,e.Matrix.ScalingToRef(this.scaling.x*this.scalingDeterminant,this.scaling.y*this.scalingDeterminant,this.scaling.z*this.scalingDeterminant,e.Tmp.Matrix[1]),this.rotationQuaternion){this.rotation.length()&&(this.rotationQuaternion.multiplyInPlace(e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)),this.rotation.copyFromFloats(0,0,0))}this.rotationQuaternion?(this.rotationQuaternion.toRotationMatrix(e.Tmp.Matrix[0]),this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)):(e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,e.Tmp.Matrix[0]),this._cache.rotation.copyFrom(this.rotation));var r=this.getScene().activeCamera;if(this.infiniteDistance&&!this.parent&&r){var n=r.getWorldMatrix(),o=new e.Vector3(n.m[12],n.m[13],n.m[14]);e.Matrix.TranslationToRef(this.position.x+o.x,this.position.y+o.y,this.position.z+o.z,e.Tmp.Matrix[2])}else e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,e.Tmp.Matrix[2]);if(this._pivotMatrix.multiplyToRef(e.Tmp.Matrix[1],e.Tmp.Matrix[4]),e.Tmp.Matrix[4].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5]),this.billboardMode!==i.BILLBOARDMODE_NONE&&r){if((this.billboardMode&i.BILLBOARDMODE_ALL)!==i.BILLBOARDMODE_ALL){var s=e.Tmp.Vector3[3];this.parent&&this.parent.getWorldMatrix?this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),e.Vector3.TransformCoordinatesToRef(this.position,e.Tmp.Matrix[6],s)):e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),s):s.copyFrom(this.position),s.subtractInPlace(r.globalPosition);var a=e.Tmp.Vector3[4].copyFromFloats(0,0,0);(this.billboardMode&i.BILLBOARDMODE_X)===i.BILLBOARDMODE_X&&(a.x=Math.atan2(-s.y,s.z)),(this.billboardMode&i.BILLBOARDMODE_Y)===i.BILLBOARDMODE_Y&&(a.y=Math.atan2(s.x,s.z)),(this.billboardMode&i.BILLBOARDMODE_Z)===i.BILLBOARDMODE_Z&&(a.z=Math.atan2(s.y,s.x)),e.Matrix.RotationYawPitchRollToRef(a.y,a.x,a.z,e.Tmp.Matrix[0])}else e.Tmp.Matrix[1].copyFrom(r.getViewMatrix()),e.Tmp.Matrix[1].setTranslationFromFloats(0,0,0),e.Tmp.Matrix[1].invertToRef(e.Tmp.Matrix[0]);e.Tmp.Matrix[1].copyFrom(e.Tmp.Matrix[5]),e.Tmp.Matrix[1].multiplyToRef(e.Tmp.Matrix[0],e.Tmp.Matrix[5])}return e.Tmp.Matrix[5].multiplyToRef(e.Tmp.Matrix[2],this._localWorld),this.parent&&this.parent.getWorldMatrix?(this.billboardMode!==i.BILLBOARDMODE_NONE?(this._transformToBoneReferal?(this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(),e.Tmp.Matrix[6]),e.Tmp.Matrix[5].copyFrom(e.Tmp.Matrix[6])):e.Tmp.Matrix[5].copyFrom(this.parent.getWorldMatrix()),this._localWorld.getTranslationToRef(e.Tmp.Vector3[5]),e.Vector3.TransformCoordinatesToRef(e.Tmp.Vector3[5],e.Tmp.Matrix[5],e.Tmp.Vector3[5]),this._worldMatrix.copyFrom(this._localWorld),this._worldMatrix.setTranslation(e.Tmp.Vector3[5])):this._transformToBoneReferal?(this._localWorld.multiplyToRef(this.parent.getWorldMatrix(),e.Tmp.Matrix[6]),e.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._postMultiplyPivotMatrix&&this._worldMatrix.multiplyToRef(this._pivotMatrixInverse,this._worldMatrix),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=e.Matrix.Invert(this._worldMatrix)),this._worldMatrixDeterminant=this._worldMatrix.determinant(),this._worldMatrix},i.prototype._afterComputeWorldMatrix=function(){},i.prototype.registerAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.add(e),this},i.prototype.unregisterAfterWorldMatrixUpdate=function(e){return this.onAfterWorldMatrixUpdateObservable.removeCallback(e),this},i.prototype.clone=function(t,r,n){var o=this,s=e.SerializationHelper.Clone((function(){return new i(t,o.getScene())}),this);if(s.name=t,s.id=t,r&&(s.parent=r),!n)for(var a=this.getDescendants(!0),l=0;l<a.length;l++){var h=a[l];h.clone&&h.clone(t+"."+h.name,s)}return s},i.prototype.serialize=function(t){var i=e.SerializationHelper.Serialize(this,t);return i.type=this.getClassName(),this.parent&&(i.parentId=this.parent.id),e.Tags&&e.Tags.HasTags(this)&&(i.tags=e.Tags.GetTags(this)),i.localMatrix=this.getPivotMatrix().asArray(),i.isEnabled=this.isEnabled(),this.parent&&(i.parentId=this.parent.id),i},i.Parse=function(t,r,n){var o=e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n);return e.Tags&&e.Tags.AddTagsTo(o,t.tags),t.localMatrix?o.setPreTransformMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&o.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),o.setEnabled(t.isEnabled),t.parentId&&(o._waitingParentId=t.parentId),o},i.prototype.dispose=function(e,i){void 0===i&&(i=!1),this.getScene().stopAnimation(this),this.getScene().removeTransformNode(this),this.onAfterWorldMatrixUpdateObservable.clear(),t.prototype.dispose.call(this,e,i)},i.BILLBOARDMODE_NONE=0,i.BILLBOARDMODE_X=1,i.BILLBOARDMODE_Y=2,i.BILLBOARDMODE_Z=4,i.BILLBOARDMODE_ALL=7,i._lookAtVectorCache=new e.Vector3(0,0,0),i._rotationAxisCache=new e.Quaternion,n([e.serializeAsVector3()],i.prototype,"_rotation",void 0),n([e.serializeAsQuaternion()],i.prototype,"_rotationQuaternion",void 0),n([e.serializeAsVector3()],i.prototype,"_scaling",void 0),n([e.serialize()],i.prototype,"billboardMode",void 0),n([e.serialize()],i.prototype,"scalingDeterminant",void 0),n([e.serialize()],i.prototype,"infiniteDistance",void 0),n([e.serializeAsVector3()],i.prototype,"position",void 0),i})(e.Node);e.TransformNode=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(r,n){void 0===n&&(n=null);var o=t.call(this,r,n,!1)||this;return o._facetNb=0,o._partitioningSubdivisions=10,o._partitioningBBoxRatio=1.01,o._facetDataEnabled=!1,o._facetParameters={},o._bbSize=e.Vector3.Zero(),o._subDiv={max:1,X:1,Y:1,Z:1},o._facetDepthSort=!1,o._facetDepthSortEnabled=!1,o.onCollideObservable=new e.Observable,o.onCollisionPositionChangeObservable=new e.Observable,o.onMaterialChangedObservable=new e.Observable,o.definedFacingForward=!0,o.occlusionQueryAlgorithmType=i.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE,o.occlusionType=i.OCCLUSION_TYPE_NONE,o.occlusionRetryCount=-1,o._occlusionInternalRetryCounter=0,o._isOccluded=!1,o._isOcclusionQueryInProgress=!1,o._visibility=1,o.alphaIndex=Number.MAX_VALUE,o.isVisible=!0,o.isPickable=!0,o.showBoundingBox=!1,o.showSubMeshesBoundingBox=!1,o.isBlocker=!1,o.enablePointerMoveEvents=!1,o.renderingGroupId=0,o._receiveShadows=!1,o.renderOutline=!1,o.outlineColor=e.Color3.Red(),o.outlineWidth=.02,o.renderOverlay=!1,o.overlayColor=e.Color3.Red(),o.overlayAlpha=.5,o._hasVertexAlpha=!1,o._useVertexColors=!0,o._computeBonesUsingShaders=!0,o._numBoneInfluencers=4,o._applyFog=!0,o.useOctreeForRenderingSelection=!0,o.useOctreeForPicking=!0,o.useOctreeForCollisions=!0,o._layerMask=268435455,o.alwaysSelectAsActiveMesh=!1,o.actionManager=null,o.physicsImpostor=null,o._checkCollisions=!1,o._collisionMask=-1,o._collisionGroup=-1,o.ellipsoid=new e.Vector3(.5,1,.5),o.ellipsoidOffset=new e.Vector3(0,0,0),o._oldPositionForCollisions=new e.Vector3(0,0,0),o._diffPositionForCollisions=new e.Vector3(0,0,0),o.edgesWidth=1,o.edgesColor=new e.Color4(1,0,0,1),o._collisionsTransformMatrix=e.Matrix.Zero(),o._collisionsScalingMatrix=e.Matrix.Zero(),o._renderId=0,o._intersectionsInProgress=new Array,o._unIndexed=!1,o._lightSources=new Array,o._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),o.getScene().workerCollisions&&i.multiplyInPlace(o._collider._radius),i.subtractToRef(o._oldPositionForCollisions,o._diffPositionForCollisions),o._diffPositionForCollisions.length()>e.Engine.CollisionsEpsilon&&o.position.addInPlace(o._diffPositionForCollisions),r&&o.onCollideObservable.notifyObservers(r),o.onCollisionPositionChangeObservable.notifyObservers(o.position)},o.getScene().addMesh(o),o._resyncLightSources(),o}return o(i,t),Object.defineProperty(i,"BILLBOARDMODE_NONE",{get:function(){return e.TransformNode.BILLBOARDMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_X",{get:function(){return e.TransformNode.BILLBOARDMODE_X},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Y",{get:function(){return e.TransformNode.BILLBOARDMODE_Y},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_Z",{get:function(){return e.TransformNode.BILLBOARDMODE_Z},enumerable:!0,configurable:!0}),Object.defineProperty(i,"BILLBOARDMODE_ALL",{get:function(){return e.TransformNode.BILLBOARDMODE_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"facetNb",{get:function(){return this._facetNb},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningSubdivisions",{get:function(){return this._partitioningSubdivisions},set:function(e){this._partitioningSubdivisions=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"partitioningBBoxRatio",{get:function(){return this._partitioningBBoxRatio},set:function(e){this._partitioningBBoxRatio=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"mustDepthSortFacets",{get:function(){return this._facetDepthSort},set:function(e){this._facetDepthSort=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"facetDepthSortFrom",{get:function(){return this._facetDepthSortFrom},set:function(e){this._facetDepthSortFrom=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isFacetDataEnabled",{get:function(){return this._facetDataEnabled},enumerable:!0,configurable:!0}),i.prototype._updateNonUniformScalingState=function(e){return!!t.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,"isOccluded",{get:function(){return this._isOccluded},set:function(e){this._isOccluded=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isOcclusionQueryInProgress",{get:function(){return this._isOcclusionQueryInProgress},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(t){var i="Name: "+this.name+", isInstance: "+(this instanceof e.InstancedMesh?"YES":"NO");return i+=", # of submeshes: "+(this.subMeshes?this.subMeshes.length:0),this._skeleton&&(i+=", skeleton: "+this._skeleton.name),t&&(i+=", billboard mode: "+["NONE","X","Y",null,"Z",null,null,"ALL"][this.billboardMode],i+=", freeze wrld mat: "+(this._isWorldMatrixFrozen||this._waitingFreezeWorldMatrix?"YES":"NO")),i},i.prototype._rebuild=function(){if(this._occlusionQuery&&(this._occlusionQuery=null),this._edgesRenderer&&this._edgesRenderer._rebuild(),this.subMeshes)for(var e=0,t=this.subMeshes;e<t.length;e++){var i=t[e];i._rebuild()}},i.prototype._resyncLightSources=function(){this._lightSources.length=0;for(var e=0,t=this.getScene().lights;e<t.length;e++){var i=t[e];i.isEnabled()&&(i.canAffectMesh(this)&&this._lightSources.push(i))}this._markSubMeshesAsLightDirty()},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 t=0,i=this.subMeshes;t<i.length;t++){var r=i[t],n=r.getMaterial();n&&n.markAsDirty(e.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}),i.prototype.disableEdgesRendering=function(){return this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),this},i.prototype.enableEdgesRendering=function(t,i){return void 0===t&&(t=.95),void 0===i&&(i=!1),this.disableEdgesRendering(),this._edgesRenderer=new e.EdgesRenderer(this,t,i),this},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(e.VertexBuffer.MatricesIndicesKind)&&this.isVerticesDataPresent(e.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():t.prototype.getWorldMatrix.call(this)},i.prototype._getWorldMatrixDeterminant=function(){return this._masterMesh?this._masterMesh._getWorldMatrixDeterminant():t.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(t,i,r){var n=new e.Matrix;(this.rotationQuaternion?this.rotationQuaternion:e.Quaternion.RotationYawPitchRoll(this.rotation.y,this.rotation.x,this.rotation.z)).toRotationMatrix(n);var o=e.Vector3.Zero(),s=this.definedFacingForward?-1:1;return e.Vector3.TransformCoordinatesFromFloatsToRef(t*s,i,r*s,n,o),o},i.prototype.rotatePOV=function(e,t,i){return this.rotation.addInPlace(this.calcRotatePOV(e,t,i)),this},i.prototype.calcRotatePOV=function(t,i,r){var n=this.definedFacingForward?1:-1;return new e.Vector3(t*n,i,r*n)},i.prototype.getHierarchyBoundingVectors=function(t){void 0===t&&(t=!0),this.getScene().incrementRenderId(),this.computeWorldMatrix(!0);var i,r,n=this.getBoundingInfo();if(this.subMeshes?(i=n.boundingBox.minimumWorld,r=n.boundingBox.maximumWorld):(i=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE)),t)for(var o=this.getDescendants(!1),s=0,a=o;s<a.length;s++){var l=a[s],h=l;if(h.computeWorldMatrix(!0),h.getBoundingInfo&&0!==h.getTotalVertices()){var c=h.getBoundingInfo(),u=c.boundingBox,f=u.minimumWorld,p=u.maximumWorld;e.Tools.CheckExtends(f,i,r),e.Tools.CheckExtends(p,i,r)}}return{min:i,max:r}},i.prototype._updateBoundingInfo=function(){return this._boundingInfo=this._boundingInfo||new e.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=0;t<this.subMeshes.length;t++){var i=this.subMeshes[t];i.IsGlobal||i.updateBoundingInfo(e)}return this},i.prototype._afterComputeWorldMatrix=function(){this._updateBoundingInfo()},i.prototype.isInFrustum=function(e){return null!==this._boundingInfo&&this._boundingInfo.isInFrustum(e)},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++){var o=n[r];if(o.intersectsMesh(e,t,!0))return!0}return!1},i.prototype.intersectsPoint=function(e){return!!this._boundingInfo&&this._boundingInfo.intersectsPoint(e)},i.prototype.getPhysicsImpostor=function(){return this.physicsImpostor},i.prototype.getPositionInCameraSpace=function(t){return void 0===t&&(t=null),t||(t=this.getScene().activeCamera),e.Vector3.TransformCoordinates(this.absolutePosition,t.getViewMatrix())},i.prototype.getDistanceToCamera=function(e){return void 0===e&&(e=null),e||(e=this.getScene().activeCamera),this.absolutePosition.subtract(e.position).length()},i.prototype.applyImpulse=function(e,t){return this.physicsImpostor?(this.physicsImpostor.applyImpulse(e,t),this):this},i.prototype.setPhysicsLinkWith=function(t,i,r,n){return this.physicsImpostor&&t.physicsImpostor?(this.physicsImpostor.createJoint(t.physicsImpostor,e.PhysicsJoint.HingeJoint,{mainPivot:i,connectedPivot:r,nativeParams:n}),this):this},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(t){return this.getAbsolutePosition().addToRef(this.ellipsoidOffset,this._oldPositionForCollisions),this._collider||(this._collider=new e.Collider),this._collider._radius=this.ellipsoid,this.getScene().collisionCoordinator.getNewPosition(this._oldPositionForCollisions,t,this._collider,3,this,this._onCollisionPositionChange,this.uniqueId),this},i.prototype.createOrUpdateSubmeshesOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._submeshesOctree||(this._submeshesOctree=new e.Octree(e.Octree.CreationFuncForSubMeshes,t,i)),this.computeWorldMatrix(!0);var r=this.getBoundingInfo(),n=r.boundingBox;return this._submeshesOctree.update(n.minimumWorld,n.maximumWorld,this.subMeshes),this._submeshesOctree},i.prototype._collideForSubMesh=function(t,i,r){if(this._generatePointsArray(),!this._positions)return this;if(!t._lastColliderWorldVertices||!t._lastColliderTransformMatrix.equals(i)){t._lastColliderTransformMatrix=i.clone(),t._lastColliderWorldVertices=[],t._trianglePlanes=[];for(var n=t.verticesStart,o=t.verticesStart+t.verticesCount,s=n;s<o;s++)t._lastColliderWorldVertices.push(e.Vector3.TransformCoordinates(this._positions[s],i))}return r._collide(t._trianglePlanes,t._lastColliderWorldVertices,this.getIndices(),t.indexStart,t.indexStart+t.indexCount,t.verticesStart,!!t.getMaterial()),r.collisionFound&&(r.collidedMesh=this),this},i.prototype._processCollisionsForSubMeshes=function(e,t){var i,r;if(this._submeshesOctree&&this.useOctreeForCollisions){var n=e._velocityWorldLength+Math.max(e._radius.x,e._radius.y,e._radius.z),o=this._submeshesOctree.intersects(e._basePointWorld,n);r=o.length,i=o.data}else i=this.subMeshes,r=i.length;for(var s=0;s<r;s++){var a=i[s];r>1&&!a._checkCollision(e)||this._collideForSubMesh(a,t,e)}return this},i.prototype._checkCollision=function(t){return this._boundingInfo&&this._boundingInfo._checkCollision(t)?(e.Matrix.ScalingToRef(1/t._radius.x,1/t._radius.y,1/t._radius.z,this._collisionsScalingMatrix),this.worldMatrixFromCache.multiplyToRef(this._collisionsScalingMatrix,this._collisionsTransformMatrix),this._processCollisionsForSubMeshes(t,this._collisionsTransformMatrix),this):this},i.prototype._generatePointsArray=function(){return!1},i.prototype.intersects=function(t,i){var r=new e.PickingInfo;if(!(this.subMeshes&&this._boundingInfo&&t.intersectsSphere(this._boundingInfo.boundingSphere)&&t.intersectsBox(this._boundingInfo.boundingBox)))return r;if(!this._generatePointsArray())return r;var n,o,s=null;if(this._submeshesOctree&&this.useOctreeForPicking){var a=e.Ray.Transform(t,this.getWorldMatrix()),l=this._submeshesOctree.intersectsRay(a);o=l.length,n=l.data}else n=this.subMeshes,o=n.length;for(var h=0;h<o;h++){var c=n[h];if(!(o>1)||c.canIntersects(t)){var u=c.intersects(t,this._positions,this.getIndices(),i);if(u&&(i||!s||u.distance<s.distance)&&(s=u,s.subMeshId=h,i))break}}if(s){var f=this.getWorldMatrix(),p=e.Vector3.TransformCoordinates(t.origin,f),d=t.direction.clone();d=d.scale(s.distance);var m=e.Vector3.TransformNormal(d,f),_=p.add(m);return r.hit=!0,r.distance=e.Vector3.Distance(p,_),r.pickedPoint=_,r.pickedMesh=this,r.bu=s.bu||0,r.bv=s.bv||0,r.faceId=s.faceId,r.subMeshId=s.subMeshId,r}return r},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,i){var r=this;void 0===i&&(i=!1);var n;for(this.getScene().freeActiveMeshes(),this.getScene().freeRenderingGroups(),void 0!==this.actionManager&&null!==this.actionManager&&(this.actionManager.dispose(),this.actionManager=null),this._skeleton=null,this.physicsImpostor&&this.physicsImpostor.dispose(),n=0;n<this._intersectionsInProgress.length;n++){var o=this._intersectionsInProgress[n],s=o._intersectionsInProgress.indexOf(this);o._intersectionsInProgress.splice(s,1)}this._intersectionsInProgress=[],this.getScene().lights.forEach((function(e){var t=e.includedOnlyMeshes.indexOf(r);-1!==t&&e.includedOnlyMeshes.splice(t,1),-1!==(t=e.excludedMeshes.indexOf(r))&&e.excludedMeshes.splice(t,1);var i=e.getShadowGenerator();if(i){var n=i.getShadowMap();n&&n.renderList&&-1!==(t=n.renderList.indexOf(r))&&n.renderList.splice(t,1)}})),this._edgesRenderer&&(this._edgesRenderer.dispose(),this._edgesRenderer=null),"InstancedMesh"!==this.getClassName()&&this.releaseSubMeshes();var a=this.getScene().selectionOctree;if(void 0!==a&&null!==a){var n=a.dynamicContent.indexOf(this);-1!==n&&a.dynamicContent.splice(n,1)}var l=this.getScene().getEngine();if(this._occlusionQuery&&(this._isOcclusionQueryInProgress=!1,l.deleteQuery(this._occlusionQuery),this._occlusionQuery=null),l.wipeCaches(),this.getScene().removeMesh(this),i&&this.material&&this.material.dispose(!1,!0),!e)for(n=0;n<this.getScene().particleSystems.length;n++)this.getScene().particleSystems[n].emitter===this&&(this.getScene().particleSystems[n].dispose(),n--);this._facetDataEnabled&&this.disableFacetData(),this.onAfterWorldMatrixUpdateObservable.clear(),this.onCollideObservable.clear(),this.onCollisionPositionChangeObservable.clear(),t.prototype.dispose.call(this,e,i)},i.prototype.addChild=function(e){return e.setParent(this),this},i.prototype.removeChild=function(e){return e.setParent(null),this},i.prototype._initFacetData=function(){this._facetNormals||(this._facetNormals=new Array),this._facetPositions||(this._facetPositions=new Array),this._facetPartitioning||(this._facetPartitioning=new Array),this._facetNb=this.getIndices().length/3|0,this._partitioningSubdivisions=this._partitioningSubdivisions?this._partitioningSubdivisions:10,this._partitioningBBoxRatio=this._partitioningBBoxRatio?this._partitioningBBoxRatio:1.01;for(var t=0;t<this._facetNb;t++)this._facetNormals[t]=e.Vector3.Zero(),this._facetPositions[t]=e.Vector3.Zero();return this._facetDataEnabled=!0,this},i.prototype.updateFacetData=function(){this._facetDataEnabled||this._initFacetData();var t=this.getVerticesData(e.VertexBuffer.PositionKind),i=this.getIndices(),r=this.getVerticesData(e.VertexBuffer.NormalKind),n=this.getBoundingInfo();if(this._facetDepthSort&&!this._facetDepthSortEnabled){if(this._facetDepthSortEnabled=!0,i instanceof Uint16Array)this._depthSortedIndices=new Uint16Array(i);else if(i instanceof Uint32Array)this._depthSortedIndices=new Uint32Array(i);else{for(var o=!1,s=0;s<i.length;s++)if(i[s]>65535){o=!0;break}this._depthSortedIndices=o?new Uint32Array(i):new Uint16Array(i)}if(this._facetDepthSortFunction=function(e,t){return t.sqDistance-e.sqDistance},!this._facetDepthSortFrom){var a=this.getScene().activeCamera;this._facetDepthSortFrom=a?a.position:e.Vector3.Zero()}this._depthSortedFacets=[];for(var l=0;l<this._facetNb;l++){var h={ind:3*l,sqDistance:0};this._depthSortedFacets.push(h)}this._invertedMatrix=e.Matrix.Identity(),this._facetDepthSortOrigin=e.Vector3.Zero()}this._bbSize.x=n.maximum.x-n.minimum.x>e.Epsilon?n.maximum.x-n.minimum.x:e.Epsilon,this._bbSize.y=n.maximum.y-n.minimum.y>e.Epsilon?n.maximum.y-n.minimum.y:e.Epsilon,this._bbSize.z=n.maximum.z-n.minimum.z>e.Epsilon?n.maximum.z-n.minimum.z:e.Epsilon;var c=this._bbSize.x>this._bbSize.y?this._bbSize.x:this._bbSize.y;if(c=c>this._bbSize.z?c:this._bbSize.z,this._subDiv.max=this._partitioningSubdivisions,this._subDiv.X=Math.floor(this._subDiv.max*this._bbSize.x/c),this._subDiv.Y=Math.floor(this._subDiv.max*this._bbSize.y/c),this._subDiv.Z=Math.floor(this._subDiv.max*this._bbSize.z/c),this._subDiv.X=this._subDiv.X<1?1:this._subDiv.X,this._subDiv.Y=this._subDiv.Y<1?1:this._subDiv.Y,this._subDiv.Z=this._subDiv.Z<1?1:this._subDiv.Z,this._facetParameters.facetNormals=this.getFacetLocalNormals(),this._facetParameters.facetPositions=this.getFacetLocalPositions(),this._facetParameters.facetPartitioning=this.getFacetLocalPartitioning(),this._facetParameters.bInfo=n,this._facetParameters.bbSize=this._bbSize,this._facetParameters.subDiv=this._subDiv,this._facetParameters.ratio=this.partitioningBBoxRatio,this._facetParameters.depthSort=this._facetDepthSort,this._facetDepthSort&&this._facetDepthSortEnabled&&(this.computeWorldMatrix(!0),this._worldMatrix.invertToRef(this._invertedMatrix),e.Vector3.TransformCoordinatesToRef(this._facetDepthSortFrom,this._invertedMatrix,this._facetDepthSortOrigin),this._facetParameters.distanceTo=this._facetDepthSortOrigin),this._facetParameters.depthSortedFacets=this._depthSortedFacets,e.VertexData.ComputeNormals(t,i,r,this._facetParameters),this._facetDepthSort&&this._facetDepthSortEnabled){this._depthSortedFacets.sort(this._facetDepthSortFunction);for(var u=this._depthSortedIndices.length/3|0,l=0;l<u;l++){var f=this._depthSortedFacets[l].ind;this._depthSortedIndices[3*l]=i[f],this._depthSortedIndices[3*l+1]=i[f+1],this._depthSortedIndices[3*l+2]=i[f+2]}this.updateIndices(this._depthSortedIndices)}return this},i.prototype.getFacetLocalNormals=function(){return this._facetNormals||this.updateFacetData(),this._facetNormals},i.prototype.getFacetLocalPositions=function(){return this._facetPositions||this.updateFacetData(),this._facetPositions},i.prototype.getFacetLocalPartitioning=function(){return this._facetPartitioning||this.updateFacetData(),this._facetPartitioning},i.prototype.getFacetPosition=function(t){var i=e.Vector3.Zero();return this.getFacetPositionToRef(t,i),i},i.prototype.getFacetPositionToRef=function(t,i){var r=this.getFacetLocalPositions()[t],n=this.getWorldMatrix();return e.Vector3.TransformCoordinatesToRef(r,n,i),this},i.prototype.getFacetNormal=function(t){var i=e.Vector3.Zero();return this.getFacetNormalToRef(t,i),i},i.prototype.getFacetNormalToRef=function(t,i){var r=this.getFacetLocalNormals()[t];return e.Vector3.TransformNormalToRef(r,this.getWorldMatrix(),i),this},i.prototype.getFacetsAtLocalCoordinates=function(e,t,i){var r=this.getBoundingInfo(),n=Math.floor((e-r.minimum.x*this._partitioningBBoxRatio)*this._subDiv.X*this._partitioningBBoxRatio/this._bbSize.x),o=Math.floor((t-r.minimum.y*this._partitioningBBoxRatio)*this._subDiv.Y*this._partitioningBBoxRatio/this._bbSize.y),s=Math.floor((i-r.minimum.z*this._partitioningBBoxRatio)*this._subDiv.Z*this._partitioningBBoxRatio/this._bbSize.z);return n<0||n>this._subDiv.max||o<0||o>this._subDiv.max||s<0||s>this._subDiv.max?null:this._facetPartitioning[n+this._subDiv.max*o+this._subDiv.max*this._subDiv.max*s]},i.prototype.getClosestFacetAtCoordinates=function(t,i,r,n,o,s){void 0===o&&(o=!1),void 0===s&&(s=!0);var a=this.getWorldMatrix(),l=e.Tmp.Matrix[5];a.invertToRef(l);var h=e.Tmp.Vector3[8];e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,l,h);var c=this.getClosestFacetAtLocalCoordinates(h.x,h.y,h.z,n,o,s);return n&&e.Vector3.TransformCoordinatesFromFloatsToRef(n.x,n.y,n.z,a,n),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,h=0,c=0,u=0,f=0,p=0,d=0,m=this.getFacetLocalPositions(),_=this.getFacetLocalNormals(),g=this.getFacetsAtLocalCoordinates(e,t,i);if(!g)return null;for(var v,y,b,x=Number.MAX_VALUE,T=x,E=0;E<g.length;E++)v=g[E],y=_[v],b=m[v],c=(e-b.x)*y.x+(t-b.y)*y.y+(i-b.z)*y.z,(!n||n&&o&&c>=0||n&&!o&&c<=0)&&(c=y.x*b.x+y.y*b.y+y.z*b.z,u=-(y.x*e+y.y*t+y.z*i-c)/(y.x*y.x+y.y*y.y+y.z*y.z),f=e+y.x*u,p=t+y.y*u,d=i+y.z*u,a=f-e,l=p-t,h=d-i,(T=a*a+l*l+h*h)<x&&(x=T,s=v,r&&(r.x=f,r.y=p,r.z=d)));return s},i.prototype.getFacetDataParameters=function(){return this._facetParameters},i.prototype.disableFacetData=function(){return this._facetDataEnabled&&(this._facetDataEnabled=!1,this._facetPositions=new Array,this._facetNormals=new Array,this._facetPartitioning=new Array,this._facetParameters=null,this._depthSortedIndices=new Uint32Array(0)),this},i.prototype.updateIndices=function(e){return this},i.prototype.createNormals=function(t){var i,r=this.getVerticesData(e.VertexBuffer.PositionKind),n=this.getIndices();return i=this.isVerticesDataPresent(e.VertexBuffer.NormalKind)?this.getVerticesData(e.VertexBuffer.NormalKind):[],e.VertexData.ComputeNormals(r,n,i,{useRightHandedSystem:this.getScene().useRightHandedSystem}),this.setVerticesData(e.VertexBuffer.NormalKind,i,t),this},i.prototype.alignWithNormal=function(t,i){i||(i=e.Axis.Y);var r=e.Tmp.Vector3[0],n=e.Tmp.Vector3[1];return e.Vector3.CrossToRef(i,t,n),e.Vector3.CrossToRef(t,n,r),this.rotationQuaternion?e.Quaternion.RotationQuaternionFromAxisToRef(r,t,n,this.rotationQuaternion):e.Vector3.RotationFromAxisToRef(r,t,n,this.rotation),this},i.prototype._checkOcclusionQuery=function(){var e=this.getEngine();if(e.webGLVersion<2||this.occlusionType===i.OCCLUSION_TYPE_NONE)return void(this._isOccluded=!1);if(this.isOcclusionQueryInProgress&&this._occlusionQuery){if(e.isQueryResultAvailable(this._occlusionQuery)){var t=e.getQueryResult(this._occlusionQuery);this._isOcclusionQueryInProgress=!1,this._occlusionInternalRetryCounter=0,this._isOccluded=1!==t}else{if(this._occlusionInternalRetryCounter++,!(-1!==this.occlusionRetryCount&&this._occlusionInternalRetryCounter>this.occlusionRetryCount))return;this._isOcclusionQueryInProgress=!1,this._occlusionInternalRetryCounter=0,this._isOccluded=this.occlusionType!==i.OCCLUSION_TYPE_OPTIMISTIC&&this._isOccluded}}var r=this.getScene(),n=r.getBoundingBoxRenderer();this._occlusionQuery||(this._occlusionQuery=e.createQuery()),e.beginOcclusionQuery(this.occlusionQueryAlgorithmType,this._occlusionQuery),n.renderOcclusionBoundingBox(this),e.endOcclusionQuery(this.occlusionQueryAlgorithmType),this._isOcclusionQueryInProgress=!0},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})(e.TransformNode);e.AbstractMesh=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(r,n){var o=t.call(this,r,n)||this;return o.diffuse=new e.Color3(1,1,1),o.specular=new e.Color3(1,1,1),o.intensity=1,o.range=Number.MAX_VALUE,o._photometricScale=1,o._intensityMode=i.INTENSITYMODE_AUTOMATIC,o._radius=1e-5,o.renderPriority=0,o.shadowEnabled=!0,o._excludeWithLayerMask=0,o._includeOnlyWithLayerMask=0,o._lightmapMode=0,o._excludedMeshesIds=new Array,o._includedOnlyMeshesIds=new Array,o.getScene().addLight(o),o._uniformBuffer=new e.UniformBuffer(o.getScene().getEngine()),o._buildUniformLayout(),o.includedOnlyMeshes=new Array,o.excludedMeshes=new Array,o._resyncMeshes(),o}return o(i,t),Object.defineProperty(i,"LIGHTMAP_DEFAULT",{get:function(){return i._LIGHTMAP_DEFAULT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SPECULAR",{get:function(){return i._LIGHTMAP_SPECULAR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTMAP_SHADOWSONLY",{get:function(){return i._LIGHTMAP_SHADOWSONLY},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_AUTOMATIC",{get:function(){return i._INTENSITYMODE_AUTOMATIC},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_LUMINOUSPOWER",{get:function(){return i._INTENSITYMODE_LUMINOUSPOWER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_LUMINOUSINTENSITY",{get:function(){return i._INTENSITYMODE_LUMINOUSINTENSITY},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_ILLUMINANCE",{get:function(){return i._INTENSITYMODE_ILLUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"INTENSITYMODE_LUMINANCE",{get:function(){return i._INTENSITYMODE_LUMINANCE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_POINTLIGHT",{get:function(){return i._LIGHTTYPEID_POINTLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_DIRECTIONALLIGHT",{get:function(){return i._LIGHTTYPEID_DIRECTIONALLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_SPOTLIGHT",{get:function(){return i._LIGHTTYPEID_SPOTLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"LIGHTTYPEID_HEMISPHERICLIGHT",{get:function(){return i._LIGHTTYPEID_HEMISPHERICLIGHT},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"intensityMode",{get:function(){return this._intensityMode},set:function(e){this._intensityMode=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,this._computePhotometricScale()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"includedOnlyMeshes",{get:function(){return this._includedOnlyMeshes},set:function(e){this._includedOnlyMeshes=e,this._hookArrayForIncludedOnly(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"excludedMeshes",{get:function(){return this._excludedMeshes},set:function(e){this._excludedMeshes=e,this._hookArrayForExcluded(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"excludeWithLayerMask",{get:function(){return this._excludeWithLayerMask},set:function(e){this._excludeWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"includeOnlyWithLayerMask",{get:function(){return this._includeOnlyWithLayerMask},set:function(e){this._includeOnlyWithLayerMask=e,this._resyncMeshes()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lightmapMode",{get:function(){return this._lightmapMode},set:function(e){this._lightmapMode!==e&&(this._lightmapMode=e,this._markMeshesAsLightDirty())},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"Light"},i.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},i.prototype.setEnabled=function(e){t.prototype.setEnabled.call(this,e),this._resyncMeshes()},i.prototype.getShadowGenerator=function(){return this._shadowGenerator},i.prototype.getAbsolutePosition=function(){return e.Vector3.Zero()},i.prototype.canAffectMesh=function(e){return!e||!(this.includedOnlyMeshes&&this.includedOnlyMeshes.length>0&&-1===this.includedOnlyMeshes.indexOf(e))&&(!(this.excludedMeshes&&this.excludedMeshes.length>0&&-1!==this.excludedMeshes.indexOf(e))&&((0===this.includeOnlyWithLayerMask||0!=(this.includeOnlyWithLayerMask&e.layerMask))&&!(0!==this.excludeWithLayerMask&&this.excludeWithLayerMask&e.layerMask)))},i.prototype.getWorldMatrix=function(){this._currentRenderId=this.getScene().getRenderId(),this._childRenderId=this._currentRenderId;var t=this._getWorldMatrix();return this.parent&&this.parent.getWorldMatrix?(this._parentedWorldMatrix||(this._parentedWorldMatrix=e.Matrix.Identity()),t.multiplyToRef(this.parent.getWorldMatrix(),this._parentedWorldMatrix),this._markSyncedWithParent(),this._parentedWorldMatrix):t},i.CompareLightsPriority=function(e,t){return e.shadowEnabled!==t.shadowEnabled?(t.shadowEnabled?1:0)-(e.shadowEnabled?1:0):t.renderPriority-e.renderPriority},i.prototype.dispose=function(e,i){void 0===i&&(i=!1),this._shadowGenerator&&(this._shadowGenerator.dispose(),this._shadowGenerator=null),this.getScene().stopAnimation(this);for(var r=0,n=this.getScene().meshes;r<n.length;r++){n[r]._removeLightSource(this)}this._uniformBuffer.dispose(),this.getScene().removeLight(this),t.prototype.dispose.call(this,e,i)},i.prototype.getTypeID=function(){return 0},i.prototype.getScaledIntensity=function(){return this._photometricScale*this.intensity},i.prototype.clone=function(t){var r=i.GetConstructorFromName(this.getTypeID(),t,this.getScene());return r?e.SerializationHelper.Clone(r,this):null},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getTypeID(),this.parent&&(t.parentId=this.parent.id),this.excludedMeshes.length>0&&(t.excludedMeshesIds=[],this.excludedMeshes.forEach((function(e){t.excludedMeshesIds.push(e.id)}))),this.includedOnlyMeshes.length>0&&(t.includedOnlyMeshesIds=[],this.includedOnlyMeshes.forEach((function(e){t.includedOnlyMeshesIds.push(e.id)}))),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.GetConstructorFromName=function(t,i,r){switch(t){case 0:return function(){return new e.PointLight(i,e.Vector3.Zero(),r)};case 1:return function(){return new e.DirectionalLight(i,e.Vector3.Zero(),r)};case 2:return function(){return new e.SpotLight(i,e.Vector3.Zero(),e.Vector3.Zero(),0,0,r)};case 3:return function(){return new e.HemisphericLight(i,e.Vector3.Zero(),r)}}return null},i.Parse=function(t,r){var n=i.GetConstructorFromName(t.type,t.name,r);if(!n)return null;var o=e.SerializationHelper.Parse(n,t,r);if(t.excludedMeshesIds&&(o._excludedMeshesIds=t.excludedMeshesIds),t.includedOnlyMeshesIds&&(o._includedOnlyMeshesIds=t.includedOnlyMeshesIds),t.parentId&&(o._waitingParentId=t.parentId),t.animations){for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}e.Node.ParseAnimationRanges(o,t,r)}return t.autoAnimate&&r.beginAnimation(o,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),o},i.prototype._hookArrayForExcluded=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];for(var o=i.apply(e,r),s=0,a=r;s<a.length;s++){a[s]._resyncLighSource(t)}return o};var r=e.splice;e.splice=function(i,n){for(var o=r.apply(e,[i,n]),s=0,a=o;s<a.length;s++){a[s]._resyncLighSource(t)}return o};for(var n=0,o=e;n<o.length;n++){o[n]._resyncLighSource(this)}},i.prototype._hookArrayForIncludedOnly=function(e){var t=this,i=e.push;e.push=function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];var o=i.apply(e,r);return t._resyncMeshes(),o};var r=e.splice;e.splice=function(i,n){var o=r.apply(e,[i,n]);return t._resyncMeshes(),o},this._resyncMeshes()},i.prototype._resyncMeshes=function(){for(var e=0,t=this.getScene().meshes;e<t.length;e++){t[e]._resyncLighSource(this)}},i.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()}},i.prototype._computePhotometricScale=function(){this._photometricScale=this._getPhotometricScale(),this.getScene().resetCachedMaterial()},i.prototype._getPhotometricScale=function(){var e=0,t=this.getTypeID(),r=this.intensityMode;switch(r===i.INTENSITYMODE_AUTOMATIC&&(r=t===i.LIGHTTYPEID_DIRECTIONALLIGHT?i.INTENSITYMODE_ILLUMINANCE:i.INTENSITYMODE_LUMINOUSINTENSITY),t){case i.LIGHTTYPEID_POINTLIGHT:case i.LIGHTTYPEID_SPOTLIGHT:switch(r){case i.INTENSITYMODE_LUMINOUSPOWER:e=1/(4*Math.PI);break;case i.INTENSITYMODE_LUMINOUSINTENSITY:e=1;break;case i.INTENSITYMODE_LUMINANCE:e=this.radius*this.radius}break;case i.LIGHTTYPEID_DIRECTIONALLIGHT:switch(r){case i.INTENSITYMODE_ILLUMINANCE:e=1;break;case i.INTENSITYMODE_LUMINANCE:var n=this.radius;n=Math.max(n,.001);e=2*Math.PI*(1-Math.cos(n))}break;case i.LIGHTTYPEID_HEMISPHERICLIGHT:e=1}return e},i.prototype._reorderLightsInScene=function(){var e=this.getScene();0!=this._renderPriority&&(e.requireLightSorting=!0),this.getScene().sortLightsByPriority()},i._LIGHTMAP_DEFAULT=0,i._LIGHTMAP_SPECULAR=1,i._LIGHTMAP_SHADOWSONLY=2,i._INTENSITYMODE_AUTOMATIC=0,i._INTENSITYMODE_LUMINOUSPOWER=1,i._INTENSITYMODE_LUMINOUSINTENSITY=2,i._INTENSITYMODE_ILLUMINANCE=3,i._INTENSITYMODE_LUMINANCE=4,i._LIGHTTYPEID_POINTLIGHT=0,i._LIGHTTYPEID_DIRECTIONALLIGHT=1,i._LIGHTTYPEID_SPOTLIGHT=2,i._LIGHTTYPEID_HEMISPHERICLIGHT=3,n([e.serializeAsColor3()],i.prototype,"diffuse",void 0),n([e.serializeAsColor3()],i.prototype,"specular",void 0),n([e.serialize()],i.prototype,"intensity",void 0),n([e.serialize()],i.prototype,"range",void 0),n([e.serialize()],i.prototype,"intensityMode",null),n([e.serialize()],i.prototype,"radius",null),n([e.serialize()],i.prototype,"_renderPriority",void 0),n([e.expandToProperty("_reorderLightsInScene")],i.prototype,"renderPriority",void 0),n([e.serialize()],i.prototype,"shadowEnabled",void 0),n([e.serialize("excludeWithLayerMask")],i.prototype,"_excludeWithLayerMask",void 0),
n([e.serialize("includeOnlyWithLayerMask")],i.prototype,"_includeOnlyWithLayerMask",void 0),n([e.serialize("lightmapMode")],i.prototype,"_lightmapMode",void 0),i})(e.Node);e.Light=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(r,n,o,s){void 0===s&&(s=!0);var a=t.call(this,r,o)||this;return a.upVector=e.Vector3.Up(),a.orthoLeft=null,a.orthoRight=null,a.orthoBottom=null,a.orthoTop=null,a.fov=.8,a.minZ=1,a.maxZ=1e4,a.inertia=.9,a.mode=i.PERSPECTIVE_CAMERA,a.isIntermediate=!1,a.viewport=new e.Viewport(0,0,1,1),a.layerMask=268435455,a.fovMode=i.FOVMODE_VERTICAL_FIXED,a.cameraRigMode=i.RIG_MODE_NONE,a._rigCameras=new Array,a._webvrViewMatrix=e.Matrix.Identity(),a._skipRendering=!1,a.customRenderTargets=new Array,a.onViewMatrixChangedObservable=new e.Observable,a.onProjectionMatrixChangedObservable=new e.Observable,a.onAfterCheckInputsObservable=new e.Observable,a.onRestoreStateObservable=new e.Observable,a._computedViewMatrix=e.Matrix.Identity(),a._projectionMatrix=new e.Matrix,a._doNotComputeProjectionMatrix=!1,a._worldMatrix=e.Matrix.Identity(),a._postProcesses=new Array,a._transformMatrix=e.Matrix.Zero(),a._activeMeshes=new e.SmartArray(256),a._globalPosition=e.Vector3.Zero(),a._refreshFrustumPlanes=!0,a.getScene().addCamera(a),s&&!a.getScene().activeCamera&&(a.getScene().activeCamera=a),a.position=n,a}return o(i,t),Object.defineProperty(i,"PERSPECTIVE_CAMERA",{get:function(){return i._PERSPECTIVE_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ORTHOGRAPHIC_CAMERA",{get:function(){return i._ORTHOGRAPHIC_CAMERA},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_VERTICAL_FIXED",{get:function(){return i._FOVMODE_VERTICAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOVMODE_HORIZONTAL_FIXED",{get:function(){return i._FOVMODE_HORIZONTAL_FIXED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_NONE",{get:function(){return i._RIG_MODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_ANAGLYPH",{get:function(){return i._RIG_MODE_STEREOSCOPIC_ANAGLYPH},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED",{get:function(){return i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_STEREOSCOPIC_OVERUNDER",{get:function(){return i._RIG_MODE_STEREOSCOPIC_OVERUNDER},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_VR",{get:function(){return i._RIG_MODE_VR},enumerable:!0,configurable:!0}),Object.defineProperty(i,"RIG_MODE_WEBVR",{get:function(){return i._RIG_MODE_WEBVR},enumerable:!0,configurable:!0}),i.prototype.storeState=function(){return this._stateStored=!0,this._storedFov=this.fov,this},i.prototype._restoreStateValues=function(){return!!this._stateStored&&(this.fov=this._storedFov,!0)},i.prototype.restoreState=function(){return!!this._restoreStateValues()&&(this.onRestoreStateObservable.notifyObservers(this),!0)},i.prototype.getClassName=function(){return"Camera"},i.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(i.prototype,"globalPosition",{get:function(){return this._globalPosition},enumerable:!0,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype.isReady=function(e){if(void 0===e&&(e=!1),e)for(var i=0,r=this._postProcesses;i<r.length;i++){var n=r[i];if(n&&!n.isReady())return!1}return t.prototype.isReady.call(this,e)},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.position=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.upVector=new e.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},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this),this._cache.position.copyFrom(this.position),this._cache.upVector.copyFrom(this.upVector)},i.prototype._isSynchronized=function(){return this._isSynchronizedViewMatrix()&&this._isSynchronizedProjectionMatrix()},i.prototype._isSynchronizedViewMatrix=function(){return!!t.prototype._isSynchronized.call(this)&&(this._cache.position.equals(this.position)&&this._cache.upVector.equals(this.upVector)&&this.isSynchronizedWithParent())},i.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===i.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()},i.prototype.attachControl=function(e,t){},i.prototype.detachControl=function(e){},i.prototype.update=function(){this._checkInputs(),this.cameraRigMode!==i.RIG_MODE_NONE&&this._updateRigCameras()},i.prototype._checkInputs=function(){this.onAfterCheckInputsObservable.notifyObservers(this)},Object.defineProperty(i.prototype,"rigCameras",{get:function(){return this._rigCameras},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rigPostProcess",{get:function(){return this._rigPostProcess},enumerable:!0,configurable:!0}),i.prototype._getFirstPostProcess=function(){for(var e=0;e<this._postProcesses.length;e++)if(null!==this._postProcesses[e])return this._postProcesses[e];return null},i.prototype._cascadePostProcessesToRigCams=function(){var t=this._getFirstPostProcess();t&&t.markTextureDirty();for(var i=0,r=this._rigCameras.length;i<r;i++){var n=this._rigCameras[i],o=n._rigPostProcess;if(o){o instanceof e.PassPostProcess&&(n.isIntermediate=0===this._postProcesses.length),n._postProcesses=this._postProcesses.slice(0).concat(o),o.markTextureDirty()}else n._postProcesses=this._postProcesses.slice(0)}},i.prototype.attachPostProcess=function(t,i){return void 0===i&&(i=null),!t.isReusable()&&this._postProcesses.indexOf(t)>-1?(e.Tools.Error("You're trying to reuse a post process not defined as reusable."),0):(null==i||i<0?this._postProcesses.push(t):null===this._postProcesses[i]?this._postProcesses[i]=t:this._postProcesses.splice(i,0,t),this._cascadePostProcessesToRigCams(),this._postProcesses.indexOf(t))},i.prototype.detachPostProcess=function(e){var t=this._postProcesses.indexOf(e);-1!==t&&(this._postProcesses[t]=null),this._cascadePostProcessesToRigCams()},i.prototype.getWorldMatrix=function(){return this._isSynchronizedViewMatrix()?this._worldMatrix:(this.getViewMatrix(),this._worldMatrix)},i.prototype._getViewMatrix=function(){return e.Matrix.Identity()},i.prototype.getViewMatrix=function(e){return!e&&this._isSynchronizedViewMatrix()?this._computedViewMatrix:(this.updateCache(),this._computedViewMatrix=this._getViewMatrix(),this._currentRenderId=this.getScene().getRenderId(),this._childRenderId=this._currentRenderId,this._refreshFrustumPlanes=!0,this._cameraRigParams&&this._cameraRigParams.vrPreViewMatrix&&this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix,this._computedViewMatrix),this.onViewMatrixChangedObservable.notifyObservers(this),this._computedViewMatrix.invertToRef(this._worldMatrix),this._computedViewMatrix)},i.prototype.freezeProjectionMatrix=function(e){this._doNotComputeProjectionMatrix=!0,void 0!==e&&(this._projectionMatrix=e)},i.prototype.unfreezeProjectionMatrix=function(){this._doNotComputeProjectionMatrix=!1},i.prototype.getProjectionMatrix=function(t){if(this._doNotComputeProjectionMatrix||!t&&this._isSynchronizedProjectionMatrix())return this._projectionMatrix;this._cache.mode=this.mode,this._cache.minZ=this.minZ,this._cache.maxZ=this.maxZ,this._refreshFrustumPlanes=!0;var r=this.getEngine(),n=this.getScene();if(this.mode===i.PERSPECTIVE_CAMERA)this._cache.fov=this.fov,this._cache.fovMode=this.fovMode,this._cache.aspectRatio=r.getAspectRatio(this),this.minZ<=0&&(this.minZ=.1),n.useRightHandedSystem?e.Matrix.PerspectiveFovRHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED):e.Matrix.PerspectiveFovLHToRef(this.fov,r.getAspectRatio(this),this.minZ,this.maxZ,this._projectionMatrix,this.fovMode===i.FOVMODE_VERTICAL_FIXED);else{var o=r.getRenderWidth()/2,s=r.getRenderHeight()/2;n.useRightHandedSystem?e.Matrix.OrthoOffCenterRHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,this.minZ,this.maxZ,this._projectionMatrix):e.Matrix.OrthoOffCenterLHToRef(this.orthoLeft||-o,this.orthoRight||o,this.orthoBottom||-s,this.orthoTop||s,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=r.getRenderWidth(),this._cache.renderHeight=r.getRenderHeight()}return this.onProjectionMatrixChangedObservable.notifyObservers(this),this._projectionMatrix},i.prototype.getTranformationMatrix=function(){return this._computedViewMatrix.multiplyToRef(this._projectionMatrix,this._transformMatrix),this._transformMatrix},i.prototype.updateFrustumPlanes=function(){this._refreshFrustumPlanes&&(this.getTranformationMatrix(),this._frustumPlanes?e.Frustum.GetPlanesToRef(this._transformMatrix,this._frustumPlanes):this._frustumPlanes=e.Frustum.GetPlanes(this._transformMatrix),this._refreshFrustumPlanes=!1)},i.prototype.isInFrustum=function(e){return this.updateFrustumPlanes(),e.isInFrustum(this._frustumPlanes)},i.prototype.isCompletelyInFrustum=function(e){return this.updateFrustumPlanes(),e.isCompletelyInFrustum(this._frustumPlanes)},i.prototype.getForwardRay=function(t,i,r){void 0===t&&(t=100),i||(i=this.getWorldMatrix()),r||(r=this.position);var n=new e.Vector3(0,0,1),o=e.Vector3.TransformNormal(n,i),s=e.Vector3.Normalize(o);return new e.Ray(r,s,t)},i.prototype.dispose=function(e,r){for(void 0===r&&(r=!1),this.onViewMatrixChangedObservable.clear(),this.onProjectionMatrixChangedObservable.clear(),this.onAfterCheckInputsObservable.clear(),this.onRestoreStateObservable.clear(),this.inputs&&this.inputs.clear(),this.getScene().stopAnimation(this),this.getScene().removeCamera(this);this._rigCameras.length>0;){var n=this._rigCameras.pop();n&&n.dispose()}if(this._rigPostProcess)this._rigPostProcess.dispose(this),this._rigPostProcess=null,this._postProcesses=[];else if(this.cameraRigMode!==i.RIG_MODE_NONE)this._rigPostProcess=null,this._postProcesses=[];else for(var o=this._postProcesses.length;--o>=0;){var s=this._postProcesses[o];s&&s.dispose(this)}for(var o=this.customRenderTargets.length;--o>=0;)this.customRenderTargets[o].dispose();this.customRenderTargets=[],this._activeMeshes.dispose(),t.prototype.dispose.call(this,e,r)},Object.defineProperty(i.prototype,"leftCamera",{get:function(){return this._rigCameras.length<1?null:this._rigCameras[0]},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"rightCamera",{get:function(){return this._rigCameras.length<2?null:this._rigCameras[1]},enumerable:!0,configurable:!0}),i.prototype.getLeftTarget=function(){return this._rigCameras.length<1?null:this._rigCameras[0].getTarget()},i.prototype.getRightTarget=function(){return this._rigCameras.length<2?null:this._rigCameras[1].getTarget()},i.prototype.setCameraRigMode=function(t,r){if(this.cameraRigMode!==t){for(;this._rigCameras.length>0;){var n=this._rigCameras.pop();n&&n.dispose()}if(this.cameraRigMode=t,this._cameraRigParams={},this._cameraRigParams.interaxialDistance=r.interaxialDistance||.0637,this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(this._cameraRigParams.interaxialDistance/.0637),this.cameraRigMode!==i.RIG_MODE_NONE){var o=this.createRigCamera(this.name+"_L",0),s=this.createRigCamera(this.name+"_R",1);o&&s&&(this._rigCameras.push(o),this._rigCameras.push(s))}switch(this.cameraRigMode){case i.RIG_MODE_STEREOSCOPIC_ANAGLYPH:this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.AnaglyphPostProcess(this.name+"_anaglyph",1,this._rigCameras);break;case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case i.RIG_MODE_STEREOSCOPIC_OVERUNDER:var a=this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL||this.cameraRigMode===i.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;this._rigCameras[0]._rigPostProcess=new e.PassPostProcess(this.name+"_passthru",1,this._rigCameras[0]),this._rigCameras[1]._rigPostProcess=new e.StereoscopicInterlacePostProcess(this.name+"_stereoInterlace",this._rigCameras,a);break;case i.RIG_MODE_VR:var l=r.vrCameraMetrics||e.VRCameraMetrics.GetDefault();this._rigCameras[0]._cameraRigParams.vrMetrics=l,this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0]._cameraRigParams.vrHMatrix=l.leftHMatrix,this._rigCameras[0]._cameraRigParams.vrPreViewMatrix=l.leftPreViewMatrix,this._rigCameras[0].getProjectionMatrix=this._rigCameras[0]._getVRProjectionMatrix,this._rigCameras[1]._cameraRigParams.vrMetrics=l,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1]._cameraRigParams.vrHMatrix=l.rightHMatrix,this._rigCameras[1]._cameraRigParams.vrPreViewMatrix=l.rightPreViewMatrix,this._rigCameras[1].getProjectionMatrix=this._rigCameras[1]._getVRProjectionMatrix,l.compensateDistortion&&(this._rigCameras[0]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Left",this._rigCameras[0],!1,l),this._rigCameras[1]._rigPostProcess=new e.VRDistortionCorrectionPostProcess("VR_Distort_Compensation_Right",this._rigCameras[1],!0,l));break;case i.RIG_MODE_WEBVR:if(r.vrDisplay){var h=r.vrDisplay.getEyeParameters("left"),c=r.vrDisplay.getEyeParameters("right");this._rigCameras[0].viewport=new e.Viewport(0,0,.5,1),this._rigCameras[0].setCameraRigParameter("left",!0),this._rigCameras[0].setCameraRigParameter("specs",r.specs),this._rigCameras[0].setCameraRigParameter("eyeParameters",h),this._rigCameras[0].setCameraRigParameter("frameData",r.frameData),this._rigCameras[0].setCameraRigParameter("parentCamera",r.parentCamera),this._rigCameras[0]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[0].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[0].parent=this,this._rigCameras[0]._getViewMatrix=this._getWebVRViewMatrix,this._rigCameras[1].viewport=new e.Viewport(.5,0,.5,1),this._rigCameras[1].setCameraRigParameter("eyeParameters",c),this._rigCameras[1].setCameraRigParameter("specs",r.specs),this._rigCameras[1].setCameraRigParameter("frameData",r.frameData),this._rigCameras[1].setCameraRigParameter("parentCamera",r.parentCamera),this._rigCameras[1]._cameraRigParams.vrWorkMatrix=new e.Matrix,this._rigCameras[1].getProjectionMatrix=this._getWebVRProjectionMatrix,this._rigCameras[1].parent=this,this._rigCameras[1]._getViewMatrix=this._getWebVRViewMatrix,i.UseAlternateWebVRRendering&&(this._rigCameras[1]._skipRendering=!0,this._rigCameras[0]._alternateCamera=this._rigCameras[1])}}this._cascadePostProcessesToRigCams(),this.update()}},i.prototype._getVRProjectionMatrix=function(){return e.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},i.prototype._updateCameraRotationMatrix=function(){},i.prototype._updateWebVRCameraRotationMatrix=function(){},i.prototype._getWebVRProjectionMatrix=function(){return e.Matrix.Identity()},i.prototype._getWebVRViewMatrix=function(){return e.Matrix.Identity()},i.prototype.setCameraRigParameter=function(t,i){this._cameraRigParams||(this._cameraRigParams={}),this._cameraRigParams[t]=i,"interaxialDistance"===t&&(this._cameraRigParams.stereoHalfAngle=e.Tools.ToRadians(i/.0637))},i.prototype.createRigCamera=function(e,t){return null},i.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===i.RIG_MODE_STEREOSCOPIC_ANAGLYPH&&(this._rigCameras[0].viewport=this._rigCameras[1].viewport=this.viewport)},i.prototype._setupInputs=function(){},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.type=this.getClassName(),this.parent&&(t.parentId=this.parent.id),this.inputs&&this.inputs.serialize(t),e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t},i.prototype.clone=function(t){return e.SerializationHelper.Clone(i.GetConstructorFromName(this.getClassName(),t,this.getScene(),this.interaxialDistance,this.isStereoscopicSideBySide),this)},i.prototype.getDirection=function(t){var i=e.Vector3.Zero();return this.getDirectionToRef(t,i),i},i.prototype.getDirectionToRef=function(t,i){e.Vector3.TransformNormalToRef(t,this.getWorldMatrix(),i)},i.GetConstructorFromName=function(t,i,r,n,o){switch(void 0===n&&(n=0),void 0===o&&(o=!0),t){case"ArcRotateCamera":return function(){return new e.ArcRotateCamera(i,0,0,1,e.Vector3.Zero(),r)};case"DeviceOrientationCamera":return function(){return new e.DeviceOrientationCamera(i,e.Vector3.Zero(),r)};case"FollowCamera":return function(){return new e.FollowCamera(i,e.Vector3.Zero(),r)};case"ArcFollowCamera":return function(){return new e.ArcFollowCamera(i,0,0,1,null,r)};case"GamepadCamera":return function(){return new e.GamepadCamera(i,e.Vector3.Zero(),r)};case"TouchCamera":return function(){return new e.TouchCamera(i,e.Vector3.Zero(),r)};case"VirtualJoysticksCamera":return function(){return new e.VirtualJoysticksCamera(i,e.Vector3.Zero(),r)};case"WebVRFreeCamera":case"WebVRGamepadCamera":return function(){return new e.WebVRFreeCamera(i,e.Vector3.Zero(),r)};case"VRDeviceOrientationFreeCamera":return function(){return new e.VRDeviceOrientationFreeCamera(i,e.Vector3.Zero(),r)};case"VRDeviceOrientationGamepadCamera":return function(){return new e.VRDeviceOrientationGamepadCamera(i,e.Vector3.Zero(),r)};case"AnaglyphArcRotateCamera":return function(){return new e.AnaglyphArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,r)};case"AnaglyphFreeCamera":return function(){return new e.AnaglyphFreeCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphGamepadCamera":return function(){return new e.AnaglyphGamepadCamera(i,e.Vector3.Zero(),n,r)};case"AnaglyphUniversalCamera":return function(){return new e.AnaglyphUniversalCamera(i,e.Vector3.Zero(),n,r)};case"StereoscopicArcRotateCamera":return function(){return new e.StereoscopicArcRotateCamera(i,0,0,1,e.Vector3.Zero(),n,o,r)};case"StereoscopicFreeCamera":return function(){return new e.StereoscopicFreeCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicGamepadCamera":return function(){return new e.StereoscopicGamepadCamera(i,e.Vector3.Zero(),n,o,r)};case"StereoscopicUniversalCamera":return function(){return new e.StereoscopicUniversalCamera(i,e.Vector3.Zero(),n,o,r)};case"FreeCamera":default:return function(){return new e.UniversalCamera(i,e.Vector3.Zero(),r)}}},i.prototype.computeWorldMatrix=function(){return this.getWorldMatrix()},i.Parse=function(t,r){var n=t.type,o=i.GetConstructorFromName(n,t.name,r,t.interaxial_distance,t.isStereoscopicSideBySide),s=e.SerializationHelper.Parse(o,t,r);if(t.parentId&&(s._waitingParentId=t.parentId),s.inputs&&(s.inputs.parse(t),s._setupInputs()),s.setPosition&&(s.position.copyFromFloats(0,0,0),s.setPosition(e.Vector3.FromArray(t.position))),t.target&&s.setTarget&&s.setTarget(e.Vector3.FromArray(t.target)),t.cameraRigMode){var a=t.interaxial_distance?{interaxialDistance:t.interaxial_distance}:{};s.setCameraRigMode(t.cameraRigMode,a)}if(t.animations){for(var l=0;l<t.animations.length;l++){var h=t.animations[l];s.animations.push(e.Animation.Parse(h))}e.Node.ParseAnimationRanges(s,t,r)}return t.autoAnimate&&r.beginAnimation(s,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),s},i._PERSPECTIVE_CAMERA=0,i._ORTHOGRAPHIC_CAMERA=1,i._FOVMODE_VERTICAL_FIXED=0,i._FOVMODE_HORIZONTAL_FIXED=1,i._RIG_MODE_NONE=0,i._RIG_MODE_STEREOSCOPIC_ANAGLYPH=10,i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL=11,i._RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED=12,i._RIG_MODE_STEREOSCOPIC_OVERUNDER=13,i._RIG_MODE_VR=20,i._RIG_MODE_WEBVR=21,i.ForceAttachControlToAlwaysPreventDefault=!1,i.UseAlternateWebVRRendering=!1,n([e.serializeAsVector3()],i.prototype,"position",void 0),n([e.serializeAsVector3()],i.prototype,"upVector",void 0),n([e.serialize()],i.prototype,"orthoLeft",void 0),n([e.serialize()],i.prototype,"orthoRight",void 0),n([e.serialize()],i.prototype,"orthoBottom",void 0),n([e.serialize()],i.prototype,"orthoTop",void 0),n([e.serialize()],i.prototype,"fov",void 0),n([e.serialize()],i.prototype,"minZ",void 0),n([e.serialize()],i.prototype,"maxZ",void 0),n([e.serialize()],i.prototype,"inertia",void 0),n([e.serialize()],i.prototype,"mode",void 0),n([e.serialize()],i.prototype,"layerMask",void 0),n([e.serialize()],i.prototype,"fovMode",void 0),n([e.serialize()],i.prototype,"cameraRigMode",void 0),n([e.serialize()],i.prototype,"interaxialDistance",void 0),n([e.serialize()],i.prototype,"isStereoscopicSideBySide",void 0),i})(e.Node);e.Camera=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(e){this._renderingGroups=new Array,this._autoClearDepthStencil={},this._customOpaqueSortCompareFn={},this._customAlphaTestSortCompareFn={},this._customTransparentSortCompareFn={},this._renderinGroupInfo=null,this._scene=e;for(var i=t.MIN_RENDERINGGROUPS;i<t.MAX_RENDERINGGROUPS;i++)this._autoClearDepthStencil[i]={autoClear:!0,depth:!0,stencil:!0}}return t.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)},t.prototype.render=function(i,r,n,o){var s=this._scene.onRenderingGroupObservable.hasObservers()?this._scene.onRenderingGroupObservable:null,a=null;if(s&&(this._renderinGroupInfo||(this._renderinGroupInfo=new e.RenderingGroupInfo),a=this._renderinGroupInfo,a.scene=this._scene,a.camera=this._scene.activeCamera),o)for(var l=0;l<this._scene.spriteManagers.length;l++){var h=this._scene.spriteManagers[l];this.dispatchSprites(h)}for(var l=t.MIN_RENDERINGGROUPS;l<t.MAX_RENDERINGGROUPS;l++){this._depthStencilBufferAlreadyCleaned=l===t.MIN_RENDERINGGROUPS;var c=this._renderingGroups[l];if(c||s){var u=0;if(s&&a&&(u=Math.pow(2,l),a.renderStage=e.RenderingGroupInfo.STAGE_PRECLEAR,a.renderingGroupId=l,s.notifyObservers(a,u)),t.AUTOCLEAR){var f=this._autoClearDepthStencil[l];f&&f.autoClear&&this._clearDepthStencilBuffer(f.depth,f.stencil)}s&&a&&(a.renderStage=e.RenderingGroupInfo.STAGE_PREOPAQUE,s.notifyObservers(a,u),a.renderStage=e.RenderingGroupInfo.STAGE_PRETRANSPARENT,s.notifyObservers(a,u)),c&&c.render(i,o,n,r),s&&a&&(a.renderStage=e.RenderingGroupInfo.STAGE_POSTTRANSPARENT,s.notifyObservers(a,u))}}},t.prototype.reset=function(){for(var e=t.MIN_RENDERINGGROUPS;e<t.MAX_RENDERINGGROUPS;e++){var i=this._renderingGroups[e];i&&i.prepare()}},t.prototype.dispose=function(){this.freeRenderingGroups(),this._renderingGroups.length=0},t.prototype.freeRenderingGroups=function(){for(var e=t.MIN_RENDERINGGROUPS;e<t.MAX_RENDERINGGROUPS;e++){var i=this._renderingGroups[e];i&&i.dispose()}},t.prototype._prepareRenderingGroup=function(t){void 0===this._renderingGroups[t]&&(this._renderingGroups[t]=new e.RenderingGroup(t,this._scene,this._customOpaqueSortCompareFn[t],this._customAlphaTestSortCompareFn[t],this._customTransparentSortCompareFn[t]))},t.prototype.dispatchSprites=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchSprites(e)},t.prototype.dispatchParticles=function(e){var t=e.renderingGroupId||0;this._prepareRenderingGroup(t),this._renderingGroups[t].dispatchParticles(e)},t.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)},t.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]}},t.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}},t.MAX_RENDERINGGROUPS=4,t.MIN_RENDERINGGROUPS=0,t.AUTOCLEAR=!0,t})();e.RenderingManager=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i,r,n,o){void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),this.index=t,this._opaqueSubMeshes=new e.SmartArray(256),this._transparentSubMeshes=new e.SmartArray(256),this._alphaTestSubMeshes=new e.SmartArray(256),this._depthOnlySubMeshes=new e.SmartArray(256),this._particleSystems=new e.SmartArray(256),this._spriteManagers=new e.SmartArray(256),this._edgesRenderers=new e.SmartArray(16),this._scene=i,this.opaqueSortCompareFn=r,this.alphaTestSortCompareFn=n,this.transparentSortCompareFn=o}return Object.defineProperty(t.prototype,"opaqueSortCompareFn",{set:function(e){this._opaqueSortCompareFn=e,this._renderOpaque=e?this.renderOpaqueSorted:t.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alphaTestSortCompareFn",{set:function(e){this._alphaTestSortCompareFn=e,this._renderAlphaTest=e?this.renderAlphaTestSorted:t.renderUnsorted},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"transparentSortCompareFn",{set:function(e){this._transparentSortCompareFn=e||t.defaultTransparentSortCompare,this._renderTransparent=this.renderTransparentSorted},enumerable:!0,configurable:!0}),t.prototype.render=function(t,i,r,n){if(t)return void t(this._opaqueSubMeshes,this._alphaTestSubMeshes,this._transparentSubMeshes,this._depthOnlySubMeshes);var o=this._scene.getEngine();0!==this._depthOnlySubMeshes.length&&(o.setColorWrite(!1),this._renderAlphaTest(this._depthOnlySubMeshes),o.setColorWrite(!0)),0!==this._opaqueSubMeshes.length&&this._renderOpaque(this._opaqueSubMeshes),0!==this._alphaTestSubMeshes.length&&this._renderAlphaTest(this._alphaTestSubMeshes);var s=o.getStencilBuffer();o.setStencilBuffer(!1),i&&this._renderSprites(),r&&this._renderParticles(n),this.onBeforeTransparentRendering&&this.onBeforeTransparentRendering(),0!==this._transparentSubMeshes.length&&(this._renderTransparent(this._transparentSubMeshes),o.setAlphaMode(e.Engine.ALPHA_DISABLE)),o.setStencilBuffer(!1);for(var a=0;a<this._edgesRenderers.length;a++)this._edgesRenderers.data[a].render();o.setStencilBuffer(s)},t.prototype.renderOpaqueSorted=function(e){return t.renderSorted(e,this._opaqueSortCompareFn,this._scene.activeCamera,!1)},t.prototype.renderAlphaTestSorted=function(e){return t.renderSorted(e,this._alphaTestSortCompareFn,this._scene.activeCamera,!1)},t.prototype.renderTransparentSorted=function(e){return t.renderSorted(e,this._transparentSortCompareFn,this._scene.activeCamera,!0)},t.renderSorted=function(t,i,r,n){for(var o,s=0,a=r?r.globalPosition:e.Vector3.Zero();s<t.length;s++)o=t.data[s],o._alphaIndex=o.getMesh().alphaIndex,o._distanceToCamera=o.getBoundingInfo().boundingSphere.centerWorld.subtract(a).length();var l=t.data.slice(0,t.length);for(i&&l.sort(i),s=0;s<l.length;s++){if(o=l[s],n){var h=o.getMaterial();if(h&&h.needDepthPrePass){var c=h.getScene().getEngine();c.setColorWrite(!1),c.setAlphaMode(e.Engine.ALPHA_DISABLE),o.render(!1),c.setColorWrite(!0)}}o.render(n)}},t.renderUnsorted=function(e){for(var t=0;t<e.length;t++){e.data[t].render(!1)}},t.defaultTransparentSortCompare=function(e,i){return e._alphaIndex>i._alphaIndex?1:e._alphaIndex<i._alphaIndex?-1:t.backToFrontSortCompare(e,i)},t.backToFrontSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?1:e._distanceToCamera>t._distanceToCamera?-1:0},t.frontToBackSortCompare=function(e,t){return e._distanceToCamera<t._distanceToCamera?-1:e._distanceToCamera>t._distanceToCamera?1:0},t.prototype.prepare=function(){this._opaqueSubMeshes.reset(),this._transparentSubMeshes.reset(),this._alphaTestSubMeshes.reset(),this._depthOnlySubMeshes.reset(),this._particleSystems.reset(),this._spriteManagers.reset(),this._edgesRenderers.reset()},t.prototype.dispose=function(){this._opaqueSubMeshes.dispose(),this._transparentSubMeshes.dispose(),this._alphaTestSubMeshes.dispose(),this._depthOnlySubMeshes.dispose(),this._particleSystems.dispose(),this._spriteManagers.dispose(),this._edgesRenderers.dispose()},t.prototype.dispatch=function(e,t,i){void 0===t&&(t=e.getMesh()),void 0===i&&(i=e.getMaterial()),null!==i&&void 0!==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)),null!==t._edgesRenderer&&void 0!==t._edgesRenderer&&this._edgesRenderers.push(t._edgesRenderer))},t.prototype.dispatchSprites=function(e){this._spriteManagers.push(e)},t.prototype.dispatchParticles=function(e){this._particleSystems.push(e)},t.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)}},t.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)}},t})();e.RenderingGroup=t})(r||(r={}));var r;!(function(e){var t=(function(){function e(){this._singleClick=!1,this._doubleClick=!1,this._hasSwiped=!1,this._ignore=!1}return Object.defineProperty(e.prototype,"singleClick",{get:function(){return this._singleClick},set:function(e){this._singleClick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"doubleClick",{get:function(){return this._doubleClick},set:function(e){this._doubleClick=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"hasSwiped",{get:function(){return this._hasSwiped},set:function(e){this._hasSwiped=e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"ignore",{
get:function(){return this._ignore},set:function(e){this._ignore=e},enumerable:!0,configurable:!0}),e})(),i=(function(){function e(){}return e.STAGE_PRECLEAR=1,e.STAGE_PREOPAQUE=2,e.STAGE_PRETRANSPARENT=3,e.STAGE_POSTTRANSPARENT=4,e})();e.RenderingGroupInfo=i;var r=(function(){function i(t){this.autoClear=!0,this.autoClearDepthAndStencil=!0,this.clearColor=new e.Color4(.2,.2,.3,1),this.ambientColor=new e.Color3(0,0,0),this._forceWireframe=!1,this._forcePointsCloud=!1,this.forceShowBoundingBoxes=!1,this.animationsEnabled=!0,this._animationPropertiesOverride=null,this.useConstantAnimationDeltaTime=!1,this.constantlyUpdateMeshUnderPointer=!1,this.hoverCursor="pointer",this.defaultCursor="",this.preventDefaultOnPointerDown=!0,this.metadata=null,this.disableOfflineSupportExceptionRules=new Array,this.onDisposeObservable=new e.Observable,this._onDisposeObserver=null,this.onBeforeRenderObservable=new e.Observable,this._onBeforeRenderObserver=null,this.onAfterRenderObservable=new e.Observable,this._onAfterRenderObserver=null,this.onBeforeAnimationsObservable=new e.Observable,this.onAfterAnimationsObservable=new e.Observable,this.onBeforeDrawPhaseObservable=new e.Observable,this.onAfterDrawPhaseObservable=new e.Observable,this.onBeforePhysicsObservable=new e.Observable,this.onAfterPhysicsObservable=new e.Observable,this.onReadyObservable=new e.Observable,this.onBeforeCameraRenderObservable=new e.Observable,this._onBeforeCameraRenderObserver=null,this.onAfterCameraRenderObservable=new e.Observable,this._onAfterCameraRenderObserver=null,this.onBeforeActiveMeshesEvaluationObservable=new e.Observable,this.onAfterActiveMeshesEvaluationObservable=new e.Observable,this.onBeforeParticlesRenderingObservable=new e.Observable,this.onAfterParticlesRenderingObservable=new e.Observable,this.onBeforeSpritesRenderingObservable=new e.Observable,this.onAfterSpritesRenderingObservable=new e.Observable,this.onDataLoadedObservable=new e.Observable,this.onNewCameraAddedObservable=new e.Observable,this.onCameraRemovedObservable=new e.Observable,this.onNewLightAddedObservable=new e.Observable,this.onLightRemovedObservable=new e.Observable,this.onNewGeometryAddedObservable=new e.Observable,this.onGeometryRemovedObservable=new e.Observable,this.onNewTransformNodeAddedObservable=new e.Observable,this.onTransformNodeRemovedObservable=new e.Observable,this.onNewMeshAddedObservable=new e.Observable,this.onMeshRemovedObservable=new e.Observable,this.onBeforeRenderTargetsRenderObservable=new e.Observable,this.onAfterRenderTargetsRenderObservable=new e.Observable,this.onBeforeStepObservable=new e.Observable,this.onAfterStepObservable=new e.Observable,this.onRenderingGroupObservable=new e.Observable,this.animations=[],this._registeredForLateAnimationBindings=new e.SmartArrayNoDuplicate(256),this.onPrePointerObservable=new e.Observable,this.onPointerObservable=new e.Observable,this._meshPickProceed=!1,this._currentPickResult=null,this._previousPickResult=null,this._totalPointersPressed=0,this._doubleClickOccured=!1,this.cameraToUseForPointers=null,this._startingPointerPosition=new e.Vector2(0,0),this._previousStartingPointerPosition=new e.Vector2(0,0),this._startingPointerTime=0,this._previousStartingPointerTime=0,this._pointerCaptures={},this._timeAccumulator=0,this._currentStepId=0,this._currentInternalStep=0,this.onPreKeyboardObservable=new e.Observable,this.onKeyboardObservable=new e.Observable,this._useRightHandedSystem=!1,this._fogEnabled=!0,this._fogMode=i.FOGMODE_NONE,this.fogColor=new e.Color3(.2,.2,.3),this.fogDensity=.1,this.fogStart=0,this.fogEnd=1e3,this._shadowsEnabled=!0,this._lightsEnabled=!0,this.lights=new Array,this.cameras=new Array,this.activeCameras=new Array,this.transformNodes=new Array,this.meshes=new Array,this.animationGroups=new Array,this._geometries=new Array,this.materials=new Array,this.multiMaterials=new Array,this._texturesEnabled=!0,this.textures=new Array,this.particlesEnabled=!0,this.particleSystems=new Array,this.spritesEnabled=!0,this.spriteManagers=new Array,this.layers=new Array,this.effectLayers=new Array,this._skeletonsEnabled=!0,this.skeletons=new Array,this.morphTargetManagers=new Array,this.lensFlaresEnabled=!0,this.lensFlareSystems=new Array,this.collisionsEnabled=!0,this.gravity=new e.Vector3(0,-9.807,0),this.postProcessesEnabled=!0,this.postProcesses=new Array,this.renderTargetsEnabled=!0,this.dumpNextRenderTargets=!1,this.customRenderTargets=new Array,this.importedMeshesFiles=new Array,this.probesEnabled=!0,this.reflectionProbes=new Array,this._actionManagers=new Array,this._meshesForIntersections=new e.SmartArrayNoDuplicate(256),this.proceduralTexturesEnabled=!0,this.proceduralTextures=new Array,this.soundTracks=new Array,this._audioEnabled=!0,this._headphone=!1,this._totalVertices=new e.PerfCounter,this._activeIndices=new e.PerfCounter,this._activeParticles=new e.PerfCounter,this._activeBones=new e.PerfCounter,this._animationTime=0,this.animationTimeScale=1,this._renderId=0,this._executeWhenReadyTimeoutId=-1,this._intermediateRendering=!1,this._viewUpdateFlag=-1,this._projectionUpdateFlag=-1,this._alternateViewUpdateFlag=-1,this._alternateProjectionUpdateFlag=-1,this._toBeDisposed=new e.SmartArray(256),this._activeRequests=new Array,this._pendingData=new Array,this._isDisposed=!1,this.dispatchAllSubMeshesOfActiveMeshes=!1,this._activeMeshes=new e.SmartArray(256),this._processedMaterials=new e.SmartArray(256),this._renderTargets=new e.SmartArrayNoDuplicate(256),this._activeParticleSystems=new e.SmartArray(256),this._activeSkeletons=new e.SmartArrayNoDuplicate(32),this._softwareSkinnedMeshes=new e.SmartArrayNoDuplicate(32),this._activeAnimatables=new Array,this._transformMatrix=e.Matrix.Zero(),this._useAlternateCameraConfiguration=!1,this._alternateRendering=!1,this.requireLightSorting=!1,this._depthRenderer={},this._activeMeshesFrozen=!1,this._tempPickingRay=e.Ray?e.Ray.Zero():null,this._engine=t||e.Engine.LastCreatedEngine,this._engine.scenes.push(this),this._uid=null,this._renderingManager=new e.RenderingManager(this),this.postProcessManager=new e.PostProcessManager(this),e.OutlineRenderer&&(this._outlineRenderer=new e.OutlineRenderer(this)),e.Tools.IsWindowObjectExist()&&this.attachControl(),e.SimplificationQueue&&(this.simplificationQueue=new e.SimplificationQueue),this.workerCollisions=!1,this._createUbo(),this._imageProcessingConfiguration=new e.ImageProcessingConfiguration}return Object.defineProperty(i,"FOGMODE_NONE",{get:function(){return i._FOGMODE_NONE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP",{get:function(){return i._FOGMODE_EXP},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_EXP2",{get:function(){return i._FOGMODE_EXP2},enumerable:!0,configurable:!0}),Object.defineProperty(i,"FOGMODE_LINEAR",{get:function(){return i._FOGMODE_LINEAR},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"environmentTexture",{get:function(){return this._environmentTexture},set:function(t){this._environmentTexture!==t&&(this._environmentTexture=t,this.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"forceWireframe",{get:function(){return this._forceWireframe},set:function(t){this._forceWireframe!==t&&(this._forceWireframe=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"forcePointsCloud",{get:function(){return this._forcePointsCloud},set:function(t){this._forcePointsCloud!==t&&(this._forcePointsCloud=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationPropertiesOverride",{get:function(){return this._animationPropertiesOverride},set:function(e){this._animationPropertiesOverride=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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(i.prototype,"beforeCameraRender",{set:function(e){this._onBeforeCameraRenderObserver&&this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver),this._onBeforeCameraRenderObserver=this.onBeforeCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"afterCameraRender",{set:function(e){this._onAfterCameraRenderObserver&&this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver),this._onAfterCameraRenderObserver=this.onAfterCameraRenderObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"gamepadManager",{get:function(){return this._gamepadManager||(this._gamepadManager=new e.GamepadManager(this)),this._gamepadManager},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"unTranslatedPointer",{get:function(){return new e.Vector2(this._unTranslatedPointerX,this._unTranslatedPointerY)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useRightHandedSystem",{get:function(){return this._useRightHandedSystem},set:function(t){this._useRightHandedSystem!==t&&(this._useRightHandedSystem=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),i.prototype.setStepId=function(e){this._currentStepId=e},i.prototype.getStepId=function(){return this._currentStepId},i.prototype.getInternalStep=function(){return this._currentInternalStep},Object.defineProperty(i.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(t){this._fogEnabled!==t&&(this._fogEnabled=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"fogMode",{get:function(){return this._fogMode},set:function(t){this._fogMode!==t&&(this._fogMode=t,this.markAllMaterialsAsDirty(e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowsEnabled",{get:function(){return this._shadowsEnabled},set:function(t){this._shadowsEnabled!==t&&(this._shadowsEnabled=t,this.markAllMaterialsAsDirty(e.Material.LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"lightsEnabled",{get:function(){return this._lightsEnabled},set:function(t){this._lightsEnabled!==t&&(this._lightsEnabled=t,this.markAllMaterialsAsDirty(e.Material.LightDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.prototype,"texturesEnabled",{get:function(){return this._texturesEnabled},set:function(t){this._texturesEnabled!==t&&(this._texturesEnabled=t,this.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"skeletonsEnabled",{get:function(){return this._skeletonsEnabled},set:function(t){this._skeletonsEnabled!==t&&(this._skeletonsEnabled=t,this.markAllMaterialsAsDirty(e.Material.AttributesDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"postProcessRenderPipelineManager",{get:function(){return this._postProcessRenderPipelineManager||(this._postProcessRenderPipelineManager=new e.PostProcessRenderPipelineManager),this._postProcessRenderPipelineManager},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"mainSoundTrack",{get:function(){return this._mainSoundTrack||(this._mainSoundTrack=new e.SoundTrack(this,{mainTrack:!0})),this._mainSoundTrack},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"_isAlternateRenderingEnabled",{get:function(){return this._alternateRendering},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frustumPlanes",{get:function(){return this._frustumPlanes},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"geometryBufferRenderer",{get:function(){return this._geometryBufferRenderer},set:function(e){e&&e.isSupported&&(this._geometryBufferRenderer=e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"debugLayer",{get:function(){return this._debugLayer||(this._debugLayer=new e.DebugLayer(this)),this._debugLayer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"workerCollisions",{get:function(){return this._workerCollisions},set:function(t){e.CollisionCoordinatorLegacy&&(t=t&&!!Worker&&!!e.CollisionWorker,this._workerCollisions=t,this.collisionCoordinator&&this.collisionCoordinator.destroy(),this.collisionCoordinator=t?new e.CollisionCoordinatorWorker:new e.CollisionCoordinatorLegacy,this.collisionCoordinator.init(this))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"selectionOctree",{get:function(){return this._selectionOctree},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"meshUnderPointer",{get:function(){return this._pointerOverMesh},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerX",{get:function(){return this._pointerX},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"pointerY",{get:function(){return this._pointerY},enumerable:!0,configurable:!0}),i.prototype.getCachedMaterial=function(){return this._cachedMaterial},i.prototype.getCachedEffect=function(){return this._cachedEffect},i.prototype.getCachedVisibility=function(){return this._cachedVisibility},i.prototype.isCachedMaterialInvalid=function(e,t,i){return void 0===i&&(i=1),this._cachedEffect!==t||this._cachedMaterial!==e||this._cachedVisibility!==i},i.prototype.getBoundingBoxRenderer=function(){return this._boundingBoxRenderer||(this._boundingBoxRenderer=new e.BoundingBoxRenderer(this)),this._boundingBoxRenderer},i.prototype.getOutlineRenderer=function(){return this._outlineRenderer},i.prototype.getEngine=function(){return this._engine},i.prototype.getTotalVertices=function(){return this._totalVertices.current},Object.defineProperty(i.prototype,"totalVerticesPerfCounter",{get:function(){return this._totalVertices},enumerable:!0,configurable:!0}),i.prototype.getActiveIndices=function(){return this._activeIndices.current},Object.defineProperty(i.prototype,"totalActiveIndicesPerfCounter",{get:function(){return this._activeIndices},enumerable:!0,configurable:!0}),i.prototype.getActiveParticles=function(){return this._activeParticles.current},Object.defineProperty(i.prototype,"activeParticlesPerfCounter",{get:function(){return this._activeParticles},enumerable:!0,configurable:!0}),i.prototype.getActiveBones=function(){return this._activeBones.current},Object.defineProperty(i.prototype,"activeBonesPerfCounter",{get:function(){return this._activeBones},enumerable:!0,configurable:!0}),i.prototype.getInterFramePerfCounter=function(){return e.Tools.Warn("getInterFramePerfCounter is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(i.prototype,"interFramePerfCounter",{get:function(){return e.Tools.Warn("interFramePerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),i.prototype.getLastFrameDuration=function(){return e.Tools.Warn("getLastFrameDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(i.prototype,"lastFramePerfCounter",{get:function(){return e.Tools.Warn("lastFramePerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),i.prototype.getEvaluateActiveMeshesDuration=function(){return e.Tools.Warn("getEvaluateActiveMeshesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(i.prototype,"evaluateActiveMeshesDurationPerfCounter",{get:function(){return e.Tools.Warn("evaluateActiveMeshesDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),i.prototype.getActiveMeshes=function(){return this._activeMeshes},i.prototype.getRenderTargetsDuration=function(){return e.Tools.Warn("getRenderTargetsDuration is deprecated. Please use SceneInstrumentation class"),0},i.prototype.getRenderDuration=function(){return e.Tools.Warn("getRenderDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(i.prototype,"renderDurationPerfCounter",{get:function(){return e.Tools.Warn("renderDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),i.prototype.getParticlesDuration=function(){return e.Tools.Warn("getParticlesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(i.prototype,"particlesDurationPerfCounter",{get:function(){return e.Tools.Warn("particlesDurationPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),i.prototype.getSpritesDuration=function(){return e.Tools.Warn("getSpritesDuration is deprecated. Please use SceneInstrumentation class"),0},Object.defineProperty(i.prototype,"spriteDuractionPerfCounter",{get:function(){return e.Tools.Warn("spriteDuractionPerfCounter is deprecated. Please use SceneInstrumentation class"),null},enumerable:!0,configurable:!0}),i.prototype.getAnimationRatio=function(){return this._animationRatio},i.prototype.getRenderId=function(){return this._renderId},i.prototype.incrementRenderId=function(){this._renderId++},i.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)},i.prototype._createUbo=function(){this._sceneUbo=new e.UniformBuffer(this._engine,void 0,!0),this._sceneUbo.addUniform("viewProjection",16),this._sceneUbo.addUniform("view",16)},i.prototype._createAlternateUbo=function(){this._alternateSceneUbo=new e.UniformBuffer(this._engine,void 0,!0),this._alternateSceneUbo.addUniform("viewProjection",16),this._alternateSceneUbo.addUniform("view",16)},i.prototype.simulatePointerMove=function(e,t){var i=new PointerEvent("pointermove",t);return this._processPointerMove(e,i)},i.prototype._processPointerMove=function(t,i){var r=this._engine.getRenderingCanvas();if(!r)return this;if(t&&t.hit&&t.pickedMesh?(this.setPointerOverSprite(null),this.setPointerOverMesh(t.pickedMesh),this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.hasPointerTriggers?this._pointerOverMesh.actionManager.hoverCursor?r.style.cursor=this._pointerOverMesh.actionManager.hoverCursor:r.style.cursor=this.hoverCursor:r.style.cursor=this.defaultCursor):(this.setPointerOverMesh(null),t=this.pickSprite(this._unTranslatedPointerX,this._unTranslatedPointerY,this._spritePredicate,!1,this.cameraToUseForPointers||void 0),t&&t.hit&&t.pickedSprite?(this.setPointerOverSprite(t.pickedSprite),this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.hoverCursor?r.style.cursor=this._pointerOverSprite.actionManager.hoverCursor:r.style.cursor=this.hoverCursor):(this.setPointerOverSprite(null),r.style.cursor=this.defaultCursor)),t){var n="mousewheel"===i.type||"DOMMouseScroll"===i.type?e.PointerEventTypes.POINTERWHEEL:e.PointerEventTypes.POINTERMOVE;if(this.onPointerMove&&this.onPointerMove(i,t,n),this.onPointerObservable.hasObservers()){var o=new e.PointerInfo(n,i,t);this.onPointerObservable.notifyObservers(o,n)}}return this},i.prototype.simulatePointerDown=function(e,t){var i=new PointerEvent("pointerdown",t);return this._processPointerDown(e,i)},i.prototype._processPointerDown=function(t,r){var n=this;if(t&&t.hit&&t.pickedMesh){this._pickedDownMesh=t.pickedMesh;var o=t.pickedMesh.actionManager;if(o){if(o.hasPickTriggers)switch(o.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNew(t.pickedMesh,r)),r.button){case 0:o.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,r));break;case 1:o.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,r));break;case 2:o.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,r))}o.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)&&window.setTimeout((function(){var t=n.pick(n._unTranslatedPointerX,n._unTranslatedPointerY,(function(t){return t.isPickable&&t.isVisible&&t.isReady()&&t.actionManager&&t.actionManager.hasSpecificTrigger(e.ActionManager.OnLongPressTrigger)&&t==n._pickedDownMesh}),!1,n.cameraToUseForPointers);t&&t.hit&&t.pickedMesh&&o&&0!==n._totalPointersPressed&&Date.now()-n._startingPointerTime>i.LongPressDelay&&Math.abs(n._startingPointerPosition.x-n._pointerX)<i.DragMovementThreshold&&Math.abs(n._startingPointerPosition.y-n._pointerY)<i.DragMovementThreshold&&(n._startingPointerTime=0,o.processTrigger(e.ActionManager.OnLongPressTrigger,e.ActionEvent.CreateNew(t.pickedMesh,r)))}),i.LongPressDelay)}}if(t){var s=e.PointerEventTypes.POINTERDOWN;if(this.onPointerDown&&this.onPointerDown(r,t,s),this.onPointerObservable.hasObservers()){var a=new e.PointerInfo(s,r,t);this.onPointerObservable.notifyObservers(a,s)}}return this},i.prototype.simulatePointerUp=function(e,i){var r=new PointerEvent("pointerup",i),n=new t;return n.singleClick=!0,n.ignore=!0,this._processPointerUp(e,r,n)},i.prototype._processPointerUp=function(t,i,r){if(t&&t&&t.pickedMesh){if(this._pickedUpMesh=t.pickedMesh,this._pickedDownMesh===this._pickedUpMesh&&(this.onPointerPick&&this.onPointerPick(i,t),r.singleClick&&!r.ignore&&this.onPointerObservable.hasObservers())){var n=e.PointerEventTypes.POINTERPICK,o=new e.PointerInfo(n,i,t);this.onPointerObservable.notifyObservers(o,n)}t.pickedMesh.actionManager&&(r.ignore&&t.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i)),r.hasSwiped||r.ignore||!r.singleClick||t.pickedMesh.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i)),r.doubleClick&&!r.ignore&&t.pickedMesh.actionManager.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&t.pickedMesh.actionManager.processTrigger(e.ActionManager.OnDoublePickTrigger,e.ActionEvent.CreateNew(t.pickedMesh,i)))}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,i));var s=e.PointerEventTypes.POINTERUP;if(this.onPointerObservable.hasObservers())if(r.ignore){var o=new e.PointerInfo(s,i,t);this.onPointerObservable.notifyObservers(o,s)}else if(!r.hasSwiped){if(r.singleClick&&this.onPointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERTAP)){var a=e.PointerEventTypes.POINTERTAP,o=new e.PointerInfo(a,i,t);this.onPointerObservable.notifyObservers(o,a)}if(r.doubleClick&&this.onPointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)){var l=e.PointerEventTypes.POINTERDOUBLETAP,o=new e.PointerInfo(l,i,t);this.onPointerObservable.notifyObservers(o,l)}}return this.onPointerUp&&this.onPointerUp(i,t,s),this},i.prototype.attachControl=function(r,n,o){var s=this;void 0===r&&(r=!0),void 0===n&&(n=!0),void 0===o&&(o=!0),this._initActionManager=function(e,t){if(!s._meshPickProceed){var i=s.pick(s._unTranslatedPointerX,s._unTranslatedPointerY,s.pointerDownPredicate,!1,s.cameraToUseForPointers);s._currentPickResult=i,i&&(e=i.hit&&i.pickedMesh?i.pickedMesh.actionManager:null),s._meshPickProceed=!0}return e},this._delayedSimpleClick=function(e,t,r){(Date.now()-s._previousStartingPointerTime>i.DoubleClickDelay&&!s._doubleClickOccured||e!==s._previousButtonPressed)&&(s._doubleClickOccured=!1,t.singleClick=!0,t.ignore=!1,r(t,s._currentPickResult))},this._initClickEvent=function(r,n,o,a){var l=new t;s._currentPickResult=null;var h=null,c=r.hasSpecificMask(e.PointerEventTypes.POINTERPICK)||n.hasSpecificMask(e.PointerEventTypes.POINTERPICK)||r.hasSpecificMask(e.PointerEventTypes.POINTERTAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERTAP)||r.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP);if(!c&&e.ActionManager&&e.ActionManager.HasPickTriggers&&(h=s._initActionManager(h,l))&&(c=h.hasPickTriggers),c){var u=o.button;if(l.hasSwiped=Math.abs(s._startingPointerPosition.x-s._pointerX)>i.DragMovementThreshold||Math.abs(s._startingPointerPosition.y-s._pointerY)>i.DragMovementThreshold,!l.hasSwiped){var f=!i.ExclusiveDoubleClickMode;f||(f=!r.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)&&!n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP))&&!e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(h=s._initActionManager(h,l))&&(f=!h.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),f?(Date.now()-s._previousStartingPointerTime>i.DoubleClickDelay||u!==s._previousButtonPressed)&&(l.singleClick=!0,a(l,s._currentPickResult)):(s._previousDelayedSimpleClickTimeout=s._delayedSimpleClickTimeout,s._delayedSimpleClickTimeout=window.setTimeout(s._delayedSimpleClick.bind(s,u,l,a),i.DoubleClickDelay));var p=r.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)||n.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP);!p&&e.ActionManager.HasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)&&(h=s._initActionManager(h,l))&&(p=h.hasSpecificTrigger(e.ActionManager.OnDoublePickTrigger)),p&&(u===s._previousButtonPressed&&Date.now()-s._previousStartingPointerTime<i.DoubleClickDelay&&!s._doubleClickOccured?!l.hasSwiped&&Math.abs(s._previousStartingPointerPosition.x-s._startingPointerPosition.x)<i.DragMovementThreshold&&Math.abs(s._previousStartingPointerPosition.y-s._startingPointerPosition.y)<i.DragMovementThreshold?(s._previousStartingPointerTime=0,s._doubleClickOccured=!0,l.doubleClick=!0,l.ignore=!1,i.ExclusiveDoubleClickMode&&s._previousDelayedSimpleClickTimeout&&clearTimeout(s._previousDelayedSimpleClickTimeout),s._previousDelayedSimpleClickTimeout=s._delayedSimpleClickTimeout,a(l,s._currentPickResult)):(s._doubleClickOccured=!1,s._previousStartingPointerTime=s._startingPointerTime,s._previousStartingPointerPosition.x=s._startingPointerPosition.x,s._previousStartingPointerPosition.y=s._startingPointerPosition.y,s._previousButtonPressed=u,i.ExclusiveDoubleClickMode?(s._previousDelayedSimpleClickTimeout&&clearTimeout(s._previousDelayedSimpleClickTimeout),s._previousDelayedSimpleClickTimeout=s._delayedSimpleClickTimeout,a(l,s._previousPickResult)):a(l,s._currentPickResult)):(s._doubleClickOccured=!1,s._previousStartingPointerTime=s._startingPointerTime,s._previousStartingPointerPosition.x=s._startingPointerPosition.x,s._previousStartingPointerPosition.y=s._startingPointerPosition.y,s._previousButtonPressed=u))}}l.ignore=!0,a(l,s._currentPickResult)},this._spritePredicate=function(e){return e.isPickable&&e.actionManager&&e.actionManager.hasPointerTriggers},this._onPointerMove=function(t){if(s._updatePointerPosition(t),s.onPrePointerObservable.hasObservers()&&!s._pointerCaptures[t.pointerId]){var i="mousewheel"===t.type||"DOMMouseScroll"===t.type?e.PointerEventTypes.POINTERWHEEL:e.PointerEventTypes.POINTERMOVE,r=new e.PointerInfoPre(i,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(r,i),r.skipOnPointerObservable)return}if(s.cameraToUseForPointers||s.activeCamera){s.pointerMovePredicate||(s.pointerMovePredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()&&(e.enablePointerMoveEvents||s.constantlyUpdateMeshUnderPointer||null!==e.actionManager&&void 0!==e.actionManager)});var n=s.pick(s._unTranslatedPointerX,s._unTranslatedPointerY,s.pointerMovePredicate,!1,s.cameraToUseForPointers);s._processPointerMove(n,t)}},this._onPointerDown=function(t){if(s._totalPointersPressed++,s._pickedDownMesh=null,s._meshPickProceed=!1,s._updatePointerPosition(t),s.preventDefaultOnPointerDown&&h&&(t.preventDefault(),h.focus()),s.onPrePointerObservable.hasObservers()){var i=e.PointerEventTypes.POINTERDOWN,r=new e.PointerInfoPre(i,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(r,i),r.skipOnPointerObservable)return}if(s.cameraToUseForPointers||s.activeCamera){s._pointerCaptures[t.pointerId]=!0,s._startingPointerPosition.x=s._pointerX,s._startingPointerPosition.y=s._pointerY,s._startingPointerTime=Date.now(),s.pointerDownPredicate||(s.pointerDownPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),s._pickedDownMesh=null;var n=s.pick(s._unTranslatedPointerX,s._unTranslatedPointerY,s.pointerDownPredicate,!1,s.cameraToUseForPointers);if(s._processPointerDown(n,t),s._pickedDownSprite=null,s.spriteManagers.length>0&&(n=s.pickSprite(s._unTranslatedPointerX,s._unTranslatedPointerY,s._spritePredicate,!1,s.cameraToUseForPointers||void 0))&&n.hit&&n.pickedSprite&&n.pickedSprite.actionManager){switch(s._pickedDownSprite=n.pickedSprite,t.button){case 0:n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnLeftPickTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t));break;case 1:n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnCenterPickTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t));break;case 2:n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnRightPickTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t))}n.pickedSprite.actionManager&&n.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickDownTrigger,e.ActionEvent.CreateNewFromSprite(n.pickedSprite,s,t))}}},this._onPointerUp=function(t){0!==s._totalPointersPressed&&(s._totalPointersPressed--,s._pickedUpMesh=null,s._meshPickProceed=!1,s._updatePointerPosition(t),s._initClickEvent(s.onPrePointerObservable,s.onPointerObservable,t,(function(r,n){if(s.onPrePointerObservable.hasObservers()&&!s._pointerCaptures[t.pointerId])if(r.ignore){var o=e.PointerEventTypes.POINTERUP,a=new e.PointerInfoPre(o,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(a,o),a.skipOnPointerObservable)return}else if(!r.hasSwiped){if(r.singleClick&&s.onPrePointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERTAP)){var o=e.PointerEventTypes.POINTERTAP,a=new e.PointerInfoPre(o,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(a,o),a.skipOnPointerObservable)return}if(r.doubleClick&&s.onPrePointerObservable.hasSpecificMask(e.PointerEventTypes.POINTERDOUBLETAP)){var o=e.PointerEventTypes.POINTERDOUBLETAP,a=new e.PointerInfoPre(o,t,s._unTranslatedPointerX,s._unTranslatedPointerY);if(s.onPrePointerObservable.notifyObservers(a,o),a.skipOnPointerObservable)return}}if(s.cameraToUseForPointers||s.activeCamera){if(s._pointerCaptures[t.pointerId]=!1,s.pointerUpPredicate||(s.pointerUpPredicate=function(e){return e.isPickable&&e.isVisible&&e.isReady()&&e.isEnabled()}),!s._meshPickProceed&&(e.ActionManager&&e.ActionManager.HasTriggers||s.onPointerObservable.hasObservers())&&s._initActionManager(null,r),n||(n=s._currentPickResult),s._processPointerUp(n,t,r),!r.ignore&&s.spriteManagers.length>0){
var l=s.pickSprite(s._unTranslatedPointerX,s._unTranslatedPointerY,s._spritePredicate,!1,s.cameraToUseForPointers||void 0);l&&(l.hit&&l.pickedSprite&&l.pickedSprite.actionManager&&(l.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickUpTrigger,e.ActionEvent.CreateNewFromSprite(l.pickedSprite,s,t)),l.pickedSprite.actionManager&&Math.abs(s._startingPointerPosition.x-s._pointerX)<i.DragMovementThreshold&&Math.abs(s._startingPointerPosition.y-s._pointerY)<i.DragMovementThreshold&&l.pickedSprite.actionManager.processTrigger(e.ActionManager.OnPickTrigger,e.ActionEvent.CreateNewFromSprite(l.pickedSprite,s,t))),s._pickedDownSprite&&s._pickedDownSprite.actionManager&&s._pickedDownSprite!==l.pickedSprite&&s._pickedDownSprite.actionManager.processTrigger(e.ActionManager.OnPickOutTrigger,e.ActionEvent.CreateNewFromSprite(s._pickedDownSprite,s,t)))}s._previousPickResult=s._currentPickResult}})))},this._onKeyDown=function(t){var i=e.KeyboardEventTypes.KEYDOWN;if(s.onPreKeyboardObservable.hasObservers()){var r=new e.KeyboardInfoPre(i,t);if(s.onPreKeyboardObservable.notifyObservers(r,i),r.skipOnPointerObservable)return}if(s.onKeyboardObservable.hasObservers()){var r=new e.KeyboardInfo(i,t);s.onKeyboardObservable.notifyObservers(r,i)}s.actionManager&&s.actionManager.processTrigger(e.ActionManager.OnKeyDownTrigger,e.ActionEvent.CreateNewFromScene(s,t))},this._onKeyUp=function(t){var i=e.KeyboardEventTypes.KEYUP;if(s.onPreKeyboardObservable.hasObservers()){var r=new e.KeyboardInfoPre(i,t);if(s.onPreKeyboardObservable.notifyObservers(r,i),r.skipOnPointerObservable)return}if(s.onKeyboardObservable.hasObservers()){var r=new e.KeyboardInfo(i,t);s.onKeyboardObservable.notifyObservers(r,i)}s.actionManager&&s.actionManager.processTrigger(e.ActionManager.OnKeyUpTrigger,e.ActionEvent.CreateNewFromScene(s,t))};var a=this.getEngine();this._onCanvasFocusObserver=a.onCanvasFocusObservable.add((function(){h&&(h.addEventListener("keydown",s._onKeyDown,!1),h.addEventListener("keyup",s._onKeyUp,!1))})),this._onCanvasBlurObserver=a.onCanvasBlurObservable.add((function(){h&&(h.removeEventListener("keydown",s._onKeyDown),h.removeEventListener("keyup",s._onKeyUp))}));var l=e.Tools.GetPointerPrefix(),h=this._engine.getRenderingCanvas();h&&(o&&(h.addEventListener(l+"move",this._onPointerMove,!1),h.addEventListener("mousewheel",this._onPointerMove,!1),h.addEventListener("DOMMouseScroll",this._onPointerMove,!1)),n&&h.addEventListener(l+"down",this._onPointerDown,!1),r&&window.addEventListener(l+"up",this._onPointerUp,!1),h.tabIndex=1)},i.prototype.detachControl=function(){var t=this.getEngine(),i=e.Tools.GetPointerPrefix(),r=t.getRenderingCanvas();r&&(r.removeEventListener(i+"move",this._onPointerMove),r.removeEventListener(i+"down",this._onPointerDown),window.removeEventListener(i+"up",this._onPointerUp),this._onCanvasBlurObserver&&t.onCanvasBlurObservable.remove(this._onCanvasBlurObserver),this._onCanvasFocusObserver&&t.onCanvasFocusObservable.remove(this._onCanvasFocusObserver),r.removeEventListener("mousewheel",this._onPointerMove),r.removeEventListener("DOMMouseScroll",this._onPointerMove),r.removeEventListener("keydown",this._onKeyDown),r.removeEventListener("keyup",this._onKeyUp),this.onKeyboardObservable.clear(),this.onPreKeyboardObservable.clear(),this.onPointerObservable.clear(),this.onPrePointerObservable.clear())},i.prototype.isReady=function(){if(this._isDisposed)return!1;if(this._pendingData.length>0)return!1;var t,i=this.getEngine();for(t=0;t<this._geometries.length;t++){if(this._geometries[t].delayLoadState===e.Engine.DELAYLOADSTATE_LOADING)return!1}for(t=0;t<this.meshes.length;t++){var r=this.meshes[t];if(r.isEnabled()&&(r.subMeshes&&0!==r.subMeshes.length)){if(!r.isReady(!0))return!1;for(var n="InstancedMesh"===r.getClassName()||i.getCaps().instancedArrays&&r.instances.length>0,o=0,s=this.effectLayers;o<s.length;o++){var a=s[o];if(a.hasMesh(r))for(var l=0,h=r.subMeshes;l<h.length;l++){var c=h[l];if(!a.isReady(c,n))return!1}}}}if(this.activeCameras&&this.activeCameras.length>0)for(var u=0,f=this.activeCameras;u<f.length;u++){var p=f[u];if(!p.isReady(!0))return!1}else if(this.activeCamera&&!this.activeCamera.isReady(!0))return!1;for(var d=0,m=this.particleSystems;d<m.length;d++){if(!m[d].isReady())return!1}return!0},i.prototype.resetCachedMaterial=function(){this._cachedMaterial=null,this._cachedEffect=null,this._cachedVisibility=null},i.prototype.registerBeforeRender=function(e){this.onBeforeRenderObservable.add(e)},i.prototype.unregisterBeforeRender=function(e){this.onBeforeRenderObservable.removeCallback(e)},i.prototype.registerAfterRender=function(e){this.onAfterRenderObservable.add(e)},i.prototype.unregisterAfterRender=function(e){this.onAfterRenderObservable.removeCallback(e)},i.prototype._executeOnceBeforeRender=function(e){var t=this,i=function(){e(),setTimeout((function(){t.unregisterBeforeRender(i)}))};this.registerBeforeRender(i)},i.prototype.executeOnceBeforeRender=function(e,t){var i=this;void 0!==t?setTimeout((function(){i._executeOnceBeforeRender(e)}),t):this._executeOnceBeforeRender(e)},i.prototype._addPendingData=function(e){this._pendingData.push(e)},i.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)},i.prototype.getWaitingItemsCount=function(){return this._pendingData.length},Object.defineProperty(i.prototype,"isLoading",{get:function(){return this._pendingData.length>0},enumerable:!0,configurable:!0}),i.prototype.executeWhenReady=function(e){var t=this;this.onReadyObservable.add(e),-1===this._executeWhenReadyTimeoutId&&(this._executeWhenReadyTimeoutId=setTimeout((function(){t._checkIsReady()}),150))},i.prototype.whenReadyAsync=function(){var e=this;return new Promise(function(t){e.executeWhenReady((function(){t()}))})},i.prototype._checkIsReady=function(){var e=this;if(this.isReady())return this.onReadyObservable.notifyObservers(this),this.onReadyObservable.clear(),void(this._executeWhenReadyTimeoutId=-1);this._executeWhenReadyTimeoutId=setTimeout((function(){e._checkIsReady()}),150)},i.prototype.beginWeightedAnimation=function(e,t,i,r,n,o,s,a){void 0===r&&(r=1),void 0===o&&(o=1);var l=this.beginAnimation(e,t,i,n,o,s,a,!1);return l.weight=r,l},i.prototype.beginAnimation=function(t,i,r,n,o,s,a,l){if(void 0===o&&(o=1),void 0===l&&(l=!0),i>r&&o>0&&(o*=-1),l&&this.stopAnimation(t),a||(a=new e.Animatable(this,t,i,r,n,o,s)),t.animations&&a.appendAnimations(t,t.animations),t.getAnimatables)for(var h=t.getAnimatables(),c=0;c<h.length;c++)this.beginAnimation(h[c],i,r,n,o,s,a,l);return a.reset(),a},i.prototype.beginDirectAnimation=function(t,i,r,n,o,s,a){return void 0===s&&(s=1),new e.Animatable(this,t,r,n,o,s,a,i)},i.prototype.beginDirectHierarchyAnimation=function(e,t,i,r,n,o,s,a){for(var l=e.getDescendants(t),h=[],c=0,u=l;c<u.length;c++){var f=u[c];h.push(this.beginDirectAnimation(f,i,r,n,o,s,a))}return h},i.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},i.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(i.prototype,"animatables",{get:function(){return this._activeAnimatables},enumerable:!0,configurable:!0}),i.prototype.stopAnimation=function(e,t){for(var i=this.getAllAnimatablesByTarget(e),r=0,n=i;r<n.length;r++){n[r].stop(t)}},i.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()}},i.prototype._animate=function(){if(this.animationsEnabled&&0!==this._activeAnimatables.length){var t=e.Tools.Now;if(!this._animationTimeLast){if(this._pendingData.length>0)return;this._animationTimeLast=t}var i=this.useConstantAnimationDeltaTime?16:(t-this._animationTimeLast)*this.animationTimeScale;this._animationTime+=i,this._animationTimeLast=t;for(var r=0;r<this._activeAnimatables.length;r++)this._activeAnimatables[r]._animate(this._animationTime);this._processLateAnimationBindings()}},i.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},i.prototype._processLateAnimationBindingsForMatrices=function(t){var i=1,r=e.Tmp.Vector3[0],n=e.Tmp.Vector3[1],o=e.Tmp.Quaternion[0],s=0,a=t.animations[0],l=t.originalValue,h=1;if(t.totalWeight<1)l.decompose(n,o,r),h=1-t.totalWeight;else if(s=1,i=t.totalWeight,a.currentValue.decompose(n,o,r),1==(h=a.weight/i))return a.currentValue;n.scaleInPlace(h),r.scaleInPlace(h),o.scaleInPlace(h);for(var c=s;c<t.animations.length;c++){var u=t.animations[c],h=u.weight/i,f=e.Tmp.Vector3[2],p=e.Tmp.Vector3[3],d=e.Tmp.Quaternion[1];u.currentValue.decompose(p,d,f),p.scaleAndAddToRef(h,n),d.scaleAndAddToRef(h,o),f.scaleAndAddToRef(h,r)}return e.Matrix.ComposeToRef(n,o,r,a._workValue),a._workValue},i.prototype._processLateAnimationBindingsForQuaternions=function(t){var i=t.animations[0],r=t.originalValue;if(1===t.animations.length)return e.Quaternion.Slerp(r,i.currentValue,Math.min(1,t.totalWeight));var n,o,s=1;if(t.totalWeight<1){var a=1-t.totalWeight;n=[],o=[],n.push(r),o.push(a)}else{if(2===t.animations.length)return e.Quaternion.Slerp(t.animations[0].currentValue,t.animations[1].currentValue,t.animations[1].weight/t.totalWeight);n=[],o=[],s=t.totalWeight}for(var l=0;l<t.animations.length;l++){var h=t.animations[l];n.push(h.currentValue),o.push(h.weight/s)}for(var c=0,u=null,f=0;f<n.length;)u?(c+=o[f],e.Quaternion.SlerpToRef(u,n[f],o[f]/c,u),f++):(u=e.Quaternion.Slerp(n[f],n[f+1],o[f+1]/(o[f]+o[f+1])),c=o[f]+o[f+1],f+=2);return u},i.prototype._processLateAnimationBindings=function(){if(this._registeredForLateAnimationBindings.length){for(var t=0;t<this._registeredForLateAnimationBindings.length;t++){var i=this._registeredForLateAnimationBindings.data[t];for(var r in i._lateAnimationHolders){var n=i._lateAnimationHolders[r],o=n.animations[0],s=n.originalValue,a=e.Animation.AllowMatrixDecomposeForInterpolation&&s.m,l=void 0;if(a)l=this._processLateAnimationBindingsForMatrices(n);else{if(void 0!==s.w)l=this._processLateAnimationBindingsForQuaternions(n);else{var h=0,c=1;if(n.totalWeight<1)l=s.scale?s.scale(1-n.totalWeight):s*(1-n.totalWeight);else{c=n.totalWeight;var u=o.weight/c;l=1!==u?o.currentValue.scale?o.currentValue.scale(u):o.currentValue*u:o.currentValue,h=1}for(var f=h;f<n.animations.length;f++){var p=n.animations[f],d=p.weight/c;p.currentValue.scaleAndAddToRef?p.currentValue.scaleAndAddToRef(d,l):l+=p.currentValue*d}}}i[r]=l}i._lateAnimationHolders={}}this._registeredForLateAnimationBindings.reset()}},i.prototype._switchToAlternateCameraConfiguration=function(e){this._useAlternateCameraConfiguration=e},i.prototype.getViewMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateViewMatrix:this._viewMatrix},i.prototype.getProjectionMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateProjectionMatrix:this._projectionMatrix},i.prototype.getTransformMatrix=function(){return this._useAlternateCameraConfiguration?this._alternateTransformMatrix:this._transformMatrix},i.prototype.setTransformMatrix=function(t,i){if(this._viewUpdateFlag!==t.updateFlag||this._projectionUpdateFlag!==i.updateFlag){if(this._viewUpdateFlag=t.updateFlag,this._projectionUpdateFlag=i.updateFlag,this._viewMatrix=t,this._projectionMatrix=i,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 r=this.activeCamera._alternateCamera;r.getViewMatrix().multiplyToRef(r.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())}},i.prototype._setAlternateTransformMatrix=function(t,i){this._alternateViewUpdateFlag===t.updateFlag&&this._alternateProjectionUpdateFlag===i.updateFlag||(this._alternateViewUpdateFlag=t.updateFlag,this._alternateProjectionUpdateFlag=i.updateFlag,this._alternateViewMatrix=t,this._alternateProjectionMatrix=i,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()))},i.prototype.getSceneUniformBuffer=function(){return this._useAlternateCameraConfiguration?this._alternateSceneUbo:this._sceneUbo},i.prototype.getUniqueId=function(){var e=i._uniqueIdCounter;return i._uniqueIdCounter++,e},i.prototype.addMesh=function(e){this.meshes.push(e),this.collisionCoordinator&&this.collisionCoordinator.onMeshAdded(e),e._resyncLightSources(),this.onNewMeshAddedObservable.notifyObservers(e)},i.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},i.prototype.addTransformNode=function(e){this.transformNodes.push(e),this.onNewTransformNodeAddedObservable.notifyObservers(e)},i.prototype.removeTransformNode=function(e){var t=this.transformNodes.indexOf(e);return-1!==t&&this.transformNodes.splice(t,1),this.onTransformNodeRemovedObservable.notifyObservers(e),t},i.prototype.removeSkeleton=function(e){var t=this.skeletons.indexOf(e);return-1!==t&&this.skeletons.splice(t,1),t},i.prototype.removeMorphTargetManager=function(e){var t=this.morphTargetManagers.indexOf(e);return-1!==t&&this.morphTargetManagers.splice(t,1),t},i.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},i.prototype.removeCamera=function(e){var t=this.cameras.indexOf(e);-1!==t&&this.cameras.splice(t,1);var i=this.activeCameras.indexOf(e);return-1!==i&&this.activeCameras.splice(i,1),this.activeCamera===e&&(this.cameras.length>0?this.activeCamera=this.cameras[0]:this.activeCamera=null),this.onCameraRemovedObservable.notifyObservers(e),t},i.prototype.removeParticleSystem=function(e){var t=this.particleSystems.indexOf(e);return-1!==t&&this.particleSystems.splice(t,1),t},i.prototype.removeAnimation=function(e){var t=this.animations.indexOf(e);return-1!==t&&this.animations.splice(t,1),t},i.prototype.removeAnimationGroup=function(e){var t=this.animationGroups.indexOf(e);return-1!==t&&this.animationGroups.splice(t,1),t},i.prototype.removeMultiMaterial=function(e){var t=this.multiMaterials.indexOf(e);return-1!==t&&this.multiMaterials.splice(t,1),t},i.prototype.removeMaterial=function(e){var t=this.materials.indexOf(e);return-1!==t&&this.materials.splice(t,1),t},i.prototype.removeLensFlareSystem=function(e){var t=this.lensFlareSystems.indexOf(e);return-1!==t&&this.lensFlareSystems.splice(t,1),t},i.prototype.removeActionManager=function(e){var t=this._actionManagers.indexOf(e);return-1!==t&&this._actionManagers.splice(t,1),t},i.prototype.removeEffectLayer=function(e){var t=this.effectLayers.indexOf(e);return-1!==t&&this.effectLayers.splice(t,1),t},i.prototype.removeTexture=function(e){var t=this.textures.indexOf(e);return-1!==t&&this.textures.splice(t,1),t},i.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)},i.prototype.sortLightsByPriority=function(){this.requireLightSorting&&this.lights.sort(e.Light.CompareLightsPriority)},i.prototype.addCamera=function(e){this.cameras.push(e),this.onNewCameraAddedObservable.notifyObservers(e)},i.prototype.addSkeleton=function(e){this.skeletons.push(e)},i.prototype.addParticleSystem=function(e){this.particleSystems.push(e)},i.prototype.addAnimation=function(e){this.animations.push(e)},i.prototype.addAnimationGroup=function(e){this.animationGroups.push(e)},i.prototype.addMultiMaterial=function(e){this.multiMaterials.push(e)},i.prototype.addMaterial=function(e){this.materials.push(e)},i.prototype.addMorphTargetManager=function(e){this.morphTargetManagers.push(e)},i.prototype.addGeometry=function(e){this._geometries.push(e)},i.prototype.addLensFlareSystem=function(e){this.lensFlareSystems.push(e)},i.prototype.addEffectLayer=function(e){this.effectLayers.push(e)},i.prototype.addActionManager=function(e){this._actionManagers.push(e)},i.prototype.addTexture=function(e){this.textures.push(e)},i.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))},i.prototype.setActiveCameraByID=function(e){var t=this.getCameraByID(e);return t?(this.activeCamera=t,t):null},i.prototype.setActiveCameraByName=function(e){var t=this.getCameraByName(e);return t?(this.activeCamera=t,t):null},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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},i.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)},i.prototype.removeGeometry=function(e){var t=this._geometries.indexOf(e);return t>-1&&(this._geometries.splice(t,1),this.collisionCoordinator&&this.collisionCoordinator.onGeometryDeleted(e),this.onGeometryRemovedObservable.notifyObservers(e),!0)},i.prototype.getGeometries=function(){return this._geometries},i.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},i.prototype.getMeshesByID=function(e){return this.meshes.filter((function(t){return t.id===e}))},i.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},i.prototype.getTransformNodesByID=function(e){return this.transformNodes.filter((function(t){return t.id===e}))},i.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},i.prototype.getLastMeshByID=function(e){for(var t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];return null},i.prototype.getLastEntryByID=function(e){var t;for(t=this.meshes.length-1;t>=0;t--)if(this.meshes[t].id===e)return this.meshes[t];for(t=this.transformNodes.length-1;t>=0;t--)if(this.transformNodes[t].id===e)return this.transformNodes[t];for(t=this.cameras.length-1;t>=0;t--)if(this.cameras[t].id===e)return this.cameras[t];for(t=this.lights.length-1;t>=0;t--)if(this.lights[t].id===e)return this.lights[t];return null},i.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)},i.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)},i.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},i.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},i.prototype.getSoundByName=function(t){var i;if(e.AudioEngine){for(i=0;i<this.mainSoundTrack.soundCollection.length;i++)if(this.mainSoundTrack.soundCollection[i].name===t)return this.mainSoundTrack.soundCollection[i];for(var r=0;r<this.soundTracks.length;r++)for(i=0;i<this.soundTracks[r].soundCollection.length;i++)if(this.soundTracks[r].soundCollection[i].name===t)return this.soundTracks[r].soundCollection[i]}return null},i.prototype.getLastSkeletonByID=function(e){for(var t=this.skeletons.length-1;t>=0;t--)if(this.skeletons[t].id===e)return this.skeletons[t];return null},i.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},i.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},i.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},i.prototype.isActiveMesh=function(e){return-1!==this._activeMeshes.indexOf(e)},i.prototype.getHighlightLayerByName=function(t){for(var i=0;i<this.effectLayers.length;i++)if(this.effectLayers[i].name===t&&this.effectLayers[i].getEffectName()===e.HighlightLayer.EffectName)return this.effectLayers[i];return null},i.prototype.getGlowLayerByName=function(t){for(var i=0;i<this.effectLayers.length;i++)if(this.effectLayers[i].name===t&&this.effectLayers[i].getEffectName()===e.GlowLayer.EffectName)return this.effectLayers[i];return null},Object.defineProperty(i.prototype,"uid",{get:function(){return this._uid||(this._uid=e.Tools.RandomId()),this._uid},enumerable:!0,configurable:!0}),i.prototype.addExternalData=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.add(t,i)},i.prototype.getExternalData=function(e){return this._externalData?this._externalData.get(e):null},i.prototype.getOrAddExternalDataWithFactory=function(t,i){return this._externalData||(this._externalData=new e.StringDictionary),this._externalData.getOrAddWithFactory(t,i)},i.prototype.removeExternalData=function(e){return this._externalData.remove(e)},i.prototype._evaluateSubMesh=function(e,t){if(this.dispatchAllSubMeshesOfActiveMeshes||t.alwaysSelectAsActiveMesh||1===t.subMeshes.length||e.isInFrustum(this._frustumPlanes)){if(t.showSubMeshesBoundingBox){var i=e.getBoundingInfo();null!==i&&void 0!==i&&this.getBoundingBoxRenderer().renderList.push(i.boundingBox)}var r=e.getMaterial();null!==r&&void 0!==r&&(void 0!==r.getRenderTargetTextures&&-1===this._processedMaterials.indexOf(r)&&(this._processedMaterials.push(r),this._renderTargets.concatWithNoDuplicate(r.getRenderTargetTextures())),this._activeIndices.addCount(e.indexCount,!1),this._renderingManager.dispatch(e,t,r))}},i.prototype.freeProcessedMaterials=function(){this._processedMaterials.dispose()},i.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()}},i.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()}},i.prototype._isInIntermediateRendering=function(){return this._intermediateRendering},i.prototype.setActiveMeshCandidateProvider=function(e){this._activeMeshCandidateProvider=e},i.prototype.getActiveMeshCandidateProvider=function(){return this._activeMeshCandidateProvider},i.prototype.freezeActiveMeshes=function(){return this.activeCamera?(this._frustumPlanes||this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix()),this._evaluateActiveMeshes(),this._activeMeshesFrozen=!0,this):this},i.prototype.unfreezeActiveMeshes=function(){return this._activeMeshesFrozen=!1,this},i.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(),this._boundingBoxRenderer&&this._boundingBoxRenderer.reset();var t,i,r=!0;if(void 0!==this._activeMeshCandidateProvider)t=this._activeMeshCandidateProvider.getMeshes(this),r=!1===this._activeMeshCandidateProvider.checksIsEnabled,i=void 0!==t?t.length:0;else if(void 0!==this._selectionOctree){var n=this._selectionOctree.select(this._frustumPlanes);t=n.data,i=n.length}else i=this.meshes.length,t=this.meshes;for(var o,s,a=0;a<i;a++)o=t[a],o.isBlocked||(this._totalVertices.addCount(o.getTotalVertices(),!1),!o.isReady()||r&&!o.isEnabled()||(o.computeWorldMatrix(),o.actionManager&&o.actionManager.hasSpecificTriggers([e.ActionManager.OnIntersectionEnterTrigger,e.ActionManager.OnIntersectionExitTrigger])&&this._meshesForIntersections.pushNoDuplicate(o),void 0!==(s=o.getLOD(this.activeCamera))&&null!==s&&(o._preActivate(),(o.alwaysSelectAsActiveMesh||o.isVisible&&o.visibility>0&&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 l=0;l<this.particleSystems.length;l++){var h=this.particleSystems[l];if(h.isStarted()&&h.emitter){var c=h.emitter;c.position&&!c.isEnabled()||(this._activeParticleSystems.push(h),h.animate(),this._renderingManager.dispatchParticles(h))}}this.onAfterParticlesRenderingObservable.notifyObservers(this)}}},i.prototype._activeMesh=function(e,t){if(this.skeletonsEnabled&&null!==t.skeleton&&void 0!==t.skeleton&&(this._activeSkeletons.pushNoDuplicate(t.skeleton)&&t.skeleton.prepare(),t.computeBonesUsingShaders||this._softwareSkinnedMeshes.pushNoDuplicate(t)),e.showBoundingBox||this.forceShowBoundingBoxes){var i=e.getBoundingInfo();this.getBoundingBoxRenderer().renderList.push(i.boundingBox)}if(void 0!==t&&null!==t&&void 0!==t.subMeshes&&null!==t.subMeshes&&t.subMeshes.length>0){var r,n;if(t.useOctreeForRenderingSelection&&void 0!==t._submeshesOctree&&null!==t._submeshesOctree){var o=t._submeshesOctree.select(this._frustumPlanes);r=o.length,n=o.data}else n=t.subMeshes,r=n.length;for(var s,a=0;a<r;a++)s=n[a],this._evaluateSubMesh(s,t)}},i.prototype.updateTransformMatrix=function(e){this.activeCamera&&this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix(e))},i.prototype.updateAlternateTransformMatrix=function(e){this._setAlternateTransformMatrix(e.getViewMatrix(),e.getProjectionMatrix())},i.prototype._renderForCamera=function(t,i){if(!t||!t._skipRendering){var r=this._engine;if(this.activeCamera=t,!this.activeCamera)throw new Error("Active camera not set");e.Tools.StartPerformanceCounter("Rendering camera "+this.activeCamera.name),r.setViewport(this.activeCamera.viewport),this.resetCachedMaterial(),this._renderId++,this.updateTransformMatrix(),t._alternateCamera&&(this.updateAlternateTransformMatrix(t._alternateCamera),this._alternateRendering=!0),this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera),this._evaluateActiveMeshes();for(var n=0;n<this._softwareSkinnedMeshes.length;n++){var o=this._softwareSkinnedMeshes.data[n];o.applySkeleton(o.skeleton)}this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var s=!1;if(t.customRenderTargets&&t.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(t.customRenderTargets),i&&i.customRenderTargets&&i.customRenderTargets.length>0&&this._renderTargets.concatWithNoDuplicate(i.customRenderTargets),this.renderTargetsEnabled&&this._renderTargets.length>0){this._intermediateRendering=!0,e.Tools.StartPerformanceCounter("Render targets",this._renderTargets.length>0);for(var a=0;a<this._renderTargets.length;a++){var l=this._renderTargets.data[a];if(l._shouldRender()){this._renderId++;var h=l.activeCamera&&l.activeCamera!==this.activeCamera;l.render(h,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Render targets",this._renderTargets.length>0),this._intermediateRendering=!1,this._renderId++,s=!0}var c=this._engine.getStencilBuffer(),u=!1,f=!1;if(this.renderTargetsEnabled&&this.effectLayers&&this.effectLayers.length>0){this._intermediateRendering=!0;for(var p=0;p<this.effectLayers.length;p++){var d=this.effectLayers[p];if(d.shouldRender()&&(!d.camera||d.camera.cameraRigMode===e.Camera.RIG_MODE_NONE&&t===d.camera||d.camera.cameraRigMode!==e.Camera.RIG_MODE_NONE&&d.camera._rigCameras.indexOf(t)>-1)){u=!0,f=f||d.needStencil()
;var l=d._mainTexture;l._shouldRender()&&(this._renderId++,l.render(!1,!1),s=!0)}}this._intermediateRendering=!1,this._renderId++}s&&r.restoreDefaultFramebuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.postProcessManager._prepareFrame();var m,_;if(this.layers.length){for(r.setDepthBuffer(!1),m=0;m<this.layers.length;m++)_=this.layers[m],_.isBackground&&0!=(_.layerMask&this.activeCamera.layerMask)&&_.render();r.setDepthBuffer(!0)}if(f&&this._engine.setStencilBuffer(!0),this.onBeforeDrawPhaseObservable.notifyObservers(this),this._renderingManager.render(null,null,!0,!0),this.onAfterDrawPhaseObservable.notifyObservers(this),f&&this._engine.setStencilBuffer(c),this._boundingBoxRenderer&&this._boundingBoxRenderer.render(),this.lensFlaresEnabled){e.Tools.StartPerformanceCounter("Lens flares",this.lensFlareSystems.length>0);for(var g=0;g<this.lensFlareSystems.length;g++){var v=this.lensFlareSystems[g];0!=(t.layerMask&v.layerMask)&&v.render()}e.Tools.EndPerformanceCounter("Lens flares",this.lensFlareSystems.length>0)}if(u){r.setDepthBuffer(!1);for(var p=0;p<this.effectLayers.length;p++)this.effectLayers[p].shouldRender()&&this.effectLayers[p].render();r.setDepthBuffer(!0)}if(this.layers.length){for(r.setDepthBuffer(!1),m=0;m<this.layers.length;m++)_=this.layers[m],_.isBackground||0==(_.layerMask&this.activeCamera.layerMask)||_.render();r.setDepthBuffer(!0)}this.postProcessManager._finalizeFrame(t.isIntermediate),this._renderTargets.reset(),this._alternateRendering=!1,this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera),e.Tools.EndPerformanceCounter("Rendering camera "+this.activeCamera.name)}},i.prototype._processSubCameras=function(t){if(t.cameraRigMode===e.Camera.RIG_MODE_NONE)return void this._renderForCamera(t);for(var i=0;i<t._rigCameras.length;i++)this._renderForCamera(t._rigCameras[i],t);this.activeCamera=t,this.setTransformMatrix(this.activeCamera.getViewMatrix(),this.activeCamera.getProjectionMatrix())},i.prototype._checkIntersections=function(){for(var t=0;t<this._meshesForIntersections.length;t++){var i=this._meshesForIntersections.data[t];if(i.actionManager)for(var r=0;r<i.actionManager.actions.length;r++){var n=i.actionManager.actions[r];if(n.trigger===e.ActionManager.OnIntersectionEnterTrigger||n.trigger===e.ActionManager.OnIntersectionExitTrigger){var o=n.getTriggerParameter(),s=o instanceof e.AbstractMesh?o:o.mesh,a=s.intersectsMesh(i,o.usePreciseIntersection),l=i._intersectionsInProgress.indexOf(s);a&&-1===l?n.trigger===e.ActionManager.OnIntersectionEnterTrigger?(n._executeCurrent(e.ActionEvent.CreateNew(i,void 0,s)),i._intersectionsInProgress.push(s)):n.trigger===e.ActionManager.OnIntersectionExitTrigger&&i._intersectionsInProgress.push(s):!a&&l>-1&&(n.trigger===e.ActionManager.OnIntersectionExitTrigger&&n._executeCurrent(e.ActionEvent.CreateNew(i,void 0,s)),i.actionManager.hasSpecificTrigger(e.ActionManager.OnIntersectionExitTrigger,(function(t){var i=t instanceof e.AbstractMesh?t:t.mesh;return s===i}))&&n.trigger!==e.ActionManager.OnIntersectionExitTrigger||i._intersectionsInProgress.splice(l,1))}}}},i.prototype.render=function(){if(!this.isDisposed){if(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.simplificationQueue&&!this.simplificationQueue.running&&this.simplificationQueue.executeNext(),this._engine.isDeterministicLockStep()){var t=Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime))+this._timeAccumulator,r=1e3/60;this._physicsEngine&&(r=1e3*this._physicsEngine.getTimeStep());var n=0,o=this._engine.getLockstepMaxSteps(),s=Math.floor(t/60);s=Math.min(s,o);do{this.onBeforeStepObservable.notifyObservers(this),this._animationRatio=.06*r,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._physicsEngine&&(this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(r/1e3),this.onAfterPhysicsObservable.notifyObservers(this)),this.onAfterStepObservable.notifyObservers(this),this._currentStepId++,n++,t-=r}while(t>0&&n<s);this._timeAccumulator=t<0?0:t}else{var t=this.useConstantAnimationDeltaTime?16:Math.max(i.MinDeltaTime,Math.min(this._engine.getDeltaTime(),i.MaxDeltaTime));this._animationRatio=.06*t,this._animate(),this.onAfterAnimationsObservable.notifyObservers(this),this._physicsEngine&&(this.onBeforePhysicsObservable.notifyObservers(this),this._physicsEngine._step(t/1e3),this.onAfterPhysicsObservable.notifyObservers(this))}if(this._gamepadManager&&this._gamepadManager._isMonitoring&&this._gamepadManager._checkGamepadsStatus(),this.activeCameras.length>0)for(var a=0;a<this.activeCameras.length;a++){var l=this.activeCameras[a];if(l.update(),l.cameraRigMode!==e.Camera.RIG_MODE_NONE)for(var h=0;h<l._rigCameras.length;h++)l._rigCameras[h].update()}else if(this.activeCamera&&(this.activeCamera.update(),this.activeCamera.cameraRigMode!==e.Camera.RIG_MODE_NONE))for(var h=0;h<this.activeCamera._rigCameras.length;h++)this.activeCamera._rigCameras[h].update();this.onBeforeRenderObservable.notifyObservers(this),this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);var c=this.getEngine(),u=this.activeCamera;if(this.renderTargetsEnabled){e.Tools.StartPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),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");c.setViewport(this.activeCamera.viewport),this.updateTransformMatrix(),p.render(u!==this.activeCamera,this.dumpNextRenderTargets)}}e.Tools.EndPerformanceCounter("Custom render targets",this.customRenderTargets.length>0),this._intermediateRendering=!1,this._renderId++}if(this.customRenderTargets.length>0&&c.restoreDefaultFramebuffer(),this.onAfterRenderTargetsRenderObservable.notifyObservers(this),this.activeCamera=u,this.proceduralTexturesEnabled){e.Tools.StartPerformanceCounter("Procedural textures",this.proceduralTextures.length>0);for(var d=0;d<this.proceduralTextures.length;d++){var m=this.proceduralTextures[d];m._shouldRender()&&m.render()}e.Tools.EndPerformanceCounter("Procedural textures",this.proceduralTextures.length>0)}if((this.autoClearDepthAndStencil||this.autoClear)&&this._engine.clear(this.clearColor,this.autoClear||this.forceWireframe||this.forcePointsCloud,this.autoClearDepthAndStencil,this.autoClearDepthAndStencil),this.shadowsEnabled)for(var _=0;_<this.lights.length;_++){var g=this.lights[_],v=g.getShadowGenerator();if(g.isEnabled()&&g.shadowEnabled&&v){var y=v.getShadowMap();-1!==this.textures.indexOf(y)&&this._renderTargets.push(y)}}for(var b in this._depthRenderer)this._renderTargets.push(this._depthRenderer[b].getDepthMap());if(this._geometryBufferRenderer&&this._renderTargets.push(this._geometryBufferRenderer.getGBuffer()),this._postProcessRenderPipelineManager&&this._postProcessRenderPipelineManager.update(),this.activeCameras.length>0)for(var a=0;a<this.activeCameras.length;a++)a>0&&this._engine.clear(null,!1,!0,!0),this._processSubCameras(this.activeCameras[a]);else{if(!this.activeCamera)throw new Error("No camera defined");this._processSubCameras(this.activeCamera)}this._checkIntersections(),e.AudioEngine&&this._updateAudioParameters(),this.afterRender&&this.afterRender(),this.onAfterRenderObservable.notifyObservers(this);for(var h=0;h<this._toBeDisposed.length;h++){var x=this._toBeDisposed.data[h];x&&x.dispose(),this._toBeDisposed[h]=null}this._toBeDisposed.reset(),this.dumpNextRenderTargets&&(this.dumpNextRenderTargets=!1),this._activeBones.addCount(0,!0),this._activeIndices.addCount(0,!0),this._activeParticles.addCount(0,!0)}},i.prototype._updateAudioParameters=function(){if(this.audioEnabled&&this._mainSoundTrack&&(0!==this._mainSoundTrack.soundCollection.length||1!==this.soundTracks.length)){var t,i=e.Engine.audioEngine;if((t=this.activeCameras.length>0?this.activeCameras[0]:this.activeCamera)&&i.canUseWebAudio&&i.audioContext){i.audioContext.listener.setPosition(t.position.x,t.position.y,t.position.z),t.rigCameras&&t.rigCameras.length>0&&(t=t.rigCameras[0]);var r=e.Matrix.Invert(t.getViewMatrix()),n=e.Vector3.TransformNormal(new e.Vector3(0,0,-1),r);n.normalize(),isNaN(n.x)||isNaN(n.y)||isNaN(n.z)||i.audioContext.listener.setOrientation(n.x,n.y,n.z,0,1,0);var o;for(o=0;o<this.mainSoundTrack.soundCollection.length;o++){var s=this.mainSoundTrack.soundCollection[o];s.useCustomAttenuation&&s.updateDistanceFromListener()}for(o=0;o<this.soundTracks.length;o++)for(var a=0;a<this.soundTracks[o].soundCollection.length;a++)s=this.soundTracks[o].soundCollection[a],s.useCustomAttenuation&&s.updateDistanceFromListener()}}},Object.defineProperty(i.prototype,"audioEnabled",{get:function(){return this._audioEnabled},set:function(t){this._audioEnabled=t,e.AudioEngine&&(this._audioEnabled?this._enableAudio():this._disableAudio())},enumerable:!0,configurable:!0}),i.prototype._disableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].pause();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].pause()},i.prototype._enableAudio=function(){var e;for(e=0;e<this.mainSoundTrack.soundCollection.length;e++)this.mainSoundTrack.soundCollection[e].isPaused&&this.mainSoundTrack.soundCollection[e].play();for(e=0;e<this.soundTracks.length;e++)for(var t=0;t<this.soundTracks[e].soundCollection.length;t++)this.soundTracks[e].soundCollection[t].isPaused&&this.soundTracks[e].soundCollection[t].play()},Object.defineProperty(i.prototype,"headphone",{get:function(){return this._headphone},set:function(t){this._headphone=t,e.AudioEngine&&(this._headphone?this._switchAudioModeForHeadphones():this._switchAudioModeForNormalSpeakers())},enumerable:!0,configurable:!0}),i.prototype._switchAudioModeForHeadphones=function(){this.mainSoundTrack.switchPanningModelToHRTF();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToHRTF()},i.prototype._switchAudioModeForNormalSpeakers=function(){this.mainSoundTrack.switchPanningModelToEqualPower();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].switchPanningModelToEqualPower()},i.prototype.enableDepthRenderer=function(t){if(!(t=t||this.activeCamera))throw"No camera available to enable depth renderer";if(!this._depthRenderer[t.id]){var i=0;if(this._engine.getCaps().textureHalfFloatRender)i=e.Engine.TEXTURETYPE_HALF_FLOAT;else{if(!this._engine.getCaps().textureFloatRender)throw"Depth renderer does not support int texture type";i=e.Engine.TEXTURETYPE_FLOAT}this._depthRenderer[t.id]=new e.DepthRenderer(this,i,t)}return this._depthRenderer[t.id]},i.prototype.disableDepthRenderer=function(e){(e=e||this.activeCamera)&&this._depthRenderer[e.id]&&(this._depthRenderer[e.id].dispose(),delete this._depthRenderer[e.id])},i.prototype.enableGeometryBufferRenderer=function(t){return void 0===t&&(t=1),this._geometryBufferRenderer?this._geometryBufferRenderer:(this._geometryBufferRenderer=new e.GeometryBufferRenderer(this,t),this._geometryBufferRenderer.isSupported||(this._geometryBufferRenderer=null),this._geometryBufferRenderer)},i.prototype.disableGeometryBufferRenderer=function(){this._geometryBufferRenderer&&(this._geometryBufferRenderer.dispose(),this._geometryBufferRenderer=null)},i.prototype.freezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].freeze()},i.prototype.unfreezeMaterials=function(){for(var e=0;e<this.materials.length;e++)this.materials[e].unfreeze()},i.prototype.dispose=function(){this.beforeRender=null,this.afterRender=null,this.skeletons=[],this.morphTargetManagers=[],this.importedMeshesFiles=new Array,this.stopAllAnimations(),this.resetCachedMaterial();for(var t in this._depthRenderer)this._depthRenderer[t].dispose();this._gamepadManager&&(this._gamepadManager.dispose(),this._gamepadManager=null),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._boundingBoxRenderer&&this._boundingBoxRenderer.dispose(),this._meshesForIntersections.dispose(),this._toBeDisposed.dispose();for(var i=0,r=this._activeRequests;i<r.length;i++){r[i].abort()}this._debugLayer&&this._debugLayer.hide(),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.onBeforeSpritesRenderingObservable.clear(),this.onAfterSpritesRenderingObservable.clear(),this.onBeforeDrawPhaseObservable.clear(),this.onAfterDrawPhaseObservable.clear(),this.onBeforePhysicsObservable.clear(),this.onAfterPhysicsObservable.clear(),this.onBeforeAnimationsObservable.clear(),this.onAfterAnimationsObservable.clear(),this.onDataLoadedObservable.clear(),this.detachControl(),e.AudioEngine&&this.disposeSounds(),this.VRHelper&&this.VRHelper.dispose();var n=this._engine.getRenderingCanvas();if(n){var o;for(o=0;o<this.cameras.length;o++)this.cameras[o].detachControl(n)}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.spriteManagers.length;)this.spriteManagers[0].dispose();for(;this.postProcesses.length;)this.postProcesses[0].dispose();for(;this.layers.length;)this.layers[0].dispose();for(;this.effectLayers.length;)this.effectLayers[0].dispose();for(;this.textures.length;)this.textures[0].dispose();this._sceneUbo.dispose(),this._alternateSceneUbo&&this._alternateSceneUbo.dispose(),this.postProcessManager.dispose(),this._postProcessRenderPipelineManager&&this._postProcessRenderPipelineManager.dispose(),this._physicsEngine&&this.disablePhysicsEngine(),o=this._engine.scenes.indexOf(this),o>-1&&this._engine.scenes.splice(o,1),this._engine.wipeCaches(!0),this._isDisposed=!0},Object.defineProperty(i.prototype,"isDisposed",{get:function(){return this._isDisposed},enumerable:!0,configurable:!0}),i.prototype.disposeSounds=function(){if(this._mainSoundTrack){this.mainSoundTrack.dispose();for(var e=0;e<this.soundTracks.length;e++)this.soundTracks[e].dispose()}},i.prototype.getWorldExtends=function(t){var i=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),r=new e.Vector3(-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE);return t=t||function(){return!0},this.meshes.filter(t).forEach((function(t){if(t.computeWorldMatrix(!0),t.subMeshes&&0!==t.subMeshes.length&&!t.infiniteDistance){var n=t.getBoundingInfo(),o=n.boundingBox.minimumWorld,s=n.boundingBox.maximumWorld;e.Tools.CheckExtends(o,i,r),e.Tools.CheckExtends(s,i,r)}})),{min:i,max:r}},i.prototype.createOrUpdateSelectionOctree=function(t,i){void 0===t&&(t=64),void 0===i&&(i=2),this._selectionOctree||(this._selectionOctree=new e.Octree(e.Octree.CreationFuncForMeshes,t,i));var r=this.getWorldExtends();return this._selectionOctree.update(r.min,r.max,this.meshes),this._selectionOctree},i.prototype.createPickingRay=function(t,i,r,n,o){void 0===o&&(o=!1);var s=e.Ray.Zero();return this.createPickingRayToRef(t,i,r,s,n,o),s},i.prototype.createPickingRayToRef=function(t,i,r,n,o,s){void 0===s&&(s=!1);var a=this._engine;if(!o){if(!this.activeCamera)throw new Error("Active camera not set");o=this.activeCamera}var l=o.viewport,h=l.toGlobal(a.getRenderWidth(),a.getRenderHeight());return t=t/this._engine.getHardwareScalingLevel()-h.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-h.y-h.height),n.update(t,i,h.width,h.height,r||e.Matrix.Identity(),s?e.Matrix.Identity():o.getViewMatrix(),o.getProjectionMatrix()),this},i.prototype.createPickingRayInCameraSpace=function(t,i,r){var n=e.Ray.Zero();return this.createPickingRayInCameraSpaceToRef(t,i,n,r),n},i.prototype.createPickingRayInCameraSpaceToRef=function(t,i,r,n){if(!e.PickingInfo)return this;var o=this._engine;if(!n){if(!this.activeCamera)throw new Error("Active camera not set");n=this.activeCamera}var s=n.viewport,a=s.toGlobal(o.getRenderWidth(),o.getRenderHeight()),l=e.Matrix.Identity();return t=t/this._engine.getHardwareScalingLevel()-a.x,i=i/this._engine.getHardwareScalingLevel()-(this._engine.getRenderHeight()-a.y-a.height),r.update(t,i,a.width,a.height,l,l,n.getProjectionMatrix()),this},i.prototype._internalPick=function(t,i,r){if(!e.PickingInfo)return null;for(var n=null,o=0;o<this.meshes.length;o++){var s=this.meshes[o];if(i){if(!i(s))continue}else if(!s.isEnabled()||!s.isVisible||!s.isPickable)continue;var a=s.getWorldMatrix(),l=t(a),h=s.intersects(l,r);if(h&&h.hit&&((r||null==n||!(h.distance>=n.distance))&&(n=h,r)))break}return n||new e.PickingInfo},i.prototype._internalMultiPick=function(t,i){if(!e.PickingInfo)return null;for(var r=new Array,n=0;n<this.meshes.length;n++){var o=this.meshes[n];if(i){if(!i(o))continue}else if(!o.isEnabled()||!o.isVisible||!o.isPickable)continue;var s=o.getWorldMatrix(),a=t(s),l=o.intersects(a,!1);l&&l.hit&&r.push(l)}return r},i.prototype._internalPickSprites=function(t,i,r,n){if(!e.PickingInfo)return null;var o=null;if(!n){if(!this.activeCamera)return null;n=this.activeCamera}if(this.spriteManagers.length>0)for(var s=0;s<this.spriteManagers.length;s++){var a=this.spriteManagers[s];if(a.isPickable){var l=a.intersects(t,n,i,r);if(l&&l.hit&&(r||null==o||!(l.distance>=o.distance))&&(o=l,r))break}}return o||new e.PickingInfo},i.prototype.pick=function(t,i,r,n,o){var s=this;return e.PickingInfo?this._internalPick((function(e){return s.createPickingRayToRef(t,i,e,s._tempPickingRay,o||null),s._tempPickingRay}),r,n):null},i.prototype.pickSprite=function(e,t,i,r,n){return this.createPickingRayInCameraSpaceToRef(e,t,this._tempPickingRay,n),this._internalPickSprites(this._tempPickingRay,i,r,n)},i.prototype.pickWithRay=function(t,i,r){var n=this;return this._internalPick((function(i){return n._pickWithRayInverseMatrix||(n._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(n._pickWithRayInverseMatrix),n._cachedRayForTransform||(n._cachedRayForTransform=e.Ray.Zero()),e.Ray.TransformToRef(t,n._pickWithRayInverseMatrix,n._cachedRayForTransform),n._cachedRayForTransform}),i,r)},i.prototype.multiPick=function(e,t,i,r){var n=this;return this._internalMultiPick((function(i){return n.createPickingRay(e,t,i,r||null)}),i)},i.prototype.multiPickWithRay=function(t,i){var r=this;return this._internalMultiPick((function(i){return r._pickWithRayInverseMatrix||(r._pickWithRayInverseMatrix=e.Matrix.Identity()),i.invertToRef(r._pickWithRayInverseMatrix),r._cachedRayForTransform||(r._cachedRayForTransform=e.Ray.Zero()),e.Ray.TransformToRef(t,r._pickWithRayInverseMatrix,r._cachedRayForTransform),r._cachedRayForTransform}),i)},i.prototype.setPointerOverMesh=function(t){this._pointerOverMesh!==t&&(this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)),this._pointerOverMesh=t,this._pointerOverMesh&&this._pointerOverMesh.actionManager&&this._pointerOverMesh.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNew(this._pointerOverMesh)))},i.prototype.getPointerOverMesh=function(){return this._pointerOverMesh},i.prototype.setPointerOverSprite=function(t){this._pointerOverSprite!==t&&(this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOutTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)),this._pointerOverSprite=t,this._pointerOverSprite&&this._pointerOverSprite.actionManager&&this._pointerOverSprite.actionManager.processTrigger(e.ActionManager.OnPointerOverTrigger,e.ActionEvent.CreateNewFromSprite(this._pointerOverSprite,this)))},i.prototype.getPointerOverSprite=function(){return this._pointerOverSprite},i.prototype.getPhysicsEngine=function(){return this._physicsEngine},i.prototype.enablePhysics=function(t,i){if(void 0===t&&(t=null),this._physicsEngine)return!0;try{return this._physicsEngine=new e.PhysicsEngine(t,i),!0}catch(t){return e.Tools.Error(t.message),!1}},i.prototype.disablePhysicsEngine=function(){this._physicsEngine&&(this._physicsEngine.dispose(),this._physicsEngine=null)},i.prototype.isPhysicsEnabled=function(){return void 0!==this._physicsEngine},i.prototype.deleteCompoundImpostor=function(e){var t=e.parts[0].mesh;t.physicsImpostor&&(t.physicsImpostor.dispose(),t.physicsImpostor=null)},i.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.layers;n<o.length;n++){o[n]._rebuild()}for(var s=0,a=this.effectLayers;s<a.length;s++){a[s]._rebuild()}this._boundingBoxRenderer&&this._boundingBoxRenderer._rebuild();for(var l=0,h=this.particleSystems;l<h.length;l++){h[l].rebuild()}this._postProcessRenderPipelineManager&&this._postProcessRenderPipelineManager._rebuild()},i.prototype._rebuildTextures=function(){for(var t=0,i=this.textures;t<i.length;t++){i[t]._rebuild()}this.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag)},i.prototype.createDefaultLight=function(t){if(void 0===t&&(t=!1),t&&this.lights)for(var i=0;i<this.lights.length;i++)this.lights[i].dispose();0===this.lights.length&&new e.HemisphericLight("default light",e.Vector3.Up(),this)},i.prototype.createDefaultCamera=function(t,i,r){if(void 0===t&&(t=!1),void 0===i&&(i=!1),void 0===r&&(r=!1),i&&this.activeCamera&&(this.activeCamera.dispose(),this.activeCamera=null),!this.activeCamera){var n,o=this.getWorldExtends(),s=o.max.subtract(o.min),a=o.min.add(s.scale(.5)),l=1.5*s.length();if(isFinite(l)||(l=1,a.copyFromFloats(0,0,0)),t){var h=new e.ArcRotateCamera("default camera",-Math.PI/2,Math.PI/2,l,a,this);h.lowerRadiusLimit=.01*l,h.wheelPrecision=100/l,n=h}else{var c=new e.FreeCamera("default camera",new e.Vector3(a.x,a.y,-l),this);c.setTarget(a),n=c}n.minZ=.01*l,n.maxZ=1e3*l,n.speed=.2*l,this.activeCamera=n;var u=this.getEngine().getRenderingCanvas();r&&u&&n.attachControl(u)}},i.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)},i.prototype.createDefaultSkybox=function(t,i,r,n,o){if(void 0===i&&(i=!1),void 0===r&&(r=1e3),void 0===n&&(n=0),void 0===o&&(o=!0),!t)return e.Tools.Warn("Can not create default skybox without environment texture."),null;o&&t&&(this.environmentTexture=t);var s=e.Mesh.CreateBox("hdrSkyBox",r,this);if(i){var a=new e.PBRMaterial("skyBox",this);a.backFaceCulling=!1,a.reflectionTexture=t.clone(),a.reflectionTexture&&(a.reflectionTexture.coordinatesMode=e.Texture.SKYBOX_MODE),a.microSurface=1-n,a.disableLighting=!0,a.twoSidedLighting=!0,s.infiniteDistance=!0,s.material=a}else{var l=new e.StandardMaterial("skyBox",this);l.backFaceCulling=!1,l.reflectionTexture=t.clone(),l.reflectionTexture&&(l.reflectionTexture.coordinatesMode=e.Texture.SKYBOX_MODE),l.disableLighting=!0,s.infiniteDistance=!0,s.material=l}return s},i.prototype.createDefaultEnvironment=function(t){return e.EnvironmentHelper?new e.EnvironmentHelper(t,this):null},i.prototype.createDefaultVRExperience=function(t){return void 0===t&&(t={}),new e.VRExperienceHelper(this,t)},i.prototype._getByTags=function(t,i,r){if(void 0===i)return t;var n=[];r=r||function(e){};for(var o in t){var s=t[o];e.Tags&&e.Tags.MatchesQuery(s,i)&&(n.push(s),r(s))}return n},i.prototype.getMeshesByTags=function(e,t){return this._getByTags(this.meshes,e,t)},i.prototype.getCamerasByTags=function(e,t){return this._getByTags(this.cameras,e,t)},i.prototype.getLightsByTags=function(e,t){return this._getByTags(this.lights,e,t)},i.prototype.getMaterialByTags=function(e,t){return this._getByTags(this.materials,e,t).concat(this._getByTags(this.multiMaterials,e,t))},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,i,r){void 0===i&&(i=!0),void 0===r&&(r=!0),this._renderingManager.setRenderingAutoClearDepthStencil(e,t,i,r)},i.prototype.markAllMaterialsAsDirty=function(e,t){for(var i=0,r=this.materials;i<r.length;i++){var n=r[i];t&&!t(n)||n.markAsDirty(e)}},i.prototype._loadFile=function(t,i,r,n,o,s){var a=this,l=e.Tools.LoadFile(t,i,r,n?this.database:void 0,o,s);return this._activeRequests.push(l),l.onCompleteObservable.add((function(e){a._activeRequests.splice(a._activeRequests.indexOf(e),1)})),l},i.prototype._loadFileAsync=function(e,t,i){var r=this;return new Promise(function(n,o){r._loadFile(e,(function(e){n(e)}),void 0,t,i,(function(e,t){o(t)}))})},i._FOGMODE_NONE=0,i._FOGMODE_EXP=1,i._FOGMODE_EXP2=2,i._FOGMODE_LINEAR=3,i._uniqueIdCounter=0,i.MinDeltaTime=1,i.MaxDeltaTime=1e3,i.DragMovementThreshold=10,i.LongPressDelay=500,i.DoubleClickDelay=300,i.ExclusiveDoubleClickMode=!1,i})();e.Scene=r})(r||(r={}));var r;!(function(e){var t=(function(){function e(){this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=new Array,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.lensFlareSystems=new Array,this.shadowGenerators=new Array,this.actionManagers=new Array,this.sounds=new Array,this.textures=new Array,this.effectLayers=new Array}return e})();e.KeepAssets=t;var i=(function(){function e(e){this.cameras=new Array,this.lights=new Array,this.meshes=new Array,this.skeletons=new Array,this.particleSystems=new Array,this.animations=new Array,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.lensFlareSystems=new Array,this.shadowGenerators=new Array,this.actionManagers=new Array,this.sounds=new Array,this.textures=new Array,this.effectLayers=new Array,this.scene=e}return e.prototype.addAllToScene=function(){var e=this;this.cameras.forEach((function(t){e.scene.addCamera(t)})),this.lights.forEach((function(t){e.scene.addLight(t)})),this.meshes.forEach((function(t){e.scene.addMesh(t)})),this.skeletons.forEach((function(t){e.scene.addSkeleton(t)})),this.particleSystems.forEach((function(t){e.scene.addParticleSystem(t)})),this.animations.forEach((function(t){e.scene.addAnimation(t)})),this.animationGroups.forEach((function(t){e.scene.addAnimationGroup(t)})),this.multiMaterials.forEach((function(t){e.scene.addMultiMaterial(t)})),this.materials.forEach((function(t){e.scene.addMaterial(t)})),this.morphTargetManagers.forEach((function(t){e.scene.addMorphTargetManager(t)})),this.geometries.forEach((function(t){e.scene.addGeometry(t)})),this.transformNodes.forEach((function(t){e.scene.addTransformNode(t)})),this.lensFlareSystems.forEach((function(t){e.scene.addLensFlareSystem(t)})),this.actionManagers.forEach((function(t){e.scene.addActionManager(t)})),this.sounds.forEach((function(t){t.play(),t.autoplay=!0,e.scene.mainSoundTrack.AddSound(t)})),this.textures.forEach((function(t){e.scene.addTexture(t)})),this.effectLayers.forEach((function(t){e.scene.addEffectLayer(t)}))},e.prototype.removeAllFromScene=function(){var e=this;this.cameras.forEach((function(t){e.scene.removeCamera(t)})),this.lights.forEach((function(t){e.scene.removeLight(t)})),this.meshes.forEach((function(t){e.scene.removeMesh(t)})),this.skeletons.forEach((function(t){e.scene.removeSkeleton(t)})),this.particleSystems.forEach((function(t){e.scene.removeParticleSystem(t)})),this.animations.forEach((function(t){e.scene.removeAnimation(t)})),this.animationGroups.forEach((function(t){e.scene.removeAnimationGroup(t)})),this.multiMaterials.forEach((function(t){e.scene.removeMultiMaterial(t)})),this.materials.forEach((function(t){e.scene.removeMaterial(t)})),this.morphTargetManagers.forEach((function(t){e.scene.removeMorphTargetManager(t)})),this.geometries.forEach((function(t){e.scene.removeGeometry(t)})),this.transformNodes.forEach((function(t){e.scene.removeTransformNode(t)})),this.lensFlareSystems.forEach((function(t){e.scene.removeLensFlareSystem(t)})),this.actionManagers.forEach((function(t){e.scene.removeActionManager(t)})),this.sounds.forEach((function(t){t.stop(),t.autoplay=!1,e.scene.mainSoundTrack.RemoveSound(t)})),this.textures.forEach((function(t){e.scene.removeTexture(t)})),this.effectLayers.forEach((function(t){e.scene.removeEffectLayer(t)}))},e.prototype._moveAssets=function(e,t,i){for(var r=0,n=e;r<n.length;r++){for(var o=n[r],s=!0,a=0,l=i;a<l.length;a++){if(o===l[a]){s=!1;break}}s&&t.push(o)}},e.prototype.moveAllFromScene=function(e){void 0===e&&(e=new t),this._moveAssets(this.scene.cameras,this.cameras,e.cameras),this._moveAssets(this.scene.meshes,this.meshes,e.meshes),this._moveAssets(this.scene.getGeometries(),this.geometries,e.geometries),this._moveAssets(this.scene.materials,this.materials,e.materials),this._moveAssets(this.scene._actionManagers,this.actionManagers,e.actionManagers),this._moveAssets(this.scene.animations,this.animations,e.animations),this._moveAssets(this.scene.animationGroups,this.animationGroups,e.animationGroups),this._moveAssets(this.scene.lensFlareSystems,this.lensFlareSystems,e.lensFlareSystems),this._moveAssets(this.scene.lights,this.lights,e.lights),this._moveAssets(this.scene.morphTargetManagers,this.morphTargetManagers,e.morphTargetManagers),this._moveAssets(this.scene.multiMaterials,this.multiMaterials,e.multiMaterials),this._moveAssets(this.scene.skeletons,this.skeletons,e.skeletons),this._moveAssets(this.scene.particleSystems,this.particleSystems,e.particleSystems),this._moveAssets(this.scene.mainSoundTrack.soundCollection,this.sounds,e.sounds),this._moveAssets(this.scene.transformNodes,this.transformNodes,e.transformNodes),this._moveAssets(this.scene.textures,this.textures,e.textures),this._moveAssets(this.scene.effectLayers,this.effectLayers,e.effectLayers),this.removeAllFromScene()},e})();e.AssetContainer=i})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a){void 0===n&&(n=0),void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=!1),t instanceof e.Mesh?this._engine=t.getScene().getEngine():this._engine=t,this._updatable=r,this._instanced=s,this._data=i,this.byteStride=a?n:n*Float32Array.BYTES_PER_ELEMENT,o||this.create()}return t.prototype.createVertexBuffer=function(t,i,r,n,o,s){void 0===s&&(s=!1);var a=s?i:i*Float32Array.BYTES_PER_ELEMENT,l=n?s?n:n*Float32Array.BYTES_PER_ELEMENT:this.byteStride
;return new e.VertexBuffer(this._engine,this,t,this._updatable,!0,l,void 0===o?this._instanced:o,a,r,void 0,void 0,!0)},t.prototype.isUpdatable=function(){return this._updatable},t.prototype.getData=function(){return this._data},t.prototype.getBuffer=function(){return this._buffer},t.prototype.getStrideSize=function(){return this.byteStride/Float32Array.BYTES_PER_ELEMENT},t.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))},t.prototype._rebuild=function(){this._buffer=null,this.create(this._data)},t.prototype.update=function(e){this.create(e)},t.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)},t.prototype.dispose=function(){this._buffer&&this._engine._releaseBuffer(this._buffer)&&(this._buffer=null)},t})();e.Buffer=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(i,r,n,o,s,a,l,h,c,u,f,p){if(void 0===f&&(f=!1),void 0===p&&(p=!1),r instanceof e.Buffer?(this._buffer=r,this._ownsBuffer=!1):(this._buffer=new e.Buffer(i,r,o,a,s,l,p),this._ownsBuffer=!0),this._kind=n,void 0==u){var d=this.getData();this.type=t.FLOAT,d instanceof Int8Array?this.type=t.BYTE:d instanceof Uint8Array?this.type=t.UNSIGNED_BYTE:d instanceof Int16Array?this.type=t.SHORT:d instanceof Uint16Array?this.type=t.UNSIGNED_SHORT:d instanceof Int32Array?this.type=t.INT:d instanceof Uint32Array&&(this.type=t.UNSIGNED_INT)}else this.type=u;var m=t.GetTypeByteLength(this.type);p?(this._size=c||(a?a/m:t.DeduceStride(n)),this.byteStride=a||this._buffer.byteStride||this._size*m,this.byteOffset=h||0):(this._size=c||a||t.DeduceStride(n),this.byteStride=a?a*m:this._buffer.byteStride||this._size*m,this.byteOffset=(h||0)*m),this.normalized=f,this._instanced=void 0!==l&&l,this._instanceDivisor=l?1:0}return Object.defineProperty(t.prototype,"instanceDivisor",{get:function(){return this._instanceDivisor},set:function(e){this._instanceDivisor=e,this._instanced=0!=e},enumerable:!0,configurable:!0}),t.prototype._rebuild=function(){this._buffer&&this._buffer._rebuild()},t.prototype.getKind=function(){return this._kind},t.prototype.isUpdatable=function(){return this._buffer.isUpdatable()},t.prototype.getData=function(){return this._buffer.getData()},t.prototype.getBuffer=function(){return this._buffer.getBuffer()},t.prototype.getStrideSize=function(){return this.byteStride/t.GetTypeByteLength(this.type)},t.prototype.getOffset=function(){return this.byteOffset/t.GetTypeByteLength(this.type)},t.prototype.getSize=function(){return this._size},t.prototype.getIsInstanced=function(){return this._instanced},t.prototype.getInstanceDivisor=function(){return this._instanceDivisor},t.prototype.create=function(e){return this._buffer.create(e)},t.prototype.update=function(e){return this._buffer.update(e)},t.prototype.updateDirectly=function(e,t,i){void 0===i&&(i=!1),this._buffer.updateDirectly(e,t,void 0,i)},t.prototype.dispose=function(){this._ownsBuffer&&this._buffer.dispose()},t.prototype.forEach=function(e,i){t.ForEach(this._buffer.getData(),this.byteOffset,this.byteStride,this._size,this.type,e,this.normalized,i)},Object.defineProperty(t,"PositionKind",{get:function(){return t._PositionKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"NormalKind",{get:function(){return t._NormalKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TangentKind",{get:function(){return t._TangentKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UVKind",{get:function(){return t._UVKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV2Kind",{get:function(){return t._UV2Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV3Kind",{get:function(){return t._UV3Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV4Kind",{get:function(){return t._UV4Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV5Kind",{get:function(){return t._UV5Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"UV6Kind",{get:function(){return t._UV6Kind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ColorKind",{get:function(){return t._ColorKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesKind",{get:function(){return t._MatricesIndicesKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsKind",{get:function(){return t._MatricesWeightsKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesIndicesExtraKind",{get:function(){return t._MatricesIndicesExtraKind},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MatricesWeightsExtraKind",{get:function(){return t._MatricesWeightsExtraKind},enumerable:!0,configurable:!0}),t.DeduceStride=function(e){switch(e){case t.UVKind:case t.UV2Kind:case t.UV3Kind:case t.UV4Kind:case t.UV5Kind:case t.UV6Kind:return 2;case t.NormalKind:case t.PositionKind:return 3;case t.ColorKind:case t.MatricesIndicesKind:case t.MatricesIndicesExtraKind:case t.MatricesWeightsKind:case t.MatricesWeightsExtraKind:case t.TangentKind:return 4;default:throw new Error("Invalid kind '"+e+"'")}},t.GetTypeByteLength=function(e){switch(e){case t.BYTE:case t.UNSIGNED_BYTE:return 1;case t.SHORT:case t.UNSIGNED_SHORT:return 2;case t.INT:case t.FLOAT:return 4;default:throw new Error("Invalid type '"+e+"'")}},t.ForEach=function(e,i,r,n,o,s,a,l){if(e instanceof Array)for(var h=i/4,c=r/4,u=0;u<s;u+=n){for(var f=0;f<n;f++)l(e[h+f],u+f);h+=c}else for(var p=e instanceof ArrayBuffer?new DataView(e):new DataView(e.buffer,e.byteOffset,e.byteLength),d=t.GetTypeByteLength(o),u=0;u<s;u+=n){for(var m=i,f=0;f<n;f++){var _=t._GetFloatValue(p,o,m,a);l(_,u+f),m+=d}i+=r}},t._GetFloatValue=function(e,i,r,n){switch(i){case t.BYTE:var o=e.getInt8(r);return n&&(o=Math.max(o/127,-1)),o;case t.UNSIGNED_BYTE:var o=e.getUint8(r);return n&&(o/=255),o;case t.SHORT:var o=e.getInt16(r,!0);return n&&(o=Math.max(o/16383,-1)),o;case t.UNSIGNED_SHORT:var o=e.getUint16(r,!0);return n&&(o/=65535),o;case t.FLOAT:return e.getFloat32(r,!0);default:throw new Error("Invalid component type "+i)}},t.BYTE=5120,t.UNSIGNED_BYTE=5121,t.SHORT=5122,t.UNSIGNED_SHORT=5123,t.INT=5124,t.UNSIGNED_INT=5125,t.FLOAT=5126,t._PositionKind="position",t._NormalKind="normal",t._TangentKind="tangent",t._UVKind="uv",t._UV2Kind="uv2",t._UV3Kind="uv3",t._UV4Kind="uv4",t._UV5Kind="uv5",t._UV6Kind="uv6",t._ColorKind="color",t._MatricesIndicesKind="matricesIndices",t._MatricesWeightsKind="matricesWeights",t._MatricesIndicesExtraKind="matricesIndicesExtra",t._MatricesWeightsExtraKind="matricesWeightsExtra",t})();e.VertexBuffer=t})(r||(r={}));var r;!(function(e){var t=(function(){function e(){this.previous=null,this.next=null}return e})();e.DummyInternalTextureTracker=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(i,r){this.onLoadedObservable=new e.Observable,this.previous=null,this.next=null,this._initialSlot=-1,this._designatedSlot=-1,this._dataSource=t.DATASOURCE_UNKNOWN,this._comparisonFunction=0,this._references=1,this._engine=i,this._dataSource=r,this._webGLTexture=i._createTexture()}return Object.defineProperty(t.prototype,"dataSource",{get:function(){return this._dataSource},enumerable:!0,configurable:!0}),t.prototype.incrementReferences=function(){this._references++},t.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},t.prototype._rebuild=function(){var i,r=this;switch(this.isReady=!1,this._cachedCoordinatesMode=null,this._cachedWrapU=null,this._cachedWrapV=null,this._cachedAnisotropicFilteringLevel=null,this._dataSource){case t.DATASOURCE_TEMP:return;case t.DATASOURCE_URL:return i=this._engine.createTexture(this.url,!this.generateMipMaps,this.invertY,null,this.samplingMode,(function(){r.isReady=!0}),null,this._buffer,void 0,this.format),void i._swapAndDie(this);case t.DATASOURCE_RAW:return i=this._engine.createRawTexture(this._bufferView,this.baseWidth,this.baseHeight,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),i._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_RAW3D:return i=this._engine.createRawTexture3D(this._bufferView,this.baseWidth,this.baseHeight,this.baseDepth,this.format,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),i._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_DYNAMIC:return i=this._engine.createDynamicTexture(this.baseWidth,this.baseHeight,this.generateMipMaps,this.samplingMode),void i._swapAndDie(this);case t.DATASOURCE_RENDERTARGET:var n=new e.RenderTargetCreationOptions;if(n.generateDepthBuffer=this._generateDepthBuffer,n.generateMipMaps=this.generateMipMaps,n.generateStencilBuffer=this._generateStencilBuffer,n.samplingMode=this.samplingMode,n.type=this.type,this.isCube)i=this._engine.createRenderTargetCubeTexture(this.width,n);else{var o={width:this.width,height:this.height};i=this._engine.createRenderTargetTexture(o,n)}return i._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_DEPTHTEXTURE:var s={bilinearFiltering:this.samplingMode!==e.Texture.BILINEAR_SAMPLINGMODE,comparisonFunction:this._comparisonFunction,generateStencil:this._generateStencilBuffer,isCube:this.isCube};return i=this._engine.createDepthStencilTexture({width:this.width,height:this.height},s),i._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_CUBE:return i=this._engine.createCubeTexture(this.url,null,this._files,!this.generateMipMaps,(function(){r.isReady=!0}),null,this.format,this._extension),void i._swapAndDie(this);case t.DATASOURCE_CUBERAW:return i=this._engine.createRawCubeTexture(this._bufferViewArray,this.width,this.format,this.type,this.generateMipMaps,this.invertY,this.samplingMode,this._compression),i._swapAndDie(this),void(this.isReady=!0);case t.DATASOURCE_CUBEPREFILTERED:return void(i=this._engine.createPrefilteredCubeTexture(this.url,null,this._lodGenerationScale,this._lodGenerationOffset,(function(e){e&&e._swapAndDie(r),r.isReady=!0}),null,this.format,this._extension))}},t.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)},t.prototype.dispose=function(){this._webGLTexture&&0===--this._references&&(this._engine._releaseTexture(this),this._webGLTexture=null,this.previous=null,this.next=null)},t.DATASOURCE_UNKNOWN=0,t.DATASOURCE_URL=1,t.DATASOURCE_TEMP=2,t.DATASOURCE_RAW=3,t.DATASOURCE_DYNAMIC=4,t.DATASOURCE_RENDERTARGET=5,t.DATASOURCE_MULTIRENDERTARGET=6,t.DATASOURCE_CUBE=7,t.DATASOURCE_CUBERAW=8,t.DATASOURCE_CUBEPREFILTERED=9,t.DATASOURCE_RAW3D=10,t.DATASOURCE_DEPTHTEXTURE=11,t})();e.InternalTexture=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(i){this._hasAlpha=!1,this.getAlphaFromRGB=!1,this.level=1,this.coordinatesIndex=0,this._coordinatesMode=e.Texture.EXPLICIT_MODE,this.wrapU=e.Texture.WRAP_ADDRESSMODE,this.wrapV=e.Texture.WRAP_ADDRESSMODE,this.wrapR=e.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.lodGenerationOffset=0,this.lodGenerationScale=.8,this.isRenderTarget=!1,this.animations=new Array,this.onDisposeObservable=new e.Observable,this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._scene=i||e.Engine.LastCreatedScene,this._scene&&this._scene.textures.push(this),this._uid=null}return Object.defineProperty(t.prototype,"hasAlpha",{get:function(){return this._hasAlpha},set:function(t){this._hasAlpha!==t&&(this._hasAlpha=t,this._scene&&this._scene.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag|e.Material.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"coordinatesMode",{get:function(){return this._coordinatesMode},set:function(t){this._coordinatesMode!==t&&(this._coordinatesMode=t,this._scene&&this._scene.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"uid",{get:function(){return this._uid||(this._uid=e.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 e.Matrix.IdentityReadOnly},t.prototype.getReflectionTextureMatrix=function(){return e.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===e.Engine.DELAYLOADSTATE_NOTLOADED?(this.delayLoad(),!1):!!this._texture&&this._texture.isReady},t.prototype.getSize=function(){return this._texture&&this._texture.width?new e.Size(this._texture.width,this._texture.height):this._texture&&this._texture._size?new e.Size(this._texture._size,this._texture._size):e.Size.Zero()},t.prototype.getBaseSize=function(){return this.isReady()&&this._texture?this._texture._size?new e.Size(this._texture._size,this._texture._size):new e.Size(this._texture.baseWidth,this._texture.baseHeight):e.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:e.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:e.Engine.TEXTUREFORMAT_RGBA},enumerable:!0,configurable:!0}),t.prototype.readPixels=function(e){if(void 0===e&&(e=0),!this._texture)return null;var t=this.getSize(),i=this.getScene();if(!i)return null;var r=i.getEngine();return this._texture.isCube?r._readTexturePixels(this._texture,t.width,t.height,e):r._readTexturePixels(this._texture,t.width,t.height,-1)},t.prototype.releaseInternalTexture=function(){this._texture&&(this._texture.dispose(),this._texture=null)},Object.defineProperty(t.prototype,"sphericalPolynomial",{get:function(){return this._texture&&e.CubeMapToSphericalPolynomialTools&&this.isReady()?(this._texture._sphericalPolynomial||(this._texture._sphericalPolynomial=e.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);e>=0&&this._scene.textures.splice(e,1),void 0!==this._texture&&(this.releaseInternalTexture(),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear())}},t.prototype.serialize=function(){if(!this.name)return null;var t=e.SerializationHelper.Serialize(this);return e.Animation.AppendSerializedAnimations(this,t),t},t.WhenAllReady=function(e,t){var i=e.length;if(0===i)return void t();for(var r,n,o=0;o<e.length;o++)!(function(){if(r=e[o],r.isReady())0==--i&&t();else{n=r.onLoadObservable;var s=function(){n.removeCallback(s),0==--i&&t()};n.add(s)}})()},t.DEFAULT_ANISOTROPIC_FILTERING_LEVEL=4,n([e.serialize()],t.prototype,"name",void 0),n([e.serialize("hasAlpha")],t.prototype,"_hasAlpha",void 0),n([e.serialize()],t.prototype,"getAlphaFromRGB",void 0),n([e.serialize()],t.prototype,"level",void 0),n([e.serialize()],t.prototype,"coordinatesIndex",void 0),n([e.serialize("coordinatesMode")],t.prototype,"_coordinatesMode",void 0),n([e.serialize()],t.prototype,"wrapU",void 0),n([e.serialize()],t.prototype,"wrapV",void 0),n([e.serialize()],t.prototype,"wrapR",void 0),n([e.serialize()],t.prototype,"anisotropicFilteringLevel",void 0),n([e.serialize()],t.prototype,"isCube",void 0),n([e.serialize()],t.prototype,"is3D",void 0),n([e.serialize()],t.prototype,"gammaSpace",void 0),n([e.serialize()],t.prototype,"invertZ",void 0),n([e.serialize()],t.prototype,"lodLevelInAlpha",void 0),n([e.serialize()],t.prototype,"lodGenerationOffset",void 0),n([e.serialize()],t.prototype,"lodGenerationScale",void 0),n([e.serialize()],t.prototype,"isRenderTarget",void 0),t})();e.BaseTexture=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(r,n,o,s,a,l,h,c,u,f){void 0===o&&(o=!1),void 0===s&&(s=!0),void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===h&&(h=null),void 0===c&&(c=null),void 0===u&&(u=!1);var p=t.call(this,n)||this;if(p.uOffset=0,p.vOffset=0,p.uScale=1,p.vScale=1,p.uAng=0,p.vAng=0,p.wAng=0,p._isBlocking=!0,p.name=r||"",p.url=r,p._noMipmap=o,p._invertY=s,p._samplingMode=a,p._buffer=c,p._deleteBuffer=u,f&&(p._format=f),!(n=p.getScene()))return p;n.getEngine().onBeforeTextureInitObservable.notifyObservers(p);var d=function(){p._onLoadObservable&&p._onLoadObservable.hasObservers()&&p.onLoadObservable.notifyObservers(p),l&&l(),!p.isBlocking&&n&&n.resetCachedMaterial()};return p.url?(p._texture=p._getFromCache(p.url,o,a),p._texture?p._texture.isReady?e.Tools.SetImmediate((function(){return d()})):p._texture.onLoadedObservable.add(d):n.useDelayedTextureLoading?(p.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,p._delayedOnLoad=d,p._delayedOnError=h):(p._texture=n.getEngine().createTexture(p.url,o,s,n,p._samplingMode,d,h,p._buffer,void 0,p._format),u&&delete p._buffer),p):(p._delayedOnLoad=d,p._delayedOnError=h,p)}return o(i,t),Object.defineProperty(i.prototype,"noMipmap",{get:function(){return this._noMipmap},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isBlocking",{get:function(){return this._isBlocking},set:function(e){this._isBlocking=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"samplingMode",{get:function(){return this._samplingMode},enumerable:!0,configurable:!0}),i.prototype.updateURL=function(t){this.url=t,this.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,this.delayLoad()},i.prototype.delayLoad=function(){if(this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED){var t=this.getScene();t&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,this._noMipmap,this._samplingMode),this._texture?this._delayedOnLoad&&(this._texture.isReady?e.Tools.SetImmediate(this._delayedOnLoad):this._texture.onLoadedObservable.add(this._delayedOnLoad)):(this._texture=t.getEngine().createTexture(this.url,this._noMipmap,this._invertY,t,this._samplingMode,this._delayedOnLoad,this._delayedOnError,this._buffer,null,this._format),this._deleteBuffer&&delete this._buffer),this._delayedOnLoad=null,this._delayedOnError=null)}},i.prototype.updateSamplingMode=function(e){if(this._texture){var t=this.getScene();t&&(this._samplingMode=e,t.getEngine().updateTextureSamplingMode(e,this._texture))}},i.prototype._prepareRowForTextureGeneration=function(t,i,r,n){t*=this.uScale,i*=this.vScale,t-=.5*this.uScale,i-=.5*this.vScale,r-=.5,e.Vector3.TransformCoordinatesFromFloatsToRef(t,i,r,this._rowGenerationMatrix,n),n.x+=.5*this.uScale+this.uOffset,n.y+=.5*this.vScale+this.vOffset,n.z+=.5},i.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=e.Matrix.Zero(),this._rowGenerationMatrix=new e.Matrix,this._t0=e.Vector3.Zero(),this._t1=e.Vector3.Zero(),this._t2=e.Vector3.Zero()),e.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),e.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 i=this.getScene();return i?(i.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag,(function(e){return e.hasTexture(t)})),this._cachedTextureMatrix):this._cachedTextureMatrix},i.prototype.getReflectionTextureMatrix=function(){var t=this,r=this.getScene();if(!r)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!==i.PROJECTION_MODE)return this._cachedTextureMatrix;if(this._cachedProjectionMatrixId===r.getProjectionMatrix().updateFlag)return this._cachedTextureMatrix}switch(this._cachedTextureMatrix||(this._cachedTextureMatrix=e.Matrix.Zero()),this._projectionModeMatrix||(this._projectionModeMatrix=e.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 i.PLANAR_MODE:e.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 i.PROJECTION_MODE:e.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 n=r.getProjectionMatrix();this._cachedProjectionMatrixId=n.updateFlag,n.multiplyToRef(this._projectionModeMatrix,this._cachedTextureMatrix);break;default:e.Matrix.IdentityToRef(this._cachedTextureMatrix)}return r.markAllMaterialsAsDirty(e.Material.TextureDirtyFlag,(function(e){return-1!==e.getActiveTextures().indexOf(t)})),this._cachedTextureMatrix},i.prototype.clone=function(){var t=this;return e.SerializationHelper.Clone((function(){return new i(t._texture?t._texture.url:null,t.getScene(),t._noMipmap,t._invertY,t._samplingMode)}),this)},Object.defineProperty(i.prototype,"onLoadObservable",{get:function(){return this._onLoadObservable||(this._onLoadObservable=new e.Observable),this._onLoadObservable},enumerable:!0,configurable:!0}),i.prototype.serialize=function(){var e=t.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},i.prototype.getClassName=function(){return"Texture"},i.prototype.dispose=function(){t.prototype.dispose.call(this),this.onLoadObservable&&(this.onLoadObservable.clear(),this._onLoadObservable=null),this._delayedOnLoad=null,this._delayedOnError=null},i.CreateFromBase64String=function(t,r,n,o,s,a,l,h,c){return void 0===a&&(a=i.TRILINEAR_SAMPLINGMODE),void 0===l&&(l=null),void 0===h&&(h=null),void 0===c&&(c=e.Engine.TEXTUREFORMAT_RGBA),new i("data:"+r,n,o,s,a,l,h,t,!1,c)},i.Parse=function(t,r,n){if(t.customType){var o=e.Tools.Instantiate(t.customType),s=o.Parse(t,r,n);return t.samplingMode&&s.updateSamplingMode&&s._samplingMode&&s._samplingMode!==t.samplingMode&&s.updateSamplingMode(t.samplingMode),s}if(t.isCube)return e.CubeTexture.Parse(t,r,n);if(!t.name&&!t.isRenderTarget)return null;var a=e.SerializationHelper.Parse((function(){var o=!0;if(t.noMipmap&&(o=!1),t.mirrorPlane){var s=new e.MirrorTexture(t.name,t.renderTargetSize,r,o);return s._waitingRenderList=t.renderList,s.mirrorPlane=e.Plane.FromArray(t.mirrorPlane),s}if(t.isRenderTarget){var a=new e.RenderTargetTexture(t.name,t.renderTargetSize,r,o);return a._waitingRenderList=t.renderList,a}var l;if(t.base64String)l=i.CreateFromBase64String(t.base64String,t.name,r,!o);else{var h=n+t.name;i.UseSerializedUrlIfAny&&t.url&&(h=t.url),l=new i(h,r,!o,t.invertY)}return l}),t,r);if(t.samplingMode){var l=t.samplingMode;a._samplingMode!==l&&a.updateSamplingMode(l)}if(t.animations)for(var h=0;h<t.animations.length;h++){var c=t.animations[h];a.animations.push(e.Animation.Parse(c))}return a},i.LoadFromDataString=function(t,r,n,o,s,a,l,h,c,u){return void 0===o&&(o=!1),void 0===s&&(s=!1),void 0===a&&(a=!0),void 0===l&&(l=i.TRILINEAR_SAMPLINGMODE),void 0===h&&(h=null),void 0===c&&(c=null),void 0===u&&(u=e.Engine.TEXTUREFORMAT_RGBA),"data:"!==t.substr(0,5)&&(t="data:"+t),new i(t,n,s,a,l,h,c,r,o,u)},i.NEAREST_SAMPLINGMODE=1,i.NEAREST_NEAREST_MIPLINEAR=1,i.BILINEAR_SAMPLINGMODE=2,i.LINEAR_LINEAR_MIPNEAREST=2,i.TRILINEAR_SAMPLINGMODE=3,i.LINEAR_LINEAR_MIPLINEAR=3,i.NEAREST_NEAREST_MIPNEAREST=4,i.NEAREST_LINEAR_MIPNEAREST=5,i.NEAREST_LINEAR_MIPLINEAR=6,i.NEAREST_LINEAR=7,i.NEAREST_NEAREST=8,i.LINEAR_NEAREST_MIPNEAREST=9,i.LINEAR_NEAREST_MIPLINEAR=10,i.LINEAR_LINEAR=11,i.LINEAR_NEAREST=12,i.EXPLICIT_MODE=0,i.SPHERICAL_MODE=1,i.PLANAR_MODE=2,i.CUBIC_MODE=3,i.PROJECTION_MODE=4,i.SKYBOX_MODE=5,i.INVCUBIC_MODE=6,i.EQUIRECTANGULAR_MODE=7,i.FIXED_EQUIRECTANGULAR_MODE=8,i.FIXED_EQUIRECTANGULAR_MIRRORED_MODE=9,i.CLAMP_ADDRESSMODE=0,i.WRAP_ADDRESSMODE=1,i.MIRROR_ADDRESSMODE=2,i.UseSerializedUrlIfAny=!1,n([e.serialize()],i.prototype,"url",void 0),n([e.serialize()],i.prototype,"uOffset",void 0),n([e.serialize()],i.prototype,"vOffset",void 0),n([e.serialize()],i.prototype,"uScale",void 0),n([e.serialize()],i.prototype,"vScale",void 0),n([e.serialize()],i.prototype,"uAng",void 0),n([e.serialize()],i.prototype,"vAng",void 0),n([e.serialize()],i.prototype,"wAng",void 0),n([e.serialize()],i.prototype,"isBlocking",null),i})(e.BaseTexture);e.Texture=t})(r||(r={}));var r;!(function(e){var t=(function(){function e(){this.mustReturn=!1,this.visibleInstances=new Array,this.renderSelf=new Array}return e})();e._InstancesBatch=t;var i=(function(i){function r(n,o,s,a,l,h){void 0===o&&(o=null),void 0===s&&(s=null),void 0===a&&(a=null),void 0===h&&(h=!0);var c=i.call(this,n,o)||this;if(c.onBeforeRenderObservable=new e.Observable,c.onAfterRenderObservable=new e.Observable,c.onBeforeDrawObservable=new e.Observable,c.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,c.instances=new Array,c._LODLevels=new Array,c._visibleInstances={},c._renderIdForInstances=new Array,c._batchCache=new t,c._instancesBufferSize=2048,c._originalBuilderSideOrientation=r._DEFAULTSIDE,c.overrideMaterialSideOrientation=null,c._areNormalsFrozen=!1,c._source=null,o=c.getScene(),a){c._source=a,a._geometry&&a._geometry.applyToMesh(c),e.Tools.DeepCopy(a,c,["name","material","skeleton","instances","parent","uniqueId","source","metadata","hasLODLevels","geometry","isBlocked","areNormalsFrozen"],["_poseMatrix","_source"]),a.metadata&&a.metadata.clone?c.metadata=a.metadata.clone():c.metadata=a.metadata,e.Tags&&e.Tags.HasTags(a)&&e.Tags.AddTagsTo(c,e.Tags.GetTags(a,!0)),c.parent=a.parent,c.setPivotMatrix(a.getPivotMatrix()),c.id=n+"."+a.id,c.material=a.material;var u;if(!l)for(var f=a.getDescendants(!0),p=0;p<f.length;p++){var d=f[p];d.clone&&d.clone(n+"."+d.name,c)}var m=c.getScene().getPhysicsEngine();if(h&&m){var _=m.getImpostorForPhysicsObject(a);_&&(c.physicsImpostor=_.clone(c))}for(u=0;u<o.particleSystems.length;u++){var g=o.particleSystems[u];g.emitter===a&&g.clone(g.name,c)}c.computeWorldMatrix(!0)}return null!==s&&(c.parent=s),c}return o(r,i),Object.defineProperty(r,"FRONTSIDE",{get:function(){return r._FRONTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BACKSIDE",{get:function(){return r._BACKSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DOUBLESIDE",{get:function(){return r._DOUBLESIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"DEFAULTSIDE",{get:function(){return r._DEFAULTSIDE},enumerable:!0,configurable:!0}),Object.defineProperty(r,"NO_CAP",{get:function(){return r._NO_CAP},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_START",{get:function(){return r._CAP_START},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_END",{get:function(){return r._CAP_END},enumerable:!0,configurable:!0}),Object.defineProperty(r,"CAP_ALL",{get:function(){return r._CAP_ALL},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"onBeforeDraw",{set:function(e){this._onBeforeDrawObserver&&this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver),this._onBeforeDrawObserver=this.onBeforeDrawObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"morphTargetManager",{get:function(){return this._morphTargetManager},set:function(e){this._morphTargetManager!==e&&(this._morphTargetManager=e,this._syncGeometryWithMorphTargetManager())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"source",{get:function(){return this._source},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"isUnIndexed",{get:function(){return this._unIndexed},set:function(e){this._unIndexed!==e&&(this._unIndexed=e,this._markSubMeshesAsAttributesDirty())},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"Mesh"},r.prototype.toString=function(t){var r=i.prototype.toString.call(this,t);if(r+=", n vertices: "+this.getTotalVertices(),r+=", parent: "+(this._waitingParentId?this._waitingParentId:this.parent?this.parent.name:"NONE"),this.animations)for(var n=0;n<this.animations.length;n++)r+=", animation[0]: "+this.animations[n].toString(t);if(t)if(this._geometry){
var o=this.getIndices(),s=this.getVerticesData(e.VertexBuffer.PositionKind);s&&o&&(r+=", flat shading: "+(s.length/3===o.length?"YES":"NO"))}else r+=", flat shading: UNKNOWN";return r},r.prototype._unBindEffect=function(){i.prototype._unBindEffect.call(this);for(var e=0,t=this.instances;e<t.length;e++){t[e]._unBindEffect()}},Object.defineProperty(r.prototype,"hasLODLevels",{get:function(){return this._LODLevels.length>0},enumerable:!0,configurable:!0}),r.prototype.getLODLevels=function(){return this._LODLevels},r.prototype._sortLODLevels=function(){this._LODLevels.sort((function(e,t){return e.distance<t.distance?1:e.distance>t.distance?-1:0}))},r.prototype.addLODLevel=function(t,i){if(i&&i._masterMesh)return e.Tools.Warn("You cannot use a mesh as LOD level twice"),this;var r=new e.MeshLODLevel(t,i);return this._LODLevels.push(r),i&&(i._masterMesh=this),this._sortLODLevels(),this},r.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},r.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},r.prototype.getLOD=function(e,t){if(!this._LODLevels||0===this._LODLevels.length)return this;var i;if(t)i=t;else{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(r.prototype,"geometry",{get:function(){return this._geometry},enumerable:!0,configurable:!0}),r.prototype.getTotalVertices=function(){return null===this._geometry||void 0===this._geometry?0:this._geometry.getTotalVertices()},r.prototype.getVerticesData=function(e,t,i){return this._geometry?this._geometry.getVerticesData(e,t,i):null},r.prototype.getVertexBuffer=function(e){return this._geometry?this._geometry.getVertexBuffer(e):null},r.prototype.isVerticesDataPresent=function(e){return this._geometry?this._geometry.isVerticesDataPresent(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},r.prototype.isVertexBufferUpdatable=function(e){return this._geometry?this._geometry.isVertexBufferUpdatable(e):!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},r.prototype.getVerticesDataKinds=function(){if(!this._geometry){var e=new Array;return this._delayInfo&&this._delayInfo.forEach((function(t,i,r){e.push(t)})),e}return this._geometry.getVerticesDataKinds()},r.prototype.getTotalIndices=function(){return this._geometry?this._geometry.getTotalIndices():0},r.prototype.getIndices=function(e){return this._geometry?this._geometry.getIndices(e):[]},Object.defineProperty(r.prototype,"isBlocked",{get:function(){return null!==this._masterMesh&&void 0!==this._masterMesh},enumerable:!0,configurable:!0}),r.prototype.isReady=function(t,r){if(void 0===t&&(t=!1),void 0===r&&(r=!1),this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADING)return!1;if(!i.prototype.isReady.call(this,t))return!1;if(!this.subMeshes||0===this.subMeshes.length)return!0;if(!t)return!0;var n=this.getEngine(),o=this.getScene(),s=r||n.getCaps().instancedArrays&&this.instances.length>0;this.computeWorldMatrix();var a=this.material||o.defaultMaterial;if(a)if(a.storeEffectOnSubMeshes)for(var l=0,h=this.subMeshes;l<h.length;l++){var c=h[l],u=c.getMaterial();if(u)if(u.storeEffectOnSubMeshes){if(!u.isReadyForSubMesh(this,c,s))return!1}else if(!u.isReady(this,s))return!1}else if(!a.isReady(this,s))return!1;for(var f=0,p=this._lightSources;f<p.length;f++){var d=p[f],m=d.getShadowGenerator();if(m)for(var _=0,g=this.subMeshes;_<g.length;_++){var c=g[_];if(!m.isReady(c,s))return!1}}for(var v=0,y=this._LODLevels;v<y.length;v++){var b=y[v];if(b.mesh&&!b.mesh.isReady(s))return!1}return!0},Object.defineProperty(r.prototype,"areNormalsFrozen",{get:function(){return this._areNormalsFrozen},enumerable:!0,configurable:!0}),r.prototype.freezeNormals=function(){return this._areNormalsFrozen=!0,this},r.prototype.unfreezeNormals=function(){return this._areNormalsFrozen=!1,this},Object.defineProperty(r.prototype,"overridenInstanceCount",{set:function(e){this._overridenInstanceCount=e},enumerable:!0,configurable:!0}),r.prototype._preActivate=function(){var e=this.getScene().getRenderId();return this._preActivateId===e?this:(this._preActivateId=e,this._visibleInstances=null,this)},r.prototype._preActivateForIntermediateRendering=function(e){return this._visibleInstances&&(this._visibleInstances.intermediateDefaultRenderId=e),this},r.prototype._registerInstanceForRenderId=function(e,t){return this._visibleInstances||(this._visibleInstances={},this._visibleInstances.defaultRenderId=t,this._visibleInstances.selfDefaultRenderId=this._renderId),this._visibleInstances[t]||(this._visibleInstances[t]=new Array),this._visibleInstances[t].push(e),this},r.prototype.refreshBoundingInfo=function(){return this._refreshBoundingInfo(!1)},r.prototype._refreshBoundingInfo=function(t){if(this._boundingInfo&&this._boundingInfo.isLocked)return this;var i=this._getPositionData(t);if(i){var r=e.Tools.ExtractMinAndMax(i,0,this.getTotalVertices());this._boundingInfo=new e.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},r.prototype._getPositionData=function(t){var i=this.getVerticesData(e.VertexBuffer.PositionKind);if(i&&t&&this.skeleton){i=e.Tools.Slice(i);var r=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),n=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind);if(n&&r)for(var o=this.numBoneInfluencers>4,s=o?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,a=o?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,l=this.skeleton.getTransformMatrices(this),h=e.Tmp.Vector3[0],c=e.Tmp.Matrix[0],u=e.Tmp.Matrix[1],f=0,p=0;p<i.length;p+=3,f+=4){c.reset();var d,m;for(d=0;d<4&&!((m=n[f+d])<=0);d++)e.Matrix.FromFloat32ArrayToRefScaled(l,Math.floor(16*r[f+d]),m,u),c.addToSelf(u);if(o)for(d=0;d<4&&!((m=a[f+d])<=0);d++)e.Matrix.FromFloat32ArrayToRefScaled(l,Math.floor(16*s[f+d]),m,u),c.addToSelf(u);e.Vector3.TransformCoordinatesFromFloatsToRef(i[p],i[p+1],i[p+2],c,h),h.toArray(i,p)}}return i},r.prototype._createGlobalSubMesh=function(t){var i=this.getTotalVertices();if(!i||!this.getIndices())return null;if(this.subMeshes&&this.subMeshes.length>0){var r=this.getIndices();if(!r)return null;var n=r.length,o=!1;if(t)o=!0;else for(var s=0,a=this.subMeshes;s<a.length;s++){var l=a[s];if(l.indexStart+l.indexCount>=n){o=!0;break}if(l.verticesStart+l.verticesCount>=i){o=!0;break}}if(!o)return this.subMeshes[0]}return this.releaseSubMeshes(),new e.SubMesh(0,0,i,0,this.getTotalIndices(),this)},r.prototype.subdivide=function(t){if(!(t<1)){for(var i=this.getTotalIndices(),r=i/t|0,n=0;r%3!=0;)r++;this.releaseSubMeshes();for(var o=0;o<t&&!(n>=i);o++)e.SubMesh.CreateFromIndices(0,n,Math.min(r,i-n),this),n+=r;this.synchronizeInstances()}},r.prototype.setVerticesData=function(t,i,r,n){if(void 0===r&&(r=!1),this._geometry)this._geometry.setVerticesData(t,i,r,n);else{var o=new e.VertexData;o.set(i,t);var s=this.getScene();new e.Geometry(e.Geometry.RandomId(),s,o,r,this)}return this},r.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)},r.prototype.setVerticesBuffer=function(t){return this._geometry||(this._geometry=e.Geometry.CreateGeometryForMesh(this)),this._geometry.setVerticesBuffer(t),this},r.prototype.updateVerticesData=function(e,t,i,r){return this._geometry?(r?(this.makeGeometryUnique(),this.updateVerticesData(e,t,i,!1)):this._geometry.updateVerticesData(e,t,i),this):this},r.prototype.updateMeshPositions=function(t,i){void 0===i&&(i=!0);var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(!r)return this;if(t(r),this.updateVerticesData(e.VertexBuffer.PositionKind,r,!1,!1),i){var n=this.getIndices(),o=this.getVerticesData(e.VertexBuffer.NormalKind);if(!o)return this;e.VertexData.ComputeNormals(r,n,o),this.updateVerticesData(e.VertexBuffer.NormalKind,o,!1,!1)}return this},r.prototype.makeGeometryUnique=function(){if(!this._geometry)return this;var t=this._geometry,i=this._geometry.copy(e.Geometry.RandomId());return t.releaseForMesh(this,!0),i.applyToMesh(this),this},r.prototype.setIndices=function(t,i,r){if(void 0===i&&(i=null),void 0===r&&(r=!1),this._geometry)this._geometry.setIndices(t,i,r);else{var n=new e.VertexData;n.indices=t;var o=this.getScene();new e.Geometry(e.Geometry.RandomId(),o,n,r,this)}return this},r.prototype.updateIndices=function(e,t){return this._geometry?(this._geometry.updateIndices(e,t),this):this},r.prototype.toLeftHanded=function(){return this._geometry?(this._geometry.toLeftHanded(),this):this},r.prototype._bind=function(t,i,r){if(!this._geometry)return this;var n,o=this.getScene().getEngine();if(this._unIndexed)n=null;else switch(r){case e.Material.PointFillMode:n=null;break;case e.Material.WireFrameFillMode:n=t.getLinesIndexBuffer(this.getIndices(),o);break;default:case e.Material.TriangleFillMode:n=this._unIndexed?null:this._geometry.getIndexBuffer()}return this._geometry._bind(i,n),this},r.prototype._draw=function(t,i,r,n){if(void 0===n&&(n=!1),!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this.onBeforeDrawObservable.notifyObservers(this);var o=this.getScene(),s=o.getEngine();if(this._unIndexed||i==e.Material.PointFillMode?s.drawArraysType(i,t.verticesStart,t.verticesCount,r):i==e.Material.WireFrameFillMode?s.drawElementsType(i,0,t.linesIndexCount,r):s.drawElementsType(i,t.indexStart,t.indexCount,r),o._isAlternateRenderingEnabled&&!n){var a=t.effect||this._effectiveMaterial.getEffect();if(!a||!o.activeCamera)return this;o._switchToAlternateCameraConfiguration(!0),this._effectiveMaterial.bindView(a),this._effectiveMaterial.bindViewProjection(a),s.setViewport(o.activeCamera._alternateCamera.viewport),this._draw(t,i,r,!0),s.setViewport(o.activeCamera.viewport),o._switchToAlternateCameraConfiguration(!1),this._effectiveMaterial.bindView(a),this._effectiveMaterial.bindViewProjection(a)}return this},r.prototype.registerBeforeRender=function(e){return this.onBeforeRenderObservable.add(e),this},r.prototype.unregisterBeforeRender=function(e){return this.onBeforeRenderObservable.removeCallback(e),this},r.prototype.registerAfterRender=function(e){return this.onAfterRenderObservable.add(e),this},r.prototype.unregisterAfterRender=function(e){return this.onAfterRenderObservable.removeCallback(e),this},r.prototype._getInstancesRenderList=function(e){var t=this.getScene();if(this._batchCache.mustReturn=!1,this._batchCache.renderSelf[e]=this.isEnabled()&&this.isVisible,this._batchCache.visibleInstances[e]=null,this._visibleInstances){var i=t.getRenderId(),r=t._isInIntermediateRendering()?this._visibleInstances.intermediateDefaultRenderId:this._visibleInstances.defaultRenderId;this._batchCache.visibleInstances[e]=this._visibleInstances[i];var n=this._renderId;!this._batchCache.visibleInstances[e]&&r&&(this._batchCache.visibleInstances[e]=this._visibleInstances[r],i=Math.max(r,i),n=Math.max(this._visibleInstances.selfDefaultRenderId,i));var o=this._batchCache.visibleInstances[e];if(o&&o.length){if(this._renderIdForInstances[e]===i)return this._batchCache.mustReturn=!0,this._batchCache;i!==n&&(this._batchCache.renderSelf[e]=!1)}this._renderIdForInstances[e]=i}return this._batchCache},r.prototype._renderWithInstances=function(t,i,r,n,o){var s=r.visibleInstances[t._id];if(!s)return this;for(var a=s.length+1,l=16*a*4,h=this._instancesBufferSize,c=this._instancesBuffer;this._instancesBufferSize<l;)this._instancesBufferSize*=2;this._instancesData&&h==this._instancesBufferSize||(this._instancesData=new Float32Array(this._instancesBufferSize/4));var u=0,f=0,p=this.getWorldMatrix();if(r.renderSelf[t._id]&&(p.copyToArray(this._instancesData,u),u+=16,f++),s)for(var d=0;d<s.length;d++){var m=s[d];m.getWorldMatrix().copyToArray(this._instancesData,u),u+=16,f++}return c&&h==this._instancesBufferSize?c.updateDirectly(this._instancesData,0,f):(c&&c.dispose(),c=new e.Buffer(o,this._instancesData,!0,16,!1,!0),this._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(t,n,i),this._draw(t,i,f),o.unbindInstanceAttributes(),this},r.prototype._processRendering=function(e,t,i,r,n,o,s){var a=this.getScene(),l=a.getEngine();if(n)this._renderWithInstances(e,i,r,t,l);else{r.renderSelf[e._id]&&(o&&o(!1,this.getWorldMatrix(),s),this._draw(e,i,this._overridenInstanceCount));var h=r.visibleInstances[e._id];if(h)for(var c=0;c<h.length;c++){var u=h[c],f=u.getWorldMatrix();o&&o(!0,f,s),this._draw(e,i)}}return this},r.prototype.render=function(t,i){if(this._checkOcclusionQuery(),this._isOccluded)return this;var r=this.getScene(),n=this._getInstancesRenderList(t._id);if(n.mustReturn)return this;if(!this._geometry||!this._geometry.getVertexBuffers()||!this._unIndexed&&!this._geometry.getIndexBuffer())return this;this.onBeforeRenderObservable.notifyObservers(this);var o=r.getEngine(),s=o.getCaps().instancedArrays&&null!==n.visibleInstances[t._id]&&void 0!==n.visibleInstances[t._id],a=t.getMaterial();if(!a)return this;if(this._effectiveMaterial=a,this._effectiveMaterial.storeEffectOnSubMeshes){if(!this._effectiveMaterial.isReadyForSubMesh(this,t,s))return this}else if(!this._effectiveMaterial.isReady(this,s))return this;i&&o.setAlphaMode(this._effectiveMaterial.alphaMode);var l=o.getDepthWrite();this.renderOutline&&(o.setDepthWrite(!1),r.getOutlineRenderer().render(t,n),o.setDepthWrite(l));var h;if(!(h=this._effectiveMaterial.storeEffectOnSubMeshes?t.effect:this._effectiveMaterial.getEffect()))return this;var c=this.overrideMaterialSideOrientation;null==c&&(c=this._effectiveMaterial.sideOrientation,this._getWorldMatrixDeterminant()<0&&(c=c===e.Material.ClockWiseSideOrientation?e.Material.CounterClockWiseSideOrientation:e.Material.ClockWiseSideOrientation));var u=this._effectiveMaterial._preBind(h,c);this._effectiveMaterial.forceDepthWrite&&o.setDepthWrite(!0);var f=r.forcePointsCloud?e.Material.PointFillMode:r.forceWireframe?e.Material.WireFrameFillMode:this._effectiveMaterial.fillMode;s||this._bind(t,h,f);var p=this.getWorldMatrix();if(this._effectiveMaterial.storeEffectOnSubMeshes?this._effectiveMaterial.bindForSubMesh(p,this,t):this._effectiveMaterial.bind(p,this),!this._effectiveMaterial.backFaceCulling&&this._effectiveMaterial.separateCullingPass&&(o.setState(!0,this._effectiveMaterial.zOffset,!1,!u),this._processRendering(t,h,f,n,s,this._onBeforeDraw,this._effectiveMaterial),o.setState(!0,this._effectiveMaterial.zOffset,!1,u)),this._processRendering(t,h,f,n,s,this._onBeforeDraw,this._effectiveMaterial),this._effectiveMaterial.unbind(),this.renderOutline&&l&&(o.setDepthWrite(!0),o.setColorWrite(!1),r.getOutlineRenderer().render(t,n),o.setColorWrite(!0)),this.renderOverlay){var d=o.getAlphaMode();o.setAlphaMode(e.Engine.ALPHA_COMBINE),r.getOutlineRenderer().render(t,n,!0),o.setAlphaMode(d)}return this.onAfterRenderObservable.notifyObservers(this),this},r.prototype._onBeforeDraw=function(e,t,i){e&&i&&i.bindOnlyWorldMatrix(t)},r.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},r.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},r.prototype.cleanMatrixWeights=function(){var t=0;if(this.skeleton){t=this.skeleton.bones.length;for(var i=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),r=this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind),n=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind),o=this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind),s=this.numBoneInfluencers,a=n.length,l=0;l<a;l+=4){for(var h=0,c=-1,u=0;u<4;u++){var f=n[l+u];h+=f,f<.001&&c<0&&(c=u)}if(o)for(var u=0;u<4;u++){var f=o[l+u];h+=f,f<.001&&c<0&&(c=u+4)}if((c<0||c>s-1)&&(c=s-1),h>.001){for(var p=1/h,u=0;u<4;u++)n[l+u]*=p;if(o)for(var u=0;u<4;u++)o[l+u]*=p}else c>=4?(o[l+c-4]=1-h,r[l+c-4]=t):(n[l+c]=1-h,i[l+c]=t)}this.setVerticesData(e.VertexBuffer.MatricesIndicesKind,i),r&&this.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,r),this.setVerticesData(e.VertexBuffer.MatricesWeightsKind,n),o&&this.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,o)}},r.prototype._checkDelayState=function(){var t=this.getScene();return this._geometry?this._geometry.load(t):this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t)),this},r.prototype._queueLoad=function(t){var i=this;t._addPendingData(this);var r=-1!==this.delayLoadingFile.indexOf(".babylonbinarymeshdata");return e.Tools.LoadFile(this.delayLoadingFile,(function(r){r instanceof ArrayBuffer?i._delayLoadingFunction(r,i):i._delayLoadingFunction(JSON.parse(r),i),i.instances.forEach((function(e){e._syncSubMeshes()})),i.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,t._removePendingData(i)}),(function(){}),t.database,r),this},r.prototype.isInFrustum=function(t){return this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING&&(!!i.prototype.isInFrustum.call(this,t)&&(this._checkDelayState(),!0))},r.prototype.setMaterialByID=function(e){var t,i=this.getScene().materials;for(t=i.length-1;t>-1;t--)if(i[t].id===e)return this.material=i[t],this;var r=this.getScene().multiMaterials;for(t=r.length-1;t>-1;t--)if(r[t].id===e)return this.material=r[t],this;return this},r.prototype.getAnimatables=function(){var e=new Array;return this.material&&e.push(this.material),this.skeleton&&e.push(this.skeleton),e},r.prototype.bakeTransformIntoVertices=function(t){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;var i=this.subMeshes.splice(0);this._resetPointsArrayCache();var r,n=this.getVerticesData(e.VertexBuffer.PositionKind),o=new Array;for(r=0;r<n.length;r+=3)e.Vector3.TransformCoordinates(e.Vector3.FromArray(n,r),t).toArray(o,r);if(this.setVerticesData(e.VertexBuffer.PositionKind,o,this.getVertexBuffer(e.VertexBuffer.PositionKind).isUpdatable()),!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;for(n=this.getVerticesData(e.VertexBuffer.NormalKind),o=[],r=0;r<n.length;r+=3)e.Vector3.TransformNormal(e.Vector3.FromArray(n,r),t).normalize().toArray(o,r);return this.setVerticesData(e.VertexBuffer.NormalKind,o,this.getVertexBuffer(e.VertexBuffer.NormalKind).isUpdatable()),t.m[0]*t.m[5]*t.m[10]<0&&this.flipFaces(),this.releaseSubMeshes(),this.subMeshes=i,this},r.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=e.Quaternion.Identity()),this._worldMatrix=e.Matrix.Identity(),this},Object.defineProperty(r.prototype,"_positions",{get:function(){return this._geometry?this._geometry._positions:null},enumerable:!0,configurable:!0}),r.prototype._resetPointsArrayCache=function(){return this._geometry&&this._geometry._resetPointsArrayCache(),this},r.prototype._generatePointsArray=function(){return!!this._geometry&&this._geometry._generatePointsArray()},r.prototype.clone=function(e,t,i,n){return void 0===n&&(n=!0),new r(e,this.getScene(),t,this,i,n)},r.prototype.dispose=function(e,t){var r=this;void 0===t&&(t=!1),this.morphTargetManager=null,this._geometry&&this._geometry.releaseForMesh(this,!0);var n=this.getScene().meshes;for(n.forEach((function(e){var t=e;t._source&&t._source===r&&(t._source=null)})),this._source=null,this._instancesBuffer&&(this._instancesBuffer.dispose(),this._instancesBuffer=null);this.instances.length;)this.instances[0].dispose();for(var o=this.getScene().effectLayers,s=0;s<o.length;s++){var a=o[s];a&&a._disposeMesh(this)}i.prototype.dispose.call(this,e,t)},r.prototype.applyDisplacementMap=function(t,i,r,n,o,s){var a=this,l=this.getScene(),h=function(e){var t=document.createElement("canvas"),l=t.getContext("2d"),h=e.width,c=e.height;t.width=h,t.height=c,l.drawImage(e,0,0);var u=l.getImageData(0,0,h,c).data;a.applyDisplacementMapFromBuffer(u,h,c,i,r,o,s),n&&n(a)};return e.Tools.LoadImage(t,h,(function(){}),l.database),this},r.prototype.applyDisplacementMapFromBuffer=function(t,i,r,n,o,s,a){if(!this.isVerticesDataPresent(e.VertexBuffer.PositionKind)||!this.isVerticesDataPresent(e.VertexBuffer.NormalKind)||!this.isVerticesDataPresent(e.VertexBuffer.UVKind))return e.Tools.Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing"),this;var l=this.getVerticesData(e.VertexBuffer.PositionKind),h=this.getVerticesData(e.VertexBuffer.NormalKind),c=this.getVerticesData(e.VertexBuffer.UVKind),u=e.Vector3.Zero(),f=e.Vector3.Zero(),p=e.Vector2.Zero();s=s||e.Vector2.Zero(),a=a||new e.Vector2(1,1);for(var d=0;d<l.length;d+=3){e.Vector3.FromArrayToRef(l,d,u),e.Vector3.FromArrayToRef(h,d,f),e.Vector2.FromArrayToRef(c,d/3*2,p);var m=Math.abs(p.x*a.x+s.x)*i%i|0,_=Math.abs(p.y*a.y+s.y)*r%r|0,g=4*(m+_*i),v=t[g]/255,y=t[g+1]/255,b=t[g+2]/255,x=.3*v+.59*y+.11*b;f.normalize(),f.scaleInPlace(n+(o-n)*x),u=u.add(f),u.toArray(l,d)}return e.VertexData.ComputeNormals(l,this.getIndices(),h),this.updateVerticesData(e.VertexBuffer.PositionKind,l),this.updateVerticesData(e.VertexBuffer.NormalKind,h),this},r.prototype.convertToFlatShadedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n={},o={},s={},a=!1;for(t=0;t<r.length;t++){i=r[t];var l=this.getVertexBuffer(i);i!==e.VertexBuffer.NormalKind?(n[i]=l,o[i]=n[i].getData(),s[i]=[]):(a=l.isUpdatable(),r.splice(t,1),t--)}var h,c=this.subMeshes.slice(0),u=this.getIndices(),f=this.getTotalIndices();for(h=0;h<f;h++){var p=u[h];for(t=0;t<r.length;t++){i=r[t];for(var d=n[i].getStrideSize(),m=0;m<d;m++)s[i].push(o[i][p*d+m])}}var _=[],g=s[e.VertexBuffer.PositionKind];for(h=0;h<f;h+=3){u[h]=h,u[h+1]=h+1,u[h+2]=h+2;for(var v=e.Vector3.FromArray(g,3*h),y=e.Vector3.FromArray(g,3*(h+1)),b=e.Vector3.FromArray(g,3*(h+2)),x=v.subtract(y),T=b.subtract(y),E=e.Vector3.Normalize(e.Vector3.Cross(x,T)),P=0;P<3;P++)_.push(E.x),_.push(E.y),_.push(E.z)}for(this.setIndices(u),this.setVerticesData(e.VertexBuffer.NormalKind,_,a),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var A=0;A<c.length;A++){var M=c[A];e.SubMesh.AddToMesh(M.materialIndex,M.indexStart,M.indexCount,M.indexStart,M.indexCount,this)}return this.synchronizeInstances(),this},r.prototype.convertToUnIndexedMesh=function(){var t,i,r=this.getVerticesDataKinds(),n={},o={},s={};for(t=0;t<r.length;t++){i=r[t];var a=this.getVertexBuffer(i);n[i]=a,o[i]=n[i].getData(),s[i]=[]}var l,h=this.subMeshes.slice(0),c=this.getIndices(),u=this.getTotalIndices();for(l=0;l<u;l++){var f=c[l];for(t=0;t<r.length;t++){i=r[t];for(var p=n[i].getStrideSize(),d=0;d<p;d++)s[i].push(o[i][f*p+d])}}for(l=0;l<u;l+=3)c[l]=l,c[l+1]=l+1,c[l+2]=l+2;for(this.setIndices(c),t=0;t<r.length;t++)i=r[t],this.setVerticesData(i,s[i],n[i].isUpdatable());this.releaseSubMeshes();for(var m=0;m<h.length;m++){var _=h[m];e.SubMesh.AddToMesh(_.materialIndex,_.indexStart,_.indexCount,_.indexStart,_.indexCount,this)}return this._unIndexed=!0,this.synchronizeInstances(),this},r.prototype.flipFaces=function(t){void 0===t&&(t=!1);var i,r=e.VertexData.ExtractFromMesh(this);if(t&&this.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&r.normals)for(i=0;i<r.normals.length;i++)r.normals[i]*=-1;if(r.indices){var n;for(i=0;i<r.indices.length;i+=3)n=r.indices[i+1],r.indices[i+1]=r.indices[i+2],r.indices[i+2]=n}return r.applyToMesh(this),this},r.prototype.createInstance=function(t){return new e.InstancedMesh(t,this)},r.prototype.synchronizeInstances=function(){for(var e=0;e<this.instances.length;e++){this.instances[e]._syncSubMeshes()}return this},r.prototype.simplify=function(t,i,r,n){return void 0===i&&(i=!0),void 0===r&&(r=e.SimplificationType.QUADRATIC),this.getScene().simplificationQueue.addTask({settings:t,parallelProcessing:i,mesh:this,simplificationType:r,successCallback:n}),this},r.prototype.optimizeIndices=function(t){var i=this,r=this.getIndices(),n=this.getVerticesData(e.VertexBuffer.PositionKind);if(!n||!r)return this;for(var o=new Array,s=0;s<n.length;s+=3)o.push(e.Vector3.FromArray(n,s));var a=new Array;return e.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)){a[t]=r;break}}}),(function(){for(var e=0;e<r.length;++e)r[e]=a[r[e]]||r[e];var n=i.subMeshes.slice(0);i.setIndices(r),i.subMeshes=n,t&&t(i)})),this},r.prototype.serialize=function(t){t.name=this.name,t.id=this.id,t.type=this.getClassName(),e.Tags&&e.Tags.HasTags(this)&&(t.tags=e.Tags.GetTags(this)),t.position=this.position.asArray(),this.rotationQuaternion?t.rotationQuaternion=this.rotationQuaternion.asArray():this.rotation&&(t.rotation=this.rotation.asArray()),t.scaling=this.scaling.asArray(),t.localMatrix=this.getPivotMatrix().asArray(),t.isEnabled=this.isEnabled(!1),t.isVisible=this.isVisible,t.infiniteDistance=this.infiniteDistance,t.pickable=this.isPickable,t.receiveShadows=this.receiveShadows,t.billboardMode=this.billboardMode,t.visibility=this.visibility,t.checkCollisions=this.checkCollisions,t.isBlocker=this.isBlocker,this.parent&&(t.parentId=this.parent.id),t.isUnIndexed=this.isUnIndexed;var i=this._geometry;if(i){var r=i.id;t.geometryId=r,t.subMeshes=[];for(var n=0;n<this.subMeshes.length;n++){var o=this.subMeshes[n];t.subMeshes.push({materialIndex:o.materialIndex,verticesStart:o.verticesStart,verticesCount:o.verticesCount,indexStart:o.indexStart,indexCount:o.indexCount})}}this.material?t.materialId=this.material.id:this.material=null,this.morphTargetManager&&(t.morphTargetManagerId=this.morphTargetManager.uniqueId),this.skeleton&&(t.skeletonId=this.skeleton.id);var s=this.getPhysicsImpostor();s&&(t.physicsMass=s.getParam("mass"),t.physicsFriction=s.getParam("friction"),t.physicsRestitution=s.getParam("mass"),t.physicsImpostor=s.type),this.metadata&&(t.metadata=this.metadata),t.instances=[];for(var a=0;a<this.instances.length;a++){var l=this.instances[a],h={name:l.name,id:l.id,position:l.position.asArray(),scaling:l.scaling.asArray()};l.rotationQuaternion?h.rotationQuaternion=l.rotationQuaternion.asArray():l.rotation&&(h.rotation=l.rotation.asArray()),t.instances.push(h),e.Animation.AppendSerializedAnimations(l,h),h.ranges=l.serializeAnimationRanges()}e.Animation.AppendSerializedAnimations(this,t),t.ranges=this.serializeAnimationRanges(),t.layerMask=this.layerMask,t.alphaIndex=this.alphaIndex,t.hasVertexAlpha=this.hasVertexAlpha,t.overlayAlpha=this.overlayAlpha,t.overlayColor=this.overlayColor.asArray(),t.renderOverlay=this.renderOverlay,t.applyFog=this.applyFog,this.actionManager&&(t.actions=this.actionManager.serialize(this.name))},r.prototype._syncGeometryWithMorphTargetManager=function(){if(this.geometry){this._markSubMeshesAsAttributesDirty();var t=this._morphTargetManager;if(t&&t.vertexCount){if(t.vertexCount!==this.getTotalVertices())return e.Tools.Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count."),void(this.morphTargetManager=null);for(var i=0;i<t.numInfluencers;i++){var r=t.getActiveTarget(i),n=r.getPositions();if(!n)return void e.Tools.Error("Invalid morph target. Target must have positions.");this.geometry.setVerticesData(e.VertexBuffer.PositionKind+i,n,!1,3);var o=r.getNormals();o&&this.geometry.setVerticesData(e.VertexBuffer.NormalKind+i,o,!1,3);var s=r.getTangents();s&&this.geometry.setVerticesData(e.VertexBuffer.TangentKind+i,s,!1,3)}}else for(var i=0;this.geometry.isVerticesDataPresent(e.VertexBuffer.PositionKind+i);)this.geometry.removeVerticesData(e.VertexBuffer.PositionKind+i),this.geometry.isVerticesDataPresent(e.VertexBuffer.NormalKind+i)&&this.geometry.removeVerticesData(e.VertexBuffer.NormalKind+i),this.geometry.isVerticesDataPresent(e.VertexBuffer.TangentKind+i)&&this.geometry.removeVerticesData(e.VertexBuffer.TangentKind+i),i++}},r.Parse=function(t,i,n){var o;if(o=t.type&&"GroundMesh"===t.type?e.GroundMesh.Parse(t,i):new r(t.name,i),o.id=t.id,e.Tags&&e.Tags.AddTagsTo(o,t.tags),o.position=e.Vector3.FromArray(t.position),void 0!==t.metadata&&(o.metadata=t.metadata),t.rotationQuaternion?o.rotationQuaternion=e.Quaternion.FromArray(t.rotationQuaternion):t.rotation&&(o.rotation=e.Vector3.FromArray(t.rotation)),o.scaling=e.Vector3.FromArray(t.scaling),t.localMatrix?o.setPreTransformMatrix(e.Matrix.FromArray(t.localMatrix)):t.pivotMatrix&&o.setPivotMatrix(e.Matrix.FromArray(t.pivotMatrix)),o.setEnabled(t.isEnabled),o.isVisible=t.isVisible,o.infiniteDistance=t.infiniteDistance,o.showBoundingBox=t.showBoundingBox,o.showSubMeshesBoundingBox=t.showSubMeshesBoundingBox,void 0!==t.applyFog&&(o.applyFog=t.applyFog),void 0!==t.pickable&&(o.isPickable=t.pickable),void 0!==t.alphaIndex&&(o.alphaIndex=t.alphaIndex),o.receiveShadows=t.receiveShadows,o.billboardMode=t.billboardMode,void 0!==t.visibility&&(o.visibility=t.visibility),o.checkCollisions=t.checkCollisions,void 0!==t.isBlocker&&(o.isBlocker=t.isBlocker),o._shouldGenerateFlatShading=t.useFlatShading,t.freezeWorldMatrix&&(o._waitingFreezeWorldMatrix=t.freezeWorldMatrix),t.parentId&&(o._waitingParentId=t.parentId),void 0!==t.actions&&(o._waitingActions=t.actions),void 0!==t.overlayAlpha&&(o.overlayAlpha=t.overlayAlpha),void 0!==t.overlayColor&&(o.overlayColor=e.Color3.FromArray(t.overlayColor)),void 0!==t.renderOverlay&&(o.renderOverlay=t.renderOverlay),o.isUnIndexed=!!t.isUnIndexed,o.hasVertexAlpha=t.hasVertexAlpha,t.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+t.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(t.boundingBoxMinimum),e.Vector3.FromArray(t.boundingBoxMaximum)),t._binaryInfo&&(o._binaryInfo=t._binaryInfo),o._delayInfo=[],t.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),t.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),t.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),t.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),t.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),t.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),t.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),t.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),t.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.Geometry._ImportGeometry,e.SceneLoader.ForceFullSceneLoadingForIncremental&&o._checkDelayState()):e.Geometry._ImportGeometry(t,o),t.materialId?o.setMaterialByID(t.materialId):o.material=null,t.morphTargetManagerId>-1&&(o.morphTargetManager=i.getMorphTargetManagerById(t.morphTargetManagerId)),t.skeletonId>-1&&(o.skeleton=i.getLastSkeletonByID(t.skeletonId),t.numBoneInfluencers&&(o.numBoneInfluencers=t.numBoneInfluencers)),t.animations){for(var s=0;s<t.animations.length;s++){var a=t.animations[s];o.animations.push(e.Animation.Parse(a))}e.Node.ParseAnimationRanges(o,t,i)}
if(t.autoAnimate&&i.beginAnimation(o,t.autoAnimateFrom,t.autoAnimateTo,t.autoAnimateLoop,t.autoAnimateSpeed||1),t.layerMask&&!isNaN(t.layerMask)?o.layerMask=Math.abs(parseInt(t.layerMask)):o.layerMask=268435455,t.physicsImpostor&&(o.physicsImpostor=new e.PhysicsImpostor(o,t.physicsImpostor,{mass:t.physicsMass,friction:t.physicsFriction,restitution:t.physicsRestitution},i)),t.instances)for(var l=0;l<t.instances.length;l++){var h=t.instances[l],c=o.createInstance(h.name);if(h.id&&(c.id=h.id),e.Tags&&e.Tags.AddTagsTo(c,h.tags),c.position=e.Vector3.FromArray(h.position),h.parentId&&(c._waitingParentId=h.parentId),h.rotationQuaternion?c.rotationQuaternion=e.Quaternion.FromArray(h.rotationQuaternion):h.rotation&&(c.rotation=e.Vector3.FromArray(h.rotation)),c.scaling=e.Vector3.FromArray(h.scaling),c.checkCollisions=o.checkCollisions,t.animations){for(s=0;s<t.animations.length;s++)a=t.animations[s],c.animations.push(e.Animation.Parse(a));e.Node.ParseAnimationRanges(c,t,i)}}return o},r.CreateRibbon=function(t,i,r,n,o,s,a,l,h){return void 0===r&&(r=!1),void 0===a&&(a=!1),e.MeshBuilder.CreateRibbon(t,{pathArray:i,closeArray:r,closePath:n,offset:o,updatable:a,sideOrientation:l,instance:h},s)},r.CreateDisc=function(t,i,r,n,o,s){void 0===n&&(n=null);var a={radius:i,tessellation:r,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateDisc(t,a,n)},r.CreateBox=function(t,i,r,n,o){void 0===r&&(r=null);var s={size:i,sideOrientation:o,updatable:n};return e.MeshBuilder.CreateBox(t,s,r)},r.CreateSphere=function(t,i,r,n,o,s){var a={segments:i,diameterX:r,diameterY:r,diameterZ:r,sideOrientation:s,updatable:o};return e.MeshBuilder.CreateSphere(t,a,n)},r.CreateCylinder=function(t,i,n,o,s,a,l,h,c){void 0!==l&&l instanceof e.Scene||(void 0!==l&&(c=h||r.DEFAULTSIDE,h=l),l=a,a=1);var u={height:i,diameterTop:n,diameterBottom:o,tessellation:s,subdivisions:a,sideOrientation:c,updatable:h};return e.MeshBuilder.CreateCylinder(t,u,l)},r.CreateTorus=function(t,i,r,n,o,s,a){var l={diameter:i,thickness:r,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateTorus(t,l,o)},r.CreateTorusKnot=function(t,i,r,n,o,s,a,l,h,c){var u={radius:i,tube:r,radialSegments:n,tubularSegments:o,p:s,q:a,sideOrientation:c,updatable:h};return e.MeshBuilder.CreateTorusKnot(t,u,l)},r.CreateLines=function(t,i,r,n,o){void 0===r&&(r=null),void 0===n&&(n=!1),void 0===o&&(o=null);var s={points:i,updatable:n,instance:o};return e.MeshBuilder.CreateLines(t,s,r)},r.CreateDashedLines=function(t,i,r,n,o,s,a,l){void 0===s&&(s=null);var h={points:i,dashSize:r,gapSize:n,dashNb:o,updatable:a,instance:l};return e.MeshBuilder.CreateDashedLines(t,h,s)},r.CreatePolygon=function(t,i,r,n,o,s){var a={shape:i,holes:n,updatable:o,sideOrientation:s};return e.MeshBuilder.CreatePolygon(t,a,r)},r.ExtrudePolygon=function(t,i,r,n,o,s,a){var l={shape:i,holes:o,depth:r,updatable:s,sideOrientation:a};return e.MeshBuilder.ExtrudePolygon(t,l,n)},r.ExtrudeShape=function(t,i,n,o,s,a,l,h,c,u){void 0===l&&(l=null);var f={shape:i,path:n,scale:o,rotation:s,cap:0===a?0:a||r.NO_CAP,sideOrientation:c,instance:u,updatable:h};return e.MeshBuilder.ExtrudeShape(t,f,l)},r.ExtrudeShapeCustom=function(t,i,n,o,s,a,l,h,c,u,f,p){var d={shape:i,path:n,scaleFunction:o,rotationFunction:s,ribbonCloseArray:a,ribbonClosePath:l,cap:0===h?0:h||r.NO_CAP,sideOrientation:f,instance:p,updatable:u};return e.MeshBuilder.ExtrudeShapeCustom(t,d,c)},r.CreateLathe=function(t,i,r,n,o,s,a){var l={shape:i,radius:r,tessellation:n,sideOrientation:a,updatable:s};return e.MeshBuilder.CreateLathe(t,l,o)},r.CreatePlane=function(t,i,r,n,o){var s={size:i,width:i,height:i,sideOrientation:o,updatable:n};return e.MeshBuilder.CreatePlane(t,s,r)},r.CreateGround=function(t,i,r,n,o,s){var a={width:i,height:r,subdivisions:n,updatable:s};return e.MeshBuilder.CreateGround(t,a,o)},r.CreateTiledGround=function(t,i,r,n,o,s,a,l,h){var c={xmin:i,zmin:r,xmax:n,zmax:o,subdivisions:s,precision:a,updatable:h};return e.MeshBuilder.CreateTiledGround(t,c,l)},r.CreateGroundFromHeightMap=function(t,i,r,n,o,s,a,l,h,c){var u={width:r,height:n,subdivisions:o,minHeight:s,maxHeight:a,updatable:h,onReady:c};return e.MeshBuilder.CreateGroundFromHeightMap(t,i,u,l)},r.CreateTube=function(t,i,r,n,o,s,a,l,h,c){var u={path:i,radius:r,tessellation:n,radiusFunction:o,arc:1,cap:s,updatable:l,sideOrientation:h,instance:c};return e.MeshBuilder.CreateTube(t,u,a)},r.CreatePolyhedron=function(t,i,r){return e.MeshBuilder.CreatePolyhedron(t,i,r)},r.CreateIcoSphere=function(t,i,r){return e.MeshBuilder.CreateIcoSphere(t,i,r)},r.CreateDecal=function(t,i,r,n,o,s){var a={position:r,normal:n,size:o,angle:s};return e.MeshBuilder.CreateDecal(t,i,a)},r.prototype.setPositionsForCPUSkinning=function(){if(!this._sourcePositions){var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return this._sourcePositions;this._sourcePositions=new Float32Array(t),this.isVertexBufferUpdatable(e.VertexBuffer.PositionKind)||this.setVerticesData(e.VertexBuffer.PositionKind,t,!0)}return this._sourcePositions},r.prototype.setNormalsForCPUSkinning=function(){if(!this._sourceNormals){var t=this.getVerticesData(e.VertexBuffer.NormalKind);if(!t)return this._sourceNormals;this._sourceNormals=new Float32Array(t),this.isVertexBufferUpdatable(e.VertexBuffer.NormalKind)||this.setVerticesData(e.VertexBuffer.NormalKind,t,!0)}return this._sourceNormals},r.prototype.applySkeleton=function(t){if(!this.geometry)return this;if(this.geometry._softwareSkinningRenderId==this.getScene().getRenderId())return this;if(this.geometry._softwareSkinningRenderId=this.getScene().getRenderId(),!this.isVerticesDataPresent(e.VertexBuffer.PositionKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.NormalKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind))return this;if(!this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind))return this;if(!this._sourcePositions){var i=this.subMeshes.slice();this.setPositionsForCPUSkinning(),this.subMeshes=i}this._sourceNormals||this.setNormalsForCPUSkinning();var r=this.getVerticesData(e.VertexBuffer.PositionKind);if(!r)return this;r instanceof Float32Array||(r=new Float32Array(r));var n=this.getVerticesData(e.VertexBuffer.NormalKind);if(!n)return this;n instanceof Float32Array||(n=new Float32Array(n));var o=this.getVerticesData(e.VertexBuffer.MatricesIndicesKind),s=this.getVerticesData(e.VertexBuffer.MatricesWeightsKind);if(!s||!o)return this;for(var a,l=this.numBoneInfluencers>4,h=l?this.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind):null,c=l?this.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind):null,u=t.getTransformMatrices(this),f=e.Vector3.Zero(),p=new e.Matrix,d=new e.Matrix,m=0,_=0;_<r.length;_+=3,m+=4){var g;for(a=0;a<4&&(g=s[m+a])>0;a++)e.Matrix.FromFloat32ArrayToRefScaled(u,Math.floor(16*o[m+a]),g,d),p.addToSelf(d);if(l)for(a=0;a<4&&(g=c[m+a])>0;a++)e.Matrix.FromFloat32ArrayToRefScaled(u,Math.floor(16*h[m+a]),g,d),p.addToSelf(d);e.Vector3.TransformCoordinatesFromFloatsToRef(this._sourcePositions[_],this._sourcePositions[_+1],this._sourcePositions[_+2],p,f),f.toArray(r,_),e.Vector3.TransformNormalFromFloatsToRef(this._sourceNormals[_],this._sourceNormals[_+1],this._sourceNormals[_+2],p,f),f.toArray(n,_),p.reset()}return this.updateVerticesData(e.VertexBuffer.PositionKind,r),this.updateVerticesData(e.VertexBuffer.NormalKind,n),this},r.MinMax=function(t){var i=null,r=null;return t.forEach((function(e,t,n){var o=e.getBoundingInfo(),s=o.boundingBox;i&&r?(i.minimizeInPlace(s.minimumWorld),r.maximizeInPlace(s.maximumWorld)):(i=s.minimumWorld,r=s.maximumWorld)})),i&&r?{min:i,max:r}:{min:e.Vector3.Zero(),max:e.Vector3.Zero()}},r.Center=function(t){var i=t instanceof Array?r.MinMax(t):t;return e.Vector3.Center(i.min,i.max)},r.MergeMeshes=function(t,i,n,o,s){void 0===i&&(i=!0);var a;if(!n){var l=0;for(a=0;a<t.length;a++)if(t[a]&&(l+=t[a].getTotalVertices())>65536)return e.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 h,c=null,u=new Array,f=null;for(a=0;a<t.length;a++)t[a]&&(t[a].computeWorldMatrix(!0),h=e.VertexData.ExtractFromMesh(t[a],!0),h.transform(t[a].getWorldMatrix()),c?c.merge(h):(c=h,f=t[a]),s&&u.push(t[a].getTotalIndices()));if(f=f,o||(o=new r(f.name+"_merged",f.getScene())),c.applyToMesh(o),o.material=f.material,o.checkCollisions=f.checkCollisions,i)for(a=0;a<t.length;a++)t[a]&&t[a].dispose();if(s){o.releaseSubMeshes(),a=0;for(var p=0;a<u.length;)e.SubMesh.CreateFromIndices(0,p,u[a],o),p+=u[a],a++}return o},r._FRONTSIDE=0,r._BACKSIDE=1,r._DOUBLESIDE=2,r._DEFAULTSIDE=0,r._NO_CAP=0,r._CAP_START=1,r._CAP_END=2,r._CAP_ALL=3,r})(e.AbstractMesh);e.Mesh=i})(r||(r={}));var r;!(function(e){var t=(function(){function e(){}return Object.defineProperty(e.prototype,"effect",{get:function(){return this._materialEffect},enumerable:!0,configurable:!0}),e.prototype.setEffect=function(e,t){if(void 0===t&&(t=null),this._materialEffect===e)return void(e||(this._materialDefines=null));this._materialDefines=t,this._materialEffect=e},e})();e.BaseSubMesh=t;var i=(function(t){function i(e,i,r,n,o,s,a,l){void 0===l&&(l=!0);var h=t.call(this)||this;return h.materialIndex=e,h.verticesStart=i,h.verticesCount=r,h.indexStart=n,h.indexCount=o,h._renderId=0,h._mesh=s,h._renderingMesh=a||s,s.subMeshes.push(h),h._trianglePlanes=[],h._id=s.subMeshes.length-1,l&&(h.refreshBoundingInfo(),s.computeWorldMatrix(!0)),h}return o(i,t),i.AddToMesh=function(e,t,r,n,o,s,a,l){return void 0===l&&(l=!0),new i(e,t,r,n,o,s,a,l)},Object.defineProperty(i.prototype,"IsGlobal",{get:function(){return 0===this.verticesStart&&this.verticesCount==this._mesh.getTotalVertices()},enumerable:!0,configurable:!0}),i.prototype.getBoundingInfo=function(){return this.IsGlobal?this._mesh.getBoundingInfo():this._boundingInfo},i.prototype.setBoundingInfo=function(e){return this._boundingInfo=e,this},i.prototype.getMesh=function(){return this._mesh},i.prototype.getRenderingMesh=function(){return this._renderingMesh},i.prototype.getMaterial=function(){var e=this._renderingMesh.material;if(null===e||void 0===e)return this._mesh.getScene().defaultMaterial;if(e.getSubMaterial){var t=e,i=t.getSubMaterial(this.materialIndex);return this._currentMaterial!==i&&(this._currentMaterial=i,this._materialDefines=null),i}return e},i.prototype.refreshBoundingInfo=function(){if(this._lastColliderWorldVertices=null,this.IsGlobal||!this._renderingMesh||!this._renderingMesh.geometry)return this;var t=this._renderingMesh.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return this._boundingInfo=this._mesh.getBoundingInfo(),this;var i,r=this._renderingMesh.getIndices();if(0===this.indexStart&&this.indexCount===r.length){var n=this._renderingMesh.getBoundingInfo();i={minimum:n.minimum.clone(),maximum:n.maximum.clone()}}else i=e.Tools.ExtractMinAndMaxIndexed(t,r,this.indexStart,this.indexCount,this._renderingMesh.geometry.boundingBias);return this._boundingInfo=new e.BoundingInfo(i.minimum,i.maximum),this},i.prototype._checkCollision=function(e){return this.getBoundingInfo()._checkCollision(e)},i.prototype.updateBoundingInfo=function(e){var t=this.getBoundingInfo();return t||(this.refreshBoundingInfo(),t=this.getBoundingInfo()),t.update(e),this},i.prototype.isInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isInFrustum(e)},i.prototype.isCompletelyInFrustum=function(e){var t=this.getBoundingInfo();return!!t&&t.isCompletelyInFrustum(e)},i.prototype.render=function(e){return this._renderingMesh.render(this,e),this},i.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},i.prototype.canIntersects=function(e){var t=this.getBoundingInfo();return!!t&&e.intersectsBox(t.boundingBox)},i.prototype.intersects=function(t,i,r,n){var o=null,s=this.getMaterial();if(!s)return null;switch(s.fillMode){case e.Material.PointListDrawMode:case e.Material.LineListDrawMode:case e.Material.LineLoopDrawMode:case e.Material.LineStripDrawMode:case e.Material.TriangleFanDrawMode:case e.Material.TriangleStripDrawMode:return null}if(e.LinesMesh&&this._mesh instanceof e.LinesMesh)for(var a=this._mesh,l=this.indexStart;l<this.indexStart+this.indexCount;l+=2){var h=i[r[l]],c=i[r[l+1]],u=t.intersectionSegment(h,c,a.intersectionThreshold);if(!(u<0)&&((n||!o||u<o.distance)&&(o=new e.IntersectionInfo(null,null,u),n)))break}else for(var l=this.indexStart;l<this.indexStart+this.indexCount;l+=3){var h=i[r[l]],c=i[r[l+1]],f=i[r[l+2]],p=t.intersectsTriangle(h,c,f);if(p){if(p.distance<0)continue;if((n||!o||p.distance<o.distance)&&(o=p,o.faceId=l/3,n))break}}return o},i.prototype._rebuild=function(){this._linesIndexBuffer&&(this._linesIndexBuffer=null)},i.prototype.clone=function(t,r){var n=new i(this.materialIndex,this.verticesStart,this.verticesCount,this.indexStart,this.indexCount,t,r,!1);if(!this.IsGlobal){var o=this.getBoundingInfo();if(!o)return n;n._boundingInfo=new e.BoundingInfo(o.minimum,o.maximum)}return n},i.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)},i.CreateFromIndices=function(e,t,r,n,o){var s=Number.MAX_VALUE,a=-Number.MAX_VALUE;o=o||n;for(var l=o.getIndices(),h=t;h<t+r;h++){var c=l[h];c<s&&(s=c),c>a&&(a=c)}return new i(e,s,a-s+1,t,r,n,o)},i})(t);e.SubMesh=i})(r||(r={}));var r,s=this&&this.__assign||Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e};!(function(e){var t=(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})();e.MaterialDefines=t;var i=(function(){function t(i,r,n){this.checkReadyOnEveryCall=!1,this.checkReadyOnlyOnce=!1,this.state="",this._alpha=1,this._backFaceCulling=!0,this.doNotSerialize=!1,this.storeEffectOnSubMeshes=!1,this.onDisposeObservable=new e.Observable,this.onBindObservable=new e.Observable,this.onUnBindObservable=new e.Observable,this._alphaMode=e.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=t.TriangleFillMode,this.name=i,this.id=i||e.Tools.RandomId(),this._scene=r||e.Engine.LastCreatedScene,this._scene.useRightHandedSystem?this.sideOrientation=t.ClockWiseSideOrientation:this.sideOrientation=t.CounterClockWiseSideOrientation,this._uniformBuffer=new e.UniformBuffer(this._scene.getEngine()),this._useUBO=this.getScene().getEngine().supportsUniformBuffers,n||this._scene.materials.push(this)}return Object.defineProperty(t,"TriangleFillMode",{get:function(){return t._TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WireFrameFillMode",{get:function(){return t._WireFrameFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointFillMode",{get:function(){return t._PointFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"PointListDrawMode",{get:function(){return t._PointListDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LineListDrawMode",{get:function(){return t._LineListDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LineLoopDrawMode",{get:function(){return t._LineLoopDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LineStripDrawMode",{get:function(){return t._LineStripDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TriangleStripDrawMode",{get:function(){return t._TriangleStripDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TriangleFanDrawMode",{get:function(){return t._TriangleFanDrawMode},enumerable:!0,configurable:!0}),Object.defineProperty(t,"ClockWiseSideOrientation",{get:function(){return t._ClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"CounterClockWiseSideOrientation",{get:function(){return t._CounterClockWiseSideOrientation},enumerable:!0,configurable:!0}),Object.defineProperty(t,"TextureDirtyFlag",{get:function(){return t._TextureDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"LightDirtyFlag",{get:function(){return t._LightDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"FresnelDirtyFlag",{get:function(){return t._FresnelDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"AttributesDirtyFlag",{get:function(){return t._AttributesDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t,"MiscDirtyFlag",{get:function(){return t._MiscDirtyFlag},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alpha",{get:function(){return this._alpha},set:function(e){this._alpha!==e&&(this._alpha=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"backFaceCulling",{get:function(){return this._backFaceCulling},set:function(e){this._backFaceCulling!==e&&(this._backFaceCulling=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onBind",{set:function(e){this._onBindObserver&&this.onBindObservable.remove(this._onBindObserver),this._onBindObserver=this.onBindObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"alphaMode",{get:function(){return this._alphaMode},set:function(e){this._alphaMode!==e&&(this._alphaMode=e,this.markAsDirty(t.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.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(t.prototype,"fogEnabled",{get:function(){return this._fogEnabled},set:function(e){this._fogEnabled!==e&&(this._fogEnabled=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"wireframe",{get:function(){switch(this._fillMode){case t.WireFrameFillMode:case t.LineListDrawMode:case t.LineLoopDrawMode:case t.LineStripDrawMode:return!0}return this._scene.forceWireframe},set:function(e){this.fillMode=e?t.WireFrameFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"pointsCloud",{get:function(){switch(this._fillMode){case t.PointFillMode:case t.PointListDrawMode:return!0}return this._scene.forcePointsCloud},set:function(e){this.fillMode=e?t.PointFillMode:t.TriangleFillMode},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"fillMode",{get:function(){return this._fillMode},set:function(e){this._fillMode!==e&&(this._fillMode=e,this.markAsDirty(t.MiscDirtyFlag))},enumerable:!0,configurable:!0}),t.prototype.toString=function(e){return"Name: "+this.name},t.prototype.getClassName=function(){return"Material"},Object.defineProperty(t.prototype,"isFrozen",{get:function(){return this.checkReadyOnlyOnce},enumerable:!0,configurable:!0}),t.prototype.freeze=function(){this.checkReadyOnlyOnce=!0},t.prototype.unfreeze=function(){this.checkReadyOnlyOnce=!1},t.prototype.isReady=function(e,t){return!0},t.prototype.isReadyForSubMesh=function(e,t,i){return!1},t.prototype.getEffect=function(){return this._effect},t.prototype.getScene=function(){return this._scene},t.prototype.needAlphaBlending=function(){return this.alpha<1},t.prototype.needAlphaBlendingForMesh=function(e){return this.needAlphaBlending()||e.visibility<1||e.hasVertexAlpha},t.prototype.needAlphaTesting=function(){return!1},t.prototype.getAlphaTestTexture=function(){return null},t.prototype.markDirty=function(){this._wasPreviouslyReady=!1},t.prototype._preBind=function(e,i){void 0===i&&(i=null);var r=this._scene.getEngine(),n=null==i?this.sideOrientation:i,o=n===t.ClockWiseSideOrientation;return r.enableEffect(e||this._effect),r.setState(this.backFaceCulling,this.zOffset,!1,o),o},t.prototype.bind=function(e,t){},t.prototype.bindForSubMesh=function(e,t,i){},t.prototype.bindOnlyWorldMatrix=function(e){},t.prototype.bindSceneUniformBuffer=function(e,t){t.bindToEffect(e,"Scene")},t.prototype.bindView=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("view",this.getScene().getViewMatrix())},t.prototype.bindViewProjection=function(e){this._useUBO?this.bindSceneUniformBuffer(e,this.getScene().getSceneUniformBuffer()):e.setMatrix("viewProjection",this.getScene().getTransformMatrix())},t.prototype._shouldTurnAlphaTestOn=function(e){return!this.needAlphaBlendingForMesh(e)&&this.needAlphaTesting()},t.prototype._afterBind=function(e){if(this._scene._cachedMaterial=this,this._scene._cachedVisibility=e?e.visibility:1,e&&this.onBindObservable.notifyObservers(e),this.disableDepthWrite){var t=this._scene.getEngine();this._cachedDepthWriteState=t.getDepthWrite(),t.setDepthWrite(!1)}},t.prototype.unbind=function(){if(this.onUnBindObservable.notifyObservers(this),this.disableDepthWrite){this._scene.getEngine().setDepthWrite(this._cachedDepthWriteState)}},t.prototype.getActiveTextures=function(){return[]},t.prototype.hasTexture=function(e){return!1},t.prototype.clone=function(e){return null},t.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},t.prototype.forceCompilation=function(t,i,r){var n=this,o=s({clipPlane:!1},r),a=new e.BaseSubMesh,l=this.getScene(),h=function(){if(n._scene&&n._scene.getEngine()){a._materialDefines&&(a._materialDefines._renderId=-1);var r=l.clipPlane;o.clipPlane&&(l.clipPlane=new e.Plane(0,0,0,1)),n.storeEffectOnSubMeshes?n.isReadyForSubMesh(t,a)?i&&i(n):setTimeout(h,16):n.isReady(t)?i&&i(n):setTimeout(h,16),o.clipPlane&&(l.clipPlane=r)}};h()},t.prototype.forceCompilationAsync=function(e,t){var i=this;return new Promise(function(r){i.forceCompilation(e,(function(){r()}),t)})},t.prototype.markAsDirty=function(e){e&t.TextureDirtyFlag&&this._markAllSubMeshesAsTexturesDirty(),e&t.LightDirtyFlag&&this._markAllSubMeshesAsLightsDirty(),e&t.FresnelDirtyFlag&&this._markAllSubMeshesAsFresnelDirty(),e&t.AttributesDirtyFlag&&this._markAllSubMeshesAsAttributesDirty(),e&t.MiscDirtyFlag&&this._markAllSubMeshesAsMiscDirty(),this.getScene().resetCachedMaterial()},t.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))}}},t.prototype._markAllSubMeshesAsImageProcessingDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsImageProcessingDirty()}))},t.prototype._markAllSubMeshesAsTexturesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsTexturesDirty()}))},t.prototype._markAllSubMeshesAsFresnelDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsFresnelDirty()}))},t.prototype._markAllSubMeshesAsFresnelAndMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){e.markAsFresnelDirty(),e.markAsMiscDirty()}))},t.prototype._markAllSubMeshesAsLightsDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsLightDirty()}))},t.prototype._markAllSubMeshesAsAttributesDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsAttributesDirty()}))},t.prototype._markAllSubMeshesAsMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){return e.markAsMiscDirty()}))},t.prototype._markAllSubMeshesAsTexturesAndMiscDirty=function(){this._markAllSubMeshesAsDirty((function(e){e.markAsTexturesDirty(),e.markAsMiscDirty()}))},t.prototype.dispose=function(e,t){this.getScene().stopAnimation(this),this.getScene().freeProcessedMaterials();var i=this._scene.materials.indexOf(this);for(i>=0&&this._scene.materials.splice(i,1),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.clear(),this.onUnBindObservable.clear()},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.ParseMultiMaterial=function(t,i){var r=new e.MultiMaterial(t.name,i);r.id=t.id,e.Tags&&e.Tags.AddTagsTo(r,t.tags);for(var n=0;n<t.materials.length;n++){var o=t.materials[n];o?r.subMaterials.push(i.getMaterialByID(o)):r.subMaterials.push(null)}return r},t.Parse=function(t,i,r){return t.customType&&"BABYLON.StandardMaterial"!==t.customType?"BABYLON.PBRMaterial"===t.customType&&t.overloadedAlbedo&&(t.customType="BABYLON.LegacyPBRMaterial",!e.LegacyPBRMaterial)?void e.Tools.Error("Your scene is trying to load a legacy version of the PBRMaterial, please, include it from the materials library."):e.Tools.Instantiate(t.customType).Parse(t,i,r):e.StandardMaterial.Parse(t,i,r)},t._TriangleFillMode=0,t._WireFrameFillMode=1,t._PointFillMode=2,t._PointListDrawMode=3,t._LineListDrawMode=4,t._LineLoopDrawMode=5,t._LineStripDrawMode=6,t._TriangleStripDrawMode=7,t._TriangleFanDrawMode=8,t._ClockWiseSideOrientation=0,t._CounterClockWiseSideOrientation=1,t._TextureDirtyFlag=1,t._LightDirtyFlag=2,t._FresnelDirtyFlag=4,t._AttributesDirtyFlag=8,t._MiscDirtyFlag=16,n([e.serialize()],t.prototype,"id",void 0),n([e.serialize()],t.prototype,"name",void 0),n([e.serialize()],t.prototype,"checkReadyOnEveryCall",void 0),n([e.serialize()],t.prototype,"checkReadyOnlyOnce",void 0),n([e.serialize()],t.prototype,"state",void 0),n([e.serialize("alpha")],t.prototype,"_alpha",void 0),n([e.serialize("backFaceCulling")],t.prototype,"_backFaceCulling",void 0),n([e.serialize()],t.prototype,"sideOrientation",void 0),n([e.serialize("alphaMode")],t.prototype,"_alphaMode",void 0),n([e.serialize()],t.prototype,"_needDepthPrePass",void 0),n([e.serialize()],t.prototype,"disableDepthWrite",void 0),n([e.serialize()],t.prototype,"forceDepthWrite",void 0),n([e.serialize()],t.prototype,"separateCullingPass",void 0),n([e.serialize("fogEnabled")],t.prototype,"_fogEnabled",void 0),n([e.serialize()],t.prototype,"pointSize",void 0),n([e.serialize()],t.prototype,"zOffset",void 0),n([e.serialize()],t.prototype,"wireframe",null),n([e.serialize()],t.prototype,"pointsCloud",null),n([e.serialize()],t.prototype,"fillMode",null),t})();e.Material=i})(r||(r={}));var r;!(function(e){var t=(function(){function t(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(t.prototype,"useUbo",{get:function(){return!this._noUBO},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSync",{get:function(){return!this._needSync},enumerable:!0,configurable:!0}),t.prototype.isDynamic=function(){return void 0!==this._dynamic},t.prototype.getData=function(){return this._bufferData},t.prototype.getBuffer=function(){return this._buffer},t.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)}},t.prototype.addUniform=function(e,t){if(!this._noUBO&&void 0===this._uniformLocations[e]){var i;if(t instanceof Array)i=t,t=i.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(var r=0;r<t;r++)this._data.push(i[r]);this._needSync=!0}},t.prototype.addMatrix=function(e,t){this.addUniform(e,Array.prototype.slice.call(t.toArray()))},
t.prototype.addFloat2=function(e,t,i){var r=[t,i];this.addUniform(e,r)},t.prototype.addFloat3=function(e,t,i,r){var n=[t,i,r];this.addUniform(e,n)},t.prototype.addColor3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},t.prototype.addColor4=function(e,t,i){var r=new Array;t.toArray(r),r.push(i),this.addUniform(e,r)},t.prototype.addVector3=function(e,t){var i=new Array;t.toArray(i),this.addUniform(e,i)},t.prototype.addMatrix3x3=function(e){this.addUniform(e,12)},t.prototype.addMatrix2x2=function(e){this.addUniform(e,8)},t.prototype.create=function(){this._noUBO||this._buffer||(this._fillAlignment(4),this._bufferData=new Float32Array(this._data),this._rebuild(),this._needSync=!0)},t.prototype._rebuild=function(){this._noUBO||(this._dynamic?this._buffer=this._engine.createDynamicUniformBuffer(this._bufferData):this._buffer=this._engine.createUniformBuffer(this._bufferData))},t.prototype.update=function(){if(!this._buffer)return void this.create();(this._dynamic||this._needSync)&&(this._engine.updateUniformBuffer(this._buffer,this._bufferData),this._needSync=!1)},t.prototype.updateUniform=function(t,i,r){var n=this._uniformLocations[t];if(void 0===n){if(this._buffer)return void e.Tools.Error("Cannot add an uniform after UBO has been created.");this.addUniform(t,r),n=this._uniformLocations[t]}if(this._buffer||this.create(),this._dynamic)for(var o=0;o<r;o++)this._bufferData[n+o]=i[o];else{for(var s=!1,o=0;o<r;o++)this._bufferData[n+o]!==i[o]&&(s=!0,this._bufferData[n+o]=i[o]);this._needSync=this._needSync||s}},t.prototype._updateMatrix3x3ForUniform=function(e,i){for(var r=0;r<3;r++)t._tempBuffer[4*r]=i[3*r],t._tempBuffer[4*r+1]=i[3*r+1],t._tempBuffer[4*r+2]=i[3*r+2],t._tempBuffer[4*r+3]=0;this.updateUniform(e,t._tempBuffer,12)},t.prototype._updateMatrix3x3ForEffect=function(e,t){this._currentEffect.setMatrix3x3(e,t)},t.prototype._updateMatrix2x2ForEffect=function(e,t){this._currentEffect.setMatrix2x2(e,t)},t.prototype._updateMatrix2x2ForUniform=function(e,i){for(var r=0;r<2;r++)t._tempBuffer[4*r]=i[2*r],t._tempBuffer[4*r+1]=i[2*r+1],t._tempBuffer[4*r+2]=0,t._tempBuffer[4*r+3]=0;this.updateUniform(e,t._tempBuffer,8)},t.prototype._updateFloatForEffect=function(e,t){this._currentEffect.setFloat(e,t)},t.prototype._updateFloatForUniform=function(e,i){t._tempBuffer[0]=i,this.updateUniform(e,t._tempBuffer,1)},t.prototype._updateFloat2ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setFloat2(e+r,t,i)},t.prototype._updateFloat2ForUniform=function(e,i,r,n){void 0===n&&(n=""),t._tempBuffer[0]=i,t._tempBuffer[1]=r,this.updateUniform(e,t._tempBuffer,2)},t.prototype._updateFloat3ForEffect=function(e,t,i,r,n){void 0===n&&(n=""),this._currentEffect.setFloat3(e+n,t,i,r)},t.prototype._updateFloat3ForUniform=function(e,i,r,n,o){void 0===o&&(o=""),t._tempBuffer[0]=i,t._tempBuffer[1]=r,t._tempBuffer[2]=n,this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateFloat4ForEffect=function(e,t,i,r,n,o){void 0===o&&(o=""),this._currentEffect.setFloat4(e+o,t,i,r,n)},t.prototype._updateFloat4ForUniform=function(e,i,r,n,o,s){void 0===s&&(s=""),t._tempBuffer[0]=i,t._tempBuffer[1]=r,t._tempBuffer[2]=n,t._tempBuffer[3]=o,this.updateUniform(e,t._tempBuffer,4)},t.prototype._updateMatrixForEffect=function(e,t){this._currentEffect.setMatrix(e,t)},t.prototype._updateMatrixForUniform=function(e,t){this.updateUniform(e,t.toArray(),16)},t.prototype._updateVector3ForEffect=function(e,t){this._currentEffect.setVector3(e,t)},t.prototype._updateVector3ForUniform=function(e,i){i.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateVector4ForEffect=function(e,t){this._currentEffect.setVector4(e,t)},t.prototype._updateVector4ForUniform=function(e,i){i.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,4)},t.prototype._updateColor3ForEffect=function(e,t,i){void 0===i&&(i=""),this._currentEffect.setColor3(e+i,t)},t.prototype._updateColor3ForUniform=function(e,i,r){void 0===r&&(r=""),i.toArray(t._tempBuffer),this.updateUniform(e,t._tempBuffer,3)},t.prototype._updateColor4ForEffect=function(e,t,i,r){void 0===r&&(r=""),this._currentEffect.setColor4(e+r,t,i)},t.prototype._updateColor4ForUniform=function(e,i,r,n){void 0===n&&(n=""),i.toArray(t._tempBuffer),t._tempBuffer[3]=r,this.updateUniform(e,t._tempBuffer,4)},t.prototype.setTexture=function(e,t){this._currentEffect.setTexture(e,t)},t.prototype.updateUniformDirectly=function(e,t){this.updateUniform(e,t,t.length),this.update()},t.prototype.bindToEffect=function(e,t){this._currentEffect=e,!this._noUBO&&this._buffer&&e.bindUniformBuffer(this._buffer,t)},t.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)}},t._MAX_UNIFORM_SIZE=256,t._tempBuffer=new Float32Array(t._MAX_UNIFORM_SIZE),t})();e.UniformBuffer=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){}return t.prototype.set=function(t,i){switch(i){case e.VertexBuffer.PositionKind:this.positions=t;break;case e.VertexBuffer.NormalKind:this.normals=t;break;case e.VertexBuffer.TangentKind:this.tangents=t;break;case e.VertexBuffer.UVKind:this.uvs=t;break;case e.VertexBuffer.UV2Kind:this.uvs2=t;break;case e.VertexBuffer.UV3Kind:this.uvs3=t;break;case e.VertexBuffer.UV4Kind:this.uvs4=t;break;case e.VertexBuffer.UV5Kind:this.uvs5=t;break;case e.VertexBuffer.UV6Kind:this.uvs6=t;break;case e.VertexBuffer.ColorKind:this.colors=t;break;case e.VertexBuffer.MatricesIndicesKind:this.matricesIndices=t;break;case e.VertexBuffer.MatricesWeightsKind:this.matricesWeights=t;break;case e.VertexBuffer.MatricesIndicesExtraKind:this.matricesIndicesExtra=t;break;case e.VertexBuffer.MatricesWeightsExtraKind:this.matricesWeightsExtra=t}},t.prototype.applyToMesh=function(e,t){return this._applyTo(e,t),this},t.prototype.applyToGeometry=function(e,t){return this._applyTo(e,t),this},t.prototype.updateMesh=function(e,t,i){return this._update(e),this},t.prototype.updateGeometry=function(e,t,i){return this._update(e),this},t.prototype._applyTo=function(t,i){return void 0===i&&(i=!1),this.positions&&t.setVerticesData(e.VertexBuffer.PositionKind,this.positions,i),this.normals&&t.setVerticesData(e.VertexBuffer.NormalKind,this.normals,i),this.tangents&&t.setVerticesData(e.VertexBuffer.TangentKind,this.tangents,i),this.uvs&&t.setVerticesData(e.VertexBuffer.UVKind,this.uvs,i),this.uvs2&&t.setVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i),this.uvs3&&t.setVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i),this.uvs4&&t.setVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i),this.uvs5&&t.setVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i),this.uvs6&&t.setVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i),this.colors&&t.setVerticesData(e.VertexBuffer.ColorKind,this.colors,i),this.matricesIndices&&t.setVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i),this.matricesWeights&&t.setVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i),this.matricesIndicesExtra&&t.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,i),this.matricesWeightsExtra&&t.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,i),this.indices&&t.setIndices(this.indices,null,i),this},t.prototype._update=function(t,i,r){return this.positions&&t.updateVerticesData(e.VertexBuffer.PositionKind,this.positions,i,r),this.normals&&t.updateVerticesData(e.VertexBuffer.NormalKind,this.normals,i,r),this.tangents&&t.updateVerticesData(e.VertexBuffer.TangentKind,this.tangents,i,r),this.uvs&&t.updateVerticesData(e.VertexBuffer.UVKind,this.uvs,i,r),this.uvs2&&t.updateVerticesData(e.VertexBuffer.UV2Kind,this.uvs2,i,r),this.uvs3&&t.updateVerticesData(e.VertexBuffer.UV3Kind,this.uvs3,i,r),this.uvs4&&t.updateVerticesData(e.VertexBuffer.UV4Kind,this.uvs4,i,r),this.uvs5&&t.updateVerticesData(e.VertexBuffer.UV5Kind,this.uvs5,i,r),this.uvs6&&t.updateVerticesData(e.VertexBuffer.UV6Kind,this.uvs6,i,r),this.colors&&t.updateVerticesData(e.VertexBuffer.ColorKind,this.colors,i,r),this.matricesIndices&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices,i,r),this.matricesWeights&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights,i,r),this.matricesIndicesExtra&&t.updateVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra,i,r),this.matricesWeightsExtra&&t.updateVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra,i,r),this.indices&&t.setIndices(this.indices,null),this},t.prototype.transform=function(t){var i,r=e.Vector3.Zero();if(this.positions){var n=e.Vector3.Zero();for(i=0;i<this.positions.length;i+=3)e.Vector3.FromArrayToRef(this.positions,i,n),e.Vector3.TransformCoordinatesToRef(n,t,r),this.positions[i]=r.x,this.positions[i+1]=r.y,this.positions[i+2]=r.z}if(this.normals){var o=e.Vector3.Zero();for(i=0;i<this.normals.length;i+=3)e.Vector3.FromArrayToRef(this.normals,i,o),e.Vector3.TransformNormalToRef(o,t,r),this.normals[i]=r.x,this.normals[i+1]=r.y,this.normals[i+2]=r.z}if(this.tangents){var s=e.Vector4.Zero(),a=e.Vector4.Zero();for(i=0;i<this.tangents.length;i+=4)e.Vector4.FromArrayToRef(this.tangents,i,s),e.Vector4.TransformNormalToRef(s,t,a),this.tangents[i]=a.x,this.tangents[i+1]=a.y,this.tangents[i+2]=a.z,this.tangents[i+3]=a.w}return this},t.prototype.merge=function(e){if(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=[]);for(var t=this.positions?this.positions.length/3:0,i=0;i<e.indices.length;i++)this.indices.push(e.indices[i]+t)}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},t.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){for(var s=e.slice(0),a=0,i=t.length;a<i;a++)s.push(t[a]);return s}return e.concat(t)},t.prototype._validate=function(){if(!this.positions)throw new Error("Positions are required");var t=function(t,i){var r=e.VertexBuffer.DeduceStride(t);if(i.length%r!=0)throw new Error("The "+t+"s array count must be a multiple of "+r);return i.length/r},i=t(e.VertexBuffer.PositionKind,this.positions),r=function(e,r){var n=t(e,r);if(n!==i)throw new Error("The "+e+"s element count ("+n+") does not match the positions count ("+i+")")};this.normals&&r(e.VertexBuffer.NormalKind,this.normals),this.tangents&&r(e.VertexBuffer.TangentKind,this.tangents),this.uvs&&r(e.VertexBuffer.UVKind,this.uvs),this.uvs2&&r(e.VertexBuffer.UV2Kind,this.uvs2),this.uvs3&&r(e.VertexBuffer.UV3Kind,this.uvs3),this.uvs4&&r(e.VertexBuffer.UV4Kind,this.uvs4),this.uvs5&&r(e.VertexBuffer.UV5Kind,this.uvs5),this.uvs6&&r(e.VertexBuffer.UV6Kind,this.uvs6),this.colors&&r(e.VertexBuffer.ColorKind,this.colors),this.matricesIndices&&r(e.VertexBuffer.MatricesIndicesKind,this.matricesIndices),this.matricesWeights&&r(e.VertexBuffer.MatricesWeightsKind,this.matricesWeights),this.matricesIndicesExtra&&r(e.VertexBuffer.MatricesIndicesExtraKind,this.matricesIndicesExtra),this.matricesWeightsExtra&&r(e.VertexBuffer.MatricesWeightsExtraKind,this.matricesWeightsExtra)},t.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},t.ExtractFromMesh=function(e,i,r){return t._ExtractFrom(e,i,r)},t.ExtractFromGeometry=function(e,i,r){return t._ExtractFrom(e,i,r)},t._ExtractFrom=function(i,r,n){var o=new t;return i.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(o.positions=i.getVerticesData(e.VertexBuffer.PositionKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(o.normals=i.getVerticesData(e.VertexBuffer.NormalKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(o.tangents=i.getVerticesData(e.VertexBuffer.TangentKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(o.uvs=i.getVerticesData(e.VertexBuffer.UVKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(o.uvs2=i.getVerticesData(e.VertexBuffer.UV2Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(o.uvs3=i.getVerticesData(e.VertexBuffer.UV3Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(o.uvs4=i.getVerticesData(e.VertexBuffer.UV4Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(o.uvs5=i.getVerticesData(e.VertexBuffer.UV5Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(o.uvs6=i.getVerticesData(e.VertexBuffer.UV6Kind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(o.colors=i.getVerticesData(e.VertexBuffer.ColorKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(o.matricesIndices=i.getVerticesData(e.VertexBuffer.MatricesIndicesKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(o.matricesWeights=i.getVerticesData(e.VertexBuffer.MatricesWeightsKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesExtraKind)&&(o.matricesIndicesExtra=i.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,r,n)),i.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsExtraKind)&&(o.matricesWeightsExtra=i.getVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,r,n)),o.indices=i.getIndices(r),o},t.CreateRibbon=function(i){var r=i.pathArray,n=i.closeArray||!1,o=i.closePath||!1,s=i.invertUV||!1,a=Math.floor(r[0].length/2),l=i.offset||a;l=l>a?a:Math.floor(l);var h,c,u,f,p=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,d=i.uvs,m=i.colors,_=[],g=[],v=[],y=[],b=[],x=[],T=[],E=[],P=[],A=[];if(r.length<2){var M=[],S=[];for(u=0;u<r[0].length-l;u++)M.push(r[0][u]),S.push(r[0][u+l]);r=[M,S]}var C,R,O=0,I=o?1:0;h=r[0].length;var D,w;for(c=0;c<r.length;c++){for(T[c]=0,b[c]=[0],C=r[c],R=C.length,h=h<R?h:R,f=0;f<R;)_.push(C[f].x,C[f].y,C[f].z),f>0&&(D=C[f].subtract(C[f-1]).length(),w=D+T[c],b[c].push(w),T[c]=w),f++;o&&(f--,_.push(C[0].x,C[0].y,C[0].z),D=C[f].subtract(C[0]).length(),w=D+T[c],b[c].push(w),T[c]=w),P[c]=R+I,A[c]=O,O+=R+I}var L,F,B=null,V=null;for(u=0;u<h+I;u++){for(E[u]=0,x[u]=[0],c=0;c<r.length-1;c++)L=r[c],F=r[c+1],u===h?(B=L[0],V=F[0]):(B=L[u],V=F[u]),D=V.subtract(B).length(),w=D+E[u],x[u].push(w),E[u]=w;n&&V&&B&&(L=r[c],F=r[0],u===h&&(V=F[0]),D=V.subtract(B).length(),w=D+E[u],E[u]=w)}var N,U;if(d)for(c=0;c<d.length;c++)y.push(d[c].x,d[c].y);else for(c=0;c<r.length;c++)for(u=0;u<h+I;u++)N=0!=T[c]?b[c][u]/T[c]:0,U=0!=E[u]?x[u][c]/E[u]:0,s?y.push(U,N):y.push(N,U);c=0;for(var z=0,k=P[c]-1,G=P[c+1]-1,W=k<G?k:G,H=A[1]-A[0],j=n?P.length:P.length-1;z<=W&&c<j;)g.push(z,z+H,z+1),g.push(z+H+1,z+1,z+H),(z+=1)===W&&(c++,c===P.length-1?(H=A[0]-A[c],k=P[c]-1,G=P[0]-1):(H=A[c+1]-A[c],k=P[c]-1,G=P[c+1]-1),z=A[c],W=k<G?k+z:G+z);if(t.ComputeNormals(_,g,v),o){var X=0,Y=0;for(c=0;c<r.length;c++)X=3*A[c],Y=c+1<r.length?3*(A[c+1]-1):v.length-3,v[X]=.5*(v[X]+v[Y]),v[X+1]=.5*(v[X+1]+v[Y+1]),v[X+2]=.5*(v[X+2]+v[Y+2]),v[Y]=v[X],v[Y+1]=v[X+1],v[Y+2]=v[X+2]}t._ComputeSides(p,_,g,v,y,i.frontUVs,i.backUVs);var K=null;if(m){K=new Float32Array(4*m.length);for(var Q=0;Q<m.length;Q++)K[4*Q]=m[Q].r,K[4*Q+1]=m[Q].g,K[4*Q+2]=m[Q].b,K[4*Q+3]=m[Q].a}var Z=new t,q=new Float32Array(_),J=new Float32Array(v),$=new Float32Array(y);return Z.indices=g,Z.positions=q,Z.normals=J,Z.uvs=$,K&&Z.set(K,e.VertexBuffer.ColorKind),o&&(Z._idx=A),Z},t.CreateBox=function(i){for(var r=[new e.Vector3(0,0,1),new e.Vector3(0,0,-1),new e.Vector3(1,0,0),new e.Vector3(-1,0,0),new e.Vector3(0,1,0),new e.Vector3(0,-1,0)],n=[],o=[],s=[],a=[],l=i.width||i.size||1,h=i.height||i.size||1,c=i.depth||i.size||1,u=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,f=i.faceUV||new Array(6),p=i.faceColors,d=[],m=0;m<6;m++)void 0===f[m]&&(f[m]=new e.Vector4(0,0,1,1)),p&&void 0===p[m]&&(p[m]=new e.Color4(1,1,1,1));for(var _=new e.Vector3(l/2,h/2,c/2),g=0;g<r.length;g++){var v=r[g],y=new e.Vector3(v.y,v.z,v.x),b=e.Vector3.Cross(v,y),x=o.length/3;n.push(x),n.push(x+1),n.push(x+2),n.push(x),n.push(x+2),n.push(x+3);var T=v.subtract(y).subtract(b).multiply(_);o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(f[g].z,f[g].w),p&&d.push(p[g].r,p[g].g,p[g].b,p[g].a),T=v.subtract(y).add(b).multiply(_),o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(f[g].x,f[g].w),p&&d.push(p[g].r,p[g].g,p[g].b,p[g].a),T=v.add(y).add(b).multiply(_),o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(f[g].x,f[g].y),p&&d.push(p[g].r,p[g].g,p[g].b,p[g].a),T=v.add(y).subtract(b).multiply(_),o.push(T.x,T.y,T.z),s.push(v.x,v.y,v.z),a.push(f[g].z,f[g].y),p&&d.push(p[g].r,p[g].g,p[g].b,p[g].a)}t._ComputeSides(u,o,n,s,a,i.frontUVs,i.backUVs);var E=new t;if(E.indices=n,E.positions=o,E.normals=s,E.uvs=a,p){var P=u===e.Mesh.DOUBLESIDE?d.concat(d):d;E.colors=P}return E},t.CreateSphere=function(i){for(var r=i.segments||32,n=i.diameterX||i.diameter||1,o=i.diameterY||i.diameter||1,s=i.diameterZ||i.diameter||1,a=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,l=i.slice&&i.slice<=0?1:i.slice||1,h=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=new e.Vector3(n/2,o/2,s/2),u=2+r,f=2*u,p=[],d=[],m=[],_=[],g=0;g<=u;g++){for(var v=g/u,y=v*Math.PI*l,b=0;b<=f;b++){var x=b/f,T=x*Math.PI*2*a,E=e.Matrix.RotationZ(-y),P=e.Matrix.RotationY(T),A=e.Vector3.TransformCoordinates(e.Vector3.Up(),E),M=e.Vector3.TransformCoordinates(A,P),S=M.multiply(c),C=M.divide(c).normalize();d.push(S.x,S.y,S.z),m.push(C.x,C.y,C.z),_.push(x,v)}if(g>0)for(var R=d.length/3,O=R-2*(f+1);O+f+2<R;O++)p.push(O),p.push(O+1),p.push(O+f+1),p.push(O+f+1),p.push(O+1),p.push(O+f+2)}t._ComputeSides(h,d,p,m,_,i.frontUVs,i.backUVs);var I=new t;return I.indices=p,I.positions=d,I.normals=m,I.uvs=_,I},t.CreateCylinder=function(i){var r,n=i.height||2,o=0===i.diameterTop?0:i.diameterTop||i.diameter||1,s=0===i.diameterBottom?0:i.diameterBottom||i.diameter||1,a=i.tessellation||24,l=i.subdivisions||1,h=!!i.hasRings,c=!!i.enclose,u=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,f=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,p=i.faceUV||new Array(3),d=i.faceColors,m=1!==u&&c?2:0,_=h?l:1,g=2+(1+m)*_;for(r=0;r<g;r++)d&&void 0===d[r]&&(d[r]=new e.Color4(1,1,1,1));for(r=0;r<g;r++)p&&void 0===p[r]&&(p[r]=new e.Vector4(0,0,1,1));var v,y,b,x,T,E,P=new Array,A=new Array,M=new Array,S=new Array,C=new Array,R=2*Math.PI*u/a,O=(s-o)/2/n,I=e.Vector3.Zero(),D=e.Vector3.Zero(),w=e.Vector3.Zero(),L=e.Vector3.Zero(),F=e.Vector3.Zero(),B=e.Axis.Y,V=1,N=1,U=0,z=0;for(x=0;x<=l;x++)for(y=x/l,b=(y*(o-s)+s)/2,V=h&&0!==x&&x!==l?2:1,E=0;E<V;E++){for(h&&(N+=E),c&&(N+=2*E),T=0;T<=a;T++)v=T*R,I.x=Math.cos(-v)*b,I.y=-n/2+y*n,I.z=Math.sin(-v)*b,0===o&&x===l?(D.x=M[M.length-3*(a+1)],D.y=M[M.length-3*(a+1)+1],D.z=M[M.length-3*(a+1)+2]):(D.x=I.x,D.z=I.z,D.y=Math.sqrt(D.x*D.x+D.z*D.z)*O,D.normalize()),0===T&&(w.copyFrom(I),L.copyFrom(D)),A.push(I.x,I.y,I.z),M.push(D.x,D.y,D.z),z=h?U!==N?p[N].y:p[N].w:p[N].y+(p[N].w-p[N].y)*y,S.push(p[N].x+(p[N].z-p[N].x)*T/a,z),d&&C.push(d[N].r,d[N].g,d[N].b,d[N].a);1!==u&&c&&(A.push(I.x,I.y,I.z),A.push(0,I.y,0),A.push(0,I.y,0),A.push(w.x,w.y,w.z),e.Vector3.CrossToRef(B,D,F),F.normalize(),M.push(F.x,F.y,F.z,F.x,F.y,F.z),e.Vector3.CrossToRef(L,B,F),F.normalize(),M.push(F.x,F.y,F.z,F.x,F.y,F.z),z=h?U!==N?p[N+1].y:p[N+1].w:p[N+1].y+(p[N+1].w-p[N+1].y)*y,S.push(p[N+1].x,z),S.push(p[N+1].z,z),z=h?U!==N?p[N+2].y:p[N+2].w:p[N+2].y+(p[N+2].w-p[N+2].y)*y,S.push(p[N+2].x,z),S.push(p[N+2].z,z),d&&(C.push(d[N+1].r,d[N+1].g,d[N+1].b,d[N+1].a),C.push(d[N+1].r,d[N+1].g,d[N+1].b,d[N+1].a),C.push(d[N+2].r,d[N+2].g,d[N+2].b,d[N+2].a),C.push(d[N+2].r,d[N+2].g,d[N+2].b,d[N+2].a))),U!==N&&(U=N)}var N,k=1!==u&&c?a+4:a;for(x=0,N=0;N<l;N++){var G=0,W=0,H=0,j=0;for(T=0;T<a;T++)G=x*(k+1)+T,W=(x+1)*(k+1)+T,H=x*(k+1)+(T+1),j=(x+1)*(k+1)+(T+1),P.push(G,W,H),P.push(j,H,W);1!==u&&c&&(P.push(G+2,W+2,H+2),P.push(j+2,H+2,W+2),P.push(G+4,W+4,H+4),P.push(j+4,H+4,W+4)),x=h?x+2:x+1}var X=function(t){var i=t?o/2:s/2;if(0!==i){var r,l,h,c=t?p[g-1]:p[0],f=null;d&&(f=t?d[g-1]:d[0]);var m=A.length/3,_=t?n/2:-n/2,v=new e.Vector3(0,_,0);A.push(v.x,v.y,v.z),M.push(0,t?1:-1,0),S.push(c.x+.5*(c.z-c.x),c.y+.5*(c.w-c.y)),f&&C.push(f.r,f.g,f.b,f.a);var y=new e.Vector2(.5,.5);for(h=0;h<=a;h++){r=2*Math.PI*h*u/a;var b=Math.cos(-r),x=Math.sin(-r);l=new e.Vector3(b*i,_,x*i);var T=new e.Vector2(b*y.x+.5,x*y.y+.5);A.push(l.x,l.y,l.z),M.push(0,t?1:-1,0),S.push(c.x+(c.z-c.x)*T.x,c.y+(c.w-c.y)*T.y),f&&C.push(f.r,f.g,f.b,f.a)}for(h=0;h<a;h++)t?(P.push(m),P.push(m+(h+2)),P.push(m+(h+1))):(P.push(m),P.push(m+(h+1)),P.push(m+(h+2)))}};X(!1),X(!0),t._ComputeSides(f,A,P,M,S,i.frontUVs,i.backUVs);var Y=new t;return Y.indices=P,Y.positions=A,Y.normals=M,Y.uvs=S,d&&(Y.colors=C),Y},t.CreateTorus=function(i){for(var r=[],n=[],o=[],s=[],a=i.diameter||1,l=i.thickness||.5,h=i.tessellation||16,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,u=h+1,f=0;f<=h;f++)for(var p=f/h,d=f*Math.PI*2/h-Math.PI/2,m=e.Matrix.Translation(a/2,0,0).multiply(e.Matrix.RotationY(d)),_=0;_<=h;_++){var g=1-_/h,v=_*Math.PI*2/h+Math.PI,y=Math.cos(v),b=Math.sin(v),x=new e.Vector3(y,b,0),T=x.scale(l/2),E=new e.Vector2(p,g);T=e.Vector3.TransformCoordinates(T,m),x=e.Vector3.TransformNormal(x,m),n.push(T.x,T.y,T.z),o.push(x.x,x.y,x.z),s.push(E.x,E.y);var P=(f+1)%u,A=(_+1)%u;r.push(f*u+_),r.push(f*u+A),r.push(P*u+_),r.push(f*u+A),r.push(P*u+A),r.push(P*u+_)}t._ComputeSides(c,n,r,o,s,i.frontUVs,i.backUVs);var M=new t;return M.indices=r,M.positions=n,M.normals=o,M.uvs=s,M},t.CreateLineSystem=function(e){for(var i=[],r=[],n=e.lines,o=e.colors,s=[],a=0,l=0;l<n.length;l++)for(var h=n[l],c=0;c<h.length;c++){if(r.push(h[c].x,h[c].y,h[c].z),o){var u=o[l];s.push(u[c].r,u[c].g,u[c].b,u[c].a)}c>0&&(i.push(a-1),i.push(a)),a++}var f=new t;return f.indices=i,f.positions=r,o&&(f.colors=s),f},t.CreateDashedLines=function(i){var r=i.dashSize||3,n=i.gapSize||1,o=i.dashNb||200,s=i.points,a=new Array,l=new Array,h=e.Vector3.Zero(),c=0,u=0,f=0,p=0,d=0,m=0,_=0;for(_=0;_<s.length-1;_++)s[_+1].subtractToRef(s[_],h),c+=h.length();for(f=c/o,p=r*f/(r+n),_=0;_<s.length-1;_++){s[_+1].subtractToRef(s[_],h),u=Math.floor(h.length()/f),h.normalize();for(var g=0;g<u;g++)d=f*g,a.push(s[_].x+d*h.x,s[_].y+d*h.y,s[_].z+d*h.z),a.push(s[_].x+(d+p)*h.x,s[_].y+(d+p)*h.y,s[_].z+(d+p)*h.z),l.push(m,m+1),m+=2}var v=new t;return v.positions=a,v.indices=l,v},t.CreateGround=function(i){var r,n,o=[],s=[],a=[],l=[],h=i.width||1,c=i.height||1,u=i.subdivisionsX||i.subdivisions||1,f=i.subdivisionsY||i.subdivisions||1;for(r=0;r<=f;r++)for(n=0;n<=u;n++){var p=new e.Vector3(n*h/u-h/2,0,(f-r)*c/f-c/2),d=new e.Vector3(0,1,0);s.push(p.x,p.y,p.z),a.push(d.x,d.y,d.z),l.push(n/u,1-r/f)}for(r=0;r<f;r++)for(n=0;n<u;n++)o.push(n+1+(r+1)*(u+1)),o.push(n+1+r*(u+1)),o.push(n+r*(u+1)),o.push(n+(r+1)*(u+1)),o.push(n+1+(r+1)*(u+1)),o.push(n+r*(u+1));var m=new t;return m.indices=o,m.positions=s,m.normals=a,m.uvs=l,m},t.CreateTiledGround=function(i){var r,n,o,s,a=void 0!==i.xmin&&null!==i.xmin?i.xmin:-1,l=void 0!==i.zmin&&null!==i.zmin?i.zmin:-1,h=void 0!==i.xmax&&null!==i.xmax?i.xmax:1,c=void 0!==i.zmax&&null!==i.zmax?i.zmax:1,u=i.subdivisions||{w:1,h:1},f=i.precision||{w:1,h:1},p=new Array,d=new Array,m=new Array,_=new Array;u.h=u.h<1?1:u.h,u.w=u.w<1?1:u.w,f.w=f.w<1?1:f.w,f.h=f.h<1?1:f.h;var g={w:(h-a)/u.w,h:(c-l)/u.h};for(o=0;o<u.h;o++)for(s=0;s<u.w;s++)!(function(t,i,o,s){var a=d.length/3,l=f.w+1;for(r=0;r<f.h;r++)for(n=0;n<f.w;n++){var h=[a+n+r*l,a+(n+1)+r*l,a+(n+1)+(r+1)*l,a+n+(r+1)*l];p.push(h[1]),p.push(h[2]),p.push(h[3]),p.push(h[0]),p.push(h[1]),p.push(h[3])}var c=e.Vector3.Zero(),u=new e.Vector3(0,1,0);for(r=0;r<=f.h;r++)for(c.z=r*(s-i)/f.h+i,n=0;n<=f.w;n++)c.x=n*(o-t)/f.w+t,c.y=0,d.push(c.x,c.y,c.z),m.push(u.x,u.y,u.z),_.push(n/f.w,r/f.h)})(a+s*g.w,l+o*g.h,a+(s+1)*g.w,l+(o+1)*g.h);var v=new t;return v.indices=p,v.positions=d,v.normals=m,v.uvs=_,v},t.CreateGroundFromHeightMap=function(i){var r,n,o=[],s=[],a=[],l=[],h=i.colorFilter||new e.Color3(.3,.59,.11);for(r=0;r<=i.subdivisions;r++)for(n=0;n<=i.subdivisions;n++){var c=new e.Vector3(n*i.width/i.subdivisions-i.width/2,0,(i.subdivisions-r)*i.height/i.subdivisions-i.height/2),u=(c.x+i.width/2)/i.width*(i.bufferWidth-1)|0,f=(1-(c.z+i.height/2)/i.height)*(i.bufferHeight-1)|0,p=4*(u+f*i.bufferWidth),d=i.buffer[p]/255,m=i.buffer[p+1]/255,_=i.buffer[p+2]/255,g=d*h.r+m*h.g+_*h.b;c.y=i.minHeight+(i.maxHeight-i.minHeight)*g,s.push(c.x,c.y,c.z),a.push(0,0,0),l.push(n/i.subdivisions,1-r/i.subdivisions)}for(r=0;r<i.subdivisions;r++)for(n=0;n<i.subdivisions;n++)o.push(n+1+(r+1)*(i.subdivisions+1)),o.push(n+1+r*(i.subdivisions+1)),o.push(n+r*(i.subdivisions+1)),o.push(n+(r+1)*(i.subdivisions+1)),o.push(n+1+(r+1)*(i.subdivisions+1)),o.push(n+r*(i.subdivisions+1));t.ComputeNormals(s,o,a);var v=new t;return v.indices=o,v.positions=s,v.normals=a,v.uvs=l,v},t.CreatePlane=function(i){var r=[],n=[],o=[],s=[],a=i.width||i.size||1,l=i.height||i.size||1,h=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,c=a/2,u=l/2;n.push(-c,-u,0),o.push(0,0,-1),s.push(0,0),n.push(c,-u,0),o.push(0,0,-1),s.push(1,0),n.push(c,u,0),o.push(0,0,-1),s.push(1,1),n.push(-c,u,0),o.push(0,0,-1),s.push(0,1),r.push(0),r.push(1),r.push(2),r.push(0),r.push(2),r.push(3),t._ComputeSides(h,n,r,o,s,i.frontUVs,i.backUVs);var f=new t;return f.indices=r,f.positions=n,f.normals=o,f.uvs=s,f},t.CreateDisc=function(i){var r=new Array,n=new Array,o=new Array,s=new Array,a=i.radius||.5,l=i.tessellation||64,h=i.arc&&(i.arc<=0||i.arc>1)?1:i.arc||1,c=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE;r.push(0,0,0),s.push(.5,.5);for(var u=2*Math.PI*h,f=u/l,p=0;p<u;p+=f){var d=Math.cos(p),m=Math.sin(p),_=(d+1)/2,g=(1-m)/2;r.push(a*d,a*m,0),s.push(_,g)}1===h&&(r.push(r[3],r[4],r[5]),s.push(s[2],s[3]));for(var v=r.length/3,y=1;y<v-1;y++)n.push(y+1,0,y);t.ComputeNormals(r,n,o),t._ComputeSides(c,r,n,o,s,i.frontUVs,i.backUVs);var b=new t;return b.indices=n,b.positions=r,b.normals=o,b.uvs=s,b},t.CreatePolygon=function(i,r,n,o,s,a){for(var l=n||new Array(3),h=o,c=[],u=0;u<3;u++)void 0===l[u]&&(l[u]=new e.Vector4(0,0,1,1)),h&&void 0===h[u]&&(h[u]=new e.Color4(1,1,1,1));for(var f=i.getVerticesData(e.VertexBuffer.PositionKind),p=i.getVerticesData(e.VertexBuffer.NormalKind),d=i.getVerticesData(e.VertexBuffer.UVKind),m=i.getIndices(),_=0,g=0,v=0;v<p.length;v+=3)Math.abs(p[v+1])<.001&&(g=1),Math.abs(p[v+1]-1)<.001&&(g=0),Math.abs(p[v+1]+1)<.001&&(g=2),_=v/3,d[2*_]=(1-d[2*_])*l[g].x+d[2*_]*l[g].z,d[2*_+1]=(1-d[2*_+1])*l[g].y+d[2*_+1]*l[g].w,h&&c.push(h[g].r,h[g].g,h[g].b,h[g].a);t._ComputeSides(r,f,m,p,d,s,a);var y=new t;if(y.indices=m,y.positions=f,y.normals=p,y.uvs=d,h){var b=r===e.Mesh.DOUBLESIDE?c.concat(c):c;y.colors=b}return y},t.CreateIcoSphere=function(i){var r,n=i.sideOrientation||e.Mesh.DEFAULTSIDE,o=i.radius||1,s=void 0===i.flat||i.flat,a=i.subdivisions||4,l=i.radiusX||o,h=i.radiusY||o,c=i.radiusZ||o,u=(1+Math.sqrt(5))/2,f=[-1,u,-0,1,u,0,-1,-u,0,1,-u,0,0,-1,-u,0,1,-u,0,-1,u,0,1,u,u,0,1,u,0,-1,-u,0,1,-u,0,-1],p=[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],d=[0,1,2,3,4,5,6,7,8,9,10,11,0,2,3,3,3,4,7,8,9,9,10,11],m=[5,1,3,1,6,4,0,0,5,3,4,2,2,2,4,0,2,0,1,1,6,0,6,2,0,4,3,3,4,4,3,1,4,2,4,4,0,2,1,1,2,2,3,3,1,3,2,4],_=[0,0,0,0,1,0,0,1,1,0,0,0,1,1,0,0,1,1,1,0],g=new Array,v=new Array,y=new Array,b=new Array,x=0,T=new Array(3),E=new Array(3);for(r=0;r<3;r++)T[r]=e.Vector3.Zero(),E[r]=e.Vector2.Zero();for(var P=0;P<20;P++){for(r=0;r<3;r++){var A=p[3*P+r];T[r].copyFromFloats(f[3*d[A]],f[3*d[A]+1],f[3*d[A]+2]),T[r].normalize().scaleInPlace(o),E[r].copyFromFloats(m[2*A]*(138/1024)+60/1024+_[P]*(-40/1024),m[2*A+1]*(239/1024)+26/1024+_[P]*(20/1024))}for(var M=function(t,i,r,n){var o=e.Vector3.Lerp(T[0],T[2],i/a),u=e.Vector3.Lerp(T[1],T[2],i/a),f=a===i?T[2]:e.Vector3.Lerp(o,u,t/(a-i));f.normalize();var p;if(s){var d=e.Vector3.Lerp(T[0],T[2],n/a),m=e.Vector3.Lerp(T[1],T[2],n/a);p=e.Vector3.Lerp(d,m,r/(a-n))}else p=new e.Vector3(f.x,f.y,f.z);p.x/=l,p.y/=h,p.z/=c,p.normalize();var _=e.Vector2.Lerp(E[0],E[2],i/a),P=e.Vector2.Lerp(E[1],E[2],i/a),A=a===i?E[2]:e.Vector2.Lerp(_,P,t/(a-i));v.push(f.x*l,f.y*h,f.z*c),y.push(p.x,p.y,p.z),b.push(A.x,A.y),g.push(x),x++},S=0;S<a;S++)for(var C=0;C+S<a;C++)M(C,S,C+1/3,S+1/3),M(C+1,S,C+1/3,S+1/3),M(C,S+1,C+1/3,S+1/3),C+S+1<a&&(M(C+1,S,C+2/3,S+2/3),M(C+1,S+1,C+2/3,S+2/3),M(C,S+1,C+2/3,S+2/3))}t._ComputeSides(n,v,g,y,b,i.frontUVs,i.backUVs);var R=new t;return R.indices=g,R.positions=v,R.normals=y,R.uvs=b,R},t.CreatePolyhedron=function(i){var r=[];r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[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]]},r[14]={vertex:[[-.93465,.300459,-.271185],[-.838689,-.260219,-.516017],[-.711319,.717591,.128359],[-.710334,-.156922,.080946],[-.599799,.556003,-.725148],[-.503838,-.004675,-.969981],[-.487004,.26021,.48049],[-.460089,-.750282,-.512622],[-.376468,.973135,-.325605],[-.331735,-.646985,.084342],[-.254001,.831847,.530001],[-.125239,-.494738,-.966586],[.029622,.027949,.730817],[.056536,-.982543,-.262295],[.08085,1.087391,.076037],[.125583,-.532729,.485984],[.262625,.599586,.780328],[.391387,-.726999,-.716259],[.513854,-.868287,.139347],[.597475,.85513,.326364],[.641224,.109523,.783723],[.737185,-.451155,.538891],[.848705,-.612742,-.314616],[.976075,.365067,.32976],[1.072036,-.19561,.084927]],face:[[15,18,21],[12,20,16],[6,10,2],[3,0,1],[9,7,13],[2,8,4,0],[0,4,5,1],[1,5,11,7],[7,11,17,13],[13,17,22,18],[18,22,24,21],[21,24,23,20],[20,23,19,16],[16,19,14,10],[10,14,8,2],[15,9,13,18],[12,15,21,20],[6,12,16,10],[3,6,2,0],[9,3,1,7],[9,15,12,6,3],[22,17,11,5,4,8,14,19,23,24]]};var n,o,s,a,l,h,c=i.type&&(i.type<0||i.type>=r.length)?0:i.type||0,u=i.size,f=i.sizeX||u||1,p=i.sizeY||u||1,d=i.sizeZ||u||1,m=i.custom||r[c],_=m.face.length,g=i.faceUV||new Array(_),v=i.faceColors,y=void 0===i.flat||i.flat,b=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,x=new Array,T=new Array,E=new Array,P=new Array,A=new Array,M=0,S=0,C=new Array,R=0,O=0;if(y)for(O=0;O<_;O++)v&&void 0===v[O]&&(v[O]=new e.Color4(1,1,1,1)),g&&void 0===g[O]&&(g[O]=new e.Vector4(0,0,1,1));if(y)for(O=0;O<_;O++){var I=m.face[O].length;for(s=2*Math.PI/I,a=.5*Math.tan(s/2),l=.5,R=0;R<I;R++)x.push(m.vertex[m.face[O][R]][0]*f,m.vertex[m.face[O][R]][1]*p,m.vertex[m.face[O][R]][2]*d),C.push(M),M++,n=g[O].x+(g[O].z-g[O].x)*(.5+a),o=g[O].y+(g[O].w-g[O].y)*(l-.5),P.push(n,o),h=a*Math.cos(s)-l*Math.sin(s),l=a*Math.sin(s)+l*Math.cos(s),a=h,v&&A.push(v[O].r,v[O].g,v[O].b,v[O].a);for(R=0;R<I-2;R++)T.push(C[0+S],C[R+2+S],C[R+1+S]);S+=I}else{for(R=0;R<m.vertex.length;R++)x.push(m.vertex[R][0]*f,m.vertex[R][1]*p,m.vertex[R][2]*d),P.push(0,0);for(O=0;O<_;O++)for(R=0;R<m.face[O].length-2;R++)T.push(m.face[O][0],m.face[O][R+2],m.face[O][R+1])}t.ComputeNormals(x,T,E),t._ComputeSides(b,x,T,E,P,i.frontUVs,i.backUVs);var D=new t;return D.positions=x,D.indices=T,D.normals=E,D.uvs=P,v&&y&&(D.colors=A),D},t.CreateTorusKnot=function(i){var r,n,o=new Array,s=new Array,a=new Array,l=new Array,h=i.radius||2,c=i.tube||.5,u=i.radialSegments||32,f=i.tubularSegments||32,p=i.p||2,d=i.q||3,m=0===i.sideOrientation?0:i.sideOrientation||e.Mesh.DEFAULTSIDE,_=function(t){var i=Math.cos(t),r=Math.sin(t),n=d/p*t,o=Math.cos(n),s=h*(2+o)*.5*i,a=h*(2+o)*r*.5,l=h*Math.sin(n)*.5;return new e.Vector3(s,a,l)};for(r=0;r<=u;r++){var g=r%u,v=g/u*2*p*Math.PI,y=_(v),b=_(v+.01),x=b.subtract(y),T=b.add(y),E=e.Vector3.Cross(x,T);for(T=e.Vector3.Cross(E,x),E.normalize(),T.normalize(),n=0;n<f;n++){var P=n%f,A=P/f*2*Math.PI,M=-c*Math.cos(A),S=c*Math.sin(A);s.push(y.x+M*T.x+S*E.x),s.push(y.y+M*T.y+S*E.y),s.push(y.z+M*T.z+S*E.z),l.push(r/u),l.push(n/f)}}for(r=0;r<u;r++)for(n=0;n<f;n++){var C=(n+1)%f,R=r*f+n,O=(r+1)*f+n,I=(r+1)*f+C,D=r*f+C;o.push(D),o.push(O),o.push(R),o.push(D),o.push(I),o.push(O)}t.ComputeNormals(s,o,a),t._ComputeSides(m,s,o,a,l,i.frontUVs,i.backUVs);var w=new t;return w.indices=o,w.positions=s,w.normals=a,w.uvs=l,w},t.ComputeNormals=function(t,i,r,n){var o=0,s=0,a=0,l=0,h=0,c=0,u=0,f=0,p=0,d=0,m=0,_=0,g=0,v=0,y=0,b=0,x=0,T=0,E=0,P=0,A=!1,M=!1,S=!1,C=!1,R=1,O=0,I=null;if(n&&(A=!!n.facetNormals,M=!!n.facetPositions,S=!!n.facetPartitioning,R=!0===n.useRightHandedSystem?-1:1,O=n.ratio||0,C=!!n.depthSort,I=n.distanceTo,C)){void 0===I&&(I=e.Vector3.Zero());var D=n.depthSortedFacets}var w=0,L=0,F=0,B=0;if(S&&n&&n.bbSize){var V=0,N=0,U=0,z=0,k=0,G=0,W=0,H=0,j=0,X=0,Y=0,K=0,Q=0,Z=0,q=0,J=0,$=n.bbSize.x>n.bbSize.y?n.bbSize.x:n.bbSize.y;$=$>n.bbSize.z?$:n.bbSize.z,w=n.subDiv.X*O/n.bbSize.x,L=n.subDiv.Y*O/n.bbSize.y,F=n.subDiv.Z*O/n.bbSize.z,B=n.subDiv.max*n.subDiv.max,n.facetPartitioning.length=0}for(o=0;o<t.length;o++)r[o]=0;var ee=i.length/3|0;for(o=0;o<ee;o++){if(_=3*i[3*o],g=_+1,v=_+2,y=3*i[3*o+1],b=y+1,x=y+2,T=3*i[3*o+2],E=T+1,P=T+2,s=t[_]-t[y],a=t[g]-t[b],l=t[v]-t[x],h=t[T]-t[y],c=t[E]-t[b],u=t[P]-t[x],f=R*(a*u-l*c),p=R*(l*h-s*u),d=R*(s*c-a*h),m=Math.sqrt(f*f+p*p+d*d),m=0===m?1:m,f/=m,p/=m,d/=m,A&&n&&(n.facetNormals[o].x=f,n.facetNormals[o].y=p,n.facetNormals[o].z=d),M&&n&&(n.facetPositions[o].x=(t[_]+t[y]+t[T])/3,n.facetPositions[o].y=(t[g]+t[b]+t[E])/3,n.facetPositions[o].z=(t[v]+t[x]+t[P])/3),S&&n&&(V=Math.floor((n.facetPositions[o].x-n.bInfo.minimum.x*O)*w),N=Math.floor((n.facetPositions[o].y-n.bInfo.minimum.y*O)*L),U=Math.floor((n.facetPositions[o].z-n.bInfo.minimum.z*O)*F),z=Math.floor((t[_]-n.bInfo.minimum.x*O)*w),k=Math.floor((t[g]-n.bInfo.minimum.y*O)*L),G=Math.floor((t[v]-n.bInfo.minimum.z*O)*F),W=Math.floor((t[y]-n.bInfo.minimum.x*O)*w),H=Math.floor((t[b]-n.bInfo.minimum.y*O)*L),j=Math.floor((t[x]-n.bInfo.minimum.z*O)*F),X=Math.floor((t[T]-n.bInfo.minimum.x*O)*w),Y=Math.floor((t[E]-n.bInfo.minimum.y*O)*L),K=Math.floor((t[P]-n.bInfo.minimum.z*O)*F),Z=z+n.subDiv.max*k+B*G,q=W+n.subDiv.max*H+B*j,J=X+n.subDiv.max*Y+B*K,Q=V+n.subDiv.max*N+B*U,n.facetPartitioning[Q]=n.facetPartitioning[Q]?n.facetPartitioning[Q]:new Array,n.facetPartitioning[Z]=n.facetPartitioning[Z]?n.facetPartitioning[Z]:new Array,n.facetPartitioning[q]=n.facetPartitioning[q]?n.facetPartitioning[q]:new Array,n.facetPartitioning[J]=n.facetPartitioning[J]?n.facetPartitioning[J]:new Array,n.facetPartitioning[Z].push(o),q!=Z&&n.facetPartitioning[q].push(o),J!=q&&J!=Z&&n.facetPartitioning[J].push(o),Q!=Z&&Q!=q&&Q!=J&&n.facetPartitioning[Q].push(o)),C&&n&&n.facetPositions){var te=D[o];te.ind=3*o,te.sqDistance=e.Vector3.DistanceSquared(n.facetPositions[o],I)}r[_]+=f,r[g]+=p,r[v]+=d,r[y]+=f,r[b]+=p,r[x]+=d,r[T]+=f,r[E]+=p,r[P]+=d}for(o=0;o<r.length/3;o++)f=r[3*o],p=r[3*o+1],d=r[3*o+2],m=Math.sqrt(f*f+p*p+d*d),m=0===m?1:m,f/=m,p/=m,d/=m,r[3*o]=f,r[3*o+1]=p,r[3*o+2]=d},t._ComputeSides=function(t,i,r,n,o,s,a){var l,h,c=r.length,u=n.length;switch(t=t||e.Mesh.DEFAULTSIDE){case e.Mesh.FRONTSIDE:break;case e.Mesh.BACKSIDE:var f;for(l=0;l<c;l+=3)f=r[l],r[l]=r[l+2],r[l+2]=f;for(h=0;h<u;h++)n[h]=-n[h];break;case e.Mesh.DOUBLESIDE:for(var p=i.length,d=p/3,m=0;m<p;m++)i[p+m]=i[m];for(l=0;l<c;l+=3)r[l+c]=r[l+2]+d,r[l+1+c]=r[l+1]+d,r[l+2+c]=r[l]+d;for(h=0;h<u;h++)n[u+h]=-n[h];var _=o.length,g=0;for(g=0;g<_;g++)o[g+_]=o[g];for(s=s||new e.Vector4(0,0,1,1),a=a||new e.Vector4(0,0,1,1),g=0,l=0;l<_/2;l++)o[g]=s.x+(s.z-s.x)*o[g],o[g+1]=s.y+(s.w-s.y)*o[g+1],o[g+_]=a.x+(a.z-a.x)*o[g+_],o[g+_+1]=a.y+(a.w-a.y)*o[g+_+1],g+=2}},t.ImportVertexData=function(i,r){var n=new t,o=i.positions;o&&n.set(o,e.VertexBuffer.PositionKind);var s=i.normals;s&&n.set(s,e.VertexBuffer.NormalKind);var a=i.tangents;a&&n.set(a,e.VertexBuffer.TangentKind);var l=i.uvs;l&&n.set(l,e.VertexBuffer.UVKind);var h=i.uv2s;h&&n.set(h,e.VertexBuffer.UV2Kind);var c=i.uv3s;c&&n.set(c,e.VertexBuffer.UV3Kind);var u=i.uv4s;u&&n.set(u,e.VertexBuffer.UV4Kind);var f=i.uv5s;f&&n.set(f,e.VertexBuffer.UV5Kind);var p=i.uv6s;p&&n.set(p,e.VertexBuffer.UV6Kind);var d=i.colors;d&&n.set(e.Color4.CheckColors4(d,o.length/3),e.VertexBuffer.ColorKind);var m=i.matricesIndices;m&&n.set(m,e.VertexBuffer.MatricesIndicesKind);var _=i.matricesWeights;_&&n.set(_,e.VertexBuffer.MatricesWeightsKind);var g=i.indices;g&&(n.indices=g),r.setAllVerticesData(n,i.updatable)},t})();e.VertexData=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i,r,n,o){void 0===n&&(n=!1),void 0===o&&(o=null),this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this._totalVertices=0,this._isDisposed=!1,this._indexBufferIsUpdatable=!1,this.id=t,this._engine=i.getEngine(),this._meshes=[],this._scene=i,this._vertexBuffers={},this._indices=[],this._updatable=n,r?this.setAllVerticesData(r,n):(this._totalVertices=0,this._indices=[]),this._engine.getCaps().vertexArrayObject&&(this._vertexArrayObjects={}),o&&("LinesMesh"===o.getClassName()&&(this.boundingBias=new e.Vector2(0,o.intersectionThreshold),this._updateExtend()),this.applyToMesh(o),o.computeWorldMatrix(!0))}return Object.defineProperty(t.prototype,"boundingBias",{get:function(){return this._boundingBias},set:function(e){this._boundingBias&&this._boundingBias.equals(e)||(this._boundingBias=e.clone(),this._updateBoundingInfo(!0,null))},enumerable:!0,configurable:!0}),t.CreateGeometryForMesh=function(e){var i=new t(t.RandomId(),e.getScene());return i.applyToMesh(e),i},Object.defineProperty(t.prototype,"extend",{get:function(){return this._extend},enumerable:!0,configurable:!0}),t.prototype.getScene=function(){return this._scene},t.prototype.getEngine=function(){return this._engine},t.prototype.isReady=function(){return this.delayLoadState===e.Engine.DELAYLOADSTATE_LOADED||this.delayLoadState===e.Engine.DELAYLOADSTATE_NONE},Object.defineProperty(t.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}),t.prototype._rebuild=function(){this._vertexArrayObjects&&(this._vertexArrayObjects={}),0!==this._meshes.length&&this._indices&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices));for(var e in this._vertexBuffers){this._vertexBuffers[e]._rebuild()}},t.prototype.setAllVerticesData=function(e,t){e.applyToGeometry(this,t),this.notifyUpdate()},t.prototype.setVerticesData=function(t,i,r,n){void 0===r&&(r=!1);var o=new e.VertexBuffer(this._engine,i,t,r,0===this._meshes.length,n);this.setVerticesBuffer(o)},t.prototype.removeVerticesData=function(e){this._vertexBuffers[e]&&(this._vertexBuffers[e].dispose(),delete this._vertexBuffers[e])},t.prototype.setVerticesBuffer=function(t,i){void 0===i&&(i=null);var r=t.getKind();if(this._vertexBuffers[r]&&this._vertexBuffers[r].dispose(),this._vertexBuffers[r]=t,r===e.VertexBuffer.PositionKind){var n=t.getData();null!=i?this._totalVertices=i:null!=n&&(this._totalVertices=n.length/(t.byteStride/4)),this._updateExtend(n),this._resetPointsArrayCache();for(var o=this._meshes,s=o.length,a=0;a<s;a++){var l=o[a];l._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),l._createGlobalSubMesh(!1),l.computeWorldMatrix(!0)}}this.notifyUpdate(r),this._vertexArrayObjects&&(this._disposeVertexArrayObjects(),this._vertexArrayObjects={})},t.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))},t.prototype.updateVerticesData=function(t,i,r){void 0===r&&(r=!1);var n=this.getVertexBuffer(t);n&&(n.update(i),t===e.VertexBuffer.PositionKind&&this._updateBoundingInfo(r,i),this.notifyUpdate(t))},t.prototype._updateBoundingInfo=function(t,i){t&&this._updateExtend(i);var r=this._meshes,n=r.length;this._resetPointsArrayCache();for(var o=0;o<n;o++){var s=r[o];if(t){s._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum);for(var a=0;a<s.subMeshes.length;a++){s.subMeshes[a].refreshBoundingInfo()}}}},t.prototype._bind=function(e,t){if(e){void 0===t&&(t=this._indexBuffer);var i=this.getVertexBuffers();if(i){if(t!=this._indexBuffer||!this._vertexArrayObjects)return void this._engine.bindBuffers(i,t,e);this._vertexArrayObjects[e.key]||(this._vertexArrayObjects[e.key]=this._engine.recordVertexArrayObject(i,t,e)),this._engine.bindVertexArrayObject(this._vertexArrayObjects[e.key],t)}}},t.prototype.getTotalVertices=function(){return this.isReady()?this._totalVertices:0},t.prototype.getVerticesData=function(t,i,r){var n=this.getVertexBuffer(t);if(!n)return null;var o=n.getData();if(!o)return null;var s=n.getSize()*e.VertexBuffer.GetTypeByteLength(n.type),a=this._totalVertices*n.getSize();if(n.type!==e.VertexBuffer.FLOAT||n.byteStride!==s){var l=new Array(a);return n.forEach(a,(function(e,t){l[t]=e})),l}if(!(o instanceof Array||o instanceof Float32Array)||0!==n.byteOffset||o.length!==a){if(o instanceof Array){var h=n.byteOffset/4;return e.Tools.Slice(o,h,h+a)}return o instanceof ArrayBuffer?new Float32Array(o,n.byteOffset,a):new Float32Array(o.buffer,o.byteOffset+n.byteOffset,a)}return r||i&&1!==this._meshes.length?e.Tools.Slice(o):o},t.prototype.isVertexBufferUpdatable=function(e){var t=this._vertexBuffers[e];return!!t&&t.isUpdatable()},t.prototype.getVertexBuffer=function(e){return this.isReady()?this._vertexBuffers[e]:null},t.prototype.getVertexBuffers=function(){return this.isReady()?this._vertexBuffers:null},t.prototype.isVerticesDataPresent=function(e){return this._vertexBuffers?void 0!==this._vertexBuffers[e]:!!this._delayInfo&&-1!==this._delayInfo.indexOf(e)},t.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},t.prototype.updateIndices=function(e,t){this._indexBuffer&&(this._indexBufferIsUpdatable?this._engine.updateDynamicIndexBuffer(this._indexBuffer,e,t):this.setIndices(e,null,!0))},t.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)),void 0!=t&&(this._totalVertices=t);for(var r=this._meshes,n=r.length,o=0;o<n;o++)r[o]._createGlobalSubMesh(!0);this.notifyUpdate()},t.prototype.getTotalIndices=function(){return this.isReady()?this._indices.length:0},t.prototype.getIndices=function(e){if(!this.isReady())return null;var t=this._indices;if(e&&1!==this._meshes.length){for(var i=t.length,r=[],n=0;n<i;n++)r.push(t[n]);return r}return t},t.prototype.getIndexBuffer=function(){return this.isReady()?this._indexBuffer:null},t.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])},t.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())},t.prototype.applyToMesh=function(e){if(e._geometry!==this){var t=e._geometry;t&&t.releaseForMesh(e);var i=this._meshes;e._geometry=this,this._scene.pushGeometry(this),i.push(e),this.isReady()?this._applyToMesh(e):e._boundingInfo=this._boundingInfo}},t.prototype._updateExtend=function(t){void 0===t&&(t=null),t||(t=this.getVerticesData(e.VertexBuffer.PositionKind)),this._extend=e.Tools.ExtractMinAndMax(t,0,this._totalVertices,this.boundingBias,3)},t.prototype._applyToMesh=function(t){var i=this._meshes.length;for(var r in this._vertexBuffers){1===i&&this._vertexBuffers[r].create();var n=this._vertexBuffers[r].getBuffer();n&&(n.references=i),r===e.VertexBuffer.PositionKind&&(this._extend||this._updateExtend(),t._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),t._createGlobalSubMesh(!1),t._updateBoundingInfo())}1===i&&this._indices&&this._indices.length>0&&(this._indexBuffer=this._engine.createIndexBuffer(this._indices)),this._indexBuffer&&(this._indexBuffer.references=i)},t.prototype.notifyUpdate=function(e){this.onGeometryUpdated&&this.onGeometryUpdated(this,e);for(var t=0,i=this._meshes;t<i.length;t++){i[t]._markSubMeshesAsAttributesDirty()}},t.prototype.load=function(t,i){if(this.delayLoadState!==e.Engine.DELAYLOADSTATE_LOADING){if(this.isReady())return void(i&&i());this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADING,this._queueLoad(t,i)}},t.prototype._queueLoad=function(t,i){var r=this;this.delayLoadingFile&&(t._addPendingData(this),t._loadFile(this.delayLoadingFile,(function(n){if(r._delayLoadingFunction){r._delayLoadingFunction(JSON.parse(n),r),r.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,r._delayInfo=[],t._removePendingData(r);for(var o=r._meshes,s=o.length,a=0;a<s;a++)r._applyToMesh(o[a]);i&&i()}}),void 0,!0))},t.prototype.toLeftHanded=function(){var t=this.getIndices(!1);if(null!=t&&t.length>0){for(var i=0;i<t.length;i+=3){var r=t[i+0];t[i+0]=t[i+2],t[i+2]=r}this.setIndices(t)}var n=this.getVerticesData(e.VertexBuffer.PositionKind,!1);if(null!=n&&n.length>0){for(var i=0;i<n.length;i+=3)n[i+2]=-n[i+2];this.setVerticesData(e.VertexBuffer.PositionKind,n,!1)}var o=this.getVerticesData(e.VertexBuffer.NormalKind,!1);if(null!=o&&o.length>0){for(var i=0;i<o.length;i+=3)o[i+2]=-o[i+2];this.setVerticesData(e.VertexBuffer.NormalKind,o,!1)}},t.prototype._resetPointsArrayCache=function(){this._positions=null},t.prototype._generatePointsArray=function(){if(this._positions)return!0;this._positions=[];var t=this.getVerticesData(e.VertexBuffer.PositionKind);if(!t)return!1;for(var i=0;i<t.length;i+=3)this._positions.push(e.Vector3.FromArray(t,i));return!0},t.prototype.isDisposed=function(){return this._isDisposed},t.prototype._disposeVertexArrayObjects=function(){if(this._vertexArrayObjects){for(var e in this._vertexArrayObjects)this._engine.releaseVertexArrayObject(this._vertexArrayObjects[e]);this._vertexArrayObjects={}}},t.prototype.dispose=function(){var t,i=this._meshes,r=i.length;for(t=0;t<r;t++)this.releaseForMesh(i[t]);this._meshes=[],this._disposeVertexArrayObjects();for(var n in this._vertexBuffers)this._vertexBuffers[n].dispose();this._vertexBuffers={},this._totalVertices=0,this._indexBuffer&&this._engine._releaseBuffer(this._indexBuffer),this._indexBuffer=null,this._indices=[],this.delayLoadState=e.Engine.DELAYLOADSTATE_NONE,this.delayLoadingFile=null,this._delayLoadingFunction=null,this._delayInfo=[],this._boundingInfo=null,this._scene.removeGeometry(this),this._isDisposed=!0},t.prototype.copy=function(i){var r=new e.VertexData;r.indices=[];var n=this.getIndices();if(n)for(var o=0;o<n.length;o++)r.indices.push(n[o]);var s,a=!1,l=!1;for(s in this._vertexBuffers){var h=this.getVerticesData(s);if(h instanceof Float32Array?r.set(new Float32Array(h),s):r.set(h.slice(0),s),!l){var c=this.getVertexBuffer(s);c&&(a=c.isUpdatable(),l=!a)}}var u=new t(i,this._scene,r,a);u.delayLoadState=this.delayLoadState,u.delayLoadingFile=this.delayLoadingFile,u._delayLoadingFunction=this._delayLoadingFunction;for(s in this._delayInfo)u._delayInfo=u._delayInfo||[],u._delayInfo.push(s);return u._boundingInfo=new e.BoundingInfo(this._extend.minimum,this._extend.maximum),u},t.prototype.serialize=function(){var t={};return t.id=this.id,t.updatable=this._updatable,e.Tags&&e.Tags.HasTags(this)&&(t.tags=e.Tags.GetTags(this)),t},t.prototype.toNumberArray=function(e){return Array.isArray(e)?e:Array.prototype.slice.call(e)},t.prototype.serializeVerticeData=function(){var t=this.serialize();return this.isVerticesDataPresent(e.VertexBuffer.PositionKind)&&(t.positions=this.toNumberArray(this.getVerticesData(e.VertexBuffer.PositionKind)),this.isVertexBufferUpdatable(e.VertexBuffer.PositionKind)&&(t.positions._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.NormalKind)&&(t.normals=this.toNumberArray(this.getVerticesData(e.VertexBuffer.NormalKind)),this.isVertexBufferUpdatable(e.VertexBuffer.NormalKind)&&(t.normals._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(t.tangets=this.toNumberArray(this.getVerticesData(e.VertexBuffer.TangentKind)),this.isVertexBufferUpdatable(e.VertexBuffer.TangentKind)&&(t.tangets._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UVKind)&&(t.uvs=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UVKind)),this.isVertexBufferUpdatable(e.VertexBuffer.UVKind)&&(t.uvs._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV2Kind)&&(t.uv2s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV2Kind)),this.isVertexBufferUpdatable(e.VertexBuffer.UV2Kind)&&(t.uv2s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV3Kind)&&(t.uv3s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV3Kind)),this.isVertexBufferUpdatable(e.VertexBuffer.UV3Kind)&&(t.uv3s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV4Kind)&&(t.uv4s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV4Kind)),this.isVertexBufferUpdatable(e.VertexBuffer.UV4Kind)&&(t.uv4s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV5Kind)&&(t.uv5s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV5Kind)),this.isVertexBufferUpdatable(e.VertexBuffer.UV5Kind)&&(t.uv5s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.UV6Kind)&&(t.uv6s=this.toNumberArray(this.getVerticesData(e.VertexBuffer.UV6Kind)),this.isVertexBufferUpdatable(e.VertexBuffer.UV6Kind)&&(t.uv6s._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.ColorKind)&&(t.colors=this.toNumberArray(this.getVerticesData(e.VertexBuffer.ColorKind)),this.isVertexBufferUpdatable(e.VertexBuffer.ColorKind)&&(t.colors._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.MatricesIndicesKind)&&(t.matricesIndices=this.toNumberArray(this.getVerticesData(e.VertexBuffer.MatricesIndicesKind)),t.matricesIndices._isExpanded=!0,this.isVertexBufferUpdatable(e.VertexBuffer.MatricesIndicesKind)&&(t.matricesIndices._updatable=!0)),this.isVerticesDataPresent(e.VertexBuffer.MatricesWeightsKind)&&(t.matricesWeights=this.toNumberArray(this.getVerticesData(e.VertexBuffer.MatricesWeightsKind)),this.isVertexBufferUpdatable(e.VertexBuffer.MatricesWeightsKind)&&(t.matricesWeights._updatable=!0)),t.indices=this.toNumberArray(this.getIndices()),t},t.ExtractFromMesh=function(e,t){var i=e._geometry;return i?i.copy(t):null},t.RandomId=function(){return e.Tools.RandomId()},t._ImportGeometry=function(i,r){var n=r.getScene(),o=i.geometryId;if(o){var s=n.getGeometryByID(o);s&&s.applyToMesh(r)}else if(i instanceof ArrayBuffer){var a=r._binaryInfo;if(a.positionsAttrDesc&&a.positionsAttrDesc.count>0){var l=new Float32Array(i,a.positionsAttrDesc.offset,a.positionsAttrDesc.count);r.setVerticesData(e.VertexBuffer.PositionKind,l,!1)}if(a.normalsAttrDesc&&a.normalsAttrDesc.count>0){var h=new Float32Array(i,a.normalsAttrDesc.offset,a.normalsAttrDesc.count);r.setVerticesData(e.VertexBuffer.NormalKind,h,!1)}if(a.tangetsAttrDesc&&a.tangetsAttrDesc.count>0){var c=new Float32Array(i,a.tangetsAttrDesc.offset,a.tangetsAttrDesc.count);r.setVerticesData(e.VertexBuffer.TangentKind,c,!1)}if(a.uvsAttrDesc&&a.uvsAttrDesc.count>0){var u=new Float32Array(i,a.uvsAttrDesc.offset,a.uvsAttrDesc.count);r.setVerticesData(e.VertexBuffer.UVKind,u,!1)}if(a.uvs2AttrDesc&&a.uvs2AttrDesc.count>0){var f=new Float32Array(i,a.uvs2AttrDesc.offset,a.uvs2AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV2Kind,f,!1)}if(a.uvs3AttrDesc&&a.uvs3AttrDesc.count>0){var p=new Float32Array(i,a.uvs3AttrDesc.offset,a.uvs3AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV3Kind,p,!1)}if(a.uvs4AttrDesc&&a.uvs4AttrDesc.count>0){var d=new Float32Array(i,a.uvs4AttrDesc.offset,a.uvs4AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV4Kind,d,!1)}if(a.uvs5AttrDesc&&a.uvs5AttrDesc.count>0){var m=new Float32Array(i,a.uvs5AttrDesc.offset,a.uvs5AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV5Kind,m,!1)}if(a.uvs6AttrDesc&&a.uvs6AttrDesc.count>0){var _=new Float32Array(i,a.uvs6AttrDesc.offset,a.uvs6AttrDesc.count);r.setVerticesData(e.VertexBuffer.UV6Kind,_,!1)}if(a.colorsAttrDesc&&a.colorsAttrDesc.count>0){var g=new Float32Array(i,a.colorsAttrDesc.offset,a.colorsAttrDesc.count);r.setVerticesData(e.VertexBuffer.ColorKind,g,!1,a.colorsAttrDesc.stride)}if(a.matricesIndicesAttrDesc&&a.matricesIndicesAttrDesc.count>0){var v=new Int32Array(i,a.matricesIndicesAttrDesc.offset,a.matricesIndicesAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,v,!1)}if(a.matricesWeightsAttrDesc&&a.matricesWeightsAttrDesc.count>0){var y=new Float32Array(i,a.matricesWeightsAttrDesc.offset,a.matricesWeightsAttrDesc.count);r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,y,!1)}if(a.indicesAttrDesc&&a.indicesAttrDesc.count>0){var b=new Int32Array(i,a.indicesAttrDesc.offset,a.indicesAttrDesc.count);r.setIndices(b,null)}if(a.subMeshesAttrDesc&&a.subMeshesAttrDesc.count>0){var x=new Int32Array(i,a.subMeshesAttrDesc.offset,5*a.subMeshesAttrDesc.count);r.subMeshes=[];for(var T=0;T<a.subMeshesAttrDesc.count;T++){var E=x[5*T+0],P=x[5*T+1],A=x[5*T+2],M=x[5*T+3],S=x[5*T+4];e.SubMesh.AddToMesh(E,P,A,M,S,r)}}}else if(i.positions&&i.normals&&i.indices){if(r.setVerticesData(e.VertexBuffer.PositionKind,i.positions,i.positions._updatable),r.setVerticesData(e.VertexBuffer.NormalKind,i.normals,i.normals._updatable),i.tangents&&r.setVerticesData(e.VertexBuffer.TangentKind,i.tangents,i.tangents._updatable),i.uvs&&r.setVerticesData(e.VertexBuffer.UVKind,i.uvs,i.uvs._updatable),i.uvs2&&r.setVerticesData(e.VertexBuffer.UV2Kind,i.uvs2,i.uvs2._updatable),i.uvs3&&r.setVerticesData(e.VertexBuffer.UV3Kind,i.uvs3,i.uvs3._updatable),i.uvs4&&r.setVerticesData(e.VertexBuffer.UV4Kind,i.uvs4,i.uvs4._updatable),i.uvs5&&r.setVerticesData(e.VertexBuffer.UV5Kind,i.uvs5,i.uvs5._updatable),i.uvs6&&r.setVerticesData(e.VertexBuffer.UV6Kind,i.uvs6,i.uvs6._updatable),i.colors&&r.setVerticesData(e.VertexBuffer.ColorKind,e.Color4.CheckColors4(i.colors,i.positions.length/3),i.colors._updatable),i.matricesIndices)if(i.matricesIndices._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,i.matricesIndices,i.matricesIndices._updatable);else{for(var C=[],T=0;T<i.matricesIndices.length;T++){var R=i.matricesIndices[T];C.push(255&R),C.push((65280&R)>>8),C.push((16711680&R)>>16),C.push(R>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesKind,C,i.matricesIndices._updatable)}if(i.matricesIndicesExtra)if(i.matricesIndicesExtra._isExpanded)delete i.matricesIndices._isExpanded,r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,i.matricesIndicesExtra,i.matricesIndicesExtra._updatable);else{for(var C=[],T=0;T<i.matricesIndicesExtra.length;T++){var R=i.matricesIndicesExtra[T];C.push(255&R),C.push((65280&R)>>8),C.push((16711680&R)>>16),C.push(R>>24)}r.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,C,i.matricesIndicesExtra._updatable)}i.matricesWeights&&(t._CleanMatricesWeights(i,r),r.setVerticesData(e.VertexBuffer.MatricesWeightsKind,i.matricesWeights,i.matricesWeights._updatable)),i.matricesWeightsExtra&&r.setVerticesData(e.VertexBuffer.MatricesWeightsExtraKind,i.matricesWeightsExtra,i.matricesWeights._updatable),r.setIndices(i.indices,null)}if(i.subMeshes){r.subMeshes=[];for(var O=0;O<i.subMeshes.length;O++){var I=i.subMeshes[O];e.SubMesh.AddToMesh(I.materialIndex,I.verticesStart,I.verticesCount,I.indexStart,I.indexCount,r)}}r._shouldGenerateFlatShading&&(r.convertToFlatShadedMesh(),delete r._shouldGenerateFlatShading),r.computeWorldMatrix(!0);var D=n.selectionOctree;void 0!==D&&null!==D&&D.addMesh(r)},t._CleanMatricesWeights=function(t,i){if(e.SceneLoader.CleanBoneMatrixWeights){var r=0;if(t.skeletonId>-1){var n=i.getScene().getLastSkeletonByID(t.skeletonId);if(n){r=n.bones.length;for(var o=i.getVerticesData(e.VertexBuffer.MatricesIndicesKind),s=i.getVerticesData(e.VertexBuffer.MatricesIndicesExtraKind),a=t.matricesWeights,l=t.matricesWeightsExtra,h=t.numBoneInfluencer,c=a.length,u=0;u<c;u+=4){for(var f=0,p=-1,d=0;d<4;d++){var m=a[u+d];f+=m,m<.001&&p<0&&(p=d)}if(l)for(var d=0;d<4;d++){var m=l[u+d];f+=m,m<.001&&p<0&&(p=d+4)}if((p<0||p>h-1)&&(p=h-1),f>.001){for(var _=1/f,d=0;d<4;d++)a[u+d]*=_;if(l)for(var d=0;d<4;d++)l[u+d]*=_}else p>=4?(l[u+p-4]=1-f,s[u+p-4]=r):(a[u+p]=1-f,o[u+p]=r)}i.setVerticesData(e.VertexBuffer.MatricesIndicesKind,o),t.matricesWeightsExtra&&i.setVerticesData(e.VertexBuffer.MatricesIndicesExtraKind,s)}}}},t.Parse=function(i,r,n){if(r.getGeometryByID(i.id))return null;var o=new t(i.id,r,void 0,i.updatable);return e.Tags&&e.Tags.AddTagsTo(o,i.tags),i.delayLoadingFile?(o.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED,o.delayLoadingFile=n+i.delayLoadingFile,o._boundingInfo=new e.BoundingInfo(e.Vector3.FromArray(i.boundingBoxMinimum),e.Vector3.FromArray(i.boundingBoxMaximum)),o._delayInfo=[],i.hasUVs&&o._delayInfo.push(e.VertexBuffer.UVKind),i.hasUVs2&&o._delayInfo.push(e.VertexBuffer.UV2Kind),i.hasUVs3&&o._delayInfo.push(e.VertexBuffer.UV3Kind),i.hasUVs4&&o._delayInfo.push(e.VertexBuffer.UV4Kind),i.hasUVs5&&o._delayInfo.push(e.VertexBuffer.UV5Kind),i.hasUVs6&&o._delayInfo.push(e.VertexBuffer.UV6Kind),
i.hasColors&&o._delayInfo.push(e.VertexBuffer.ColorKind),i.hasMatricesIndices&&o._delayInfo.push(e.VertexBuffer.MatricesIndicesKind),i.hasMatricesWeights&&o._delayInfo.push(e.VertexBuffer.MatricesWeightsKind),o._delayLoadingFunction=e.VertexData.ImportVertexData):e.VertexData.ImportVertexData(i,o),r.pushGeometry(o,!0),o},t})();e.Geometry=t;var i=(function(e){function t(t,i,r,n){void 0===r&&(r=!1),void 0===n&&(n=null);var o=e.call(this,t,i,void 0,!1,n)||this;return o._canBeRegenerated=r,o._beingRegenerated=!0,o.regenerate(),o._beingRegenerated=!1,o}return o(t,e),t.prototype.canBeRegenerated=function(){return this._canBeRegenerated},t.prototype.regenerate=function(){this._canBeRegenerated&&(this._beingRegenerated=!0,this.setAllVerticesData(this._regenerateVertexData(),!1),this._beingRegenerated=!1)},t.prototype.asNewGeometry=function(t){return e.prototype.copy.call(this,t)},t.prototype.setAllVerticesData=function(t,i){this._beingRegenerated&&e.prototype.setAllVerticesData.call(this,t,!1)},t.prototype.setVerticesData=function(t,i,r){this._beingRegenerated&&e.prototype.setVerticesData.call(this,t,i,!1)},t.prototype._regenerateVertexData=function(){throw new Error("Abstract method")},t.prototype.copy=function(e){throw new Error("Must be overriden in sub-classes.")},t.prototype.serialize=function(){var t=e.prototype.serialize.call(this);return t.canBeRegenerated=this.canBeRegenerated(),t},t})(t);e._PrimitiveGeometry=i;var r=(function(t){function i(i,r,n,o,s,a,l,h,c){void 0===c&&(c=e.Mesh.DEFAULTSIDE);var u=t.call(this,i,r,l,h)||this;return u.pathArray=n,u.closeArray=o,u.closePath=s,u.offset=a,u.side=c,u}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateRibbon({pathArray:this.pathArray,closeArray:this.closeArray,closePath:this.closePath,offset:this.offset,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.pathArray,this.closeArray,this.closePath,this.offset,this.canBeRegenerated(),void 0,this.side)},i})(i);e.RibbonGeometry=r;var n=(function(t){function i(i,r,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=t.call(this,i,r,o,s)||this;return l.size=n,l.side=a,l}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateBox({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),void 0,this.side)},i.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(t,r){if(r.getGeometryByID(t.id))return null;var n=new i(t.id,r,t.size,t.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,t.tags),r.pushGeometry(n,!0),n},i})(i);e.BoxGeometry=n;var s=(function(t){function i(i,r,n,o,s,a,l){void 0===a&&(a=null),void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=t.call(this,i,r,s,a)||this;return h.segments=n,h.diameter=o,h.side=l,h}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateSphere({segments:this.segments,diameter:this.diameter,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.segments,this.diameter,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.segments=this.segments,e.diameter=this.diameter,e},i.Parse=function(t,r){if(r.getGeometryByID(t.id))return null;var n=new i(t.id,r,t.segments,t.diameter,t.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,t.tags),r.pushGeometry(n,!0),n},i})(i);e.SphereGeometry=s;var a=(function(t){function i(i,r,n,o,s,a,l){void 0===a&&(a=null),void 0===l&&(l=e.Mesh.DEFAULTSIDE);var h=t.call(this,i,r,s,a)||this;return h.radius=n,h.tessellation=o,h.side=l,h}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateDisc({radius:this.radius,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tessellation,this.canBeRegenerated(),null,this.side)},i})(i);e.DiscGeometry=a;var l=(function(t){function i(i,r,n,o,s,a,l,h,c,u){void 0===l&&(l=1),void 0===c&&(c=null),void 0===u&&(u=e.Mesh.DEFAULTSIDE);var f=t.call(this,i,r,h,c)||this;return f.height=n,f.diameterTop=o,f.diameterBottom=s,f.tessellation=a,f.subdivisions=l,f.side=u,f}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateCylinder({height:this.height,diameterTop:this.diameterTop,diameterBottom:this.diameterBottom,tessellation:this.tessellation,subdivisions:this.subdivisions,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.height,this.diameterTop,this.diameterBottom,this.tessellation,this.subdivisions,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.height=this.height,e.diameterTop=this.diameterTop,e.diameterBottom=this.diameterBottom,e.tessellation=this.tessellation,e},i.Parse=function(t,r){if(r.getGeometryByID(t.id))return null;var n=new i(t.id,r,t.height,t.diameterTop,t.diameterBottom,t.tessellation,t.subdivisions,t.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,t.tags),r.pushGeometry(n,!0),n},i})(i);e.CylinderGeometry=l;var h=(function(t){function i(i,r,n,o,s,a,l,h){void 0===l&&(l=null),void 0===h&&(h=e.Mesh.DEFAULTSIDE);var c=t.call(this,i,r,a,l)||this;return c.diameter=n,c.thickness=o,c.tessellation=s,c.side=h,c}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorus({diameter:this.diameter,thickness:this.thickness,tessellation:this.tessellation,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.diameter,this.thickness,this.tessellation,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.diameter=this.diameter,e.thickness=this.thickness,e.tessellation=this.tessellation,e},i.Parse=function(t,r){if(r.getGeometryByID(t.id))return null;var n=new i(t.id,r,t.diameter,t.thickness,t.tessellation,t.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,t.tags),r.pushGeometry(n,!0),n},i})(i);e.TorusGeometry=h;var c=(function(t){function i(e,i,r,n,o,s,a){void 0===a&&(a=null);var l=t.call(this,e,i,s,a)||this;return l.width=r,l.height=n,l.subdivisions=o,l}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateGround({width:this.width,height:this.height,subdivisions:this.subdivisions})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.width,this.height,this.subdivisions,this.canBeRegenerated(),null)},i.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.width=this.width,e.height=this.height,e.subdivisions=this.subdivisions,e},i.Parse=function(t,r){if(r.getGeometryByID(t.id))return null;var n=new i(t.id,r,t.width,t.height,t.subdivisions,t.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,t.tags),r.pushGeometry(n,!0),n},i})(i);e.GroundGeometry=c;var u=(function(t){function i(e,i,r,n,o,s,a,l,h,c){void 0===c&&(c=null);var u=t.call(this,e,i,h,c)||this;return u.xmin=r,u.zmin=n,u.xmax=o,u.zmax=s,u.subdivisions=a,u.precision=l,u}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTiledGround({xmin:this.xmin,zmin:this.zmin,xmax:this.xmax,zmax:this.zmax,subdivisions:this.subdivisions,precision:this.precision})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.xmin,this.zmin,this.xmax,this.zmax,this.subdivisions,this.precision,this.canBeRegenerated(),null)},i})(i);e.TiledGroundGeometry=u;var f=(function(t){function i(i,r,n,o,s,a){void 0===s&&(s=null),void 0===a&&(a=e.Mesh.DEFAULTSIDE);var l=t.call(this,i,r,o,s)||this;return l.size=n,l.side=a,l}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreatePlane({size:this.size,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.size,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.size=this.size,e},i.Parse=function(t,r){if(r.getGeometryByID(t.id))return null;var n=new i(t.id,r,t.size,t.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,t.tags),r.pushGeometry(n,!0),n},i})(i);e.PlaneGeometry=f;var p=(function(t){function i(i,r,n,o,s,a,l,h,c,u,f){void 0===u&&(u=null),void 0===f&&(f=e.Mesh.DEFAULTSIDE);var p=t.call(this,i,r,c,u)||this;return p.radius=n,p.tube=o,p.radialSegments=s,p.tubularSegments=a,p.p=l,p.q=h,p.side=f,p}return o(i,t),i.prototype._regenerateVertexData=function(){return e.VertexData.CreateTorusKnot({radius:this.radius,tube:this.tube,radialSegments:this.radialSegments,tubularSegments:this.tubularSegments,p:this.p,q:this.q,sideOrientation:this.side})},i.prototype.copy=function(e){return new i(e,this.getScene(),this.radius,this.tube,this.radialSegments,this.tubularSegments,this.p,this.q,this.canBeRegenerated(),null,this.side)},i.prototype.serialize=function(){var e=t.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},i.Parse=function(t,r){if(r.getGeometryByID(t.id))return null;var n=new i(t.id,r,t.radius,t.tube,t.radialSegments,t.tubularSegments,t.p,t.q,t.canBeRegenerated,null);return e.Tags&&e.Tags.AddTagsTo(n,t.tags),r.pushGeometry(n,!0),n},i})(i);e.TorusKnotGeometry=p})(r||(r={}));var r;!(function(e){var t=(function(){function t(e){this._vertexBuffers={},this._scene=e}return t.prototype._prepareBuffers=function(){if(!this._vertexBuffers[e.VertexBuffer.PositionKind]){var t=[];t.push(1,1),t.push(-1,1),t.push(-1,-1),t.push(1,-1),this._vertexBuffers[e.VertexBuffer.PositionKind]=new e.VertexBuffer(this._scene.getEngine(),t,e.VertexBuffer.PositionKind,!1,!1,2),this._buildIndexBuffer()}},t.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)},t.prototype._rebuild=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t._rebuild(),this._buildIndexBuffer())},t.prototype._prepareFrame=function(e,t){void 0===e&&(e=null),void 0===t&&(t=null);var i=this._scene.activeCamera;if(!i)return!1;var t=t||i._postProcesses.filter((function(e){return null!=e}));return!(!t||0===t.length||!this._scene.postProcessesEnabled)&&(t[0].activate(i,e,null!==t&&void 0!==t),!0)},t.prototype.directRender=function(t,i,r){void 0===i&&(i=null),void 0===r&&(r=!1);for(var n=this._scene.getEngine(),o=0;o<t.length;o++){o<t.length-1?t[o+1].activate(this._scene.activeCamera,i):i?n.bindFramebuffer(i,0,void 0,void 0,r):n.restoreDefaultFramebuffer();var s=t[o],a=s.apply();a&&(s.onBeforeRenderObservable.notifyObservers(a),this._prepareBuffers(),n.bindBuffers(this._vertexBuffers,this._indexBuffer,a),n.drawElementsType(e.Material.TriangleFillMode,0,6),s.onAfterRenderObservable.notifyObservers(a))}n.setDepthBuffer(!0),n.setDepthWrite(!0)},t.prototype._finalizeFrame=function(t,i,r,n,o){void 0===o&&(o=!1);var s=this._scene.activeCamera;if(s&&(n=n||s._postProcesses.filter((function(e){return null!=e})),0!==n.length&&this._scene.postProcessesEnabled)){for(var a=this._scene.getEngine(),l=0,h=n.length;l<h;l++){var c=n[l];if(l<h-1?c._outputTexture=n[l+1].activate(s,i):i?(a.bindFramebuffer(i,r,void 0,void 0,o),c._outputTexture=i):(a.restoreDefaultFramebuffer(),c._outputTexture=null),t)break;var u=c.apply();u&&(c.onBeforeRenderObservable.notifyObservers(u),this._prepareBuffers(),a.bindBuffers(this._vertexBuffers,this._indexBuffer,u),a.drawElementsType(e.Material.TriangleFillMode,0,6),c.onAfterRenderObservable.notifyObservers(u))}a.setDepthBuffer(!0),a.setDepthWrite(!0),a.setAlphaMode(e.Engine.ALPHA_DISABLE)}},t.prototype.dispose=function(){var t=this._vertexBuffers[e.VertexBuffer.PositionKind];t&&(t.dispose(),this._vertexBuffers[e.VertexBuffer.PositionKind]=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null)},t})();e.PostProcessManager=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(e){void 0===e&&(e=30),this._enabled=!0,this._rollingFrameTime=new i(e)}return t.prototype.sampleFrame=function(t){if(void 0===t&&(t=e.Tools.Now),this._enabled){if(null!=this._lastFrameTimeMs){var i=t-this._lastFrameTimeMs;this._rollingFrameTime.add(i)}this._lastFrameTimeMs=t}},Object.defineProperty(t.prototype,"averageFrameTime",{get:function(){return this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"averageFrameTimeVariance",{get:function(){return this._rollingFrameTime.variance},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"instantaneousFrameTime",{get:function(){return this._rollingFrameTime.history(0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"averageFPS",{get:function(){return 1e3/this._rollingFrameTime.average},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"instantaneousFPS",{get:function(){var e=this._rollingFrameTime.history(0);return 0===e?0:1e3/e},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isSaturated",{get:function(){return this._rollingFrameTime.isSaturated()},enumerable:!0,configurable:!0}),t.prototype.enable=function(){this._enabled=!0},t.prototype.disable=function(){this._enabled=!1,this._lastFrameTimeMs=null},Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._enabled},enumerable:!0,configurable:!0}),t.prototype.reset=function(){this._lastFrameTimeMs=null,this._rollingFrameTime.reset()},t})();e.PerformanceMonitor=t;var i=(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})();e.RollingAverage=i})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this.colorCurves=new e.ColorCurves,this._colorCurvesEnabled=!1,this._colorGradingEnabled=!1,this._colorGradingWithGreenDepth=!0,this._colorGradingBGR=!0,this._exposure=1,this._toneMappingEnabled=!1,this._contrast=1,this.vignetteStretch=0,this.vignetteCentreX=0,this.vignetteCentreY=0,this.vignetteWeight=1.5,this.vignetteColor=new e.Color4(0,0,0,0),this.vignetteCameraFov=.5,this._vignetteBlendMode=t.VIGNETTEMODE_MULTIPLY,this._vignetteEnabled=!1,this._applyByPostProcess=!1,this._isEnabled=!0,this.onUpdateParameters=new e.Observable}return Object.defineProperty(t.prototype,"colorCurvesEnabled",{get:function(){return this._colorCurvesEnabled},set:function(e){this._colorCurvesEnabled!==e&&(this._colorCurvesEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingEnabled",{get:function(){return this._colorGradingEnabled},set:function(e){this._colorGradingEnabled!==e&&(this._colorGradingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingWithGreenDepth",{get:function(){return this._colorGradingWithGreenDepth},set:function(e){this._colorGradingWithGreenDepth!==e&&(this._colorGradingWithGreenDepth=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"colorGradingBGR",{get:function(){return this._colorGradingBGR},set:function(e){this._colorGradingBGR!==e&&(this._colorGradingBGR=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"exposure",{get:function(){return this._exposure},set:function(e){this._exposure!==e&&(this._exposure=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"toneMappingEnabled",{get:function(){return this._toneMappingEnabled},set:function(e){this._toneMappingEnabled!==e&&(this._toneMappingEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"contrast",{get:function(){return this._contrast},set:function(e){this._contrast!==e&&(this._contrast=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteBlendMode",{get:function(){return this._vignetteBlendMode},set:function(e){this._vignetteBlendMode!==e&&(this._vignetteBlendMode=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"vignetteEnabled",{get:function(){return this._vignetteEnabled},set:function(e){this._vignetteEnabled!==e&&(this._vignetteEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"applyByPostProcess",{get:function(){return this._applyByPostProcess},set:function(e){this._applyByPostProcess!==e&&(this._applyByPostProcess=e,this._updateParameters())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isEnabled",{get:function(){return this._isEnabled},set:function(e){this._isEnabled!==e&&(this._isEnabled=e,this._updateParameters())},enumerable:!0,configurable:!0}),t.prototype._updateParameters=function(){this.onUpdateParameters.notifyObservers(this)},t.prototype.getClassName=function(){return"ImageProcessingConfiguration"},t.PrepareUniforms=function(t,i){i.EXPOSURE&&t.push("exposureLinear"),i.CONTRAST&&t.push("contrast"),i.COLORGRADING&&t.push("colorTransformSettings"),i.VIGNETTE&&(t.push("vInverseScreenSize"),t.push("vignetteSettings1"),t.push("vignetteSettings2")),i.COLORCURVES&&e.ColorCurves.PrepareUniforms(t)},t.PrepareSamplers=function(e,t){t.COLORGRADING&&e.push("txColorTransform")},t.prototype.prepareDefines=function(e,i){if(void 0===i&&(i=!1),i!==this.applyByPostProcess||!this._isEnabled)return e.VIGNETTE=!1,e.TONEMAPPING=!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);e.VIGNETTE=this.vignetteEnabled,e.VIGNETTEBLENDMODEMULTIPLY=this.vignetteBlendMode===t._VIGNETTEMODE_MULTIPLY,e.VIGNETTEBLENDMODEOPAQUE=!e.VIGNETTEBLENDMODEMULTIPLY,e.TONEMAPPING=this.toneMappingEnabled,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},t.prototype.isReady=function(){return!this.colorGradingEnabled||!this.colorGradingTexture||this.colorGradingTexture.isReady()},t.prototype.bind=function(t,i){if(void 0===i&&(i=1),this._colorCurvesEnabled&&this.colorCurves&&e.ColorCurves.Bind(this.colorCurves,t),this._vignetteEnabled){var r=1/t.getEngine().getRenderWidth(),n=1/t.getEngine().getRenderHeight();t.setFloat2("vInverseScreenSize",r,n);var o=Math.tan(.5*this.vignetteCameraFov),s=o*i,a=Math.sqrt(s*o);s=e.Tools.Mix(s,a,this.vignetteStretch),o=e.Tools.Mix(o,a,this.vignetteStretch),t.setFloat4("vignetteSettings1",s,o,-s*this.vignetteCentreX,-o*this.vignetteCentreY);var l=-2*this.vignetteWeight;t.setFloat4("vignetteSettings2",this.vignetteColor.r,this.vignetteColor.g,this.vignetteColor.b,l)}if(t.setFloat("exposureLinear",this.exposure),t.setFloat("contrast",this.contrast),this.colorGradingTexture){t.setTexture("txColorTransform",this.colorGradingTexture);var h=this.colorGradingTexture.getSize().height;t.setFloat4("colorTransformSettings",(h-1)/h,.5/h,h,this.colorGradingTexture.level)}},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},Object.defineProperty(t,"VIGNETTEMODE_MULTIPLY",{get:function(){return this._VIGNETTEMODE_MULTIPLY},enumerable:!0,configurable:!0}),Object.defineProperty(t,"VIGNETTEMODE_OPAQUE",{get:function(){return this._VIGNETTEMODE_OPAQUE},enumerable:!0,configurable:!0}),t._VIGNETTEMODE_MULTIPLY=0,t._VIGNETTEMODE_OPAQUE=1,n([e.serializeAsColorCurves()],t.prototype,"colorCurves",void 0),n([e.serialize()],t.prototype,"_colorCurvesEnabled",void 0),n([e.serializeAsTexture()],t.prototype,"colorGradingTexture",void 0),n([e.serialize()],t.prototype,"_colorGradingEnabled",void 0),n([e.serialize()],t.prototype,"_colorGradingWithGreenDepth",void 0),n([e.serialize()],t.prototype,"_colorGradingBGR",void 0),n([e.serialize()],t.prototype,"_exposure",void 0),n([e.serialize()],t.prototype,"_toneMappingEnabled",void 0),n([e.serialize()],t.prototype,"_contrast",void 0),n([e.serialize()],t.prototype,"vignetteStretch",void 0),n([e.serialize()],t.prototype,"vignetteCentreX",void 0),n([e.serialize()],t.prototype,"vignetteCentreY",void 0),n([e.serialize()],t.prototype,"vignetteWeight",void 0),n([e.serializeAsColor4()],t.prototype,"vignetteColor",void 0),n([e.serialize()],t.prototype,"vignetteCameraFov",void 0),n([e.serialize()],t.prototype,"_vignetteBlendMode",void 0),n([e.serialize()],t.prototype,"_vignetteEnabled",void 0),n([e.serialize()],t.prototype,"_applyByPostProcess",void 0),n([e.serialize()],t.prototype,"_isEnabled",void 0),t})();e.ImageProcessingConfiguration=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,r)||this;return i?(n._engine=r.getEngine(),n._textureMatrix=e.Matrix.Identity(),n.name=i,n.url=i,n.hasAlpha=!1,n.isCube=!1,n.is3D=n._engine.webGLVersion>1,n.wrapU=e.Texture.CLAMP_ADDRESSMODE,n.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.wrapR=e.Texture.CLAMP_ADDRESSMODE,n.anisotropicFilteringLevel=1,n._texture=n._getFromCache(i,!0),n._texture||(r.useDelayedTextureLoading?n.delayLoadState=e.Engine.DELAYLOADSTATE_NOTLOADED:n.loadTexture()),n):n}return o(i,t),i.prototype.getTextureMatrix=function(){return this._textureMatrix},i.prototype.load3dlTexture=function(){var t,r=this._engine;t=1===r.webGLVersion?r.createRawTexture(null,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE):r.createRawTexture3D(null,1,1,1,e.Engine.TEXTUREFORMAT_RGBA,!1,!1,e.Texture.BILINEAR_SAMPLINGMODE),this._texture=t;var n=function(n){if("string"==typeof n){for(var o,s=null,a=null,l=n.split("\n"),h=0,c=0,u=0,f=0,p=0,d=0;d<l.length;d++)if(o=l[d],i._noneEmptyLineRegex.test(o)&&0!==o.indexOf("#")){var m=o.split(" ");if(0!==h){if(0!=h){var _=Math.max(parseInt(m[0]),0),g=Math.max(parseInt(m[1]),0),v=Math.max(parseInt(m[2]),0);p=Math.max(_,p),p=Math.max(g,p),p=Math.max(v,p);var y=4*(c+f*h+u*h*h);a&&(a[y+0]=_,a[y+1]=g,a[y+2]=v),f++,f%h==0&&(u++,f=0,u%h==0&&(c++,u=0))}}else h=m.length,s=new Uint8Array(h*h*h*4),a=new Float32Array(h*h*h*4)}if(a&&s)for(var d=0;d<a.length;d++)if(d>0&&(d+1)%4==0)s[d]=255;else{var b=a[d];s[d]=b/p*255}t.is3D?(t.updateSize(h,h,h),r.updateRawTexture3D(t,s,e.Engine.TEXTUREFORMAT_RGBA,!1)):(t.updateSize(h*h,h),r.updateRawTexture(t,s,e.Engine.TEXTUREFORMAT_RGBA,!1))}},o=this.getScene();return o?o._loadFile(this.url,n):this._engine._loadFile(this.url,n),this._texture},i.prototype.loadTexture=function(){this.url&&this.url.toLocaleLowerCase().indexOf(".3dl")==this.url.length-4&&this.load3dlTexture()},i.prototype.clone=function(){var e=new i(this.url,this.getScene());return e.level=this.level,e},i.prototype.delayLoad=function(){this.delayLoadState===e.Engine.DELAYLOADSTATE_NOTLOADED&&(this.delayLoadState=e.Engine.DELAYLOADSTATE_LOADED,this._texture=this._getFromCache(this.url,!0),this._texture||this.loadTexture())},i.Parse=function(e,t,r){var n=null;return e.name&&!e.isRenderTarget&&(n=new i(e.name,t),n.name=e.name,n.level=e.level),n},i.prototype.serialize=function(){if(!this.name)return null;var e={};return e.name=this.name,e.level=this.level,e.customType="BABYLON.ColorGradingTexture",e},i._noneEmptyLineRegex=/\S+/,i})(e.BaseTexture);e.ColorGradingTexture=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this._dirty=!0,this._tempColor=new e.Color4(0,0,0,0),this._globalCurve=new e.Color4(0,0,0,0),this._highlightsCurve=new e.Color4(0,0,0,0),this._midtonesCurve=new e.Color4(0,0,0,0),this._shadowsCurve=new e.Color4(0,0,0,0),this._positiveCurve=new e.Color4(0,0,0,0),this._negativeCurve=new e.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(t.prototype,"globalHue",{get:function(){return this._globalHue},set:function(e){this._globalHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalDensity",{get:function(){return this._globalDensity},set:function(e){this._globalDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"globalSaturation",{get:function(){return this._globalSaturation},set:function(e){this._globalSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsHue",{get:function(){return this._highlightsHue},set:function(e){this._highlightsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsDensity",{get:function(){return this._highlightsDensity},set:function(e){this._highlightsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsSaturation",{get:function(){return this._highlightsSaturation},set:function(e){this._highlightsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"highlightsExposure",{get:function(){return this._highlightsExposure},set:function(e){this._highlightsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesHue",{get:function(){return this._midtonesHue},set:function(e){this._midtonesHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesDensity",{get:function(){return this._midtonesDensity},set:function(e){this._midtonesDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesSaturation",{get:function(){return this._midtonesSaturation},set:function(e){this._midtonesSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"midtonesExposure",{get:function(){return this._midtonesExposure},set:function(e){this._midtonesExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsHue",{get:function(){return this._shadowsHue},set:function(e){this._shadowsHue=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsDensity",{get:function(){return this._shadowsDensity},set:function(e){this._shadowsDensity=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsSaturation",{get:function(){return this._shadowsSaturation},set:function(e){this._shadowsSaturation=e,this._dirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"shadowsExposure",{get:function(){return this._shadowsExposure},set:function(e){this._shadowsExposure=e,this._dirty=!0},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ColorCurves"},t.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))},t.PrepareUniforms=function(e){e.push("vCameraColorCurveNeutral","vCameraColorCurvePositive","vCameraColorCurveNegative")},t.prototype.getColorGradingDataToRef=function(e,i,r,n,o){null!=e&&(e=t.clamp(e,0,360),i=t.clamp(i,-100,100),r=t.clamp(r,-100,100),n=t.clamp(n,-100,100),i=t.applyColorGradingSliderNonlinear(i),i*=.5,n=t.applyColorGradingSliderNonlinear(n),i<0&&(i*=-1,e=(e+180)%360),t.fromHSBToRef(e,i,50+.25*n,o),o.scaleToRef(2,o),o.a=1+.01*r)},t.applyColorGradingSliderNonlinear=function(e){e/=100;var t=Math.abs(e);return t=Math.pow(t,2),e<0&&(t*=-1),t*=100},t.fromHSBToRef=function(e,i,r,n){var o=t.clamp(e,0,360),s=t.clamp(i/100,0,1),a=t.clamp(r/100,0,1);if(0===s)n.r=a,n.g=a,n.b=a;else{o/=60;var l=Math.floor(o),h=o-l,c=a*(1-s),u=a*(1-s*h),f=a*(1-s*(1-h));switch(l){case 0:n.r=a,n.g=f,n.b=c;break;case 1:n.r=u,n.g=a,n.b=c;break;case 2:n.r=c,n.g=a,n.b=f;break;case 3:n.r=c,n.g=u,n.b=a;break;case 4:n.r=f,n.g=c,n.b=a;break;default:n.r=a,n.g=c,n.b=u}}n.a=1},t.clamp=function(e,t,i){return Math.min(Math.max(e,t),i)},t.prototype.clone=function(){return e.SerializationHelper.Clone((function(){return new t}),this)},t.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},t.Parse=function(i){return e.SerializationHelper.Parse((function(){return new t}),i,null,null)},n([e.serialize()],t.prototype,"_globalHue",void 0),n([e.serialize()],t.prototype,"_globalDensity",void 0),n([e.serialize()],t.prototype,"_globalSaturation",void 0),n([e.serialize()],t.prototype,"_globalExposure",void 0),n([e.serialize()],t.prototype,"_highlightsHue",void 0),n([e.serialize()],t.prototype,"_highlightsDensity",void 0),n([e.serialize()],t.prototype,"_highlightsSaturation",void 0),n([e.serialize()],t.prototype,"_highlightsExposure",void 0),n([e.serialize()],t.prototype,"_midtonesHue",void 0),n([e.serialize()],t.prototype,"_midtonesDensity",void 0),n([e.serialize()],t.prototype,"_midtonesSaturation",void 0),n([e.serialize()],t.prototype,"_midtonesExposure",void 0),t})();e.ColorCurves=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){}return t.BindEyePosition=function(e,t){if(t._forcedViewPosition)return void e.setVector3("vEyePosition",t._forcedViewPosition);e.setVector3("vEyePosition",t._mirroredCameraPosition?t._mirroredCameraPosition:t.activeCamera.globalPosition)},t.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},
t.BindTextureMatrix=function(e,t,i){var r=e.getTextureMatrix();r.isIdentity(!0)||t.updateMatrix(i+"Matrix",r)},t.PrepareDefinesForMisc=function(t,i,r,n,o,s,a){a._areMiscDirty&&(a.LOGARITHMICDEPTH=r,a.POINTSIZE=n,a.FOG=i.fogEnabled&&t.applyFog&&i.fogMode!==e.Scene.FOGMODE_NONE&&o,a.NONUNIFORMSCALING=t.nonUniformScaling,a.ALPHATEST=s)},t.PrepareDefinesForFrameBoundValues=function(e,t,i,r,n){void 0===n&&(n=null);var o=!1;null==n&&(n=void 0!==e.clipPlane&&null!==e.clipPlane),i.CLIPPLANE!==n&&(i.CLIPPLANE=n,o=!0),i.DEPTHPREPASS!==!t.getColorWrite()&&(i.DEPTHPREPASS=!i.DEPTHPREPASS,o=!0),i.INSTANCES!==r&&(i.INSTANCES=r,o=!0),o&&i.markAsUnprocessed()},t.PrepareDefinesForAttributes=function(t,i,r,n,o,s){if(void 0===o&&(o=!1),void 0===s&&(s=!0),!i._areAttributesDirty&&i._needNormals===i._normals&&i._needUVs===i._uvs)return!1;if(i._normals=i._needNormals,i._uvs=i._needUVs,i.NORMAL=i._needNormals&&t.isVerticesDataPresent(e.VertexBuffer.NormalKind),i._needNormals&&t.isVerticesDataPresent(e.VertexBuffer.TangentKind)&&(i.TANGENT=!0),i._needUVs?(i.UV1=t.isVerticesDataPresent(e.VertexBuffer.UVKind),i.UV2=t.isVerticesDataPresent(e.VertexBuffer.UV2Kind)):(i.UV1=!1,i.UV2=!1),r){var a=t.useVertexColors&&t.isVerticesDataPresent(e.VertexBuffer.ColorKind);i.VERTEXCOLOR=a,i.VERTEXALPHA=t.hasVertexAlpha&&a&&s}if(n&&(t.useBones&&t.computeBonesUsingShaders&&t.skeleton?(i.NUM_BONE_INFLUENCERS=t.numBoneInfluencers,i.BonesPerMesh=t.skeleton.bones.length+1):(i.NUM_BONE_INFLUENCERS=0,i.BonesPerMesh=0)),o){var l=t.morphTargetManager;l?(i.MORPHTARGETS_TANGENT=l.supportsTangents&&i.TANGENT,i.MORPHTARGETS_NORMAL=l.supportsNormals&&i.NORMAL,i.MORPHTARGETS=l.numInfluencers>0,i.NUM_MORPH_INFLUENCERS=l.numInfluencers):(i.MORPHTARGETS_TANGENT=!1,i.MORPHTARGETS_NORMAL=!1,i.MORPHTARGETS=!1,i.NUM_MORPH_INFLUENCERS=0)}return!0},t.PrepareDefinesForLights=function(t,i,r,n,o,s){if(void 0===o&&(o=4),void 0===s&&(s=!1),!r._areLightsDirty)return r._needNormals;var a=0,l=!1,h=!1,c=!1,u=!1,f=!1;if(t.lightsEnabled&&!s)for(var p=0,d=i._lightSources;p<d.length;p++){var m=d[p];l=!0,void 0===r["LIGHT"+a]&&(h=!0),r["LIGHT"+a]=!0,r["SPOTLIGHT"+a]=!1,r["HEMILIGHT"+a]=!1,r["POINTLIGHT"+a]=!1,r["DIRLIGHT"+a]=!1;var _;if(m.getTypeID()===e.Light.LIGHTTYPEID_SPOTLIGHT){_="SPOTLIGHT"+a;var g=m;r["PROJECTEDLIGHTTEXTURE"+a]=!!g.projectionTexture}else _=m.getTypeID()===e.Light.LIGHTTYPEID_HEMISPHERICLIGHT?"HEMILIGHT"+a:m.getTypeID()===e.Light.LIGHTTYPEID_POINTLIGHT?"POINTLIGHT"+a:"DIRLIGHT"+a;if(r[_]=!0,n&&!m.specular.equalsFloats(0,0,0)&&(f=!0),r["SHADOW"+a]=!1,r["SHADOWPCF"+a]=!1,r["SHADOWPCSS"+a]=!1,r["SHADOWPOISSON"+a]=!1,r["SHADOWESM"+a]=!1,r["SHADOWCUBE"+a]=!1,r["SHADOWLOWQUALITY"+a]=!1,r["SHADOWMEDIUMQUALITY"+a]=!1,i&&i.receiveShadows&&t.shadowsEnabled&&m.shadowEnabled){var v=m.getShadowGenerator();v&&(u=!0,v.prepareDefines(r,a))}if(m.lightmapMode!=e.Light.LIGHTMAP_DEFAULT?(c=!0,r["LIGHTMAPEXCLUDED"+a]=!0,r["LIGHTMAPNOSPECULAR"+a]=m.lightmapMode==e.Light.LIGHTMAP_SHADOWSONLY):(r["LIGHTMAPEXCLUDED"+a]=!1,r["LIGHTMAPNOSPECULAR"+a]=!1),++a===o)break}r.SPECULARTERM=f,r.SHADOWS=u;for(var y=a;y<o;y++)void 0!==r["LIGHT"+y]&&(r["LIGHT"+y]=!1,r["HEMILIGHT"+a]=!1,r["POINTLIGHT"+a]=!1,r["DIRLIGHT"+a]=!1,r["SPOTLIGHT"+a]=!1,r["SHADOW"+a]=!1);var b=t.getEngine().getCaps();return void 0===r.SHADOWFLOAT&&(h=!0),r.SHADOWFLOAT=u&&(b.textureFloatRender&&b.textureFloatLinearFiltering||b.textureHalfFloatRender&&b.textureHalfFloatLinearFiltering),r.LIGHTMAPEXCLUDED=c,h&&r.rebuild(),l},t.PrepareUniformsAndSamplersList=function(e,t,i,r){void 0===r&&(r=4);var n,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,"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")},t.HandleFallbacksForShadows=function(e,t,i,r){void 0===i&&(i=4),void 0===r&&(r=0);for(var n=0,o=0;o<i&&e["LIGHT"+o];o++)o>0&&(n=r+o,t.addFallback(n,"LIGHT"+o)),e.SHADOWS||(e["SHADOW"+o]&&t.addFallback(r,"SHADOW"+o),e["SHADOWPCF"+o]&&t.addFallback(r,"SHADOWPCF"+o),e["SHADOWPCSS"+o]&&t.addFallback(r,"SHADOWPCSS"+o),e["SHADOWPOISSON"+o]&&t.addFallback(r,"SHADOWPOISSON"+o),e["SHADOWESM"+o]&&t.addFallback(r,"SHADOWESM"+o));return n++},t.PrepareAttributesForMorphTargets=function(t,i,r){var n=r.NUM_MORPH_INFLUENCERS;if(n>0&&e.Engine.LastCreatedEngine)for(var o=e.Engine.LastCreatedEngine.getCaps().maxVertexAttribs,s=i.morphTargetManager,a=s&&s.supportsNormals&&r.NORMAL,l=s&&s.supportsTangents&&r.TANGENT,h=0;h<n;h++)t.push(e.VertexBuffer.PositionKind+h),a&&t.push(e.VertexBuffer.NormalKind+h),l&&t.push(e.VertexBuffer.TangentKind+h),t.length>o&&e.Tools.Error("Cannot add more vertex attributes for mesh "+i.name)},t.PrepareAttributesForBones=function(t,i,r,n){r.NUM_BONE_INFLUENCERS>0&&(n.addCPUSkinningFallback(0,i),t.push(e.VertexBuffer.MatricesIndicesKind),t.push(e.VertexBuffer.MatricesWeightsKind),r.NUM_BONE_INFLUENCERS>4&&(t.push(e.VertexBuffer.MatricesIndicesExtraKind),t.push(e.VertexBuffer.MatricesWeightsExtraKind)))},t.PrepareAttributesForInstances=function(e,t){t.INSTANCES&&(e.push("world0"),e.push("world1"),e.push("world2"),e.push("world3"))},t.BindLightShadow=function(e,t,i,r,n){if(e.shadowEnabled&&i.receiveShadows){var o=e.getShadowGenerator();o&&o.bindShadowLight(r,n)}},t.BindLightProperties=function(e,t,i){e.transferToEffect(t,i+"")},t.BindLights=function(i,r,n,o,s,a){void 0===s&&(s=4),void 0===a&&(a=!1);for(var l=Math.min(r._lightSources.length,s),h=0;h<l;h++){var c=r._lightSources[h],u=h.toString(),f=c.getScaledIntensity();c._uniformBuffer.bindToEffect(n,"Light"+h),t.BindLightProperties(c,n,h),c.diffuse.scaleToRef(f,e.Tmp.Color3[0]),c._uniformBuffer.updateColor4("vLightDiffuse",e.Tmp.Color3[0],a?c.radius:c.range,u),o.SPECULARTERM&&(c.specular.scaleToRef(f,e.Tmp.Color3[1]),c._uniformBuffer.updateColor3("vLightSpecular",e.Tmp.Color3[1],u)),i.shadowsEnabled&&this.BindLightShadow(c,i,r,u,n),c._uniformBuffer.update()}},t.BindFogParameters=function(t,i,r){t.fogEnabled&&i.applyFog&&t.fogMode!==e.Scene.FOGMODE_NONE&&(r.setFloat4("vFogInfos",t.fogMode,t.fogStart,t.fogEnd,t.fogDensity),r.setColor3("vFogColor",t.fogColor))},t.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)}},t.BindMorphTargetParameters=function(e,t){var i=e.morphTargetManager;e&&i&&t.setFloatArray("morphTargetInfluences",i.influences)},t.BindLogDepth=function(e,t,i){e.LOGARITHMICDEPTH&&t.setFloat("logarithmicDepthConstant",2/(Math.log(i.activeCamera.maxZ+1)/Math.LN2))},t.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)}},t})();e.MaterialHelper=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n._normalMatrix=new e.Matrix,n.storeEffectOnSubMeshes=!0,n}return o(i,t),i.prototype.getEffect=function(){return this._activeEffect},i.prototype.isReady=function(e,t){return!!e&&(!e.subMeshes||0===e.subMeshes.length||this.isReadyForSubMesh(e,e.subMeshes[0],t))},i.prototype.bindOnlyWorldMatrix=function(e){this._activeEffect.setMatrix("world",e)},i.prototype.bindOnlyNormalMatrix=function(e){this._activeEffect.setMatrix("normalMatrix",e)},i.prototype.bind=function(e,t){t&&this.bindForSubMesh(e,t,t.subMeshes[0])},i.prototype._afterBind=function(e,i){void 0===i&&(i=null),t.prototype._afterBind.call(this,e),this.getScene()._cachedEffect=i},i.prototype._mustRebind=function(e,t,i){return void 0===i&&(i=1),e.isCachedMaterialInvalid(this,t,i)},i})(e.Material);e.PushMaterial=t})(r||(r={}));var r;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.MAINUV1=!1,t.MAINUV2=!1,t.DIFFUSE=!1,t.DIFFUSEDIRECTUV=0,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.OPACITY=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.REFLECTION=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.SPECULAR=!1,t.SPECULARDIRECTUV=0,t.BUMP=!1,t.BUMPDIRECTUV=0,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.SPECULAROVERALPHA=!1,t.CLIPPLANE=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHAFROMDIFFUSE=!1,t.POINTSIZE=!1,t.FOG=!1,t.SPECULARTERM=!1,t.DIFFUSEFRESNEL=!1,t.OPACITYFRESNEL=!1,t.REFLECTIONFRESNEL=!1,t.REFRACTIONFRESNEL=!1,t.EMISSIVEFRESNEL=!1,t.FRESNEL=!1,t.NORMAL=!1,t.UV1=!1,t.UV2=!1,t.VERTEXCOLOR=!1,t.VERTEXALPHA=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.INSTANCES=!1,t.GLOSSINESS=!1,t.ROUGHNESS=!1,t.EMISSIVEASILLUMINATION=!1,t.LINKEMISSIVEWITHDIFFUSE=!1,t.REFLECTIONFRESNELFROMSPECULAR=!1,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.OBJECTSPACE_NORMALMAP=!1,t.USELIGHTMAPASSHADOWMAP=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_EXPLICIT=!1,t.REFLECTIONMAP_EQUIRECTANGULAR=!1,t.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,t.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,t.INVERTCUBICMAP=!1,t.LOGARITHMICDEPTH=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFLECTIONOVERALPHA=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.NONUNIFORMSCALING=!1,t.PREMULTIPLYALPHA=!1,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.IS_REFLECTION_LINEAR=!1,t.IS_REFRACTION_LINEAR=!1,t.EXPOSURE=!1,t.rebuild(),t}return o(t,e),t.prototype.setReflectionMode=function(e){for(var t=["REFLECTIONMAP_CUBIC","REFLECTIONMAP_EXPLICIT","REFLECTIONMAP_PLANAR","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_PROJECTION","REFLECTIONMAP_SKYBOX","REFLECTIONMAP_SPHERICAL","REFLECTIONMAP_EQUIRECTANGULAR","REFLECTIONMAP_EQUIRECTANGULAR_FIXED","REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"],i=0,r=t;i<r.length;i++){var n=r[i];this[n]=n===e}},t})(e.MaterialDefines);e.StandardMaterialDefines=t;var i=(function(i){function r(t,n){var o=i.call(this,t,n)||this;return o.ambientColor=new e.Color3(0,0,0),o.diffuseColor=new e.Color3(1,1,1),o.specularColor=new e.Color3(1,1,1),o.emissiveColor=new e.Color3(0,0,0),o.specularPower=64,o._useAlphaFromDiffuseTexture=!1,o._useEmissiveAsIllumination=!1,o._linkEmissiveWithDiffuse=!1,o._useSpecularOverAlpha=!1,o._useReflectionOverAlpha=!1,o._disableLighting=!1,o._useObjectSpaceNormalMap=!1,o._useParallax=!1,o._useParallaxOcclusion=!1,o.parallaxScaleBias=.05,o._roughness=0,o.indexOfRefraction=.98,o.invertRefractionY=!0,o.alphaCutOff=.4,o._useLightmapAsShadowmap=!1,o._useReflectionFresnelFromSpecular=!1,o._useGlossinessFromSpecularMapAlpha=!1,o._maxSimultaneousLights=4,o._invertNormalMapX=!1,o._invertNormalMapY=!1,o._twoSidedLighting=!1,o._renderTargets=new e.SmartArray(16),o._worldViewProjectionMatrix=e.Matrix.Zero(),o._globalAmbientColor=new e.Color3(0,0,0),o._attachImageProcessingConfiguration(null),o.getRenderTargetTextures=function(){return o._renderTargets.reset(),r.ReflectionTextureEnabled&&o._reflectionTexture&&o._reflectionTexture.isRenderTarget&&o._renderTargets.push(o._reflectionTexture),r.RefractionTextureEnabled&&o._refractionTexture&&o._refractionTexture.isRenderTarget&&o._renderTargets.push(o._refractionTexture),o._renderTargets},o}return o(r,i),Object.defineProperty(r.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),r.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._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},Object.defineProperty(r.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),r.prototype.getClassName=function(){return"StandardMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported,this._markAllSubMeshesAsMiscDirty()},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromDiffuseTexture()||this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled},r.prototype.needAlphaTesting=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha},r.prototype._shouldUseAlphaFromDiffuseTexture=function(){return null!=this._diffuseTexture&&this._diffuseTexture.hasAlpha&&this._useAlphaFromDiffuseTexture},r.prototype.getAlphaTestTexture=function(){return this._diffuseTexture},r.prototype.isReadyForSubMesh=function(i,n,o){if(void 0===o&&(o=!1),n.effect&&this.isFrozen&&this._wasPreviouslyReady&&n.effect)return!0;n._materialDefines||(n._materialDefines=new t);var s=this.getScene(),a=n._materialDefines;if(!this.checkReadyOnEveryCall&&n.effect&&a._renderId===s.getRenderId())return!0;var l=s.getEngine();if(a._needNormals=e.MaterialHelper.PrepareDefinesForLights(s,i,a,!0,this._maxSimultaneousLights,this._disableLighting),a._areTexturesDirty){if(a._needUVs=!1,a.MAINUV1=!1,a.MAINUV2=!1,s.texturesEnabled){if(this._diffuseTexture&&r.DiffuseTextureEnabled){if(!this._diffuseTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._diffuseTexture,a,"DIFFUSE")}else a.DIFFUSE=!1;if(this._ambientTexture&&r.AmbientTextureEnabled){if(!this._ambientTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,a,"AMBIENT")}else a.AMBIENT=!1;if(this._opacityTexture&&r.OpacityTextureEnabled){if(!this._opacityTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,a,"OPACITY"),a.OPACITYRGB=this._opacityTexture.getAlphaFromRGB}else a.OPACITY=!1;if(this._reflectionTexture&&r.ReflectionTextureEnabled){if(!this._reflectionTexture.isReadyOrNotBlocking())return!1;switch(a._needNormals=!0,a.REFLECTION=!0,a.ROUGHNESS=this._roughness>0,a.REFLECTIONOVERALPHA=this._useReflectionOverAlpha,a.INVERTCUBICMAP=this._reflectionTexture.coordinatesMode===e.Texture.INVCUBIC_MODE,a.REFLECTIONMAP_3D=this._reflectionTexture.isCube,this._reflectionTexture.coordinatesMode){case e.Texture.EXPLICIT_MODE:a.setReflectionMode("REFLECTIONMAP_EXPLICIT");break;case e.Texture.PLANAR_MODE:a.setReflectionMode("REFLECTIONMAP_PLANAR");break;case e.Texture.PROJECTION_MODE:a.setReflectionMode("REFLECTIONMAP_PROJECTION");break;case e.Texture.SKYBOX_MODE:a.setReflectionMode("REFLECTIONMAP_SKYBOX");break;case e.Texture.SPHERICAL_MODE:a.setReflectionMode("REFLECTIONMAP_SPHERICAL");break;case e.Texture.EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:a.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:a.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");break;case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:default:a.setReflectionMode("REFLECTIONMAP_CUBIC")}a.USE_LOCAL_REFLECTIONMAP_CUBIC=!!this._reflectionTexture.boundingBoxSize}else a.REFLECTION=!1;if(this._emissiveTexture&&r.EmissiveTextureEnabled){if(!this._emissiveTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,a,"EMISSIVE")}else a.EMISSIVE=!1;if(this._lightmapTexture&&r.LightmapTextureEnabled){if(!this._lightmapTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,a,"LIGHTMAP"),a.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap}else a.LIGHTMAP=!1;if(this._specularTexture&&r.SpecularTextureEnabled){if(!this._specularTexture.isReadyOrNotBlocking())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._specularTexture,a,"SPECULAR"),a.GLOSSINESS=this._useGlossinessFromSpecularMapAlpha}else a.SPECULAR=!1;if(s.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&r.BumpTextureEnabled){if(!this._bumpTexture.isReady())return!1;e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,a,"BUMP"),a.PARALLAX=this._useParallax,a.PARALLAXOCCLUSION=this._useParallaxOcclusion,a.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap}else a.BUMP=!1;if(this._refractionTexture&&r.RefractionTextureEnabled){if(!this._refractionTexture.isReadyOrNotBlocking())return!1;a._needUVs=!0,a.REFRACTION=!0,a.REFRACTIONMAP_3D=this._refractionTexture.isCube}else a.REFRACTION=!1;a.TWOSIDEDLIGHTING=!this._backFaceCulling&&this._twoSidedLighting}else a.DIFFUSE=!1,a.AMBIENT=!1,a.OPACITY=!1,a.REFLECTION=!1,a.EMISSIVE=!1,a.LIGHTMAP=!1,a.BUMP=!1,a.REFRACTION=!1;a.ALPHAFROMDIFFUSE=this._shouldUseAlphaFromDiffuseTexture(),a.EMISSIVEASILLUMINATION=this._useEmissiveAsIllumination,a.LINKEMISSIVEWITHDIFFUSE=this._linkEmissiveWithDiffuse,a.SPECULAROVERALPHA=this._useSpecularOverAlpha,a.PREMULTIPLYALPHA=this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF}if(a._areImageProcessingDirty){if(!this._imageProcessingConfiguration.isReady())return!1;this._imageProcessingConfiguration.prepareDefines(a),a.IS_REFLECTION_LINEAR=null!=this.reflectionTexture&&!this.reflectionTexture.gammaSpace,a.IS_REFRACTION_LINEAR=null!=this.refractionTexture&&!this.refractionTexture.gammaSpace}if(a._areFresnelDirty&&(r.FresnelEnabled?(this._diffuseFresnelParameters||this._opacityFresnelParameters||this._emissiveFresnelParameters||this._refractionFresnelParameters||this._reflectionFresnelParameters)&&(a.DIFFUSEFRESNEL=this._diffuseFresnelParameters&&this._diffuseFresnelParameters.isEnabled,a.OPACITYFRESNEL=this._opacityFresnelParameters&&this._opacityFresnelParameters.isEnabled,a.REFLECTIONFRESNEL=this._reflectionFresnelParameters&&this._reflectionFresnelParameters.isEnabled,a.REFLECTIONFRESNELFROMSPECULAR=this._useReflectionFresnelFromSpecular,a.REFRACTIONFRESNEL=this._refractionFresnelParameters&&this._refractionFresnelParameters.isEnabled,a.EMISSIVEFRESNEL=this._emissiveFresnelParameters&&this._emissiveFresnelParameters.isEnabled,a._needNormals=!0,a.FRESNEL=!0):a.FRESNEL=!1),e.MaterialHelper.PrepareDefinesForMisc(i,s,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(i),a),e.MaterialHelper.PrepareDefinesForAttributes(i,a,!0,!0,!0),e.MaterialHelper.PrepareDefinesForFrameBoundValues(s,l,a,o),a.isDirty){a.markAsProcessed(),s.resetCachedMaterial();var h=new e.EffectFallbacks;a.REFLECTION&&h.addFallback(0,"REFLECTION"),a.SPECULAR&&h.addFallback(0,"SPECULAR"),a.BUMP&&h.addFallback(0,"BUMP"),a.PARALLAX&&h.addFallback(1,"PARALLAX"),a.PARALLAXOCCLUSION&&h.addFallback(0,"PARALLAXOCCLUSION"),a.SPECULAROVERALPHA&&h.addFallback(0,"SPECULAROVERALPHA"),a.FOG&&h.addFallback(1,"FOG"),a.POINTSIZE&&h.addFallback(0,"POINTSIZE"),a.LOGARITHMICDEPTH&&h.addFallback(0,"LOGARITHMICDEPTH"),e.MaterialHelper.HandleFallbacksForShadows(a,h,this._maxSimultaneousLights),a.SPECULARTERM&&h.addFallback(0,"SPECULARTERM"),a.DIFFUSEFRESNEL&&h.addFallback(1,"DIFFUSEFRESNEL"),a.OPACITYFRESNEL&&h.addFallback(2,"OPACITYFRESNEL"),a.REFLECTIONFRESNEL&&h.addFallback(3,"REFLECTIONFRESNEL"),a.EMISSIVEFRESNEL&&h.addFallback(4,"EMISSIVEFRESNEL"),a.FRESNEL&&h.addFallback(4,"FRESNEL");var c=[e.VertexBuffer.PositionKind];a.NORMAL&&c.push(e.VertexBuffer.NormalKind),a.UV1&&c.push(e.VertexBuffer.UVKind),a.UV2&&c.push(e.VertexBuffer.UV2Kind),a.VERTEXCOLOR&&c.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(c,i,a,h),e.MaterialHelper.PrepareAttributesForInstances(c,a),e.MaterialHelper.PrepareAttributesForMorphTargets(c,i,a);var u="default",f=["world","view","viewProjection","vEyePosition","vLightsType","vAmbientColor","vDiffuseColor","vSpecularColor","vEmissiveColor","vFogInfos","vFogColor","pointSize","vDiffuseInfos","vAmbientInfos","vOpacityInfos","vReflectionInfos","vEmissiveInfos","vSpecularInfos","vBumpInfos","vLightmapInfos","vRefractionInfos","mBones","vClipPlane","diffuseMatrix","ambientMatrix","opacityMatrix","reflectionMatrix","emissiveMatrix","specularMatrix","bumpMatrix","normalMatrix","lightmapMatrix","refractionMatrix","diffuseLeftColor","diffuseRightColor","opacityParts","reflectionLeftColor","reflectionRightColor","emissiveLeftColor","emissiveRightColor","refractionLeftColor","refractionRightColor","vReflectionPosition","vReflectionSize","logarithmicDepthConstant","vTangentSpaceParams","alphaCutOff"],p=["diffuseSampler","ambientSampler","opacitySampler","reflectionCubeSampler","reflection2DSampler","emissiveSampler","specularSampler","bumpSampler","lightmapSampler","refractionCubeSampler","refraction2DSampler"],d=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,a),e.ImageProcessingConfiguration.PrepareSamplers(p,a),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:d,samplers:p,defines:a,maxSimultaneousLights:this._maxSimultaneousLights}),this.customShaderNameResolve&&(u=this.customShaderNameResolve(u,f,d,p,a));var m=a.toString();n.setEffect(s.getEngine().createEffect(u,{attributes:c,uniformsNames:f,uniformBuffersNames:d,samplers:p,defines:m,fallbacks:h,onCompiled:this.onCompiled,onError:this.onError,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:a.NUM_MORPH_INFLUENCERS}},l),a),this.buildUniformLayout()}return!(!n.effect||!n.effect.isReady())&&(a._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.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()},r.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()}i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,n){var o=this.getScene(),s=n._materialDefines;if(s){var a=n.effect;if(a){this._activeEffect=a,this.bindOnlyWorldMatrix(t),s.OBJECTSPACE_NORMALMAP&&(t.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var l=this._mustRebind(o,a,i.visibility);if(e.MaterialHelper.BindBonesParameters(i,a),l){if(this._uniformBuffer.bindToEffect(a,"Material"),this.bindViewProjection(a),!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(r.FresnelEnabled&&s.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 e.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))),o.texturesEnabled){if(this._diffuseTexture&&r.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vDiffuseInfos",this._diffuseTexture.coordinatesIndex,this._diffuseTexture.level),e.MaterialHelper.BindTextureMatrix(this._diffuseTexture,this._uniformBuffer,"diffuse"),this._diffuseTexture.hasAlpha&&a.setFloat("alphaCutOff",this.alphaCutOff)),this._ambientTexture&&r.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat2("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&r.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._uniformBuffer.updateFloat2("vReflectionInfos",this._reflectionTexture.level,this.roughness),this._uniformBuffer.updateMatrix("reflectionMatrix",this._reflectionTexture.getReflectionTextureMatrix()),this._reflectionTexture.boundingBoxSize)){var h=this._reflectionTexture;this._uniformBuffer.updateVector3("vReflectionPosition",h.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",h.boundingBoxSize)}if(this._emissiveTexture&&r.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&r.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),this._specularTexture&&r.SpecularTextureEnabled&&(this._uniformBuffer.updateFloat2("vSpecularInfos",this._specularTexture.coordinatesIndex,this._specularTexture.level),e.MaterialHelper.BindTextureMatrix(this._specularTexture,this._uniformBuffer,"specular")),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,1/this._bumpTexture.level,this.parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),o._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&&r.RefractionTextureEnabled){var c=1;this._refractionTexture.isCube||(this._uniformBuffer.updateMatrix("refractionMatrix",this._refractionTexture.getReflectionTextureMatrix()),this._refractionTexture.depth&&(c=this._refractionTexture.depth)),this._uniformBuffer.updateFloat4("vRefractionInfos",this._refractionTexture.level,this.indexOfRefraction,c,this.invertRefractionY?-1:1)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),s.SPECULARTERM&&this._uniformBuffer.updateColor4("vSpecularColor",this.specularColor,this.specularPower),this._uniformBuffer.updateColor3("vEmissiveColor",this.emissiveColor),this._uniformBuffer.updateColor4("vDiffuseColor",this.diffuseColor,this.alpha*i.visibility)}if(o.texturesEnabled&&(this._diffuseTexture&&r.DiffuseTextureEnabled&&a.setTexture("diffuseSampler",this._diffuseTexture),this._ambientTexture&&r.AmbientTextureEnabled&&a.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&r.OpacityTextureEnabled&&a.setTexture("opacitySampler",this._opacityTexture),
this._reflectionTexture&&r.ReflectionTextureEnabled&&(this._reflectionTexture.isCube?a.setTexture("reflectionCubeSampler",this._reflectionTexture):a.setTexture("reflection2DSampler",this._reflectionTexture)),this._emissiveTexture&&r.EmissiveTextureEnabled&&a.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&r.LightmapTextureEnabled&&a.setTexture("lightmapSampler",this._lightmapTexture),this._specularTexture&&r.SpecularTextureEnabled&&a.setTexture("specularSampler",this._specularTexture),this._bumpTexture&&o.getEngine().getCaps().standardDerivatives&&r.BumpTextureEnabled&&a.setTexture("bumpSampler",this._bumpTexture),this._refractionTexture&&r.RefractionTextureEnabled)){var c=1;this._refractionTexture.isCube?a.setTexture("refractionCubeSampler",this._refractionTexture):a.setTexture("refraction2DSampler",this._refractionTexture)}e.MaterialHelper.BindClipPlane(a,o),o.ambientColor.multiplyToRef(this.ambientColor,this._globalAmbientColor),e.MaterialHelper.BindEyePosition(a,o),a.setColor3("vAmbientColor",this._globalAmbientColor)}!l&&this.isFrozen||(o.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(o,i,a,s,this._maxSimultaneousLights),(o.fogEnabled&&i.applyFog&&o.fogMode!==e.Scene.FOGMODE_NONE||this._reflectionTexture||this._refractionTexture)&&this.bindView(a),e.MaterialHelper.BindFogParameters(o,i,a),s.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,a),e.MaterialHelper.BindLogDepth(s,a,o),this._imageProcessingConfiguration.applyByPostProcess||this._imageProcessingConfiguration.bind(this._activeEffect)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}}},r.prototype.getAnimatables=function(){var e=[];return this._diffuseTexture&&this._diffuseTexture.animations&&this._diffuseTexture.animations.length>0&&e.push(this._diffuseTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._specularTexture&&this._specularTexture.animations&&this._specularTexture.animations.length>0&&e.push(this._specularTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype.getActiveTextures=function(){var e=i.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},r.prototype.hasTexture=function(e){return!!i.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))))))))},r.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),i.prototype.dispose.call(this,e,t)},r.prototype.clone=function(t){var i=this,n=e.SerializationHelper.Clone((function(){return new r(t,i.getScene())}),this);return n.name=t,n.id=t,n},r.prototype.serialize=function(){return e.SerializationHelper.Serialize(this)},r.Parse=function(t,i,n){return e.SerializationHelper.Parse((function(){return new r(t.name,i)}),t,i,n)},Object.defineProperty(r,"DiffuseTextureEnabled",{get:function(){return r._DiffuseTextureEnabled},set:function(t){r._DiffuseTextureEnabled!==t&&(r._DiffuseTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"AmbientTextureEnabled",{get:function(){return r._AmbientTextureEnabled},set:function(t){r._AmbientTextureEnabled!==t&&(r._AmbientTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"OpacityTextureEnabled",{get:function(){return r._OpacityTextureEnabled},set:function(t){r._OpacityTextureEnabled!==t&&(r._OpacityTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ReflectionTextureEnabled",{get:function(){return r._ReflectionTextureEnabled},set:function(t){r._ReflectionTextureEnabled!==t&&(r._ReflectionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"EmissiveTextureEnabled",{get:function(){return r._EmissiveTextureEnabled},set:function(t){r._EmissiveTextureEnabled!==t&&(r._EmissiveTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"SpecularTextureEnabled",{get:function(){return r._SpecularTextureEnabled},set:function(t){r._SpecularTextureEnabled!==t&&(r._SpecularTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"BumpTextureEnabled",{get:function(){return r._BumpTextureEnabled},set:function(t){r._BumpTextureEnabled!==t&&(r._BumpTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"LightmapTextureEnabled",{get:function(){return r._LightmapTextureEnabled},set:function(t){r._LightmapTextureEnabled!==t&&(r._LightmapTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"RefractionTextureEnabled",{get:function(){return r._RefractionTextureEnabled},set:function(t){r._RefractionTextureEnabled!==t&&(r._RefractionTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"ColorGradingTextureEnabled",{get:function(){return r._ColorGradingTextureEnabled},set:function(t){r._ColorGradingTextureEnabled!==t&&(r._ColorGradingTextureEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.TextureDirtyFlag))},enumerable:!0,configurable:!0}),Object.defineProperty(r,"FresnelEnabled",{get:function(){return r._FresnelEnabled},set:function(t){r._FresnelEnabled!==t&&(r._FresnelEnabled=t,e.Engine.MarkAllMaterialsAsDirty(e.Material.FresnelDirtyFlag))},enumerable:!0,configurable:!0}),r._DiffuseTextureEnabled=!0,r._AmbientTextureEnabled=!0,r._OpacityTextureEnabled=!0,r._ReflectionTextureEnabled=!0,r._EmissiveTextureEnabled=!0,r._SpecularTextureEnabled=!0,r._BumpTextureEnabled=!0,r._LightmapTextureEnabled=!0,r._RefractionTextureEnabled=!0,r._ColorGradingTextureEnabled=!0,r._FresnelEnabled=!0,n([e.serializeAsTexture("diffuseTexture")],r.prototype,"_diffuseTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],r.prototype,"diffuseTexture",void 0),n([e.serializeAsTexture("ambientTexture")],r.prototype,"_ambientTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"ambientTexture",void 0),n([e.serializeAsTexture("opacityTexture")],r.prototype,"_opacityTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],r.prototype,"opacityTexture",void 0),n([e.serializeAsTexture("reflectionTexture")],r.prototype,"_reflectionTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"reflectionTexture",void 0),n([e.serializeAsTexture("emissiveTexture")],r.prototype,"_emissiveTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"emissiveTexture",void 0),n([e.serializeAsTexture("specularTexture")],r.prototype,"_specularTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"specularTexture",void 0),n([e.serializeAsTexture("bumpTexture")],r.prototype,"_bumpTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"bumpTexture",void 0),n([e.serializeAsTexture("lightmapTexture")],r.prototype,"_lightmapTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"lightmapTexture",void 0),n([e.serializeAsTexture("refractionTexture")],r.prototype,"_refractionTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"refractionTexture",void 0),n([e.serializeAsColor3("ambient")],r.prototype,"ambientColor",void 0),n([e.serializeAsColor3("diffuse")],r.prototype,"diffuseColor",void 0),n([e.serializeAsColor3("specular")],r.prototype,"specularColor",void 0),n([e.serializeAsColor3("emissive")],r.prototype,"emissiveColor",void 0),n([e.serialize()],r.prototype,"specularPower",void 0),n([e.serialize("useAlphaFromDiffuseTexture")],r.prototype,"_useAlphaFromDiffuseTexture",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useAlphaFromDiffuseTexture",void 0),n([e.serialize("useEmissiveAsIllumination")],r.prototype,"_useEmissiveAsIllumination",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useEmissiveAsIllumination",void 0),n([e.serialize("linkEmissiveWithDiffuse")],r.prototype,"_linkEmissiveWithDiffuse",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"linkEmissiveWithDiffuse",void 0),n([e.serialize("useSpecularOverAlpha")],r.prototype,"_useSpecularOverAlpha",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useSpecularOverAlpha",void 0),n([e.serialize("useReflectionOverAlpha")],r.prototype,"_useReflectionOverAlpha",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useReflectionOverAlpha",void 0),n([e.serialize("disableLighting")],r.prototype,"_disableLighting",void 0),n([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"disableLighting",void 0),n([e.serialize("useObjectSpaceNormalMap")],r.prototype,"_useObjectSpaceNormalMap",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useObjectSpaceNormalMap",void 0),n([e.serialize("useParallax")],r.prototype,"_useParallax",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallax",void 0),n([e.serialize("useParallaxOcclusion")],r.prototype,"_useParallaxOcclusion",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useParallaxOcclusion",void 0),n([e.serialize()],r.prototype,"parallaxScaleBias",void 0),n([e.serialize("roughness")],r.prototype,"_roughness",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"roughness",void 0),n([e.serialize()],r.prototype,"indexOfRefraction",void 0),n([e.serialize()],r.prototype,"invertRefractionY",void 0),n([e.serialize()],r.prototype,"alphaCutOff",void 0),n([e.serialize("useLightmapAsShadowmap")],r.prototype,"_useLightmapAsShadowmap",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useLightmapAsShadowmap",void 0),n([e.serializeAsFresnelParameters("diffuseFresnelParameters")],r.prototype,"_diffuseFresnelParameters",void 0),n([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"diffuseFresnelParameters",void 0),n([e.serializeAsFresnelParameters("opacityFresnelParameters")],r.prototype,"_opacityFresnelParameters",void 0),n([e.expandToProperty("_markAllSubMeshesAsFresnelAndMiscDirty")],r.prototype,"opacityFresnelParameters",void 0),n([e.serializeAsFresnelParameters("reflectionFresnelParameters")],r.prototype,"_reflectionFresnelParameters",void 0),n([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"reflectionFresnelParameters",void 0),n([e.serializeAsFresnelParameters("refractionFresnelParameters")],r.prototype,"_refractionFresnelParameters",void 0),n([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"refractionFresnelParameters",void 0),n([e.serializeAsFresnelParameters("emissiveFresnelParameters")],r.prototype,"_emissiveFresnelParameters",void 0),n([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"emissiveFresnelParameters",void 0),n([e.serialize("useReflectionFresnelFromSpecular")],r.prototype,"_useReflectionFresnelFromSpecular",void 0),n([e.expandToProperty("_markAllSubMeshesAsFresnelDirty")],r.prototype,"useReflectionFresnelFromSpecular",void 0),n([e.serialize("useGlossinessFromSpecularMapAlpha")],r.prototype,"_useGlossinessFromSpecularMapAlpha",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"useGlossinessFromSpecularMapAlpha",void 0),n([e.serialize("maxSimultaneousLights")],r.prototype,"_maxSimultaneousLights",void 0),n([e.expandToProperty("_markAllSubMeshesAsLightsDirty")],r.prototype,"maxSimultaneousLights",void 0),n([e.serialize("invertNormalMapX")],r.prototype,"_invertNormalMapX",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapX",void 0),n([e.serialize("invertNormalMapY")],r.prototype,"_invertNormalMapY",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"invertNormalMapY",void 0),n([e.serialize("twoSidedLighting")],r.prototype,"_twoSidedLighting",void 0),n([e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],r.prototype,"twoSidedLighting",void 0),n([e.serialize()],r.prototype,"useLogarithmicDepth",null),r})(e.PushMaterial);e.StandardMaterial=i})(r||(r={}));var r;!(function(e){var t=(function(e){function t(){var t=e.call(this)||this;return t.PBR=!0,t.MAINUV1=!1,t.MAINUV2=!1,t.UV1=!1,t.UV2=!1,t.ALBEDO=!1,t.ALBEDODIRECTUV=0,t.VERTEXCOLOR=!1,t.AMBIENT=!1,t.AMBIENTDIRECTUV=0,t.AMBIENTINGRAYSCALE=!1,t.OPACITY=!1,t.VERTEXALPHA=!1,t.OPACITYDIRECTUV=0,t.OPACITYRGB=!1,t.ALPHATEST=!1,t.DEPTHPREPASS=!1,t.ALPHABLEND=!1,t.ALPHAFROMALBEDO=!1,t.ALPHATESTVALUE="0.5",t.SPECULAROVERALPHA=!1,t.RADIANCEOVERALPHA=!1,t.ALPHAFRESNEL=!1,t.LINEARALPHAFRESNEL=!1,t.PREMULTIPLYALPHA=!1,t.EMISSIVE=!1,t.EMISSIVEDIRECTUV=0,t.REFLECTIVITY=!1,t.REFLECTIVITYDIRECTUV=0,t.SPECULARTERM=!1,t.MICROSURFACEFROMREFLECTIVITYMAP=!1,t.MICROSURFACEAUTOMATIC=!1,t.LODBASEDMICROSFURACE=!1,t.MICROSURFACEMAP=!1,t.MICROSURFACEMAPDIRECTUV=0,t.METALLICWORKFLOW=!1,t.ROUGHNESSSTOREINMETALMAPALPHA=!1,t.ROUGHNESSSTOREINMETALMAPGREEN=!1,t.METALLNESSSTOREINMETALMAPBLUE=!1,t.AOSTOREINMETALMAPRED=!1,t.ENVIRONMENTBRDF=!1,t.NORMAL=!1,t.TANGENT=!1,t.BUMP=!1,t.BUMPDIRECTUV=0,t.OBJECTSPACE_NORMALMAP=!1,t.PARALLAX=!1,t.PARALLAXOCCLUSION=!1,t.NORMALXYSCALE=!0,t.LIGHTMAP=!1,t.LIGHTMAPDIRECTUV=0,t.USELIGHTMAPASSHADOWMAP=!1,t.GAMMALIGHTMAP=!1,t.REFLECTION=!1,t.REFLECTIONMAP_3D=!1,t.REFLECTIONMAP_SPHERICAL=!1,t.REFLECTIONMAP_PLANAR=!1,t.REFLECTIONMAP_CUBIC=!1,t.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,t.REFLECTIONMAP_PROJECTION=!1,t.REFLECTIONMAP_SKYBOX=!1,t.REFLECTIONMAP_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.RADIANCEOCCLUSION=!1,t.HORIZONOCCLUSION=!1,t.REFRACTION=!1,t.REFRACTIONMAP_3D=!1,t.REFRACTIONMAP_OPPOSITEZ=!1,t.LODINREFRACTIONALPHA=!1,t.GAMMAREFRACTION=!1,t.LINKREFRACTIONTOTRANSPARENCY=!1,t.INSTANCES=!1,t.NUM_BONE_INFLUENCERS=0,t.BonesPerMesh=0,t.NONUNIFORMSCALING=!1,t.MORPHTARGETS=!1,t.MORPHTARGETS_NORMAL=!1,t.MORPHTARGETS_TANGENT=!1,t.NUM_MORPH_INFLUENCERS=0,t.IMAGEPROCESSING=!1,t.VIGNETTE=!1,t.VIGNETTEBLENDMODEMULTIPLY=!1,t.VIGNETTEBLENDMODEOPAQUE=!1,t.TONEMAPPING=!1,t.CONTRAST=!1,t.COLORCURVES=!1,t.COLORGRADING=!1,t.COLORGRADING3D=!1,t.SAMPLER3DGREENDEPTH=!1,t.SAMPLER3DBGRMAP=!1,t.IMAGEPROCESSINGPOSTPROCESS=!1,t.EXPOSURE=!1,t.USEPHYSICALLIGHTFALLOFF=!1,t.TWOSIDEDLIGHTING=!1,t.SHADOWFLOAT=!1,t.CLIPPLANE=!1,t.POINTSIZE=!1,t.FOG=!1,t.LOGARITHMICDEPTH=!1,t.FORCENORMALFORWARD=!1,t.SPECULARAA=!1,t.UNLIT=!1,t.rebuild(),t}return o(t,e),t.prototype.reset=function(){e.prototype.reset.call(this),this.ALPHATESTVALUE="0.5",this.PBR=!0},t})(e.MaterialDefines),i=(function(i){function r(t,r){var n=i.call(this,t,r)||this;return n._directIntensity=1,n._emissiveIntensity=1,n._environmentIntensity=1,n._specularIntensity=1,n._lightingInfos=new e.Vector4(n._directIntensity,n._emissiveIntensity,n._environmentIntensity,n._specularIntensity),n._disableBumpMap=!1,n._ambientTextureStrength=1,n._ambientColor=new e.Color3(0,0,0),n._albedoColor=new e.Color3(1,1,1),n._reflectivityColor=new e.Color3(1,1,1),n._reflectionColor=new e.Color3(1,1,1),n._emissiveColor=new e.Color3(0,0,0),n._microSurface=.9,n._indexOfRefraction=.66,n._invertRefractionY=!1,n._linkRefractionWithTransparency=!1,n._useLightmapAsShadowmap=!1,n._useHorizonOcclusion=!0,n._useRadianceOcclusion=!0,n._useAlphaFromAlbedoTexture=!1,n._useSpecularOverAlpha=!0,n._useMicroSurfaceFromReflectivityMapAlpha=!1,n._useRoughnessFromMetallicTextureAlpha=!0,n._useRoughnessFromMetallicTextureGreen=!1,n._useMetallnessFromMetallicTextureBlue=!1,n._useAmbientOcclusionFromMetallicTextureRed=!1,n._useAmbientInGrayScale=!1,n._useAutoMicroSurfaceFromReflectivityMap=!1,n._usePhysicalLightFalloff=!0,n._useRadianceOverAlpha=!0,n._useObjectSpaceNormalMap=!1,n._useParallax=!1,n._useParallaxOcclusion=!1,n._parallaxScaleBias=.05,n._disableLighting=!1,n._maxSimultaneousLights=4,n._invertNormalMapX=!1,n._invertNormalMapY=!1,n._twoSidedLighting=!1,n._alphaCutOff=.4,n._forceAlphaTest=!1,n._useAlphaFresnel=!1,n._useLinearAlphaFresnel=!1,n._transparencyMode=null,n._environmentBRDFTexture=null,n._forceIrradianceInFragment=!1,n._forceNormalForward=!1,n._enableSpecularAntiAliasing=!1,n._renderTargets=new e.SmartArray(16),n._globalAmbientColor=new e.Color3(0,0,0),n._unlit=!1,n._attachImageProcessingConfiguration(null),n.getRenderTargetTextures=function(){return n._renderTargets.reset(),e.StandardMaterial.ReflectionTextureEnabled&&n._reflectionTexture&&n._reflectionTexture.isRenderTarget&&n._renderTargets.push(n._reflectionTexture),e.StandardMaterial.RefractionTextureEnabled&&n._refractionTexture&&n._refractionTexture.isRenderTarget&&n._renderTargets.push(n._refractionTexture),n._renderTargets},n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return o(r,i),r.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._imageProcessingObserver=this._imageProcessingConfiguration.onUpdateParameters.add((function(e){t._markAllSubMeshesAsImageProcessingDirty()})))},r.prototype.getClassName=function(){return"PBRBaseMaterial"},Object.defineProperty(r.prototype,"useLogarithmicDepth",{get:function(){return this._useLogarithmicDepth},set:function(e){this._useLogarithmicDepth=e&&this.getScene().getEngine().getCaps().fragmentDepthSupported},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"transparencyMode",{get:function(){return this._transparencyMode},set:function(t){this._transparencyMode!==t&&(this._transparencyMode=t,this._forceAlphaTest=t===e.PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND,this._markAllSubMeshesAsTexturesAndMiscDirty())},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"_disableAlphaBlending",{get:function(){return this._linkRefractionWithTransparency||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_OPAQUE||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),r.prototype.needAlphaBlending=function(){return!this._disableAlphaBlending&&(this.alpha<1||null!=this._opacityTexture||this._shouldUseAlphaFromAlbedoTexture())},r.prototype.needAlphaBlendingForMesh=function(e){return!this._disableAlphaBlending&&i.prototype.needAlphaBlendingForMesh.call(this,e)},r.prototype.needAlphaTesting=function(){return!!this._forceAlphaTest||!this._linkRefractionWithTransparency&&(null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&(null==this._transparencyMode||this._transparencyMode===e.PBRMaterial.PBRMATERIAL_ALPHATEST))},r.prototype._shouldUseAlphaFromAlbedoTexture=function(){return null!=this._albedoTexture&&this._albedoTexture.hasAlpha&&this._useAlphaFromAlbedoTexture&&this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE},r.prototype.getAlphaTestTexture=function(){return this._albedoTexture},r.prototype.isReadyForSubMesh=function(i,r,n){if(r.effect&&this.isFrozen&&this._wasPreviouslyReady)return!0;r._materialDefines||(r._materialDefines=new t);var o=r._materialDefines;if(!this.checkReadyOnEveryCall&&r.effect&&o._renderId===this.getScene().getRenderId())return!0;var s=this.getScene(),a=s.getEngine();if(o._areTexturesDirty&&s.texturesEnabled){if(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&!this._albedoTexture.isReadyOrNotBlocking())return!1;if(this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&!this._ambientTexture.isReadyOrNotBlocking())return!1;if(this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&!this._opacityTexture.isReadyOrNotBlocking())return!1;var l=this._getReflectionTexture();if(l&&e.StandardMaterial.ReflectionTextureEnabled&&!l.isReadyOrNotBlocking())return!1;if(this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&!this._lightmapTexture.isReadyOrNotBlocking())return!1;if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&!this._emissiveTexture.isReadyOrNotBlocking())return!1;if(e.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(a.getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&!this._bumpTexture.isReady())return!1;var h=this._getRefractionTexture();if(h&&e.StandardMaterial.RefractionTextureEnabled&&!h.isReadyOrNotBlocking())return!1;if(this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled&&!this._environmentBRDFTexture.isReady())return!1}if(o._areImageProcessingDirty&&!this._imageProcessingConfiguration.isReady())return!1;a.getCaps().standardDerivatives||i.isVerticesDataPresent(e.VertexBuffer.NormalKind)||(i.createNormals(!0),e.Tools.Warn("PBRMaterial: Normals have been created for the mesh: "+i.name));var c=this._prepareEffect(i,o,this.onCompiled,this.onError,n);return c&&(s.resetCachedMaterial(),r.setEffect(c,o),this.buildUniformLayout()),!(!r.effect||!r.effect.isReady())&&(o._renderId=s.getRenderId(),this._wasPreviouslyReady=!0,!0)},r.prototype.isMetallicWorkflow=function(){return!(null==this._metallic&&null==this._roughness&&!this._metallicTexture)},r.prototype._prepareEffect=function(t,i,r,n,o,s){if(void 0===r&&(r=null),void 0===n&&(n=null),void 0===o&&(o=null),void 0===s&&(s=null),this._prepareDefines(t,i,o,s),!i.isDirty)return null;i.markAsProcessed();var a=this.getScene(),l=a.getEngine(),h=new e.EffectFallbacks,c=0;i.USESPHERICALINVERTEX&&h.addFallback(c++,"USESPHERICALINVERTEX"),i.FOG&&h.addFallback(c,"FOG"),i.SPECULARAA&&h.addFallback(c,"SPECULARAA"),i.POINTSIZE&&h.addFallback(c,"POINTSIZE"),i.LOGARITHMICDEPTH&&h.addFallback(c,"LOGARITHMICDEPTH"),i.PARALLAX&&h.addFallback(c,"PARALLAX"),i.PARALLAXOCCLUSION&&h.addFallback(c++,"PARALLAXOCCLUSION"),i.ENVIRONMENTBRDF&&h.addFallback(c++,"ENVIRONMENTBRDF"),i.TANGENT&&h.addFallback(c++,"TANGENT"),i.BUMP&&h.addFallback(c++,"BUMP"),c=e.MaterialHelper.HandleFallbacksForShadows(i,h,this._maxSimultaneousLights,c++),i.SPECULARTERM&&h.addFallback(c++,"SPECULARTERM"),i.USESPHERICALFROMREFLECTIONMAP&&h.addFallback(c++,"USESPHERICALFROMREFLECTIONMAP"),i.LIGHTMAP&&h.addFallback(c++,"LIGHTMAP"),i.NORMAL&&h.addFallback(c++,"NORMAL"),i.AMBIENT&&h.addFallback(c++,"AMBIENT"),i.EMISSIVE&&h.addFallback(c++,"EMISSIVE"),i.VERTEXCOLOR&&h.addFallback(c++,"VERTEXCOLOR"),i.NUM_BONE_INFLUENCERS>0&&h.addCPUSkinningFallback(c++,t),i.MORPHTARGETS&&h.addFallback(c++,"MORPHTARGETS");var u=[e.VertexBuffer.PositionKind];i.NORMAL&&u.push(e.VertexBuffer.NormalKind),i.TANGENT&&u.push(e.VertexBuffer.TangentKind),i.UV1&&u.push(e.VertexBuffer.UVKind),i.UV2&&u.push(e.VertexBuffer.UV2Kind),i.VERTEXCOLOR&&u.push(e.VertexBuffer.ColorKind),e.MaterialHelper.PrepareAttributesForBones(u,t,i,h),e.MaterialHelper.PrepareAttributesForInstances(u,i),e.MaterialHelper.PrepareAttributesForMorphTargets(u,t,i);var f=["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","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"],p=["albedoSampler","reflectivitySampler","ambientSampler","emissiveSampler","bumpSampler","lightmapSampler","opacitySampler","refractionSampler","refractionSamplerLow","refractionSamplerHigh","reflectionSampler","reflectionSamplerLow","reflectionSamplerHigh","microSurfaceSampler","environmentBrdfSampler"],d=["Material","Scene"];e.ImageProcessingConfiguration.PrepareUniforms(f,i),e.ImageProcessingConfiguration.PrepareSamplers(p,i),e.MaterialHelper.PrepareUniformsAndSamplersList({uniformsNames:f,uniformBuffersNames:d,samplers:p,defines:i,maxSimultaneousLights:this._maxSimultaneousLights});var m=i.toString();return l.createEffect("pbr",{attributes:u,uniformsNames:f,uniformBuffersNames:d,samplers:p,defines:m,fallbacks:h,onCompiled:r,onError:n,indexParameters:{maxSimultaneousLights:this._maxSimultaneousLights,maxSimultaneousMorphTargets:i.NUM_MORPH_INFLUENCERS}},l)},r.prototype._prepareDefines=function(t,i,r,n){void 0===r&&(r=null),void 0===n&&(n=null);var o=this.getScene(),s=o.getEngine();if(e.MaterialHelper.PrepareDefinesForLights(o,t,i,!0,this._maxSimultaneousLights,this._disableLighting),i._needNormals=!0,i.METALLICWORKFLOW=this.isMetallicWorkflow(),i._areTexturesDirty){if(i._needUVs=!1,o.texturesEnabled){o.getEngine().getCaps().textureLOD&&(i.LODBASEDMICROSFURACE=!0),this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?e.MaterialHelper.PrepareDefinesForMergedUV(this._albedoTexture,i,"ALBEDO"):i.ALBEDO=!1,this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled?(e.MaterialHelper.PrepareDefinesForMergedUV(this._ambientTexture,i,"AMBIENT"),i.AMBIENTINGRAYSCALE=this._useAmbientInGrayScale):i.AMBIENT=!1,this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled?(e.MaterialHelper.PrepareDefinesForMergedUV(this._opacityTexture,i,"OPACITY"),i.OPACITYRGB=this._opacityTexture.getAlphaFromRGB):i.OPACITY=!1;var a=this._getReflectionTexture();if(a&&e.StandardMaterial.ReflectionTextureEnabled){switch(i.REFLECTION=!0,i.GAMMAREFLECTION=a.gammaSpace,i.REFLECTIONMAP_OPPOSITEZ=this.getScene().useRightHandedSystem?!a.invertZ:a.invertZ,i.LODINREFLECTIONALPHA=a.lodLevelInAlpha,a.coordinatesMode===e.Texture.INVCUBIC_MODE&&(i.INVERTCUBICMAP=!0),i.REFLECTIONMAP_3D=a.isCube,a.coordinatesMode){case e.Texture.EXPLICIT_MODE:i.REFLECTIONMAP_EXPLICIT=!0;break;case e.Texture.PLANAR_MODE:i.REFLECTIONMAP_PLANAR=!0;break;case e.Texture.PROJECTION_MODE:i.REFLECTIONMAP_PROJECTION=!0;break;case e.Texture.SKYBOX_MODE:i.REFLECTIONMAP_SKYBOX=!0;break;case e.Texture.SPHERICAL_MODE:i.REFLECTIONMAP_SPHERICAL=!0;break;case e.Texture.EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MODE:i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!0;break;case e.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE:i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!0;break;case e.Texture.CUBIC_MODE:case e.Texture.INVCUBIC_MODE:default:i.REFLECTIONMAP_CUBIC=!0,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!!a.boundingBoxSize}a.coordinatesMode!==e.Texture.SKYBOX_MODE&&a.sphericalPolynomial&&(i.USESPHERICALFROMREFLECTIONMAP=!0,this._forceIrradianceInFragment||o.getEngine().getCaps().maxVaryingVectors<=8?i.USESPHERICALINVERTEX=!1:i.USESPHERICALINVERTEX=!0)}else i.REFLECTION=!1,i.REFLECTIONMAP_3D=!1,i.REFLECTIONMAP_SPHERICAL=!1,i.REFLECTIONMAP_PLANAR=!1,i.REFLECTIONMAP_CUBIC=!1,i.USE_LOCAL_REFLECTIONMAP_CUBIC=!1,i.REFLECTIONMAP_PROJECTION=!1,i.REFLECTIONMAP_SKYBOX=!1,i.REFLECTIONMAP_EXPLICIT=!1,i.REFLECTIONMAP_EQUIRECTANGULAR=!1,i.REFLECTIONMAP_EQUIRECTANGULAR_FIXED=!1,i.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED=!1,i.INVERTCUBICMAP=!1,i.USESPHERICALFROMREFLECTIONMAP=!1,i.USESPHERICALINVERTEX=!1,i.REFLECTIONMAP_OPPOSITEZ=!1,i.LODINREFLECTIONALPHA=!1,i.GAMMAREFLECTION=!1;this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled?(e.MaterialHelper.PrepareDefinesForMergedUV(this._lightmapTexture,i,"LIGHTMAP"),i.USELIGHTMAPASSHADOWMAP=this._useLightmapAsShadowmap,i.GAMMALIGHTMAP=this._lightmapTexture.gammaSpace):i.LIGHTMAP=!1,this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled?e.MaterialHelper.PrepareDefinesForMergedUV(this._emissiveTexture,i,"EMISSIVE"):i.EMISSIVE=!1,e.StandardMaterial.SpecularTextureEnabled?(this._metallicTexture?(e.MaterialHelper.PrepareDefinesForMergedUV(this._metallicTexture,i,"REFLECTIVITY"),i.ROUGHNESSSTOREINMETALMAPALPHA=this._useRoughnessFromMetallicTextureAlpha,i.ROUGHNESSSTOREINMETALMAPGREEN=!this._useRoughnessFromMetallicTextureAlpha&&this._useRoughnessFromMetallicTextureGreen,i.METALLNESSSTOREINMETALMAPBLUE=this._useMetallnessFromMetallicTextureBlue,i.AOSTOREINMETALMAPRED=this._useAmbientOcclusionFromMetallicTextureRed):this._reflectivityTexture?(e.MaterialHelper.PrepareDefinesForMergedUV(this._reflectivityTexture,i,"REFLECTIVITY"),i.MICROSURFACEFROMREFLECTIVITYMAP=this._useMicroSurfaceFromReflectivityMapAlpha,i.MICROSURFACEAUTOMATIC=this._useAutoMicroSurfaceFromReflectivityMap):i.REFLECTIVITY=!1,this._microSurfaceTexture?e.MaterialHelper.PrepareDefinesForMergedUV(this._microSurfaceTexture,i,"MICROSURFACEMAP"):i.MICROSURFACEMAP=!1):(i.REFLECTIVITY=!1,i.MICROSURFACEMAP=!1),
o.getEngine().getCaps().standardDerivatives&&this._bumpTexture&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap?(e.MaterialHelper.PrepareDefinesForMergedUV(this._bumpTexture,i,"BUMP"),this._useParallax&&this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled?(i.PARALLAX=!0,i.PARALLAXOCCLUSION=!!this._useParallaxOcclusion):i.PARALLAX=!1,i.OBJECTSPACE_NORMALMAP=this._useObjectSpaceNormalMap):i.BUMP=!1;var l=this._getRefractionTexture();l&&e.StandardMaterial.RefractionTextureEnabled?(i.REFRACTION=!0,i.REFRACTIONMAP_3D=l.isCube,i.GAMMAREFRACTION=l.gammaSpace,i.REFRACTIONMAP_OPPOSITEZ=l.invertZ,i.LODINREFRACTIONALPHA=l.lodLevelInAlpha,this._linkRefractionWithTransparency&&(i.LINKREFRACTIONTOTRANSPARENCY=!0)):i.REFRACTION=!1,this._environmentBRDFTexture&&e.StandardMaterial.ReflectionTextureEnabled?i.ENVIRONMENTBRDF=!0:i.ENVIRONMENTBRDF=!1,this._shouldUseAlphaFromAlbedoTexture()?i.ALPHAFROMALBEDO=!0:i.ALPHAFROMALBEDO=!1}i.SPECULAROVERALPHA=this._useSpecularOverAlpha,i.USEPHYSICALLIGHTFALLOFF=this._usePhysicalLightFalloff,i.RADIANCEOVERALPHA=this._useRadianceOverAlpha,!this.backFaceCulling&&this._twoSidedLighting?i.TWOSIDEDLIGHTING=!0:i.TWOSIDEDLIGHTING=!1,i.ALPHATESTVALUE=this._alphaCutOff+(this._alphaCutOff%1==0?".":""),i.PREMULTIPLYALPHA=this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED||this.alphaMode===e.Engine.ALPHA_PREMULTIPLIED_PORTERDUFF,i.ALPHABLEND=this.needAlphaBlendingForMesh(t),i.ALPHAFRESNEL=this._useAlphaFresnel||this._useLinearAlphaFresnel,i.LINEARALPHAFRESNEL=this._useLinearAlphaFresnel,i.SPECULARAA=o.getEngine().getCaps().standardDerivatives&&this._enableSpecularAntiAliasing}i._areImageProcessingDirty&&this._imageProcessingConfiguration.prepareDefines(i),i.FORCENORMALFORWARD=this._forceNormalForward,i.RADIANCEOCCLUSION=this._useRadianceOcclusion,i.HORIZONOCCLUSION=this._useHorizonOcclusion,i._areMiscDirty&&(e.MaterialHelper.PrepareDefinesForMisc(t,o,this._useLogarithmicDepth,this.pointsCloud,this.fogEnabled,this._shouldTurnAlphaTestOn(t)||this._forceAlphaTest,i),i.UNLIT=this._unlit||(this.pointsCloud||this.wireframe)&&!t.isVerticesDataPresent(e.VertexBuffer.NormalKind)),e.MaterialHelper.PrepareDefinesForFrameBoundValues(o,s,i,!!r,n),e.MaterialHelper.PrepareDefinesForAttributes(t,i,!0,!0,!0,this._transparencyMode!==e.PBRMaterial.PBRMATERIAL_OPAQUE)},r.prototype.forceCompilation=function(e,i,r){var n=this,o=s({clipPlane:!1},r),a=new t,l=this._prepareEffect(e,a,void 0,void 0,void 0,o.clipPlane);l.isReady()?i&&i(this):l.onCompileObservable.add((function(){i&&i(n)}))},r.prototype.buildUniformLayout=function(){this._uniformBuffer.addUniform("vAlbedoInfos",2),this._uniformBuffer.addUniform("vAmbientInfos",3),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()},r.prototype.unbind=function(){this._reflectionTexture&&this._reflectionTexture.isRenderTarget&&this._uniformBuffer.setTexture("reflectionSampler",null),this._refractionTexture&&this._refractionTexture.isRenderTarget&&this._uniformBuffer.setTexture("refractionSampler",null),i.prototype.unbind.call(this)},r.prototype.bindForSubMesh=function(t,i,r){var n=this.getScene(),o=r._materialDefines;if(o){var s=r.effect;if(s){this._activeEffect=s,this.bindOnlyWorldMatrix(t),o.OBJECTSPACE_NORMALMAP&&(t.toNormalMatrix(this._normalMatrix),this.bindOnlyNormalMatrix(this._normalMatrix));var a=this._mustRebind(n,s,i.visibility);e.MaterialHelper.BindBonesParameters(i,this._activeEffect);var l=null;if(a){this._uniformBuffer.bindToEffect(s,"Material"),this.bindViewProjection(s),l=this._getReflectionTexture();var h=this._getRefractionTexture();if(!this._uniformBuffer.useUbo||!this.isFrozen||!this._uniformBuffer.isSync){if(n.texturesEnabled){if(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&(this._uniformBuffer.updateFloat2("vAlbedoInfos",this._albedoTexture.coordinatesIndex,this._albedoTexture.level),e.MaterialHelper.BindTextureMatrix(this._albedoTexture,this._uniformBuffer,"albedo")),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&(this._uniformBuffer.updateFloat3("vAmbientInfos",this._ambientTexture.coordinatesIndex,this._ambientTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._ambientTexture,this._uniformBuffer,"ambient")),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&(this._uniformBuffer.updateFloat2("vOpacityInfos",this._opacityTexture.coordinatesIndex,this._opacityTexture.level),e.MaterialHelper.BindTextureMatrix(this._opacityTexture,this._uniformBuffer,"opacity")),l&&e.StandardMaterial.ReflectionTextureEnabled){if(this._uniformBuffer.updateMatrix("reflectionMatrix",l.getReflectionTextureMatrix()),this._uniformBuffer.updateFloat2("vReflectionInfos",l.level,0),l.boundingBoxSize){var c=l;this._uniformBuffer.updateVector3("vReflectionPosition",c.boundingBoxPosition),this._uniformBuffer.updateVector3("vReflectionSize",c.boundingBoxSize)}var u=l.sphericalPolynomial;o.USESPHERICALFROMREFLECTIONMAP&&u&&(this._activeEffect.setFloat3("vSphericalX",u.x.x,u.x.y,u.x.z),this._activeEffect.setFloat3("vSphericalY",u.y.x,u.y.y,u.y.z),this._activeEffect.setFloat3("vSphericalZ",u.z.x,u.z.y,u.z.z),this._activeEffect.setFloat3("vSphericalXX_ZZ",u.xx.x-u.zz.x,u.xx.y-u.zz.y,u.xx.z-u.zz.z),this._activeEffect.setFloat3("vSphericalYY_ZZ",u.yy.x-u.zz.x,u.yy.y-u.zz.y,u.yy.z-u.zz.z),this._activeEffect.setFloat3("vSphericalZZ",u.zz.x,u.zz.y,u.zz.z),this._activeEffect.setFloat3("vSphericalXY",u.xy.x,u.xy.y,u.xy.z),this._activeEffect.setFloat3("vSphericalYZ",u.yz.x,u.yz.y,u.yz.z),this._activeEffect.setFloat3("vSphericalZX",u.zx.x,u.zx.y,u.zx.z)),this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos",l.getSize().width,l.lodGenerationScale,l.lodGenerationOffset)}if(this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&(this._uniformBuffer.updateFloat2("vEmissiveInfos",this._emissiveTexture.coordinatesIndex,this._emissiveTexture.level),e.MaterialHelper.BindTextureMatrix(this._emissiveTexture,this._uniformBuffer,"emissive")),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&(this._uniformBuffer.updateFloat2("vLightmapInfos",this._lightmapTexture.coordinatesIndex,this._lightmapTexture.level),e.MaterialHelper.BindTextureMatrix(this._lightmapTexture,this._uniformBuffer,"lightmap")),e.StandardMaterial.SpecularTextureEnabled&&(this._metallicTexture?(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._metallicTexture.coordinatesIndex,this._metallicTexture.level,this._ambientTextureStrength),e.MaterialHelper.BindTextureMatrix(this._metallicTexture,this._uniformBuffer,"reflectivity")):this._reflectivityTexture&&(this._uniformBuffer.updateFloat3("vReflectivityInfos",this._reflectivityTexture.coordinatesIndex,this._reflectivityTexture.level,1),e.MaterialHelper.BindTextureMatrix(this._reflectivityTexture,this._uniformBuffer,"reflectivity")),this._microSurfaceTexture&&(this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos",this._microSurfaceTexture.coordinatesIndex,this._microSurfaceTexture.level),e.MaterialHelper.BindTextureMatrix(this._microSurfaceTexture,this._uniformBuffer,"microSurfaceSampler"))),this._bumpTexture&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&(this._uniformBuffer.updateFloat3("vBumpInfos",this._bumpTexture.coordinatesIndex,this._bumpTexture.level,this._parallaxScaleBias),e.MaterialHelper.BindTextureMatrix(this._bumpTexture,this._uniformBuffer,"bump"),n._mirroredCameraPosition?this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?1:-1,this._invertNormalMapY?1:-1):this._uniformBuffer.updateFloat2("vTangentSpaceParams",this._invertNormalMapX?-1:1,this._invertNormalMapY?-1:1)),h&&e.StandardMaterial.RefractionTextureEnabled){this._uniformBuffer.updateMatrix("refractionMatrix",h.getReflectionTextureMatrix());var f=1;h.isCube||h.depth&&(f=h.depth),this._uniformBuffer.updateFloat4("vRefractionInfos",h.level,this._indexOfRefraction,f,this._invertRefractionY?-1:1),this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos",h.getSize().width,h.lodGenerationScale,h.lodGenerationOffset)}}this.pointsCloud&&this._uniformBuffer.updateFloat("pointSize",this.pointSize),o.METALLICWORKFLOW?(e.PBRMaterial._scaledReflectivity.r=void 0===this._metallic||null===this._metallic?1:this._metallic,e.PBRMaterial._scaledReflectivity.g=void 0===this._roughness||null===this._roughness?1:this._roughness,this._uniformBuffer.updateColor4("vReflectivityColor",e.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*i.visibility),this._lightingInfos.x=this._directIntensity,this._lightingInfos.y=this._emissiveIntensity,this._lightingInfos.z=this._environmentIntensity,this._lightingInfos.w=this._specularIntensity,this._uniformBuffer.updateVector4("vLightingIntensity",this._lightingInfos)}n.texturesEnabled&&(this._albedoTexture&&e.StandardMaterial.DiffuseTextureEnabled&&this._uniformBuffer.setTexture("albedoSampler",this._albedoTexture),this._ambientTexture&&e.StandardMaterial.AmbientTextureEnabled&&this._uniformBuffer.setTexture("ambientSampler",this._ambientTexture),this._opacityTexture&&e.StandardMaterial.OpacityTextureEnabled&&this._uniformBuffer.setTexture("opacitySampler",this._opacityTexture),l&&e.StandardMaterial.ReflectionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("reflectionSampler",l):(this._uniformBuffer.setTexture("reflectionSampler",l._lodTextureMid||l),this._uniformBuffer.setTexture("reflectionSamplerLow",l._lodTextureLow||l),this._uniformBuffer.setTexture("reflectionSamplerHigh",l._lodTextureHigh||l))),o.ENVIRONMENTBRDF&&this._uniformBuffer.setTexture("environmentBrdfSampler",this._environmentBRDFTexture),h&&e.StandardMaterial.RefractionTextureEnabled&&(o.LODBASEDMICROSFURACE?this._uniformBuffer.setTexture("refractionSampler",h):(this._uniformBuffer.setTexture("refractionSampler",h._lodTextureMid||h),this._uniformBuffer.setTexture("refractionSamplerLow",h._lodTextureLow||h),this._uniformBuffer.setTexture("refractionSamplerHigh",h._lodTextureHigh||h))),this._emissiveTexture&&e.StandardMaterial.EmissiveTextureEnabled&&this._uniformBuffer.setTexture("emissiveSampler",this._emissiveTexture),this._lightmapTexture&&e.StandardMaterial.LightmapTextureEnabled&&this._uniformBuffer.setTexture("lightmapSampler",this._lightmapTexture),e.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&&n.getEngine().getCaps().standardDerivatives&&e.StandardMaterial.BumpTextureEnabled&&!this._disableBumpMap&&this._uniformBuffer.setTexture("bumpSampler",this._bumpTexture)),e.MaterialHelper.BindClipPlane(this._activeEffect,n),n.ambientColor.multiplyToRef(this._ambientColor,this._globalAmbientColor);var p=n._forcedViewPosition?n._forcedViewPosition:n._mirroredCameraPosition?n._mirroredCameraPosition:n.activeCamera.globalPosition,d=n.useRightHandedSystem===(null!=n._mirroredCameraPosition);s.setFloat4("vEyePosition",p.x,p.y,p.z,d?-1:1),s.setColor3("vAmbientColor",this._globalAmbientColor)}!a&&this.isFrozen||(n.lightsEnabled&&!this._disableLighting&&e.MaterialHelper.BindLights(n,i,this._activeEffect,o,this._maxSimultaneousLights,this._usePhysicalLightFalloff),(n.fogEnabled&&i.applyFog&&n.fogMode!==e.Scene.FOGMODE_NONE||l)&&this.bindView(s),e.MaterialHelper.BindFogParameters(n,i,this._activeEffect),o.NUM_MORPH_INFLUENCERS&&e.MaterialHelper.BindMorphTargetParameters(i,this._activeEffect),this._imageProcessingConfiguration.bind(this._activeEffect),e.MaterialHelper.BindLogDepth(o,this._activeEffect,n)),this._uniformBuffer.update(),this._afterBind(i,this._activeEffect)}}},r.prototype.getAnimatables=function(){var e=[];return this._albedoTexture&&this._albedoTexture.animations&&this._albedoTexture.animations.length>0&&e.push(this._albedoTexture),this._ambientTexture&&this._ambientTexture.animations&&this._ambientTexture.animations.length>0&&e.push(this._ambientTexture),this._opacityTexture&&this._opacityTexture.animations&&this._opacityTexture.animations.length>0&&e.push(this._opacityTexture),this._reflectionTexture&&this._reflectionTexture.animations&&this._reflectionTexture.animations.length>0&&e.push(this._reflectionTexture),this._emissiveTexture&&this._emissiveTexture.animations&&this._emissiveTexture.animations.length>0&&e.push(this._emissiveTexture),this._metallicTexture&&this._metallicTexture.animations&&this._metallicTexture.animations.length>0?e.push(this._metallicTexture):this._reflectivityTexture&&this._reflectivityTexture.animations&&this._reflectivityTexture.animations.length>0&&e.push(this._reflectivityTexture),this._bumpTexture&&this._bumpTexture.animations&&this._bumpTexture.animations.length>0&&e.push(this._bumpTexture),this._lightmapTexture&&this._lightmapTexture.animations&&this._lightmapTexture.animations.length>0&&e.push(this._lightmapTexture),this._refractionTexture&&this._refractionTexture.animations&&this._refractionTexture.animations.length>0&&e.push(this._refractionTexture),e},r.prototype._getReflectionTexture=function(){return this._reflectionTexture?this._reflectionTexture:this.getScene().environmentTexture},r.prototype._getRefractionTexture=function(){return this._refractionTexture?this._refractionTexture:this._linkRefractionWithTransparency?this.getScene().environmentTexture:null},r.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),i.prototype.dispose.call(this,e,t)},r._scaledReflectivity=new e.Color3,n([e.serializeAsImageProcessingConfiguration()],r.prototype,"_imageProcessingConfiguration",void 0),n([e.serialize()],r.prototype,"useLogarithmicDepth",null),n([e.serialize()],r.prototype,"transparencyMode",null),r})(e.PushMaterial);e.PBRBaseMaterial=i})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.maxSimultaneousLights=4,n.disableLighting=!1,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.emissiveColor=new e.Color3(0,0,0),n.occlusionStrength=1,n.useLightmapAsShadowmap=!1,n._useAlphaFromAlbedoTexture=!0,n._useAmbientInGrayScale=!0,n}return o(i,t),Object.defineProperty(i.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}),i.prototype.getActiveTextures=function(){var e=t.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},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||this.lightmapTexture===e},i.prototype.getClassName=function(){return"PBRBaseSimpleMaterial"},n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectionTexture")],i.prototype,"environmentTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_bumpTexture")],i.prototype,"normalTexture",void 0),n([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTextureStrength")],i.prototype,"occlusionStrength",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_ambientTexture")],i.prototype,"occlusionTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_alphaCutOff")],i.prototype,"alphaCutOff",void 0),n([e.serialize()],i.prototype,"doubleSided",null),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],i.prototype,"lightmapTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),i})(e.PBRBaseMaterial);e.PBRBaseSimpleMaterial=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r){var n=t.call(this,i,r)||this;return n.directIntensity=1,n.emissiveIntensity=1,n.environmentIntensity=1,n.specularIntensity=1,n.disableBumpMap=!1,n.ambientTextureStrength=1,n.ambientColor=new e.Color3(0,0,0),n.albedoColor=new e.Color3(1,1,1),n.reflectivityColor=new e.Color3(1,1,1),n.reflectionColor=new e.Color3(1,1,1),n.emissiveColor=new e.Color3(0,0,0),n.microSurface=1,n.indexOfRefraction=.66,n.invertRefractionY=!1,n.linkRefractionWithTransparency=!1,n.useLightmapAsShadowmap=!1,n.useAlphaFromAlbedoTexture=!1,n.forceAlphaTest=!1,n.alphaCutOff=.4,n.useSpecularOverAlpha=!0,n.useMicroSurfaceFromReflectivityMapAlpha=!1,n.useRoughnessFromMetallicTextureAlpha=!0,n.useRoughnessFromMetallicTextureGreen=!1,n.useMetallnessFromMetallicTextureBlue=!1,n.useAmbientOcclusionFromMetallicTextureRed=!1,n.useAmbientInGrayScale=!1,n.useAutoMicroSurfaceFromReflectivityMap=!1,n.usePhysicalLightFalloff=!0,n.useRadianceOverAlpha=!0,n.useObjectSpaceNormalMap=!1,n.useParallax=!1,n.useParallaxOcclusion=!1,n.parallaxScaleBias=.05,n.disableLighting=!1,n.forceIrradianceInFragment=!1,n.maxSimultaneousLights=4,n.invertNormalMapX=!1,n.invertNormalMapY=!1,n.twoSidedLighting=!1,n.useAlphaFresnel=!1,n.useLinearAlphaFresnel=!1,n.environmentBRDFTexture=null,n.forceNormalForward=!1,n.enableSpecularAntiAliasing=!1,n.useHorizonOcclusion=!0,n.useRadianceOcclusion=!0,n.unlit=!1,n._environmentBRDFTexture=e.TextureTools.GetEnvironmentBRDFTexture(r),n}return o(i,t),Object.defineProperty(i,"PBRMATERIAL_OPAQUE",{get:function(){return this._PBRMATERIAL_OPAQUE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATEST",{get:function(){return this._PBRMATERIAL_ALPHATEST},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHABLEND",{get:function(){return this._PBRMATERIAL_ALPHABLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i,"PBRMATERIAL_ALPHATESTANDBLEND",{get:function(){return this._PBRMATERIAL_ALPHATESTANDBLEND},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"imageProcessingConfiguration",{get:function(){return this._imageProcessingConfiguration},set:function(e){this._attachImageProcessingConfiguration(e),this._markAllSubMeshesAsTexturesDirty()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurvesEnabled",{get:function(){return this.imageProcessingConfiguration.colorCurvesEnabled},set:function(e){this.imageProcessingConfiguration.colorCurvesEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingEnabled",{get:function(){return this.imageProcessingConfiguration.colorGradingEnabled},set:function(e){this.imageProcessingConfiguration.colorGradingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraToneMappingEnabled",{get:function(){return this._imageProcessingConfiguration.toneMappingEnabled},set:function(e){this._imageProcessingConfiguration.toneMappingEnabled=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraExposure",{get:function(){return this._imageProcessingConfiguration.exposure},set:function(e){this._imageProcessingConfiguration.exposure=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraContrast",{get:function(){return this._imageProcessingConfiguration.contrast},set:function(e){this._imageProcessingConfiguration.contrast=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorGradingTexture",{get:function(){return this._imageProcessingConfiguration.colorGradingTexture},set:function(e){this._imageProcessingConfiguration.colorGradingTexture=e},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"cameraColorCurves",{get:function(){return this._imageProcessingConfiguration.colorCurves},set:function(e){this._imageProcessingConfiguration.colorCurves=e},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"PBRMaterial"},i.prototype.getActiveTextures=function(){var e=t.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},i.prototype.hasTexture=function(e){return!!t.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)))))))))},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.id=t,n.name=t,n},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},i._PBRMATERIAL_OPAQUE=0,i._PBRMATERIAL_ALPHATEST=1,i._PBRMATERIAL_ALPHABLEND=2,i._PBRMATERIAL_ALPHATESTANDBLEND=3,n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"directIntensity",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveIntensity",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"environmentIntensity",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"specularIntensity",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"disableBumpMap",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"albedoTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientTextureStrength",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],i.prototype,"opacityTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectivityTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"metallicTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"metallic",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"microSurfaceTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"bumpTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty",null)],i.prototype,"lightmapTexture",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"refractionTexture",void 0),n([e.serializeAsColor3("ambient"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"ambientColor",void 0),n([e.serializeAsColor3("albedo"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"albedoColor",void 0),n([e.serializeAsColor3("reflectivity"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectivityColor",void 0),n([e.serializeAsColor3("reflection"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"reflectionColor",void 0),n([e.serializeAsColor3("emissive"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"emissiveColor",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"microSurface",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"indexOfRefraction",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertRefractionY",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"linkRefractionWithTransparency",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLightmapAsShadowmap",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],i.prototype,"useAlphaFromAlbedoTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],i.prototype,"forceAlphaTest",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesAndMiscDirty")],i.prototype,"alphaCutOff",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useSpecularOverAlpha",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useMicroSurfaceFromReflectivityMapAlpha",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRoughnessFromMetallicTextureAlpha",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRoughnessFromMetallicTextureGreen",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useMetallnessFromMetallicTextureBlue",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAmbientOcclusionFromMetallicTextureRed",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAmbientInGrayScale",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAutoMicroSurfaceFromReflectivityMap",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"usePhysicalLightFalloff",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRadianceOverAlpha",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useObjectSpaceNormalMap",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallax",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useParallaxOcclusion",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"parallaxScaleBias",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"disableLighting",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"forceIrradianceInFragment",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"maxSimultaneousLights",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapX",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"invertNormalMapY",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"twoSidedLighting",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useAlphaFresnel",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useLinearAlphaFresnel",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"environmentBRDFTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"forceNormalForward",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"enableSpecularAntiAliasing",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useHorizonOcclusion",void 0),
n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"useRadianceOcclusion",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsLightsDirty")],i.prototype,"unlit",void 0),i})(e.PBRBaseMaterial);e.PBRMaterial=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useRoughnessFromMetallicTextureAlpha=!1,r._useRoughnessFromMetallicTextureGreen=!0,r._useMetallnessFromMetallicTextureBlue=!0,r.metallic=1,r.roughness=1,r}return o(i,t),i.prototype.getClassName=function(){return"PBRMetallicRoughnessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.baseTexture&&e.push(this.baseTexture),this.metallicRoughnessTexture&&e.push(this.metallicRoughnessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.baseTexture===e||this.metallicRoughnessTexture===e)},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.id=t,n.name=t,n},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRMetallicRoughnessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},n([e.serializeAsColor3(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],i.prototype,"baseColor",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],i.prototype,"baseTexture",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"metallic",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty")],i.prototype,"roughness",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_metallicTexture")],i.prototype,"metallicRoughnessTexture",void 0),i})(e.PBRBaseSimpleMaterial);e.PBRMetallicRoughnessMaterial=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(e,i){var r=t.call(this,e,i)||this;return r._useMicroSurfaceFromReflectivityMapAlpha=!0,r}return o(i,t),i.prototype.getClassName=function(){return"PBRSpecularGlossinessMaterial"},i.prototype.getActiveTextures=function(){var e=t.prototype.getActiveTextures.call(this);return this.diffuseTexture&&e.push(this.diffuseTexture),this.specularGlossinessTexture&&e.push(this.specularGlossinessTexture),e},i.prototype.hasTexture=function(e){return!!t.prototype.hasTexture.call(this,e)||(this.diffuseTexture===e||this.specularGlossinessTexture===e)},i.prototype.clone=function(t){var r=this,n=e.SerializationHelper.Clone((function(){return new i(t,r.getScene())}),this);return n.id=t,n.name=t,n},i.prototype.serialize=function(){var t=e.SerializationHelper.Serialize(this);return t.customType="BABYLON.PBRSpecularGlossinessMaterial",t},i.Parse=function(t,r,n){return e.SerializationHelper.Parse((function(){return new i(t.name,r)}),t,r,n)},n([e.serializeAsColor3("diffuse"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoColor")],i.prototype,"diffuseColor",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_albedoTexture")],i.prototype,"diffuseTexture",void 0),n([e.serializeAsColor3("specular"),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityColor")],i.prototype,"specularColor",void 0),n([e.serialize(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_microSurface")],i.prototype,"glossiness",void 0),n([e.serializeAsTexture(),e.expandToProperty("_markAllSubMeshesAsTexturesDirty","_reflectivityTexture")],i.prototype,"specularGlossinessTexture",void 0),i})(e.PBRBaseSimpleMaterial);e.PBRSpecularGlossinessMaterial=t})(r||(r={}));var r;!(function(e){e.CameraInputTypes={};var t=(function(){function t(e){this.attached={},this.camera=e,this.checkInputs=function(){}}return t.prototype.add=function(t){var i=t.getSimpleName();if(this.attached[i])return void e.Tools.Warn("camera input of type "+i+" already exists on camera");this.attached[i]=t,t.camera=this.camera,t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t))),this.attachedElement&&t.attachControl(this.attachedElement)},t.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())}},t.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())}},t.prototype._addCheckInputs=function(e){var t=this.checkInputs;return function(){t(),e()}},t.prototype.attachInput=function(e){this.attachedElement&&e.attachControl(this.attachedElement,this.noPreventDefault)},t.prototype.attachElement=function(t,i){if(void 0===i&&(i=!1),!this.attachedElement){i=!e.Camera.ForceAttachControlToAlwaysPreventDefault&&i,this.attachedElement=t,this.noPreventDefault=i;for(var r in this.attached)this.attached[r].attachControl(t,i)}},t.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}},t.prototype.rebuildInputCheck=function(){this.checkInputs=function(){};for(var e in this.attached){var t=this.attached[e];t.checkInputs&&(this.checkInputs=this._addCheckInputs(t.checkInputs.bind(t)))}},t.prototype.clear=function(){this.attachedElement&&this.detachElement(this.attachedElement,!0),this.attached={},this.attachedElement=null,this.checkInputs=function(){}},t.prototype.serialize=function(t){var i={};for(var r in this.attached){var n=this.attached[r],o=e.SerializationHelper.Serialize(n);i[n.getClassName()]=o}t.inputsmgr=i},t.prototype.parse=function(t){var i=t.inputsmgr;if(i){this.clear();for(var r in i){var n=e.CameraInputTypes[r];if(n){var o=i[r],s=e.SerializationHelper.Parse((function(){return new n}),o,null);this.add(s)}}}else for(var r in this.attached){var n=e.CameraInputTypes[this.attached[r].getClassName()];if(n){var s=e.SerializationHelper.Parse((function(){return new n}),t,null);this.remove(this.attached[r]),this.add(s)}}},t})();e.CameraInputsManager=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r,n,o){void 0===o&&(o=!0);var s=t.call(this,i,r,n,o)||this;return s.cameraDirection=new e.Vector3(0,0,0),s.cameraRotation=new e.Vector2(0,0),s.rotation=new e.Vector3(0,0,0),s.speed=2,s.noRotationConstraint=!1,s.lockedTarget=null,s._currentTarget=e.Vector3.Zero(),s._viewMatrix=e.Matrix.Zero(),s._camMatrix=e.Matrix.Zero(),s._cameraTransformMatrix=e.Matrix.Zero(),s._cameraRotationMatrix=e.Matrix.Zero(),s._referencePoint=new e.Vector3(0,0,1),s._currentUpVector=new e.Vector3(0,1,0),s._transformedReferencePoint=e.Vector3.Zero(),s._globalCurrentTarget=e.Vector3.Zero(),s._globalCurrentUpVector=e.Vector3.Zero(),s}return o(i,t),i.prototype.getFrontPosition=function(e){this.getWorldMatrix();var t=this.getTarget().subtract(this.position);return t.normalize(),t.scaleInPlace(e),this.globalPosition.add(t)},i.prototype._getLockedTargetPosition=function(){return this.lockedTarget?(this.lockedTarget.absolutePosition&&this.lockedTarget.computeWorldMatrix(),this.lockedTarget.absolutePosition||this.lockedTarget):null},i.prototype.storeState=function(){return this._storedPosition=this.position.clone(),this._storedRotation=this.rotation.clone(),this.rotationQuaternion&&(this._storedRotationQuaternion=this.rotationQuaternion.clone()),t.prototype.storeState.call(this)},i.prototype._restoreStateValues=function(){return!!t.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)},i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache.lockedTarget=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotation=new e.Vector3(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE),this._cache.rotationQuaternion=new e.Quaternion(Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE)},i.prototype._updateCache=function(e){e||t.prototype._updateCache.call(this);var i=this._getLockedTargetPosition();i?this._cache.lockedTarget?this._cache.lockedTarget.copyFrom(i):this._cache.lockedTarget=i.clone():this._cache.lockedTarget=null,this._cache.rotation.copyFrom(this.rotation),this.rotationQuaternion&&this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion)},i.prototype._isSynchronizedViewMatrix=function(){if(!t.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))},i.prototype._computeLocalCameraSpeed=function(){var e=this.getEngine();return this.speed*Math.sqrt(e.getDeltaTime()/(100*e.getFps()))},i.prototype.setTarget=function(t){this.upVector.normalize(),e.Matrix.LookAtLHToRef(this.position,t,this.upVector,this._camMatrix),this._camMatrix.invert(),this.rotation.x=Math.atan(this._camMatrix.m[6]/this._camMatrix.m[10]);var i=t.subtract(this.position);i.x>=0?this.rotation.y=-Math.atan(i.z/i.x)+Math.PI/2:this.rotation.y=-Math.atan(i.z/i.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&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)},i.prototype.getTarget=function(){return this._currentTarget},i.prototype._decideIfNeedsToMove=function(){return Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){if(this.parent)return this.parent.getWorldMatrix().invertToRef(e.Tmp.Matrix[0]),e.Vector3.TransformNormalToRef(this.cameraDirection,e.Tmp.Matrix[0],e.Tmp.Vector3[0]),void this.position.addInPlace(e.Tmp.Vector3[0]);this.position.addInPlace(this.cameraDirection)},i.prototype._checkInputs=function(){var i=this._decideIfNeedsToMove(),r=Math.abs(this.cameraRotation.x)>0||Math.abs(this.cameraRotation.y)>0;if(i&&this._updatePosition(),r){if(this.rotation.x+=this.cameraRotation.x,this.rotation.y+=this.cameraRotation.y,this.rotationQuaternion){this.rotation.lengthSquared()&&e.Quaternion.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this.rotationQuaternion)}if(!this.noRotationConstraint){var n=Math.PI/2*.95;this.rotation.x>n&&(this.rotation.x=n),this.rotation.x<-n&&(this.rotation.x=-n)}}i&&(Math.abs(this.cameraDirection.x)<this.speed*e.Epsilon&&(this.cameraDirection.x=0),Math.abs(this.cameraDirection.y)<this.speed*e.Epsilon&&(this.cameraDirection.y=0),Math.abs(this.cameraDirection.z)<this.speed*e.Epsilon&&(this.cameraDirection.z=0),this.cameraDirection.scaleInPlace(this.inertia)),r&&(Math.abs(this.cameraRotation.x)<this.speed*e.Epsilon&&(this.cameraRotation.x=0),Math.abs(this.cameraRotation.y)<this.speed*e.Epsilon&&(this.cameraRotation.y=0),this.cameraRotation.scaleInPlace(this.inertia)),t.prototype._checkInputs.call(this)},i.prototype._updateCameraRotationMatrix=function(){this.rotationQuaternion?this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix):e.Matrix.RotationYawPitchRollToRef(this.rotation.y,this.rotation.x,this.rotation.z,this._cameraRotationMatrix),e.Vector3.TransformNormalToRef(this.upVector,this._cameraRotationMatrix,this._currentUpVector)},i.prototype._getViewMatrix=function(){return this.lockedTarget&&this.setTarget(this._getLockedTargetPosition()),this._updateCameraRotationMatrix(),e.Vector3.TransformCoordinatesToRef(this._referencePoint,this._cameraRotationMatrix,this._transformedReferencePoint),this.position.addToRef(this._transformedReferencePoint,this._currentTarget),this._computeViewMatrix(this.position,this._currentTarget,this._currentUpVector),this._viewMatrix},i.prototype._computeViewMatrix=function(t,i,r){if(this.parent){var n=this.parent.getWorldMatrix();e.Vector3.TransformCoordinatesToRef(this.position,n,this._globalPosition),e.Vector3.TransformCoordinatesToRef(i,n,this._globalCurrentTarget),e.Vector3.TransformNormalToRef(r,n,this._globalCurrentUpVector),this._markSyncedWithParent()}else this._globalPosition.copyFrom(this.position),this._globalCurrentTarget.copyFrom(i),this._globalCurrentUpVector.copyFrom(r);this.getScene().useRightHandedSystem?e.Matrix.LookAtRHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix):e.Matrix.LookAtLHToRef(this._globalPosition,this._globalCurrentTarget,this._globalCurrentUpVector,this._viewMatrix)},i.prototype.createRigCamera=function(t,r){if(this.cameraRigMode!==e.Camera.RIG_MODE_NONE){var n=new i(t,this.position.clone(),this.getScene());return this.cameraRigMode!==e.Camera.RIG_MODE_VR&&this.cameraRigMode!==e.Camera.RIG_MODE_WEBVR||(this.rotationQuaternion||(this.rotationQuaternion=new e.Quaternion),n._cameraRigParams={},n.rotationQuaternion=new e.Quaternion),n}return null},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:var n=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?1:-1,o=this.cameraRigMode===e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED?-1:1;this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*n,i.position),this._getRigCamPosition(this._cameraRigParams.stereoHalfAngle*o,r.position),i.setTarget(this.getTarget()),r.setTarget(this.getTarget());break;case e.Camera.RIG_MODE_VR:i.rotationQuaternion?(i.rotationQuaternion.copyFrom(this.rotationQuaternion),r.rotationQuaternion.copyFrom(this.rotationQuaternion)):(i.rotation.copyFrom(this.rotation),r.rotation.copyFrom(this.rotation)),i.position.copyFrom(this.position),r.position.copyFrom(this.position)}t.prototype._updateRigCameras.call(this)},i.prototype._getRigCamPosition=function(t,i){this._rigCamTransformMatrix||(this._rigCamTransformMatrix=new e.Matrix);var r=this.getTarget();e.Matrix.Translation(-r.x,-r.y,-r.z).multiplyToRef(e.Matrix.RotationY(t),this._rigCamTransformMatrix),this._rigCamTransformMatrix=this._rigCamTransformMatrix.multiply(e.Matrix.Translation(r.x,r.y,r.z)),e.Vector3.TransformCoordinatesToRef(this.position,this._rigCamTransformMatrix,i)},i.prototype.getClassName=function(){return"TargetCamera"},n([e.serializeAsVector3()],i.prototype,"rotation",void 0),n([e.serialize()],i.prototype,"speed",void 0),n([e.serializeAsMeshReference("lockedTargetId")],i.prototype,"lockedTarget",void 0),i})(e.Camera);e.TargetCamera=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(e){void 0===e&&(e=!0),this.touchEnabled=e,this.buttons=[0,1,2],this.angularSensibility=2e3,this.previousPosition=null}return t.prototype.attachControl=function(t,i){var r=this,n=this.camera.getEngine();this._pointerInput||(this._pointerInput=function(o,s){var a=o.event;if(!n.isInVRExclusivePointerMode&&(r.touchEnabled||"touch"!==a.pointerType)&&(o.type===e.PointerEventTypes.POINTERMOVE||-1!==r.buttons.indexOf(a.button))){var l=a.srcElement||a.target;if(o.type===e.PointerEventTypes.POINTERDOWN&&l){try{l.setPointerCapture(a.pointerId)}catch(e){}r.previousPosition={x:a.clientX,y:a.clientY},i||(a.preventDefault(),t.focus())}else if(o.type===e.PointerEventTypes.POINTERUP&&l){try{l.releasePointerCapture(a.pointerId)}catch(e){}r.previousPosition=null,i||a.preventDefault()}else if(o.type===e.PointerEventTypes.POINTERMOVE){if(!r.previousPosition||n.isPointerLock)return;var h=a.clientX-r.previousPosition.x;r.camera.getScene().useRightHandedSystem&&(h*=-1),r.camera.parent&&r.camera.parent._getWorldMatrixDeterminant()<0&&(h*=-1),r.camera.cameraRotation.y+=h/r.angularSensibility;var c=a.clientY-r.previousPosition.y;r.camera.cameraRotation.x+=c/r.angularSensibility,r.previousPosition={x:a.clientX,y:a.clientY},i||a.preventDefault()}}}),this._onMouseMove=function(e){if(n.isPointerLock&&!n.isInVRExclusivePointerMode){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0;r.camera.getScene().useRightHandedSystem&&(t*=-1),r.camera.parent&&r.camera.parent._getWorldMatrixDeterminant()<0&&(t*=-1),r.camera.cameraRotation.y+=t/r.angularSensibility;var o=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;r.camera.cameraRotation.x+=o/r.angularSensibility,r.previousPosition=null,i||e.preventDefault()}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE),t.addEventListener("mousemove",this._onMouseMove,!1)},t.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)},t.prototype.getClassName=function(){return"FreeCameraMouseInput"},t.prototype.getSimpleName=function(){return"mouse"},n([e.serialize()],t.prototype,"buttons",void 0),n([e.serialize()],t.prototype,"angularSensibility",void 0),t})();e.FreeCameraMouseInput=t,e.CameraInputTypes.FreeCameraMouseInput=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this._keys=new Array,this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39]}return t.prototype.attachControl=function(t,i){var r=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){r._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(t){var n=t.event;if(t.type===e.KeyboardEventTypes.KEYDOWN){if(-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);-1===o&&r._keys.push(n.keyCode),i||n.preventDefault()}}else if(-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);o>=0&&r._keys.splice(o,1),i||n.preventDefault()}})))},t.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=[]},t.prototype.checkInputs=function(){if(this._onKeyboardObserver)for(var t=this.camera,i=0;i<this._keys.length;i++){var r=this._keys[i],n=t._computeLocalCameraSpeed();-1!==this.keysLeft.indexOf(r)?t._localDirection.copyFromFloats(-n,0,0):-1!==this.keysUp.indexOf(r)?t._localDirection.copyFromFloats(0,0,n):-1!==this.keysRight.indexOf(r)?t._localDirection.copyFromFloats(n,0,0):-1!==this.keysDown.indexOf(r)&&t._localDirection.copyFromFloats(0,0,-n),t.getScene().useRightHandedSystem&&(t._localDirection.z*=-1),t.getViewMatrix().invertToRef(t._cameraTransformMatrix),e.Vector3.TransformNormalToRef(t._localDirection,t._cameraTransformMatrix,t._transformedDirection),t.cameraDirection.addInPlace(t._transformedDirection)}},t.prototype.getClassName=function(){return"FreeCameraKeyboardMoveInput"},t.prototype._onLostFocus=function(e){this._keys=[]},t.prototype.getSimpleName=function(){return"keyboard"},n([e.serialize()],t.prototype,"keysUp",void 0),n([e.serialize()],t.prototype,"keysDown",void 0),n([e.serialize()],t.prototype,"keysLeft",void 0),n([e.serialize()],t.prototype,"keysRight",void 0),t})();e.FreeCameraKeyboardMoveInput=t,e.CameraInputTypes.FreeCameraKeyboardMoveInput=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return o(i,t),i.prototype.addKeyboard=function(){return this.add(new e.FreeCameraKeyboardMoveInput),this},i.prototype.addMouse=function(t){return void 0===t&&(t=!0),this.add(new e.FreeCameraMouseInput(t)),this},i.prototype.addGamepad=function(){return this.add(new e.FreeCameraGamepadInput),this},i.prototype.addDeviceOrientation=function(){return this.add(new e.FreeCameraDeviceOrientationInput),this},i.prototype.addTouch=function(){return this.add(new e.FreeCameraTouchInput),this},i.prototype.addVirtualJoystick=function(){return this.add(new e.FreeCameraVirtualJoystickInput),this},i})(e.CameraInputsManager);e.FreeCameraInputsManager=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r,n,o){void 0===o&&(o=!0);var s=t.call(this,i,r,n,o)||this;return s.ellipsoid=new e.Vector3(.5,1,.5),s.ellipsoidOffset=new e.Vector3(0,0,0),s.checkCollisions=!1,s.applyGravity=!1,s._needMoveForGravity=!1,s._oldPosition=e.Vector3.Zero(),s._diffPosition=e.Vector3.Zero(),s._newPosition=e.Vector3.Zero(),s._collisionMask=-1,s._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),s.getScene().workerCollisions&&i.multiplyInPlace(s._collider._radius);!(function(t){s._newPosition.copyFrom(t),s._newPosition.subtractToRef(s._oldPosition,s._diffPosition),s._diffPosition.length()>e.Engine.CollisionsEpsilon&&(s.position.addInPlace(s._diffPosition),s.onCollide&&r&&s.onCollide(r))})(i)},s.inputs=new e.FreeCameraInputsManager(s),s.inputs.addKeyboard().addMouse(),s}return o(i,t),Object.defineProperty(i.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(i.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(i.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(i.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(i.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}),i.prototype.attachControl=function(e,t){this.inputs.attachElement(e,t)},i.prototype.detachControl=function(t){this.inputs.detachElement(t),this.cameraDirection=new e.Vector3(0,0,0),this.cameraRotation=new e.Vector2(0,0)},Object.defineProperty(i.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),i.prototype._collideWithWorld=function(t){var i;i=this.parent?e.Vector3.TransformCoordinates(this.position,this.parent.getWorldMatrix()):this.position,i.subtractFromFloatsToRef(0,this.ellipsoid.y,0,this._oldPosition),this._oldPosition.addInPlace(this.ellipsoidOffset),this._collider||(this._collider=new e.Collider),this._collider._radius=this.ellipsoid,this._collider.collisionMask=this._collisionMask;var r=t;this.applyGravity&&(r=t.add(this.getScene().gravity)),this.getScene().collisionCoordinator.getNewPosition(this._oldPosition,r,this._collider,3,null,this._onCollisionPositionChange,this.uniqueId)},i.prototype._checkInputs=function(){this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this.inputs.checkInputs(),t.prototype._checkInputs.call(this)},i.prototype._decideIfNeedsToMove=function(){return this._needMoveForGravity||Math.abs(this.cameraDirection.x)>0||Math.abs(this.cameraDirection.y)>0||Math.abs(this.cameraDirection.z)>0},i.prototype._updatePosition=function(){this.checkCollisions&&this.getScene().collisionsEnabled?this._collideWithWorld(this.cameraDirection):t.prototype._updatePosition.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"FreeCamera"},n([e.serializeAsVector3()],i.prototype,"ellipsoid",void 0),n([e.serializeAsVector3()],i.prototype,"ellipsoidOffset",void 0),n([e.serialize()],i.prototype,"checkCollisions",void 0),n([e.serialize()],i.prototype,"applyGravity",void 0),i})(e.TargetCamera);e.FreeCamera=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this._keys=new Array,this.keysUp=[38],this.keysDown=[40],this.keysLeft=[37],this.keysRight=[39],this.keysReset=[220],this.panningSensibility=50,this.zoomingSensibility=25,this.useAltToZoom=!0}return t.prototype.attachControl=function(t,i){var r=this;this._onCanvasBlurObserver||(this._scene=this.camera.getScene(),this._engine=this._scene.getEngine(),this._onCanvasBlurObserver=this._engine.onCanvasBlurObservable.add((function(){r._keys=[]})),this._onKeyboardObserver=this._scene.onKeyboardObservable.add((function(t){var n=t.event;if(t.type===e.KeyboardEventTypes.KEYDOWN){if(r._ctrlPressed=n.ctrlKey,r._altPressed=n.altKey,-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)||-1!==r.keysReset.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);-1===o&&r._keys.push(n.keyCode),n.preventDefault&&(i||n.preventDefault())}}else if(-1!==r.keysUp.indexOf(n.keyCode)||-1!==r.keysDown.indexOf(n.keyCode)||-1!==r.keysLeft.indexOf(n.keyCode)||-1!==r.keysRight.indexOf(n.keyCode)||-1!==r.keysReset.indexOf(n.keyCode)){var o=r._keys.indexOf(n.keyCode);o>=0&&r._keys.splice(o,1),n.preventDefault&&(i||n.preventDefault())}})))},t.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=[]},t.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-=.01:-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-=.01:-1!==this.keysRight.indexOf(i)?this._ctrlPressed&&this.camera._useCtrlForPanning?e.inertialPanningX+=1/this.panningSensibility:e.inertialAlphaOffset+=.01:-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+=.01:-1!==this.keysReset.indexOf(i)&&e.restoreState()}},t.prototype.getClassName=function(){return"ArcRotateCameraKeyboardMoveInput"},t.prototype.getSimpleName=function(){return"keyboard"},n([e.serialize()],t.prototype,"keysUp",void 0),n([e.serialize()],t.prototype,"keysDown",void 0),n([e.serialize()],t.prototype,"keysLeft",void 0),n([e.serialize()],t.prototype,"keysRight",void 0),n([e.serialize()],t.prototype,"keysReset",void 0),n([e.serialize()],t.prototype,"panningSensibility",void 0),n([e.serialize()],t.prototype,"zoomingSensibility",void 0),n([e.serialize()],t.prototype,"useAltToZoom",void 0),t})();e.ArcRotateCameraKeyboardMoveInput=t,e.CameraInputTypes.ArcRotateCameraKeyboardMoveInput=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this.wheelPrecision=3,this.wheelDeltaPercentage=0}return t.prototype.attachControl=function(t,i){var r=this;this._wheel=function(t,n){if(t.type===e.PointerEventTypes.POINTERWHEEL){var o=t.event,s=0;if(o.wheelDelta)if(r.wheelDeltaPercentage){var a=.01*o.wheelDelta*r.wheelDeltaPercentage*r.camera.radius;s=o.wheelDelta>0?a/(1+r.wheelDeltaPercentage):a*(1+r.wheelDeltaPercentage)}else s=o.wheelDelta/(40*r.wheelPrecision);else o.detail&&(s=-o.detail/r.wheelPrecision);s&&(r.camera.inertialRadiusOffset+=s),o.preventDefault&&(i||o.preventDefault())}},this._observer=this.camera.getScene().onPointerObservable.add(this._wheel,e.PointerEventTypes.POINTERWHEEL)},t.prototype.detachControl=function(e){this._observer&&e&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._wheel=null)},t.prototype.getClassName=function(){return"ArcRotateCameraMouseWheelInput"},t.prototype.getSimpleName=function(){return"mousewheel"},n([e.serialize()],t.prototype,"wheelPrecision",void 0),n([e.serialize()],t.prototype,"wheelDeltaPercentage",void 0),t})();e.ArcRotateCameraMouseWheelInput=t,e.CameraInputTypes.ArcRotateCameraMouseWheelInput=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){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._isPanClick=!1,this.pinchInwards=!0}return t.prototype.attachControl=function(t,i){var r,n=this,o=this.camera.getEngine(),s=null,a=null,l=0,h=0,c=0,u={x:0,y:0,isPaning:!1,isPinching:!1};this._pointerInput=function(f,p){var d=f.event,m="touch"===f.event.pointerType;if(!o.isInVRExclusivePointerMode&&(f.type===e.PointerEventTypes.POINTERMOVE||-1!==n.buttons.indexOf(d.button))){var _=d.srcElement||d.target;if(f.type===e.PointerEventTypes.POINTERDOWN&&_){try{_.setPointerCapture(d.pointerId)}catch(e){}n._isPanClick=d.button===n.camera._panningMouseButton,r={x:d.clientX,y:d.clientY,pointerId:d.pointerId,type:d.pointerType},null===s?s=r:null===a&&(a=r),i||(d.preventDefault(),t.focus())}else if(f.type===e.PointerEventTypes.POINTERDOUBLETAP)n.camera.restoreState();else if(f.type===e.PointerEventTypes.POINTERUP&&_){try{_.releasePointerCapture(d.pointerId)}catch(e){}r=null,l=0,u.isPaning=!1,u.isPinching=!1,c=0,h=0,m||(a=null),o._badOS?s=a=null:a&&s&&s.pointerId==d.pointerId?(s=a,a=null,r={x:s.x,y:s.y,pointerId:s.pointerId,type:d.pointerType}):s&&a&&a.pointerId==d.pointerId?(a=null,r={x:s.x,y:s.y,pointerId:s.pointerId,type:d.pointerType}):s=a=null,i||d.preventDefault()}else if(f.type===e.PointerEventTypes.POINTERMOVE)if(i||d.preventDefault(),s&&null===a&&r){if(0!==n.panningSensibility&&(d.ctrlKey&&n.camera._useCtrlForPanning||n._isPanClick))n.camera.inertialPanningX+=-(d.clientX-r.x)/n.panningSensibility,n.camera.inertialPanningY+=(d.clientY-r.y)/n.panningSensibility;else{var g=d.clientX-r.x,v=d.clientY-r.y;n.camera.inertialAlphaOffset-=g/n.angularSensibilityX,n.camera.inertialBetaOffset-=v/n.angularSensibilityY}r.x=d.clientX,r.y=d.clientY}else if(s&&a){var y=s.pointerId===d.pointerId?s:a;y.x=d.clientX,y.y=d.clientY;var b=n.pinchInwards?1:-1,x=s.x-a.x,T=s.y-a.y,E=x*x+T*T,P=Math.sqrt(E);if(0===l)return h=P,l=E,u.x=(s.x+a.x)/2,void(u.y=(s.y+a.y)/2);if(n.multiTouchPanAndZoom){if(n.pinchDeltaPercentage?n.camera.inertialRadiusOffset+=.001*(E-l)*n.camera.radius*n.pinchDeltaPercentage:n.camera.inertialRadiusOffset+=(E-l)/(n.pinchPrecision*((n.angularSensibilityX+n.angularSensibilityY)/2)*b),0!==n.panningSensibility){var A=(s.x+a.x)/2,M=(s.y+a.y)/2,S=A-u.x,C=M-u.y;u.x=A,u.y=M,n.camera.inertialPanningX+=-S/n.panningSensibility,n.camera.inertialPanningY+=C/n.panningSensibility}}else{if(c++,
u.isPinching||c<20&&Math.abs(P-h)>n.camera.pinchToPanMaxDistance)n.pinchDeltaPercentage?n.camera.inertialRadiusOffset+=.001*(E-l)*n.camera.radius*n.pinchDeltaPercentage:n.camera.inertialRadiusOffset+=(E-l)/(n.pinchPrecision*((n.angularSensibilityX+n.angularSensibilityY)/2)*b),u.isPaning=!1,u.isPinching=!0;else if(r&&r.pointerId===y.pointerId&&0!==n.panningSensibility&&n.multiTouchPanning){if(!u.isPaning)return u.isPaning=!0,u.isPinching=!1,u.x=y.x,void(u.y=y.y);n.camera.inertialPanningX+=-(y.x-u.x)/n.panningSensibility,n.camera.inertialPanningY+=(y.y-u.y)/n.panningSensibility}r&&r.pointerId===d.pointerId&&(u.x=y.x,u.y=y.y)}l=E}}},this._observer=this.camera.getScene().onPointerObservable.add(this._pointerInput,e.PointerEventTypes.POINTERDOWN|e.PointerEventTypes.POINTERUP|e.PointerEventTypes.POINTERMOVE|e.PointerEventTypes._POINTERDOUBLETAP),this._onContextMenu=function(e){e.preventDefault()},this.camera._useCtrlForPanning||t.addEventListener("contextmenu",this._onContextMenu,!1),this._onLostFocus=function(){s=a=null,l=0,u.isPaning=!1,u.isPinching=!1,c=0,r=null,h=0},this._onMouseMove=function(e){if(o.isPointerLock){var t=e.movementX||e.mozMovementX||e.webkitMovementX||e.msMovementX||0,r=e.movementY||e.mozMovementY||e.webkitMovementY||e.msMovementY||0;n.camera.inertialAlphaOffset-=t/n.angularSensibilityX,n.camera.inertialBetaOffset-=r/n.angularSensibilityY,i||e.preventDefault()}},this._onGestureStart=function(e){void 0!==window.MSGesture&&(n._MSGestureHandler||(n._MSGestureHandler=new MSGesture,n._MSGestureHandler.target=t),n._MSGestureHandler.addPointer(e.pointerId))},this._onGesture=function(e){n.camera.radius*=e.scale,e.preventDefault&&(i||(e.stopPropagation(),e.preventDefault()))},t.addEventListener("mousemove",this._onMouseMove,!1),t.addEventListener("MSPointerDown",this._onGestureStart,!1),t.addEventListener("MSGestureChange",this._onGesture,!1),e.Tools.RegisterTopRootEvents([{name:"blur",handler:this._onLostFocus}])},t.prototype.detachControl=function(t){this._onLostFocus&&e.Tools.UnregisterTopRootEvents([{name:"blur",handler:this._onLostFocus}]),t&&this._observer&&(this.camera.getScene().onPointerObservable.remove(this._observer),this._observer=null,this._onContextMenu&&t.removeEventListener("contextmenu",this._onContextMenu),this._onMouseMove&&t.removeEventListener("mousemove",this._onMouseMove),this._onGestureStart&&t.removeEventListener("MSPointerDown",this._onGestureStart),this._onGesture&&t.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)},t.prototype.getClassName=function(){return"ArcRotateCameraPointersInput"},t.prototype.getSimpleName=function(){return"pointers"},n([e.serialize()],t.prototype,"buttons",void 0),n([e.serialize()],t.prototype,"angularSensibilityX",void 0),n([e.serialize()],t.prototype,"angularSensibilityY",void 0),n([e.serialize()],t.prototype,"pinchPrecision",void 0),n([e.serialize()],t.prototype,"pinchDeltaPercentage",void 0),n([e.serialize()],t.prototype,"panningSensibility",void 0),n([e.serialize()],t.prototype,"multiTouchPanning",void 0),n([e.serialize()],t.prototype,"multiTouchPanAndZoom",void 0),t})();e.ArcRotateCameraPointersInput=t,e.CameraInputTypes.ArcRotateCameraPointersInput=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(e){return t.call(this,e)||this}return o(i,t),i.prototype.addMouseWheel=function(){return this.add(new e.ArcRotateCameraMouseWheelInput),this},i.prototype.addPointers=function(){return this.add(new e.ArcRotateCameraPointersInput),this},i.prototype.addKeyboard=function(){return this.add(new e.ArcRotateCameraKeyboardMoveInput),this},i.prototype.addGamepad=function(){return this.add(new e.ArcRotateCameraGamepadInput),this},i.prototype.addVRDeviceOrientation=function(){return this.add(new e.ArcRotateCameraVRDeviceOrientationInput),this},i})(e.CameraInputsManager);e.ArcRotateCameraInputsManager=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l){void 0===l&&(l=!0);var h=t.call(this,i,e.Vector3.Zero(),a,l)||this;return h.inertialAlphaOffset=0,h.inertialBetaOffset=0,h.inertialRadiusOffset=0,h.lowerAlphaLimit=null,h.upperAlphaLimit=null,h.lowerBetaLimit=.01,h.upperBetaLimit=Math.PI,h.lowerRadiusLimit=null,h.upperRadiusLimit=null,h.inertialPanningX=0,h.inertialPanningY=0,h.pinchToPanMaxDistance=20,h.panningDistanceLimit=null,h.panningOriginTarget=e.Vector3.Zero(),h.panningInertia=.9,h.zoomOnFactor=1,h.targetScreenOffset=e.Vector2.Zero(),h.allowUpsideDown=!0,h._viewMatrix=new e.Matrix,h.panningAxis=new e.Vector3(1,1,0),h.onMeshTargetChangedObservable=new e.Observable,h.checkCollisions=!1,h.collisionRadius=new e.Vector3(.5,.5,.5),h._previousPosition=e.Vector3.Zero(),h._collisionVelocity=e.Vector3.Zero(),h._newPosition=e.Vector3.Zero(),h._computationVector=e.Vector3.Zero(),h._onCollisionPositionChange=function(t,i,r){void 0===r&&(r=null),h.getScene().workerCollisions&&h.checkCollisions&&i.multiplyInPlace(h._collider._radius),r?(h.setPosition(i),h.onCollide&&h.onCollide(r)):h._previousPosition.copyFrom(h.position);var n=Math.cos(h.alpha),o=Math.sin(h.alpha),s=Math.cos(h.beta),a=Math.sin(h.beta);0===a&&(a=1e-4);var l=h._getTargetPosition();h._computationVector.copyFromFloats(h.radius*n*a,h.radius*s,h.radius*o*a),l.addToRef(h._computationVector,h._newPosition),h.position.copyFrom(h._newPosition);var c=h.upVector;h.allowUpsideDown&&h.beta<0&&(c=c.clone(),c=c.negate()),e.Matrix.LookAtLHToRef(h.position,l,c,h._viewMatrix),h._viewMatrix.m[12]+=h.targetScreenOffset.x,h._viewMatrix.m[13]+=h.targetScreenOffset.y,h._collisionTriggered=!1},h._target=e.Vector3.Zero(),s&&h.setTarget(s),h.alpha=r,h.beta=n,h.radius=o,h.getViewMatrix(),h.inputs=new e.ArcRotateCameraInputsManager(h),h.inputs.addKeyboard().addMouseWheel().addPointers(),h}return o(i,t),Object.defineProperty(i.prototype,"target",{get:function(){return this._target},set:function(e){this.setTarget(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.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(i.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(i.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(i.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(i.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(i.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(i.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(i.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(i.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(i.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(i.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(i.prototype,"bouncingBehavior",{get:function(){return this._bouncingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useBouncingBehavior",{get:function(){return null!=this._bouncingBehavior},set:function(t){t!==this.useBouncingBehavior&&(t?(this._bouncingBehavior=new e.BouncingBehavior,this.addBehavior(this._bouncingBehavior)):this._bouncingBehavior&&(this.removeBehavior(this._bouncingBehavior),this._bouncingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"framingBehavior",{get:function(){return this._framingBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useFramingBehavior",{get:function(){return null!=this._framingBehavior},set:function(t){t!==this.useFramingBehavior&&(t?(this._framingBehavior=new e.FramingBehavior,this.addBehavior(this._framingBehavior)):this._framingBehavior&&(this.removeBehavior(this._framingBehavior),this._framingBehavior=null))},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"autoRotationBehavior",{get:function(){return this._autoRotationBehavior},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"useAutoRotationBehavior",{get:function(){return null!=this._autoRotationBehavior},set:function(t){t!==this.useAutoRotationBehavior&&(t?(this._autoRotationBehavior=new e.AutoRotationBehavior,this.addBehavior(this._autoRotationBehavior)):this._autoRotationBehavior&&(this.removeBehavior(this._autoRotationBehavior),this._autoRotationBehavior=null))},enumerable:!0,configurable:!0}),i.prototype._initCache=function(){t.prototype._initCache.call(this),this._cache._target=new e.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=e.Vector2.Zero()},i.prototype._updateCache=function(e){e||t.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)},i.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},i.prototype.storeState=function(){return this._storedAlpha=this.alpha,this._storedBeta=this.beta,this._storedRadius=this.radius,this._storedTarget=this._getTargetPosition().clone(),t.prototype.storeState.call(this)},i.prototype._restoreStateValues=function(){return!!t.prototype._restoreStateValues.call(this)&&(this.alpha=this._storedAlpha,this.beta=this._storedBeta,this.radius=this._storedRadius,this.setTarget(this._storedTarget.clone()),this.inertialAlphaOffset=0,this.inertialBetaOffset=0,this.inertialRadiusOffset=0,this.inertialPanningX=0,this.inertialPanningY=0,!0)},i.prototype._isSynchronizedViewMatrix=function(){return!!t.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))},i.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}},i.prototype.detachControl=function(e){this.inputs.detachElement(e),this._reset&&this._reset()},i.prototype._checkInputs=function(){if(!this._collisionTriggered){if(this.inputs.checkInputs(),0!==this.inertialAlphaOffset||0!==this.inertialBetaOffset||0!==this.inertialRadiusOffset){var i=this.inertialAlphaOffset;this.beta<=0&&(i*=-1),this.getScene().useRightHandedSystem&&(i*=-1),this.parent&&this.parent._getWorldMatrixDeterminant()<0&&(i*=-1),this.alpha+=i,this.beta+=this.inertialBetaOffset,this.radius-=this.inertialRadiusOffset,this.inertialAlphaOffset*=this.inertia,this.inertialBetaOffset*=this.inertia,this.inertialRadiusOffset*=this.inertia,Math.abs(this.inertialAlphaOffset)<e.Epsilon&&(this.inertialAlphaOffset=0),Math.abs(this.inertialBetaOffset)<e.Epsilon&&(this.inertialBetaOffset=0),Math.abs(this.inertialRadiusOffset)<this.speed*e.Epsilon&&(this.inertialRadiusOffset=0)}if(0!==this.inertialPanningX||0!==this.inertialPanningY){if(this._localDirection||(this._localDirection=e.Vector3.Zero(),this._transformedDirection=e.Vector3.Zero()),this._localDirection.copyFromFloats(this.inertialPanningX,this.inertialPanningY,this.inertialPanningY),this._localDirection.multiplyInPlace(this.panningAxis),this._viewMatrix.invertToRef(this._cameraTransformMatrix),e.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);var r=e.Vector3.DistanceSquared(this._transformedDirection,this.panningOriginTarget);r<=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*e.Epsilon&&(this.inertialPanningX=0),Math.abs(this.inertialPanningY)<this.speed*e.Epsilon&&(this.inertialPanningY=0)}this._checkLimits(),t.prototype._checkInputs.call(this)}},i.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),this.lowerAlphaLimit&&this.alpha<this.lowerAlphaLimit&&(this.alpha=this.lowerAlphaLimit),this.upperAlphaLimit&&this.alpha>this.upperAlphaLimit&&(this.alpha=this.upperAlphaLimit),this.lowerRadiusLimit&&this.radius<this.lowerRadiusLimit&&(this.radius=this.lowerRadiusLimit),this.upperRadiusLimit&&this.radius>this.upperRadiusLimit&&(this.radius=this.upperRadiusLimit)},i.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()},i.prototype.setPosition=function(e){this.position.equals(e)||(this.position.copyFrom(e),this.rebuildAnglesAndRadius())},i.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()},i.prototype._getViewMatrix=function(){var t=Math.cos(this.alpha),i=Math.sin(this.alpha),r=Math.cos(this.beta),n=Math.sin(this.beta);0===n&&(n=1e-4);var o=this._getTargetPosition();if(this._computationVector.copyFromFloats(this.radius*t*n,this.radius*r,this.radius*i*n),o.addToRef(this._computationVector,this._newPosition),this.getScene().collisionsEnabled&&this.checkCollisions)this._collider||(this._collider=new e.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 s=this.upVector;this.allowUpsideDown&&n<0&&(s=s.clone(),s=s.negate()),this._computeViewMatrix(this.position,o,s),this._viewMatrix.m[12]+=this.targetScreenOffset.x,this._viewMatrix.m[13]+=this.targetScreenOffset.y}return this._currentTarget=o,this._viewMatrix},i.prototype.zoomOn=function(t,i){void 0===i&&(i=!1),t=t||this.getScene().meshes;var r=e.Mesh.MinMax(t),n=e.Vector3.Distance(r.min,r.max);this.radius=n*this.zoomOnFactor,this.focusOn({min:r.min,max:r.max,distance:n},i)},i.prototype.focusOn=function(t,i){void 0===i&&(i=!1);var r,n;if(void 0===t.min){var o=t||this.getScene().meshes;r=e.Mesh.MinMax(o),n=e.Vector3.Distance(r.min,r.max)}else{var s=t;r=s,n=s.distance}this._target=e.Mesh.Center(r),i||(this.maxZ=2*n)},i.prototype.createRigCamera=function(t,r){var n=0;switch(this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:n=this._cameraRigParams.stereoHalfAngle*(0===r?1:-1);break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:n=this._cameraRigParams.stereoHalfAngle*(0===r?-1:1)}var o=new i(t,this.alpha+n,this.beta,this.radius,this._target,this.getScene());return o._cameraRigParams={},o},i.prototype._updateRigCameras=function(){var i=this._rigCameras[0],r=this._rigCameras[1];switch(i.beta=r.beta=this.beta,i.radius=r.radius=this.radius,this.cameraRigMode){case e.Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:case e.Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:case e.Camera.RIG_MODE_VR:i.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle;break;case e.Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:i.alpha=this.alpha+this._cameraRigParams.stereoHalfAngle,r.alpha=this.alpha-this._cameraRigParams.stereoHalfAngle}t.prototype._updateRigCameras.call(this)},i.prototype.dispose=function(){this.inputs.clear(),t.prototype.dispose.call(this)},i.prototype.getClassName=function(){return"ArcRotateCamera"},n([e.serialize()],i.prototype,"alpha",void 0),n([e.serialize()],i.prototype,"beta",void 0),n([e.serialize()],i.prototype,"radius",void 0),n([e.serializeAsVector3("target")],i.prototype,"_target",void 0),n([e.serialize()],i.prototype,"inertialAlphaOffset",void 0),n([e.serialize()],i.prototype,"inertialBetaOffset",void 0),n([e.serialize()],i.prototype,"inertialRadiusOffset",void 0),n([e.serialize()],i.prototype,"lowerAlphaLimit",void 0),n([e.serialize()],i.prototype,"upperAlphaLimit",void 0),n([e.serialize()],i.prototype,"lowerBetaLimit",void 0),n([e.serialize()],i.prototype,"upperBetaLimit",void 0),n([e.serialize()],i.prototype,"lowerRadiusLimit",void 0),n([e.serialize()],i.prototype,"upperRadiusLimit",void 0),n([e.serialize()],i.prototype,"inertialPanningX",void 0),n([e.serialize()],i.prototype,"inertialPanningY",void 0),n([e.serialize()],i.prototype,"pinchToPanMaxDistance",void 0),n([e.serialize()],i.prototype,"panningDistanceLimit",void 0),n([e.serializeAsVector3()],i.prototype,"panningOriginTarget",void 0),n([e.serialize()],i.prototype,"panningInertia",void 0),n([e.serialize()],i.prototype,"zoomOnFactor",void 0),n([e.serialize()],i.prototype,"allowUpsideDown",void 0),i})(e.TargetCamera);e.ArcRotateCamera=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r,n){var o=t.call(this,i,n)||this;return o.groundColor=new e.Color3(0,0,0),o.direction=r||e.Vector3.Up(),o}return o(i,t),i.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()},i.prototype.getClassName=function(){return"HemisphericLight"},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(e.Vector3.Zero())),this.direction},i.prototype.getShadowGenerator=function(){return null},i.prototype.transferToEffect=function(t,i){var r=e.Vector3.Normalize(this.direction);return this._uniformBuffer.updateFloat4("vLightData",r.x,r.y,r.z,0,i),this._uniformBuffer.updateColor3("vLightGround",this.groundColor.scale(this.intensity),i),this},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),this._worldMatrix},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_HEMISPHERICLIGHT},n([e.serializeAsColor3()],i.prototype,"groundColor",void 0),n([e.serializeAsVector3()],i.prototype,"direction",void 0),i})(e.Light);e.HemisphericLight=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(){var e=null!==t&&t.apply(this,arguments)||this;return e._needProjectionMatrixCompute=!0,e}return o(i,t),i.prototype._setPosition=function(e){this._position=e},Object.defineProperty(i.prototype,"position",{get:function(){return this._position},set:function(e){this._setPosition(e)},enumerable:!0,configurable:!0}),i.prototype._setDirection=function(e){this._direction=e},Object.defineProperty(i.prototype,"direction",{get:function(){return this._direction},set:function(e){this._setDirection(e)},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMinZ",{get:function(){return this._shadowMinZ},set:function(e){this._shadowMinZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowMaxZ",{get:function(){return this._shadowMaxZ},set:function(e){this._shadowMaxZ=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.computeTransformedInformation=function(){return!(!this.parent||!this.parent.getWorldMatrix)&&(this.transformedPosition||(this.transformedPosition=e.Vector3.Zero()),e.Vector3.TransformCoordinatesToRef(this.position,this.parent.getWorldMatrix(),this.transformedPosition),this.direction&&(this.transformedDirection||(this.transformedDirection=e.Vector3.Zero()),e.Vector3.TransformNormalToRef(this.direction,this.parent.getWorldMatrix(),this.transformedDirection)),!0)},i.prototype.getDepthScale=function(){return 50},i.prototype.getShadowDirection=function(e){return this.transformedDirection?this.transformedDirection:this.direction},i.prototype.getAbsolutePosition=function(){return this.transformedPosition?this.transformedPosition:this.position},i.prototype.setDirectionToTarget=function(t){return this.direction=e.Vector3.Normalize(t.subtract(this.position)),this.direction},i.prototype.getRotation=function(){this.direction.normalize();var t=e.Vector3.Cross(this.direction,e.Axis.Y),i=e.Vector3.Cross(t,this.direction);return e.Vector3.RotationFromAxis(t,i,this.direction)},i.prototype.needCube=function(){return!1},i.prototype.needProjectionMatrixCompute=function(){return this._needProjectionMatrixCompute},i.prototype.forceProjectionMatrixCompute=function(){this._needProjectionMatrixCompute=!0},i.prototype._getWorldMatrix=function(){return this._worldMatrix||(this._worldMatrix=e.Matrix.Identity()),e.Matrix.TranslationToRef(this.position.x,this.position.y,this.position.z,this._worldMatrix),this._worldMatrix},i.prototype.getDepthMinZ=function(e){return void 0!==this.shadowMinZ?this.shadowMinZ:e.minZ},i.prototype.getDepthMaxZ=function(e){return void 0!==this.shadowMaxZ?this.shadowMaxZ:e.maxZ},i.prototype.setShadowProjectionMatrix=function(e,t,i){return this.customProjectionMatrixBuilder?this.customProjectionMatrixBuilder(t,i,e):this._setDefaultShadowProjectionMatrix(e,t,i),this},n([e.serializeAsVector3()],i.prototype,"position",null),n([e.serializeAsVector3()],i.prototype,"direction",null),n([e.serialize()],i.prototype,"shadowMinZ",null),n([e.serialize()],i.prototype,"shadowMaxZ",null),i})(e.Light);e.ShadowLight=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowAngle=Math.PI/2,n.position=i,n}return o(i,t),Object.defineProperty(i.prototype,"shadowAngle",{get:function(){return this._shadowAngle},set:function(e){this._shadowAngle=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.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}),i.prototype.getClassName=function(){return"PointLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_POINTLIGHT},i.prototype.needCube=function(){return!this.direction},i.prototype.getShadowDirection=function(i){if(this.direction)return t.prototype.getShadowDirection.call(this,i);switch(i){case 0:return new e.Vector3(1,0,0);case 1:return new e.Vector3(-1,0,0);case 2:return new e.Vector3(0,-1,0);case 3:return new e.Vector3(0,1,0);case 4:return new e.Vector3(0,0,1);case 5:return new e.Vector3(0,0,-1)}return e.Vector3.Zero()},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;n&&e.Matrix.PerspectiveFovLHToRef(this.shadowAngle,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)},i.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()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,0,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,0,t),this)},n([e.serialize()],i.prototype,"shadowAngle",null),i})(e.ShadowLight);e.PointLight=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._shadowFrustumSize=0,n._shadowOrthoScale=.1,n.autoUpdateExtends=!0,n._orthoLeft=Number.MAX_VALUE,n._orthoRight=Number.MIN_VALUE,n._orthoTop=Number.MIN_VALUE,n._orthoBottom=Number.MAX_VALUE,n.position=i.scale(-1),n.direction=i,n}return o(i,t),Object.defineProperty(i.prototype,"shadowFrustumSize",{get:function(){return this._shadowFrustumSize},set:function(e){this._shadowFrustumSize=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowOrthoScale",{get:function(){return this._shadowOrthoScale},set:function(e){this._shadowOrthoScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"DirectionalLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_DIRECTIONALLIGHT},i.prototype._setDefaultShadowProjectionMatrix=function(e,t,i){this.shadowFrustumSize>0?this._setDefaultFixedFrustumShadowProjectionMatrix(e,t):this._setDefaultAutoExtendShadowProjectionMatrix(e,t,i)},i.prototype._setDefaultFixedFrustumShadowProjectionMatrix=function(t,i){var r=this.getScene().activeCamera;r&&e.Matrix.OrthoLHToRef(this.shadowFrustumSize,this.shadowFrustumSize,void 0!==this.shadowMinZ?this.shadowMinZ:r.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:r.maxZ,t)},i.prototype._setDefaultAutoExtendShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(n){if(this.autoUpdateExtends||this._orthoLeft===Number.MAX_VALUE){var o=e.Vector3.Zero();this._orthoLeft=Number.MAX_VALUE,this._orthoRight=Number.MIN_VALUE,this._orthoTop=Number.MIN_VALUE,this._orthoBottom=Number.MAX_VALUE;for(var s=0;s<r.length;s++){var a=r[s];if(a)for(var l=a.getBoundingInfo(),h=l.boundingBox,c=0;c<h.vectorsWorld.length;c++)e.Vector3.TransformCoordinatesToRef(h.vectorsWorld[c],i,o),o.x<this._orthoLeft&&(this._orthoLeft=o.x),o.y<this._orthoBottom&&(this._orthoBottom=o.y),o.x>this._orthoRight&&(this._orthoRight=o.x),o.y>this._orthoTop&&(this._orthoTop=o.y)}}var u=this._orthoRight-this._orthoLeft,f=this._orthoTop-this._orthoBottom;e.Matrix.OrthoOffCenterLHToRef(this._orthoLeft-u*this.shadowOrthoScale,this._orthoRight+u*this.shadowOrthoScale,this._orthoBottom-f*this.shadowOrthoScale,this._orthoTop+f*this.shadowOrthoScale,void 0!==this.shadowMinZ?this.shadowMinZ:n.minZ,void 0!==this.shadowMaxZ?this.shadowMaxZ:n.maxZ,t)}},i.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()},i.prototype.transferToEffect=function(e,t){return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedDirection.x,this.transformedDirection.y,this.transformedDirection.z,1,t),this):(this._uniformBuffer.updateFloat4("vLightData",this.direction.x,this.direction.y,this.direction.z,1,t),this)},i.prototype.getDepthMinZ=function(e){return 1},i.prototype.getDepthMaxZ=function(e){return 1},n([e.serialize()],i.prototype,"shadowFrustumSize",null),n([e.serialize()],i.prototype,"shadowOrthoScale",null),n([e.serialize()],i.prototype,"autoUpdateExtends",void 0),i})(e.ShadowLight);e.DirectionalLight=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r,n,o,s,a){var l=t.call(this,i,a)||this;return l._projectionTextureMatrix=e.Matrix.Zero(),l._projectionTextureLightNear=1e-6,l._projectionTextureLightFar=1e3,l._projectionTextureUpDirection=e.Vector3.Up(),l._projectionTextureViewLightDirty=!0,l._projectionTextureProjectionLightDirty=!0,l._projectionTextureDirty=!0,l._projectionTextureViewTargetVector=e.Vector3.Zero(),l._projectionTextureViewLightMatrix=e.Matrix.Zero(),l._projectionTextureProjectionLightMatrix=e.Matrix.Zero(),l._projectionTextureScalingMatrix=e.Matrix.FromValues(.5,0,0,0,0,.5,0,0,0,0,.5,0,.5,.5,.5,1),l.position=r,l.direction=n,l.angle=o,l.exponent=s,l}return o(i,t),Object.defineProperty(i.prototype,"angle",{get:function(){return this._angle},set:function(e){this._angle=e,this._projectionTextureProjectionLightDirty=!0,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"shadowAngleScale",{get:function(){return this._shadowAngleScale},set:function(e){this._shadowAngleScale=e,this.forceProjectionMatrixCompute()},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"projectionTextureMatrix",{get:function(){return this._projectionTextureMatrix},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"projectionTextureLightNear",{get:function(){return this._projectionTextureLightNear},set:function(e){this._projectionTextureLightNear=e,this._projectionTextureProjectionLightDirty=!0},
enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"projectionTextureLightFar",{get:function(){return this._projectionTextureLightFar},set:function(e){this._projectionTextureLightFar=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"projectionTextureUpDirection",{get:function(){return this._projectionTextureUpDirection},set:function(e){this._projectionTextureUpDirection=e,this._projectionTextureProjectionLightDirty=!0},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"projectionTexture",{get:function(){return this._projectionTexture},set:function(e){this._projectionTexture=e,this._projectionTextureDirty=!0},enumerable:!0,configurable:!0}),i.prototype.getClassName=function(){return"SpotLight"},i.prototype.getTypeID=function(){return e.Light.LIGHTTYPEID_SPOTLIGHT},i.prototype._setDirection=function(e){t.prototype._setDirection.call(this,e),this._projectionTextureViewLightDirty=!0},i.prototype._setPosition=function(e){t.prototype._setPosition.call(this,e),this._projectionTextureViewLightDirty=!0},i.prototype._setDefaultShadowProjectionMatrix=function(t,i,r){var n=this.getScene().activeCamera;if(n){this._shadowAngleScale=this._shadowAngleScale||1;var o=this._shadowAngleScale*this._angle;e.Matrix.PerspectiveFovLHToRef(o,1,this.getDepthMinZ(n),this.getDepthMaxZ(n),t)}},i.prototype._computeProjectionTextureViewLightMatrix=function(){this._projectionTextureViewLightDirty=!1,this._projectionTextureDirty=!0,this.position.addToRef(this.direction,this._projectionTextureViewTargetVector),e.Matrix.LookAtLHToRef(this.position,this._projectionTextureViewTargetVector,this._projectionTextureUpDirection,this._projectionTextureViewLightMatrix)},i.prototype._computeProjectionTextureProjectionLightMatrix=function(){this._projectionTextureProjectionLightDirty=!1,this._projectionTextureDirty=!0;var t=this.projectionTextureLightFar,i=this.projectionTextureLightNear,r=t/(t-i),n=-r*i,o=1/Math.tan(this._angle/2);e.Matrix.FromValuesToRef(o/1,0,0,0,0,o,0,0,0,0,r,1,0,0,n,0,this._projectionTextureProjectionLightMatrix)},i.prototype._computeProjectionTextureMatrix=function(){this._projectionTextureDirty=!1,this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix,this._projectionTextureMatrix),this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix,this._projectionTextureMatrix)},i.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("shadowsInfo",3),this._uniformBuffer.addUniform("depthValues",2),this._uniformBuffer.create()},i.prototype.transferToEffect=function(t,i){var r;return this.computeTransformedInformation()?(this._uniformBuffer.updateFloat4("vLightData",this.transformedPosition.x,this.transformedPosition.y,this.transformedPosition.z,this.exponent,i),r=e.Vector3.Normalize(this.transformedDirection)):(this._uniformBuffer.updateFloat4("vLightData",this.position.x,this.position.y,this.position.z,this.exponent,i),r=e.Vector3.Normalize(this.direction)),this._uniformBuffer.updateFloat4("vLightDirection",r.x,r.y,r.z,Math.cos(.5*this.angle),i),this.projectionTexture&&this.projectionTexture.isReady()&&(this._projectionTextureViewLightDirty&&this._computeProjectionTextureViewLightMatrix(),this._projectionTextureProjectionLightDirty&&this._computeProjectionTextureProjectionLightMatrix(),this._projectionTextureDirty&&this._computeProjectionTextureMatrix(),t.setMatrix("textureProjectionMatrix"+i,this._projectionTextureMatrix),t.setTexture("projectionLightSampler"+i,this.projectionTexture)),this},i.prototype.dispose=function(){t.prototype.dispose.call(this),this._projectionTexture&&this._projectionTexture.dispose()},n([e.serialize()],i.prototype,"angle",null),n([e.serialize()],i.prototype,"shadowAngleScale",null),n([e.serialize()],i.prototype,"exponent",void 0),n([e.serialize()],i.prototype,"projectionTextureLightNear",null),n([e.serialize()],i.prototype,"projectionTextureLightFar",null),n([e.serialize()],i.prototype,"projectionTextureUpDirection",null),n([e.serializeAsTexture("projectedLightTexture")],i.prototype,"_projectionTexture",void 0),i})(e.ShadowLight);e.SpotLight=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this.enableBlending=!1,this.blendingSpeed=.01,this.loopMode=e.Animation.ANIMATIONLOOPMODE_CYCLE}return t})();e.AnimationPropertiesOverride=t})(r||(r={}));var r;!(function(e){var t=(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})();e.AnimationRange=t;var i=(function(){function e(e,t,i){this.frame=e,this.action=t,this.onlyOnce=i,this.isDone=!1}return e})();e.AnimationEvent=i;var r=(function(){function t(e){this.path=e,this._onchange=new Array,this.value=0,this.animations=new Array}return t.prototype.getPoint=function(){var t=this.path.getPointAtLengthPosition(this.value);return new e.Vector3(t.x,0,t.y)},t.prototype.moveAhead=function(e){return void 0===e&&(e=.002),this.move(e),this},t.prototype.moveBack=function(e){return void 0===e&&(e=.002),this.move(-e),this},t.prototype.move=function(e){if(Math.abs(e)>1)throw"step size should be less than 1.";return this.value+=e,this.ensureLimits(),this.raiseOnChange(),this},t.prototype.ensureLimits=function(){for(;this.value>1;)this.value-=1;for(;this.value<0;)this.value+=1;return this},t.prototype.raiseOnChange=function(){var e=this;return this._onchange.forEach((function(t){return t(e)})),this},t.prototype.onchange=function(e){return this._onchange.push(e),this},t})();e.PathCursor=r;var n;!(function(e){e[e.STEP=1]="STEP"})(n=e.AnimationKeyInterpolation||(e.AnimationKeyInterpolation={}));var o=(function(){function i(e,t,r,n,o,s){this.name=e,this.targetProperty=t,this.framePerSecond=r,this.dataType=n,this.loopMode=o,this.enableBlending=s,this._runtimeAnimations=new Array,this._events=new Array,this.blendingSpeed=.01,this._ranges={},this.targetPropertyPath=t.split("."),this.dataType=n,this.loopMode=void 0===o?i.ANIMATIONLOOPMODE_CYCLE:o}return i._PrepareAnimation=function(t,r,n,o,s,a,l,h){var c=void 0;if(!isNaN(parseFloat(s))&&isFinite(s)?c=i.ANIMATIONTYPE_FLOAT:s instanceof e.Quaternion?c=i.ANIMATIONTYPE_QUATERNION:s instanceof e.Vector3?c=i.ANIMATIONTYPE_VECTOR3:s instanceof e.Vector2?c=i.ANIMATIONTYPE_VECTOR2:s instanceof e.Color3?c=i.ANIMATIONTYPE_COLOR3:s instanceof e.Size&&(c=i.ANIMATIONTYPE_SIZE),void 0==c)return null;var u=new i(t,r,n,c,l),f=[{frame:0,value:s},{frame:o,value:a}];return u.setKeys(f),void 0!==h&&u.setEasingFunction(h),u},i.CreateAnimation=function(e,t,r,n){var o=new i(e+"Animation",e,r,t,i.ANIMATIONLOOPMODE_CONSTANT);return o.setEasingFunction(n),o},i.CreateAndStartAnimation=function(e,t,r,n,o,s,a,l,h,c){var u=i._PrepareAnimation(e,r,n,o,s,a,l,h);return u?t.getScene().beginDirectAnimation(t,[u],0,o,1===u.loopMode,1,c):null},i.CreateAndStartHierarchyAnimation=function(e,t,r,n,o,s,a,l,h,c,u){var f=i._PrepareAnimation(e,n,o,s,a,l,h,c);return f?t.getScene().beginDirectHierarchyAnimation(t,r,[f],0,s,1===f.loopMode,1,u):null},i.CreateMergeAndStartAnimation=function(e,t,r,n,o,s,a,l,h,c){var u=i._PrepareAnimation(e,r,n,o,s,a,l,h);return u?(t.animations.push(u),t.getScene().beginAnimation(t,0,o,1===u.loopMode,1,c)):null},i.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 h=r.beginAnimation(i,0,l,!1);return h.onAnimationEnd=a,h},Object.defineProperty(i.prototype,"runtimeAnimations",{get:function(){return this._runtimeAnimations},enumerable:!0,configurable:!0}),Object.defineProperty(i.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}),i.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},i.prototype.addEvent=function(e){this._events.push(e)},i.prototype.removeEvents=function(e){for(var t=0;t<this._events.length;t++)this._events[t].frame===e&&(this._events.splice(t,1),t--)},i.prototype.getEvents=function(){return this._events},i.prototype.createRange=function(e,i,r){this._ranges[e]||(this._ranges[e]=new t(e,i,r))},i.prototype.deleteRange=function(e,t){void 0===t&&(t=!0);var i=this._ranges[e];if(i){if(t)for(var r=i.from,n=i.to,o=this._keys.length-1;o>=0;o--)this._keys[o].frame>=r&&this._keys[o].frame<=n&&this._keys.splice(o,1);this._ranges[e]=null}},i.prototype.getRange=function(e){return this._ranges[e]},i.prototype.getKeys=function(){return this._keys},i.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},i.prototype.getEasingFunction=function(){return this._easingFunction},i.prototype.setEasingFunction=function(e){this._easingFunction=e},i.prototype.floatInterpolateFunction=function(t,i,r){return e.Scalar.Lerp(t,i,r)},i.prototype.floatInterpolateFunctionWithTangents=function(t,i,r,n,o){return e.Scalar.Hermite(t,i,r,n,o)},i.prototype.quaternionInterpolateFunction=function(t,i,r){return e.Quaternion.Slerp(t,i,r)},i.prototype.quaternionInterpolateFunctionWithTangents=function(t,i,r,n,o){return e.Quaternion.Hermite(t,i,r,n,o).normalize()},i.prototype.vector3InterpolateFunction=function(t,i,r){return e.Vector3.Lerp(t,i,r)},i.prototype.vector3InterpolateFunctionWithTangents=function(t,i,r,n,o){return e.Vector3.Hermite(t,i,r,n,o)},i.prototype.vector2InterpolateFunction=function(t,i,r){return e.Vector2.Lerp(t,i,r)},i.prototype.vector2InterpolateFunctionWithTangents=function(t,i,r,n,o){return e.Vector2.Hermite(t,i,r,n,o)},i.prototype.sizeInterpolateFunction=function(t,i,r){return e.Size.Lerp(t,i,r)},i.prototype.color3InterpolateFunction=function(t,i,r){return e.Color3.Lerp(t,i,r)},i.prototype._getKeyValue=function(e){return"function"==typeof e?e():e},i.prototype._interpolate=function(e,t,r,o,s,a){if(o===i.ANIMATIONLOOPMODE_CONSTANT&&t>0)return a.clone?a.clone():a;var l=this.getKeys(),h=Math.max(0,Math.min(l.length-1,Math.floor(l.length*(e-l[0].frame)/(l[l.length-1].frame-l[0].frame))-1));if(l[h].frame>=e)for(;h-1>=0&&l[h].frame>=e;)h--;for(var c=h;c<l.length;c++){var u=l[c+1];if(u.frame>=e){var f=l[c],p=this._getKeyValue(f.value);if(f.interpolation===n.STEP)return p;var d=this._getKeyValue(u.value),m=void 0!==f.outTangent&&void 0!==u.inTangent,_=u.frame-f.frame,g=(e-f.frame)/_,v=this.getEasingFunction();switch(null!=v&&(g=v.ease(g)),this.dataType){case i.ANIMATIONTYPE_FLOAT:var y=m?this.floatInterpolateFunctionWithTangents(p,f.outTangent*_,d,u.inTangent*_,g):this.floatInterpolateFunction(p,d,g);switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return y;case i.ANIMATIONLOOPMODE_RELATIVE:return s*t+y}break;case i.ANIMATIONTYPE_QUATERNION:var b=m?this.quaternionInterpolateFunctionWithTangents(p,f.outTangent.scale(_),d,u.inTangent.scale(_),g):this.quaternionInterpolateFunction(p,d,g);switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return b;case i.ANIMATIONLOOPMODE_RELATIVE:return b.addInPlace(s.scale(t))}return b;case i.ANIMATIONTYPE_VECTOR3:var x=m?this.vector3InterpolateFunctionWithTangents(p,f.outTangent.scale(_),d,u.inTangent.scale(_),g):this.vector3InterpolateFunction(p,d,g);switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return x;case i.ANIMATIONLOOPMODE_RELATIVE:return x.add(s.scale(t))}case i.ANIMATIONTYPE_VECTOR2:var T=m?this.vector2InterpolateFunctionWithTangents(p,f.outTangent.scale(_),d,u.inTangent.scale(_),g):this.vector2InterpolateFunction(p,d,g);switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return T;case i.ANIMATIONLOOPMODE_RELATIVE:return T.add(s.scale(t))}case i.ANIMATIONTYPE_SIZE:switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.sizeInterpolateFunction(p,d,g);case i.ANIMATIONLOOPMODE_RELATIVE:return this.sizeInterpolateFunction(p,d,g).add(s.scale(t))}case i.ANIMATIONTYPE_COLOR3:switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:return this.color3InterpolateFunction(p,d,g);case i.ANIMATIONLOOPMODE_RELATIVE:return this.color3InterpolateFunction(p,d,g).add(s.scale(t))}case i.ANIMATIONTYPE_MATRIX:switch(o){case i.ANIMATIONLOOPMODE_CYCLE:case i.ANIMATIONLOOPMODE_CONSTANT:if(i.AllowMatricesInterpolation)return this.matrixInterpolateFunction(p,d,g,r);case i.ANIMATIONLOOPMODE_RELATIVE:return p}}break}}return this._getKeyValue(l[l.length-1].value)},i.prototype.matrixInterpolateFunction=function(t,r,n,o){return i.AllowMatrixDecomposeForInterpolation?o?(e.Matrix.DecomposeLerpToRef(t,r,n,o),o):e.Matrix.DecomposeLerp(t,r,n):o?(e.Matrix.LerpToRef(t,r,n,o),o):e.Matrix.Lerp(t,r,n)},i.prototype.clone=function(){var e=new i(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){e._ranges={};for(var t in this._ranges){var r=this._ranges[t];r&&(e._ranges[t]=r.clone())}}return e},i.prototype.setKeys=function(e){this._keys=e.slice(0)},i.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 r=this.getKeys(),n=0;n<r.length;n++){var o=r[n],s={};switch(s.frame=o.frame,t){case i.ANIMATIONTYPE_FLOAT:s.values=[o.value];break;case i.ANIMATIONTYPE_QUATERNION:case i.ANIMATIONTYPE_MATRIX:case i.ANIMATIONTYPE_VECTOR3:case i.ANIMATIONTYPE_COLOR3:s.values=o.value.asArray()}e.keys.push(s)}e.ranges=[];for(var a in this._ranges){var l=this._ranges[a];if(l){var h={};h.name=a,h.from=l.from,h.to=l.to,e.ranges.push(h)}}return e},Object.defineProperty(i,"ANIMATIONTYPE_FLOAT",{get:function(){return i._ANIMATIONTYPE_FLOAT},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_VECTOR3",{get:function(){return i._ANIMATIONTYPE_VECTOR3},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_VECTOR2",{get:function(){return i._ANIMATIONTYPE_VECTOR2},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_SIZE",{get:function(){return i._ANIMATIONTYPE_SIZE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_QUATERNION",{get:function(){return i._ANIMATIONTYPE_QUATERNION},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_MATRIX",{get:function(){return i._ANIMATIONTYPE_MATRIX},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONTYPE_COLOR3",{get:function(){return i._ANIMATIONTYPE_COLOR3},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_RELATIVE",{get:function(){return i._ANIMATIONLOOPMODE_RELATIVE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_CYCLE",{get:function(){return i._ANIMATIONLOOPMODE_CYCLE},enumerable:!0,configurable:!0}),Object.defineProperty(i,"ANIMATIONLOOPMODE_CONSTANT",{get:function(){return i._ANIMATIONLOOPMODE_CONSTANT},enumerable:!0,configurable:!0}),i._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},i.Parse=function(t){var r,n,o=new i(t.name,t.property,t.framePerSecond,t.dataType,t.loopBehavior),s=t.dataType,a=[];for(t.enableBlending&&(o.enableBlending=t.enableBlending),t.blendingSpeed&&(o.blendingSpeed=t.blendingSpeed),n=0;n<t.keys.length;n++){var l,h,c=t.keys[n];switch(s){case i.ANIMATIONTYPE_FLOAT:r=c.values[0],c.values.length>=1&&(l=c.values[1]),c.values.length>=2&&(h=c.values[2]);break;case i.ANIMATIONTYPE_QUATERNION:if(r=e.Quaternion.FromArray(c.values),c.values.length>=8){var u=e.Quaternion.FromArray(c.values.slice(4,8));u.equals(e.Quaternion.Zero())||(l=u)}if(c.values.length>=12){var f=e.Quaternion.FromArray(c.values.slice(8,12));f.equals(e.Quaternion.Zero())||(h=f)}break;case i.ANIMATIONTYPE_MATRIX:r=e.Matrix.FromArray(c.values);break;case i.ANIMATIONTYPE_COLOR3:r=e.Color3.FromArray(c.values);break;case i.ANIMATIONTYPE_VECTOR3:default:r=e.Vector3.FromArray(c.values)}var p={};p.frame=c.frame,p.value=r,void 0!=l&&(p.inTangent=l),void 0!=h&&(p.outTangent=h),a.push(p)}if(o.setKeys(a),t.ranges)for(n=0;n<t.ranges.length;n++)r=t.ranges[n],o.createRange(r.name,r.from,r.to);return o},i.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())}}},i.AllowMatricesInterpolation=!1,i.AllowMatrixDecomposeForInterpolation=!0,i._ANIMATIONTYPE_FLOAT=0,i._ANIMATIONTYPE_VECTOR3=1,i._ANIMATIONTYPE_QUATERNION=2,i._ANIMATIONTYPE_MATRIX=3,i._ANIMATIONTYPE_COLOR3=4,i._ANIMATIONTYPE_VECTOR2=5,i._ANIMATIONTYPE_SIZE=6,i._ANIMATIONLOOPMODE_RELATIVE=0,i._ANIMATIONLOOPMODE_CYCLE=1,i._ANIMATIONLOOPMODE_CONSTANT=2,i})();e.Animation=o})(r||(r={}));var r;!(function(e){var t=(function(){function e(){}return e})();e.TargetedAnimation=t;var i=(function(){function t(t,i){void 0===i&&(i=null),this.name=t,this._targetedAnimations=new Array,this._animatables=new Array,this._from=Number.MAX_VALUE,this._to=-Number.MAX_VALUE,this._speedRatio=1,this.onAnimationEndObservable=new e.Observable,this._scene=i||e.Engine.LastCreatedScene,this._scene.animationGroups.push(this)}return Object.defineProperty(t.prototype,"from",{get:function(){return this._from},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"to",{get:function(){return this._to},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isStarted",{get:function(){return this._isStarted},enumerable:!0,configurable:!0}),Object.defineProperty(t.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(t.prototype,"targetedAnimations",{get:function(){return this._targetedAnimations},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animatables",{get:function(){return this._animatables},enumerable:!0,configurable:!0}),t.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},t.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],n=r.animation.getKeys(),o=n[0],s=n[n.length-1];if(o.frame>e){var a={frame:e,value:o.value,inTangent:o.inTangent,outTangent:o.outTangent,interpolation:o.interpolation};n.splice(0,0,a)}if(s.frame<t){var a={frame:t,value:s.value,inTangent:s.outTangent,outTangent:s.outTangent,interpolation:s.interpolation};n.push(a)}}return this._from=e,this._to=t,this},t.prototype.start=function(e,t,i,r){var n=this;if(void 0===e&&(e=!1),void 0===t&&(t=1),this._isStarted||0===this._targetedAnimations.length)return this;for(var o=this,s=0,a=this._targetedAnimations;s<a.length;s++){var l=a[s];!(function(s){o._animatables.push(o._scene.beginDirectAnimation(s.target,[s.animation],void 0!==i?i:o._from,void 0!==r?r:o._to,e,t,(function(){n.onAnimationEndObservable.notifyObservers(s)})))})(l)}return this._speedRatio=t,this._isStarted=!0,this},t.prototype.pause=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].pause()}return this},t.prototype.play=function(e){if(this.isStarted){if(void 0!==e)for(var t=0;t<this._animatables.length;t++){var i=this._animatables[t];i.loopAnimation=e}this.restart()}else this.start(e,this._speedRatio);return this},t.prototype.reset=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].reset()}return this},t.prototype.restart=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].restart()}return this},t.prototype.stop=function(){if(!this._isStarted)return this;for(var e=0;e<this._animatables.length;e++){this._animatables[e].stop()}return this._isStarted=!1,this},t.prototype.setWeightForAllAnimatables=function(e){for(var t=0;t<this._animatables.length;t++){this._animatables[t].weight=e}return this},t.prototype.syncAllAnimationsWith=function(e){for(var t=0;t<this._animatables.length;t++){this._animatables[t].syncWith(e)}return this},t.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},t.prototype.dispose=function(){this._targetedAnimations=[],this._animatables=[];var e=this._scene.animationGroups.indexOf(this);e>-1&&this._scene.animationGroups.splice(e,1)},t})();e.AnimationGroup=i})(r||(r={}));var r;!(function(e){var t=(function(){function t(e,t,i,r){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)}return Object.defineProperty(t.prototype,"currentFrame",{get:function(){return this._currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"weight",{get:function(){return this._weight},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"currentValue",{get:function(){return this._currentValue},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"targetPath",{get:function(){return this._targetPath},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){return this._activeTarget},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"animation",{get:function(){return this._animation},enumerable:!0,configurable:!0}),t.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},t.prototype.isStopped=function(){return this._stopped},t.prototype.dispose=function(){var e=this._animation.runtimeAnimations.indexOf(this);e>-1&&this._animation.runtimeAnimations.splice(e,1)},t.prototype._interpolate=function(t,i,r,n,o){return this._currentFrame=t,this._animation.dataType!==e.Animation.ANIMATIONTYPE_MATRIX||this._workValue||(this._workValue=e.Matrix.Zero()),this._animation._interpolate(t,i,this._workValue,r,n,o)},t.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)},t.prototype._setValue=function(t,i,r,n){void 0===n&&(n=0);var o,s,a=this._animation.targetPropertyPath;if(a.length>1){for(var l=t[a[0]],h=1;h<a.length-1;h++)l=l[a[h]];o=a[a.length-1],s=l}else o=a[0],s=t;if(this._targetPath=o,this._activeTarget=s,this._weight=r,void 0===this._originalValue[n]){var c=void 0;c=s.getRestPose&&"_matrix"===o?s.getRestPose():s[o],c&&c.clone?this._originalValue[n]=c.clone():this._originalValue[n]=c}if((t&&t.animationPropertiesOverride?t.animationPropertiesOverride.enableBlending:this._animation.enableBlending)&&this._blendingFactor<=1){if(!this._originalBlendValue){var c=s[o];c.clone?this._originalBlendValue=c.clone():this._originalBlendValue=c}this._originalBlendValue.m?e.Animation.AllowMatrixDecomposeForInterpolation?this._currentValue?e.Matrix.DecomposeLerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=e.Matrix.DecomposeLerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue?e.Matrix.LerpToRef(this._originalBlendValue,i,this._blendingFactor,this._currentValue):this._currentValue=e.Matrix.Lerp(this._originalBlendValue,i,this._blendingFactor):this._currentValue=e.Animation._UniversalLerp(this._originalBlendValue,i,this._blendingFactor);var u=t&&t.animationPropertiesOverride?t.animationPropertiesOverride.blendingSpeed:this._animation.blendingSpeed;this._blendingFactor+=u}else this._currentValue=i;-1!==r?this._scene._registerTargetForLateAnimationBinding(this,this._originalValue[n]):s[o]=this._currentValue,t.markAsDirty&&t.markAsDirty(this._animation.targetProperty)},t.prototype._getCorrectLoopMode=function(){return this._target&&this._target.animationPropertiesOverride?this._target.animationPropertiesOverride.loopMode:this._animation.loopMode},t.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)},t.prototype._prepareForSpeedRatioChange=function(e){var t=this._previousDelay*(this._animation.framePerSecond*e)/1e3;this._ratioOffset=this._previousRatio-t},t.prototype.animate=function(t,i,r,n,o,s){void 0===s&&(s=-1);var a=this._animation.targetPropertyPath;if(!a||a.length<1)return this._stopped=!0,!1;var l=!0,h=this._animation.getKeys();if(0!==h[0].frame){var c={frame:0,value:h[0].value};h.splice(0,0,c)}(i<h[0].frame||i>h[h.length-1].frame)&&(i=h[0].frame),(r<h[0].frame||r>h[h.length-1].frame)&&(r=h[h.length-1].frame),i===r&&(i>h[0].frame?i--:r<h[h.length-1].frame&&r++);var u,f=r-i,p=t*(this._animation.framePerSecond*o)/1e3+this._ratioOffset,d=0;if(this._previousDelay=t,this._previousRatio=p,(r>i&&p>f||i>r&&p<f)&&!n)l=!1,d=this._animation._getKeyValue(h[h.length-1].value);else if(this._getCorrectLoopMode()!==e.Animation.ANIMATIONLOOPMODE_CYCLE){var m=r.toString()+i.toString();if(!this._offsetsCache[m]){var _=this._interpolate(i,0,e.Animation.ANIMATIONLOOPMODE_CYCLE),g=this._interpolate(r,0,e.Animation.ANIMATIONLOOPMODE_CYCLE);switch(this._animation.dataType){case e.Animation.ANIMATIONTYPE_FLOAT:this._offsetsCache[m]=g-_;break;case e.Animation.ANIMATIONTYPE_QUATERNION:this._offsetsCache[m]=g.subtract(_);break;case e.Animation.ANIMATIONTYPE_VECTOR3:this._offsetsCache[m]=g.subtract(_);case e.Animation.ANIMATIONTYPE_VECTOR2:this._offsetsCache[m]=g.subtract(_);case e.Animation.ANIMATIONTYPE_SIZE:this._offsetsCache[m]=g.subtract(_);case e.Animation.ANIMATIONTYPE_COLOR3:this._offsetsCache[m]=g.subtract(_)}this._highLimitsCache[m]=g}d=this._highLimitsCache[m],u=this._offsetsCache[m]}if(void 0===u)switch(this._animation.dataType){case e.Animation.ANIMATIONTYPE_FLOAT:u=0;break;case e.Animation.ANIMATIONTYPE_QUATERNION:u=new e.Quaternion(0,0,0,0);break;case e.Animation.ANIMATIONTYPE_VECTOR3:u=e.Vector3.Zero();break;case e.Animation.ANIMATIONTYPE_VECTOR2:u=e.Vector2.Zero();break;case e.Animation.ANIMATIONTYPE_SIZE:u=e.Size.Zero();break;case e.Animation.ANIMATIONTYPE_COLOR3:u=e.Color3.Black()}var v=p/f>>0,y=l?i+p%f:r;if(this._host&&this._host.syncRoot){var b=this._host.syncRoot;y=i+(r-i)*((b.masterFrame-b.fromFrame)/(b.toFrame-b.fromFrame))}var x=this._interpolate(y,v,this._getCorrectLoopMode(),u,d);this.setValue(x,s);for(var T=this._animation.getEvents(),E=0;E<T.length;E++)if(f>0&&y>=T[E].frame&&T[E].frame>=i||f<0&&y<=T[E].frame&&T[E].frame<=i){var P=T[E];P.isDone||(P.onlyOnce&&(T.splice(E,1),E--),P.isDone=!0,P.action())}else T[E].isDone&&!T[E].onlyOnce&&(T[E].isDone=!1);return l||(this._stopped=!0),l},t})();e.RuntimeAnimation=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(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.animationStarted=!1,this._scene=e,a&&this.appendAnimations(t,a),this._speedRatio=o,e._activeAnimatables.push(this)}return Object.defineProperty(t.prototype,"syncRoot",{get:function(){return this._syncRoot},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"masterFrame",{get:function(){return 0===this._runtimeAnimations.length?0:this._runtimeAnimations[0].currentFrame},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"weight",{get:function(){return this._weight},set:function(e){if(-1===e)return void(this._weight=-1);this._weight=Math.min(Math.max(e,0),1)},enumerable:!0,configurable:!0}),Object.defineProperty(t.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}),t.prototype.syncWith=function(e){if(this._syncRoot=e,e){var t=this._scene._activeAnimatables.indexOf(this);t>-1&&(this._scene._activeAnimatables.splice(t,1),this._scene._activeAnimatables.push(this))}return this},t.prototype.getAnimations=function(){return this._runtimeAnimations},t.prototype.appendAnimations=function(t,i){for(var r=0;r<i.length;r++){var n=i[r];this._runtimeAnimations.push(new e.RuntimeAnimation(t,n,this._scene,this))}},t.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},t.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},t.prototype.reset=function(){for(var e=this._runtimeAnimations,t=0;t<e.length;t++)e[t].reset(!0);this._localDelayOffset=null,this._pausedDelay=null},t.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},t.prototype.disableBlending=function(){for(var e=this._runtimeAnimations,t=0;t<e.length;t++)e[t].animation.enableBlending=!1},t.prototype.goToFrame=function(e){var t=this._runtimeAnimations;if(t[0]){var i=t[0].animation.framePerSecond,r=t[0].currentFrame,n=e-r,o=1e3*n/(i*this.speedRatio);null===this._localDelayOffset&&(this._localDelayOffset=0),this._localDelayOffset-=o}for(var s=0;s<t.length;s++)t[s].goToFrame(e)},t.prototype.pause=function(){this._paused||(this._paused=!0)},t.prototype.restart=function(){this._paused=!1},t.prototype.stop=function(e){if(e){var t=this._scene._activeAnimatables.indexOf(this);if(t>-1){for(var i=this._runtimeAnimations,r=i.length-1;r>=0;r--)"string"==typeof e&&i[r].animation.name!=e||(i[r].dispose(),i.splice(r,1));0==i.length&&(this._scene._activeAnimatables.splice(t,1),this.onAnimationEnd&&this.onAnimationEnd())}}else{var r=this._scene._activeAnimatables.indexOf(this);if(r>-1){this._scene._activeAnimatables.splice(r,1);for(var i=this._runtimeAnimations,r=0;r<i.length;r++)i[r].dispose();this.onAnimationEnd&&this.onAnimationEnd()}}},t.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],o=n.animate(e-this._localDelayOffset,this.fromFrame,this.toFrame,this.loopAnimation,this._speedRatio,this._weight);i=i||o}if(this.animationStarted=i,!i)for(t=this._scene._activeAnimatables.indexOf(this),this._scene._activeAnimatables.splice(t,1),t=0;t<r.length;t++)r[t].dispose();return!i&&this.onAnimationEnd&&(this.onAnimationEnd(),this.onAnimationEnd=null),i},t})();e.Animatable=t})(r||(r={}));var r;!(function(e){var t=(function(){function e(){this._easingMode=e.EASINGMODE_EASEIN}return Object.defineProperty(e,"EASINGMODE_EASEIN",{get:function(){return e._EASINGMODE_EASEIN},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEOUT",{get:function(){return e._EASINGMODE_EASEOUT},enumerable:!0,configurable:!0}),Object.defineProperty(e,"EASINGMODE_EASEINOUT",{get:function(){return e._EASINGMODE_EASEINOUT},enumerable:!0,configurable:!0}),e.prototype.setEasingMode=function(e){var t=Math.min(Math.max(e,0),2);this._easingMode=t},e.prototype.getEasingMode=function(){return this._easingMode},e.prototype.easeInCore=function(e){throw new Error("You must implement this method")},e.prototype.ease=function(t){switch(this._easingMode){case e.EASINGMODE_EASEIN:return this.easeInCore(t);case e.EASINGMODE_EASEOUT:return 1-this.easeInCore(1-t)}return t>=.5?.5*(1-this.easeInCore(2*(1-t)))+.5:.5*this.easeInCore(2*t)},e._EASINGMODE_EASEIN=0,e._EASINGMODE_EASEOUT=1,e._EASINGMODE_EASEINOUT=2,e})();e.EasingFunction=t;var i=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.easeInCore=function(e){return e=Math.max(0,Math.min(1,e)),1-Math.sqrt(1-e*e)},t})(t);e.CircleEase=i;var r=(function(e){function t(t){void 0===t&&(t=1);var i=e.call(this)||this;return i.amplitude=t,i}return o(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.amplitude);return Math.pow(e,3)-e*t*Math.sin(3.141592653589793*e)},t})(t);e.BackEase=r;var n=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=2);var r=e.call(this)||this;return r.bounces=t,r.bounciness=i,r}return o(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.bounces),i=this.bounciness;i<=1&&(i=1.001);var r=Math.pow(i,t),n=1-i,o=(1-r)/n+.5*r,s=e*o,a=Math.log(-s*(1-i)+1)/Math.log(i),l=Math.floor(a),h=l+1,c=(1-Math.pow(i,l))/(n*o),u=(1-Math.pow(i,h))/(n*o),f=.5*(c+u),p=e-f,d=f-c;return-Math.pow(1/i,t-l)/(d*d)*(p-d)*(p+d)},t})(t);e.BounceEase=n;var s=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.easeInCore=function(e){return e*e*e},t})(t);e.CubicEase=s;var a=(function(e){function t(t,i){void 0===t&&(t=3),void 0===i&&(i=3);var r=e.call(this)||this;return r.oscillations=t,r.springiness=i,r}return o(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.oscillations),i=Math.max(0,this.springiness);return(0==i?e:(Math.exp(i*e)-1)/(Math.exp(i)-1))*Math.sin((6.283185307179586*t+1.5707963267948966)*e)},t})(t);e.ElasticEase=a;var l=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.exponent=t,i}return o(t,e),t.prototype.easeInCore=function(e){return this.exponent<=0?e:(Math.exp(this.exponent*e)-1)/(Math.exp(this.exponent)-1)},t})(t);e.ExponentialEase=l;var h=(function(e){function t(t){void 0===t&&(t=2);var i=e.call(this)||this;return i.power=t,i}return o(t,e),t.prototype.easeInCore=function(e){var t=Math.max(0,this.power);return Math.pow(e,t)},t})(t);e.PowerEase=h;var c=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.easeInCore=function(e){return e*e},t})(t);e.QuadraticEase=c;var u=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.easeInCore=function(e){return e*e*e*e},t})(t);e.QuarticEase=u;var f=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.easeInCore=function(e){return e*e*e*e*e},t})(t);e.QuinticEase=f;var p=(function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),t.prototype.easeInCore=function(e){return 1-Math.sin(1.5707963267948966*(1-e))},t})(t);e.SineEase=p;var d=(function(t){function i(e,i,r,n){void 0===e&&(e=0),void 0===i&&(i=0),void 0===r&&(r=1),void 0===n&&(n=1);var o=t.call(this)||this;return o.x1=e,o.y1=i,o.x2=r,o.y2=n,o}return o(i,t),i.prototype.easeInCore=function(t){return e.BezierCurve.interpolate(t,this.x1,this.y1,this.x2,this.y2)},i})(t);e.BezierCurveEase=d})(r||(r={}));var r;!(function(e){var t=(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})();e.Condition=t;var i=(function(t){function i(e,r,n,o,s){void 0===s&&(s=i.IsEqual);var a=t.call(this,e)||this;return a.propertyPath=n,a.value=o,a.operator=s,a._target=r,a._effectiveTarget=a._getEffectiveTarget(r,a.propertyPath),a._property=a._getProperty(a.propertyPath),a}return o(i,t),Object.defineProperty(i,"IsEqual",{get:function(){return i._IsEqual},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsDifferent",{get:function(){return i._IsDifferent},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsGreater",{get:function(){return i._IsGreater},enumerable:!0,configurable:!0}),Object.defineProperty(i,"IsLesser",{get:function(){return i._IsLesser},enumerable:!0,configurable:!0}),i.prototype.isValid=function(){switch(this.operator){case i.IsGreater:return this._effectiveTarget[this._property]>this.value;case i.IsLesser:return this._effectiveTarget[this._property]<this.value;case i.IsEqual:case i.IsDifferent:var e;return e=this.value.equals?this.value.equals(this._effectiveTarget[this._property]):this.value===this._effectiveTarget[this._property],this.operator===i.IsEqual?e:!e}return!1},i.prototype.serialize=function(){return this._serialize({name:"ValueCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"operator",value:i.GetOperatorName(this.operator)}]})},i.GetOperatorName=function(e){switch(e){case i._IsEqual:return"IsEqual";case i._IsDifferent:return"IsDifferent";case i._IsGreater:return"IsGreater";case i._IsLesser:return"IsLesser";default:return""}},i._IsEqual=0,i._IsDifferent=1,i._IsGreater=2,i._IsLesser=3,i})(t);e.ValueCondition=i;var r=(function(e){function t(t,i){var r=e.call(this,t)||this;return r.predicate=i,r}return o(t,e),t.prototype.isValid=function(){return this.predicate()},t})(t);e.PredicateCondition=r;var n=(function(t){function i(e,i,r){var n=t.call(this,e)||this;return n.value=r,n._target=i,n}return o(i,t),i.prototype.isValid=function(){return this._target.state===this.value},i.prototype.serialize=function(){return this._serialize({name:"StateCondition",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]})},i})(t);e.StateCondition=n})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i){this.triggerOptions=t,this.onBeforeExecuteObservable=new e.Observable,t.parameter?(this.trigger=t.trigger,this._triggerParameter=t.parameter):this.trigger=t,this._nextActiveAction=this,this._condition=i}return t.prototype._prepare=function(){},t.prototype.getTriggerParameter=function(){return this._triggerParameter},t.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()},t.prototype.execute=function(e){},t.prototype.skipToNextActiveAction=function(){this._nextActiveAction._child?(this._nextActiveAction._child._actionManager||(this._nextActiveAction._child._actionManager=this._actionManager),this._nextActiveAction=this._nextActiveAction._child):this._nextActiveAction=this},t.prototype.then=function(e){return this._child=e,e._actionManager=this._actionManager,e._prepare(),e},t.prototype._getProperty=function(e){return this._actionManager._getProperty(e)},t.prototype._getEffectiveTarget=function(e,t){return this._actionManager._getEffectiveTarget(e,t)},t.prototype.serialize=function(e){},t.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},t._SerializeValueAsString=function(t){return"number"==typeof t?t.toString():"boolean"==typeof t?t?"true":"false":t instanceof e.Vector2?t.x+", "+t.y:t instanceof e.Vector3?t.x+", "+t.y+", "+t.z:t instanceof e.Color3?t.r+", "+t.g+", "+t.b:t instanceof e.Color4?t.r+", "+t.g+", "+t.b+", "+t.a:t},t._GetTargetProperty=function(t){return{name:"target",targetType:t instanceof e.Mesh?"MeshProperties":t instanceof e.Light?"LightProperties":t instanceof e.Camera?"CameraProperties":"SceneProperties",value:t instanceof e.Scene?"Scene":t.name}},t})();e.Action=t})(r||(r={}));var r;!(function(e){var t=(function(){function e(e,t,i,r,n,o){this.source=e,this.pointerX=t,this.pointerY=i,this.meshUnderPointer=r,this.sourceEvent=n,this.additionalData=o}return e.CreateNew=function(t,i,r){var n=t.getScene();return new e(t,n.pointerX,n.pointerY,n.meshUnderPointer,i,r)},e.CreateNewFromSprite=function(t,i,r,n){return new e(t,i.pointerX,i.pointerY,i.meshUnderPointer,r,n)},e.CreateNewFromScene=function(t,i){return new e(null,t.pointerX,t.pointerY,t.meshUnderPointer,i)},e.CreateNewFromPrimitive=function(t,i,r,n){return new e(t,i.x,i.y,null,r,n)},e})();e.ActionEvent=t;var i=(function(){function t(t){this.actions=new Array,this.hoverCursor="",this._scene=t||e.Engine.LastCreatedScene,t._actionManagers.push(this)}return Object.defineProperty(t,"NothingTrigger",{get:function(){return t._NothingTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickTrigger",{get:function(){return t._OnPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnLeftPickTrigger",{get:function(){return t._OnLeftPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnRightPickTrigger",{get:function(){return t._OnRightPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnCenterPickTrigger",{get:function(){return t._OnCenterPickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickDownTrigger",{get:function(){return t._OnPickDownTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnDoublePickTrigger",{get:function(){return t._OnDoublePickTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickUpTrigger",{get:function(){return t._OnPickUpTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPickOutTrigger",{get:function(){return t._OnPickOutTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnLongPressTrigger",{get:function(){return t._OnLongPressTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOverTrigger",{get:function(){return t._OnPointerOverTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnPointerOutTrigger",{get:function(){return t._OnPointerOutTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnEveryFrameTrigger",{get:function(){return t._OnEveryFrameTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionEnterTrigger",{get:function(){return t._OnIntersectionEnterTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnIntersectionExitTrigger",{get:function(){return t._OnIntersectionExitTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyDownTrigger",{get:function(){return t._OnKeyDownTrigger},enumerable:!0,configurable:!0}),Object.defineProperty(t,"OnKeyUpTrigger",{get:function(){return t._OnKeyUpTrigger},enumerable:!0,configurable:!0}),t.prototype.dispose=function(){for(var e=this._scene._actionManagers.indexOf(this),i=0;i<this.actions.length;i++){var r=this.actions[i];t.Triggers[r.trigger]--,0===t.Triggers[r.trigger]&&delete t.Triggers[r.trigger]}e>-1&&this._scene._actionManagers.splice(e,1)},t.prototype.getScene=function(){return this._scene},t.prototype.hasSpecificTriggers=function(e){for(var t=0;t<this.actions.length;t++){var i=this.actions[t];if(e.indexOf(i.trigger)>-1)return!0}return!1},t.prototype.hasSpecificTrigger=function(e,t){for(var i=0;i<this.actions.length;i++){var r=this.actions[i];if(r.trigger===e){if(!t)return!0;if(t(r.getTriggerParameter()))return!0}}return!1},Object.defineProperty(t.prototype,"hasPointerTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t._OnPickTrigger&&i.trigger<=t._OnPointerOutTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"hasPickTriggers",{get:function(){for(var e=0;e<this.actions.length;e++){var i=this.actions[e];if(i.trigger>=t._OnPickTrigger&&i.trigger<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e))return!0;return!1},enumerable:!0,configurable:!0}),Object.defineProperty(t,"HasPickTriggers",{get:function(){for(var e in t.Triggers)if(t.Triggers.hasOwnProperty(e)){var i=parseInt(e);if(i>=t._OnPickTrigger&&i<=t._OnPickUpTrigger)return!0}return!1},enumerable:!0,configurable:!0}),t.HasSpecificTrigger=function(e){for(var i in t.Triggers)if(t.Triggers.hasOwnProperty(i)){var r=parseInt(i);if(r===e)return!0}return!1},t.prototype.registerAction=function(i){return i.trigger===t.OnEveryFrameTrigger&&this.getScene().actionManager!==this?(e.Tools.Warn("OnEveryFrameTrigger can only be used with scene.actionManager"),null):(this.actions.push(i),t.Triggers[i.trigger]?t.Triggers[i.trigger]++:t.Triggers[i.trigger]=1,i._actionManager=this,i._prepare(),i)},t.prototype.unregisterAction=function(e){var i=this.actions.indexOf(e);return-1!==i&&(this.actions.splice(i,1),t.Triggers[e.trigger]-=1,0===t.Triggers[e.trigger]&&delete t.Triggers[e.trigger],delete e._actionManager,!0)},t.prototype.processTrigger=function(e,i){for(var r=0;r<this.actions.length;r++){var n=this.actions[r];if(n.trigger===e){if(i&&(e===t.OnKeyUpTrigger||e===t.OnKeyDownTrigger)){var o=n.getTriggerParameter();if(o&&o!==i.sourceEvent.keyCode){if(!o.toLowerCase)continue;var s=o.toLowerCase();if(s!==i.sourceEvent.key){var a=i.sourceEvent.charCode?i.sourceEvent.charCode:i.sourceEvent.keyCode;if(String.fromCharCode(a).toLowerCase()!==s)continue}}}n._executeCurrent(i)}}},t.prototype._getEffectiveTarget=function(e,t){for(var i=t.split("."),r=0;r<i.length-1;r++)e=e[i[r]];return e},t.prototype._getProperty=function(e){var t=e.split(".");return t[t.length-1]},t.prototype.serialize=function(i){for(var r={children:new Array,name:i,type:3,properties:new Array},n=0;n<this.actions.length;n++){var o={type:0,children:new Array,name:t.GetTriggerName(this.actions[n].trigger),properties:new Array},s=this.actions[n].triggerOptions;if(s&&"number"!=typeof s)if(s.parameter instanceof e.Node)o.properties.push(e.Action._GetTargetProperty(s.parameter));else{var a={};e.Tools.DeepCopy(s.parameter,a,["mesh"]),s.parameter.mesh&&(a._meshId=s.parameter.mesh.id),o.properties.push({name:"parameter",targetType:null,value:a})}this.actions[n].serialize(o),r.children.push(o)}return r},t.Parse=function(i,r,n){var o=new t(n);null===r?n.actionManager=o:r.actionManager=o;for(var s=function(t,i){var r=Object.create(e.Tools.Instantiate("BABYLON."+t).prototype);return r.constructor.apply(r,i),r},a=function(t,i,r,n){if(null===n){var o=parseFloat(i);return"true"===i||"false"===i?"true"===i:isNaN(o)?i:o}for(var s=n.split("."),a=i.split(","),l=0;l<s.length;l++)r=r[s[l]];if("boolean"==typeof r)return"true"===a[0];if("string"==typeof r)return a[0];for(var h=new Array,l=0;l<a.length;l++)h.push(parseFloat(a[l]));return r instanceof e.Vector3?e.Vector3.FromArray(h):r instanceof e.Vector4?e.Vector4.FromArray(h):r instanceof e.Color3?e.Color3.FromArray(h):r instanceof e.Color4?e.Color4.FromArray(h):parseFloat(a[0])},l=function(i,r,h,c,u){if(void 0===u&&(u=null),!i.detached){var f=new Array,p=null,d=null,m=i.combine&&i.combine.length>0;if(2===i.type?f.push(o):f.push(r),m){for(var _=new Array,g=0;g<i.combine.length;g++)l(i.combine[g],t.NothingTrigger,h,c,_);f.push(_)}else for(var v=0;v<i.properties.length;v++){var y=i.properties[v].value,b=i.properties[v].name,x=i.properties[v].targetType;"target"===b?y=p=null!==x&&"SceneProperties"===x?n:n.getNodeByName(y):"parent"===b?y=n.getNodeByName(y):"sound"===b?y=n.getSoundByName(y):"propertyPath"!==b?y=2===i.type&&"operator"===b?e.ValueCondition[y]:a(0,y,p,"value"===b?d:null):d=y,f.push(y)}if(null===u?f.push(h):f.push(null),"InterpolateValueAction"===i.name){var T=f[f.length-2];f[f.length-1]=T,f[f.length-2]=h}var E=s(i.name,f);if(E instanceof e.Condition&&null!==h){var P=new e.DoNothingAction(r,h);c?c.then(P):o.registerAction(P),c=P}null===u?E instanceof e.Condition?(h=E,E=c):(h=null,c?c.then(E):o.registerAction(E)):u.push(E);for(var v=0;v<i.children.length;v++)l(i.children[v],r,h,E,null)}},h=0;h<i.children.length;h++){var c,u=i.children[h];if(u.properties.length>0){var f=u.properties[0].value,p=null===u.properties[0].targetType?f:n.getMeshByName(f);p._meshId&&(p.mesh=n.getMeshByID(p._meshId)),c={trigger:t[u.name],parameter:p}}else c=t[u.name];for(var d=0;d<u.children.length;d++)u.detached||l(u.children[d],c,null,null)}},t.GetTriggerName=function(e){switch(e){case 0:return"NothingTrigger";case 1:return"OnPickTrigger";case 2:return"OnLeftPickTrigger";case 3:return"OnRightPickTrigger";case 4:return"OnCenterPickTrigger";case 5:return"OnPickDownTrigger";case 6:return"OnPickUpTrigger";case 7:return"OnLongPressTrigger";case 8:return"OnPointerOverTrigger";case 9:return"OnPointerOutTrigger";case 10:return"OnEveryFrameTrigger";case 11:return"OnIntersectionEnterTrigger";case 12:return"OnIntersectionExitTrigger";case 13:return"OnKeyDownTrigger";case 14:return"OnKeyUpTrigger";case 15:return"OnPickOutTrigger";default:return""}},t._NothingTrigger=0,t._OnPickTrigger=1,t._OnLeftPickTrigger=2,t._OnRightPickTrigger=3,t._OnCenterPickTrigger=4,t._OnPickDownTrigger=5,t._OnDoublePickTrigger=6,t._OnPickUpTrigger=7,t._OnLongPressTrigger=8,t._OnPointerOverTrigger=9,t._OnPointerOutTrigger=10,t._OnEveryFrameTrigger=11,t._OnIntersectionEnterTrigger=12,t._OnIntersectionExitTrigger=13,t._OnKeyDownTrigger=14,t._OnKeyUpTrigger=15,t._OnPickOutTrigger=16,t.Triggers={},t})();e.ActionManager=i})(r||(r={}));var r;!(function(e){var t=(function(t){function i(i,r,n,o,s,a,l,h){void 0===s&&(s=1e3);var c=t.call(this,i,a)||this;return c.propertyPath=n,c.value=o,c.duration=s,c.stopOtherAnimations=l,c.onInterpolationDone=h,c.onInterpolationDoneObservable=new e.Observable,c._target=c._effectiveTarget=r,c}return o(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){var t,i=this,r=this._actionManager.getScene(),n=[{frame:0,value:this._effectiveTarget[this._property]},{frame:100,value:this.value}];if("number"==typeof this.value)t=e.Animation.ANIMATIONTYPE_FLOAT;else if(this.value instanceof e.Color3)t=e.Animation.ANIMATIONTYPE_COLOR3;else if(this.value instanceof e.Vector3)t=e.Animation.ANIMATIONTYPE_VECTOR3;else if(this.value instanceof e.Matrix)t=e.Animation.ANIMATIONTYPE_MATRIX;else{if(!(this.value instanceof e.Quaternion))return void e.Tools.Warn("InterpolateValueAction: Unsupported type ("+typeof this.value+")");t=e.Animation.ANIMATIONTYPE_QUATERNION}var o=new e.Animation("InterpolateValueAction",this._property,1e3/this.duration*100,t,e.Animation.ANIMATIONLOOPMODE_CONSTANT);o.setKeys(n),this.stopOtherAnimations&&r.stopAnimation(this._effectiveTarget);var s=function(){i.onInterpolationDoneObservable.notifyObservers(i),i.onInterpolationDone&&i.onInterpolationDone()};r.beginDirectAnimation(this._effectiveTarget,[o],0,100,!1,1,s)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"InterpolateValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)},{name:"duration",value:e.Action._SerializeValueAsString(this.duration)},{name:"stopOtherAnimations",value:e.Action._SerializeValueAsString(this.stopOtherAnimations)||!1}]},i)},i})(e.Action);e.InterpolateValueAction=t})(r||(r={}));var r;!(function(e){var t=(function(t){function i(e,i,r,n){var o=t.call(this,e,n)||this;return o.propertyPath=r,o._target=o._effectiveTarget=i,o}return o(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=!this._effectiveTarget[this._property]},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SwitchBooleanAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath}]},i)},i})(e.Action);e.SwitchBooleanAction=t;var i=(function(t){function i(e,i,r,n){var o=t.call(this,e,n)||this;return o.value=r,o._target=i,o}return o(i,t),i.prototype.execute=function(){this._target.state=this.value},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetStateAction",properties:[e.Action._GetTargetProperty(this._target),{name:"value",value:this.value}]},i)},i})(e.Action);e.SetStateAction=i;var r=(function(t){function i(e,i,r,n,o){var s=t.call(this,e,o)||this;return s.propertyPath=r,s.value=n,s._target=s._effectiveTarget=i,s}return o(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath)},i.prototype.execute=function(){this._effectiveTarget[this._property]=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},i)},i})(e.Action);e.SetValueAction=r;var n=(function(t){function i(e,i,r,n,o){var s=t.call(this,e,o)||this;return s.propertyPath=r,s.value=n,s._target=s._effectiveTarget=i,s}return o(i,t),i.prototype._prepare=function(){this._effectiveTarget=this._getEffectiveTarget(this._effectiveTarget,this.propertyPath),this._property=this._getProperty(this.propertyPath),"number"!=typeof this._effectiveTarget[this._property]&&e.Tools.Warn("Warning: IncrementValueAction can only be used with number values")},i.prototype.execute=function(){this._effectiveTarget[this._property]+=this.value,this._target.markAsDirty&&this._target.markAsDirty(this._property)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"IncrementValueAction",properties:[e.Action._GetTargetProperty(this._target),{name:"propertyPath",value:this.propertyPath},{name:"value",value:e.Action._SerializeValueAsString(this.value)}]},i)},i})(e.Action);e.IncrementValueAction=n;var s=(function(t){function i(e,i,r,n,o,s){var a=t.call(this,e,s)||this;return a.from=r,a.to=n,a.loop=o,a._target=i,a}return o(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){this._actionManager.getScene().beginAnimation(this._target,this.from,this.to,this.loop)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"PlayAnimationAction",properties:[e.Action._GetTargetProperty(this._target),{name:"from",value:String(this.from)},{name:"to",value:String(this.to)},{name:"loop",value:e.Action._SerializeValueAsString(this.loop)||!1}]},i)},i})(e.Action);e.PlayAnimationAction=s;var a=(function(t){function i(e,i,r){var n=t.call(this,e,r)||this;return n._target=i,n}return o(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){this._actionManager.getScene().stopAnimation(this._target)},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"StopAnimationAction",properties:[e.Action._GetTargetProperty(this._target)]},i)},i})(e.Action);e.StopAnimationAction=a;var l=(function(t){function i(i,r){return void 0===i&&(i=e.ActionManager.NothingTrigger),t.call(this,i,r)||this}return o(i,t),i.prototype.execute=function(){},i.prototype.serialize=function(e){return t.prototype._serialize.call(this,{name:"DoNothingAction",properties:[]},e)},i})(e.Action);e.DoNothingAction=l;var h=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n.children=i,n}return o(t,e),t.prototype._prepare=function(){for(var e=0;e<this.children.length;e++)this.children[e]._actionManager=this._actionManager,this.children[e]._prepare()},t.prototype.execute=function(e){for(var t=0;t<this.children.length;t++)this.children[t].execute(e)},t.prototype.serialize=function(t){for(var i=e.prototype._serialize.call(this,{name:"CombineAction",properties:[],combine:[]},t),r=0;r<this.children.length;r++)i.combine.push(this.children[r].serialize(null));return i},t})(e.Action);e.CombineAction=h;var c=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n.func=i,n}return o(t,e),t.prototype.execute=function(e){this.func(e)},t})(e.Action);e.ExecuteCodeAction=c;var u=(function(t){function i(e,i,r,n){var o=t.call(this,e,n)||this;return o._target=i,o._parent=r,o}return o(i,t),i.prototype._prepare=function(){},i.prototype.execute=function(){if(this._target.parent!==this._parent){var t=this._parent.getWorldMatrix().clone();t.invert(),this._target.position=e.Vector3.TransformCoordinates(this._target.position,t),this._target.parent=this._parent}},i.prototype.serialize=function(i){return t.prototype._serialize.call(this,{name:"SetParentAction",properties:[e.Action._GetTargetProperty(this._target),e.Action._GetTargetProperty(this._parent)]},i)},i})(e.Action);e.SetParentAction=u;var f=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._sound=i,n}return o(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.play()},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"PlaySoundAction",properties:[{name:"sound",value:this._sound.name}]},t)},t})(e.Action);e.PlaySoundAction=f;var p=(function(e){function t(t,i,r){var n=e.call(this,t,r)||this;return n._sound=i,n}return o(t,e),t.prototype._prepare=function(){},t.prototype.execute=function(){void 0!==this._sound&&this._sound.stop()},t.prototype.serialize=function(t){return e.prototype._serialize.call(this,{name:"StopSoundAction",properties:[{name:"sound",value:this._sound.name}]},t)},t})(e.Action);e.StopSoundAction=p})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i,r,n,o,s,a){if(void 0===s&&(s=.01),void 0===a&&(a=e.Texture.TRILINEAR_SAMPLINGMODE),this.name=t,this.sprites=new Array,this.renderingGroupId=0,this.layerMask=268435455,this.fogEnabled=!0,this.isPickable=!1,this.onDisposeObservable=new e.Observable,this._vertexBuffers={},this._capacity=r,this._spriteTexture=new e.Texture(i,o,!0,!1,a),this._spriteTexture.wrapU=e.Texture.CLAMP_ADDRESSMODE,this._spriteTexture.wrapV=e.Texture.CLAMP_ADDRESSMODE,n.width&&n.height)this.cellWidth=n.width,this.cellHeight=n.height;else{if(void 0===n)return;this.cellWidth=n,this.cellHeight=n}this._epsilon=s,this._scene=o,this._scene.spriteManagers.push(this);for(var l=[],h=0,c=0;c<r;c++)l.push(h),l.push(h+1),l.push(h+2),l.push(h),l.push(h+2),l.push(h+3),h+=4;this._indexBuffer=o.getEngine().createIndexBuffer(l),this._vertexData=new Float32Array(16*r*4),this._buffer=new e.Buffer(o.getEngine(),this._vertexData,!0,16);var u=this._buffer.createVertexBuffer(e.VertexBuffer.PositionKind,0,4),f=this._buffer.createVertexBuffer("options",4,4),p=this._buffer.createVertexBuffer("cellInfo",8,4),d=this._buffer.createVertexBuffer(e.VertexBuffer.ColorKind,12,4);this._vertexBuffers[e.VertexBuffer.PositionKind]=u,this._vertexBuffers.options=f,this._vertexBuffers.cellInfo=p,this._vertexBuffers[e.VertexBuffer.ColorKind]=d,this._effectBase=this._scene.getEngine().createEffect("sprites",[e.VertexBuffer.PositionKind,"options","cellInfo",e.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest"],["diffuseSampler"],""),this._effectFog=this._scene.getEngine().createEffect("sprites",[e.VertexBuffer.PositionKind,"options","cellInfo",e.VertexBuffer.ColorKind],["view","projection","textureInfos","alphaTest","vFogInfos","vFogColor"],["diffuseSampler"],"#define FOG")}return 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,"texture",{get:function(){return this._spriteTexture},set:function(e){this._spriteTexture=e},enumerable:!0,configurable:!0}),t.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},t.prototype.intersects=function(t,i,r,n){for(var o=Math.min(this._capacity,this.sprites.length),s=e.Vector3.Zero(),a=e.Vector3.Zero(),l=Number.MAX_VALUE,h=null,c=e.Vector3.Zero(),u=i.getViewMatrix(),f=0;f<o;f++){var p=this.sprites[f];if(p){if(r){if(!r(p))continue}else if(!p.isPickable)continue;if(e.Vector3.TransformCoordinatesToRef(p.position,u,c),s.copyFromFloats(c.x-p.width/2,c.y-p.height/2,c.z),a.copyFromFloats(c.x+p.width/2,c.y+p.height/2,c.z),t.intersectsBoxMinMax(s,a)){var d=e.Vector3.Distance(c,t.origin);if(l>d&&(l=d,h=p,n))break}}}if(h){var m=new e.PickingInfo;return m.hit=!0,m.pickedSprite=h,m.distance=l,m}return null},t.prototype.render=function(){if(this._effectBase.isReady()&&this._effectFog.isReady()&&this._spriteTexture&&this._spriteTexture.isReady()){for(var t=this._scene.getEngine(),i=this._spriteTexture.getBaseSize(),r=t.getDeltaTime(),n=Math.min(this._capacity,this.sprites.length),o=i.width/this.cellWidth,s=0,a=0;a<n;a++){var l=this.sprites[a];l&&(l._animate(r),this._appendSpriteVertex(s++,l,0,0,o),this._appendSpriteVertex(s++,l,1,0,o),this._appendSpriteVertex(s++,l,1,1,o),this._appendSpriteVertex(s++,l,0,1,o))}this._buffer.update(this._vertexData);var h=this._effectBase;this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(h=this._effectFog),t.enableEffect(h);var c=this._scene.getViewMatrix();h.setTexture("diffuseSampler",this._spriteTexture),h.setMatrix("view",c),h.setMatrix("projection",this._scene.getProjectionMatrix()),h.setFloat2("textureInfos",this.cellWidth/i.width,this.cellHeight/i.height),
this._scene.fogEnabled&&this._scene.fogMode!==e.Scene.FOGMODE_NONE&&this.fogEnabled&&(h.setFloat4("vFogInfos",this._scene.fogMode,this._scene.fogStart,this._scene.fogEnd,this._scene.fogDensity),h.setColor3("vFogColor",this._scene.fogColor)),t.bindBuffers(this._vertexBuffers,this._indexBuffer,h),t.setDepthFunctionToLessOrEqual(),h.setBool("alphaTest",!0),t.setColorWrite(!1),t.drawElementsType(e.Material.TriangleFillMode,0,6*n),t.setColorWrite(!0),h.setBool("alphaTest",!1),t.setAlphaMode(e.Engine.ALPHA_COMBINE),t.drawElementsType(e.Material.TriangleFillMode,0,6*n),t.setAlphaMode(e.Engine.ALPHA_DISABLE)}},t.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()},t})();e.SpriteManager=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(t,i){this.name=t,this.color=new e.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._manager=i,this._manager.sprites.push(this),this.position=e.Vector3.Zero()}return Object.defineProperty(t.prototype,"size",{get:function(){return this.width},set:function(e){this.width=e,this.height=e},enumerable:!0,configurable:!0}),t.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},t.prototype.stopAnimation=function(){this._animationStarted=!1},t.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()))))},t.prototype.dispose=function(){for(var e=0;e<this._manager.sprites.length;e++)this._manager.sprites[e]==this&&this._manager.sprites.splice(e,1)},t})();e.Sprite=t})(r||(r={}));var r;!(function(e){var t=(function(){function e(e,t,i){this.bu=e,this.bv=t,this.distance=i,this.faceId=0,this.subMeshId=0}return e})();e.IntersectionInfo=t;var i=(function(){function t(){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}return t.prototype.getNormal=function(t,i){if(void 0===t&&(t=!1),void 0===i&&(i=!0),!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.NormalKind))return null;var r=this.pickedMesh.getIndices();if(!r)return null;var n;if(i){var o=this.pickedMesh.getVerticesData(e.VertexBuffer.NormalKind),s=e.Vector3.FromArray(o,3*r[3*this.faceId]),a=e.Vector3.FromArray(o,3*r[3*this.faceId+1]),l=e.Vector3.FromArray(o,3*r[3*this.faceId+2]);s=s.scale(this.bu),a=a.scale(this.bv),l=l.scale(1-this.bu-this.bv),n=new e.Vector3(s.x+a.x+l.x,s.y+a.y+l.y,s.z+a.z+l.z)}else{var h=this.pickedMesh.getVerticesData(e.VertexBuffer.PositionKind),c=e.Vector3.FromArray(h,3*r[3*this.faceId]),u=e.Vector3.FromArray(h,3*r[3*this.faceId+1]),f=e.Vector3.FromArray(h,3*r[3*this.faceId+2]),p=c.subtract(u),d=f.subtract(u);n=e.Vector3.Cross(p,d)}return t&&(n=e.Vector3.TransformNormal(n,this.pickedMesh.getWorldMatrix())),e.Vector3.Normalize(n)},t.prototype.getTextureCoordinates=function(){if(!this.pickedMesh||!this.pickedMesh.isVerticesDataPresent(e.VertexBuffer.UVKind))return null;var t=this.pickedMesh.getIndices();if(!t)return null;var i=this.pickedMesh.getVerticesData(e.VertexBuffer.UVKind);if(!i)return null;var r=e.Vector2.FromArray(i,2*t[3*this.faceId]),n=e.Vector2.FromArray(i,2*t[3*this.faceId+1]),o=e.Vector2.FromArray(i,2*t[3*this.faceId+2]);return r=r.scale(1-this.bu-this.bv),n=n.scale(this.bu),o=o.scale(this.bv),new e.Vector2(r.x+n.x+o.x,r.y+n.y+o.y)},t})();e.PickingInfo=i})(r||(r={}));var r;!(function(e){var t=(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,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)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,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)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,n===-1/0&&(n=1/0),r>n&&(o=r,r=n,n=o),s=Math.max(r,s),a=Math.min(n,a),s>a)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(t,i,r){this._edge1||(this._edge1=e.Vector3.Zero(),this._edge2=e.Vector3.Zero(),this._pvec=e.Vector3.Zero(),this._tvec=e.Vector3.Zero(),this._qvec=e.Vector3.Zero()),i.subtractToRef(t,this._edge1),r.subtractToRef(t,this._edge2),e.Vector3.CrossToRef(this.direction,this._edge2,this._pvec);var n=e.Vector3.Dot(this._edge1,this._pvec);if(0===n)return null;var o=1/n;this.origin.subtractToRef(t,this._tvec);var s=e.Vector3.Dot(this._tvec,this._pvec)*o;if(s<0||s>1)return null;e.Vector3.CrossToRef(this._tvec,this._edge1,this._qvec);var a=e.Vector3.Dot(this.direction,this._qvec)*o;if(a<0||s+a>1)return null;var l=e.Vector3.Dot(this._edge2,this._qvec)*o;return l>this.length?null:new e.IntersectionInfo(s,a,l)},t.prototype.intersectsPlane=function(t){var i,r=e.Vector3.Dot(t.normal,this.direction);if(Math.abs(r)<9.99999997475243e-7)return null;var n=e.Vector3.Dot(t.normal,this.origin);return i=(-t.d-n)/r,i<0?i<-9.99999997475243e-7?null:0:i},t.prototype.intersectsMesh=function(i,r){var n=e.Tmp.Matrix[0];return i.getWorldMatrix().invertToRef(n),this._tmpRay?t.TransformToRef(this,n,this._tmpRay):this._tmpRay=t.Transform(this,n),i.intersects(this._tmpRay,r)},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(i,r,n){var o,s,a,l,h=this.origin.add(this.direction.multiplyByFloats(t.rayl,t.rayl,t.rayl)),c=r.subtract(i),u=h.subtract(this.origin),f=i.subtract(this.origin),p=e.Vector3.Dot(c,c),d=e.Vector3.Dot(c,u),m=e.Vector3.Dot(u,u),_=e.Vector3.Dot(c,f),g=e.Vector3.Dot(u,f),v=p*m-d*d,y=v,b=v;v<t.smallnum?(s=0,y=1,l=g,b=m):(s=d*g-m*_,l=p*g-d*_,s<0?(s=0,l=g,b=m):s>y&&(s=y,l=g+d,b=m)),l<0?(l=0,-_<0?s=0:-_>p?s=y:(s=-_,y=p)):l>b&&(l=b,-_+d<0?s=0:-_+d>p?s=y:(s=-_+d,y=p)),o=Math.abs(s)<t.smallnum?0:s/y,a=Math.abs(l)<t.smallnum?0:l/b;var x=u.multiplyByFloats(a,a,a),T=f.add(c.multiplyByFloats(o,o,o)).subtract(x);return a>0&&a<=this.length&&T.lengthSquared()<n*n?x.length():-1},t.prototype.update=function(t,i,r,n,o,s,a){return e.Vector3.UnprojectFloatsToRef(t,i,0,r,n,o,s,a,this.origin),e.Vector3.UnprojectFloatsToRef(t,i,1,r,n,o,s,a,e.Tmp.Vector3[0]),e.Tmp.Vector3[0].subtractToRef(this.origin,this.direction),this.direction.normalize(),this},t.Zero=function(){return new t(e.Vector3.Zero(),e.Vector3.Zero())},t.CreateNew=function(e,i,r,n,o,s,a){return t.Zero().update(e,i,r,n,o,s,a)},t.CreateNewFromTo=function(i,r,n){void 0===n&&(n=e.Matrix.Identity());var o=r.subtract(i),s=Math.sqrt(o.x*o.x+o.y*o.y+o.z*o.z);return o.normalize(),t.Transform(new t(i,o,s),n)},t.Transform=function(i,r){var n=new t(new e.Vector3(0,0,0),new e.Vector3(0,0,0));return t.TransformToRef(i,r,n),n},t.TransformToRef=function(t,i,r){e.Vector3.TransformCoordinatesToRef(t.origin,i,r.origin),e.Vector3.TransformNormalToRef(t.direction,i,r.direction),r.length=t.length;var n=r.direction,o=n.length();if(0!==o&&1!==o){var s=1/o;n.x*=s,n.y*=s,n.z*=s,r.length*=o}},t.smallnum=1e-8,t.rayl=1e9,t})();e.Ray=t})(r||(r={}));var r;!(function(e){var t=function(e,t,i,r){return!(e.x>i.x+r)&&(!(i.x-r>t.x)&&(!(e.y>i.y+r)&&(!(i.y-r>t.y)&&(!(e.z>i.z+r)&&!(i.z-r>t.z)))))},i=(function(){var e={root:0,found:!1};return function(t,i,r,n){e.root=0,e.found=!1;var o=i*i-4*t*r;if(o<0)return e;var s=Math.sqrt(o),a=(-i-s)/(2*t),l=(-i+s)/(2*t);if(a>l){var h=l;l=a,a=h}return a>0&&a<n?(e.root=a,e.found=!0,e):l>0&&l<n?(e.root=l,e.found=!0,e):e}})(),r=(function(){function r(){this._collisionPoint=e.Vector3.Zero(),this._planeIntersectionPoint=e.Vector3.Zero(),this._tempVector=e.Vector3.Zero(),this._tempVector2=e.Vector3.Zero(),this._tempVector3=e.Vector3.Zero(),this._tempVector4=e.Vector3.Zero(),this._edge=e.Vector3.Zero(),this._baseToVertex=e.Vector3.Zero(),this._destinationPoint=e.Vector3.Zero(),this._slidePlaneNormal=e.Vector3.Zero(),this._displacementVector=e.Vector3.Zero(),this._radius=e.Vector3.One(),this._retry=0,this._basePointWorld=e.Vector3.Zero(),this._velocityWorld=e.Vector3.Zero(),this._normalizedVelocity=e.Vector3.Zero(),this._collisionMask=-1}return Object.defineProperty(r.prototype,"collisionMask",{get:function(){return this._collisionMask},set:function(e){this._collisionMask=isNaN(e)?-1:e},enumerable:!0,configurable:!0}),Object.defineProperty(r.prototype,"slidePlaneNormal",{get:function(){return this._slidePlaneNormal},enumerable:!0,configurable:!0}),r.prototype._initialize=function(t,i,r){this._velocity=i,e.Vector3.NormalizeToRef(i,this._normalizedVelocity),this._basePoint=t,t.multiplyToRef(this._radius,this._basePointWorld),i.multiplyToRef(this._radius,this._velocityWorld),this._velocityWorldLength=this._velocityWorld.length(),this._epsilon=r,this.collisionFound=!1},r.prototype._checkPointInTriangle=function(t,i,r,n,o){i.subtractToRef(t,this._tempVector),r.subtractToRef(t,this._tempVector2),e.Vector3.CrossToRef(this._tempVector,this._tempVector2,this._tempVector4);var s=e.Vector3.Dot(this._tempVector4,o);return!(s<0)&&(n.subtractToRef(t,this._tempVector3),e.Vector3.CrossToRef(this._tempVector2,this._tempVector3,this._tempVector4),!((s=e.Vector3.Dot(this._tempVector4,o))<0)&&(e.Vector3.CrossToRef(this._tempVector3,this._tempVector,this._tempVector4),(s=e.Vector3.Dot(this._tempVector4,o))>=0))},r.prototype._canDoCollision=function(i,r,n,o){var s=e.Vector3.Distance(this._basePointWorld,i),a=Math.max(this._radius.x,this._radius.y,this._radius.z);return!(s>this._velocityWorldLength+a+r)&&!!t(n,o,this._basePointWorld,this._velocityWorldLength+a)},r.prototype._testTriangle=function(t,r,n,o,s,a){var l,h=!1;r||(r=[]),r[t]||(r[t]=new e.Plane(0,0,0,0),r[t].copyFromPoints(n,o,s));var c=r[t];if(a||c.isFrontFacingTo(this._normalizedVelocity,0)){var u=c.signedDistanceTo(this._basePoint),f=e.Vector3.Dot(c.normal,this._velocity);if(0==f){if(Math.abs(u)>=1)return;h=!0,l=0}else{l=(-1-u)/f;var p=(1-u)/f;if(l>p){var d=p;p=l,l=d}if(l>1||p<0)return;l<0&&(l=0),l>1&&(l=1)}this._collisionPoint.copyFromFloats(0,0,0);var m=!1,_=1;if(h||(this._basePoint.subtractToRef(c.normal,this._planeIntersectionPoint),this._velocity.scaleToRef(l,this._tempVector),this._planeIntersectionPoint.addInPlace(this._tempVector),this._checkPointInTriangle(this._planeIntersectionPoint,n,o,s,c.normal)&&(m=!0,_=l,this._collisionPoint.copyFrom(this._planeIntersectionPoint))),!m){var g=this._velocity.lengthSquared(),v=g;this._basePoint.subtractToRef(n,this._tempVector);var y=2*e.Vector3.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,x=i(v,y,b,_);x.found&&(_=x.root,m=!0,this._collisionPoint.copyFrom(n)),this._basePoint.subtractToRef(o,this._tempVector),y=2*e.Vector3.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,x=i(v,y,b,_),x.found&&(_=x.root,m=!0,this._collisionPoint.copyFrom(o)),this._basePoint.subtractToRef(s,this._tempVector),y=2*e.Vector3.Dot(this._velocity,this._tempVector),b=this._tempVector.lengthSquared()-1,x=i(v,y,b,_),x.found&&(_=x.root,m=!0,this._collisionPoint.copyFrom(s)),o.subtractToRef(n,this._edge),n.subtractToRef(this._basePoint,this._baseToVertex);var T=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this._velocity),P=e.Vector3.Dot(this._edge,this._baseToVertex);if(v=T*-g+E*E,y=T*(2*e.Vector3.Dot(this._velocity,this._baseToVertex))-2*E*P,b=T*(1-this._baseToVertex.lengthSquared())+P*P,x=i(v,y,b,_),x.found){var A=(E*x.root-P)/T;A>=0&&A<=1&&(_=x.root,m=!0,this._edge.scaleInPlace(A),n.addToRef(this._edge,this._collisionPoint))}s.subtractToRef(o,this._edge),o.subtractToRef(this._basePoint,this._baseToVertex),T=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this._velocity),P=e.Vector3.Dot(this._edge,this._baseToVertex),v=T*-g+E*E,y=T*(2*e.Vector3.Dot(this._velocity,this._baseToVertex))-2*E*P,b=T*(1-this._baseToVertex.lengthSquared())+P*P,x=i(v,y,b,_),x.found&&(A=(E*x.root-P)/T)>=0&&A<=1&&(_=x.root,m=!0,this._edge.scaleInPlace(A),o.addToRef(this._edge,this._collisionPoint)),n.subtractToRef(s,this._edge),s.subtractToRef(this._basePoint,this._baseToVertex),T=this._edge.lengthSquared(),E=e.Vector3.Dot(this._edge,this._velocity),P=e.Vector3.Dot(this._edge,this._baseToVertex),v=T*-g+E*E,y=T*(2*e.Vector3.Dot(this._velocity,this._baseToVertex))-2*E*P,b=T*(1-this._baseToVertex.lengthSquared())+P*P,x=i(v,y,b,_),x.found&&(A=(E*x.root-P)/T)>=0&&A<=1&&(_=x.root,m=!0,this._edge.scaleInPlace(A),s.addToRef(this._edge,this._collisionPoint))}if(m){var M=_*this._velocity.length();(!this.collisionFound||M<this._nearestDistance)&&(this.intersectionPoint?this.intersectionPoint.copyFrom(this._collisionPoint):this.intersectionPoint=this._collisionPoint.clone(),this._nearestDistance=M,this.collisionFound=!0)}}},r.prototype._collide=function(e,t,i,r,n,o,s){for(var a=r;a<n;a+=3){var l=t[i[a]-o],h=t[i[a+1]-o],c=t[i[a+2]-o];this._testTriangle(a,e,c,h,l,s)}},r.prototype._getResponse=function(t,i){t.addToRef(i,this._destinationPoint),i.scaleInPlace(this._nearestDistance/i.length()),this._basePoint.addToRef(i,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(e.Plane.SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint,this._slidePlaneNormal,this._destinationPoint)),this._destinationPoint.subtractInPlace(this._slidePlaneNormal),this._destinationPoint.subtractToRef(this.intersectionPoint,i)},r})();e.Collider=r})(r||(r={}));var r;!(function(e){e.CollisionWorker="";var t;!(function(e){e[e.INIT=0]="INIT",e[e.UPDATE=1]="UPDATE",e[e.COLLIDE=2]="COLLIDE"})(t=e.WorkerTaskType||(e.WorkerTaskType={}));var i;!(function(e){e[e.SUCCESS=0]="SUCCESS",e[e.UNKNOWN_ERROR=1]="UNKNOWN_ERROR"})(i=e.WorkerReplyType||(e.WorkerReplyType={}));var r=(function(){function r(){var n=this;this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this.onMeshUpdated=function(e){n._addUpdateMeshesList[e.uniqueId]=r.SerializeMesh(e)},this.onGeometryUpdated=function(e){n._addUpdateGeometriesList[e.id]=r.SerializeGeometry(e)},this._afterRender=function(){if(n._init&&!(0==n._toRemoveGeometryArray.length&&0==n._toRemoveMeshesArray.length&&0==Object.keys(n._addUpdateGeometriesList).length&&0==Object.keys(n._addUpdateMeshesList).length||n._runningUpdated>4)){++n._runningUpdated;var e={updatedMeshes:n._addUpdateMeshesList,updatedGeometries:n._addUpdateGeometriesList,removedGeometries:n._toRemoveGeometryArray,removedMeshes:n._toRemoveMeshesArray},i={payload:e,taskType:t.UPDATE},r=[];for(var o in e.updatedGeometries)e.updatedGeometries.hasOwnProperty(o)&&(r.push(i.payload.updatedGeometries[o].indices.buffer),r.push(i.payload.updatedGeometries[o].normals.buffer),r.push(i.payload.updatedGeometries[o].positions.buffer));n._worker.postMessage(i,r),n._addUpdateMeshesList={},n._addUpdateGeometriesList={},n._toRemoveGeometryArray=[],n._toRemoveMeshesArray=[]}},this._onMessageFromWorker=function(r){var o=r.data;if(o.error!=i.SUCCESS)return void e.Tools.Warn("error returned from worker!");switch(o.taskType){case t.INIT:n._init=!0,n._scene.meshes.forEach((function(e){n.onMeshAdded(e)})),n._scene.getGeometries().forEach((function(e){n.onGeometryAdded(e)}));break;case t.UPDATE:n._runningUpdated--;break;case t.COLLIDE:var s=o.payload;if(!n._collisionsCallbackArray[s.collisionId])return;var a=n._collisionsCallbackArray[s.collisionId];if(a){var l=n._scene.getMeshByUniqueID(s.collidedMeshUniqueId);l&&a(s.collisionId,e.Vector3.FromArray(s.newPosition),l)}n._collisionsCallbackArray[s.collisionId]=null}},this._collisionsCallbackArray=[],this._init=!1,this._runningUpdated=0,this._addUpdateMeshesList={},this._addUpdateGeometriesList={},this._toRemoveGeometryArray=[],this._toRemoveMeshesArray=[]}return r.prototype.getNewPosition=function(e,i,r,n,o,s,a){if(this._init&&!this._collisionsCallbackArray[a]&&!this._collisionsCallbackArray[a+1e5]){e.divideToRef(r._radius,this._scaledPosition),i.divideToRef(r._radius,this._scaledVelocity),this._collisionsCallbackArray[a]=s;var l={collider:{position:this._scaledPosition.asArray(),velocity:this._scaledVelocity.asArray(),radius:r._radius.asArray()},collisionId:a,excludedMeshUniqueId:o?o.uniqueId:null,maximumRetry:n},h={payload:l,taskType:t.COLLIDE};this._worker.postMessage(h)}},r.prototype.init=function(i){this._scene=i,this._scene.registerAfterRender(this._afterRender);var r=e.WorkerIncluded?e.Engine.CodeRepository+"Collisions/babylon.collisionWorker.js":URL.createObjectURL(new Blob([e.CollisionWorker],{type:"application/javascript"}));this._worker=new Worker(r),this._worker.onmessage=this._onMessageFromWorker;var n={payload:{},taskType:t.INIT};this._worker.postMessage(n)},r.prototype.destroy=function(){this._scene.unregisterAfterRender(this._afterRender),this._worker.terminate()},r.prototype.onMeshAdded=function(e){e.registerAfterWorldMatrixUpdate(this.onMeshUpdated),this.onMeshUpdated(e)},r.prototype.onMeshRemoved=function(e){this._toRemoveMeshesArray.push(e.uniqueId)},r.prototype.onGeometryAdded=function(e){e.onGeometryUpdated=this.onGeometryUpdated,this.onGeometryUpdated(e)},r.prototype.onGeometryDeleted=function(e){this._toRemoveGeometryArray.push(e.id)},r.SerializeMesh=function(t){var i=[];t.subMeshes&&(i=t.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 r=null;if(t instanceof e.Mesh){var n=t.geometry;r=n?n.id:null}else if(t instanceof e.InstancedMesh){var n=t.sourceMesh&&t.sourceMesh.geometry;r=n?n.id:null}var o=t.getBoundingInfo();return{uniqueId:t.uniqueId,id:t.id,name:t.name,geometryId:r,sphereCenter:o.boundingSphere.centerWorld.asArray(),sphereRadius:o.boundingSphere.radiusWorld,boxMinimum:o.boundingBox.minimumWorld.asArray(),boxMaximum:o.boundingBox.maximumWorld.asArray(),worldMatrixFromCache:t.worldMatrixFromCache.asArray(),subMeshes:i,checkCollisions:t.checkCollisions}},r.SerializeGeometry=function(t){return{id:t.id,positions:new Float32Array(t.getVerticesData(e.VertexBuffer.PositionKind)||[]),normals:new Float32Array(t.getVerticesData(e.VertexBuffer.NormalKind)||[]),indices:new Uint32Array(t.getIndices()||[])}},r})();e.CollisionCoordinatorWorker=r;var n=(function(){function t(){this._scaledPosition=e.Vector3.Zero(),this._scaledVelocity=e.Vector3.Zero(),this._finalPosition=e.Vector3.Zero()}return t.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)},t.prototype.init=function(e){this._scene=e},t.prototype.destroy=function(){},t.prototype.onMeshAdded=function(e){},t.prototype.onMeshUpdated=function(e){},t.prototype.onMeshRemoved=function(e){},t.prototype.onGeometryAdded=function(e){},t.prototype.onGeometryUpdated=function(e){},t.prototype.onGeometryDeleted=function(e){},t.prototype._collideWithWorld=function(t,i,r,n,o,s){void 0===s&&(s=null);var a=10*e.Engine.CollisionsEpsilon;if(r._retry>=n)return void o.copyFrom(t);var l=s?s.collisionMask:r.collisionMask;r._initialize(t,i,a);for(var h=0;h<this._scene.meshes.length;h++){var c=this._scene.meshes[h];c.isEnabled()&&c.checkCollisions&&c.subMeshes&&c!==s&&0!=(l&c.collisionGroup)&&c._checkCollision(r)}return r.collisionFound?(0===i.x&&0===i.y&&0===i.z||r._getResponse(t,i),i.length()<=a?void o.copyFrom(t):(r._retry++,void this._collideWithWorld(t,i,r,n,o,s))):void t.addToRef(i,o)},t})();e.CollisionCoordinatorLegacy=n})(r||(r={}));var r;!(function(e){var t=(function(){function t(t){this.particleSystem=t,this.position=e.Vector3.Zero(),this.direction=e.Vector3.Zero(),this.color=new e.Color4(0,0,0,0),this.colorStep=new e.Color4(0,0,0,0),this.lifeTime=1,this.age=0,this.size=0,this.angle=0,this.angularSpeed=0,this.cellIndex=0,this._currentFrameCounter=0,this.particleSystem.isAnimationSheetEnabled&&this.updateCellInfoFromSystem()}return t.prototype.updateCellInfoFromSystem=function(){this.cellIndex=this.particleSystem.startSpriteCellID,0==this.particleSystem.spriteCellChangeSpeed?this.updateCellIndex=this._updateCellIndexWithSpeedCalculated:this.updateCellIndex=this._updateCellIndexWithCustomSpeed},t.prototype._updateCellIndexWithSpeedCalculated=function(e){var t=(this.lifeTime-this.age)/e/(this.particleSystem.endSpriteCellID+1-this.cellIndex);this._currentFrameCounter+=e,this._currentFrameCounter>=t*e&&(this._currentFrameCounter=0,++this.cellIndex>this.particleSystem.endSpriteCellID&&(this.cellIndex=this.particleSystem.endSpriteCellID))},t.prototype._updateCellIndexWithCustomSpeed=function(){this._currentFrameCounter>=this.particleSystem.spriteCellChangeSpeed?(this.cellIndex++,this._currentFrameCounter=0,this.cellIndex>this.particleSystem.endSpriteCellID&&(this.particleSystem.spriteCellLoop?this.cellIndex=this.particleSystem.startSpriteCellID:this.cellIndex=this.particleSystem.endSpriteCellID)):this._currentFrameCounter++},t.prototype.copyTo=function(e){e.position.copyFrom(this.position),e.direction.copyFrom(this.direction),e.color.copyFrom(this.color),e.colorStep.copyFrom(this.colorStep),e.lifeTime=this.lifeTime,e.age=this.age,e.size=this.size,e.angle=this.angle,e.angularSpeed=this.angularSpeed,e.particleSystem=this.particleSystem,e.cellIndex=this.cellIndex},t})();e.Particle=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(i,r,n,o,s,a){void 0===o&&(o=null),void 0===s&&(s=!1),void 0===a&&(a=.01);var l=this;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.minAngularSpeed=0,this.maxAngularSpeed=0,this.layerMask=268435455,this.customShader=null,this.preventAutoStart=!1,this.onAnimationEnd=null,this.blendMode=t.BLENDMODE_ONEONE,this.forceDepthWrite=!1,this.gravity=e.Vector3.Zero(),this.color1=new e.Color4(1,1,1,1),this.color2=new e.Color4(1,1,1,1),this.colorDead=new e.Color4(0,0,0,1),this.textureMask=new e.Color4(1,1,1,1),this.spriteCellLoop=!0,this.spriteCellChangeSpeed=0,this.startSpriteCellID=0,this.endSpriteCellID=0,this.spriteCellWidth=0,this.spriteCellHeight=0,this.onDisposeObservable=new e.Observable,this._particles=new Array,this._stockParticles=new Array,this._newPartsExcess=0,this._vertexBuffers={},this._scaledColorStep=new e.Color4(0,0,0,0),this._colorDiff=new e.Color4(0,0,0,0),this._scaledDirection=e.Vector3.Zero(),this._scaledGravity=e.Vector3.Zero(),this._currentRenderId=-1,this._started=!1,this._stopped=!1,this._actualFrame=0,this._vertexBufferSize=11,this.recycleParticle=function(e){var t=l._particles.pop();t!==e&&t.copyTo(e),l._stockParticles.push(t)},this._createParticle=function(){var t;return 0!==l._stockParticles.length?(t=l._stockParticles.pop(),t.age=0,t.cellIndex=l.startSpriteCellID):t=new e.Particle(l),t},this._emitFromParticle=function(e){if(l.subEmitters&&0!==l.subEmitters.length){var t=Math.floor(Math.random()*l.subEmitters.length),i=l.subEmitters[t].clone(l.name+"_sub",e.position.clone());i._rootParticleSystem=l,l.activeSubSystems.push(i),i.start()}},this._appendParticleVertexes=null,this.id=i,this.name=i,this._capacity=r,this._epsilon=a,this._isAnimationSheetEnabled=s,s&&(this._vertexBufferSize=12),this._scene=n||e.Engine.LastCreatedScene,this._customEffect=o,n.particleSystems.push(this),this._createIndexBuffer(),this._vertexData=new Float32Array(r*this._vertexBufferSize*4),this._vertexBuffer=new e.Buffer(n.getEngine(),this._vertexData,!0,this._vertexBufferSize);var h=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.PositionKind,0,3),c=this._vertexBuffer.createVertexBuffer(e.VertexBuffer.ColorKind,3,4),u=this._vertexBuffer.createVertexBuffer("options",7,4);if(this._isAnimationSheetEnabled){var f=this._vertexBuffer.createVertexBuffer("cellIndex",11,1);this._vertexBuffers.cellIndex=f}this._vertexBuffers[e.VertexBuffer.PositionKind]=h,this._vertexBuffers[e.VertexBuffer.ColorKind]=c,this._vertexBuffers.options=u,this.particleEmitterType=new e.BoxParticleEmitter,this.updateFunction=function(e){for(var t=0;t<e.length;t++){var i=e[t];i.age+=l._scaledUpdateSpeed,i.age>=i.lifeTime?(l._emitFromParticle(i),l.recycleParticle(i),t--):(i.colorStep.scaleToRef(l._scaledUpdateSpeed,l._scaledColorStep),i.color.addInPlace(l._scaledColorStep),i.color.a<0&&(i.color.a=0),i.angle+=i.angularSpeed*l._scaledUpdateSpeed,i.direction.scaleToRef(l._scaledUpdateSpeed,l._scaledDirection),i.position.addInPlace(l._scaledDirection),l.gravity.scaleToRef(l._scaledUpdateSpeed,l._scaledGravity),i.direction.addInPlace(l._scaledGravity),l._isAnimationSheetEnabled&&i.updateCellIndex(l._scaledUpdateSpeed))}}}return Object.defineProperty(t.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:e.Vector3.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:e.Vector3.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:e.Vector3.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:e.Vector3.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"onDispose",{set:function(e){this._onDisposeObserver&&this.onDisposeObservable.remove(this._onDisposeObserver),this._onDisposeObserver=this.onDisposeObservable.add(e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"isAnimationSheetEnabled",{get:function(){return this._isAnimationSheetEnabled},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"particles",{get:function(){return this._particles},enumerable:!0,configurable:!0}),t.prototype.getClassName=function(){return"ParticleSystem"},t.prototype._createIndexBuffer=function(){for(var e=[],t=0,i=0;i<this._capacity;i++)e.push(t),e.push(t+1),e.push(t+2),e.push(t),e.push(t+2),e.push(t+3),t+=4;this._indexBuffer=this._scene.getEngine().createIndexBuffer(e)},t.prototype.getCapacity=function(){return this._capacity},t.prototype.isAlive=function(){return this._alive},t.prototype.isStarted=function(){return this._started},t.prototype.start=function(){this._started=!0,this._stopped=!1,this._actualFrame=0,this.subEmitters&&0!=this.subEmitters.length&&(this.activeSubSystems=new Array)},t.prototype.stop=function(e){void 0===e&&(e=!0),this._stopped=!0,e&&this._stopSubEmitters()},t.prototype.reset=function(){this._stockParticles=[],this._particles=[]},t.prototype._appendParticleVertex=function(e,t,i,r){var n=e*this._vertexBufferSize;this._vertexData[n]=t.position.x,this._vertexData[n+1]=t.position.y,this._vertexData[n+2]=t.position.z,this._vertexData[n+3]=t.color.r,this._vertexData[n+4]=t.color.g,this._vertexData[n+5]=t.color.b,this._vertexData[n+6]=t.color.a,this._vertexData[n+7]=t.angle,this._vertexData[n+8]=t.size,this._vertexData[n+9]=i,this._vertexData[n+10]=r},t.prototype._appendParticleVertexWithAnimation=function(e,t,i,r){0===i?i=this._epsilon:1===i&&(i=1-this._epsilon),0===r?r=this._epsilon:1===r&&(r=1-this._epsilon);var n=e*this._vertexBufferSize;this._vertexData[n]=t.position.x,this._vertexData[n+1]=t.position.y,this._vertexData[n+2]=t.position.z,this._vertexData[n+3]=t.color.r,this._vertexData[n+4]=t.color.g,this._vertexData[n+5]=t.color.b,this._vertexData[n+6]=t.color.a,this._vertexData[n+7]=t.angle,this._vertexData[n+8]=t.size,this._vertexData[n+9]=i,this._vertexData[n+10]=r,this._vertexData[n+11]=t.cellIndex},t.prototype._stopSubEmitters=function(){this.activeSubSystems&&(this.activeSubSystems.forEach((function(e){e.stop(!0)})),this.activeSubSystems=new Array)},t.prototype._removeFromRoot=function(){if(this._rootParticleSystem){var e=this._rootParticleSystem.activeSubSystems.indexOf(this);-1!==e&&this._rootParticleSystem.activeSubSystems.splice(e,1)}},t.prototype._update=function(t){this._alive=this._particles.length>0,this.updateFunction(this._particles);var i;if(this.emitter.position){i=this.emitter.getWorldMatrix()}else{var r=this.emitter;i=e.Matrix.Translation(r.x,r.y,r.z)}for(var n,o=0;o<t&&this._particles.length!==this._capacity;o++){n=this._createParticle(),this._particles.push(n);var s=e.Scalar.RandomRange(this.minEmitPower,this.maxEmitPower);this.startPositionFunction?this.startPositionFunction(i,n.position,n):this.particleEmitterType.startPositionFunction(i,n.position,n),this.startDirectionFunction?this.startDirectionFunction(s,i,n.direction,n):this.particleEmitterType.startDirectionFunction(s,i,n.direction,n),n.lifeTime=e.Scalar.RandomRange(this.minLifeTime,this.maxLifeTime),n.size=e.Scalar.RandomRange(this.minSize,this.maxSize),n.angularSpeed=e.Scalar.RandomRange(this.minAngularSpeed,this.maxAngularSpeed);var a=e.Scalar.RandomRange(0,1);e.Color4.LerpToRef(this.color1,this.color2,a,n.color),this.colorDead.subtractToRef(n.color,this._colorDiff),this._colorDiff.scaleToRef(1/n.lifeTime,n.colorStep)}},t.prototype._getEffect=function(){if(this._customEffect)return this._customEffect;var t=[]
;this._scene.clipPlane&&t.push("#define CLIPPLANE"),this._isAnimationSheetEnabled&&t.push("#define ANIMATESHEET");var i=t.join("\n");if(this._cachedDefines!==i){this._cachedDefines=i;var r,n;this._isAnimationSheetEnabled?(r=[e.VertexBuffer.PositionKind,e.VertexBuffer.ColorKind,"options","cellIndex"],n=["invView","view","projection","particlesInfos","vClipPlane","textureMask"]):(r=[e.VertexBuffer.PositionKind,e.VertexBuffer.ColorKind,"options"],n=["invView","view","projection","vClipPlane","textureMask"]),this._effect=this._scene.getEngine().createEffect("particles",r,n,["diffuseSampler"],i)}return this._effect},t.prototype.animate=function(){if(this._started){var e=this._getEffect();if(this.emitter&&e.isReady()&&this.particleTexture&&this.particleTexture.isReady()&&this._currentRenderId!==this._scene.getRenderId()){this._currentRenderId=this._scene.getRenderId(),this._scaledUpdateSpeed=this.updateSpeed*this._scene.getAnimationRatio();var t;this.manualEmitCount>-1?(t=this.manualEmitCount,this._newPartsExcess=0,this.manualEmitCount=0):(t=this.emitRate*this._scaledUpdateSpeed>>0,this._newPartsExcess+=this.emitRate*this._scaledUpdateSpeed-t),this._newPartsExcess>1&&(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))),this._isAnimationSheetEnabled?this._appendParticleVertexes=this._appenedParticleVertexesWithSheet:this._appendParticleVertexes=this._appenedParticleVertexesNoSheet;for(var i=0,r=0;r<this._particles.length;r++){var n=this._particles[r];this._appendParticleVertexes(i,n),i+=4}this._vertexBuffer&&this._vertexBuffer.update(this._vertexData),0===this.manualEmitCount&&this.disposeOnStop&&this.stop()}}},t.prototype._appenedParticleVertexesWithSheet=function(e,t){this._appendParticleVertexWithAnimation(e++,t,0,0),this._appendParticleVertexWithAnimation(e++,t,1,0),this._appendParticleVertexWithAnimation(e++,t,1,1),this._appendParticleVertexWithAnimation(e++,t,0,1)},t.prototype._appenedParticleVertexesNoSheet=function(e,t){this._appendParticleVertex(e++,t,0,0),this._appendParticleVertex(e++,t,1,0),this._appendParticleVertex(e++,t,1,1),this._appendParticleVertex(e++,t,0,1)},t.prototype.rebuild=function(){this._createIndexBuffer(),this._vertexBuffer&&this._vertexBuffer._rebuild()},t.prototype.isReady=function(){var e=this._getEffect();return!!(this.emitter&&e.isReady()&&this.particleTexture&&this.particleTexture.isReady())},t.prototype.render=function(){var i=this._getEffect();if(!this.isReady()||!this._particles.length)return 0;var r=this._scene.getEngine();r.enableEffect(i),r.setState(!1);var n=this._scene.getViewMatrix();if(i.setTexture("diffuseSampler",this.particleTexture),i.setMatrix("view",n),i.setMatrix("projection",this._scene.getProjectionMatrix()),this._isAnimationSheetEnabled&&this.particleTexture){var o=this.particleTexture.getBaseSize();i.setFloat3("particlesInfos",this.spriteCellWidth/o.width,this.spriteCellHeight/o.height,o.width/this.spriteCellWidth)}if(i.setFloat4("textureMask",this.textureMask.r,this.textureMask.g,this.textureMask.b,this.textureMask.a),this._scene.clipPlane){var s=this._scene.clipPlane,a=n.clone();a.invert(),i.setMatrix("invView",a),i.setFloat4("vClipPlane",s.normal.x,s.normal.y,s.normal.z,s.d)}return r.bindBuffers(this._vertexBuffers,this._indexBuffer,i),this.blendMode===t.BLENDMODE_ONEONE?r.setAlphaMode(e.Engine.ALPHA_ONEONE):r.setAlphaMode(e.Engine.ALPHA_COMBINE),this.forceDepthWrite&&r.setDepthWrite(!0),r.drawElementsType(e.Material.TriangleFillMode,0,6*this._particles.length),r.setAlphaMode(e.Engine.ALPHA_DISABLE),this._particles.length},t.prototype.dispose=function(e){void 0===e&&(e=!0),this._vertexBuffer&&(this._vertexBuffer.dispose(),this._vertexBuffer=null),this._indexBuffer&&(this._scene.getEngine()._releaseBuffer(this._indexBuffer),this._indexBuffer=null),e&&this.particleTexture&&(this.particleTexture.dispose(),this.particleTexture=null),this._removeFromRoot();var t=this._scene.particleSystems.indexOf(this);t>-1&&this._scene.particleSystems.splice(t,1),this.onDisposeObservable.notifyObservers(this),this.onDisposeObservable.clear()},t.prototype.createSphereEmitter=function(t){void 0===t&&(t=1);var i=new e.SphereParticleEmitter(t);return this.particleEmitterType=i,i},t.prototype.createDirectedSphereEmitter=function(t,i,r){void 0===t&&(t=1),void 0===i&&(i=new e.Vector3(0,1,0)),void 0===r&&(r=new e.Vector3(0,1,0));var n=new e.SphereDirectedParticleEmitter(t,i,r);return this.particleEmitterType=n,n},t.prototype.createConeEmitter=function(t,i){void 0===t&&(t=1),void 0===i&&(i=Math.PI/4);var r=new e.ConeParticleEmitter(t,i);return this.particleEmitterType=r,r},t.prototype.createBoxEmitter=function(t,i,r,n){var o=new e.BoxParticleEmitter;return this.particleEmitterType=o,this.direction1=t,this.direction2=i,this.minEmitBox=r,this.maxEmitBox=n,o},t.prototype.clone=function(i,r){var n=null,o=null;if(null!=this.customShader){o=this.customShader;var s=o.shaderOptions.defines.length>0?o.shaderOptions.defines.join("\n"):"";n=this._scene.getEngine().createEffectForParticles(o.shaderPath.fragmentElement,o.shaderOptions.uniforms,o.shaderOptions.samplers,s)}var a=new t(i,this._capacity,this._scene,n);return a.customShader=o,e.Tools.DeepCopy(this,a,["particles","customShader"]),void 0===r&&(r=this.emitter),a.emitter=r,this.particleTexture&&(a.particleTexture=new e.Texture(this.particleTexture.url,this._scene)),this.preventAutoStart||a.start(),a},t.prototype.serialize=function(){var t={};if(t.name=this.name,t.id=this.id,this.emitter.position){var i=this.emitter;t.emitterId=i.id}else{var r=this.emitter;t.emitter=r.asArray()}return t.capacity=this.getCapacity(),this.particleTexture&&(t.textureName=this.particleTexture.name),e.Animation.AppendSerializedAnimations(this,t),t.minAngularSpeed=this.minAngularSpeed,t.maxAngularSpeed=this.maxAngularSpeed,t.minSize=this.minSize,t.maxSize=this.maxSize,t.minEmitPower=this.minEmitPower,t.maxEmitPower=this.maxEmitPower,t.minLifeTime=this.minLifeTime,t.maxLifeTime=this.maxLifeTime,t.emitRate=this.emitRate,t.minEmitBox=this.minEmitBox.asArray(),t.maxEmitBox=this.maxEmitBox.asArray(),t.gravity=this.gravity.asArray(),t.direction1=this.direction1.asArray(),t.direction2=this.direction2.asArray(),t.color1=this.color1.asArray(),t.color2=this.color2.asArray(),t.colorDead=this.colorDead.asArray(),t.updateSpeed=this.updateSpeed,t.targetStopDuration=this.targetStopDuration,t.textureMask=this.textureMask.asArray(),t.blendMode=this.blendMode,t.customShader=this.customShader,t.preventAutoStart=this.preventAutoStart,t.startSpriteCellID=this.startSpriteCellID,t.endSpriteCellID=this.endSpriteCellID,t.spriteCellLoop=this.spriteCellLoop,t.spriteCellChangeSpeed=this.spriteCellChangeSpeed,t.spriteCellWidth=this.spriteCellWidth,t.spriteCellHeight=this.spriteCellHeight,t.isAnimationSheetEnabled=this._isAnimationSheetEnabled,this.particleEmitterType&&(t.particleEmitterType=this.particleEmitterType.serialize()),t},t.Parse=function(i,r,n){var o=i.name,s=null,a=null;if(i.customShader){a=i.customShader;var l=a.shaderOptions.defines.length>0?a.shaderOptions.defines.join("\n"):"";s=r.getEngine().createEffectForParticles(a.shaderPath.fragmentElement,a.shaderOptions.uniforms,a.shaderOptions.samplers,l)}var h=new t(o,i.capacity,r,s,i.isAnimationSheetEnabled);if(h.customShader=a,i.id&&(h.id=i.id),i.preventAutoStart&&(h.preventAutoStart=i.preventAutoStart),i.textureName&&(h.particleTexture=new e.Texture(n+i.textureName,r),h.particleTexture.name=i.textureName),i.emitterId?h.emitter=r.getLastMeshByID(i.emitterId):h.emitter=e.Vector3.FromArray(i.emitter),i.animations)for(var c=0;c<i.animations.length;c++){var u=i.animations[c];h.animations.push(e.Animation.Parse(u))}return i.autoAnimate&&r.beginAnimation(h,i.autoAnimateFrom,i.autoAnimateTo,i.autoAnimateLoop,i.autoAnimateSpeed||1),h.minAngularSpeed=i.minAngularSpeed,h.maxAngularSpeed=i.maxAngularSpeed,h.minSize=i.minSize,h.maxSize=i.maxSize,h.minLifeTime=i.minLifeTime,h.maxLifeTime=i.maxLifeTime,h.minEmitPower=i.minEmitPower,h.maxEmitPower=i.maxEmitPower,h.emitRate=i.emitRate,h.minEmitBox=e.Vector3.FromArray(i.minEmitBox),h.maxEmitBox=e.Vector3.FromArray(i.maxEmitBox),h.gravity=e.Vector3.FromArray(i.gravity),h.direction1=e.Vector3.FromArray(i.direction1),h.direction2=e.Vector3.FromArray(i.direction2),h.color1=e.Color4.FromArray(i.color1),h.color2=e.Color4.FromArray(i.color2),h.colorDead=e.Color4.FromArray(i.colorDead),h.updateSpeed=i.updateSpeed,h.targetStopDuration=i.targetStopDuration,h.textureMask=e.Color4.FromArray(i.textureMask),h.blendMode=i.blendMode,h.startSpriteCellID=i.startSpriteCellID,h.endSpriteCellID=i.endSpriteCellID,h.spriteCellLoop=i.spriteCellLoop,h.spriteCellChangeSpeed=i.spriteCellChangeSpeed,h.spriteCellWidth=i.spriteCellWidth,h.spriteCellHeight=i.spriteCellHeight,h.preventAutoStart||h.start(),h},t.BLENDMODE_ONEONE=0,t.BLENDMODE_STANDARD=1,t})();e.ParticleSystem=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(){this.direction1=new e.Vector3(0,1,0),this.direction2=new e.Vector3(0,1,0),this.minEmitBox=new e.Vector3(-.5,-.5,-.5),this.maxEmitBox=new e.Vector3(.5,.5,.5)}return t.prototype.startDirectionFunction=function(t,i,r,n){var o=e.Scalar.RandomRange(this.direction1.x,this.direction2.x),s=e.Scalar.RandomRange(this.direction1.y,this.direction2.y),a=e.Scalar.RandomRange(this.direction1.z,this.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(o*t,s*t,a*t,i,r)},t.prototype.startPositionFunction=function(t,i,r){var n=e.Scalar.RandomRange(this.minEmitBox.x,this.maxEmitBox.x),o=e.Scalar.RandomRange(this.minEmitBox.y,this.maxEmitBox.y),s=e.Scalar.RandomRange(this.minEmitBox.z,this.maxEmitBox.z);e.Vector3.TransformCoordinatesFromFloatsToRef(n,o,s,t,i)},t.prototype.clone=function(){var i=new t;return e.Tools.DeepCopy(this,i),i},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"BoxEmitter"},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){this.direction1.copyFrom(e.direction1),this.direction2.copyFrom(e.direction2),this.minEmitBox.copyFrom(e.minEmitBox),this.maxEmitBox.copyFrom(e.maxEmitBox)},t})();e.BoxParticleEmitter=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(e,t,i){void 0===e&&(e=1),void 0===t&&(t=Math.PI),void 0===i&&(i=0),this.angle=t,this.directionRandomizer=i,this.radius=e}return Object.defineProperty(t.prototype,"radius",{get:function(){return this._radius},set:function(e){this._radius=e,0!==this.angle?this._height=e/Math.tan(this.angle/2):this._height=1},enumerable:!0,configurable:!0}),t.prototype.startDirectionFunction=function(t,i,r,n){if(0===this.angle)e.Vector3.TransformNormalFromFloatsToRef(0,t,0,i,r);else{var o=n.position.subtract(i.getTranslation()).normalize(),s=e.Scalar.RandomRange(0,this.directionRandomizer),a=e.Scalar.RandomRange(0,this.directionRandomizer),l=e.Scalar.RandomRange(0,this.directionRandomizer);o.x+=s,o.y+=a,o.z+=l,o.normalize(),e.Vector3.TransformNormalFromFloatsToRef(o.x*t,o.y*t,o.z*t,i,r)}},t.prototype.startPositionFunction=function(t,i,r){var n=e.Scalar.RandomRange(0,2*Math.PI),o=e.Scalar.RandomRange(0,1);o=1-o*o;var s=e.Scalar.RandomRange(0,this._radius);s*=o;var a=s*Math.sin(n),l=s*Math.cos(n),h=o*this._height;e.Vector3.TransformCoordinatesFromFloatsToRef(a,h,l,t,i)},t.prototype.clone=function(){var i=new t(this.radius,this.angle,this.directionRandomizer);return e.Tools.DeepCopy(this,i),i},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setFloat("angle",this.angle),e.setFloat("height",this._height),e.setFloat("directionRandomizer",this.directionRandomizer)},t.prototype.getEffectDefines=function(){return"#define CONEEMITTER"},t.prototype.getClassName=function(){return"ConeEmitter"},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})();e.ConeParticleEmitter=t})(r||(r={}));var r;!(function(e){var t=(function(){function t(e,t){void 0===e&&(e=1),void 0===t&&(t=0),this.radius=e,this.directionRandomizer=t}return t.prototype.startDirectionFunction=function(t,i,r,n){var o=n.position.subtract(i.getTranslation()).normalize(),s=e.Scalar.RandomRange(0,this.directionRandomizer),a=e.Scalar.RandomRange(0,this.directionRandomizer),l=e.Scalar.RandomRange(0,this.directionRandomizer);o.x+=s,o.y+=a,o.z+=l,o.normalize(),e.Vector3.TransformNormalFromFloatsToRef(o.x*t,o.y*t,o.z*t,i,r)},t.prototype.startPositionFunction=function(t,i,r){var n=e.Scalar.RandomRange(0,2*Math.PI),o=e.Scalar.RandomRange(0,Math.PI),s=e.Scalar.RandomRange(0,this.radius),a=s*Math.cos(n)*Math.sin(o),l=s*Math.cos(o),h=s*Math.sin(n)*Math.sin(o);e.Vector3.TransformCoordinatesFromFloatsToRef(a,l,h,t,i)},t.prototype.clone=function(){var i=new t(this.radius,this.directionRandomizer);return e.Tools.DeepCopy(this,i),i},t.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),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.directionRandomizer=this.directionRandomizer,e},t.prototype.parse=function(e){this.radius=e.radius,this.directionRandomizer=e.directionRandomizer},t})();e.SphereParticleEmitter=t;var i=(function(t){function i(i,r,n){void 0===i&&(i=1),void 0===r&&(r=new e.Vector3(0,1,0)),void 0===n&&(n=new e.Vector3(0,1,0));var o=t.call(this,i)||this;return o.direction1=r,o.direction2=n,o}return o(i,t),i.prototype.startDirectionFunction=function(t,i,r,n){var o=e.Scalar.RandomRange(this.direction1.x,this.direction2.x),s=e.Scalar.RandomRange(this.direction1.y,this.direction2.y),a=e.Scalar.RandomRange(this.direction1.z,this.direction2.z);e.Vector3.TransformNormalFromFloatsToRef(o*t,s*t,a*t,i,r)},i.prototype.clone=function(){var t=new i(this.radius,this.direction1,this.direction2);return e.Tools.DeepCopy(this,t),t},i.prototype.applyToShader=function(e){e.setFloat("radius",this.radius),e.setVector3("direction1",this.direction1),e.setVector3("direction2",this.direction2)},i.prototype.getEffectDefines=function(){return"#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER"},i.prototype.getClassName=function(){return"SphereDirectedParticleEmitter"},i.prototype.serialize=function(){var e=t.prototype.serialize.call(this);return e.direction1=this.direction1.asArray(),e.direction2=this.direction2.asArray(),e},i.prototype.parse=function(e){t.prototype.parse.call(this,e),this.direction1.copyFrom(e.direction1),this.direction2.copyFrom(e.direction2)},i})(t);e.SphereDirectedParticleEmitter=i})(r||(r={}));var r,s=this&&this.__assign||Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++){t=arguments[i];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e};!(function(e){var t=(function(){function t(t,i,r){this.emitter=null,this.renderingGroupId=0,this.layerMask=268435455,this._targetIndex=0,this._currentRenderId=-1,this._started=!1,this._stopped=!1,this._timeDelta=0,this._attributesStrideSize=14,this._actualFrame=0,this.animations=[],this.onDisposeObservable=new e.Observable,this.updateSpeed=.01,this.targetStopDuration=0,this.blendMode=e.ParticleSystem.BLENDMODE_ONEONE,this.minLifeTime=1,this.maxLifeTime=1,this.minSize=1,this.maxSize=1,this.color1=new e.Color4(1,1,1,1),this.color2=new e.Color4(1,1,1,1),this.colorDead=new e.Color4(0,0,0,0),this.emitRate=100,this.gravity=e.Vector3.Zero(),this.minEmitPower=1,this.maxEmitPower=1,this.forceDepthWrite=!1,this.id=t,this.name=t,this._scene=r||e.Engine.LastCreatedScene,this._engine=this._scene.getEngine();var n=s({capacity:5e4,randomTextureSize:this._engine.getCaps().maxTextureSize},i);this._capacity=n.capacity,this._activeCount=n.capacity,this._currentActiveCount=0,this._scene.particleSystems.push(this),this._updateEffectOptions={attributes:["position","age","life","seed","size","color","direction"],uniformsNames:["currentCount","timeDelta","generalRandoms","emitterWM","lifeTime","color1","color2","sizeRange","gravity","emitPower","direction1","direction2","minEmitBox","maxEmitBox","radius","directionRandomizer","height","angle","stopFactor"],uniformBuffersNames:[],samplers:["randomSampler"],defines:"",fallbacks:null,onCompiled:null,onError:null,indexParameters:null,maxSimultaneousLights:0,transformFeedbackVaryings:["outPosition","outAge","outLife","outSeed","outSize","outColor","outDirection"]};for(var o=Math.min(this._engine.getCaps().maxTextureSize,n.randomTextureSize),a=[],l=0;l<o;++l)a.push(Math.random()),a.push(Math.random()),a.push(Math.random()),a.push(Math.random());this._randomTexture=new e.RawTexture(new Float32Array(a),o,1,e.Engine.TEXTUREFORMAT_RGBA32F,this._scene,!1,!1,e.Texture.NEAREST_SAMPLINGMODE,e.Engine.TEXTURETYPE_FLOAT),this._randomTexture.wrapU=e.Texture.WRAP_ADDRESSMODE,this._randomTexture.wrapV=e.Texture.WRAP_ADDRESSMODE,this._randomTextureSize=o,this.particleEmitterType=new e.BoxParticleEmitter}return Object.defineProperty(t,"IsSupported",{get:function(){return!!e.Engine.LastCreatedEngine&&e.Engine.LastCreatedEngine.webGLVersion>1},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"direction1",{get:function(){return this.particleEmitterType.direction1?this.particleEmitterType.direction1:e.Vector3.Zero()},set:function(e){this.particleEmitterType.direction1&&(this.particleEmitterType.direction1=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"direction2",{get:function(){return this.particleEmitterType.direction2?this.particleEmitterType.direction2:e.Vector3.Zero()},set:function(e){this.particleEmitterType.direction2&&(this.particleEmitterType.direction2=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"minEmitBox",{get:function(){return this.particleEmitterType.minEmitBox?this.particleEmitterType.minEmitBox:e.Vector3.Zero()},set:function(e){this.particleEmitterType.minEmitBox&&(this.particleEmitterType.minEmitBox=e)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"maxEmitBox",{get:function(){return this.particleEmitterType.maxEmitBox?this.particleEmitterType.maxEmitBox:e.Vector3.Zero()},set:function(e){this.particleEmitterType.maxEmitBox&&(this.particleEmitterType.maxEmitBox=e)},enumerable:!0,configurable:!0}),t.prototype.getCapacity=function(){return this._capacity},Object.defineProperty(t.prototype,"activeParticleCount",{get:function(){return this._activeCount},set:function(e){this._activeCount=Math.min(e,this._capacity)},enumerable:!0,configurable:!0}),t.prototype.isReady=function(){return this._updateEffect?!!(this.emitter&&this._updateEffect.isReady()&&this._renderEffect.isReady()&&this.particleTexture&&this.particleTexture.isReady()):(this._recreateUpdateEffect(),this._recreateRenderEffect(),!1)},t.prototype.isStarted=function(){return this._started},t.prototype.start=function(){this._started=!0,this._stopped=!1},t.prototype.stop=function(){this._stopped=!0},t.prototype.reset=function(){this._releaseBuffers(),this._releaseVAOs(),this._currentActiveCount=0,this._targetIndex=0},t.prototype.getClassName=function(){return"GPUParticleSystem"},t.prototype._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,1),t.size=e.createVertexBuffer("size",6,1),t.color=e.createVertexBuffer("color",7,4),t.direction=e.createVertexBuffer("direction",11,3);var i=this._engine.recordVertexArrayObject(t,null,this._updateEffect);return this._engine.bindArrayBuffer(null),i},t.prototype._createRenderVAO=function(e,t){var i={};i.position=e.createVertexBuffer("position",0,3,this._attributesStrideSize,!0),i.age=e.createVertexBuffer("age",3,1,this._attributesStrideSize,!0),i.life=e.createVertexBuffer("life",4,1,this._attributesStrideSize,!0),i.size=e.createVertexBuffer("size",6,1,this._attributesStrideSize,!0),i.color=e.createVertexBuffer("color",7,4,this._attributesStrideSize,!0),i.offset=t.createVertexBuffer("offset",0,2),i.uv=t.createVertexBuffer("uv",2,2);var r=this._engine.recordVertexArrayObject(i,null,this._renderEffect);return this._engine.bindArrayBuffer(null),r},t.prototype._initialize=function(t){if(void 0===t&&(t=!1),!this._buffer0||t){for(var i=this._scene.getEngine(),r=new Array,n=0;n<this._capacity;n++)r.push(0),r.push(0),r.push(0),r.push(0),r.push(0),r.push(Math.random()),r.push(0),r.push(0),r.push(0),r.push(0),r.push(0),r.push(0),r.push(0),r.push(0);var o=new Float32Array([.5,.5,1,1,-.5,.5,0,1,-.5,-.5,0,0,.5,-.5,1,0]);this._buffer0=new e.Buffer(i,r,!1,this._attributesStrideSize),this._buffer1=new e.Buffer(i,r,!1,this._attributesStrideSize),this._spriteBuffer=new e.Buffer(i,o,!1,4),this._updateVAO=[],this._updateVAO.push(this._createUpdateVAO(this._buffer0)),this._updateVAO.push(this._createUpdateVAO(this._buffer1)),this._renderVAO=[],this._renderVAO.push(this._createRenderVAO(this._buffer1,this._spriteBuffer)),this._renderVAO.push(this._createRenderVAO(this._buffer0,this._spriteBuffer)),this._sourceBuffer=this._buffer0,this._targetBuffer=this._buffer1}},t.prototype._recreateUpdateEffect=function(){var t=this.particleEmitterType?this.particleEmitterType.getEffectDefines():"";this._updateEffect&&this._updateEffectOptions.defines===t||(this._updateEffectOptions.defines=t,this._updateEffect=new e.Effect("gpuUpdateParticles",this._updateEffectOptions,this._scene.getEngine()))},t.prototype._recreateRenderEffect=function(){var t="";this._scene.clipPlane&&(t="\n#define CLIPPLANE"),this._renderEffect&&this._renderEffect.defines===t||(this._renderEffect=new e.Effect("gpuRenderParticles",["position","age","life","size","color","offset","uv"],["view","projection","colorDead","invView","vClipPlane"],["textureSampler"],this._scene.getEngine(),t))},t.prototype.animate=function(){this._timeDelta=this.updateSpeed*this._scene.getAnimationRatio(),this._actualFrame+=this._timeDelta,this._stopped||this.targetStopDuration&&this._actualFrame>=this.targetStopDuration&&this.stop()},t.prototype.render=function(){if(!this._started)return 0;if(this._recreateUpdateEffect(),this._recreateRenderEffect(),!this.isReady())return 0;if(this._currentRenderId===this._scene.getRenderId())return 0;this._currentRenderId=this._scene.getRenderId(),this._initialize(),this._currentActiveCount=Math.min(this._activeCount,this._currentActiveCount+this.emitRate*this._timeDelta|0),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.setFloat3("generalRandoms",Math.random(),Math.random(),Math.random()),this._updateEffect.setTexture("randomSampler",this._randomTexture),this._updateEffect.setFloat2("lifeTime",this.minLifeTime,this.maxLifeTime),this._updateEffect.setFloat2("emitPower",this.minEmitPower,this.maxEmitPower),this._updateEffect.setDirectColor4("color1",this.color1),this._updateEffect.setDirectColor4("color2",this.color2),this._updateEffect.setFloat2("sizeRange",this.minSize,this.maxSize),this._updateEffect.setVector3("gravity",this.gravity),this.particleEmitterType&&this.particleEmitterType.applyToShader(this._updateEffect);var t;if(this.emitter.position){t=this.emitter.getWorldMatrix()}else{var i=this.emitter;t=e.Matrix.Translation(i.x,i.y,i.z)}this._updateEffect.setMatrix("emitterWM",t),this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex],null),this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer()),this._engine.setRasterizerState(!1),this._engine.beginTransformFeedback(),this._engine.drawArraysType(e.Material.PointListDrawMode,0,this._currentActiveCount),this._engine.endTransformFeedback(),this._engine.setRasterizerState(!0),this._engine.bindTransformFeedbackBuffer(null),this._engine.enableEffect(this._renderEffect);var r=this._scene.getViewMatrix();if(this._renderEffect.setMatrix("view",r),this._renderEffect.setMatrix("projection",this._scene.getProjectionMatrix()),this._renderEffect.setTexture("textureSampler",this.particleTexture),this._renderEffect.setDirectColor4("colorDead",this.colorDead),this._scene.clipPlane){var n=this._scene.clipPlane,o=r.clone();o.invert(),this._renderEffect.setMatrix("invView",o),this._renderEffect.setFloat4("vClipPlane",n.normal.x,n.normal.y,n.normal.z,n.d)}this.blendMode===e.ParticleSystem.BLENDMODE_ONEONE?this._engine.setAlphaMode(e.Engine.ALPHA_ONEONE):this._engine.setAlphaMode(e.Engine.ALPHA_COMBINE),this.forceDepthWrite&&this._engine.setDepthWrite(!0),this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex],null),this._engine.drawArraysType(e.Material.TriangleFanDrawMode,0,4,this._currentActiveCount),this._engine.setAlphaMode(e.Engine.ALPHA_DISABLE),2===++this._targetIndex&&(this._targetIndex=0);var s=this._sourceBuffer;return this._sourceBuffer=this._targetBuffer,this._targetBuffer=s,this._currentActiveCount},t.prototype.rebuild=function(){this._initialize(!0)
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment